From ff416e7da86b96ad4de20a3b1df4b8ef7897e6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vinko=20Ka=C5=A1ljevi=C4=87?= Date: Sat, 24 Oct 2020 19:57:28 +0200 Subject: [PATCH] Move from Makefile to Meson build system --- .gitignore | 1 + Makefile | 37 -------------------- config.def.h => config.h | 0 config.mk | 5 --- meson.build | 75 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 42 deletions(-) delete mode 100644 Makefile rename config.def.h => config.h (100%) delete mode 100644 config.mk create mode 100644 meson.build diff --git a/.gitignore b/.gitignore index 5c28541..f9111fa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ dwl +build *.o *-protocol.c *-protocol.h diff --git a/Makefile b/Makefile deleted file mode 100644 index 56ab751..0000000 --- a/Makefile +++ /dev/null @@ -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 diff --git a/config.def.h b/config.h similarity index 100% rename from config.def.h rename to config.h diff --git a/config.mk b/config.mk deleted file mode 100644 index a101f23..0000000 --- a/config.mk +++ /dev/null @@ -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 diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..1299584 --- /dev/null +++ b/meson.build @@ -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 +) +