1dnl 2dnl History 3dnl ------- 4dnl before time a lot happend before start of history 5dnl 8-Sep-2002 tries included more tests for used functions 6dnl 17-Sep-2002 tries fail configure if needed libs not there 7dnl 14-Nov-2002 tries support for *BSD systems 8dnl 22-Mar-2003 tries check for sockaddr_t, hstrerror() 9dnl --enable-almost-static (for Fli4l use) 10dnl --enable-uclibc (uClibc building support) 11dnl 29-Mar-2003 tries added support for libosip2 12dnl 6-Apr-2003 tries redone the fli4l specific build options 13dnl now: --enable-fli4l-libc5, --enable-fli4l-uclibc 14dnl 7-Apr-2003 tries added siproxd.spec to autoconf process 15dnl 31-Jul-2003 tries changed to support OSIP2 only 16dnl 1-Sep-2003 tries check for IPCHAINS 17dnl 5-Sep-2003 tries test for pthreads before libosip stuff 18dnl 19-Sep-2003 tries DMALLOC support 19dnl 1-Nov-2003 tries check for NETFILTER (IPTABLES) 20dnl 18-Nov-2003 tries include sysconfdir to search for config 21dnl 19-Nov-2003 tries changes to support Solaris & BSD/OS 22dnl 22-Nov-2003 tries test for gethostbyname_r() & # of args 23dnl 22-Jan-2004 tries add --enable-static-exe option 24dnl 06-Mar-2004 tries del daemon(), add setsid() 25dnl 09-Apr-2004 tries add --with-custom-fwmodule 26dnl 09-May-2004 tries fli4l-uclibc links statically agains pthreads 27dnl 29-May-2004 tries use AC_CHECK_TYPE to check for socklen_t 28dnl 09-May-2004 tries fli4l-libc5 does NOT use gethostbyname_r() 29dnl (there seems to be a bug somewhere) 30dnl 18-Aug-2004 tries fli4l-uclibc -> fli4l-21-uclibc, fli4l-22-uclibc 31dnl 2.1.x has no pthread support, link -static 32dnl 2.2.x has (maybe) pthread support 33dnl 08-Jan-2005 tries FreeBSD: check for libgnugetopt before using it 34dnl Cygwin build support 35dnl 13-Feb-2005 tries check for # of args on libosip2 functions 36dnl 10-Apr-2005 tries check for docbook 37dnl 18-Apr-2005 tries added libresolv 38dnl 9-Oct-2005 tries libresolv is now included in static build 39dnl 10-Jun-2007 tries test more .h files (DNS resolver related) 40dnl 18-Dec-2007 tries requires libosip2-3.x.x 41dnl 02-Feb-2008 tries removed variety of fli4l and static extra 42dnl build options 43dnl 21-Feb-2009 tries --enable-static-libosip2 does search static 44dnl libs now in libosip_prefix_dir 45dnl 1-Mar-2009 tries building with --enable-static-libosip2 requires 46dnl --disable-shared to be set as well (plugins will 47dnl be statically linked into siproxd) 48dnl 19-Feb-2010 tries CVE-2009-3736: use libltdl on host if existing 49dnl and fall back using convenienve libltdl (WARN) 50dnl 26-Apr-2010 tries Fresh building from distribuion TAR did fail if 51dnl the host-installed libltdl lib is used (and not the 52dnl convenience lib) 53dnl 09-Jan-2011 tries use CFLAGS -Wall only with GCC compiler 54dnl 15-Sep-2011 tries added --with-included-libtool to force the 55dnl use of the included libltdl 56dnl 17-Jul-2015 tries added --with-ltdl-fix 57dnl 58dnl 59 60dnl Process this file with autoconf to produce a configure script. 61AC_INIT(src/siproxd.c) 62 63dnl ****************************************************************** 64 65dnl 66dnl Release Version 67dnl 68SPD_MAJOR_VERSION=0 69SPD_MINOR_VERSION=8 70SPD_MICRO_VERSION=2 71 72SPD_VERSION=$SPD_MAJOR_VERSION.$SPD_MINOR_VERSION.$SPD_MICRO_VERSION 73 74dnl ********************************************************************* 75 76 77dnl 78dnl Initialize automake stuff 79dnl 80AC_CONFIG_AUX_DIR(scripts) 81AC_CANONICAL_SYSTEM 82AM_CONFIG_HEADER(config.h) 83AM_INIT_AUTOMAKE(siproxd, $SPD_VERSION) 84 85 86dnl 87dnl Checks for needed programs. 88dnl 89AC_PROG_AWK 90AC_PROG_CC 91AC_PROG_CPP 92AC_PROG_INSTALL 93AC_PROG_LN_S 94AC_CHECK_PROG(docbook2pdf,docbook2pdf,yes,) 95AM_CONDITIONAL(have_docbook2pdf,test "$docbook2pdf" = "yes") 96AC_CHECK_PROG(docbook2html,docbook2html,yes,) 97AM_CONDITIONAL(have_docbook2html,test "$docbook2html" = "yes") 98 99 100dnl ********************************************** 101dnl * Location of libraries / headerfiles 102dnl ********************************************** 103dnl 104dnl --with-extra-includes 105dnl --with-extra-libs 106dnl 107AC_ARG_WITH(extra-includes, 108 [ --with-extra-includes=DIR adds non standard include paths], 109 extra_includes="$withval" ) 110AC_SUBST(extra_includes) 111AC_MSG_CHECKING("extra includes") 112AC_MSG_RESULT($extra_includes) 113 114AC_ARG_WITH(extra-libs, 115 [ --with-extra-libs=DIR adds non standard library paths], 116 extra_libs="$withval" ) 117AC_SUBST(extra_libs) 118AC_MSG_CHECKING("extra libs") 119AC_MSG_RESULT($extra_libs) 120 121for each in $extra_includes; do 122 CPPFLAGS="$CPPFLAGS -I$each"; 123done 124 125for each in $extra_libs; do 126 LIBS="$LIBS -L$each"; 127done 128 129 130dnl ********************************************** 131dnl prepare libtool (ltdl) 132dnl ********************************************** 133dnl 134dnl We require the ltdl (libtool portable dynamic loader) 135dnl for our plugins. As this would require the automake/libtool 136dnl packages to be present we include that library with 137dnl the siproxd package as so called "convenience library" 138dnl 139AC_CHECK_LIB(ltdl, lt_dlopen, [ 140 echo "Good: native libltdl found, using it."; 141 use_native_ltdl="yes"; 142],[ 143 echo "*** WARNING: no native libltdl found, using convenience libltdl!"; 144 use_native_ltdl="no"; 145],) 146 147AC_ARG_WITH(included-libtool, 148 [ --with-included-libtool force the use of included libltdl (libtool)], 149 use_native_ltdl="no";echo "*** FORCED to use included convenience libltdl", 150 ) 151 152AC_ARG_WITH(ltdl-fix, 153 [ --with-ltdl-fix work around broken ltdl versions (fix linking 154 error "undefined reference to lt__PROGRAM..."], 155 AC_DEFINE(WITH_LTDL_FIX,,[ltdl workaround for undefined reference linking error]), 156 ) 157 158if test "x$use_native_ltdl" = "xno"; then 159 AC_LIBLTDL_CONVENIENCE 160 AM_CONDITIONAL(use_convenience_ltdl,true) 161else 162 AM_CONDITIONAL(use_convenience_ltdl,false) 163fi 164 165dnl 166dnl Check for dlopen support 167AC_LIBTOOL_DLOPEN 168dnl 169dnl Configure libtool 170AC_PROG_LIBTOOL 171dnl 172dnl Substitute LTDLINCL and LIBLTDL in the Makefiles 173dnl this is only done if no native libltdl is found. 174 175if test "x$use_native_ltdl" = "xyes"; then 176 true; 177 LIBS="$LIBS -lltdl"; 178else 179 true; 180 AC_SUBST(LTDLINCL) 181 AC_SUBST(LIBLTDL) 182fi 183AC_CONFIG_SUBDIRS(libltdl) 184 185 186dnl ********************************************** 187dnl * Building doc 188dnl ********************************************** 189 190dnl 191dnl --enable-doc 192dnl 193 194 build_docs="yes"; 195 AC_MSG_CHECKING(build documentation) 196 AC_ARG_ENABLE(doc, 197 [ --disable-doc build pdf/html doc (default=enabled)], 198 if test "x$enableval" = "xno"; then 199 build_docs="no"; 200 fi 201 AC_MSG_RESULT($build_docs), AC_MSG_RESULT($build_docs)) 202 if test "x$build_docs" = "xyes"; then 203 AC_CHECK_PROG(docbook2pdf,docbook2pdf,yes,) 204 AM_CONDITIONAL(have_docbook2pdf,test "$docbook2pdf" = "yes") 205 AC_CHECK_PROG(docbook2html,docbook2html,yes,) 206 AM_CONDITIONAL(have_docbook2html,test "$docbook2html" = "yes") 207 else 208 AM_CONDITIONAL(have_docbook2pdf,false) 209 AM_CONDITIONAL(have_docbook2html,false) 210 fi 211 212 213dnl ********************************************** 214dnl * Selection of static build variants 215dnl ********************************************** 216dnl 217dnl --enable-static-libosip2 218dnl 219 build_static_libosip="no" 220 AC_MSG_CHECKING(link statically against libosip2) 221 AC_ARG_ENABLE(static-libosip2, 222 [ --enable-static-libosip2 link statically against libosip2], 223 build_static_libosip="$enableval"; 224 AC_MSG_RESULT($enableval), AC_MSG_RESULT(no)) 225 if test "x$build_static_libosip" = "xyes"; then 226dnl AC_MSG_RESULT(Plugins will be linked in statically.) 227dnl enable_shared=no; 228 if test "x$enable_shared" = "xyes"; then 229 echo "*** ERROR: requires the '--disable-shared' option to be specified!";exit 1; 230 fi 231 fi 232 233 234dnl ********************************************** 235dnl * Debugging helps 236dnl ********************************************** 237 238dnl 239dnl --enable-dmalloc 240dnl 241 AC_MSG_CHECKING(building with DMALLOC support) 242 AC_ARG_ENABLE(dmalloc, 243 [ --enable-dmalloc build with DMALLOC support], 244 dmalloc="$enableval"; 245 AC_MSG_RESULT($enableval), AC_MSG_RESULT(no)) 246 if test "x$dmalloc" = "xyes"; then 247 CFLAGS="$CFLAGS -DDMALLOC ";LIBS="-ldmallocth $LIBS"; 248 fi 249 250 251dnl 252dnl Use -Wall if we have gcc. 253dnl 254 if test "x$GCC" = "xyes"; then 255 case " $CFLAGS " in 256 *[\ ]-Wall[\ ]*) ;; 257 *) CFLAGS="$CFLAGS -Wall" ;; 258 esac 259 fi 260 261 262dnl 263dnl target platform specific stuff 264dnl 265AC_DEFINE_UNQUOTED(UNAME,"$target",[target platform]) 266AC_MSG_CHECKING(target platform) 267case "$target" in 268 *-*-linux*) 269 AC_MSG_RESULT(Linux) 270 AC_DEFINE(_LINUX,,[building on Linux platform]) 271 ;; 272 *-*-freebsd*) 273 AC_MSG_RESULT(FreeBSD) 274 AC_DEFINE(_BSD,,[building on BSD platform]) 275 AC_DEFINE(_FREEBSD,,[building on FreeBSD platform]) 276 CPPFLAGS="$CPPFLAGS -I/usr/local/include/" 277 LIBS="$LIBS -L/usr/local/lib/" 278 AC_CHECK_LIB(gnugetopt,getopt_long,[LIBS="$LIBS -lgnugetopt"]) 279 ;; 280 *-*-openbsd*) 281 AC_MSG_RESULT(OpenBSD) 282 AC_DEFINE(_BSD,,[building on BSD platform]) 283 AC_DEFINE(_OPENBSD,,[building on OpenBSD platform]) 284 CPPFLAGS="$CPPFLAGS -I/usr/local/include/" 285 LIBS="$LIBS -L/usr/local/lib/" 286 ;; 287 *-*-netbsd*) 288 AC_MSG_RESULT(NetBSD) 289 AC_DEFINE(_BSD,,[building on BSD platform]) 290 AC_DEFINE(_NETBSD,,[building on NetBSD platform]) 291 CPPFLAGS="$CPPFLAGS -I/usr/pkg/include" 292 LIBS="$LIBS -L/usr/pkg/lib" 293 ;; 294 *-*-bsdi* | *-*-bsdos*) 295 AC_MSG_RESULT(BSD/OS) 296 AC_DEFINE(_BSD,,[building on BSD platform]) 297 AC_DEFINE(_BSDOS,,[building on BSD/OS platform]) 298 ;; 299 *-*-solaris2*) 300 # It's easier to do this here, rather than AC_CHECK_LIBS for all of the 301 # things that are/might be in libsocket or libnsl... 302 AC_MSG_RESULT(Solaris 2.x) 303 AC_DEFINE(_SOLARIS2,,[building on Solaris2 platform]) 304 LIBS="$LIBS -lsocket -lnsl" 305 ;; 306 *-*-darwin*) 307 AC_MSG_RESULT(Mac OS X) 308 AC_DEFINE(_MACOSX,,[building on Mac OSX platform]) 309 ;; 310 *-*-cygwin*) 311 AC_MSG_RESULT(Cygwin) 312 AC_DEFINE(_CYGWIN,,[building on Cygwin (Windows) platform]) 313 ;; 314 *) 315 AC_MSG_RESULT(Unknown Platform) 316 AC_DEFINE(_UNKNOWN,,[building on unknown platform]) 317 ;; 318esac 319 320 321dnl 322dnl Check for pthreads 323dnl 324ACX_PTHREAD(, 325 echo "*** ERROR: pthreads is required!"; exit 1;) 326 dnl link dynamically (default) 327 LIBS="$PTHREAD_LIBS $LIBS" 328 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 329 LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS" 330 CC="$PTHREAD_CC" 331 332 333dnl 334dnl Make sure that symbol _POSIX_THREAD_SAFE_FUNCTIONS is defined. 335dnl This is needed by some platforms to make reentrant functions 336dnl available (gethostbyname_r) 337dnl 338CFLAGS="$CFLAGS -D_POSIX_THREAD_SAFE_FUNCTIONS" 339 340 341dnl 342dnl add 343dnl --with-libosip-prefix=DIR 344dnl 345libosip_prefix_dir="" 346AC_ARG_WITH(libosip-prefix, 347 [ --with-libosip-prefix=DIR use libosip2 from DIR/include and DIR/lib], 348 if test x$withval != x ; then libosip_prefix_dir="$withval"; fi, 349 ) 350AC_SUBST(libosip_prefix_dir) 351AC_MSG_CHECKING("libosip prefix") 352AC_MSG_RESULT($libosip_prefix_dir) 353 354 355dnl 356dnl Check for libosip 357dnl 358if test x$libosip_prefix_dir != x; then 359 LIBS="-L$libosip_prefix_dir/lib $LIBS" 360 CPPFLAGS="$CPPFLAGS -I$libosip_prefix_dir/include" 361fi 362 363dnl 364dnl Static or dynamic linking against libosip 365dnl 366if test "x$build_static_libosip" = "xno"; then 367 dnl link dynamically (default) 368 AC_CHECK_LIB(osip2, osip_init,, 369 echo "*** ERROR: libosip2 is required! "\ 370 "Maybe you need to use --with-libosip-prefix ?"; exit 1;, 371 [-losipparser2]) 372 AC_CHECK_LIB(osipparser2, parser_init,, 373 echo "*** ERROR: libosipparser2 is required!";exit 1;,) 374else 375 dnl link statically to this lib 376 dnl (this probably only will work on linux yet...) 377 AC_MSG_CHECKING("where I can find libosip2.a") 378 libosip_static=`find $extra_libs $libosip_prefix_dir/lib /lib \ 379 /usr/lib /usr/local/lib \ 380 -name libosip2.a 2>/dev/null|head -1` 381 if test "x$libosip_static" != "x"; then 382 LIBS="$libosip_static $LIBS" 383 AC_MSG_RESULT($libosip_static) 384 else 385 echo "*** ERROR: a static libosip library is required!";exit 1; 386 fi 387 AC_MSG_CHECKING("where I can find libosipparser2.a") 388 libosip_static=`find $extra_libs $libosip_prefix_dir/lib /lib \ 389 /usr/lib /usr/local/lib \ 390 -name libosipparser2.a 2>/dev/null|head -1` 391 if test "x$libosip_static" != "x"; then 392 LIBS="$libosip_static $LIBS" 393 AC_MSG_RESULT($libosip_static) 394 else 395 echo "*** ERROR: a static libosip library is required!";exit 1; 396 fi 397fi 398 399dnl 400dnl correct version of libosip2? 401dnl 402ACX_CHECK_LIBOSIP_VERSION() 403 404 405dnl 406dnl add 407dnl --with-custom-fwmodule 408 AC_MSG_CHECKING(building with a custom FW module) 409 AC_ARG_WITH(custom-fwmodule, 410 [ --with-custom-fwmodule=LIBRARY.a use custom firewall control module], 411 FWLIBS="$withval"; 412 AC_DEFINE(CUSTOM_FWMODULE, 1,[use custom firewall control module]) 413 AC_MSG_RESULT($FWLIBS), AC_MSG_RESULT(no)) 414 415 416dnl 417dnl Checks for header files. 418dnl 419AC_HEADER_STDC 420AC_CHECK_HEADERS(sys/time.h errno.h) 421AC_CHECK_HEADERS(stdarg.h varargs.h) 422AC_CHECK_HEADERS(pwd.h getopt.h sys/socket.h netdb.h) 423AC_CHECK_HEADERS(resolv.h arpa/nameser.h) 424 425 426dnl 427dnl Checks for typedefs, structures, and compiler characteristics. 428dnl 429AC_C_CONST 430AC_TYPE_SIZE_T 431AC_HEADER_TIME 432AC_STRUCT_TM 433 434 435dnl 436dnl Check for Constants that may be non-existing on some platforms 437dnl 438dnl SOL_IP (used in setsockopt) 439AC_CHECK_DECL(SOL_IP, 440 , 441 AC_MSG_RESULT(SOL_IP is not available - creating DEFINE to IPPROTO_IP) 442 AC_DEFINE(SOL_IP,IPPROTO_IP,[SOL_IP for setsockopt()]), 443 [[$ac_includes_default] 444 [#ifdef HAVE_NETDB_H] 445 [#include <netdb.h>] 446 [#endif] 447 [#ifdef HAVE_SYS_SOCKET_H] 448 [#include <sys/socket.h>] 449 [#endif] 450 ] 451) 452 453 454dnl 455dnl check for typedef socklen (not available on SUSE 5.3 for example) 456dnl 457dnl FreeBSD has it in <netdb.h> and <sys/socket.h> 458AC_CHECK_TYPE(socklen_t, 459 , 460 AC_MSG_RESULT(socklen_t is not available - creating DEFINE to uint) 461 AC_DEFINE(socklen_t, [unsigned int],[typedef socklen_t available]), 462 [[$ac_includes_default] 463 [#ifdef HAVE_NETDB_H] 464 [#include <netdb.h>] 465 [#endif] 466 [#ifdef HAVE_SYS_SOCKET_H] 467 [#include <sys/socket.h>] 468 [#endif] 469 ] 470) 471 472 473dnl 474dnl Checks for libraries 475dnl Note: the __res_query symbol is to catch the lib when building "static" 476dnl 477 AC_CHECK_LIB(resolv,res_query,) dnl found only in static lib 478 AC_CHECK_LIB(resolv,__res_query,) dnl found in static and dynamic lib 479 480 481dnl 482dnl Checks for library functions. 483dnl 484 485AC_FUNC_MEMCMP 486AC_FUNC_VPRINTF 487AC_CHECK_FUNCS(strerror) 488 489AC_CHECK_FUNCS(gethostbyname) 490 491dnl !! with FLI4L 2.0.x strange behavior with gethostbyname_r() 492dnl !! has been seen, dont use it. the ACX_WHICH_GETHOSTBYNAME_R 493dnl !! shall then be commented out. 494ACX_WHICH_GETHOSTBYNAME_R() 495 496AC_CHECK_FUNCS(getopt_long setsid syslog) 497AC_CHECK_FUNCS(getuid setuid getgid setgid getpwnam chroot) 498AC_CHECK_FUNCS(socket bind select read send sendto fcntl) 499AC_CHECK_FUNCS(getifaddrs) 500AC_CHECK_FUNCS(strcmp strcasecmp) 501AC_CHECK_FUNCS(strncpy strchr strstr sprintf vfprintf vsnprintf) 502AC_CHECK_FUNCS(listen accept) 503AC_CHECK_FUNCS(fgets sscanf) 504AC_CHECK_FUNCS(hstrerror,,AC_CHECK_LIB(resolv,hstrerror,[ 505 AC_DEFINE_UNQUOTED(HAVE_HSTRERROR) 506 LIBS="$LIBS -lresolv"])) 507AC_CHECK_FUNCS(inet_pton inet_ntop inet_aton inet_ntoa) 508AC_CHECK_FUNCS(pthread_setschedparam sched_get_priority_min) 509AC_CHECK_FUNCS(sched_get_priority_max) 510AC_CHECK_FUNCS(lt_dlopen lt_dlsym lt_dlclose) 511 512 513dnl 514dnl sysconfdir 515dnl 516SIPROXDCONFPATH="" 517tmpset="$sysconfdir" 518while test "x$tmpset" != "x$SIPROXDCONFPATH"; do 519 SIPROXDCONFPATH="$tmpset" 520 eval tmpset="$tmpset" 521done 522AC_DEFINE_UNQUOTED(SIPROXDCONFPATH,"$SIPROXDCONFPATH", 523 [will search for config file here]) 524 525 526dnl 527dnl Finish... 528dnl 529LIBS="$LIBS $FWLIBS" 530 531AC_SUBST(CPPFLAGS) 532AC_SUBST(LDFLAGS) 533AC_SUBST(LIBS) 534 535 536dnl 537dnl Generate output files 538dnl 539AC_OUTPUT( \ 540siproxd.spec \ 541Makefile \ 542src/Makefile \ 543doc/Makefile \ 544scripts/Makefile \ 545contrib/Makefile \ 546) 547