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			$(foreach IMAGELOCATION,$(RESLOCATION) $(IMAGELOCATIONS),\
216				-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(IMAGELOCATION)/$(LIBRARY)) \
217				-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(IMAGELOCATION)/imglst/$(LANGUAGE)) \
218				-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(IMAGELOCATION)/imglst) \
219				-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(IMAGELOCATION)/res/$(LANGUAGE)) \
220				-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(IMAGELOCATION)/res) \
221				-lip=$(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(IMAGELOCATION)) \
222			) \
223			-lip=$(gb_ResTarget_DEFIMAGESLOCATION)res/$(LANGUAGE) \
224			-lip=$(gb_ResTarget_DEFIMAGESLOCATION)res \
225			-subMODULE=$(dir $(realpath $(gb_ResTarget_DEFIMAGESLOCATION)$(RESLOCATION))) \
226			-subGLOBALRES=$(gb_ResTarget_DEFIMAGESLOCATION)res \
227			-oil=$(dir $(call gb_ResTarget_get_imagelist_target,$*)) \
228			$(filter-out $(gb_Helper_MISCDUMMY),$^)" > $${RESPONSEFILE} && \
229		$(gb_ResTarget_RSCCOMMAND) @$${RESPONSEFILE} && \
230		rm -f $${RESPONSEFILE})
231
232$(call gb_ResTarget_get_outdir_target,%) :
233	$(call gb_Helper_abbreviate_dirs,\
234		$(call gb_Deliver_deliver,$<,$@) && \
235		$(call gb_Deliver_deliver,$(dir $<)/$(notdir $(ILSTTARGET)),$(ILSTTARGET)))
236
237define gb_ResTarget_ResTarget
238$(call gb_ResTarget_get_target,$(1)) : LIBRARY = $(2)
239$(call gb_ResTarget_get_target,$(1)) : LANGUAGE = $(3)
240$(call gb_ResTarget_get_target,$(1)) : RESLOCATION = $(2)
241$(call gb_ResTarget_get_target,$(1)) : IMAGELOCATIONS =
242$(call gb_AllLangResTarget_get_target,$(2)) : $(call gb_ResTarget_get_outdir_target,$(1))
243$(call gb_AllLangResTarget_get_clean_target,$(2)) : $(call gb_ResTarget_get_clean_target,$(1))
244$(call gb_ResTarget_get_imagelist_target,$(1)) : $(call gb_ResTarget_get_target,$(1))
245
246$(call gb_ResTarget_get_outdir_target,$(1)) : $(call gb_ResTarget_get_target,$(1))
247$(call gb_ResTarget_get_outdir_target,$(1)) : ILSTTARGET = $(call gb_ResTarget_get_outdir_imagelist_target,$(1))
248$(call gb_Deliver_add_deliverable,$(call gb_ResTarget_get_outdir_target,$(1)),$(call gb_ResTarget_get_target,$(1)),$(1))
249$(call gb_Deliver_add_deliverable,$(call gb_ResTarget_get_outdir_imagelist_target,$(1)),$(call gb_ResTarget_get_imagelist_target,$(1)),$(1))
250
251endef
252
253define gb_ResTarget_add_file
254$(call gb_ResTarget_get_target,$(1)) : $(2)
255
256endef
257
258define gb_ResTarget_add_one_srs
259$(call gb_ResTarget_add_file,$(1),$(call gb_SrsTarget_get_target,$(2)))
260$(call gb_ResTarget_get_clean_target,$(1)) : $(call gb_SrsTarget_get_clean_target,$(2))
261
262endef
263
264define gb_ResTarget_add_files
265$(foreach file,$(2),\
266	$(call gb_ResTarget_add_file,$(1),$(file)))
267
268endef
269
270define gb_ResTarget_add_srs
271$(foreach srs,$(2),\
272	$(call gb_ResTarget_add_one_srs,$(1),$(srs)))
273
274endef
275
276define gb_ResTarget_set_reslocation
277$(call gb_ResTarget_get_target,$(1)) : RESLOCATION = $(2)
278
279endef
280
281define gb_ResTarget_set_imagelocations
282$(call gb_ResTarget_get_target,$(1)) : IMAGELOCATIONS = $(2)
283
284endef
285
286
287# AllLangResTarget
288
289gb_AllLangResTarget_LANGS := en-US $(filter-out en-US,$(gb_WITH_LANG))
290
291define gb_AllLangResTarget_set_langs
292gb_AllLangResTarget_LANGS := $(1)
293endef
294
295$(call gb_AllLangResTarget_get_clean_target,%) :
296	$(call gb_Helper_abbreviate_dirs,\
297		rm -f $(call gb_AllLangResTarget_get_target,$*))
298
299$(call gb_AllLangResTarget_get_target,%) :
300	$(call gb_Helper_abbreviate_dirs,\
301		mkdir -p $(dir $@) && touch $@)
302
303define gb_AllLangResTarget_AllLangResTarget
304$(foreach lang,$(gb_AllLangResTarget_LANGS),\
305	$(call gb_ResTarget_ResTarget,$(1)$(lang),$(1),$(lang)))
306$$(eval $$(call gb_Module_register_target,$(call gb_AllLangResTarget_get_target,$(1)),$(call gb_AllLangResTarget_get_clean_target,$(1))))
307
308endef
309
310define gb_AllLangResTarget_add_one_srs
311$(foreach lang,$(gb_AllLangResTarget_LANGS),\
312	$(call gb_ResTarget_add_one_srs,$(1)$(lang),$(2)))
313
314endef
315
316define gb_AllLangResTarget_add_srs
317$(foreach srs,$(2),\
318	$(call gb_AllLangResTarget_add_one_srs,$(1),$(srs)))
319
320endef
321
322define gb_AllLangResTarget_set_reslocation
323$(foreach lang,$(gb_AllLangResTarget_LANGS),\
324	$(call gb_ResTarget_set_reslocation,$(1)$(lang),$(2)))
325endef
326
327define gb_AllLangResTarget_set_imagelocations
328$(foreach lang,$(gb_AllLangResTarget_LANGS),\
329	$(call gb_ResTarget_set_imagelocations,$(1)$(lang),$(2)))
330endef
331
332# vim: set noet sw=4 ts=4:
333