picflag.m4 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. loongarch*-*-*)
  47. $1=-fpic
  48. ;;
  49. mips-sgi-irix6*)
  50. # PIC is the default.
  51. ;;
  52. rs6000-ibm-aix* | powerpc-ibm-aix*)
  53. # All AIX code is PIC.
  54. ;;
  55. # Some targets support both -fPIC and -fpic, but prefer the latter.
  56. # FIXME: Why?
  57. i[[34567]]86-*-* | x86_64-*-*)
  58. $1=-fpic
  59. ;;
  60. # FIXME: Override -fPIC default in libgcc only?
  61. sh-*-linux* | sh[[2346lbe]]*-*-linux*)
  62. $1=-fpic
  63. ;;
  64. # FIXME: Simplify to sh*-*-netbsd*?
  65. sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
  66. sh64-*-netbsd* | sh64l*-*-netbsd*)
  67. $1=-fpic
  68. ;;
  69. # Default to -fPIC unless specified otherwise.
  70. *)
  71. $1=-fPIC
  72. ;;
  73. esac
  74. # If the user explicitly uses -fpic/-fPIC, keep that.
  75. case "${m4_bpatsubsts($1, PICFLAG, CFLAGS)}" in
  76. *-fpic*)
  77. $1=-fpic
  78. ;;
  79. *-fPIC*)
  80. $1=-fPIC
  81. ;;
  82. esac
  83. ])
  84. # GCC_PICFLAG
  85. # -----------
  86. # Store host PIC flag in PICFLAG.
  87. AC_DEFUN([GCC_PICFLAG], [
  88. AC_REQUIRE([AC_CANONICAL_HOST])
  89. _GCC_PICFLAG([PICFLAG], [host])])
  90. # GCC_PICFLAG_FOR_TARGET
  91. # ----------------------
  92. # Store target PIC flag in PICFLAG_FOR_TARGET.
  93. AC_DEFUN([GCC_PICFLAG_FOR_TARGET], [
  94. AC_REQUIRE([AC_CANONICAL_TARGET])
  95. _GCC_PICFLAG([PICFLAG_FOR_TARGET], [target])])