Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / build / find_apr.m4
1 dnl Check for APR Libraries
2 dnl CHECK_APR(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
3 dnl Sets:
4 dnl  APR_CFLAGS
5 dnl  APR_LDFLAGS
6 dnl  APR_LIBS
7 dnl  APR_LINK_LD
8
9 APR_CONFIG=""
10 APR_CFLAGS=""
11 APR_LDFLAGS=""
12 APR_LIBS=""
13 APR_LINK_LD=""
14
15 AC_DEFUN([CHECK_APR],
16 [dnl
17
18 AC_ARG_WITH(
19     apr,
20     [AC_HELP_STRING([--with-apr=PATH],[Path to apr prefix or config script])],
21     [test_paths="${with_apr}"],
22     [test_paths="/usr/local/libapr /usr/local/apr /usr/local /opt/libapr /opt/apr /opt /usr"])
23
24 AC_MSG_CHECKING([for libapr config script])
25
26 for x in ${test_paths}; do
27     dnl # Determine if the script was specified and use it directly
28     if test ! -d "$x" -a -e "$x"; then
29         APR_CONFIG=$x
30         apr_path=no
31         break
32     fi
33
34     dnl # Try known config script names/locations
35     for APR_CONFIG in apr-1-mt-config apr-1-config apr-config-1 apr-mt-config-1 apr-mt-config apr-config; do
36         if test -e "${x}/bin/${APR_CONFIG}"; then
37             apr_path="${x}/bin"
38             break
39         elif test -e "${x}/${APR_CONFIG}"; then
40             apr_path="${x}"
41             break
42         else
43             apr_path=""
44         fi
45     done
46     if test -n "$apr_path"; then
47         break
48     fi
49 done
50
51 if test -n "${apr_path}"; then
52     if test "${apr_path}" != "no"; then
53         APR_CONFIG="${apr_path}/${APR_CONFIG}"
54     fi
55     AC_MSG_RESULT([${APR_CONFIG}])
56     APR_CFLAGS="`${APR_CONFIG} --includes --cppflags --cflags`"
57     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apr CFLAGS: $APR_CFLAGS); fi
58     APR_LDFLAGS="`${APR_CONFIG} --ldflags`"
59     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apr LDFLAGS: $APR_LDFLAGS); fi
60     APR_LIBS="`${APR_CONFIG} --libs`"
61     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apr LIBS: $APR_LIBS); fi
62     APR_LINK_LD="`${APR_CONFIG} --link-ld`"
63     if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apr LINK_LD: $APR_LINK_LD); fi
64     CFLAGS=$save_CFLAGS
65     LDFLAGS=$save_LDFLAGS
66 else
67     AC_MSG_RESULT([no])
68 fi
69
70 AC_SUBST(APR_LIBS)
71 AC_SUBST(APR_CFLAGS)
72 AC_SUBST(APR_LDFLAGS)
73 AC_SUBST(APR_LINK_LD)
74
75 if test -z "${APR_LIBS}"; then
76     AC_MSG_NOTICE([*** apr library not found.])
77     ifelse([$2], , AC_MSG_ERROR([apr library is required]), $2)
78 else
79     AC_MSG_NOTICE([using '${APR_LIBS}' for apr Library])
80     ifelse([$1], , , $1) 
81 fi 
82 ])