Package: netkit-ftp Version: 0.17-27 Severity: normal Tags: patch User: crossbu...@debian.org Usertags: cross
netkit-ftp fails to cross-build as follows: [...] Generating MCONFIG... sed: -e expression #2, char 63: unknown option to `s' /usr/bin/make make[1]: Entering directory `/«PKGBUILDDIR»' (cd ftp && /usr/bin/make) make[2]: Entering directory `/«PKGBUILDDIR»/ftp' cc cmds.c -c [...] /usr/bin/make INSTALL_OPTS=-s INSTALLROOT=`pwd`/debian/ftp MANDIR=/usr/share/man install make[1]: Entering directory `/«PKGBUILDDIR»' (cd ftp && /usr/bin/make install) make[2]: Entering directory `/«PKGBUILDDIR»/ftp' install -s -m ftp /«PKGBUILDDIR»/debian/ftp install: missing destination file operand after `/«PKGBUILDDIR»/debian/ftp' Try `install --help' for more information. make[2]: *** [install] Error 1 There are multiple problems here: * The seddery in debian/rules fails to handle the situation where *FLAGS contains the '/' character. My cross-build setup sets LDFLAGS to something that contains -L/usr/lib/arm-linux-gnueabihf (and various other similar stuff) to work around for a toolchain bug; in general '/' seems moderately likely to occur in linker flags. I opted for the ';' separator instead, on the basis that that doesn't tend to occur in compiler/linker flags very often, but you might prefer to rewrite this in a more sophisticated way that can handle any input. * The native compiler is used rather than the appropriate cross-compiler. While autoconf works this out automatically with a bit of help from dh_auto_configure or manual use of --build/--host options, simpler build systems tend to have to be told what to do in a variety of ways. * The install error is due to the earlier sed failure, but after fixing that it still fails due to using 'install -s', which calls the native strip program rather than the appropriate cross-strip. We could take care to avoid -s when cross-building as dh_strip will already take care of it; but why bother with -s at all? dh_strip always does at least as good a job, so we might as well just let it get on with it in all cases. The following patch fixes all these problems and results in a successful cross-build from amd64 to armhf. * Tolerate '/' in CPPFLAGS, CFLAGS, or LDFLAGS. (This is at the expense of not tolerating ';', but that at least seems less likely to occur.) * Use correct compiler when cross-building. * Never pass -s to install; dh_strip does a more accurate job of it anyway, and knows how to use the correct strip command when cross-building. diff -Nru netkit-ftp-0.17/debian/rules netkit-ftp-0.17/debian/rules --- netkit-ftp-0.17/debian/rules 2012-05-23 18:35:11.000000000 +0100 +++ netkit-ftp-0.17/debian/rules 2012-12-02 23:57:44.000000000 +0000 @@ -7,26 +7,30 @@ #export DH_VERBOSE=1 DEFS := -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) - INSTALL_OPTS = -s -endif - CFLAGS += $(shell dpkg-buildflags --get CFLAGS) CPPFLAGS += $(shell dpkg-buildflags --get CPPFLAGS) LDFLAGS += $(shell dpkg-buildflags --get LDFLAGS) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) + CROSS := +else + CROSS := CC=$(DEB_HOST_GNU_TYPE)-gcc +endif + build: build-stamp build-stamp: dh_testdir if [ ! -f MCONFIG ]; then \ ./configure; \ - sed -e 's/^CFLAGS=\(.*\)$$/CFLAGS= -g $(DEFS) -fno-strict-aliasing $(CFLAGS) $(CPPFLAGS) \1/' \ - -e 's/^LDFLAGS=\(.*\)$$/& $(LDFLAGS)/' \ + sed -e 's;^CFLAGS=\(.*\)$$;CFLAGS= -g $(DEFS) -fno-strict-aliasing $(CFLAGS) $(CPPFLAGS) \1;' \ + -e 's;^LDFLAGS=\(.*\)$$;& $(LDFLAGS);' \ MCONFIG > MCONFIG.new; \ mv MCONFIG.new MCONFIG; \ fi - $(MAKE) + $(MAKE) $(CROSS) touch build-stamp @@ -46,7 +50,7 @@ dh_prep dh_installdirs - $(MAKE) INSTALL_OPTS=$(INSTALL_OPTS) INSTALLROOT=`pwd`/debian/ftp MANDIR=/usr/share/man install + $(MAKE) INSTALLROOT=`pwd`/debian/ftp MANDIR=/usr/share/man install mv debian/ftp/usr/bin/ftp debian/ftp/usr/bin/netkit-ftp ln -sf netkit-ftp debian/ftp/usr/bin/pftp mv debian/ftp/usr/share/man/man1/ftp.1 \ Thanks, -- Colin Watson [cjwat...@ubuntu.com] -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org