625
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
1 |
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
2 |
# All rights reserved.
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
3 |
# This component and the accompanying materials are made available
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
4 |
# under the terms of the License "Eclipse Public License v1.0"
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
5 |
# which accompanies this distribution, and is available
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
7 |
#
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
8 |
# Initial Contributors:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
9 |
# Nokia Corporation - initial contribution.
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
10 |
#
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
11 |
# Contributors:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
12 |
#
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
13 |
# Description:
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
14 |
# Function Like Makefile (FLM): Shared macros for resource.flm
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
15 |
#
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
16 |
#
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
17 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
18 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
19 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
20 |
# $1 is the name of the intermediate RESOURCEFILE that is to be produced
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
21 |
# $2 is the LANGUAGE (eg. sc or 01 or 02 ...)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
22 |
# $3 is the name of the dependency file
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
23 |
define resource.deps
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
24 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
25 |
$(if $(FLMDEBUG),$$(info <debug>resource.deps: $1 LANG:$2 dep $3 </debug>))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
26 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
27 |
RESOURCE_DEPS:: $3
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
28 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
29 |
# could force deps to be generated always - debatable.
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
30 |
# .PHONY: $3
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
31 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
32 |
$3: $(SOURCE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
33 |
$(call startrule,resourcedependencies,FORCESUCCESS) \
|
630
|
34 |
$(GNUCPP) -DLANGUAGE_$(2) -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\
|
625
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
35 |
$(CPPOPT) $(SOURCE) -M -MG -MT"$1" | \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
36 |
$$(DEPENDENCY_CORRECTOR) >$3 \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
37 |
$(call endrule,resourcedependencies)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
38 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
39 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $3
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
40 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
41 |
CLEANTARGETS:=$$(CLEANTARGETS) $3
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
42 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
43 |
endef # resource.deps #
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
44 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
45 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
46 |
|
630
|
47 |
# Must be a separate macro since we
|
|
48 |
define resource.decideheader
|
625
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
49 |
DOHEADER:=
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
50 |
ifeq ($(HEADLANG),$2)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
51 |
ifneq ($(RESOURCEHEADER),)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
52 |
RESOURCE:: $(RESOURCEHEADER)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
53 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
54 |
DOHEADER:=-h$(RESOURCEHEADER)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
55 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
56 |
# we will add the resourceheader to RELEASABLES globally
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
57 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
58 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
59 |
else
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
60 |
# Use the headlang resource (in primaryfile) as the dependency
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
61 |
# "leader" for this resource
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
62 |
$1: $(PRIMARYFILE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
63 |
endif
|
630
|
64 |
endef
|
|
65 |
|
|
66 |
# $1 is the name of the intermediate RESOURCEFILE
|
|
67 |
# $2 is the LANGUAGE (eg. sc or 01 or 02 ...)
|
|
68 |
# Uses $(RESOURCEHEADER),$(SOURCE),$(HEADLANG),$(MMPDEFS) apart from some tools
|
|
69 |
define resource.build
|
|
70 |
$(if $(FLMDEBUG),$$(info <debug>resource.build: $1 LANG:$2 </debug>))
|
|
71 |
|
|
72 |
$(eval $(resource.decideheader))
|
|
73 |
|
|
74 |
ifneq ($(DOHEADER),)
|
|
75 |
# Strictly speaking if $1 is made then the header file should be there too
|
|
76 |
# but suppose someone adds a header statement to their MMP after doing a build?
|
|
77 |
# so here we recreate the resource header if its missing even if the intermediate resource
|
|
78 |
# has actually been built. The problem is: what if the rpp file is not there (oops)?
|
|
79 |
# So this is not perfect but I think that the situation is fairly unlikely.
|
|
80 |
# We can afford to put in an if statement for the rsg file - it's not a race condition because
|
|
81 |
# $1 is done and the build engine guarantees that it's there so no resource header
|
|
82 |
# can be attempted while we're trying to test.
|
|
83 |
$(RESOURCEHEADER) : $1
|
|
84 |
$(call startrule,resourcecompile.headerfill,FORCESUCCESS) \
|
|
85 |
if [ ! -f "$(RESOURCEHEADER)" ]; then $(GNUCPP) -DLANGUAGE_$2 \
|
|
86 |
-DLANGUAGE_$(subst sc,SC,$(2)) $(call makemacrodef,-D,$(MMPDEFS))\
|
|
87 |
$(CPPOPT) $(SOURCE) -o $1.rpp; fi && \
|
|
88 |
if [ ! -f "$(RESOURCEHEADER)" ]; then $(RCOMP) -m045,046,047 -u -h$$@ -s$1.rpp; fi \
|
|
89 |
$(call endrule,resourcecompile.headerfill)
|
|
90 |
endif
|
625
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
91 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
92 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
93 |
|
630
|
94 |
RESOURCE:: $1
|
|
95 |
|
|
96 |
$1: $(SOURCE)
|
|
97 |
$(call startrule,resourcecompile,FORCESUCCESS) \
|
|
98 |
$(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$(2)) $(call makemacrodef,-D,$(MMPDEFS))\
|
|
99 |
$(CPPOPT) $(SOURCE) -o $1.rpp && \
|
|
100 |
$(RCOMP) -m045,046,047 -u $(DOHEADER) -o$$@ -s$1.rpp \
|
|
101 |
$(call endrule,resourcecompile)
|
625
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
102 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
103 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $1
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
104 |
CLEANTARGETS:=$$(CLEANTARGETS) $1 $1.rpp
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
105 |
endef # resource.build
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
106 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
107 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
108 |
# $1 is the name of the intermediate RESOURCEFILE
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
109 |
# $2 is the target name (without path) of the final resource file
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
110 |
define resource.makecopies
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
111 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
112 |
$(call copyresource,$1,$(sort $(addsuffix /$2,$(RSCCOPYDIRS))))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
113 |
endef
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
114 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
115 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
116 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
117 |
# $1 is the intermediate filename base (eg. /epoc32/build/xxx/b_)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
118 |
# $2 is the LANGUAGE (eg. sc or 01 or 02 ...)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
119 |
define resource.headeronly
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
120 |
ifeq "$(MAKEFILE_GROUP)" "RESOURCE_DEPS"
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
121 |
# generate the resource header dependency files
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
122 |
$(eval DEPENDFILENAME:=$1_$2.rsg.d)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
123 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
124 |
RESOURCE_DEPS:: $(DEPENDFILENAME)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
125 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
126 |
# could force deps to be generated always - debatable.
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
127 |
# .PHONY: $(DEPENDFILENAME)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
128 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
129 |
$(DEPENDFILENAME): $(SOURCE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
130 |
$(call startrule,resource.headeronly.deps,FORCESUCCESS) \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
131 |
$(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
132 |
$(CPPOPT) $(SOURCE) -M -MG -MT"$(RESOURCEHEADER)" | \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
133 |
$$(DEPENDENCY_CORRECTOR) > $$@ \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
134 |
$(call endrule,resource.headeronly.deps)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
135 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
136 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $(DEPENDFILENAME)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
137 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
138 |
CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
139 |
else # generate the resource header
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
140 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
141 |
RESOURCE:: $(RESOURCEHEADER)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
142 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
143 |
$(RESOURCEHEADER): $(SOURCE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
144 |
$(call startrule,resource.headeronly,FORCESUCCESS) \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
145 |
$(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
146 |
$(CPPOPT) $(SOURCE) -o $1_$2.rsg.rpp && \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
147 |
$(RCOMP) -m045,046,047 -u -h$$@ -s$1_$2.rsg.rpp \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
148 |
$(call endrule,resource.headeronly)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
149 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
150 |
CLEANTARGETS:=$$(CLEANTARGETS) $1_$2.rsg.rpp
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
151 |
# we will add the resourceheader to RELEASABLES globally
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
152 |
# individual source file compilation
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
153 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
154 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $(RESOURCEHEADER)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
155 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
156 |
$(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME)))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
157 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
158 |
ifneq "$(DEPENDFILE)" ""
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
159 |
ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" ""
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
160 |
-include $(DEPENDFILE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
161 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
162 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
163 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
164 |
endef # resource.headeronly #
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
165 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
166 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
167 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
168 |
define copyresource
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
169 |
# $(1) is the source
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
170 |
# $(2) is the space separated list of destinations which must be filenames
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
171 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
172 |
RELEASABLES:=$$(RELEASABLES) $(2)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
173 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
174 |
$(info <finalcopy source='$1'>$2</finalcopy>)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
175 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
176 |
endef # copyresource #
|