-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconfigure.in
228 lines (178 loc) · 7.28 KB
/
configure.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# Process this file with autoconf to produce a configure script.
AC_INIT
AC_CANONICAL_HOST
AC_CONFIG_SRCDIR([bandwidthd.c])
AC_CONFIG_HEADER([config.h])
MAJOR_VERSION=2
MINOR_VERSION=0
RELEASE_VERSION=2
EXTRA_VERSION=".IPv6"
VERSION="$MAJOR_VERSION.$MINOR_VERSION.$RELEASE_VERSION$EXTRA_VERSION"
# Checks for programs.
AC_PROG_YACC
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LEX
use_pgsql=no
AC_PATH_PROG(PG_CONFIG, pg_config)
if test x$enable_pgsql = xyes ; then
if test "x$PG_CONFIG" = "x" ; then
echo "*** Couldn't find pg_config. Disabling PostgreSQL support."
else
LDFLAGS="$LDFLAGS -L`$PG_CONFIG --libdir` -lpq"
pgsql_cflags=`$PG_CONFIG --includedir`
if test "x$pgsql_cflags" != "x/usr/include" ; then
CPPFLAGS="$CPPFLAGS -I$pgsql_cflags"
fi
use_pgsql=yes
AC_DEFINE(HAVE_LIBPQ, 1, "Enable PostgreSQL compiletime option")
fi
fi
# May be required for libgd on bsd
AC_PATH_X
if test -n "$x_libraries" && test "x$x_libraries" != xNONE ; then
LDFLAGS="$LDFLAGS -L$x_libraries"
fi
# May be equired for BSD
LDFLAGS="$LDFLAGS -L/usr/local/lib"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
#Check for Darwin sw directory
AC_CHECK_FILE(/sw/lib, LDFLAGS="$LDFLAGS -L/sw/lib")
AC_CHECK_FILE(/sw/include, CPPFLAGS="$CPPFLAGS -I/sw/include")
#Check for NetBSD usr/pkg directory
AC_CHECK_FILE(/usr/pkg/lib, LDFLAGS="$LDFLAGS -L/usr/pkg/lib")
AC_CHECK_FILE(/usr/pkg/include, CPPFLAGS="$CPPFLAGS -I/usr/pkg/include")
# Required for solaris
AC_CHECK_LIB(socket, connect)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(resolv, inet_aton)
# Required for openbsd png library
AC_CHECK_LIB(m, pow)
# Required for gd under netbsd
AC_CHECK_LIB(iconv, libiconv_open)
# Required Libraries
AC_CHECK_LIB(png, png_read_info, ,[AC_MSG_ERROR([Bandwidthd requires but cannot libpng])])
AC_CHECK_LIB(gd, gdImageCreate, ,[AC_MSG_ERROR([Bandwidthd requires but cannot find libgd])])
AC_CHECK_LIB(pcap, pcap_open_live, ,
[AC_CHECK_LIB(wpcap, pcap_open_live, ,[AC_MSG_ERROR([Bandwidthd requires but cannot find libpcap])])])
# Optional Library
AC_CHECK_FILE(/usr/local/pgsql/lib, LDFLAGS="$LDFLAGS -L/usr/local/pgsql/lib")
AC_CHECK_FILE(/usr/local/pgsql/include, CPPFLAGS="$CPPFLAGS -I/usr/local/pgsql/include")
AC_CHECK_LIB(pq, PQconnectdb,
[AC_CHECK_LIB(pq,PQexecParams, ,AC_MSG_WARN([libpq exists but is too old... bandwidthd requires support for PQexecParams]))])
AC_CHECK_LIB(sqlite3, sqlite3_open, ,AC_MSG_WARN([sqlite3 is recommended for storage of data but cannot be found]))
# Checks for header files.
AC_HEADER_DIRENT
AC_CHECK_HEADERS([gd.h],,
[AC_CHECK_HEADERS([gd/gd.h],,
AC_MSG_ERROR([Bandwidthd cannot find gd.h]))])
AC_CHECK_HEADERS(gdfonts.h,,
[AC_CHECK_HEADERS(gd/gdfonts.h,,
AC_MSG_ERROR([Bandwidthd cannot find gdfonts.h]))])
AC_CHECK_HEADERS([pcap.h],,
[AC_MSG_ERROR([Bandwidthd cannot find pcap.h])])
AC_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],,
[AC_MSG_ERROR([Bandwidthd cannot find some header files])])
#Headers missing on cygwin
AC_CHECK_HEADERS([arpa/nameser.h])
AC_CHECK_HEADERS([resolv.h],,,
[#include <netinet/in.h>
#include <arpa/nameser.h>])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_TM
TCPHDR_SPORT="undefined"
AC_CHECK_MEMBER(struct tcphdr.source,TCPHDR_SPORT="source",,[#include "bandwidthd.h"])
AC_CHECK_MEMBER(struct tcphdr.th_sport,TCPHDR_SPORT="th_sport",,[#include "bandwidthd.h"])
if test "$TCPHDR_SPORT" = "undefined" ; then
AC_MSG_ERROR([Could not determine souce port field name for tcphdr structure])
fi
AC_DEFINE_UNQUOTED(TCPHDR_SPORT,$TCPHDR_SPORT,[source port field name in tcphdr])
TCPHDR_DPORT="undefined"
AC_CHECK_MEMBER(struct tcphdr.dest,TCPHDR_DPORT="dest",,[#include "bandwidthd.h"])
AC_CHECK_MEMBER(struct tcphdr.th_dport,TCPHDR_DPORT="th_dport",,[#include "bandwidthd.h"])
if test "$TCPHDR_DPORT" = "undefined" ; then
AC_MSG_ERROR([Could not determine dest port field name for tcphdr structure])
fi
AC_DEFINE_UNQUOTED(TCPHDR_DPORT,$TCPHDR_DPORT,[dest port field name in tcphdr])
# Checks for library functions.
AC_FUNC_MALLOC
AC_HEADER_STDC
AC_FUNC_MKTIME
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_CHECK_FUNCS([alarm gethostbyaddr inet_ntoa memset strdup strftime pcap_findalldevs])
# Set directory names
AC_ARG_WITH([htdocs-dir], AC_HELP_STRING([--with-htdocs-dir=DIR], [Sets default htdocs directory. Default is LOCALSTATEDIR/bandwidthd/htdocs]),
htdocs_dir=${with_htdocs_dir},
htdocs_dir="${localstatedir}/bandwidthd/htdocs")
AC_ARG_WITH([log-dir], AC_HELP_STRING([--with-log-dir=DIR], [Sets default cdf log directory. Default is LOCALSTATEDIR/bandwidthd]),
log_dir=${with_log_dir},
log_dir="${localstatedir}/bandwidthd")
AC_ARG_WITH([extension-dir], AC_HELP_STRING([--with-extension-dir=DIR], [Sets default extension directory. Default is LOCALSTATEDIR/bandwidthd/extensions]),
extension_dir=${with_extension_dir},
extension_dir="${localstatedir}/bandwidthd/extensions")
config_file="${sysconfdir}/bandwidthd.conf"
AC_DEFINE_DIR(CONFIG_FILE, config_file, [Name of bandwidthd.conf])
AC_DEFINE_DIR(LOG_DIR, log_dir, [Name of log directory])
AC_DEFINE_DIR(HTDOCS_DIR, htdocs_dir, [Name of htdocs directory])
AC_DEFINE_DIR(EXTENSION_DIR, extension_dir, [Name of the extensions directory])
AC_ARG_ENABLE([pgsql], AC_HELP_STRING([--enable-pgsql],
[Enable PostgreSQL support. Default is yes, if available.]),
enable_pgsql="$enableval", enable_pgsql=yes)
AC_ARG_ENABLE([python], AC_HELP_STRING([--enable-python],
[Enable Python support. Default is yes, if available.]),
enable_python="$enableval", enable_python=yes)
HAVEPYTHON=0
if test $enable_python != "no" ; then
if test -n HAVEPYTHON && test `which python2.7-config` != "" ; then
PYTHON=`which python2.7`
LDFLAGS="$LDFLAGS `python2.7-config --libs`"
CPPFLAGS="$CPPFLAGS `python2.7-config --includes`"
PYTHON_VERSION="2.7"
HAVEPYTHON=1
echo "checking for python2.7... yes"
else
echo "checking for python2.7... no"
if test -n HAVEPYTHON && test `which python2.6-config` != "" ; then
PYTHON=`which python2.6`
LDFLAGS="$LDFLAGS `python2.6-config --libs`"
CPPFLAGS="$CPPFLAGS `python2.6-config --includes`"
PYTHON_VERSION="2.6"
HAVEPYTHON=1
echo echo "checking for python2.6... yes"
else
echo "checking for python2.6... no"
if test -n HAVEPYTHON && test `which python2.5-config` != "" ; then
PYTHON=`which python2.5`
LDFLAGS="$LDFLAGS `python5-config --libs`"
CPPFLAGS="$CPPFLAGS `python5-config --includes`"
PYTHON_VERSION="2.5"
HAVEPYTHON=1
echo echo "checking for python2.5... yes"
else
echo "checking for python2.5... no"
if test -n HAVEPYTHON && test `which python-config` != "" ; then
PYTHON=`which python`
LDFLAGS="$LDFLAGS `python-config --libs`"
CPPFLAGS="$CPPFLAGS `python-config --includes`"
PYTHON_VERSION=`$PYTHON -c "import sys; \
print sys.version[[:3]]"`
HAVEPYTHON=1
echo "checking for python... $PYTHON_VERSION"
AC_MSG_WARN([Python version not supported, but using anyway])
else
echo "checking for python... no"
fi
fi
fi
fi
fi
if test "$HAVEPYTHON" = "1" ; then
AC_DEFINE_UNQUOTED(HAVE_PYTHON, 1, "Enable Python compiletime option")
AC_DEFINE_UNQUOTED(PYTHON_VERSION, $PYTHON_VERSION, "Set version of python")
fi
AC_OUTPUT(Makefile)