]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/Makefile.sub1
update
[l4.git] / kernel / fiasco / src / Makefile.sub1
1 # -*- makefile -*-
2
3 # Targets in this Makefile:
4 # - all: Create C++ sources from Preprocess input
5 #
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.
9
10 all: do-all
11
12 BUILD_SOURCES=true
13
14 include $(srcdir)/Makeconf      # also reads srcdir/Makeconf.local
15                                 # and        objdir/Makeconf.local
16 include $(MODULES_FILE)
17 include .Modules.deps
18
19 include $(srcdir)/Makerules.global # also reads objdir/Makerules.local
20
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
24 # fragments.
25 include $(MAKERULES_SUBSYS)
26
27 ALL_STAMPS = $(foreach m, $(GENERATED_MODULES), auto/stamp-$(m).ready)
28
29 .PHONY: do-all
30 do-all: $(ALL_STAMPS)
31
32 #
33 # Auto-created source files
34 #
35
36 .Clean-auto: $(MODULES_FILES) .Modules.deps globalconfig.out
37         rm -f                                                                 \
38         $(filter-out                                                          \
39           $(addprefix auto/,                                                  \
40             $(addsuffix .cc,                                                  \
41               $(foreach mod, $(GENERATED_MODULES), $(call eval_impl,$(mod)))) \
42             $(foreach mod, $(GENERATED_MODULES),                              \
43                            $(mod).h $(mod)_i.h stamp-$(mod).ready)),          \
44           $(wildcard auto/*))
45         touch $@
46
47 define find_ld_emulation
48         emulations=$$(LANG= $(LD) --help |                                \
49                       grep -i "supported emulations:" |                   \
50                       sed -e 's/.*supported emulations: //') ;            \
51         unset found_it;                                                   \
52         for e in $$emulations; do                                         \
53           for c in $(2); do                                               \
54             if [ "$$e" = "$$c" ]; then                                    \
55               echo LD_EMULATION = $$e >> $(1);                            \
56               found_it=1;                                                 \
57               break;                                                      \
58             fi;                                                           \
59           done;                                                           \
60         done;                                                             \
61         if [ "$$found_it" != "1" ]; then                                  \
62           echo "No known ld emulation found"; exit 1;                     \
63         fi
64 endef
65
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."; }      \
84           || echo "unchanged."
85
86 .Host-config: force-the-rule
87         @$(call find_ld_emulation,$@.new,$(LD_EMULATION_CHOICE))
88         @$(MOVE_IF_CHANGE) $@.new $@ || true
89
90 force-the-rule: ;
91
92 $(ALL_STAMPS): $(MODULES_FILES) .Modules.deps globalconfig.out \
93                .Clean-auto .Compiler-config .Host-config
94
95 # Basename of implementation files = Basename of first .cpp file
96 impl_name = $(basename $(firstword $(subst -, ,\
97               $(firstword $(filter %.cpp, $(notdir $(1)))))))
98
99 $(ALL_STAMPS): auto/stamp-%.ready:
100         $(PREP_MESSAGE)
101         @test -e auto || mkdir auto
102         $(VERBOSE)$(PREPROCESS) \
103            $(PREPROCESS_FLAGS) \
104            $(if $(filter $(call impl_name,$^),$(ALWAYS_INLINE)),-i,) \
105            -p auto/new_ \
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 $^))); \
110           do \
111             $(MOVE_IF_CHANGE) auto/new_$$i auto/$$i || true; \
112           done
113         $(OK_MESSAGE)  
114         $(VERBOSE)touch $@
115
116 .PRECIOUS: auto/stamp-%.ready
117 .PRECIOUS: %.cc %.h %_i.h
118