]> granicus.if.org Git - apache/blob - acinclude.m4
Force all Apache functions to be linked into the executable, whether they
[apache] / acinclude.m4
1  
2 AC_DEFUN(APACHE_CONFIG_NICE,[
3   rm -f $1
4   cat >$1<<EOF
5 #! /bin/sh
6 #
7 # Created by configure
8
9 EOF
10
11   for arg in [$]0 "[$]@"; do
12     echo "\"[$]arg\" \\" >> $1
13   done
14   echo '"[$]@"' >> $1
15   chmod +x $1
16 ])
17
18 AC_DEFUN(APACHE_PASSTHRU,[
19   unset ac_cv_pass_$1
20   AC_CACHE_VAL(ac_cv_pass_$1, [ac_cv_pass_$1=$$1])
21 ])
22
23 dnl APACHE_SUBST(VARIABLE)
24 dnl Makes VARIABLE available in generated files
25 dnl (do not use @variable@ in Makefiles, but $(variable))
26 AC_DEFUN(APACHE_SUBST,[
27   APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
28   AC_SUBST($1)
29 ])
30
31 dnl APACHE_FAST_OUTPUT(FILENAME)
32 dnl Perform substitutions on FILENAME (Makefiles only)
33 AC_DEFUN(APACHE_FAST_OUTPUT,[
34   APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
35 ])
36
37 dnl APACHE_MKDIR_P_CHECK
38 dnl checks whether mkdir -p works
39 AC_DEFUN(APACHE_MKDIR_P_CHECK,[
40   AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
41     test -d conftestdir && rm -rf conftestdir
42     mkdir -p conftestdir/somedir >/dev/null 2>&1
43     if test -d conftestdir/somedir; then
44       ac_cv_mkdir_p=yes
45     else
46       ac_cv_mkdir_p=no
47     fi
48     rm -rf conftestdir
49   ])
50 ])
51
52 dnl APACHE_GEN_CONFIG_VARS
53 dnl Creates config_vars.mk
54 AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
55   APACHE_SUBST(abs_srcdir)
56   APACHE_SUBST(bindir)
57   APACHE_SUBST(cgidir)
58   APACHE_SUBST(logdir)
59   APACHE_SUBST(exec_prefix)
60   APACHE_SUBST(datadir)
61   APACHE_SUBST(localstatedir)
62   APACHE_SUBST(libexecdir)
63   APACHE_SUBST(htdocsdir)
64   APACHE_SUBST(includedir)
65   APACHE_SUBST(iconsdir)
66   APACHE_SUBST(sysconfdir)
67   APACHE_SUBST(progname)
68   APACHE_SUBST(prefix)
69   APACHE_SUBST(AWK)
70   APACHE_SUBST(CC)
71   APACHE_SUBST(CFLAGS)
72   APACHE_SUBST(CPPFLAGS)
73   APACHE_SUBST(CXX)
74   APACHE_SUBST(CXXFLAGS)
75   APACHE_SUBST(LTFLAGS)
76   APACHE_SUBST(LDFLAGS)
77   APACHE_SUBST(DEFS)
78   APACHE_SUBST(LIBTOOL)
79   APACHE_SUBST(SHELL)
80   APACHE_SUBST(MODULE_DIRS)
81   APACHE_SUBST(PORT)
82
83   abs_srcdir="`(cd $srcdir && pwd)`"
84
85   APACHE_MKDIR_P_CHECK
86   echo creating config_vars.mk
87   > config_vars.mk
88   for i in $APACHE_VAR_SUBST; do
89     eval echo "$i = \$$i" >> config_vars.mk
90   done
91 ])
92
93 dnl APACHE_GEN_MAKEFILES
94 dnl Creates Makefiles
95 AC_DEFUN(APACHE_GEN_MAKEFILES,[
96   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
97 ])
98
99 AC_DEFUN(APACHE_LIBTOOL_SILENT,[
100   LIBTOOL='$(SHELL) $(top_builddir)/libtool --silent'
101 ])
102
103     
104 dnl ## APACHE_OUTPUT(file)
105 dnl ## adds "file" to the list of files generated by AC_OUTPUT
106 dnl ## This macro can be used several times.
107 AC_DEFUN(APACHE_OUTPUT, [
108   APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
109 ])
110
111 dnl
112 dnl AC_ADD_LIBRARY(library)
113 dnl
114 dnl add a library to the link line
115 dnl
116 AC_DEFUN(AC_ADD_LIBRARY,[
117   APACHE_ONCE(LIBRARY, $1, [
118     EXTRA_LIBS="$EXTRA_LIBS -l$1"
119   ])
120 ])
121
122 dnl
123 dnl AC_CHECK_DEFINE(macro, headerfile)
124 dnl
125 dnl checks for the macro in the header file
126 dnl
127 AC_DEFUN(AC_CHECK_DEFINE,[
128   AC_CACHE_CHECK(for $1 in $2, ac_cv_define_$1,
129   AC_EGREP_CPP([YES_IS_DEFINED], [
130 #include <$2>
131 #ifdef $1
132 YES_IS_DEFINED
133 #endif
134   ], ac_cv_define_$1=yes, ac_cv_define_$1=no))
135   if test "$ac_cv_define_$1" = "yes" ; then
136       AC_DEFINE(HAVE_$1,,
137           [Define if the macro "$1" is defined on this system])
138   fi
139 ])
140
141 dnl
142 dnl AC_TYPE_RLIM_T
143 dnl
144 dnl If rlim_t is not defined, define it to int
145 dnl
146 AC_DEFUN(AC_TYPE_RLIM_T, [
147   AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
148     AC_TRY_COMPILE([
149 #include <sys/types.h>
150 #include <sys/time.h>
151 #include <sys/resource.h>
152 ], [rlim_t spoon;], [
153       ac_cv_type_rlim_t=yes
154     ],[ac_cv_type_rlim_t=no
155     ])
156   ])
157   if test "$ac_cv_type_rlim_t" = "no" ; then
158       AC_DEFINE(rlim_t, int,
159           [Define to 'int' if <sys/resource.h> doesn't define it for us])
160   fi
161 ])
162
163 dnl
164 dnl APACHE_ONCE(namespace, variable, code)
165 dnl
166 dnl execute code, if variable is not set in namespace
167 dnl
168 AC_DEFUN(APACHE_ONCE,[
169   unique=`echo $ac_n "$2$ac_c" | tr -cd a-zA-Z0-9`
170   cmd="echo $ac_n \"\$$1$unique$ac_c\""
171   if test -n "$unique" && test "`eval $cmd`" = "" ; then
172     eval "$1$unique=set"
173     $3
174   fi
175 ])
176
177 sinclude(srclib/apr/apr_common.m4)
178 sinclude(srclib/apr/hints.m4)
179 sinclude(hints.m4)
180
181 AC_DEFUN(APACHE_CHECK_SIGWAIT_ONE_ARG,[
182   AC_CACHE_CHECK(whether sigwait takes one argument,ac_cv_sigwait_one_arg,[
183   AC_TRY_COMPILE([
184 #ifdef __NETBSD__
185     /* When using the unproven-pthreads package, we need to pull in this 
186      * header to get a prototype for sigwait().  Else things will fail later
187      * on.  XXX Should probably be fixed in the unproven-pthreads package.
188      */
189 #include <pthread.h>
190 #endif
191 #include <signal.h>
192 ],[
193   sigset_t set;
194
195   sigwait(&set);
196 ],[
197   ac_cv_sigwait_one_arg=yes
198 ],[
199   ac_cv_sigwait_one_arg=no
200 ])])
201   if test "$ac_cv_sigwait_one_arg" = "yes"; then
202     AC_DEFINE(SIGWAIT_TAKES_ONE_ARG,1,[ ])
203   fi
204 ])
205
206 AC_DEFUN(APACHE_EBCDIC,[
207   AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
208   AC_TRY_RUN( [
209 int main(void) { 
210   return (unsigned char)'A' != (unsigned char)0xC1; 
211
212 ],[
213   ac_cv_ebcdic="yes"
214 ],[
215   ac_cv_ebcdic="no"
216 ],[
217   ac_cv_ebcdic="no"
218 ])])
219   if test "$ac_cv_ebcdic" = "yes"; then
220     AC_DEFINE(AP_CHARSET_EBCDIC,, [Define if system uses EBCDIC])
221   fi
222 ])
223
224 dnl APACHE_MODPATH_INIT(modpath)
225 AC_DEFUN(APACHE_MODPATH_INIT,[
226   current_dir=$1
227   modpath_current=modules/$1
228   modpath_static=
229   modpath_shared=
230   test -d $1 || $srcdir/build/mkdir.sh $modpath_current
231   > $modpath_current/modules.mk
232 ])dnl
233 dnl
234 AC_DEFUN(APACHE_MODPATH_FINISH,[
235   echo "static = $modpath_static" >> $modpath_current/modules.mk
236   echo "shared = $modpath_shared" >> $modpath_current/modules.mk
237   if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
238     MODULE_DIRS="$MODULE_DIRS $current_dir"
239   fi
240   APACHE_FAST_OUTPUT($modpath_current/Makefile)
241 ])dnl
242 dnl
243 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
244 AC_DEFUN(APACHE_MODPATH_ADD,[
245   if test -z "$3"; then
246     objects="mod_$1.lo"
247   else
248     objects="$3"
249   fi
250
251   if test -z "$module_standalone"; then
252     if test -z "$2"; then
253       libname="libapachemod_$1.la"
254       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
255       modpath_static="$modpath_static $libname"
256       cat >>$modpath_current/modules.mk<<EOF
257 $libname: $objects
258         \$(LINK) $objects
259 EOF
260     else
261       apache_need_shared=yes
262       libname="mod_$1.la"
263       shobjects=`echo $objects | sed 's/\.lo/.slo/'`
264       modpath_shared="$modpath_shared $libname"
265       cat >>$modpath_current/modules.mk<<EOF
266 $libname: $shobjects
267         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
268 EOF
269     fi
270   fi
271 ])dnl
272 dnl
273 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
274 AC_DEFUN(APACHE_MODULE,[
275   AC_MSG_CHECKING(whether to enable mod_$1)
276   define([optname],[  --]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
277   AC_ARG_ENABLE(translit($1,_,-),optname() substr([                         ],len(optname()))$2,,enable_$1=ifelse($5,,no,$5))
278   undefine([optname])dnl
279   AC_MSG_RESULT($enable_$1)
280   if test "$enable_$1" != "no"; then
281     case "$enable_$1" in
282     shared*)
283       enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
284       sharedobjs=yes
285       shared=yes;;
286     *)
287       MODLIST="$MODLIST ifelse($4,,$1,$4)"
288       if test "$1" = "so"; then
289           sharedobjs=yes
290       fi
291       shared="";;
292     esac
293     ifelse([$6],,:,[$6])
294     APACHE_MODPATH_ADD($1, $shared, $3)
295   fi
296 ])dnl
297 dnl
298 dnl APACHE_LAYOUT(configlayout, layoutname)
299 AC_DEFUN(APACHE_LAYOUT,[
300   if test ! -f $srcdir/../config.layout; then
301     echo "** Error: Layout file $srcdir/../config.layout not found"
302     echo "** Error: Cannot use undefined layout '$LAYOUT'"
303     exit 1
304   fi
305   pldconf=config.pld
306   changequote({,})
307   sed -e "1,/[  ]*<[lL]ayout[   ]*$2[   ]*>[    ]*/d" \
308       -e '/[    ]*<\/Layout>[   ]*/,$d' \
309       -e "s/^[  ]*//g" \
310       -e "s/:[  ]*/=\'/g" \
311       -e "s/[   ]*$/'/g" \
312       $1 > $pldconf
313   layout_name=$2
314   . $pldconf
315   rm $pldconf
316   for var in prefix exec_prefix bindir sbindir libexecdir mandir \
317              sysconfdir datadir iconsdir htdocsdir cgidir includedir \
318              localstatedir runtimedir logdir proxycachedir; do
319     eval "val=\"\$$var\""
320     case $val in
321       *+)
322         val=`echo $val | sed -e 's;\+$;;'`
323         eval "$var=\"\$val\""
324         autosuffix=yes
325         ;;
326       *)
327         autosuffix=no
328         ;;
329     esac
330     val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
331     val=`echo $val | sed -e 's:$\([a-z_]*\):$(\1):g'`
332     if test "$autosuffix" = "yes"; then
333       if echo $val | grep apache >/dev/null; then
334         addtarget=no
335       else
336         addtarget=yes
337       fi
338       if test "$addtarget" = "yes"; then
339         val="$val/apache"
340       fi
341     fi
342     eval "$var='$val'"
343   done
344   changequote([,])
345 ])dnl
346 dnl
347 dnl APACHE_ENABLE_LAYOUT
348 dnl
349 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
350 AC_ARG_ENABLE(layout,
351 [  --enable-layout=LAYOUT],[
352   LAYOUT=$enableval
353 ])
354
355 if test -z "$LAYOUT"; then
356   htdocsdir='$(prefix)/htdocs'
357   iconsdir='$(prefix)/icons'
358   cgidir='$(prefix)/cgi-bin'
359   logdir='$(prefix)/logs'
360   sysconfdir='${prefix}/conf'
361   layout_name=Apache
362 else  
363   APACHE_LAYOUT($srcdir/../config.layout, $LAYOUT)
364 fi
365
366 AC_MSG_CHECKING(for chosen layout)
367 AC_MSG_RESULT($layout_name)
368 ])dnl
369 dnl
370 dnl APACHE_ENABLE_SHARED
371 dnl
372 AC_DEFUN(APACHE_ENABLE_SHARED,[
373 AC_ARG_ENABLE(mods-shared,
374 [  --enable-mods-shared=MODULE-LIST],[
375   for i in $enableval; do
376         eval "enable_$i=shared"
377   done
378 ])
379 ])dnl
380 dnl
381 dnl APACHE_ENABLE_MODULES
382 dnl
383 AC_DEFUN(APACHE_ENABLE_MODULES,[
384 AC_ARG_ENABLE(modules,
385 [  --enable-modules=MODULE-LIST],[
386   for i in $enableval; do
387     eval "enable_$i=yes"
388   done
389 ])
390 ])dnl
391
392 AC_DEFUN(APACHE_REQUIRE_CXX,[
393   if test -z "$apache_cxx_done"; then
394     AC_PROG_CXX
395     AC_PROG_CXXCPP
396     apache_cxx_done=yes
397   fi
398 ])