Skip to content

Commit

Permalink
Use jbwm-specific make variables for jbwm_cflags, jbwm_ldflags and ob…
Browse files Browse the repository at this point in the history
…jects.

Include depend.mk.  Define per-object rule to include both jbwm_cflags and
environment defined CFLAGS.
  • Loading branch information
alisabedard committed Oct 24, 2016
1 parent b09eb17 commit c2b48ba
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 94 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
# Copyright 1999-2015, Ciaran Anscomb <jbwm@6809.org.uk>
# 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:
# Warning: valgrind reports that xft leaks memory.
#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
Expand Down
38 changes: 19 additions & 19 deletions Makefile.debug
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 6 additions & 5 deletions Makefile.small
Original file line number Diff line number Diff line change
@@ -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
10 changes: 5 additions & 5 deletions Makefile.tbonly
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# Copyright 2008-2016, Jeffrey E. Bedard <jefbed@gmail.com>
# Copyright 1999-2015, Ciaran Anscomb <jbwm@6809.org.uk>
# 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
Expand Down
2 changes: 1 addition & 1 deletion Makefile.xft
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright 2008-2016, Jeffrey E. Bedard <jefbed@gmail.com>
# Copyright 1999-2015, Ciaran Anscomb <jbwm@6809.org.uk>
# 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
Expand Down
4 changes: 2 additions & 2 deletions ewmh.mk
Original file line number Diff line number Diff line change
@@ -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
89 changes: 47 additions & 42 deletions jbwm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,48 @@
# Copyright 1999-2015, Ciaran Anscomb <jbwm@6809.org.uk>
# 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 \
Expand All @@ -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
Expand All @@ -101,3 +103,6 @@ check:
make -f Makefile.tbonly
make clean
make # Default config
depend:
cc -E -MM *.c > depend.mk
#EOF
4 changes: 2 additions & 2 deletions mwm.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# MWM hints support
CFLAGS+=-DJBWM_USE_MWM
OBJS+=mwm.o
jbwm_cflags+=-DJBWM_USE_MWM
objects+=mwm.o
6 changes: 3 additions & 3 deletions shape.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CFLAGS+=-DJBWM_USE_SHAPE
LDFLAGS+=-lXext
OBJS+=shape.o
jbwm_cflags+=-DJBWM_USE_SHAPE
jbwm_ldflags+=-lXext
objects+=shape.o
4 changes: 2 additions & 2 deletions snap.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Window snaping support
CFLAGS+=-DJBWM_USE_SNAP
OBJS+=snap.o
jbwm_cflags+=-DJBWM_USE_SNAP
objects+=snap.o
4 changes: 2 additions & 2 deletions title_bar.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CFLAGS+=-DJBWM_USE_TITLE_BAR
OBJS+=title_bar.o
jbwm_cflags+=-DJBWM_USE_TITLE_BAR
objects+=title_bar.o
10 changes: 5 additions & 5 deletions xft.mk
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c2b48ba

Please sign in to comment.