110 |
110 |
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 |
|
116 # We really should be using -iquote with a recent cpp. This is a note for when we do update: |
|
117 #CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
|
118 # -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-iquote $(I) ) $(foreach J,$(SYSTEMINCLUDE),-I $(J) ) |
|
119 |
115 CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
120 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) ) |
121 -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) ) |
117 |
122 |
118 CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH) |
123 CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH) |
119 |
124 |
|
125 # We intend to generate the resource in an intermediate location and copy to the targetpath to |
|
126 # ensure that when the "same" resource is built into separare target paths, it doesn't have to be |
|
127 # completely recreated each time - just copied. |
|
128 RSCCOPYDIRS:=$(RSCDIR) |
|
129 |
120 # additional binary resource copies performed based on BINCOPYDIRS |
130 # additional binary resource copies performed based on BINCOPYDIRS |
121 RSCCOPYDIRS:= |
|
122 ifneq ($(BINCOPYDIRS),) |
131 ifneq ($(BINCOPYDIRS),) |
123 RSCCOPYDIRS:=$(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
132 RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
124 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
133 endif |
125 endif |
134 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
126 |
135 |
127 ############################################################################### |
136 ############################################################################### |
|
137 |
|
138 |
128 define preprocessresource |
139 define preprocessresource |
129 # $(1) is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
140 # $(1) is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
130 # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc) |
141 # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc) |
131 # $(3) is the LANGUAGE (eg. sc or 01 or 02 ...) |
142 # $(3) is the LANGUAGE (eg. sc or 01 or 02 ...) |
132 |
143 |
133 ifeq ($(TARGET_$(call sanitise,$1)),) |
144 ifeq ($(TARGET_$(call sanitise,$1)),) |
134 TARGET_$(call sanitise,$1):=1 |
145 TARGET_$(call sanitise,$1):=1 |
135 $(if $(FLMDEBUG),$(info preprocessresource: $(1) for $(2) LANG:$(3))) |
146 $(if $(FLMDEBUG),$(info <debug>preprocessresource: $(1) for $(2) LANG:$(3)</debug>)) |
|
147 |
|
148 |
|
149 # Correct dependency information when a header file can't be found. |
|
150 # If the c preprocessor can't find a dependency it appears as it did in the #include statement |
|
151 # e.g. "filename.mbg" or "filename.rsg" in the dependency file. |
|
152 # we can correct the dependencies by assuming that the file will be in epoc32\include as this is the default |
|
153 ifneq ($(NO_DEPEND_GENERATE),) |
|
154 # This version minimises the size of dependency files, to contain only .mbg and .rsg deps. |
|
155 # It allows resources to be built in the right order but doesn't impose the weight of |
|
156 # of full dependency information which can overwhelm make in large builds. |
|
157 # The strategy is to filter out lines (apart from the target line which is the first) which don't have .rsg or |
|
158 # .mbg dependencies in them. The first line can sometimes not contain the target but |
|
159 # have a lonely "\" so we use a pattern to recognise the target line in order not to get confused. |
|
160 DEPENDENCY_CORRECTOR:={ $(GNUSED) -n -r '/.*: +.$$$$/ p;\%\.((rsg)|(mbg))%I {s% ([^ \/]+\.((rsg)|(mbg)))% __EPOCROOT\/epoc32\/include\/\1%ig;s% [^_][^_][^E][^ ]+%%g;s%__EPOCROOT%$(EPOCROOT)%g; p}' && echo "" ; } |
|
161 else |
|
162 # Generate full dependency information |
|
163 DEPENDENCY_CORRECTOR:=$(GNUSED) -r 's% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig' |
|
164 endif |
|
165 |
136 |
166 |
137 RESOURCE_DEPS:: $(1).d |
167 RESOURCE_DEPS:: $(1).d |
138 $(1).d: $(SOURCE) |
168 $(1).d: $(SOURCE) |
139 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
169 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
140 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
170 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
141 $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \ |
171 $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \ |
142 $(GNUSED) -r 's# ([^ \/]+\.((rsg)|(mbg)))# $(EPOCROOT)\/epoc32\/include\/\1#ig' > $(1).d \ |
172 $$(DEPENDENCY_CORRECTOR) >$$@ \ |
143 $(call endrule,resourcedependencies) |
173 $(call endrule,resourcedependencies) |
144 |
174 |
|
175 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
145 $(1): $(1).d |
176 $(1): $(1).d |
146 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
177 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
147 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
178 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
148 $(CPPOPT) $(SOURCE) -o $$@ \ |
179 $(CPPOPT) $(SOURCE) -o $$@ \ |
149 $(call endrule,resourcepreprocess) |
180 $(call endrule,resourcepreprocess) |
|
181 endif |
150 |
182 |
151 CLEANTARGETS:= $$(CLEANTARGETS) $(1) |
183 CLEANTARGETS:= $$(CLEANTARGETS) $(1) |
152 |
184 |
153 $(eval DEPENDFILENAME:=$(1).d) |
185 $(eval DEPENDFILENAME:=$(1).d) |
154 $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
186 $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
155 |
187 |
156 CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
188 CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
157 ifneq "$(DEPENDFILE)" "" |
189 ifneq "$(DEPENDFILE)" "" |
158 ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
190 ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
159 -include $(DEPENDFILE) |
191 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
|
192 -include $(DEPENDFILE) |
|
193 endif |
160 endif |
194 endif |
161 endif |
195 endif |
162 |
196 |
163 endif |
197 endif |
164 endef # preprocessresource # |
198 endef # preprocessresource # |
192 |
224 |
193 # $(1) is the resource filename e.g. /a/b/resource.rsc |
225 # $(1) is the resource filename e.g. /a/b/resource.rsc |
194 # $(2) is the preprocessed resource to make it from |
226 # $(2) is the preprocessed resource to make it from |
195 # $(3) is the language e.g. sc or 01 or 02 |
227 # $(3) is the language e.g. sc or 01 or 02 |
196 |
228 |
197 RELEASABLES:=$$(RELEASABLES) $(1) |
|
198 |
229 |
199 ifeq ($(TARGET_$(call sanitise,$1)),) |
230 ifeq ($(TARGET_$(call sanitise,$1)),) |
200 TARGET_$(call sanitise,$1):=1 |
231 TARGET_$(call sanitise,$1):=1 |
201 |
232 |
202 $(if $(FLMDEBUG),$(info generateresource: $(1) from $(2) LANG:$(3)),) |
233 $(if $(FLMDEBUG),$(info <debug>generateresource: $(1) from $(2) LANG:$(3)</debug>),) |
203 |
234 $(if $(FLMDEBUG),$(info <debug>generateresource: copies: $(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS)))</debug>)) |
|
235 |
|
236 CLEANTARGETS:=$$(CLEANTARGETS) $(1) |
204 |
237 |
205 RESOURCE:: $(1) |
238 RESOURCE:: $(1) |
206 |
239 |
207 $(1): $(2) $(RCOMP) |
240 $(1): $(2) $(RCOMP) |
208 $(call startrule,resourcecompile,FORCESUCCESS) \ |
241 $(call startrule,resourcecompile,FORCESUCCESS) \ |
209 $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) \ |
242 $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) && \ |
|
243 { $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(GNUCP) $(1) $(F) ; ) } \ |
210 $(call endrule,resourcecompile) |
244 $(call endrule,resourcecompile) |
211 |
245 |
212 endif |
246 endif |
|
247 |
213 # Whether or not we have generated this resource for some other variant, check if there |
248 # 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 |
249 # are any new copies to be made for this variant. e.g. winscw requires that we make |
215 # some extra copies. |
250 # some extra copies. We tried to copy after running rcomp itself but we still need these |
216 |
251 # targets for the sake of dependencies or, for example if someone merely adds a new copy |
|
252 # when the resource is up-to-date |
|
253 |
|
254 $(if $(FLMDEBUG),$(info <debug>resource copies of $(notdir $1) in: $(RSCCOPYDIRS)</debug>)) |
217 $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) |
255 $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) |
218 |
256 |
219 # individual source file compilation |
257 # individual source file compilation |
220 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
258 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
221 |
259 |
259 endif |
297 endif |
260 |
298 |
261 ifeq ($(HEADERONLY),) |
299 ifeq ($(HEADERONLY),) |
262 # generate a resource file for each language |
300 # generate a resource file for each language |
263 # For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc. |
301 # 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)))) |
302 $(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)))) |
303 |
|
304 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
|
305 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(INTERBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L)))) |
|
306 endif |
266 else |
307 else |
267 # No resources are going to be made so unless we specifically ask for it, there will be no |
308 # 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: |
309 # preprocessed file from which to create the header: |
269 |
310 |
270 $(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG))) |
311 $(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG))) |