get node children and refs in the same function
[protos/libecoli.git] / mk / ecoli-obj-rules.mk
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright 2015, Olivier MATZ <zer0@droids-corp.org>
3
4 # dump some infos if debug is enabled
5 ifeq ($(D),1)
6 $(call disp_list,------ all-obj,$(all-obj))
7 $(foreach obj,$(all-obj),\
8         $(info,out-$(obj): $(out-$(obj))) \
9         $(call disp_list,pre-$(obj),$(pre-$(obj))) \
10 )
11 $(call disp_list,------ all-iobj,$(all-iobj))
12 $(foreach iobj,$(all-iobj),\
13         $(call disp_list,pre-$(iobj),$(pre-$(iobj))) \
14 )
15 endif
16
17 # if a generated file has the same name than a user target,
18 # generate an error
19 conflicts := $(filter $(all-iobj),$(all-targets))
20 $(if $(conflicts), \
21         $(error Intermediate file has the same names than user targets:\
22                 $(conflicts)))
23
24 # include dependencies and commands files if they exist
25 $(foreach obj,$(all-obj),\
26         $(eval -include $(call depfile,$(obj))) \
27         $(eval -include $(call cmdfile,$(obj))) \
28 )
29 $(foreach iobj,$(all-iobj),\
30         $(eval -include $(call depfile,$(iobj))) \
31         $(eval -include $(call cmdfile,$(iobj))) \
32 )
33
34 # remove duplicates
35 filtered-all-iobj := $(sort $(all-iobj))
36
37 # convert source files to intermediate object file
38 $(filtered-all-iobj): $$(pre-$$@) $$(wildcard $$(dep-$$@)) FORCE
39         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
40         @$(call display_deps,$(pre-$(@)),$@,$(call compile_cmd,$(pre-$(@)),$@),$?)
41         @$(if $(call check_deps,$@,$(call compile_cmd,$(pre-$(@)),$@),$?),\
42                 $(call compile_print_cmd,$(pre-$(@)),$@) && \
43                 $(call compile_cmd,$(pre-$(@)),$@) && \
44                 $(call save_cmd,$(call compile_cmd,$(pre-$(@)),$@),$@) && \
45                 $(call obj-fixdep,$@))
46
47 # remove duplicates
48 filtered-all-obj := $(sort $(all-obj))
49
50 # combine several objects files to one
51 $(filtered-all-obj): $$(pre-$$@) $$(wildcard $$(dep-$$@)) FORCE
52         @[ -d $(dir $@) ] || mkdir -p $(dir $@)
53         @$(call display_deps,$(pre-$(@)),$@,\
54                 $(call combine_cmd,$(pre-$(@)),$@),$?)
55         @$(if $(call check_deps,$@,$(call combine_cmd,$(pre-$(@)),$@),$?),\
56                 $(call combine_print_cmd,$(pre-$(@)),$@) && \
57                 $(call combine_cmd,$(pre-$(@)),$@) && \
58                 $(call save_cmd,$(call combine_cmd,$(pre-$(@)),$@),$@) && \
59                 $(call create_empty_depfile,$@))