Commit ab3f234e5f33426172ecead8d964b927bb281850

Andreas Ericsson 2008-11-22T15:35:31

Make using CFLAGS a bit simpler This patch introduces the $(ALL_CFLAGS) variable, which holds $(BASIC_CFLAGS) as well as userdefined $(CFLAGS) and then consistently uses that variable where both were used anyway. Since we're in the area, we optimize the sparse running a bit, getting rid of the shell and just letting sparse iterate over the files. Signed-off-by: Andreas Ericsson <ae@op5.se> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

diff --git a/Makefile b/Makefile
index e7bed37..71628d1 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ OS     = unix
 
 BASIC_CFLAGS := -Isrc
 BASIC_CFLAGS += -fvisibility=hidden
+ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS)
 
 SRC_C = $(wildcard src/*.c)
 OBJS = $(patsubst %.c,%.o,$(SRC_C))
@@ -42,14 +43,14 @@ apidocs:
 test: $(TEST_RUN)
 
 sparse: $(CONFIG_H)
-	@for i in $(SRC_C); do sparse $$i -DSPARSE_IS_RUNNING $(SPARSE_FLAGS) $(BASIC_CFLAGS) $(CFLAGS); done
+	sparse -DSPARSE_IS_RUNNING $(ALL_CFLAGS) $(SPARSE_FLAGS) $(SRC_C)
 
 install-headers: $(PUBLIC_HEADERS)
 	@mkdir -p /tmp/gitinc/git
 	@for i in $^; do cat .HEADER $$i > /tmp/gitinc/$${i##src/}; done
 
 .c.o:
-	$(CC) $(BASIC_CFLAGS) $(CFLAGS) -c $< -o $@
+	$(CC) $(ALL_CFLAGS) -c $< -o $@
 
 $(CONFIG_H): $(CONFIG_H).in
 	sed 's/@@OS@@/$(OS)/g' $< >$@+
@@ -72,7 +73,7 @@ $(patsubst %.exe,%.toc,$(TEST_EXE)): tests/%.toc: tests/%.c
 	mv $@+ $@
 
 $(TEST_OBJ): tests/%.o: tests/%.c
-	$(CC) -Isrc $(CFLAGS) -c $< -o $@
+	$(CC) $(ALL_CFLAGS) -c $< -o $@
 
 $(patsubst %.exe,%_main.o,$(TEST_EXE)): tests/%_main.o: $(HDRS)
 $(patsubst %.exe,%_main.o,$(TEST_EXE)): tests/%_main.o: $(T_MAIN_C)