summaryrefslogtreecommitdiffstats
path: root/m4/apache.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/apache.m4')
-rw-r--r--m4/apache.m4128
1 files changed, 128 insertions, 0 deletions
diff --git a/m4/apache.m4 b/m4/apache.m4
new file mode 100644
index 0000000..b74f335
--- /dev/null
+++ b/m4/apache.m4
@@ -0,0 +1,128 @@
1dnl CHECK_PATH_APACHE([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
2dnl Test for Apache apxs
3dnl
4AC_DEFUN(CHECK_PATH_APACHE,
5[dnl
6AC_ARG_WITH(
7 apache,
8 [ --with-apache[=DIR] Apache install root],
9 apache_prefix="$withval",
10 apache_prefix="/usr"
11 )
12AC_ARG_ENABLE(apachetest, [ --disable-apachetest Do not try to compile and run apache version test program],
13 , enable_apachetest=yes)
14
15
16 AC_REQUIRE([AC_CANONICAL_TARGET])
17 PATH="$apache_prefix:$apache_prefix/bin:$apache_prefix/sbin:$PATH"
18 AC_PATH_PROG(APXS_BIN, apxs, no, [$PATH])
19 min_apache_version=ifelse([$1], ,1.3.1,$1)
20 AC_MSG_CHECKING(for Apache - version >= $min_apache_version)
21 no_apxs=""
22 if test "$APXS_BIN" == "no"; then
23 no_apxs=yes
24 else
25 APACHE_INCDIR=`$APXS_BIN -q INCLUDEDIR`
26 APACHE_CFLAGS=-I$APACHE_INCDIR
27 APACHE_MODDIR=`$APXS_BIN -q LIBEXECDIR`
28
29 if test "x$enable_apachetest" = "xyes" ; then
30 ac_save_CFLAGS="$CFLAGS"
31 CFLAGS="$CFLAGS $APACHE_CFLAGS"
32 AC_TRY_RUN([
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36#include "httpd.h"
37
38#ifndef AP_SERVER_BASEREVISION
39 #define AP_SERVER_BASEREVISION SERVER_BASEREVISION
40#endif
41
42char* my_strdup (char *str)
43{
44 char *new_str;
45
46 if (str) {
47 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
48 strcpy (new_str, str);
49 } else
50 new_str = NULL;
51
52 return new_str;
53}
54
55int main (int argc, char *argv[])
56{
57 int major1, minor1, micro1;
58 int major2, minor2, micro2;
59 char *tmp_version;
60
61 { FILE *fp = fopen("conf.apachetest", "a"); if ( fp ) fclose(fp); }
62
63 tmp_version = my_strdup("$min_apache_version");
64 if (sscanf(tmp_version, "%d.%d.%d", &major1, &minor1, &micro1) != 3) {
65 printf("%s, bad version string\n", "$min_apache_version");
66 exit(1);
67 }
68 tmp_version = my_strdup(AP_SERVER_BASEREVISION);
69 if (sscanf(tmp_version, "%d.%d.%d", &major2, &minor2, &micro2) != 3) {
70 printf("%s, bad version string\n", AP_SERVER_BASEREVISION);
71 exit(1);
72 }
73 if ((major2 > major1) ||
74 ((major2 == major1) && (minor2 > minor1)) ||
75 ((major2 == major1) && (minor2 == minor1) && (micro2 >= micro1)))
76 {
77 return 0;
78 } else {
79 printf("\n*** This module requires apache version %d.%d.%d or greater\n",
80 major1, minor1, micro1);
81 printf("*** I found version %d.%d.%d. Please verify the installation directory\n",
82 major2, minor2, micro2);
83 printf("*** of apache with the --with-apache configure option.\n");
84 return 1;
85 }
86}
87
88],, no_apxs=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
89 CFLAGS="$ac_save_CFLAGS"
90 fi
91 fi
92 if test "x$no_apxs" = x ; then
93 AC_MSG_RESULT(yes)
94 ifelse([$2], , :, [$2])
95 else
96 AC_MSG_RESULT(no)
97 if test "APXS_BIN" = "no" ; then
98 echo "*** The apxs binary installed by apache could not be found"
99 echo "*** If apache is installed in PREFIX, make sure PREFIX/bin is in"
100 echo "*** your path, or use the --with-apache configure option"
101 else
102 if test -f conf.apachetest ; then
103 :
104 else
105 echo "*** Could not run Apache test program, checking why..."
106 CFLAGS="$CFLAGS APACHE_CFLAGS"
107 AC_TRY_LINK([
108#include <stdio.h>
109#include "httpd.h"
110
111int main(int argc, char *argv[])
112{ return 0; }
113#undef main
114#define main K_and_R_C_main
115], [ return 0; ],
116 [ echo "*** The test program compiled, but failed to run. Check config.log" ],
117 [ echo "*** The test program failed to compile or link. Check config.log" ])
118 CFLAGS="$ac_save_CFLAGS"
119 fi
120 fi
121 APACHE_CFLAGS=""
122 ifelse([$3], , :, [$3])
123 fi
124 AC_SUBST(APACHE_CFLAGS)
125 AC_SUBST(APACHE_INCDIR)
126 AC_SUBST(APACHE_MODDIR)
127 rm -f conf.apachetest
128])