1# Process this file with autoconf to produce a configure script.
2AC_INIT
3AC_CANONICAL_HOST
4
5AC_CONFIG_SRCDIR([bandwidthd.c])
6AC_CONFIG_HEADER([config.h])
7
8MAJOR_VERSION=2
9MINOR_VERSION=0
10RELEASE_VERSION=0
11EXTRA_VERSION=""
12VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
13
14# Checks for programs.
15AC_PROG_YACC
16AC_PROG_CC
17AC_PROG_INSTALL
18AC_PROG_LEX
19
20
21# May be required for libgd on bsd
22AC_PATH_X
23if test -n "$x_libraries" && test "x$x_libraries" != xNONE ; then
24	LDFLAGS="$LDFLAGS -L$x_libraries"
25fi
26
27# May be equired for BSD
28LDFLAGS="$LDFLAGS -L/usr/local/lib"
29
30CPPFLAGS="$CPPFLAGS -I/usr/local/include"
31
32#Check for Darwin sw directory
33AC_CHECK_FILE(/sw/lib, LDFLAGS="$LDFLAGS -L/sw/lib")
34AC_CHECK_FILE(/sw/include, CPPFLAGS="$CPPFLAGS -I/sw/include")
35
36#Check for NetBSD usr/pkg directory
37AC_CHECK_FILE(/usr/pkg/lib, LDFLAGS="$LDFLAGS -L/usr/pkg/lib")
38AC_CHECK_FILE(/usr/pkg/include, CPPFLAGS="$CPPFLAGS -I/usr/pkg/include")
39
40# Required for solaris
41AC_CHECK_LIB(socket, connect)
42AC_CHECK_LIB(nsl, gethostbyname)
43AC_CHECK_LIB(resolv, inet_aton)
44
45# Required for openbsd png library
46AC_CHECK_LIB(m, pow)
47
48# Required for gd under netbsd
49AC_CHECK_LIB(iconv, libiconv_open)
50
51# Required Libraries
52AC_CHECK_LIB(png, png_read_info, ,[AC_MSG_ERROR([Bandwidthd requires but cannot libpng])])
53AC_CHECK_LIB(gd, gdImageCreate, ,[AC_MSG_ERROR([Bandwidthd requires but cannot find libgd])])
54AC_CHECK_LIB(pcap, pcap_open_live, ,
55	[AC_CHECK_LIB(wpcap, pcap_open_live, ,[AC_MSG_ERROR([Bandwidthd requires but cannot find libpcap])])])
56
57# Optional Library
58AC_CHECK_FILE(/usr/local/pgsql/lib, LDFLAGS="$LDFLAGS -L/usr/local/pgsql/lib")
59AC_CHECK_FILE(/usr/local/pgsql/include, CPPFLAGS="$CPPFLAGS -I/usr/local/pgsql/include")
60AC_CHECK_LIB(pq, PQconnectdb,
61	[AC_CHECK_LIB(pq,PQexecParams, ,AC_MSG_WARN([libpq exists but is too old... bandwidthd requires support for PQexecParams]))])
62
63# Checks for header files.
64AC_HEADER_DIRENT
65
66AC_CHECK_HEADERS([gd.h],,
67	[AC_CHECK_HEADERS([gd/gd.h],,
68		AC_MSG_ERROR([Bandwidthd cannot find gd.h]))])
69
70AC_CHECK_HEADERS(gdfonts.h,,
71	[AC_CHECK_HEADERS(gd/gdfonts.h,,
72		AC_MSG_ERROR([Bandwidthd cannot find gdfonts.h]))])
73
74AC_CHECK_HEADERS([pcap.h],,
75	[AC_MSG_ERROR([Bandwidthd cannot find pcap.h])])
76
77AC_CHECK_HEADERS([arpa/inet.h errno.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/socket.h sys/time.h sys/wait.h syslog.h unistd.h],,
78	[AC_MSG_ERROR([Bandwidthd cannot find some header files])])
79
80
81#Headers missing on cygwin
82AC_CHECK_HEADERS([arpa/nameser.h])
83AC_CHECK_HEADERS([resolv.h],,,
84	[#include <netinet/in.h>
85	#include <arpa/nameser.h>])
86
87
88# Checks for typedefs, structures, and compiler characteristics.
89AC_C_CONST
90AC_C_INLINE
91AC_TYPE_PID_T
92AC_TYPE_SIZE_T
93AC_STRUCT_TM
94
95TCPHDR_SPORT="undefined"
96AC_CHECK_MEMBER(struct tcphdr.source,TCPHDR_SPORT="source",,[#include "bandwidthd.h"])
97AC_CHECK_MEMBER(struct tcphdr.th_sport,TCPHDR_SPORT="th_sport",,[#include "bandwidthd.h"])
98if test "$TCPHDR_SPORT" = "undefined" ; then
99	AC_MSG_ERROR([Could not determine souce port field name for tcphdr structure])
100fi
101AC_DEFINE_UNQUOTED(TCPHDR_SPORT,$TCPHDR_SPORT,[source port field name in tcphdr])
102
103TCPHDR_DPORT="undefined"
104AC_CHECK_MEMBER(struct tcphdr.dest,TCPHDR_DPORT="dest",,[#include "bandwidthd.h"])
105AC_CHECK_MEMBER(struct tcphdr.th_dport,TCPHDR_DPORT="th_dport",,[#include "bandwidthd.h"])
106if test "$TCPHDR_DPORT" = "undefined" ; then
107	AC_MSG_ERROR([Could not determine dest port field name for tcphdr structure])
108fi
109AC_DEFINE_UNQUOTED(TCPHDR_DPORT,$TCPHDR_DPORT,[dest port field name in tcphdr])
110
111
112# Checks for library functions.
113AC_FUNC_MALLOC
114AC_HEADER_STDC
115AC_FUNC_MKTIME
116AC_TYPE_SIGNAL
117AC_FUNC_STAT
118AC_CHECK_FUNCS([alarm gethostbyaddr inet_ntoa memset strdup strftime pcap_findalldevs])
119
120AC_OUTPUT(Makefile)
121