configure.ac 7.8 KB

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