aboutsummaryrefslogtreecommitdiffstats
path: root/inc/depend.makefile
diff options
context:
space:
mode:
Diffstat (limited to 'inc/depend.makefile')
-rw-r--r--inc/depend.makefile22
1 files changed, 22 insertions, 0 deletions
diff --git a/inc/depend.makefile b/inc/depend.makefile
new file mode 100644
index 0000000..4d10534
--- /dev/null
+++ b/inc/depend.makefile
@@ -0,0 +1,22 @@
1# Generic dependency resolution. Part of liblitmus so that we don't have to
2# carry it around in every project using liblitmus.
3
4obj-all = ${sort ${foreach target,${all},${obj-${target}}}}
5
6# rule to generate dependency files
7%.d: %.c
8 @set -e; rm -f $@; \
9 $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
10 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
11 rm -f $@.$$$$
12
13ifeq ($(MAKECMDGOALS),)
14MAKECMDGOALS += all
15endif
16
17ifneq ($(filter-out clean,$(MAKECMDGOALS)),)
18
19# Pull in dependencies.
20-include ${obj-all:.o=.d}
21
22endif