xref: /aoo4110/main/solenv/gbuild/Package.mk (revision b1cdbd2c)
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
25# PackagePart class
26
27$(foreach destination,$(call gb_PackagePart_get_destinations), $(destination)/%) :
28	$(call gb_Deliver_deliver,$<,$@)
29
30define gb_PackagePart_PackagePart
31$(OUTDIR)/$(1) : $(2)
32$(2) :| $(3)
33$(call gb_Deliver_add_deliverable,$(OUTDIR)/$(1),$(2))
34
35endef
36
37
38# Package class
39
40.PHONY : $(call gb_Package_get_clean_target,%)
41$(call gb_Package_get_clean_target,%) :
42	$(call gb_Output_announce,$*,$(false),PKG,2)
43	-$(call gb_Helper_abbreviate_dirs,\
44		rm -f $(FILES))
45
46$(call gb_Package_get_preparation_target,%) :
47	mkdir -p $(dir $@) && touch $@
48
49$(call gb_Package_get_target,%) :
50	$(call gb_Output_announce,$*,$(true),PKG,2)
51	mkdir -p $(dir $@) && touch $@
52
53
54define gb_Package_Package
55gb_Package_SOURCEDIR_$(1) := $(2)
56$(call gb_Package_get_clean_target,$(1)) : FILES := $(call gb_Package_get_target,$(1)) $(call gb_Package_get_preparation_target,$(1))
57$$(eval $$(call gb_Module_register_target,$(call gb_Package_get_target,$(1)),$(call gb_Package_get_clean_target,$(1))))
58$(call gb_Package_get_target,$(1)) : $(call gb_Package_get_preparation_target,$(1))
59
60endef
61
62define gb_Package_add_file
63$(call gb_Package_get_target,$(1)) : $(OUTDIR)/$(2)
64$(call gb_Package_get_clean_target,$(1)) : FILES += $(OUTDIR)/$(2)
65$(call gb_PackagePart_PackagePart,$(2),$$(gb_Package_SOURCEDIR_$(1))/$(3),$(call gb_Package_get_preparation_target,$(1)))
66
67endef
68
69#
70# Add multiple files $(3), which are located in directory $(2) to the package $(1).
71#
72define gb_Package_add_files
73$(foreach header,$(3), $(call gb_Package_add_file,$(strip $(1)),$(strip $(2))/$(header),$(header)))
74endef
75
76define gb_Package_add_customtarget
77$(call gb_Package_get_preparation_target,$(1)) : $(call gb_CustomTarget_get_target,$(2))
78$(call gb_Package_get_clean_target,$(1)) : $(call gb_CustomTarget_get_clean_target,$(2))
79$(call gb_CustomTarget_CustomTarget,$(2))
80
81endef
82
83# vim: set noet sw=4 ts=4:
84