]> rtime.felk.cvut.cz Git - omk.git/blob - snippets/include.omk
wvtest: Output "Test function header"
[omk.git] / snippets / include.omk
1 # LN_HEADERS       .. if "y", header files are symbolicaly linked instead of copied.
2 ifeq ($(OMK_VERBOSE),1)
3 CPHEADER_FLAGS += -v
4 LNHEADER_FLAGS += -v
5 endif
6
7 ifneq ($(LN_HEADERS),y)
8 define cp_cmd
9 if ! cmp --quiet $(1) $(2); then \
10     echo "  CP      $(1:$(OUTPUT_DIR)/%=%) -> $(2:$(OUTPUT_DIR)/%=%)"; \
11     install -D $(CPHEADER_FLAGS) $(1) $(2) || exit 1; \
12 fi
13 endef
14 else
15 define cp_cmd
16 if ! cmp --quiet $(1) $(2); then \
17     echo "  LN      $(1:$(OUTPUT_DIR)/%=%) -> $(2:$(OUTPUT_DIR)/%=%)"; \
18     if [ -f $(1) ]; then d=$(2); mkdir -p $${d%/*} && ln -sf $(LNHEADER_FLAGS) $(1) $(2) || exit 1; else exit 1; fi; \
19 fi
20 endef
21 endif
22
23 # TODO: Check modification date of changed header files. If it is
24 # newer that in source dir, show a warning.
25
26 # Syntax: $(call include-pass-template,<include dir>,<keyword>)
27 define include-pass-template
28 include-pass-local: include-pass-local-$(2)
29 include-pass-local-$(2): $$($(2)_GEN_HEADERS) $$(foreach f,$$(renamed_$(2)_GEN_HEADERS),$$(shell f='$$(f)'; echo $$$${f%->*}))
30         @$$(foreach f, $$($(2)_HEADERS),$$(call cp_cmd,$$(SOURCES_DIR)/$$(f),$(1)/$$(notdir $$(f))); )
31 # FIXME: Use correct build dir, then document it (in the line bellow)
32         @$$(foreach f, $$($(2)_GEN_HEADERS),$$(call cp_cmd,$$(LOCAL_BUILD_DIR)/$$(f),$(1)/$$(notdir $$(f))); )
33         @$$(foreach f, $$(nobase_$(2)_HEADERS), $$(call cp_cmd,$$(SOURCES_DIR)/$$(f),$(1)/$$(f)); )
34         @$$(foreach f, $$(renamed_$(2)_HEADERS), \
35            f='$$(f)'; srcfname=$$$${f%->*}; destfname=$$$${f#*->}; \
36            $$(call cp_cmd,$$(SOURCES_DIR)/$$$${srcfname},$(1)/$$$${destfname}); )
37         @$$(foreach f, $$(renamed_$(2)_GEN_HEADERS), \
38            f='$$(f)'; srcfname=$$$${f%->*}; destfname=$$$${f#*->}; \
39            $$(call cp_cmd,$$(LOCAL_BUILD_DIR)/$$$${srcfname},$(1)/$$$${destfname}); )
40 # Suppress "Nothing to be done for `include-pass-local'" message if no headers are defined in Makefile.omk
41         @$$(if $$($(2)_HEADERS)$$($(2)_GEN_HEADERS)$$(nobase_$(2)_HEADERS)$$(renamed_$(2)_HEADERS)$$(renamed_$(2)_GEN_HEADERS),,true)
42 endef