1# $Id: configure.ac,v 1.4.2.11 2007/02/01 09:19:39 fedemp Exp $
2#
3# Process this file with autoconf to produce a configure script.
4AC_INIT([thrulay], [0.9rc1], [thrulay-users@internet2.edu])
5PACKAGE=thrulay
6VERSION="0.9"
7# For libtool
8LT_VERSION="0:0:0"
9# AC_PREREQ([2.59])
10AC_CONFIG_HEADER([config.h])
11AM_INIT_AUTOMAKE([$PACKAGE], [$VERSION])
12
13# Configure options.
14# Multicast support.
15AC_MSG_CHECKING([for multicast])
16AC_ARG_ENABLE([multicast],
17	      AC_HELP_STRING([--disable-multicast],
18			     [disable multicast (enabled by default)]))
19if test -z "$enable_multicast"; then
20   enable_multicast=yes
21fi
22if test "$enable_multicast" = "yes"; then
23   AC_DEFINE([ENABLE_THRULAY_MULTICAST], [1], [multicast support])
24fi
25
26# Checks for programs.
27AC_PROG_CC
28AC_PROG_MAKE_SET
29AM_PROG_LIBTOOL
30
31# Flags for restrictive warnings:
32if test $GCC = yes ; then
33   C_STD_FLAGS="-std=gnu99"
34   WARNING_FLAGS="-Wno-long-long -Wall -pedantic -W -Wpointer-arith \
35				 -Wnested-externs"
36else
37   C_STD_FLAGS=""
38   WARNING_FLAGS=""
39fi
40AC_SUBST([C_STD_FLAGS])
41AC_SUBST([WARNING_FLAGS])
42
43# Checks for host-system types
44AC_CANONICAL_HOST
45case $host in
46  *darwin*)
47    AC_DEFINE([__DARWIN__], [1], [Darwin])
48    AC_DEFINE([_BSD_SOCKLEN_T_], [], [Need this under Darwin so that \
49    	socklen_t will be defined in <sys/socket.h>])
50    ;;
51  *freebsd*)
52    AC_DEFINE([__FREEBSD__], [1], [FreeBSD])
53    ;;
54  *linux*)
55    AC_DEFINE([__LINUX__], [1], [Linux])
56    ;;
57  *solaris*)
58    AC_DEFINE([__SOLARIS__], [1], [Solaris])
59    ;;
60esac
61
62# Checks for libraries.
63AC_CHECK_LIB([m], [log])
64AC_CHECK_LIB([socket], [socket])
65AC_CHECK_LIB([nsl], [socket])
66AC_CHECK_LIB([resolv], [herror])
67AC_CHECK_LIB([rt], [nanosleep])
68AC_CHECK_LIB([fasttime], [fasttime_init_context])
69AC_CHECK_LIB([tsci2], [tsci2_init])
70
71# Checks for header files.
72AC_HEADER_STDC
73AC_CHECK_HEADERS([netdb.h syslog.h sys/resource.h sys/select.h sys/socket.h sys/wait.h])
74AC_CHECK_HEADERS([float.h stdint.h])
75AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
76AC_CHECK_HEADERS([fasttime.h tsci2.h])
77
78# Check if MinGW32 specific libs are required.
79AC_SEARCH_LIBS([gethostbyname], [nsl socket], [], [
80my_old_LIBS=$LIBS
81LIBS="-lws2_32 $LIBS"
82ws2_result=yes
83AC_MSG_CHECKING([for gethostbyname in ws2_32])
84AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]],
85				[[gethostbyname("");]])],
86		[], [LIBS=$my_old_LIBS ws2_result=no])
87AC_MSG_RESULT([$ws2_result])
88])
89
90# Checks for functions
91AC_MSG_CHECKING([for getaddrinfo])
92AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <ws2tcpip.h>]],
93				   [[getaddrinfo(NULL,NULL,NULL,NULL);]])],
94		  [AC_DEFINE([HAVE_W32_GETADDRINFO], [1],
95			     [getaddrinfo function])
96		   AC_MSG_RESULT([yes])],
97		  [AC_MSG_RESULT([no])])
98
99AC_CHECK_FUNCS([initstate getrusage])
100
101# Checks for typedefs, structures, and compiler characteristics.
102
103# Check for multicast structs
104AC_MSG_CHECKING([for struct ip_mreqn])
105AC_TRY_COMPILE([#ifndef WIN32
106		#include <netinet/in.h>
107		#else
108		#include <ws2tcpip.h>
109		#endif],
110	       [struct ip_mreqn mreq;
111	        mreq.imr_address.s_addr = 0;],
112	       [AC_MSG_RESULT([yes])
113	        AC_DEFINE([HAVE_STRUCT_IP_MREQN], [1], [Struct ip_mreqn])],
114	       [AC_MSG_RESULT([no])])
115AC_MSG_CHECKING([for struct ip_mreq])
116AC_TRY_COMPILE([#ifndef WIN32
117		#include <netinet/in.h
118		#else
119		#include <ws2tcpip.h>
120		#endif],
121	       [struct ip_mreq mreq;
122	        mreq.imr_interface.s_addr = 0;],
123	       [AC_MSG_RESULT([yes])
124	        AC_DEFINE([HAVE_STRUCT_IP_MREQ], [1], [Struct ip_mreq])],
125	       [AC_MSG_RESULT(no)])
126
127case $host in
128  *solaris*)
129    AC_MSG_NOTICE([Solaris system detected, disabling stripping of binaries])
130    STRIP=
131    ;;
132esac
133
134AC_SUBST([LT_VERSION])
135AC_OUTPUT([Makefile doc/Makefile src/Makefile thrulay.spec])
136