-
Notifications
You must be signed in to change notification settings - Fork 58
/
configure.ac
177 lines (160 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
# Initialize autoconf
AC_INIT([memkeys], [0.2], [[email protected]])
AC_PREREQ([2.63])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([build-aux/mconfig.h:build-aux/mconfig.h.in])
# Initialize automake
AM_INIT_AUTOMAKE([1.9.6 foreign])
# Checks for language
AC_LANG([C++])
# Checks for programs
CXXFLAGS="$CXXFLAGS -std=c++0x" # Will fail if not g++44 or later
AC_PROG_CXX([g++44 g++ gcc cxx cc++ c++])
AC_PROG_CXXCPP
CXXCPP="$CXXCPP -std=c++0x" # This must come after AC_PROG_CXXCPP
AC_PROG_LIBTOOL
# Check for typedefs, structures, and compiler characteristics
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
# Platform specific setup
AC_CANONICAL_HOST
case "$host" in
*linux*)
# getconf LEVEL1_DCACHE_LINESIZE
AC_DEFINE([linux], 1, [Linux])
;;
darwin*)
# sysctl -a hw.cachelinesize
AC_DEFINE([__APPLE__], 1, [Apple Hardware])
;;
esac
# Check for headers
AC_CHECK_HEADERS([getopt.h])
AC_CHECK_HEADERS([pcrecpp.h])
AC_CHECK_HEADERS([cstdatomic])
AC_CHECK_HEADERS([atomic])
# Checks for libraries
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([getopt],[getopt_long])
AC_CHECK_LIB([gnugetopt],[getopt_long])
PCRECPP=""
AC_ARG_WITH([libpcrecpp],
AS_HELP_STRING([--with-libpcrecpp=DIR], [libpcre base directory]),
[with_libpcrecpp="$withval"],
[with_libpcrecpp="no"])
if test "x$with_libpcrecpp" != "xno"; then
LDFLAGS="${LDFLAGS} -L${with_libpcrecpp}/lib"
CPPFLAGS="${CPPFLAGS} -I${with_libpcrecpp}/include"
fi
# Fail if pcrecpp is not found
AC_CHECK_LIB([pcrecpp], [main],, [AC_MSG_ERROR([libpcrecpp not found but required])])
AC_ARG_WITH(libpcap_includes,
AS_HELP_STRING([--with-libpcap-includes=DIR], [libpcap include directory]),
[with_libpcap_includes="$withval"],
[with_libpcap_includes="no"])
AC_ARG_WITH(libpcap_libraries,
AS_HELP_STRING([--with-libpcap-libraries=DIR], [libpcap library directory]),
[with_libpcap_libraries="$withval"],
[with_libpcap_libraries="no"])
if test "x$with_libpcap_includes" != "xno"; then
CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}"
fi
if test "x$with_libpcap_libraries" != "xno"; then
LDFLAGS="${LDFLAGS} -L${with_libpcap_libraries}"
fi
LPCAP=""
AC_CHECK_LIB(pcap, pcap_datalink,, LPCAP="no")
if test "x$LPCAP" = "xno"; then
echo
echo " ERROR! Libpcap library/headers (libpcap.a (or .so)/pcap.h)"
echo " not found, go get it from http://www.tcpdump.org"
echo " or use the --with-libpcap-* options, if you have it installed"
echo " in unusual place. Also check if your libpcap depends on another"
echo " shared library that may be installed in an unusual place"
exit 1
fi
CURSES=""
AC_CHECK_LIB(ncurses, initscr,, CURSES="no")
AC_CHECK_HEADERS([ncurses.h])
if test "x$CURSES" = "xno"; then
echo
echo " ERROR! ncurses library/headers (libncurses.a (or .so)/ncurses.h)"
echo " not found."
exit 1
fi
AC_MSG_CHECKING(whether to create a profiled build)
AC_ARG_ENABLE(profiling,
AS_HELP_STRING([--enable-profiling], [Turn on profiling (default=no)]),
[ case "${enableval}" in
yes)
AC_MSG_RESULT(yes)
AC_CHECK_LIB([profiler], [ProfilerStop])
;;
*)
AC_MSG_RESULT(no)
;;
esac],
[AC_MSG_RESULT(no)])
# Enable debugging
AC_MSG_CHECKING(whether to create a debug build)
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Turn on debugging (default=no)]),
[ case "${enableval}" in
yes)
AC_MSG_RESULT(yes)
# Created in mconfig.h for use as #ifdef DEBUG
AC_DEFINE([DEBUGGING], 1, [Defined if you are debugging])
debug=true
;;
no)
AC_MSG_RESULT(no)
debug=false
;;
*)
AC_MSG_ERROR([bad value ${enableval} for --enable-debug])
;;
esac],
[
AC_MSG_RESULT(no)
debug=false
])
# For use in Makefile.am as if DEBUG
AM_CONDITIONAL([DEBUGGING], [test x$debug = xtrue])
# Enable development
AC_MSG_CHECKING(whether to create a development build)
AC_ARG_ENABLE(development,
AS_HELP_STRING([--enable-development], [Turn on development (default=no)]),
[ case "${enableval}" in
yes)
AC_MSG_RESULT(yes)
# Created in mconfig.h for use as #ifdef DEVELOPMENT
AC_DEFINE([DEVELOPMENT], 1, [Defined if you are development])
development=true
;;
no)
AC_MSG_RESULT(no)
development=false
;;
*)
AC_MSG_ERROR([bad value ${enableval} for --enable-development])
;;
esac],
[
AC_MSG_RESULT(no)
development=false
])
# For use in Makefile.am as if DEVELOPMENT
AM_CONDITIONAL([DEVELOPMENT], [test x$development = xtrue])
# Check functions
AC_CHECK_FUNCS([getopt_long], ,
[AC_MSG_ERROR([no getopt_long function found])])
# Build gtest
export CFLAGS
export CXXFLAGS
AC_CONFIG_SUBDIRS([gtest])
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT