-$(INSTALL_KF_MD_LCL_GEN_FILES): $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MD_DIR)/% : %
- @true echo Installing $< in $(dir $@)
- $(_v)[ -d $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MD_DIR) ] ||$(MKDIR) $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MD_DIR); \
- filename=`$(BASENAME) $<`; \
- filename_strip=$(addsuffix .strip,$${filename}); \
- $(RM) $(RMFLAGS) $@; \
- [ -d ./kpincdir ] || $(MKDIR) ./kpincdir; \
- echo garbage > ./kpincdir/$${filename_strip}; \
- $(UNIFDEF) $(KPINCFRAME_UNIFDEF) \
- $< > ./kpincdir/$${filename} || \
- $(DECOMMENT) ./kpincdir/$${filename} r > \
- ./kpincdir/$${filename_strip}; \
- if [ -s ./kpincdir/$${filename_strip} ]; \
- then ( \
- $(INSTALL) $(INSTALL_FLAGS) ./kpincdir/$${filename} $(dir $@);\
- ); \
- else \
- echo Header file $< not exported; \
- fi;
-
-setup_installhdrs_mi:
-
-do_installhdrs_mi: $(INSTALL_MI_GEN_FILES) $(INSTALL_MI_GEN_LCL_FILES) $(INSTALL_KF_MI_GEN_FILES) $(INSTALL_KF_MI_LCL_GEN_FILES)
- @true echo "[ $(SOURCE) ] make do_installhdrs_mi $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
- $(_v)$(MKDIR) ./incmidir ./pincmidir ./kincmidir ./kpincmidir; \
- if [ -n "$(strip $(INSTALL_MI_LIST))" ]; then \
- if [ -d $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR) ]; then \
- (cd $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_MI_LIST) ); \
- else \
- $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
- fi; \
- for j in $(INSTALL_MI_LIST); \
- do \
- echo garbage > ./incmidir/$$j.strip; \
- $(UNIFDEF) $(SINCFRAME_UNIFDEF) \
- $(SOURCE)/$$j > ./incmidir/$$j || \
- $(DECOMMENT) ./incmidir/$$j r > \
- ./incmidir/$$j.strip; \
- if [ -s ./incmidir/$$j.strip ]; \
- then ( \
- $(INSTALL) $(INSTALL_FLAGS) ./incmidir/$$j $(DSTROOT)/$(INCDIR)/$(INSTALL_MI_DIR); \
- ); \
- else \
- echo Header file $$j not exported; \
- fi; \
- done; \
- fi; \
- if [ -n "$(strip $(INSTALL_MI_LCL_LIST))" ]; then \
- if [ -d $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR) ]; then \
- (cd $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_MI_LCL_LIST) ); \
- else \
- $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
- fi; \
- for j in $(INSTALL_MI_LCL_LIST); \
- do \
- echo garbage > ./pincmidir/$$j.strip; \
- $(UNIFDEF) $(SPINCFRAME_UNIFDEF) \
- $(SOURCE)/$$j > ./pincmidir/$$j || \
- $(DECOMMENT) ./pincmidir/$$j r > \
- ./pincmidir/$$j.strip; \
- if [ -s ./pincmidir/$$j.strip ]; \
- then ( \
- $(INSTALL) $(INSTALL_FLAGS) ./pincmidir/$$j $(DSTROOT)/$(LCLDIR)/$(INSTALL_MI_DIR); \
- ); \
- else \
- echo Header file $$j not exported; \
- fi; \
- done; \
- fi; \
- if [ -n "$(strip $(INSTALL_KF_MI_LIST))" ]; then \
- if [ -d $(DSTROOT)/$(KINCDIR)/$(EXPORT_MI_DIR) ]; then \
- (cd $(DSTROOT)/$(KINCDIR)/$(EXPORT_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_KF_MI_LIST) ); \
- else \
- $(MKDIR) $(DSTROOT)/$(KINCDIR)/$(EXPORT_MI_DIR); \
- fi; \
- for j in $(INSTALL_KF_MI_LIST); \
- do \
- echo garbage > ./kincmidir/$$j.strip; \
- $(UNIFDEF) $(KINCFRAME_UNIFDEF) \
- $(SOURCE)/$$j > ./kincmidir/$$j || \
- $(DECOMMENT) ./kincmidir/$$j r > \
- ./kincmidir/$$j.strip; \
- if [ -s ./kincmidir/$$j.strip ]; \
- then ( \
- $(INSTALL) $(INSTALL_FLAGS) ./kincmidir/$$j $(DSTROOT)/$(KINCDIR)/$(EXPORT_MI_DIR); \
- ); \
- else \
- echo Header file $$j not exported; \
- fi; \
- done; \
- fi; \
- if [ -n "$(strip $(INSTALL_KF_MI_LCL_LIST))" ]; then \
- if [ -d $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MI_DIR) ]; then \
- (cd $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MI_DIR);$(RM) $(RMFLAGS) $(INSTALL_KF_MI_LCL_LIST) ); \
- else \
- $(MKDIR) $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MI_DIR); \
- fi; \
- for j in $(INSTALL_KF_MI_LCL_LIST); \
- do \
- echo garbage > ./kpincmidir/$$j.strip; \
- $(UNIFDEF) $(KPINCFRAME_UNIFDEF) \
- $(SOURCE)/$$j > ./kpincmidir/$$j || \
- $(DECOMMENT) ./kpincmidir/$$j r > \
- ./kpincmidir/$$j.strip; \
- if [ -s ./kpincmidir/$$j.strip ]; \
- then ( \
- $(INSTALL) $(INSTALL_FLAGS) ./kpincmidir/$$j $(DSTROOT)/$(KPINCDIR)/$(EXPORT_MI_DIR); \
- ); \
- else \
- echo Header file $$j not exported; \
- fi; \
- done; \
- fi; \
- $(RM) -rf ./incmidir ./pincmidir ./kincmidir ./kpincmidir;
-
-setup_installhdrs_md:
-
-do_installhdrs_md: $(INSTALL_MD_GEN_INC_FILES) $(INSTALL_MD_GEN_LCL_FILES) $(INSTALL_KF_MD_GEN_FILES) $(INSTALL_KF_MD_LCL_GEN_FILES)
- @true echo "[ $(SOURCE) ] make do_installhdrs_md $(KERNEL_CONFIG) $(ARCH_CONFIG) $(TARGET)"
- $(_v)$(MKDIR) ./incdir ./pincdir ./kincdir ./kpincdir; \
- if [ -n "$(strip $(INSTALL_MD_LIST))" ]; then \
- if [ -d $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR) ]; then \
- (cd $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR);$(RM) $(RMFLAGS) $(INSTALL_MD_LIST) ); \
- else \
- $(MKDIR) $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
- fi; \
- for j in $(INSTALL_MD_LIST); \
- do \
- echo garbage > ./incdir/$$j.strip; \
- $(UNIFDEF) $(SINCFRAME_UNIFDEF) \
- $(SOURCE)/$$j > ./incdir/$$j || \
- $(DECOMMENT) ./incdir/$$j r > \
- ./incdir/$$j.strip; \
- if [ -s ./incdir/$$j.strip ]; \
- then ( \
- $(INSTALL) $(INSTALL_FLAGS) ./incdir/$$j $(DSTROOT)/$(INCDIR)/$(INSTALL_MD_DIR); \
- ); \
- else \
- echo Header file $$j not exported; \
- fi; \
- done; \
- fi; \
- if [ -n "$(strip $(INSTALL_MD_LCL_LIST))" ]; then \
- if [ -d $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR) ]; then \
- (cd $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR);$(RM) $(RMFLAGS) $(INSTALL_MD_LCL_LIST) ); \
- else \
- $(MKDIR) $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
- fi; \
- for j in $(INSTALL_MD_LCL_LIST); \
- do \
- echo garbage > ./pincdir/$$j.strip; \
- $(UNIFDEF) $(SPINCFRAME_UNIFDEF) \
- $(SOURCE)/$$j > ./pincdir/$$j || \
- $(DECOMMENT) ./pincdir/$$j r > \
- ./pincdir/$$j.strip; \
- if [ -s ./pincdir/$$j.strip ]; \
- then ( \
- $(INSTALL) $(INSTALL_FLAGS) ./pincdir/$$j $(DSTROOT)/$(LCLDIR)/$(INSTALL_MD_DIR); \
- ); \
- else \
- echo Header file $$j not exported; \
- fi; \
- done; \
+# $(1) is the list of install paths
+# $(2) is "1" if it's a "GEN"-style rule that looks locally, or else $(SOURCE)
+# $(3) is the local temp directory for processing
+# $(4) is the unifdef flags
+#
+# $$$$$$$$ is a double-escaped "$$" to represent the current pid
+# of the shell process for creating uniquely named temporary files
+
+define INSTALLHDRS_RULE_template
+
+.PHONY: $(3)_MKDIR
+
+$(3)_MKDIR:
+ $$(_v)$$(MKDIR) ./$(3)
+ $$(_v)$$(MKDIR) $(dir $(firstword $(1)))
+
+# Rebuild if unifdef flags change
+$(1): $(3)/.UNIFDEF_FLAGS
+$(3)/.UNIFDEF_FLAGS: ALWAYS | $(3)_MKDIR
+ $$(_v)$$(REPLACECONTENTS) $$@ $$(UNIFDEF) $(4)
+
+$(1): $(dir $(firstword $(1)))% : $(if $(2),%,$$(SOURCE)/%) | $(3)_MKDIR
+ $$(call makelog,$$(ColorH)INSTALLHDR$$(Color0) $$(ColorF)$$*$$(Color0))
+ $$(_v)$$(UNIFDEF) $(4) $$< > ./$(3)/$$*.unifdef.$$$$$$$$; \
+ if [ $$$$? -eq 2 ]; then \
+ $(ERR) Parse failure for $$<; \
+ exit 1; \