apr_common.m4 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  1. dnl -------------------------------------------------------- -*- autoconf -*-
  2. dnl Licensed to the Apache Software Foundation (ASF) under one or more
  3. dnl contributor license agreements. See the NOTICE file distributed with
  4. dnl this work for additional information regarding copyright ownership.
  5. dnl The ASF licenses this file to You under the Apache License, Version 2.0
  6. dnl (the "License"); you may not use this file except in compliance with
  7. dnl the License. You may obtain a copy of the License at
  8. dnl
  9. dnl http://www.apache.org/licenses/LICENSE-2.0
  10. dnl
  11. dnl Unless required by applicable law or agreed to in writing, software
  12. dnl distributed under the License is distributed on an "AS IS" BASIS,
  13. dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. dnl See the License for the specific language governing permissions and
  15. dnl limitations under the License.
  16. dnl
  17. dnl apr_common.m4: APR's general-purpose autoconf macros
  18. dnl
  19. dnl
  20. dnl APR_CONFIG_NICE(filename)
  21. dnl
  22. dnl Saves a snapshot of the configure command-line for later reuse
  23. dnl
  24. AC_DEFUN([APR_CONFIG_NICE], [
  25. rm -f $1
  26. cat >$1<<EOF
  27. #! /bin/sh
  28. #
  29. # Created by configure
  30. EOF
  31. if test -n "$CC"; then
  32. echo "CC=\"$CC\"; export CC" >> $1
  33. fi
  34. if test -n "$CFLAGS"; then
  35. echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1
  36. fi
  37. if test -n "$CPPFLAGS"; then
  38. echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1
  39. fi
  40. if test -n "$LDFLAGS"; then
  41. echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1
  42. fi
  43. if test -n "$LTFLAGS"; then
  44. echo "LTFLAGS=\"$LTFLAGS\"; export LTFLAGS" >> $1
  45. fi
  46. if test -n "$LIBS"; then
  47. echo "LIBS=\"$LIBS\"; export LIBS" >> $1
  48. fi
  49. if test -n "$INCLUDES"; then
  50. echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1
  51. fi
  52. if test -n "$NOTEST_CFLAGS"; then
  53. echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> $1
  54. fi
  55. if test -n "$NOTEST_CPPFLAGS"; then
  56. echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> $1
  57. fi
  58. if test -n "$NOTEST_LDFLAGS"; then
  59. echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> $1
  60. fi
  61. if test -n "$NOTEST_LIBS"; then
  62. echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> $1
  63. fi
  64. # Retrieve command-line arguments.
  65. eval "set x $[0] $ac_configure_args"
  66. shift
  67. for arg
  68. do
  69. APR_EXPAND_VAR(arg, $arg)
  70. echo "\"[$]arg\" \\" >> $1
  71. done
  72. echo '"[$]@"' >> $1
  73. chmod +x $1
  74. ])dnl
  75. dnl APR_MKDIR_P_CHECK(fallback-mkdir-p)
  76. dnl checks whether mkdir -p works
  77. AC_DEFUN([APR_MKDIR_P_CHECK], [
  78. AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
  79. test -d conftestdir && rm -rf conftestdir
  80. mkdir -p conftestdir/somedir >/dev/null 2>&1
  81. if test -d conftestdir/somedir; then
  82. ac_cv_mkdir_p=yes
  83. else
  84. ac_cv_mkdir_p=no
  85. fi
  86. rm -rf conftestdir
  87. ])
  88. if test "$ac_cv_mkdir_p" = "yes"; then
  89. mkdir_p="mkdir -p"
  90. else
  91. mkdir_p="$1"
  92. fi
  93. ])
  94. dnl
  95. dnl APR_SUBDIR_CONFIG(dir [, sub-package-cmdline-args, args-to-drop])
  96. dnl
  97. dnl dir: directory to find configure in
  98. dnl sub-package-cmdline-args: arguments to add to the invocation (optional)
  99. dnl args-to-drop: arguments to drop from the invocation (optional)
  100. dnl
  101. dnl Note: This macro relies on ac_configure_args being set properly.
  102. dnl
  103. dnl The args-to-drop argument is shoved into a case statement, so
  104. dnl multiple arguments can be separated with a |.
  105. dnl
  106. dnl Note: Older versions of autoconf do not single-quote args, while 2.54+
  107. dnl places quotes around every argument. So, if you want to drop the
  108. dnl argument called --enable-layout, you must pass the third argument as:
  109. dnl [--enable-layout=*|\'--enable-layout=*]
  110. dnl
  111. dnl Trying to optimize this is left as an exercise to the reader who wants
  112. dnl to put up with more autoconf craziness. I give up.
  113. dnl
  114. AC_DEFUN([APR_SUBDIR_CONFIG], [
  115. # save our work to this point; this allows the sub-package to use it
  116. AC_CACHE_SAVE
  117. echo "configuring package in $1 now"
  118. ac_popdir=`pwd`
  119. apr_config_subdirs="$1"
  120. test -d $1 || $mkdir_p $1
  121. ac_abs_srcdir=`(cd $srcdir/$1 && pwd)`
  122. cd $1
  123. changequote(, )dnl
  124. # A "../" for each directory in /$config_subdirs.
  125. ac_dots=`echo $apr_config_subdirs|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'`
  126. changequote([, ])dnl
  127. # Make the cache file pathname absolute for the subdirs
  128. # required to correctly handle subdirs that might actually
  129. # be symlinks
  130. case "$cache_file" in
  131. /*) # already absolute
  132. ac_sub_cache_file=$cache_file ;;
  133. *) # Was relative path.
  134. ac_sub_cache_file="$ac_popdir/$cache_file" ;;
  135. esac
  136. ifelse($3, [], [apr_configure_args=$ac_configure_args],[
  137. apr_configure_args=
  138. apr_sep=
  139. for apr_configure_arg in $ac_configure_args
  140. do
  141. case "$apr_configure_arg" in
  142. $3)
  143. continue ;;
  144. esac
  145. apr_configure_args="$apr_configure_args$apr_sep'$apr_configure_arg'"
  146. apr_sep=" "
  147. done
  148. ])
  149. dnl autoconf doesn't add --silent to ac_configure_args; explicitly pass it
  150. test "x$silent" = "xyes" && apr_configure_args="$apr_configure_args --silent"
  151. dnl AC_CONFIG_SUBDIRS silences option warnings, emulate this for 2.62
  152. apr_configure_args="--disable-option-checking $apr_configure_args"
  153. dnl The eval makes quoting arguments work - specifically the second argument
  154. dnl where the quoting mechanisms used is "" rather than [].
  155. dnl
  156. dnl We need to execute another shell because some autoconf/shell combinations
  157. dnl will choke after doing repeated APR_SUBDIR_CONFIG()s. (Namely Solaris
  158. dnl and autoconf-2.54+)
  159. if eval $SHELL $ac_abs_srcdir/configure $apr_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_abs_srcdir $2
  160. then :
  161. echo "$1 configured properly"
  162. else
  163. echo "configure failed for $1"
  164. exit 1
  165. fi
  166. cd $ac_popdir
  167. # grab any updates from the sub-package
  168. AC_CACHE_LOAD
  169. ])dnl
  170. dnl
  171. dnl APR_SAVE_THE_ENVIRONMENT(variable_name)
  172. dnl
  173. dnl Stores the variable (usually a Makefile macro) for later restoration
  174. dnl
  175. AC_DEFUN([APR_SAVE_THE_ENVIRONMENT], [
  176. apr_ste_save_$1="$$1"
  177. ])dnl
  178. dnl
  179. dnl APR_RESTORE_THE_ENVIRONMENT(variable_name, prefix_)
  180. dnl
  181. dnl Uses the previously saved variable content to figure out what configure
  182. dnl has added to the variable, moving the new bits to prefix_variable_name
  183. dnl and restoring the original variable contents. This makes it possible
  184. dnl for a user to override configure when it does something stupid.
  185. dnl
  186. AC_DEFUN([APR_RESTORE_THE_ENVIRONMENT], [
  187. dnl Check whether $apr_ste_save_$1 is empty or
  188. dnl only whitespace. The verbatim "X" is token number 1,
  189. dnl the following whitespace will be ignored.
  190. set X $apr_ste_save_$1
  191. if test ${#} -eq 1; then
  192. $2$1="$$1"
  193. $1=
  194. else
  195. if test "x$apr_ste_save_$1" = "x$$1"; then
  196. $2$1=
  197. else
  198. $2$1=`echo "$$1" | sed -e "s%${apr_ste_save_$1}%%"`
  199. $1="$apr_ste_save_$1"
  200. fi
  201. fi
  202. if test "x$silent" != "xyes"; then
  203. echo " restoring $1 to \"$$1\""
  204. echo " setting $2$1 to \"$$2$1\""
  205. fi
  206. AC_SUBST($2$1)
  207. ])dnl
  208. dnl
  209. dnl APR_SETIFNULL(variable, value)
  210. dnl
  211. dnl Set variable iff it's currently null
  212. dnl
  213. AC_DEFUN([APR_SETIFNULL], [
  214. if test -z "$$1"; then
  215. test "x$silent" != "xyes" && echo " setting $1 to \"$2\""
  216. $1="$2"
  217. fi
  218. ])dnl
  219. dnl
  220. dnl APR_SETVAR(variable, value)
  221. dnl
  222. dnl Set variable no matter what
  223. dnl
  224. AC_DEFUN([APR_SETVAR], [
  225. test "x$silent" != "xyes" && echo " forcing $1 to \"$2\""
  226. $1="$2"
  227. ])dnl
  228. dnl
  229. dnl APR_ADDTO(variable, value)
  230. dnl
  231. dnl Add value to variable
  232. dnl
  233. AC_DEFUN([APR_ADDTO], [
  234. if test "x$$1" = "x"; then
  235. test "x$silent" != "xyes" && echo " setting $1 to \"$2\""
  236. $1="$2"
  237. else
  238. apr_addto_bugger="$2"
  239. for i in $apr_addto_bugger; do
  240. apr_addto_duplicate="0"
  241. for j in $$1; do
  242. if test "x$i" = "x$j"; then
  243. apr_addto_duplicate="1"
  244. break
  245. fi
  246. done
  247. if test $apr_addto_duplicate = "0"; then
  248. test "x$silent" != "xyes" && echo " adding \"$i\" to $1"
  249. $1="$$1 $i"
  250. fi
  251. done
  252. fi
  253. ])dnl
  254. dnl
  255. dnl APR_REMOVEFROM(variable, value)
  256. dnl
  257. dnl Remove a value from a variable
  258. dnl
  259. AC_DEFUN([APR_REMOVEFROM], [
  260. if test "x$$1" = "x$2"; then
  261. test "x$silent" != "xyes" && echo " nulling $1"
  262. $1=""
  263. else
  264. apr_new_bugger=""
  265. apr_removed=0
  266. for i in $$1; do
  267. if test "x$i" != "x$2"; then
  268. apr_new_bugger="$apr_new_bugger $i"
  269. else
  270. apr_removed=1
  271. fi
  272. done
  273. if test $apr_removed = "1"; then
  274. test "x$silent" != "xyes" && echo " removed \"$2\" from $1"
  275. $1=$apr_new_bugger
  276. fi
  277. fi
  278. ]) dnl
  279. dnl
  280. dnl APR_CHECK_DEFINE_FILES( symbol, header_file [header_file ...] )
  281. dnl
  282. AC_DEFUN([APR_CHECK_DEFINE_FILES], [
  283. AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[
  284. ac_cv_define_$1=no
  285. for curhdr in $2
  286. do
  287. AC_EGREP_CPP(YES_IS_DEFINED, [
  288. #include <$curhdr>
  289. #ifdef $1
  290. YES_IS_DEFINED
  291. #endif
  292. ], ac_cv_define_$1=yes)
  293. done
  294. ])
  295. if test "$ac_cv_define_$1" = "yes"; then
  296. AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined])
  297. fi
  298. ])
  299. dnl
  300. dnl APR_CHECK_DEFINE(symbol, header_file)
  301. dnl
  302. AC_DEFUN([APR_CHECK_DEFINE], [
  303. AC_CACHE_CHECK([for $1 in $2],ac_cv_define_$1,[
  304. AC_EGREP_CPP(YES_IS_DEFINED, [
  305. #include <$2>
  306. #ifdef $1
  307. YES_IS_DEFINED
  308. #endif
  309. ], ac_cv_define_$1=yes, ac_cv_define_$1=no)
  310. ])
  311. if test "$ac_cv_define_$1" = "yes"; then
  312. AC_DEFINE(HAVE_$1, 1, [Define if $1 is defined in $2])
  313. fi
  314. ])
  315. dnl
  316. dnl APR_CHECK_APR_DEFINE( symbol )
  317. dnl
  318. AC_DEFUN([APR_CHECK_APR_DEFINE], [
  319. apr_old_cppflags=$CPPFLAGS
  320. CPPFLAGS="$CPPFLAGS $INCLUDES"
  321. AC_EGREP_CPP(YES_IS_DEFINED, [
  322. #include <apr.h>
  323. #if $1
  324. YES_IS_DEFINED
  325. #endif
  326. ], ac_cv_define_$1=yes, ac_cv_define_$1=no)
  327. CPPFLAGS=$apr_old_cppflags
  328. ])
  329. dnl APR_CHECK_FILE(filename); set ac_cv_file_filename to
  330. dnl "yes" if 'filename' is readable, else "no".
  331. dnl @deprecated! - use AC_CHECK_FILE instead
  332. AC_DEFUN([APR_CHECK_FILE], [
  333. dnl Pick a safe variable name
  334. define([apr_cvname], ac_cv_file_[]translit([$1], [./+-], [__p_]))
  335. AC_CACHE_CHECK([for $1], [apr_cvname],
  336. [if test -r $1; then
  337. apr_cvname=yes
  338. else
  339. apr_cvname=no
  340. fi])
  341. ])
  342. define(APR_IFALLYES,[dnl
  343. ac_rc=yes
  344. for ac_spec in $1; do
  345. ac_type=`echo "$ac_spec" | sed -e 's/:.*$//'`
  346. ac_item=`echo "$ac_spec" | sed -e 's/^.*://'`
  347. case $ac_type in
  348. header )
  349. ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'`
  350. ac_var="ac_cv_header_$ac_item"
  351. ;;
  352. file )
  353. ac_item=`echo "$ac_item" | sed 'y%./+-%__p_%'`
  354. ac_var="ac_cv_file_$ac_item"
  355. ;;
  356. func ) ac_var="ac_cv_func_$ac_item" ;;
  357. struct ) ac_var="ac_cv_struct_$ac_item" ;;
  358. define ) ac_var="ac_cv_define_$ac_item" ;;
  359. custom ) ac_var="$ac_item" ;;
  360. esac
  361. eval "ac_val=\$$ac_var"
  362. if test ".$ac_val" != .yes; then
  363. ac_rc=no
  364. break
  365. fi
  366. done
  367. if test ".$ac_rc" = .yes; then
  368. :
  369. $2
  370. else
  371. :
  372. $3
  373. fi
  374. ])
  375. define(APR_BEGIN_DECISION,[dnl
  376. ac_decision_item='$1'
  377. ac_decision_msg='FAILED'
  378. ac_decision=''
  379. ])
  380. AC_DEFUN([APR_DECIDE],[dnl
  381. dnl Define the flag (or not) in apr_private.h via autoheader
  382. AH_TEMPLATE($1, [Define if $2 will be used])
  383. ac_decision='$1'
  384. ac_decision_msg='$2'
  385. ac_decision_$1=yes
  386. ac_decision_$1_msg='$2'
  387. ])
  388. define(APR_DECISION_OVERRIDE,[dnl
  389. ac_decision=''
  390. for ac_item in $1; do
  391. eval "ac_decision_this=\$ac_decision_${ac_item}"
  392. if test ".$ac_decision_this" = .yes; then
  393. ac_decision=$ac_item
  394. eval "ac_decision_msg=\$ac_decision_${ac_item}_msg"
  395. fi
  396. done
  397. ])
  398. define(APR_DECISION_FORCE,[dnl
  399. ac_decision="$1"
  400. eval "ac_decision_msg=\"\$ac_decision_${ac_decision}_msg\""
  401. ])
  402. define(APR_END_DECISION,[dnl
  403. if test ".$ac_decision" = .; then
  404. echo "[$]0:Error: decision on $ac_decision_item failed" 1>&2
  405. exit 1
  406. else
  407. if test ".$ac_decision_msg" = .; then
  408. ac_decision_msg="$ac_decision"
  409. fi
  410. AC_DEFINE_UNQUOTED(${ac_decision_item})
  411. AC_MSG_RESULT([decision on $ac_decision_item... $ac_decision_msg])
  412. fi
  413. ])
  414. dnl
  415. dnl APR_CHECK_SIZEOF_EXTENDED(INCLUDES, TYPE [, CROSS_SIZE])
  416. dnl
  417. dnl A variant of AC_CHECK_SIZEOF which allows the checking of
  418. dnl sizes of non-builtin types
  419. dnl
  420. AC_DEFUN([APR_CHECK_SIZEOF_EXTENDED],
  421. [changequote(<<, >>)dnl
  422. dnl The name to #define.
  423. define(<<AC_TYPE_NAME>>, translit(sizeof_$2, [a-z *], [A-Z_P]))dnl
  424. dnl The cache variable name.
  425. define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$2, [ *], [_p]))dnl
  426. changequote([, ])dnl
  427. AC_MSG_CHECKING(size of $2)
  428. AC_CACHE_VAL(AC_CV_NAME,
  429. [AC_TRY_RUN([#include <stdio.h>
  430. $1
  431. #ifdef WIN32
  432. #define binmode "b"
  433. #else
  434. #define binmode
  435. #endif
  436. main()
  437. {
  438. FILE *f=fopen("conftestval", "w" binmode);
  439. if (!f) exit(1);
  440. fprintf(f, "%d\n", sizeof($2));
  441. exit(0);
  442. }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3],,,
  443. AC_CV_NAME=$3))])dnl
  444. AC_MSG_RESULT($AC_CV_NAME)
  445. AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The size of ]$2)
  446. undefine([AC_TYPE_NAME])dnl
  447. undefine([AC_CV_NAME])dnl
  448. ])
  449. dnl
  450. dnl APR_TRY_COMPILE_NO_WARNING(INCLUDES, FUNCTION-BODY,
  451. dnl [ACTIONS-IF-NO-WARNINGS], [ACTIONS-IF-WARNINGS])
  452. dnl
  453. dnl Tries a compile test with warnings activated so that the result
  454. dnl is false if the code doesn't compile cleanly. For compilers
  455. dnl where it is not known how to activate a "fail-on-error" mode,
  456. dnl it is undefined which of the sets of actions will be run.
  457. dnl
  458. AC_DEFUN([APR_TRY_COMPILE_NO_WARNING],
  459. [apr_save_CFLAGS=$CFLAGS
  460. CFLAGS="$CFLAGS $CFLAGS_WARN"
  461. if test "$ac_cv_prog_gcc" = "yes"; then
  462. CFLAGS="$CFLAGS -Werror"
  463. fi
  464. AC_COMPILE_IFELSE(
  465. [AC_LANG_SOURCE(
  466. [#include "confdefs.h"
  467. ]
  468. [[$1]]
  469. [int main(int argc, const char *const *argv) {]
  470. [[$2]]
  471. [ return 0; }]
  472. )],
  473. [$3], [$4])
  474. CFLAGS=$apr_save_CFLAGS
  475. ])
  476. dnl
  477. dnl APR_CHECK_STRERROR_R_RC
  478. dnl
  479. dnl Decide which style of retcode is used by this system's
  480. dnl strerror_r(). It either returns int (0 for success, -1
  481. dnl for failure), or it returns a pointer to the error
  482. dnl string.
  483. dnl
  484. dnl
  485. AC_DEFUN([APR_CHECK_STRERROR_R_RC], [
  486. AC_MSG_CHECKING(for type of return code from strerror_r)
  487. AC_TRY_RUN([
  488. #include <errno.h>
  489. #include <string.h>
  490. #include <stdio.h>
  491. main()
  492. {
  493. char buf[1024];
  494. if (strerror_r(ERANGE, buf, sizeof buf) < 1) {
  495. exit(0);
  496. }
  497. else {
  498. exit(1);
  499. }
  500. }], [
  501. ac_cv_strerror_r_rc_int=yes ], [
  502. ac_cv_strerror_r_rc_int=no ], [
  503. ac_cv_strerror_r_rc_int=no ] )
  504. if test "x$ac_cv_strerror_r_rc_int" = xyes; then
  505. AC_DEFINE(STRERROR_R_RC_INT, 1, [Define if strerror returns int])
  506. msg="int"
  507. else
  508. msg="pointer"
  509. fi
  510. AC_MSG_RESULT([$msg])
  511. ] )
  512. dnl
  513. dnl APR_CHECK_DIRENT_INODE
  514. dnl
  515. dnl Decide if d_fileno or d_ino are available in the dirent
  516. dnl structure on this platform. Single UNIX Spec says d_ino,
  517. dnl BSD uses d_fileno. Undef to find the real beast.
  518. dnl
  519. AC_DEFUN([APR_CHECK_DIRENT_INODE], [
  520. AC_CACHE_CHECK([for inode member of struct dirent], apr_cv_dirent_inode, [
  521. apr_cv_dirent_inode=no
  522. AC_TRY_COMPILE([
  523. #include <sys/types.h>
  524. #include <dirent.h>
  525. ],[
  526. #ifdef d_ino
  527. #undef d_ino
  528. #endif
  529. struct dirent de; de.d_fileno;
  530. ], apr_cv_dirent_inode=d_fileno)
  531. if test "$apr_cv_dirent_inode" = "no"; then
  532. AC_TRY_COMPILE([
  533. #include <sys/types.h>
  534. #include <dirent.h>
  535. ],[
  536. #ifdef d_fileno
  537. #undef d_fileno
  538. #endif
  539. struct dirent de; de.d_ino;
  540. ], apr_cv_dirent_inode=d_ino)
  541. fi
  542. ])
  543. if test "$apr_cv_dirent_inode" != "no"; then
  544. AC_DEFINE_UNQUOTED(DIRENT_INODE, $apr_cv_dirent_inode,
  545. [Define if struct dirent has an inode member])
  546. fi
  547. ])
  548. dnl
  549. dnl APR_CHECK_DIRENT_TYPE
  550. dnl
  551. dnl Decide if d_type is available in the dirent structure
  552. dnl on this platform. Not part of the Single UNIX Spec.
  553. dnl Note that this is worthless without DT_xxx macros, so
  554. dnl look for one while we are at it.
  555. dnl
  556. AC_DEFUN([APR_CHECK_DIRENT_TYPE], [
  557. AC_CACHE_CHECK([for file type member of struct dirent], apr_cv_dirent_type,[
  558. apr_cv_dirent_type=no
  559. AC_TRY_COMPILE([
  560. #include <sys/types.h>
  561. #include <dirent.h>
  562. ],[
  563. struct dirent de; de.d_type = DT_REG;
  564. ], apr_cv_dirent_type=d_type)
  565. ])
  566. if test "$apr_cv_dirent_type" != "no"; then
  567. AC_DEFINE_UNQUOTED(DIRENT_TYPE, $apr_cv_dirent_type,
  568. [Define if struct dirent has a d_type member])
  569. fi
  570. ])
  571. dnl the following is a newline, a space, a tab, and a backslash (the
  572. dnl backslash is used by the shell to skip newlines, but m4 sees it;
  573. dnl treat it like whitespace).
  574. dnl WARNING: don't reindent these lines, or the space/tab will be lost!
  575. define([apr_whitespace],[
  576. \])
  577. dnl
  578. dnl APR_COMMA_ARGS(ARG1 ...)
  579. dnl convert the whitespace-separated arguments into comman-separated
  580. dnl arguments.
  581. dnl
  582. dnl APR_FOREACH(CODE-BLOCK, ARG1, ARG2, ...)
  583. dnl subsitute CODE-BLOCK for each ARG[i]. "eachval" will be set to ARG[i]
  584. dnl within each iteration.
  585. dnl
  586. changequote({,})
  587. define({APR_COMMA_ARGS},{patsubst([$}{1],[[}apr_whitespace{]+],[,])})
  588. define({APR_FOREACH},
  589. {ifelse($}{2,,,
  590. [define([eachval],
  591. $}{2)$}{1[]APR_FOREACH([$}{1],
  592. builtin([shift],
  593. builtin([shift], $}{@)))])})
  594. changequote([,])
  595. dnl APR_FLAG_HEADERS(HEADER-FILE ... [, FLAG-TO-SET ] [, "yes" ])
  596. dnl we set FLAG-TO-SET to 1 if we find HEADER-FILE, otherwise we set to 0
  597. dnl if FLAG-TO-SET is null, we automagically determine it's name
  598. dnl by changing all "/" to "_" in the HEADER-FILE and dropping
  599. dnl all "." and "-" chars. If the 3rd parameter is "yes" then instead of
  600. dnl setting to 1 or 0, we set FLAG-TO-SET to yes or no.
  601. dnl
  602. AC_DEFUN([APR_FLAG_HEADERS], [
  603. AC_CHECK_HEADERS($1)
  604. for aprt_i in $1
  605. do
  606. ac_safe=`echo "$aprt_i" | sed 'y%./+-%__p_%'`
  607. aprt_2=`echo "$aprt_i" | sed -e 's%/%_%g' -e 's/\.//g' -e 's/-//g'`
  608. if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
  609. eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,yes,1)"
  610. else
  611. eval "ifelse($2,,$aprt_2,$2)=ifelse($3,yes,no,0)"
  612. fi
  613. done
  614. ])
  615. dnl APR_FLAG_FUNCS(FUNC ... [, FLAG-TO-SET] [, "yes" ])
  616. dnl if FLAG-TO-SET is null, we automagically determine it's name
  617. dnl prepending "have_" to the function name in FUNC, otherwise
  618. dnl we use what's provided as FLAG-TO-SET. If the 3rd parameter
  619. dnl is "yes" then instead of setting to 1 or 0, we set FLAG-TO-SET
  620. dnl to yes or no.
  621. dnl
  622. AC_DEFUN([APR_FLAG_FUNCS], [
  623. AC_CHECK_FUNCS($1)
  624. for aprt_j in $1
  625. do
  626. aprt_3="have_$aprt_j"
  627. if eval "test \"`echo '$ac_cv_func_'$aprt_j`\" = yes"; then
  628. eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,yes,1)"
  629. else
  630. eval "ifelse($2,,$aprt_3,$2)=ifelse($3,yes,no,0)"
  631. fi
  632. done
  633. ])
  634. dnl Iteratively interpolate the contents of the second argument
  635. dnl until interpolation offers no new result. Then assign the
  636. dnl final result to $1.
  637. dnl
  638. dnl Example:
  639. dnl
  640. dnl foo=1
  641. dnl bar='${foo}/2'
  642. dnl baz='${bar}/3'
  643. dnl APR_EXPAND_VAR(fraz, $baz)
  644. dnl $fraz is now "1/2/3"
  645. dnl
  646. AC_DEFUN([APR_EXPAND_VAR], [
  647. ap_last=
  648. ap_cur="$2"
  649. while test "x${ap_cur}" != "x${ap_last}";
  650. do
  651. ap_last="${ap_cur}"
  652. ap_cur=`eval "echo ${ap_cur}"`
  653. done
  654. $1="${ap_cur}"
  655. ])
  656. dnl
  657. dnl Removes the value of $3 from the string in $2, strips of any leading
  658. dnl slashes, and returns the value in $1.
  659. dnl
  660. dnl Example:
  661. dnl orig_path="${prefix}/bar"
  662. dnl APR_PATH_RELATIVE(final_path, $orig_path, $prefix)
  663. dnl $final_path now contains "bar"
  664. AC_DEFUN([APR_PATH_RELATIVE], [
  665. ap_stripped=`echo $2 | sed -e "s#^$3##"`
  666. # check if the stripping was successful
  667. if test "x$2" != "x${ap_stripped}"; then
  668. # it was, so strip of any leading slashes
  669. $1="`echo ${ap_stripped} | sed -e 's#^/*##'`"
  670. else
  671. # it wasn't so return the original
  672. $1="$2"
  673. fi
  674. ])
  675. dnl APR_HELP_STRING(LHS, RHS)
  676. dnl Autoconf 2.50 can not handle substr correctly. It does have
  677. dnl AC_HELP_STRING, so let's try to call it if we can.
  678. dnl Note: this define must be on one line so that it can be properly returned
  679. dnl as the help string. When using this macro with a multi-line RHS, ensure
  680. dnl that you surround the macro invocation with []s
  681. AC_DEFUN([APR_HELP_STRING], [ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING([$1],[$2]),[ ][$1] substr([ ],len($1))[$2])])
  682. dnl
  683. dnl APR_LAYOUT(configlayout, layoutname [, extravars])
  684. dnl
  685. AC_DEFUN([APR_LAYOUT], [
  686. if test ! -f $srcdir/config.layout; then
  687. echo "** Error: Layout file $srcdir/config.layout not found"
  688. echo "** Error: Cannot use undefined layout '$LAYOUT'"
  689. exit 1
  690. fi
  691. # Catch layout names including a slash which will otherwise
  692. # confuse the heck out of the sed script.
  693. case $2 in
  694. */*)
  695. echo "** Error: $2 is not a valid layout name"
  696. exit 1 ;;
  697. esac
  698. pldconf=./config.pld
  699. changequote({,})
  700. sed -e "1s/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*//;1t" \
  701. -e "1,/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*/d" \
  702. -e '/[ ]*<\/Layout>[ ]*/,$d' \
  703. -e "s/^[ ]*//g" \
  704. -e "s/:[ ]*/=\'/g" \
  705. -e "s/[ ]*$/'/g" \
  706. $1 > $pldconf
  707. layout_name=$2
  708. if test ! -s $pldconf; then
  709. echo "** Error: unable to find layout $layout_name"
  710. exit 1
  711. fi
  712. . $pldconf
  713. rm $pldconf
  714. for var in prefix exec_prefix bindir sbindir libexecdir mandir \
  715. sysconfdir datadir includedir localstatedir runtimedir \
  716. logfiledir libdir installbuilddir libsuffix $3; do
  717. eval "val=\"\$$var\""
  718. case $val in
  719. *+)
  720. val=`echo $val | sed -e 's;\+$;;'`
  721. eval "$var=\"\$val\""
  722. autosuffix=yes
  723. ;;
  724. *)
  725. autosuffix=no
  726. ;;
  727. esac
  728. val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
  729. val=`echo $val | sed -e 's:[\$]\([a-z_]*\):${\1}:g'`
  730. if test "$autosuffix" = "yes"; then
  731. if echo $val | grep apache >/dev/null; then
  732. addtarget=no
  733. else
  734. addtarget=yes
  735. fi
  736. if test "$addtarget" = "yes"; then
  737. val="$val/apache2"
  738. fi
  739. fi
  740. eval "$var='$val'"
  741. done
  742. changequote([,])
  743. ])dnl
  744. dnl
  745. dnl APR_ENABLE_LAYOUT(default layout name [, extra vars])
  746. dnl
  747. AC_DEFUN([APR_ENABLE_LAYOUT], [
  748. AC_ARG_ENABLE(layout,
  749. [ --enable-layout=LAYOUT],[
  750. LAYOUT=$enableval
  751. ])
  752. if test -z "$LAYOUT"; then
  753. LAYOUT="$1"
  754. fi
  755. APR_LAYOUT($srcdir/config.layout, $LAYOUT, $2)
  756. AC_MSG_CHECKING(for chosen layout)
  757. AC_MSG_RESULT($layout_name)
  758. ])
  759. dnl
  760. dnl APR_PARSE_ARGUMENTS
  761. dnl a reimplementation of autoconf's argument parser,
  762. dnl used here to allow us to co-exist layouts and argument based
  763. dnl set ups.
  764. AC_DEFUN([APR_PARSE_ARGUMENTS], [
  765. ac_prev=
  766. # Retrieve the command-line arguments. The eval is needed because
  767. # the arguments are quoted to preserve accuracy.
  768. eval "set x $ac_configure_args"
  769. shift
  770. for ac_option
  771. do
  772. # If the previous option needs an argument, assign it.
  773. if test -n "$ac_prev"; then
  774. eval "$ac_prev=\$ac_option"
  775. ac_prev=
  776. continue
  777. fi
  778. ac_optarg=`expr "x$ac_option" : 'x[[^=]]*=\(.*\)'`
  779. case $ac_option in
  780. -bindir | --bindir | --bindi | --bind | --bin | --bi)
  781. ac_prev=bindir ;;
  782. -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
  783. bindir="$ac_optarg" ;;
  784. -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
  785. ac_prev=datadir ;;
  786. -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
  787. | --da=*)
  788. datadir="$ac_optarg" ;;
  789. -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
  790. | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
  791. | --exec | --exe | --ex)
  792. ac_prev=exec_prefix ;;
  793. -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
  794. | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
  795. | --exec=* | --exe=* | --ex=*)
  796. exec_prefix="$ac_optarg" ;;
  797. -includedir | --includedir | --includedi | --included | --include \
  798. | --includ | --inclu | --incl | --inc)
  799. ac_prev=includedir ;;
  800. -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
  801. | --includ=* | --inclu=* | --incl=* | --inc=*)
  802. includedir="$ac_optarg" ;;
  803. -infodir | --infodir | --infodi | --infod | --info | --inf)
  804. ac_prev=infodir ;;
  805. -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
  806. infodir="$ac_optarg" ;;
  807. -libdir | --libdir | --libdi | --libd)
  808. ac_prev=libdir ;;
  809. -libdir=* | --libdir=* | --libdi=* | --libd=*)
  810. libdir="$ac_optarg" ;;
  811. -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
  812. | --libexe | --libex | --libe)
  813. ac_prev=libexecdir ;;
  814. -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
  815. | --libexe=* | --libex=* | --libe=*)
  816. libexecdir="$ac_optarg" ;;
  817. -localstatedir | --localstatedir | --localstatedi | --localstated \
  818. | --localstate | --localstat | --localsta | --localst \
  819. | --locals | --local | --loca | --loc | --lo)
  820. ac_prev=localstatedir ;;
  821. -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
  822. | --localstate=* | --localstat=* | --localsta=* | --localst=* \
  823. | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
  824. localstatedir="$ac_optarg" ;;
  825. -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
  826. ac_prev=mandir ;;
  827. -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
  828. mandir="$ac_optarg" ;;
  829. -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  830. ac_prev=prefix ;;
  831. -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  832. prefix="$ac_optarg" ;;
  833. -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
  834. ac_prev=sbindir ;;
  835. -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
  836. | --sbi=* | --sb=*)
  837. sbindir="$ac_optarg" ;;
  838. -sharedstatedir | --sharedstatedir | --sharedstatedi \
  839. | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
  840. | --sharedst | --shareds | --shared | --share | --shar \
  841. | --sha | --sh)
  842. ac_prev=sharedstatedir ;;
  843. -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
  844. | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
  845. | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
  846. | --sha=* | --sh=*)
  847. sharedstatedir="$ac_optarg" ;;
  848. -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
  849. | --syscon | --sysco | --sysc | --sys | --sy)
  850. ac_prev=sysconfdir ;;
  851. -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
  852. | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
  853. sysconfdir="$ac_optarg" ;;
  854. esac
  855. done
  856. # Be sure to have absolute paths.
  857. for ac_var in exec_prefix prefix
  858. do
  859. eval ac_val=$`echo $ac_var`
  860. case $ac_val in
  861. [[\\/$]]* | ?:[[\\/]]* | NONE | '' ) ;;
  862. *) AC_MSG_ERROR([expected an absolute path for --$ac_var: $ac_val]);;
  863. esac
  864. done
  865. ])dnl
  866. dnl
  867. dnl APR_CHECK_DEPEND
  868. dnl
  869. dnl Determine what program we can use to generate .deps-style dependencies
  870. dnl
  871. AC_DEFUN([APR_CHECK_DEPEND], [
  872. dnl Try to determine what depend program we can use
  873. dnl All GCC-variants should have -MM.
  874. dnl If not, then we can check on those, too.
  875. if test "$GCC" = "yes"; then
  876. MKDEP='$(CC) -MM'
  877. else
  878. rm -f conftest.c
  879. dnl <sys/types.h> should be available everywhere!
  880. cat > conftest.c <<EOF
  881. #include <sys/types.h>
  882. int main() { return 0; }
  883. EOF
  884. MKDEP="true"
  885. for i in "$CC -MM" "$CC -M" "$CPP -MM" "$CPP -M" "cpp -M"; do
  886. AC_MSG_CHECKING([if $i can create proper make dependencies])
  887. if $i conftest.c 2>/dev/null | grep 'conftest.o: conftest.c' >/dev/null; then
  888. MKDEP=$i
  889. AC_MSG_RESULT(yes)
  890. break;
  891. fi
  892. AC_MSG_RESULT(no)
  893. done
  894. rm -f conftest.c
  895. fi
  896. AC_SUBST(MKDEP)
  897. ])
  898. dnl
  899. dnl APR_CHECK_TYPES_COMPATIBLE(TYPE-1, TYPE-2, [ACTION-IF-TRUE])
  900. dnl
  901. dnl Try to determine whether two types are the same. Only works
  902. dnl for gcc and icc.
  903. dnl
  904. AC_DEFUN([APR_CHECK_TYPES_COMPATIBLE], [
  905. define([apr_cvname], apr_cv_typematch_[]translit([$1], [ ], [_])_[]translit([$2], [ ], [_]))
  906. AC_CACHE_CHECK([whether $1 and $2 are the same], apr_cvname, [
  907. AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [
  908. int foo[0 - !__builtin_types_compatible_p($1, $2)];
  909. ], [apr_cvname=yes
  910. $3], [apr_cvname=no])])
  911. ])