1dnl
2dnl  $Id: configure.in,v 1.13 2008/10/14 13:10:11 psavola Exp $
3dnl
4dnl   Authors:
5dnl    Lars Fenneberg		<lf@elemental.net>	 
6dnl
7dnl   This software is Copyright 1996-2000 by the above mentioned author(s), 
8dnl   All Rights Reserved.
9dnl
10dnl   The license which is distributed with this software in the file COPYRIGHT
11dnl   applies to this software. If your distribution is missing this file, you
12dnl   may request it from <pekkas@netcore.fi>.
13dnl
14dnl
15
16AC_REVISION ($Id: configure.in,v 1.13 2008/10/14 13:10:11 psavola Exp $)
17AC_INIT(radvd.c)
18
19AC_CANONICAL_SYSTEM
20VERSION=`cat ${srcdir}/VERSION | grep -v '^#' | tr -d '\012'`
21AM_INIT_AUTOMAKE(radvd,$VERSION,true)
22
23echo $ac_n "building for architecture""... $ac_c" 1>&6
24case "$target" in
25	*linux*)
26		AC_MSG_RESULT(linux)
27		AC_DEFINE([_GNU_SOURCE], [], [whether compiling on Linux, glibc>=2.8 doesn't expose in6_pktinfo otherwise..])
28                arch=linux
29        ;;
30        *bsd*)
31		AC_MSG_RESULT(bsd44)
32                arch=bsd44
33        ;;
34        *)      
35		AC_MSG_RESULT(unknown)
36		AC_MSG_ERROR(
37[currently only Linux and BSD 4.4 with NRL's IPv6 code are
38supported. If you have such a system and it is not guessed correctly 
39you must specifiy it with --target on the configure command line])
40        ;;
41esac
42
43dnl Determine CC and preset CFLAGS
44AC_PROG_CC
45
46dnl Needed for normal compile
47AC_PROG_INSTALL
48AC_PATH_PROG(RM, rm, NOTFOUND)
49if test "x$RM" = xNOTFOUND; then
50	AC_MSG_ERROR(can't find rm in your path - check PATH)
51fi
52AC_PATH_PROG(SED, sed, NOTFOUND)
53if test "x$SED" = xNOTFOUND; then
54	AC_MSG_ERROR(can't find sed in your path - check PATH)
55fi
56dnl Not needed
57AC_PATH_PROG(LN, ln)
58AC_PROG_YACC
59AM_PROG_LEX
60AC_PATH_PROG(TAR, tar)
61AC_PATH_PROG(GZIP, gzip)
62
63dnl Check where to put the logfile
64AC_MSG_CHECKING(where to put logfile)
65AC_ARG_WITH(logfile,
66[  --with-logfile          Path to the radvd logfile [/var/log/radvd.log]],
67	PATH_RADVD_LOG=$withval,
68	PATH_RADVD_LOG=/var/log/radvd.log)
69AC_MSG_RESULT($PATH_RADVD_LOG)
70
71dnl Check where to put the pidfile
72AC_MSG_CHECKING(where to put pidfile)
73AC_ARG_WITH(pidfile,
74[  --with-pidfile          Path to the radvd pidfile [/var/run/radvd.pid]],
75	PATH_RADVD_PID=$withval,
76	PATH_RADVD_PID=/var/run/radvd.pid)
77AC_MSG_RESULT($PATH_RADVD_PID)
78
79dnl Check where to put the configfile
80AC_MSG_CHECKING(where to find configfile)
81AC_ARG_WITH(configfile,
82[  --with-configfile       Path to the radvd config file [SYSCONF/radvd.conf]],
83	PATH_RADVD_CONF=$withval,
84	PATH_RADVD_CONF=${sysconfdir}/radvd.conf)
85AC_MSG_RESULT($PATH_RADVD_CONF)
86
87dnl Checking which syslog facility to use
88AC_MSG_CHECKING(which syslog facility to use)
89AC_ARG_WITH(facility,
90[  --with-facility         Syslog facility to use when using syslog logging],
91	LOG_FACILITY=$withval,
92	LOG_FACILITY=LOG_DAEMON)
93AC_MSG_RESULT($LOG_FACILITY)
94
95dnl Checks for libraries.
96
97AC_CHECK_LIB(c, inet_ntop,,
98 AC_CHECK_LIB(inet6, inet_ntop,
99  LIBS="$LIBS -linet6"
100  ,
101    AC_MSG_ERROR(can't continue without libinet6.a library - check your LDFLAGS)
102 )
103)
104# prevent caching
105unset ac_cv_lib_inet6_inet_ntop
106
107dnl Checks for header files.
108AC_HEADER_STDC
109AC_CHECK_HEADERS(sys/time.h)
110AC_HEADER_TIME
111
112AC_CHECK_HEADER(netinet/ip6.h, hdrfound=yes, hdrfound=no)
113if test "$hdrfound" = no
114then
115 # deprecated
116 AC_CHECK_HEADER(netinet/ipv6.h, hdrfound=yes)
117fi
118if test "$hdrfound" = no
119then
120   AC_MSG_RESULT(no)
121fi
122unset hdrfound
123
124AC_CHECK_HEADERS(ifaddrs.h sys/sockio.h getopt.h inttypes.h)
125AC_CHECK_HEADERS(net/if_dl.h net/if_types.h net/if_arp.h)
126AC_CHECK_HEADERS(sys/param.h)
127AC_CHECK_HEADERS(machine/param.h)
128AC_CHECK_HEADERS(machine/limits.h)
129
130dnl Checks for typedefs, structures, and compiler characteristics.
131AC_C_CONST
132
133AC_MSG_CHECKING(whether struct sockaddr_in6 has sin6_scope_id)
134AC_TRY_COMPILE([#include <sys/types.h>
135#include <netinet/in.h>], [static struct sockaddr_in6 ac_sin6; int ac_size = 
136sizeof (ac_sin6.sin6_scope_id);], [AC_MSG_RESULT(yes); AC_DEFINE([HAVE_SIN6_SCOPE_ID],
1371, [whether struct sockaddr_in6 has sin6_scope_id])],
138AC_MSG_RESULT(no))
139
140AC_MSG_CHECKING(whether struct in6_addr has u6_addrXX and defines s6_addrXX)
141AC_TRY_COMPILE([#include <netinet/in.h>], [static struct in6_addr in6_u; 
142int u =  in6_u.s6_addr16;], [AC_MSG_RESULT(yes); AC_DEFINE([HAVE_IN6_ADDR_S6_ADDR],
1431, [whether struct in6_addr has u6_addrXX and defines s6_addrXX])],
144AC_MSG_RESULT(no))
145
146dnl Checks for library functions.
147AC_CHECK_FUNCS(getopt_long)
148
149AC_LINK_FILES(device-${arch}.c, device.c)
150AC_LINK_FILES(privsep-${arch}.c, privsep.c)
151
152AC_SUBST(VERSION)
153AC_SUBST(PATH_RADVD_CONF)
154AC_SUBST(PATH_RADVD_PID)
155AC_SUBST(PATH_RADVD_LOG)
156AC_SUBST(LOG_FACILITY)
157
158AM_CONFIG_HEADER(config.h)
159AC_OUTPUT(Makefile)
160