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