3 # Targets in this Makefile:
4 # - all: Create C++ sources from Preprocess input
6 # This Makefile is invoked in a sub-Make from the top-level Makefile
7 # (via Makerules.global) when globalconfig.out, Modules and
8 # .Modules.deps are up-to-date.
14 include $(srcdir)/Makeconf # also reads srcdir/Makeconf.local
15 # and objdir/Makeconf.local
16 include $(MODULES_FILE)
19 include $(srcdir)/Makerules.global # also reads objdir/Makerules.local
21 # Read subsystem Makefile fragments. We do not explicity use any
22 # targets of these fragments in this Makefile, but this include allows
23 # subsystem Makefile fragments to implicitly create more Makefile
25 include $(MAKERULES_SUBSYS)
27 ALL_STAMPS = $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready)
33 # Auto-created source files
36 .Clean-auto: $(MODULES_FILES) .Modules.deps globalconfig.out
41 $(foreach mod, $(GENERATED_MODULES), $(call eval_impl,$(mod)))) \
42 $(foreach mod, $(GENERATED_MODULES), \
43 $(mod).h $(mod)_i.h stamp-$(mod).ready)), \
47 define find_ld_emulation
48 emulations=$$(LANG= $(LD) --help | \
49 grep -i "supported emulations:" | \
50 sed -e 's/.*supported emulations: //') ; \
52 for e in $$emulations; do \
54 if [ "$$e" = "$$c" ]; then \
55 echo LD_EMULATION = $$e >> $(1); \
61 if [ "$$found_it" != "1" ]; then \
62 echo "No known ld emulation found"; exit 1; \
66 # Force that rule to ensure that compiler changes caused by make command line
67 # or system-wide compiler updates are noticed.
68 # Do not use .PHONY, because preprocess would then be triggered everytime.
69 .Compiler-config: force-the-rule
70 @echo -n "Checking compiler config... "
71 @echo "CC = $(CC)" > $@.new
72 @echo "CXX = $(CXX)" >> $@.new
73 @echo "CPPFLAGS = $(CPPFLAGS)" >> $@.new
74 @echo "CFLAGS = $(CFLAGS)" >> $@.new
75 @echo "CXXFLAGS = $(CXXFLAGS)" >> $@.new
76 @echo "OPT_CFLAGS = $(OPT_CFLAGS)" >> $@.new
77 @echo "OPT_CXXFLAGS = $(OPT_CXXFLAGS)" >> $@.new
78 @echo "ASFLAGS = $(ASFLAGS)" >> $@.new
79 @echo "CONFIG_XARCH = $(CONFIG_XARCH)" >> $@.new
80 # If the compiler configuration has changed, remove all dependency
81 # files -- they have just become useless.
82 @$(MOVE_IF_CHANGE) $@.new $@ \
83 && { $(RM) .*.d */.*.d; echo "CHANGED. Recompiling."; } \
86 .Host-config: force-the-rule
87 @$(call find_ld_emulation,$@.new,$(LD_EMULATION_CHOICE))
88 @$(MOVE_IF_CHANGE) $@.new $@ || true
92 $(ALL_STAMPS): $(MODULES_FILES) .Modules.deps globalconfig.out \
93 .Clean-auto .Compiler-config .Host-config
95 # Basename of implementation files = Basename of first .cpp file
96 impl_name = $(basename $(firstword $(subst -, ,\
97 $(firstword $(filter %.cpp, $(notdir $(1)))))))
99 $(ALL_STAMPS): auto/stamp-%.ready:
101 @test -e auto || mkdir auto
102 $(VERBOSE)$(PREPROCESS) \
103 $(PREPROCESS_FLAGS) \
104 $(if $(filter $(call impl_name,$^),$(ALWAYS_INLINE)),-i,) \
106 -e "$(PREPROCESS_PARTS)" -s \
107 -h $* -c $(call impl_name,$^) $(filter %.cpp, $^)
108 @for i in $*.h $(call impl_name,$^)_i.h \
109 $(patsubst %.cpp, %.cc, $(filter %.cpp, $(notdir $^))); \
111 $(MOVE_IF_CHANGE) auto/new_$$i auto/$$i || true; \
116 .PRECIOUS: auto/stamp-%.ready
117 .PRECIOUS: %.cc %.h %_i.h