This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
configure.ac
409 lines (322 loc) · 14.2 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
AC_PREREQ(2.59)
AC_INIT([LibNyoci],m4_esyscmd([printf "%s" `cat .default-version`]),[https://github.com/darconeous/libnyoci/],[libnyoci],[http://libnyoci.org/])
AC_CONFIG_AUX_DIR([m4])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_LIBOBJ_DIR([src/missing/])
AC_CONFIG_SRCDIR([src/libnyoci/nyoci.c])
AC_CONFIG_HEADERS([src/config.h src/libnyoci/nyoci-config.h])
AM_INIT_AUTOMAKE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
m4_ifdef([AX_CODE_COVERAGE], [AX_CODE_COVERAGE], [AC_SUBST([CODE_COVERAGE_RULES])])
AC_GNU_SOURCE
AC_PROG_LIBTOOL
AM_MAINTAINER_MODE
LT_INIT
dnl ###########################################################################
AC_PROG_CC
AX_PTHREAD
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS([stdlib.h dlfcn.h unistd.h string.h stdio.h errno.h stdarg.h stddef.h stdint.h stdbool.h])
AC_CHECK_HEADERS([alloca.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_C_VOLATILE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
# Checks for library functions.
AC_CHECK_FUNCS([alloca memcmp memset strtol strdup strndup strlcpy strlcat stpncpy vsnprintf vsprintf snprintf getloadavg])
AC_REPLACE_FUNCS([getline])
dnl ###########################################################################
AC_DEFUN([REPLACE_MISSING_FUNC], [
AC_CHECK_FUNC($1, [], [
nl_cv_missing_$1=yes
MISSING_CPPFLAGS="${MISSING_CPPFLAGS} "'-include $(top_srcdir)/src/missing/$1/$1.h'
MISSING_LIBADD="${MISSING_LIBADD} "'$(top_builddir)/src/missing/$1/lib$1.la'
])
AM_CONDITIONAL(m4_toupper(MISSING_$1), [test "${nl_cv_missing_$1}" = "yes"])
])
AC_SUBST(MISSING_CPPFLAGS)
AC_SUBST(MISSING_LIBADD)
REPLACE_MISSING_FUNC([strlcpy])
REPLACE_MISSING_FUNC([strlcat])
dnl ###########################################################################
#-fvisibility=hidden and -fvisibility-inlines-hidden
AC_DEFUN([NY_CC_SUPPORTS_VISIBILITY], [
AC_LANG_PUSH(C)
prev_CFLAGS="${CFLAGS}"
CFLAGS="-fvisibility=hidden"
AC_MSG_CHECKING([for simple visibility declarations])
AC_TRY_COMPILE(
[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
extern __attribute__((__visibility__("default"))) int exportedvar;
extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
extern __attribute__((__visibility__("default"))) int exportedfunc (void);],
[],
[
AC_MSG_RESULT([yes])
$1
], [
AC_MSG_RESULT([no])
$2
])
CFLAGS="${prev_CFLAGS}"
unset prev_CFLAGS
AC_LANG_POP(C)
])
NY_CC_SUPPORTS_VISIBILITY([
AC_DEFINE_UNQUOTED([NYOCI_INTERNAL_EXTERN], [__attribute__((visibility("default"))) extern], [.])
AC_DEFINE_UNQUOTED([NYOCI_API_EXTERN], [__attribute__((visibility("default"))) extern], [.])
HIDDEN_VISIBILITY_CFLAGS="$CFLAGS"
])
AC_SUBST([HIDDEN_VISIBILITY_CFLAGS])
m4_ifdef([AX_GCC_FUNC_ATTRIBUTE], [
AX_GCC_FUNC_ATTRIBUTE([deprecated])
AX_GCC_FUNC_ATTRIBUTE([pure])
])
dnl ###########################################################################
dnl ## GIT VERSION INTEGRATION ################################################
SOURCE_VERSION=m4_esyscmd([
configver="$PACKAGE_VERSION"
(test -d .git && gitver=`git describe --dirty` && printf "$gitver") 2>/dev/null ||
(test -d .git && gitver=`git describe --always` && printf "$configver-g$gitver") 2>/dev/null ||
printf "$configver"
])
AC_DEFINE_UNQUOTED([SOURCE_VERSION], ["`eval echo "$SOURCE_VERSION"`"], [Source version])
dnl ###########################################################################
dnl ## PLATFORM WRAPPERS ######################################################
dnl This is the list of network platform wrappers included with
dnl LibNyoci. As platforms are added, they should be appended to
dnl this list.
m4_define(AVAILABLE_NET_PLATFORMS, [ dnl
posix dnl
uip dnl
dnl lwip
])
dnl This is the list of TLS wrappers included with LibNyoci. As
dnl others are added, they should be appended to this list.
m4_define(AVAILABLE_TLS_PLATFORMS, [ dnl
openssl dnl
])
# Set up AC_CONFIG_FILES for all of the supported net platforms
AC_CONFIG_FILES(m4_normalize(m4_foreach_w(THIS_PLATFORM,AVAILABLE_NET_PLATFORMS,[src/plat-net/[]THIS_PLATFORM/Makefile ])))
# Set up AC_CONFIG_FILES for all of the supported TLS wrappers
AC_CONFIG_FILES(m4_normalize(m4_foreach_w(THIS_PLATFORM,AVAILABLE_TLS_PLATFORMS,[src/plat-tls/[]THIS_PLATFORM/Makefile ])))
PLATFORM_SUBDIRS="[]m4_foreach_w(THIS_PLATFORM,AVAILABLE_NET_PLATFORMS,plat-net/[]THIS_PLATFORM )dnl
[]m4_foreach_w(THIS_PLATFORM,AVAILABLE_TLS_PLATFORMS,plat-tls/[]THIS_PLATFORM )"
AC_SUBST(PLATFORM_SUBDIRS)
dnl ###########################################################################
dnl ## NETWORK ADDRESS FAMILY SUPPORT #########################################
AC_ARG_WITH(address-family, AC_HELP_STRING([--with-address-family=[inet|inet6]],
[Specify address family (inet6 is the default)]), [
if test "${withval}" = "inet"
then NYOCI_PLAT_NET_POSIX_FAMILY=AF_INET
NYOCI_PLAT_NET=posix
elif test "${withval}" = "inet6"
then NYOCI_PLAT_NET_POSIX_FAMILY=AF_INET6
NYOCI_PLAT_NET=posix
else AC_MSG_ERROR(["Unknown family '${withval}'"])
fi
])
dnl ###########################################################################
dnl ## NETWORK PLATFORM SUPPORT ###############################################
NYOCI_PLAT_NET=${NYOCI_PLAT_NET-posix}
NYOCI_PLAT_NET_DIR='plat-net/$(NYOCI_PLAT_NET)'
AC_DEFINE_UNQUOTED([NYOCI_PLAT_NET],[${NYOCI_PLAT_NET}],[LibNyoci network abstraction])
AC_SUBST([NYOCI_PLAT_NET])
AC_SUBST([NYOCI_PLAT_NET_DIR])
NYOCI_CPPFLAGS+=' -I$(top_builddir)/src -I$(top_srcdir)/src -I$(top_srcdir)/src/libnyoci -I$(top_srcdir)/src/plat-net/$(NYOCI_PLAT_NET)'
dnl ###########################################################################
AC_ARG_ENABLE(singleton, AC_HELP_STRING([--enable-singleton], [Make nyoci instance a singleton)]), [
if test "${enable_singleton}" = "yes"
then NYOCI_SINGLETON=1
else NYOCI_SINGLETON=0
fi
])
dnl ###########################################################################
AC_ARG_ENABLE(embedded, AC_HELP_STRING([--enable-embedded], [enable embedded mode]), [])
if test "${enable_embedded}" = "yes"
then
NYOCI_EMBEDDED=1
enable_nyocictl=${enable_nyocictl-no}
fi
AC_CHECK_FUNCS([malloc],[],[NYOCI_AVOID_MALLOC=${NYOCI_AVOID_MALLOC-1}])
AC_CHECK_FUNCS([printf fprintf sprintf vsnprintf],[],[NYOCI_AVOID_PRINTF=${NYOCI_AVOID_PRINTF-1}])
dnl ###########################################################################
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
[enable compiling with debugging information]), [
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_g}" = "yes"); then
CFLAGS="$CFLAGS -g -DDEBUG=1"
CXXFLAGS="$CXXFLAGS -g -DDEBUG=1"
fi
if (test "${enableval}" = "verbose" &&
test "${ac_cv_prog_cc_g}" = "yes"); then
CFLAGS="$CFLAGS -g -DDEBUG=1 -DVERBOSE_DEBUG=1"
CXXFLAGS="$CXXFLAGS -g -DDEBUG=1 -DVERBOSE_DEBUG=1"
fi
])
dnl ###########################################################################
AC_ARG_ENABLE(examples, AC_HELP_STRING([--disable-examples], [Disable building examples]), [])
AM_CONDITIONAL([BUILD_EXAMPLES],test "${enable_examples}" != "no")
dnl ###########################################################################
AC_ARG_ENABLE(nyocictl, AC_HELP_STRING([--disable-nyocictl], [Disable building nyocictl]), [])
dnl Required Functions
if test "${enable_nyocictl}" != "no"
then
AC_CHECK_FUNCS([gettimeofday setenv strchr strdup strerror strndup strstr strtol printf fprintf], [], [
if test "${enable_nyocictl}" == "yes"
then AC_MSG_ERROR([Missing required functions for nyocictl])
fi
enable_nyocictl=${enable_nyocictl-no}
])
fi
AM_CONDITIONAL([BUILD_NYOCICTL],test "${enable_nyocictl}" != "no")
dnl ###########################################################################
AC_ARG_ENABLE(plugtest, AC_HELP_STRING([--disable-plugtest], [Disable building plugtest]), [])
AM_CONDITIONAL([BUILD_PLUGTEST],test "${enable_plugtest}" != "no")
dnl ###########################################################################
dnl ### LIBNYOCIEXTRA SUPPORT #################################################
AC_ARG_ENABLE(extra, AC_HELP_STRING([--disable-extra], [Disable building libnyociextra]), [])
AM_CONDITIONAL([BUILD_LIBNYOCIEXTRA],test "${enable_extra}" != "no")
dnl ###########################################################################
dnl ### TLS SUPPORT ###########################################################
unset NYOCI_PLAT_TLS
AC_ARG_ENABLE(tls, AC_HELP_STRING([--enable-tls], [Enable experimental TLS support]), [], [enable_tls=no])
if test "x${enable_tls}" != "xno"
then
if test "x${enable_tls-openssl}" == "xopenssl" -o "x${enable_tls}" == "xyes" -o "${with_openssl+set}" == "set"
then AX_CHECK_OPENSSL([
NYOCI_PLAT_TLS=openssl
AC_DEFINE_UNQUOTED([HAVE_OPENSSL],[1],[Set if OpenSSL is present])
AC_CHECK_FUNC([HMAC_CTX_new],[AC_DEFINE_UNQUOTED([HAVE_OPENSSL_HMAC_CTX_NEW],[1],[Set if OpenSSL has HMAC_CTX_new()])])
AC_CHECK_FUNC([DTLSv1_2_method],[AC_DEFINE_UNQUOTED([HAVE_OPENSSL_DTLSV1_2_METHOD],[1],[Set if OpenSSL has DTLSv1_2_method()])])
AC_CHECK_FUNC([DTLSv1_method],[AC_DEFINE_UNQUOTED([HAVE_OPENSSL_DTLSV1_METHOD],[1],[Set if OpenSSL has DTLSv1_method()])])
AC_CHECK_FUNC([DTLS_method],[AC_DEFINE_UNQUOTED([HAVE_OPENSSL_DTLS_METHOD],[1],[Set if OpenSSL has DTLS_method()])])
AC_CHECK_FUNC([SSL_CONF_CTX_new],[AC_DEFINE_UNQUOTED([HAVE_OPENSSL_SSL_CONF_CTX_NEW],[1],[Set if OpenSSL has SSL_CONF_CTX_new()])])
AC_CHECK_FUNC([SSL_CONF_finish],[AC_DEFINE_UNQUOTED([HAVE_OPENSSL_SSL_CONF_FINISH],[1],[Set if OpenSSL has SSL_CONF_finish()])])
],[
if test "x${enable_tls-openssl}" == "xopenssl" -o "${with_openssl+set}" == "set"
then AC_MSG_ERROR([Could not find usable OpenSSL])
fi
])
fi
if test "x${enable_tls+set}" == "xset" -a "x${NYOCI_PLAT_TLS+set}" != "xset"
then AC_MSG_ERROR([TLS support explicitly requested but unable to find viable TLS implementation])
fi
fi
if test "${NYOCI_PLAT_TLS+set}" == "set"
then
NYOCI_CPPFLAGS+=' -I$(top_srcdir)/src/plat-tls/$(NYOCI_PLAT_TLS)'
AC_DEFINE_UNQUOTED([NYOCI_PLAT_TLS],[${NYOCI_PLAT_TLS}],[LibNyoci TLS abstraction])
fi
AM_CONDITIONAL([NYOCI_PLAT_TLS],test "${NYOCI_PLAT_TLS+set}" == "set")
AC_SUBST([NYOCI_PLAT_TLS])
NYOCI_PLAT_TLS_DIR='plat-tls/$(NYOCI_PLAT_TLS)'
AC_SUBST([NYOCI_PLAT_TLS_DIR])
dnl ###########################################################################
HAVE_LIBREADLINE=false
AC_ARG_ENABLE(libreadline,
[ --disable-libreadline Do not use libreadline],
nyoci_check_for_libreadline="$enableval",
nyoci_check_for_libreadline=yes
)
if test x"$nyoci_check_for_libreadline" = xyes; then :
AC_CHECK_HEADER([readline/readline.h],AC_CHECK_LIB([readline], [readline]))
if test "x$ac_cv_lib_readline_readline" = xyes; then :
HAVE_LIBREADLINE=true
AC_CACHE_CHECK([libedit rl_completion_entry_function bug], rl_cv_libedit_completion_entry_bug,
tmp_CFLAGS="${CFLAGS}"
CFLAGS+=" -Werror"
AC_TRY_COMPILE(
[
#include <stdio.h>
#include <readline/readline.h>
],
[
const char *res = (*rl_completion_entry_function)(0,0);
],
[rl_cv_libedit_completion_entry_bug=no],
[
rl_cv_libedit_completion_entry_bug=yes
AC_DEFINE_UNQUOTED([HAS_LIBEDIT_COMPLETION_ENTRY_BUG], [1],
[rl_completion_entry_function has the wrong return type])
],
)
)
CFLAGS="${tmp_CFLAGS}"
fi
fi
AM_CONDITIONAL([HAVE_LIBREADLINE],$HAVE_LIBREADLINE)
AC_CHECK_FUNCS([rl_set_prompt])
dnl ###########################################################################
AC_SUBST([NYOCI_CPPFLAGS])
if test "${NYOCI_EMBEDDED+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_EMBEDDED], [$NYOCI_EMBEDDED], [.])
fi
if test "${NYOCI_SINGLETON+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_SINGLETON], [$NYOCI_SINGLETON], [.])
fi
if test "${NYOCI_PLAT_NET_POSIX_FAMILY+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_PLAT_NET_POSIX_FAMILY], [$NYOCI_PLAT_NET_POSIX_FAMILY], [.])
fi
if test "${NYOCI_AVOID_MALLOC+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_AVOID_MALLOC], [$NYOCI_AVOID_MALLOC], [.])
fi
if test "${NYOCI_AVOID_PRINTF+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_AVOID_PRINTF], [$NYOCI_AVOID_PRINTF], [.])
fi
if test "${NYOCI_MAX_VHOSTS+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_MAX_VHOSTS], [$NYOCI_MAX_VHOSTS], [.])
fi
if test "${NYOCI_CONF_TRANS_ENABLE_BLOCK2+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_CONF_TRANS_ENABLE_BLOCK2], [$NYOCI_CONF_TRANS_ENABLE_BLOCK2], [.])
fi
if test "${NYOCI_CONF_TRANS_ENABLE_OBSERVING+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_CONF_TRANS_ENABLE_OBSERVING], [$NYOCI_CONF_TRANS_ENABLE_OBSERVING], [.])
fi
if test "${NYOCI_MAX_OBSERVERS+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_MAX_OBSERVERS], [$NYOCI_MAX_OBSERVERS], [.])
fi
if test "${NYOCI_CONF_NODE_ROUTER+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_CONF_NODE_ROUTER], [$NYOCI_CONF_NODE_ROUTER], [.])
fi
if test "${NYOCI_USE_CASCADE_COUNT+set}" = "set"
then AC_DEFINE_UNQUOTED([NYOCI_USE_CASCADE_COUNT], [$NYOCI_USE_CASCADE_COUNT], [.])
fi
dnl ###########################################################################
AC_CONFIG_FILES(
Makefile
doxygen.cfg
src/Makefile
doc/Makefile
src/libnyoci/Makefile
src/libnyoci/libnyoci.pc
src/libnyociextra/Makefile
src/libnyociextra/libnyociextra.pc
src/plugtest/Makefile
src/nyocictl/Makefile
src/examples/Makefile
src/tests/Makefile
src/missing/Makefile
src/missing/strlcat/Makefile
src/missing/strlcpy/Makefile
)
AC_OUTPUT
echo ""
echo "= Summary ====================================================================="
echo ""
echo "Network Platform ............... ${NYOCI_PLAT_NET-none}"
echo "DTLS Support ................... ${NYOCI_PLAT_TLS-none}"
echo "Embedded mode .................. ${enable_embedded-no}"
echo "Singleton instance ............. ${enable_singleton-${enable_embedded-no}}"
echo ""
echo "Building nyocictl .............. ${enable_nyocictl-yes}"
echo "Building libnyociextra ......... ${enable_libnyociextra-yes}"
echo "Building examples .............. ${enable_examples-yes}"
echo "Building plugtest .............. ${enable_plugtest-yes}"
echo ""
$HAVE_LIBREADLINE ||
echo "warning: libreadline was disabled or not found, interactive nyocictl command line interface will not be enabled."