46 RESBASE:=$(RSCDIR)/$(TARGET_lower) |
46 RESBASE:=$(RSCDIR)/$(TARGET_lower) |
47 |
47 |
48 # Ensure that RELEASABLES and CLEANTARGETS cannot expand indefinitely in successive calls to this flm: |
48 # Ensure that RELEASABLES and CLEANTARGETS cannot expand indefinitely in successive calls to this flm: |
49 CLEANTARGETS:= |
49 CLEANTARGETS:= |
50 RELEASABLES:= |
50 RELEASABLES:= |
51 CREATABLEPATHS:= |
|
52 |
51 |
53 # There is only one resource header (.rsg) file and we only |
52 # There is only one resource header (.rsg) file and we only |
54 # make that if we are asked. |
53 # make that if we are asked. |
55 RSGDIR:=$(EPOCROOT)/epoc32/include |
54 RSGDIR:=$(EPOCROOT)/epoc32/include |
56 # If there are multiple LANGUAGES then it is the last one in the list |
|
57 # which produces the header. |
|
58 HEADLANG:=$(lastword $(LANGUAGES:SC=sc)) |
|
59 ifneq ($(or $(HEADER),$(HEADERONLY)),) |
55 ifneq ($(or $(HEADER),$(HEADERONLY)),) |
60 RESOURCEHEADER:=$(RSGDIR)/$(HEADER) |
56 RESOURCEHEADER:=$(RSGDIR)/$(HEADER) |
61 |
57 |
|
58 # If there are multiple LANGUAGES then it is the last one in the list |
|
59 # which produces the header. |
|
60 HEADLANG:=$(lastword $(LANGUAGES:SC=sc)) |
62 else |
61 else |
63 RESOURCEHEADER:= |
62 HEADLANG:= |
|
63 RESOURCEHEADER:= |
64 endif |
64 endif |
65 |
65 |
66 # we create intermediate .rpp and .d files |
66 # we create intermediate .rpp and .d files |
67 INTERBASE_TMP:=$(OUTPUTPATH)/$(TARGET_lower)_$(notdir $(basename $(SOURCE))) |
67 INTERBASE:=$(OUTPUTPATH)/$(TARGET_lower)$(if $(TARGETPATH),_$(subst /,_,$(TARGETPATH)),) |
68 |
68 |
|
69 ################################## localisation ###########################$(GNUMKDIR)############# |
|
70 # Only make copies for full resource builds |
|
71 |
|
72 # Initialise to prevent RELEASABLES spill-over between calls |
|
73 DESTRPP:= |
|
74 INFOFILE:= |
|
75 |
|
76 ifeq ($(HEADERONLY),) |
|
77 |
|
78 RSSBASENAME:=$(call lowercase,$(basename $(notdir $(SOURCE)))) |
|
79 DESTRPP:=$(EPOCROOT)/epoc32/localisation/$(RSSBASENAME)/rsc/$(RSSBASENAME).rpp |
|
80 $(call makepath,$(EPOCROOT)/epoc32/localisation/$(RSSBASENAME)/rsc) |
|
81 |
|
82 INFOFILE:=$(EPOCROOT)/epoc32/localisation/group/$(RSSBASENAME).info |
|
83 # If there are MULTIPLE languages then copy the .rpp for the last one |
|
84 RPPLANG:=$(lastword $(LANGUAGES:SC=sc)) |
|
85 |
|
86 # Copy .rpp files from epoc32/build/ to epoc32/localisation/x/rsc/x.rpp and create .info files in localisation |
|
87 define CreateRppAndInfo |
|
88 |
|
89 ifeq ($(RESOURCE_$(call sanitise,$(SOURCE))),) |
|
90 RESOURCE_$(call sanitise,$(SOURCE)):=1 |
|
91 |
|
92 RESOURCE:: $(DESTRPP) $(INFOFILE) |
|
93 |
|
94 $(DESTRPP): $(INTERBASE)_$(RPPLANG).rpp |
|
95 $(call startrule,rppfilecopy,FORCESUCCESS) \ |
|
96 $(GNUCP) $$< $$@ \ |
|
97 $(call endrule,rppfilecopy) |
|
98 |
|
99 $(INFOFILE):: |
|
100 @if [ ! -d $(EPOCROOT)/epoc32/localisation/group ]; then $(GNUMKDIR) -p $(EPOCROOT)/epoc32/localisation/group; fi |
|
101 @if [ ! -f $$@ ]; then echo "DATADIR: /$(RSSBASENAME)" > $$@ ; fi |
|
102 @echo -e "\n/z$(TARGETPATH)/$(TARGET_lower).rsc : $(RSSBASENAME).rpp" >> $$@ |
|
103 |
|
104 endif |
|
105 endef |
|
106 |
|
107 $(eval $(call CreateRppAndInfo)) |
|
108 endif |
|
109 ################################# end of localisation ################################### |
|
110 |
|
111 # make the output directories while reading makefile - some build engines prefer this |
|
112 $(call makepath,$(INTERBASE)) |
69 |
113 |
70 # common pre-processor options |
114 # common pre-processor options |
71 |
115 CPPOPT:=-nostdinc -undef -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
72 # We really should be using -iquote with a recent cpp. This is a note for when we do update: |
|
73 #CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
|
74 # -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-iquote $(I) ) $(foreach J,$(SYSTEMINCLUDE),-I $(J) ) |
|
75 |
|
76 CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
|
77 -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) ) |
116 -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) ) |
78 |
117 |
79 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCDIR) $(RSGDIR) $(OUTPUTPATH) |
118 CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH) |
80 |
|
81 # We intend to generate the resource in an intermediate location and copy to the targetpath to |
|
82 # ensure that when the "same" resource is built into separare target paths, it doesn't have to be |
|
83 # completely recreated each time - just copied. |
|
84 RSCCOPYDIRS:=$(RSCDIR) |
|
85 |
119 |
86 # additional binary resource copies performed based on BINCOPYDIRS |
120 # additional binary resource copies performed based on BINCOPYDIRS |
|
121 RSCCOPYDIRS:= |
87 ifneq ($(BINCOPYDIRS),) |
122 ifneq ($(BINCOPYDIRS),) |
88 RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
123 RSCCOPYDIRS:=$(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
89 endif |
124 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
90 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
125 endif |
91 |
126 |
92 ############################################################################### |
127 ############################################################################### |
93 |
|
94 |
|
95 define preprocessresource |
128 define preprocessresource |
96 # $1 is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
129 # $(1) is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
97 # $2 is the LANGUAGE (eg. sc or 01 or 02 ...) |
130 # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc) |
98 # $3 is the "primary" language on which all the others depend |
131 # $(3) is the LANGUAGE (eg. sc or 01 or 02 ...) |
99 |
132 |
100 ifeq ($(TARGET_$(call sanitise,$1)),) |
133 ifeq ($(TARGET_$(call sanitise,$1)),) |
101 TARGET_$(call sanitise,$1):=1 |
134 TARGET_$(call sanitise,$1):=1 |
102 $(if $(FLMDEBUG),$$(info <debug>preprocessresource: $1 LANG:$2 dep $3</debug>)) |
135 $(if $(FLMDEBUG),$(info preprocessresource: $(1) for $(2) LANG:$(3))) |
103 |
136 |
104 |
137 RESOURCE_DEPS:: $(1).d |
105 # Correct dependency information when a header file can't be found. |
138 $(1).d: $(SOURCE) |
106 # If the c preprocessor can't find a dependency it appears as it did in the #include statement |
|
107 # e.g. "filename.mbg" or "filename.rsg" in the dependency file. |
|
108 |
|
109 ifneq ($(NO_DEPEND_GENERATE),) |
|
110 # This version minimises the size of dependency files, to contain only .mbg and .rsg deps. |
|
111 # It allows resources to be built in the right order but doesn't impose the weight of |
|
112 # of full dependency information which can overwhelm make in large builds. |
|
113 # The strategy is filter lines which don't have .rsg or .mbg dependencies in them and |
|
114 # to sift each line to leave out non-relevant things like other header files, .hrh |
|
115 # files etc. In the end don't print anything at all if we did not find the target. |
|
116 |
|
117 define DEPENDENCY_CORRECTOR |
|
118 { $(DEPCRUNCH) --extensions rsg,mbg --assume '$$$$(EPOCROOT)/epoc32/include' ; } |
|
119 endef |
|
120 |
|
121 else |
|
122 # This can correct the dependencies by assuming that the file will be in epoc32\include as this is the default |
|
123 DEPENDENCY_CORRECTOR:=$(GNUSED) -r 's% ([^ \/]+\.((rsg)|(mbg)))% $(EPOCROOT)\/epoc32\/include\/\1%ig' |
|
124 endif |
|
125 |
|
126 |
|
127 ifeq "$1" "$3" |
|
128 RESOURCE_DEPS:: $1.d |
|
129 |
|
130 $1.d: $(SOURCE) |
|
131 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
139 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
132 $(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\ |
140 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
133 $(CPPOPT) $(SOURCE) -M -MG -MT"$1" | \ |
141 $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \ |
134 $$(DEPENDENCY_CORRECTOR) >$$@ \ |
142 $(GNUSED) -r 's# ([^ \/]+\.((rsg)|(mbg)))# $(EPOCROOT)\/epoc32\/include\/\1#ig' > $(1).d \ |
135 $(call endrule,resourcedependencies) |
143 $(call endrule,resourcedependencies) |
136 |
144 |
137 $1 : $1.d |
145 $(1): $(1).d |
138 |
|
139 else |
|
140 $1 : $3 |
|
141 endif |
|
142 |
|
143 $1: |
|
144 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
146 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
145 $(GNUCPP) -C -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\ |
147 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
146 $(CPPOPT) $(SOURCE) -o $$@ \ |
148 $(CPPOPT) $(SOURCE) -o $$@ \ |
147 $(call endrule,resourcepreprocess) |
149 $(call endrule,resourcepreprocess) |
148 endif |
150 |
149 |
151 CLEANTARGETS:= $$(CLEANTARGETS) $(1) |
150 CLEANTARGETS:= $$(CLEANTARGETS) $1 |
152 |
151 |
153 $(eval DEPENDFILENAME:=$(1).d) |
152 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
154 $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
153 ifeq "$1" "$3" |
155 |
154 $(eval DEPENDFILENAME:=$1.d) |
156 CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
155 $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
157 ifneq "$(DEPENDFILE)" "" |
156 |
158 ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
157 CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
159 -include $(DEPENDFILE) |
158 ifneq "$(DEPENDFILE)" "" |
|
159 ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
|
160 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
|
161 -include $(DEPENDFILE) |
|
162 endif |
|
163 endif |
|
164 endif |
160 endif |
165 endif |
161 endif |
166 |
162 |
167 endif |
163 endif |
168 endef # preprocessresource # |
164 endef # preprocessresource # |
169 |
165 |
170 ############################################################################### |
166 ############################################################################### |
171 define copyresource |
167 define copyresource |
172 # $(1) is the source |
168 # $(1) is the source |
173 # $(2) is the space separated list of destinations which must be filenames |
169 # $(2) is the destination |
174 |
170 |
175 RELEASABLES:=$$(RELEASABLES) $(2) |
171 RELEASABLES:=$$(RELEASABLES) $(2) |
176 |
172 |
177 $(info <finalcopy source='$1'>$2</finalcopy>) |
173 ifeq ($(TARGET_$(call sanitise,$2)),) |
178 |
174 TARGET_$(call sanitise,$2):=1 |
|
175 |
|
176 RESOURCE:: $2 |
|
177 ## perform additional copies of binaries |
|
178 # |
|
179 # Only certain builds require further copies of the generated resource binaries |
|
180 # |
|
181 $(2): $(1) |
|
182 $(call startrule,resourcecopy,FORCESUCCESS) \ |
|
183 $(GNUCP) $$< $$@ \ |
|
184 $(call endrule,resourcecopy) |
|
185 |
|
186 endif |
|
187 |
179 endef # copyresource # |
188 endef # copyresource # |
180 |
189 |
181 ############################################################################### |
190 ############################################################################### |
182 define generateresource |
191 define generateresource |
183 |
192 |
184 # $(1) is the intermediate resource filename with path e.g. /a/b/resource.rsc |
193 # $(1) is the resource filename e.g. /a/b/resource.rsc |
185 # $(2) is the preprocessed resource to make it from |
194 # $(2) is the preprocessed resource to make it from |
186 # $(3) is the language e.g. sc or 01 or 02 |
195 # $(3) is the language e.g. sc or 01 or 02 |
187 # $(4) is the target resource filename without path |
196 |
188 |
197 RELEASABLES:=$$(RELEASABLES) $(1) |
189 |
198 |
190 ifeq ($(TARGET_$(call sanitise,$1)),) |
199 ifeq ($(TARGET_$(call sanitise,$1)),) |
191 TARGET_$(call sanitise,$1):=1 |
200 TARGET_$(call sanitise,$1):=1 |
192 |
201 |
193 $(if $(FLMDEBUG),$(info <debug>generateresource: $(1) from $(2) LANG:$(3)</debug>),) |
202 $(if $(FLMDEBUG),$(info generateresource: $(1) from $(2) LANG:$(3)),) |
194 $(if $(FLMDEBUG),$(info <debug>generateresource: copies: $(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS)))</debug>)) |
203 |
195 |
|
196 CLEANTARGETS:=$$(CLEANTARGETS) $(1) |
|
197 |
204 |
198 RESOURCE:: $(1) |
205 RESOURCE:: $(1) |
199 |
206 |
200 $(1): $(2) $(RCOMP) |
207 $(1): $(2) $(RCOMP) |
201 $(call startrule,resourcecompile,FORCESUCCESS) \ |
208 $(call startrule,resourcecompile,FORCESUCCESS) \ |
202 $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) \ |
209 $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) \ |
203 $(call endrule,resourcecompile) |
210 $(call endrule,resourcecompile) |
204 |
211 |
205 endif |
212 endif |
206 |
|
207 # Whether or not we have generated this resource for some other variant, check if there |
213 # 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 |
214 # 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 |
215 # some extra copies. |
210 # targets for the sake of dependencies or, for example, if someone merely adds a new copy |
216 |
211 # when the resource is up-to-date |
217 $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) |
212 |
|
213 $(call copyresource,$1,$(sort $(patsubst %,%/$4,$(RSCCOPYDIRS)))) |
|
214 |
|
215 |
218 |
216 # individual source file compilation |
219 # individual source file compilation |
217 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
220 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
218 |
221 |
219 endef # generateresource |
222 endef # generateresource |
250 ## call the generator |
253 ## call the generator |
251 |
254 |
252 # We always create at least the header |
255 # We always create at least the header |
253 # even if we sometimes don't create the resources |
256 # even if we sometimes don't create the resources |
254 ifneq ($(RESOURCEHEADER),) |
257 ifneq ($(RESOURCEHEADER),) |
255 $(eval $(call generateresourceheader,$(RESOURCEHEADER),$(INTERBASE_TMP)_$(HEADLANG).rpp,$(HEADLANG))) |
258 $(eval $(call generateresourceheader,$(RESOURCEHEADER),$(INTERBASE)_$(HEADLANG).rpp,$(HEADLANG))) |
256 endif |
259 endif |
257 |
260 |
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),) |
261 ifeq ($(HEADERONLY),) |
265 # generate a resource file for each language |
262 # generate a resource file for each language |
266 # For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc. |
263 # 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)))) |
264 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE)_$(L).rpp,$(RESBASE).r$(L),$(L)))) |
268 |
265 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(RESBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L)))) |
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 |
266 else |
273 # No resources are going to be made so unless we specifically ask for it, there will be no |
267 # 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: |
268 # preprocessed file from which to create the header: |
275 |
269 |
276 $(eval $(call preprocessresource,$(INTERBASE_TMP)_$(HEADLANG).rpp,,$(HEADLANG),$(PRIMARYRPPFILE))) |
270 $(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG))) |
277 |
271 |
278 endif |
272 endif |
279 |
273 |
280 ############################################################################### |
274 ############################################################################### |
281 ## .rfi generation in support of the gccxml build |
275 ## .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 |
276 ## Note that .rfi files are created from the dependency files generated from preprocessing resources to create .rpp files |
283 ifneq ($(RFIFILE),) |
277 ifneq ($(RFIFILE),) |
284 RESOURCE:: $(RFIFILE) |
278 RESOURCE:: $(RFIFILE) |
285 RELEASABLES:=$(RELEASABLES) $(RFIFILE) |
279 RELEASABLES:=$(RELEASABLES) $(RFIFILE) |
286 CREATABLEPATHS:=$(CREATABLEPATHS) $(dir $(RFIFILE))/ |
280 CREATABLEPATHS:=$(CREATABLEPATHS) $(dir $(RFIFILE)) |
287 |
281 |
288 RPPFILES:=$(foreach L,$(LANGUAGES:SC=sc),$(INTERBASE_TMP)_$(L).rpp) |
282 RPPFILES:=$(foreach L,$(LANGUAGES:SC=sc),$(INTERBASE)_$(L).rpp) |
289 $(eval $(call generaterfifile,$(RFIFILE),$(RPPFILES),$(PRIMARYRPPFILE).d)) |
283 $(eval $(call generaterfifile,$(RFIFILE),$(RPPFILES),$(addsuffix .d,$(RPPFILES)))) |
290 endif |
284 endif |
291 |
285 |
292 |
286 |
293 ## Clean up |
287 ## Clean up |
294 $(call raptor_clean,$(CLEANTARGETS)) |
288 $(call raptor_clean,$(CLEANTARGETS)) |