summaryrefslogtreecommitdiffstats
path: root/solenv/gbuild/InstallModuleTarget.mk
blob: 3ae5f67e0839f90277d794ad7bd7b3e1e5240747 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

# Overview of dependencies and tasks of InstallModuleTarget
# target						task						depends on

# ScpTemplateTarget class

gb_ScpTemplateTarget_TARGET := $(SRCDIR)/scp2/source/templates/modules.pl
gb_ScpTemplateTarget_COMMAND := $(PERL) -w $(gb_ScpTemplateTarget_TARGET)

gb_ScpTemplateTarget_LANGS := $(sort $(ALL_LANGS))

# Pass first arg if make is running in silent mode, second arg otherwise
define gb_ScpTemplateTarget__if_silent
$(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),$(1),$(2))
endef

gb_ScpTemplateTarget_get_source = $(SRCDIR)/$(1).sct

define gb_ScpTemplateTarget__command
$(call gb_Helper_abbreviate_dirs,\
	export COMPLETELANGISO_VAR='$(gb_ScpTemplateTarget_LANGS)' && \
	$(gb_ScpTemplateTarget_COMMAND) \
		$(call gb_ScpTemplateTarget__if_silent,,-verbose) \
		-i $(SCP_TEMPLATE) \
		-o $(1) \
)
endef

$(dir $(call gb_ScpTemplateTarget_get_target,%))%/.dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

# depend on configure output to rebuild everything
$(call gb_ScpTemplateTarget_get_target,%) : \
		$(gb_ScpTemplateTarget_TARGET) $(BUILDDIR)/config_$(gb_Side).mk
	$(call gb_Output_announce,$*,$(true),SCT,1)
	$(call gb_Trace_StartRange,$*,SCT)
	$(call gb_ScpTemplateTarget__command,$@,$*)
	$(call gb_Trace_EndRange,$*,SCT)

.PHONY : $(call gb_ScpTemplateTarget_get_clean_target,%)
$(call gb_ScpTemplateTarget_get_clean_target,%) :
	$(call gb_Output_announce,$*,$(false),SCT,1)
	rm -f $(call gb_ScpTemplateTarget_get_target,$*)

# gb_ScpTemplateTarget_ScpTemplateTarget(<target>)
define gb_ScpTemplateTarget_ScpTemplateTarget
$(call gb_ScpTemplateTarget_get_target,$(1)) : $(call gb_ScpTemplateTarget_get_source,$(1))
$(call gb_ScpTemplateTarget_get_target,$(1)) :| $(dir $(call gb_ScpTemplateTarget_get_target,$(1))).dir
$(call gb_ScpTemplateTarget_get_target,$(1)) : SCP_TEMPLATE := $(call gb_ScpTemplateTarget_get_source,$(1))

endef

# ScpPreprocessTarget class

gb_ScpPreprocessTarget_DEPS := $(call gb_Executable_get_runtime_dependencies,cpp)
gb_ScpPreprocessTarget_COMMAND := $(call gb_Executable_get_command,cpp)

gb_ScpPreprocessTarget_get_source = $(SRCDIR)/$(1).scp

define gb_ScpPreprocessTarget__command
$(call gb_Helper_abbreviate_dirs,\
	$(gb_ScpPreprocessTarget_COMMAND) \
		-+ -P \
		$(SCPDEFS) $(SCP_DEFS) \
		$(SCP_INCLUDE) $(SCP_TEMPLATE_INCLUDE) \
	    $(if $(ENABLE_JAVA),-DENABLE_JAVA) \
		$(SCP_SOURCE) > $(1) \
)
endef

$(dir $(call gb_ScpPreprocessTarget_get_target,%))%/.dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

