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