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