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
* Set BUILD_* for reproducible builds

Index: cctools-7.0.9/configure
===================================================================
--- cctools-7.0.9.orig/configure
+++ cctools-7.0.9/configure
@@ -42,13 +42,21 @@ configure_arguments=`echo "$*" | sed 's/
 # Here's what we want to exec literally:
 #   uname -a | sed s/#/\\#/ | sed s/\$/$$/
 # The above sed commands are to escape the output for the Makefile.
-system_information=`uname -a | sed 's/#/\\\\#/' | sed 's/\\$/$$/'`
+# Avoid capture of system info
+# system_information=`uname -a | sed 's/#/\\\\#/' | sed 's/\\$/$$/'`
+system_information="Debian build of cctools"
+
+#BUILD_CPU="$(uname -m | tr \[a-z\] \[A-Z\])"
+BUILD_DATE="2018-12-25"
+# BUILD_HOST="$(uname -n)"
+BUILD_HOST="debian"
+#BUILD_SYS="$(uname -s | tr \[a-z\] \[A-Z\] | awk -F_ '{print $1}')"
+BUILD_USER="debian"
+# 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_\])"
 
-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_USER="$USER"
 
 if [ "$BUILD_CPU" = UNKNOWN ]
 then
@@ -453,7 +461,8 @@ if [ $BUILD_SYS = LINUX ]
 then
 		if [ "${config_static_libgcc}" = yes ]
 		then
-				ldflags="${ldflags} -Xlinker -Bstatic -static-libgcc"
+				ldflags="${ldflags} ${link_as_needed}"
+
 		fi
 		
 		ldflags="${ldflags} -Xlinker -Bdynamic ${link_as_needed}"
@@ -465,6 +474,9 @@ then
 		fi
 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}"
@@ -474,12 +486,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
@@ -634,7 +646,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}"
 
