111 # make the output directories while reading makefile - some build engines prefer this |
111 # make the output directories while reading makefile - some build engines prefer this |
112 $(call makepath,$(INTERBASE)) |
112 $(call makepath,$(INTERBASE)) |
113 |
113 |
114 # common pre-processor options |
114 # common pre-processor options |
115 CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
115 CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
116 -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) ) |
116 -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-iquote $(I) ) $(foreach J,$(SYSTEMINCLUDE),-I $(J) ) |
117 |
117 |
118 CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH) |
118 CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH) |
119 |
119 |
|
120 # We intend to generate the resource in an intermediate locationand copy to the final destination to |
|
121 # ensure that when the "same" resource is built into separare locations it is |
|
122 RSCCOPYDIRS:=$(RSCDIR) |
120 # additional binary resource copies performed based on BINCOPYDIRS |
123 # additional binary resource copies performed based on BINCOPYDIRS |
121 RSCCOPYDIRS:= |
|
122 ifneq ($(BINCOPYDIRS),) |
124 ifneq ($(BINCOPYDIRS),) |
123 RSCCOPYDIRS:=$(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
125 RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
124 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
126 endif |
125 endif |
127 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
126 |
128 |
127 ############################################################################### |
129 ############################################################################### |
|
130 |
|
131 |
128 define preprocessresource |
132 define preprocessresource |
129 # $(1) is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
133 # $(1) is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
130 # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc) |
134 # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc) |
131 # $(3) is the LANGUAGE (eg. sc or 01 or 02 ...) |
135 # $(3) is the LANGUAGE (eg. sc or 01 or 02 ...) |
132 |
136 |
133 ifeq ($(TARGET_$(call sanitise,$1)),) |
137 ifeq ($(TARGET_$(call sanitise,$1)),) |
134 TARGET_$(call sanitise,$1):=1 |
138 TARGET_$(call sanitise,$1):=1 |
135 $(if $(FLMDEBUG),$(info preprocessresource: $(1) for $(2) LANG:$(3))) |
139 $(if $(FLMDEBUG),$(info <debug>preprocessresource: $(1) for $(2) LANG:$(3)</debug>)) |
|
140 |
|
141 |
|
142 # Correct dependency information when a header file can't be found. |
|
143 # If the c preprocessor can't find a dependency it appears as it did in the #include statement |
|
144 # e.g. "filename.mbg" or "filename.rsg" in the dependency file. |
|
145 # we can correct the dependencies by assuming that the file will be in epoc32\include as this is the default |
|
146 ifneq ($(NO_DEPEND_GENERATE),) |
|
147 # This version minimises the size of dependency files, to contain only .mbg and .rsg deps. |
|
148 # It allows resources to be built in the right order but doesn't impose the weight of |
|
149 # of full dependency information which can overwhelm make in large builds. |
|
150 DEPENDENCY_CORRECTOR:={ $(GNUSED) -n -r '1 p;\% [^ \/]+\.((rsg)|(mbg))%I {s% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig; p}' && echo "" ; } |
|
151 else |
|
152 # Generate full dependency information |
|
153 DEPENDENCY_CORRECTOR:=$(GNUSED) -r 's% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig' |
|
154 endif |
|
155 |
136 |
156 |
137 RESOURCE_DEPS:: $(1).d |
157 RESOURCE_DEPS:: $(1).d |
138 $(1).d: $(SOURCE) |
158 $(1).d: $(SOURCE) |
139 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
159 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
140 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
160 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
141 $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \ |
161 $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \ |
142 $(GNUSED) -r 's# ([^ \/]+\.((rsg)|(mbg)))# $(EPOCROOT)\/epoc32\/include\/\1#ig' > $(1).d \ |
162 $(DEPENDENCY_CORRECTOR) >$$@ \ |
143 $(call endrule,resourcedependencies) |
163 $(call endrule,resourcedependencies) |
144 |
164 |
145 $(1): $(1).d |
165 $(1): $(1).d |
146 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
166 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
147 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
167 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
212 endif |
234 endif |
213 # Whether or not we have generated this resource for some other variant, check if there |
235 # Whether or not we have generated this resource for some other variant, check if there |
214 # are any new copies to be made for this variant. e.g. winscw requires that we make |
236 # are any new copies to be made for this variant. e.g. winscw requires that we make |
215 # some extra copies. |
237 # some extra copies. |
216 |
238 |
|
239 $(if $(FLMDEBUG),$(info <debug>resource copies of $(notdir $1) in: $(RSCCOPYDIRS)</debug>)) |
|
240 $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) |
217 $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) |
241 $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) |
218 |
242 |
219 # individual source file compilation |
243 # individual source file compilation |
220 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
244 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
221 |
245 |
259 endif |
283 endif |
260 |
284 |
261 ifeq ($(HEADERONLY),) |
285 ifeq ($(HEADERONLY),) |
262 # generate a resource file for each language |
286 # generate a resource file for each language |
263 # For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc. |
287 # For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc. |
264 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE)_$(L).rpp,$(RESBASE).r$(L),$(L)))) |
288 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE)_$(L).rpp,$(INTERBASE).r$(L),$(L)))) |
265 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(RESBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L)))) |
289 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(INTERBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L)))) |
266 else |
290 else |
267 # No resources are going to be made so unless we specifically ask for it, there will be no |
291 # No resources are going to be made so unless we specifically ask for it, there will be no |
268 # preprocessed file from which to create the header: |
292 # preprocessed file from which to create the header: |
269 |
293 |
270 $(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG))) |
294 $(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG))) |