-
Notifications
You must be signed in to change notification settings - Fork 326
/
configure.ac
452 lines (418 loc) · 11.6 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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([openfortivpn], [1.22.1])
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign subdir-objects])
# Checks for programs.
AC_PROG_CC
AC_PROG_MKDIR_P
AC_PROG_SED
AC_PROG_INSTALL
AC_USE_SYSTEM_EXTENSIONS
m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([Please install pkg-config.])])
PKG_PROG_PKG_CONFIG
REVISION=""
AS_IF([test -d .git], [
AC_PATH_PROG(GIT, [git], [""], "$PATH:/sbin:/usr/sbin")
AS_IF([test "x$GIT" != "x"], [
REVISION=`$GIT describe --tags | sed -e 's/-/+git/;y/-/./'`
])
])
AS_IF([test "x$REVISION" = "x"], [
REVISION="unavailable"
])
AC_SUBST(REVISION)
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Checks for libraries.
PKG_CHECK_MODULES(OPENSSL, [libssl >= 1.0.2 libcrypto >= 1.0.2], [], [AC_MSG_ERROR([Cannot find OpenSSL 1.0.2 or higher.])])
AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([Cannot find libpthread.])])
AC_CHECK_LIB([util], [forkpty], [], [AC_MSG_ERROR([Cannot find libutil.])])
PKG_CHECK_MODULES(LIBSYSTEMD, [libsystemd], [AC_DEFINE(HAVE_SYSTEMD)], [AC_MSG_RESULT([libsystemd not present])])
# we assume presence of the following C standard headers
# and omit them in the following header checks
#
# assert.h
# ctype.h
# errno.h
# limits.h
# signal.h
# stdarg.h
# stddef.h
# stdint.h
# stdio.h
# stdlib.h
# string.h
# Checks for required header files.
AC_CHECK_HEADERS([ \
arpa/inet.h \
fcntl.h \
getopt.h \
ifaddrs.h \
netdb.h \
netinet/in.h \
netinet/tcp.h \
pthread.h \
strings.h \
sys/ioctl.h \
syslog.h \
sys/socket.h \
sys/stat.h \
sys/types.h \
sys/wait.h \
termios.h \
unistd.h \
], [], AC_MSG_ERROR([Required header not found]))
# Checks for header files with prerequisites of other headers.
AC_CHECK_HEADERS([net/if.h], [], AC_MSG_ERROR([Required header not found]), [#include <sys/socket.h>])
AC_CHECK_HEADERS([net/route.h], [], AC_MSG_ERROR([Required header not found]), [#include <sys/socket.h>], [#include <net/if.h>])
# Checks for optional header files.
AC_CHECK_HEADERS([ \
libutil.h \
mach/mach.h \
pty.h \
semaphore.h \
util.h \
])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_CHECK_TYPES([struct termios], [], [], [#include <termios.h>])
# Checks for library functions.
AC_CHECK_FUNCS([ \
access \
close \
connect \
execv \
_exit \
fcntl \
fileno \
forkpty \
freeaddrinfo \
freeifaddrs \
gai_strerror \
getaddrinfo \
geteuid \
getifaddrs \
getopt_long \
htons \
inet_addr \
inet_ntoa \
ioctl \
isatty \
memmem \
ntohs \
open \
openlog \
pclose \
popen \
pthread_cancel \
pthread_cond_init \
pthread_cond_signal \
pthread_cond_wait \
pthread_create \
pthread_join \
pthread_mutexattr_init \
pthread_mutex_destroy \
pthread_mutex_init \
pthread_mutex_lock \
pthread_mutex_unlock \
pthread_self \
pthread_sigmask \
read \
select \
sem_destroy \
sem_init \
sem_post \
sem_wait \
setenv \
setsockopt \
sigaddset \
sigemptyset \
sleep \
socket \
strcasecmp \
strdup \
strncasecmp \
strsignal \
strtok_r \
syslog \
tcgetattr \
tcsetattr \
usleep \
vsyslog \
waitpid \
write \
], [], AC_MSG_ERROR([Required function not found]))
# Checks for optional functions.
AC_CHECK_FUNCS([ \
pthread_mutexattr_setrobust \
vdprintf \
])
# Use PKG_CHECK_MODULES compiler/linker flags
save_openssl_CPPFLAGS="${CPPFLAGS}"
save_openssl_LIBS="${LIBS}"
CPPFLAGS="${OPENSSL_CFLAGS} ${CPPFLAGS}"
LIBS="${OPENSSL_LIBS} ${LIBS}"
CPPFLAGS="${save_openssl_CPPFLAGS}"
LIBS="${save_openssl_LIBS}"
# Specialised checks for particular features.
# When cross compile, don't run the tests.
AC_ARG_WITH([rt_dst],
AS_HELP_STRING([--with-rt_dst],
[disable rtentry with rt_dst testing (for linux target when cross compile)]),
AS_IF([test "x$with_rt_dst" = "xyes"],[
AC_MSG_NOTICE([HAVE_RT_ENTRY_WITH_RT_DST... 1])
AC_DEFINE(HAVE_RT_ENTRY_WITH_RT_DST)
])
)
AS_IF([test "x$with_rt_dst" = "x"], [
AC_MSG_CHECKING(whether rtentry is available and has rt_dst)
AC_LANG(C)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
static inline struct sockaddr_in *cast_addr(struct sockaddr *addr)
{
return (struct sockaddr_in *) addr;
}
],[
struct rtentry route;
cast_addr(&(&route)->rt_dst)->sin_family = AF_INET;
])],[
AC_DEFINE(HAVE_RT_ENTRY_WITH_RT_DST)
AC_MSG_RESULT(yes)
], AC_MSG_RESULT(no))
])
NETSTAT_PATH=""
PPP_PATH=""
RESOLVCONF_PATH=""
# prepare possibility to override default locations
AC_ARG_WITH([netstat],
AS_HELP_STRING([--with-netstat],
[set the path to the netstat executable on MacOS or FreeBSD]),
NETSTAT_PATH="$withval"
)
# this is for the pppd daemon executable
AC_ARG_WITH([pppd],
AS_HELP_STRING([--with-pppd],
[set the path to the pppd daemon executable]),
AS_IF([test ! "x$with_pppd" = "xno" -a ! "x$with_pppd" = "xyes"],[
PPP_PATH="$withval"
with_pppd="yes"
with_ppp="no"
])
)
# support pppd < 2.5.0 by default instead of pppd >= 2.5.0
AC_ARG_ENABLE([legacy_pppd],
AS_HELP_STRING([--enable-legacy-pppd],
[support pppd < 2.5.0 by default instead of pppd >= 2.5.0]))
# this is for the ppp user space client on FreeBSD
AC_ARG_WITH([ppp],
AS_HELP_STRING([--with-ppp],
[set the path to the ppp userspace client on FreeBSD]),
AS_IF([test ! "x$with_ppp" = "xno" -a ! "x$with_ppp" = "xyes"],[
PPP_PATH="$withval"
with_ppp="yes"
with_pppd="no"
])
)
# override for /proc/net/route detection
AC_ARG_ENABLE([proc],
AS_HELP_STRING([--enable-proc],
[enable route manipulations directly via /proc/net/route \
when cross-compiling, use --disable-proc for the opposite]))
# check for netstat if not cross-compiling
AS_IF([test "x$enable_proc" = "x"], [
AC_CHECK_FILE([/proc/net/route],[
AS_IF([test "x$enable_proc" = "x"], [
enable_proc="yes"
])
],[
AS_IF([test "x$NETSTAT_PATH" = "x"], [
AC_CHECK_FILE([/usr/sbin/netstat],[
NETSTAT_PATH="/usr/sbin/netstat"
],[
AC_CHECK_FILE([/usr/bin/netstat],[
NETSTAT_PATH="/usr/bin/netstat"
],[])
])
])
])
])
# check for ppp if not specified
AC_PATH_PROG(PPP, [ppp], [/usr/sbin/ppp], "$PATH:/sbin:/usr/sbin")
AS_IF([test "x$PPP_PATH" = "x"], [
AC_CHECK_FILE([$PPP], [
AS_IF([test "x$PPP_PATH" = "x"], [
PPP_PATH="$PPP"
])
AS_IF([test "x$with_ppp" = "x"], [
with_ppp="yes"
])
],[])
])
# check for pppd if not specified
AC_PATH_PROG(PPPD, [pppd], [/usr/sbin/pppd], "$PATH:/sbin:/usr/sbin")
AS_IF([test "x$PPP_PATH" = "x"], [
AC_CHECK_FILE([$PPPD], [
AS_IF([test "x$PPP_PATH" = "x"], [
PPP_PATH="$PPPD"
])
AS_IF([test "x$with_pppd" = "x"], [
with_pppd="yes"
])
],[])
])
# when neither ppp nor pppd are enabled fall back to a sensible choice for the platform
AS_IF([test "x$with_ppp" = "x" -a "x$with_pppd" = "x"], [
AS_IF([test "x$(uname)" = "xFreeBSD"], [
with_ppp="yes"
PPP_PATH="/usr/sbin/ppp"
], [
with_pppd="yes"
PPP_PATH="/usr/sbin/pppd"
])
])
# when both are enabled, give pppd the higher priority (we can only use one of them)
AS_IF([test "x$with_ppp" = "xyes" -a "x$with_pppd" = "xyes"], [
with_ppp="no"
])
# replace empty settings with "no"
AS_IF([test "x$with_pppd" = "x"], [
with_pppd="no"
])
AS_IF([test "x$with_ppp" = "x"], [
with_ppp="no"
])
AS_IF([test "x$with_ppp" = "xyes"], [
AC_DEFINE(HAVE_USR_SBIN_PPP, 1)
AC_MSG_NOTICE([HAVE_USR_SBIN_PPP... 1])
],[
AC_DEFINE(HAVE_USR_SBIN_PPP, 0)
AC_MSG_NOTICE([HAVE_USR_SBIN_PPP... 0])
])
AS_IF([test "x$with_pppd" = "xyes"], [
AC_DEFINE(HAVE_USR_SBIN_PPPD, 1)
AC_MSG_NOTICE([HAVE_USR_SBIN_PPPD... 1])
],[
AC_DEFINE(HAVE_USR_SBIN_PPPD, 0)
AC_MSG_NOTICE([HAVE_USR_SBIN_PPPD... 0])
])
AS_IF([test "x$enable_legacy_pppd" = "xyes"], [
AC_DEFINE(LEGACY_PPPD, 1)
AC_MSG_NOTICE([LEGACY_PPPD... 1])
],[
AC_DEFINE(LEGACY_PPPD, 0)
AC_MSG_NOTICE([LEGACY_PPPD... 0])
])
AS_IF([test "x$enable_proc" = "xyes"], [
AC_DEFINE(HAVE_PROC_NET_ROUTE, 1)
AC_MSG_NOTICE([HAVE_PROC_NET_ROUTE... 1])
],[
AC_DEFINE(HAVE_PROC_NET_ROUTE, 0)
AC_MSG_NOTICE([HAVE_PROC_NET_ROUTE... 0])
])
AC_SUBST(PPP_PATH)
AC_MSG_NOTICE([PPP_PATH...] $PPP_PATH)
AC_SUBST(NETSTAT_PATH)
AS_IF([test "x$NETSTAT_PATH" != "x"], [
AC_MSG_NOTICE([NETSTAT_PATH...] $NETSTAT_PATH)
])
# use resolvconf if present
AC_PATH_PROG(RESOLVCONF_PATH, [resolvconf], [DISABLED], "$PATH:/sbin:/usr/sbin")
# allow override at configure time
AC_ARG_WITH([resolvconf],
AS_HELP_STRING([--with-resolvconf],
[set the path to the resolvconf executable, \
with special value "DISABLED" fully disabling \
resolvconf support at build-time]),
RESOLVCONF_PATH="$withval"
)
AC_SUBST(RESOLVCONF_PATH)
AS_IF([test "x$RESOLVCONF_PATH" != "x"], [
AC_MSG_NOTICE([RESOLVCONF_PATH...] $RESOLVCONF_PATH)
])
AS_IF([test "x$RESOLVCONF_PATH" = "xDISABLED"], [
AC_DEFINE(HAVE_RESOLVCONF, 0)
AC_MSG_NOTICE([HAVE_RESOLVCONF... 0])
],[
AC_DEFINE(HAVE_RESOLVCONF, 1)
AC_MSG_NOTICE([HAVE_RESOLVCONF... 1])
])
# the default for the --use-resolvconf runtime command line option
AC_ARG_ENABLE([resolvconf],
AS_HELP_STRING([--enable-resolvconf],
[enable usage of resolvconf at runtime by default \
(please note that resolvconf support will still \
be compiled in with --disable-resolvconf but \
disabled unless explicitly enabled at runtime)]))
# Determine how resolvconf works at build-time if it is installed:
# * openresolv supports option -l that lists active configurations and returns 0
# * resolvconf in Ubuntu/Debian does not support listing but returns 99
# if invoked without parameters
# * skip resolvectl which does not work as expected when invoked as resolveconf
AS_IF([test "x$enable_resolvconf" = "x" -a "x$RESOLVCONF_PATH" != "xDISABLED"], [
AC_CHECK_FILE([$RESOLVCONF_PATH],[
AS_IF([$RESOLVCONF_PATH -l >/dev/null 2>/dev/null], [
enable_resolvconf="yes"
],[
AS_IF([$RESOLVCONF_PATH >/dev/null 2>/dev/null ; test $? -eq 99], [
enable_resolvconf="yes"
],[
enable_resolvconf="no"
])
])
],[
enable_resolvconf="no"
])
])
AS_IF([test "x$enable_resolvconf" = "xyes"], [
AC_DEFINE(USE_RESOLVCONF, 1)
AC_MSG_NOTICE([USE_RESOLVCONF... 1])
],[
AC_DEFINE(USE_RESOLVCONF, 0)
AC_MSG_NOTICE([USE_RESOLVCONF... 0])
])
# install systemd service file
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [directory for systemd service files])],,
[with_systemdsystemunitdir=auto])
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
AS_IF([test "x$def_systemdsystemunitdir" = "x"],
[AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemdsystemunitdir=no],
[with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
AC_MSG_NOTICE([systemdsystemunitdir... $systemdsystemunitdir])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char **argv){
int ret, handle;
handle = socket(AF_INET, SOCK_STREAM, 0);
ret = setsockopt(handle, SOL_SOCKET, SO_BINDTODEVICE,"lo",3);
}
])], [
AC_DEFINE(HAVE_SO_BINDTODEVICE, 1)
AC_MSG_NOTICE([HAVE_SO_BINDTODEVICE... 1])
],[
AC_DEFINE(HAVE_SO_BINDTODEVICE, 0)
AC_MSG_NOTICE([HAVE_SO_BINDTODEVICE... 0])
])
AC_CONFIG_COMMANDS([timestamp], [touch src/.dirstamp])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT