root/cherokee/branches/0.5/cherokee.m4

Revision 1, 6.4 kB (checked in by alo, 4 years ago)

--

Line 
1 # Configure paths for Cherokee
2 # originally by Owen Taylor
3
4 dnl AM_PATH_CHEROKEE([MINIMUM-VERSION, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
5 dnl Test for CHEROKEE, and define CHEROKEE_CFLAGS and CHEROKEE_LIBS
6 dnl
7 AC_DEFUN([AM_PATH_CHEROKEE],[
8 AC_SYS_LARGEFILE
9
10 dnl
11 dnl Get the cflags and libraries from the cherokee-config script
12 dnl
13 AC_ARG_WITH(cherokee-prefix,[  --with-cherokee-prefix=PFX   Prefix where Cherokee is
14 installed (optional)],
15             cherokee_prefix="$withval", cherokee_prefix="")
16 AC_ARG_WITH(cherokee-exec-prefix,[  --with-cherokee-exec-prefix=PFX Exec prefix
17 where Cherokee is installed (optional)],
18             cherokee_exec_prefix="$withval", cherokee_exec_prefix="")
19 AC_ARG_ENABLE(cherokeetest, [  --disable-cherokeetest       Do not try to compile
20 and run a test Cherokee program],
21                     , enable_cherokeetest=yes)
22
23   if test x$cherokee_exec_prefix != x ; then
24      cherokee_args="$cherokee_args --exec-prefix=$cherokee_exec_prefix"
25      if test x${CHEROKEE_CONFIG+set} != xset ; then
26         CHEROKEE_CONFIG=$cherokee_exec_prefix/bin/cherokee-config
27      fi
28   fi
29   if test x$cherokee_prefix != x ; then
30      cherokee_args="$cherokee_args --prefix=$cherokee_prefix"
31      if test x${CHEROKEE_CONFIG+set} != xset ; then
32         CHEROKEE_CONFIG=$cherokee_prefix/bin/cherokee-config
33      fi
34   fi
35
36   AC_PATH_PROG(CHEROKEE_CONFIG, cherokee-config, no)
37   min_cherokee_version=ifelse([$1], ,0.4.18,$1)
38   AC_MSG_CHECKING(for CHEROKEE - version >= $min_cherokee_version)
39   no_cherokee=""
40   if test "$CHEROKEE_CONFIG" = "no" ; then
41     no_cherokee=yes
42   else
43     CHEROKEE_CFLAGS=`$CHEROKEE_CONFIG $cherokeeconf_args --cflags`
44     CHEROKEE_LIBS=`$CHEROKEE_CONFIG $cherokeeconf_args --libs`
45
46     cherokee_major_version=`$CHEROKEE_CONFIG $cherokee_args --version | \
47                  sed 's/\([[0-9]]\+\)\.\([[0-9]]\+\)\.\([[0-9]]\+\)\(b\?[[0-9]]\+\)/\1/'`
48     cherokee_minor_version=`$CHEROKEE_CONFIG $cherokee_args --version | \
49                  sed 's/\([[0-9]]\+\)\.\([[0-9]]\+\)\.\([[0-9]]\+\)\(b\?[[0-9]]\+\)/\2/'`
50     cherokee_micro_version=`$CHEROKEE_CONFIG $cherokee_config_args --version | \
51                  sed 's/\([[0-9]]\+\)\.\([[0-9]]\+\)\.\([[0-9]]\+\)\(b\?[[0-9]]\+\)/\3/'`
52     if test "x$enable_cherokeetest" = "xyes" ; then
53       ac_save_CFLAGS="$CFLAGS"
54       ac_save_LIBS="$LIBS"
55       CFLAGS="$CFLAGS $CHEROKEE_CFLAGS $SDL_CFLAGS"
56       LIBS="$LIBS $CHEROKEE_LIBS $SDL_LIBS"
57 dnl
58 dnl Now check if the installed CHEROKEE is sufficiently new. (Also sanity
59 dnl checks the results of cherokee-config to some extent
60 dnl
61       rm -f conf.cherokeetest
62       AC_TRY_RUN([
63 #include <stdio.h>
64 #include <stdlib.h>
65 #include <string.h>
66 #include "cherokee.h"
67
68 char*
69 my_strdup (char *str)
70 {
71   char *new_str;
72
73   if (str)
74     {
75       new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
76       strcpy (new_str, str);
77     }
78   else
79     new_str = NULL;
80
81   return new_str;
82 }
83
84 int main (int argc, char *argv[])
85 {
86   int major, minor, micro;
87   char *tmp_version;
88
89   /* This hangs on some systems (?)
90   system ("touch conf.cherokeetest");
91   */
92   { FILE *fp = fopen("conf.cherokeetest", "a"); if ( fp ) fclose(fp); }
93
94   /* HP/UX 9 (%@#!) writes to sscanf strings */
95   tmp_version = my_strdup("$min_cherokee_version");
96   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
97      printf("%s, bad version string\n", "$min_cherokee_version");
98      exit(1);
99    }
100
101    if (($cherokee_major_version  > major) ||
102       (($cherokee_major_version == major) && ($cherokee_minor_version  > minor)) ||
103       (($cherokee_major_version == major) && ($cherokee_minor_version == minor) && ($cherokee_micro_version >= micro)))
104     {
105       return 0;
106     }
107   else
108     {
109       printf("\n*** 'cherokee-config --version' returned %d.%d.%d, but the minimum version\n",
110                    $cherokee_major_version, $cherokee_minor_version, $cherokee_micro_version);
111       printf("*** of Cherokee required is %d.%d.%d. If cherokee-config is correct, then it is\n",
112                    major, minor, micro);
113       printf("*** best to upgrade to the required version.\n");
114       printf("*** If cherokee-config was wrong, set the environment variable CHEROKEE_CONFIG\n");
115       printf("*** to point to the correct copy of cherokee-config, and remove the file\n");
116       printf("*** config.cache before re-running configure\n");
117       return 1;
118     }
119 }
120
121 ],, no_cherokee=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
122        CFLAGS="$ac_save_CFLAGS"
123        LIBS="$ac_save_LIBS"
124      fi
125   fi
126   if test "x$no_cherokee" = x ; then
127      AC_MSG_RESULT(yes)
128      ifelse([$2], , :, [$2])
129   else
130      AC_MSG_RESULT(no)
131      if test "$CHEROKEE_CONFIG" = "no" ; then
132        echo "*** The cherokee-config script installed by Cherokee could not be found"
133        echo "*** If Cherokee was installed in PREFIX, make sure PREFIX/bin is in"
134        echo "*** your path, or set the CHEROKEE_CONFIG environment variable to the"
135        echo "*** full path to cherokee-config."
136      else
137        if test -f conf.cherokeetest ; then
138         :
139        else
140           echo "*** Could not run Cherokee test program, checking why..."
141           CFLAGS="$CFLAGS $CHEROKEE_CFLAGS $SDL_CFLAGS"
142           LIBS="$LIBS $CHEROKEE_LIBS $SDL_LIBS"
143           AC_TRY_LINK([
144 #include <stdio.h>
145 #include "cherokee.h"
146 ],      [ return 0; ],
147         [ echo "*** The test program compiled, but did not run. This usually means"
148           echo "*** that the run-time linker is not finding Cherokee or finding the wrong"
149           echo "*** version of Cherokee. If it is not finding Cherokee, you'll need to set your"
150           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
151           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
152           echo "*** is required on your system"
153           echo "***"
154           echo "*** If you have an old version installed, it is best to remove it, although"
155           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
156         [ echo "*** The test program failed to compile or link. See the file config.log for the"
157           echo "*** exact error that occured. This usually means Cherokee was incorrectly installed"
158           echo "*** or that you have moved Cherokee since it was installed. In the latter case, you"
159           echo "*** may want to edit the cherokee-config script: $CHEROKEE_CONFIG" ])
160           CFLAGS="$ac_save_CFLAGS"
161           LIBS="$ac_save_LIBS"
162        fi
163      fi
164      CHEROKEE_CFLAGS=""
165      CHEROKEE_LIBS=""
166      ifelse([$3], , :, [$3])
167   fi
168   AC_SUBST(CHEROKEE_CFLAGS)
169   AC_SUBST(CHEROKEE_LIBS)
170   rm -f conf.cherokeetest
171 ])
Note: See TracBrowser for help on using the browser.