#!/usr/bin/make -f # # debian/rules for perl. # # Note that although this rules file currently invokes tools from dpkg-dev # implemented in perl (such as dpkg-architecture and so on), it aspires # to not use perl at all, so that a new architecture can easily be # bootstrapped. This aspiration should be considered when changing this # file. # # # we use bash-specific functionality, at least "shopt -s globstar" export SHELL = /bin/bash # at least LOCALTIME_{MIN,MAX} are affected by this export TZ=UTC # Configure output is sorted and varies with LC_COLLATE export LC_ALL=C # use the timestamp from debian/changelog for Pod::Man generated man pages # this may end up in dpkg-buildpackage eventually but it's not there yet export SOURCE_DATE_EPOCH = $(shell date -d "$$(dpkg-parsechangelog -SDate)" +%s) fullversion := $(shell /bin/bash debian/config.debian --full-version) nextversion := $(shell /bin/bash debian/config.debian --next-version) version := $(shell /bin/bash debian/config.debian --version) installtype := $(shell /bin/bash debian/config.debian --install-type) test_target := $(shell /bin/bash debian/config.debian --test-target) strip := $(shell /bin/bash debian/config.debian --strip) archtriplet := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) arch := $(shell dpkg-architecture -qDEB_HOST_ARCH) srcdir := $(shell pwd) packages := $(shell sed -n 's/^Package: *//p' debian/control) arch_pkgs := $(shell sed -n '/^Package:/ { s/^Package: *//; h }; /^Architecture: any/ { x; p }' debian/control) indep_pkgs := $(shell sed -n '/^Package:/ { s/^Package: *//; h }; /^Architecture: all/ { x; p }' debian/control) build_date := $(shell dpkg-parsechangelog | sed -n -e 's/^Date: //p') tmp = debian/tmp bin = $(tmp)/usr/bin man = $(tmp)/usr/share/man lib = $(tmp)/usr/lib/$(archtriplet)/perl/$(version) share = $(tmp)/usr/share/perl/$(version) build = debian/build debug = $(build)/perl-debug/usr/lib/debug patches = debian/patches/series patchlevel = patchlevel-debian.h # we put the generated config.sh files here pcd = $(tmp)/usr/lib/$(archtriplet)/perl/debian-config-data-$(fullversion) # If nonempty, this will determine $Config{debian_abi} and Provides: entries # (otherwise, the Provides: entries will be generated by debian/mkprovides) perlabi = checkdir = test -d debian checkroot = test `id -u` -eq 0 checkperl = $(SHELL) debian/checkperl DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) OBJCOPY = $(DEB_HOST_GNU_TYPE)-objcopy STRIP = $(DEB_HOST_GNU_TYPE)-strip # 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)/perl.static -I $(srcdir)/lib else PERL_TO_USE = $(shell which perl) export TIME_HIRES_DONT_RUN_PROBES=1 endif # this may differ from $(fullversion) for release candidates and the like package_upstream_version = $(shell dpkg-parsechangelog | \ sed -ne 's/-[^-]\+$$//; s/^Version: *\([0-9]\+:\)*//p') package_version = $(shell dpkg-parsechangelog | sed -n 's/^Version: *//p') # this gets prepended to the patch names in patchlevel.h patchprefix = DEBPKG: # control file substitutions subst_upstream = -VUpstream-Version=$(package_upstream_version) 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 build: build-stamp install: install-stamp build-arch: build build-indep: build build-stamp: verify-configure-stamp $(patchlevel) perl.static perl.debug libperl.so.$(fullversion) touch $@ update-configure: update-configure-stamp 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 update-configure-stamp: 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 $@ $(patchlevel): $(patches) $(checkdir) test -f $< # maintainer sanity check debian/gen-patchlevel -p $(patchprefix) -v $(package_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 perl.static: $(checkdir) rm -f libperl.so* # must be built last [ ! -f Makefile ] || $(MAKE) distclean [ -f $(patchlevel) ] || touch $(patchlevel) $(SHELL) debian/config.debian --static # stash generated config.sh cp config.sh config.sh.static $(MAKE) perl $(test_target) mv libperl.a libperl-static mv perl perl.static ifeq ($(DEB_HOST_GNU_TYPE), $(DEB_BUILD_GNU_TYPE)) # for the build log $(PERL_TO_USE) -Ilib -V endif # save these for the perl-base package cp lib/Config.pm lib/Config.pm.static cp lib/Config_heavy.pl lib/Config_heavy.pl.static perl.debug: $(checkdir) rm -f libperl.so* # must be built last [ ! -f Makefile ] || $(MAKE) distclean [ -f $(patchlevel) ] || touch $(patchlevel) $(SHELL) debian/config.debian --debug # stash generated config.sh cp config.sh config.sh.debug $(MAKE) perl mv perl perl.debug libperl.so.$(fullversion): $(checkdir) [ ! -f Makefile ] || $(MAKE) distclean [ -f $(patchlevel) ] || touch $(patchlevel) $(SHELL) debian/config.debian --shared # stash generated config.sh cp config.sh config.sh.shared $(MAKE) SHRPLDFLAGS='$$(LDDLFLAGS) -Wl,-soname,libperl.so.$(version)' $@ ln -s libperl.so.$(fullversion) libperl.so.$(version) ln -s libperl.so.$(version) libperl.so $(MAKE) all $(test_target) || { rm -f libperl.so*; exit 1; } clean: $(checkdir) $(checkroot) test -f $(patches) # maintainer sanity check [ ! -f Makefile ] || $(MAKE) distclean [ ! -f Configure.orig ] || mv Configure.orig Configure [ ! -f config_h.SH.orig ] || mv config_h.SH.orig config_h.SH rm -rf config.over perl.static perl.debug libperl-static libperl.so* \ $(patchlevel) build-stamp install-stamp t/auto debian/shlibs.local \ debian/perl-base.shlibs debian/libperl$(version).shlibs \ build-miniperl build-generate_uudmap optdef.sh config.sh.* \ U .package Wanted Obsolete update-configure-stamp verify-configure-stamp \ debian/substvars debian/files debian/list.tmp $(tmp) $(build) install-stamp: build-stamp $(checkdir) $(checkroot) $(checkperl) rm -rf $(tmp) $(build) $(MAKE) install DESTDIR="$(tmp)" # these end up in the wrong place mv $(share)/Config.pm.static $(lib) mv $(share)/Config_heavy.pl.static $(lib) # switch man extensions to 1p and 3pm for vendor module installs $(PERL_TO_USE) -i -p \ -e 's/^(man1ext=).*/$$1'\''1p'\''/;' \ -e 's/^(man3ext=).*/$$1'\''3pm'\''/;' \ $(lib)/Config.pm $(lib)/Config_heavy.pl \ $(lib)/Config.pm.static $(lib)/Config_heavy.pl.static ifeq (,$(perlabi)) else # add \$Config{debian_abi} sed -i -e "/version =>/i\ debian_abi => '$(perlabi)'," \ $(lib)/Config.pm $(lib)/Config.pm.static endif # avoid exposing the point release in libperl names, to # avoid unnecessary breakage # see #759989 $(PERL_TO_USE) -i -p \ -e 's/^(libperl='\''libperl\.so)\.$(fullversion)'\''/$$1.$(version)'\''/' \ $(lib)/Config.pm $(lib)/Config_heavy.pl \ $(lib)/Config.pm.static $(lib)/Config_heavy.pl.static # remove dpkg-buildflags effects from %Config # see #657853 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) ;; \ *) export flag; $(PERL_TO_USE) -i -pe "/^(cc|cpp)flags/ and \ s/(['\s])\Q\$$ENV{flag}\E(['\s])/\1\2/ and s/ +/ /" \ $(lib)/Config.pm $(lib)/Config_heavy.pl \ $(lib)/Config.pm.static $(lib)/Config_heavy.pl.static ;; \ 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/ +/ /" \ $(lib)/Config.pm $(lib)/Config_heavy.pl \ $(lib)/Config.pm.static $(lib)/Config_heavy.pl.static ; \ done; \ fi # convert required header files -cd /usr/include; \ $(srcdir)/debian/fake-config $(srcdir)/lib $(PERL_TO_USE) \ $(srcdir)/utils/h2ph -a -d $(srcdir)/$(lib) \ `cat $(srcdir)/debian/headers` # fix up generated headers $(PERL_TO_USE) debian/fixheaders $(lib) # simple wrapper around Errno module cp debian/errno.ph $(lib) ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) ifeq (,$(findstring x-perl-notest,$(DEB_BUILD_OPTIONS))) # Verify that the headers are usable for ph in `< debian/headers sed -e 's/\.h$$/.ph/'`; do \ if [ ! -f $(lib)/$$ph ]; then \ echo "$$ph: missing"; else \ echo $$ph | $(PERL_TO_USE) debian/check-require $(tmp) \ || exit 1; \ fi; \ done endif endif # remove some cruft rm -f $(lib)/.packlist # installperl copies the symlinks as a files rm -f $(lib)/CORE/libperl.so $(lib)/CORE/libperl.so.$(version) # remove versioned binary, relink after moving files rm -f $(bin)/perl$(fullversion) # relocate perl libraries and create links cp libperl-static $(tmp)/usr/lib/$(archtriplet)/libperl.a mv $(lib)/CORE/libperl.so.$(fullversion) $(tmp)/usr/lib/$(archtriplet) ln -s libperl.so.$(fullversion) $(tmp)/usr/lib/$(archtriplet)/libperl.so.$(version) ln -s libperl.so.$(version) $(tmp)/usr/lib/$(archtriplet)/libperl.so # move to full version (symlinks created in libperl5.* below) mv $(lib) $(tmp)/usr/lib/$(archtriplet)/perl/$(fullversion) mv $(share) $(tmp)/usr/share/perl/$(fullversion) ifeq ($(installtype),static) cp perl.static $(bin)/perl endif # install debug binary as debugperl cp perl.debug $(bin)/debugperl # install the stashed config.sh files mkdir -p $(pcd) cp config.sh.* $(pcd) gzip -n $(pcd)/config.sh.* cp debian/cross/README $(pcd) # split packages # Note: this relies on the order of debian/control for p in $(packages); \ do \ mkdir -p $(build)/$$p; \ (cd $(tmp); \ for sfx in '' .$(installtype); \ do \ list=../$$p.files$$sfx; \ test -s $$list || continue; \ shopt -s globstar; \ find `grep -v '^#' $$list` ! -type d; \ done) >debian/list.tmp; \ (cd $(tmp); cpio -vdumpl ../build/$$p) &1 | \ grep -v ' linked to '; \ (cd $(tmp); $(PERL_TO_USE) -nle unlink) &2; \ fi; \ done # copy manual pages for {perl,cpan}- test -d $(build)/libperl$(version)/usr/share/man/man1 || \ mkdir -p $(build)/libperl$(version)/usr/share/man/man1 cp $(build)/perl-base/usr/share/man/man1/perl.1 \ $(build)/libperl$(version)/usr/share/man/man1/perl$(version)-$(archtriplet).1 cp $(build)/perl/usr/share/man/man1/cpan.1 \ $(build)/libperl$(version)/usr/share/man/man1/cpan$(version)-$(archtriplet).1 # remove some linked man pages (symlinked later and cause # problems as-is when compressing) rm -f $(build)/perl/usr/share/man/man1/perlthanks.1 # the diagnostics module needs perldiag.pod mkdir $(build)/perl-modules-$(version)/usr/share/perl/$(fullversion)/pod mv $(build)/perl-doc/usr/share/perl/$(fullversion)/pod/perldiag.pod \ $(build)/perl-modules-$(version)/usr/share/perl/$(fullversion)/pod # copy dummy perldoc to perl package cp debian/perl.perldoc $(build)/perl/usr/bin/perldoc chmod 755 $(build)/perl/usr/bin/perldoc # install docs for p in $(packages); \ do \ doc=$(build)/$$p/usr/share/doc; \ test -d $$doc || mkdir -p $$doc; \ if test -f debian/$$p.docs; \ then \ while read src target; \ do \ d=`echo $$target | sed 's,/[^/]*$$,,'`; \ test -d $$doc/$$d || mkdir -p $$doc/$$d; \ if [ "$$src" = "debian/changelog" ] && \ head -1 $$src | grep -iq 'binary-only=yes'; \ then \ # split out binNMU changelog entries \ debian/split-binnmu $$src > $$doc/$$target \ 2> $$doc/$${target}.$(arch); \ else \ cp -p $$src $$doc/$$target; \ fi; \ done $(build)/$$p/DEBIAN/conffiles; \ chmod 644 $(build)/$$p/DEBIAN/conffiles; \ (cd $(build)/$$p; find usr -type f -print | LC_ALL=C sort | xargs -r md5sum) \ >$(build)/$$p/DEBIAN/md5sums; \ chmod 644 $(build)/$$p/DEBIAN/md5sums; \ dpkg-gencontrol -p$$p -P$(build)/$$p $(subst_upstream) $(subst_next_upstream); \ find $(build)/$$p -depth -newermt '$(build_date)' -print0 | \ xargs -0r touch --no-dereference --date='$(build_date)'; \ dpkg --build $(build)/$$p ..; \ done # Build architecture-dependent files here. binary-arch: build-stamp install-stamp $(checkdir) $(checkroot) ifeq ($(installtype),static) echo 'libperl $(version) libperl$(version) (= $${binary:Version})' \ >debian/shlibs.local echo 'libperl $(version) libperl$(version) (>= $(package_upstream_version))' \ >debian/libperl$(version).shlibs else echo 'libperl $(version)' >debian/shlibs.local echo 'libperl $(version) libperl$(version) (>= $(package_upstream_version))' \ >debian/perl-base.shlibs endif for p in $(arch_pkgs); \ do \ rm -rf $(build)/$$p/DEBIAN debian/substvars; \ mkdir $(build)/$$p/DEBIAN; \ for c in preinst postinst prerm postrm shlibs triggers; \ do \ test -f debian/$$p.$$c || continue; \ cp debian/$$p.$$c $(build)/$$p/DEBIAN/$$c; \ chmod 755 $(build)/$$p/DEBIAN/$$c; \ done; \ ! test -f $(build)/$$p/DEBIAN/shlibs || chmod 644 $(build)/$$p/DEBIAN/shlibs; \ ! test -f $(build)/$$p/DEBIAN/triggers || chmod 644 $(build)/$$p/DEBIAN/triggers; \ test -d $(build)/$$p/etc && find $(build)/$$p/etc -type f \ -printf '/etc/%P\n' | LC_ALL=C sort >$(build)/$$p/DEBIAN/conffiles; \ chmod 644 $(build)/$$p/DEBIAN/conffiles; \ (cd $(build)/$$p; find usr -type f -print | LC_ALL=C sort | xargs -r md5sum) \ >$(build)/$$p/DEBIAN/md5sums; \ chmod 644 $(build)/$$p/DEBIAN/md5sums; \ done ifeq ($(installtype),static) dpkg-gensymbols -plibperl$(version) -P$(build)/libperl$(version) endif # dpkg-shlibdeps needs to be run only after all the shlibs are present for p in $(arch_pkgs); \ do \ find $(build)/$$p/usr -type f \ \( -perm /111 -o -name \*.so\* \) -print | \ fgrep -v /usr/lib/debug/ | \ xargs -r dpkg-shlibdeps -S$(srcdir)/$(build)/libperl$(version) \ -S$(srcdir)/$(build)/perl-base 2>&1 | \ fgrep -v 'File format not recognized'; # scripts \ dpkg-gencontrol -p$$p -P$(build)/$$p $(subst_perlapi) $(subst_upstream); \ find $(build)/$$p -depth -newermt '$(build_date)' -print0 | \ xargs -0r touch --no-dereference --date='$(build_date)'; \ dpkg --build $(build)/$$p ..; \ done binary: binary-indep binary-arch .NOTPARALLEL: .PHONY: build clean binary-indep binary-arch binary install build-arch build-indep update-configure