File: configure.ac

package info (click to toggle)
openfortivpn 1.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 448 kB
  • sloc: ansic: 4,645; sh: 105; makefile: 39; python: 23
file content (383 lines) | stat: -rw-r--r-- 8,571 bytes parent folder | download
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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])
AC_INIT([openfortivpn], [1.10.0])
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([foreign subdir-objects])

# Checks for programs.
AC_PROG_CC
AC_GNU_SOURCE
m4_ifndef([PKG_PROG_PKG_CONFIG], [m4_fatal([Please install pkg-config.])])
PKG_PROG_PKG_CONFIG

# Helps support multiarch by setting 'host_os' and 'host_cpu'
AC_CANONICAL_HOST

m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

# Checks for libraries.
PKG_CHECK_MODULES(OPENSSL, [libssl >= 0.9.8 libcrypto >= 0.9.8], [], [AC_MSG_ERROR([Cannot find OpenSSL 0.9.8 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 follwowing C standard headers
# and ommit them in the follwoing header checks
#
# assert.h
# ctype.h
# errno.h
# limits.h
# signal.h
# stdarg.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 \
net/if.h \
netinet/in.h \
netinet/tcp.h \
pthread.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/route.h], [], AC_MSG_ERROR([Required header not found]), [#include <net/if.h>])

# Checks for optional header files.
AC_CHECK_HEADERS([ \
libutil.h \
mach/mach.h \
pty.h \
semaphore.h \
sys/mutex.h \
util.h \
])

# Checks for optional header files with prerequisites of other headers.
AC_CHECK_HEADERS([net/if_var.h],[],[],[#include <net/if.h>])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
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_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([ \
access \
atoi \
close \
connect \
execv \
exit \
_exit \
fclose \
fcntl \
fflush \
fileno \
fopen \
forkpty \
fprintf \
fputc \
fputs \
fread \
free \
freeaddrinfo \
freeifaddrs \
freopen \
fwrite \
gai_strerror \
getaddrinfo \
getchar \
getenv \
geteuid \
getifaddrs \
getopt_long \
htons \
index \
inet_addr \
inet_ntoa \
ioctl \
isatty \
isdigit \
isspace \
malloc \
memcmp \
memcpy \
memmem \
memmove \
memset \
ntohs \
open \
openlog \
optarg \
optind \
pclose \
popen \
printf \
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 \
putchar \
puts \
read \
realloc \
rewind \
select \
sem_destroy \
sem_init \
sem_post \
sem_wait \
setenv \
setsockopt \
sigaddset \
sigemptyset \
signal \
sleep \
snprintf \
socket \
sprintf \
sscanf \
strcasecmp \
strcasestr \
strcat \
strchr \
strcmp \
strcpy \
strdup \
strerror \
strlen \
strncasecmp \
strncat \
strncmp \
strncpy \
strsignal \
strstr \
strtok \
strtok_r \
strtol \
strtoul \
syslog \
system \
tcgetattr \
tcsetattr \
usleep \
vprintf \
vsnprintf \
vsyslog \
waitpid \
write \
], [], AC_MSG_ERROR([Required function not found]))

# Checks for optional functions.
AC_CHECK_FUNCS([pthread_mutexattr_setrobust])
# Use PKG_CHECK_MODULES compiler/linker flags
save_openssl_CPPFLAGS="${CPPFLAGS}"
save_openssl_LIBS="${LIBS}"
CPPFLAGS="${OPENSSL_CFLAGS} ${CPPFLAGS}"
LIBS="${OPENSSL_LIBS} ${LIBS}"
AC_CHECK_FUNCS([X509_check_host])
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_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=""

# prepare possibility to override default locations
AC_ARG_WITH([netstat],
        AS_HELP_STRING([--with-netstat],
                       [Set the path to the netstat executable on MacOSX 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"
	])
)
# and 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]))

# Checks for existence of specific files 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 user space client 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"
  ])
],[])
])
# replace empty settings with "no"
AS_IF([test "x$with_ppp" = "x" ], [
    with_ppp="no"
])
AS_IF([test "x$with_pppd" = "x" ], [
    with_pppd="no"
])

# when neither ppp nor pppd are enabled fall back to a sensible choice for the platform
AS_IF([test "x$with_ppp" = "xno" -a "x$with_pppd" = "xno" ], [
   AS_IF([test "x$uname" = "xFreeBSD" ], [
     PPP_PATH="/usr/sbin/ppp"
     with_ppp="yes"
   ], [
     with_pppd="yes"
     PPP_PATH="/usr/sbin/pppd"
   ])
])

# When both are enabled, give pppd the higher priority (we can only use one of them).
# Note that PPP_PATH should already be correct since pppd is detected later
# and PPP_PATH is overwritten during detection.
AS_IF([test "x$with_ppp" = "xyes" -a "x$with_pppd" = "xyes"], [
   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_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)
])

AC_CONFIG_COMMANDS([timestamp], [touch src/.dirstamp])
AC_OUTPUT(Makefile)