# depend on configure output to rebuild everything
$(call gb_ScpPreprocessTarget_get_target,%) : \
		$(gb_ScpPreprocessTarget_DEPS) $(BUILDDIR)/config_$(gb_Side).mk
	$(call gb_Output_announce,$*,$(true),SPP,2)
	$(call gb_Trace_StartRange,$*,SPP)
	$(call gb_ScpPreprocessTarget__command,$@,$*)
	$(call gb_Trace_EndRange,$*,SPP)

.PHONY : $(call gb_ScpPreprocessTarget_get_clean_target,%)
$(call gb_ScpPreprocessTarget_get_clean_target,%) :
	$(call gb_Output_announce,$*,$(false),SPP,2)
	rm -f $(call gb_ScpPreprocessTarget_get_target,$*)

# gb_ScpPreprocessTarget_ScpPreprocessTarget(<target>)
define gb_ScpPreprocessTarget_ScpPreprocessTarget
$(call gb_ScpPreprocessTarget_get_target,$(1)) : SCP_SOURCE := $(call gb_ScpPreprocessTarget_get_source,$(1))
$(call gb_ScpPreprocessTarget_get_target,$(1)) : $(call gb_ScpPreprocessTarget_get_source,$(1))
$(call gb_ScpPreprocessTarget_get_target,$(1)) :| $(dir $(call gb_ScpPreprocessTarget_get_target,$(1))).dir

endef

# ScpMergeTarget class

gb_ScpMergeTarget_get_source = $(SRCDIR)/$(1).ulf

$(dir $(call gb_ScpMergeTarget_get_target,%)).dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

$(dir $(call gb_ScpMergeTarget_get_target,%))%/.dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

$(eval $(call gb_CustomTarget_ulfex_rule,\
	$(call gb_ScpMergeTarget_get_target,%),\
	$(call gb_ScpMergeTarget_get_source,%),\
	$$(SCP_POFILES)))

.PHONY : $(call gb_ScpMergeTarget_get_clean_target,%)
$(call gb_ScpMergeTarget_get_clean_target,%) :
	$(call gb_Output_announce,$*,$(false),SUM,1)
	rm -f $(call gb_ScpMergeTarget_get_target,$*)

# gb_ScpMergeTarget_ScpMergeTarget(<target>)
define gb_ScpMergeTarget_ScpMergeTarget
$(call gb_ScpMergeTarget_get_target,$(1)) :| $(dir $(call gb_ScpMergeTarget_get_target,$(1))).dir
$(call gb_ScpMergeTarget_get_target,$(1)) : \
	SCP_POFILES := $(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po)
$(call gb_ScpMergeTarget_get_target,$(1)) : \
	$(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po)
$(foreach lang,$(gb_TRANS_LANGS),$(gb_POLOCATION)/$(lang)/$(patsubst %/,%,$(dir $(1))).po) :

endef

# ScpTarget class

gb_ScpTarget_TARGET := $(SRCDIR)/solenv/bin/pre2par.pl
gb_ScpTarget_COMMAND := $(PERL) $(gb_ScpTarget_TARGET)

define gb_ScpTarget__command
$(call gb_Helper_abbreviate_dirs,\
	$(gb_ScpTarget_COMMAND) -l $(SCP_ULF) -s $(SCP_SOURCE) -o $(1) \
)
endef

$(dir $(call gb_ScpTarget_get_target,%))%/.dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

$(call gb_ScpTarget_get_target,%) : $(gb_ScpTarget_TARGET)
	$(call gb_Output_announce,$*,$(true),SCP,2)
	$(call gb_Trace_StartRange,$*,SCP)
	$(call gb_ScpTarget__command,$@,$*)
	$(call gb_Trace_EndRange,$*,SCP)

$(call gb_ScpTarget_get_external_target,%) :
	touch $@

.PHONY : $(call gb_ScpTarget_get_clean_target,%)
$(call gb_ScpTarget_get_clean_target,%) :
	$(call gb_Output_announce,$*,$(false),SCP,2)
	rm -f \
		$(call gb_ScpTarget_get_target,$*) \
		$(call gb_ScpTarget_get_external_target,$*)

