forked from netoptimizer/IPTV-Analyzer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
267 lines (245 loc) · 7.95 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
#
# Notice: The VERSION is defined/controlled by AC_INIT
#
AC_INIT([iptv-analyzer], [0.9.4], [[email protected]], [], [www.iptv-analyzer.org])
#AC_INIT(package, version, [bug-report], [tarname], [url])
#
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
#AC_PROG_INSTALL
#AM_INIT_AUTOMAKE([1.10.2 -Wall foreign subdir-objects])
AM_INIT_AUTOMAKE([foreign])
#AC_DISABLE_STATIC
#AC_PROG_LIBTOOL
# Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
# Checks for header files.
AC_CHECK_HEADERS([netdb.h stddef.h stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT8_T
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_CHECK_FUNCS([strchr])
AC_ARG_WITH([kbuild],
AS_HELP_STRING([--with-kbuild=PATH],
[Path to kernel build directory [[/lib/modules/CURRENT/build]]]),
[kbuilddir="$withval"],
[kbuilddir="/lib/modules/$(uname -r)/build"])
#
# check for --without-kbuild
#
if [[ "$kbuilddir" == no ]]; then
kbuilddir="";
fi
# Check iptables binary exist and set variable IPTABLES to the program
# with full path. Add "sbin" dirs to the search PATH as the user
# running configure might not have this in their path.
#
SBIN_PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin:
AC_PATH_PROG([IPTABLES], [iptables], [no], $SBIN_PATH)
if [[ "$IPTABLES" = "no" ]]; then
AC_MSG_ERROR([Cannot find iptables binary - You need to install iptables])
fi
# Extract iptables base dirname / path
IPTABLES_BINDIR=`AS_DIRNAME([$IPTABLES])`
IPTABLES_DIR=`AS_DIRNAME([$IPTABLES_BINDIR])`
# Find the include path for xtables.h
IPTABLES_INC="${IPTABLES_DIR}/include"
if [[ "$IPTABLES_DIR" = "/" ]]; then
IPTABLES_INC="/usr/include"
fi
# xtlibdir the Xtables extensions path
AC_ARG_WITH([xtlibdir],
AS_HELP_STRING([--with-xtlibdir=PATH],
[Path where to install Xtables extensions.
Configure will try to auto DETECT, based on iptables binary path]),
[xtlibdir="$withval"],
[xtlibdir="detect"])
# [xtlibdir='${libexecdir}/xtables'])
# Default setting of xtlibdir is "detect".
# ----------------------------------------
# Try to detect xtlibdir based upon the location of the detected
# iptables binary IPTABLES_DIR, unless --with-xtlibdir is used.
#
# Problem statement:
#
# The userspace lib dir is differs on different Linux distributions,
# further more the distributions choose not to follow the source code
# (and just alter the exec_prefix to libexec). Instead they force
# the usage of /lib/xtables/ or /lib64/xtables/, via
#
# ./configure --with-xtlibdir=/lib/xtables
#
# We also support this configure switch, but if none given, try to
# detect the xtlibdir used by iptables on the system.
#
xtlibdir_check="";
if test "${with_xtlibdir+set}" = set; then
# No detection and expantion needed, if specified via --with-xtlibdir
xtlibdir_check=$xtlibdir;
elif test "${xtlibdir}" = "detect"; then
AC_MSG_NOTICE([Entering auto-detect mode for Xtables extensions dir xtlibdir])
test_dir=""
if [[ "${IPTABLES_DIR}" = "/" -o "${IPTABLES_DIR}" = "/usr" ]]; then
# First detect via pkt-config
xtlibdir="$(pkg-config --variable=xtlibdir xtables)"
if [[ -z "$xtlibdir" ]]; then
# Try a more low level detect method
# Need to test for /lib{,64}/xtables/ and /usr/lib{,64}/xtables/
if [[ -d /lib/xtables ]]; then
xtlibdir=/lib/xtables
elif [[ -d /lib64/xtables ]]; then
xtlibdir=/lib64/xtables
elif [[ -d /usr/lib/xtables ]]; then
xtlibdir=/usr/lib/xtables
elif [[ -d /usr/lib64/xtables ]]; then
xtlibdir=/usr/lib64/xtables
else
xtlibdir=""
test_dir=""
fi
fi
if [[ -n "$xtlibdir" ]]; then
AC_MSG_NOTICE([ - Found xtlibdir: $xtlibdir])
test_dir=$xtlibdir
fi
else
test_dir=${IPTABLES_DIR}/libexec/xtables
if [[ -d "$test_dir" ]]; then
AC_MSG_NOTICE([ - Found xtlibdir: $test_dir])
xtlibdir=$test_dir
# Handle the case where IPTABLES_DIR = $prefix and
# then pass it along with a quoted '$prefix'
myprefix=${prefix}
if [[ "${myprefix}" = "NONE" ]]; then
myprefix=$ac_default_prefix
fi
if [[ "${myprefix}" = "${IPTABLES_DIR}" ]]; then
xtlibdir='${prefix}/libexec/xtables'
fi
# Handle if exec_prefix is set
if [[ "${exec_prefix}" != "NONE" ]]; then
if [[ "${exec_prefix}" = "${IPTABLES_DIR}" ]]; then
xtlibdir='${libexecdir}/xtables'
fi
fi
else
xtlibdir="$(pkg-config --variable=xtlibdir xtables)"
test_dir=$xtlibdir
fi
fi
# Double check the $test_dir
xtlibdir_check=$test_dir
else
# Skip/avoid check if "detect" is not in use/specified
xtlibdir_check="/"
fi
#
# Test directory exist
if [[ ! -d "$xtlibdir_check" ]]; then
AC_MSG_ERROR([Xtables extensions dir ${xtlibdir_check} does not exist], [2])
fi
# This adds a dependency to pkg-config, alternativly we could define
# libxtables_CFLAGS and libxtables_LIBS to avoid the need to call
# pkg-config.
PKG_CHECK_MODULES([libxtables], [xtables >= 1.4.3])
AC_CHECK_HEADERS([linux/netfilter/x_tables.h], [],
[AC_MSG_ERROR([You need to have linux/netfilter/x_tables.h, see INSTALL file for details])])
regular_CFLAGS="-D_LARGEFILE_SOURCE=1 -D_LARGE_FILES -D_FILE_OFFSET_BITS=64 \
-D_REENTRANT -Wall -Waggregate-return -Wmissing-declarations \
-Wmissing-prototypes -Wredundant-decls -Wshadow -Wstrict-prototypes \
-Winline -pipe -DXTABLES_LIBDIR=\\\"\${xtlibdir}\\\" \
";
#
# Check kernel version
#
if grep -q "CentOS release 5\." /etc/redhat-release 2>/dev/null ||
grep -q "Red Hat Enterprise Linux Server release 5" /etc/redhat-release 2>/dev/null; then
#
# Well, just a warning. Maybe the admin updated the kernel.
echo "WARNING: This distribution's shipped kernel is not supported.";
fi;
krel="$(make -sC ${kbuilddir} kernelrelease)";
krel="${krel%%-*}";
kmajor="${krel%%.*}";
krel="${krel#*.}";
kminor="${krel%%.*}";
krel="${krel#*.}";
kmicro="${krel%%.*}";
if test "$kmicro" = "$krel"; then
kstable=0;
else
kstable="${krel#*.}";
if test -z "$kstable"; then
kstable=0;
fi;
fi;
echo "Found kernel version $kmajor.$kminor.$kmicro.$kstable in $kbuilddir";
if test "$kmajor" -gt 2 -o "$kminor" -gt 6 -o "$kmicro" -gt 38; then
echo "WARNING: You are trying a newer kernel. Results may vary. :-)";
elif test \( "$kmajor" -lt 2 -o "$kminor" -lt 6 -o "$kmicro" -lt 28 \); then
echo "ERROR: Your kernel version is not supported";
echo " Minimum kernel versions > 2.6.27";
echo " (as we need the RCU locking API).";
exit 1;
fi;
# Need perl for the iptv-collector daemon
AC_PATH_PROG([PERL], [perl], [no])
if [[ "$PERL" = "no" ]]; then
AC_MSG_ERROR([Cannot find perl - You need to install perl to run collector])
fi
AC_SUBST([regular_CFLAGS])
AC_SUBST([kbuilddir])
AC_SUBST([xtlibdir])
AC_SUBST([IPTABLES])
AC_SUBST([IPTABLES_DIR])
AC_SUBST([IPTABLES_INC])
AC_CONFIG_FILES([
Makefile
iptables-module/Makefile
collector/lib/IPTV/Analyzer/Version.pm
collector/etc/version
])
#
# $prefix expand for perl collector
PERL_PREFIX="";
if [[ "${prefix}" != "NONE" ]]; then
PERL_PREFIX="PREFIX=$prefix"
fi
AC_OUTPUT
# Configure the iptv-collector
#
# Which is based upon Perl MakeMaker system. To integrate, call the
# MakeMaker system, from the configure script.
#
# Remember to pass $prefix parameter along
echo " Processing Collector Daemon"
echo " -- Calling Perl MakeMaker system"
cd collector
${PERL} Makefile.PL $PERL_PREFIX
cd ..
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-"
echo " Visit the project homepage at:"
echo " http://$PACKAGE_URL"
echo ""
echo " Create bugreports, patches and insults via:"
echo " https://github.com/netoptimizer/IPTV-Analyzer/issues"
echo " or email:"
echo " $PACKAGE_BUGREPORT"
echo ""
echo "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-"