node_any: check attribute presence
[protos/libecoli.git] / mk / ecoli-ar-vars.mk
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright 2015, Olivier MATZ <zer0@droids-corp.org>
3
4 # ar-y-$(ar) is provided by the user
5 #   $(ar) is the path of the static library, and the variable contains
6 #   the list of sources. Several ar-y-$(ar) can be present.
7
8 # list all ar builds requested by user
9 all-ar := $(patsubst ar-y-%,%,$(filter ar-y-%,$(.VARIABLES)))
10
11 # add them to the list of targets
12 all-targets += $(all-ar)
13
14 # for each ar, create the following variables:
15 #   out-$(ar) = output path of the arcutable
16 #   pre-$(ar) = list of prerequisites for this arcutable
17 # Some source files need intermediate objects, we define these variables
18 # for them too, and add them in a list: $(all-iobj).
19 # Last, we add the generated files in $(all-clean-file).
20 $(foreach ar,$(all-ar),\
21         $(eval out-$(ar) := $(dir $(ar))) \
22         $(eval pre-$(ar) := ) \
23         $(foreach src,$(ar-y-$(ar)), \
24                 $(if $(call is_cc_source,$(src)), \
25                         $(eval iobj := $(call src2iobj,$(src),$(out-$(ar)))) \
26                         $(eval pre-$(iobj) := $(src)) \
27                         $(eval all-iobj += $(iobj)) \
28                         $(eval all-clean-file += $(iobj)) \
29                         $(eval pre-$(ar) += $(iobj)) \
30                 , \
31                 $(if $(call is_obj_source,$(src)),\
32                         $(eval pre-$(ar) += $(src)) \
33                 , \
34                 $(error "unsupported source format: $(src)"))) \
35         )\
36         $(eval all-clean-file += $(ar)) \
37 )
38
39 # link several *.o files into a static libary
40 #   $1: sources (*.o)
41 #   $2: dst (xyz.a)
42 ar_cmd = ar crsD $(2) $(1)
43
44 # print line used to ar object files
45 ifeq ($(V),1)
46 ar_print_cmd = echo $(call protect_quote,$(call ar_cmd,$1,$2))
47 else
48 ar_print_cmd = echo "  AR $(2)"
49 endif
50
51 all-clean-file += $(all-ar)