bump product version to 6.3.0.0.beta1
[LibreOffice.git] / solenv / gbuild / Package.mk
blob841e819c7c78e96ff52d9e6cd19e7a0d29467d72
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 -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
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 $(if $(PACKAGE_DEFINED),,$(call gb_Output_error,Something depends on package $* which does not exist.))
83 rm -f $@ && \
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)) : PACKAGE_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
97 endef
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 ifeq (,$$(filter $(1),$$(gb_Package_REGISTERED)))
104 $$(eval $$(call gb_Output_info,Currently known packages are: $(sort $(gb_Package_REGISTERED)),ALL))
105 $$(eval $$(call gb_Output_error,Package $(1) must be registered in Repository.mk or RepositoryExternal.mk))
106 endif
107 $(call gb_Package_Package_internal,$(1),$(2))
108 $$(eval $$(call gb_Module_register_target,$(call gb_Package_get_target,$(1)),$(call gb_Package_get_clean_target,$(1))))
109 $(call gb_Helper_make_userfriendly_targets,$(1),Package)
111 endef
113 # Ensure that the package is defined.
115 # gb_Package__check package
116 define gb_Package__check
117 $$(if $$(gb_Package_SOURCEDIR_$(1)),,$$(call gb_Output_error,gb_Package__check: Package $(1) has not been defined))
119 endef
121 # Set output dir for the package files.
123 # Default is $(INSTROOT).
125 # gb_Package_set_outdir package outdir
126 define gb_Package_set_outdir
127 $(call gb_Package__check,$(1))
128 gb_Package_OUTDIR_$(1) := $(2)
130 endef
132 define gb_Package_add_symbolic_link
133 $(call gb_Package__check,$(1))
134 $(if $(strip $(3)),,$(call gb_Output_error,gb_Package_add_symbolic_link requires 3 arguments))
135 $(call gb_Package_get_target,$(1)) : $$(gb_Package_OUTDIR_$(1))/$(2)
136 $$(gb_Package_OUTDIR_$(1))/$(2) :| $$(dir $$(gb_Package_OUTDIR_$(1))/$(2)).dir
137 rm -f $$@ && ln -s $(3) $$@
139 $(call gb_Package_get_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
140 $(call gb_Package_get_clean_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
142 endef
144 define gb_Package_add_file
145 $(call gb_Package__check,$(1))
146 $(if $(strip $(3)),,$(call gb_Output_error,gb_Package_add_file requires 3 arguments))
147 $(call gb_Package_get_target,$(1)) : $$(gb_Package_OUTDIR_$(1))/$(2)
148 $(call gb_Package_get_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
149 $(call gb_Package_get_clean_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
150 $(call gb_PackagePart_PackagePart,$(2),$$(gb_Package_SOURCEDIR_$(1))/$(3),$(call gb_Package_get_preparation_target,$(1)),$$(gb_Package_OUTDIR_$(1)))
152 endef
154 # Adds several files at once.
156 # Files are copied directly into the specified directory.
158 # Example:
159 # $(eval $(call gb_Package_Package,foo_inc,$(SRCDIR)/foo/inc))
160 # $(eval $(call gb_Package_add_files,foo_inc,inc/foo,foo/bar/foo.hxx))
161 # # -> inc/foo/foo.hxx
162 define gb_Package_add_files
163 $(call gb_Package__check,$(1))
164 $(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)))
165 $(foreach file,$(3),$(call gb_Package_add_file,$(1),$(2)/$(notdir $(file)),$(file)))
167 endef
169 # Adds several files at once.
171 # Files are copied including subdirectories.
173 # Example:
174 # $(eval $(call gb_Package_Package,foo_inc,$(SRCDIR)/foo/inc))
175 # $(eval $(call gb_Package_add_files,foo_inc,inc,foo/bar/foo.hxx))
176 # # -> inc/foo/bar/foo.hxx
177 define gb_Package_add_files_with_dir
178 $(call gb_Package__check,$(1))
179 $(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)))
180 $(foreach file,$(3),$(call gb_Package_add_file,$(1),$(2)/$(file),$(file)))
182 endef
184 # Package files from custom target
185 define gb_Package_use_custom_target
186 $(call gb_Package__check,$(1))
187 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_CustomTarget_get_target,$(2))
189 endef
191 # Package files from unpacked tarball of an external project
192 define gb_Package_use_unpacked
193 $(call gb_Package__check,$(1))
194 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_UnpackedTarball_get_target,$(2))
196 endef
198 # Package files from build of an external project
199 define gb_Package_use_external_project
200 $(call gb_Package__check,$(1))
201 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_ExternalProject_get_target,$(2))
203 endef
205 # vim: set noet sw=4: