-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.ac
More file actions
265 lines (236 loc) · 6.27 KB
/
configure.ac
File metadata and controls
265 lines (236 loc) · 6.27 KB
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
AC_PREREQ([2.69])
AC_INIT([esocks], [ESOCKS_VERSION], [shunsuketamiya@posteo.net])
AC_CANONICAL_HOST
AC_CONFIG_SRCDIR([server.c])
AM_INIT_AUTOMAKE([foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AM_CONFIG_HEADER([config.h])
AC_PROG_CC
dnl Initialize prefix
if ! test -z "$prefix"; then
prefix=/usr/local
fi
dnl If possible, enable extensions to C or Posix on hosts that disable the extensions.
dnl Autocnf version > 2.60
AC_USE_SYSTEM_EXTENSIONS
dnl Checks for programs.
dnl A macro for GNU Make to choose the default C compilation rule.
AC_PROG_CC_C_O
# Not yet
# AC_PROG_INSTALL
dnl Configure `ln -s`, if works. Otherwise set it to `cp -p.
AC_PROG_LN_S
if test "$GCC" = "yes"; then
# Include all gcc warnings
CFLAGS="$CFLAGS -Wall"
fi
AC_ARG_ENABLE(gcc-warnings,
AS_HELP_STRING([--disable-gcc-warnings],[disable all warnings with GCC]))
AC_ARG_ENABLE(gcc-hardening,
AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks),
[if test x$enableval = xyes; then
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
CFLAGS="$CFLAGS --param ssp-buffer-size=1"
fi])
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--enable-debug],[build debug mode])])
if test "x$enable_debug" = "xyes"; then
old_cflags=$CFLAGS
CFLAGS="-DDEBUG=1 -g -ggdb -O3"
fi
AC_ARG_ENABLE(64bit,
[AS_HELP_STRING([--enable-64bit],[build 64-bit version])])
if test "x$enable_64bit" = "xyes"; then
CFLAGS="-m64 $CFLAGS"
fi
AC_ARG_ENABLE(static,
[AS_HELP_STRING([--enable-static],[build static binary])])
LIBS="-ldl"
if test "x$enable_static" = "xyes"; then
CFLAGS="-static $CFLAGS"
LIBS="-pthread $LIBS"
fi
dnl Checks for header files.
AC_CHECK_HEADERS([ \
errno.h \
getopt.h \
fcntl.h \
netdb.h \
netinet/in.h \
netinet/in6.h \
netinet/tcp.h \
])
dnl Search for network library to handle static linking
AC_SEARCH_LIBS(socket, socket)
AC_SEARCH_LIBS(gethostbyname, nsl)
dnl Checks for library functions.
AC_CHECK_FUNCS([accept4], [AC_DEFINE(HAVE_ACCEPT4, 1, [Define to 1 if support accept4])])
AC_CACHE_CHECK(
[for getaddrinfo],
[ac_cv_getaddrinfo],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
]],
[[
getaddrinfo;
]]
)],
[ac_cv_getaddrinfo=yes],
[ac_cv_getaddrinfo=no]
)]
)
if test "$ac_cv_getaddrinfo" = "$xyes"; then
AC_DEFINE([HAVE_GETADDRINFO], 1, [Define to 1 if support getaddrinfo])
fi
dnl Checks for TCP_FASTOPEN and TCP_NODELAY.
AC_CACHE_CHECK(
[for sol_tcp],
[ac_cv_sol_tcp],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#ifdef HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
#include <sys/socket.h>
#include <sys/types.h>
]],
[[
int fd, optval=5;
fd=socket(AF_INET,SOCK_STREAM,0);
setsockopt(fd,SOL_TCP,TCP_FASTOPEN,(void*)&optval, sizeof(optval));
setsockopt(fd,SOL_TCP,TCP_NODELAY,(void*)&optval, sizeof(optval));
]]
)],
[ac_cv_sol_tcp=yes],
[ac_cv_sol_tcp=no]
)]
)
if test "$ac_cv_sol_tcp" = "yes"; then
AC_DEFINE([HAVE_TCP_FASTOPEN], 1, [Define to 1 if support tcp fastopen])
AC_DEFINE([HAVE_TCP_NODELAY], 1, [Define to 1 if support tcp nodelay])
fi
trylibeventdir=""
AC_ARG_WITH(libevent,
[ --with-libevent=PATH Specify path to libevent installation ],
[
if test "x$withval" != "xno" ; then
trylibeventdir=$withval
fi
]
)
dnl ------------------------------------------------------
dnl libevent detection. swiped from Tor and Memcached.
LIBEVENT_URL=http://www.monkey.org/~provos/libevent/
AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [
saved_LIBS="$LIBS"
saved_LDFLAGS="$LDFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
le_found=no
for ledir in $trylibeventdir "" $prefix /usr/local ; do
LDFLAGS="$saved_LDFLAGS"
LIBS="-levent $saved_LIBS"
# Skip the directory if it isn't there.
if test ! -z "$ledir" -a ! -d "$ledir" ; then
continue;
fi
if test ! -z "$ledir" ; then
if test -d "$ledir/lib" ; then
LDFLAGS="-L$ledir/lib $LDFLAGS"
else
LDFLAGS="-L$ledir $LDFLAGS"
fi
if test -d "$ledir/include" ; then
CPPFLAGS="-I$ledir/include $CPPFLAGS"
else
CPPFLAGS="-I$ledir $CPPFLAGS"
fi
fi
# Can I compile and link it?
AC_TRY_LINK([#include <sys/time.h>
#include <sys/types.h>
#include <event.h>], [ event_init(); ],
[ libevent_linked=yes ], [ libevent_linked=no ])
if test $libevent_linked = yes; then
if test ! -z "$ledir" ; then
ac_cv_libevent_dir=$ledir
_myos=`echo $target_os | cut -f 1 -d .`
AS_IF(test "$SUNCC" = "yes" -o "x$_myos" = "xsolaris2",
[saved_LDFLAGS="$saved_LDFLAGS -Wl,-R$ledir/lib"],
[AS_IF(test "$GCC" = "yes",
[saved_LDFLAGS="$saved_LDFLAGS -Wl,-rpath,$ledir/lib"])])
else
ac_cv_libevent_dir="(system)"
fi
le_found=yes
break
fi
done
LIBS="$saved_LIBS"
LDFLAGS="$saved_LDFLAGS"
CPPFLAGS="$saved_CPPFLAGS"
if test $le_found = no ; then
AC_MSG_ERROR([libevent is required. You can get it from $LIBEVENT_URL
If it's already installed, specify its path using --with-libevent=/dir/
])
fi
])
LIBS="-levent $LIBS"
if test $ac_cv_libevent_dir != "(system)"; then
if test -d "$ac_cv_libevent_dir/lib" ; then
LDFLAGS="-L$ac_cv_libevent_dir/lib $LDFLAGS"
le_libdir="$ac_cv_libevent_dir/lib"
else
LDFLAGS="-L$ac_cv_libevent_dir $LDFLAGS"
le_libdir="$ac_cv_libevent_dir"
fi
if test -d "$ac_cv_libevent_dir/include" ; then
CPPFLAGS="-I$ac_cv_libevent_dir/include $CPPFLAGS"
else
CPPFLAGS="-I$ac_cv_libevent_dir $CPPFLAGS"
fi
fi
tryopenssl=""
AC_ARG_WITH(openssl,
[ --with-openssl=PATH Specify a path to openssl],
[
if test "x$xwithval" != "xno"; then
tryopenssl=$withval
fi
]
)
dnl Checks for OpenSSL.
AC_CACHE_CHECK(
[for openssl],
[ac_cv_openssl],
[
CPPFLAGS="-I$tryopenssl/include $CPPFLAGS"
LDFLAGS="-L$tryopenssl/lib $LDFLAGS"
LIBS="-lcrypto $LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <openssl/evp.h>
#include <openssl/err.h>
]],
[[
OPENSSL_malloc_init();
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
]],
)],
[ac_cv_openssl=yes],
[ac_cv_openssl=no]
)]
if test $ac_cv_openssl = no; then
AC_MSG_ERROR([You have wrong version of OpenSSL.
])
fi
)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT