Makefile: move 'ifdef DEVELOPER' after config.mak* inclusion

The DEVELOPER knob was introduced in 658df95 (add DEVELOPER makefile knob to check for acknowledged warnings, 2016-02-25), and works well when used as "make DEVELOPER=1", and when the configure script was not used. However, the advice given in CodingGuidelines to add DEVELOPER=1 to config.mak does not: config.mak is included after testing for DEVELOPER in the Makefile, and at least GNU Make's manual specifies "Conditional directives are parsed immediately", hence the config.mak declaration is not visible at the time the conditional is evaluated. Also, when using the configure script to generate a config.mak.autogen, the later file contained a "CFLAGS = <flags>" initialization, which overrode the "CFLAGS += -W..." triggered by DEVELOPER. This patch fixes both issues. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Matthieu Moy committed May 31, 2016 at 15:24 UTC d615628c354ad2aaf3f3f37b3f84ddcc7c3537c6
1 file changed +12 -12
Makefile
+12 -12
@@ -380,18 +380,6 @@ ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
380 ALL_LDFLAGS = $(LDFLAGS)
381 STRIP ?= strip
382
383 -ifdef DEVELOPER
384 -CFLAGS += -Werror \
385 - -Wdeclaration-after-statement \
386 - -Wno-format-zero-length \
387 - -Wold-style-definition \
388 - -Woverflow \
389 - -Wpointer-arith \
390 - -Wstrict-prototypes \
391 - -Wunused \
392 - -Wvla
393 -endif
394 -
383 # Create as necessary, replace existing, make ranlib unneeded.
384 ARFLAGS = rcs
385
@@ -952,6 +940,18 @@ include config.mak.uname
940 -include config.mak.autogen
941 -include config.mak
942
943 +ifdef DEVELOPER
944 +CFLAGS += -Werror \
945 + -Wdeclaration-after-statement \
946 + -Wno-format-zero-length \
947 + -Wold-style-definition \
948 + -Woverflow \
949 + -Wpointer-arith \
950 + -Wstrict-prototypes \
951 + -Wunused \
952 + -Wvla
953 +endif
954 +
955 ifndef sysconfdir
956 ifeq ($(prefix),/usr)
957 sysconfdir = /etc