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) \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
34 |
$(GNUCPP) -DLANGUAGE_$(3) -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\
|
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 |
# $1 is the name of the intermediate RESOURCEFILE
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
47 |
# $2 is the LANGUAGE (eg. sc or 01 or 02 ...)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
48 |
# Uses $(RESOURCEHEADER),$(SOURCE),$(HEADLANG),$(MMPDEFS) apart from some tools
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
49 |
define resource.build
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
50 |
$(if $(FLMDEBUG),$$(info <debug>resource.build: $1 LANG:$2 </debug>))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
51 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
52 |
DOHEADER:=
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
53 |
ifeq ($(HEADLANG),$2)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
54 |
ifneq ($(RESOURCEHEADER),)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
55 |
RESOURCE:: $(RESOURCEHEADER)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
56 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
57 |
DOHEADER:=-h$(RESOURCEHEADER)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
58 |
# strictly speaking if $1 is made then the header file should be there too
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
59 |
# but suppose someone adds a header statement to their MMP after doing a build?
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
60 |
# so here we recreate the resource header if its missing even if the intermediate resource
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
61 |
# has actually been built. The problem is: what if the rpp file is not there (oops)?
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
62 |
# So this is not perfect but I think that the situation is fairly unlikely.
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
63 |
# We can afford to put in an if statement for the rsg file - it's not a race condition because
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
64 |
# $1 is done and the build engine guarantees that it's there so no resource header
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
65 |
# can be attempted while we're trying to test.
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
66 |
$(RESOURCEHEADER) : $1
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
67 |
$(call startrule,resourcecompile.headerfill,FORCESUCCESS) \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
68 |
if [ ! -f "$(RESOURCEHEADER)" ]; then $(GNUCPP) -DLANGUAGE_$2 \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
69 |
-DLANGUAGE_$(subst sc,SC,$(2)) $(call makemacrodef,-D,$(MMPDEFS))\
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
70 |
$(CPPOPT) $(SOURCE) -o $1.rpp; fi && \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
71 |
if [ ! -f "$(RESOURCEHEADER)" ]; then $(RCOMP) -m045,046,047 -u -h$$@ -s$1.rpp; fi \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
72 |
$(call endrule,resourcecompile.headerfill)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
73 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
74 |
# we will add the resourceheader to RELEASABLES globally
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
75 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
76 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
77 |
else
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
78 |
# Use the headlang resource (in primaryfile) as the dependency
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
79 |
# "leader" for this resource
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
80 |
$1: $(PRIMARYFILE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
81 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
82 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
83 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
84 |
RESOURCE:: $1
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
85 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
86 |
$1: $(SOURCE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
87 |
$(call startrule,resourcecompile,FORCESUCCESS) \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
88 |
$(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$(2)) $(call makemacrodef,-D,$(MMPDEFS))\
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
89 |
$(CPPOPT) $(SOURCE) -o $1.rpp && \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
90 |
$(RCOMP) -m045,046,047 -u $$(DOHEADER) -o$$@ -s$1.rpp \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
91 |
$(call endrule,resourcecompile)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
92 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
93 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $1
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
94 |
CLEANTARGETS:=$$(CLEANTARGETS) $1 $1.rpp
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
95 |
endef # resource.build
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
96 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
97 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
98 |
# $1 is the name of the intermediate RESOURCEFILE
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
99 |
# $2 is the target name (without path) of the final resource file
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
100 |
define resource.makecopies
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
101 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
102 |
$(call copyresource,$1,$(sort $(addsuffix /$2,$(RSCCOPYDIRS))))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
103 |
endef
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
104 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
105 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
106 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
107 |
# $1 is the intermediate filename base (eg. /epoc32/build/xxx/b_)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
108 |
# $2 is the LANGUAGE (eg. sc or 01 or 02 ...)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
109 |
define resource.headeronly
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
110 |
ifeq "$(MAKEFILE_GROUP)" "RESOURCE_DEPS"
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
111 |
# generate the resource header dependency files
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
112 |
$(eval DEPENDFILENAME:=$1_$2.rsg.d)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
113 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
114 |
RESOURCE_DEPS:: $(DEPENDFILENAME)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
115 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
116 |
# could force deps to be generated always - debatable.
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
117 |
# .PHONY: $(DEPENDFILENAME)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
118 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
119 |
$(DEPENDFILENAME): $(SOURCE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
120 |
$(call startrule,resource.headeronly.deps,FORCESUCCESS) \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
121 |
$(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$2) $(call makemacrodef,-D,$(MMPDEFS))\
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
122 |
$(CPPOPT) $(SOURCE) -M -MG -MT"$(RESOURCEHEADER)" | \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
123 |
$$(DEPENDENCY_CORRECTOR) > $$@ \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
124 |
$(call endrule,resource.headeronly.deps)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
125 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
126 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $(DEPENDFILENAME)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
127 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
128 |
CLEANTARGETS:=$$(CLEANTARGETS) $(DEPENDFILENAME)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
129 |
else # generate the resource header
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
130 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
131 |
RESOURCE:: $(RESOURCEHEADER)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
132 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
133 |
$(RESOURCEHEADER): $(SOURCE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
134 |
$(call startrule,resource.headeronly,FORCESUCCESS) \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
135 |
$(GNUCPP) -DLANGUAGE_$2 -DLANGUAGE_$(subst sc,SC,$(3)) $(call makemacrodef,-D,$(MMPDEFS))\
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
136 |
$(CPPOPT) $(SOURCE) -o $1_$2.rsg.rpp && \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
137 |
$(RCOMP) -m045,046,047 -u -h$$@ -s$1_$2.rsg.rpp \
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
138 |
$(call endrule,resource.headeronly)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
139 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
140 |
CLEANTARGETS:=$$(CLEANTARGETS) $1_$2.rsg.rpp
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
141 |
# we will add the resourceheader to RELEASABLES globally
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
142 |
# individual source file compilation
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
143 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
144 |
SOURCETARGET_$(call sanitise,$(SOURCE)): $(RESOURCEHEADER)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
145 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
146 |
$(eval DEPENDFILE:=$(wildcard $(DEPENDFILENAME)))
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
147 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
148 |
ifneq "$(DEPENDFILE)" ""
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
149 |
ifeq "$(filter %CLEAN,$(call uppercase,$(MAKECMDGOALS)))" ""
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
150 |
-include $(DEPENDFILE)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
151 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
152 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
153 |
endif
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
154 |
endef # resource.headeronly #
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
155 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
156 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
157 |
###############################################################################
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
158 |
define copyresource
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
159 |
# $(1) is the source
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
160 |
# $(2) is the space separated list of destinations which must be filenames
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
161 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
162 |
RELEASABLES:=$$(RELEASABLES) $(2)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
163 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
164 |
$(info <finalcopy source='$1'>$2</finalcopy>)
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
165 |
|
Richard Taylor <richard.i.taylor@nokia.com>
parents:
diff
changeset
|
166 |
endef # copyresource #
|