I looked into it a little further last night, and the error was on the AC_CHECK_LIB check for libemosR64, failing with errors such as:
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libemosR64.so: undefined reference to `sqrtq' This appears to be related to the --no-add-needed option. The fix is to add the relevant libraries directly to LIBS (they previously would have been pulled in indirectly by -lemosR64). The attached patch fully fixes the FTBFS, tested on sid and Ubuntu precise. It doesn't address the questions about the debian-changes-* patches and failure to fully clean before a second run of debuild, I was just focused on clearing the FTBFS. Hope this helps, and gives you a little more free time on the weekend.
=== modified file 'debian/as-needed.patch' --- debian/as-needed.patch 2011-09-13 13:45:47 +0000 +++ debian/as-needed.patch 2011-12-06 09:30:04 +0000 @@ -3,12 +3,12 @@ Note that this patch is applied by ./debian/rules AFTER autoreconf is run; it cannot be applied in ./debian/patches Bug-Debian: http://bugs.debian.org/347650 -Last-Updated: 2011-09-13 +Last-Updated: 2011-12-05 Forwarded: no ---- ltmain.sh.orig 2011-09-13 10:05:45.000000000 +0100 -+++ ltmain.sh 2011-09-13 10:22:40.000000000 +0100 -@@ -5500,6 +5500,11 @@ +--- ltmain.sh.orig 2011-12-05 23:13:53.614777184 +0000 ++++ ltmain.sh 2011-12-05 23:21:58.310794860 +0000 +@@ -5512,6 +5512,11 @@ continue ;; @@ -20,19 +20,19 @@ -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" -@@ -6150,6 +6155,15 @@ +@@ -6163,6 +6168,15 @@ lib= found=no case $deplib in -+ -Wl,--as-needed) -+ if test "$linkmode,$pass" = "prog,link"; then -+ compile_deplibs="$deplib $compile_deplibs" -+ finalize_deplibs="$deplib $finalize_deplibs" -+ else -+ deplibs="$deplib $deplibs" -+ fi -+ continue -+ ;; - -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) ++ -Wl,--as-needed) ++ if test "$linkmode,$pass" = "prog,link"; then ++ compile_deplibs="$deplib $compile_deplibs" ++ finalize_deplibs="$deplib $finalize_deplibs" ++ else ++ deplibs="$deplib $deplibs" ++ fi ++ continue ++ ;; + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ + |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then - compile_deplibs="$deplib $compile_deplibs" === modified file 'debian/changelog' --- debian/changelog 2011-10-20 10:40:35 +0000 +++ debian/changelog 2011-12-06 18:46:00 +0000 @@ -1,3 +1,14 @@ +magics++ (2.12.9-6) UNRELEASED; urgency=low + + * Update debian/as-needed.patch so it applies to changed + config/ltmain.sh. + * debian/rules: Add "-lm -lquadmath -lgfortran" to LIBS in configure + line to directly link libraries that are needed. + * Update debian/patches/dynamic_link.patch to add + "-lm -lquadmath -lgfortran". + + -- Allison Randal <alli...@lohutok.net> Tue, 06 Dec 2011 10:43:17 -0800 + magics++ (2.12.9-5) unstable; urgency=low * Recommends: pkg-config in -dev package. === modified file 'debian/patches/dynamic_link.patch' --- debian/patches/dynamic_link.patch 2011-07-08 17:16:45 +0000 +++ debian/patches/dynamic_link.patch 2011-12-06 18:12:07 +0000 @@ -1,20 +1,20 @@ Description: Link libMagPlus.so.3.0.0 against extra libraries that are provided in dynamic form by Debian. Author: Alastair McKinstry <mckins...@debian.org> -Last-Updated: 2010-07-23 +Last-Updated: 2011-12-06 Forwarded: no -Index: Magics++-2.12.1/configure.ac +Index: debbug-650453/configure.ac =================================================================== ---- Magics++-2.12.1.orig/configure.ac 2011-02-14 14:26:20.000000000 +0000 -+++ Magics++-2.12.1/configure.ac 2011-02-14 14:27:00.000000000 +0000 -@@ -747,7 +747,9 @@ +--- debbug-650453.orig/configure.ac 2011-12-06 16:22:38.194231000 +0000 ++++ debbug-650453/configure.ac 2011-12-06 18:09:26.757261761 +0000 +@@ -767,7 +767,9 @@ fi AC_SUBST(cairo) - +# Add dynamic libs needed by Debian -+LIBS="$CAIRO_LIBS $LIBS -lemosR64 -lgrib_api -lterralib -lstdc++ -lm $NETCDF_LIBS" ++LIBS="$CAIRO_LIBS $LIBS -lemosR64 -lgrib_api -lterralib -lstdc++ -lm -lquadmath -lgfortran $NETCDF_LIBS" +LDFLAGS="$CAIRO_LDFLAGS $LDFLAGS -Wl,--as-needed" # Autoheader === modified file 'debian/rules' --- debian/rules 2011-09-24 15:05:00 +0000 +++ debian/rules 2011-12-06 18:46:30 +0000 @@ -37,7 +37,7 @@ dh_auto_configure -- \ --enable-bufr --enable-static --enable-cairo --with-emos-libraries=/usr/lib \ --with-terralib=/usr --enable-python \ - LDFLAGS="-L$(shell pwd)/src/.libs -Wl,--as-needed" LIBS=" -lX11 -lpng12 -lz" + LDFLAGS="-L$(shell pwd)/src/.libs -Wl,--as-needed" LIBS=" -lX11 -lm -lquadmath -lgfortran -lpng12 -lz" override_dh_auto_test check: echo "Tests disabled; see README-testfailures.txt for details"