1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 # This file incorporates work covered by the following license notice:
11 # Licensed to the Apache Software Foundation (ASF) under one or more
12 # contributor license agreements. See the NOTICE file distributed
13 # with this work for additional information regarding copyright
14 # ownership. The ASF licenses this file to you under the Apache
15 # License, Version 2.0 (the "License"); you may not use this file
16 # except in compliance with the License. You may obtain a copy of
17 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 # a pattern rule with multiple targets is actually executed only once for each
24 # match, so define only pattern rules with one target here
25 # the .dir is for make 3.81, which ignores trailing /
26 define gb_PackagePart__rule
28 $$(if
$$(wildcard $$(dir $$@
)),,mkdir
-p
$$(dir $$@
))
30 $$(if
$$(wildcard $$(dir $$@
)),,mkdir
-p
$$(dir $$@
))
32 $$(call gb_Deliver_deliver
,$$<,$$@
)
35 $(foreach destination
,$(call gb_PackagePart_get_destinations
),$(eval \
36 $(call gb_PackagePart__rule
,$(destination
))))
38 # Deliver one file to the output dir.
40 # gb_PackagePart_PackagePart destfile source prep-target outdir
41 define gb_PackagePart_PackagePart
42 $(4)/$(1) : $(2) |
$(dir $(4)/$(1)).
dir
45 $(if
$(gb_Package_PRESTAGEDIR
),\
46 $(if
$(wildcard $(gb_Package_PRESTAGEDIR
)/$(1)),\
47 $(call gb_Deliver_add_deliverable
,$(4)/$(1),$(gb_Package_PRESTAGEDIR
)/$(1),$(3)),\
48 $(call gb_Deliver_add_deliverable
,$(4)/$(1),$(2),$(3)) \
50 $(call gb_Deliver_add_deliverable
,$(4)/$(1),$(2),$(3)) \
58 $(dir $(call gb_Package_get_target
,%)).
dir :
59 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
61 $(dir $(call gb_Package_get_target
,%))%/.
dir :
62 $(if
$(wildcard $(dir $@
)),,mkdir
-p
$(dir $@
))
64 .PHONY
: $(call gb_Package_get_clean_target
,%)
65 $(call gb_Package_get_clean_target
,%) :
66 $(call gb_Output_announce
,$*,$(false
),PKG
,2)
67 RESPONSEFILE
=$(call var2file
,$(shell $(gb_MKTEMP
)),500,$(FILES
)) \
68 && cat
$${RESPONSEFILE} | xargs
$(if
$(filter MACOSX
,$(OS_FOR_BUILD
)),-n
1000) rm -f \
69 && rm -f
$${RESPONSEFILE}
71 $(call gb_Package_get_preparation_target
,%) :
72 mkdir
-p
$(dir $@
) && touch
$@
74 # NOTE: It is possible that a file has been added to the package more
75 # than once, so we must drop the duplicates, or Windows installer will
77 # TODO: this is only for convenience for impl. of gbuild classes. There
78 # should be check that it does not happen in "normal" use, i.e., in
79 # Package_foo makefiles.
80 $(call gb_Package_get_target
,%) :
81 $(call gb_Output_announce
,$*,$(true
),PKG
,2)
82 $(if
$(PACAKGE_DEFINED
),,$(call gb_Output_error
,Something depends on package
$* which does not exist.
))
84 mv
$(call var2file
,$@.tmp
,100,$(sort $(FILES
))) $@
86 # for other targets that want to create Packages, does not register at Module
87 define gb_Package_Package_internal
88 gb_Package_SOURCEDIR_
$(1) := $(2)
89 gb_Package_OUTDIR_
$(1) := $(INSTROOT
)
90 $(call gb_Package_get_target
,$(1)) : PACAKGE_DEFINED
:= $(true
)
91 $(call gb_Package_get_target
,$(1)) : FILES
:=
92 $(call gb_Package_get_clean_target
,$(1)) : FILES
:= $(call gb_Package_get_target
,$(1)) $(call gb_Package_get_preparation_target
,$(1))
93 $(call gb_Package_get_target
,$(1)) : $(call gb_Package_get_preparation_target
,$(1))
94 $(call gb_Package_get_target
,$(1)) : $(gb_Module_CURRENTMAKEFILE
)
95 $(call gb_Package_get_target
,$(1)) :|
$(dir $(call gb_Package_get_target
,$(1))).
dir
99 define gb_Package_Package
100 $$(if
$$(gb_Package_SOURCEDIR_
$(1)),$$(call gb_Output_error
,gb_Package__check
: Package
$(1) has already been defined
))
101 $(if
$(filter postprocess
% instsetoo_native
%,$(1)),,\
102 $(call gb_Postprocess_register_target
,AllPackages
,Package
,$(1)))
103 $(call gb_Package_Package_internal
,$(1),$(2))
104 $$(eval
$$(call gb_Module_register_target
,$(call gb_Package_get_target
,$(1)),$(call gb_Package_get_clean_target
,$(1))))
105 $(call gb_Helper_make_userfriendly_targets
,$(1),Package
)
109 # Ensure that the package is defined.
111 # gb_Package__check package
112 define gb_Package__check
113 $$(if
$$(gb_Package_SOURCEDIR_
$(1)),,$$(call gb_Output_error
,gb_Package__check
: Package
$(1) has not been defined
))
117 # Set output dir for the package files.
119 # Default is $(INSTROOT).
121 # gb_Package_set_outdir package outdir
122 define gb_Package_set_outdir
123 $(call gb_Package__check
,$(1))
124 gb_Package_OUTDIR_
$(1) := $(2)
128 define gb_Package_add_symbolic_link
129 $(call gb_Package__check
,$(1))
130 $(if
$(strip $(3)),,$(call gb_Output_error
,gb_Package_add_symbolic_link requires
3 arguments
))
131 $(call gb_Package_get_target
,$(1)) : $$(gb_Package_OUTDIR_
$(1))/$(2)
132 $$(gb_Package_OUTDIR_
$(1))/$(2) :|
$$(dir $$(gb_Package_OUTDIR_
$(1))/$(2)).
dir
133 rm -f
$$@
&& ln
-s
$(3) $$@
135 $(call gb_Package_get_target
,$(1)) : FILES
+= $$(gb_Package_OUTDIR_
$(1))/$(2)
136 $(call gb_Package_get_clean_target
,$(1)) : FILES
+= $$(gb_Package_OUTDIR_
$(1))/$(2)
140 define gb_Package_add_file
141 $(call gb_Package__check
,$(1))
142 $(if
$(strip $(3)),,$(call gb_Output_error
,gb_Package_add_file requires
3 arguments
))
143 $(call gb_Package_get_target
,$(1)) : $$(gb_Package_OUTDIR_
$(1))/$(2)
144 $(call gb_Package_get_target
,$(1)) : FILES
+= $$(gb_Package_OUTDIR_
$(1))/$(2)
145 $(call gb_Package_get_clean_target
,$(1)) : FILES
+= $$(gb_Package_OUTDIR_
$(1))/$(2)
146 $(call gb_PackagePart_PackagePart
,$(2),$$(gb_Package_SOURCEDIR_
$(1))/$(3),$(call gb_Package_get_preparation_target
,$(1)),$$(gb_Package_OUTDIR_
$(1)))
150 # Adds several files at once.
152 # Files are copied directly into the specified directory.
155 # $(eval $(call gb_Package_Package,foo_inc,$(SRCDIR)/foo/inc))
156 # $(eval $(call gb_Package_add_files,foo_inc,inc/foo,foo/bar/foo.hxx))
157 # # -> inc/foo/foo.hxx
158 define gb_Package_add_files
159 $(call gb_Package__check
,$(1))
160 $(if
$(strip $(3)),,$(if
$(filter 1,$(words $(2))),,$(call gb_Output_error
,gb_Package_add_files
: it looks like either pkg name or dest.
dir is missing
)))
161 $(foreach file
,$(3),$(call gb_Package_add_file
,$(1),$(2)/$(notdir $(file
)),$(file
)))
165 # Adds several files at once.
167 # Files are copied including subdirectories.
170 # $(eval $(call gb_Package_Package,foo_inc,$(SRCDIR)/foo/inc))
171 # $(eval $(call gb_Package_add_files,foo_inc,inc,foo/bar/foo.hxx))
172 # # -> inc/foo/bar/foo.hxx
173 define gb_Package_add_files_with_dir
174 $(call gb_Package__check
,$(1))
175 $(if
$(strip $(3)),,$(if
$(filter 1,$(words $(2))),,$(call gb_Output_error
,gb_Package_add_files
: it looks like either pkg name or dest.
dir is missing
)))
176 $(foreach file
,$(3),$(call gb_Package_add_file
,$(1),$(2)/$(file
),$(file
)))
180 # Package files from custom target
181 define gb_Package_use_custom_target
182 $(call gb_Package__check
,$(1))
183 $(call gb_Package_get_preparation_target
,$(1)) :|
$(call gb_CustomTarget_get_target
,$(2))
187 # Package files from unpacked tarball of an external project
188 define gb_Package_use_unpacked
189 $(call gb_Package__check
,$(1))
190 $(call gb_Package_get_preparation_target
,$(1)) :|
$(call gb_UnpackedTarball_get_target
,$(2))
194 # Package files from build of an external project
195 define gb_Package_use_external_project
196 $(call gb_Package__check
,$(1))
197 $(call gb_Package_get_preparation_target
,$(1)) :|
$(call gb_ExternalProject_get_target
,$(2))
201 # vim: set noet sw=4: