configure.ac 6.9 KB

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