bump product version to 7.2.5.1
[LibreOffice.git] / solenv / gbuild / Package.mk
blob90e22806c99445e8c8187e5371fc3ff933b900fa
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 .
21 # PackagePart class
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
27 $(1)/.dir :
28 $$(if $$(wildcard $$(dir $$@)),,mkdir -p $$(dir $$@))
29 $(1)/%/.dir :
30 $$(if $$(wildcard $$(dir $$@)),,mkdir -p $$(dir $$@))
31 $(1)/% :
32 $$(call gb_Deliver_deliver,$$<,$$@)
33 endef
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
43 $(2) :| $(3)
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)) \
49 ),\
50 $(call gb_Deliver_add_deliverable,$(4)/$(1),$(2),$(3)) \
53 endef
56 # Package class
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} | $(if $(filter WNT,$(OS)),env -i PATH="$$PATH") xargs $(if $(filter MACOSX,$(OS_FOR_BUILD)),-n 1000) rm -fr \
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
76 # be unhappy.
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 $(call gb_Trace_StartRange,$*,PKG)
83 $(if $(PACKAGE_DEFINED),,$(call gb_Output_error,Something depends on package $* which does not exist.))
84 rm -f $@ && \
85 mv $(call var2file,$@.tmp,100,$(sort $(FILES))) $@
86 $(call gb_Trace_EndRange,$*,PKG)
88 # for other targets that want to create Packages, does not register at Module
89 define gb_Package_Package_internal
90 gb_Package_SOURCEDIR_$(1) := $(2)
91 gb_Package_OUTDIR_$(1) := $(INSTROOT)
92 $(call gb_Package_get_target,$(1)) : PACKAGE_DEFINED := $(true)
93 $(call gb_Package_get_target,$(1)) : FILES :=
94 $(call gb_Package_get_clean_target,$(1)) : FILES := $(call gb_Package_get_target,$(1)) $(call gb_Package_get_preparation_target,$(1))
95 $(call gb_Package_get_target,$(1)) : $(call gb_Package_get_preparation_target,$(1))
96 $(call gb_Package_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
97 $(call gb_Package_get_target,$(1)) :| $(dir $(call gb_Package_get_target,$(1))).dir
99 endef
101 define gb_Package_Package
102 $$(if $$(gb_Package_SOURCEDIR_$(1)),$$(call gb_Output_error,gb_Package__check: Package $(1) has already been defined))
103 $(if $(filter postprocess% instsetoo_native%,$(1)),,\
104 $(call gb_Postprocess_register_target,AllPackages,Package,$(1)))
105 ifeq (,$$(filter $(1),$$(gb_Package_REGISTERED)))
106 $$(eval $$(call gb_Output_info,Currently known packages are: $(sort $(gb_Package_REGISTERED)),ALL))
107 $$(eval $$(call gb_Output_error,Package $(1) must be registered in Repository.mk or RepositoryExternal.mk))
108 endif
109 $(call gb_Package_Package_internal,$(1),$(2))
110 $$(eval $$(call gb_Module_register_target,$(call gb_Package_get_target,$(1)),$(call gb_Package_get_clean_target,$(1))))
111 $(call gb_Helper_make_userfriendly_targets,$(1),Package)
113 endef
115 # Ensure that the package is defined.
117 # gb_Package__check package
118 define gb_Package__check
119 $$(if $$(gb_Package_SOURCEDIR_$(1)),,$$(call gb_Output_error,gb_Package__check: Package $(1) has not been defined))
121 endef
123 # Set output dir for the package files.
125 # Default is $(INSTROOT).
127 # gb_Package_set_outdir package outdir
128 define gb_Package_set_outdir
129 $(call gb_Package__check,$(1))
130 gb_Package_OUTDIR_$(1) := $(2)
132 endef
134 # Add empty directory (if it's non-empty, don't use this, use
135 # gb_Package_add_file for the files in it instead!)
136 define gb_Package_add_empty_directory
137 $(call gb_Package__check,$(1))
138 $(if $(strip $(2)),,$(call gb_Output_error,gb_Package_add_directory requires 2 arguments))
139 $(call gb_Package_get_target,$(1)) :| $$(gb_Package_OUTDIR_$(1))/$(2)/.dir
140 $(call gb_Package_get_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
141 $(call gb_Package_get_clean_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
143 endef
145 # Example:
146 # $(eval $(call gb_Package_add_empty_directories,foo_inc,inc/foo))
147 # # -> inc/foo
148 define gb_Package_add_empty_directories
149 $(call gb_Package__check,$(1))
150 $(foreach file,$(2),$(call gb_Package_add_empty_directory,$(1),$(file)))
152 endef
154 define gb_Package_add_symbolic_link
155 $(call gb_Package__check,$(1))
156 $(if $(strip $(3)),,$(call gb_Output_error,gb_Package_add_symbolic_link requires 3 arguments))
157 $(call gb_Package_get_target,$(1)) : $$(gb_Package_OUTDIR_$(1))/$(2)
158 $$(gb_Package_OUTDIR_$(1))/$(2) :| $$(dir $$(gb_Package_OUTDIR_$(1))/$(2)).dir
159 rm -f $$@ && ln -s $(3) $$@
161 $(call gb_Package_get_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
162 $(call gb_Package_get_clean_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
164 endef
166 define gb_Package_add_file
167 $(call gb_Package__check,$(1))
168 $(if $(strip $(3)),,$(call gb_Output_error,gb_Package_add_file requires 3 arguments))
169 $(call gb_Package_get_target,$(1)) : $$(gb_Package_OUTDIR_$(1))/$(2)
170 $(call gb_Package_get_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
171 $(call gb_Package_get_clean_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
172 $(call gb_PackagePart_PackagePart,$(2),$$(gb_Package_SOURCEDIR_$(1))/$(3),$(call gb_Package_get_preparation_target,$(1)),$$(gb_Package_OUTDIR_$(1)))
174 endef
176 # Adds several files at once.
178 # Files are copied directly into the specified directory.
180 # Example:
181 # $(eval $(call gb_Package_Package,foo_inc,$(SRCDIR)/foo/inc))
182 # $(eval $(call gb_Package_add_files,foo_inc,inc/foo,foo/bar/foo.hxx))
183 # # -> inc/foo/foo.hxx
184 define gb_Package_add_files
185 $(call gb_Package__check,$(1))
186 $(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)))
187 $(foreach file,$(3),$(call gb_Package_add_file,$(1),$(2)/$(notdir $(file)),$(file)))
189 endef
191 # Adds several files at once.
193 # Files are copied including subdirectories.
195 # Example:
196 # $(eval $(call gb_Package_Package,foo_inc,$(SRCDIR)/foo/inc))
197 # $(eval $(call gb_Package_add_files,foo_inc,inc,foo/bar/foo.hxx))
198 # # -> inc/foo/bar/foo.hxx
199 define gb_Package_add_files_with_dir
200 $(call gb_Package__check,$(1))
201 $(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)))
202 $(foreach file,$(3),$(call gb_Package_add_file,$(1),$(2)/$(file),$(file)))
204 endef
206 # Package files from custom target
207 define gb_Package_use_custom_target
208 $(call gb_Package__check,$(1))
209 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_CustomTarget_get_target,$(2))
211 endef
213 # Package files from unpacked tarball of an external project
214 define gb_Package_use_unpacked
215 $(call gb_Package__check,$(1))
216 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_UnpackedTarball_get_target,$(2))
218 endef
220 # Package files from build of an external project
221 define gb_Package_use_external_project
222 $(call gb_Package__check,$(1))
223 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_ExternalProject_get_target,$(2))
225 endef
227 # vim: set noet sw=4: