[RCF/PATCH] Makefile: move 'ifdef DEVELOPER' after config.mak* inclusion

Subsystems: kernel build + files below scripts/ (unless maintained elsewhere), the rest

2 messages, 2 authors, 2016-06-16 · open the first message on its own page

[RCF/PATCH] Makefile: move 'ifdef DEVELOPER' after config.mak* inclusion

From: Matthieu Moy <hidden>
Date: 2016-06-16 02:19:40

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 <redacted>
---
I'm surprised that no one noticed the issue. Probably because the
Makefile is silent by default. Did I miss anything obvious?

 Makefile | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/Makefile b/Makefile
index 15fcd57..2226319 100644
--- a/Makefile
+++ b/Makefile
@@ -380,18 +380,6 @@ ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip
 
-ifdef DEVELOPER
-CFLAGS += -Werror \
-	-Wdeclaration-after-statement \
-	-Wno-format-zero-length \
-	-Wold-style-definition \
-	-Woverflow \
-	-Wpointer-arith \
-	-Wstrict-prototypes \
-	-Wunused \
-	-Wvla
-endif
-
 # Create as necessary, replace existing, make ranlib unneeded.
 ARFLAGS = rcs
 
@@ -952,6 +940,18 @@ include config.mak.uname
 -include config.mak.autogen
 -include config.mak
 
+ifdef DEVELOPER
+CFLAGS += -Werror \
+	-Wdeclaration-after-statement \
+	-Wno-format-zero-length \
+	-Wold-style-definition \
+	-Woverflow \
+	-Wpointer-arith \
+	-Wstrict-prototypes \
+	-Wunused \
+	-Wvla
+endif
+
 ifndef sysconfdir
 ifeq ($(prefix),/usr)
 sysconfdir = /etc
-- 
2.8.2.397.gbe91ebf.dirty

Re: [RCF/PATCH] Makefile: move 'ifdef DEVELOPER' after config.mak* inclusion

From: Jeff King <hidden>
Date: 2016-06-16 02:19:41

On Tue, May 31, 2016 at 03:24:43PM +0200, Matthieu Moy wrote:
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.
Hmm. So I think this does fix some issues, but it also means that one's
config.mak cannot use DEVELOPER as a base and then override particular
flags.

I dunno if people want to do that or not. I do not use DEVELOPER myself
because I have my own detailed config.mak that is a superset.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help