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