# gb_ScpTarget_ScpTarget(<target>)
define gb_ScpTarget_ScpTarget
$(call gb_ScpPreprocessTarget_ScpPreprocessTarget,$(1))

$(call gb_ScpTarget_get_target,$(1)) : $(call gb_ScpPreprocessTarget_get_target,$(1))
$(call gb_ScpTarget_get_target,$(1)) : $(call gb_ScpTarget_get_external_target,$(1))
$(call gb_ScpTarget_get_external_target,$(1)) :| $(dir $(call gb_ScpTarget_get_target,$(1))).dir
$(call gb_ScpPreprocessTarget_get_target,$(1)) : $(call gb_ScpTarget_get_external_target,$(1))
$(call gb_ScpTarget_get_clean_target,$(1)) : $(call gb_ScpPreprocessTarget_get_clean_target,$(1))
$(call gb_ScpTarget_get_target,$(1)) : SCP_SOURCE := $(call gb_ScpPreprocessTarget_get_target,$(1))
$(call gb_ScpTarget_get_target,$(1)) : SCP_ULF := $(gb_Helper_PHONY)

endef

define gb_ScpTarget_set_localized
ifneq ($(gb_WITH_LANG),)
$(call gb_ScpMergeTarget_ScpMergeTarget,$(1))
$(call gb_ScpTarget_get_target,$(1)) : SCP_ULF := $(call gb_ScpMergeTarget_get_target,$(1))
$(call gb_ScpTarget_get_target,$(1)) : $(call gb_ScpMergeTarget_get_target,$(1))
$(call gb_ScpTarget_get_clean_target,$(1)) : $(call gb_ScpMergeTarget_get_clean_target,$(1))
else
$(call gb_ScpTarget_get_target,$(1)) : SCP_ULF := $(call gb_ScpMergeTarget_get_source,$(1))
$(call gb_ScpTarget_get_target,$(1)) : $(call gb_ScpMergeTarget_get_source,$(1))
endif

endef

# InstallModuleTarget class

# platform:
#  gb_InstallModuleTarget_InstallModuleTarget_platform

define gb_InstallModuleTarget__command
$(call gb_Helper_abbreviate_dirs,\
	rm -f $(1) \
	$(foreach scpfile,$(SCP_FILES),&& echo $(scpfile) >> $(1)) \
)
endef

$(dir $(call gb_InstallModuleTarget_get_target,%))%/.dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

$(call gb_InstallModuleTarget_get_target,%) :
	$(call gb_Output_announce,$*,$(true),INM,3)
	$(call gb_Trace_StartRange,$*,INM)
	$(call gb_InstallModuleTarget__command,$@,$*)
	$(call gb_Trace_EndRange,$*,INM)

$(call gb_InstallModuleTarget_get_external_target,%) :
	touch $@

.PHONY : $(call gb_InstallModuleTarget_get_clean_target,%)
$(call gb_InstallModuleTarget_get_clean_target,%) :
	$(call gb_Output_announce,$*,$(false),INM,3)
	rm -rf \
		$(call gb_InstallModuleTarget_get_target,$*) \
		$(call gb_InstallModuleTarget_get_external_target,$*)

define gb_InstallModuleTarget_InstallModuleTarget
$(call gb_InstallModuleTarget_get_target,$(1)) : \
	$(call gb_InstallModuleTarget_get_external_target,$(1))
$(call gb_InstallModuleTarget_get_external_target,$(1)) :| \
	$(dir $(call gb_InstallModuleTarget_get_target,$(1))).dir

$(call gb_InstallModuleTarget_get_target,$(1)) : SCP_FILES :=
$(call gb_InstallModuleTarget_get_target,$(1)) : SCP_DEFS :=
$(call gb_InstallModuleTarget_get_target,$(1)) : SCP_INCLUDE := -I$(SRCDIR)/scp2/inc -I$(WORKDIR) -I$(BUILDDIR)/config_$(gb_Side)
$(call gb_InstallModuleTarget_get_target,$(1)) : SCP_TEMPLATE_INCLUDE :=
$(call gb_InstallModuleTarget_use_custom_headers,$(1),scp2/macros)

