]> granicus.if.org Git - apache/blob - acinclude.m4
Backport the CSS security fixes to Apache 2.0a. Or is that forward
[apache] / acinclude.m4
1
2 AC_DEFUN(APACHE_PASSTHRU,[
3   unset ac_cv_pass_$1
4   AC_CACHE_VAL(ac_cv_pass_$1, [ac_cv_pass_$1=$$1])
5 ])
6
7 dnl APACHE_SUBST(VARIABLE)
8 dnl Makes VARIABLE available in generated files
9 dnl (do not use @variable@ in Makefiles, but $(variable))
10 AC_DEFUN(APACHE_SUBST,[
11   APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
12   AC_SUBST($1)
13 ])
14
15 dnl APACHE_FAST_OUTPUT(FILENAME)
16 dnl Perform substitutions on FILENAME (Makefiles only)
17 AC_DEFUN(APACHE_FAST_OUTPUT,[
18   APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
19 ])
20
21 dnl APACHE_MKDIR_P_CHECK
22 dnl checks whether mkdir -p works
23 AC_DEFUN(APACHE_MKDIR_P_CHECK,[
24   AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
25     test -d conftestdir && rm -rf conftestdir
26     mkdir -p conftestdir/somedir >/dev/null 2>&1
27     if test -d conftestdir/somedir; then
28       ac_cv_mkdir_p=yes
29     else
30       ac_cv_mkdir_p=no
31     fi
32     rm -rf conftestdir
33   ])
34 ])
35
36 dnl APACHE_FAST_GENERATE
37 dnl Creates Makefiles and config_vars.mk
38 AC_DEFUN(APACHE_FAST_GENERATE,[
39   APACHE_SUBST(abs_srcdir)
40   APACHE_SUBST(bindir)
41   APACHE_SUBST(cgidir)
42   APACHE_SUBST(logdir)
43   APACHE_SUBST(exec_prefix)
44   APACHE_SUBST(libexecdir)
45   APACHE_SUBST(htdocsdir)
46   APACHE_SUBST(includedir)
47   APACHE_SUBST(iconsdir)
48   APACHE_SUBST(sysconfdir)
49   APACHE_SUBST(prefix)
50   APACHE_SUBST(CC)
51   APACHE_SUBST(CFLAGS)
52   APACHE_SUBST(CPPFLAGS)
53   APACHE_SUBST(LTFLAGS)
54   APACHE_SUBST(LDFLAGS)
55   APACHE_SUBST(DEFS)
56   APACHE_SUBST(LIBTOOL)
57   APACHE_SUBST(SHELL)
58   APACHE_SUBST(MODULE_DIRS)
59
60   abs_srcdir="`(cd $srcdir && pwd)`"
61
62   APACHE_MKDIR_P_CHECK
63   echo creating config_vars.mk
64   > config_vars.mk
65   for i in $APACHE_VAR_SUBST; do
66     eval echo "$i = \$$i" >> config_vars.mk
67   done
68   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $APACHE_FAST_OUTPUT_FILES
69 ])
70
71 AC_DEFUN(APACHE_LIBTOOL_SILENT,[
72   LIBTOOL='$(SHELL) $(top_builddir)/libtool --silent'
73 ])
74
75     
76 dnl ## APACHE_OUTPUT(file)
77 dnl ## adds "file" to the list of files generated by AC_OUTPUT
78 dnl ## This macro can be used several times.
79 AC_DEFUN(APACHE_OUTPUT, [
80   APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
81 ])
82
83 dnl
84 dnl AC_ADD_LIBRARY(library)
85 dnl
86 dnl add a library to the link line
87 dnl
88 AC_DEFUN(AC_ADD_LIBRARY,[
89   APACHE_ONCE(LIBRARY, $1, [
90     EXTRA_LIBS="$EXTRA_LIBS -l$1"
91   ])
92 ])
93
94 dnl
95 dnl AC_CHECK_DEFINE(macro, headerfile)
96 dnl
97 dnl checks for the macro in the header file
98 dnl
99 AC_DEFUN(AC_CHECK_DEFINE,[
100   AC_CACHE_CHECK(for $1 in $2, ac_cv_define_$1,
101   AC_EGREP_CPP([YES_IS_DEFINED], [
102 #include <$2>
103 #ifdef $1
104 YES_IS_DEFINED
105 #endif
106   ], ac_cv_define_$1=yes, ac_cv_define_$1=no))
107   if test "$ac_cv_define_$1" = "yes" ; then
108       AC_DEFINE(HAVE_$1,,
109           [Define if the macro "$1" is defined on this system])
110   fi
111 ])
112
113 dnl
114 dnl AC_TYPE_RLIM_T
115 dnl
116 dnl If rlim_t is not defined, define it to int
117 dnl
118 AC_DEFUN(AC_TYPE_RLIM_T, [
119   AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
120     AC_TRY_COMPILE([#include <sys/resource.h>], [rlim_t spoon;], [
121       ac_cv_type_rlim_t=yes
122     ],[ac_cv_type_rlim_t=no
123     ])
124   ])
125   if test "$ac_ac_type_rlim_t" = "no" ; then
126       AC_DEFINE(rlim_t, int,
127           [Define to 'int' if <sys/resource.h> doesn't define it for us])
128   fi
129 ])
130
131 dnl
132 dnl APACHE_ONCE(namespace, variable, code)
133 dnl
134 dnl execute code, if variable is not set in namespace
135 dnl
136 AC_DEFUN(APACHE_ONCE,[
137   unique=`echo $ac_n "$2$ac_c" | tr -cd a-zA-Z0-9`
138   cmd="echo $ac_n \"\$$1$unique$ac_c\""
139   if test -n "$unique" && test "`eval $cmd`" = "" ; then
140     eval "$1$unique=set"
141     $3
142   fi
143 ])
144
145 sinclude(lib/apr/threads.m4)
146
147 dnl
148 dnl APACHE_INADDR_NONE
149 dnl
150 dnl checks for missing INADDR_NONE macro
151 dnl
152 AC_DEFUN(APACHE_INADDR_NONE,[
153   AC_CACHE_CHECK(whether system defines INADDR_NONE, ac_cv_inaddr_none,[
154   AC_TRY_COMPILE([
155 #ifdef HAVE_SYS_TYPES_H
156 #include <sys/types.h>
157 #endif
158 #ifdef HAVE_SYS_SOCKET_H
159 #include <sys/socket.h>
160 #endif
161 #ifdef HAVE_NETINET_IN_H
162 #include <netinet/in.h>
163 #endif
164 #ifdef HAVE_ARPA_INET_H
165 #include <arpa/inet.h>
166 #endif
167 ],[
168 unsigned long foo = INADDR_NONE;
169 ],[
170     ac_cv_inaddr_none=yes
171 ],[
172     ac_cv_inaddr_none=no
173 ])])
174   if test "$ac_cv_inaddr_none" = "no"; then     
175     AC_DEFINE(INADDR_NONE, ((unsigned int) 0xffffffff), [ ])
176   fi
177 ])
178
179 AC_DEFUN(APACHE_CHECK_SHM_RW,[
180   AC_CACHE_CHECK([whether system defines SHM_R,SHM_W],ac_cv_shm_rw,[
181   AC_TRY_COMPILE([
182 #include <sys/types.h>
183 #include <sys/ipc.h>
184 #include <sys/shm.h>
185 ],[
186   int x = SHM_R | SHM_W;
187 ],[
188   ac_cv_shm_rw=yes
189 ],[
190   ac_cv_shm_rw=no
191 ])])
192   if test "$ac_cv_shm_rw" = "no"; then
193     AC_DEFINE(SHM_R, 0x400, [ ])
194     AC_DEFINE(SHM_W, 0x200, [ ])
195   fi
196 ])
197
198
199 dnl APACHE_MODPATH_INIT(modpath)
200 AC_DEFUN(APACHE_MODPATH_INIT,[
201   modpath_current=modules/$1
202   modpath_static=
203   modpath_shared=
204   test -d $1 || $srcdir/helpers/mkdir.sh $modpath_current
205   > $modpath_current/modules.mk
206   MODULE_DIRS="$MODULE_DIRS $1"
207 ])dnl
208 dnl
209 AC_DEFUN(APACHE_MODPATH_FINISH,[
210   echo "static = $modpath_static" >> $modpath_current/modules.mk
211   echo "shared = $modpath_shared" >> $modpath_current/modules.mk
212   APACHE_FAST_OUTPUT($modpath_current/Makefile)
213 ])dnl
214 dnl
215 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
216 AC_DEFUN(APACHE_MODPATH_ADD,[
217   if test -z "$3"; then
218     objects="mod_$1.lo"
219   else
220     objects="$3"
221   fi
222
223   if test -z "$module_standalone"; then
224     if test -z "$2"; then
225       libname="libapachemod_$1.la"
226       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
227       modpath_static="$modpath_static $libname"
228       cat >>$modpath_current/modules.mk<<EOF
229 $libname: $objects
230         \$(LINK) $objects
231 EOF
232     else
233       apache_need_shared=yes
234       libname="mod_$1.la"
235       shobjects=`echo $objects | sed 's/\.lo/.slo/'`
236       modpath_shared="$modpath_shared $libname"
237       cat >>$modpath_current/modules.mk<<EOF
238 $libname: $shobjects
239         \$(SHLINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
240 EOF
241     fi
242   fi
243 ])dnl
244 dnl
245 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
246 AC_DEFUN(APACHE_MODULE,[
247   AC_MSG_CHECKING(whether to enable mod_$1)
248   AC_ARG_ENABLE(translit($1,_,-),[  --]ifelse($5,yes,disable,enable)[-]translit($1,_,-),,enable_$1=ifelse($5,,no,$5))
249   AC_MSG_RESULT($enable_$1)
250   if test "$enable_$1" != "no"; then
251     case "$enable_$1" in
252     shared*)
253       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
254       sharedobjs=yes
255       shared=yes;;
256     *)
257       MODLIST="$MODLIST ifelse($4,,$1,$4)"
258       shared="";;
259     esac
260     ifelse($6,,:,$6)
261     APACHE_MODPATH_ADD($1, $shared, $3)
262   fi
263 ])dnl
264 dnl
265 dnl APACHE_LAYOUT(configlayout, layoutname)
266 AC_DEFUN(APACHE_LAYOUT,[
267   pldconf=config.pld
268   changequote({,})
269   sed -e "1,/[  ]*<[lL]ayout[   ]*$2[   ]*>[    ]*/d" \
270       -e '/[    ]*<\/Layout>[   ]*/,$d' \
271       -e "s/^[  ]*//g" \
272       -e "s/:[  ]*/=\'/g" \
273       -e "s/[   ]*$/'/g" \
274       $1 > $pldconf
275   changequote([,])
276   layout_name=$name
277   . $pldconf
278   rm $pldconf
279   for var in prefix exec_prefix bindir sbindir libexecdir mandir \
280              sysconfdir datadir iconsdir htdocsdir cgidir includedir \
281              localstatedir runtimedir logfiledir proxycachedir; do
282     eval "val=\"\$$var\""
283     case $val in
284       *+)
285         val=`echo $val | sed -e 's;\+$;;'`
286         eval "$var=\"\$val\""
287         autosuffix=yes
288         ;;
289       *)
290         autosuffix=no
291         ;;
292     esac
293     val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
294     if test "$autosuffix" = "yes"; then
295       if echo $val | grep apache >/dev/null; then
296         addtarget=no
297       else
298         addtarget=yes
299       fi
300       if test "$addtarget" = "yes"; then
301         val="$val/apache"
302       fi
303     fi
304     eval "$var=\"$val\""
305   done
306 ])dnl
307 dnl
308 dnl APACHE_ENABLE_LAYOUT
309 dnl
310 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
311 AC_ARG_ENABLE(layout,
312 [  --enable-layout=LAYOUT],[
313   LAYOUT=$enableval
314 ])
315
316 if test -z "$LAYOUT"; then
317   htdocsdir='$(prefix)/htdocs'
318   iconsdir='$(prefix)/icons'
319   cgidir='$(prefix)/cgi-bin'
320   logdir='$(prefix)/logs'
321   sysconfdir='$(prefix)/conf'
322   layout_name=Apache
323 else  
324   APACHE_LAYOUT($srcdir/../config.layout, $LAYOUT)
325 fi
326
327 AC_MSG_CHECKING(for chosen layout)
328 AC_MSG_RESULT($layout_name)
329 ])dnl
330 dnl
331 dnl APACHE_ENABLE_SHARED
332 dnl
333 AC_DEFUN(APACHE_ENABLE_SHARED,[
334 AC_ARG_ENABLE(shared,
335 [  --enable-shared=MODULE-LIST],[
336   for i in $enableval; do
337         eval "enable_$i=shared"
338   done
339 ])
340 ])dnl
341 dnl
342 dnl APACHE_ENABLE_MODULES
343 dnl
344 AC_DEFUN(APACHE_ENABLE_MODULES,[
345 AC_ARG_ENABLE(modules,
346 [  --enable-modules=MODULE-LIST],[
347   for i in $enableval; do
348     eval "enable_$i=yes"
349   done
350 ])
351 ])dnl