bump product version to 4.1.6.2
[LibreOffice.git] / solenv / gbuild / Package.mk
blob176b2f37990a11b206cdede7aa8f01b05d63d98d
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)
44 $(call gb_Deliver_add_deliverable,$(4)/$(1),$(2),$(3))
45 endef
48 # Package class
50 # defined by platform
51 # gb_Package_PROGRAMDIRNAME
52 # gb_Package_SDKDIRNAME
54 $(dir $(call gb_Package_get_target,%)).dir :
55 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
57 $(dir $(call gb_Package_get_target,%))%/.dir :
58 $(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))
60 .PHONY : $(call gb_Package_get_clean_target,%)
61 $(call gb_Package_get_clean_target,%) :
62 $(call gb_Output_announce,$*,$(false),PKG,2)
63 RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),500,$(FILES)) \
64 && cat $${RESPONSEFILE} | xargs $(if $(filter MACOSX,$(OS_FOR_BUILD)),-n 1000) rm -f \
65 && rm -f $${RESPONSEFILE}
67 $(call gb_Package_get_preparation_target,%) :
68 mkdir -p $(dir $@) && touch $@
70 # NOTE: It is possible that a file has been added to the package more
71 # than once, so we must drop the duplicates, or Windows installer will
72 # be unhappy.
73 # TODO: this is only for convenience for impl. of gbuild classes. There
74 # should be check that it does not happen in "normal" use, i.e., in
75 # Package_foo makefiles.
76 $(call gb_Package_get_target,%) :
77 $(call gb_Output_announce,$*,$(true),PKG,2)
78 rm -f $@ && \
79 mv $(call var2file,$@.tmp,100,$(sort $(FILES))) $@
81 # for other targets that want to create Packages, does not register at Module
82 define gb_Package_Package_internal
83 gb_Package_SOURCEDIR_$(1) := $(2)
84 gb_Package_OUTDIR_$(1) := $(OUTDIR)
85 $(call gb_Package_get_target,$(1)) : FILES :=
86 $(call gb_Package_get_clean_target,$(1)) : FILES := $(call gb_Package_get_target,$(1)) $(call gb_Package_get_preparation_target,$(1))
87 $(call gb_Package_get_target,$(1)) : $(call gb_Package_get_preparation_target,$(1))
88 $(call gb_Package_get_target,$(1)) : $(gb_Module_CURRENTMAKEFILE)
89 $(call gb_Package_get_target,$(1)) :| $(dir $(call gb_Package_get_target,$(1))).dir
91 endef
93 define gb_Package_Package
94 $(if $(filter postprocess% instsetoo_native%,$(1)),,$(call gb_Postprocess_get_target,AllPackages) : $(call gb_Package_get_target,$(1)))
95 $(call gb_Package_Package_internal,$(1),$(2))
96 $$(eval $$(call gb_Module_register_target,$(call gb_Package_get_target,$(1)),$(call gb_Package_get_clean_target,$(1))))
97 $(call gb_Helper_make_userfriendly_targets,$(1),Package)
99 endef
101 # Ensure that the package is defined.
103 # gb_Package__check package
104 define gb_Package__check
105 $$(if $$(gb_Package_SOURCEDIR_$(1)),,$$(call gb_Output_error,gb_Package__check: Package $(1) has not been defined))
107 endef
109 # Set output dir for the package files.
111 # Default is $(OUTDIR).
113 # gb_Package_set_outdir package outdir
114 define gb_Package_set_outdir
115 $(call gb_Package__check,$(1))
116 gb_Package_OUTDIR_$(1) := $(2)
118 endef
120 define gb_Package_add_file
121 $(call gb_Package__check,$(1))
122 $(if $(strip $(3)),,$(call gb_Output_error,gb_Package_add_file requires 3 arguments))
123 $(call gb_Package_get_target,$(1)) : $$(gb_Package_OUTDIR_$(1))/$(2)
124 $(call gb_Package_get_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
125 $(call gb_Package_get_clean_target,$(1)) : FILES += $$(gb_Package_OUTDIR_$(1))/$(2)
126 $(call gb_PackagePart_PackagePart,$(2),$$(gb_Package_SOURCEDIR_$(1))/$(3),$(call gb_Package_get_preparation_target,$(1)),$$(gb_Package_OUTDIR_$(1)))
128 endef
130 # Adds several files at once.
132 # Files are copied directly into the specified directory.
134 # Example:
135 # $(eval $(call gb_Package_Package,foo_inc,$(SRCDIR)/foo/inc))
136 # $(eval $(call gb_Package_add_files,foo_inc,inc/foo,foo/bar/foo.hxx))
137 # # -> inc/foo/foo.hxx
138 define gb_Package_add_files
139 $(call gb_Package__check,$(1))
140 $(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)))
141 $(foreach file,$(3),$(call gb_Package_add_file,$(1),$(2)/$(notdir $(file)),$(file)))
143 endef
145 # Adds several files at once.
147 # Files are copied including subdirectories.
149 # Example:
150 # $(eval $(call gb_Package_Package,foo_inc,$(SRCDIR)/foo/inc))
151 # $(eval $(call gb_Package_add_files,foo_inc,inc,foo/bar/foo.hxx))
152 # # -> inc/foo/bar/foo.hxx
153 define gb_Package_add_files_with_dir
154 $(call gb_Package__check,$(1))
155 $(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)))
156 $(foreach file,$(3),$(call gb_Package_add_file,$(1),$(2)/$(file),$(file)))
158 endef
160 # Package files from custom target
161 define gb_Package_use_custom_target
162 $(call gb_Package__check,$(1))
163 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_CustomTarget_get_target,$(2))
165 endef
167 # Package files from unpacked tarball of an external project
168 define gb_Package_use_unpacked
169 $(call gb_Package__check,$(1))
170 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_UnpackedTarball_get_target,$(2))
172 endef
174 # Package files from build of an external project
175 define gb_Package_use_external_project
176 $(call gb_Package__check,$(1))
177 $(call gb_Package_get_preparation_target,$(1)) :| $(call gb_ExternalProject_get_target,$(2))
179 endef
181 # vim: set noet sw=4: