4 dnl before time a lot happend before start of history
5 dnl 8-Sep-2002 tries included more tests for used functions
6 dnl 17-Sep-2002 tries fail configure if needed libs not there
7 dnl 14-Nov-2002 tries support for *BSD systems
8 dnl 22-Mar-2003 tries check for sockaddr_t, hstrerror()
9 dnl --enable-almost-static (for Fli4l use)
10 dnl --enable-uclibc (uClibc building support)
11 dnl 29-Mar-2003 tries added support for libosip2
12 dnl 6-Apr-2003 tries redone the fli4l specific build options
13 dnl now: --enable-fli4l-libc5, --enable-fli4l-uclibc
14 dnl 7-Apr-2003 tries added siproxd.spec to autoconf process
15 dnl 31-Jul-2003 tries changed to support OSIP2 only
16 dnl 1-Sep-2003 tries check for IPCHAINS
17 dnl 5-Sep-2003 tries test for pthreads before libosip stuff
18 dnl 19-Sep-2003 tries DMALLOC support
19 dnl 1-Nov-2003 tries check for NETFILTER (IPTABLES)
20 dnl 18-Nov-2003 tries include sysconfdir to search for config
21 dnl 19-Nov-2003 tries changes to support Solaris & BSD/OS
22 dnl 22-Nov-2003 tries test for gethostbyname_r() & # of args
23 dnl 22-Jan-2004 tries add --enable-static option
24 dnl 06-Mar-2004 tries del daemon(), add setsid()
25 dnl 09-Apr-2004 tries add --with-custom-fwmodule
26 dnl 09-May-2004 tries fli4l-uclibc links statically agains pthreads
27 dnl 29-May-2004 tries use AC_CHECK_TYPE to check for socklen_t
28 dnl 09-May-2004 tries fli4l-libc5 does NOT use gethostbyname_r()
29 dnl (there seems to be a bug somewhere)
30 dnl 18-Aug-2004 tries fli4l-uclibc -> fli4l-21-uclibc, fli4l-22-uclibc
31 dnl 2.1.x has no pthread support, link -static
32 dnl 2.2.x has (maybe) pthread support
33 dnl 08-Jan-2005 tries FreeBSD: check for libgnugetopt before using it
34 dnl Cygwin build support
38 dnl Process this file with autoconf to produce a configure script.
39 AC_INIT(src/siproxd.c)
41 dnl ******************************************************************
50 SPD_VERSION=$SPD_MAJOR_VERSION.$SPD_MINOR_VERSION.$SPD_MICRO_VERSION
52 dnl *********************************************************************
55 dnl Initialize automake stuff
57 AC_CONFIG_AUX_DIR(scripts)
59 AM_CONFIG_HEADER(config.h)
60 AM_INIT_AUTOMAKE(siproxd, $SPD_VERSION)
63 dnl Checks for needed programs.
74 dnl --with-extra-includes
77 AC_ARG_WITH(extra-includes,
78 [ --with-extra-includes=DIR adds non standard include paths],
79 extra_includes="$withval" )
80 AC_SUBST(extra_includes)
81 AC_MSG_CHECKING("extra includes")
82 AC_MSG_RESULT($extra_includes)
84 AC_ARG_WITH(extra-libs,
85 [ --with-extra-libs=DIR adds non standard library paths],
86 extra_libs="$withval" )
88 AC_MSG_CHECKING("extra libs")
89 AC_MSG_RESULT($extra_libs)
91 for each in $extra_includes; do
92 CPPFLAGS="$CPPFLAGS -I$each";
95 for each in $extra_libs; do
102 AC_MSG_CHECKING(build statically linked executable)
103 AC_ARG_ENABLE(static,
104 [ --enable-static build statically linked executable],
105 LDFLAGS="$LDFLAGS -static";
106 AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
111 AC_MSG_CHECKING(building with DMALLOC support)
112 AC_ARG_ENABLE(dmalloc,
113 [ --enable-dmalloc build with DMALLOC support],
114 CFLAGS="$CFLAGS -DDMALLOC ";LIBS="-ldmallocth $LIBS";
115 AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
119 dnl target platform specific stuff
121 AC_DEFINE_UNQUOTED(UNAME,"$target",[target platform])
122 AC_MSG_CHECKING(target platform)
126 AC_DEFINE(_LINUX,,[building on Linux platform])
129 AC_MSG_RESULT(FreeBSD)
130 AC_DEFINE(_BSD,,[building on BSD platform])
131 AC_DEFINE(_FREEBSD,,[building on FreeBSD platform])
132 CPPFLAGS="$CPPFLAGS -I/usr/local/include/"
133 LIBS="$LIBS -L/usr/local/lib/"
134 AC_CHECK_LIB(gnugetopt,getopt_long,[LIBS="$LIBS -lgnugetopt"])
137 AC_MSG_RESULT(OpenBSD)
138 AC_DEFINE(_BSD,,[building on BSD platform])
139 AC_DEFINE(_OPENBSD,,[building on OpenBSD platform])
140 CPPFLAGS="$CPPFLAGS -I/usr/local/include/"
141 LIBS="$LIBS -L/usr/local/lib/"
144 AC_MSG_RESULT(NetBSD)
145 AC_DEFINE(_BSD,,[building on BSD platform])
146 AC_DEFINE(_NETBSD,,[building on NetBSD platform])
147 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include"
148 LIBS="$LIBS -L/usr/pkg/lib"
150 *-*-bsdi* | *-*-bsdos*)
151 AC_MSG_RESULT(BSD/OS)
152 AC_DEFINE(_BSD,,[building on BSD platform])
153 AC_DEFINE(_BSDOS,,[building on BSD/OS platform])
156 # It's easier to do this here, rather than AC_CHECK_LIBS for all of the
157 # things that are/might be in libsocket or libnsl...
158 AC_MSG_RESULT(Solaris 2.x)
159 AC_DEFINE(_SOLARIS2,,[building on Solaris2 platform])
160 LIBS="$LIBS -lsocket -lnsl"
163 AC_MSG_RESULT(Mac OS X)
164 AC_DEFINE(_MACOSX,,[building on Mac OSX platform])
167 AC_MSG_RESULT(Cygwin)
168 AC_DEFINE(_CYGWIN,,[building on Cygwin (Windows) platform])
171 AC_MSG_RESULT(Unknown Platform)
172 AC_DEFINE(_UNKNOWN,,[building on unknown platform])
179 dnl Fli4l libc5 support (only available on Linux, yet)
180 dnl Fli4l uClibc support (only available on Linux, yet)
182 build_fli4l_libc5="no"
183 build_fli4l_21_uclibc="no"
184 build_fli4l_22_uclibc="no"
187 AC_MSG_CHECKING(whether build for FLI4L 2.0.x libc5 )
188 AC_ARG_ENABLE(fli4l-libc5,
189 [ --enable-fli4l-libc5 build FLI4L 2.0.x (libc5)],
190 build_fli4l_libc5=$enableval,)
191 AC_MSG_RESULT($build_fli4l_libc5)
193 AC_MSG_CHECKING(whether build for FLI4L 2.1.x uClibc)
194 AC_ARG_ENABLE(fli4l-21-uclibc,
195 [ --enable-fli4l-21-uclibc build FLI4L 2.1.x (uClibc, no pthreads support)],
196 build_fli4l_21_uclibc=$enableval,)
197 AC_MSG_RESULT($build_fli4l_21_uclibc)
199 AC_MSG_CHECKING(whether build for FLI4L 2.2.x uClibc)
200 AC_ARG_ENABLE(fli4l-22-uclibc,
201 [ --enable-fli4l-22-uclibc build FLI4L 2.2.x (uClibc, with pthreads support)],
202 build_fli4l_22_uclibc=$enableval,)
203 AC_MSG_RESULT($build_fli4l_22_uclibc)
207 AC_MSG_RESULT(building FLI4L not available on this platform)
211 build_static_libosip="no"
212 build_static_pthread="no"
213 if test "x$build_fli4l_libc5" = "xyes"; then
214 dnl FLI4l 2.0.x libc5: make libosip and libpthread static
215 build_static_libosip="yes"
216 build_static_pthread="yes"
217 elif test "x$build_fli4l_21_uclibc" = "xyes"; then
218 dnl FLI4l 2.1.x uClibc: build all static
219 LDFLAGS="$LDFLAGS -static";
220 elif test "x$build_fli4l_22_uclibc" = "xyes"; then
221 dnl FLI4l 2.2.x uClibc: make libosip and libpthread static
222 build_static_libosip="yes"
227 dnl Check for pthreads
230 echo "*** ERROR: pthreads is required!"; exit 1;)
231 if test "x$build_static_pthread" = "xno"; then
232 dnl link dynamically (default)
233 LIBS="$PTHREAD_LIBS $LIBS"
234 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
237 dnl link statically to this lib
238 dnl (this probably only will work on linux yet...)
239 AC_MSG_CHECKING("where I can find static threads library")
240 libpthreads_static=`find $extra_libs /lib /usr/lib /usr/local/lib \
241 -name 'lib*thread*.a' 2>/dev/null| \
242 egrep 'lib[p]?thread[s]?.a' |head -1`
243 if test "x$libpthreads_static" != "x"; then
244 LIBS="$libpthreads_static $LIBS"
245 AC_MSG_RESULT($libpthreads_static)
247 echo "*** ERROR: a static threads library is required!";exit 1;
254 dnl Make sure that symbol _POSIX_THREAD_SAFE_FUNCTIONS is defined.
255 dnl This is needed by some platforms to make reentrant functions
256 dnl available (gethostbyname_r)
258 CFLAGS="$CFLAGS -D_POSIX_THREAD_SAFE_FUNCTIONS"
263 dnl --with-libosip-prefix=DIR
265 libosip_prefix_dir=""
266 AC_ARG_WITH(libosip-prefix,
267 [ --with-libosip-prefix=DIR use libosip2 from DIR/include and DIR/lib],
268 if test x$withval != x ; then libosip_prefix_dir="$withval"; fi,
270 AC_SUBST(libosip_prefix_dir)
271 AC_MSG_CHECKING("libosip prefix")
272 AC_MSG_RESULT($libosip_prefix_dir)
275 dnl Check for libosip
277 if test x$libosip_prefix_dir != x; then
278 LIBS="-L$libosip_prefix_dir/lib $LIBS"
279 CPPFLAGS="$CPPFLAGS -I$libosip_prefix_dir/include"
282 if test "x$build_static_libosip" = "xno"; then
283 dnl link dynamically (default)
284 AC_CHECK_LIB(osip2, osip_init,,
285 echo "*** ERROR: libosip2 is required! "\
286 "Maybe you need to use --with-libosip-prefix ?"; exit 1;,
288 AC_CHECK_LIB(osipparser2, parser_init,,
289 echo "*** ERROR: libosipparser2 is required!";exit 1;,)
291 dnl link statically to this lib
292 dnl (this probably only will work on linux yet...)
293 AC_MSG_CHECKING("where I can find libosip2.a")
294 libosip_static=`find $extra_libs /lib /usr/lib /usr/local/lib \
295 -name libosip2.a 2>/dev/null|head -1`
296 if test "x$libosip_static" != "x"; then
297 LIBS="$libosip_static $LIBS"
298 AC_MSG_RESULT($libosip_static)
300 echo "*** ERROR: a static libosip library is required!";exit 1;
302 AC_MSG_CHECKING("where I can find libosipparser2.a")
303 libosip_static=`find $extra_libs /lib /usr/lib /usr/local/lib \
304 -name libosipparser2.a 2>/dev/null|head -1`
305 if test "x$libosip_static" != "x"; then
306 LIBS="$libosip_static $LIBS"
307 AC_MSG_RESULT($libosip_static)
309 echo "*** ERROR: a static libosip library is required!";exit 1;
316 dnl --with-custom-fwmodule
317 AC_MSG_CHECKING(building with a custom FW module)
318 AC_ARG_WITH(custom-fwmodule,
319 [ --with-custom-fwmodule=LIBRARY.a use custom firewall control module],
321 AC_DEFINE(CUSTOM_FWMODULE, 1,[use custom firewall control module])
322 AC_MSG_RESULT($FWLIBS), AC_MSG_RESULT(no))
326 dnl Checks for header files.
329 AC_CHECK_HEADERS(sys/time.h errno.h)
330 AC_CHECK_HEADERS(stdarg.h varargs.h)
331 AC_CHECK_HEADERS(pwd.h getopt.h sys/socket.h netdb.h)
334 dnl Checks for typedefs, structures, and compiler characteristics.
342 dnl check for typedef socklen (not available on SUSE 5.3 for example)
344 dnl FreeBSD has it in <netdb.h> and <sys/socket.h>
345 AC_CHECK_TYPE(socklen_t,
347 AC_MSG_RESULT(socklen_t is not available - creating DEFINE to uint)
348 AC_DEFINE(socklen_t, [unsigned int],[typedef socklen_t available]),
349 [[$ac_includes_default]
350 [#ifdef HAVE_NETDB_H]
356 dnl Checks for library functions.
362 AC_CHECK_FUNCS(strerror)
364 AC_CHECK_FUNCS(gethostbyname)
366 dnl !! with FLI4L 2.0.x strange behavior with gethostbyname_r()
367 dnl !! has been seen, dont use it.
368 if test "x$build_fli4l_libc5" = "xno"; then
369 dnl AC_CHECK_FUNCS(gethostbyname_r)
370 ACX_WHICH_GETHOSTBYNAME_R()
373 AC_CHECK_FUNCS(getopt_long setsid syslog)
374 AC_CHECK_FUNCS(getuid setuid getgid setgid getpwnam chroot)
375 AC_CHECK_FUNCS(socket bind select read send sendto fcntl)
376 AC_CHECK_FUNCS(strncpy strchr strstr sprintf vfprintf vsnprintf)
377 AC_CHECK_FUNCS(listen accept)
378 AC_CHECK_FUNCS(fgets sscanf)
379 AC_CHECK_FUNCS(hstrerror,,AC_CHECK_LIB(resolv,hstrerror,[
380 AC_DEFINE_UNQUOTED(HAVE_HSTRERROR)
381 LIBS="$LIBS -lresolv"]))
382 AC_CHECK_FUNCS(inet_pton inet_ntop inet_aton inet_ntoa)
383 AC_CHECK_FUNCS(pthread_setschedparam sched_get_priority_min)
384 AC_CHECK_FUNCS(sched_get_priority_max)
393 while test "x$tmpset" != "x$SIPROXDCONFPATH"; do
394 SIPROXDCONFPATH="$tmpset"
395 eval tmpset="$tmpset"
397 AC_DEFINE_UNQUOTED(SIPROXDCONFPATH,"$SIPROXDCONFPATH",
398 [will search for config file here])
407 dnl Generate output files