diff --git a/config/rules.mk b/config/rules.mk index ad748deed7b7..56b51dad8826 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -1227,17 +1227,9 @@ PREF_PPFLAGS = --line-endings=crlf endif ifndef NO_DIST_INSTALL -$(FINAL_TARGET)/$(PREF_DIR): - $(NSINSTALL) -D $@ - -libs:: $(FINAL_TARGET)/$(PREF_DIR) -libs:: $(PREF_JS_EXPORTS) - $(EXIT_ON_ERROR) \ - for i in $^; do \ - dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \ - $(RM) -f $$dest; \ - $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \ - done +PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR) +PREF_JS_EXPORTS_FLAGS := $(PREF_PPFLAGS) +PP_TARGETS += PREF_JS_EXPORTS endif endif @@ -1370,16 +1362,9 @@ endif endif ifdef EXTRA_PP_COMPONENTS -libs:: $(EXTRA_PP_COMPONENTS) ifndef NO_DIST_INSTALL - $(EXIT_ON_ERROR) \ - $(NSINSTALL) -D $(FINAL_TARGET)/components; \ - for i in $^; do \ - fname=`basename $$i`; \ - dest=$(FINAL_TARGET)/components/$${fname}; \ - $(RM) -f $$dest; \ - $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \ - done +EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components +PP_TARGETS += EXTRA_PP_COMPONENTS endif endif @@ -1400,17 +1385,10 @@ endif endif ifdef EXTRA_PP_JS_MODULES -libs:: $(EXTRA_PP_JS_MODULES) ifndef NO_DIST_INSTALL - $(EXIT_ON_ERROR) \ - $(NSINSTALL) -D $(FINAL_TARGET)/modules; \ - for i in $^; do \ - dest=$(FINAL_TARGET)/modules/`basename $$i`; \ - $(RM) -f $$dest; \ - $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \ - done +EXTRA_PP_JS_MODULES_PATH := $(FINAL_TARGET)/modules +PP_TARGETS += EXTRA_PP_JS_MODULES endif - endif ################################################################################ @@ -1481,31 +1459,15 @@ endif endif ifneq ($(DIST_FILES),) -$(DIST)/bin: - $(NSINSTALL) -D $@ - -libs:: $(DIST)/bin -libs:: $(DIST_FILES) - @$(EXIT_ON_ERROR) \ - for f in $^; do \ - dest=$(FINAL_TARGET)/`basename $$f`; \ - $(RM) -f $$dest; \ - $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \ - $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \ - $$f > $$dest; \ - done +DIST_FILES_PATH := $(FINAL_TARGET) +DIST_FILES_FLAGS := $(XULAPP_DEFINES) $(XULPPFLAGS) +PP_TARGETS += DIST_FILES endif ifneq ($(DIST_CHROME_FILES),) -libs:: $(DIST_CHROME_FILES) - @$(EXIT_ON_ERROR) \ - for f in $^; do \ - dest=$(FINAL_TARGET)/chrome/`basename $$f`; \ - $(RM) -f $$dest; \ - $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \ - $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \ - $$f > $$dest; \ - done +DIST_CHROME_FILES_PATH := $(FINAL_TARGET)/chrome +DIST_CHROME_FILES_FLAGS := $(XULAPP_DEFINES) $(XULPPFLAGS) +PP_TARGETS += DIST_CHROME_FILES endif ifneq ($(XPI_PKGNAME),) @@ -1680,6 +1642,37 @@ TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS) endif endif +################################################################################ +# Preprocessing rules +# +# The PP_TARGETS variable contains a list of all preprocessing target +# categories. Each category defines a target path, and optional extra flags +# like the following: +# +# FOO_PATH := target_path +# FOO_FLAGS := -Dsome_flag +# PP_TARGETS += FOO + +# PP_DEP defines preprocessing rules dependencies. +# $(call PP_DEP, source_file, target_path, extra_flags) +define PP_DEP +$(2)/$(notdir $(1)): $(1) $(call mkdir_deps,$(2)) $(GLOBAL_DEPS) +$(2)/$(notdir $(1)): EXTRA_PP_FLAGS := $(3) +PP_FILES += $(2)/$(notdir $(1)) +endef + +$(foreach target,$(PP_TARGETS),\ + $(foreach file,$($(target)),\ + $(eval $(call PP_DEP,$(file),$($(target)_PATH),$($(target)_FLAGS)))\ + )\ + ) + +$(PP_FILES): + $(RM) $@ + $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(EXTRA_PP_FLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $< > $@ + +libs:: $(PP_FILES) + ################################################################################ # Special gmake rules. ################################################################################ diff --git a/js/src/config/rules.mk b/js/src/config/rules.mk index ad748deed7b7..56b51dad8826 100644 --- a/js/src/config/rules.mk +++ b/js/src/config/rules.mk @@ -1227,17 +1227,9 @@ PREF_PPFLAGS = --line-endings=crlf endif ifndef NO_DIST_INSTALL -$(FINAL_TARGET)/$(PREF_DIR): - $(NSINSTALL) -D $@ - -libs:: $(FINAL_TARGET)/$(PREF_DIR) -libs:: $(PREF_JS_EXPORTS) - $(EXIT_ON_ERROR) \ - for i in $^; do \ - dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \ - $(RM) -f $$dest; \ - $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \ - done +PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR) +PREF_JS_EXPORTS_FLAGS := $(PREF_PPFLAGS) +PP_TARGETS += PREF_JS_EXPORTS endif endif @@ -1370,16 +1362,9 @@ endif endif ifdef EXTRA_PP_COMPONENTS -libs:: $(EXTRA_PP_COMPONENTS) ifndef NO_DIST_INSTALL - $(EXIT_ON_ERROR) \ - $(NSINSTALL) -D $(FINAL_TARGET)/components; \ - for i in $^; do \ - fname=`basename $$i`; \ - dest=$(FINAL_TARGET)/components/$${fname}; \ - $(RM) -f $$dest; \ - $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \ - done +EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components +PP_TARGETS += EXTRA_PP_COMPONENTS endif endif @@ -1400,17 +1385,10 @@ endif endif ifdef EXTRA_PP_JS_MODULES -libs:: $(EXTRA_PP_JS_MODULES) ifndef NO_DIST_INSTALL - $(EXIT_ON_ERROR) \ - $(NSINSTALL) -D $(FINAL_TARGET)/modules; \ - for i in $^; do \ - dest=$(FINAL_TARGET)/modules/`basename $$i`; \ - $(RM) -f $$dest; \ - $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \ - done +EXTRA_PP_JS_MODULES_PATH := $(FINAL_TARGET)/modules +PP_TARGETS += EXTRA_PP_JS_MODULES endif - endif ################################################################################ @@ -1481,31 +1459,15 @@ endif endif ifneq ($(DIST_FILES),) -$(DIST)/bin: - $(NSINSTALL) -D $@ - -libs:: $(DIST)/bin -libs:: $(DIST_FILES) - @$(EXIT_ON_ERROR) \ - for f in $^; do \ - dest=$(FINAL_TARGET)/`basename $$f`; \ - $(RM) -f $$dest; \ - $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \ - $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \ - $$f > $$dest; \ - done +DIST_FILES_PATH := $(FINAL_TARGET) +DIST_FILES_FLAGS := $(XULAPP_DEFINES) $(XULPPFLAGS) +PP_TARGETS += DIST_FILES endif ifneq ($(DIST_CHROME_FILES),) -libs:: $(DIST_CHROME_FILES) - @$(EXIT_ON_ERROR) \ - for f in $^; do \ - dest=$(FINAL_TARGET)/chrome/`basename $$f`; \ - $(RM) -f $$dest; \ - $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \ - $(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \ - $$f > $$dest; \ - done +DIST_CHROME_FILES_PATH := $(FINAL_TARGET)/chrome +DIST_CHROME_FILES_FLAGS := $(XULAPP_DEFINES) $(XULPPFLAGS) +PP_TARGETS += DIST_CHROME_FILES endif ifneq ($(XPI_PKGNAME),) @@ -1680,6 +1642,37 @@ TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS) endif endif +################################################################################ +# Preprocessing rules +# +# The PP_TARGETS variable contains a list of all preprocessing target +# categories. Each category defines a target path, and optional extra flags +# like the following: +# +# FOO_PATH := target_path +# FOO_FLAGS := -Dsome_flag +# PP_TARGETS += FOO + +# PP_DEP defines preprocessing rules dependencies. +# $(call PP_DEP, source_file, target_path, extra_flags) +define PP_DEP +$(2)/$(notdir $(1)): $(1) $(call mkdir_deps,$(2)) $(GLOBAL_DEPS) +$(2)/$(notdir $(1)): EXTRA_PP_FLAGS := $(3) +PP_FILES += $(2)/$(notdir $(1)) +endef + +$(foreach target,$(PP_TARGETS),\ + $(foreach file,$($(target)),\ + $(eval $(call PP_DEP,$(file),$($(target)_PATH),$($(target)_FLAGS)))\ + )\ + ) + +$(PP_FILES): + $(RM) $@ + $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(EXTRA_PP_FLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $< > $@ + +libs:: $(PP_FILES) + ################################################################################ # Special gmake rules. ################################################################################