apr_common.m4 26 KB

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