13
|
1 |
# Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
# All rights reserved.
|
|
3 |
# This component and the accompanying materials are made available
|
|
4 |
# under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
# which accompanies this distribution, and is available
|
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
#
|
|
8 |
# Initial Contributors:
|
|
9 |
# Nokia Corporation - initial contribution.
|
|
10 |
#
|
|
11 |
# Contributors:
|
|
12 |
#
|
|
13 |
# Description:
|
|
14 |
# Function Like Makefile (FLM) to create a resource header (.rsg)
|
|
15 |
# and resource files (.rsc, .r01, .r02 etc.)
|
|
16 |
#
|
|
17 |
#
|
|
18 |
|
|
19 |
## Parameters that are expected:
|
|
20 |
# TARGET
|
|
21 |
# TARGETPATH
|
|
22 |
# LANGUAGES
|
|
23 |
# HEADER
|
|
24 |
# HEADERONLY
|
|
25 |
# EPOCROOT
|
|
26 |
# MMPDEFS
|
|
27 |
# PRODUCT_INCLUDE
|
|
28 |
# SYSTEMINCLUDE
|
|
29 |
# USERINCLUDE
|
|
30 |
# GNUCPP
|
|
31 |
# GNUSED
|
|
32 |
# RCOMP
|
|
33 |
# OUTPUTPATH
|
|
34 |
# SOURCE
|
|
35 |
# BINCOPYDIRS
|
|
36 |
|
|
37 |
|
|
38 |
# The rss is pre-processed once for each language and results
|
|
39 |
# in a file with extension r$(LANGUAGE) where $(LANGUAGE) is
|
|
40 |
# either "sc" or a 2 (or more) digit number.
|
|
41 |
ifneq ($(TARGETPATH),)
|
|
42 |
RSCDIR:=$(subst //,/,$(EPOCROOT)/epoc32/data/z/$(TARGETPATH))
|
|
43 |
else
|
|
44 |
RSCDIR:=$(subst //,/,$(EPOCROOT)/epoc32/data)
|
|
45 |
endif
|
|
46 |
RESBASE:=$(RSCDIR)/$(TARGET_lower)
|
|
47 |
|
|
48 |
# Ensure that RELEASABLES and CLEANTARGETS cannot expand indefinitely in successive calls to this flm:
|
|
49 |
CLEANTARGETS:=
|
|
50 |
RELEASABLES:=
|
18
|
51 |
CREATABLEPATHS:=
|
13
|
52 |
|
|
53 |
# There is only one resource header (.rsg) file and we only
|
|
54 |
# make that if we are asked.
|
|
55 |
RSGDIR:=$(EPOCROOT)/epoc32/include
|
18
|
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))
|
13
|
59 |
ifneq ($(or $(HEADER),$(HEADERONLY)),)
|
|
60 |
RESOURCEHEADER:=$(RSGDIR)/$(HEADER)
|
|
61 |
|
|
62 |
else
|
18
|
63 |
RESOURCEHEADER:=
|
13
|
64 |
endif
|
|
65 |
|
|
66 |
# we create intermediate .rpp and .d files
|
18
|
67 |
INTERBASE_TMP:=$(OUTPUTPATH)/$(TARGET_lower)_$(notdir $(basename $(SOURCE)))
|
13
|
68 |
|
28
|
69 |
LANGUAGES:=$(LANGUAGES:SC=sc) # ensure that we don't ever have to worry about case consistency w.r.t languages or get confused into thinking that SC!=sc (which it is)
|
|
70 |
LANGUAGES:=$(call uniq,$(LANGUAGES)) # remove any duplicates from the list (usually the result of multiple LANG lists both in and out of START RESOURCE blocks)
|
|
71 |
|
13
|
72 |
|
|
73 |
# common pre-processor options
|
18
|
74 |
|
|
75 |
# We really should be using -iquote with a recent cpp. This is a note for when we do update:
|
|
76 |
#CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\
|
|
77 |
# -I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-iquote $(I) ) $(foreach J,$(SYSTEMINCLUDE),-I $(J) )
|
|
78 |
|
13
|
79 |
CPPOPT:=-nostdinc -undef -Wno-trigraphs -D_UNICODE -include $(PRODUCT_INCLUDE)\
|
|
80 |
-I$(dir $(SOURCE)) $(foreach I, $(USERINCLUDE),-I$(I) ) -I- $(foreach J,$(SYSTEMINCLUDE),-I$(J) )
|
|
81 |
|
18
|
82 |
CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCDIR) $(RSGDIR) $(OUTPUTPATH)
|
|
83 |
|
|
84 |
# We intend to generate the resource in an intermediate location and copy to the targetpath to
|
|
85 |
# ensure that when the "same" resource is built into separare target paths, it doesn't have to be
|
|
86 |
# completely recreated each time - just copied.
|
|
87 |
RSCCOPYDIRS:=$(RSCDIR)
|
13
|
88 |
|
|
89 |
# additional binary resource copies performed based on BINCOPYDIRS
|
|
90 |
ifneq ($(BINCOPYDIRS),)
|
18
|
91 |
RSCCOPYDIRS:=$(RSCCOPYDIRS) $(subst //,/,$(patsubst %,%/$(if $(TARGETPATH),/z/$(TARGETPATH),),$(BINCOPYDIRS)))
|
13
|
92 |
endif
|
18
|
93 |
CREATABLEPATHS:=$(CREATABLEPATHS) $(RSCCOPYDIRS)
|
13
|
94 |
|
28
|
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.
|
18
|
106 |
|
28
|
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
|
13
|
115 |
|
28
|
116 |
###############################################################################
|
|
117 |
# Include all the macros - but not if it has been done already
|
|
118 |
|
|
119 |
ifeq ($(include_resource_mk),)
|
|
120 |
include_resource_mk:=1
|
|
121 |
|
|
122 |
include $(FLMHOME)/resource.mk
|
|
123 |
|
|
124 |
endif
|
|
125 |
|
|
126 |
###############################################################################
|
|
127 |
## Generate a string of resourcefiles optionally with a header OR
|
|
128 |
## just a header (HEADERONLY)
|
18
|
129 |
|
|
130 |
|
28
|
131 |
ifeq ($(HEADERONLY),) # i.e IF NOT HEADERONLY
|
|
132 |
|
|
133 |
# The resources that are not for the "HEADER language" will all depend on
|
|
134 |
# that "headlang resource" - they will "sit in its dependency slipstream"
|
|
135 |
# or in other words We only have to make one dependency file because
|
|
136 |
# all of the other languages will benefit from it indirectly through their
|
|
137 |
# dependency on the header language.
|
|
138 |
|
|
139 |
# The guard is based on the languages we're building so that 2 resource blocks can
|
|
140 |
# create different languages if so needed (no known reason for this but someone
|
|
141 |
# could do it and in the past it would have worked).
|
|
142 |
GUARD:=TARGET_$(call sanitise,$(INTERBASE_TMP))
|
|
143 |
$(if $(FLMDEBUG),$(info <debug>resource.flm: $(GUARD)=$($(GUARD)) LANGUAGES:=$(LANGUAGES)</debug>))
|
|
144 |
|
|
145 |
# Don't generate new rules for languages we've already seen for this resource file
|
|
146 |
# i.e. this allows one to define a single resource using two startresource blocks.
|
|
147 |
# each of which specifies one half of the languages.
|
|
148 |
REMAINING_LANGUAGES:=$(filter-out $($(GUARD)),$(LANGUAGES))
|
|
149 |
$(if $(FLMDEBUG),$(info <debug>resource.flm: REMAINING_LANGUAGES=$(REMAINING_LANGUAGES)</debug>))
|
|
150 |
|
|
151 |
ifneq ($(REMAINING_LANGUAGES),)
|
|
152 |
$(GUARD):=$($(GUARD)) $(REMAINING_LANGUAGES)
|
|
153 |
|
|
154 |
LANGUAGES:=$(REMAINING_LANGUAGES)
|
|
155 |
|
|
156 |
# PRIMARYFILE is the resource that will have a dependency file and that all the other
|
|
157 |
# resources will depend on.
|
|
158 |
PRIMARYFILE:=$(INTERBASE_TMP).r$(HEADLANG)
|
|
159 |
DEPENDFILENAME:=$(INTERBASE_TMP).r$(HEADLANG).d
|
|
160 |
$(if $(FLMDEBUG),$(info <debug>resource.flm: in guard with primary file=$(PRIMARYFILE)</debug>))
|
|
161 |
|
|
162 |
ifeq "$(MAKEFILE_GROUP)" "RESOURCE_DEPS"
|
|
163 |
# Generate PRIMARYFILE's dependencies
|
|
164 |
$(eval $(call resource.deps,$(INTERBASE_TMP).r$(HEADLANG),$(HEADLANG),$(DEPENDFILENAME)))
|
|
165 |
else
|
|
166 |
RESOURCE:: $(PRIMARYFILE)
|
|
167 |
|
|
168 |
# invoke the macro that creates targets for building resources, once per language
|
|
169 |
# For sc we generate $(INTERBASE_TMP).rsc and define LANGUAGE_SC and LANGUAGE_sc.
|
|
170 |
$(foreach L,$(LANGUAGES),$(eval $(call resource.build,$(INTERBASE_TMP).r$(L),$(L),$(TARGET_lower).r$(L))))
|
18
|
171 |
|
28
|
172 |
|
|
173 |
DEPENDFILE:=$(wildcard $(DEPENDFILENAME))
|
|
174 |
ifneq "$(DEPENDFILE)" ""
|
|
175 |
ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" ""
|
|
176 |
-include $(DEPENDFILE)
|
|
177 |
endif
|
|
178 |
endif
|
|
179 |
|
|
180 |
endif
|
|
181 |
endif
|
|
182 |
ifneq "$(MAKEFILE_GROUP)" "RESOURCE_DEPS"
|
|
183 |
# Whether or not we have generated this resource for some other start
|
|
184 |
# resource block, check if there are any new copies to be made for
|
|
185 |
# this variant. e.g. winscw requires that we make some extra copies.
|
|
186 |
# We tried to copy after running rcomp itself but we still need these
|
|
187 |
# targets for the sake of dependencies or, for example, if someone
|
|
188 |
# merely adds a new copy when the resource is up-to-date
|
|
189 |
$(foreach L,$(LANGUAGES),$(eval $(call resource.makecopies,$(INTERBASE_TMP).r$(L),$(TARGET_lower).r$(L))))
|
13
|
190 |
|
28
|
191 |
endif
|
|
192 |
else
|
|
193 |
#
|
|
194 |
# HEADERONLY was specified
|
|
195 |
#
|
|
196 |
GUARD:=TARGET_$(call sanitise,$(INTERBASE_TMP))_rsg
|
|
197 |
$(if $(FLMDEBUG),$(info <debug>resource.flm: Headeronly $(INTERBASE_TMP) $(TARGET_lower).rsg LANGUAGES:=$(LANGUAGES)</debug>))
|
18
|
198 |
|
28
|
199 |
ifeq ($($(GUARD)),)
|
|
200 |
$(GUARD):=1
|
|
201 |
$(eval $(call resource.headeronly,$(INTERBASE_TMP),$(HEADLANG)))
|
|
202 |
# The headeronly macro manages dependency including on its own
|
|
203 |
endif
|
|
204 |
|
|
205 |
endif
|
|
206 |
|
|
207 |
ifneq "$(MAKEFILE_GROUP)" "RESOURCE_DEPS"
|
|
208 |
# Add header to releasables anyway despite guard since sone things
|
|
209 |
# like the abldcache want to see the rsg for each platform even
|
|
210 |
# if we only declare one rule.
|
|
211 |
# If there's no header then it will be blank which is fine.
|
|
212 |
RELEASABLES:=$(RELEASABLES) $(RESOURCEHEADER)
|
18
|
213 |
endif
|
|
214 |
|
|
215 |
|
13
|
216 |
|
|
217 |
###############################################################################
|
|
218 |
## .rfi generation in support of the gccxml build
|
|
219 |
## Note that .rfi files are created from the dependency files generated from preprocessing resources to create .rpp files
|
|
220 |
ifneq ($(RFIFILE),)
|
|
221 |
RESOURCE:: $(RFIFILE)
|
|
222 |
RELEASABLES:=$(RELEASABLES) $(RFIFILE)
|
18
|
223 |
CREATABLEPATHS:=$(CREATABLEPATHS) $(dir $(RFIFILE))/
|
13
|
224 |
|
28
|
225 |
$(eval $(call generaterfifile,$(RFIFILE),$(PRIMARYFILE).d))
|
13
|
226 |
endif
|
|
227 |
|
|
228 |
|
|
229 |
## Clean up
|
|
230 |
$(call raptor_clean,$(CLEANTARGETS))
|
|
231 |
# make the output directories while reading makefile - some build engines prefer this
|
|
232 |
$(call makepath,$(CREATABLEPATHS))
|
|
233 |
|
|
234 |
# for the --what option and the log file
|
|
235 |
$(call raptor_release,$(RELEASABLES),RESOURCE)
|
|
236 |
|