summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-02-12 21:28:59 -0800
committerAaron Plattner <aplattner@nvidia.com>2008-02-12 21:28:59 -0800
commitbb33b26f8d104cb8c0acbff21d1f2b4638d81f20 (patch)
tree46d6c65cc2f2f2fc28cec5d20c89b7d2e3590f2c /Makefile
parent818140c39f7818755070e3b853956b818c842f2e (diff)
100.14.03100.14.03
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile11
1 files changed, 10 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 6fe0c47..865a534 100644
--- a/Makefile
+++ b/Makefile
@@ -201,11 +201,20 @@ $(OBJS_DIR)/%.o: %.c
@ mkdir -p $(OBJS_DIR)
$(CC) -c $(ALL_CFLAGS) $< -o $@
+# to generate the dependency files, use the compiler's "-MM" option to
+# generate output of the form "foo.o : foo.c foo.h"; then, use sed to
+# replace the target with "$(OBJS_DIR)/foo.o $(DEPS_DIR)/foo.d", and
+# wrap the prerequisites with $(wildcard ...); the wildcard function
+# serves as an existence filter, so that files that are later removed
+# from the build do not cause stale references.
+
$(DEPS_DIR)/%.d: %.c
@ mkdir -p $(DEPS_DIR)
@ set -e; b=`basename $* .c` ; \
$(CC) -MM $(CPPFLAGS) $< \
- | sed "s%\\($$b\\)\\.o[ :]*%$(OBJS_DIR)/\\1.o $(DEPS_DIR)/\\1.d : %g" > $@; \
+ | sed \
+ -e "s%\\($$b\\)\\.o[ :]*%$(OBJS_DIR)/\\1.o $(DEPS_DIR)/\\1.d : $$\(wildcard %g" \
+ -e "s,\([^\\]\)$$,\1)," > $@; \
[ -s $@ ] || rm -f $@
$(STAMP_C): $(filter-out $(OBJS_DIR)/$(STAMP_C:.c=.o), $(OBJS))