From c2b48ba0082c4f769194f9359693f9493ce16127 Mon Sep 17 00:00:00 2001 From: "Jeffrey E. Bedard" Date: Sun, 23 Oct 2016 20:28:19 -0400 Subject: [PATCH] Use jbwm-specific make variables for jbwm_cflags, jbwm_ldflags and objects. Include depend.mk. Define per-object rule to include both jbwm_cflags and environment defined CFLAGS. --- Makefile | 12 +++---- Makefile.debug | 38 ++++++++++----------- Makefile.small | 11 +++--- Makefile.tbonly | 10 +++--- Makefile.xft | 2 +- ewmh.mk | 4 +-- jbwm.mk | 89 ++++++++++++++++++++++++++----------------------- mwm.mk | 4 +-- shape.mk | 6 ++-- snap.mk | 4 +-- title_bar.mk | 4 +-- xft.mk | 10 +++--- 12 files changed, 100 insertions(+), 94 deletions(-) diff --git a/Makefile b/Makefile index d1e8dca..202fa0b 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,13 @@ # Copyright 1999-2015, Ciaran Anscomb # See README for license and other details. # Debugging symbols, enabled to be able to debug core dumps -#CFLAGS+=-ggdb +#jbwm_cflags+=-ggdb # Link time optimization greatly reduces binary size: # However, it may not work correctly with clang. -#CFLAGS+=-flto -O3 -#CFLAGS+=-ggdb +#jbwm_cflags+=-flto -O3 +#jbwm_cflags+=-ggdb # Enable all warnings -CFLAGS+=-Wall -Wextra +jbwm_cflags+=-Wall -Wextra # Uncomment to enable SHAPE extension support include shape.mk # Titlebar Xft support: @@ -16,13 +16,13 @@ include shape.mk #include xft.mk # Uncomment to enable parsing command line arguments. # Saves ~2030 bytes -CFLAGS+=-DUSE_ARGV +jbwm_cflags+=-DUSE_ARGV # Uncomment to enable title bars include title_bar.mk # Uncomment to enable window snapping. ~4k include snap.mk # Uncomment to enable STDIO -CFLAGS+=-DSTDIO +jbwm_cflags+=-DSTDIO # Uncomment to enable EWMH ~8k include ewmh.mk # Uncomment to enable MWM hints diff --git a/Makefile.debug b/Makefile.debug index b372884..0902326 100644 --- a/Makefile.debug +++ b/Makefile.debug @@ -1,25 +1,25 @@ # Debug -CFLAGS=-O0 -CFLAGS+=-ggdb -CFLAGS+=-DDEBUG +jbwm_cflags=-O0 +jbwm_cflags+=-ggdb +jbwm_cflags+=-DDEBUG # Profile -CFLAGS+=-pg +jbwm_cflags+=-pg # Enable all warnings -CFLAGS+=-W -Wall -Wextra -Werror -CFLAGS+=-Wuninitialized -Wstrict-overflow=5 -CFLAGS+=-Wsuggest-attribute=pure -CFLAGS+=-Wsuggest-attribute=const -CFLAGS+=-Wsuggest-attribute=noreturn -CFLAGS+=-Wsuggest-attribute=format -#CFLAGS+=-Wlarger-than=512 -Wframe-larger-than=512 -Wstack-usage=512 -CFLAGS+=-Wcast-qual -Wcast-align -Wjump-misses-init -CFLAGS+=-Wlogical-op -Wmissing-prototypes -#CFLAGS+=-Wpadded -CFLAGS+=-Wredundant-decls -Wpointer-sign -CFLAGS+=-fstrict-aliasing -Wstrict-aliasing=2 -CFLAGS+=-Wformat=2 -CFLAGS+=-DUSE_ARGV -CFLAGS+=-DSTDIO +jbwm_cflags+=-W -Wall -Wextra -Werror +jbwm_cflags+=-Wuninitialized -Wstrict-overflow=5 +jbwm_cflags+=-Wsuggest-attribute=pure +jbwm_cflags+=-Wsuggest-attribute=const +jbwm_cflags+=-Wsuggest-attribute=noreturn +jbwm_cflags+=-Wsuggest-attribute=format +#jbwm_cflags+=-Wlarger-than=512 -Wframe-larger-than=512 -Wstack-usage=512 +jbwm_cflags+=-Wcast-qual -Wcast-align -Wjump-misses-init +jbwm_cflags+=-Wlogical-op -Wmissing-prototypes +#jbwm_cflags+=-Wpadded +jbwm_cflags+=-Wredundant-decls -Wpointer-sign +jbwm_cflags+=-fstrict-aliasing -Wstrict-aliasing=2 +jbwm_cflags+=-Wformat=2 +jbwm_cflags+=-DUSE_ARGV +jbwm_cflags+=-DSTDIO include ewmh.mk include mwm.mk include shape.mk diff --git a/Makefile.small b/Makefile.small index c793a81..9b49be3 100644 --- a/Makefile.small +++ b/Makefile.small @@ -1,9 +1,10 @@ -CFLAGS=-Os +jbwm_cflags=-Os # Compile for current machine -CFLAGS+=-march=native +jbwm_cflags+=-march=native # Tuning -CFLAGS+=-fomit-frame-pointer -pipe -flto -#CFLAGS+=-W -Wall -Wextra +jbwm_cflags+=-fomit-frame-pointer -pipe -flto +#jbwm_cflags+=-W -Wall -Wextra # disable everything for minimal configuration -#CFLAGS+=-DNDEBUG +#jbwm_cflags+=-DNDEBUG +CFLAGS=${jbwm_cflags} include jbwm.mk diff --git a/Makefile.tbonly b/Makefile.tbonly index 656f4fd..92c6e4a 100644 --- a/Makefile.tbonly +++ b/Makefile.tbonly @@ -2,12 +2,12 @@ # Copyright 2008-2016, Jeffrey E. Bedard # Copyright 1999-2015, Ciaran Anscomb # See README for license and other details. -CFLAGS=-Os -CFLAGS+=-march=native -CFLAGS+=-fomit-frame-pointer -pipe -flto -CFLAGS+=-W -Wall -Wextra +jbwm_cflags=-Os +jbwm_cflags+=-march=native +jbwm_cflags+=-fomit-frame-pointer -pipe -flto +jbwm_cflags+=-W -Wall -Wextra # Uncomment to disable assertions -CFLAGS+=-DNDEBUG +jbwm_cflags+=-DNDEBUG # Titlebar Xft support: #include xft.mk # Uncomment to enable title bars diff --git a/Makefile.xft b/Makefile.xft index 9a5218d..e9a0884 100644 --- a/Makefile.xft +++ b/Makefile.xft @@ -2,7 +2,7 @@ # Copyright 2008-2016, Jeffrey E. Bedard # Copyright 1999-2015, Ciaran Anscomb # See README for license and other details. -CFLAGS+=-Wall -Wextra +jbwm_cflags+=-Wall -Wextra # Titlebar Xft support: include xft.mk # Uncomment to enable title bars diff --git a/ewmh.mk b/ewmh.mk index f548fed..8a24c3d 100644 --- a/ewmh.mk +++ b/ewmh.mk @@ -1,2 +1,2 @@ -CFLAGS+=-DJBWM_USE_EWMH -OBJS+=ewmh.o ewmh_state.o +jbwm_cflags+=-DJBWM_USE_EWMH +objects+=ewmh.o ewmh_state.o diff --git a/jbwm.mk b/jbwm.mk index 08a7e38..cb6d4c4 100644 --- a/jbwm.mk +++ b/jbwm.mk @@ -3,42 +3,48 @@ # Copyright 1999-2015, Ciaran Anscomb # See README for license and other details. version=1.50 -PROG=jbwm -distname=$(PROG)-$(version) +exe=jbwm +distname=$(exe)-$(version) # Edit/override this line if you don't want jbwm to install under /usr. PREFIX=/usr # Note that $(DESTDIR) is used by the Debian build process. dest=$(DESTDIR)$(PREFIX) # FreeBSD: -CFLAGS+=-I/usr/local/include -LDFLAGS+=-L/usr/local/lib +jbwm_cflags+=-I/usr/local/include +jbwm_ldflags+=-L/usr/local/lib # OpenBSD: -CFLAGS+=-I/usr/X11R6/include -CFLAGS+=-I/usr/X11R6/include/freetype2 -LDFLAGS+=-L/usr/X11R6/lib +jbwm_cflags+=-I/usr/X11R6/include +jbwm_cflags+=-I/usr/X11R6/include/freetype2 +jbwm_ldflags+=-L/usr/X11R6/lib # NetBSD: -CFLAGS+=-I/usr/X11R7/include -CFLAGS+=-I/usr/X11R7/include/freetype2 -CFLAGS+=-Wno-missing-field-initializers -#LDFLAGS+=-Wl,-R/usr/X11R6/lib -LDFLAGS+=-L/usr/X11R7/lib -LDFLAGS+=-Wl,-R/usr/X11R7/lib -LDFLAGS+=-lX11 +jbwm_cflags+=-I/usr/X11R7/include +jbwm_cflags+=-I/usr/X11R7/include/freetype2 +jbwm_cflags+=-Wno-missing-field-initializers +#jbwm_ldflags+=-Wl,-R/usr/X11R6/lib +jbwm_ldflags+=-L/usr/X11R7/lib +jbwm_ldflags+=-Wl,-R/usr/X11R7/lib +jbwm_ldflags+=-lX11 # Uncomment to enable X11 miscellaneous debugging (events) -#CFLAGS+=-DXDEBUG -CFLAGS+=-DVERSION=\"$(version)\" $(DEBIAN) -CFLAGS+=-D_XOPEN_SOURCE=700 -std=c11 +#jbwm_cflags+=-DXDEBUG +jbwm_cflags+=-DVERSION=\"$(version)\" $(DEBIAN) +jbwm_cflags+=-D_XOPEN_SOURCE=700 -std=c11 # Uncomment for static linking of binary: -#LDFLAGS+=-static -OBJS+=client.o events.o jbwm.o new.o screen.o -OBJS+=button_event.o keys.o util.o max.o -$(PROG): $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -o $@ - strip $(PROG) -o $(PROG).tmp - ls -l $(PROG).tmp >> sz.log - rm -f $(PROG).tmp +#jbwm_ldflags+=-static +objects+=client.o events.o jbwm.o new.o screen.o +objects+=button_event.o keys.o util.o max.o +#CFLAGS+=${jbwm_cflags} +#LDFLAGS+=${jbwm_ldflags} + +$(exe): $(objects) + $(CC) ${jbwm_ldflags} $(LDFLAGS) $(objects) -o $@ + strip $(exe) -o $(exe).tmp + ls -l $(exe).tmp >> sz.log + rm -f $(exe).tmp tail sz.log -all: $(PROG) +include depend.mk +# Use `` for basename for BSD make compatibility +${objects}: + ${CC} ${CFLAGS} ${jbwm_cflags} -c `basename -s .o $@`.c strip: # Leave .plt.got strip -s \ @@ -53,45 +59,41 @@ strip: -R .comment \ -R .gnu.hash \ -R .shstrtab \ - $(PROG) + $(exe) INSTALL=install -c -INSTALL_PROG=$(INSTALL) +INSTALL_exe=$(INSTALL) INSTALL_DIR=install -d install: $(INSTALL_DIR) $(dest)/bin $(dest)/share/man/man1 - $(INSTALL_PROG) $(PROG) $(dest)/bin - $(INSTALL) $(PROG).1 $(dest)/share/man/man1 + $(INSTALL_exe) $(exe) $(dest)/bin + $(INSTALL) $(exe).1 $(dest)/share/man/man1 clean: - rm -f $(PROG) *.o + rm -f $(exe) *.o distclean: clean rm -f *~ *.out .*.swp .*.swn *.orig .*~ *~~ archive: distclean - cd ..; tar cJf $(PROG)-$(version).tar.xz $(PROG) + cd ..; tar cJf $(exe)-$(version).tar.xz $(exe) tags: ctags * indent: indent *.[ch] sed 's/ \/\//\/\//g' -i'~~' *.[ch] -debug: - make clean +debug: clean make -f Makefile.debug -j 4 -small: - make clean +small: clean + jbwm_cflags= make -f Makefile.small cp jbwm jbwm.small.dbg make strip ls -l jbwm >> small.log tail small.log -clang: - make clean +clang: clean make -f Makefile.clang -tbonly: - make clean +tbonly: clean make -f Makefile.tbonly -check: +check: clean CFLAGS='-Werror' - make clean make -f Makefile.clang make clean make -f Makefile.debug @@ -101,3 +103,6 @@ check: make -f Makefile.tbonly make clean make # Default config +depend: + cc -E -MM *.c > depend.mk +#EOF diff --git a/mwm.mk b/mwm.mk index d62909c..208f93a 100644 --- a/mwm.mk +++ b/mwm.mk @@ -1,3 +1,3 @@ # MWM hints support -CFLAGS+=-DJBWM_USE_MWM -OBJS+=mwm.o +jbwm_cflags+=-DJBWM_USE_MWM +objects+=mwm.o diff --git a/shape.mk b/shape.mk index 9d7cfbe..31102ad 100644 --- a/shape.mk +++ b/shape.mk @@ -1,3 +1,3 @@ -CFLAGS+=-DJBWM_USE_SHAPE -LDFLAGS+=-lXext -OBJS+=shape.o +jbwm_cflags+=-DJBWM_USE_SHAPE +jbwm_ldflags+=-lXext +objects+=shape.o diff --git a/snap.mk b/snap.mk index 9aceb92..f08f5ba 100644 --- a/snap.mk +++ b/snap.mk @@ -1,3 +1,3 @@ # Window snaping support -CFLAGS+=-DJBWM_USE_SNAP -OBJS+=snap.o +jbwm_cflags+=-DJBWM_USE_SNAP +objects+=snap.o diff --git a/title_bar.mk b/title_bar.mk index f029412..6f66e13 100644 --- a/title_bar.mk +++ b/title_bar.mk @@ -1,2 +1,2 @@ -CFLAGS+=-DJBWM_USE_TITLE_BAR -OBJS+=title_bar.o +jbwm_cflags+=-DJBWM_USE_TITLE_BAR +objects+=title_bar.o diff --git a/xft.mk b/xft.mk index 5cb4814..b350f9e 100644 --- a/xft.mk +++ b/xft.mk @@ -1,7 +1,7 @@ # Titlebar Xft support: -CFLAGS+=-DJBWM_USE_XFT -CFLAGS+=`pkg-config --cflags xft` -LDFLAGS+=-lXft +jbwm_cflags+=-DJBWM_USE_XFT +jbwm_cflags+=`pkg-config --cflags xft` +jbwm_ldflags+=-lXft # NetBSD: -CFLAGS+=-I/usr/pkg/include/freetype2 -CFLAGS+=-I/usr/X11R6/include/freetype2 +jbwm_cflags+=-I/usr/pkg/include/freetype2 +jbwm_cflags+=-I/usr/X11R6/include/freetype2