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:= |
51 |
52 |
52 # There is only one resource header (.rsg) file and we only |
53 # There is only one resource header (.rsg) file and we only |
53 # make that if we are asked. |
54 # make that if we are asked. |
54 RSGDIR:=$(EPOCROOT)/epoc32/include |
55 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)) |
55 ifneq ($(or $(HEADER),$(HEADERONLY)),) |
59 ifneq ($(or $(HEADER),$(HEADERONLY)),) |
56 RESOURCEHEADER:=$(RSGDIR)/$(HEADER) |
60 RESOURCEHEADER:=$(RSGDIR)/$(HEADER) |
57 |
61 |
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)) |
|
61 else |
62 else |
62 HEADLANG:= |
63 RESOURCEHEADER:= |
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:=$(OUTPUTPATH)/$(TARGET_lower)$(if $(TARGETPATH),_$(subst /,_,$(TARGETPATH)),) |
67 INTERBASE_TMP:=$(OUTPUTPATH)/$(TARGET_lower)_$(notdir $(basename $(SOURCE))) |
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)) |
|
113 |
69 |
114 # common pre-processor options |
70 # common pre-processor options |
|
71 |
|
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 |
115 CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\ |
76 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) ) |
77 -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) ) |
117 |
78 |
118 CREATABLEPATHS:=$(RSCDIR) $(RSGDIR) $(OUTPUTPATH) |
79 CREATABLEPATHS:=$(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) |
119 |
85 |
120 # additional binary resource copies performed based on BINCOPYDIRS |
86 # additional binary resource copies performed based on BINCOPYDIRS |
121 RSCCOPYDIRS:= |
|
122 ifneq ($(BINCOPYDIRS),) |
87 ifneq ($(BINCOPYDIRS),) |
123 RSCCOPYDIRS:=$(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
88 RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS))) |
124 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
89 endif |
125 endif |
90 CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS) |
126 |
91 |
127 ############################################################################### |
92 ############################################################################### |
|
93 |
|
94 |
128 define preprocessresource |
95 define preprocessresource |
129 # $(1) is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
96 # $1 is the RPPFILE (eg. /epoc32/build/xxx/b_sc.rpp) |
130 # $(2) is the related RESOURCEFILE if any (eg. /a/b.rsc) |
97 # $2 is the LANGUAGE (eg. sc or 01 or 02 ...) |
131 # $(3) is the LANGUAGE (eg. sc or 01 or 02 ...) |
98 # $3 is the "primary" language on which all the others depend |
132 |
99 |
133 ifeq ($(TARGET_$(call sanitise,$1)),) |
100 ifeq ($(TARGET_$(call sanitise,$1)),) |
134 TARGET_$(call sanitise,$1):=1 |
101 TARGET_$(call sanitise,$1):=1 |
135 $(if $(FLMDEBUG),$(info preprocessresource: $(1) for $(2) LANG:$(3))) |
102 $(if $(FLMDEBUG),$$(info <debug>preprocessresource: $1 LANG:$2 dep $3</debug>)) |
136 |
103 |
137 RESOURCE_DEPS:: $(1).d |
104 |
138 $(1).d: $(SOURCE) |
105 # Correct dependency information when a header file can't be found. |
|
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) |
139 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
131 $(call startrule,resourcedependencies,FORCESUCCESS) \ |
140 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
132 $(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\ |
141 $(CPPOPT) $(SOURCE) -M -MG -MT"$(1)" | \ |
133 $(CPPOPT) $(SOURCE) -M -MG -MT"$1" | \ |
142 $(GNUSED) -r 's# ([^ \/]+\.((rsg)|(mbg)))# $(EPOCROOT)\/epoc32\/include\/\1#ig' > $(1).d \ |
134 $$(DEPENDENCY_CORRECTOR) >$$@ \ |
143 $(call endrule,resourcedependencies) |
135 $(call endrule,resourcedependencies) |
144 |
136 |
145 $(1): $(1).d |
137 $1 : $1.d |
|
138 |
|
139 else |
|
140 $1 : $3 |
|
141 endif |
|
142 |
|
143 $1: |
146 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
144 $(call startrule,resourcepreprocess,FORCESUCCESS) \ |
147 $(GNUCPP) -C -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\ |
145 $(GNUCPP) -C -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\ |
148 $(CPPOPT) $(SOURCE) -o $$@ \ |
146 $(CPPOPT) $(SOURCE) -o $$@ \ |
149 $(call endrule,resourcepreprocess) |
147 $(call endrule,resourcepreprocess) |
150 |
148 endif |
151 CLEANTARGETS:= $$(CLEANTARGETS) $(1) |
149 |
152 |
150 CLEANTARGETS:= $$(CLEANTARGETS) $1 |
153 $(eval DEPENDFILENAME:=$(1).d) |
151 |
154 $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
152 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
155 |
153 ifeq "$1" "$3" |
156 CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
154 $(eval DEPENDFILENAME:=$1.d) |
157 ifneq "$(DEPENDFILE)" "" |
155 $(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME))) |
158 ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
156 |
159 -include $(DEPENDFILE) |
157 CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME) |
|
158 ifneq "$(DEPENDFILE)" "" |
|
159 ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" "" |
|
160 ifeq "$(MAKEFILE_GROUP)" "RESOURCE" |
|
161 -include $(DEPENDFILE) |
|
162 endif |
|
163 endif |
160 endif |
164 endif |
161 endif |
165 endif |
162 |
166 |
163 endif |
167 endif |
164 endef # preprocessresource # |
168 endef # preprocessresource # |
165 |
169 |
166 ############################################################################### |
170 ############################################################################### |
167 define copyresource |
171 define copyresource |
168 # $(1) is the source |
172 # $(1) is the source |
169 # $(2) is the destination |
173 # $(2) is the space separated list of destinations which must be filenames |
170 |
174 |
171 RELEASABLES:=$$(RELEASABLES) $(2) |
175 RELEASABLES:=$$(RELEASABLES) $(2) |
172 |
176 |
173 ifeq ($(TARGET_$(call sanitise,$2)),) |
177 $(info <finalcopy source='$1'>$2</finalcopy>) |
174 TARGET_$(call sanitise,$2):=1 |
178 |
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 |
|
188 endef # copyresource # |
179 endef # copyresource # |
189 |
180 |
190 ############################################################################### |
181 ############################################################################### |
191 define generateresource |
182 define generateresource |
192 |
183 |
193 # $(1) is the resource filename e.g. /a/b/resource.rsc |
184 # $(1) is the intermediate resource filename with path e.g. /a/b/resource.rsc |
194 # $(2) is the preprocessed resource to make it from |
185 # $(2) is the preprocessed resource to make it from |
195 # $(3) is the language e.g. sc or 01 or 02 |
186 # $(3) is the language e.g. sc or 01 or 02 |
196 |
187 # $(4) is the target resource filename without path |
197 RELEASABLES:=$$(RELEASABLES) $(1) |
188 |
198 |
189 |
199 ifeq ($(TARGET_$(call sanitise,$1)),) |
190 ifeq ($(TARGET_$(call sanitise,$1)),) |
200 TARGET_$(call sanitise,$1):=1 |
191 TARGET_$(call sanitise,$1):=1 |
201 |
192 |
202 $(if $(FLMDEBUG),$(info generateresource: $(1) from $(2) LANG:$(3)),) |
193 $(if $(FLMDEBUG),$(info <debug>generateresource: $(1) from $(2) LANG:$(3)</debug>),) |
203 |
194 $(if $(FLMDEBUG),$(info <debug>generateresource: copies: $(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS)))</debug>)) |
|
195 |
|
196 CLEANTARGETS:=$$(CLEANTARGETS) $(1) |
204 |
197 |
205 RESOURCE:: $(1) |
198 RESOURCE:: $(1) |
206 |
199 |
207 $(1): $(2) $(RCOMP) |
200 $(1): $(2) $(RCOMP) |
208 $(call startrule,resourcecompile,FORCESUCCESS) \ |
201 $(call startrule,resourcecompile,FORCESUCCESS) \ |
209 $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) \ |
202 $(RCOMP) -m045,046,047 -u -o$(1) -s$(2) \ |
210 $(call endrule,resourcecompile) |
203 $(call endrule,resourcecompile) |
211 |
204 |
212 endif |
205 endif |
|
206 |
213 # Whether or not we have generated this resource for some other variant, check if there |
207 # 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 |
208 # are any new copies to be made for this variant. e.g. winscw requires that we make |
215 # some extra copies. |
209 # some extra copies. We tried to copy after running rcomp itself but we still need these |
216 |
210 # targets for the sake of dependencies or, for example, if someone merely adds a new copy |
217 $(foreach F,$(sort $(patsubst %,%/$(notdir $(1)),$(RSCCOPYDIRS))),$(call copyresource,$(1),$(F))) |
211 # when the resource is up-to-date |
|
212 |
|
213 $(call copyresource,$1,$(sort $(patsubst %,%/$4,$(RSCCOPYDIRS)))) |
|
214 |
218 |
215 |
219 # individual source file compilation |
216 # individual source file compilation |
220 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
217 SOURCETARGET_$(call sanitise,$(SOURCE)): $(1) |
221 |
218 |
222 endef # generateresource |
219 endef # generateresource |
253 ## call the generator |
250 ## call the generator |
254 |
251 |
255 # We always create at least the header |
252 # We always create at least the header |
256 # even if we sometimes don't create the resources |
253 # even if we sometimes don't create the resources |
257 ifneq ($(RESOURCEHEADER),) |
254 ifneq ($(RESOURCEHEADER),) |
258 $(eval $(call generateresourceheader,$(RESOURCEHEADER),$(INTERBASE)_$(HEADLANG).rpp,$(HEADLANG))) |
255 $(eval $(call generateresourceheader,$(RESOURCEHEADER),$(INTERBASE_TMP)_$(HEADLANG).rpp,$(HEADLANG))) |
259 endif |
256 endif |
260 |
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 |
261 ifeq ($(HEADERONLY),) |
264 ifeq ($(HEADERONLY),) |
262 # generate a resource file for each language |
265 # generate a resource file for each language |
263 # For sc we generate $(RESBASE).rsc and define LANGUAGE_SC and LANGUAGE_sc. |
266 # 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)))) |
267 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call preprocessresource,$(INTERBASE_TMP)_$(L).rpp,$(L),$(PRIMARYRPPFILE)))) |
265 $(foreach L,$(LANGUAGES:SC=sc),$(eval $(call generateresource,$(RESBASE).r$(L),$(INTERBASE)_$(L).rpp,$(L)))) |
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 |
266 else |
272 else |
267 # No resources are going to be made so unless we specifically ask for it, there will be no |
273 # 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: |
274 # preprocessed file from which to create the header: |
269 |
275 |
270 $(eval $(call preprocessresource,$(INTERBASE)_$(HEADLANG).rpp,,$(HEADLANG))) |
276 $(eval $(call preprocessresource,$(INTERBASE_TMP)_$(HEADLANG).rpp,,$(HEADLANG),$(PRIMARYRPPFILE))) |
271 |
277 |
272 endif |
278 endif |
273 |
279 |
274 ############################################################################### |
280 ############################################################################### |
275 ## .rfi generation in support of the gccxml build |
281 ## .rfi generation in support of the gccxml build |
276 ## Note that .rfi files are created from the dependency files generated from preprocessing resources to create .rpp files |
282 ## Note that .rfi files are created from the dependency files generated from preprocessing resources to create .rpp files |
277 ifneq ($(RFIFILE),) |
283 ifneq ($(RFIFILE),) |
278 RESOURCE:: $(RFIFILE) |
284 RESOURCE:: $(RFIFILE) |
279 RELEASABLES:=$(RELEASABLES) $(RFIFILE) |
285 RELEASABLES:=$(RELEASABLES) $(RFIFILE) |
280 CREATABLEPATHS:=$(CREATABLEPATHS) $(dir $(RFIFILE)) |
286 CREATABLEPATHS:=$(CREATABLEPATHS) $(dir $(RFIFILE))/ |
281 |
287 |
282 RPPFILES:=$(foreach L,$(LANGUAGES:SC=sc),$(INTERBASE)_$(L).rpp) |
288 RPPFILES:=$(foreach L,$(LANGUAGES:SC=sc),$(INTERBASE_TMP)_$(L).rpp) |
283 $(eval $(call generaterfifile,$(RFIFILE),$(RPPFILES),$(addsuffix .d,$(RPPFILES)))) |
289 $(eval $(call generaterfifile,$(RFIFILE),$(RPPFILES),$(PRIMARYRPPFILE).d)) |
284 endif |
290 endif |
285 |
291 |
286 |
292 |
287 ## Clean up |
293 ## Clean up |
288 $(call raptor_clean,$(CLEANTARGETS)) |
294 $(call raptor_clean,$(CLEANTARGETS)) |