Debian Codegraph @

debian/buildcore.mk

raw symbols SCIP
1 # -*- mode: makefile; coding: utf-8 -*-
2 # Copyright © 2002,2003 Colin Walters <[email protected]>
3 # Copyright © 2009-2016 Jonas Smedegaard <[email protected]>
4 # Description: Defines the rule framework
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_buildcore
20 _cdbs_rules_buildcore = 1
21
22 include debian/buildvars.mk$(_cdbs_makefile_suffix)
23
24 export SOURCE_DATE_EPOCH
25
26 testdir: debian/control
27 test -x debian/rules
28
29 testroot:
30 $(if $(_cdbs_rules_debhelper),dh_testroot,test "`id -u`" = 0)
31
32 # These targets are triggered by pre-build and clean targets allowing
33 # for non-intrusive sanity checks of the build environment
34 $(patsubst %,testsanity/%,$(DEB_ALL_PACKAGES)):: testsanity/%:
35 testsanity:: $(patsubst %,testsanity/%,$(DEB_ALL_PACKAGES))
36
37 $(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES)):: makebuilddir/%:
38 $(if $(DEB_BUILDDIR_$(cdbs_curpkg)),\
39 mkdir -p "$(DEB_BUILDDIR_$(cdbs_curpkg))")
40
41 makebuilddir:: $(patsubst %,makebuilddir/%,$(DEB_ALL_PACKAGES))
42 mkdir -p "$(DEB_BUILDDIR)"
43
44 cleanbuilddir:: $(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES))
45 -$(if $(call cdbs_streq,$(DEB_BUILDDIR),$(DEB_SRCDIR)),\
46 ,\
47 rmdir $(DEB_BUILDDIR))
48
49 $(patsubst %,cleanbuilddir/%,$(DEB_ALL_PACKAGES)):: cleanbuilddir/%:
50 -$(if $(DEB_BUILDDIR_$(cdbs_curpkg)),\
51 $(if $(call cdbs_streq,$(DEB_BUILDDIR_$(cdbs_curpkg)),$(DEB_SRCDIR)),\
52 ,\
53 rmdir "$(DEB_BUILDDIR_$(cdbs_curpkg))"))
54
55
56
57 config_guess := $(shell find $(DEB_SRCDIR) \( -type f -or -type l \) -name config.guess)
58 config_sub := $(shell find $(DEB_SRCDIR) \( -type f -or -type l \) -name config.sub)
59 config_rpath := $(shell find $(DEB_SRCDIR) \( -type f -or -type l \) -name config.rpath)
60
61
62 # This target is called before almost anything else happens. It's a good place
63 # to do stuff like unpack extra source tarballs, apply patches, and stuff. In
64 # the future it will be a good place to generate debian/control, but right
65 # now we don't support that very well.
66 pre-build:: testdir testsanity makebuilddir
67 $(foreach x,$(_cdbs_deprecated_vars),\
68 $(eval y=$(subst $(comma), ,$x))\
69 $(eval z=$(firstword $y))\
70 $(if $(call cdbs_streq,$($z),$(_cdbs_deprecated_$z_default)),\
71 ,\
72 $(call cdbs_warn_deprecated,\
73 $z,$(word 2,$y),$(wordlist 3,$(words $y),$y))))
74
75 # This target is called after patches are applied. Used by the patch system.
76 post-patches:: pre-build apply-patches update-config
77 update-config::
78 $(if $(and $(config_guess),$(wildcard /usr/share/misc/config.guess)),\
79 set -e; \
80 $(foreach file,$(config_guess),\
81 $(if $(wildcard $(file)),$(if $(wildcard $(file).cdbs-orig),\
82 ,\
83 mv $(file) $(file).cdbs-orig; \
84 cp --remove-destination \
85 /usr/share/misc/config.guess $(file);))))
86 $(if $(and $(config_sub),$(wildcard /usr/share/misc/config.sub)),\
87 set -e; \
88 $(foreach file,$(config_sub),\
89 $(if $(wildcard $(file)),$(if $(wildcard $(file).cdbs-orig),\
90 ,\
91 mv $(file) $(file).cdbs-orig; \
92 cp --remove-destination \
93 /usr/share/misc/config.sub $(file);))))
94 $(if $(and $(config_rpath),$(wildcard /usr/share/gnulib/build-aux/config.rpath)), \
95 set -e; \
96 $(foreach file,$(config_rpath),\
97 $(if $(wildcard $(file)),$(if $(wildcard $(file).cdbs-orig),\
98 ,\
99 mv $(file) $(file).cdbs-orig; \
100 cp --remove-destination \
101 /usr/share/gnulib/build-aux/config.rpath $(file);))))
102
103 # This target should be used to configure the package before building. Typically
104 # this involves running things like ./configure.
105 common-configure-arch:: post-patches
106 common-configure-indep:: post-patches
107 $(patsubst %,configure/%,$(DEB_ARCH_PACKAGES)):: configure/%: common-configure-arch
108 $(patsubst %,configure/%,$(DEB_INDEP_PACKAGES)):: configure/%: common-configure-indep
109
110 # This is a required Debian target; however, its specific semantics is
111 # in dispute. We are of the opinion that 'build' should invoke
112 # build-arch and build-indep. Policy tends to support us here.
113 # However, dpkg-buildpackage is currently invokes debian/rules build
114 # even when doing an architecture-specific (binary-arch) build. This
115 # essentially means Build-Depends-Indep is worthless. For more
116 # information, see Policy §5.2, Policy §7.6, and Debian Bug #178809.
117 # For now, you may override the dependencies by setting the variable
118 # DEB_BUILD_DEPENDENCIES, below. This is not recommended.
119 DEB_BUILD_DEPENDENCIES ?= build-arch build-indep
120 build: $(DEB_BUILD_DEPENDENCIES)
121
122 # This target should take care of actually compiling the package from source.
123 # Most often this involves invoking "make".
124 common-build-arch:: testdir $(patsubst %,configure/%,$(DEB_ARCH_PACKAGES))
125 common-build-indep:: testdir $(patsubst %,configure/%,$(DEB_INDEP_PACKAGES))
126 $(patsubst %,build/%,$(DEB_ARCH_PACKAGES)):: build/%: common-build-arch configure/%
127 $(patsubst %,build/%,$(DEB_INDEP_PACKAGES)):: build/%: common-build-indep configure/%
128
129 # This rule is for stuff to run after the build process. Note that this
130 # may run under fakeroot or sudo, so it's inappropriate for things that
131 # should be run under the build target.
132 common-post-build-arch:: common-build-arch $(patsubst %,build/%,$(DEB_ARCH_PACKAGES))
133 common-post-build-indep:: common-build-indep $(patsubst %,build/%,$(DEB_INDEP_PACKAGES))
134
135 # Required Debian targets.
136 build-arch: $(patsubst %,build/%,$(DEB_ARCH_PACKAGES))
137 build-indep: $(patsubst %,build/%,$(DEB_INDEP_PACKAGES))
138
139 # This rule is used to prepare the source package before a diff is generated.
140 # Typically you will invoke upstream's "make clean" rule here, although you
141 # can also hook in other stuff here. Many of the included rules and classes
142 # add stuff to this rule.
143 clean:: testdir cleanbuilddir reverse-config testsanity
144 reverse-config::
145 $(if $(config_guess)$(config_sub)$(config_rpath),\
146 set -e;\
147 $(foreach file,$(config_guess) $(config_sub) $(config_rpath),\
148 $(if $(wildcard $(file).cdbs-orig),\
149 mv $(file).cdbs-orig $(file);)))
150
151 # Style of separating build-dependencies. Perl-style: tab=\t, newline=\n
152 # * Default follows recommended multiline style (see Debian Policy §7.1)
153 # * Unset to get recomended single-line style ", "
154 CDBS_BUILD_DEPENDS_DELIMITER ?= ,\n$(space)
155
156 cdbs_re_squash_extended_space = s/[ \t\n]+/ /g
157
158 cdbs_pkgrel_varnames = $(patsubst %,CDBS_%,DEPENDS PREDEPENDS RECOMMENDS SUGGESTS BREAKS PROVIDES REPLACES CONFLICTS ENHANCES)
159 cdbs_pkgrel_allvars = $(call cdbs_expand_allvars,$(cdbs_pkgrel_varnames))
160
161 # This rule is called before the common-install target. It's currently only
162 # used by debhelper.mk, to run dh_clean -k.
163 common-install-prehook-arch::
164 common-install-prehook-indep::
165
166 # This target should do all the work of installing the package into the
167 # staging directory (debian/packagename or debian/tmp).
168 common-install-arch:: testdir common-install-prehook-arch common-post-build-arch
169 common-install-indep:: testdir common-install-prehook-indep common-post-build-indep
170
171 # Required Debian targets.
172 install-arch: $(patsubst %,install/%,$(DEB_ARCH_PACKAGES))
173 install-indep: $(patsubst %,install/%,$(DEB_INDEP_PACKAGES))
174
175 # These rules should do any installation work specific to a particular package.
176 $(patsubst %,install/%,$(DEB_ARCH_PACKAGES)):: install/%: testdir testroot common-install-arch build/%
177 $(patsubst %,install/%,$(DEB_INDEP_PACKAGES)):: install/%: testdir testroot common-install-indep build/%
178
179 _cdbs_deprecated_vars += $(patsubst %,CDBS_%$(comma)0.4.85,\
180 DEPENDS PREDEPENDS RECOMMENDS SUGGESTS BREAKS PROVIDES REPLACES \
181 CONFLICTS ENHANCES)
182 CDBS_DEPENDS_DEFAULT ?= $(CDBS_DEPENDS)
183 CDBS_PREDEPENDS_DEFAULT ?= $(CDBS_PREDEPENDS)
184 CDBS_RECOMMENDS_DEFAULT ?= $(CDBS_RECOMMENDS)
185 CDBS_SUGGESTS_DEFAULT ?= $(CDBS_SUGGESTS)
186 CDBS_BREAKS_DEFAULT ?= $(CDBS_BREAKS)
187 CDBS_PROVIDES_DEFAULT ?= $(CDBS_PROVIDES)
188 CDBS_REPLACES_DEFAULT ?= $(CDBS_REPLACES)
189 CDBS_CONFLICTS_DEFAULT ?= $(CDBS_CONFLICTS)
190 CDBS_ENHANCES_DEFAULT ?= $(CDBS_ENHANCES)
191
192 # Resolve CDBS-declared binary package relations and apply to substvars files
193 $(patsubst %,install/%,$(DEB_ALL_PACKAGES)) :: install/%:
194 @echo 'Adding cdbs dependencies to debian/$(cdbs_curpkg).substvars'
195 @echo '$(call cdbs_expand_curvar,CDBS_DEPENDS,$(comma) )' \
196 | perl -0 -n \
197 -e '$(cdbs_re_squash_extended_space);' \
198 -e '$(re_squash_commas_and_spaces);' \
199 -e '/\w/ and print "cdbs:Depends=$$_\n"' \
200 >> debian/$(cdbs_curpkg).substvars
201 @echo '$(call cdbs_expand_curvar,CDBS_PREDEPENDS,$(comma) )' \
202 | perl -0 -n \
203 -e '$(cdbs_re_squash_extended_space);' \
204 -e '$(re_squash_commas_and_spaces);' \
205 -e '/\w/ and print "cdbs:Pre-Depends=$$_\n"' \
206 >> debian/$(cdbs_curpkg).substvars
207 @echo '$(call cdbs_expand_curvar,CDBS_RECOMMENDS,$(comma) )' \
208 | perl -0 -n \
209 -e '$(cdbs_re_squash_extended_space);' \
210 -e '$(re_squash_commas_and_spaces);' \
211 -e '/\w/ and print "cdbs:Recommends=$$_\n"' \
212 >> debian/$(cdbs_curpkg).substvars
213 @echo '$(call cdbs_expand_curvar,CDBS_SUGGESTS,$(comma) )' \
214 | perl -0 -n \
215 -e '$(cdbs_re_squash_extended_space);' \
216 -e '$(re_squash_commas_and_spaces);' \
217 -e '/\w/ and print "cdbs:Suggests=$$_\n"' \
218 >> debian/$(cdbs_curpkg).substvars
219 @echo '$(call cdbs_expand_curvar,CDBS_BREAKS,$(comma) )' \
220 | perl -0 -n \
221 -e '$(cdbs_re_squash_extended_space);' \
222 -e '$(re_squash_commas_and_spaces);' \
223 -e '/\w/ and print "cdbs:Breaks=$$_\n"' \
224 >> debian/$(cdbs_curpkg).substvars
225 @echo '$(call cdbs_expand_curvar,CDBS_PROVIDES,$(comma) )' \
226 | perl -0 -n \
227 -e '$(cdbs_re_squash_extended_space);' \
228 -e '$(re_squash_commas_and_spaces);' \
229 -e '/\w/ and print "cdbs:Provides=$$_\n"' \
230 >> debian/$(cdbs_curpkg).substvars
231 @echo '$(call cdbs_expand_curvar,CDBS_REPLACES,$(comma) )' \
232 | perl -0 -n \
233 -e '$(cdbs_re_squash_extended_space);' \
234 -e '$(re_squash_commas_and_spaces);' \
235 -e '/\w/ and print "cdbs:Replaces=$$_\n"' \
236 >> debian/$(cdbs_curpkg).substvars
237 @echo '$(call cdbs_expand_curvar,CDBS_CONFLICTS,$(comma) )' \
238 | perl -0 -n \
239 -e '$(cdbs_re_squash_extended_space);' \
240 -e '$(re_squash_commas_and_spaces);' \
241 -e '/\w/ and print "cdbs:Conflicts=$$_\n"' \
242 >> debian/$(cdbs_curpkg).substvars
243 @echo '$(call cdbs_expand_curvar,CDBS_ENHANCES,$(comma) )' \
244 | perl -0 -n \
245 -e '$(cdbs_re_squash_extended_space);' \
246 -e '$(re_squash_commas_and_spaces);' \
247 -e '/\w/ and print "cdbs:Enhances=$$_\n"' \
248 >> debian/$(cdbs_curpkg).substvars
249
250 # This rule is called after all packages are installed.
251 common-binary-arch:: testdir testroot $(patsubst %,install/%,$(DEB_ARCH_PACKAGES))
252 common-binary-indep:: testdir testroot $(patsubst %,install/%,$(DEB_INDEP_PACKAGES))
253
254 # Required Debian targets
255 binary-indep: $(patsubst %,binary/%,$(DEB_INDEP_PACKAGES))
256 binary-arch: $(patsubst %,binary/%,$(DEB_ARCH_PACKAGES))
257
258 # These rules should do all the work of actually creating a .deb from the staging
259 # directory.
260 $(patsubst %,binary/%,$(DEB_ARCH_PACKAGES)):: binary/%: testdir testroot common-binary-arch install/%
261 $(patsubst %,binary/%,$(DEB_INDEP_PACKAGES)):: binary/%: testdir testroot common-binary-indep install/%
262
263 # Required Debian target
264 binary: binary-indep binary-arch
265
266 ##
267 # Deprecated targets. You should use the -arch and -indep targets instead.
268 ##
269 common-configure:: common-configure-arch common-configure-indep
270 common-build:: common-build-arch common-build-indep
271 common-post-build:: common-post-build-arch common-post-build-indep
272 common-install-prehook:: common-install-prehook-arch common-install-prehook-indep
273 common-install:: common-install-arch common-install-indep
274 common-binary:: common-binary-arch common-binary-indep
275
276 .PHONY: pre-build testsanity $(patsubst %,testsanity/%,$(DEB_ALL_PACKAGES)) apply-patches post-patches common-configure-arch common-configure-indep $(patsubst %,configure/%,$(DEB_ALL_PACKAGES)) build common-build-arch common-build-indep $(patsubst %,build/%,$(DEB_ALL_PACKAGES)) build-arch build-indep clean common-install-arch common-install-indep install-arch install-indep $(patsubst %,install/%,$(DEB_ALL_PACKAGES)) common-binary-arch common-binary-indep $(patsubst %,binary/%,$(DEB_ALL_PACKAGES)) binary-indep binary-arch binary $(DEB_PHONY_RULES)
277
278 # Parallel execution of the cdbs makefile fragments will fail, but
279 # this way you can call dpkg-buildpackage with MAKEFLAGS=-j in the
280 # environment and the package's own makefiles can use parallel make.
281 .NOTPARALLEL:
282
283 endif