From 000c7fbeea391188f53710880aab0c80958b2a62 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Wed, 17 Nov 2021 03:02:06 +0500 Subject: [PATCH] Configure build --- .gitignore | 5 +- Makefile | 36 ++++++++------ config.mk | 23 --------- config/4-defvars.mk | 15 ++++++ configure | 118 ++++++++++++++++++++++++++++++++++++++++++++ src/dwm.c | 12 ++--- 6 files changed, 164 insertions(+), 45 deletions(-) delete mode 100644 config.mk create mode 100644 config/4-defvars.mk create mode 100755 configure diff --git a/.gitignore b/.gitignore index 3392289..0526db3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ -/config/active.mk +/config/1-custom.mk +/config/2-generated.mk +/config/3-custom.mk +/config/5-custom.mk /polytreewm /src/*.o diff --git a/Makefile b/Makefile index fb8ebb4..47c5a2a 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,17 @@ # PolytreeWM - tiling window manager # See LICENSE file for copyright and license details. -include config.mk +CONFIGMKS = \ + config/1-custom.mk \ + config/2-generated.mk \ + config/3-custom.mk \ + config/4-defvars.mk \ + config/5-custom.mk + +include $(CONFIGMKS) VERSION = 6.2 -CPPFLAGS += -DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -CFLAGS += $(CPPFLAGS) -std=c99 -Os -pedantic -Wall -Wno-deprecated-declarations -LDFLAGS += - SRC = \ src/atoms.c \ src/drw.c \ @@ -57,23 +60,26 @@ polytreewm: ${OBJ} ${CC} -c $< -o $@ ${CFLAGS} dwm.o: ${DWM_SRC} ${DWM_HDR} -${OBJ}: ${HDR} +${OBJ}: ${CONFIGMKS} ${HDR} clean: rm -f polytreewm ${OBJ} +distclean: clean + rm -f config/2-generated.mk + install: all - mkdir -p ${DESTDIR}${PREFIX}/bin - cp -f polytreewm ${DESTDIR}${PREFIX}/bin - chmod 755 ${DESTDIR}${PREFIX}/bin/polytreewm + mkdir -p ${DESTDIR}${BINDIR} + cp -f polytreewm ${DESTDIR}${BINDIR} + chmod 755 ${DESTDIR}${BINDIR}/polytreewm - mkdir -p ${DESTDIR}${MANPREFIX}/man1 - sed "s/VERSION/${VERSION}/g" < polytreewm.1 > ${DESTDIR}${MANPREFIX}/man1/polytreewm.1 - chmod 644 ${DESTDIR}${MANPREFIX}/man1/polytreewm.1 + mkdir -p ${DESTDIR}${MANDIR}/man1 + sed "s/VERSION/${VERSION}/g" < polytreewm.1 > ${DESTDIR}${MANDIR}/man1/polytreewm.1 + chmod 644 ${DESTDIR}${MANDIR}/man1/polytreewm.1 uninstall: rm -f \ - ${DESTDIR}${PREFIX}/bin/polytreewm \ - ${DESTDIR}${MANPREFIX}/man1/polytreewm.1 + ${DESTDIR}${BINDIR}/polytreewm \ + ${DESTDIR}${MANDIR}/man1/polytreewm.1 -.PHONY: all options clean install uninstall +.PHONY: all options clean distclean install uninstall diff --git a/config.mk b/config.mk deleted file mode 100644 index fd410e7..0000000 --- a/config.mk +++ /dev/null @@ -1,23 +0,0 @@ -########################## -# Compiler, linker, etc. # -########################## - -CC = cc -PKGCONFIG = pkg-config - -######### -# Paths # -######### - -PREFIX = /usr/local -MANPREFIX = $(PREFIX)/share/man - -################ -# Dependencies # -################ - -PKGS = fontconfig freetype2 x11 x11-xcb xcb xcb-res xft xinerama - -CPPFLAGS = -DXINERAMA -CFLAGS = `$(PKGCONFIG) --cflags $(PKGS)` -LDFLAGS = `$(PKGCONFIG) --libs $(PKGS)` diff --git a/config/4-defvars.mk b/config/4-defvars.mk new file mode 100644 index 0000000..3d1bcf1 --- /dev/null +++ b/config/4-defvars.mk @@ -0,0 +1,15 @@ +CC = cc +PKGCONFIG = pkg-config + +PKGS += fontconfig freetype2 x11 x11-xcb xcb xcb-res xft + +ifeq (yes,$(ENABLE_XINERAMA)) +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/configure b/configure new file mode 100755 index 0000000..084b746 --- /dev/null +++ b/configure @@ -0,0 +1,118 @@ +#!/bin/sh + +set -e + +help() { + cat <> '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' diff --git a/src/dwm.c b/src/dwm.c index ed06a0b..5914811 100644 --- a/src/dwm.c +++ b/src/dwm.c @@ -34,9 +34,9 @@ #include #include #include -#ifdef XINERAMA +#ifdef ENABLE_XINERAMA #include -#endif /* XINERAMA */ +#endif /* ENABLE_XINERAMA */ #include #include #include @@ -1007,7 +1007,7 @@ incnmaster(const Arg *arg) arrange(selmon); } -#ifdef XINERAMA +#ifdef ENABLE_XINERAMA static int isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) { @@ -1017,7 +1017,7 @@ isuniquegeom(XineramaScreenInfo *unique, size_t n, XineramaScreenInfo *info) return 0; return 1; } -#endif /* XINERAMA */ +#endif /* ENABLE_XINERAMA */ void killclient(const Arg *arg) @@ -2047,7 +2047,7 @@ updategeom(void) { int dirty = 0; -#ifdef XINERAMA +#ifdef ENABLE_XINERAMA if (XineramaIsActive(dpy)) { int i, j, n, nn; Client *c; @@ -2102,7 +2102,7 @@ updategeom(void) } free(unique); } else -#endif /* XINERAMA */ +#endif /* ENABLE_XINERAMA */ { /* default monitor setup */ if (!mons) mons = createmon();