Debian Codegraph @

debian/buildvars.mk

raw symbols SCIP
1 # -*- mode: makefile; coding: utf-8 -*-
2 # Copyright © 2002,2003 Colin Walters <[email protected]>
3 # Copyright © 2009-2012, 2014-2017 Jonas Smedegaard <[email protected]>
4 # Description: Defines some useful variables, but no rules
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
19 ifndef _cdbs_rules_buildvars
20 _cdbs_rules_buildvars = 1
21
22 include /usr/share/dpkg/pkg-info.mk
23 include /usr/share/dpkg/architecture.mk
24
25 CDBS_VERSION = 0.4.182
26
27 # variables included from pkg-info.mk and architecture.mk
28 #DEB_SOURCE
29 #DEB_VERSION
30 #DEB_VERSION_EPOCH_UPSTREAM
31 #DEB_VERSION_UPSTREAM_REVISION
32 #DEB_VERSION_UPSTREAM
33 #DEB_DISTRIBUTION
34 #SOURCE_DATE_EPOCH
35 #DEB_ARCH
36 #DEB_HOST_GNU_TYPE
37 #DEB_HOST_GNU_SYSTEM
38 #DEB_HOST_GNU_CPU
39 #DEB_HOST_ARCH
40 #DEB_HOST_ARCH_CPU
41 #DEB_HOST_ARCH_OS
42 #DEB_HOST_MULTIARCH
43 #DEB_BUILD_GNU_TYPE
44 #DEB_BUILD_GNU_SYSTEM
45 #DEB_BUILD_GNU_CPU
46 #DEB_BUILD_ARCH
47 #DEB_BUILD_ARCH_CPU
48 #DEB_BUILD_ARCH_OS
49
50 # TODO deprecate
51 DEB_SOURCE_PACKAGE = $(DEB_SOURCE)
52 DEB_SUITE ?= $(DEB_DISTRIBUTION)
53
54 DEB_NOEPOCH_VERSION = $(lastword \
55 $(subst :,$(space),\
56 $(DEB_VERSION)))
57 DEB_UPSTREAM_VERSION = $(DEB_VERSION_UPSTREAM)
58 DEB_ISNATIVE = $(strip $(if $(findstring -,$(DEB_VERSION))\
59 ,\
60 ,native))
61
62 # Split into arch/indep packages
63 ifneq ($(DEB_INDEP_PACKAGES),cdbs)
64 ifdef _cdbs_rules_debhelper
65 DEB_INDEP_PACKAGES := $(strip $(shell \
66 dh_listpackages -i))
67 DEB_ARCH_PACKAGES := $(filter-out $(DEB_INDEP_PACKAGES),\
68 $(strip $(shell \
69 dh_listpackages -a)))
70 else
71 DEB_INDEP_PACKAGES := $(strip $(shell \
72 debian/list-packages indep))
73 DEB_ARCH_PACKAGES := $(filter-out $(DEB_INDEP_PACKAGES),\
74 $(strip $(shell \
75 debian/list-packages same)))
76 endif
77 endif
78
79 # Support for udeb packages has been removed in 0.4.172
80 DEB_PACKAGES ?= $(DEB_ARCH_PACKAGES) $(DEB_INDEP_PACKAGES)
81 DEB_ALL_PACKAGES ?= $(DEB_PACKAGES)
82 DEB_INDEP_REGULAR_PACKAGES ?= $(DEB_INDEP_PACKAGES)
83 DEB_ARCH_REGULAR_PACKAGES ?= $(DEB_ARCH_PACKAGES)
84
85 # Some support for srcdir != builddir builds.
86 # These are relative to the root of the package
87 DEB_SRCDIR ?= .
88 DEB_BUILDDIR ?= $(strip $(DEB_SRCDIR))
89
90 # TODO deprecate
91 DEB_ARCH = $(DEB_HOST_ARCH)
92
93 ifeq ($(words $(DEB_ALL_PACKAGES)),1)
94 DEB_DESTDIR ?= $(CURDIR)/debian/$(strip $(DEB_ALL_PACKAGES))/
95 else
96 DEB_DESTDIR ?= $(CURDIR)/debian/tmp/
97 endif
98
99 # Internal useful variables/expansions
100
101 cdbs_info = $(info CDBS: $1)
102 cdbs_warn = $(info CDBS WARNING: $1)
103
104 # emit warning on use of deprecated variable
105 # * $1: variable name
106 # * $2: optional last version before deprecation
107 # * $3: optional alternative variable to use instead
108 cdbs_warn_deprecated = $(call cdbs_warn,\
109 $1 is deprecated$(if $2, since $2)$(if $3, - please use $3 instead))
110
111 cdbs_curpkg = $(notdir $@)
112
113 cdbs_cursrcdir = $(or $(DEB_PKGSRCDIR_$(cdbs_curpkg)),$(DEB_SRCDIR))
114 cdbs_curbuilddir = $(or $(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_BUILDDIR))
115 cdbs_curdestdir = $(or $(DEB_DESTDIR_$(cdbs_curpkg)),$(DEB_DESTDIR))
116
117 cdbs_streq = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),,yes)
118
119 nullstring =
120 space = $(nullstring) # <- notice the trailing space (only leading is stripped)
121 define newline =
122 $(nullstring)
123 $(nullstring)
124 endef
125 comma = ,
126 open_parenthesis = (
127 close_parenthesis = )
128 cdbs_delimit = $(subst $(space),$2,$(strip $1))
129
130 # workaround for lack of uppercase/lowercase functions in make
131 cdbs_uc = $(shell echo '$1' | tr '[:lower:]' '[:upper:]')
132 cdbs_lc = $(shell echo '$1' | tr '[:upper:]' '[:lower:]')
133
134 # Resolve VAR_ALL and either VAR_pkg or VAR_DEFAULT, space- or custom-delimited
135 # * VAR_ALL applies to all packages
136 # * VAR_pkg applies to current package
137 # * VAR_DEFAULT applies to current package if not overridden by VAR_pkg
138 cdbs_expand_curvar = $(strip \
139 $($(1)_ALL)$(if $($(1)_ALL),$(or $2,$(space)))$(strip \
140 $(if $(filter-out $(origin $(1)_$(cdbs_curpkg)),undefined),$(strip \
141 $($(1)_$(cdbs_curpkg))),$(strip \
142 $($(1)_DEFAULT)))))
143 cdbs_expand_allvars = $(strip \
144 $(foreach stem,$(1),$(strip \
145 $($(stem)_ALL))$(strip \
146 $($(stem)))$(strip \
147 $(foreach pkg,$(DEB_ALL_PACKAGES),$(strip \
148 $($(stem)_$(pkg)))))))
149
150 # List "packages multiplied with branches", or just packages if no branches
151 # Syntax: PACKAGES BRANCHES WORDDELIMITER BRANCHDELIMITER [FALLBACK-MAIN-BRANCH]
152 cdbs_expand_branches = $(strip $(subst WORDDELIMITER,$3,\
153 $(subst BRANCHDELIMITER,$4,\
154 $(call cdbs_delimit,\
155 $(if $2,\
156 $(foreach pkg,$1,\
157 $(call cdbs_delimit,$(foreach branch,$2,\
158 $(pkg)$(branch:%=-%)),$(strip \
159 BRANCHDELIMITER))),\
160 $(if $5,\
161 $(foreach pkg,$1,\
162 $(pkg)-$(5)BRANCHDELIMITER$(pkg)),\
163 $1)),$(strip \
164 WORDDELIMITER)))))
165
166 cdbs_findargs-path-or-name = $(strip \
167 $(if $(findstring /,$(firstword $(1))),\
168 -path './$(patsubst ./%,%,$(firstword $(1)))',\
169 -name '$(firstword $(1))') \
170 $(foreach obj,$(wordlist 2,$(words $(1)),$(1)),\
171 -or \
172 $(if $(findstring /,$(obj)),\
173 -path './$(obj:./%=%)',\
174 -name '$(obj)')))
175
176 # Resolve VAR only if declared explicitly in makefile or environment
177 cdbs_expand_nondefaultvar = $(strip $(if $(filter-out undefined default,\
178 $(origin $1)),\
179 $2))
180
181 # Declare (shell-style) variables to itself if explicitly declared
182 cdbs_set_nondefaultvars = $(strip $(foreach v,$1,\
183 $(call cdbs_expand_nondefaultvar,$v,$v="$($v)")))
184
185 # Return non-empty if build system is different from host system
186 cdbs_crossbuild = $(if $(call cdbs_streq,$(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)),,yes)
187
188 endif