87 ifneq ($(BINCOPYDIRS),) |
90 ifneq ($(BINCOPYDIRS),) |
88 RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
91 RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
89 endif |
92 endif |
90 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
93 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
91 |
94 |
|
95 ################################################################################ |
|
96 # Correct dependency information when a header file can't be found. |
|
97 # If the c preprocessor can't find a dependency it appears as it did in the #include statement |
|
98 # e.g. "filename.mbg" or "filename.rsg" in the dependency file. |
|
99 ifneq ($(NO_DEPEND_GENERATE),) |
|
100 # This version minimises the size of dependency files, to contain only .mbg and .rsg deps. |
|
101 # It allows resources to be built in the right order but doesn't impose the weight of |
|
102 # of full dependency information which can overwhelm make in large builds. |
|
103 # The strategy is filter lines which don't have .rsg or .mbg dependencies in them and |
|
104 # to sift each line to leave out non-relevant things like other header files, .hrh |
|
105 # files etc. In the end don't print anything at all if we did not find the target. |
|
106 |
|
107 define DEPENDENCY_CORRECTOR |
|
108 { $(DEPCRUNCH) --extensions rsg,mbg --assume '$(EPOCROOT)/epoc32/include' ; } |
|
109 endef |
|
110 |
|
111 else |
|
112 # This can correct the dependencies by assuming that the file will be in epoc32\include as this is the default |
|
113 DEPENDENCY_CORRECTOR:=$(GNUSED) -r 's% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig' |
|
114 endif |
|
115 |
92 ############################################################################### |
116 ############################################################################### |
93 |
117 # Include all the macros - but not if it has been done already |
94 |
118 |
95 define preprocessresource |
119 ifeq ($(include_resource_mk),) |
96 # $1 is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
120 include_resource_mk:=1 |
97 # $2 is the LANGUAGE (eg. sc or 01 or 02 ...) |
121 |
98 # $3 is the "primary" language on which all the others depend |
122 include $(FLMHOME)/resource.mk |
99 |
123 |
100 ifeq ($(TARGET_$(call sanitise,$1)),) |
124 endif |
101 TARGET_$(call sanitise,$1):=1 |
125 |
102 $(if $(FLMDEBUG),$$(info <debug>preprocessresource: $1 LANG:$2 dep $3</debug>)) |
126 ############################################################################### |
103 |
127 ## Generate a string of resourcefiles optionally with a header OR |
104 |
128 ## just a header (HEADERONLY) |
105 # Correct dependency information when a header file can't be found. |
129 |
106 # If the c preprocessor can't find a dependency it appears as it did in the #include statement |
130 |
107 # e.g. "filename.mbg" or "filename.rsg" in the dependency file. |
131 ifeq ($(HEADERONLY),) # i.e IF NOT HEADERONLY |
108 |
132 |
109 ifneq ($(NO_DEPEND_GENERATE),) |
133 # The resources that are not for the "HEADER language" will all depend on |
110 # This version minimises the size of dependency files, to contain only .mbg and .rsg deps. |
134 # that "headlang resource" - they will "sit in its dependency slipstream" |
111 # It allows resources to be built in the right order but doesn't impose the weight of |
135 # or in other words We only have to make one dependency file because |
112 # of full dependency information which can overwhelm make in large builds. |
136 # all of the other languages will benefit from it indirectly through their |
113 # The strategy is filter lines which don't have .rsg or .mbg dependencies in them and |
137 # dependency on the header language. |
114 # to sift each line to leave out non-relevant things like other header files, .hrh |
138 |
115 # files etc. In the end don't print anything at all if we did not find the target. |
139 # The guard is based on the languages we're building so that 2 resource blocks can |
116 |
140 # create different languages if so needed (no known reason for this but someone |
117 define DEPENDENCY_CORRECTOR |
141 # could do it and in the past it would have worked). |
118 { $(DEPCRUNCH) --extensions rsg,mbg --assume '$$$$(EPOCROOT)/epoc32/include' ; } |
142 GUARD:=TARGET_$(call sanitise,$(INTERBASE_TMP)) |
119 endef |
143 $(if $(FLMDEBUG),$(info <debug>resource.flm: $(GUARD)=$($(GUARD)) LANGUAGES:=$(LANGUAGES)</debug>)) |
120 |
144 |
121 else |
145 # Don't generate new rules for languages we've already seen for this resource file |
122 # This can correct the dependencies by assuming that the file will be in epoc32\include as this is the default |
146 # i.e. this allows one to define a single resource using two startresource blocks. |
123 DEPENDENCY_CORRECTOR:=$(GNUSED) -r 's% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig' |
147 # each of which specifies one half of the languages. |
124 endif |
148 REMAINING_LANGUAGES:=$(filter-out $($(GUARD)),$(LANGUAGES)) |
125 |
149 $(if $(FLMDEBUG),$(info <debug>resource.flm: REMAINING_LANGUAGES=$(REMAINING_LANGUAGES)</debug>)) |
126 |
150 |
127 ifeq "$1" "$3" |
151 ifneq ($(REMAINING_LANGUAGES),) |
128 RESOURCE_DEPS:: $1.d |
152 $(GUARD):=$($(GUARD)) $(REMAINING_LANGUAGES) |
129 |
153 |
130 $1.d: $(SOURCE) |
154 LANGUAGES:=$(REMAINING_LANGUAGES) |
131 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
155 |
132 $(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\ |
156 # PRIMARYFILE is the resource that will have a dependency file and that all the other |
133 $(CPPOPT) $(SOURCE) -M -MG -MT"$1" | \ |
157 # resources will depend on. |
134 $$(DEPENDENCY_CORRECTOR) >$$@ \ |
158 PRIMARYFILE:=$(INTERBASE_TMP).r$(HEADLANG) |
135 $(call endrule,resourcedependencies) |
159 DEPENDFILENAME:=$(INTERBASE_TMP).r$(HEADLANG).d |
136 |
160 $(if $(FLMDEBUG),$(info <debug>resource.flm: in guard with primary file=$(PRIMARYFILE)</debug>)) |
137 $1 : $1.d |
161 |
138 |
162 ifeq "$(MAKEFILE_GROUP)" "RESOURCE_DEPS" |
|
163 # Generate PRIMARYFILE's dependencies |
|
164 $(eval $(call resource.deps,$(INTERBASE_TMP).r$(HEADLANG),$(HEADLANG),$(DEPENDFILENAME))) |
139 else |
165 else |
140 $1 : $3 |
166 RESOURCE:: $(PRIMARYFILE) |
141 endif |
167 |
142 |
168 # invoke the macro that creates targets for building resources, once per language |
143 $1: |
169 # For sc we generate $(INTERBASE_TMP).rsc and define LANGUAGE_SC and LANGUAGE_sc. |
144 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
170 $(foreach L,$(LANGUAGES),$(eval $(call resource.build,$(INTERBASE_TMP).r$(L),$(L),$(TARGET_lower).r$(L)))) |
145 $(GNUCPP) -C -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\ |
171 |
146 $(CPPOPT) $(SOURCE) -o $$@ \ |
172 |
147 $(call endrule,resourcepreprocess) |
173 DEPENDFILE:=$(wildcard $(DEPENDFILENAME)) |
148 endif |
174 ifneq "$(DEPENDFILE)" "" |
149 |
175 ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
150 CLEANTARGETS:= $$(CLEANTARGETS) $1 |
176 -include $(DEPENDFILE) |
151 |
|
152 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
|
153 ifeq "$1" "$3" |
|
154 $(eval DEPENDFILENAME:=$1.d) |
|
155 $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
|
156 |
|
157 CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
|
158 ifneq "$(DEPENDFILE)" "" |
|
159 ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
|
160 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
|
161 -include $(DEPENDFILE) |
|
162 endif |
177 endif |
163 endif |
178 endif |
164 endif |
179 |
165 endif |
180 endif |
166 |
|
167 endif |
181 endif |
168 endef # preprocessresource # |
182 ifneq "$(MAKEFILE_GROUP)" "RESOURCE_DEPS" |
169 |
183 # Whether or not we have generated this resource for some other start |
170 ############################################################################### |
184 # resource block, check if there are any new copies to be made for |
171 define copyresource |
185 # this variant. e.g. winscw requires that we make some extra copies. |
172 # $(1) is the source |
186 # We tried to copy after running rcomp itself but we still need these |
173 # $(2) is the space separated list of destinations which must be filenames |
187 # targets for the sake of dependencies or, for example, if someone |
174 |
188 # merely adds a new copy when the resource is up-to-date |
175 RELEASABLES:=$$(RELEASABLES) $(2) |
189 $(foreach L,$(LANGUAGES),$(eval $(call resource.makecopies,$(INTERBASE_TMP).r$(L),$(TARGET_lower).r$(L)))) |
176 |
190 |
177 $(info <finalcopy source='$1'>$2</finalcopy>) |
191 endif |
178 |
192 else |
179 endef # copyresource # |
193 # |
180 |
194 # HEADERONLY was specified |
181 ############################################################################### |
195 # |
182 define generateresource |
196 GUARD:=TARGET_$(call sanitise,$(INTERBASE_TMP))_rsg |
183 |
197 $(if $(FLMDEBUG),$(info <debug>resource.flm: Headeronly $(INTERBASE_TMP) $(TARGET_lower).rsg LANGUAGES:=$(LANGUAGES)</debug>)) |
184 # $(1) is the intermediate resource filename with path e.g. /a/b/resource.rsc |
198 |
185 # $(2) is the preprocessed resource to make it from |
199 ifeq ($($(GUARD)),) |
186 # $(3) is the language e.g. sc or 01 or 02 |
200 $(GUARD):=1 |
187 # $(4) is the target resource filename without path |
201 $(eval $(call resource.headeronly,$(INTERBASE_TMP),$(HEADLANG))) |
188 |
202 # The headeronly macro manages dependency including on its own |
189 |
203 endif |
190 ifeq ($(TARGET_$(call sanitise,$1)),) |
204 |
191 TARGET_$(call sanitise,$1):=1 |
205 endif |
192 |
206 |
193 $(if $(FLMDEBUG),$(info <debug>generateresource: $(1) from $(2) LANG:$(3)</debug>),) |
207 ifneq "$(MAKEFILE_GROUP)" "RESOURCE_DEPS" |
194 $(if $(FLMDEBUG),$(info <debug>generateresource: copies: $(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS)))</debug>)) |
208 # Add header to releasables anyway despite guard since sone things |
195 |
209 # like the abldcache want to see the rsg for each platform even |
196 CLEANTARGETS:=$$(CLEANTARGETS) $(1) |
210 # if we only declare one rule. |
197 |
211 # If there's no header then it will be blank which is fine. |
198 RESOURCE:: $(1) |
212 RELEASABLES:=$(RELEASABLES) $(RESOURCEHEADER) |
199 |
213 endif |
200 $(1): $(2) $(RCOMP) |
214 |
201 $(call startrule,resourcecompile,FORCESUCCESS) \ |
215 |
202 $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) \ |
|
203 $(call endrule,resourcecompile) |
|
204 |
|
205 endif |
|
206 |
|
207 # Whether or not we have generated this resource for some other variant, check if there |
|
208 # are any new copies to be made for this variant. e.g. winscw requires that we make |
|
209 # some extra copies. We tried to copy after running rcomp itself but we still need these |
|
210 # targets for the sake of dependencies or, for example, if someone merely adds a new copy |
|
211 # when the resource is up-to-date |
|
212 |
|
213 $(call copyresource,$1,$(sort $(patsubst %,%/$4,$(RSCCOPYDIRS)))) |
|
214 |
|
215 |
|
216 # individual source file compilation |
|
217 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
|
218 |
|
219 endef # generateresource |
|
220 |
|
221 |
|
222 ############################################################################### |
|
223 define generateresourceheader |
|
224 # $(1) is the resource header (eg. /epoc32/include/a.rsg) |
|
225 # $(2) is the preprocessed resource to make it from |
|
226 # $(3) is the language to use (eg. sc) |
|
227 |
|
228 RELEASABLES:= $$(RELEASABLES) $(1) |
|
229 |
|
230 ifeq ($(TARGET_$(call sanitise,$1)),) |
|
231 TARGET_$(call sanitise,$1):=1 |
|
232 $(if $(FLMDEBUG),$(info <debug>resourceheader: $(1) from $(2) LANG:$(3)</debug>)) |
|
233 |
|
234 RESOURCE:: $(1) |
|
235 |
|
236 $(1): $(2) $(RCOMP) |
|
237 $(call startrule,resourceheader,FORCESUCCESS) \ |
|
238 $(RCOMP) -m045,046,047 -u -h$(1) -s$(2) \ |
|
239 $(call endrule,resourceheader) |
|
240 |
|
241 endif |
|
242 |
|
243 |
|
244 # individual source file compilation |
|
245 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
|
246 |
|
247 endef |
|
248 |
|
249 ############################################################################### |
|
250 ## call the generator |
|
251 |
|
252 # We always create at least the header |
|
253 # even if we sometimes don't create the resources |
|
254 ifneq ($(RESOURCEHEADER),) |
|
255 $(eval $(call generateresourceheader,$(RESOURCEHEADER),$(INTERBASE_TMP)_$(HEADLANG).rpp,$(HEADLANG))) |
|
256 endif |
|
257 |
|
258 # The one on which the others will depend i.e. they will |
|
259 # "sit in it's dependency slipstream" or in other words |
|
260 # We only have to make one dependency file because all of |
|
261 # the other languages will benefit from the dependency file |
|
262 # belonging to this language. |
|
263 PRIMARYRPPFILE:=$(INTERBASE_TMP)_$(HEADLANG).rpp |
|
264 ifeq ($(HEADERONLY),) |
|
265 # generate a resource file for each language |
|
266 # For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc. |
|
267 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE_TMP)_$(L).rpp,$(L),$(PRIMARYRPPFILE)))) |
|
268 |
|
269 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
|
270 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(INTERBASE_TMP).r$(L),$(INTERBASE_TMP)_$(L).rpp,$(L),$(TARGET_lower).r$(L)))) |
|
271 endif |
|
272 else |
|
273 # No resources are going to be made so unless we specifically ask for it, there will be no |
|
274 # preprocessed file from which to create the header: |
|
275 |
|
276 $(eval $(call preprocessresource,$(INTERBASE_TMP)_$(HEADLANG).rpp,$(HEADLANG),$(PRIMARYRPPFILE))) |
|
277 |
|
278 endif |
|
279 |
216 |
280 ############################################################################### |
217 ############################################################################### |
281 ## .rfi generation in support of the gccxml build |
218 ## .rfi generation in support of the gccxml build |
282 ## Note that .rfi files are created from the dependency files generated from preprocessing resources to create .rpp files |
219 ## Note that .rfi files are created from the dependency files generated from preprocessing resources to create .rpp files |
283 ifneq ($(RFIFILE),) |
220 ifneq ($(RFIFILE),) |
284 RESOURCE:: $(RFIFILE) |
221 RESOURCE:: $(RFIFILE) |
285 RELEASABLES:=$(RELEASABLES) $(RFIFILE) |
222 RELEASABLES:=$(RELEASABLES) $(RFIFILE) |
286 CREATABLEPATHS:=$(CREATABLEPATHS) $(dir $(RFIFILE))/ |
223 CREATABLEPATHS:=$(CREATABLEPATHS) $(dir $(RFIFILE))/ |
287 |
224 |
288 RPPFILES:=$(foreach L,$(LANGUAGES:SC=sc),$(INTERBASE_TMP)_$(L).rpp) |
225 $(eval $(call generaterfifile,$(RFIFILE),$(PRIMARYFILE).d)) |
289 $(eval $(call generaterfifile,$(RFIFILE),$(RPPFILES),$(PRIMARYRPPFILE).d)) |
|
290 endif |
226 endif |
291 |
227 |
292 |
228 |
293 ## Clean up |
229 ## Clean up |
294 $(call raptor_clean,$(CLEANTARGETS)) |
230 $(call raptor_clean,$(CLEANTARGETS)) |
295 # make the output directories while reading makefile - some build engines prefer this |
231 # make the output directories while reading makefile - some build engines prefer this |
296 $(call makepath,$(CREATABLEPATHS)) |
232 $(call makepath,$(CREATABLEPATHS)) |
297 |
233 |
298 # for the --what option and the log file |
234 # for the --what option and the log file |
299 RELEASABLES:=$(RELEASABLES) $(DESTRPP) $(INFOFILE) |
|
300 $(call raptor_release,$(RELEASABLES),RESOURCE) |
235 $(call raptor_release,$(RELEASABLES),RESOURCE) |
301 |
236 |