From 488bbf13be6f3f079c983dc0b23a930a30489dd8 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 17 Nov 2021 03:35:52 +0500 Subject: [PATCH] Configure build for both GNU and BSD makes --- .gitignore | 1 + Makefile | 15 ++++++++++++--- config/4-defvars-bsd.mk | 15 +++++++++++++++ config/{4-defvars.mk => 4-defvars-gnu.mk} | 0 configure | 21 ++++++++++++++------- 5 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 config/4-defvars-bsd.mk rename config/{4-defvars.mk => 4-defvars-gnu.mk} (100%) diff --git a/.gitignore b/.gitignore index 0526db3..9b02266 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /config/1-custom.mk /config/2-generated.mk /config/3-custom.mk +/config/4-defvars.mk /config/5-custom.mk /polytreewm /src/*.o diff --git a/Makefile b/Makefile index 47c5a2a..8876344 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,12 @@ # PolytreeWM - tiling window manager # See LICENSE file for copyright and license details. +include config/1-custom.mk +include config/2-generated.mk +include config/3-custom.mk +include config/4-defvars.mk +include config/5-custom.mk + CONFIGMKS = \ config/1-custom.mk \ config/2-generated.mk \ @@ -8,8 +14,6 @@ CONFIGMKS = \ config/4-defvars.mk \ config/5-custom.mk -include $(CONFIGMKS) - VERSION = 6.2 SRC = \ @@ -66,7 +70,12 @@ clean: rm -f polytreewm ${OBJ} distclean: clean - rm -f config/2-generated.mk + rm -f \ + config/1-custom.mk \ + config/2-generated.mk \ + config/3-custom.mk \ + config/4-defvars.mk \ + config/5-custom.mk install: all mkdir -p ${DESTDIR}${BINDIR} diff --git a/config/4-defvars-bsd.mk b/config/4-defvars-bsd.mk new file mode 100644 index 0000000..d32322d --- /dev/null +++ b/config/4-defvars-bsd.mk @@ -0,0 +1,15 @@ +CC = cc +PKGCONFIG = pkg-config + +PKGS += fontconfig freetype2 x11 x11-xcb xcb xcb-res xft + +.if "$(ENABLE_XINERAMA)" == 'yes' +CPPFLAGS += -DENABLE_XINERAMA +PKGS += xinerama +.endif + +CFLAGS += `$(PKGCONFIG) --cflags $(PKGS)` +LDFLAGS += `$(PKGCONFIG) --libs $(PKGS)` + +CPPFLAGS += -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L +CFLAGS += $(CPPFLAGS) -std=c99 -Os -pedantic -Wall -Wno-deprecated-declarations diff --git a/config/4-defvars.mk b/config/4-defvars-gnu.mk similarity index 100% rename from config/4-defvars.mk rename to config/4-defvars-gnu.mk diff --git a/configure b/configure index 084b746..da3b1fd 100755 --- a/configure +++ b/configure @@ -108,11 +108,18 @@ touch 'config/1-custom.mk' touch 'config/3-custom.mk' touch 'config/5-custom.mk' -rm -f 'config/2-generated.mk' +cat > 'config/2-generated.mk' << MAKE +PREFIX = $prefix +EPREFIX = $eprefix +BINDIR = $bindir +DATAROOTDIR = $datarootdir +MANDIR = $mandir +ENABLE_XINERAMA = $enable_xinerama +MAKE -echo "PREFIX = $prefix" >> 'config/2-generated.mk' -echo "EPREFIX = $eprefix" >> 'config/2-generated.mk' -echo "BINDIR = $bindir" >> 'config/2-generated.mk' -echo "DATAROOTDIR = $datarootdir" >> 'config/2-generated.mk' -echo "MANDIR = $mandir" >> 'config/2-generated.mk' -echo "ENABLE_XINERAMA = $enable_xinerama" >> 'config/2-generated.mk' +make_help_result="$(make --help)" +if [ "$(echo "$make_help_result" | grep 'gnu.org')" = '' ]; then + ln -sf '4-defvars-bsd.mk' 'config/4-defvars.mk' +else + ln -sf '4-defvars-gnu.mk' 'config/4-defvars.mk' +fi