$(call gb_InstallModuleTarget_InstallModuleTarget_platform,$(1))

endef

define gb_InstallModuleTarget_add_defs
$(call gb_InstallModuleTarget_get_target,$(1)) : SCP_DEFS += $(2)

endef

define gb_InstallModuleTarget_define_if_set
$(call gb_InstallModuleTarget_add_defs,$(1),\
	$(foreach def,$(2),$(if $(filter TRUE YES,$($(def))),-D$(def))) \
)

endef

define gb_InstallModuleTarget_define_value_if_set
$(call gb_InstallModuleTarget_add_defs,$(1),\
	$(foreach def,$(2),$(if $($(def)),-D$(def)=\""$($(def))"\")) \
)

endef

define gb_InstallModuleTarget_use_auto_install_libs
$(call gb_InstallModuleTarget_get_external_target,$(1)) : $(foreach ai,$(2),$(call gb_AutoInstall_get_target,$(ai)))

endef

define gb_InstallModuleTarget_use_custom_header
$(call gb_InstallModuleTarget_get_external_target,$(1)) : $(call gb_CustomTarget_get_target,$(2))
$(call gb_InstallModuleTarget_get_target,$(1)) : SCP_INCLUDE += -I$(call gb_CustomTarget_get_workdir,$(2)) \

endef

define gb_InstallModuleTarget_use_custom_headers
$(foreach customtarget,$(2),$(call gb_InstallModuleTarget_use_custom_header,$(1),$(customtarget)))

endef

define gb_InstallModuleTarget_add_scpfile
$(call gb_ScpTarget_ScpTarget,$(2))
$(call gb_InstallModuleTarget_get_target,$(1)) : $(call gb_ScpTarget_get_target,$(2))
$(call gb_InstallModuleTarget_get_clean_target,$(1)) : $(call gb_ScpTarget_get_clean_target,$(2))
$(call gb_InstallModuleTarget_get_target,$(1)) : SCP_FILES += $(call gb_ScpTarget_get_target,$(2))
$(call gb_ScpTarget_get_external_target,$(2)) : $(call gb_InstallModuleTarget_get_external_target,$(1))

endef

define gb_InstallModuleTarget_add_scpfiles
$(foreach scpfile,$(2),$(call gb_InstallModuleTarget_add_scpfile,$(1),$(scpfile)))

endef

define gb_InstallModuleTarget_add_localized_scpfile
$(call gb_InstallModuleTarget_add_scpfile,$(1),$(2))
$(call gb_ScpTarget_set_localized,$(2))

endef

define gb_InstallModuleTarget_add_localized_scpfiles
$(foreach scpfile,$(2),$(call gb_InstallModuleTarget_add_localized_scpfile,$(1),$(scpfile)))

endef

define gb_InstallModuleTarget_add_template
$(call gb_ScpTemplateTarget_ScpTemplateTarget,$(2))
$(call gb_InstallModuleTarget_get_external_target,$(1)) : $(call gb_ScpTemplateTarget_get_target,$(2))
$(call gb_InstallModuleTarget_get_clean_target,$(1)) : $(call gb_ScpTemplateTarget_get_clean_target,$(2))
$(call gb_InstallModuleTarget_get_target,$(1)) : \
	SCP_TEMPLATE_INCLUDE := $$(sort $$(SCP_TEMPLATE_INCLUDE) -I$(call gb_ScpTemplateTarget_get_dir,$(2)))

endef

define gb_InstallModuleTarget_add_templates
$(foreach template,$(2),$(call gb_InstallModuleTarget_add_template,$(1),$(template)))

endef

# vim: set shiftwidth=4 tabstop=4 noexpandtab: