--- debian/changelog	2013-02-12 04:14:33.000000000 +0000
+++ perl/codehelp/perl-5.14.2/debian/changelog	2013-02-15 09:28:27.000000000 +0000
@@ -1,14 +1,10 @@
-perl (5.14.2-18ma1cross1) precise; urgency=low
-
-  [ Neil Williams ]
-  * Cross build with debian-perl-cross 
-
- -- Wookey <wookey@wookware.org>  Tue, 12 Feb 2013 04:10:19 +0000
-
 perl (5.14.2-18ma1) raring; urgency=low
 
-  [ Niko Tyni]
-  * Multiarch support
+  [ Wookey ]
+  * Include Niko Tyni's multiarch support
+
+  [ Neil Williams ]
+  * Add perl-cross-debian support
 
  -- Wookey <wookey@e102475-lin>  Mon, 11 Feb 2013 23:49:28 +0000
 
--- debian/control	2013-02-12 14:39:46.000000000 +0000
+++ perl/codehelp/perl-5.14.2/debian/control	2013-02-15 09:22:07.000000000 +0000
@@ -7,7 +7,7 @@
 Homepage: http://dev.perl.org/perl5/
 Build-Depends: file, cpio (>= 2.6-5), libdb-dev, libgdbm-dev, netbase [!hurd-any],
  gcc (>= 4:4.2), procps [!hurd-any], zlib1g-dev | libz-dev, libbz2-dev,
- dpkg-dev (>= 1.16.0), debian-perl-cross
+ dpkg-dev (>= 1.16.0)
 Build-Conflicts: libterm-readline-gnu-perl (<< 1.17), libfile-sharedir-perl
 Vcs-Git: git://anonscm.debian.org/perl/perl.git
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=perl/perl.git
--- debian/patches/debian/fakeroot.diff	2013-02-09 13:29:11.000000000 +0000
+++ perl/codehelp/perl-5.14.2/debian/patches/debian/fakeroot.diff	2013-02-15 10:21:09.000000000 +0000
@@ -15,11 +15,9 @@
  Makefile.SH |    9 ++-------
  1 file changed, 2 insertions(+), 7 deletions(-)
 
-diff --git a/Makefile.SH b/Makefile.SH
-index eb6326a..1dac585 100755
 --- a/Makefile.SH
 +++ b/Makefile.SH
-@@ -36,12 +36,7 @@ case "$useshrplib" in
+@@ -36,12 +36,7 @@
  true)
  	# Prefix all runs of 'miniperl' and 'perl' with
  	# $ldlibpth so that ./perl finds *this* shared libperl.
@@ -33,7 +31,7 @@
  
  	pldlflags="$cccdlflags"
  	static_ldflags=''
-@@ -112,7 +107,7 @@ true)
+@@ -112,7 +107,7 @@
  	    ;;
  	esac
  	case "$ldlibpthname" in
--- debian/patches/debian/Makefile-cross.diff	1970-01-01 01:00:00.000000000 +0100
+++ perl/codehelp/perl-5.14.2/debian/patches/debian/Makefile-cross.diff	2013-02-15 10:21:35.000000000 +0000
@@ -0,0 +1,142 @@
+Description: Add existing patch from perl-cross-debian
+ .
+ perl (5.14.2-18ma1) raring; urgency=low
+ .
+   [ Wookey ]
+   * Include Niko Tyni's multiarch support
+ .
+   [ Neil Williams ]
+   * Add perl-cross-debian support
+Author: Neil Williams <codehelp@debian.org>
+
+--- a/Makefile.SH
++++ b/Makefile.SH
+@@ -291,10 +291,12 @@
+ OBJ_EXT = $_o
+ PATH_SEP = $p_
+ 
++ifeq (,\$(CROSS_PERL))
+ # Macros to invoke a copy of miniperl during the build.  Targets which
+ # are built using these macros should depend on \$(MINIPERL_EXE)
+ MINIPERL_EXE = miniperl\$(EXE_EXT)
+ MINIPERL = \$(LDLIBPTH) \$(RUN) ./miniperl\$(EXE_EXT) -Ilib
++HOST_MINIPERL = $(MINIPERL_EXE)
+ 
+ # Macros to invoke a copy of our fully operational perl during the build.
+ PERL_EXE = perl\$(EXE_EXT)
+@@ -303,6 +305,23 @@
+ # Macros to run our tests
+ RUN_TESTS = \$(LDLIBPTH) ./runtests
+ 
++else # CROSS_PERL
++
++# Macros to invoke a copy of miniperl during the build.  Targets which
++# are built using these macros should depend on \$(MINIPERL_EXE)
++MINIPERL_EXE = miniperl\$(EXE_EXT)
++MINIPERL = \$(CROSS_PERL)
++HOST_MINIPERL = \$(CROSS_PERL)
++
++# Macros to invoke a copy of our fully operational perl during the build.
++PERL_EXE = perl\$(EXE_EXT)
++RUN_PERL = \$(CROSS_PERL)
++
++# Macros to run our tests
++RUN_TESTS = echo "Not running tests"
++
++endif # CROSS_PERL
++
+ dynamic_ext = $dynamic_list
+ dynamic_ext_re = $dynamic_ext_re
+ static_ext = $static_list
+@@ -533,6 +552,9 @@
+ 	@echo " ";
+ 	@echo "	Everything is up to date. Type '$(MAKE) test' to run test suite."
+ 
++# Cross building requires a separate target to allow manipulation of the build tree
++extensions:     $(dynamic_ext) $(nonxs_ext)
++
+ .PHONY: all translators utilities
+ 
+ # Both git_version.h and lib/Config_git.pl are built
+@@ -616,6 +638,9 @@
+ 
+ globals$(OBJ_EXT): uudmap.h bitcount.h
+ 
++ifeq (,\$(CROSS_PERL))
++# If we're cross-building, we should have uudmap.h and bitcount.h
++# provided already
+ uudmap.h: bitcount.h
+ 
+ bitcount.h: generate_uudmap$(HOST_EXE_EXT)
+@@ -623,6 +648,7 @@
+ 
+ generate_uudmap$(HOST_EXE_EXT): generate_uudmap$(OBJ_EXT)
+ 	$(CC) -o generate_uudmap$(EXE_EXT) $(LDFLAGS) generate_uudmap$(OBJ_EXT) $(libs)
++endif
+ 
+ miniperlmain$(OBJ_EXT): miniperlmain.c patchlevel.h
+ 	$(CCCMD) $(PLDLFLAGS) $*.c
+@@ -795,18 +821,30 @@
+ 	aix*|beos*)
+ 		$spitshell >>$Makefile <<'!NO!SUBS!'
+ $(MINIPERL_EXE): $& miniperlmain$(OBJ_EXT) $(mini_obj) opmini$(OBJ_EXT) perlmini$(OBJ_EXT)
++ifeq (,$(CROSS_PERL))
+ 	$(CC) -o $(MINIPERL_EXE) $(CLDFLAGS) \
+ 	    $(mini_obj) \
+ 	    miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perlmini$(OBJ_EXT) $(libs)
+ 	$(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
++else
++	-rm $(MINIPERL_EXE)
++	ln -s $(HOST_MINIPERL) $(MINIPERL_EXE)
++endif
++
+ !NO!SUBS!
+ 		;;
+ 	next4*)
+ 		$spitshell >>$Makefile <<'!NO!SUBS!'
+ $(MINIPERL_EXE): $& miniperlmain$(OBJ_EXT) $(mini_obj) perlmini$(OBJ_EXT) opmini$(OBJ_EXT)
++ifeq (,$(CROSS_PERL))
+ 	$(CC) -o $(MINIPERL_EXE) $(mini_obj) \
+ 	    miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perlmini$(OBJ_EXT) $(libs)
+ 	$(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
++else
++	-rm $(MINIPERL_EXE)
++	ln -s $(HOST_MINIPERL) $(MINIPERL_EXE)
++endif
++
+ !NO!SUBS!
+ 		;;
+ 	darwin*)
+@@ -825,20 +863,32 @@
+ 		$spitshell >>$Makefile <<'!NO!SUBS!'
+ $(MINIPERL_EXE): $& miniperlmain$(OBJ_EXT) $(mini_obj) opmini$(OBJ_EXT) perlmini$(OBJ_EXT)
+ 	-@rm -f miniperl.xok
++ifeq (,$(CROSS_PERL))
+ 	$(CC) $(CLDFLAGS) $(NAMESPACEFLAGS) -o $(MINIPERL_EXE) \
+ 	    $(mini_obj) \
+ 	    miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perlmini$(OBJ_EXT) $(libs)
+ 	$(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
++else
++	-rm $(MINIPERL_EXE)
++	ln -s $(HOST_MINIPERL) $(MINIPERL_EXE)
++endif
++
+ !NO!SUBS!
+ 		;;
+ 	*)
+ 		$spitshell >>$Makefile <<'!NO!SUBS!'
+ $(MINIPERL_EXE): $& miniperlmain$(OBJ_EXT) $(mini_obj) opmini$(OBJ_EXT) perlmini$(OBJ_EXT)
+ 	-@rm -f miniperl.xok
++ifeq (,$(CROSS_PERL))
+ 	$(LDLIBPTH) $(CC) $(CLDFLAGS) -o $(MINIPERL_EXE) \
+ 	    $(mini_obj) \
+ 	    miniperlmain$(OBJ_EXT) opmini$(OBJ_EXT) perlmini$(OBJ_EXT) $(libs)
+ 	$(LDLIBPTH) $(RUN) ./miniperl$(HOST_EXE_EXT) -w -Ilib -MExporter -e '<?>' || $(MAKE) minitest
++else
++	-rm $(MINIPERL_EXE)
++	ln -s $(HOST_MINIPERL) $(MINIPERL_EXE)
++endif
++
+ !NO!SUBS!
+ 		;;
+ 	esac
--- debian/patches/series	2013-02-09 13:29:12.000000000 +0000
+++ perl/codehelp/perl-5.14.2/debian/patches/series	2013-02-15 09:31:52.000000000 +0000
@@ -76,3 +76,5 @@
 fixes/digest-sha-doublefree.diff
 fixes/64bitint-signedness-wraparound.diff
 fixes/stdin-sigchld.diff
+debian/Makefile-cross.diff
+
--- debian/rules	2013-02-12 04:09:51.000000000 +0000
+++ perl/codehelp/perl-5.14.2/debian/rules	2013-02-18 12:12:23.000000000 +0000
@@ -26,6 +26,7 @@
 tmp	    = debian/tmp
 bin         = $(tmp)/usr/bin
 man         = $(tmp)/usr/share/man
+hostlibs    = $(tmp)/usr/lib/perl/$(version)
 lib         = $(tmp)/usr/lib/$(archtriplet)/perl/$(version)
 share       = $(tmp)/usr/share/perl/$(version)
 build	    = debian/build
@@ -59,20 +60,32 @@
         HOST_PERL = 
         PERL_TO_USE = $(srcdir)/perl.static
         HEADER_DIR = /usr/include
-        LIBRARY_DIR = /usr/lib
         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
         HOST_PERL = $(shell which perl)
         PERL_TO_USE = $(HOST_PERL)
-        HOST_PERL_LIBS = /usr/lib/perl/$(package_upstream_version)
-        HEADER_DIR  = /usr/include/$(DEB_HOST_GNU_TYPE)
-        LIBRARY_DIR = /usr/lib/$(DEB_HOST_GNU_TYPE)
+        ifneq (,$(wildcard /usr/lib/$(DEB_BUILD_MULTIARCH)/perl))
+           HOST_PERL_LIBS = /usr/lib/$(DEB_BUILD_MULTIARCH)/perl/$(package_upstream_version)
+        else
+          HOST_PERL_LIBS = /usr/lib/perl/$(package_upstream_version)
+        endif
+        HEADER_DIR  = /usr/$(DEB_HOST_GNU_TYPE)/include
         OBJCOPY = $(DEB_HOST_GNU_TYPE)-objcopy
         STRIP = $(DEB_HOST_GNU_TYPE)-strip
+        export ZLIB_INCLUDE=/usr/$(DEB_HOST_GNU_TYPE)/include
+        export ZLIB_LIB=/usr/lib/$(DEB_HOST_GNU_TYPE)
+        export BZIP2_INCLUDE=/usr/$(DEB_HOST_GNU_TYPE)/include
+        export BZIP2_LIB=/usr/lib/$(DEB_HOST_GNU_TYPE)
+        export INCLUDE=/usr/$(DEB_HOST_GNU_TYPE)/include
+        export LIB=/usr/lib/$(DEB_HOST_GNU_TYPE)
 endif
-export INCLUDE=$(HEADER_DIR)
-export LIB=$(LIBRARY_DIR)
 
 # this gets prepended to the patch names in patchlevel.h
 patchprefix = DEBPKG:
@@ -91,13 +104,9 @@
 
 # for cpan/Compress-Raw-Zlib
 export BUILD_ZLIB=False
-export ZLIB_INCLUDE=$(HEADER_DIR)
-export ZLIB_LIB=$(LIBRARY_DIR)
 
 # for cpan/Compress-Raw-Bzip2
 export BUILD_BZIP2=0
