configure.ac 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_PREREQ(2.61)
  3. AC_INIT([tinc], [1.0.24])
  4. AC_CONFIG_SRCDIR([src/tincd.c])
  5. AM_INIT_AUTOMAKE([1.11 check-news std-options subdir-objects nostdinc -Wall])
  6. AC_CONFIG_HEADERS([config.h])
  7. AM_MAINTAINER_MODE
  8. # Enable GNU extensions.
  9. # Define this here, not in acconfig's @TOP@ section, since definitions
  10. # in the latter don't make it into the configure-time tests.
  11. AC_GNU_SOURCE
  12. AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions])
  13. dnl Checks for programs.
  14. AC_PROG_CC_C99
  15. AC_PROG_CPP
  16. AC_PROG_INSTALL
  17. dnl Check and set OS
  18. AC_CANONICAL_HOST
  19. case $host_os in
  20. *linux*)
  21. linux=true
  22. AC_DEFINE(HAVE_LINUX, 1, [Linux])
  23. ;;
  24. *freebsd*)
  25. bsd=true
  26. AC_DEFINE(HAVE_FREEBSD, 1, [FreeBSD])
  27. ;;
  28. *darwin*)
  29. bsd=true
  30. AC_DEFINE(HAVE_DARWIN, 1, [Darwin (MacOS/X)])
  31. ;;
  32. *solaris*)
  33. solaris=true
  34. AC_DEFINE(HAVE_SOLARIS, 1, [Solaris/SunOS])
  35. ;;
  36. *openbsd*)
  37. bsd=true
  38. AC_DEFINE(HAVE_OPENBSD, 1, [OpenBSD])
  39. ;;
  40. *netbsd*)
  41. bsd=true
  42. AC_DEFINE(HAVE_NETBSD, 1, [NetBSD])
  43. ;;
  44. *dragonfly*)
  45. bsd=true
  46. AC_DEFINE(HAVE_DRAGONFLY, 1, [DragonFly])
  47. ;;
  48. *bsd*)
  49. bsd=true
  50. AC_MSG_WARN("Unknown BSD variant, tinc might not compile or work!")
  51. AC_DEFINE(HAVE_BSD, 1, [Unknown BSD variant])
  52. ;;
  53. *cygwin*)
  54. cygwin=true
  55. AC_DEFINE(HAVE_CYGWIN, 1, [Cygwin])
  56. ;;
  57. *mingw*)
  58. mingw=true
  59. AC_DEFINE(HAVE_MINGW, 1, [MinGW])
  60. LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32"
  61. ;;
  62. *)
  63. AC_MSG_ERROR("Unknown operating system.")
  64. ;;
  65. esac
  66. AC_ARG_ENABLE(uml,
  67. AS_HELP_STRING([--enable-uml], [enable support for User Mode Linux]),
  68. [ AS_IF([test "x$enable_uml" = "xyes"],
  69. [ AC_DEFINE(ENABLE_UML, 1, [Support for UML])
  70. uml=true
  71. ],
  72. [uml=false])
  73. ],
  74. [uml=false]
  75. )
  76. AC_ARG_ENABLE(vde,
  77. AS_HELP_STRING([--enable-vde], [enable support for Virtual Distributed Ethernet]),
  78. [ AS_IF([test "x$enable_vde" = "xyes"],
  79. [ AC_CHECK_HEADERS(libvdeplug_dyn.h, [], [AC_MSG_ERROR([VDE plug header files not found.]); break])
  80. AC_DEFINE(ENABLE_VDE, 1, [Support for VDE])
  81. vde=true
  82. ],
  83. [vde=false])
  84. ],
  85. [vde=false]
  86. )
  87. AC_ARG_ENABLE(tunemu,
  88. AS_HELP_STRING([--enable-tunemu], [enable support for the tunemu driver]),
  89. [ AS_IF([test "x$enable_tunemu" = "xyes"],
  90. [ AC_DEFINE(ENABLE_TUNEMU, 1, [Support for tunemu])
  91. tunemu=true
  92. ],
  93. [tunemu=false])
  94. ],
  95. [tunemu=false]
  96. )
  97. AC_ARG_WITH(windows2000,
  98. AS_HELP_STRING([--with-windows2000], [compile with support for Windows 2000. This disables support for tunneling over existing IPv6 networks.]),
  99. [ AS_IF([test "x$with_windows2000" = "xyes"],
  100. [AC_DEFINE(WITH_WINDOWS2000, 1, [Compile with support for Windows 2000])])
  101. ]
  102. )
  103. AM_CONDITIONAL(LINUX, test "$linux" = true)
  104. AM_CONDITIONAL(BSD, test "$bsd" = true)
  105. AM_CONDITIONAL(SOLARIS, test "$solaris" = true)
  106. AM_CONDITIONAL(MINGW, test "$mingw" = true)
  107. AM_CONDITIONAL(CYGWIN, test "$cygwin" = true)
  108. AM_CONDITIONAL(UML, test "$uml" = true)
  109. AM_CONDITIONAL(VDE, test "$vde" = true)
  110. AM_CONDITIONAL(TUNEMU, test "$tunemu" = true)
  111. AC_CACHE_SAVE
  112. if test -d /sw/include ; then
  113. CPPFLAGS="$CPPFLAGS -I/sw/include"
  114. fi
  115. if test -d /sw/lib ; then
  116. LIBS="$LIBS -L/sw/lib"
  117. fi
  118. dnl Compiler hardening flags
  119. dnl No -fstack-protector-all because it doesn't work on all platforms or architectures.
  120. AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags]))
  121. AS_IF([test "x$enable_hardening" != "xno"],
  122. [AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"])
  123. AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])
  124. AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"])
  125. case $host_os in
  126. *mingw*)
  127. AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
  128. AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
  129. ;;
  130. *)
  131. AX_CHECK_COMPILE_FLAG([-fPIE], [CPPFLAGS="$CPPFLAGS -fPIE"])
  132. AX_CHECK_LINK_FLAG([-pie], [LDFLAGS="$LDFLAGS -pie"])
  133. ;;
  134. esac
  135. AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
  136. AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
  137. ]
  138. );
  139. dnl Checks for libraries.
  140. dnl Checks for header files.
  141. dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
  142. AC_HEADER_STDC
  143. AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h arpa/nameser.h dirent.h])
  144. AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h netpacket/packet.h],
  145. [], [], [#include "src/have.h"]
  146. )
  147. AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h resolv.h],
  148. [], [], [#include "src/have.h"]
  149. )
  150. AC_CHECK_HEADERS([netinet/tcp.h netinet/ip_icmp.h netinet/icmp6.h],
  151. [], [], [#include "src/have.h"]
  152. )
  153. dnl Checks for typedefs, structures, and compiler characteristics.
  154. AC_C_CONST
  155. AC_C_VOLATILE
  156. AC_TYPE_PID_T
  157. AC_TYPE_SIZE_T
  158. AC_HEADER_TIME
  159. AC_STRUCT_TM
  160. tinc_ATTRIBUTE(__malloc__)
  161. AC_CHECK_TYPES([socklen_t, struct ether_header, struct arphdr, struct ether_arp, struct in_addr, struct addrinfo, struct ip, struct icmp, struct in6_addr, struct sockaddr_in6, struct ip6_hdr, struct icmp6_hdr, struct nd_neighbor_solicit, struct nd_opt_hdr], , ,
  162. [#include "src/have.h"]
  163. )
  164. dnl Checks for library functions.
  165. AC_TYPE_SIGNAL
  166. AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall pselect putenv random select strdup strerror strsignal strtol system unsetenv usleep vsyslog writev],
  167. [], [], [#include "src/have.h"]
  168. )
  169. dnl Support for SunOS
  170. AC_CHECK_FUNC(socket, [], [
  171. AC_CHECK_LIB(socket, connect)
  172. ])
  173. AC_CHECK_FUNC(gethostbyname, [], [
  174. AC_CHECK_LIB(nsl, gethostbyname)
  175. ])
  176. AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
  177. [], [], [#include "src/have.h"]
  178. )
  179. AC_CHECK_DECLS([res_init], [], [], [
  180. #include <netinet/in.h>
  181. #include <resolv.h>
  182. ])
  183. AC_CACHE_SAVE
  184. dnl These are defined in files in m4/
  185. tinc_ZLIB
  186. tinc_LZO
  187. tinc_OPENSSL
  188. dnl Check if support for jumbograms is requested
  189. AC_ARG_ENABLE(jumbograms,
  190. AS_HELP_STRING([--enable-jumbograms], [enable support for jumbograms (packets up to 9000 bytes)]),
  191. [ AS_IF([test "x$enable_jumbograms" = "xyes"],
  192. [ AC_DEFINE(ENABLE_JUMBOGRAMS, 1, [Support for jumbograms (packets up to 9000 bytes)]) ])
  193. ]
  194. )
  195. AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile])
  196. AC_OUTPUT