[Xorg-driver-geode] [PATCH 15/15] Detect 32bit support on 64bit OS and compile with -m32 if found

Gaetan Nadon memsize at videotron.ca
Fri Nov 18 14:28:24 PST 2011


For gcc compiler only at the moment.
The configuration reports if support is found or not, e.g.:

   checking if gcc supports the -m32 Intel/AMD option... yes

The configuration C test relies on #include unistd.h which includes
features.h which includes gnu/stubs.h which includes gnu/stubs-32.h
which is missing on 64 bit system without the 32 bit library support.

Tested on x86_64 AMD64 CPU with/without libc6-dev-i386 which provides
32 bit support. Remains to be tested on Geode and FreeBSD 32/64 bit.

The configuration does not attempt to decide if building should proceed
or be aborted. If no 32 bit support then the build will die in the
assembly code as it always did before.

The variable M32_CFLAGS provides the flag for the makefiles.
The variable names and organization is subject to change.

Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
 configure.ac    |   24 ++++++++++++++++++++++++
 src/Makefile.am |    1 +
 ztv/Makefile.am |    2 +-
 3 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 179fd28..307ffe2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -81,6 +81,30 @@ if test "x$ztv" != "xno" ; then
 fi
 AM_CONDITIONAL(BUILD_ZTV, [test "x$BUILD_ZTV" = xyes])
 
+# Check if GCC supports compiling in 32 bit mode for 64 bit computers
+case $host_cpu in
+    x86_64*|amd64*)
+	if  test "x$GCC" = xyes ; then
+	    SAVE_CFLAGS="$CFLAGS"
+	    CFLAGS="$CFLAGS -m32"
+	    AC_MSG_CHECKING([if $CC supports the -m32 Intel/AMD option])
+	    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include <unistd.h>
+int
+main ()
+{
+  ;
+  return 0;
+}]])],
+		[m32_support=yes; M32_CFLAGS=-m32],
+		[m32_support=no])
+	    AC_MSG_RESULT([$m32_support])
+	    CFLAGS="$SAVE_CFLAGS"
+	fi
+	;;
+esac
+AC_SUBST([M32_CFLAGS])
+
 # Checks for extensions
 XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
 XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
diff --git a/src/Makefile.am b/src/Makefile.am
index d5f57b9..86139de 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,7 @@ AM_CFLAGS = 		\
 	$(XORG_CFLAGS)	\
 	$(CWARNFLAGS)	\
 	$(AMD_CFLAGS)	\
+	$(M32_CFLAGS)	\
 	-DHAVE_GX	\
 	-DHAVE_LX	\
 	-DOPT_ACCEL
diff --git a/ztv/Makefile.am b/ztv/Makefile.am
index 670842b..0bc133e 100644
--- a/ztv/Makefile.am
+++ b/ztv/Makefile.am
@@ -1,7 +1,7 @@
 
 if BUILD_ZTV
 
-AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS)
+AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) $(M32_CFLAGS)
 
 ztv_drv_la_LTLIBRARIES = ztv_drv.la
 ztv_drv_la_LDFLAGS = -module -avoid-version
-- 
1.7.4.1



More information about the Xorg-driver-geode mailing list