summaryrefslogtreecommitdiffstats
path: root/m4/apache.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/apache.m4')
-rw-r--r--m4/apache.m4175
1 files changed, 175 insertions, 0 deletions
diff --git a/m4/apache.m4 b/m4/apache.m4
new file mode 100644
index 0000000..3d76b72
--- /dev/null
+++ b/m4/apache.m4
@@ -0,0 +1,175 @@
1dnl TEST_APACHE_VERSION([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
2dnl Test for Apache
3dnl
4AC_DEFUN(TEST_APACHE_VERSION,
5[dnl
6 AC_REQUIRE([AC_CANONICAL_TARGET])
7
8 min_apache_version="$1"
9 no_apache=""
10 ac_save_CFLAGS="$CFLAGS"
11 CFLAGS="$CFLAGS $APACHE_CFLAGS"
12
13 AC_TRY_RUN([
14#include <stdio.h>
15#include <stdlib.h>
16#include <string.h>
17#include "httpd.h"
18
19#ifndef AP_SERVER_BASEREVISION
20 #define AP_SERVER_BASEREVISION SERVER_BASEREVISION
21#endif
22
23char* my_strdup (char *str)
24{
25 char *new_str;
26
27 if (str) {
28 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
29 strcpy (new_str, str);
30 } else
31 new_str = NULL;
32
33 return new_str;
34}
35
36int main (int argc, char *argv[])
37{
38 int major1, minor1, micro1;
39 int major2, minor2, micro2;
40 char *tmp_version;
41
42 { FILE *fp = fopen("conf.apachetest", "a"); if ( fp ) fclose(fp); }
43
44 tmp_version = my_strdup("$min_apache_version");
45 if (sscanf(tmp_version, "%d.%d.%d", &major1, &minor1, &micro1) != 3) {
46 printf("%s, bad version string\n", "$min_apache_version");
47 exit(1);
48 }
49 tmp_version = my_strdup(AP_SERVER_BASEREVISION);
50 if (sscanf(tmp_version, "%d.%d.%d", &major2, &minor2, &micro2) != 3) {
51 printf("%s, bad version string\n", AP_SERVER_BASEREVISION);
52 exit(1);
53 }
54 if ((major2 > major1) ||
55 ((major2 == major1) && (minor2 > minor1)) ||
56 ((major2 == major1) && (minor2 == minor1) && (micro2 >= micro1)))
57 {
58 exit(0);
59 } else {
60 /*printf("\n*** This module requires apache version %d.%d.%d or greater\n",
61 major1, minor1, micro1);
62 printf("*** I found version %d.%d.%d. Please verify the installation directory\n",
63 major2, minor2, micro2);
64 printf("*** of apache with the --with-apxs configure option.\n");*/
65 exit(1);
66 }
67}
68
69],, no_apache=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
70 CFLAGS="$ac_save_CFLAGS"
71
72 if test "x$no_apache" = x ; then
73 ifelse([$2], , :, [$2])
74 else
75 if test -f conf.apachetest ; then
76 :
77 else
78 echo "*** Could not run Apache test program, checking why..."
79 CFLAGS="$CFLAGS APACHE_CFLAGS"
80 AC_TRY_LINK([
81#include <stdio.h>
82#include "httpd.h"
83
84int main(int argc, char *argv[])
85{ return 0; }
86#undef main
87#define main K_and_R_C_main
88], [ return 0; ],
89 [ echo "*** The test program compiled, but failed to run. Check config.log" ],
90 [ echo "*** The test program failed to compile or link. Check config.log" ])
91 CFLAGS="$ac_save_CFLAGS"
92 fi
93 ifelse([$3], , :, [$3])
94 fi
95 rm -f conf.apachetest
96])
97
98dnl CHECK_PATH_APACHE([MINIMUM13-VERSION [, MINIMUM20-VERSION [,
99dnl ACTION-IF-FOUND13 [, ACTION-IF-FOUND20 [, ACTION-IF-NOT-FOUND]]])
100dnl Test for Apache apxs
101dnl
102AC_DEFUN(CHECK_PATH_APACHE,
103[dnl
104AC_ARG_WITH(
105 apxs,
106 [AC_HELP_STRING([--with-apxs=PATH],[Location to APXS binary (default: /usr)])],
107 apxs_prefix="$withval",
108 apxs_prefix="/usr"
109 )
110AC_ARG_ENABLE(
111 apachetest,
112 [AC_HELP_STRING([--disable-apachetest],[Do not try to compile and run apache version test program])],
113 ,
114 enable_apachetest=yes
115 )
116
117 PATH="$apxs_prefix:$apxs_prefix/bin:$apxs_prefix/sbin:$PATH"
118 if test -x $apxs_prefix -a ! -d $apxs_prefix; then
119 APXS_BIN=$apxs_prefix
120 else
121 AC_PATH_PROG(APXS_BIN, apxs, no, [$PATH])
122 fi
123 min_apache13_version=ifelse([$1], ,no,$1)
124 min_apache20_version=ifelse([$2], ,no,$2)
125 no_apxs=""
126 if test "$APXS_BIN" = "no"; then
127 AC_MSG_ERROR([*** The apxs binary installed by apache could not be found!])
128 AC_MSG_ERROR([*** If apache is installed in PREFIX, make sure PREFIX/bin is in])
129 AC_MSG_ERROR([*** your path, or use the --with-apxs configure option])
130 else
131 APACHE_INCDIR=`$APXS_BIN -q INCLUDEDIR`
132 APACHE_CPPFLAGS=`$APXS_BIN -q CFLAGS`
133 APACHE_CFLAGS="-I$APACHE_INCDIR"
134 APACHE_MODDIR=`$APXS_BIN -q LIBEXECDIR`
135
136 if test "x$enable_apachetest" = "xyes" ; then
137 if test "$min_apache20_version" != "no"; then
138 AC_MSG_CHECKING(for Apache 2.0 version >= $min_apache20_version)
139 TEST_APACHE_VERSION($min_apache20_version,
140 AC_MSG_RESULT(yes)
141 AC_DEFINE(WITH_APACHE20,1,[Define to 1 if we are compiling with Apache 2.0.x])
142 APACHE_VERSION="20"
143 APXS_EXTENSION=.la
144 APACHE_DEFS="-DWITH_APACHE20"
145 ifelse([$4], , , $4),
146 AC_MSG_RESULT(no)
147 if test "x$min_apache13_version" = "xno"; then
148 ifelse([$5], , , $5)
149 fi
150 )
151 fi
152 if test "$min_apache13_version" != "no" -a "x$APACHE_VERSION" = "x"; then
153 AC_MSG_CHECKING(for Apache 1.3 version >= $min_apache13_version)
154 TEST_APACHE_VERSION($min_apache13_version,
155 AC_MSG_RESULT(yes)
156 AC_DEFINE(WITH_APACHE13,1,[Define to 1 if we are compiling with Apache 1.3.x])
157 APACHE_VERSION="13"
158 APXS_EXTENSION=.so
159 APACHE_CFLAGS="-g $APACHE_CFLAGS"
160 APACHE_DEFS="-DWITH_APACHE13"
161 ifelse([$3], , , $3),
162 AC_MSG_RESULT(no)
163 ifelse([$5], , , $5)
164 )
165 fi
166 fi
167 AC_SUBST(APACHE_DEFS)
168 AC_SUBST(APACHE_CFLAGS)
169 AC_SUBST(APACHE_CPPFLAGS)
170 AC_SUBST(APACHE_INCDIR)
171 AC_SUBST(APACHE_MODDIR)
172 AC_SUBST(APACHE_VERSION)
173 AC_SUBST(APXS_EXTENSION)
174 fi
175])