2013-05-30 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / config / picflag.m4
blob2ee5cd0785f4f3c774cbd141d8d0aa69f2e11339
1 # _GCC_PICFLAG(FLAG, DISPATCH)
2 # ----------------------------
3 # Store PIC flag corresponding to DISPATCH triplet in FLAG.
4 # Explit use of -fpic in CFLAGS corresponding to FLAG overrides default.
5 AC_DEFUN([_GCC_PICFLAG], [
7 case "${$2}" in
8     # PIC is the default on some targets or must not be used.
9     *-*-darwin*)
10         # PIC is the default on this platform
11         # Common symbols not allowed in MH_DYLIB files
12         $1=-fno-common
13         ;;
14     alpha*-dec-osf5*)
15         # PIC is the default.
16         ;;
17     hppa*64*-*-hpux*)
18         # PIC is the default for 64-bit PA HP-UX.
19         ;;
20     i[[34567]]86-*-cygwin* | x86_64-*-cygwin*)
21         ;;
22     i[[34567]]86-*-mingw* | x86_64-*-mingw*)
23         ;;
24     i[[34567]]86-*-interix[[3-9]]*)
25         # Interix 3.x gcc -fpic/-fPIC options generate broken code.
26         # Instead, we relocate shared libraries at runtime.
27         ;;
28     i[[34567]]86-*-nto-qnx*)
29         # QNX uses GNU C++, but need to define -shared option too, otherwise
30         # it will coredump.
31         $1='-fPIC -shared'
32         ;;
33     i[[34567]]86-pc-msdosdjgpp*)
34         # DJGPP does not support shared libraries at all.
35         ;;
36     ia64*-*-hpux*)
37         # On IA64 HP-UX, PIC is the default but the pic flag
38         # sets the default TLS model and affects inlining.
39         $1=-fPIC
40         ;;
41     mips-sgi-irix6*)
42         # PIC is the default.
43         ;;
44     rs6000-ibm-aix* | powerpc-ibm-aix*)
45         # All AIX code is PIC.
46         ;;
48     # Some targets support both -fPIC and -fpic, but prefer the latter.
49     # FIXME: Why?
50     i[[34567]]86-*-* | x86_64-*-*)
51         $1=-fpic
52         ;;
53     m68k-*-*)
54         $1=-fpic
55         ;;
56     # FIXME: Override -fPIC default in libgcc only? 
57     sh-*-linux* | sh[[2346lbe]]*-*-linux*)
58         $1=-fpic
59         ;;
60     # FIXME: Simplify to sh*-*-netbsd*?
61     sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
62       sh64-*-netbsd* | sh64l*-*-netbsd*)
63         $1=-fpic
64         ;;
65     # Default to -fPIC unless specified otherwise.
66     *)
67         $1=-fPIC
68         ;;
69 esac
71 # If the user explicitly uses -fpic/-fPIC, keep that.
72 case "${m4_bpatsubsts($1, PICFLAG, CFLAGS)}" in
73     *-fpic*)
74         $1=-fpic
75         ;;
76     *-fPIC*)
77         $1=-fPIC
78         ;;
79 esac
82 # GCC_PICFLAG
83 # -----------
84 # Store host PIC flag in PICFLAG.
85 AC_DEFUN([GCC_PICFLAG], [
86   AC_REQUIRE([AC_CANONICAL_HOST])
87   _GCC_PICFLAG([PICFLAG], [host])])
89 # GCC_PICFLAG_FOR_TARGET
90 # ----------------------
91 # Store target PIC flag in PICFLAG_FOR_TARGET.
92 AC_DEFUN([GCC_PICFLAG_FOR_TARGET], [
93   AC_REQUIRE([AC_CANONICAL_TARGET])
94   _GCC_PICFLAG([PICFLAG_FOR_TARGET], [target])])