]> granicus.if.org Git - apache/blob - acinclude.m4
Removing rpm stuff from buildconf until it becomes portable
[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       libname="mod_$1.la"
174       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
175       modpath_static="$modpath_static $libname"
176       cat >>$modpath_current/modules.mk<<EOF
177 $libname: $objects
178         \$(MOD_LINK) $objects
179 EOF
180     else
181       apache_need_shared=yes
182       libname="mod_$1.la"
183       shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
184       modpath_shared="$modpath_shared $libname"
185       cat >>$modpath_current/modules.mk<<EOF
186 $libname: $shobjects
187         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
188 EOF
189     fi
190   fi
191 ])dnl
192
193 dnl
194 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
195 dnl
196 dnl default is one of:
197 dnl   yes    -- enabled by default. user must explicitly disable.
198 dnl   no     -- disabled under default, most, all. user must explicitly enable.
199 dnl   most   -- disabled by default. enabled explicitly or with most or all.
200 dnl   static -- enabled as static by default, must be explicitly changed.
201 dnl   ""     -- disabled under default, most. enabled explicitly or with all.
202 dnl
203 dnl basically: yes/no is a hard setting. "most" means follow the "most"
204 dnl            setting. otherwise, fall under the "all" setting.
205 dnl            explicit yes/no always overrides.
206 dnl
207 AC_DEFUN(APACHE_MODULE,[
208   AC_MSG_CHECKING(whether to enable mod_$1)
209   define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
210   AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
211   undefine([optname])dnl
212   _apmod_extra_msg=""
213   dnl When --enable-modules=most is set and the module was not explicitly
214   dnl requested, allow a module to disable itself if its pre-reqs fail.
215   if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
216     _apmod_error_fatal="no"
217   else
218     _apmod_error_fatal="yes"
219   fi
220   if test "$enable_$1" = "static"; then
221     enable_$1=yes
222   elif test "$enable_$1" = "yes"; then
223     enable_$1=$module_default
224     _apmod_extra_msg=" ($module_selection)"
225   elif test "$enable_$1" = "most"; then
226     if test "$module_selection" = "most" -o "$module_selection" = "all"; then
227       enable_$1=$module_default
228       _apmod_extra_msg=" ($module_selection)"
229     elif test "$enable_$1" != "yes"; then
230       enable_$1=no
231     fi
232   elif test "$enable_$1" = "maybe-all"; then
233     if test "$module_selection" = "all"; then
234       enable_$1=$module_default
235       _apmod_extra_msg=" (all)"
236     else
237       enable_$1=no
238     fi
239   fi
240   if test "$enable_$1" != "no"; then
241     dnl If we plan to enable it, allow the module to run some autoconf magic
242     dnl that may disable it because of missing dependencies.
243     ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
244                     $6
245                     AC_MSG_CHECKING(whether to enable mod_$1)
246                     if test "$enable_$1" = "no"; then
247                       if test "$_apmod_error_fatal" = "no"; then
248                         _apmod_extra_msg=" (disabled)"
249                       else
250                         AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
251                       fi
252                     fi])
253   fi
254   AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
255   if test "$enable_$1" != "no"; then
256     case "$enable_$1" in
257     shared*)
258       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
259       sharedobjs=yes
260       shared=yes
261       DSO_MODULES="$DSO_MODULES $1"
262       ;;
263     *)
264       MODLIST="$MODLIST ifelse($4,,$1,$4)"
265       if test "$1" = "so"; then
266           sharedobjs=yes
267       fi
268       shared="";;
269     esac
270     APACHE_MODPATH_ADD($1, $shared, $3)
271   fi
272 ])dnl
273
274 dnl
275 dnl APACHE_ENABLE_MODULES
276 dnl
277 AC_DEFUN(APACHE_ENABLE_MODULES,[
278   module_selection=default
279   module_default=yes
280
281   AC_ARG_ENABLE(modules,
282   APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Modules to enable),[
283     for i in $enableval; do
284       if test "$i" = "all" -o "$i" = "most"; then
285         module_selection=$i
286       else
287         eval "enable_$i=yes"
288       fi
289     done
290   ])
291   
292   AC_ARG_ENABLE(mods-shared,
293   APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Shared modules to enable),[
294     for i in $enableval; do
295       if test "$i" = "all" -o "$i" = "most"; then
296         module_selection=$i
297         module_default=shared
298       else
299         i=`echo $i | sed 's/-/_/g'`
300         eval "enable_$i=shared"
301       fi
302     done
303   ])
304 ])
305
306 AC_DEFUN(APACHE_REQUIRE_CXX,[
307   if test -z "$apache_cxx_done"; then
308     AC_PROG_CXX
309     AC_PROG_CXXCPP
310     apache_cxx_done=yes
311   fi
312 ])
313
314 dnl
315 dnl APACHE_CHECK_SSL_TOOLKIT
316 dnl
317 dnl Configure for the detected openssl/ssl-c toolkit installation, giving
318 dnl preference to "--with-ssl=<path>" if it was specified.
319 dnl
320 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
321 if test "x$ap_ssltk_configured" = "x"; then
322   dnl initialise the variables we use
323   ap_ssltk_base=""
324   ap_ssltk_inc=""
325   ap_ssltk_lib=""
326   ap_ssltk_type=""
327
328   dnl Determine the SSL/TLS toolkit's base directory, if any
329   AC_MSG_CHECKING(for SSL/TLS toolkit base)
330   AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,SSL/TLS toolkit), [
331     dnl If --with-ssl specifies a directory, we use that directory or fail
332     if test "x$withval" != "xyes" -a "x$withval" != "x"; then
333       dnl This ensures $withval is actually a directory and that it is absolute
334       ap_ssltk_base="`cd $withval ; pwd`"
335     fi
336   ])
337   if test "x$ap_ssltk_base" = "x"; then
338     AC_MSG_RESULT(none)
339   else
340     AC_MSG_RESULT($ap_ssltk_base)
341   fi
342
343   dnl Run header and version checks
344   saved_CPPFLAGS=$CPPFLAGS
345   if test "x$ap_ssltk_base" != "x"; then
346     ap_ssltk_inc="-I$ap_ssltk_base/include"
347     CPPFLAGS="$CPPFLAGS $ap_ssltk_inc"
348   fi
349   AC_CHECK_HEADERS([sslc.h], [ap_ssltk_type="sslc"], [])
350   if test "x$ap_ssltk_type" = "x"; then
351     AC_CHECK_HEADERS([openssl/opensslv.h openssl/ssl.h], [ap_ssltk_type="openssl"], [])
352     if test "x$ap_ssltk_type" = "x"; then
353       AC_MSG_ERROR([No SSL/TLS headers were available])
354     fi
355     dnl so it's OpenSSL - report, then test for a good version
356     echo "... SSL/TLS support configuring for OpenSSL"
357     AC_MSG_CHECKING(for OpenSSL version)
358     AC_TRY_COMPILE([#include <openssl/opensslv.h>],
359 [#if !defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x0090609f
360 #error "invalid openssl version"
361 #endif],
362       [dnl Replace this with OPENSSL_VERSION_TEXT from opensslv.h?
363       AC_MSG_RESULT(OK)],
364       [AC_MSG_RESULT([not encouraging])
365       echo "WARNING: OpenSSL version may contain security vulnerabilities!"])
366
367   else
368
369     dnl so it's SSL-C - report, then test anything relevant
370     echo "... SSL/TLS support configuring for SSL-C"
371     AC_MSG_CHECKING(for SSL-C version)
372     AC_TRY_COMPILE([#include <sslc.h>],
373 [#if !defined(SSLC_VERSION_NUMBER) || SSLC_VERSION_NUMBER < 0x2100
374 #error "invalid SSL-C version"
375 #endif],
376     [AC_MSG_RESULT(OK)],
377     [AC_MSG_ERROR([SSL-C Versions < 2.1 has not been tested])])
378   fi
379   dnl restore
380   CPPFLAGS=$saved_CPPFLAGS
381
382   dnl Run library checks
383   saved_LDFLAGS=$LDFLAGS
384   saved_LIBS=$LIBS
385   if test "x$ap_ssltk_base" != "x"; then
386     if test -d "$ap_ssltk_base/lib"; then
387       ap_ssltk_lib="$ap_ssltk_base/lib"
388     else
389       ap_ssltk_lib="$ap_ssltk_base"
390     fi
391     LDFLAGS="$LDFLAGS -L$ap_ssltk_lib"
392   fi
393   dnl make sure "other" flags are available so libcrypto and libssl can link
394   LIBS="$LIBS `$apr_config --libs`"
395   liberrors=""
396   if test "$ap_ssltk_type" = "openssl"; then
397     AC_CHECK_LIB(crypto, SSLeay_version, [], [liberrors="yes"])
398     AC_CHECK_LIB(ssl, SSL_CTX_new, [], [liberrors="yes"])
399   else
400     AC_CHECK_LIB(sslc, SSL_CTX_new, [], [liberrors="yes"])
401   fi
402   if test "x$liberrors" != "x"; then
403     AC_MSG_ERROR([... Error, SSL/TLS libraries were missing or unusable])
404   fi
405   dnl restore
406   LDFLAGS=$saved_LDFLAGS
407   LIBS=$saved_LIBS
408
409   dnl Adjust apache's configuration based on what we found above.
410   dnl (a) define preprocessor symbols
411   if test "$ap_ssltk_type" = "openssl"; then
412     AC_DEFINE(HAVE_OPENSSL)
413   else
414     AC_DEFINE(HAVE_SSLC)
415   fi
416   dnl (b) hook up include paths
417   if test "x$ap_ssltk_inc" != "x"; then
418     APR_ADDTO(INCLUDES, [$ap_ssltk_inc])
419   fi
420   dnl (c) hook up linker paths
421   if test "x$ap_ssltk_lib" != "x"; then
422     APR_ADDTO(LDFLAGS, ["-L$ap_ssltk_lib"])
423     if test "x$ap_platform_runtime_link_flag" != "x"; then
424       APR_ADDTO(LDFLAGS, ["$ap_platform_runtime_link_flag$ap_ssltk_libdir"])
425     fi
426   fi
427   dnl (d) add "-lssl -lcrypto" OR "-lsslc" to LIBS because restoring LIBS
428   dnl after AC_CHECK_LIB() obliterates any flags AC_CHECK_LIB() added.
429   if test "$ap_ssltk_type" = "openssl"; then
430     APR_ADDTO(LIBS, [-lssl -lcrypto])
431   else
432     APR_ADDTO(LIBS, [-lsslc])
433   fi
434 fi
435 ])
436
437 dnl
438 dnl APACHE_EXPORT_ARGUMENTS
439 dnl Export (via APACHE_SUBST) the various path-related variables that
440 dnl apache will use while generating scripts like autoconf and apxs and
441 dnl the default config file.
442
443 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
444   APR_EXPAND_VAR(exp_$1, [$]$1)
445   APACHE_SUBST(exp_$1)
446   APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
447   APACHE_SUBST(rel_$1)
448 ])
449
450 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
451   APACHE_SUBST_EXPANDED_ARG(exec_prefix)
452   APACHE_SUBST_EXPANDED_ARG(bindir)
453   APACHE_SUBST_EXPANDED_ARG(sbindir)
454   APACHE_SUBST_EXPANDED_ARG(libdir)
455   APACHE_SUBST_EXPANDED_ARG(libexecdir)
456   APACHE_SUBST_EXPANDED_ARG(mandir)
457   APACHE_SUBST_EXPANDED_ARG(sysconfdir)
458   APACHE_SUBST_EXPANDED_ARG(datadir)
459   APACHE_SUBST_EXPANDED_ARG(installbuilddir)
460   APACHE_SUBST_EXPANDED_ARG(errordir)
461   APACHE_SUBST_EXPANDED_ARG(iconsdir)
462   APACHE_SUBST_EXPANDED_ARG(htdocsdir)
463   APACHE_SUBST_EXPANDED_ARG(manualdir)
464   APACHE_SUBST_EXPANDED_ARG(cgidir)
465   APACHE_SUBST_EXPANDED_ARG(includedir)
466   APACHE_SUBST_EXPANDED_ARG(localstatedir)
467   APACHE_SUBST_EXPANDED_ARG(runtimedir)
468   APACHE_SUBST_EXPANDED_ARG(logfiledir)
469   APACHE_SUBST_EXPANDED_ARG(proxycachedir)
470 ])
471