-export BZIP2_INCLUDE=$(HEADER_DIR)
-export BZIP2_LIB=$(LIBRARY_DIR)
 
 build: build-stamp
 install: install-stamp
@@ -113,6 +122,18 @@
 	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
@@ -121,7 +142,7 @@
 ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 	$(SHELL) debian/config.debian --static
 else
-	perl-cross-debian --variant static
+	$(cross-config)
 endif
 	$(MAKE) perl $(test_target)  CROSS_PERL=$(HOST_PERL)
 	mv libperl.a libperl-static
@@ -138,7 +159,7 @@
 ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 	$(SHELL) debian/config.debian --debug
 else
-	perl-cross-debian --variant debug
+	$(cross-config)
 endif
 	$(MAKE) perl CROSS_PERL=$(HOST_PERL)
 	mv perl perl.debug
@@ -150,7 +171,7 @@
 ifeq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 	$(SHELL) debian/config.debian --shared
 else
-	perl-cross-debian --variant shared
+	$(cross-config)
 endif
 	$(MAKE) SHRPLDFLAGS='$$(LDDLFLAGS) -Wl,-soname,libperl.so.$(version)' $@ CROSS_PERL=$(HOST_PERL)
 	ln -s libperl.so.$(fullversion) libperl.so.$(version)
@@ -166,11 +187,12 @@
 	$(MAKE) extensions CROSS_PERL=$(HOST_PERL) INST_ARCHLIB=$(srcdir)/lib/$(DEB_HOST_GNU_TYPE)
 endif
 
+
 clean:
 	$(checkdir)
 	$(checkroot)
 	test -f $(patches)	# maintainer sanity check
-	[ ! -f Makefile ] || $(MAKE) distclean CROSS_PERL=$(HOST_PERL)
+	[ ! -f Makefile ] || $(MAKE) distclean  CROSS_PERL=$(HOST_PERL)
 	rm -rf config.over perl.static perl.debug libperl-static libperl.so* \
 	    $(patchlevel) build-stamp install-stamp t/auto \
 	    debian/libperl$(version).shlibs \
@@ -178,7 +200,6 @@
 	# <https://rt.cpan.org/Public/Bug/Display.html?id=68214>
 	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
-	find lib -name .exists -o -name '*.so' -o -name '*.bs' -o -name '*.ld' | xargs rm -f
 ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
 	perl-cross-debian --clean
 endif
@@ -190,11 +211,11 @@
 	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"
-	mkdir -p $(lib)/auto/
-	cp -fr $(HOST_PERL_LIBS)/auto/* $(lib)/auto/
+	cp -fr $(HOST_PERL_LIBS)/auto/* lib/auto/
 	$(MAKE) install CROSS_PERL=$(HOST_PERL)
 	@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 {} \;
@@ -203,6 +224,7 @@
 endif
 	# remove temporary prefix on install vars and switch man
 	# extensions to 1p and 3pm for vendor module installs
+
 	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'\''/;' \
@@ -212,7 +234,7 @@
 	# 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 \$(PERL_TO_USE)
+		         $(shell dpkg-buildflags --get CFLAGS); do \
 			case "$$flag" in -fstack-protector) ;; \
 			     *) $(PERL_TO_USE) -i -pe "/^(cc|cpp)flags/ and \
 			          s/(['\s])\Q$$flag\E(['\s])/\1\2/ and s/  +/ /" \
@@ -250,10 +272,10 @@
 endif
 
 	# remove some cruft
-	rm -f $(lib)/.packlist
+	rm -f $(hostlibs)/.packlist
 
 	# installperl copies the symlinks as a files
-	rm -f $(lib)/CORE/libperl.so $(lib)/CORE/libperl.so.$(version)
+	rm -f $(hostlibs)/CORE/libperl.so $(lib)/CORE/libperl.so.$(version)
 
 	# remove versioned binary, relink after moving files
 	rm -f $(bin)/perl$(fullversion)
@@ -265,7 +287,7 @@
 
 	# 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)
+	mv $(hostlibs)/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
@@ -273,6 +295,9 @@
 	# move to full version (symlinks created in perl-base below)
 	mv $(lib) $(tmp)/usr/lib/$(archtriplet)/perl/$(fullversion)
 	mv $(share) $(tmp)/usr/share/perl/$(fullversion)
+ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
+	rm -rf $(hostlibs)
+endif
 
 ifeq ($(installtype),static)
 	cp perl.static $(bin)/perl
