From fdbb78f4555e144f625d76365b045f6780dfc699 Mon Sep 17 00:00:00 2001 From: "Aaron M. Ucko" Date: Sun, 29 Sep 2019 21:50:15 -0400 Subject: [PATCH] debian/rules: Allow for cross-building (Closes: #930240). - Factor a DEB_CONFIGURE_COMMON_FLAGS macro out of DEB_CONFIGURE_EXTRA_FLAGS for flags that also make sense for native builds of internal helpers. - Conditionally supply --build=... and --host= to the main (historically, only) configure run per Helmut Grohne's suggestion. (dh_auto_configure would take care of this, but insists on passing a --runstatedir=... flag this configure script doesn't accept.) - Conditionally add a rule for building native datatool and project_tree_builder binaries (in a parallel build tree established via another configure invocation), make it a dependency of override_dh_auto_configure-arch, and arrange for everything else to use these binaries as needed. - Honor DEB_BUILD_OPTIONS="... nocheck ...", also per Helmut. - Rework logic to install (possibly indirect) local library dependencies to use readelf rather than ldd, making as many passes as necessary (four at present, but no hardcoded count). --- debian/changelog | 26 ++++++++++++++++--- debian/rules | 66 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9c0df93d..99c6c39f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,28 @@ ncbi-blast+ (2.9.0-2) UNRELEASED; urgency=medium * NOT RELEASED YET. - * debian/rules: Delegate dpkg-{architecture,buildflags} calls to - /usr/share/dpkg/{architecture,buildflags}.mk respectively. - - -- Aaron M. Ucko Sun, 29 Sep 2019 15:40:25 -0400 + * debian/rules: + - Delegate dpkg-{architecture,buildflags} calls to + /usr/share/dpkg/{architecture,buildflags}.mk respectively. + - Allow for cross-building (Closes: #930240): + -- Factor a DEB_CONFIGURE_COMMON_FLAGS macro out of + DEB_CONFIGURE_EXTRA_FLAGS for flags that also make sense for native + builds of internal helpers. + -- Conditionally supply --build=... and --host= to the main + (historically, only) configure run per Helmut Grohne's suggestion. + (dh_auto_configure would take care of this, but insists on passing + a --runstatedir=... flag this configure script doesn't accept.) + -- Conditionally add a rule for building native datatool and + project_tree_builder binaries (in a parallel build tree established + via another configure invocation), make it a dependency of + override_dh_auto_configure-arch, and arrange for everything else to + use these binaries as needed. + -- Honor DEB_BUILD_OPTIONS="... nocheck ...", also per Helmut. + -- Rework logic to install (possibly indirect) local library + dependencies to use readelf rather than ldd, making as many passes + as necessary (four at present, but no hardcoded count). + + -- Aaron M. Ucko Sun, 29 Sep 2019 21:50:14 -0400 ncbi-blast+ (2.9.0-1) unstable; urgency=medium diff --git a/debian/rules b/debian/rules index 95cbb751..8ddcb42c 100755 --- a/debian/rules +++ b/debian/rules @@ -9,12 +9,12 @@ ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) endif +DEB_CONFIGURE_COMMON_FLAGS=--without-autodep --without-makefile-auto-update \ + --with-flat-makefile --without-caution --without-dbapi --without-lzo \ + --without-debug --without-downloaded-vdb +DEB_CONFIGURE_EXTRA_FLAGS=$(DEB_CONFIGURE_COMMON_FLAGS) --with-dll --with-mt \ + --with-runpath=/usr/lib/ncbi-blast+ --with-build-root=BUILD --with-mbedtls -DEB_CONFIGURE_EXTRA_FLAGS=--with-dll --with-mt --without-autodep \ - --without-makefile-auto-update --with-flat-makefile --without-caution \ - --without-dbapi --without-lzo --with-runpath=/usr/lib/ncbi-blast+ \ - --with-build-root=BUILD --without-debug --without-downloaded-vdb \ - --with-mbedtls proj=algo/blast/ app/ objmgr/ objtools/align_format/ objtools/blast/ #ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) @@ -39,16 +39,33 @@ endif export CFLAGS CPPFLAGS CXXFLAGS LDFLAGS MAKE # used for run_with_lock -DEB_CONFIGURE_EXTRA_FLAGS += CFLAGS_FOR_BUILD="$(CFLAGS) -fPIE" -DEB_CONFIGURE_EXTRA_FLAGS += LDFLAGS_FOR_BUILD="$(LDFLAGS)" +DEB_CONFIGURE_COMMON_FLAGS += CFLAGS_FOR_BUILD="$(CFLAGS) -fPIE" +DEB_CONFIGURE_COMMON_FLAGS += LDFLAGS_FOR_BUILD="$(LDFLAGS)" BLAST2_VERSION=1:$(shell dpkg-parsechangelog | awk '/^Version:/ { print $$2 }') -llp=LD_LIBRARY_PATH +ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH)) +NATIVE=.native +DEB_CONFIGURE_EXTRA_FLAGS += --build=$(DEB_BUILD_GNU_TYPE) \ + --host=$(DEB_HOST_GNU_TYPE) +NATIVE_BINDIR=$(CURDIR)/c++/BUILD$(NATIVE)/bin +PREBUILT_DATATOOL_EXE=$(NATIVE_BINDIR)/datatool +PREBUILT_PTB_EXE=$(NATIVE_BINDIR)/project_tree_builder +export PREBUILT_DATATOOL_EXE PREBUILT_PTB_EXE + +$(PREBUILT_DATATOOL_EXE): + cd c++ && PREBUILT_PTB_EXE=bootstrap \ + ./configure $(DEB_CONFIGURE_COMMON_FLAGS) --without-objects \ + --without-algo --without-app --with-build-root=BUILD.native || \ + (tail -v -n +0 config.log BUILD.native/status/config.log; exit 1) + make -j$(NUMJOBS) -C c++/BUILD$(NATIVE)/build -f Makefile.flat \ + datatool.exe +endif + override_dh_auto_configure-indep:; -override_dh_auto_configure-arch: - cd c++ && $(llp)=$(CURDIR)/c++/BUILD/lib$${$(llp)+:$$$(llp)} \ - CONFIG_SHELL=/bin/bash ./configure $(DEB_CONFIGURE_EXTRA_FLAGS) \ +override_dh_auto_configure-arch: $(PREBUILT_DATATOOL_EXE) + cd c++ && CONFIG_SHELL=/bin/bash \ + ./configure $(DEB_CONFIGURE_EXTRA_FLAGS) \ || (tail -v -n +0 config.log BUILD/status/config.log; exit 1) override_dh_auto_build-arch: @@ -60,9 +77,11 @@ override_dh_auto_build-indep: echo "Save time and do nothing for architecture independent builds" override_dh_auto_test: +ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) -dh_auto_test -c++/BUILD/build/check.sh concat_err -cat c++/BUILD/build/check.sh.out_err +endif instroot = debian/ncbi-blast+/usr leg_bin = debian/ncbi-blast+-legacy/usr/bin @@ -88,10 +107,22 @@ override_dh_install-arch: rm -f $(instroot)/bin/*test* $(instroot)/bin/seqdb_demo \ $(instroot)/bin/datatool $(instroot)/bin/run_with_lock \ $(instroot)/bin/project_tree_builder - for x in $(instroot)/bin/*; do \ - LD_LIBRARY_PATH=c++/BUILD/lib ldd $$x; \ - done 2>/dev/null | awk '/BUILD/ { print $$3 }' | sort -u | \ - xargs cp -v -t $(instroot)/lib/ncbi-blast+ + mkdir c++/BUILD/lib.observed + d=$(instroot)/bin; \ + while :; do \ + (for x in $$d/*; do \ + readelf -d $$x 2>/dev/null \ + | sed -ne 's/.*NEEDED.* \[\(.*\)]$$/\1/p'; \ + done; rm -f c++/BUILD/lib.observed/*) | sort -u | while read l; do \ + [ -f $(instroot)/lib/ncbi-blast+/$$l \ + -o \! -f c++/BUILD/lib/$$l ] || \ + cp -av c++/BUILD/lib/$$l c++/BUILD/lib.observed/; \ + done; \ + [ -n "$$(ls c++/BUILD/lib.observed)" ] || break; \ + echo ------------------------------------------------------------; \ + cp -a c++/BUILD/lib.observed/* $(instroot)/lib/ncbi-blast+; \ + d=c++/BUILD/lib.observed; \ + done override_dh_install-indep: #if test -d $(leg_bin); then cp debian/legacy/legacy.sh $(leg_bin)/; fi @@ -116,14 +147,15 @@ override_dh_clean: mods="`echo *.module`" ; \ [ "$${mods#*\*}" = "$$mods" ] || mods="`basename $$x`" ; \ for mod in $$mods ; do \ - ../../../BUILD/build/new_module.sh $$mod purge_sources ; \ + ../../../BUILD$(NATIVE)/build/new_module.sh $$mod \ + purge_sources ; \ done ) ; \ ) ; \ done rm -rf c++/compilers/dll c++/config.log c++/Makefile rm -f c++/configure.lineno c++/src/objects/blastxml/blastxml.module find -name check_exec.pid -delete - rm -rf c++/BUILD + rm -rf c++/BUILD c++/BUILD.native mv configure.orig.save c++/configure.orig mv c++/src/util/lmdb/Makefile.orig.save c++/src/util/lmdb/Makefile.orig mv c++/src/util/lmdbxx/Makefile.orig.save c++/src/util/lmdbxx/Makefile.orig -- 2.30.2