]> granicus.if.org Git - apache/blob - acinclude.m4
Return "1" to apr_table_do()
[apache] / acinclude.m4
1
2 dnl APACHE_SUBST(VARIABLE)
3 dnl Makes VARIABLE available in generated files
4 dnl (do not use @variable@ in Makefiles, but $(variable))
5 AC_DEFUN(APACHE_SUBST,[
6   APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
7   AC_SUBST($1)
8 ])
9
10 dnl APACHE_FAST_OUTPUT(FILENAME)
11 dnl Perform substitutions on FILENAME (Makefiles only)
12 AC_DEFUN(APACHE_FAST_OUTPUT,[
13   APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
14 ])
15
16 dnl APACHE_MKDIR_P_CHECK
17 dnl checks whether mkdir -p works
18 AC_DEFUN(APACHE_MKDIR_P_CHECK,[
19   AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
20     test -d conftestdir && rm -rf conftestdir
21     mkdir -p conftestdir/somedir >/dev/null 2>&1
22     if test -d conftestdir/somedir; then
23       ac_cv_mkdir_p=yes
24     else
25       ac_cv_mkdir_p=no
26     fi
27     rm -rf conftestdir
28   ])
29 ])
30
31 dnl APACHE_GEN_CONFIG_VARS
32 dnl Creates config_vars.mk
33 AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
34   APACHE_SUBST(abs_srcdir)
35   APACHE_SUBST(bindir)
36   APACHE_SUBST(sbindir)
37   APACHE_SUBST(cgidir)
38   APACHE_SUBST(logfiledir)
39   APACHE_SUBST(exec_prefix)
40   APACHE_SUBST(datadir)
41   APACHE_SUBST(localstatedir)
42   APACHE_SUBST(libexecdir)
43   APACHE_SUBST(htdocsdir)
44   APACHE_SUBST(includedir)
45   APACHE_SUBST(iconsdir)
46   APACHE_SUBST(sysconfdir)
47   APACHE_SUBST(other_targets)
48   APACHE_SUBST(progname)
49   APACHE_SUBST(prefix)
50   APACHE_SUBST(AWK)
51   APACHE_SUBST(CC)
52   APACHE_SUBST(CPP)
53   APACHE_SUBST(CXX)
54   APACHE_SUBST(CPPFLAGS)
55   APACHE_SUBST(CFLAGS)
56   APACHE_SUBST(CXXFLAGS)
57   APACHE_SUBST(LTFLAGS)
58   APACHE_SUBST(LDFLAGS)
59   APACHE_SUBST(LT_LDFLAGS)
60   APACHE_SUBST(SH_LDFLAGS)
61   APACHE_SUBST(HTTPD_LDFLAGS)
62   APACHE_SUBST(LIBS)
63   APACHE_SUBST(DEFS)
64   APACHE_SUBST(INCLUDES)
65   APACHE_SUBST(NOTEST_CPPFLAGS)
66   APACHE_SUBST(NOTEST_CFLAGS)
67   APACHE_SUBST(NOTEST_CXXFLAGS)
68   APACHE_SUBST(NOTEST_LDFLAGS)
69   APACHE_SUBST(NOTEST_LIBS)
70   APACHE_SUBST(EXTRA_CPPFLAGS)
71   APACHE_SUBST(EXTRA_CFLAGS)
72   APACHE_SUBST(EXTRA_CXXFLAGS)
73   APACHE_SUBST(EXTRA_LDFLAGS)
74   APACHE_SUBST(EXTRA_LIBS)
75   APACHE_SUBST(EXTRA_INCLUDES)
76   APACHE_SUBST(LIBTOOL)
77   APACHE_SUBST(SHELL)
78   APACHE_SUBST(MODULE_DIRS)
79   APACHE_SUBST(MODULE_CLEANDIRS)
80   APACHE_SUBST(PORT)
81   APACHE_SUBST(CORE_IMPLIB_FILE)
82   APACHE_SUBST(CORE_IMPLIB)
83   APACHE_SUBST(SH_LIBTOOL)
84   APACHE_SUBST(MK_IMPLIB)
85   APACHE_SUBST(INSTALL_PROG_FLAGS)
86
87   abs_srcdir="`(cd $srcdir && pwd)`"
88
89   APACHE_MKDIR_P_CHECK
90   echo creating config_vars.mk
91   > config_vars.mk
92   for i in $APACHE_VAR_SUBST; do
93     eval echo "$i = \$$i" >> config_vars.mk
94   done
95 ])
96
97 dnl APACHE_GEN_MAKEFILES
98 dnl Creates Makefiles
99 AC_DEFUN(APACHE_GEN_MAKEFILES,[
100   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
101 ])
102
103 dnl ## APACHE_OUTPUT(file)
104 dnl ## adds "file" to the list of files generated by AC_OUTPUT
105 dnl ## This macro can be used several times.
106 AC_DEFUN(APACHE_OUTPUT, [
107   APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
108 ])
109
110 dnl
111 dnl APACHE_TYPE_RLIM_T
112 dnl
113 dnl If rlim_t is not defined, define it to int
114 dnl
115 AC_DEFUN(APACHE_TYPE_RLIM_T, [
116   AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
117     AC_TRY_COMPILE([
118 #include <sys/types.h>
119 #include <sys/time.h>
120 #include <sys/resource.h>
121 ], [rlim_t spoon;], [
122       ac_cv_type_rlim_t=yes
123     ],[ac_cv_type_rlim_t=no
124     ])
125   ])
126   if test "$ac_cv_type_rlim_t" = "no" ; then
127       AC_DEFINE(rlim_t, int,
128           [Define to 'int' if <sys/resource.h> doesn't define it for us])
129   fi
130 ])
131
132 dnl APACHE_MODPATH_INIT(modpath)
133 AC_DEFUN(APACHE_MODPATH_INIT,[
134   current_dir=$1
135   modpath_current=modules/$1
136   modpath_static=
137   modpath_shared=
138   test -d $1 || $srcdir/build/mkdir.sh $modpath_current
139   > $modpath_current/modules.mk
140 ])dnl
141 dnl
142 AC_DEFUN(APACHE_MODPATH_FINISH,[
143   echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
144   echo "static = $modpath_static" >> $modpath_current/modules.mk
145   echo "shared = $modpath_shared" >> $modpath_current/modules.mk
146   if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
147     MODULE_DIRS="$MODULE_DIRS $current_dir"
148   else
149     MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
150   fi
151   APACHE_FAST_OUTPUT($modpath_current/Makefile)
152 ])dnl
153 dnl
154 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
155 AC_DEFUN(APACHE_MODPATH_ADD,[
156   if test -z "$3"; then
157     objects="mod_$1.lo"
158   else
159     objects="$3"
160   fi
161
162   if test -z "$module_standalone"; then
163     if test -z "$2"; then
164       libname="mod_$1.la"
165       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
166       modpath_static="$modpath_static $libname"
167       cat >>$modpath_current/modules.mk<<EOF
168 $libname: $objects
169         \$(MOD_LINK) $objects
170 EOF
171     else
172       apache_need_shared=yes
173       libname="mod_$1.la"
174       shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
175       modpath_shared="$modpath_shared $libname"
176       cat >>$modpath_current/modules.mk<<EOF
177 $libname: $shobjects
178         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
179 EOF
180     fi
181   fi
182 ])dnl
183
184 dnl
185 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
186 dnl
187 dnl default is one of:
188 dnl   yes  -- enabled by default. user must explicitly disable.
189 dnl   no   -- disabled under default, most, all. user must explicitly enable.
190 dnl   most -- disabled by default. enabled explicitly or with most or all.
191 dnl   ""   -- disabled under default, most. enabled explicitly or with all.
192 dnl
193 dnl basically: yes/no is a hard setting. "most" means follow the "most"
194 dnl            setting. otherwise, fall under the "all" setting.
195 dnl            explicit yes/no always overrides.
196 dnl
197 AC_DEFUN(APACHE_MODULE,[
198   AC_MSG_CHECKING(whether to enable mod_$1)
199   define([optname],[  --]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
200   AC_ARG_ENABLE(translit($1,_,-),optname() substr([                         ],len(optname()))$2,,enable_$1=ifelse($5,,maybe-all,$5))
201   undefine([optname])dnl
202   _apmod_extra_msg=""
203   if test "$enable_$1" = "most"; then
204     if test "$module_selection" = "most" -o "$module_selection" = "all"; then
205       enable_$1=$module_default
206       _apmod_extra_msg=" ($module_selection)"
207     else
208       enable_$1=no
209     fi
210   elif test "$enable_$1" = "maybe-all"; then
211     if test "$module_selection" = "all"; then
212       enable_$1=$module_default
213       _apmod_extra_msg=" (all)"
214     else
215       enable_$1=no
216     fi
217   fi
218   AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
219   if test "$enable_$1" != "no"; then
220     case "$enable_$1" in
221     shared*)
222       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
223       sharedobjs=yes
224       shared=yes;;
225     *)
226       MODLIST="$MODLIST ifelse($4,,$1,$4)"
227       if test "$1" = "so"; then
228           sharedobjs=yes
229       fi
230       shared="";;
231     esac
232     ifelse([$6],,:,[$6])
233     APACHE_MODPATH_ADD($1, $shared, $3)
234   fi
235 ])dnl
236 dnl
237 dnl APACHE_LAYOUT(configlayout, layoutname)
238 AC_DEFUN(APACHE_LAYOUT,[
239   if test ! -f $srcdir/config.layout; then
240     echo "** Error: Layout file $srcdir/config.layout not found"
241     echo "** Error: Cannot use undefined layout '$LAYOUT'"
242     exit 1
243   fi
244   pldconf=./config.pld
245   changequote({,})
246   sed -e "1,/[  ]*<[lL]ayout[   ]*$2[   ]*>[    ]*/d" \
247       -e '/[    ]*<\/Layout>[   ]*/,$d' \
248       -e "s/^[  ]*//g" \
249       -e "s/:[  ]*/=\'/g" \
250       -e "s/[   ]*$/'/g" \
251       $1 > $pldconf
252   layout_name=$2
253   . $pldconf
254   rm $pldconf
255   for var in prefix exec_prefix bindir sbindir libexecdir mandir \
256              sysconfdir datadir iconsdir htdocsdir cgidir includedir \
257              localstatedir runtimedir logfiledir proxycachedir; do
258     eval "val=\"\$$var\""
259     case $val in
260       *+)
261         val=`echo $val | sed -e 's;\+$;;'`
262         eval "$var=\"\$val\""
263         autosuffix=yes
264         ;;
265       *)
266         autosuffix=no
267         ;;
268     esac
269     val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
270     val=`echo $val | sed -e 's:$\([a-z_]*\):$(\1):g'`
271     if test "$autosuffix" = "yes"; then
272       if echo $val | grep apache >/dev/null; then
273         addtarget=no
274       else
275         addtarget=yes
276       fi
277       if test "$addtarget" = "yes"; then
278         val="$val/apache"
279       fi
280     fi
281     eval "$var='$val'"
282   done
283   changequote([,])
284 ])dnl
285 dnl
286 dnl APACHE_ENABLE_LAYOUT
287 dnl
288 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
289 AC_ARG_ENABLE(layout,
290 [  --enable-layout=LAYOUT],[
291   LAYOUT=$enableval
292 ])
293
294 if test -z "$LAYOUT"; then
295   # XXX FIXME: this isn't a complete list of things that have to be set to 
296   # create the Apache layout in config.layout, and it really should just
297   # use what is specified in config.layout instead of duping it.
298   htdocsdir='$(prefix)/htdocs'
299   iconsdir='$(prefix)/icons'
300   cgidir='$(prefix)/cgi-bin'
301   logfiledir='$(prefix)/logs'
302   sysconfdir='${prefix}/conf'
303   libexecdir='${prefix}/modules'
304   layout_name=Apache
305 else 
306   APACHE_LAYOUT($srcdir/config.layout, $LAYOUT)
307 fi
308
309 AC_MSG_CHECKING(for chosen layout)
310 AC_MSG_RESULT($layout_name)
311 ])
312
313 dnl
314 dnl APACHE_ENABLE_MODULES
315 dnl
316 AC_DEFUN(APACHE_ENABLE_MODULES,[
317   module_selection=default
318   module_default=yes
319
320   AC_ARG_ENABLE(modules,
321   [  --enable-modules=MODULE-LIST],[
322     for i in $enableval; do
323       if test "$i" = "all" -o "$i" = "most"; then
324         module_selection=$i
325       else
326         eval "enable_$i=yes"
327       fi
328     done
329   ])
330   
331   AC_ARG_ENABLE(mods-shared,
332   [  --enable-mods-shared=MODULE-LIST],[
333     for i in $enableval; do
334       if test "$i" = "all" -o "$i" = "most"; then
335         module_selection=$i
336         module_default=shared
337       else
338         i=`echo $i | sed 's/-/_/g'`
339         eval "enable_$i=shared"
340       fi
341     done
342   ])
343 ])
344
345 AC_DEFUN(APACHE_REQUIRE_CXX,[
346   if test -z "$apache_cxx_done"; then
347     AC_PROG_CXX
348     AC_PROG_CXXCPP
349     apache_cxx_done=yes
350   fi
351 ])
352
353 dnl
354 dnl APACHE_CHECK_SSL_TOOLKIT
355 dnl
356 dnl Find the openssl toolkit installation and check it for the right
357 dnl version, then add its flags to INCLUDES and LIBS.  This should
358 dnl really be using a custom AC_TRY_COMPILE function to test the includes
359 dnl and then AC_TRY_LINK to test the libraries directly for the version,
360 dnl but that will require someone who knows how to program openssl.
361 dnl
362 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
363 if test "x$ap_ssltk_base" = "x"; then
364   AC_MSG_CHECKING(for SSL/TLS toolkit base)
365   ap_ssltk_base=""
366   AC_ARG_WITH(ssl, [  --with-ssl[=DIR]        SSL/TLS toolkit (OpenSSL)], [
367     if test "x$withval" != "xyes" -a "x$withval" != "x"; then
368       ap_ssltk_base="$withval"
369     fi
370   ])
371   if test "x$ap_ssltk_base" = "x"; then
372     AC_CACHE_VAL(ap_cv_ssltk,[
373       #
374       # shotgun approach: find all occurrences of the openssl program
375       #
376       ap_ssltk_try=""
377       for p in /usr/local/openssl/bin /usr/local/ssl/bin $path; do
378         if test -f "$p/openssl"; then
379           ap_ssltk_try="$ap_ssltk_try $p"
380         fi
381       done
382       if test "x$ap_ssltk_try" = "x"; then
383         AC_MSG_ERROR(['openssl' not found in path])
384       fi
385       for p in $ap_ssltk_try; do
386         ap_ssltk_version="`$p/openssl version`"
387         case "$ap_ssltk_version" in
388             "OpenSSL "[[1-9]]* | \
389             "OpenSSL "0.9.[[6-9]]* | \
390             "OpenSSL "0.[[1-9]][[0-9]]* )
391                 ap_cv_ssltk="`(cd $p/.. && pwd)`"
392                 break
393                 ;;
394             *)
395                 # skip because it is too old or a bad result
396                 ;;
397         esac
398       done
399       if test "x$ap_cv_ssltk" = "x"; then
400         AC_MSG_ERROR([requires OpenSSL 0.9.6 or higher])
401       fi
402     ])
403     ap_ssltk_base="$ap_cv_ssltk"
404   fi
405   if test ! -d $ap_ssltk_base; then
406     AC_MSG_ERROR([invalid SSL/TLS toolkit base directory $ap_ssltk_base])
407   fi
408   AC_MSG_RESULT($ap_ssltk_base)
409     
410   AC_MSG_CHECKING(for SSL/TLS toolkit version)
411   AC_MSG_RESULT($ap_ssltk_version)
412     
413   AC_MSG_CHECKING(for SSL/TLS toolkit includes)
414   ap_ssltk_incdir=""
415   for p in $ap_ssltk_base/include /usr/local/openssl/include \
416            /usr/local/ssl/include /usr/local/include /usr/include; do
417     if test -f "$p/openssl/ssl.h"; then
418       ap_ssltk_incdir="$p"
419       break
420     fi
421   done
422   if test "x$ap_ssltk_incdir" = "x"; then
423     AC_MSG_ERROR([OpenSSL headers not found])
424   fi
425   AC_MSG_RESULT($ap_ssltk_incdir)
426
427   AC_MSG_CHECKING(for SSL/TLS toolkit libraries)
428   ap_ssltk_libdir=""
429   for p in $ap_ssltk_base/lib /usr/local/openssl/lib \
430            /usr/local/ssl/lib /usr/local/lib /usr/lib /lib; do
431     if test -f "$p/libssl.a" -o -f "$p/libssl.so"; then
432       ap_ssltk_libdir="$p"
433       break
434     fi
435   done
436   if test ".$ap_ssltk_libdir" = .; then
437     AC_MSG_ERROR([OpenSSL libraries not found])
438   fi
439   AC_MSG_RESULT($ap_ssltk_libdir)
440
441   dnl #  annotate the Apache build environment with determined information
442   if test "x$ap_ssltk_incdir" != "x/usr/include"; then
443     APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir])
444   fi
445   if test "x$ap_ssltk_libdir" != "x/usr/lib"; then
446     APR_ADDTO(LIBS, [-L$ap_ssltk_libdir])
447     if test "x$ap_platform_runtime_link_flag" != "x"; then
448       APR_ADDTO(LIBS, [$ap_platform_runtime_link_flag$ap_ssltk_libdir])
449     fi
450   fi
451   APR_ADDTO(LIBS, [-lssl -lcrypto])
452   ap_cv_ssltk="$ap_ssltk_base"
453 fi
454 ])
455