]> granicus.if.org Git - apache/blob - acinclude.m4
Don't crap out if we couldn't gzip the file.
[apache] / acinclude.m4
1
2 dnl APACHE_HELP_STRING(LHS, RHS)
3 dnl Autoconf 2.50 can not handle substr correctly.  It does have 
4 dnl AC_HELP_STRING, so let's try to call it if we can.
5 dnl Note: this define must be on one line so that it can be properly returned
6 dnl as the help string.
7 AC_DEFUN(APACHE_HELP_STRING,[ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING($1,$2),[  ]$1 substr([                       ],len($1))$2)])dnl
8
9 dnl APACHE_SUBST(VARIABLE)
10 dnl Makes VARIABLE available in generated files
11 dnl (do not use @variable@ in Makefiles, but $(variable))
12 AC_DEFUN(APACHE_SUBST,[
13   APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
14   AC_SUBST($1)
15 ])
16
17 dnl APACHE_FAST_OUTPUT(FILENAME)
18 dnl Perform substitutions on FILENAME (Makefiles only)
19 AC_DEFUN(APACHE_FAST_OUTPUT,[
20   APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
21 ])
22
23 dnl APACHE_GEN_CONFIG_VARS
24 dnl Creates config_vars.mk
25 AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
26   APACHE_SUBST(abs_srcdir)
27   APACHE_SUBST(bindir)
28   APACHE_SUBST(sbindir)
29   APACHE_SUBST(cgidir)
30   APACHE_SUBST(logfiledir)
31   APACHE_SUBST(exec_prefix)
32   APACHE_SUBST(datadir)
33   APACHE_SUBST(localstatedir)
34   APACHE_SUBST(mandir)
35   APACHE_SUBST(libdir)
36   APACHE_SUBST(libexecdir)
37   APACHE_SUBST(htdocsdir)
38   APACHE_SUBST(manualdir)
39   APACHE_SUBST(includedir)
40   APACHE_SUBST(errordir)
41   APACHE_SUBST(iconsdir)
42   APACHE_SUBST(sysconfdir)
43   APACHE_SUBST(installbuilddir)
44   APACHE_SUBST(runtimedir)
45   APACHE_SUBST(proxycachedir)
46   APACHE_SUBST(other_targets)
47   APACHE_SUBST(progname)
48   APACHE_SUBST(prefix)
49   APACHE_SUBST(AWK)
50   APACHE_SUBST(CC)
51   APACHE_SUBST(CPP)
52   APACHE_SUBST(CXX)
53   APACHE_SUBST(CPPFLAGS)
54   APACHE_SUBST(CFLAGS)
55   APACHE_SUBST(CXXFLAGS)
56   APACHE_SUBST(LTFLAGS)
57   APACHE_SUBST(LDFLAGS)
58   APACHE_SUBST(LT_LDFLAGS)
59   APACHE_SUBST(SH_LDFLAGS)
60   APACHE_SUBST(HTTPD_LDFLAGS)
61   APACHE_SUBST(UTIL_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(nonssl_listen_stmt_1)
82   APACHE_SUBST(nonssl_listen_stmt_2)
83   APACHE_SUBST(CORE_IMPLIB_FILE)
84   APACHE_SUBST(CORE_IMPLIB)
85   APACHE_SUBST(SH_LIBS)
86   APACHE_SUBST(SH_LIBTOOL)
87   APACHE_SUBST(MK_IMPLIB)
88   APACHE_SUBST(INSTALL_PROG_FLAGS)
89   APACHE_SUBST(DSO_MODULES)
90   APACHE_SUBST(APR_BINDIR)
91   APACHE_SUBST(APU_BINDIR)
92
93   abs_srcdir="`(cd $srcdir && pwd)`"
94
95   echo creating config_vars.mk
96   test -d build || $mkdir_p build
97   > build/config_vars.mk
98   for i in $APACHE_VAR_SUBST; do
99     eval echo "$i = \$$i" >> build/config_vars.mk
100   done
101 ])
102
103 dnl APACHE_GEN_MAKEFILES
104 dnl Creates Makefiles
105 AC_DEFUN(APACHE_GEN_MAKEFILES,[
106   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
107 ])
108
109 dnl ## APACHE_OUTPUT(file)
110 dnl ## adds "file" to the list of files generated by AC_OUTPUT
111 dnl ## This macro can be used several times.
112 AC_DEFUN(APACHE_OUTPUT, [
113   APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
114 ])
115
116 dnl
117 dnl APACHE_TYPE_RLIM_T
118 dnl
119 dnl If rlim_t is not defined, define it to int
120 dnl
121 AC_DEFUN(APACHE_TYPE_RLIM_T, [
122   AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
123     AC_TRY_COMPILE([
124 #include <sys/types.h>
125 #include <sys/time.h>
126 #include <sys/resource.h>
127 ], [rlim_t spoon;], [
128       ac_cv_type_rlim_t=yes
129     ],[ac_cv_type_rlim_t=no
130     ])
131   ])
132   if test "$ac_cv_type_rlim_t" = "no" ; then
133       AC_DEFINE(rlim_t, int,
134           [Define to 'int' if <sys/resource.h> doesn't define it for us])
135   fi
136 ])
137
138 dnl APACHE_MODPATH_INIT(modpath)
139 AC_DEFUN(APACHE_MODPATH_INIT,[
140   current_dir=$1
141   modpath_current=modules/$1
142   modpath_static=
143   modpath_shared=
144   test -d $1 || $srcdir/build/mkdir.sh $modpath_current
145   > $modpath_current/modules.mk
146 ])dnl
147 dnl
148 AC_DEFUN(APACHE_MODPATH_FINISH,[
149   echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
150   echo "static = $modpath_static" >> $modpath_current/modules.mk
151   echo "shared = $modpath_shared" >> $modpath_current/modules.mk
152   if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
153     MODULE_DIRS="$MODULE_DIRS $current_dir"
154   else
155     MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
156   fi
157   APACHE_FAST_OUTPUT($modpath_current/Makefile)
158 ])dnl
159 dnl
160 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
161 AC_DEFUN(APACHE_MODPATH_ADD,[
162   if test -z "$3"; then
163     objects="mod_$1.lo"
164   else
165     objects="$3"
166   fi
167
168   if test -z "$module_standalone"; then
169     if test -z "$2"; then
170       libname="mod_$1.la"
171       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
172       modpath_static="$modpath_static $libname"
173       cat >>$modpath_current/modules.mk<<EOF
174 $libname: $objects
175         \$(MOD_LINK) $objects
176 EOF
177     else
178       apache_need_shared=yes
179       libname="mod_$1.la"
180       shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
181       modpath_shared="$modpath_shared $libname"
182       cat >>$modpath_current/modules.mk<<EOF
183 $libname: $shobjects
184         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
185 EOF
186     fi
187   fi
188 ])dnl
189
190 dnl
191 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
192 dnl
193 dnl default is one of:
194 dnl   yes    -- enabled by default. user must explicitly disable.
195 dnl   no     -- disabled under default, most, all. user must explicitly enable.
196 dnl   most   -- disabled by default. enabled explicitly or with most or all.
197 dnl   static -- enabled as static by default, must be explicitly changed.
198 dnl   ""     -- disabled under default, most. enabled explicitly or with all.
199 dnl
200 dnl basically: yes/no is a hard setting. "most" means follow the "most"
201 dnl            setting. otherwise, fall under the "all" setting.
202 dnl            explicit yes/no always overrides.
203 dnl
204 AC_DEFUN(APACHE_MODULE,[
205   AC_MSG_CHECKING(whether to enable mod_$1)
206   define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
207   AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
208   undefine([optname])dnl
209   _apmod_extra_msg=""
210   dnl When --enable-modules=most is set and the module was not explicitly
211   dnl requested, allow a module to disable itself if its pre-reqs fail.
212   if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
213     _apmod_error_fatal="no"
214   else
215     _apmod_error_fatal="yes"
216   fi
217   if test "$enable_$1" = "static"; then
218     enable_$1=yes
219   elif test "$enable_$1" = "yes"; then
220     enable_$1=$module_default
221     _apmod_extra_msg=" ($module_selection)"
222   elif test "$enable_$1" = "most"; then
223     if test "$module_selection" = "most" -o "$module_selection" = "all"; then
224       enable_$1=$module_default
225       _apmod_extra_msg=" ($module_selection)"
226     elif test "$enable_$1" != "yes"; then
227       enable_$1=no
228     fi
229   elif test "$enable_$1" = "maybe-all"; then
230     if test "$module_selection" = "all"; then
231       enable_$1=$module_default
232       _apmod_extra_msg=" (all)"
233     else
234       enable_$1=no
235     fi
236   fi
237   if test "$enable_$1" != "no"; then
238     dnl If we plan to enable it, allow the module to run some autoconf magic
239     dnl that may disable it because of missing dependencies.
240     ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
241                     $6
242                     AC_MSG_CHECKING(whether to enable mod_$1)
243                     if test "$enable_$1" = "no"; then
244                       if test "$_apmod_error_fatal" = "no"; then
245                         _apmod_extra_msg=" (disabled)"
246                       else
247                         AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
248                       fi
249                     fi])
250   fi
251   AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
252   if test "$enable_$1" != "no"; then
253     case "$enable_$1" in
254     shared*)
255       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
256       sharedobjs=yes
257       shared=yes
258       DSO_MODULES="$DSO_MODULES $1"
259       ;;
260     *)
261       MODLIST="$MODLIST ifelse($4,,$1,$4)"
262       if test "$1" = "so"; then
263           sharedobjs=yes
264       fi
265       shared="";;
266     esac
267     APACHE_MODPATH_ADD($1, $shared, $3)
268   fi
269 ])dnl
270
271 dnl
272 dnl APACHE_LAYOUT(configlayout, layoutname)
273 dnl
274 AC_DEFUN(APACHE_LAYOUT,[
275   if test ! -f $srcdir/config.layout; then
276     echo "** Error: Layout file $srcdir/config.layout not found"
277     echo "** Error: Cannot use undefined layout '$LAYOUT'"
278     exit 1
279   fi
280   pldconf=./config.pld
281   changequote({,})
282   sed -e "1,/[  ]*<[lL]ayout[   ]*$2[   ]*>[    ]*/d" \
283       -e '/[    ]*<\/Layout>[   ]*/,$d' \
284       -e "s/^[  ]*//g" \
285       -e "s/:[  ]*/=\'/g" \
286       -e "s/[   ]*$/'/g" \
287       $1 > $pldconf
288   layout_name=$2
289   . $pldconf
290   rm $pldconf
291   for var in prefix exec_prefix bindir sbindir libexecdir mandir \
292              sysconfdir datadir errordir iconsdir htdocsdir cgidir \
293              includedir localstatedir runtimedir logfiledir libdir \
294              manualdir proxycachedir installbuilddir; do
295     eval "val=\"\$$var\""
296     case $val in
297       *+)
298         val=`echo $val | sed -e 's;\+$;;'`
299         eval "$var=\"\$val\""
300         autosuffix=yes
301         ;;
302       *)
303         autosuffix=no
304         ;;
305     esac
306     val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
307     val=`echo $val | sed -e 's:[\$]\([a-z_]*\):${\1}:g'`
308     if test "$autosuffix" = "yes"; then
309       if echo $val | grep apache >/dev/null; then
310         addtarget=no
311       else
312         addtarget=yes
313       fi
314       if test "$addtarget" = "yes"; then
315         val="$val/apache2"
316       fi
317     fi
318     eval "$var='$val'"
319   done
320   changequote([,])
321 ])dnl
322
323 dnl
324 dnl APACHE_ENABLE_LAYOUT
325 dnl
326 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
327 AC_ARG_ENABLE(layout,
328 [  --enable-layout=LAYOUT],[
329   LAYOUT=$enableval
330 ])
331
332 if test -z "$LAYOUT"; then
333   LAYOUT="Apache"
334 fi
335 APACHE_LAYOUT($srcdir/config.layout, $LAYOUT)
336
337 AC_MSG_CHECKING(for chosen layout)
338 AC_MSG_RESULT($layout_name)
339 ])
340
341 dnl
342 dnl APACHE_ENABLE_MODULES
343 dnl
344 AC_DEFUN(APACHE_ENABLE_MODULES,[
345   module_selection=default
346   module_default=yes
347
348   AC_ARG_ENABLE(modules,
349   APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Modules to enable),[
350     for i in $enableval; do
351       if test "$i" = "all" -o "$i" = "most"; then
352         module_selection=$i
353       else
354         eval "enable_$i=yes"
355       fi
356     done
357   ])
358   
359   AC_ARG_ENABLE(mods-shared,
360   APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Shared modules to enable),[
361     for i in $enableval; do
362       if test "$i" = "all" -o "$i" = "most"; then
363         module_selection=$i
364         module_default=shared
365       else
366         i=`echo $i | sed 's/-/_/g'`
367         eval "enable_$i=shared"
368       fi
369     done
370   ])
371 ])
372
373 AC_DEFUN(APACHE_REQUIRE_CXX,[
374   if test -z "$apache_cxx_done"; then
375     AC_PROG_CXX
376     AC_PROG_CXXCPP
377     apache_cxx_done=yes
378   fi
379 ])
380
381 dnl
382 dnl APACHE_CHECK_SSL_TOOLKIT
383 dnl
384 dnl Find the openssl toolkit installation and check it for the right
385 dnl version, then add its flags to INCLUDES and LIBS.  This should
386 dnl really be using a custom AC_TRY_COMPILE function to test the includes
387 dnl and then AC_TRY_LINK to test the libraries directly for the version,
388 dnl but that will require someone who knows how to program openssl.
389 dnl
390 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
391 if test "x$ap_ssltk_base" = "x"; then
392   AC_MSG_CHECKING(for SSL/TLS toolkit base)
393   ap_ssltk_base=""
394   AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,SSL/TLS toolkit (OpenSSL)), [
395     if test "x$withval" != "xyes" -a "x$withval" != "x"; then
396       ap_ssltk_base="$withval"
397       if test -f "$ap_ssltk_base/bin/openssl"; then
398           ap_ssltk_version="`$ap_ssltk_base/bin/openssl version`"
399       else
400           ap_ssltk_version="unknown"
401       fi
402     fi
403   ])
404   if test "x$ap_ssltk_base" = "x"; then
405     AC_CACHE_VAL(ap_cv_ssltk,[
406       #
407       # shotgun approach: find all occurrences of the openssl program
408       #
409       # The IFS=... trick eliminates the colons from $PATH, without using an external program
410       for p in `IFS=":$IFS"; echo $PATH` /usr/local/openssl/bin /usr/local/ssl/bin; do
411         if test -f "$p/openssl"; then
412           ap_ssltk_version="`$p/openssl version`"
413           if test "x$ap_ssltk_version" != "x"; then
414             ap_cv_ssltk="`(cd $p/.. && pwd)`"
415             break
416           fi
417         fi
418       done
419       if test "x$ap_cv_ssltk" = "x"; then
420         AC_MSG_ERROR([requires OpenSSL 0.9.6e or higher])
421       fi
422     ])
423     ap_ssltk_base="$ap_cv_ssltk"
424   fi
425   if test ! -d $ap_ssltk_base; then
426     AC_MSG_ERROR([invalid SSL/TLS toolkit base directory $ap_ssltk_base])
427   fi
428   AC_MSG_RESULT($ap_ssltk_base)
429     
430   AC_MSG_CHECKING(for SSL/TLS toolkit version)
431   AC_MSG_RESULT($ap_ssltk_version)
432   case "$ap_ssltk_version" in
433     "OpenSSL "[[1-9]]* | \
434     "OpenSSL "0.9.6[[e-z]]* | \
435     "OpenSSL "0.9.[[7-9]]* | \
436     "OpenSSL "0.[[1-9]][[0-9]]* )
437        # okay versions that do not have known security holes
438        ;;
439     "OpenSSL"*)
440        AC_MSG_WARN([OpenSSL versions prior to 0.9.6e have known security holes])
441        ;;
442     *)
443        # unknown version -- assume the user knows what they are doing
444        ;;
445   esac
446     
447   AC_MSG_CHECKING(for SSL/TLS toolkit includes)
448   ap_ssltk_incdir=""
449   for p in $ap_ssltk_base/include /usr/local/openssl/include \
450            /usr/local/ssl/include /usr/local/include /usr/include; do
451     if test -f "$p/openssl/ssl.h"; then
452       ap_ssltk_incdir="$p"
453       break
454     elif test -f "$p/ssl.h"; then
455       ap_ssltk_incdir="$p"
456       break
457     fi
458   done
459   if test "x$ap_ssltk_incdir" = "x"; then
460     AC_MSG_ERROR([OpenSSL headers not found])
461   fi
462   AC_MSG_RESULT($ap_ssltk_incdir)
463
464   AC_MSG_CHECKING(for SSL/TLS toolkit libraries)
465   ap_ssltk_libdir=""
466   for p in $ap_ssltk_base/lib /usr/local/openssl/lib \
467            /usr/local/ssl/lib /usr/local/lib /usr/lib /lib /usr/lib64; do
468     if test -f "$p/libssl.a" -o -f "$p/libssl.so" -o -f "$p/libssl.dylib"; then
469       ap_ssltk_libdir="$p"
470       break
471     fi
472   done
473   if test ".$ap_ssltk_libdir" = .; then
474     AC_MSG_ERROR([OpenSSL libraries not found])
475   fi
476   AC_MSG_RESULT($ap_ssltk_libdir)
477
478   dnl #  annotate the Apache build environment with determined information
479   APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir/openssl])
480   if test "x$ap_ssltk_incdir" != "x/usr/include"; then
481     APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir])
482   fi
483   if test "x$ap_ssltk_libdir" != "x/usr/lib"; then
484     APR_ADDTO(LDFLAGS, [-L$ap_ssltk_libdir])
485     if test "x$ap_platform_runtime_link_flag" != "x"; then
486       APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_ssltk_libdir])
487     fi
488   fi
489   APR_ADDTO(LIBS, [-lssl -lcrypto])
490   ap_cv_ssltk="$ap_ssltk_base"
491 fi
492 ])
493
494 dnl
495 dnl APACHE_EXPORT_ARGUMENTS
496 dnl Export (via APACHE_SUBST) the various path-related variables that
497 dnl apache will use while generating scripts like autoconf and apxs and
498 dnl the default config file.
499
500 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
501   APR_EXPAND_VAR(exp_$1, [$]$1)
502   APACHE_SUBST(exp_$1)
503   APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
504   APACHE_SUBST(rel_$1)
505 ])
506
507 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
508   APACHE_SUBST_EXPANDED_ARG(exec_prefix)
509   APACHE_SUBST_EXPANDED_ARG(bindir)
510   APACHE_SUBST_EXPANDED_ARG(sbindir)
511   APACHE_SUBST_EXPANDED_ARG(libdir)
512   APACHE_SUBST_EXPANDED_ARG(libexecdir)
513   APACHE_SUBST_EXPANDED_ARG(mandir)
514   APACHE_SUBST_EXPANDED_ARG(sysconfdir)
515   APACHE_SUBST_EXPANDED_ARG(datadir)
516   APACHE_SUBST_EXPANDED_ARG(installbuilddir)
517   APACHE_SUBST_EXPANDED_ARG(errordir)
518   APACHE_SUBST_EXPANDED_ARG(iconsdir)
519   APACHE_SUBST_EXPANDED_ARG(htdocsdir)
520   APACHE_SUBST_EXPANDED_ARG(manualdir)
521   APACHE_SUBST_EXPANDED_ARG(cgidir)
522   APACHE_SUBST_EXPANDED_ARG(includedir)
523   APACHE_SUBST_EXPANDED_ARG(localstatedir)
524   APACHE_SUBST_EXPANDED_ARG(runtimedir)
525   APACHE_SUBST_EXPANDED_ARG(logfiledir)
526   APACHE_SUBST_EXPANDED_ARG(proxycachedir)
527 ])
528