]> granicus.if.org Git - apache/blob - acinclude.m4
fix references / update transformation
[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(MKDEP)
89   APACHE_SUBST(INSTALL_PROG_FLAGS)
90   APACHE_SUBST(DSO_MODULES)
91   APACHE_SUBST(APR_BINDIR)
92   APACHE_SUBST(APR_INCLUDEDIR)
93   APACHE_SUBST(APU_BINDIR)
94   APACHE_SUBST(APU_INCLUDEDIR)
95
96   abs_srcdir="`(cd $srcdir && pwd)`"
97
98   echo creating config_vars.mk
99   test -d build || $mkdir_p build
100   > build/config_vars.mk
101   for i in $APACHE_VAR_SUBST; do
102     eval echo "$i = \$$i" >> build/config_vars.mk
103   done
104 ])
105
106 dnl APACHE_GEN_MAKEFILES
107 dnl Creates Makefiles
108 AC_DEFUN(APACHE_GEN_MAKEFILES,[
109   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
110 ])
111
112 dnl ## APACHE_OUTPUT(file)
113 dnl ## adds "file" to the list of files generated by AC_OUTPUT
114 dnl ## This macro can be used several times.
115 AC_DEFUN(APACHE_OUTPUT, [
116   APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
117 ])
118
119 dnl
120 dnl APACHE_TYPE_RLIM_T
121 dnl
122 dnl If rlim_t is not defined, define it to int
123 dnl
124 AC_DEFUN(APACHE_TYPE_RLIM_T, [
125   AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
126     AC_TRY_COMPILE([
127 #include <sys/types.h>
128 #include <sys/time.h>
129 #include <sys/resource.h>
130 ], [rlim_t spoon;], [
131       ac_cv_type_rlim_t=yes
132     ],[ac_cv_type_rlim_t=no
133     ])
134   ])
135   if test "$ac_cv_type_rlim_t" = "no" ; then
136       AC_DEFINE(rlim_t, int,
137           [Define to 'int' if <sys/resource.h> doesn't define it for us])
138   fi
139 ])
140
141 dnl APACHE_MODPATH_INIT(modpath)
142 AC_DEFUN(APACHE_MODPATH_INIT,[
143   current_dir=$1
144   modpath_current=modules/$1
145   modpath_static=
146   modpath_shared=
147   test -d $1 || $srcdir/build/mkdir.sh $modpath_current
148   > $modpath_current/modules.mk
149 ])dnl
150 dnl
151 AC_DEFUN(APACHE_MODPATH_FINISH,[
152   echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
153   echo "static = $modpath_static" >> $modpath_current/modules.mk
154   echo "shared = $modpath_shared" >> $modpath_current/modules.mk
155   if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
156     MODULE_DIRS="$MODULE_DIRS $current_dir"
157   else
158     MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
159   fi
160   APACHE_FAST_OUTPUT($modpath_current/Makefile)
161 ])dnl
162 dnl
163 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
164 AC_DEFUN(APACHE_MODPATH_ADD,[
165   if test -z "$3"; then
166     objects="mod_$1.lo"
167   else
168     objects="$3"
169   fi
170
171   if test -z "$module_standalone"; then
172     if test -z "$2"; then
173       # The filename of a convenience library must have a "lib" prefix:
174       libname="libmod_$1.la"
175       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
176       modpath_static="$modpath_static $libname"
177       cat >>$modpath_current/modules.mk<<EOF
178 $libname: $objects
179         \$(MOD_LINK) $objects $5
180 EOF
181     else
182       apache_need_shared=yes
183       libname="mod_$1.la"
184       shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
185       modpath_shared="$modpath_shared $libname"
186       cat >>$modpath_current/modules.mk<<EOF
187 $libname: $shobjects
188         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
189 EOF
190     fi
191   fi
192 ])dnl
193
194 dnl
195 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
196 dnl
197 dnl default is one of:
198 dnl   yes    -- enabled by default. user must explicitly disable.
199 dnl   no     -- disabled under default, most, all. user must explicitly enable.
200 dnl   most   -- disabled by default. enabled explicitly or with most or all.
201 dnl   static -- enabled as static by default, must be explicitly changed.
202 dnl   ""     -- disabled under default, most. enabled explicitly or with all.
203 dnl
204 dnl basically: yes/no is a hard setting. "most" means follow the "most"
205 dnl            setting. otherwise, fall under the "all" setting.
206 dnl            explicit yes/no always overrides.
207 dnl
208 AC_DEFUN(APACHE_MODULE,[
209   AC_MSG_CHECKING(whether to enable mod_$1)
210   define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
211   AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
212   undefine([optname])dnl
213   _apmod_extra_msg=""
214   dnl When --enable-modules=most is set and the module was not explicitly
215   dnl requested, allow a module to disable itself if its pre-reqs fail.
216   if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
217     _apmod_error_fatal="no"
218   else
219     _apmod_error_fatal="yes"
220   fi
221   if test "$enable_$1" = "static"; then
222     enable_$1=yes
223   elif test "$enable_$1" = "yes"; then
224     enable_$1=$module_default
225     _apmod_extra_msg=" ($module_selection)"
226   elif test "$enable_$1" = "most"; then
227     if test "$module_selection" = "most" -o "$module_selection" = "all"; then
228       enable_$1=$module_default
229       _apmod_extra_msg=" ($module_selection)"
230     elif test "$enable_$1" != "yes"; then
231       enable_$1=no
232     fi
233   elif test "$enable_$1" = "maybe-all"; then
234     if test "$module_selection" = "all"; then
235       enable_$1=$module_default
236       _apmod_extra_msg=" (all)"
237     else
238       enable_$1=no
239     fi
240   fi
241   if test "$enable_$1" != "no"; then
242     dnl If we plan to enable it, allow the module to run some autoconf magic
243     dnl that may disable it because of missing dependencies.
244     ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
245                     $6
246                     AC_MSG_CHECKING(whether to enable mod_$1)
247                     if test "$enable_$1" = "no"; then
248                       if test "$_apmod_error_fatal" = "no"; then
249                         _apmod_extra_msg=" (disabled)"
250                       else
251                         AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
252                       fi
253                     fi])
254   fi
255   AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
256   if test "$enable_$1" != "no"; then
257     case "$enable_$1" in
258     shared*)
259       enable_$1=`echo $enable_$1|sed 's/shared,*//'`
260       sharedobjs=yes
261       shared=yes
262       DSO_MODULES="$DSO_MODULES $1"
263       ;;
264     *)
265       MODLIST="$MODLIST ifelse($4,,$1,$4)"
266       if test "$1" = "so"; then
267           sharedobjs=yes
268       fi
269       shared="";;
270     esac
271     define([modprefix], [MOD_]translit($1, [a-z-], [A-Z_]))
272     APACHE_MODPATH_ADD($1, $shared, $3,, [\$(]modprefix[_LDADD)])
273     APACHE_SUBST(modprefix[_LDADD])
274     undefine([modprefix])
275   fi
276 ])dnl
277
278 dnl
279 dnl APACHE_ENABLE_MODULES
280 dnl
281 AC_DEFUN(APACHE_ENABLE_MODULES,[
282   module_selection=default
283   module_default=yes
284
285   AC_ARG_ENABLE(modules,
286   APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Space-separated list of modules to enable | "all" | "most"),[
287     for i in $enableval; do
288       if test "$i" = "all" -o "$i" = "most"; then
289         module_selection=$i
290       else
291         i=`echo $i | sed 's/-/_/g'`
292         eval "enable_$i=yes"
293       fi
294     done
295   ])
296   
297   AC_ARG_ENABLE(mods-shared,
298   APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Space-separated list of shared modules to enable | "all" | "most"),[
299     for i in $enableval; do
300       if test "$i" = "all" -o "$i" = "most"; then
301         module_selection=$i
302         module_default=shared
303       else
304         i=`echo $i | sed 's/-/_/g'`
305         eval "enable_$i=shared"
306       fi
307     done
308   ])
309 ])
310
311 AC_DEFUN(APACHE_REQUIRE_CXX,[
312   if test -z "$apache_cxx_done"; then
313     AC_PROG_CXX
314     AC_PROG_CXXCPP
315     apache_cxx_done=yes
316   fi
317 ])
318
319 dnl
320 dnl APACHE_CHECK_SSL_TOOLKIT
321 dnl
322 dnl Configure for the detected openssl/ssl-c toolkit installation, giving
323 dnl preference to "--with-ssl=<path>" if it was specified.
324 dnl
325 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
326 if test "x$ap_ssltk_configured" = "x"; then
327   dnl initialise the variables we use
328   ap_ssltk_base=""
329   ap_ssltk_inc=""
330   ap_ssltk_lib=""
331   ap_ssltk_type=""
332
333   dnl Determine the SSL/TLS toolkit's base directory, if any
334   AC_MSG_CHECKING(for SSL/TLS toolkit base)
335   AC_ARG_WITH(sslc, APACHE_HELP_STRING(--with-sslc=DIR,RSA SSL-C SSL/TLS toolkit), [
336     dnl If --with-sslc specifies a directory, we use that directory or fail
337     if test "x$withval" != "xyes" -a "x$withval" != "x"; then
338       dnl This ensures $withval is actually a directory and that it is absolute
339       ap_ssltk_base="`cd $withval ; pwd`"
340     fi
341     ap_ssltk_type="sslc"
342   ])
343   AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,OpenSSL SSL/TLS toolkit), [
344     dnl If --with-ssl specifies a directory, we use that directory or fail
345     if test "x$withval" != "xyes" -a "x$withval" != "x"; then
346       dnl This ensures $withval is actually a directory and that it is absolute
347       ap_ssltk_base="`cd $withval ; pwd`"
348     fi
349   ])
350   if test "x$ap_ssltk_base" = "x"; then
351     AC_MSG_RESULT(none)
352   else
353     AC_MSG_RESULT($ap_ssltk_base)
354   fi
355
356   dnl Run header and version checks
357   saved_CPPFLAGS=$CPPFLAGS
358   if test "x$ap_ssltk_base" != "x"; then
359     ap_ssltk_inc="-I$ap_ssltk_base/include"
360     CPPFLAGS="$CPPFLAGS $ap_ssltk_inc"
361   fi
362   if test "x$ap_ssltk_type" = "x"; then
363     AC_MSG_CHECKING(for OpenSSL version)
364     dnl First check for manditory headers
365     AC_CHECK_HEADERS([openssl/opensslv.h openssl/ssl.h], [ap_ssltk_type="openssl"], [])
366     if test "$ap_ssltk_type" = "openssl"; then
367       dnl so it's OpenSSL - test for a good version
368       AC_TRY_COMPILE([#include <openssl/opensslv.h>],[
369 #if !defined(OPENSSL_VERSION_NUMBER)
370 #error "Missing openssl version"
371 #endif
372 #if  (OPENSSL_VERSION_NUMBER < 0x009060af) \
373  || ((OPENSSL_VERSION_NUMBER > 0x00907000) && (OPENSSL_VERSION_NUMBER < 0x0090702f))
374 #error "Insecure openssl version " OPENSSL_VERSION_TEXT
375 #endif],
376       [AC_MSG_RESULT(OK)],
377       [dnl Replace this with OPENSSL_VERSION_TEXT from opensslv.h?
378        AC_MSG_RESULT([not encouraging])
379        echo "WARNING: OpenSSL version may contain security vulnerabilities!"
380        echo "         Ensure the latest security patches have been applied!"
381       ])
382       dnl Look for additional, possibly missing headers
383       AC_CHECK_HEADERS(openssl/engine.h)
384     else
385       AC_MSG_RESULT([no OpenSSL headers found])
386     fi
387   fi
388   if test "$ap_ssltk_type" != "openssl"; then
389     dnl Might be SSL-C - report, then test anything relevant
390     AC_MSG_CHECKING(for SSL-C version)
391     AC_CHECK_HEADERS([sslc.h], [ap_ssltk_type="sslc"], [ap_ssltk_type=""])
392     if test "$ap_ssltk_type" = "sslc"; then
393       AC_MSG_CHECKING(for SSL-C version)
394       AC_TRY_COMPILE([#include <sslc.h>],[
395 #if !defined(SSLC_VERSION_NUMBER)
396 #error "Missing SSL-C version"
397 #endif
398 #if SSLC_VERSION_NUMBER < 0x2310
399 #define stringize_ver(x) #x
400 #error "Insecure SSL-C version " stringize_ver(SSLC_VERSION_NUMBER)
401 #endif],
402       [AC_MSG_RESULT(OK)],
403       [dnl Replace this with SSLC_VERSION_NUMBER?
404        AC_MSG_RESULT([not encouraging])
405        echo "WARNING: SSL-C version may contain security vulnerabilities!"
406        echo "         Ensure the latest security patches have been applied!"
407       ])
408     else
409       AC_MSG_RESULT([no SSL-C headers found])
410     fi
411   fi
412   dnl restore
413   CPPFLAGS=$saved_CPPFLAGS
414   if test "x$ap_ssltk_type" = "x"; then
415     AC_MSG_ERROR([...No recognized SSL/TLS toolkit detected])
416   fi
417
418   dnl Run library and function checks
419   saved_LDFLAGS=$LDFLAGS
420   saved_LIBS=$LIBS
421   if test "x$ap_ssltk_base" != "x"; then
422     if test -d "$ap_ssltk_base/lib"; then
423       ap_ssltk_lib="$ap_ssltk_base/lib"
424     else
425       ap_ssltk_lib="$ap_ssltk_base"
426     fi
427     LDFLAGS="$LDFLAGS -L$ap_ssltk_lib"
428   fi
429   dnl make sure "other" flags are available so libcrypto and libssl can link
430   LIBS="$LIBS `$apr_config --libs`"
431   liberrors=""
432   if test "$ap_ssltk_type" = "openssl"; then
433     AC_CHECK_LIB(crypto, SSLeay_version, [], [liberrors="yes"])
434     AC_CHECK_LIB(ssl, SSL_CTX_new, [], [liberrors="yes"])
435     AC_CHECK_FUNCS(ENGINE_init)
436     AC_CHECK_FUNCS(ENGINE_load_builtin_engines)
437   else
438     AC_CHECK_LIB(sslc, SSLC_library_version, [], [liberrors="yes"])
439     AC_CHECK_LIB(sslc, SSL_CTX_new, [], [liberrors="yes"])
440     AC_CHECK_FUNCS(SSL_set_state)
441   fi
442   AC_CHECK_FUNCS(SSL_set_cert_store)
443   dnl restore
444   LDFLAGS=$saved_LDFLAGS
445   LIBS=$saved_LIBS
446   if test "x$liberrors" != "x"; then
447     AC_MSG_ERROR([... Error, SSL/TLS libraries were missing or unusable])
448   fi
449
450   dnl Adjust apache's configuration based on what we found above.
451   dnl (a) define preprocessor symbols
452   if test "$ap_ssltk_type" = "openssl"; then
453     AC_DEFINE(HAVE_OPENSSL, 1, [Define if SSL is supported using OpenSSL])
454   else
455     AC_DEFINE(HAVE_SSLC, 1, [Define if SSL is supported using SSL-C])
456   fi
457   dnl (b) hook up include paths
458   if test "x$ap_ssltk_inc" != "x"; then
459     APR_ADDTO(INCLUDES, [$ap_ssltk_inc])
460   fi
461   dnl (c) hook up linker paths
462   if test "x$ap_ssltk_lib" != "x"; then
463     APR_ADDTO(LDFLAGS, ["-L$ap_ssltk_lib"])
464     if test "x$ap_platform_runtime_link_flag" != "x"; then
465       APR_ADDTO(LDFLAGS, ["$ap_platform_runtime_link_flag$ap_ssltk_lib"])
466     fi
467   fi
468   # Put SSL libraries in SSL_LIBS.
469   if test "$ap_ssltk_type" = "openssl"; then
470     APR_SETVAR(SSL_LIBS, [-lssl -lcrypto])
471   else
472     APR_SETVAR(SSL_LIBS, [-lsslc])
473   fi
474   APACHE_SUBST(SSL_LIBS)
475 fi
476 ])
477
478 dnl
479 dnl APACHE_EXPORT_ARGUMENTS
480 dnl Export (via APACHE_SUBST) the various path-related variables that
481 dnl apache will use while generating scripts like autoconf and apxs and
482 dnl the default config file.
483
484 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
485   APR_EXPAND_VAR(exp_$1, [$]$1)
486   APACHE_SUBST(exp_$1)
487   APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
488   APACHE_SUBST(rel_$1)
489 ])
490
491 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
492   APACHE_SUBST_EXPANDED_ARG(exec_prefix)
493   APACHE_SUBST_EXPANDED_ARG(bindir)
494   APACHE_SUBST_EXPANDED_ARG(sbindir)
495   APACHE_SUBST_EXPANDED_ARG(libdir)
496   APACHE_SUBST_EXPANDED_ARG(libexecdir)
497   APACHE_SUBST_EXPANDED_ARG(mandir)
498   APACHE_SUBST_EXPANDED_ARG(sysconfdir)
499   APACHE_SUBST_EXPANDED_ARG(datadir)
500   APACHE_SUBST_EXPANDED_ARG(installbuilddir)
501   APACHE_SUBST_EXPANDED_ARG(errordir)
502   APACHE_SUBST_EXPANDED_ARG(iconsdir)
503   APACHE_SUBST_EXPANDED_ARG(htdocsdir)
504   APACHE_SUBST_EXPANDED_ARG(manualdir)
505   APACHE_SUBST_EXPANDED_ARG(cgidir)
506   APACHE_SUBST_EXPANDED_ARG(includedir)
507   APACHE_SUBST_EXPANDED_ARG(localstatedir)
508   APACHE_SUBST_EXPANDED_ARG(runtimedir)
509   APACHE_SUBST_EXPANDED_ARG(logfiledir)
510   APACHE_SUBST_EXPANDED_ARG(proxycachedir)
511 ])
512