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