]> granicus.if.org Git - apache/blob - acinclude.m4
Add an error condition to the filter code. Basically, if somehow we get
[apache] / acinclude.m4
1  
2 AC_DEFUN(APACHE_CONFIG_NICE,[
3   rm -f $1
4   cat >$1<<EOF
5 #! /bin/sh
6 #
7 # Created by configure
8
9 EOF
10
11   for arg in [$]0 "[$]@"; do
12     echo "\"[$]arg\" \\" >> $1
13   done
14   echo '"[$]@"' >> $1
15   chmod +x $1
16 ])
17
18 AC_DEFUN(APACHE_PASSTHRU,[
19   unset ac_cv_pass_$1
20   AC_CACHE_VAL(ac_cv_pass_$1, [ac_cv_pass_$1=$$1])
21 ])
22
23 dnl APACHE_SUBST(VARIABLE)
24 dnl Makes VARIABLE available in generated files
25 dnl (do not use @variable@ in Makefiles, but $(variable))
26 AC_DEFUN(APACHE_SUBST,[
27   APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
28   AC_SUBST($1)
29 ])
30
31 dnl APACHE_FAST_OUTPUT(FILENAME)
32 dnl Perform substitutions on FILENAME (Makefiles only)
33 AC_DEFUN(APACHE_FAST_OUTPUT,[
34   APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
35 ])
36
37 dnl APACHE_MKDIR_P_CHECK
38 dnl checks whether mkdir -p works
39 AC_DEFUN(APACHE_MKDIR_P_CHECK,[
40   AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
41     test -d conftestdir && rm -rf conftestdir
42     mkdir -p conftestdir/somedir >/dev/null 2>&1
43     if test -d conftestdir/somedir; then
44       ac_cv_mkdir_p=yes
45     else
46       ac_cv_mkdir_p=no
47     fi
48     rm -rf conftestdir
49   ])
50 ])
51
52 dnl APACHE_GEN_CONFIG_VARS
53 dnl Creates config_vars.mk
54 AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
55   APACHE_SUBST(abs_srcdir)
56   APACHE_SUBST(bindir)
57   APACHE_SUBST(cgidir)
58   APACHE_SUBST(logdir)
59   APACHE_SUBST(exec_prefix)
60   APACHE_SUBST(libexecdir)
61   APACHE_SUBST(htdocsdir)
62   APACHE_SUBST(includedir)
63   APACHE_SUBST(iconsdir)
64   APACHE_SUBST(sysconfdir)
65   APACHE_SUBST(progname)
66   APACHE_SUBST(prefix)
67   APACHE_SUBST(CC)
68   APACHE_SUBST(CFLAGS)
69   APACHE_SUBST(CPPFLAGS)
70   APACHE_SUBST(CXX)
71   APACHE_SUBST(CXXFLAGS)
72   APACHE_SUBST(LTFLAGS)
73   APACHE_SUBST(LDFLAGS)
74   APACHE_SUBST(DEFS)
75   APACHE_SUBST(LIBTOOL)
76   APACHE_SUBST(SHELL)
77   APACHE_SUBST(MODULE_DIRS)
78   APACHE_SUBST(PORT)
79
80   abs_srcdir="`(cd $srcdir && pwd)`"
81
82   APACHE_MKDIR_P_CHECK
83   echo creating config_vars.mk
84   > config_vars.mk
85   for i in $APACHE_VAR_SUBST; do
86     eval echo "$i = \$$i" >> config_vars.mk
87   done
88 ])
89
90 dnl APACHE_GEN_MAKEFILES
91 dnl Creates Makefiles
92 AC_DEFUN(APACHE_GEN_MAKEFILES,[
93   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $APACHE_FAST_OUTPUT_FILES
94 ])
95
96 AC_DEFUN(APACHE_LIBTOOL_SILENT,[
97   LIBTOOL='$(SHELL) $(top_builddir)/libtool --silent'
98 ])
99
100     
101 dnl ## APACHE_OUTPUT(file)
102 dnl ## adds "file" to the list of files generated by AC_OUTPUT
103 dnl ## This macro can be used several times.
104 AC_DEFUN(APACHE_OUTPUT, [
105   APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
106 ])
107
108 dnl
109 dnl AC_ADD_LIBRARY(library)
110 dnl
111 dnl add a library to the link line
112 dnl
113 AC_DEFUN(AC_ADD_LIBRARY,[
114   APACHE_ONCE(LIBRARY, $1, [
115     EXTRA_LIBS="$EXTRA_LIBS -l$1"
116   ])
117 ])
118
119 dnl
120 dnl AC_CHECK_DEFINE(macro, headerfile)
121 dnl
122 dnl checks for the macro in the header file
123 dnl
124 AC_DEFUN(AC_CHECK_DEFINE,[
125   AC_CACHE_CHECK(for $1 in $2, ac_cv_define_$1,
126   AC_EGREP_CPP([YES_IS_DEFINED], [
127 #include <$2>
128 #ifdef $1
129 YES_IS_DEFINED
130 #endif
131   ], ac_cv_define_$1=yes, ac_cv_define_$1=no))
132   if test "$ac_cv_define_$1" = "yes" ; then
133       AC_DEFINE(HAVE_$1,,
134           [Define if the macro "$1" is defined on this system])
135   fi
136 ])
137
138 dnl
139 dnl AC_TYPE_RLIM_T
140 dnl
141 dnl If rlim_t is not defined, define it to int
142 dnl
143 AC_DEFUN(AC_TYPE_RLIM_T, [
144   AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
145     AC_TRY_COMPILE([
146 #include <sys/types.h>
147 #include <sys/time.h>
148 #include <sys/resource.h>
149 ], [rlim_t spoon;], [
150       ac_cv_type_rlim_t=yes
151     ],[ac_cv_type_rlim_t=no
152     ])
153   ])
154   if test "$ac_cv_type_rlim_t" = "no" ; then
155       AC_DEFINE(rlim_t, int,
156           [Define to 'int' if <sys/resource.h> doesn't define it for us])
157   fi
158 ])
159
160 dnl
161 dnl APACHE_ONCE(namespace, variable, code)
162 dnl
163 dnl execute code, if variable is not set in namespace
164 dnl
165 AC_DEFUN(APACHE_ONCE,[
166   unique=`echo $ac_n "$2$ac_c" | tr -cd a-zA-Z0-9`
167   cmd="echo $ac_n \"\$$1$unique$ac_c\""
168   if test -n "$unique" && test "`eval $cmd`" = "" ; then
169     eval "$1$unique=set"
170     $3
171   fi
172 ])
173
174 sinclude(lib/apr/apr_common.m4)
175 sinclude(lib/apr/hints.m4)
176
177 dnl
178 dnl APACHE_INADDR_NONE
179 dnl
180 dnl checks for missing INADDR_NONE macro
181 dnl
182 AC_DEFUN(APACHE_INADDR_NONE,[
183   AC_CACHE_CHECK(whether system defines INADDR_NONE, ac_cv_inaddr_none,[
184   AC_TRY_COMPILE([
185 #ifdef HAVE_SYS_TYPES_H
186 #include <sys/types.h>
187 #endif
188 #ifdef HAVE_SYS_SOCKET_H
189 #include <sys/socket.h>
190 #endif
191 #ifdef HAVE_NETINET_IN_H
192 #include <netinet/in.h>
193 #endif
194 #ifdef HAVE_ARPA_INET_H
195 #include <arpa/inet.h>
196 #endif
197 ],[
198 unsigned long foo = INADDR_NONE;
199 ],[
200     ac_cv_inaddr_none=yes
201 ],[
202     ac_cv_inaddr_none=no
203 ])])
204   if test "$ac_cv_inaddr_none" = "no"; then     
205     AC_DEFINE(INADDR_NONE, ((unsigned int) 0xffffffff), [ ])
206   fi
207 ])
208
209 AC_DEFUN(APACHE_CHECK_SIGWAIT_ONE_ARG,[
210   AC_CACHE_CHECK(whether sigwait takes one argument,ac_cv_sigwait_one_arg,[
211   AC_TRY_COMPILE([
212 #ifdef __NETBSD__
213     /* When using the unproven-pthreads package, we need to pull in this 
214      * header to get a prototype for sigwait().  Else things will fail later
215      * on.  XXX Should probably be fixed in the unproven-pthreads package.
216      */
217 #include <pthread.h>
218 #endif
219 #include <signal.h>
220 ],[
221   sigset_t set;
222
223   sigwait(&set);
224 ],[
225   ac_cv_sigwait_one_arg=yes
226 ],[
227   ac_cv_sigwait_one_arg=no
228 ])])
229   if test "$ac_cv_sigwait_one_arg" = "yes"; then
230     AC_DEFINE(SIGWAIT_TAKES_ONE_ARG,1,[ ])
231   fi
232 ])
233
234 AC_DEFUN(APACHE_EBCDIC,[
235   AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
236   AC_TRY_RUN( [
237 int main(void) { 
238   return (unsigned char)'A' != (unsigned char)0xC1; 
239
240 ],[
241   ac_cv_ebcdic="yes"
242 ],[
243   ac_cv_ebcdic="no"
244 ],[
245   ac_cv_ebcdic="no"
246 ])])
247   if test "$ac_cv_ebcdic" = "yes"; then
248     AC_DEFINE(CHARSET_EBCDIC,, [Define if system uses EBCDIC])
249   fi
250 ])
251
252 dnl APACHE_MODPATH_INIT(modpath)
253 AC_DEFUN(APACHE_MODPATH_INIT,[
254   current_dir=$1
255   modpath_current=modules/$1
256   modpath_static=
257   modpath_shared=
258   test -d $1 || $srcdir/helpers/mkdir.sh $modpath_current
259   > $modpath_current/modules.mk
260 ])dnl
261 dnl
262 AC_DEFUN(APACHE_MODPATH_FINISH,[
263   echo "static = $modpath_static" >> $modpath_current/modules.mk
264   echo "shared = $modpath_shared" >> $modpath_current/modules.mk
265   if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
266     MODULE_DIRS="$MODULE_DIRS $current_dir"
267   fi
268   APACHE_FAST_OUTPUT($modpath_current/Makefile)
269 ])dnl
270 dnl
271 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
272 AC_DEFUN(APACHE_MODPATH_ADD,[
273   if test -z "$3"; then
274     objects="mod_$1.lo"
275   else
276     objects="$3"
277   fi
278
279   if test -z "$module_standalone"; then
280     if test -z "$2"; then
281       libname="libapachemod_$1.la"
282       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
283       modpath_static="$modpath_static $libname"
284       cat >>$modpath_current/modules.mk<<EOF
285 $libname: $objects
286         \$(LINK) $objects
287 EOF
288     else
289       apache_need_shared=yes
290       libname="mod_$1.la"
291       shobjects=`echo $objects | sed 's/\.lo/.slo/'`
292       modpath_shared="$modpath_shared $libname"
293       cat >>$modpath_current/modules.mk<<EOF
294 $libname: $shobjects
295         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
296 EOF
297     fi
298   fi
299 ])dnl
300 dnl
301 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
302 AC_DEFUN(APACHE_MODULE,[
303   AC_MSG_CHECKING(whether to enable mod_$1)
304   define([optname],[  --]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
305   AC_ARG_ENABLE(translit($1,_,-),optname() substr([                         ],len(optname()))$2,,enable_$1=ifelse($5,,no,$5))
306   undefine([optname])dnl
307   AC_MSG_RESULT($enable_$1)
308   if test "$enable_$1" != "no"; then
309     case "$enable_$1" in
310     shared*)
311       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
312       sharedobjs=yes
313       shared=yes;;
314     *)
315       MODLIST="$MODLIST ifelse($4,,$1,$4)"
316       if test "$1" = "so"; then
317           sharedobjs=yes
318       fi
319       shared="";;
320     esac
321     ifelse($6,,:,$6)
322     APACHE_MODPATH_ADD($1, $shared, $3)
323   fi
324 ])dnl
325 dnl
326 dnl APACHE_LAYOUT(configlayout, layoutname)
327 AC_DEFUN(APACHE_LAYOUT,[
328   if test ! -f $srcdir/../config.layout; then
329     echo "** Error: Layout file $srcdir/../config.layout not found"
330     echo "** Error: Cannot use undefined layout '$LAYOUT'"
331     exit 1
332   fi
333   pldconf=config.pld
334   changequote({,})
335   sed -e "1,/[  ]*<[lL]ayout[   ]*$2[   ]*>[    ]*/d" \
336       -e '/[    ]*<\/Layout>[   ]*/,$d' \
337       -e "s/^[  ]*//g" \
338       -e "s/:[  ]*/=\'/g" \
339       -e "s/[   ]*$/'/g" \
340       $1 > $pldconf
341   changequote([,])
342   layout_name=$name
343   . $pldconf
344   rm $pldconf
345   for var in prefix exec_prefix bindir sbindir libexecdir mandir \
346              sysconfdir datadir iconsdir htdocsdir cgidir includedir \
347              localstatedir runtimedir logfiledir proxycachedir; do
348     eval "val=\"\$$var\""
349     case $val in
350       *+)
351         val=`echo $val | sed -e 's;\+$;;'`
352         eval "$var=\"\$val\""
353         autosuffix=yes
354         ;;
355       *)
356         autosuffix=no
357         ;;
358     esac
359     val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
360     if test "$autosuffix" = "yes"; then
361       if echo $val | grep apache >/dev/null; then
362         addtarget=no
363       else
364         addtarget=yes
365       fi
366       if test "$addtarget" = "yes"; then
367         val="$val/apache"
368       fi
369     fi
370     eval "$var=\"$val\""
371   done
372 ])dnl
373 dnl
374 dnl APACHE_ENABLE_LAYOUT
375 dnl
376 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
377 AC_ARG_ENABLE(layout,
378 [  --enable-layout=LAYOUT],[
379   LAYOUT=$enableval
380 ])
381
382 if test -z "$LAYOUT"; then
383   htdocsdir='$(prefix)/htdocs'
384   iconsdir='$(prefix)/icons'
385   cgidir='$(prefix)/cgi-bin'
386   logdir='$(prefix)/logs'
387   sysconfdir='$(prefix)/conf'
388   layout_name=Apache
389 else  
390   APACHE_LAYOUT($srcdir/../config.layout, $LAYOUT)
391 fi
392
393 AC_MSG_CHECKING(for chosen layout)
394 AC_MSG_RESULT($layout_name)
395 ])dnl
396 dnl
397 dnl APACHE_ENABLE_SHARED
398 dnl
399 AC_DEFUN(APACHE_ENABLE_SHARED,[
400 AC_ARG_ENABLE(mods-shared,
401 [  --enable-mods-shared=MODULE-LIST],[
402   for i in $enableval; do
403         eval "enable_$i=shared"
404   done
405 ])
406 ])dnl
407 dnl
408 dnl APACHE_ENABLE_MODULES
409 dnl
410 AC_DEFUN(APACHE_ENABLE_MODULES,[
411 AC_ARG_ENABLE(modules,
412 [  --enable-modules=MODULE-LIST],[
413   for i in $enableval; do
414     eval "enable_$i=yes"
415   done
416 ])
417 ])dnl
418
419 AC_DEFUN(APACHE_REQUIRE_CXX,[
420   if test -z "$apache_cxx_done"; then
421     AC_PROG_CXX
422     AC_PROG_CXXCPP
423     apache_cxx_done=yes
424   fi
425 ])