configure.ac 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. AC_PREREQ(2.69)
  2. AC_INIT([ptunnel-ng], [1.0.0], [], [], [])
  3. AC_CONFIG_SRCDIR([src/config.h.in])
  4. AC_CONFIG_FILES([Makefile src/Makefile])
  5. AC_CANONICAL_BUILD
  6. AC_CANONICAL_HOST
  7. if test x"$cross_compiling" != x"no"; then
  8. HOST_PREFIX="${host_alias}-"
  9. HOST_SUFFIX="-$host_alias"
  10. if test x"${build_alias}" = x; then
  11. AC_MSG_ERROR([Cross compile enabled but no --build *explicitly* specified. For example: --build=$(gcc -dumpmachine)])
  12. fi
  13. else
  14. HOST_PREFIX=
  15. HOST_SUFFIX=
  16. fi
  17. case x"${host}" in
  18. x*-*-cygwin* | x*-*-mingw32*)
  19. dnl Some Windows includes required by third-party modules.
  20. use_msw=yes
  21. PROGRAM_EXT=".exe"
  22. ;;
  23. esac
  24. AM_SILENT_RULES([yes])
  25. AM_INIT_AUTOMAKE
  26. AC_PROG_INSTALL
  27. AC_C_CONST
  28. AC_C_INLINE
  29. AC_TYPE_SIZE_T
  30. AC_CHECK_HEADER_STDBOOL
  31. AC_FUNC_VPRINTF
  32. AC_FUNC_MEMCMP
  33. dnl Check for std includes.
  34. AC_CHECK_HEADERS([stdarg.h stdio.h unistd.h stdlib.h string.h stdint.h time.h signal.h assert.h],,
  35. [AC_MSG_ERROR([Missing essential std headers.])])
  36. if test x"${use_msw}" != x"yes"; then
  37. AC_CHECK_HEADERS([sys/unistd.h sys/types.h sys/socket.h netinet/in.h arpa/inet.h netdb.h pthread.h errno.h net/ethernet.h syslog.h pwd.h grp.h],,
  38. [AC_MSG_ERROR([Missing essential non-Windows std headers.])])
  39. AC_SEARCH_LIBS([pthread_create], [pthread],,
  40. [AC_MSG_ERROR([Missing pthread library.])],)
  41. AC_CHECK_FUNCS([pthread_mutex_init pthread_mutex_lock pthread_mutex_unlock],,
  42. [AC_MSG_ERROR([Missing essential pthread functions.])])
  43. else
  44. AC_CHECK_HEADERS([winsock2.h windows.h ws2tcpip.h],,
  45. [AC_MSG_ERROR([Missing essential Windows std headers.])])
  46. fi
  47. dnl Check timeval struct members.
  48. AC_CHECK_MEMBER([struct timeval.tv_sec], [],
  49. [AC_MSG_ERROR([Invalid \`struct timeval\` structure.])],
  50. [[#include <sys/time.h>]])
  51. AC_CHECK_MEMBER([struct timeval.tv_usec], [],
  52. [AC_MSG_ERROR([Invalid \`struct timeval\` structure.])],
  53. [[#include <sys/time.h>]])
  54. dnl Check size
  55. AC_CHECK_SIZEOF(char)
  56. AC_CHECK_SIZEOF(uint8_t)
  57. AC_CHECK_SIZEOF(uint16_t)
  58. AC_CHECK_SIZEOF(uint32_t)
  59. AC_CHECK_SIZEOF(int)
  60. if test $ac_cv_sizeof_char != "1" -o \
  61. $ac_cv_sizeof_uint8_t != "1" -o \
  62. $ac_cv_sizeof_uint16_t != "2" -o \
  63. $ac_cv_sizeof_uint32_t != "4" -o \
  64. $ac_cv_sizeof_int != "4"; then
  65. AC_MSG_ERROR([Invalid type size.])
  66. fi
  67. AC_MSG_CHECKING([for __attribute__ ((packed))])
  68. AC_COMPILE_IFELSE(
  69. [AC_LANG_PROGRAM([[
  70. #include <stdlib.h>
  71. struct foo {
  72. int num;
  73. char *str;
  74. void *ptr;
  75. } __attribute__ ((packed));
  76. ]], [])]
  77. ,[AC_MSG_RESULT([yes])]
  78. ,[AC_MSG_ERROR([Your compiler does not support \`__attribute__ ((packed))\`.])])
  79. dnl Check for std functions.
  80. AC_CHECK_FUNCS([malloc calloc free memcpy memset signal printf sprintf vsnprintf strerror strlen strncmp strstr strtol strtoul fopen fprintf gettimeofday close fclose exit],,
  81. [AC_MSG_ERROR([Missing essential std functions.])])
  82. dnl `--disable-pcap`: Enabled if found.
  83. AC_ARG_ENABLE([pcap],
  84. [AS_HELP_STRING([--disable-pcap], [Disable pcap support. (default: enabled if found)])],,[pcap_enabled=yes])
  85. pcap_enabled=$(echo ${pcap_enabled})
  86. case ${pcap_enabled} in
  87. 1|y|yes) pcap_enabled=yes ;;
  88. ''|0|n|no) pcap_enabled= ;;
  89. *) AC_MSG_ERROR([Unknown option \`${pcap_enabled}\` for --disable-pcap]) ;;
  90. esac
  91. dnl `--disable-selinux`: Enabled if found.
  92. AC_ARG_ENABLE([selinux],
  93. [AS_HELP_STRING([--disable-selinux], [Disable SELINUX support. (default: enabled if found)])],,[selinux_enabled=yes])
  94. selinux_enabled=$(echo ${selinux_enabled})
  95. case ${selinux_enabled} in
  96. 1|y|yes) selinux_enabled=yes ;;
  97. ''|0|n|no) selinux_enabled= ;;
  98. *) AC_MSG_ERROR([Unknown option \`${selinux_enabled}\` for --disable-selinux]) ;;
  99. esac
  100. dnl Check libcap headers/functions.
  101. if test x"${pcap_enabled}" != x; then
  102. AC_CHECK_HEADERS([pcap.h],,
  103. [pcap_enabled=])
  104. AC_SEARCH_LIBS([pcap_lookupnet], [pcap],,
  105. [pcap_enabled=],)
  106. AC_CHECK_FUNCS([pcap_compile pcap_close pcap_setfilter pcap_dispatch],,
  107. [pcap_enabled=])
  108. fi
  109. dnl Check for SELINUX
  110. if test x"${selinux_enabled}" != x; then
  111. AC_CHECK_HEADERS([selinux/selinux.h],,
  112. [selinux_enabled=])
  113. AC_SEARCH_LIBS([setcon], [selinux],,[selinux_enabled=],)
  114. fi
  115. dnl Set automake conf vars
  116. AM_CONDITIONAL([HAVE_PCAP], [test x"${pcap_enabled}" = xyes])
  117. AM_CONDITIONAL([HAVE_SELINUX], [test x"${selinux_enabled}" = xyes])
  118. dnl output config headers
  119. AC_CONFIG_HEADERS([src/config.h:src/config.h.in])
  120. AC_OUTPUT