Detect 32bit support on 64bit OS and compile with -m32 if found

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@videotron.ca>
This commit is contained in:
Gaetan Nadon
2011-11-18 16:36:12 -05:00
committed by Martin-Éric Racine
parent 3021c6df08
commit ac99bf2c5c
3 changed files with 26 additions and 1 deletions

View File

@@ -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)

View File

@@ -35,6 +35,7 @@ AM_CFLAGS = \
$(XORG_CFLAGS) \
$(CWARNFLAGS) \
$(AMD_CFLAGS) \
$(M32_CFLAGS) \
-DHAVE_GX \
-DHAVE_LX \
-DOPT_ACCEL

View File

@@ -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