Commit d818ba597945cd9a59583eb6efe75f58b468cfe5

suzuki toshiya 2009-12-16T13:23:14

Improve configure.raw to copy some options from CFLAGS to LDFLAGS.

diff --git a/ChangeLog b/ChangeLog
index 403d2c9..e1ec9cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-12-16  suzuki toshiya  <mpsuzuki@hiroshima-u.ac.jp>
+
+	Improve configure.raw to copy some options from CFLAGS to LDFLAGS.
+	The linker of Mac OS X 10.6 is sensitive the architechture.
+	When the architechtures are specified explicitly for C compiler,
+	the linker requires the architechture specifications too.
+
+	* builds/unix/configure.raw: Replace `-isysroot' option parser
+	by more generic argument parser.
+
 2009-12-15  Werner Lemberg  <wl@gnu.org>
 
 	Fix compiler warnings.
diff --git a/builds/unix/configure.raw b/builds/unix/configure.raw
index 8a99988..4ecd619 100644
--- a/builds/unix/configure.raw
+++ b/builds/unix/configure.raw
@@ -230,30 +230,48 @@ if test x$with_zlib != xno && test -n "$LIBZ"; then
 fi
 
 
-# check Apple's `-isysroot' option and duplicate it to LDFLAGS if required --
-# Apple TechNote 2137 recommends to include it in CFLAGS but not in LDFLAGS
-
-AC_MSG_CHECKING([whether CFLAGS includes -isysroot option])
-case "$CFLAGS" in
-*sysroot* )
-  AC_MSG_RESULT([yes])
-  AC_MSG_CHECKING([whether LDFLAGS includes -isysroot option])
-  case "$LDFLAGS" in
-  *sysroot* )
-    AC_MSG_RESULT([yes])
+# Some options handling SDKs/archs in CFLAGS should be copied
+# to LDFLAGS. Apple TechNote 2137 recommends to include these
+# options in CFLAGS but not in LDFLAGS.
+
+save_config_args=$*
+set dummy ${CFLAGS}
+i=1
+while test $i -lt $#
+do
+  c=$1
+
+  case "${c}" in
+  -isysroot|-arch) # options taking 1 argument
+    a=$2
+    AC_MSG_CHECKING([whether CFLAGS and LDFLAGS share ${c} ${a}])
+    if expr " ${LDFLAGS} " : ".* ${c} *${a}.*" > /dev/null
+    then
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no, copy to LDFLAGS])
+      LDFLAGS="${LDFLAGS} ${c} ${a}"
+    fi
+    shift 1
     ;;
-  *)
-    AC_MSG_RESULT([no])
-    isysroot_dir=`echo ${CFLAGS} | tr '\t' ' ' | sed 's/^.*-isysroot *//;s/ .*//'`
-    AC_MSG_WARN(-isysroot ${isysroot_dir} is added to LDFLAGS)
-    LDFLAGS="-isysroot ${isysroot_dir} ${LDFLAGS}"
+  -m32|-m64) # options taking no argument
+    AC_MSG_RESULT([whether CFLAGS and LDFLAGS share ${c}])
+    if expr " ${LDFLAGS} " : ".* ${c} *${a}.*" > /dev/null
+    then
+      AC_MSG_RESULT([yes])
+    else
+      AC_MSG_RESULT([no, copy to LDFLAGS])
+      LDFLAGS="${LDFLAGS} ${c}"
+    fi
     ;;
+  # *)
+  #   AC_MSG_RESULT([${c} is not copied to LDFLAGS])
+  #   ;;
   esac
-  ;;
-*)
-  AC_MSG_RESULT([no])
-  ;;
-esac
+
+  shift 1
+done
+set ${save_config_args}
 
 
 # Whether to use Mac OS resource-based fonts.