-
Notifications
You must be signed in to change notification settings - Fork 3
/
depend.mk
48 lines (36 loc) · 1.34 KB
/
depend.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# How to build automatic dependencies
# Don't include dependencies if $(no_deps) is set; the master makefile
# does this for clean and other such targets that don't need
# dependencies. That then avoids rebuilding dependencies.
ifneq ($(no_deps),t)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),mrproper)
ifneq ($(MAKECMDGOALS),menuconfig)
# For each .o file we need a .d file.
-include $(subst .o,.d,$(filter %.o,$(OBJECTS)))
-include $(subst .o,.d,$(filter %.o,$(OBJECTS_SIM)))
endif
endif
endif
endif
# Here is how to build those dependency files
define make-deps
echo "checking dependencies for $<"
if [ ! -d obj_avr ]; then mkdir obj_avr ; fi
set -e; $(CC) $(CFLAGS) $(CPPFLAGS) -M -MM $< | \
sed > [email protected] -e 's;$(*F)\.o:;$@ obj_avr/$*.o obj_avr/$*.E $*.s:;' \
-e 's% [^ ]*/gcc-lib/[^ ]*\.h%%g'
endef
# Here is how to make .d files from .c files
obj_avr/%.d: %.c ; @ $(make-deps)
obj_avr/%.d: %.S ; @ $(make-deps)
define make-deps-sim
echo "checking dependencies for $<"
if [ ! -d obj_sim ]; then mkdir obj_sim ; fi
set -e; $(HOSTCC) $(SIM_CFLAGS) -M -MM $< | \
sed > [email protected] -e 's;$(*F)\.o:;$@ obj_sim/$*.o obj_sim/$*.E $*.s:;' \
-e 's% [^ ]*/gcc-lib/[^ ]*\.h%%g'
endef
obj_sim/%.d: %.c ; @ $(make-deps-sim)