Merge commit 'origin/gallium-0.1' into gallium-0.2
[profile/ivi/mesa.git] / acinclude.m4
1 # A few convenience macros for Mesa, mostly to keep all the platform
2 # specifics out of configure.ac.
3
4 # MESA_PIC_FLAGS()
5 #
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.
9 #
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
14 #
15 AC_DEFUN([MESA_PIC_FLAGS],
16 [AC_REQUIRE([AC_PROG_CC])dnl
17 AC_ARG_VAR([PIC_FLAGS], [compiler flags for PIC code])
18 AC_ARG_ENABLE([pic],
19     [AS_HELP_STRING([--disable-pic],
20         [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],
24     [enable_pic=auto])
25 # disable PIC by default for static builds
26 if test "$enable_pic" = auto && test "$enable_static" = yes; then
27     enable_pic=no
28 fi
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
36             case "$host_os" in
37             aix*|beos*|cygwin*|irix5*|irix6*|osf3*|osf4*|osf5*)
38                 # PIC is the default for these OSes.
39                 ;;
40             mingw*|os2*|pw32*)
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"
45                 ;;
46             darwin*|rhapsody*)
47                 # PIC is the default on this platform
48                 # Common symbols not allowed in MH_DYLIB files
49                 PIC_FLAGS="-fno-common"
50                 ;;
51             hpux*)
52                 # PIC is the default for IA64 HP-UX and 64-bit HP-UX,
53                 # but not for PA HP-UX.
54                 case $host_cpu in
55                 hppa*64*|ia64*)
56                     ;;
57                 *)
58                     PIC_FLAGS="-fPIC"
59                     ;;
60                 esac
61                 ;;
62             *)
63                 # Everyone else on GCC uses -fPIC
64                 PIC_FLAGS="-fPIC"
65                 ;;
66             esac
67         else # !GCC
68             case "$host_os" in
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.
72                 case "$host_cpu" in
73                 hppa*64*|ia64*)
74                     # +Z the default
75                     ;;
76                 *)
77                     PIC_FLAGS="+Z"
78                     ;;
79                 esac
80                 ;;
81             linux*|k*bsd*-gnu)
82                 case `basename "$CC"` in
83                 icc*|ecc*|ifort*)
84                     PIC_FLAGS="-KPIC"
85                     ;;
86                 pgcc*|pgf77*|pgf90*|pgf95*)
87                     # Portland Group compilers (*not* the Pentium gcc
88                     # compiler, which looks to be a dead project)
89                     PIC_FLAGS="-fpic"
90                     ;;
91                 ccc*)
92                     # All Alpha code is PIC.
93                     ;;
94                 xl*)
95                     # IBM XL C 8.0/Fortran 10.1 on PPC
96                     PIC_FLAGS="-qpic"
97                     ;;
98                 *)
99                     case `$CC -V 2>&1 | sed 5q` in
100                     *Sun\ C*|*Sun\ F*)
101                         # Sun C 5.9 or Sun Fortran
102                         PIC_FLAGS="-KPIC"
103                         ;;
104                     esac
105                 esac
106                 ;;
107             solaris*)
108                 PIC_FLAGS="-KPIC"
109                 ;;
110             sunos4*)
111                 PIC_FLAGS="-PIC"
112                 ;;
113             esac
114         fi # GCC
115     fi # PIC_FLAGS
116     AC_MSG_RESULT([$PIC_FLAGS])
117 fi
118 AC_SUBST([PIC_FLAGS])
119 ])# MESA_PIC_FLAGS