The attached test project demonstrates a lack in dh_auto_build for Makefile
projects: the Debian-specified build flags are not necessarily communicated to
the compiler. Debhelper should override CPPFLAGS and CFLAGS on the make
command line.
It is, I think, quite common for Makefile projects to define defaults for
CFLAGS and sometimes even CPPFLAGS in their Makefiles. However, this means
that the corresponding environment variables (which debhelper sets) are
ignored. The correct way to override Makefile-specified defaults is to
pass the variables on the make command line. Compare:
$ make CFLAGS="`dpkg-buildflags --get CFLAGS`"
gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -c -o testhello.o testhello.c
gcc testhello.o -o testhello
to
$ make
gcc -g -c -o testhello.o testhello.c
gcc testhello.o -o testhello
(Both in the test project's toplevel directory.)
The current debhelper manner of passing CFLAGS is ignored by such projects:
$ DH_VERBOSE=1 debian/rules build
dh build
dh_testdir
dh_auto_configure
dh_auto_build
make -j1
make[1]: Siirrytään hakemistoon "/home/ajk/scratch/testhello-0.1"
gcc -g -D_FORTIFY_SOURCE=2 -c -o testhello.o testhello.c
gcc -Wl,-z,relro testhello.o -o testhello
make[1]: Poistutaan hakemistosta "/home/ajk/scratch/testhello-0.1"
dh_auto_test
Notice how CPPFLAGS and LDFLAGS are honored but CFLAGS is ignored.
This currently affects dctrl-tools, but I'm going to work around the problem
in my next upload.