xref: /trunk/main/solenv/gbuild/ComponentTarget.mk (revision b63233d8)
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
24gb_ComponentTarget_REPOS := $(gb_REPOS)
25
26gb_ComponentTarget_XSLTCOMMANDFILE := $(SOLARENV)/bin/createcomponent.xslt
27gb_ComponentTarget_get_source = $(1)/$(2).component
28
29define gb_ComponentTarget__command
30$(call gb_Output_announce,$(3),$(true),CMP,1)
31$(call gb_Helper_abbreviate_dirs_native,\
32	mkdir -p $(dir $(1)) && \
33	$(gb_XSLTPROC) --nonet --stringparam uri \
34    	'$(subst \d,$$,$(COMPONENTPREFIX))$(LIBFILENAME)' -o $(1) \
35		$(gb_ComponentTarget_XSLTCOMMANDFILE) $(2))
36endef
37
38# creates 2 componentfiles: the first is for the installation set,
39# the second is for using the component during the build.
40# bit of a hack, hopefully inbuild can be removed when solver layout is fixed.
41define gb_ComponentTarget__rules
42$$(call gb_ComponentTarget_get_inbuild_target,%) : $$(call gb_ComponentTarget_get_source,$(1),%) | $(gb_XSLTPROCTARGET)
43	$$(call gb_ComponentTarget__command,$$@,$$<,$$*)
44
45$$(call gb_ComponentTarget_get_target,%) : $$(call gb_ComponentTarget_get_source,$(1),%) | $(gb_XSLTPROCTARGET)
46	$$(call gb_ComponentTarget__command,$$@,$$<,$$*)
47
48endef
49
50$(call gb_ComponentTarget_get_clean_target,%) :
51	$(call gb_Output_announce,$$*,$(false),CMP,1)
52	rm -f $(call gb_ComponentTarget_get_outdir_target,$*) \
53		$(call gb_ComponentTarget_get_target,$*) \
54		$(call gb_ComponentTarget_get_outdir_inbuild_target,$*) \
55		$(call gb_ComponentTarget_get_inbuild_target,$*) \
56
57$(foreach repo,$(gb_ComponentTarget_REPOS),$(eval $(call gb_ComponentTarget__rules,$(repo))))
58
59$(call gb_ComponentTarget_get_target,%) :
60	$(eval $(call gb_Outpt_error,Unable to find component file $(call gb_ComponentTarget_get_source,,$*) in the repositories: $(gb_ComponentTarget_REPOS) or xlstproc is missing.))
61
62$(call gb_ComponentTarget_get_external_target,%) :
63	$(call gb_Deliver_deliver,$<,$@)
64
65define gb_ComponentTarget_ComponentTarget
66$(call gb_ComponentTarget_get_target,$(1)) : LIBFILENAME := $(3)
67$(call gb_ComponentTarget_get_inbuild_target,$(1)) : LIBFILENAME := $(3)
68$(call gb_ComponentTarget_get_target,$(1)) : COMPONENTPREFIX := $(2)
69$(call gb_ComponentTarget_get_inbuild_target,$(1)) : \
70	COMPONENTPREFIX := $(call gb_Library__get_layer_componentprefix,NONE)
71$(call gb_ComponentTarget_get_outdir_target,$(1)) : $(call gb_ComponentTarget_get_target,$(1))
72$(call gb_ComponentTarget_get_outdir_inbuild_target,$(1)) : \
73	$(call gb_ComponentTarget_get_inbuild_target,$(1))
74$(call gb_Deliver_add_deliverable,$(call gb_ComponentTarget_get_outdir_target,$(1)),$(call gb_ComponentTarget_get_target,$(1)),$(1))
75$(call gb_Deliver_add_deliverable,$(call gb_ComponentTarget_get_outdir_inbuild_target,$(1)),$(call gb_ComponentTarget_get_inbuild_target,$(1)),$(1))
76
77endef
78
79# vim: set noet sw=4 ts=4:
80