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