configure.ac 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901
  1. dnl Process this file with autoconf to produce a configure script.
  2. dnl Note we do not use AC_PREREQ here! See aclocal.m4 for what we use instead.
  3. AC_INIT([GNU C Library], [(see version.h)], [https://sourceware.org/bugzilla/], [glibc])
  4. AC_CONFIG_SRCDIR([include/features.h])
  5. AC_CONFIG_HEADERS([config.h])
  6. AC_CONFIG_AUX_DIR([scripts])
  7. ACX_PKGVERSION([GNU libc])
  8. ACX_BUGURL([http://www.gnu.org/software/libc/bugs.html])
  9. AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"],
  10. [Package description])
  11. AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"],
  12. [Bug reporting address])
  13. # Glibc should not depend on any header files
  14. AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
  15. [m4_divert_text([DEFAULTS],
  16. [ac_includes_default='/* none */'])])
  17. # We require GCC, and by default use its preprocessor. Override AC_PROG_CPP
  18. # here to work around the Autoconf issue discussed in
  19. # <https://sourceware.org/ml/libc-alpha/2013-01/msg00721.html>.
  20. AC_DEFUN([AC_PROG_CPP],
  21. [AC_REQUIRE([AC_PROG_CC])dnl
  22. AC_ARG_VAR([CPP], [C preprocessor])dnl
  23. _AC_ARG_VAR_CPPFLAGS()dnl
  24. # On Suns, sometimes $CPP names a directory.
  25. if test -n "$CPP" && test -d "$CPP"; then
  26. CPP=
  27. fi
  28. if test -z "$CPP"; then
  29. CPP="$CC -E"
  30. fi
  31. AC_SUBST(CPP)dnl
  32. ])# AC_PROG_CPP
  33. # We require GCC. Override _AC_PROG_CC_C89 here to work around the Autoconf
  34. # issue discussed in
  35. # <https://sourceware.org/ml/libc-alpha/2013-01/msg00757.html>.
  36. AC_DEFUN([_AC_PROG_CC_C89], [[$1]])
  37. dnl This is here so we can set $subdirs directly based on configure fragments.
  38. AC_CONFIG_SUBDIRS()
  39. AC_CANONICAL_HOST
  40. AC_PROG_CC
  41. if test $host != $build; then
  42. AC_CHECK_PROGS(BUILD_CC, gcc cc)
  43. fi
  44. AC_SUBST(cross_compiling)
  45. AC_PROG_CPP
  46. AC_CHECK_TOOL(READELF, readelf, false)
  47. # We need the C++ compiler only for testing.
  48. AC_PROG_CXX
  49. # It's useless to us if it can't link programs (e.g. missing -lstdc++).
  50. AC_CACHE_CHECK([whether $CXX can link programs], libc_cv_cxx_link_ok, [dnl
  51. AC_LANG_PUSH([C++])
  52. # Default, dynamic case.
  53. AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
  54. [libc_cv_cxx_link_ok=yes],
  55. [libc_cv_cxx_link_ok=no])
  56. # Static case.
  57. old_LDFLAGS="$LDFLAGS"
  58. LDFLAGS="$LDFLAGS -static"
  59. AC_LINK_IFELSE([AC_LANG_SOURCE([
  60. #include <iostream>
  61. int
  62. main()
  63. {
  64. std::cout << "Hello, world!";
  65. return 0;
  66. }
  67. ])],
  68. [],
  69. [libc_cv_cxx_link_ok=no])
  70. LDFLAGS="$old_LDFLAGS"
  71. AC_LANG_POP([C++])])
  72. AS_IF([test $libc_cv_cxx_link_ok != yes], [CXX=])
  73. if test "`cd $srcdir; pwd -P`" = "`pwd -P`"; then
  74. AC_MSG_ERROR([you must configure in a separate build directory])
  75. fi
  76. # This will get text that should go into config.make.
  77. config_vars=
  78. # Check for a --with-gd argument and set libgd-LDFLAGS in config.make.
  79. AC_ARG_WITH([gd],
  80. AC_HELP_STRING([--with-gd=DIR],
  81. [find libgd include dir and library with prefix DIR]),
  82. [dnl
  83. case "$with_gd" in
  84. yes|''|no) ;;
  85. *) libgd_include="-I$withval/include"
  86. libgd_ldflags="-L$withval/lib" ;;
  87. esac
  88. ])
  89. AC_ARG_WITH([gd-include],
  90. AC_HELP_STRING([--with-gd-include=DIR],
  91. [find libgd include files in DIR]),
  92. [dnl
  93. case "$with_gd_include" in
  94. ''|no) ;;
  95. *) libgd_include="-I$withval" ;;
  96. esac
  97. ])
  98. AC_ARG_WITH([gd-lib],
  99. AC_HELP_STRING([--with-gd-lib=DIR],
  100. [find libgd library files in DIR]),
  101. [dnl
  102. case "$with_gd_lib" in
  103. ''|no) ;;
  104. *) libgd_ldflags="-L$withval" ;;
  105. esac
  106. ])
  107. if test -n "$libgd_include"; then
  108. config_vars="$config_vars
  109. CFLAGS-memusagestat.c = $libgd_include"
  110. fi
  111. if test -n "$libgd_ldflags"; then
  112. config_vars="$config_vars
  113. libgd-LDFLAGS = $libgd_ldflags"
  114. fi
  115. dnl Arguments to specify presence of other packages/features.
  116. AC_ARG_WITH([binutils],
  117. AC_HELP_STRING([--with-binutils=PATH],
  118. [specify location of binutils (as and ld)]),
  119. [path_binutils=$withval],
  120. [path_binutils=''])
  121. AC_ARG_WITH([selinux],
  122. AC_HELP_STRING([--with-selinux],
  123. [if building with SELinux support]),
  124. [with_selinux=$withval],
  125. [with_selinux=auto])
  126. AC_ARG_WITH([headers],
  127. AC_HELP_STRING([--with-headers=PATH],
  128. [location of system headers to use
  129. (for example /usr/src/linux/include)
  130. @<:@default=compiler default@:>@]),
  131. [sysheaders=$withval],
  132. [sysheaders=''])
  133. AC_SUBST(sysheaders)
  134. AC_SUBST(use_default_link)
  135. AC_ARG_WITH([default-link],
  136. AC_HELP_STRING([--with-default-link],
  137. [do not use explicit linker scripts]),
  138. [use_default_link=$withval],
  139. [use_default_link=default])
  140. dnl Additional build flags injection.
  141. AC_ARG_WITH([nonshared-cflags],
  142. AC_HELP_STRING([--with-nonshared-cflags=CFLAGS],
  143. [build nonshared libraries with additional CFLAGS]),
  144. [extra_nonshared_cflags=$withval],
  145. [extra_nonshared_cflags=])
  146. AC_SUBST(extra_nonshared_cflags)
  147. AC_ARG_ENABLE([sanity-checks],
  148. AC_HELP_STRING([--disable-sanity-checks],
  149. [really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
  150. [enable_sanity=$enableval],
  151. [enable_sanity=yes])
  152. AC_ARG_ENABLE([shared],
  153. AC_HELP_STRING([--enable-shared],
  154. [build shared library @<:@default=yes if GNU ld@:>@]),
  155. [shared=$enableval],
  156. [shared=yes])
  157. AC_ARG_ENABLE([profile],
  158. AC_HELP_STRING([--enable-profile],
  159. [build profiled library @<:@default=no@:>@]),
  160. [profile=$enableval],
  161. [profile=no])
  162. AC_ARG_ENABLE([static-pie],
  163. AC_HELP_STRING([--enable-static-pie],
  164. [enable static PIE support and use it in the testsuite @<:@default=no@:>@]),
  165. [static_pie=$enableval],
  166. [static_pie=no])
  167. AC_ARG_ENABLE([timezone-tools],
  168. AC_HELP_STRING([--disable-timezone-tools],
  169. [do not install timezone tools @<:@default=install@:>@]),
  170. [enable_timezone_tools=$enableval],
  171. [enable_timezone_tools=yes])
  172. AC_SUBST(enable_timezone_tools)
  173. AC_ARG_ENABLE([hardcoded-path-in-tests],
  174. AC_HELP_STRING([--enable-hardcoded-path-in-tests],
  175. [hardcode newly built glibc path in tests @<:@default=no@:>@]),
  176. [hardcoded_path_in_tests=$enableval],
  177. [hardcoded_path_in_tests=no])
  178. AC_SUBST(hardcoded_path_in_tests)
  179. AC_ARG_ENABLE([stackguard-randomization],
  180. AC_HELP_STRING([--enable-stackguard-randomization],
  181. [initialize __stack_chk_guard canary with a random number at program start]),
  182. [enable_stackguard_randomize=$enableval],
  183. [enable_stackguard_randomize=no])
  184. if test "$enable_stackguard_randomize" = yes; then
  185. AC_DEFINE(ENABLE_STACKGUARD_RANDOMIZE)
  186. fi
  187. AC_ARG_ENABLE([hidden-plt],
  188. AC_HELP_STRING([--disable-hidden-plt],
  189. [do not hide internal function calls to avoid PLT]),
  190. [hidden=$enableval],
  191. [hidden=yes])
  192. if test "x$hidden" = xno; then
  193. AC_DEFINE(NO_HIDDEN)
  194. fi
  195. AC_ARG_ENABLE([bind-now],
  196. AC_HELP_STRING([--enable-bind-now],
  197. [disable lazy relocations in DSOs]),
  198. [bindnow=$enableval],
  199. [bindnow=no])
  200. AC_SUBST(bindnow)
  201. if test "x$bindnow" = xyes; then
  202. AC_DEFINE(BIND_NOW)
  203. fi
  204. dnl Build glibc with -fstack-protector, -fstack-protector-all, or
  205. dnl -fstack-protector-strong.
  206. AC_ARG_ENABLE([stack-protector],
  207. AC_HELP_STRING([--enable-stack-protector=@<:@yes|no|all|strong@:>@],
  208. [Use -fstack-protector[-all|-strong] to detect glibc buffer overflows]),
  209. [enable_stack_protector=$enableval],
  210. [enable_stack_protector=no])
  211. case "$enable_stack_protector" in
  212. all|yes|no|strong) ;;
  213. *) AC_MSG_ERROR([Not a valid argument for --enable-stack-protector: \"$enable_stack_protector\"]);;
  214. esac
  215. dnl On some platforms we cannot use dynamic loading. We must provide
  216. dnl static NSS modules.
  217. AC_ARG_ENABLE([static-nss],
  218. AC_HELP_STRING([--enable-static-nss],
  219. [build static NSS modules @<:@default=no@:>@]),
  220. [static_nss=$enableval],
  221. [static_nss=no])
  222. dnl Enable static NSS also if we build no shared objects.
  223. if test x"$static_nss" = xyes || test x"$shared" = xno; then
  224. static_nss=yes
  225. AC_DEFINE(DO_STATIC_NSS)
  226. fi
  227. AC_ARG_ENABLE([force-install],
  228. AC_HELP_STRING([--disable-force-install],
  229. [don't force installation of files from this package, even if they are older than the installed files]),
  230. [force_install=$enableval],
  231. [force_install=yes])
  232. AC_SUBST(force_install)
  233. AC_ARG_ENABLE([maintainer-mode],
  234. AC_HELP_STRING([--enable-maintainer-mode],
  235. [enable make rules and dependencies not useful (and sometimes confusing) to the casual installer]),
  236. [maintainer=$enableval],
  237. [maintainer=no])
  238. dnl On some platforms we allow dropping compatibility with all kernel
  239. dnl versions.
  240. AC_ARG_ENABLE([kernel],
  241. AC_HELP_STRING([--enable-kernel=VERSION],
  242. [compile for compatibility with kernel not older than VERSION]),
  243. [minimum_kernel=$enableval],
  244. [])
  245. dnl Prevent unreasonable values.
  246. if test "$minimum_kernel" = yes || test "$minimum_kernel" = no; then
  247. # Better nothing than this.
  248. minimum_kernel=""
  249. else
  250. if test "$minimum_kernel" = current; then
  251. minimum_kernel=`uname -r 2>/dev/null` || minimum_kernel=
  252. fi
  253. fi
  254. dnl For the development we sometimes want gcc to issue even more warnings.
  255. dnl This is not the default since many of the extra warnings are not
  256. dnl appropriate.
  257. AC_ARG_ENABLE([all-warnings],
  258. AC_HELP_STRING([--enable-all-warnings],
  259. [enable all useful warnings gcc can issue]),
  260. [all_warnings=$enableval],
  261. [])
  262. AC_SUBST(all_warnings)
  263. AC_ARG_ENABLE([werror],
  264. AC_HELP_STRING([--disable-werror],
  265. [do not build with -Werror]),
  266. [enable_werror=$enableval],
  267. [enable_werror=yes])
  268. AC_SUBST(enable_werror)
  269. AC_ARG_ENABLE([multi-arch],
  270. AC_HELP_STRING([--enable-multi-arch],
  271. [enable single DSO with optimizations for multiple architectures]),
  272. [multi_arch=$enableval],
  273. [multi_arch=default])
  274. AC_ARG_ENABLE([experimental-malloc],
  275. AC_HELP_STRING([--disable-experimental-malloc],
  276. [disable experimental malloc features]),
  277. [experimental_malloc=$enableval],
  278. [experimental_malloc=yes])
  279. AC_SUBST(experimental_malloc)
  280. AC_ARG_ENABLE([crypt],
  281. AC_HELP_STRING([--disable-crypt],
  282. [do not build nor install the passphrase hashing library, libcrypt]),
  283. [build_crypt=$enableval],
  284. [build_crypt=yes])
  285. AC_SUBST(build_crypt)
  286. AC_ARG_ENABLE([nss-crypt],
  287. AC_HELP_STRING([--enable-nss-crypt],
  288. [enable libcrypt to use nss]),
  289. [nss_crypt=$enableval],
  290. [nss_crypt=no])
  291. if test x$build_libcrypt = xno && test x$nss_crypt = xyes; then
  292. AC_MSG_WARN([--enable-nss-crypt has no effect when libcrypt is disabled])
  293. nss_crypt=no
  294. fi
  295. if test x$nss_crypt = xyes; then
  296. nss_includes=-I$(nss-config --includedir 2>/dev/null)
  297. if test $? -ne 0; then
  298. AC_MSG_ERROR([cannot find include directory with nss-config])
  299. fi
  300. nspr_includes=-I$(nspr-config --includedir 2>/dev/null)
  301. if test $? -ne 0; then
  302. AC_MSG_ERROR([cannot find include directory with nspr-config])
  303. fi
  304. old_CFLAGS="$CFLAGS"
  305. CFLAGS="$CFLAGS $nss_includes $nspr_includes"
  306. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
  307. #include <hasht.h>
  308. #include <nsslowhash.h>
  309. void f (void) { NSSLOW_Init (); }])],
  310. libc_cv_nss_crypt=yes,
  311. AC_MSG_ERROR([
  312. cannot find NSS headers with lowlevel hash function interfaces]))
  313. old_LIBS="$LIBS"
  314. old_LDFLAGS="$LDFLAGS"
  315. LIBS="$LIBS -lfreebl3"
  316. AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
  317. #include <hasht.h>
  318. #include <nsslowhash.h>],
  319. [NSSLOW_Init();])],
  320. libc_cv_nss_crypt=yes,
  321. AC_MSG_ERROR([
  322. cannot link program using lowlevel NSS hash functions]))
  323. # Check to see if there is a static NSS cryptographic library.
  324. # If there isn't then we can't link anything with libcrypt.a,
  325. # and that might mean disabling some static tests.
  326. LDFLAGS="$LDFLAGS -static"
  327. AC_LINK_IFELSE([AC_LANG_PROGRAM([typedef int PRBool;
  328. #include <hasht.h>
  329. #include <nsslowhash.h>],
  330. [NSSLOW_Init();])],
  331. libc_cv_static_nss_crypt=yes,
  332. libc_cv_static_nss_crypt=no)
  333. LDFLAGS="$old_LDFLAGS"
  334. CFLAGS="$old_CFLAGS"
  335. LIBS="$old_LIBS"
  336. else
  337. libc_cv_nss_crypt=no
  338. libc_cv_static_nss_crypt=no
  339. fi
  340. AC_SUBST(libc_cv_nss_crypt)
  341. AC_SUBST(libc_cv_static_nss_crypt)
  342. AC_ARG_ENABLE([obsolete-rpc],
  343. AC_HELP_STRING([--enable-obsolete-rpc],
  344. [build and install the obsolete RPC code for link-time usage]),
  345. [link_obsolete_rpc=$enableval],
  346. [link_obsolete_rpc=no])
  347. AC_SUBST(link_obsolete_rpc)
  348. if test "$link_obsolete_rpc" = yes; then
  349. AC_DEFINE(LINK_OBSOLETE_RPC)
  350. fi
  351. AC_ARG_ENABLE([obsolete-nsl],
  352. AC_HELP_STRING([--enable-obsolete-nsl],
  353. [build and install the obsolete libnsl library and depending NSS modules]),
  354. [build_obsolete_nsl=$enableval],
  355. [build_obsolete_nsl=no])
  356. AC_SUBST(build_obsolete_nsl)
  357. if test "$build_obsolete_nsl" = yes; then
  358. AC_DEFINE(LINK_OBSOLETE_NSL)
  359. fi
  360. AC_ARG_ENABLE([systemtap],
  361. [AS_HELP_STRING([--enable-systemtap],
  362. [enable systemtap static probe points @<:@default=no@:>@])],
  363. [systemtap=$enableval],
  364. [systemtap=no])
  365. if test "x$systemtap" != xno; then
  366. AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
  367. old_CFLAGS="$CFLAGS"
  368. CFLAGS="-std=gnu11 $CFLAGS"
  369. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/sdt.h>
  370. void foo (int i, void *p)
  371. {
  372. asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
  373. :: STAP_PROBE_ASM_OPERANDS (2, i, p));
  374. }]])], [libc_cv_sdt=yes], [libc_cv_sdt=no])
  375. CFLAGS="$old_CFLAGS"])
  376. if test $libc_cv_sdt = yes; then
  377. AC_DEFINE([USE_STAP_PROBE])
  378. elif test "x$systemtap" != xauto; then
  379. AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
  380. fi
  381. fi
  382. AC_ARG_ENABLE([build-nscd],
  383. [AS_HELP_STRING([--disable-build-nscd],
  384. [disable building and installing the nscd daemon])],
  385. [build_nscd=$enableval],
  386. [build_nscd=default])
  387. AC_SUBST(build_nscd)
  388. # Note the use of $use_nscd is near the bottom of the file.
  389. AC_ARG_ENABLE([nscd],
  390. [AS_HELP_STRING([--disable-nscd],
  391. [library functions will not contact the nscd daemon])],
  392. [use_nscd=$enableval],
  393. [use_nscd=yes])
  394. AC_ARG_ENABLE([pt_chown],
  395. [AS_HELP_STRING([--enable-pt_chown],
  396. [Enable building and installing pt_chown])],
  397. [build_pt_chown=$enableval],
  398. [build_pt_chown=no])
  399. AC_SUBST(build_pt_chown)
  400. if test "$build_pt_chown" = yes; then
  401. AC_DEFINE(HAVE_PT_CHOWN)
  402. fi
  403. AC_ARG_ENABLE([tunables],
  404. [AS_HELP_STRING([--enable-tunables],
  405. [Enable tunables support. Known values are 'yes', 'no' and 'valstring'])],
  406. [have_tunables=$enableval],
  407. [have_tunables=yes])
  408. AC_SUBST(have_tunables)
  409. if test "$have_tunables" = yes; then
  410. AC_DEFINE(HAVE_TUNABLES)
  411. fi
  412. # The abi-tags file uses a fairly simplistic model for name recognition that
  413. # can't distinguish i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a
  414. # $host_os of `gnu*' here to be `gnu-gnu*' just so that it can tell.
  415. # This doesn't get used much beyond that, so it's fairly safe.
  416. case "$host_os" in
  417. linux*)
  418. ;;
  419. gnu*)
  420. host_os=`echo $host_os | sed -e 's/gnu/gnu-gnu/'`
  421. ;;
  422. esac
  423. AC_ARG_ENABLE([mathvec],
  424. [AS_HELP_STRING([--enable-mathvec],
  425. [Enable building and installing mathvec @<:@default depends on architecture@:>@])],
  426. [build_mathvec=$enableval],
  427. [build_mathvec=notset])
  428. AC_ARG_ENABLE([cet],
  429. AC_HELP_STRING([--enable-cet],
  430. [enable Intel Control-flow Enforcement Technology (CET), x86 only]),
  431. [enable_cet=$enableval],
  432. [enable_cet=no])
  433. # We keep the original values in `$config_*' and never modify them, so we
  434. # can write them unchanged into config.make. Everything else uses
  435. # $machine, $vendor, and $os, and changes them whenever convenient.
  436. config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
  437. # Don't allow vendor == "unknown"
  438. test "$config_vendor" = unknown && config_vendor=
  439. config_os="`echo $config_os | sed 's/^unknown-//'`"
  440. # Some configurations imply other options.
  441. elf=yes
  442. # The configure fragment of a port can modify these to supplement
  443. # or override the table in the case statement below. No fragment should
  444. # ever change the config_* variables, however.
  445. machine=$config_machine
  446. vendor=$config_vendor
  447. os=$config_os
  448. base_os=''
  449. submachine=
  450. AC_ARG_WITH([cpu],
  451. AS_HELP_STRING([--with-cpu=CPU], [select code for CPU variant]),
  452. [dnl
  453. case "$withval" in
  454. yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;;
  455. no) ;;
  456. *) submachine="$withval" ;;
  457. esac
  458. ])
  459. # An preconfigure script can set this when it wants to disable the sanity
  460. # check below.
  461. libc_config_ok=no
  462. # A preconfigure script for a system that may or may not use fpu
  463. # sysdeps directories sets this to a preprocessor conditional for
  464. # whether to use such directories.
  465. with_fp_cond=1
  466. dnl Let sysdeps/*/preconfigure act here.
  467. LIBC_PRECONFIGURE([$srcdir], [for sysdeps])
  468. ###
  469. ### By using the undocumented --enable-hacker-mode option for configure
  470. ### one can skip this test to make the configuration not fail for unsupported
  471. ### platforms.
  472. ###
  473. if test -z "$enable_hacker_mode" && test x"$libc_config_ok" != xyes; then
  474. case "$machine-$host_os" in
  475. *-linux* | *-gnu*)
  476. ;;
  477. *)
  478. AC_MSG_ERROR([
  479. *** The GNU C library is currently unavailable for this platform.
  480. *** If you are interested in seeing glibc on this platform visit
  481. *** the "How to submit a new port" in the wiki:
  482. *** https://sourceware.org/glibc/wiki/#Development
  483. *** and join the community!])
  484. ;;
  485. esac
  486. fi
  487. # Set base_machine if not set by a preconfigure fragment.
  488. test -n "$base_machine" || base_machine=$machine
  489. AC_SUBST(base_machine)
  490. # Determine whether to use fpu or nofpu sysdeps directories.
  491. AC_CACHE_CHECK([for use of fpu sysdeps directories],
  492. libc_cv_with_fp, [dnl
  493. cat > conftest.c <<EOF
  494. #if $with_fp_cond
  495. int dummy;
  496. #else
  497. # error "no hardware floating point"
  498. #endif
  499. EOF
  500. libc_cv_with_fp=no
  501. if ${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c -o conftest.s \
  502. 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
  503. libc_cv_with_fp=yes
  504. fi
  505. rm -f conftest*])
  506. AC_SUBST(libc_cv_with_fp)
  507. AC_CACHE_CHECK(for -fstack-protector, libc_cv_ssp, [dnl
  508. LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector],
  509. [libc_cv_ssp=yes],
  510. [libc_cv_ssp=no])
  511. ])
  512. AC_CACHE_CHECK(for -fstack-protector-strong, libc_cv_ssp_strong, [dnl
  513. LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-strong],
  514. [libc_cv_ssp_strong=yes],
  515. [libc_cv_ssp_strong=no])
  516. ])
  517. AC_CACHE_CHECK(for -fstack-protector-all, libc_cv_ssp_all, [dnl
  518. LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fstack-protector-all],
  519. [libc_cv_ssp_all=yes],
  520. [libc_cv_ssp_all=no])
  521. ])
  522. stack_protector=
  523. no_stack_protector=
  524. if test "$libc_cv_ssp" = yes; then
  525. no_stack_protector="-fno-stack-protector -DSTACK_PROTECTOR_LEVEL=0"
  526. AC_DEFINE(HAVE_CC_NO_STACK_PROTECTOR)
  527. fi
  528. if test "$enable_stack_protector" = yes && test "$libc_cv_ssp" = yes; then
  529. stack_protector="-fstack-protector"
  530. AC_DEFINE(STACK_PROTECTOR_LEVEL, 1)
  531. elif test "$enable_stack_protector" = all && test "$libc_cv_ssp_all" = yes; then
  532. stack_protector="-fstack-protector-all"
  533. AC_DEFINE(STACK_PROTECTOR_LEVEL, 2)
  534. elif test "$enable_stack_protector" = strong && test "$libc_cv_ssp_strong" = yes; then
  535. stack_protector="-fstack-protector-strong"
  536. AC_DEFINE(STACK_PROTECTOR_LEVEL, 3)
  537. else
  538. stack_protector="-fno-stack-protector"
  539. AC_DEFINE(STACK_PROTECTOR_LEVEL, 0)
  540. fi
  541. AC_SUBST(libc_cv_ssp)
  542. AC_SUBST(stack_protector)
  543. AC_SUBST(no_stack_protector)
  544. if test -n "$stack_protector"; then
  545. dnl Don't run configure tests with stack-protection on, to avoid problems with
  546. dnl bootstrapping.
  547. no_ssp=-fno-stack-protector
  548. else
  549. no_ssp=
  550. if test "$enable_stack_protector" != no; then
  551. AC_MSG_ERROR([--enable-stack-protector=$enable_stack_protector specified, but specified level of stack protection is not supported by the compiler.])
  552. fi
  553. fi
  554. # For the multi-arch option we need support in the assembler & linker.
  555. AC_CACHE_CHECK([for assembler and linker STT_GNU_IFUNC support],
  556. libc_cv_ld_gnu_indirect_function, [dnl
  557. cat > conftest.S <<EOF
  558. .type foo,%gnu_indirect_function
  559. foo:
  560. .globl _start
  561. _start:
  562. .globl __start
  563. __start:
  564. .data
  565. #ifdef _LP64
  566. .quad foo
  567. #else
  568. .long foo
  569. #endif
  570. EOF
  571. libc_cv_ld_gnu_indirect_function=no
  572. if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
  573. -nostartfiles -nostdlib $no_ssp \
  574. -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
  575. # Do a link to see if the backend supports IFUNC relocs.
  576. $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
  577. LC_ALL=C $READELF -r conftest | grep 'no relocations' >/dev/null || {
  578. libc_cv_ld_gnu_indirect_function=yes
  579. }
  580. fi
  581. rm -f conftest*])
  582. # Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
  583. AC_CACHE_CHECK([for gcc attribute ifunc support],
  584. libc_cv_gcc_indirect_function, [dnl
  585. cat > conftest.c <<EOF
  586. extern int func (int);
  587. int used_func (int a)
  588. {
  589. return a;
  590. }
  591. static void *resolver ()
  592. {
  593. return &used_func;
  594. }
  595. extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
  596. EOF
  597. libc_cv_gcc_indirect_function=no
  598. if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
  599. 2>&AS_MESSAGE_LOG_FD ; then
  600. if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
  601. libc_cv_gcc_indirect_function=yes
  602. fi
  603. fi
  604. rm -f conftest*])
  605. # Check if linker supports textrel relocation with ifunc (used on elf/tests).
  606. # Note that it relies on libc_cv_ld_gnu_indirect_function test above.
  607. AC_CACHE_CHECK([whether the linker supports textrels along with ifunc],
  608. libc_cv_textrel_ifunc, [dnl
  609. cat > conftest.S <<EOF
  610. .type foo,%gnu_indirect_function
  611. foo:
  612. .globl _start
  613. _start:
  614. .globl __start
  615. __start:
  616. .data
  617. #ifdef _LP64
  618. .quad foo
  619. #else
  620. .long foo
  621. #endif
  622. .text
  623. .globl address
  624. address:
  625. #ifdef _LP64
  626. .quad address
  627. #else
  628. .long address
  629. #endif
  630. EOF
  631. libc_cv_textrel_ifunc=no
  632. if test $libc_cv_ld_gnu_indirect_function = yes; then
  633. if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -nostartfiles -nostdlib $no_ssp -pie -o conftest conftest.S); then
  634. libc_cv_textrel_ifunc=yes
  635. fi
  636. fi
  637. rm -f conftest*])
  638. AC_SUBST(libc_cv_textrel_ifunc)
  639. # Check if gcc warns about alias for function with incompatible types.
  640. AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
  641. libc_cv_gcc_incompatible_alias, [dnl
  642. cat > conftest.c <<EOF
  643. int __redirect_foo (const void *s, int c);
  644. __typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
  645. __typeof (__redirect_foo) *foo_impl (void)
  646. {
  647. return 0;
  648. }
  649. extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
  650. EOF
  651. libc_cv_gcc_incompatible_alias=yes
  652. if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
  653. libc_cv_gcc_incompatible_alias=no
  654. fi
  655. rm -f conftest*])
  656. if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
  657. if test x"$multi_arch" = xyes; then
  658. AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
  659. else
  660. multi_arch=no
  661. fi
  662. fi
  663. if test x"$libc_cv_gcc_indirect_function" != xyes; then
  664. # GCC 8+ emits a warning for alias with incompatible types and it might
  665. # fail to build ifunc resolvers aliases to either weak or internal
  666. # symbols. Disables multiarch build in this case.
  667. if test x"$libc_cv_gcc_incompatible_alias" == xyes; then
  668. AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
  669. if test x"$multi_arch" = xyes; then
  670. AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
  671. fi
  672. AC_MSG_WARN([Multi-arch is disabled.])
  673. multi_arch=no
  674. elif test x"$multi_arch" = xyes; then
  675. AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
  676. Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
  677. fi
  678. fi
  679. multi_arch_d=
  680. if test x"$multi_arch" != xno; then
  681. multi_arch_d=/multiarch
  682. fi
  683. # Compute the list of sysdep directories for this configuration.
  684. # This can take a while to compute.
  685. sysdep_dir=$srcdir/sysdeps
  686. AC_MSG_CHECKING(sysdep dirs)
  687. dnl We need to use [ and ] for other purposes for a while now.
  688. changequote(,)dnl
  689. # Make sco3.2v4 become sco3.2.4 and sunos4.1.1_U1 become sunos4.1.1.U1.
  690. os="`echo $os | sed 's/\([0-9A-Z]\)[v_]\([0-9A-Z]\)/\1.\2/g'`"
  691. test "x$base_os" != x || case "$os" in
  692. gnu*)
  693. base_os=mach/hurd ;;
  694. linux*)
  695. base_os=unix/sysv ;;
  696. esac
  697. # For sunos4.1.1, try sunos4.1.1, then sunos4.1, then sunos4, then sunos.
  698. tail=$os
  699. ostry=$os
  700. while o=`echo $tail | sed 's/\.[^.]*$//'`; test $o != $tail; do
  701. ostry="$ostry /$o"
  702. tail=$o
  703. done
  704. o=`echo $tail | sed 's/[0-9]*$//'`
  705. if test $o != $tail; then
  706. ostry="$ostry /$o"
  707. fi
  708. # For linux-gnu, try linux-gnu, then linux.
  709. o=`echo $tail | sed 's/-.*$//'`
  710. if test $o != $tail; then
  711. ostry="$ostry /$o"
  712. fi
  713. # For unix/sysv/sysv4, try unix/sysv/sysv4, then unix/sysv, then unix.
  714. base=
  715. tail=$base_os
  716. while b=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$b"; do
  717. set $b
  718. base="$base /$1"
  719. tail="$2"
  720. done
  721. # For sparc/sparc32, try sparc/sparc32 and then sparc.
  722. mach=
  723. tail=$machine${submachine:+/$submachine}
  724. while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do
  725. set $m
  726. # Prepend the machine's FPU directory unless --without-fp.
  727. if test "$libc_cv_with_fp" = yes; then
  728. maybe_fpu=/fpu
  729. else
  730. maybe_fpu=/nofpu
  731. fi
  732. # For each machine term, try it with and then without /multiarch.
  733. for try_fpu in $maybe_fpu ''; do
  734. for try_multi in $multi_arch_d ''; do
  735. mach="$mach /$1$try_fpu$try_multi"
  736. done
  737. done
  738. tail="$2"
  739. done
  740. dnl We are done with glob and regexp uses of [ and ]; return to autoconf.
  741. changequote([,])dnl
  742. # Find what sysdep directories exist.
  743. sysnames=
  744. for b in $base ''; do
  745. for m0 in $mach ''; do
  746. for v in /$vendor ''; do
  747. test "$v" = / && continue
  748. for o in /$ostry ''; do
  749. test "$o" = / && continue
  750. for m in $mach ''; do
  751. try_suffix="$m0$b$v$o$m"
  752. if test -n "$try_suffix"; then
  753. try_srcdir="${srcdir}/"
  754. try="sysdeps$try_suffix"
  755. test -n "$enable_debug_configure" &&
  756. echo "$0 [DEBUG]: try $try" >&2
  757. if test -d "$try_srcdir$try"; then
  758. sysnames="$sysnames $try"
  759. { test -n "$o" || test -n "$b"; } && os_used=t
  760. { test -n "$m" || test -n "$m0"; } && machine_used=t
  761. case x${m0:-$m} in
  762. x*/$submachine) submachine_used=t ;;
  763. esac
  764. fi
  765. fi
  766. done
  767. done
  768. done
  769. done
  770. done
  771. # If the assembler supports gnu_indirect_function symbol type and the
  772. # architecture supports multi-arch, we enable multi-arch by default.
  773. case $sysnames in
  774. *"$multi_arch_d"*)
  775. ;;
  776. *)
  777. test x"$multi_arch" = xdefault && multi_arch=no
  778. ;;
  779. esac
  780. if test x"$multi_arch" != xno; then
  781. AC_DEFINE(USE_MULTIARCH)
  782. fi
  783. AC_SUBST(multi_arch)
  784. if test -z "$os_used" && test "$os" != none; then
  785. AC_MSG_ERROR(Operating system $os is not supported.)
  786. fi
  787. if test -z "$machine_used" && test "$machine" != none; then
  788. AC_MSG_ERROR(The $machine is not supported.)
  789. fi
  790. if test -z "$submachine_used" && test -n "$submachine"; then
  791. AC_MSG_ERROR(The $submachine subspecies of $host_cpu is not supported.)
  792. fi
  793. AC_SUBST(submachine)
  794. # We have now validated the configuration.
  795. # Expand the list of system names into a full list of directories
  796. # from each element's parent name and Implies file (if present).
  797. set $sysnames
  798. names=
  799. while test $# -gt 0; do
  800. name=$1
  801. shift
  802. case " $names " in *" $name "*)
  803. # Already in the list.
  804. continue
  805. esac
  806. # Report each name as we discover it, so there is no long pause in output.
  807. echo $ECHO_N "$name $ECHO_C" >&AS_MESSAGE_FD
  808. name_base=`echo $name | sed -e 's@\(.*sysdeps\)/.*@\1@'`
  809. case $name in
  810. /*) xsrcdir= ;;
  811. *) xsrcdir=$srcdir/ ;;
  812. esac
  813. test -n "$enable_debug_configure" &&
  814. echo "[DEBUG]: name/Implies $xsrcdir$name/Implies" >&2
  815. for implies_file in Implies Implies-before Implies-after; do
  816. implies_type=`echo $implies_file | sed s/-/_/`
  817. eval ${implies_type}=
  818. if test -f $xsrcdir$name/$implies_file; then
  819. # Collect more names from the `Implies' file (removing comments).
  820. implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/$implies_file`"
  821. for x in $implied_candidate; do
  822. found=no
  823. if test -d $xsrcdir$name_base/$x; then
  824. eval "${implies_type}=\"\$${implies_type} \$name_base/\$x\""
  825. found=yes
  826. fi
  827. try="sysdeps/$x"
  828. try_srcdir=$srcdir/
  829. test -n "$enable_debug_configure" &&
  830. echo "[DEBUG]: $name $implies_file $x try() {$try_srcdir}$try" >&2
  831. if test $try != $xsrcdir$name_base/$x && test -d $try_srcdir$try;
  832. then
  833. eval "${implies_type}=\"\$${implies_type} \$try\""
  834. found=yes
  835. fi
  836. if test $found = no; then
  837. AC_MSG_WARN($name/$implies_file specifies nonexistent $x)
  838. fi
  839. done
  840. fi
  841. done
  842. # Add NAME to the list of names.
  843. names="$names $name"
  844. # Find the parent of NAME, using the empty string if it has none.
  845. changequote(,)dnl
  846. parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`"
  847. changequote([,])dnl
  848. test -n "$enable_debug_configure" &&
  849. echo "[DEBUG]: $name Implies='$Implies' rest='$*' parent='$parent' \
  850. Implies_before='$Implies_before' Implies_after='$Implies_after'" >&2
  851. # Add the names implied by NAME, and NAME's parent (if it has one), to
  852. # the list of names to be processed (the argument list). We prepend the
  853. # implied names to the list and append the parent. We want implied
  854. # directories to come before further directories inferred from the
  855. # configuration components; this ensures that for sysv4, unix/common
  856. # (implied by unix/sysv/sysv4) comes before unix/sysv (in ostry (here $*)
  857. # after sysv4).
  858. sysnames="`echo $Implies $* $Implies_before $parent $Implies_after`"
  859. test -n "$sysnames" && set $sysnames
  860. done
  861. # Add the default directories.
  862. default_sysnames="sysdeps/generic"
  863. sysnames="$names $default_sysnames"
  864. AC_SUBST(sysnames)
  865. # The other names were emitted during the scan.
  866. AC_MSG_RESULT($default_sysnames)
  867. ### Locate tools.
  868. AC_PROG_INSTALL
  869. if test "$INSTALL" = "${srcdir}/scripts/install-sh -c"; then
  870. # The makefiles need to use a different form to find it in $srcdir.
  871. INSTALL='\$(..)./scripts/install-sh -c'
  872. fi
  873. AC_PROG_LN_S
  874. LIBC_PROG_BINUTILS
  875. # Accept binutils 2.25 or newer.
  876. AC_CHECK_PROG_VER(AS, $AS, --version,
  877. [GNU assembler.* \([0-9]*\.[0-9.]*\)],
  878. [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
  879. AS=: critic_missing="$critic_missing as")
  880. if test -n "`$LD --version | sed -n 's/^GNU \(gold\).*$/\1/p'`"; then
  881. # Accept gold 1.14 or higher
  882. AC_CHECK_PROG_VER(LD, $LD, --version,
  883. [GNU gold.* \([0-9][0-9]*\.[0-9.]*\)],
  884. [1.1[4-9]*|1.[2-9][0-9]*|1.1[0-9][0-9]*|[2-9].*|[1-9][0-9]*],
  885. LD=: critic_missing="$critic_missing GNU gold")
  886. else
  887. AC_CHECK_PROG_VER(LD, $LD, --version,
  888. [GNU ld.* \([0-9][0-9]*\.[0-9.]*\)],
  889. [2.1[0-9][0-9]*|2.2[5-9]*|2.[3-9][0-9]*|[3-9].*|[1-9][0-9]*],
  890. LD=: critic_missing="$critic_missing GNU ld")
  891. fi
  892. # These programs are version sensitive.
  893. AC_CHECK_TOOL_PREFIX
  894. AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version,
  895. [GNU Make[^0-9]*\([0-9][0-9.]*\)],
  896. [[4-9].* | [1-9][0-9]*], critic_missing="$critic_missing make")
  897. AC_CHECK_PROG_VER(MSGFMT, gnumsgfmt gmsgfmt msgfmt, --version,
  898. [GNU gettext.* \([0-9]*\.[0-9.]*\)],
  899. [0.10.3[6-9]* | 0.10.[4-9][0-9]* | 0.1[1-9]* | 0.[2-9][0-9]* | [1-9].*],
  900. MSGFMT=: aux_missing="$aux_missing msgfmt")
  901. AC_CHECK_PROG_VER(MAKEINFO, makeinfo, --version,
  902. [GNU texinfo.* \([0-9][0-9.]*\)],
  903. [4.[7-9]*|4.[1-9][0-9]*|[5-9].*],
  904. MAKEINFO=: aux_missing="$aux_missing makeinfo")
  905. AC_CHECK_PROG_VER(SED, sed, --version,
  906. [GNU sed[^0-9]* \([0-9]*\.[0-9.]*\)],
  907. [3.0[2-9]*|3.[1-9]*|[4-9]*],
  908. SED=: aux_missing="$aux_missing sed")
  909. AC_CHECK_PROG_VER(AWK, gawk, --version,
  910. [GNU Awk[^0-9]*\([0-9][0-9.]*\)],
  911. [3.1.[2-9]*|3.[2-9]*|[4-9]*], critic_missing="$critic_missing gawk")
  912. AC_CHECK_PROG_VER(BISON, bison, --version,
  913. [bison (GNU Bison) \([0-9]*\.[0-9.]*\)],
  914. [2.7*|[3-9].*|[1-9][0-9]*], critic_missing="$critic_missing bison")
  915. AC_CACHE_CHECK([if $CC is sufficient to build libc], libc_cv_compiler_ok, [
  916. AC_TRY_COMPILE([], [
  917. #if !defined __GNUC__ || __GNUC__ < 5
  918. #error insufficient compiler
  919. #endif],
  920. [libc_cv_compiler_ok=yes],
  921. [libc_cv_compiler_ok=no])])
  922. AS_IF([test $libc_cv_compiler_ok != yes],
  923. [critic_missing="$critic_missing compiler"])
  924. AC_CHECK_TOOL(NM, nm, false)
  925. if test "x$maintainer" = "xyes"; then
  926. AC_CHECK_PROGS(AUTOCONF, autoconf, no)
  927. case "x$AUTOCONF" in
  928. xno|x|x:) AUTOCONF=no ;;
  929. *)
  930. AC_CACHE_CHECK(dnl
  931. whether $AUTOCONF${ACFLAGS:+ }$ACFLAGS works, libc_cv_autoconf_works, [dnl
  932. if (cd $srcdir; $AUTOCONF $ACFLAGS configure.ac > /dev/null 2>&1); then
  933. libc_cv_autoconf_works=yes
  934. else
  935. libc_cv_autoconf_works=no
  936. fi])
  937. test $libc_cv_autoconf_works = yes || AUTOCONF=no
  938. ;;
  939. esac
  940. if test "x$AUTOCONF" = xno; then
  941. aux_missing="$aux_missing autoconf"
  942. fi
  943. else
  944. AUTOCONF=no
  945. fi
  946. # Check for python3 if available, or else python.
  947. AC_CHECK_PROG_VER(PYTHON_PROG, python3 python, --version,
  948. [Python \([0-9][0-9.]*\)],
  949. [3.[4-9]*|3.[1-9][0-9]*|[4-9].*|[1-9][0-9]*],
  950. critic_missing="$critic_missing python")
  951. PYTHON="$PYTHON_PROG -B"
  952. AC_SUBST(PYTHON)
  953. test -n "$critic_missing" && AC_MSG_ERROR([
  954. *** These critical programs are missing or too old:$critic_missing
  955. *** Check the INSTALL file for required versions.])
  956. test -n "$aux_missing" && AC_MSG_WARN([
  957. *** These auxiliary programs are missing or incompatible versions:$aux_missing
  958. *** some features or tests will be disabled.
  959. *** Check the INSTALL file for required versions.])
  960. # if using special system headers, find out the compiler's sekrit
  961. # header directory and add that to the list. NOTE: Only does the right
  962. # thing on a system that doesn't need fixincludes. (Not presently a problem.)
  963. if test -n "$sysheaders"; then
  964. SYSINCLUDES=-nostdinc
  965. for d in include include-fixed; do
  966. i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" &&
  967. SYSINCLUDES="$SYSINCLUDES -isystem $i"
  968. done
  969. SYSINCLUDES="$SYSINCLUDES \
  970. -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`"
  971. if test -n "$CXX"; then
  972. CXX_SYSINCLUDES=
  973. for cxxheaders in `$CXX -v -S -x c++ /dev/null -o /dev/null 2>&1 \
  974. | sed -n -e '1,/#include/d' -e 's/^ \(\/.*\/[cg]++\)/\1/p'`; do
  975. test "x$cxxheaders" != x &&
  976. CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders"
  977. done
  978. fi
  979. fi
  980. AC_SUBST(SYSINCLUDES)
  981. AC_SUBST(CXX_SYSINCLUDES)
  982. # Obtain some C++ header file paths. This is used to make a local
  983. # copy of those headers in Makerules.
  984. if test -n "$CXX"; then
  985. find_cxx_header () {
  986. echo "#include <$1>" | $CXX -M -MP -x c++ - 2>/dev/null \
  987. | sed -n "\,$1:,{s/:\$//;p}"
  988. }
  989. CXX_CSTDLIB_HEADER="$(find_cxx_header cstdlib)"
  990. CXX_CMATH_HEADER="$(find_cxx_header cmath)"
  991. CXX_BITS_STD_ABS_H="$(find_cxx_header bits/std_abs.h)"
  992. fi
  993. AC_SUBST(CXX_CSTDLIB_HEADER)
  994. AC_SUBST(CXX_CMATH_HEADER)
  995. AC_SUBST(CXX_BITS_STD_ABS_H)
  996. # Test if LD_LIBRARY_PATH contains the notation for the current directory
  997. # since this would lead to problems installing/building glibc.
  998. # LD_LIBRARY_PATH contains the current directory if one of the following
  999. # is true:
  1000. # - one of the terminals (":" and ";") is the first or last sign
  1001. # - two terminals occur directly after each other
  1002. # - the path contains an element with a dot in it
  1003. AC_MSG_CHECKING(LD_LIBRARY_PATH variable)
  1004. changequote(,)dnl
  1005. case ${LD_LIBRARY_PATH} in
  1006. [:\;]* | *[:\;] | *[:\;][:\;]* | *[:\;]. | .[:\;]*| . | *[:\;].[:\;]* )
  1007. ld_library_path_setting="contains current directory"
  1008. ;;
  1009. *)
  1010. ld_library_path_setting="ok"
  1011. ;;
  1012. esac
  1013. changequote([,])dnl
  1014. AC_MSG_RESULT($ld_library_path_setting)
  1015. if test "$ld_library_path_setting" != "ok"; then
  1016. AC_MSG_ERROR([
  1017. *** LD_LIBRARY_PATH shouldn't contain the current directory when
  1018. *** building glibc. Please change the environment variable
  1019. *** and run configure again.])
  1020. fi
  1021. AC_PATH_PROG(BASH_SHELL, bash, no)
  1022. AC_PATH_PROG(PERL, perl, no)
  1023. if test "$PERL" != no &&
  1024. (eval `$PERL -V:apiversion`; test `expr "$apiversion" \< 5` -ne 0); then
  1025. PERL=no
  1026. fi
  1027. AC_PATH_PROG(INSTALL_INFO, install-info, no,
  1028. $PATH:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin)
  1029. AC_CACHE_CHECK(for .set assembler directive, libc_cv_asm_set_directive, [dnl
  1030. cat > conftest.s <<EOF
  1031. .text
  1032. foo:
  1033. .set glibc_conftest_frobozz,foo
  1034. .globl glibc_conftest_frobozz
  1035. EOF
  1036. # The alpha-dec-osf1 assembler gives only a warning for `.set'
  1037. # (but it doesn't work), so we must do a linking check to be sure.
  1038. cat > conftest1.c <<\EOF
  1039. extern int glibc_conftest_frobozz;
  1040. void _start() { glibc_conftest_frobozz = 1; }
  1041. EOF
  1042. if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
  1043. -nostartfiles -nostdlib $no_ssp \
  1044. -o conftest conftest.s conftest1.c 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
  1045. libc_cv_asm_set_directive=yes
  1046. else
  1047. libc_cv_asm_set_directive=no
  1048. fi
  1049. rm -f conftest*])
  1050. if test $libc_cv_asm_set_directive = yes; then
  1051. AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
  1052. fi
  1053. AC_CACHE_CHECK(linker support for protected data symbol,
  1054. libc_cv_protected_data,
  1055. [cat > conftest.c <<EOF
  1056. int bar __attribute__ ((visibility ("protected"))) = 1;
  1057. EOF
  1058. libc_cv_protected_data=no
  1059. if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -o conftest.so); then
  1060. cat > conftest.c <<EOF
  1061. extern int bar;
  1062. int main (void) { return bar; }
  1063. EOF
  1064. if AC_TRY_COMMAND(${CC-cc} -nostdlib -nostartfiles $no_ssp conftest.c -o conftest conftest.so); then
  1065. libc_cv_protected_data=yes
  1066. fi
  1067. fi
  1068. rm -f conftest.*
  1069. ])
  1070. AC_SUBST(libc_cv_protected_data)
  1071. AC_CACHE_CHECK(linker support for INSERT in linker script,
  1072. libc_cv_insert,
  1073. [cat > conftest.c <<EOF
  1074. const int __attribute__ ((section(".bar"))) bar = 0x12345678;
  1075. int test (void) { return bar; }
  1076. EOF
  1077. cat > conftest.t <<EOF
  1078. SECTIONS
  1079. {
  1080. .bar : { *(.bar) }
  1081. }
  1082. INSERT AFTER .rela.dyn;
  1083. EOF
  1084. libc_cv_insert=no
  1085. if AC_TRY_COMMAND([${CC-cc} -nostdlib -nostartfiles $no_ssp -fPIC -shared conftest.c -Wl,-T,conftest.t -o conftest.so]); then
  1086. libc_cv_insert=yes
  1087. fi
  1088. rm -f conftest.*
  1089. ])
  1090. AC_SUBST(libc_cv_insert)
  1091. AC_CACHE_CHECK(for broken __attribute__((alias())),
  1092. libc_cv_broken_alias_attribute,
  1093. [cat > conftest.c <<EOF
  1094. extern int foo (int x) __asm ("xyzzy");
  1095. int bar (int x) { return x; }
  1096. extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
  1097. extern int dfoo;
  1098. extern __typeof (dfoo) dfoo __asm ("abccb");
  1099. int dfoo = 1;
  1100. EOF
  1101. libc_cv_broken_alias_attribute=yes
  1102. if AC_TRY_COMMAND(${CC-cc} -Werror -S conftest.c -o conftest.s 1>&AS_MESSAGE_LOG_FD); then
  1103. if grep 'xyzzy' conftest.s >/dev/null &&
  1104. grep 'abccb' conftest.s >/dev/null; then
  1105. libc_cv_broken_alias_attribute=no
  1106. fi
  1107. fi
  1108. rm -f conftest.c conftest.s
  1109. ])
  1110. if test $libc_cv_broken_alias_attribute = yes; then
  1111. AC_MSG_ERROR(working alias attribute support required)
  1112. fi
  1113. AC_CACHE_CHECK(whether to put _rtld_local into .sdata section,
  1114. libc_cv_have_sdata_section,
  1115. [echo "int i;" > conftest.c
  1116. libc_cv_have_sdata_section=no
  1117. if ${CC-cc} $LDFLAGS -fPIC -shared -Wl,--verbose conftest.c -o conftest.so 2>&1 \
  1118. | grep '\.sdata' >/dev/null; then
  1119. libc_cv_have_sdata_section=yes
  1120. fi
  1121. rm -f conftest.c conftest.so
  1122. ])
  1123. if test $libc_cv_have_sdata_section = yes; then
  1124. AC_DEFINE(HAVE_SDATA_SECTION)
  1125. fi
  1126. AC_CACHE_CHECK(whether to use .ctors/.dtors header and trailer,
  1127. libc_cv_ctors_header, [dnl
  1128. libc_cv_ctors_header=yes
  1129. LIBC_TRY_LINK_STATIC([
  1130. __attribute__ ((constructor)) void ctor (void) { asm (""); }
  1131. __attribute__ ((destructor)) void dtor (void) { asm (""); }
  1132. ],
  1133. [dnl
  1134. AS_IF([$READELF -WS conftest$ac_exeext | $AWK '
  1135. { gsub(/\@<:@ */, "@<:@") }
  1136. $2 == ".ctors" || $2 == ".dtors" {
  1137. size = strtonum("0x" $6)
  1138. align = strtonum("0x" $NF)
  1139. seen@<:@$2@:>@ = 1
  1140. stub@<:@$2@:>@ = size == align * 2
  1141. }
  1142. END {
  1143. ctors_ok = !seen@<:@".ctors"@:>@ || stub@<:@".ctors"@:>@
  1144. dtors_ok = !seen@<:@".dtors"@:>@ || stub@<:@".dtors"@:>@
  1145. exit ((ctors_ok && dtors_ok) ? 0 : 1)
  1146. }
  1147. '], [libc_cv_ctors_header=no])
  1148. ], [dnl
  1149. AC_MSG_ERROR([missing __attribute__ ((constructor)) support??])
  1150. ])
  1151. ])
  1152. if test $libc_cv_ctors_header = no; then
  1153. AC_DEFINE(NO_CTORS_DTORS_SECTIONS)
  1154. fi
  1155. AC_CACHE_CHECK(for libunwind-support in compiler,
  1156. libc_cv_cc_with_libunwind, [
  1157. cat > conftest.c <<EOF
  1158. int main (void) { return 0; }
  1159. EOF
  1160. if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static -o conftest \
  1161. conftest.c -v 2>&1 >/dev/null | grep ' -lunwind ' >/dev/null; then
  1162. libc_cv_cc_with_libunwind=yes
  1163. else
  1164. libc_cv_cc_with_libunwind=no
  1165. fi
  1166. rm -f conftest*])
  1167. AC_SUBST(libc_cv_cc_with_libunwind)
  1168. if test $libc_cv_cc_with_libunwind = yes; then
  1169. AC_DEFINE(HAVE_CC_WITH_LIBUNWIND)
  1170. fi
  1171. ASFLAGS_config=
  1172. AC_CACHE_CHECK(whether --noexecstack is desirable for .S files,
  1173. libc_cv_as_noexecstack, [dnl
  1174. cat > conftest.c <<EOF
  1175. void foo (void) { }
  1176. EOF
  1177. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS
  1178. -S -o conftest.s conftest.c 1>&AS_MESSAGE_LOG_FD]) \
  1179. && grep .note.GNU-stack conftest.s >/dev/null \
  1180. && AC_TRY_COMMAND([${CC-cc} $ASFLAGS -Wa,--noexecstack
  1181. -c -o conftest.o conftest.s 1>&AS_MESSAGE_LOG_FD])
  1182. then
  1183. libc_cv_as_noexecstack=yes
  1184. else
  1185. libc_cv_as_noexecstack=no
  1186. fi
  1187. rm -f conftest*])
  1188. if test $libc_cv_as_noexecstack = yes; then
  1189. ASFLAGS_config="$ASFLAGS_config -Wa,--noexecstack"
  1190. fi
  1191. AC_SUBST(ASFLAGS_config)
  1192. AC_CACHE_CHECK(for -z combreloc,
  1193. libc_cv_z_combreloc, [dnl
  1194. cat > conftest.c <<EOF
  1195. extern int bar (int);
  1196. extern int mumble;
  1197. int foo (void) { return bar (mumble); }
  1198. EOF
  1199. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
  1200. -fPIC -shared $no_ssp -o conftest.so conftest.c
  1201. -nostdlib -nostartfiles
  1202. -Wl,-z,combreloc 1>&AS_MESSAGE_LOG_FD])
  1203. then
  1204. dnl The following test is a bit weak. We must use a tool which can test
  1205. dnl cross-platform since the gcc used can be a cross compiler. Without
  1206. dnl introducing new options this is not easily doable. Instead use a tool
  1207. dnl which always is cross-platform: readelf. To detect whether -z combreloc
  1208. dnl look for a section named .rel.dyn or .rela.dyn.
  1209. if $READELF -S conftest.so | grep -E '.rela?.dyn' > /dev/null; then
  1210. libc_cv_z_combreloc=yes
  1211. else
  1212. libc_cv_z_combreloc=no
  1213. fi
  1214. else
  1215. libc_cv_z_combreloc=no
  1216. fi
  1217. rm -f conftest*])
  1218. if test "$libc_cv_z_combreloc" = yes; then
  1219. AC_DEFINE(HAVE_Z_COMBRELOC)
  1220. fi
  1221. AC_SUBST(libc_cv_z_combreloc)
  1222. LIBC_LINKER_FEATURE([-z execstack], [-Wl,-z,execstack],
  1223. [libc_cv_z_execstack=yes], [libc_cv_z_execstack=no])
  1224. AC_SUBST(libc_cv_z_execstack)
  1225. LIBC_LINKER_FEATURE([--no-dynamic-linker],
  1226. [-Wl,--no-dynamic-linker],
  1227. [libc_cv_no_dynamic_linker=yes],
  1228. [libc_cv_no_dynamic_linker=no])
  1229. LIBC_CONFIG_VAR([have-no-dynamic-linker], [$libc_cv_no_dynamic_linker])
  1230. AC_CACHE_CHECK(for -static-pie, libc_cv_static_pie, [dnl
  1231. LIBC_TRY_CC_OPTION([-static-pie],
  1232. [libc_cv_static_pie=yes],
  1233. [libc_cv_static_pie=no])
  1234. ])
  1235. LIBC_CONFIG_VAR([have-static-pie], [$libc_cv_static_pie])
  1236. AC_CACHE_CHECK(for -fpie, libc_cv_fpie, [dnl
  1237. LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
  1238. ])
  1239. AC_SUBST(libc_cv_fpie)
  1240. AC_CACHE_CHECK(for --hash-style option,
  1241. libc_cv_hashstyle, [dnl
  1242. cat > conftest.c <<EOF
  1243. int _start (void) { return 42; }
  1244. EOF
  1245. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
  1246. -fPIC -shared -o conftest.so conftest.c
  1247. -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
  1248. then
  1249. libc_cv_hashstyle=yes
  1250. else
  1251. libc_cv_hashstyle=no
  1252. fi
  1253. rm -f conftest*])
  1254. AC_SUBST(libc_cv_hashstyle)
  1255. # The linker's default -shared behavior is good enough if it
  1256. # does these things that our custom linker scripts ensure that
  1257. # all allocated NOTE sections come first.
  1258. if test "$use_default_link" = default; then
  1259. AC_CACHE_CHECK([for sufficient default -shared layout],
  1260. libc_cv_use_default_link, [dnl
  1261. libc_cv_use_default_link=no
  1262. cat > conftest.s <<\EOF
  1263. .section .note.a,"a",%note
  1264. .balign 4
  1265. .long 4,4,9
  1266. .string "GNU"
  1267. .string "foo"
  1268. .section .note.b,"a",%note
  1269. .balign 4
  1270. .long 4,4,9
  1271. .string "GNU"
  1272. .string "bar"
  1273. EOF
  1274. if AC_TRY_COMMAND([dnl
  1275. ${CC-cc} $ASFLAGS -shared -o conftest.so conftest.s 1>&AS_MESSAGE_LOG_FD]) &&
  1276. ac_try=`$READELF -S conftest.so | sed -n \
  1277. ['${x;p;}
  1278. s/^ *\[ *[1-9][0-9]*\] *\([^ ][^ ]*\) *\([^ ][^ ]*\) .*$/\2 \1/
  1279. t a
  1280. b
  1281. : a
  1282. H']`
  1283. then
  1284. libc_seen_a=no libc_seen_b=no
  1285. set -- $ac_try
  1286. while test $# -ge 2 -a "$1" = NOTE; do
  1287. case "$2" in
  1288. .note.a) libc_seen_a=yes ;;
  1289. .note.b) libc_seen_b=yes ;;
  1290. esac
  1291. shift 2
  1292. done
  1293. case "$libc_seen_a$libc_seen_b" in
  1294. yesyes)
  1295. libc_cv_use_default_link=yes
  1296. ;;
  1297. *)
  1298. echo >&AS_MESSAGE_LOG_FD "\
  1299. $libc_seen_a$libc_seen_b from:
  1300. $ac_try"
  1301. ;;
  1302. esac
  1303. fi
  1304. rm -f conftest*])
  1305. use_default_link=$libc_cv_use_default_link
  1306. fi
  1307. AC_CACHE_CHECK(for GLOB_DAT reloc,
  1308. libc_cv_has_glob_dat, [dnl
  1309. cat > conftest.c <<EOF
  1310. extern int mumble;
  1311. int foo (void) { return mumble; }
  1312. EOF
  1313. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS
  1314. -fPIC -shared -o conftest.so conftest.c
  1315. -nostdlib -nostartfiles $no_ssp
  1316. 1>&AS_MESSAGE_LOG_FD])
  1317. then
  1318. dnl look for GLOB_DAT relocation.
  1319. if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then
  1320. libc_cv_has_glob_dat=yes
  1321. else
  1322. libc_cv_has_glob_dat=no
  1323. fi
  1324. else
  1325. libc_cv_has_glob_dat=no
  1326. fi
  1327. rm -f conftest*])
  1328. AC_SUBST(libc_cv_has_glob_dat)
  1329. AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
  1330. if libc_cv_output_format=`
  1331. ${CC-cc} -nostartfiles -nostdlib $no_ssp -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
  1332. then
  1333. :
  1334. else
  1335. libc_cv_output_format=
  1336. fi
  1337. test -n "$libc_cv_output_format" || libc_cv_output_format=unknown])
  1338. AC_SUBST(libc_cv_output_format)
  1339. AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
  1340. cat > conftest.c <<EOF
  1341. int foo;
  1342. EOF
  1343. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
  1344. conftest.c 1>&AS_MESSAGE_LOG_FD])
  1345. then
  1346. libc_cv_fno_toplevel_reorder=yes
  1347. else
  1348. libc_cv_fno_toplevel_reorder=no
  1349. fi
  1350. rm -f conftest*])
  1351. if test $libc_cv_fno_toplevel_reorder = yes; then
  1352. fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
  1353. else
  1354. fno_unit_at_a_time=-fno-unit-at-a-time
  1355. fi
  1356. AC_SUBST(fno_unit_at_a_time)
  1357. AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
  1358. [dnl
  1359. cat > conftest.c <<EOF
  1360. __thread int i;
  1361. void foo (void)
  1362. {
  1363. i = 10;
  1364. }
  1365. EOF
  1366. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fPIC -mtls-dialect=gnu2
  1367. conftest.c 1>&AS_MESSAGE_LOG_FD])
  1368. then
  1369. libc_cv_mtls_dialect_gnu2=yes
  1370. else
  1371. libc_cv_mtls_dialect_gnu2=no
  1372. fi
  1373. rm -f conftest*])
  1374. AC_SUBST(libc_cv_mtls_dialect_gnu2)
  1375. LIBC_CONFIG_VAR([have-mtls-dialect-gnu2], [$libc_cv_mtls_dialect_gnu2])
  1376. AC_CACHE_CHECK(whether cc puts quotes around section names,
  1377. libc_cv_have_section_quotes,
  1378. [cat > conftest.c <<EOF
  1379. static const int foo
  1380. __attribute__ ((section ("bar"))) = 1;
  1381. EOF
  1382. if ${CC-cc} -S conftest.c -o conftest.s; then
  1383. if grep '\.section.*"bar"' conftest.s >/dev/null; then
  1384. libc_cv_have_section_quotes=yes
  1385. else
  1386. libc_cv_have_section_quotes=no
  1387. fi
  1388. else
  1389. libc_cv_have_section_quotes=unknown
  1390. fi
  1391. rm -f conftest.{c,s}
  1392. ])
  1393. if test $libc_cv_have_section_quotes = yes; then
  1394. AC_DEFINE(HAVE_SECTION_QUOTES)
  1395. fi
  1396. AC_CACHE_CHECK(for __builtin_memset, libc_cv_gcc_builtin_memset, [dnl
  1397. cat > conftest.c <<\EOF
  1398. void zero (void *x)
  1399. {
  1400. __builtin_memset (x, 0, 1000);
  1401. }
  1402. EOF
  1403. dnl
  1404. if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "memset" > /dev/null]);
  1405. then
  1406. libc_cv_gcc_builtin_memset=no
  1407. else
  1408. libc_cv_gcc_builtin_memset=yes
  1409. fi
  1410. rm -f conftest* ])
  1411. if test "$libc_cv_gcc_builtin_memset" = yes ; then
  1412. AC_DEFINE(HAVE_BUILTIN_MEMSET)
  1413. fi
  1414. AC_CACHE_CHECK(for redirection of built-in functions, libc_cv_gcc_builtin_redirection, [dnl
  1415. cat > conftest.c <<\EOF
  1416. extern char *strstr (const char *, const char *) __asm ("my_strstr");
  1417. char *foo (const char *a, const char *b)
  1418. {
  1419. return __builtin_strstr (a, b);
  1420. }
  1421. EOF
  1422. dnl
  1423. if AC_TRY_COMMAND([${CC-cc} -O3 -S conftest.c -o - | grep -F "my_strstr" > /dev/null]);
  1424. then
  1425. libc_cv_gcc_builtin_redirection=yes
  1426. else
  1427. libc_cv_gcc_builtin_redirection=no
  1428. fi
  1429. rm -f conftest* ])
  1430. if test "$libc_cv_gcc_builtin_redirection" = no; then
  1431. AC_MSG_ERROR([support for the symbol redirection needed])
  1432. fi
  1433. dnl Determine how to disable generation of FMA instructions.
  1434. AC_CACHE_CHECK([for compiler option to disable generation of FMA instructions],
  1435. libc_cv_cc_nofma, [dnl
  1436. libc_cv_cc_nofma=
  1437. for opt in -ffp-contract=off -mno-fused-madd; do
  1438. LIBC_TRY_CC_OPTION([$opt], [libc_cv_cc_nofma=$opt; break])
  1439. done])
  1440. AC_SUBST(libc_cv_cc_nofma)
  1441. if test -n "$submachine"; then
  1442. AC_CACHE_CHECK([for compiler option for CPU variant],
  1443. libc_cv_cc_submachine, [dnl
  1444. libc_cv_cc_submachine=no
  1445. for opt in "-march=$submachine" "-mcpu=$submachine"; do
  1446. LIBC_TRY_CC_OPTION([$opt], [
  1447. libc_cv_cc_submachine="$opt"
  1448. break], [])
  1449. done])
  1450. if test "x$libc_cv_cc_submachine" = xno; then
  1451. AC_MSG_ERROR([${CC-cc} does not support $submachine])
  1452. fi
  1453. fi
  1454. AC_SUBST(libc_cv_cc_submachine)
  1455. AC_CACHE_CHECK(if $CC accepts -fno-tree-loop-distribute-patterns with \
  1456. __attribute__ ((__optimize__)), libc_cv_cc_loop_to_function, [dnl
  1457. cat > conftest.c <<EOF
  1458. void
  1459. __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
  1460. foo (void) {}
  1461. EOF
  1462. libc_cv_cc_loop_to_function=no
  1463. if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c])
  1464. then
  1465. libc_cv_cc_loop_to_function=yes
  1466. fi
  1467. rm -f conftest*])
  1468. if test $libc_cv_cc_loop_to_function = yes; then
  1469. AC_DEFINE(HAVE_CC_INHIBIT_LOOP_TO_LIBCALL)
  1470. fi
  1471. AC_SUBST(libc_cv_cc_loop_to_function)
  1472. dnl Check whether we have the gd library available.
  1473. AC_MSG_CHECKING(for libgd)
  1474. if test "$with_gd" != "no"; then
  1475. old_CFLAGS="$CFLAGS"
  1476. CFLAGS="$CFLAGS $libgd_include"
  1477. old_LDFLAGS="$LDFLAGS"
  1478. LDFLAGS="$LDFLAGS $libgd_ldflags"
  1479. old_LIBS="$LIBS"
  1480. LIBS="$LIBS -lgd -lpng -lz -lm"
  1481. AC_TRY_LINK([#include <gd.h>], [gdImagePng (0, 0)], LIBGD=yes, LIBGD=no)
  1482. CFLAGS="$old_CFLAGS"
  1483. LDFLAGS="$old_LDFLAGS"
  1484. LIBS="$old_LIBS"
  1485. else
  1486. LIBGD=no
  1487. fi
  1488. AC_MSG_RESULT($LIBGD)
  1489. AC_SUBST(LIBGD)
  1490. # SELinux detection
  1491. if test x$with_selinux = xno ; then
  1492. have_selinux=no;
  1493. else
  1494. # See if we have the SELinux library
  1495. AC_CHECK_LIB(selinux, is_selinux_enabled,
  1496. have_selinux=yes, have_selinux=no)
  1497. if test x$with_selinux = xyes ; then
  1498. if test x$have_selinux = xno ; then
  1499. AC_MSG_ERROR([SELinux explicitly required, but SELinux library not found])
  1500. fi
  1501. fi
  1502. fi
  1503. # Check if we're building with SELinux support.
  1504. if test "x$have_selinux" = xyes; then
  1505. AC_DEFINE(HAVE_SELINUX, 1, [SELinux support])
  1506. # See if we have the libaudit library
  1507. AC_CHECK_LIB(audit, audit_log_user_avc_message,
  1508. have_libaudit=yes, have_libaudit=no)
  1509. if test "x$have_libaudit" = xyes; then
  1510. AC_DEFINE(HAVE_LIBAUDIT, 1, [SELinux libaudit support])
  1511. fi
  1512. AC_SUBST(have_libaudit)
  1513. # See if we have the libcap library
  1514. AC_CHECK_LIB(cap, cap_init, have_libcap=yes, have_libcap=no)
  1515. if test "x$have_libcap" = xyes; then
  1516. AC_DEFINE(HAVE_LIBCAP, 1, [SELinux libcap support])
  1517. fi
  1518. AC_SUBST(have_libcap)
  1519. fi
  1520. AC_SUBST(have_selinux)
  1521. CPPUNDEFS=
  1522. dnl Check for silly hacked compilers predefining _FORTIFY_SOURCE.
  1523. dnl Since we are building the implementations of the fortified functions here,
  1524. dnl having the macro defined interacts very badly.
  1525. AC_CACHE_CHECK([for _FORTIFY_SOURCE predefine], libc_cv_predef_fortify_source,
  1526. [AC_TRY_COMPILE([], [
  1527. #ifdef _FORTIFY_SOURCE
  1528. # error bogon
  1529. #endif],
  1530. [libc_cv_predef_fortify_source=no],
  1531. [libc_cv_predef_fortify_source=yes])])
  1532. if test $libc_cv_predef_fortify_source = yes; then
  1533. CPPUNDEFS="${CPPUNDEFS:+$CPPUNDEFS }-U_FORTIFY_SOURCE"
  1534. fi
  1535. AC_SUBST(CPPUNDEFS)
  1536. # Some linkers on some architectures support __ehdr_start but with
  1537. # bugs. Make sure usage of it does not create relocations in the
  1538. # output (as the linker should resolve them all for us).
  1539. AC_CACHE_CHECK([whether the linker provides working __ehdr_start],
  1540. libc_cv_ehdr_start, [
  1541. old_CFLAGS="$CFLAGS"
  1542. old_LDFLAGS="$LDFLAGS"
  1543. old_LIBS="$LIBS"
  1544. CFLAGS="$CFLAGS -fPIC"
  1545. LDFLAGS="$LDFLAGS -nostdlib -nostartfiles -shared $no_ssp"
  1546. LIBS=
  1547. AC_LINK_IFELSE([AC_LANG_SOURCE([
  1548. typedef struct {
  1549. char foo;
  1550. long val;
  1551. } Ehdr;
  1552. extern const Ehdr __ehdr_start __attribute__ ((visibility ("hidden")));
  1553. long ehdr (void) { return __ehdr_start.val; }
  1554. ])],
  1555. [if $READELF -r conftest | grep -F __ehdr_start >/dev/null; then
  1556. libc_cv_ehdr_start=broken
  1557. else
  1558. libc_cv_ehdr_start=yes
  1559. fi], [libc_cv_ehdr_start=no])
  1560. CFLAGS="$old_CFLAGS"
  1561. LDFLAGS="$old_LDFLAGS"
  1562. LIBS="$old_LIBS"
  1563. ])
  1564. if test "$libc_cv_ehdr_start" = yes; then
  1565. AC_DEFINE([HAVE_EHDR_START])
  1566. elif test "$libc_cv_ehdr_start" = broken; then
  1567. AC_MSG_WARN([linker is broken -- you should upgrade])
  1568. fi
  1569. AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
  1570. libc_cv_builtin_trap, [dnl
  1571. libc_cv_builtin_trap=no
  1572. AC_TRY_COMPILE([], [__builtin_trap ()], [
  1573. libc_undefs=`$NM -u conftest.o |
  1574. LC_ALL=C $AWK '$1 == "U" { print $2 | "sort -u"; next } { exit(1) }' \
  1575. 2>&AS_MESSAGE_LOG_FD` || {
  1576. AC_MSG_ERROR([confusing output from $NM -u])
  1577. }
  1578. echo >&AS_MESSAGE_LOG_FD "libc_undefs='$libc_undefs'"
  1579. if test -z "$libc_undefs"; then
  1580. libc_cv_builtin_trap=yes
  1581. fi])])
  1582. if test $libc_cv_builtin_trap = yes; then
  1583. AC_DEFINE([HAVE_BUILTIN_TRAP])
  1584. fi
  1585. dnl C++ feature tests.
  1586. AC_LANG_PUSH([C++])
  1587. AC_CACHE_CHECK([whether the C++ compiler supports thread_local],
  1588. libc_cv_cxx_thread_local, [
  1589. old_CXXFLAGS="$CXXFLAGS"
  1590. CXXFLAGS="$CXXFLAGS -std=gnu++11"
  1591. AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  1592. #include <thread>
  1593. // Compiler support.
  1594. struct S
  1595. {
  1596. S ();
  1597. ~S ();
  1598. };
  1599. thread_local S s;
  1600. S * get () { return &s; }
  1601. // libstdc++ support.
  1602. #ifndef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
  1603. #error __cxa_thread_atexit_impl not supported
  1604. #endif
  1605. ])],
  1606. [libc_cv_cxx_thread_local=yes],
  1607. [libc_cv_cxx_thread_local=no])
  1608. CXXFLAGS="$old_CXXFLAGS"
  1609. ])
  1610. AC_SUBST(libc_cv_cxx_thread_local)
  1611. AC_LANG_POP([C++])
  1612. dnl End of C++ feature tests.
  1613. ### End of automated tests.
  1614. ### Now run sysdeps configure fragments.
  1615. # They also can set these variables.
  1616. use_ldconfig=no
  1617. ldd_rewrite_script=no
  1618. libc_cv_sysconfdir=$sysconfdir
  1619. libc_cv_localstatedir=$localstatedir
  1620. libc_cv_gcc_unwind_find_fde=no
  1621. libc_cv_idn=no
  1622. # Iterate over all the sysdep directories we will use, running their
  1623. # configure fragments.
  1624. for dir in $sysnames; do
  1625. case $dir in
  1626. /*) dest=$dir ;;
  1627. *) dest=$srcdir/$dir ;;
  1628. esac
  1629. if test -r $dest/configure; then
  1630. AC_MSG_RESULT(running configure fragment for $dir)
  1631. . $dest/configure
  1632. fi
  1633. done
  1634. if test x"$build_mathvec" = xnotset; then
  1635. build_mathvec=no
  1636. fi
  1637. LIBC_CONFIG_VAR([build-mathvec], [$build_mathvec])
  1638. AC_SUBST(libc_extra_cflags)
  1639. AC_SUBST(libc_extra_cppflags)
  1640. if test x$libc_cv_gcc_unwind_find_fde = xyes; then
  1641. AC_DEFINE(EXPORT_UNWIND_FIND_FDE)
  1642. fi
  1643. AC_SUBST(libc_cv_gcc_unwind_find_fde)
  1644. # A sysdeps configure fragment can reset this if IFUNC is not actually
  1645. # usable even though the assembler knows how to generate the symbol type.
  1646. if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
  1647. AC_DEFINE(HAVE_IFUNC)
  1648. fi
  1649. if test x"$libc_cv_gcc_indirect_function" = xyes; then
  1650. AC_DEFINE(HAVE_GCC_IFUNC)
  1651. fi
  1652. # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps
  1653. # configure fragment can override the value to prevent this AC_DEFINE.
  1654. AC_SUBST(use_nscd)
  1655. if test "x$use_nscd" != xno; then
  1656. AC_DEFINE([USE_NSCD])
  1657. fi
  1658. if test "x$build_nscd" = xdefault; then
  1659. build_nscd=$use_nscd
  1660. fi
  1661. AC_SUBST(libc_cv_slibdir)
  1662. AC_SUBST(libc_cv_rtlddir)
  1663. AC_SUBST(libc_cv_complocaledir)
  1664. AC_SUBST(libc_cv_sysconfdir)
  1665. AC_SUBST(libc_cv_localstatedir)
  1666. AC_SUBST(libc_cv_rootsbindir)
  1667. if test x$use_ldconfig = xyes; then
  1668. AC_DEFINE(USE_LDCONFIG)
  1669. fi
  1670. AC_SUBST(use_ldconfig)
  1671. AC_SUBST(ldd_rewrite_script)
  1672. AC_SUBST(static)
  1673. AC_SUBST(shared)
  1674. AC_CACHE_CHECK([whether -fPIC is default], libc_cv_pic_default,
  1675. [libc_cv_pic_default=yes
  1676. cat > conftest.c <<EOF
  1677. #if defined __PIC__ || defined __pic__ || defined PIC || defined pic
  1678. # error PIC is default.
  1679. #endif
  1680. EOF
  1681. if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
  1682. libc_cv_pic_default=no
  1683. fi
  1684. rm -f conftest.*])
  1685. AC_SUBST(libc_cv_pic_default)
  1686. AC_CACHE_CHECK([whether -fPIE is default], libc_cv_cc_pie_default,
  1687. [libc_cv_cc_pie_default=yes
  1688. cat > conftest.c <<EOF
  1689. #if defined __PIE__ || defined __pie__ || defined PIE || defined pie
  1690. # error PIE is default.
  1691. #endif
  1692. EOF
  1693. if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
  1694. libc_cv_cc_pie_default=no
  1695. fi
  1696. rm -f conftest.*])
  1697. libc_cv_pie_default=$libc_cv_cc_pie_default
  1698. AC_SUBST(libc_cv_cc_pie_default)
  1699. AC_SUBST(libc_cv_pie_default)
  1700. # Set the `multidir' variable by grabbing the variable from the compiler.
  1701. # We do it once and save the result in a generated makefile.
  1702. libc_cv_multidir=`${CC-cc} $CFLAGS $CPPFLAGS -print-multi-directory`
  1703. AC_SUBST(libc_cv_multidir)
  1704. if test "$static_pie" = yes; then
  1705. # The linker must support --no-dynamic-linker.
  1706. if test "$libc_cv_no_dynamic_linker" != yes; then
  1707. AC_MSG_ERROR([linker support for --no-dynamic-linker needed])
  1708. fi
  1709. # Default to PIE.
  1710. libc_cv_pie_default=yes
  1711. AC_DEFINE(ENABLE_STATIC_PIE)
  1712. fi
  1713. LIBC_CONFIG_VAR([enable-static-pie], [$static_pie])
  1714. AC_SUBST(profile)
  1715. AC_SUBST(static_nss)
  1716. AC_SUBST(DEFINES)
  1717. dnl See sysdeps/mach/configure.ac for this variable.
  1718. AC_SUBST(mach_interface_list)
  1719. VERSION=`sed -n -e 's/^#define VERSION "\([^"]*\)"/\1/p' < $srcdir/version.h`
  1720. RELEASE=`sed -n -e 's/^#define RELEASE "\([^"]*\)"/\1/p' < $srcdir/version.h`
  1721. AC_SUBST(VERSION)
  1722. AC_SUBST(RELEASE)
  1723. AC_CONFIG_FILES([config.make Makefile])
  1724. AC_CONFIG_COMMANDS([default],[[
  1725. case $CONFIG_FILES in *config.make*)
  1726. echo "$config_vars" >> config.make;;
  1727. esac
  1728. test -d bits || mkdir bits]],[[config_vars='$config_vars']])
  1729. AC_OUTPUT