From 7b42232ad10bdb5585a5df9222dd9c15a1a63f80 Mon Sep 17 00:00:00 2001 From: KawaiiAmber Date: Wed, 25 May 2022 16:04:19 -0600 Subject: convert makefile to be more portable --- Makefile | 92 +++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 50 insertions(+), 42 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0c2b78d..cab513c 100644 --- a/Makefile +++ b/Makefile @@ -1,73 +1,81 @@ -include config.mk - -CFLAGS += -I. -DWLR_USE_UNSTABLE -std=c99 -pedantic -DVERSION=\"$(VERSION)\" - -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 libinput -CFLAGS += $(foreach p,$(PKGS),$(shell pkg-config --cflags $(p))) -LDLIBS += $(foreach p,$(PKGS),$(shell pkg-config --libs $(p))) - -all: dwl +.POSIX: +.SUFFIXES: -clean: - rm -f dwl *.o *-protocol.h *-protocol.c +include config.mk -dist: clean - mkdir -p dwl-$(VERSION) - cp -R LICENSE* Makefile README.md generate-version.sh client.h\ - config.def.h config.mk protocols dwl.1 dwl.c util.c util.h\ - dwl-$(VERSION) - echo "echo $(VERSION)" > dwl-$(VERSION)/generate-version.sh - tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION) - rm -rf dwl-$(VERSION) +# flags for compiling +DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -DVERSION=\"$(VERSION)\" -install: dwl - install -Dm755 dwl $(DESTDIR)$(PREFIX)/bin/dwl - install -Dm644 dwl.1 $(DESTDIR)$(MANDIR)/man1/dwl.1 +# Wayland utils +WAYLAND_PROTOCOLS = `pkg-config --variable=pkgdatadir wayland-protocols` +WAYLAND_SCANNER = `pkg-config --variable=wayland_scanner wayland-scanner` -uninstall: - rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1 +# CFLAGS / LDFLAGS +PKGS = wlroots wayland-server xcb xkbcommon libinput +DWLCFLAGS = `pkg-config --cflags $(PKGS)` $(DWLCPPFLAGS) $(CFLAGS) $(XWAYLAND) +LDLIBS = `pkg-config --libs $(PKGS)` -.PHONY: all clean dist install uninstall +# build rules # 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. +all: dwl +dwl: dwl.o xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o idle-protocol.o util.o + $(CC) $(LDLIBS) -o $@ dwl.o xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o idle-protocol.o util.o +dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h +xdg-shell-protocol.o: xdg-shell-protocol.h xdg-shell-protocol.c +wlr-layer-shell-unstable-v1-protocol.o: wlr-layer-shell-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.c +idle-protocol.o: idle-protocol.h idle-protocol.c +util.o: util.c util.h + +# wayland scanner rules to generate .h / .c files 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 - wlr-layer-shell-unstable-v1-protocol.h: $(WAYLAND_SCANNER) server-header \ protocols/wlr-layer-shell-unstable-v1.xml $@ - wlr-layer-shell-unstable-v1-protocol.c: $(WAYLAND_SCANNER) private-code \ protocols/wlr-layer-shell-unstable-v1.xml $@ - -wlr-layer-shell-unstable-v1-protocol.o: wlr-layer-shell-unstable-v1-protocol.h - idle-protocol.h: $(WAYLAND_SCANNER) server-header \ protocols/idle.xml $@ - idle-protocol.c: $(WAYLAND_SCANNER) private-code \ protocols/idle.xml $@ -idle-protocol.o: idle-protocol.h - -config.h: | config.def.h +config.h: cp config.def.h $@ +clean: + rm -f dwl *.o *-protocol.h *-protocol.c + +# distribution archive +dist: clean + mkdir -p dwl-$(VERSION) + cp -R LICENSE* Makefile README.md generate-version.sh client.h\ + config.def.h config.mk protocols dwl.1 dwl.c util.c util.h\ + dwl-$(VERSION) + echo "echo $(VERSION)" > dwl-$(VERSION)/generate-version.sh + tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION) + rm -rf dwl-$(VERSION) + +# install rules -dwl.o: config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h util.h +install: dwl + mkdir -p $(DESTDIR)$(PREFIX)/bin + cp dwl $(DESTDIR)$(PREFIX)/bin + chmod 755 $(DESTDIR)$(PREFIX)/bin/dwl + mkdir -p $(DESTDIR)$(MANDIR)/man1 + cp dwl.1 $(DESTDIR)$(MANDIR)/man1 + chmod 644 $(DESTDIR)$(MANDIR)/man1/dwl.1 +uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1 -dwl: xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o idle-protocol.o util.o +.SUFFIXES: .c .o +.c.o: + $(CC) $(CPPFLAGS) $(DWLCFLAGS) -c $< -- cgit v1.2.3 From 14641560b0035402e699b0df0bea75f183ceb057 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Mon, 30 May 2022 16:18:31 -0500 Subject: include xcb only when building with xwayland support --- Makefile | 2 +- config.mk | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index cab513c..3371144 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ WAYLAND_PROTOCOLS = `pkg-config --variable=pkgdatadir wayland-protocols` WAYLAND_SCANNER = `pkg-config --variable=wayland_scanner wayland-scanner` # CFLAGS / LDFLAGS -PKGS = wlroots wayland-server xcb xkbcommon libinput +PKGS = wlroots wayland-server xkbcommon libinput $(XLIBS) DWLCFLAGS = `pkg-config --cflags $(PKGS)` $(DWLCPPFLAGS) $(CFLAGS) $(XWAYLAND) LDLIBS = `pkg-config --libs $(PKGS)` diff --git a/config.mk b/config.mk index 3a5e37f..ba24bb8 100644 --- a/config.mk +++ b/config.mk @@ -9,5 +9,7 @@ MANDIR = $(PREFIX)/share/man #CFLAGS = -pedantic -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement XWAYLAND = +XLIBS = # Uncomment to build XWayland support #XWAYLAND = -DXWAYLAND +#XLIBS = xcb -- cgit v1.2.3 From 50b6630f3d53b6635ce83565ccc4b900fdc15956 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Mon, 30 May 2022 16:23:14 -0500 Subject: do not generate *-protocol.{c,o} according with https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/62fbf3f4ba1b2993e29dfb46f077e5806f7aac1c they are unused and wlroots-based compositors don't need to do this --- Makefile | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3371144..a8c1c0f 100644 --- a/Makefile +++ b/Makefile @@ -21,38 +21,26 @@ LDLIBS = `pkg-config --libs $(PKGS)` # 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. all: dwl -dwl: dwl.o xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o idle-protocol.o util.o - $(CC) $(LDLIBS) -o $@ dwl.o xdg-shell-protocol.o wlr-layer-shell-unstable-v1-protocol.o idle-protocol.o util.o +dwl: dwl.o util.o + $(CC) $(LDLIBS) -o $@ dwl.o util.o dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h -xdg-shell-protocol.o: xdg-shell-protocol.h xdg-shell-protocol.c -wlr-layer-shell-unstable-v1-protocol.o: wlr-layer-shell-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.c -idle-protocol.o: idle-protocol.h idle-protocol.c util.o: util.c util.h # wayland scanner rules to generate .h / .c files 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 $@ wlr-layer-shell-unstable-v1-protocol.h: $(WAYLAND_SCANNER) server-header \ protocols/wlr-layer-shell-unstable-v1.xml $@ -wlr-layer-shell-unstable-v1-protocol.c: - $(WAYLAND_SCANNER) private-code \ - protocols/wlr-layer-shell-unstable-v1.xml $@ idle-protocol.h: $(WAYLAND_SCANNER) server-header \ protocols/idle.xml $@ -idle-protocol.c: - $(WAYLAND_SCANNER) private-code \ - protocols/idle.xml $@ config.h: cp config.def.h $@ clean: - rm -f dwl *.o *-protocol.h *-protocol.c + rm -f dwl *.o *-protocol.h # distribution archive dist: clean -- cgit v1.2.3 From d969289bafbbd5f035f8f483746ae824415bd1d7 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Mon, 6 Jun 2022 23:31:35 -0500 Subject: use LDFLAGS to build dwl target --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a8c1c0f..59b2519 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ LDLIBS = `pkg-config --libs $(PKGS)` # to your build system yourself and provide them in the include path. all: dwl dwl: dwl.o util.o - $(CC) $(LDLIBS) -o $@ dwl.o util.o + $(CC) $(LDLIBS) $(LDFLAGS) -o $@ dwl.o util.o dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h util.o: util.c util.h -- cgit v1.2.3 From c990dbd441684a9744cb744792488c34af20e9c7 Mon Sep 17 00:00:00 2001 From: Dima Krasner Date: Fri, 10 Jun 2022 19:26:45 +0300 Subject: fix link failure with --as-needed --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 59b2519..36a0f2f 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ LDLIBS = `pkg-config --libs $(PKGS)` # to your build system yourself and provide them in the include path. all: dwl dwl: dwl.o util.o - $(CC) $(LDLIBS) $(LDFLAGS) -o $@ dwl.o util.o + $(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) -o $@ dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h util.o: util.c util.h -- cgit v1.2.3 From c008bf2a7d76fd4b91267be6a67bd090b839c3ce Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Fri, 10 Jun 2022 12:08:36 -0500 Subject: add $(LIBS) to $(LDLIBS) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 36a0f2f..ac24ae7 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ WAYLAND_SCANNER = `pkg-config --variable=wayland_scanner wayland-scanner` # CFLAGS / LDFLAGS PKGS = wlroots wayland-server xkbcommon libinput $(XLIBS) DWLCFLAGS = `pkg-config --cflags $(PKGS)` $(DWLCPPFLAGS) $(CFLAGS) $(XWAYLAND) -LDLIBS = `pkg-config --libs $(PKGS)` +LDLIBS = `pkg-config --libs $(PKGS)` $(LIBS) # build rules -- cgit v1.2.3 From 671a9b450b636f5a2ebfefe159fea44e3b615fad Mon Sep 17 00:00:00 2001 From: Grant Nichol Date: Sun, 12 Jun 2022 15:41:43 -0500 Subject: Fix make install while files are in use When the dwl executable is in use, cp fails without the -f flag. POSIX defines this flag with: > If a file descriptor for a destination file cannot be obtained, > as described in step 3.a.ii., attempt to unlink the destination > file and proceed. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index ac24ae7..2c1782b 100644 --- a/Makefile +++ b/Makefile @@ -56,10 +56,10 @@ dist: clean install: dwl mkdir -p $(DESTDIR)$(PREFIX)/bin - cp dwl $(DESTDIR)$(PREFIX)/bin + cp -f dwl $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/dwl mkdir -p $(DESTDIR)$(MANDIR)/man1 - cp dwl.1 $(DESTDIR)$(MANDIR)/man1 + cp -f dwl.1 $(DESTDIR)$(MANDIR)/man1 chmod 644 $(DESTDIR)$(MANDIR)/man1/dwl.1 uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1 -- cgit v1.2.3 From 0eff78d6c268f7dc1a16861f051d9cd2108161a4 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Wed, 6 Jul 2022 23:28:49 -0500 Subject: include DWLCFLAGS into linking step --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2c1782b..6a8323b 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ LDLIBS = `pkg-config --libs $(PKGS)` $(LIBS) # to your build system yourself and provide them in the include path. all: dwl dwl: dwl.o util.o - $(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) -o $@ + $(CC) dwl.o util.o $(LDLIBS) $(LDFLAGS) $(DWLCFLAGS) -o $@ dwl.o: dwl.c config.mk config.h client.h xdg-shell-protocol.h wlr-layer-shell-unstable-v1-protocol.h idle-protocol.h util.o: util.c util.h -- cgit v1.2.3 From 6ce035303e686d976b98fa887231c0a23690aefb Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Mon, 8 Aug 2022 21:30:37 -0500 Subject: fix dist target --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6a8323b..1bdc7d6 100644 --- a/Makefile +++ b/Makefile @@ -45,10 +45,9 @@ clean: # distribution archive dist: clean mkdir -p dwl-$(VERSION) - cp -R LICENSE* Makefile README.md generate-version.sh client.h\ - config.def.h config.mk protocols dwl.1 dwl.c util.c util.h\ + cp -R LICENSE* Makefile README.md client.h config.def.h\ + config.mk protocols dwl.1 dwl.c util.c util.h\ dwl-$(VERSION) - echo "echo $(VERSION)" > dwl-$(VERSION)/generate-version.sh tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION) rm -rf dwl-$(VERSION) -- cgit v1.2.3