configure.ac 22 KB

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