From: Julian Blanche <jblache@debian.org>
Subject: avoid building libraries if configure-stamp exists 

The build script should not build the libraries if configure-stamp exists
debian/rules takes care of that.

Do not link unneeded libraries:
 - -lutil is only needed if legacy PTYs are used
 - -ltiff is not needed at all (pulled in for spandsp, but
   tiff-dependent code in spandsp is not used by iaxmodem and not
   linked in the final binary)
 - Move libraries to end of link command: fixes ld --as-needed (Matthias Klose)

@DPATCH@
diff -urNad iaxmodem-1.2.0~dfsg~/build iaxmodem-1.2.0~dfsg/build
--- iaxmodem-1.2.0~dfsg~/build	2009-02-21 19:57:52.000000000 +0100
+++ iaxmodem-1.2.0~dfsg/build	2009-02-22 11:41:49.107062425 +0100
@@ -16,12 +16,13 @@
 }
 
 PTYUSE="-DUSE_UNIX98_PTY"
+LLIBS=
 if [ "$1" = "-bsdptys" ]; then
     PTYUSE=""
+    LLIBS="-lutil"
     shift
 fi
 
-LLIBS="-lutil"
 if [ "`uname`" = "SunOS" ]; then
     PATH=$PATH:/usr/sfw/bin; export PATH
     MAKE="gmake"; export MAKE
@@ -31,23 +32,20 @@
 fi
 
 if [ "$1" = "static" ]; then
-    cd lib/libiax2 && \
-    ./configure --disable-shared && \
-    ${MAKE-make} && \
-    cd ../spandsp && \
-    ./configure --disable-shared && \
-    if [ "`uname`" = "SunOS" ]; then
-	grep -v HAVE_TGMATH_H src/config.h > src/config.h.new && \
-	mv -f src/config.h.new src/config.h && \
-        grep -v HAVE_TGMATH_H config-h.in > config-h.in.new && \
-        mv -f config-h.in.new config-h.in
-    fi && \
-    ${MAKE-make} && \
-    cd ../.. && \
+    if [ ! -e configure-stamp ]; then
+	cd lib/libiax2 && \
+	    ./configure --disable-shared && \
+	    ${MAKE-make} && \
+	    cd ../spandsp && \
+	    ./configure --disable-shared && \
+	    ${MAKE-make} && \
+	    cd ../.. || exit 1
+    fi
+
     getVersions && \
     gcc -Wall -g $PTYUSE $CFLAGS -DMODEMVER=\"$MODEMVER\" -DDSPVER=\"$DSPVER\" -DIAXVER=\"$IAXVER\" -DSTATICLIBS \
 	-std=c99 -Ilib/libiax2/src -Ilib/spandsp/src -c -o iaxmodem.o iaxmodem.c && \
-    gcc -lm $LLIBS -ltiff -o iaxmodem iaxmodem.o lib/spandsp/src/.libs/libspandsp.a lib/libiax2/src/.libs/libiax.a
+    gcc -o iaxmodem iaxmodem.o lib/spandsp/src/.libs/libspandsp.a lib/libiax2/src/.libs/libiax.a -lm $LLIBS
 else
     getVersions && \
     gcc -Wall -g $PTYUSE -DMODEMVER=\"$MODEMVER\" -DDSPVER=\"$DSPVER\" -DIAXVER=\"$IAXVER\" \
