Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 include /usr/share/dpkg/pkg-info.mk
4
5 # at least LOCALTIME_{MIN,MAX} are affected by this, see #791362
6 export TZ=UTC
7
8 # these are used by executible dh_install files
9 export fullversion := $(shell /bin/bash debian/config.debian --full-version)
10 export archtriplet := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
11 export version := $(shell /bin/bash debian/config.debian --version)
12
13 nextversion := $(shell /bin/bash debian/config.debian --next-version)
14 srcdir := $(shell pwd)
15 tmp = debian/tmp
16 lib = usr/lib/$(archtriplet)/perl/$(version)
17 baselib = usr/lib/$(archtriplet)/perl-base
18 share = usr/share/perl/$(version)
19 patchlevel = patchlevel-debian.h
20
21 # we put the generated config.sh files here
22 configdata = $(tmp)/usr/lib/$(archtriplet)/perl/debian-config-data-$(fullversion)
23
24 DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
25 DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
26 DEB_HOST_ARCH_BITS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_BITS)
27 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
28
29 ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
30 NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
31 MAKEFLAGS += -j$(NUMJOBS)
32 endif
33
34 # If nonempty, this will determine $Config{debian_abi} and Provides: entries
35 # (otherwise, the Provides: entries will be generated by debian/mkprovides)
36 perlabi =
37
38 # the static flavour is for perl-base;
39 # shared is for libperl5.xx and debug goes into perl-debug
40 flavours = static shared debug
41
42 # Invoking PERL_TO_USE is expected to find its standard library
43 # without additional command line arguments, so include lib/ here
44 # in its definition.
45 ifeq ($(DEB_HOST_GNU_TYPE), $(DEB_BUILD_GNU_TYPE))
46 PERL_TO_USE = $(srcdir)/build-static/perl -I $(srcdir)/build-static/lib
47 else
48 PERL_TO_USE = $(shell which perl)
49 export TIME_HIRES_DONT_RUN_PROBES=1
50 endif
51
52 # this gets prepended to the patch names in patchlevel.h
53 patchprefix = DEBPKG:
54
55 # control file substitutions
56 subst_upstream = -VUpstream-Version=$(DEB_VERSION_UPSTREAM)
57 subst_next_upstream = -VNext-Upstream-Version=$(nextversion)
58
59 ifeq (,$(perlabi))
60 subst_perlapi = -Vperlapi:Provides="`$(PERL_TO_USE) debian/mkprovides`"
61 else
62 subst_perlapi = -Vperlapi:Provides="perlapi-$(perlabi)"
63 endif
64
65 # for cpan/Compress-Raw-Zlib
66 export BUILD_ZLIB=False
67 export ZLIB_INCLUDE=/usr/include
68 export ZLIB_LIB=/usr/lib
69
70 # for cpan/Compress-Raw-Bzip2
71 export BUILD_BZIP2=0
72 export BZIP2_INCLUDE=/usr/include
73 export BZIP2_LIB=/usr/lib
74
75 # disable tests declared upstream as not useful for packaging
76 export PERL_BUILD_PACKAGING=1
77
78 # Debian Bug #896827: riscv64 currently has excessively slow build hosts
79 DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)
80 ifeq (riscv64,$(DEB_BUILD_ARCH))
81 export PERL_TEST_TIME_OUT_FACTOR=3
82 endif
83
84 # not really quite this simple :)
85 %:
86 dh $@ --parallel
87
88 verify-configure-stamp: update-configure-stamp
89 if ! diff -u Configure.orig Configure || ! diff -u config_h.SH.orig config_h.SH; then \
90 echo "Unexpected modifications after rebuilding Configure, aborting" 1>&2; \
91 echo '(See "A special note on patching Configure" in README.source for details)' 1>&2; \
92 exit 1; \
93 fi
94 touch $@
95
96 # manual target documented in README.source
97 update-configure: update-configure-stamp
98 # sanity check
99 test -f Configure
100
101 update-configure-stamp:
102 if [ -e regen-configure/bin ]; then \
103 echo "regen-configure/bin is present but should have been repacked away, aborting" 1>&2; \
104 echo '(see README.source and https://bugs.debian.org/992200)' 1>&2; \
105 exit 1; \
106 fi
107 mv Configure Configure.orig
108 mv config_h.SH config_h.SH.orig
109 ln -s regen-configure/U
110 ln -s regen-configure/.package
111 metaconfig -X .metaconf-exclusions.txt -m -L regen-configure/dist
112 ./Porting/config_h.pl # reorders config_h.SH
113 chmod +x config_h.SH Configure # placate t/porting/exec-bit.t
114 touch $@
115
116 perl-config-%-stamp: verify-configure-stamp
117 $(SHELL) debian/config.debian --$*
118 touch $@
119
120 perl-build-%-stamp: perl-config-%-stamp $(patchlevel)
121 ln -s ../$(patchlevel) build-$*/$(pathlevel)
122 if [ "$*" = "shared" ]; then \
123 ln -s libperl.so.$(fullversion) build-$*/libperl.so.$(version); \
124 ln -s libperl.so.$(version) build-$*/libperl.so; \
125 dh_auto_build --builddirectory=build-$* -- SHRPLDFLAGS='$$(LDDLFLAGS) -Wl,-soname,libperl.so.$(version)'; \
126 elif [ "$*" = "debug" ]; then \
127 dh_auto_build --builddirectory=build-$* -- perl; \
128 else \
129 dh_auto_build --builddirectory=build-$*; \
130 fi
131 touch $@
132
133 perl-test-%-stamp: perl-build-%-stamp
134 dh_auto_test --builddirectory=build-$*
135 touch $@
136
137 $(patchlevel): debian/patches/series
138 $(checkdir)
139 test -f $< # maintainer sanity check
140 debian/gen-patchlevel -p $(patchprefix) -v $(DEB_VERSION) $< > $@
141 # patchlevel_date in perlbug is extracted from patchlevel.h mtime, let's set
142 # it to highest mtime of Debian patches for build reproducibility
143 patchdate=`debian/gen-patchlevel -d`; touch --date="@$$patchdate" patchlevel.h
144
145 override_dh_auto_configure-indep: perl-config-shared-stamp
146
147 override_dh_auto_configure-arch: $(addsuffix -stamp,$(addprefix perl-config-,$(flavours)))
148
149 override_dh_auto_build-indep: perl-build-shared-stamp
150
151 override_dh_auto_build-arch: $(addsuffix -stamp,$(addprefix perl-build-,$(flavours)))
152
153 override_dh_auto_test-indep: perl-test-shared-stamp
154
155 override_dh_auto_test-arch: perl-test-static-stamp perl-test-shared-stamp
156
157 perl-install-shared-stamp:
158 dh_auto_install --builddirectory=build-shared --destdir=debian/tmp
159 touch $@
160
161 override_dh_auto_install-indep: perl-install-shared-stamp
162 # move to full version; symlinks to match @INC will be created after dh_install
163 mv $(tmp)/$(share) $(tmp)/usr/share/perl/$(fullversion)
164
165 override_dh_auto_install-arch: perl-install-shared-stamp
166 # store probed configuration to support cross builds
167 for flavour in $(flavours); do \
168 install -D -m 644 build-$$flavour/config.sh $(configdata)/config.sh.$$flavour; \
169 $(PERL_TO_USE) -pi -e 's@\Q$(CURDIR)\E@/dummy/build/dir@g' $(configdata)/config.sh.$$flavour; \
170 gzip -n $(configdata)/config.sh.$$flavour; \
171 done
172
173 ifeq (,$(perlabi))
174 else
175 # support \$Config{debian_abi} (see the Debian Perl policy)
176 sed -i -e "/version =>/i\ debian_abi => '$(perlabi)'," \
177 $(tmp)/$(lib)/Config.pm
178 endif
179
180 # avoid exposing the point release in libperl names, to
181 # avoid unnecessary breakage
182 # see #759989
183 for file in Config.pm Config_heavy.pl; do \
184 $(PERL_TO_USE) -i -p \
185 -e 's/^(libperl='\''libperl\.so)\.$(fullversion)'\''/$$1.$(version)'\''/' \
186 $(tmp)/$(lib)/$$file; \
187 done
188
189 # remove dpkg-buildflags effects from %Config
190 # see #657853
191 for file in Config.pm Config_heavy.pl; do \
192 if which dpkg-buildflags >/dev/null 2>&1; then \
193 for flag in $(shell dpkg-buildflags --get CPPFLAGS) \
194 $(shell dpkg-buildflags --get CFLAGS) \
195 ; do \
196 case "$$flag" in -fstack-protector) ;; \
197 -D_TIME_BITS=64) ;; \
198 *) export flag; $(PERL_TO_USE) -i -pe "/^(cc|cpp)flags/ and \
199 s/(['\s])\Q\$$ENV{flag}\E(['\s])/\1\2/ and s/ +/ /" \
200 $(tmp)/$(lib)/$$file ;; \
201 esac; done; \
202 for flag in $(shell dpkg-buildflags --get LDFLAGS); do \
203 export flag; $(PERL_TO_USE) -i -pe "/^ld(dl)?flags/ and \
204 s/(['\s])\Q\$$ENV{flag}\E(['\s])/\1\2/ and s/ +/ /" \
205 $(tmp)/$(lib)/$$file ; \
206 done; \
207 fi; \
208 done
209
210 # convert required header files
211 -cd /usr/include; \
212 $(srcdir)/debian/fake-config $(srcdir)/$(tmp)/$(lib) $(PERL_TO_USE) \
213 &$(srcdir)/build-static/utils/h2ph -a -d $(srcdir)/$(tmp)/$(lib) \
214 `cat $(srcdir)/debian/headers`
215
216 # fix up generated headers
217 $(PERL_TO_USE) debian/fixheaders $(tmp)/$(lib)
218
219 # remove references to the build directory in some files
220 find $(tmp) \
221 -path '*/CORE/config.h' -or -path '*/Config_heavy.pl' | \
222 xargs -tr $(PERL_TO_USE) -pi -e 's@\Q$(CURDIR)\E@/dummy/build/dir@g'
223
224 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
225 # Verify that the headers are usable
226 for ph in `< debian/headers sed -e 's/\.h$$/.ph/'`; do \
227 if [ ! -f $(tmp)/$(lib)/$$ph ]; then \
228 echo "$$ph: missing"; else \
229 echo $$ph | $(PERL_TO_USE) debian/check-require $(tmp) \
230 || exit 1; \
231 fi; \
232 done
233 endif
234 # remove some cruft
235 rm -f $(tmp)/$(lib)/.packlist
236
237 # relocate perl library
238 mv $(tmp)/$(lib)/CORE/libperl.so.$(fullversion) $(tmp)/usr/lib/$(archtriplet)
239
240 # replaced by dh_link symlinks
241 rm -f $(tmp)/$(lib)/CORE/libperl.so $(tmp)/$(lib)/CORE/libperl.so.$(version)
242
243 # move to full version; symlinks to match @INC will be created after dh_install
244 mv $(tmp)/$(lib) $(tmp)/usr/lib/$(archtriplet)/perl/$(fullversion)
245
246 execute_after_dh_install-indep:
247 ln -s $(fullversion) debian/perl-modules-$(version)/$(share)
248
249 # POD files are in perl-doc
250 rm -f debian/perl-modules-$(version)/usr/share/perl/$(fullversion)/pod/*
251
252 # except perldiag.pod which is needed by the diagnostics module
253 mv debian/perl-doc/usr/share/perl/$(fullversion)/pod/perldiag.pod \
254 debian/perl-modules-$(version)/usr/share/perl/$(fullversion)/pod
255
256 execute_after_dh_install-arch:
257 ln -s $(fullversion) debian/libperl$(version)/$(lib)
258
259 # switch man extensions to 1p and 3pm for vendor module installs
260 for instdir in debian/libperl$(version)/$(lib) debian/perl-base/$(baselib); do \
261 for file in Config.pm Config_heavy.pl; do \
262 $(PERL_TO_USE) -i -p \
263 -e 's/^(man1ext=).*/$$1'\''1p'\''/;' \
264 -e 's/^(man3ext=).*/$$1'\''3pm'\''/;' \
265 $$instdir/$$file; \
266 done; \
267 done
268
269 # put version+arch -specific binaries in libperl5.xx
270 for prefix in perl cpan; do \
271 mv debian/libperl$(version)/usr/bin/$$prefix \
272 debian/libperl$(version)/usr/bin/$${prefix}$(version)-$(archtriplet); \
273 done
274 sed -i "1 s,/usr/bin/perl,/usr/bin/perl$(version)-$(archtriplet)," \
275 debian/libperl$(version)/usr/bin/cpan$(version)-$(archtriplet)
276
277 # perl itself goes in perl-base
278 ln debian/perl-base/usr/bin/perl debian/perl-base/usr/bin/perl$(fullversion)
279 rm debian/perl/usr/bin/perl debian/perl/usr/bin/perl$(fullversion)
280
281 # debugging version has a different name
282 mv debian/perl-debug/usr/bin/perl debian/perl-debug/usr/bin/debugperl
283
284 # put a perldoc stub in the perl package
285 mv debian/perl/usr/bin/perl.perldoc debian/perl/usr/bin/perldoc
286
287 # rip pod out of -base modules
288 $(PERL_TO_USE) debian/stripdoc debian/perl-base
289
290 ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
291 # Verify that perl-base stays self contained
292
293 ( cd $(srcdir)/debian/perl-base && find . -name '*.p[hlm]' ) | \
294 $(PERL_TO_USE) $(srcdir)/debian/check-require $(srcdir)/debian/perl-base
295 endif
296
297 ifeq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
298 execute_after_dh_installman-arch:
299 # put version+arch -specific manpages in libperl5.xx
300 for prefix in perl cpan; do \
301 mv debian/libperl$(version)/usr/share/man/man1/$$prefix.1 \
302 debian/libperl$(version)/usr/share/man/man1/$${prefix}$(version)-$(archtriplet).1; \
303 done
304 endif
305
306 override_dh_strip:
307 dh_strip --no-package=perl-debug --dbg-package=perl-debug
308
309 # subst_perlapi uses build-static/perl, not present in arch-indep builds
310 override_dh_gencontrol-indep:
311 dh_gencontrol -- $(subst_upstream) $(subst_next_upstream)
312
313 override_dh_gencontrol-arch:
314 dh_gencontrol -- $(subst_upstream) $(subst_next_upstream) $(subst_perlapi)
315
316 override_dh_installdocs-arch:
317 dh_installdocs --package=perl-debug --link-doc=perl
318 dh_installdocs --package=perl-base --doc-main-package=perl
319 dh_installdocs --remaining-packages