-
Notifications
You must be signed in to change notification settings - Fork 22
/
configure.ac
178 lines (143 loc) · 4.81 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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT(nfqfilter, 0.3, max1976@mail.ru)
NDPI_HOME=./nDPI
NDPI_GIT_VERSION=1.7-stable
AM_INIT_AUTOMAKE()
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(no)])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADERS([include/config.h])
AC_LANG([C++])
AC_LANG_PUSH([C++])
# store current user given compiler flags to avoid default setup via AC_PROG_CXX
OLD_CXXFLAGS=$CXXFLAGS
OLD_CFLAGS=$CFLAGS
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
CXXFLAGS=$OLD_CXXFLAGS
CFLAGS=$OLD_CFLAGS
CFLAGS="$CFLAGS --pedantic -Wall -O2"
AC_ARG_ENABLE(debug,
AS_HELP_STRING(
[--enable-debug],
[enable debugging, default: no]),
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],
[debug=false])
AC_MSG_CHECKING([for debug enabled])
if test x"$debug" = x"true"; then
CXXFLAGS="$CXXFLAGS -std=c++0x -O0 -g -Wall -pthread"
else
CXXFLAGS="$CXXFLAGS -std=c++0x -O2 -pthread"
fi
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
[[template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
};
typedef check<check<bool>> right_angle_brackets;
int a;
decltype(a) b;
typedef check<int> check_type;
check_type c;
check_type&& cr = static_cast<check_type&&>(c);]])],,
AC_MSG_FAILURE(['$CXX $CXXFLAGS' does not accept ISO C++11]))
# Checks for libraries.
# Checks for header files.
AC_CHECK_HEADERS([netinet/in.h stdint.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_CHECK_FUNCS([strerror])
# Check for methods in library and check for header files
AC_CHECK_HEADERS([Poco/Foundation.h Poco/Net/HTTPCookie.h Poco/Util/Timer.h],
[],
AC_MSG_ERROR([Poco include files not found.])
)
AC_CHECK_LIB([PocoFoundation],[main],[HAVE_POCOFOUNDATION=1],AC_MSG_ERROR([PocoFoundation library not found.]))
if test "$HAVE_POCOFOUNDATION"; then
save_libs="${LIBS}"
LIBS="-lPocoFoundation"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include "Poco/UnicodeConverter.h"],
[std::wstring wstr; Poco::UnicodeConverter::toUTF16("hello", wstr);]
)],
[LIBS="$LIBS $save_libs"],
[AC_MSG_ERROR([linking with PocoFoundation failed.])]
)
fi
AC_CHECK_LIB([PocoUtil],[main],[HAVE_POCOUTIL=1],AC_MSG_ERROR([PocoUtil library not found.]))
if test "$HAVE_POCOUTIL"; then
save_libs="${LIBS}"
LIBS="-lPocoUtil"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include "Poco/Util/Option.h"],
[Poco::Util::Option();]
)],
[LIBS="$LIBS $save_libs"],
[AC_MSG_ERROR([linking with PocoUtil failed.])]
)
fi
AC_CHECK_LIB([PocoNet],[main],[HAVE_POCONET=1],AC_MSG_ERROR([PocoNet library not found.]))
if test "$HAVE_POCONET"; then
save_libs="${LIBS}"
LIBS="-lPocoNet"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include "Poco/Net/HTTPClientSession.h"],
[Poco::Net::HTTPClientSession();]
)],
[LIBS="$LIBS $save_libs"],
[AC_MSG_ERROR([linking with PocoNET failed.])]
)
fi
AC_CHECK_LIB([netfilter_queue], [nfq_open],,AC_MSG_ERROR([Netfilter_queue library not found!]))
AC_CHECK_LIB([nfnetlink], [nfnl_fd],,AC_MSG_ERROR([Nfnetlink library not found!]))
dnl nDPI checks...
AC_MSG_CHECKING(for nDPI $NDPI_HOME)
if test -d "$NDPI_HOME" ; then :
AC_MSG_RESULT(found in $NDPI_HOME)
else
AC_MSG_RESULT(not found)
AC_MSG_NOTICE(Getting nDPI from git)
git clone -b $NDPI_GIT_VERSION https://github.com/ntop/nDPI.git $NDPI_HOME; cd $NDPI_HOME; patch -p1 < ../nDPI-1.7-bugfixes.patch ; cd -
AC_MSG_CHECKING(for nDPI $NDPI_HOME)
if test -d "$NDPI_HOME" ; then :
AC_MSG_RESULT(found in $NDPI_HOME)
else
AC_MSG_ERROR(Install nDPI 1.7-stable: git clone -b $NDPI_GIT_VERSION https://github.com/ntop/nDPI.git $NDPI_HOME; cd $NDPI_HOME; patch -p1 < ../nDPI-1.7-bugfixes.patch ; ./autogen.sh; make; cd - )
fi
fi
NDPI_LIB=$NDPI_HOME/src/lib/.libs/libndpi.a
AC_MSG_CHECKING(for $NDPI_LIB)
if test -f "$NDPI_LIB" ; then :
else
AC_MSG_RESULT([not found, compiling...])
cd $NDPI_HOME; ./autogen.sh; make; cd -
fi
AC_MSG_RESULT(yes)
save_flags="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} -I${NDPI_HOME}/src/include"
AC_MSG_CHECKING(for compiling with nDPI)
save_libs="${LIBS}"
LIBS="$NDPI_LIB"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[#include "ndpi_api.h"],
[ndpi_revision();]
)],
[LIBS="$save_libs"],
[AC_MSG_ERROR([Linking with nDPI failed!])]
)
AC_MSG_RESULT(yes)
CXXFLAGS="$save_flags"
AC_OUTPUT(Makefile src/Makefile include/Makefile)