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.
124 lines
3.7 KiB
124 lines
3.7 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]) |
|
|
|
# === ОБЯЗАТЕЛЬНО для правильного определения host === |
|
AC_CANONICAL_HOST |
|
AC_CANONICAL_BUILD |
|
|
|
# Required programs |
|
AC_PROG_CC |
|
AC_PROG_RANLIB |
|
AM_PROG_AR |
|
AM_INIT_AUTOMAKE([foreign subdir-objects -Wall]) |
|
|
|
AC_PROG_INSTALL |
|
AC_PROG_MAKE_SET |
|
|
|
# Option to use OpenSSL |
|
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 |
|
# MSYS2 OpenSSL paths (для Windows) |
|
case "$host" in |
|
*mingw* | *msys* | *cygwin* | *win*) |
|
if test -d "/c/msys64/ucrt64/include/openssl"; then |
|
OPENSSL_CFLAGS="-I/c/msys64/ucrt64/include" |
|
OPENSSL_LIBS="-L/c/msys64/ucrt64/lib -lcrypto" |
|
AC_MSG_NOTICE([Using MSYS2 UCRT64 OpenSSL]) |
|
elif test -d "/ucrt64/include/openssl"; then |
|
OPENSSL_CFLAGS="-I/ucrt64/include" |
|
OPENSSL_LIBS="-L/ucrt64/lib -lcrypto" |
|
AC_MSG_NOTICE([Using MSYS2 UCRT64 OpenSSL]) |
|
elif test -d "/mingw64/include/openssl"; then |
|
OPENSSL_CFLAGS="-I/mingw64/include" |
|
OPENSSL_LIBS="-L/mingw64/lib -lcrypto" |
|
AC_MSG_NOTICE([Using MSYS2 MINGW64 OpenSSL]) |
|
fi |
|
CFLAGS="$CFLAGS $OPENSSL_CFLAGS" |
|
LDFLAGS="$LDFLAGS $OPENSSL_LIBS" |
|
;; |
|
esac |
|
|
|
save_LIBS="$LIBS" |
|
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.])]) |
|
LIBS="$save_LIBS" |
|
fi |
|
|
|
AM_CONDITIONAL([USE_OPENSSL], [test "x$with_openssl" = "xyes"]) |
|
|
|
# ==================== НАДЁЖНЫЙ ДЕТЕКТ WINDOWS ==================== |
|
AC_MSG_CHECKING([for Windows]) |
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
|
#ifndef _WIN32 |
|
#error "Not Windows" |
|
#endif |
|
]], [[ return 0; ]])], |
|
[os_windows=yes], |
|
[os_windows=no]) |
|
AC_MSG_RESULT([$os_windows]) |
|
|
|
AM_CONDITIONAL([OS_WINDOWS], [test "x$os_windows" = "xyes"]) |
|
|
|
# ==================== DETECT FREEBSD ==================== |
|
AC_MSG_CHECKING([for FreeBSD]) |
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ |
|
#ifndef __FreeBSD__ |
|
#error "Not FreeBSD" |
|
#endif |
|
]], [[ return 0; ]])], |
|
[os_freebsd=yes], |
|
[os_freebsd=no]) |
|
AC_MSG_RESULT([$os_freebsd]) |
|
|
|
AM_CONDITIONAL([OS_FREEBSD], [test "x$os_freebsd" = "xyes"]) |
|
|
|
# Set TUN libs based on platform |
|
if test "x$os_windows" = "xyes"; then |
|
TUN_LIBS="-liphlpapi -lws2_32 -ladvapi32 -lbcrypt -ldbghelp" |
|
else |
|
TUN_LIBS="" |
|
fi |
|
AC_SUBST([TUN_LIBS]) |
|
|
|
# Checks for header files, typedefs, functions... |
|
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]) |
|
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 |
|
|
|
AC_FUNC_MALLOC |
|
AC_CHECK_FUNCS([gettimeofday memset socket strchr strdup strerror strstr]) |
|
|
|
# TUN/TAP (только для Linux) |
|
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 |
|
AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile lib/Makefile]) |
|
AC_OUTPUT |
|
|
|
# Summary |
|
echo " |
|
Configuration summary: |
|
---------------------- |
|
Host: ${host} |
|
Windows: ${os_windows} |
|
Prefix: ${prefix} |
|
Compiler: ${CC} |
|
CFLAGS: ${CFLAGS} |
|
" |