You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.8 KiB
139 lines
3.8 KiB
AC_INIT([utun],[2.0.0],[https://github.com/anomalyco/utun3/issues]) |
|
AC_CONFIG_SRCDIR([src/utun.c]) |
|
AC_CONFIG_HEADERS([config.h]) |
|
AC_CONFIG_AUX_DIR([build-aux]) |
|
AC_CONFIG_MACRO_DIR([m4]) |
|
|
|
# Required programs |
|
AC_PROG_CC |
|
AC_PROG_RANLIB |
|
AM_PROG_AR |
|
AM_INIT_AUTOMAKE([foreign subdir-objects -Wall]) |
|
|
|
# Checks for programs |
|
AC_PROG_INSTALL |
|
AC_PROG_MAKE_SET |
|
|
|
# Option to use OpenSSL instead of TinyCrypt for secure_channel |
|
AC_ARG_WITH([openssl], |
|
AS_HELP_STRING([--with-openssl], [Use OpenSSL for cryptography (default: yes)]), |
|
[with_openssl=$withval], |
|
[with_openssl=yes]) |
|
|
|
if test "x$with_openssl" = "xyes"; then |
|
# For Windows cross-compilation, check MSYS2 paths |
|
case "$host" in |
|
*mingw* | *msys* | *cygwin* | *win*) |
|
# Try MSYS2 UCRT64 paths |
|
if test -d "/c/msys64/ucrt64/include/openssl"; then |
|
OPENSSL_CFLAGS="-I/c/msys64/ucrt64/include" |
|
OPENSSL_LIBS="-L/c/msys64/ucrt64/lib -lcrypto" |
|
CFLAGS="$CFLAGS $OPENSSL_CFLAGS" |
|
LDFLAGS="$LDFLAGS $OPENSSL_LIBS" |
|
AC_MSG_NOTICE([Using MSYS2 UCRT64 OpenSSL: /c/msys64/ucrt64]) |
|
elif test -d "/ucrt64/include/openssl"; then |
|
OPENSSL_CFLAGS="-I/ucrt64/include" |
|
OPENSSL_LIBS="-L/ucrt64/lib -lcrypto" |
|
CFLAGS="$CFLAGS $OPENSSL_CFLAGS" |
|
LDFLAGS="$LDFLAGS $OPENSSL_LIBS" |
|
AC_MSG_NOTICE([Using MSYS2 UCRT64 OpenSSL: /ucrt64]) |
|
elif test -d "/mingw64/include/openssl"; then |
|
OPENSSL_CFLAGS="-I/mingw64/include" |
|
OPENSSL_LIBS="-L/mingw64/lib -lcrypto" |
|
CFLAGS="$CFLAGS $OPENSSL_CFLAGS" |
|
LDFLAGS="$LDFLAGS $OPENSSL_LIBS" |
|
AC_MSG_NOTICE([Using MSYS2 MINGW64 OpenSSL: /mingw64]) |
|
fi |
|
;; |
|
esac |
|
|
|
# Save original LIBS |
|
save_LIBS="$LIBS" |
|
# Add crypto library to LIBS for the check |
|
LIBS="-lcrypto $LIBS" |
|
|
|
AC_CHECK_LIB([crypto], [SHA256_Init], |
|
[ |
|
AC_DEFINE([USE_OPENSSL], [1], [Define to use OpenSSL for cryptography]) |
|
], |
|
[ |
|
AC_MSG_ERROR([OpenSSL crypto library required. Use --without-openssl to use TinyCrypt instead.]) |
|
]) |
|
|
|
# Restore LIBS (the actual linking will use the flags we set) |
|
LIBS="$save_LIBS" |
|
fi |
|
|
|
AM_CONDITIONAL([USE_OPENSSL], [test "x$with_openssl" = "xyes"]) |
|
|
|
# Detect Windows for TUN implementation |
|
AC_MSG_CHECKING([for Windows]) |
|
case $host_os in |
|
*mingw* | *msys* | *cygwin* | *win*) |
|
os_windows=yes |
|
;; |
|
*) |
|
# Also check $host for cross-compilation case |
|
case $host in |
|
*mingw* | *msys* | *cygwin* | *win*) |
|
os_windows=yes |
|
;; |
|
*) |
|
os_windows=no |
|
;; |
|
esac |
|
;; |
|
esac |
|
AC_MSG_RESULT([$os_windows]) |
|
AM_CONDITIONAL([OS_WINDOWS], [test "x$os_windows" = "xyes"]) |
|
|
|
# Checks for header files |
|
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h]) |
|
|
|
# Checks for typedefs, structures, and compiler characteristics |
|
AC_TYPE_SIZE_T |
|
AC_TYPE_SSIZE_T |
|
AC_TYPE_UINT16_T |
|
AC_TYPE_UINT32_T |
|
AC_TYPE_UINT64_T |
|
AC_TYPE_UINT8_T |
|
AC_C_INLINE |
|
|
|
# Checks for library functions |
|
AC_FUNC_MALLOC |
|
AC_CHECK_FUNCS([gettimeofday memset socket strchr strdup strerror strstr]) |
|
|
|
# Check for TUN/TAP support |
|
AC_MSG_CHECKING([for TUN/TAP support]) |
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
|
#include <linux/if_tun.h> |
|
]], [[ |
|
int fd = open("/dev/net/tun", O_RDWR); |
|
]])], [ |
|
AC_MSG_RESULT([yes]) |
|
AC_DEFINE([HAVE_TUN_TAP], [1], [Define if TUN/TAP is available]) |
|
], [ |
|
AC_MSG_RESULT([no]) |
|
]) |
|
|
|
# Output files |
|
AC_CONFIG_FILES([ |
|
Makefile |
|
src/Makefile |
|
tests/Makefile |
|
lib/Makefile |
|
]) |
|
|
|
AC_OUTPUT |
|
|
|
# Summary |
|
echo " |
|
Configuration summary: |
|
---------------------- |
|
Prefix: ${prefix} |
|
Compiler: ${CC} |
|
CFLAGS: ${CFLAGS} |
|
|
|
Features: |
|
TUN/TAP: ${have_tun_tap} |
|
"
|
|
|