diff options
Diffstat (limited to 'm4/apache_test.m4')
-rw-r--r-- | m4/apache_test.m4 | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/m4/apache_test.m4 b/m4/apache_test.m4 new file mode 100644 index 0000000..8c91adf --- /dev/null +++ b/m4/apache_test.m4 | |||
@@ -0,0 +1,96 @@ | |||
1 | dnl TEST_APACHE_VERSION(RELEASE, [MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
2 | dnl Test for Apache | ||
3 | dnl | ||
4 | AC_DEFUN([TEST_APACHE_VERSION], | ||
5 | [dnl | ||
6 | AC_REQUIRE([AC_CANONICAL_TARGET]) | ||
7 | releasetest=$1 | ||
8 | min_apache_version="$2" | ||
9 | no_apache="" | ||
10 | ac_save_CFLAGS="$CFLAGS" | ||
11 | CFLAGS="$CFLAGS $AP_CFLAGS" | ||
12 | if test $releasetest -eq 20; then | ||
13 | CFLAGS="$CFLAGS $APU_INCLUDES $APR_INCLUDES" | ||
14 | fi | ||
15 | AC_TRY_RUN([ | ||
16 | #include <stdio.h> | ||
17 | #include <stdlib.h> | ||
18 | #include <string.h> | ||
19 | #include "httpd.h" | ||
20 | |||
21 | #ifndef AP_SERVER_BASEREVISION | ||
22 | #define AP_SERVER_BASEREVISION SERVER_BASEREVISION | ||
23 | #endif | ||
24 | |||
25 | char* my_strdup (char *str) | ||
26 | { | ||
27 | char *new_str; | ||
28 | |||
29 | if (str) { | ||
30 | new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); | ||
31 | strcpy (new_str, str); | ||
32 | } else | ||
33 | new_str = NULL; | ||
34 | |||
35 | return new_str; | ||
36 | } | ||
37 | |||
38 | int main (int argc, char *argv[]) | ||
39 | { | ||
40 | int major1, minor1, micro1; | ||
41 | int major2, minor2, micro2; | ||
42 | char *tmp_version; | ||
43 | |||
44 | { FILE *fp = fopen("conf.apachetest", "a"); if ( fp ) fclose(fp); } | ||
45 | |||
46 | tmp_version = my_strdup("$min_apache_version"); | ||
47 | if (sscanf(tmp_version, "%d.%d.%d", &major1, &minor1, µ1) != 3) { | ||
48 | printf("%s, bad version string\n", "$min_apache_version"); | ||
49 | exit(1); | ||
50 | } | ||
51 | tmp_version = my_strdup(AP_SERVER_BASEREVISION); | ||
52 | if (sscanf(tmp_version, "%d.%d.%d", &major2, &minor2, µ2) != 3) { | ||
53 | printf("%s, bad version string\n", AP_SERVER_BASEREVISION); | ||
54 | exit(1); | ||
55 | } | ||
56 | |||
57 | if ( (major2 == major1) && | ||
58 | ( (minor2 > minor1) || | ||
59 | ((minor2 == minor1) && (micro2 >= micro1)) ) ) { | ||
60 | exit(0); | ||
61 | } else { | ||
62 | exit(1); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | ],, no_apache=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) | ||
67 | CFLAGS="$ac_save_CFLAGS" | ||
68 | |||
69 | if test "x$no_apache" = x ; then | ||
70 | ifelse([$3], , :, [$3]) | ||
71 | else | ||
72 | if test -f conf.apachetest ; then | ||
73 | : | ||
74 | else | ||
75 | echo "*** Could not run Apache test program, checking why..." | ||
76 | CFLAGS="$CFLAGS $AP_CFLAGS" | ||
77 | if test $releasetest -eq 20; then | ||
78 | CFLAGS="$CFLAGS $APU_INCLUDES $APR_INCLUDES" | ||
79 | fi | ||
80 | AC_TRY_LINK([ | ||
81 | #include <stdio.h> | ||
82 | #include "httpd.h" | ||
83 | |||
84 | int 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([$4], , :, [$4]) | ||
94 | fi | ||
95 | rm -f conf.apachetest | ||
96 | ]) | ||