1 # A few convenience macros for Mesa, mostly to keep all the platform
2 # specifics out of configure.ac.
6 # Find out whether to build PIC code using the option --enable-pic and
7 # the configure enable_static/enable_shared settings. If PIC is needed,
8 # figure out the necessary flags for the platform and compiler.
10 # The platform checks have been shamelessly taken from libtool and
11 # stripped down to just what's needed for Mesa. See _LT_COMPILER_PIC in
12 # /usr/share/aclocal/libtool.m4 or
13 # http://git.savannah.gnu.org/gitweb/?p=libtool.git;a=blob;f=libltdl/m4/libtool.m4;hb=HEAD
15 AC_DEFUN([MESA_PIC_FLAGS],
16 [AC_REQUIRE([AC_PROG_CC])dnl
17 AC_ARG_VAR([PIC_FLAGS], [compiler flags for PIC code])
19 [AS_HELP_STRING([--disable-pic],
20 [don't compile PIC objects @<:@default=enabled for shared builds
21 on supported platforms@:>@])],
22 [enable_pic="$enableval"
23 test "x$enable_pic" = x && enable_pic=auto],
25 # disable PIC by default for static builds
26 if test "$enable_pic" = auto && test "$enable_static" = yes; then
29 # if PIC hasn't been explicitly disabled, try to figure out the flags
30 if test "$enable_pic" != no; then
31 AC_MSG_CHECKING([for $CC option to produce PIC])
32 # allow the user's flags to override
33 if test "x$PIC_FLAGS" = x; then
34 # see if we're using GCC
35 if test "x$GCC" = xyes; then
37 aix*|beos*|cygwin*|irix5*|irix6*|osf3*|osf4*|osf5*)
38 # PIC is the default for these OSes.
41 # This hack is so that the source file can tell whether
42 # it is being built for inclusion in a dll (and should
43 # export symbols for example).
44 PIC_FLAGS="-DDLL_EXPORT"
47 # PIC is the default on this platform
48 # Common symbols not allowed in MH_DYLIB files
49 PIC_FLAGS="-fno-common"
52 # PIC is the default for IA64 HP-UX and 64-bit HP-UX,
53 # but not for PA HP-UX.
63 # Everyone else on GCC uses -fPIC
69 hpux9*|hpux10*|hpux11*)
70 # PIC is the default for IA64 HP-UX and 64-bit HP-UX,
71 # but not for PA HP-UX.
82 case `basename "$CC"` in
86 pgcc*|pgf77*|pgf90*|pgf95*)
87 # Portland Group compilers (*not* the Pentium gcc
88 # compiler, which looks to be a dead project)
92 # All Alpha code is PIC.
95 # IBM XL C 8.0/Fortran 10.1 on PPC
99 case `$CC -V 2>&1 | sed 5q` in
101 # Sun C 5.9 or Sun Fortran
116 AC_MSG_RESULT([$PIC_FLAGS])
118 AC_SUBST([PIC_FLAGS])