configure.ac 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. dnl Process this file with autoconf to produce a configure script
  2. AC_INIT
  3. AC_CONFIG_SRCDIR([xmalloc.c])
  4. # This works around the fact that libtool configuration may change LD
  5. # for this particular configuration, but some shells, instead of
  6. # keeping the changes in LD private, export them just because LD is
  7. # exported. We don't use libtool yet, but some day we might, so...
  8. ORIGINAL_LD_FOR_MULTILIBS=$LD
  9. dnl We use these options to decide which functions to include.
  10. AC_ARG_WITH(target-subdir,
  11. [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
  12. AC_ARG_WITH(build-subdir,
  13. [ --with-build-subdir=SUBDIR Configuring in a subdirectory for build])
  14. AC_ARG_WITH(cross-host,
  15. [ --with-cross-host=HOST Configuring with a cross compiler])
  16. AC_ARG_WITH(newlib,
  17. [ --with-newlib Configuring with newlib])
  18. if test "${srcdir}" = "."; then
  19. if test -n "${with_build_subdir}"; then
  20. libiberty_topdir="${srcdir}/../.."
  21. with_target_subdir=
  22. elif test -z "${with_target_subdir}"; then
  23. libiberty_topdir="${srcdir}/.."
  24. else
  25. if test "${with_target_subdir}" != "."; then
  26. libiberty_topdir="${srcdir}/${with_multisrctop}../.."
  27. else
  28. libiberty_topdir="${srcdir}/${with_multisrctop}.."
  29. fi
  30. fi
  31. else
  32. libiberty_topdir="${srcdir}/.."
  33. fi
  34. AC_SUBST(libiberty_topdir)
  35. AC_CONFIG_AUX_DIR($libiberty_topdir)
  36. dnl Very limited version of automake's enable-maintainer-mode
  37. AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
  38. dnl maintainer-mode is disabled by default
  39. AC_ARG_ENABLE(maintainer-mode,
  40. [ --enable-maintainer-mode
  41. enable make rules and dependencies not useful
  42. (and sometimes confusing) to the casual installer],
  43. maintainer_mode=$enableval,
  44. maintainer_mode=no)
  45. AC_MSG_RESULT($maintainer_mode)
  46. if test "$maintainer_mode" = "yes"; then
  47. MAINT=''
  48. NOTMAINT='#'
  49. else
  50. MAINT='#'
  51. NOTMAINT=''
  52. fi
  53. AC_SUBST(MAINT)dnl
  54. AC_SUBST(NOTMAINT)dnl
  55. if test -z "$ETAGS"; then
  56. ETAGS=etags
  57. fi
  58. AC_SUBST([ETAGS])
  59. # Do we have a single-tree copy of texinfo? Even if we do, we can't
  60. # rely on it - libiberty is built before texinfo.
  61. AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
  62. if test "x$MAKEINFO" = "x"; then
  63. MAKEINFO="@echo makeinfo missing; true"
  64. BUILD_INFO=
  65. else
  66. BUILD_INFO=info
  67. case "$MAKEINFO" in
  68. */missing\ makeinfo*)
  69. BUILD_INFO=
  70. AC_MSG_WARN([
  71. *** Makeinfo is missing. Info documentation will not be built.])
  72. ;;
  73. *)
  74. case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
  75. x*\ [[1-3]].* )
  76. MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
  77. BUILD_INFO=
  78. AC_MSG_WARN([
  79. *** Makeinfo is too old. Info documentation will not be built.])
  80. ;;
  81. esac
  82. ;;
  83. esac
  84. fi
  85. AC_SUBST(MAKEINFO)
  86. AC_SUBST(BUILD_INFO)
  87. AC_CHECK_PROG(PERL, perl, perl, )
  88. if test x"$PERL" = x""; then
  89. HAVE_PERL='#'
  90. else
  91. HAVE_PERL=''
  92. fi
  93. AC_SUBST(HAVE_PERL)
  94. AC_CANONICAL_HOST
  95. dnl When we start using automake:
  96. dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
  97. dnl These must be called before AM_PROG_LIBTOOL, because it may want
  98. dnl to call AC_CHECK_PROG.
  99. AC_CHECK_TOOL(AR, ar)
  100. AC_CHECK_TOOL(RANLIB, ranlib, :)
  101. dnl When switching to automake, replace the following with AM_ENABLE_MULTILIB.
  102. # Add --enable-multilib to configure.
  103. # Default to --enable-multilib
  104. AC_ARG_ENABLE(multilib,
  105. [ --enable-multilib build many library versions (default)],
  106. [case "$enableval" in
  107. yes) multilib=yes ;;
  108. no) multilib=no ;;
  109. *) AC_MSG_ERROR([bad value $enableval for multilib option]) ;;
  110. esac],
  111. [multilib=yes])
  112. # Even if the default multilib is not a cross compilation,
  113. # it may be that some of the other multilibs are.
  114. if test $cross_compiling = no && test $multilib = yes \
  115. && test "x${with_multisubdir}" != x ; then
  116. cross_compiling=maybe
  117. fi
  118. # We may wish to install the target headers somewhere.
  119. AC_MSG_CHECKING([whether to install libiberty headers and static library])
  120. dnl install-libiberty is disabled by default
  121. AC_ARG_ENABLE(install-libiberty,
  122. [ --enable-install-libiberty Install headers and library for end users],
  123. enable_install_libiberty=$enableval,
  124. enable_install_libiberty=no)dnl
  125. # Option parsed, now set things appropriately.
  126. case x"$enable_install_libiberty" in
  127. xyes|x)
  128. target_header_dir=libiberty
  129. ;;
  130. xno)
  131. target_header_dir=
  132. ;;
  133. *)
  134. # This could be sanity-checked in various ways...
  135. target_header_dir="${enable_install_libiberty}"
  136. ;;
  137. esac
  138. AC_MSG_RESULT($enable_install_libiberty)
  139. AC_MSG_NOTICE([target_header_dir = $target_header_dir])
  140. GCC_NO_EXECUTABLES
  141. AC_PROG_CC
  142. AC_GNU_SOURCE
  143. AC_SYS_LARGEFILE
  144. AC_PROG_CPP_WERROR
  145. ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wc++-compat \
  146. -Wstrict-prototypes \
  147. -Wshadow=local], [ac_libiberty_warn_cflags])
  148. ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([], [ac_libiberty_warn_cflags])
  149. AC_PROG_CC_C_O
  150. # autoconf is lame and doesn't give us any substitution variable for this.
  151. if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
  152. NO_MINUS_C_MINUS_O=yes
  153. else
  154. OUTPUT_OPTION='-o $@'
  155. fi
  156. AC_SUBST(NO_MINUS_C_MINUS_O)
  157. AC_SUBST(OUTPUT_OPTION)
  158. AC_C_CONST
  159. AC_C_INLINE
  160. AC_C_BIGENDIAN
  161. dnl When we start using libtool:
  162. dnl Default to a non shared library. This may be overridden by the
  163. dnl configure option --enable-shared.
  164. dnl AM_DISABLE_SHARED
  165. dnl When we start using libtool:
  166. dnl AM_PROG_LIBTOOL
  167. dnl When we start using automake:
  168. dnl AM_CONFIG_HEADER(config.h:config.in)
  169. AC_CONFIG_HEADER(config.h:config.in)
  170. dnl When we start using automake:
  171. dnl AM_MAINTAINER_MODE
  172. dnl AC_EXEEXT
  173. dnl When we start using automake:
  174. dnl AM_PROG_INSTALL
  175. AC_PROG_INSTALL
  176. # Don't build the shared library for build.
  177. if [[ -n "${with_build_subdir}" ]]; then
  178. enable_shared=no
  179. fi
  180. frag=
  181. case "${host}" in
  182. rs6000-ibm-aix3.1 | rs6000-ibm-aix)
  183. frag=mh-aix ;;
  184. *-*-cxux7*) frag=mh-cxux7 ;;
  185. *-*-freebsd2.1.*) frag=mh-fbsd21 ;;
  186. *-*-freebsd2.2.[[012]]) frag=mh-fbsd21 ;;
  187. i370-*-opened*) frag=mh-openedition ;;
  188. i[[34567]]86-*-windows*) frag=mh-windows ;;
  189. esac
  190. if [[ -n "${frag}" ]]; then
  191. frag=${libiberty_topdir}/libiberty/config/$frag
  192. fi
  193. GCC_PICFLAG
  194. # If they didn't specify --enable-shared, don't generate shared libs.
  195. case "${enable_shared}" in
  196. yes) shared=yes ;;
  197. no) shared=no ;;
  198. "") shared=no ;;
  199. *) shared=yes ;;
  200. esac
  201. # ...unless --enable-host-shared was passed from top-level config:
  202. if [[ "${enable_host_shared}" = "yes" ]]; then
  203. shared=yes
  204. fi
  205. if [[ "${shared}" != "yes" ]]; then
  206. PICFLAG=
  207. fi
  208. AC_SUBST(PICFLAG)
  209. NOASANFLAG=
  210. case " ${CFLAGS} " in
  211. *\ -fsanitize=address\ *) NOASANFLAG=-fno-sanitize=address ;;
  212. *\ -fsanitize=hwaddress\ *) NOASANFLAG=-fno-sanitize=hwaddress ;;
  213. esac
  214. AC_SUBST(NOASANFLAG)
  215. GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
  216. AC_SUBST(CET_HOST_FLAGS)
  217. echo "# Warning: this fragment is automatically generated" > temp-frag
  218. if [[ -n "${frag}" ]] && [[ -f "${frag}" ]]; then
  219. echo "Appending ${frag} to xhost-mkfrag"
  220. echo "# Following fragment copied from ${frag}" >> temp-frag
  221. cat ${frag} >> temp-frag
  222. fi
  223. # record if we want to build shared libs.
  224. if [[ "${shared}" = "yes" ]]; then
  225. echo enable_shared = yes >> temp-frag
  226. else
  227. echo enable_shared = no >> temp-frag
  228. fi
  229. frag=xhost-mkfrag
  230. ${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
  231. host_makefile_frag=${frag}
  232. AC_SUBST_FILE(host_makefile_frag)
  233. # It's OK to check for header files. Although the compiler may not be
  234. # able to link anything, it had better be able to at least compile
  235. # something.
  236. AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h stdint.h stdio_ext.h process.h sys/prctl.h)
  237. AC_HEADER_SYS_WAIT
  238. AC_HEADER_TIME
  239. libiberty_AC_DECLARE_ERRNO
  240. # Determine sizes of some types.
  241. AC_CHECK_SIZEOF([int])
  242. AC_CHECK_SIZEOF([long])
  243. AC_CHECK_SIZEOF([size_t])
  244. # Check for presense of long long
  245. AC_CHECK_TYPE([long long],
  246. [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if you have the `long long' type.]) AC_CHECK_SIZEOF([long long])],
  247. [])
  248. # Look for a 64-bit type.
  249. AC_MSG_CHECKING([for a 64-bit type])
  250. AC_CACHE_VAL(liberty_cv_uint64,
  251. [AC_TRY_COMPILE(
  252. [#ifdef HAVE_STDINT_H
  253. #include <stdint.h>
  254. #endif],
  255. [extern uint64_t foo;],
  256. liberty_cv_uint64=uint64_t,
  257. [AC_TRY_COMPILE(
  258. [#ifdef HAVE_LIMITS_H
  259. #include <limits.h>
  260. #endif
  261. #ifndef CHAR_BIT
  262. #define CHAR_BIT 8
  263. #endif],
  264. [extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];],
  265. liberty_cv_uint64="unsigned long",
  266. [AC_TRY_COMPILE(
  267. [#ifdef HAVE_LIMITS_H
  268. #include <limits.h>
  269. #endif
  270. #ifndef CHAR_BIT
  271. #define CHAR_BIT 8
  272. #endif],
  273. [extern char foo[sizeof(long long) * CHAR_BIT >= 64 ? 1 : -1];],
  274. liberty_cv_uint64="unsigned long long", liberty_cv_uint64=none)])])])
  275. AC_MSG_RESULT($liberty_cv_uint64)
  276. if test "$liberty_cv_uint64" != none; then
  277. AC_DEFINE_UNQUOTED(UNSIGNED_64BIT_TYPE, $liberty_cv_uint64,
  278. [Define to an unsigned 64-bit type available in the compiler.])
  279. fi
  280. AC_TYPE_INTPTR_T
  281. AC_TYPE_UINTPTR_T
  282. AC_TYPE_SSIZE_T
  283. # Given the above check, we always have uintptr_t or a fallback
  284. # definition. So define HAVE_UINTPTR_T in case any imported code
  285. # relies on it.
  286. AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
  287. AC_TYPE_PID_T
  288. # This is the list of functions which libiberty will provide if they
  289. # are not available on the host.
  290. funcs="asprintf"
  291. funcs="$funcs atexit"
  292. funcs="$funcs basename"
  293. funcs="$funcs bcmp"
  294. funcs="$funcs bcopy"
  295. funcs="$funcs bsearch"
  296. funcs="$funcs bzero"
  297. funcs="$funcs calloc"
  298. funcs="$funcs clock"
  299. funcs="$funcs ffs"
  300. funcs="$funcs getcwd"
  301. funcs="$funcs getpagesize"
  302. funcs="$funcs gettimeofday"
  303. funcs="$funcs index"
  304. funcs="$funcs insque"
  305. funcs="$funcs memchr"
  306. funcs="$funcs memcmp"
  307. funcs="$funcs memcpy"
  308. funcs="$funcs memmem"
  309. funcs="$funcs memmove"
  310. funcs="$funcs mempcpy"
  311. funcs="$funcs memset"
  312. funcs="$funcs mkstemps"
  313. funcs="$funcs putenv"
  314. funcs="$funcs random"
  315. funcs="$funcs rename"
  316. funcs="$funcs rindex"
  317. funcs="$funcs setenv"
  318. funcs="$funcs snprintf"
  319. funcs="$funcs sigsetmask"
  320. funcs="$funcs stpcpy"
  321. funcs="$funcs stpncpy"
  322. funcs="$funcs strcasecmp"
  323. funcs="$funcs strchr"
  324. funcs="$funcs strdup"
  325. funcs="$funcs strncasecmp"
  326. funcs="$funcs strndup"
  327. funcs="$funcs strnlen"
  328. funcs="$funcs strrchr"
  329. funcs="$funcs strstr"
  330. funcs="$funcs strtod"
  331. funcs="$funcs strtol"
  332. funcs="$funcs strtoul"
  333. funcs="$funcs strtoll"
  334. funcs="$funcs strtoull"
  335. funcs="$funcs strverscmp"
  336. funcs="$funcs tmpnam"
  337. funcs="$funcs vasprintf"
  338. funcs="$funcs vfprintf"
  339. funcs="$funcs vprintf"
  340. funcs="$funcs vsnprintf"
  341. funcs="$funcs vsprintf"
  342. funcs="$funcs waitpid"
  343. funcs="$funcs setproctitle"
  344. # Also in the old function.def file: alloca, vfork, getopt.
  345. vars="sys_errlist sys_nerr sys_siglist"
  346. checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
  347. getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
  348. realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \
  349. sysmp table times wait3 wait4"
  350. # Darwin has sbrk, but it is deprecated and that produces build-time warnings
  351. # so do not check for it.
  352. case "${host}" in
  353. *-*-darwin*) ;;
  354. *) checkfuncs="$checkfuncs sbrk"
  355. esac
  356. # These are neither executed nor required, but they help keep
  357. # autoheader happy without adding a bunch of text to acconfig.h.
  358. if test "x" = "y"; then
  359. AC_CHECK_FUNCS(asprintf atexit \
  360. basename bcmp bcopy bsearch bzero \
  361. calloc canonicalize_file_name clock \
  362. dup3 \
  363. ffs __fsetlocking \
  364. getcwd getpagesize getrlimit getrusage getsysinfo gettimeofday \
  365. index insque \
  366. memchr memcmp memcpy memmem memmove memset mkstemps \
  367. on_exit \
  368. pipe2 psignal pstat_getdynamic pstat_getstatic putenv \
  369. random realpath rename rindex \
  370. sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
  371. stpcpy stpncpy strcasecmp strchr strdup \
  372. strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \
  373. strtol strtoul strtoll strtoull strverscmp sysconf sysctl sysmp \
  374. table times tmpnam \
  375. vasprintf vfprintf vprintf vsprintf \
  376. wait3 wait4 waitpid)
  377. AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf, strtol, strtoul, strtoll, strtoull, strnlen])
  378. AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
  379. AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
  380. AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
  381. fi
  382. # For each of these functions, if the host does not provide the
  383. # function we want to put FN.o in LIBOBJS, and if the host does
  384. # provide the function, we want to define HAVE_FN in config.h.
  385. setobjs=
  386. CHECK=
  387. if test -n "${with_target_subdir}"; then
  388. # We are being configured as a target library. AC_REPLACE_FUNCS
  389. # may not work correctly, because the compiler may not be able to
  390. # link executables. Note that we may still be being configured
  391. # native.
  392. # If we are being configured for newlib, we know which functions
  393. # newlib provide and which ones we will be expected to provide.
  394. if test "x${with_newlib}" = "xyes"; then
  395. AC_LIBOBJ([asprintf])
  396. AC_LIBOBJ([basename])
  397. AC_LIBOBJ([insque])
  398. AC_LIBOBJ([random])
  399. AC_LIBOBJ([strdup])
  400. AC_LIBOBJ([vasprintf])
  401. for f in $funcs; do
  402. case "$f" in
  403. asprintf | basename | insque | random | strdup | vasprintf)
  404. ;;
  405. *)
  406. n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
  407. AC_DEFINE_UNQUOTED($n)
  408. ;;
  409. esac
  410. done
  411. # newlib doesnt provide any of the variables in $vars, so we
  412. # dont have to check them here.
  413. # Of the functions in $checkfuncs, newlib only has strerror.
  414. AC_DEFINE(HAVE_STRERROR)
  415. setobjs=yes
  416. fi
  417. # If we are being configured for Mingw, we know which functions
  418. # Mingw provides and which ones we will be expected to provide.
  419. case "${host}" in
  420. *-*-mingw*)
  421. AC_LIBOBJ([asprintf])
  422. AC_LIBOBJ([basename])
  423. AC_LIBOBJ([bcmp])
  424. AC_LIBOBJ([bcopy])
  425. AC_LIBOBJ([bzero])
  426. AC_LIBOBJ([clock])
  427. AC_LIBOBJ([ffs])
  428. AC_LIBOBJ([getpagesize])
  429. AC_LIBOBJ([index])
  430. AC_LIBOBJ([insque])
  431. AC_LIBOBJ([mempcpy])
  432. AC_LIBOBJ([mkstemps])
  433. AC_LIBOBJ([random])
  434. AC_LIBOBJ([rindex])
  435. AC_LIBOBJ([sigsetmask])
  436. AC_LIBOBJ([stpcpy])
  437. AC_LIBOBJ([stpncpy])
  438. AC_LIBOBJ([strndup])
  439. AC_LIBOBJ([strnlen])
  440. AC_LIBOBJ([strverscmp])
  441. AC_LIBOBJ([vasprintf])
  442. AC_LIBOBJ([waitpid])
  443. for f in $funcs; do
  444. case "$f" in
  445. asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid)
  446. ;;
  447. *)
  448. n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
  449. AC_DEFINE_UNQUOTED($n)
  450. ;;
  451. esac
  452. done
  453. # Mingw doesnt provide any of the variables in $vars, so we
  454. # dont have to check them here.
  455. # Of the functions in $checkfuncs, Mingw only has strerror.
  456. AC_DEFINE(HAVE_STRERROR)
  457. setobjs=yes
  458. ;;
  459. *-*-msdosdjgpp)
  460. AC_LIBOBJ([vasprintf])
  461. AC_LIBOBJ([vsnprintf])
  462. AC_LIBOBJ([snprintf])
  463. AC_LIBOBJ([asprintf])
  464. for f in atexit basename bcmp bcopy bsearch bzero calloc clock ffs \
  465. getcwd getpagesize getrusage gettimeofday \
  466. index insque memchr memcmp memcpy memmove memset psignal \
  467. putenv random rename rindex sbrk setenv stpcpy strcasecmp \
  468. strchr strdup strerror strncasecmp strrchr strstr strtod \
  469. strtol strtoul sysconf times tmpnam vfprintf vprintf \
  470. vsprintf waitpid
  471. do
  472. n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
  473. AC_DEFINE_UNQUOTED($n)
  474. done
  475. setobjs=yes
  476. ;;
  477. esac
  478. else
  479. # Not a target library, so we set things up to run the test suite.
  480. CHECK=really-check
  481. fi
  482. AC_SUBST(CHECK)
  483. AC_SUBST(target_header_dir)
  484. case "${host}" in
  485. *-*-cygwin* | *-*-mingw*)
  486. AC_DEFINE(HAVE_SYS_ERRLIST)
  487. AC_DEFINE(HAVE_SYS_NERR)
  488. ;;
  489. esac
  490. if test -z "${setobjs}"; then
  491. case "${host}" in
  492. *-*-vxworks*)
  493. # Handle VxWorks configuration specially, since on VxWorks the
  494. # libraries are actually on the target board, not in the file
  495. # system.
  496. AC_LIBOBJ([basename])
  497. AC_LIBOBJ([getpagesize])
  498. AC_LIBOBJ([insque])
  499. AC_LIBOBJ([random])
  500. AC_LIBOBJ([strcasecmp])
  501. AC_LIBOBJ([strncasecmp])
  502. AC_LIBOBJ([strdup])
  503. AC_LIBOBJ([vfork])
  504. AC_LIBOBJ([waitpid])
  505. AC_LIBOBJ([vasprintf])
  506. for f in $funcs; do
  507. case "$f" in
  508. basename | getpagesize | insque | random | strcasecmp)
  509. ;;
  510. strncasecmp | strdup | vfork | waitpid | vasprintf)
  511. ;;
  512. *)
  513. n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
  514. AC_DEFINE_UNQUOTED($n)
  515. ;;
  516. esac
  517. done
  518. # VxWorks doesn't provide any of the variables in $vars, so we
  519. # don't have to check them here.
  520. # Of the functions in $checkfuncs, VxWorks only has strerror.
  521. AC_DEFINE(HAVE_STRERROR)
  522. setobjs=yes
  523. ;;
  524. esac
  525. fi
  526. if test -z "${setobjs}"; then
  527. case "${host}" in
  528. *-*-android*)
  529. # On android, getpagesize is defined in unistd.h as a static inline
  530. # function, which AC_CHECK_FUNCS does not handle properly.
  531. ac_cv_func_getpagesize=yes
  532. ;;
  533. hppa*-*-hpux*)
  534. # Replace system snprintf and vsnprintf with libiberty implementations.
  535. AC_LIBOBJ([snprintf])
  536. AC_LIBOBJ([vsnprintf])
  537. ;;
  538. *-*-mingw32*)
  539. # Under mingw32, sys_nerr and sys_errlist exist, but they are
  540. # macros, so the test below won't find them.
  541. libiberty_cv_var_sys_nerr=yes
  542. libiberty_cv_var_sys_errlist=yes
  543. ;;
  544. *-*-msdosdjgpp*)
  545. # vfork and fork are stubs.
  546. ac_cv_func_vfork_works=no
  547. ;;
  548. *-*-uwin*)
  549. # Under some versions of uwin, vfork is notoriously buggy and the test
  550. # can hang configure; on other versions, vfork exists just as a stub.
  551. # FIXME: This should be removed once vfork in uwin's runtime is fixed.
  552. ac_cv_func_vfork_works=no
  553. # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
  554. # macros (actually, these are imported from a DLL, but the end effect
  555. # is the same), so the test below won't find them.
  556. libiberty_cv_var_sys_nerr=yes
  557. libiberty_cv_var_sys_errlist=yes
  558. ;;
  559. *-*-*vms*)
  560. # Under VMS, vfork works very different than on Unix. The standard test
  561. # won't work, and it isn't easily adaptable. It makes more sense to
  562. # just force it.
  563. ac_cv_func_vfork_works=yes
  564. ;;
  565. esac
  566. # We haven't set the list of objects yet. Use the standard autoconf
  567. # tests. This will only work if the compiler works.
  568. AC_ISC_POSIX
  569. AC_REPLACE_FUNCS($funcs)
  570. libiberty_AC_FUNC_C_ALLOCA
  571. AC_FUNC_FORK
  572. if test $ac_cv_func_vfork_works = no; then
  573. AC_LIBOBJ([vfork])
  574. fi
  575. # We only need _doprnt if we might use it to implement v*printf.
  576. if test $ac_cv_func_vprintf != yes \
  577. || test $ac_cv_func_vfprintf != yes \
  578. || test $ac_cv_func_vsprintf != yes; then
  579. AC_REPLACE_FUNCS(_doprnt)
  580. else
  581. AC_CHECK_FUNCS(_doprnt)
  582. fi
  583. for v in $vars; do
  584. AC_MSG_CHECKING([for $v])
  585. AC_CACHE_VAL(libiberty_cv_var_$v,
  586. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int $v [];]],[[if ($v [0]) return 1;]])],
  587. [eval "libiberty_cv_var_$v=yes"],
  588. [eval "libiberty_cv_var_$v=no"])])
  589. if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
  590. AC_MSG_RESULT(yes)
  591. n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
  592. AC_DEFINE_UNQUOTED($n)
  593. else
  594. AC_MSG_RESULT(no)
  595. fi
  596. done
  597. # special check for _system_configuration because AIX <4.3.2 do not
  598. # contain the `physmem' member.
  599. AC_MSG_CHECKING([for external symbol _system_configuration])
  600. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/systemcfg.h>]],
  601. [[double x = _system_configuration.physmem;]])],
  602. [AC_MSG_RESULT([yes])
  603. AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
  604. [Define if you have the _system_configuration variable.])],
  605. [AC_MSG_RESULT([no])])
  606. AC_CHECK_FUNCS($checkfuncs)
  607. AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
  608. AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc])
  609. case "${host}" in
  610. *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
  611. *) AC_CHECK_DECLS([sbrk]);;
  612. esac
  613. AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull])
  614. AC_CHECK_DECLS([strverscmp])
  615. AC_CHECK_DECLS([strnlen])
  616. libiberty_NEED_DECLARATION(canonicalize_file_name)
  617. fi
  618. # Figure out which version of pexecute to use.
  619. case "${host}" in
  620. *-*-mingw* | *-*-winnt*) pexecute=pex-win32 ;;
  621. *-*-msdosdjgpp*) pexecute=pex-djgpp ;;
  622. *-*-msdos*) pexecute=pex-msdos ;;
  623. *) pexecute=pex-unix ;;
  624. esac
  625. AC_SUBST(pexecute)
  626. libiberty_AC_FUNC_STRNCMP
  627. # Install a library built with a cross compiler in $(tooldir) rather
  628. # than $(libdir).
  629. if test -z "${with_cross_host}"; then
  630. INSTALL_DEST=libdir
  631. else
  632. INSTALL_DEST=tooldir
  633. fi
  634. AC_SUBST(INSTALL_DEST)
  635. m4_pattern_allow(LIBOBJS)
  636. L=""
  637. for l in x $LIBOBJS; do
  638. case $l in
  639. x) ;;
  640. *) L="$L ./$l" ;;
  641. esac
  642. done
  643. LIBOBJS="$L"
  644. dnl Required by html and install-html
  645. AC_SUBST(datarootdir)
  646. AC_SUBST(docdir)
  647. AC_SUBST(htmldir)
  648. # We need multilib support, but only if configuring for the target.
  649. AC_CONFIG_FILES([Makefile testsuite/Makefile])
  650. AC_CONFIG_COMMANDS([default],
  651. [[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
  652. if test -n "$CONFIG_FILES"; then
  653. if test -n "${with_target_subdir}"; then
  654. # FIXME: We shouldn't need to set ac_file
  655. ac_file=Makefile
  656. LD="${ORIGINAL_LD_FOR_MULTILIBS}"
  657. . ${libiberty_topdir}/config-ml.in
  658. fi
  659. fi]],
  660. [[srcdir=${srcdir}
  661. host=${host}
  662. target=${target}
  663. with_target_subdir=${with_target_subdir}
  664. with_multisubdir=${with_multisubdir}
  665. ac_configure_args="--enable-multilib ${ac_configure_args}"
  666. CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
  667. ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
  668. libiberty_topdir=${libiberty_topdir}
  669. ]])
  670. AC_OUTPUT