From: Michael Hanke <mih@debian.org>
Subject: Configure Debian build and runtime environment

Modifications include:

* Always build for LINUX, even on non-Linux Debian platforms (e.g. kFreeBSD).
  The test for Linux seems to be more of a test for the GNU libc and all target
  platform in Debian have that.
* Prefer to link against shared libraries.
* Accept externally provided CFLAGS
* Path tweaks for Debian-specific install locations.
* Deal with the difference between netstat APIs on Linux and kFreeBSD

Index: cctools-6.2.9/configure
===================================================================
--- cctools-6.2.9.orig/configure
+++ cctools-6.2.9/configure
@@ -44,11 +44,16 @@ configure_arguments=`echo "$*" | sed 's/
 # The above sed commands are to escape the output for the Makefile.
 system_information=`uname -a | sed 's/#/\\\\#/' | sed 's/\\$/$$/'`
 
-BUILD_CPU="$(uname -m | tr \[a-z\] \[A-Z\])"
+#BUILD_CPU="$(uname -m | tr \[a-z\] \[A-Z\])"
 BUILD_DATE="$NOW"
 BUILD_HOST="$(uname -n)"
-BUILD_SYS="$(uname -s | tr \[a-z\] \[A-Z\] | awk -F_ '{print $1}')"
+#BUILD_SYS="$(uname -s | tr \[a-z\] \[A-Z\] | awk -F_ '{print $1}')"
 BUILD_USER="$USER"
+# this setting is actually used to identify GNU libc platforms
+# and Debian is all GNU libc, so force "Linux" even on non-Linux systems
+BUILD_SYS=LINUX
+BUILD_CPU="$(dpkg-architecture -qDEB_BUILD_ARCH | tr \[a-z-\] \[A-Z_\])"
+
 
 if [ "$BUILD_CPU" = UNKNOWN ]
 then
@@ -444,7 +449,8 @@ fi
 
 if [ $BUILD_SYS = LINUX ]
 then
-		ldflags="-Xlinker -Bstatic -static-libgcc -Xlinker -Bdynamic ${link_as_needed}"
+    ldflags="${link_as_needed}"
+
 elif [ $BUILD_SYS = DARWIN ]
 then
 		ldflags=""
@@ -452,6 +458,9 @@ else
 		ldflags="-static-libgcc"
 fi
 
+# accept ldflags from outside
+ldflags="$ldflags $LDFLAGS"
+
 if [ "$optsanitize" = 1 ]; then
 	ccflags="${ccflags} -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined"
 	ldflags="-fsanitize=address -lasan -lubsan ${ldflags}"
@@ -461,12 +470,12 @@ fi
 ##########################################################################
 # SWITCH TO STATIC LINKING FOR UNCOMMON THIRD-PARTY PACKAGES
 ##########################################################################
-library_search_mode=prefer_static
+library_search_mode=prefer_dynamic
 ##########################################################################
 
 if [ "$globus_flavor" = auto ]
 then
-	if [ $BUILD_CPU = X86_64 ]
+	if [ $BUILD_CPU = X86_64 -o $BUILD_CPU = AMD64 ]
 	then
 		globus_flavor=gcc64
 	else
@@ -621,7 +630,7 @@ else
 fi
 
 
-if [ $config_mysql_path != no ] && library_search mysqlclient ${mysql_path} mysql
+if [ $config_mysql_path != no ] && library_search mysqlclient ${mysql_path}
 then
 	mysql_ldflags="${library_search_result}"
 
