-
Notifications
You must be signed in to change notification settings - Fork 28
/
configure.ac
337 lines (285 loc) · 9.34 KB
/
configure.ac
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
AC_CONFIG_MACRO_DIR([m4])
dnl Blah blah standard autoconf
AC_INIT(Makefile.in)
dnl Host type
AC_CANONICAL_HOST
dnl Check for standard tools
AC_PROG_CC
AC_PROG_LIBTOOL
# Liberated from ethereal's configure.in
#
# Add any platform-specific compiler flags needed.
#
AC_MSG_CHECKING(for platform-specific compiler flags)
if test "x$GCC" = x
then
#
# Not GCC - assume it's the vendor's compiler.
#
case "$host_os" in
hpux*)
#
# HP's ANSI C compiler; flags suggested by Jost Martin.
# "-Ae" for ANSI C plus extensions such as "long long".
# "+O2", for optimization. XXX - works with "-g"?
#
CFLAGS="-Ae +O2 $CFLAGS"
AC_MSG_RESULT(HP ANSI C compiler - added -Ae +O2)
;;
darwin*)
#
# It may be called "cc", but it's really a GCC derivative
# with a problematic special precompiler and precompiled
# headers; turn off the special precompiler, as some
# apparently-legal code won't compile with its precompiled
# headers.
#
CFLAGS="-no-cpp-precomp $CFLAGS"
AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
darwin="yes"
;;
linux*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_LINUX, 1, Compiling for Linux OS)
linux="yes"
;;
freebsd*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_FREEBSD, 1, Compiling for FreeBSD)
;;
openbsd*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_OPENBSD, 1, Compiling for OpenBSD)
;;
cygwin*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_CYGWIN, 1, Compiling for Cygwin)
cygwin="yes"
;;
*)
AC_MSG_RESULT(none needed)
;;
esac
else
case "$host_os" in
solaris*)
# the X11 headers don't automatically include prototype info
# and a lot don't include the return type
CFLAGS="$CFLAGS -Wno-return-type -DFUNCPROTO=15"
AC_MSG_RESULT(GCC on Solaris - added -Wno-return-type -DFUNCPROTO=15)
;;
darwin*)
#
# See comments above about Apple's lovely C compiler.
#
CFLAGS="-no-cpp-precomp $CFLAGS"
AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
darwin="yes"
;;
linux*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_LINUX, 1, Compiling for Linux OS)
linux="yes"
;;
freebsd*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_FREEBSD, 1, Compiling for FreeBSD)
;;
openbsd*)
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_OPENBSD, 1, Compiling for OpenBSD)
;;
cygwin*)
# Adding -mno-cygwin uses the MingW linking process, precluding the use
# of cygwin.dll; linking to cygwin.dll forces GPL
CFLAGS="-mno-cygwin $CFLAGS"
AC_MSG_RESULT(none needed)
AC_DEFINE(SYS_CYGWIN, 1, Compiling for Cygwin)
cygwin="yes"
;;
*)
AC_MSG_RESULT(none needed)
;;
esac
fi
dnl Check for endian
AC_C_BIGENDIAN
dnl Check for headers and such
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(fcntl.h sys/ioctl.h sys/time.h unistd.h net/if_arp.h sys/socket.h)
dnl Look for linux kernel wireless headers
if test "$linux" = "yes"; then
AC_MSG_CHECKING(that linux/wireless.h is what we expect)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <sys/types.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/resource.h>
#include <asm/types.h>
#include <linux/if.h>
#include <linux/wireless.h>
]], [[
struct iwreq wrq;
wrq.u.essid.flags = 0;
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_LINUX_WIRELESS, 1, Linux wireless extentions present)
],[
AC_MSG_RESULT(no)
AC_MSG_ERROR(*** Missing working Linux wireless kernel extensions ***)
])
fi # linux
dnl Look for libpcap
if test "$cygwin" != "yes"; then
AC_CHECK_LIB([pcap], [pcap_open_live],
AC_DEFINE(HAVE_LIBPCAP, 1, libpcap packet capture lib),
AC_MSG_ERROR(*** Missing working libpcap library ***))
AC_CHECK_HEADER([pcap.h],
AC_DEFINE(HAVE_PCAP_H, 1, pcap.h present),
AC_MSG_ERROR(*** Missing pcap.h is libpcap-dev installed ***))
LIBS="$LIBS -lpcap"
fi
dnl Look for airpcap under cygwin
if test "$cygwin" = "yes"; then
AC_ARG_ENABLE(airpcap, [ --disable-airpcap disable checking for CACE airpcap],,wantairpcap=yes)
if test "$wantairpcap" = "yes"; then
airpcap_devpack="none"
AC_ARG_WITH(airpcap-devpack,
[ --with-airpcap[=DIR] Location of the CACE AirPcap device pack NOTE cygwin appears to have link errors if the path is not within the current directory],
[ airpcap_devpack="$withval" ])
if test "$airpcap_devpack" = "none"; then
AC_MSG_ERROR(No airpcap path provided use --with-airpcap-devpack)
fi # devpack none
dnl set the lib flags to refer to the devpack files
LDFLAGS="$LDFLAGS -L$airpcap_devpack/WinPcap_Devpack/Lib -L$airpcap_devpack/Airpcap_Devpack/Lib"
dnl set the CPP flags to refer to the devpack files
CPPFLAGS="$CPPFLAGS -I$airpcap_devpack/WinPcap_Devpack/Include -I$airpcap_devpack/Airpcap_Devpack/include"
AC_CHECK_LIB([wpcap], [pcap_open_live],
AC_DEFINE(HAVE_LIBWPCAP, 1, libwpcap library),
AC_MSG_ERROR(Could not link libwpcap check airpcap-devpack path))
AC_CHECK_LIB([wpcap], [pcap_get_airpcap_handle],,
AC_MSG_ERROR(Could not use pcap_get_airpcap_handle are you using the CACE airpcap libwpcap))
#AC_CHECK_LIB([airpcap], [AirpcapSetLinkType],
# AC_DEFINE(HAVE_LIBAIRPCAP, 1, libairpcap library),
# AC_MSG_ERROR(Could not link libairpcap check airpcap-devpack path))
AC_CHECK_HEADER([pcap.h],
AC_DEFINE(HAVE_PCAP_H, 1, pcap.h present),
AC_MSG_ERROR(Could not find pcap.h check airpcap-devpack path))
AC_CHECK_HEADER([airpcap.h],
AC_DEFINE(HAVE_AIRPCAP_H, 1, airpcap.h preset),
AC_MSG_ERROR(Could not find airpcap.h check airpcap-devpack path))
LIBS="$LIBS -lwpcap -lairpcap"
fi # waitairpcap
fi # cygwin
if test "$linux" = "yes"; then
AC_CHECK_PROG(havepkgconfig, [pkg-config], yes, no)
if test "$havepkgconfig" = "no"; then
AC_MSG_WARN(Missing pkg-config will lead to multiple other checks failing)
fi
NLLIBS=""
NLCFLAGS=""
nlname=""
havenetlink=yes
netlink_force=no
AC_ARG_WITH(netlink-tiny,
[ --with-netlink-tiny Force libnl-tiny ],
[
netlink_force="tiny"
])
if test "$havenetlink" = "yes"; then
PKG_CHECK_MODULES(libnl30, [libnl-3.0], libnl30=yes, libnl30=no)
PKG_CHECK_MODULES(libnlgenl30, [libnl-genl-3.0], libnlgenl30=yes, libnlgenl30=no)
PKG_CHECK_MODULES(libnl20, [libnl-2.0], libnl20=yes, libnl20=no)
PKG_CHECK_MODULES(libnl1, [libnl-1], libnl1=yes, libnl1=no)
picked_nl=no
if test $netlink_force = "tiny"; then
picked_nl="tiny"
AC_CHECK_HEADER([netlink/netlink.h],
AC_DEFINE(HAVE_LIBNLTINY_HEADERS, 1, [libnltiny headers present]),
AC_MSG_ERROR([libnl-tiny requested but could not find headers]))
AC_DEFINE(HAVE_LIBNL, 1, libnl netlink library)
AC_DEFINE(HAVE_LIBNLTINY, 1, libnl-2.0 netlink library)
nlname="libnl-tiny"
fi
if test $picked_nl = "no" -a "$libnl30" = "yes" -a "$libnlgenl30" = "yes"; then
if test $netlink_force = "no" -o $netlink_force = "3"; then
picked_nl=3
AC_DEFINE(HAVE_LIBNL, 1, libnl netlink library)
AC_DEFINE(HAVE_LIBNL30, 1, libnl-3.0 netlink library)
nlname="libnl-3.0 libnl-genl-3.0"
fi
fi
if test $picked_nl = "no" -a "$libnl20" = "yes"; then
if test $netlink_force = "no" -o $netlink_force = "2"; then
picked_nl=2
AC_DEFINE(HAVE_LIBNL, 1, libnl netlink library)
AC_DEFINE(HAVE_LIBNL20, 1, libnl-2.0 netlink library)
nlname="libnl-2.0"
fi
fi
if test $picked_nl = "no" -a "$libnl1" = "yes"; then
if test $netlink_force = "no" -o $netlink_force = "1"; then
picked_nl=1
AC_DEFINE(HAVE_LIBNL, 1, libnl netlink library)
AC_DEFINE(HAVE_LIBNL10, 1, libnl netlink library)
nlname="libnl-1"
fi
fi
if test $picked_nl = "no"; then
havenetlink="no"
fi
if test "$nlname" != ""; then
if test "$picked_nl" == "tiny"; then
NLLIBS="-lnl-tiny"
else
NLLIBS=`pkg-config --libs $nlname`
NLCFLAGS=`pkg-config --cflags $nlname`
fi
fi
fi
if test "$havenetlink" = "yes"; then
OLIBS="$LIBS"
LIBS="$LIBS $NLLIBS"
OCPPFL="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $NLCFLAGS"
AC_MSG_CHECKING(For mac80211 support in netlink library)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
#include <asm/types.h>
#include <netlink/genl/genl.h>
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>
#include <netlink/msg.h>
#include <netlink/attr.h>
#include <linux/nl80211.h>
#include <linux/if_arp.h>
#include <linux/wireless.h>
]], [[
NL80211_IFTYPE_MONITOR;
NL80211_CMD_NEW_INTERFACE;
return 0;
]])],[havenetlink=yes],[havenetlink=no])
LIBS="$OLIBS"
CPPFLAGS="$OCPPFL"
else
AC_MSG_WARN(Missing libnl netlink library will not be able to control mac80211 vaps)
havenetlink=no
fi
if test "$havenetlink" = "yes"; then
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_LINUX_NETLINK, 1, Netlink works)
fi
AC_SUBST(NLLIBS)
AC_SUBST(NLCFLAGS)
fi
AC_CHECK_LIB([m], [pow],
AC_DEFINE(HAVE_LIBM, 1, Math lib) LIBS="$LIBS -lm",
AC_MSG_ERROR(*** Missing working libm math lib ***)
)
AC_CONFIG_HEADER(config.h)
CFLAGS=" -DHAVE_CONFIG_H $CFLAGS"
dnl Write it
AC_OUTPUT(Makefile)