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