autoconf: Helper options for adding GCC 32/64 bit flags
authorDan Nicholson <dbn.lists@gmail.com>
Wed, 26 Dec 2007 17:12:29 +0000 (11:12 -0600)
committerDan Nicholson <dbn.lists@gmail.com>
Wed, 26 Dec 2007 21:38:30 +0000 (15:38 -0600)
Two new configure options to add -m32 or -m64 to the CFLAGS and CXXFLAGS
when GCC is in use. By default, the user supplied options are
environment variables are respected, but these options are quick helps
for the common case of x86/x86_64 using GCC.

configure.ac
docs/autoconf.html

index f2f2d75a1a03e09ebbed6bf78a39903ad26bfe82..2acbd67e510493af688b05bed33bb2d348abc0ea 100644 (file)
@@ -79,6 +79,38 @@ AC_ARG_VAR(ARCH_FLAGS, [Additional architecture specific flags for the
 AC_SUBST(OPT_FLAGS)
 AC_SUBST(ARCH_FLAGS)
 
+dnl
+dnl Hacks to enable 32 or 64 bit build
+dnl
+AC_ARG_ENABLE(32-bit,
+    [AS_HELP_STRING([--enable-32-bit],
+        [build 32-bit libraries @<:@default=auto@:>@])],
+    enable_32bit="$enableval",
+    enable_32bit=auto
+)
+if test "x$enable_32bit" = xyes; then
+    if test "x$GCC" = xyes; then
+        CFLAGS="$CFLAGS -m32"
+    fi
+    if test "x$GXX" = xyes; then
+        CXXFLAGS="$CXXFLAGS -m32"
+    fi
+fi
+AC_ARG_ENABLE(64-bit,
+    [AS_HELP_STRING([--enable-64-bit],
+        [build 64-bit libraries @<:@default=auto@:>@])],
+    enable_64bit="$enableval",
+    enable_64bit=auto
+)
+if test "x$enable_64bit" = xyes; then
+    if test "x$GCC" = xyes; then
+        CFLAGS="$CFLAGS -m64"
+    fi
+    if test "x$GXX" = xyes; then
+        CXXFLAGS="$CXXFLAGS -m64"
+    fi
+fi
+
 dnl
 dnl shared/static libraries, mimic libtool options
 dnl
index ab1e21db08f9d36deecb52d41f98e4e3d84ab502..964ff140abc7e5a642b40403521e3c6e8bcd096d 100644 (file)
@@ -124,6 +124,13 @@ available for a few architectures. These will be used by default if
 one of these architectures is detected. This option ensures that
 assembly will not be used.
 </li>
+<li><code>--enable-32-bit, --enable-64-bit</code> - By default, the
+build will compile code as directed by the environment variables
+<code>CC</code>, <code>CFLAGS</code>, etc. If the compiler is
+<code>gcc</code>, these options offer a helper to add the compiler flags
+to force 32- or 64-bit code generation as used on the x86 and x86_64
+architectures.
+</li>
 </ul>
 </p>