git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
May 31, 2016, 13:24 UTC
Message-ID
<20160531132443.5033-1-Matthieu.Moy@imag.fr>

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>
---
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
Next: Junio C Hamano
Message 1 of 7 in “Makefile: move 'ifdef DEVELOPER' after config.mak* inclusion”
  1. Makefile: move 'ifdef DEVELOPER' after config.mak* inclusionMatthieu Moy, May 31, 2016
  2. Junio C HamanoMay 31, 2016
  3. Jeff KingJun 1, 2016
  4. Matthieu MoyJun 1, 2016
  5. Makefile: add $(DEVELOPER_CFLAGS) variableMatthieu Moy, Jun 1, 2016
  6. Jeff KingJun 1, 2016
  7. Jeff KingJun 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.