Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / siproxd / configure.in
1 dnl
2 dnl     History
3 dnl     -------
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
35 dnl
36 dnl
37
38 dnl Process this file with autoconf to produce a configure script.
39 AC_INIT(src/siproxd.c)
40
41 dnl ******************************************************************
42
43 dnl
44 dnl Release Version
45 dnl
46 SPD_MAJOR_VERSION=0
47 SPD_MINOR_VERSION=5
48 SPD_MICRO_VERSION=10
49
50 SPD_VERSION=$SPD_MAJOR_VERSION.$SPD_MINOR_VERSION.$SPD_MICRO_VERSION
51
52 dnl *********************************************************************
53
54 dnl
55 dnl Initialize automake stuff
56 dnl
57 AC_CONFIG_AUX_DIR(scripts)
58 AC_CANONICAL_SYSTEM
59 AM_CONFIG_HEADER(config.h)
60 AM_INIT_AUTOMAKE(siproxd, $SPD_VERSION)
61
62 dnl
63 dnl Checks for needed programs.
64 dnl
65 AC_PROG_AWK
66 AC_PROG_CC
67 AC_PROG_CPP
68 AC_PROG_RANLIB
69 AC_PROG_INSTALL
70 AC_PROG_LN_S
71
72 dnl
73 dnl add
74 dnl    --with-extra-includes
75 dnl    --with-extra-libs
76 dnl
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)
83
84 AC_ARG_WITH(extra-libs,
85    [  --with-extra-libs=DIR       adds non standard library paths],
86    extra_libs="$withval" )
87 AC_SUBST(extra_libs)
88 AC_MSG_CHECKING("extra libs")
89 AC_MSG_RESULT($extra_libs)
90
91 for each in $extra_includes; do
92    CPPFLAGS="$CPPFLAGS -I$each";
93 done
94
95 for each in $extra_libs; do
96    LIBS="$LIBS -L$each";
97 done
98
99 dnl
100 dnl add
101 dnl    --enable-static
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))
107
108 dnl
109 dnl add
110 dnl    --enable-dmalloc
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))
116
117
118 dnl
119 dnl target platform specific stuff
120 dnl
121 AC_DEFINE_UNQUOTED(UNAME,"$target",[target platform])
122 AC_MSG_CHECKING(target platform)
123 case "$target" in
124   *-*-linux*)
125     AC_MSG_RESULT(Linux)
126     AC_DEFINE(_LINUX,,[building on Linux platform])
127     ;;
128   *-*-freebsd*)
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"])
135     ;;
136   *-*-openbsd*)
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/"
142     ;;
143   *-*-netbsd*)
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"
149     ;;
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])
154     ;;
155   *-*-solaris2*)
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"
161     ;;
162   *-*-darwin*)
163     AC_MSG_RESULT(Mac OS X)
164     AC_DEFINE(_MACOSX,,[building on Mac OSX platform])
165     ;;
166   *-*-cygwin*)
167     AC_MSG_RESULT(Cygwin)
168     AC_DEFINE(_CYGWIN,,[building on Cygwin (Windows) platform])
169     ;;
170   *)
171     AC_MSG_RESULT(Unknown Platform)
172     AC_DEFINE(_UNKNOWN,,[building on unknown platform])
173     ;;
174 esac
175
176
177 dnl
178 dnl Feature:
179 dnl  Fli4l libc5 support  (only available on Linux, yet)
180 dnl  Fli4l uClibc support (only available on Linux, yet)
181 dnl
182 build_fli4l_libc5="no"
183 build_fli4l_21_uclibc="no"
184 build_fli4l_22_uclibc="no"
185 case "$target" in
186   *-*-linux*)
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)
192
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)
198
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)
204    ;;
205
206   *)
207     AC_MSG_RESULT(building FLI4L not available on this platform)
208     ;;
209 esac
210
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"
223 fi
224
225
226 dnl
227 dnl Check for pthreads
228 dnl
229 ACX_PTHREAD(,
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"
235    CC="$PTHREAD_CC"
236 else
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)
246    else
247       echo "*** ERROR: a static threads library is required!";exit 1;
248    fi
249    CC="$PTHREAD_CC"
250 fi
251
252
253 dnl
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)
257 dnl
258 CFLAGS="$CFLAGS -D_POSIX_THREAD_SAFE_FUNCTIONS"
259
260
261 dnl
262 dnl add
263 dnl    --with-libosip-prefix=DIR
264 dnl
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,
269    )
270 AC_SUBST(libosip_prefix_dir)
271 AC_MSG_CHECKING("libosip prefix")
272 AC_MSG_RESULT($libosip_prefix_dir)
273
274 dnl
275 dnl Check for libosip
276 dnl
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"
280 fi
281
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;,
287       [-losipparser2])
288    AC_CHECK_LIB(osipparser2, parser_init,,
289       echo "*** ERROR: libosipparser2 is required!";exit 1;,)
290 else
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)
299    else
300       echo "*** ERROR: a static libosip library is required!";exit 1;
301    fi
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)
308    else
309       echo "*** ERROR: a static libosip library is required!";exit 1;
310    fi
311 fi
312
313
314 dnl
315 dnl add
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],
320       FWLIBS="$withval";
321       AC_DEFINE(CUSTOM_FWMODULE, 1,[use custom firewall control module])
322       AC_MSG_RESULT($FWLIBS), AC_MSG_RESULT(no))
323
324
325 dnl
326 dnl Checks for header files.
327 dnl
328 AC_HEADER_STDC
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)
332
333 dnl
334 dnl Checks for typedefs, structures, and compiler characteristics.
335 dnl
336 AC_C_CONST
337 AC_TYPE_SIZE_T
338 AC_HEADER_TIME
339 AC_STRUCT_TM
340
341 dnl
342 dnl check for typedef socklen (not available on SUSE 5.3 for example)
343 dnl
344 dnl  FreeBSD has it in <netdb.h> and <sys/socket.h>
345 AC_CHECK_TYPE(socklen_t,
346     ,
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]
351     [#include <netdb.h>]
352     [#endif]]
353 )
354
355 dnl
356 dnl Checks for library functions.
357 dnl
358
359
360 AC_FUNC_MEMCMP
361 AC_FUNC_VPRINTF
362 AC_CHECK_FUNCS(strerror)
363
364 AC_CHECK_FUNCS(gethostbyname)
365
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()
371 fi
372
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)
385
386
387
388 dnl
389 dnl sysconfdir
390 dnl
391 SIPROXDCONFPATH=""
392 tmpset="$sysconfdir"
393 while test "x$tmpset" != "x$SIPROXDCONFPATH"; do
394   SIPROXDCONFPATH="$tmpset"
395   eval tmpset="$tmpset"
396 done
397 AC_DEFINE_UNQUOTED(SIPROXDCONFPATH,"$SIPROXDCONFPATH",
398                   [will search for config file here])
399
400 LIBS="$LIBS $FWLIBS"
401
402 AC_SUBST(CPPFLAGS)
403 AC_SUBST(LDFLAGS)
404 AC_SUBST(LIBS)
405
406 dnl
407 dnl Generate output files
408 dnl
409 AC_OUTPUT( \
410 siproxd.spec \
411 Makefile \
412 src/Makefile \
413 doc/Makefile \
414 scripts/Makefile \
415 contrib/Makefile \
416 )