-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.ac
333 lines (290 loc) · 9.98 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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#AC_PREREQ(2.61)
# define variables for version numbers
m4_define([_version_major], [3])
m4_define([_version_minor], [2])
m4_define([_version_bugfix], [2])
m4_define([_version_date], ["iThu 8 Apr 18:11:13 CEST 2021"])
m4_define([_version_flavor], ["Syzygy"])
m4_define([_libtstat_version], [1.0.0])
AC_INIT([tstat],
m4_esyscmd([echo _version_major._version_minor._version_bugfix | tr -d '\n']),
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([tstat/tstat.c])
#AC_CONFIG_SUBDIRS([DPMI_utils
# lib-demo
# src])
# define statement for version numbers
AC_DEFINE([VERSION_MAJOR], [_version_major], [Package major number])
AC_DEFINE([VERSION_MINOR], [_version_minor], [Package minor number])
AC_DEFINE([VERSION_BUGFIX], [_version_bugfix], [Package bugfix number])
AC_DEFINE([VERSION_DATE], [_version_date], [Package date])
AC_DEFINE([VERSION_FLAVOR], [_version_flavor], [Package flavor])
AC_CONFIG_HEADER([config.h])
# Check for build system
#AC_CANONICAL_SYSTEM
AC_CANONICAL_HOST
build_linux=no
build_mac=no
build_other=no
# Detect the target system
case "${host_os}" in
linux*)
build_linux=yes
;;
darwin*)
build_mac=yes
;;
*)
build_other=yes
;;
esac
AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"])
m4_pattern_allow([AC_LBL_C_INIT (V_CCOPT, V_INCLS)])
## Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
## See if "unsigned long long int" works
AC_CHECK_SIZEOF(unsigned long long int)
AC_CHECK_SIZEOF(unsigned long int)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned short)
## include additional checking if developing
m4_pattern_allow([AC_LBL_DEVEL(V_CCOPT)])
## check for needed network libraries
m4_pattern_allow([AC_LBL_LIBRARY_NET()])
## use fpurge if available, otherwise fflush
AC_CHECK_FUNCS(fpurge)
## use mkstemp if available, otherwise tempnam
AC_CHECK_FUNCS(mkstemp)
## check for the IPv6 routines inet_pton
AC_CHECK_FUNCS(inet_pton)
## Grab includes from ./cygwin-includes under Windows versions
PCAP_LDLINK="-lpcap"
case "$target" in
*cygwin*) V_INCLS="$V_INCLS -I./cygwin-includes";
V_DEFINES="$V_DEFINES -D__USE_BSD -D__FAVOR_BSD -D__USE_MISC -D__WIN32";
PCAP_LDLINK="-lwpcap"
esac
## Checks for libraries
AC_CHECK_LIB([m], [log],, AC_MSG_ERROR([missing 'm' library]))
#AC_CHECK_LIB([pthread], [pthread_cond_init],,AC_MSG_ERROR([missing 'pthread' library]))
## --enable-android option
ENABLE_ANDROID=no
AC_ARG_ENABLE(android,
AS_HELP_STRING([--enable-android], [ignore the pthread test for Android compilation]),
ENABLE_ANDROID=$enableval)
AM_CONDITIONAL([ANDROID], [test "x$ENABLE_ANDROID" = "xyes"])
if test ".${ENABLE_ANDROID}" = ".no"; then
AC_CHECK_LIB([pthread], [pthread_cond_init],,AC_MSG_ERROR([missing 'pthread' library]))
fi
##AM_COND_IF([ANDROID],,
## [AC_CHECK_LIB([pthread], [pthread_cond_init],,AC_MSG_ERROR([missing 'pthread' library]))])
## --enable-libtstat option
ENABLE_LIBTSTAT=no
AC_ARG_ENABLE(libtstat,
AS_HELP_STRING([--enable-libtstat], [generate a shared library from tstat code]),
ENABLE_LIBTSTAT=$enableval)
AM_CONDITIONAL([LIBTSTAT], [test "x$ENABLE_LIBTSTAT" = "xyes"])
## --enable-debug option
#ENABLE_DEBUG=yes
#AC_ARG_ENABLE(debug,
# AS_HELP_STRING([--enable-debug], [compile with debug support]),
# ENABLE_DEBUG=$enableval)
#if test "xENABLE_DEBUG" = "xyes"; then
# DEBUG_CFLAGS = -g -ggdb
#fi
#AM_CONDITIONAL([DEBUG], [test "x$ENABLE_DEBUG" = "xyes"])
## --enable-rrdthread option
ENABLE_RRDTHREAD=no
AC_ARG_ENABLE(rrdthread,
AS_HELP_STRING([--enable-rrdthread], [RRD I/O on a separate thread (requires Linux>=2.6.35)]),
ENABLE_RRDTHREAD=$enableval)
if test "x$ENABLE_RRDTHREAD" = "xyes"; then
V_DEFINES="$V_DEFINES -DRRD_THREADED"
fi
AM_CONDITIONAL([RRDTHREAD], [test "x$ENABLE_RRDTHREAD" = "xyes"])
dnl look for pcap library
dnl add ./configure option to specify libpcap path
# AC_ARG_WITH( pcap-root,
# [ --with-pcap-root=DIR LBNL pcap located in DIR],
# PCAP_INCLUDE="$withval" PCAP_LIB="$withval",
# PCAP_LIB= PCAP_INCLUDE=)
#AC_ARG_WITH( pcap-lib,
# [ --with-pcap-lib=DIR or libpcap located in DIR],
# PCAP_LIB="$withval")
#AC_ARG_WITH( pcap-include,
# [ --with-pcap-include=DIR or pcap.h located in DIR],
# PCAP_INCLUDE="$withval")
#
#if (test ".${PCAP_LIB}" != "." &&
# test ! -d ${PCAP_LIB}) ||
# (test ".${PCAP_INCLUDE}" != "." &&
# test ! -d ${PCAP_INCLUDE}); then
# echo
# echo "*******************************************************************"
# echo "*"
# echo "* ERROR: You specified or implied a non-existent directory for"
# echo "* libpcap:"
# echo "* --with-pcap-lib=${PCAP_LIB}"
# echo "* --with-pcap-include=${PCAP_INCLUDE}"
# echo "*"
# echo "*>>> Continuing without libpcap is impossible."
# echo "*"
# echo "*??? 1. Correct the --with-pcap-xxxxx option and rerun"
# echo "*??? ./configure"
# echo "*"
# echo "*******************************************************************"
# echo
# exit 1
#else
# if (test "${PCAP_INCLUDE}" != "");then
# V_PCAP_INCLUDE=-I[${PCAP_INCLUDE}];
# fi
# if (test "${PCAP_INCLUDE}" != "");then
# V_PCAP_LIBPATH=-L[${PCAP_LIB}];
# fi
#fi
###################################
## Libpcap
AC_CHECK_HEADERS([pcap.h])
## at least one of the two headers must be present
AC_CHECK_HEADERS([net/bpf.h])
AC_CHECK_HEADERS([pcap-bpf.h])
AC_CHECK_LIB([pcap], [pcap_open_live],,AC_MSG_ERROR([missing 'pcap' library]))
if test ".${ac_cv_header_pcap_h}" != ".yes" ||
(test ".${ac_cv_header_net_bpf_h}" != ".yes" &&
test ".${ac_cv_header_pcap_bpf_h}" != ".yes" )
then
echo
echo "*******************************************************************"
echo "*"
echo "* ERROR: pcap header, or library are missing."
echo "* At least one of bpf header must be found."
echo "* (yes == found, no == NOT found)"
echo "*"
echo "* pcap.h.......................${ac_cv_header_pcap_h}"
echo "* pcap-bpf.h...................${ac_cv_header_pcap_bpf_h}"
echo "* net/bpf.h....................${ac_cv_header_net_bpf_h}"
echo "* pcap_open_live() in -lpcap...${ac_cv_lib_pcap_pcap_open_live}"
echo "*"
echo "*>>> No way to proceed."
echo "*"
echo "*??? 1. Install libpcap and rerun ./configure"
# echo "*??? or 2. Use the --with-pcap-root= option"
echo "*"
echo "*******************************************************************"
echo
AC_MSG_ERROR(Unable to continue... aborting ./configure)
fi
dnl define _BSD_SOURCE for libc-2
if [[ -f /lib/libc-2* ]]; then
V_DEFINES="$V_DEFINES -D_BSD_SOURCE"
else
if [[ -f /lib64/libc-2* ]]; then
V_DEFINES="$V_DEFINES -D_BSD_SOURCE"
else
ls -1 /lib/*/libc-2* > /dev/null 2>&1
if [[ "$?" = "0" ]]; then
V_DEFINES="$V_DEFINES -D_BSD_SOURCE"
fi
fi
fi
dnl define __FAVOR_BSD when compiling for Android
if test ".${ENABLE_ANDROID}" = ".yes"; then
V_DEFINES="$V_DEFINES -D__FAVOR_BSD"
fi
#####################
## RRD library
AC_CHECK_LIB([rrd], [rrd_init], [AC_CHECK_HEADERS(rrd.h, have_rrd=yes, have_rrd=no)], [have_rrd=no])
if test "x$have_rrd" = "xyes"; then
V_DEFINES="$V_DEFINES -DHAVE_RRDTOOL"
LIBS="$LIBS -lrrd"
fi
######################
## ZLIB library
## --enable-zlib option
ENABLE_ZLIB=no
AC_ARG_ENABLE(zlib,
AS_HELP_STRING([--enable-zlib], [enable zlib support to generate compressed data]),
ENABLE_ZLIB=$enableval)
AM_CONDITIONAL([ZLIB], [test "x$ENABLE_ZLIB" = "xyes"])
if test ".${ENABLE_ZLIB}" = ".yes"; then
AC_CHECK_LIB([z], [gzopen], [AC_CHECK_HEADERS(zlib.h, have_zlib=yes, have_zlib=no)], [have_zlib=no])
if test "x$have_zlib" = "xyes"; then
V_DEFINES="$V_DEFINES -DHAVE_ZLIB"
LIBS="$LIBS -lz"
fi
else
have_zlib=no
fi
#####################
## LDNS library
## --enable-ldns option
ENABLE_LDNS=no
AC_ARG_ENABLE(ldns,
AS_HELP_STRING([--enable-ldns], [enable generation of DNS log files (requires ldns and ldns-devel packages)]),
ENABLE_LDNS=$enableval)
AM_CONDITIONAL([LDNS], [test "x$ENABLE_LDNS" = "xyes"])
if test ".${ENABLE_LDNS}" = ".yes"; then
AC_CHECK_LIB([ldns], [ldns_wire2pkt], [AC_CHECK_HEADERS(ldns/ldns.h, have_ldns=yes, have_ldns=no)], [have_ldns=no])
if test "x$have_ldns" = "xyes"; then
V_DEFINES="$V_DEFINES -DHAVE_LDNS"
LIBS="$LIBS -lldns"
else
echo
echo "*******************************************************************"
echo "*"
echo "* ERROR: LDNS libraries or headers are not installed"
echo "*"
echo "*>>> No way to proceed."
echo "*"
echo "*??? 1. Install ldns and ldns-devel and rerun ./configure"
echo "*??? or 2. Do not use the --enable-ldns option"
echo "*"
echo "*******************************************************************"
echo
AC_MSG_ERROR(Unable to continue... aborting ./configure)
fi
else
have_ldns=no
fi
AC_SUBST(V_CCOPT)
AC_SUBST(V_INCLS)
#AC_SUBST(V_PCAP_LDLIBS)
#AC_SUBST(V_PCAP_INCLUDE)
#AC_SUBST(V_PCAP_LIBPATH)
AC_SUBST(V_DEFINES)
AC_SUBST(LIBTSTAT_VERSION, _libtstat_version)
AC_SUBST(PCAP_LDLINK)
#AC_SUBST(RRD_LDLINK)
AC_SUBST(PACKAGE_VERSION)
AC_CONFIG_FILES([
Makefile
tstat/Makefile
libtstat/Makefile
libtstat/libtstat.pc
libtstat-demo/Makefile
README
NEWS
])
AC_OUTPUT
echo \
"-------------------------------------------------
${PACKAGE_NAME} Version ${PACKAGE_VERSION}
${LIBS}
Prefix: '${prefix}'
Package features:
- pcap yes
- zlib ${have_zlib}
- rrd ${have_rrd}
- ldns ${have_ldns}
- libtstat ${ENABLE_LIBTSTAT}
- rrdthread ${ENABLE_RRDTHREAD}
--------------------------------------------------"