picflag.m4 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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], [
  6. case "${$2}" in
  7. # PIC is the default on some targets or must not be used.
  8. *-*-darwin*)
  9. # For darwin, common symbols are not allowed in MH_DYLIB files
  10. case "${CFLAGS}" in
  11. # If we are using a compiler supporting mdynamic-no-pic
  12. # and the option has been tested as safe to add, then cancel
  13. # it here, since the code generated is incompatible with shared
  14. # libs.
  15. *-mdynamic-no-pic*) $1='-fno-common -mno-dynamic-no-pic' ;;
  16. *) $1=-fno-common ;;
  17. esac
  18. ;;
  19. alpha*-dec-osf5*)
  20. # PIC is the default.
  21. ;;
  22. hppa*64*-*-hpux*)
  23. # PIC is the default for 64-bit PA HP-UX.
  24. ;;
  25. i[[34567]]86-*-cygwin* | x86_64-*-cygwin*)
  26. ;;
  27. i[[34567]]86-*-mingw* | x86_64-*-mingw*)
  28. ;;
  29. i[[34567]]86-*-interix[[3-9]]*)
  30. # Interix 3.x gcc -fpic/-fPIC options generate broken code.
  31. # Instead, we relocate shared libraries at runtime.
  32. ;;
  33. i[[34567]]86-*-nto-qnx*)
  34. # QNX uses GNU C++, but need to define -shared option too, otherwise
  35. # it will coredump.
  36. $1='-fPIC -shared'
  37. ;;
  38. i[[34567]]86-pc-msdosdjgpp*)
  39. # DJGPP does not support shared libraries at all.
  40. ;;
  41. ia64*-*-hpux*)
  42. # On IA64 HP-UX, PIC is the default but the pic flag
  43. # sets the default TLS model and affects inlining.
  44. $1=-fPIC
  45. ;;
  46. mips-sgi-irix6*)
  47. # PIC is the default.
  48. ;;
  49. rs6000-ibm-aix* | powerpc-ibm-aix*)
  50. # All AIX code is PIC.
  51. ;;
  52. # Some targets support both -fPIC and -fpic, but prefer the latter.
  53. # FIXME: Why?
  54. i[[34567]]86-*-* | x86_64-*-*)
  55. $1=-fpic
  56. ;;
  57. # FIXME: Override -fPIC default in libgcc only?
  58. sh-*-linux* | sh[[2346lbe]]*-*-linux*)
  59. $1=-fpic
  60. ;;
  61. # FIXME: Simplify to sh*-*-netbsd*?
  62. sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
  63. sh64-*-netbsd* | sh64l*-*-netbsd*)
  64. $1=-fpic
  65. ;;
  66. # Default to -fPIC unless specified otherwise.
  67. *)
  68. $1=-fPIC
  69. ;;
  70. 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
  80. ])
  81. # GCC_PICFLAG
  82. # -----------
  83. # Store host PIC flag in PICFLAG.
  84. AC_DEFUN([GCC_PICFLAG], [
  85. AC_REQUIRE([AC_CANONICAL_HOST])
  86. _GCC_PICFLAG([PICFLAG], [host])])
  87. # GCC_PICFLAG_FOR_TARGET
  88. # ----------------------
  89. # Store target PIC flag in PICFLAG_FOR_TARGET.
  90. AC_DEFUN([GCC_PICFLAG_FOR_TARGET], [
  91. AC_REQUIRE([AC_CANONICAL_TARGET])
  92. _GCC_PICFLAG([PICFLAG_FOR_TARGET], [target])])