1#**************************************************************
2#
3#  Licensed to the Apache Software Foundation (ASF) under one
4#  or more contributor license agreements.  See the NOTICE file
5#  distributed with this work for additional information
6#  regarding copyright ownership.  The ASF licenses this file
7#  to you under the Apache License, Version 2.0 (the
8#  "License"); you may not use this file except in compliance
9#  with the License.  You may obtain a copy of the License at
10#
11#    http://www.apache.org/licenses/LICENSE-2.0
12#
13#  Unless required by applicable law or agreed to in writing,
14#  software distributed under the License is distributed on an
15#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16#  KIND, either express or implied.  See the License for the
17#  specific language governing permissions and limitations
18#  under the License.
19#
20#**************************************************************
21
22
23
24# SrsPartMergeTarget class
25
26gb_SrsPartMergeTarget_TRANSEXTARGET := $(call gb_Executable_get_target,transex3)
27# gb_SrsPartMergeTarget_TRANSEXPRECOMMAND is set by the platforms
28
29gb_SrsPartMergeTarget_TRANSEXCOMMAND := $(gb_SrsPartMergeTarget_TRANSEXPRECOMMAND) $(gb_SrsPartMergeTarget_TRANSEXTARGET)
30gb_SrsPartMergeTarget_SDFLOCATION := $(LOCDIR)/l10n/$(INPATH)/misc/sdf/
31gb_SrsPartMergeTarget_REPOS := $(gb_REPOS)
32
33define gb_SrsPartMergeTarget__command
34$(call gb_Output_announce,$(3),$(true),srs,1)
35$(call gb_Helper_abbreviate_dirs_native,\
36	mkdir -p $(dir $(1)) && \
37	$(gb_SrsPartMergeTarget_TRANSEXCOMMAND) \
38		-p $(firstword $(subst /, ,$(2))) \
39		-i $(3) \
40		-o $(1) \
41		-m $(SDF) \
42		-l all)
43
44endef
45
46define gb_SrsPartMergeTarget__rules
47$$(call gb_SrsPartMergeTarget_get_target,%) : $(1)/% $$(gb_Helper_MISCDUMMY) | $$(gb_SrsPartMergeTarget_TRANSEXTARGET)
48	$$(if $$(SDF),$$(call gb_SrsPartMergeTarget__command,$$@,$$*,$$<),mkdir -p $$(dir $$@) && cp $$< $$@)
49
50endef
51
52$(foreach repo,$(gb_SrsPartMergeTarget_REPOS),$(eval $(call gb_SrsPartMergeTarget__rules,$(repo))))
53
54# SrsPartTarget class
55
56gb_SrsPartTarget_REPOS := $(gb_REPOS)
57# defined by platform
58#  gb_SrsPartTarget_RSCTARGET
59#  gb_SrsPartTarget_RSCCOMMAND
60#  gb_SrsPartTarget__command_dep
61
62define gb_SrsPartTarget__command
63$(call gb_Helper_abbreviate_dirs_native,\
64	mkdir -p $(dir $(1)) && \
65	RESPONSEFILE=`$(gb_MKTEMP)` && \
66	echo "-s \
67		$(INCLUDE) \
68		-I$(dir $(3)) \
69		$(DEFS) \
70		-fp=$(1) \
71		$(if $(MERGEDFILE),$(MERGEDFILE),$<)" > $${RESPONSEFILE} && \
72	$(gb_SrsPartTarget_RSCCOMMAND) -presponse @$${RESPONSEFILE} && \
73	rm -rf $${RESPONSEFILE})
74
75endef
76
77define gb_SrsPartTarget__rules
78$$(call gb_SrsPartTarget_get_target,%) : $(1)/% $$(gb_Helper_MISCDUMMY) | $$(gb_SrsPartTarget_RSCTARGET)
79	$$(call gb_SrsPartTarget__command_dep,$$*,$$<)
80	$$(call gb_SrsPartTarget__command,$$@,$$*,$$<)
81
82ifeq ($(gb_FULLDEPS),$(true))
83$$(call gb_SrsPartTarget_get_dep_target,%) : $(1)/% $$(gb_Helper_MISCDUMMY)
84	$$(call gb_Helper_abbreviate_dirs,\
85		mkdir -p $$(dir $$@) && \
86		echo '$$(call gb_SrsPartTarget_get_target,$$*) : $$(gb_Helper_PHONY)' > $$@)
87endif
88
89endef
90
91$(foreach repo,$(gb_SrsPartTarget_REPOS),$(eval $(call gb_SrsPartTarget__rules,$(repo))))
92
93ifeq ($(gb_FULLDEPS),$(true))
94$(call gb_SrsPartTarget_get_dep_target,%) :
95	$(eval $(call gb_Output_error,Unable to find resource definition file $* in repositories: $(gb_SrsPartTarget_REPOS)))
96endif
97
98
99define gb_SrsPartTarget_SrsPartTarget
100ifeq ($(strip $(gb_WITH_LANG)),)
101$(call gb_SrsPartTarget_get_target,$(1)) : MERGEDFILE :=
102else
103$(call gb_SrsPartTarget_get_target,$(1)) : MERGEDFILE := $(call gb_SrsPartMergeTarget_get_target,$(1))
104$(call gb_SrsPartTarget_get_target,$(1)) : $(call gb_SrsPartMergeTarget_get_target,$(1))
105$(call gb_SrsPartMergeTarget_get_target,$(1)) : SDF := $(realpath $(gb_SrsPartMergeTarget_SDFLOCATION)$(dir $(1))localize.sdf)
106$(call gb_SrsPartMergeTarget_get_target,$(1)) : $(realpath $(gb_SrsPartMergeTarget_SDFLOCATION)$(dir $(1))localize.sdf)
107endif
108
109endef
110
111
112# SrsTarget class
113
114gb_SrsTarget_DEFAULTDEFS := $(gb_GLOBALDEFS)
115
116.PHONY : $(call gb_SrsTarget_get_clean_target,%)
117$(call gb_SrsTarget_get_clean_target,%) :
118	$(call gb_Output_announce,$*,$(false),SRS,1)
119	-$(call gb_Helper_abbreviate_dirs,\
120		rm -f $(call gb_SrsTarget_get_target,$*) \
121			$(call gb_SrsTarget_get_dep_target,$*) \
122			$(foreach part,$(PARTS),$(call gb_SrsPartTarget_get_target,$(part))) \
123			$(foreach part,$(PARTS),$(call gb_SrsPartTarget_get_dep_target,$(part))) \
124			$(foreach part,$(PARTS),$(call gb_SrsPartMergeTarget_get_target,$(part))))
125
126ifeq ($(gb_FULLDEPS),$(true))
127define gb_SrsTarget__command_dep
128$(call gb_Output_announce,SRS:$(2),$(true),DEP,1)
129$(call gb_Helper_abbreviate_dirs,\
130	mkdir -p $(dir $(1)) && \
131	cat $(3) > $(1))
132endef
133endif
134
135$(call gb_SrsTarget_get_target,%) :
136	$(call gb_SrsTarget__command_dep,$(call gb_SrsTarget_get_dep_target,$*),$*,$(foreach part,$(PARTS),$(call gb_SrsPartTarget_get_dep_target,$(part))))
137	$(call gb_Output_announce,$*,$(true),SRS,1)
138	$(call gb_Helper_abbreviate_dirs,\
139		mkdir -p $(dir $@) && \
140		cat $^ > $@)
141
142ifeq ($(gb_FULLDEPS),$(true))
143$(call gb_SrsTarget_get_dep_target,%) :
144	$(call gb_SrsTarget__command_dep,$@,$*,$^)
145endif
146
147define gb_SrsTarget_SrsTarget
148$(call gb_SrsTarget_get_target,$(1)) : DEFS := $(gb_SrsTarget_DEFAULTDEFS)
149$(call gb_SrsTarget_get_target,$(1)) : INCLUDE := $(SOLARINC)
150$(call gb_SrsTarget_get_clean_target,$(1)) : PARTS :=
151$(call gb_SrsTarget_get_target,$(1)) : PARTS :=
152ifeq ($(gb_FULLDEPS),$(true))
153ifneq ($(wildcard $(call gb_SrsTarget_get_dep_target,$(1))),)
154include $(call gb_SrsTarget_get_dep_target,$(1))
155else
156$(firstword $(MAKEFILE_LIST)) : $(call gb_SrsTarget_get_dep_target,$(1))
157endif
158endif
159
160endef
161
162define gb_SrsTarget_set_defs
163$(call gb_SrsTarget_get_target,$(1)) : DEFS := $(2)
164ifeq ($(gb_FULLDEPS),$(true))
165$(call gb_SrsTarget_get_dep_target,$(1)) : DEFS := $(2)
166endif
167
168endef
169
170define gb_SrsTarget_set_include
171$(call gb_SrsTarget_get_target,$(1)) : INCLUDE := $(2)
172ifeq ($(gb_FULLDEPS),$(true))
173$(call gb_SrsTarget_get_dep_target,$(1)) : INCLUDE := $(2)
174endif
175
176endef
177
178define gb_SrsTarget_add_file
179ifeq ($(gb_FULLDEPS),$(true))
180$(call gb_SrsTarget_get_dep_target,$(1)) : $(call gb_SrsPartTarget_get_dep_target,$(2))
181endif
182$(call gb_SrsPartTarget_SrsPartTarget,$(2))
183$(call gb_SrsTarget_get_target,$(1)) : $(call gb_SrsPartTarget_get_target,$(2))
184$(call gb_SrsTarget_get_clean_target,$(1)) : PARTS += $(2)
185$(call gb_SrsTarget_get_target,$(1)) : PARTS += $(2)
186
187endef
188
189define gb_SrsTarget_add_files
190$(foreach file,$(2),$(call gb_SrsTarget_add_file,$(1),$(file)))
191
192endef
193
194
195# ResTarget
196
197gb_ResTarget_RSCTARGET := $(gb_SrsPartTarget_RSCTARGET)
198gb_ResTarget_RSCCOMMAND := $(gb_SrsPartTarget_RSCCOMMAND)
199gb_ResTarget_DEFIMAGESLOCATION := $(SRCDIR)/default_images/
200
201$(call gb_ResTarget_get_clean_target,%) :
202	$(call gb_Output_announce,$*,$(false),RES,2)
203	$(call gb_Helper_abbreviate_dirs,\
204		rm -f $(call gb_ResTarget_get_target,$*) $(call gb_ResTarget_get_imagelist_target,$*) $(call gb_ResTarget_get_outdir_target,$*) $(call gb_ResTarget_get_outdir_imagelist_target,$*))
205
206$(call gb_ResTarget_get_target,%) : $(gb_Helper_MISCDUMMY) | $(gb_ResTarget_RSCTARGET)
207	$(call gb_Output_announce,$*,$(true),RES,2)
208	$(call gb_Helper_abbreviate_dirs_native,\
209		mkdir -p $(dir $@) $(OUTDIR)/bin \
210			$(dir $(call gb_ResTarget_get_imagelist_target,$*)) && \
211		RESPONSEFILE=`$(gb_MKTEMP)` && \
212		echo "-r -p \
213			-lg$(LANGUAGE) \
214			-fs=$@ \
215			-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(RESLOCATION)/$(LIBRARY)) \
216			-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(RESLOCATION)/imglst/$(LANGUAGE)) \
217			-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(RESLOCATION)/imglst) \
218			-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(RESLOCATION)/res/$(LANGUAGE)) \
219			-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(RESLOCATION)/res) \
220			-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(RESLOCATION)) \
221			-lip=$(gb_ResTarget_DEFIMAGESLOCATION)res/$(LANGUAGE) \
222			-lip=$(gb_ResTarget_DEFIMAGESLOCATION)res \
223			-subMODULE=$(dir $(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(RESLOCATION))) \
224			-subGLOBALRES=$(gb_ResTarget_DEFIMAGESLOCATION)res \
225			-oil=$(dir $(call gb_ResTarget_get_imagelist_target,$*)) \
226			$(filter-out $(gb_Helper_MISCDUMMY),$^)" > $${RESPONSEFILE} && \
227		$(gb_ResTarget_RSCCOMMAND) @$${RESPONSEFILE} && \
228		rm -f $${RESPONSEFILE})
229
230$(call gb_ResTarget_get_outdir_target,%) :
231	$(call gb_Helper_abbreviate_dirs,\
232		$(call gb_Deliver_deliver,$<,$@) && \
233		$(call gb_Deliver_deliver,$(dir $<)/$(notdir $(ILSTTARGET)),$(ILSTTARGET)))
234
235define gb_ResTarget_ResTarget
236$(call gb_ResTarget_get_target,$(1)) : LIBRARY = $(2)
237$(call gb_ResTarget_get_target,$(1)) : LANGUAGE = $(3)
238$(call gb_ResTarget_get_target,$(1)) : RESLOCATION = $(2)
239$(call gb_AllLangResTarget_get_target,$(2)) : $(call gb_ResTarget_get_outdir_target,$(1))
240$(call gb_AllLangResTarget_get_clean_target,$(2)) : $(call gb_ResTarget_get_clean_target,$(1))
241$(call gb_ResTarget_get_imagelist_target,$(1)) : $(call gb_ResTarget_get_target,$(1))
242
243$(call gb_ResTarget_get_outdir_target,$(1)) : $(call gb_ResTarget_get_target,$(1))
244$(call gb_ResTarget_get_outdir_target,$(1)) : ILSTTARGET = $(call gb_ResTarget_get_outdir_imagelist_target,$(1))
245$(call gb_Deliver_add_deliverable,$(call gb_ResTarget_get_outdir_target,$(1)),$(call gb_ResTarget_get_target,$(1)),$(1))
246$(call gb_Deliver_add_deliverable,$(call gb_ResTarget_get_outdir_imagelist_target,$(1)),$(call gb_ResTarget_get_imagelist_target,$(1)),$(1))
247
248endef
249
250define gb_ResTarget_add_file
251$(call gb_ResTarget_get_target,$(1)) : $(2)
252
253endef
254
255define gb_ResTarget_add_one_srs
256$(call gb_ResTarget_add_file,$(1),$(call gb_SrsTarget_get_target,$(2)))
257$(call gb_ResTarget_get_clean_target,$(1)) : $(call gb_SrsTarget_get_clean_target,$(2))
258
259endef
260
261define gb_ResTarget_add_files
262$(foreach file,$(2),\
263	$(call gb_ResTarget_add_file,$(1),$(file)))
264
265endef
266
267define gb_ResTarget_add_srs
268$(foreach srs,$(2),\
269	$(call gb_ResTarget_add_one_srs,$(1),$(srs)))
270
271endef
272
273define gb_ResTarget_set_reslocation
274$(call gb_ResTarget_get_target,$(1)) : RESLOCATION = $(2)
275
276endef
277
278
279# AllLangResTarget
280
281gb_AllLangResTarget_LANGS := en-US $(filter-out en-US,$(gb_WITH_LANG))
282
283define gb_AllLangResTarget_set_langs
284gb_AllLangResTarget_LANGS := $(1)
285endef
286
287$(call gb_AllLangResTarget_get_clean_target,%) :
288	$(call gb_Helper_abbreviate_dirs,\
289		rm -f $(call gb_AllLangResTarget_get_target,$*))
290
291$(call gb_AllLangResTarget_get_target,%) :
292	$(call gb_Helper_abbreviate_dirs,\
293		mkdir -p $(dir $@) && touch $@)
294
295define gb_AllLangResTarget_AllLangResTarget
296$(foreach lang,$(gb_AllLangResTarget_LANGS),\
297	$(call gb_ResTarget_ResTarget,$(1)$(lang),$(1),$(lang)))
298$$(eval $$(call gb_Module_register_target,$(call gb_AllLangResTarget_get_target,$(1)),$(call gb_AllLangResTarget_get_clean_target,$(1))))
299
300endef
301
302define gb_AllLangResTarget_add_one_srs
303$(foreach lang,$(gb_AllLangResTarget_LANGS),\
304	$(call gb_ResTarget_add_one_srs,$(1)$(lang),$(2)))
305
306endef
307
308define gb_AllLangResTarget_add_srs
309$(foreach srs,$(2),\
310	$(call gb_AllLangResTarget_add_one_srs,$(1),$(srs)))
311
312endef
313
314define gb_AllLangResTarget_set_reslocation
315$(foreach lang,$(gb_AllLangResTarget_LANGS),\
316	$(call gb_ResTarget_set_reslocation,$(1)$(lang),$(2)))
317
318endef
319
320# vim: set noet sw=4 ts=4:
321