Move from Makefile to Meson build system

This commit is contained in:
Vinko Kašljević 2020-10-24 19:57:28 +02:00
parent 44ef698d6e
commit ff416e7da8
5 changed files with 76 additions and 42 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
dwl
build
*.o
*-protocol.c
*-protocol.h

View File

@ -1,37 +0,0 @@
include config.mk
CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 -Werror=declaration-after-statement
WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
PKGS = wlroots wayland-server xcb xkbcommon
CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p)))
LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p)))
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
xdg-shell-protocol.c:
$(WAYLAND_SCANNER) private-code \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
xdg-shell-protocol.o: xdg-shell-protocol.h
config.h: | config.def.h
cp config.def.h $@
dwl.o: config.h xdg-shell-protocol.h
dwl: xdg-shell-protocol.o
clean:
rm -f dwl *.o xdg-shell-protocol.h xdg-shell-protocol.c
.DEFAULT_GOAL=dwl
.PHONY: clean

View File

@ -1,5 +0,0 @@
# Default compile flags (overridable by environment)
CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-error=unused-function
# Uncomment to build XWayland support
#CFLAGS += -DXWAYLAND

75
meson.build Normal file
View File

@ -0,0 +1,75 @@
project(
'dwl',
'c',
)
add_project_arguments(
[
'-DWLR_USE_UNSTABLE',
'-DXWAYLAND', # XWayland support
# C compiler options
'-g',
'-Wall',
'-Wextra',
'-Werror',
'-Wno-unused-parameter',
'-Wno-sign-compare',
'-Wno-error=unused-function',
'-Wno-unused-result',
'-Wno-missing-braces',
'-Wundef',
'-Wvla',
'-std=c99',
'-Werror=declaration-after-statement',
],
language: 'c',
)
### Generate xdg-shell-protocol files
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
# TODO(vkasljevic):
#
# WAYLAND_PROTOCOLS=$(shell pkg-config --variable=pkgdatadir wayland-protocols)
# WAYLAND_SCANNER=$(shell pkg-config --variable=wayland_scanner wayland-scanner)
#
# xdg-shell-protocol.h:
# $(WAYLAND_SCANNER) server-header \
# $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
# xdg-shell-protocol.c:
# $(WAYLAND_SCANNER) private-code \
# $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
#
xdg_shell_protocol_c = custom_target(
'xdg-shell-protocol.c',
output : 'xdg-shell-protocol.c',
command : ['wayland-scanner', 'private-code', '/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml', '@OUTPUT@'],
)
xdg_shell_protocol_h = custom_target(
'xdg-shell-protocol.h',
output : 'xdg-shell-protocol.h',
command : ['wayland-scanner', 'server-header', '/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml', '@OUTPUT@'],
)
xdg_shell_protocol = static_library('xdg-shell-protocol', [xdg_shell_protocol_h, xdg_shell_protocol_c])
### List all dependencies. They must be present on system before compiling.
# wayland-scanner
# wayland-protocols
dependencies = [
dependency('pixman-1'),
dependency('wlroots'),
dependency('wayland-server'),
dependency('xkbcommon'),
dependency('xcb')
]
executable(
'dwl',
'dwl.c',
dependencies : dependencies,
link_with : xdg_shell_protocol
)