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