--- /home/neil/code/debian/src/perl/patches/original/perl-5.14.2/debian/rules 2013-03-07 17:01:37.000000000 +0000 +++ patches/debian/rules 2013-03-23 17:48:09.000000000 +0000 @@ -35,29 +35,67 @@ checkroot = test `id -u` -eq 0 checkperl = $(SHELL) debian/checkperl +# CROSSING +# Don't configure - copy in cross files +# NOTE: Different for static/shared/debug +# usecrosscompile not set no target host etc +# Don't build miniperl - use host perl +# Later - build host miniperl +# Later - find on host +# + +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) + # 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') +ifeq ($(DEB_HOST_GNU_TYPE), $(DEB_BUILD_GNU_TYPE)) + PERL_EXE = + PERL_TO_USE = $(srcdir)/perl.static + HEADER_DIR = /usr/include + OBJCOPY = objcopy + STRIP = strip + export ZLIB_INCLUDE=/usr/include + export ZLIB_LIB=/usr/lib + export BZIP2_INCLUDE=/usr/include + export BZIP2_LIB=/usr/lib + export INCLUDE=/usr/include + export LIB=/usr/lib +else + PERL_EXE = $(shell which perl) + PERL_TO_USE = $(PERL_EXE) + # we use old-style dpkg-cross paths only. See other rules file. + ifeq (,$(wildcard /usr/lib/$(DEB_BUILD_MULTIARCH)/perl)) + PERL_EXE_LIBS = /usr/lib/perl/$(package_upstream_version) + HEADER_DIR = /usr/$(DEB_HOST_GNU_TYPE)/include + export ZLIB_INCLUDE=/usr/$(DEB_HOST_GNU_TYPE)/include + export ZLIB_LIB=/usr/$(DEB_HOST_GNU_TYPE)/lib + export BZIP2_INCLUDE=/usr/$(DEB_HOST_GNU_TYPE)/include + export BZIP2_LIB=/usr/$(DEB_HOST_GNU_TYPE)/lib + export INCLUDE=/usr/$(DEB_HOST_GNU_TYPE)/include + export LIB=/usr/$(DEB_HOST_GNU_TYPE)/lib + endif + OBJCOPY = $(DEB_HOST_GNU_TYPE)-objcopy + STRIP = $(DEB_HOST_GNU_TYPE)-strip +endif + # this gets prepended to the patch names in patchlevel.h patchprefix = DEBPKG: # control file substitutions subst_upstream = -VUpstream-Version=$(package_upstream_version) -subst_perlapi = -Vperlapi:Provides="`./perl.static debian/mkprovides`" +subst_perlapi = -Vperlapi:Provides="`$(PERL_TO_USE) debian/mkprovides`" subst_next_upstream = -VNext-Upstream-Version=$(nextversion) # 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 build: build-stamp install: install-stamp @@ -73,43 +111,77 @@ test -f $< # maintainer sanity check debian/gen-patchlevel -p $(patchprefix) -v $(package_version) $< > $@ +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + +define variant +$(if $(findstring static,$1),static,$(if $(findstring debug,$1),debug,shared)) +endef + +define cross-config + /usr/bin/perl-cross-debian --variant $(call variant,$@) + perl -Ilib make_patchnum.pl +endef +endif + perl.static: $(checkdir) rm -f libperl.so* # must be built last - [ ! -f Makefile ] || $(MAKE) distclean + [ ! -f Makefile ] || $(MAKE) distclean CROSS_PERL=$(PERL_EXE) [ -f $(patchlevel) ] || touch $(patchlevel) +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) $(SHELL) debian/config.debian --static - $(MAKE) perl $(test_target) +else + $(cross-config) +endif + $(MAKE) perl $(test_target) CROSS_PERL=$(PERL_EXE) mv libperl.a libperl-static mv perl perl.static # for the build log - ./perl.static -Ilib -V + $(PERL_TO_USE) -Ilib -V perl.debug: $(checkdir) rm -f libperl.so* # must be built last - [ ! -f Makefile ] || $(MAKE) distclean + [ ! -f Makefile ] || $(MAKE) distclean CROSS_PERL=$(PERL_EXE) [ -f $(patchlevel) ] || touch $(patchlevel) +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) $(SHELL) debian/config.debian --debug - $(MAKE) perl +else + $(cross-config) +endif + $(MAKE) perl CROSS_PERL=$(PERL_EXE) mv perl perl.debug libperl.so.$(fullversion): $(checkdir) - [ ! -f Makefile ] || $(MAKE) distclean + [ ! -f Makefile ] || $(MAKE) distclean CROSS_PERL=$(PERL_EXE) [ -f $(patchlevel) ] || touch $(patchlevel) +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) $(SHELL) debian/config.debian --shared - $(MAKE) SHRPLDFLAGS='$$(LDDLFLAGS) -Wl,-soname,libperl.so.$(version)' $@ +else + $(cross-config) +endif + $(MAKE) SHRPLDFLAGS='$$(LDDLFLAGS) -Wl,-soname,libperl.so.$(version)' $@ CROSS_PERL=$(PERL_EXE) ln -s libperl.so.$(fullversion) libperl.so.$(version) ln -s libperl.so.$(version) libperl.so +ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) $(MAKE) all $(test_target) || { rm -f libperl.so*; exit 1; } +else + @echo "Need to use installed (host) extensions when building extensions...." + @echo "Overwrite any built so far" + cp -fr $(PERL_EXE_LIBS)/auto/* lib/auto/ + @echo "Now make the extensions" + -mkdir lib/$(DEB_HOST_GNU_TYPE) + $(MAKE) extensions CROSS_PERL=$(PERL_EXE) INST_ARCHLIB=$(srcdir)/lib/$(DEB_HOST_GNU_TYPE) +endif + clean: $(checkdir) $(checkroot) test -f $(patches) # maintainer sanity check - [ ! -f Makefile ] || $(MAKE) distclean + [ ! -f Makefile ] || $(MAKE) distclean CROSS_PERL=$(PERL_EXE) 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 \ @@ -117,17 +189,33 @@ # rm -f cpan/DB_File/DB_File.pm.bak cpan/DB_File/t/db-btree.t.bak \ cpan/DB_File/t/db-hash.t.bak cpan/DB_File/t/db-recno.t.bak + $(RM) t/pod2htmd.tmp t/pod2htmi.tmp +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + perl-cross-debian --clean +endif install-stamp: build-stamp $(checkdir) $(checkroot) $(checkperl) rm -rf $(tmp) $(build) - +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) + @echo "Copy back all the target-independent extensions - for use and installation" + cp -fr $(PERL_EXE_LIBS)/auto/* lib/auto/ + $(MAKE) install CROSS_PERL=$(PERL_EXE) + @echo "Copy the arch dependent ones over the debian ones for installation into packages" + find . -name .exists -o -name '*.bs' | xargs rm -f + -mkdir -p $(lib)/auto + cp -fr lib/$(DEB_HOST_GNU_TYPE)/auto/* $(lib)/auto/ + echo "Don't install INST_ARCHLIB into packages" + -find $(tmp)/usr/share/perl -name $(DEB_HOST_GNU_TYPE) -exec rm -fr {} \; +else $(MAKE) install +endif # remove temporary prefix on install vars and switch man # extensions to 1p and 3pm for vendor module installs - SRCDIR="$(srcdir)" ./perl.static -i -pe 's!\Q$$ENV{SRCDIR}\E/$(tmp)/!/! if /install/;' \ + + SRCDIR="$(srcdir)" $(PERL_TO_USE) -i -pe 's!\Q$$ENV{SRCDIR}\E/$(tmp)/!/! if /install/;' \ -e 's/^(man1ext=).*/$$1'\''1p'\''/;' \ -e 's/^(man3ext=).*/$$1'\''3pm'\''/;' \ $(lib)/Config.pm $(lib)/Config_heavy.pl @@ -138,24 +226,24 @@ for flag in $(shell dpkg-buildflags --get CPPFLAGS) \ $(shell dpkg-buildflags --get CFLAGS); do \ case "$$flag" in -fstack-protector) ;; \ - *) ./perl.static -i -pe "/^(cc|cpp)flags/ and \ - s/(['\s])\Q$$flag\E(['\s])/\1\2/ and s/ +/ /" \ + *) $(PERL_TO_USE) -i -pe "/^(cc|cpp)flags/ and \ + s#(['\s])\Q$$flag\E(['\s])#\1\2# and s/ +/ /" \ $(lib)/Config.pm $(lib)/Config_heavy.pl ;; \ esac; done; \ for flag in $(shell dpkg-buildflags --get LDFLAGS); do \ - ./perl.static -i -pe "/^ld(dl)?flags/ and \ - s/(['\s])\Q$$flag\E(['\s])/\1\2/ and s/ +/ /" \ + $(PERL_TO_USE) -i -pe "/^ld(dl)?flags/ and \ + s#(['\s])\Q$$flag\E(['\s])#\1\2# and s/ +/ /" \ $(lib)/Config.pm $(lib)/Config_heavy.pl ; \ done; \ fi # convert required header files - -cd /usr/include; $(srcdir)/perl.static -I $(srcdir)/lib \ + -cd $(HEADER_DIR); $(PERL_TO_USE) -I $(srcdir)/lib \ $(srcdir)/utils/h2ph -a -d $(srcdir)/$(lib) \ `cat $(srcdir)/debian/headers` # fix up generated headers - ./perl.static -Ilib debian/fixheaders $(lib) + $(PERL_TO_USE) -Ilib debian/fixheaders $(lib) # simple wrapper around Errno module cp debian/errno.ph $(lib) @@ -163,10 +251,10 @@ 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 \ + for ph in `< $(srcdir)/debian/headers sed -e 's/\.h$$/.ph/'`; do \ + if [ ! -f $(srcdir)/$(lib)/$$ph ]; then \ echo "$$ph: missing"; else \ - echo $$ph | ./perl.static debian/check-require $(tmp) \ + echo $$ph | $(PERL_TO_USE) debian/check-require $(tmp) \ || exit 1; \ fi; \ done @@ -184,7 +272,7 @@ # relocate perl libraries and create links cp libperl-static $(tmp)/usr/lib/libperl.a - mv $(lib)/CORE/libperl.so.$(fullversion) $(tmp)/usr/lib + -mv $(lib)/CORE/libperl.so.$(fullversion) $(tmp)/usr/lib ln -s libperl.so.$(fullversion) $(tmp)/usr/lib/libperl.so.$(version) ln -s libperl.so.$(version) $(tmp)/usr/lib/libperl.so @@ -213,14 +301,14 @@ done) >debian/list.tmp; \ (cd $(tmp); cpio -vdumpl ../build/$$p) &1 | \ grep -v ' linked to '; \ - (cd $(tmp); ../../perl.static -nle unlink) $(build)/perl/usr/share/man/man1/prename.1 # install docs @@ -336,12 +424,12 @@ dir=$${path%/*}; \ test -d $(debug)$$dir || mkdir -p $(debug)$$dir; \ # stash debugging symbols \ - objcopy --only-keep-debug $$f $(debug)$$path; \ + $(OBJCOPY) --only-keep-debug $$f $(debug)$$path; \ # strip \ - strip --remove-section=.comment --remove-section=.note \ + $(STRIP) --remove-section=.comment --remove-section=.note \ $$extra $$f; \ # add debuglink \ - objcopy --add-gnu-debuglink=$(debug)$$path $$f; \ + $(OBJCOPY) --add-gnu-debuglink=$(debug)$$path $$f; \ esac; \ done # versioned hardlink for the detached debug symbols @@ -384,7 +472,7 @@ $(checkdir) $(checkroot) rm -f debian/substvars - for p in `./perl.static -l -00ne 'print $$1 if /^Architecture:\s+all/m \ + for p in `$(PERL_TO_USE) -l -00ne 'print $$1 if /^Architecture:\s+all/m \ and /^Package:\s+(.*)/m' debian/control`; \ do \ rm -rf $(build)/$$p/DEBIAN; \ @@ -420,7 +508,7 @@ >debian/perl-base.shlibs endif - for p in `./perl.static -l -00ne 'print $$1 if /^Architecture:\s+any/m \ + for p in `$(PERL_TO_USE) -l -00ne 'print $$1 if /^Architecture:\s+any/m \ and /^Package:\s+(.*)/m' debian/control`; \ do \ rm -rf $(build)/$$p/DEBIAN debian/substvars; \ @@ -436,7 +524,7 @@ >$(build)/$$p/DEBIAN/md5sums; \ done # dpkg-shlibdeps needs to be run only after all the shlibs are present - for p in `./perl.static -l -00ne 'print $$1 if /^Architecture:\s+any/m \ + for p in `$(PERL_TO_USE) -l -00ne 'print $$1 if /^Architecture:\s+any/m \ and /^Package:\s+(.*)/m' debian/control`; \ do \ find $(build)/$$p/usr -type f \