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