-# probe for libraries
-if [ $STATIC_LIBRARIES = 0 ]; then
- sed -e "s/^STATIC_LIBRARIES := .*/STATIC_LIBRARIES := n/" -i global_config
- cd thirdparty && ./configure shared && cd ..
-else
- sed -e "s/^STATIC_LIBRARIES := .*/STATIC_LIBRARIES := y/" -i global_config
- cd thirdparty && ./configure static && cd ..
-fi
+# test for libdl
+
+rm -f a.out
+cat > conftest.c << EOF
+int main()
+{
+ return 0;
+}
+EOF
+
+gcc conftest.c -ldl > /dev/null 2>&1
+
+if [ -x a.out ]; then HAVE_DL=y; else HAVE_DL=n; fi
+
+rm -f a.out conftest.c
+
+
+# test for libnuma
+
+rm -f a.out
+cat > conftest.c << EOF
+int main()
+{
+ return 0;
+}
+EOF
+
+gcc conftest.c -lnuma > /dev/null 2>&1
+
+if [ -x a.out ]; then HAVE_NUMA=y; else HAVE_NUMA=n; fi
+
+rm -f a.out conftest.c
+
+
+# update global_config with probe data
+
+for v in $PROBED; do
+ sed -e "s/^#$v := .*/$v := ${!v}/" -i global_config
+done
+
+# configure thirdparty build
+
+cd thirdparty
+case "$STATIC_LIBRARIES" in
+ "y") ./configure static ;;
+ "n") ./configure shared ;;
+ *) echo "configuration failed"; exit 1;;
+esac