summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2012-08-14 21:36:11 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2012-08-14 21:36:11 +0000
commitf3b8d9d632adf293fd7bda64dbbb5c51f81bb2c3 (patch)
tree95f7b96689c8d85c12a53fbd40a739a496a3f020 /util
parentb9de3ee1035a93c7e00af4e10858996c09648f1a (diff)
downloadflashrom-f3b8d9d632adf293fd7bda64dbbb5c51f81bb2c3.tar.gz
Allow the user to specify CFLAGS without breaking the build
GNU make has a very interesting quirk: If you set a variable on the command line, any changes to that variable in the Makefile are ignored unless marked with the "override" keyword. Use CFLAGS only for optimization and warning options, and use CPPFLAGS for the dependency and other preprocessor related options. That way packagers can specify their own CFLAGS without breaking the build. As a side benefit, the ich_descriptors_tool Makefile now behaves exactly the same whether called standalone or as part of the main Makefile. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1574 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util')
-rw-r--r--util/ich_descriptors_tool/Makefile31
1 files changed, 23 insertions, 8 deletions
diff --git a/util/ich_descriptors_tool/Makefile b/util/ich_descriptors_tool/Makefile
index d8a79f5..4d18aec 100644
--- a/util/ich_descriptors_tool/Makefile
+++ b/util/ich_descriptors_tool/Makefile
@@ -1,4 +1,8 @@
-CC ?= gcc
+#
+# This file is part of the flashrom project.
+#
+# This Makefile works standalone, but it is usually called from the main
+# Makefile in the flashrom directory.
PROGRAM=ich_descriptors_tool
EXTRAINCDIRS = ../../ .
@@ -6,19 +10,30 @@ DEPPATH = .dep
OBJATH = .obj
SHAREDSRC = ich_descriptors.c
SHAREDSRCDIR = ../..
+# If your compiler spits out excessive warnings, run make WARNERROR=no
+# You shouldn't have to change this flag.
+WARNERROR ?= yes
SRC = $(wildcard *.c)
-CFLAGS += -Wall
-CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
-# enables functions that populate the descriptor structs from plain binary dumps
-CFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP
-CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
+CC ?= gcc
+# If the user has specified custom CFLAGS, all CFLAGS settings below will be
+# completely ignored by gnumake.
+CFLAGS ?= -Os -Wall -Wshadow
ifeq ($(TARGET_OS), DOS)
# DJGPP has odd uint*_t definitions which cause lots of format string warnings.
CFLAGS += -Wno-format
endif
+ifeq ($(WARNERROR), yes)
+CFLAGS += -Werror
+endif
+
+
+CPPFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
+# enables functions that populate the descriptor structs from plain binary dumps
+CPPFLAGS += -D ICH_DESCRIPTORS_FROM_DUMP
+CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
OBJ = $(OBJATH)/$(SRC:%.c=%.o)
@@ -27,12 +42,12 @@ SHAREDOBJ = $(OBJATH)/$(notdir $(SHAREDSRC:%.c=%.o))
all:$(PROGRAM)$(EXEC_SUFFIX)
$(OBJ): $(OBJATH)/%.o : %.c
- $(CC) $(CFLAGS) -o $@ -c $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
# this enables us to share source files without simultaneously sharing .o files
# with flashrom, which would lead to unexpected results (w/o running make clean)
$(SHAREDOBJ): $(OBJATH)/%.o : $(SHAREDSRCDIR)/%.c
- $(CC) $(CFLAGS) -o $@ -c $<
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
$(PROGRAM)$(EXEC_SUFFIX): $(OBJ) $(SHAREDOBJ)
$(CC) -o $(PROGRAM)$(EXEC_SUFFIX) $(OBJ) $(SHAREDOBJ)