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