configure.ac 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485
  1. AC_INIT([openconnect], [9.01])
  2. AC_LANG([C])
  3. AC_CONFIG_HEADERS([config.h])
  4. m4_ifdef([AC_CONFIG_MACRO_DIRS], [AC_CONFIG_MACRO_DIRS([m4])])
  5. PKG_PROG_PKG_CONFIG
  6. AC_CANONICAL_HOST
  7. AM_MAINTAINER_MODE([enable])
  8. AM_INIT_AUTOMAKE([foreign tar-ustar subdir-objects])
  9. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  10. AC_PREREQ([2.62])
  11. # Upstream's pkg.m4 (since 0.27) offers this now, but define our own
  12. # compatible version in case the local version of pkgconfig isn't new enough.
  13. # https://bugs.freedesktop.org/show_bug.cgi?id=48743
  14. m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
  15. [AC_ARG_WITH([pkgconfigdir],
  16. [AS_HELP_STRING([--with-pkgconfigdir],
  17. [install directory for openconnect.pc pkg-config file])],
  18. [],[with_pkgconfigdir='$(libdir)/pkgconfig'])
  19. AC_SUBST([pkgconfigdir], [${with_pkgconfigdir}])])
  20. use_openbsd_libtool=
  21. symver_time=
  22. symver_getline=
  23. symver_asprintf=
  24. symver_vasprintf=
  25. symver_win32_strerror=
  26. symver_win32_setenv=
  27. # Autoconf is stupid and if the first time it needs to find the C compiler
  28. # is conditional (as it is here for some of the MinGW checks), it forgets
  29. # to ever look for one in the other code paths. Do it explicitly here.
  30. AC_PROG_CC
  31. # Before autoconf 2.70, AC_PROG_CC_C99 appears to be necessary for some
  32. # compilers if you want C99 support. Starting with 2.70, it is obsolete.
  33. m4_version_prereq([2.70], [:], [AC_PROG_CC_C99])
  34. default_browser=xdg-open
  35. have_vhost=no
  36. case $host_os in
  37. *linux* | *gnu* | *nacl*)
  38. have_vhost=yes
  39. AC_MSG_NOTICE([Applying feature macros for GNU build])
  40. AC_DEFINE(_GNU_SOURCE, 1, [_GNU_SOURCE])
  41. ;;
  42. *netbsd*)
  43. AC_MSG_NOTICE([Applying feature macros for NetBSD build])
  44. AC_DEFINE(_POSIX_C_SOURCE, 200112L, [_POSIX_C_SOURCE])
  45. AC_DEFINE(_NETBSD_SOURCE, 1, [_NETBSD_SOURCE])
  46. ;;
  47. *openbsd*)
  48. AC_MSG_NOTICE([Applying feature macros for OpenBSD build])
  49. use_openbsd_libtool=true
  50. ;;
  51. *solaris*|*sunos*)
  52. AC_MSG_NOTICE([Applying workaround for broken SunOS time() function])
  53. AC_DEFINE(HAVE_SUNOS_BROKEN_TIME, 1, [On SunOS time() can go backwards])
  54. symver_time="openconnect__time;"
  55. ;;
  56. *mingw32*|*mingw64*|*msys*)
  57. AC_MSG_NOTICE([Applying feature macros for MinGW/Windows build])
  58. # For GetVolumeInformationByHandleW() which is Vista+
  59. AC_DEFINE(_WIN32_WINNT, 0x600, [Windows API version])
  60. have_win=yes
  61. # For asprintf()
  62. AC_DEFINE(_GNU_SOURCE, 1, [_GNU_SOURCE])
  63. symver_win32_strerror="openconnect__win32_strerror;"
  64. symver_win32_setenv="openconnect__win32_setenv;"
  65. # Win32 does have the SCard API
  66. system_pcsc_libs="-lwinscard"
  67. system_pcsc_cflags=
  68. AC_CHECK_TOOL([WINDRES], [windres], [])
  69. AC_CHECK_TOOL([MAKENSIS], [makensis], [])
  70. default_browser=
  71. case $host_cpu in
  72. x86_64|amd64)
  73. wintun_arch=amd64
  74. ;;
  75. *86)
  76. wintun_arch=x86
  77. ;;
  78. aarch64|arm64)
  79. wintun_arch=arm64
  80. ;;
  81. arm*)
  82. wintun_arch=arm
  83. ;;
  84. esac
  85. AC_SUBST(WINTUN_ARCH, "$wintun_arch")
  86. # Per https://github.com/MisterDA/ocaml/commit/5855ce5ffd931a2802d5b9a5b2987ab0b276fd0a,
  87. # "The header file <afunix.h> declares the `struct sockaddr_un` type, but hasn't been picked by mingw-w64."
  88. AC_CHECK_HEADER([afunix.h], AC_DEFINE([HAVE_AF_UNIX_H], 1, [MinGW has afunix.h]))
  89. # MINGW_HAS_SECURE_API may only work on newer MinGW:
  90. # https://stackoverflow.com/a/51977723
  91. AC_DEFINE(MINGW_HAS_SECURE_API, 1, [Try to make getenv_s and _putenv_s available])
  92. AC_CHECK_DECL(_putenv_s, [AC_DEFINE(HAVE_PUTENV_S_DECL, 1, [MinGW declares _putenv_s])], [], [#include <sec_api/stdlib_s.h>])
  93. AC_CHECK_DECL(getenv_s, [AC_DEFINE(HAVE_GETENV_S_DECL, 1, [MinGW declares getenv_s])], [], [#include <sec_api/stdlib_s.h>])
  94. ;;
  95. *darwin*)
  96. system_pcsc_libs="-Wl,-framework -Wl,PCSC"
  97. system_pcsc_cflags=
  98. default_browser=open
  99. ;;
  100. *)
  101. # On FreeBSD the only way to get vsyslog() visible is to define
  102. # *nothing*, which makes absolutely everything visible.
  103. # On Darwin enabling _POSIX_C_SOURCE breaks <sys/mount.h> because
  104. # u_long and other types don't get defined. OpenBSD is similar.
  105. ;;
  106. esac
  107. AM_CONDITIONAL(OPENCONNECT_WIN32, [ test "$have_win" = "yes" ])
  108. build_nsis=no
  109. if test "${MAKENSIS}" != ""; then
  110. AC_CHECK_PROG(have_curl, curl, yes)
  111. if test "${have_curl}" = "yes"; then
  112. build_nsis=yes
  113. if test "${wintun_arch}" != ""; then
  114. AC_CHECK_PROG(have_unzip, unzip, yes)
  115. if test "${have_unzip}" != "yes"; then
  116. wintun_arch=
  117. fi
  118. fi
  119. fi
  120. fi
  121. AM_CONDITIONAL(BUILD_NSIS, [ test "$build_nsis" = "yes" ])
  122. AM_CONDITIONAL(OPENCONNECT_WINTUN, [ test "${wintun_arch}" != "" ])
  123. AC_ARG_WITH([external-browser],
  124. [AS_HELP_STRING([--with-external-browser],
  125. [command to use for spawning external web browser])])
  126. if test "$with_external_browser" = "yes" || test "$with_external_browser" = ""; then
  127. if test "$default_browser" != ""; then
  128. AC_MSG_CHECKING([for ${default_browser}])
  129. AC_PATH_PROG(with_external_browser, ${default_browser}, no)
  130. else
  131. with_external_browser=no
  132. fi
  133. fi
  134. if test "$with_external_browser" != "no"; then
  135. if test -x "${with_external_browser}"; then
  136. AC_DEFINE_UNQUOTED(DEFAULT_EXTERNAL_BROWSER, "${with_external_browser}", [External browser executable])
  137. else
  138. AC_MSG_ERROR([${with_external_browser} does not seem to be executable.])
  139. fi
  140. fi
  141. AC_ARG_WITH([vpnc-script],
  142. [AS_HELP_STRING([--with-vpnc-script],
  143. [default location of vpnc-script helper])])
  144. if test "$with_vpnc_script" = "yes" || test "$with_vpnc_script" = ""; then
  145. AC_MSG_CHECKING([for vpnc-script in standard locations])
  146. if test "$have_win" = "yes"; then
  147. with_vpnc_script=vpnc-script-win.js
  148. else
  149. for with_vpnc_script in /usr/local/share/vpnc-scripts/vpnc-script /usr/local/sbin/vpnc-script /usr/share/vpnc-scripts/vpnc-script /usr/sbin/vpnc-script /etc/vpnc/vpnc-script; do
  150. if test -x "$with_vpnc_script"; then
  151. break
  152. fi
  153. done
  154. if ! test -x "$with_vpnc_script"; then
  155. AC_MSG_ERROR([${with_vpnc_script} does not seem to be executable.]
  156. [OpenConnect will not function correctly without a vpnc-script.]
  157. [See https://www.infradead.org/openconnect/vpnc-script.html for more details.]
  158. []
  159. [If you are building a distribution package, please ensure that your]
  160. [packaging is correct, and that a vpnc-script will be installed when the]
  161. [user installs your package. You should provide a --with-vpnc-script=]
  162. [argument to this configure script, giving the full path where the script]
  163. [will be installed.]
  164. []
  165. [The standard location is ${with_vpnc_script}. To bypass this error and]
  166. [build OpenConnect to use the script from this location, even though it is]
  167. [not present at the time you are building OpenConnect, pass the argument]
  168. ["--with-vpnc-script=${with_vpnc_script}"])
  169. else
  170. AC_MSG_RESULT([${with_vpnc_script}])
  171. fi
  172. fi
  173. elif test "$with_vpnc_script" = "no"; then
  174. AC_MSG_ERROR(You cannot disable vpnc-script.
  175. OpenConnect will not function correctly without it.
  176. See https://www.infradead.org/openconnect/vpnc-script.html)
  177. elif test "$have_win" = "yes"; then
  178. # Oh Windows how we hate thee. If user specifies a vpnc-script and it contains
  179. # backslashes, double them all up to survive escaping.
  180. with_vpnc_script="$(echo "${with_vpnc_script}" | sed s/\\\\/\\\\\\\\/g)"
  181. fi
  182. AC_DEFINE_UNQUOTED(DEFAULT_VPNCSCRIPT, "${with_vpnc_script}", [Default vpnc-script locatin])
  183. AC_SUBST(DEFAULT_VPNCSCRIPT, "${with_vpnc_script}")
  184. AC_CHECK_FUNC(fdevname_r, [AC_DEFINE(HAVE_FDEVNAME_R, 1, [Have fdevname_r() function])], [])
  185. AC_CHECK_FUNC(statfs, [AC_DEFINE(HAVE_STATFS, 1, [Have statfs() function])], [])
  186. AC_CHECK_FUNC(getline, [AC_DEFINE(HAVE_GETLINE, 1, [Have getline() function])],
  187. [symver_getline="openconnect__getline;"])
  188. AC_CHECK_FUNC(strcasestr, [AC_DEFINE(HAVE_STRCASESTR, 1, [Have strcasestr() function])], [])
  189. AC_CHECK_FUNC(strndup, [AC_DEFINE(HAVE_STRNDUP, 1, [Have strndup() function])], [])
  190. AC_CHECK_FUNC(strchrnul, [AC_DEFINE(HAVE_STRCHRNUL, 1, [Have strchrnul() function])], [])
  191. AC_CHECK_FUNC(asprintf, [AC_DEFINE(HAVE_ASPRINTF, 1, [Have asprintf() function])],
  192. [symver_asprintf="openconnect__asprintf;"])
  193. AC_CHECK_FUNC(vasprintf, [AC_DEFINE(HAVE_VASPRINTF, 1, [Have vasprintf() function])],
  194. [symver_vasprintf="openconnect__vasprintf;"])
  195. AC_MSG_CHECKING([for __builtin_clz])
  196. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[return __builtin_clz(0xffffffff);])],
  197. [AC_MSG_RESULT(yes)
  198. AC_DEFINE(HAVE_BUILTIN_CLZ, 1, [Have __builtin_clz()])],
  199. [AC_MSG_RESULT(no)])
  200. if test -n "$symver_vasprintf"; then
  201. AC_MSG_CHECKING([for va_copy])
  202. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  203. #include <stdarg.h>
  204. va_list a;],[
  205. va_list b;
  206. va_copy(b,a);
  207. va_end(b);])],
  208. [AC_DEFINE(HAVE_VA_COPY, 1, [Have va_copy()])
  209. AC_MSG_RESULT(va_copy)],
  210. [AC_LINK_IFELSE([AC_LANG_PROGRAM([
  211. #include <stdarg.h>
  212. va_list a;],[
  213. va_list b;
  214. __va_copy(b,a);
  215. va_end(b);])],
  216. [AC_DEFINE(HAVE___VA_COPY, 1, [Have __va_copy()])
  217. AC_MSG_RESULT(__va_copy)],
  218. [AC_MSG_RESULT(no)
  219. AC_MSG_ERROR([Your system lacks vasprintf() and va_copy()])])
  220. ])
  221. fi
  222. AC_SUBST(SYMVER_TIME, $symver_time)
  223. AC_SUBST(SYMVER_GETLINE, $symver_getline)
  224. AC_SUBST(SYMVER_ASPRINTF, $symver_asprintf)
  225. AC_SUBST(SYMVER_VASPRINTF, $symver_vasprintf)
  226. AC_SUBST(SYMVER_WIN32_STRERROR, $symver_win32_strerror)
  227. AC_SUBST(SYMVER_WIN32_SETENV, $symver_win32_setenv)
  228. AS_COMPILER_FLAGS(WFLAGS,
  229. "-Wall
  230. -Wextra
  231. -Wno-missing-field-initializers
  232. -Wno-sign-compare
  233. -Wno-unused-parameter
  234. -Werror=pointer-to-int-cast
  235. -Werror-implicit-function-declaration
  236. -Wformat-nonliteral
  237. -Wformat-security
  238. -Winit-self
  239. -Wmissing-declarations
  240. -Wmissing-include-dirs
  241. -Wnested-externs
  242. -Wpointer-arith
  243. -Wwrite-strings")
  244. AC_SUBST(WFLAGS, [$WFLAGS])
  245. oldCFLAGS="$CFLAGS"
  246. CFLAGS="$CFLAGS $WFLAGS"
  247. AC_MSG_CHECKING([For memset_s])
  248. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  249. #define __STDC_WANT_LIB_EXT1__ 1
  250. #include <string.h>],[[
  251. unsigned char *foo[16];
  252. memset_s(foo, 16, 0, 16);]])],
  253. [AC_MSG_RESULT([yes])
  254. AC_DEFINE(__STDC_WANT_LIB_EXT1__, 1, [To request memset_s])
  255. AC_DEFINE(HAVE_MEMSET_S, 1, [Have memset_s() function])],
  256. [AC_MSG_RESULT([no])
  257. AC_CHECK_FUNC(explicit_memset,
  258. [AC_DEFINE(HAVE_EXPLICIT_MEMSET, 1, [Have explicit_memset() function])],
  259. [AC_CHECK_FUNC(explicit_bzero,
  260. [AC_DEFINE(HAVE_EXPLICIT_BZERO, 1, [Have explicit_bzero() function])],
  261. [])
  262. ])
  263. ])
  264. CFLAGS="$oldCFLAGS"
  265. AC_MSG_CHECKING([For localtime_r])
  266. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>],[[
  267. struct tm tm;
  268. time_t t = 0;
  269. localtime_r(&t, &tm);]])],
  270. [AC_MSG_RESULT([yes])
  271. AC_DEFINE(HAVE_LOCALTIME_R, 1, [Have localtime_r() function])],
  272. [AC_MSG_RESULT([no])])
  273. if test "$have_win" = yes; then
  274. # Checking "properly" for __attribute__((dllimport,stdcall)) functions is non-trivial
  275. LIBS="$LIBS -lws2_32 -lshlwapi -lsecur32 -liphlpapi"
  276. AC_MSG_CHECKING([For localtime_s])
  277. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>],[[
  278. struct tm tm;
  279. time_t t = 0;
  280. localtime_s(&tm, (time_t)0);]])],
  281. [AC_MSG_RESULT([yes])
  282. AC_DEFINE(HAVE_LOCALTIME_S, 1, [Have localtime_s() function])],
  283. [AC_MSG_RESULT([no])])
  284. else
  285. AC_CHECK_FUNC(socket, [], AC_CHECK_LIB(socket, socket, [], AC_MSG_ERROR(Cannot find socket() function)))
  286. fi
  287. have_inet_aton=yes
  288. AC_CHECK_FUNC(inet_aton, [], AC_CHECK_LIB(nsl, inet_aton, [], have_inet_aton=no))
  289. if test "$have_inet_aton" = "yes"; then
  290. AC_DEFINE(HAVE_INET_ATON, 1, [Have inet_aton()])
  291. fi
  292. AC_MSG_CHECKING([for IPV6_PATHMTU socket option])
  293. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  294. #include <netinet/in.h>
  295. #include <sys/socket.h>
  296. #include <sys/types.h>],[
  297. int foo = IPV6_PATHMTU; (void)foo;])],
  298. [AC_DEFINE(HAVE_IPV6_PATHMTU, 1, [Have IPV6_PATHMTU socket option])
  299. AC_MSG_RESULT([yes])],
  300. [AC_MSG_RESULT([no])])
  301. AC_CHECK_FUNC(__android_log_vprint, [], AC_CHECK_LIB(log, __android_log_vprint, [], []))
  302. AC_ENABLE_SHARED
  303. AC_DISABLE_STATIC
  304. AC_CHECK_FUNC(nl_langinfo, [AC_DEFINE(HAVE_NL_LANGINFO, 1, [Have nl_langinfo() function])], [])
  305. AC_CHECK_FUNC(posix_spawn, [AC_DEFINE(HAVE_POSIX_SPAWN, 1, [Have posix_spawn() function])], [])
  306. if test "$ac_cv_func_nl_langinfo" = "yes"; then
  307. AM_ICONV
  308. if test "$am_cv_func_iconv" = "yes"; then
  309. AC_SUBST(ICONV_LIBS, [$LTLIBICONV])
  310. AC_SUBST(ICONV_CFLAGS, [$INCICONV])
  311. AC_DEFINE(HAVE_ICONV, 1, [Have iconv() function])
  312. fi
  313. fi
  314. AM_CONDITIONAL(OPENCONNECT_ICONV, [test "$am_cv_func_iconv" = "yes"])
  315. AC_ARG_ENABLE([nls],
  316. AS_HELP_STRING([--disable-nls], [Do not use Native Language Support]),
  317. [USE_NLS=$enableval], [USE_NLS=yes])
  318. LIBINTL=
  319. if test "$USE_NLS" = "yes"; then
  320. AC_PATH_PROG(MSGFMT, msgfmt)
  321. if test "$MSGFMT" = ""; then
  322. AC_MSG_ERROR(msgfmt could not be found. Try configuring with --disable-nls)
  323. fi
  324. fi
  325. LIBINTL=
  326. if test "$USE_NLS" = "yes"; then
  327. AC_MSG_CHECKING([for functional NLS support])
  328. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  329. #include <locale.h>
  330. #include <libintl.h>],[
  331. setlocale(LC_ALL, "");
  332. bindtextdomain("openconnect", "/tmp");
  333. (void)dgettext("openconnect", "foo");])],
  334. [AC_MSG_RESULT(yes)],
  335. [AC_LIB_LINKFLAGS_BODY([intl])
  336. oldLIBS="$LIBS"
  337. LIBS="$LIBINTL $LIBS"
  338. oldCFLAGS="$LIBS"
  339. CFLAGS="$CFLAGS $INCINTL"
  340. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  341. #include <locale.h>
  342. #include <libintl.h>],[
  343. setlocale(LC_ALL, "");
  344. bindtextdomain("openconnect", "/tmp");
  345. (void)dgettext("openconnect", "foo");])],
  346. [AC_MSG_RESULT(yes (with $INCINTL $LIBINTL))],
  347. [AC_MSG_RESULT(no)
  348. USE_NLS=no])
  349. LIBS="$oldLIBS"])
  350. fi
  351. if test "$USE_NLS" = "yes"; then
  352. AC_SUBST(INTL_LIBS, [$LTLIBINTL])
  353. AC_SUBST(INTL_CFLAGS, [$INCINTL])
  354. AC_DEFINE(ENABLE_NLS, 1, [Enable NLS support])
  355. fi
  356. AM_CONDITIONAL(USE_NLS, [test "$USE_NLS" = "yes"])
  357. AC_ARG_WITH([system-cafile],
  358. AS_HELP_STRING([--with-system-cafile],
  359. [Location of the default system CA certificate file for old (<3.0.20) GnuTLS versions]))
  360. # We will use GnuTLS by default if it's present. We used to support
  361. # using GnuTLS for the TLS connections and OpenSSL for DTLS, but none
  362. # of the reasons for that make sense any more.
  363. AC_ARG_WITH([gnutls],
  364. AS_HELP_STRING([--without-gnutls], [Do not attempt to use GnuTLS; use OpenSSL instead]))
  365. AC_ARG_WITH([openssl],
  366. AS_HELP_STRING([--with-openssl], [Location of OpenSSL build dir]))
  367. ssl_library=
  368. esp=
  369. dtls=
  370. hpke=
  371. if test "$with_openssl" != "" -a "$with_openssl" != "no"; then
  372. if test "$with_gnutls" = ""; then
  373. with_gnutls=no
  374. elif test "$with_gnutls" = "yes"; then
  375. AC_MSG_ERROR([You cannot choose both GnuTLS and OpenSSL.])
  376. fi
  377. fi
  378. # First, check if GnuTLS exists and is usable
  379. if test "$with_gnutls" = "yes" || test "$with_gnutls" = ""; then
  380. PKG_CHECK_MODULES(GNUTLS, gnutls,
  381. [if ! $PKG_CONFIG --atleast-version=3.2.10 gnutls; then
  382. AC_MSG_WARN([Your GnuTLS is too old. At least v3.2.10 is required])
  383. else
  384. ssl_library=GnuTLS
  385. fi], [:])
  386. elif test "$with_gnutls" != "no"; then
  387. AC_MSG_ERROR(Values other than 'yes' or 'no' for --with-gnutls are not supported)
  388. fi
  389. # Do we need to look for OpenSSL?
  390. if test "$ssl_library" = ""; then
  391. if test "$with_gnutls" = "yes" -o "$with_openssl" = "no"; then
  392. AC_MSG_ERROR([Suitable GnuTLS required but not found])
  393. elif test "$with_openssl" = "yes" -o "$with_openssl" = ""; then
  394. PKG_CHECK_MODULES(OPENSSL, openssl, [AC_SUBST(SSL_PC, [openssl])],
  395. [oldLIBS="$LIBS"
  396. LIBS="-lssl -lcrypto $LIBS"
  397. AC_MSG_CHECKING([for OpenSSL without pkg-config])
  398. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  399. #include <openssl/ssl.h>
  400. #include <openssl/err.h>],[
  401. SSL_library_init();
  402. ERR_clear_error();
  403. SSL_load_error_strings();
  404. OpenSSL_add_all_algorithms();])],
  405. [AC_MSG_RESULT(yes)
  406. AC_SUBST([OPENSSL_LIBS], ["-lssl -lcrypto"])
  407. AC_SUBST([OPENSSL_CFLAGS], [])]
  408. AC_SUBST([openssl_pc_libs], [$OPENSSL_LIBS]),
  409. [AC_MSG_RESULT(no)
  410. AC_MSG_ERROR(Could not build against OpenSSL)])
  411. LIBS="$oldLIBS"])
  412. ssl_library=OpenSSL
  413. PKG_CHECK_MODULES(P11KIT, p11-kit-1,
  414. # libp11 0.4.7 fails to export ERR_LIB_PKCS11 so we don't know what it
  415. # is and can't match its errors, which we need to for login checks.
  416. [PKG_CHECK_MODULES(LIBP11, libp11 != 0.4.7,
  417. [AC_DEFINE(HAVE_LIBP11, 1, [Have libp11 and p11-kit for OpenSSL])
  418. AC_SUBST(P11KIT_PC, ["libp11 p11-kit-1"])
  419. proxy_module="`$PKG_CONFIG --variable=proxy_module p11-kit-1`"
  420. pkcs11_support="libp11"
  421. AC_DEFINE_UNQUOTED([DEFAULT_PKCS11_MODULE], "${proxy_module}", [p11-kit proxy])],
  422. [:])], [:])
  423. else
  424. OPENSSL_CFLAGS="-I${with_openssl}/include ${OPENSSL_CFLAGS}"
  425. if test -r "${with_openssl}/libssl.a" -a -r "${with_openssl}/libcrypto.a"; then
  426. OPENSSL_LIBS="${with_openssl}/libssl.a ${with_openssl}/libcrypto.a -ldl -lz -pthread"
  427. elif test -r "${with_openssl}/crypto/.libs/libcrypto.a" -a \
  428. -r "${with_openssl}/ssl/.libs/libssl.a"; then
  429. OPENSSL_LIBS="${with_openssl}/ssl/.libs/libssl.a ${with_openssl}/crypto/.libs/libcrypto.a -ldl -lz -pthread"
  430. else
  431. AC_MSG_ERROR(Could not find OpenSSL libraries in ${with_openssl});
  432. fi
  433. AC_SUBST(OPENSSL_CFLAGS)
  434. AC_SUBST(OPENSSL_LIBS)
  435. enable_static=yes
  436. enable_shared=no
  437. ssl_library=OpenSSL
  438. fi
  439. fi
  440. AC_ARG_WITH([openssl-version-check],
  441. AS_HELP_STRING([--without-openssl-version-check], [Do not check for known-broken OpenSSL versions]))
  442. AC_ARG_WITH([gnutls-version-check],
  443. AS_HELP_STRING([--without-gnutls-version-check], [Do not check for known-broken GnuTLS versions]))
  444. AC_ARG_WITH([default-gnutls-priority],
  445. AS_HELP_STRING([--with-default-gnutls-priority=STRING],
  446. [Provide a default string as GnuTLS priority string]),
  447. default_gnutls_priority=$withval)
  448. if test -n "$default_gnutls_priority"; then
  449. AC_DEFINE_UNQUOTED([DEFAULT_PRIO], ["$default_gnutls_priority"], [The GnuTLS priority string])
  450. fi
  451. AC_ARG_WITH([gnutls-tss2],
  452. AS_HELP_STRING([--with-gnutls-tss2], [Specify TSS2 library (tss2-esys, ibmtss)]))
  453. tss2lib=none
  454. case "$ssl_library" in
  455. OpenSSL)
  456. oldLIBS="${LIBS}"
  457. oldCFLAGS="${CFLAGS}"
  458. LIBS="${OPENSSL_LIBS} ${LIBS}"
  459. CFLAGS="${CFLAGS} ${OPENSSL_CFLAGS}"
  460. # Check for the various known-broken versions of OpenSSL, which includes LibreSSL.
  461. if test "$with_openssl_version_check" != "no"; then
  462. AC_MSG_CHECKING([for known-broken versions of OpenSSL])
  463. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <openssl/opensslv.h>],
  464. [#if defined(LIBRESSL_VERSION_NUMBER)
  465. #error Bad OpenSSL
  466. #endif
  467. ])],
  468. [],
  469. [AC_MSG_RESULT(yes)
  470. AC_MSG_ERROR([LibreSSL does not support Cisco DTLS.]
  471. [Build with OpenSSL or GnuTLS instead.])])
  472. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <openssl/opensslv.h>],[#if \
  473. (OPENSSL_VERSION_NUMBER == 0x10002000L || \
  474. (OPENSSL_VERSION_NUMBER >= 0x100000b0L && OPENSSL_VERSION_NUMBER <= 0x100000c0L) || \
  475. (OPENSSL_VERSION_NUMBER >= 0x10001040L && OPENSSL_VERSION_NUMBER <= 0x10001060L))
  476. #error Bad OpenSSL
  477. #endif
  478. ])],
  479. [],
  480. [AC_MSG_RESULT(yes)
  481. AC_MSG_ERROR(This version of OpenSSL is known to be broken with Cisco DTLS.
  482. See http://rt.openssl.org/Ticket/Display.html?id=2984&user=guest&pass=guest
  483. Add --without-openssl-version-check to configure args to avoid this check, or
  484. perhaps consider building with GnuTLS instead.)])
  485. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <openssl/opensslv.h>],[#if \
  486. (OPENSSL_VERSION_NUMBER == 0x1000200fL)
  487. #error Bad OpenSSL
  488. #endif
  489. ])],
  490. [],
  491. [AC_MSG_RESULT(yes)
  492. AC_MSG_ERROR(This version of OpenSSL is known to be broken with Cisco DTLS.
  493. See http://rt.openssl.org/Ticket/Display.html?id=3703&user=guest&pass=guest
  494. and http://rt.openssl.org/Ticket/Display.html?id=3711&user=guest&pass=guest
  495. Add --without-openssl-version-check to configure args to avoid this check, or
  496. perhaps consider building with GnuTLS instead.)])
  497. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <openssl/opensslv.h>],[#if \
  498. ((OPENSSL_VERSION_NUMBER >= 0x10001110L && OPENSSL_VERSION_NUMBER <= 0x10001150L) || \
  499. (OPENSSL_VERSION_NUMBER >= 0x10002050L && OPENSSL_VERSION_NUMBER <= 0x10002090L))
  500. #error Bad OpenSSL
  501. #endif
  502. ])],
  503. [],
  504. [AC_MSG_RESULT(yes)
  505. AC_MSG_ERROR(This version of OpenSSL is known to be broken with Cisco DTLS.
  506. See http://rt.openssl.org/Ticket/Display.html?id=4631&user=guest&pass=guest
  507. Add --without-openssl-version-check to configure args to avoid this check, or
  508. perhaps consider building with GnuTLS instead.)])
  509. AC_MSG_RESULT(no)
  510. fi
  511. AC_MSG_CHECKING([for ENGINE_by_id() in OpenSSL])
  512. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/engine.h>],
  513. [ENGINE_by_id("foo");])],
  514. [AC_MSG_RESULT(yes)
  515. AC_DEFINE(HAVE_ENGINE, [1], [OpenSSL has ENGINE support])],
  516. [AC_MSG_RESULT(no)
  517. AC_MSG_NOTICE([Building without OpenSSL TPM ENGINE support])])
  518. AC_MSG_CHECKING([for dtls1_stop_timer() in OpenSSL])
  519. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>
  520. #include <stdlib.h>
  521. extern void dtls1_stop_timer(SSL *);],
  522. [dtls1_stop_timer(NULL);])],
  523. [AC_MSG_RESULT(yes)
  524. AC_DEFINE(HAVE_DTLS1_STOP_TIMER, [1], [OpenSSL has dtls1_stop_timer() function])],
  525. [AC_MSG_RESULT(no)])
  526. # DTLS_client_method() and DTLSv1_2_client_method() were both added between
  527. # OpenSSL v1.0.1 and v1.0.2. DTLSV1.2_client_method() was later deprecated
  528. # in v1.1.0 so we use DTLS_client_method() as our check for DTLSv1.2 support
  529. # and that's what we actually use in openssl-dtls.c too.
  530. AC_MSG_CHECKING([for DTLS_client_method() in OpenSSL])
  531. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>],
  532. [DTLS_client_method();])],
  533. [AC_MSG_RESULT(yes)
  534. AC_DEFINE(HAVE_DTLS12, [1], [OpenSSL has DTLS_client_method() function])],
  535. [AC_MSG_RESULT(no)])
  536. AC_MSG_CHECKING([for SSL_CTX_set_min_proto_version() in OpenSSL])
  537. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>],
  538. [SSL_CTX_set_min_proto_version((void *)0, 0);])],
  539. [AC_MSG_RESULT(yes)
  540. AC_DEFINE(HAVE_SSL_CTX_PROTOVER, [1], [OpenSSL has SSL_CTX_set_min_proto_version() function])],
  541. [AC_MSG_RESULT(no)])
  542. AC_MSG_CHECKING([for BIO_meth_free() in OpenSSL])
  543. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/bio.h>],
  544. [BIO_meth_free((void *)0);])],
  545. [AC_MSG_RESULT(yes)
  546. AC_DEFINE(HAVE_BIO_METH_FREE, [1], [OpenSSL has BIO_meth_free() function])],
  547. [AC_MSG_RESULT(no)])
  548. AC_CHECK_FUNC(HMAC_CTX_copy,
  549. [esp=yes],
  550. [AC_MSG_WARN([ESP support will be disabled])])
  551. AC_MSG_CHECKING([for SSL_CIPHER_find() in OpenSSL])
  552. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>],
  553. [SSL_CIPHER_find((void *)0, "");])],
  554. [AC_MSG_RESULT(yes)
  555. AC_DEFINE(HAVE_SSL_CIPHER_FIND, [1], [OpenSSL has SSL_CIPHER_find() function])],
  556. [AC_MSG_RESULT(no)])
  557. AC_MSG_CHECKING([for HKDF support in OpenSSL])
  558. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <openssl/ssl.h>
  559. #include <openssl/kdf.h>],
  560. [EVP_PKEY_CTX *ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL);
  561. EVP_PKEY_CTX_hkdf_mode(ctx, EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND);])],
  562. [AC_MSG_RESULT(yes)
  563. hpke=yes],
  564. [AC_MSG_RESULT(no)])
  565. LIBS="${oldLIBS}"
  566. CFLAGS="${oldCFLAGS}"
  567. dtls=yes
  568. AC_DEFINE(OPENCONNECT_OPENSSL, 1, [Using OpenSSL])
  569. AC_DEFINE(OPENSSL_SUPPRESS_DEPRECATED, 1, [We need to update to OpenSSL 3.0.0 API])
  570. AC_SUBST(SSL_LIBS, ['$(OPENSSL_LIBS)'])
  571. AC_SUBST(SSL_CFLAGS, ['$(OPENSSL_CFLAGS)'])
  572. ;;
  573. GnuTLS)
  574. oldlibs="$LIBS"
  575. oldcflags="$CFLAGS"
  576. LIBS="$GNUTLS_LIBS $LIBS"
  577. CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
  578. esp=yes
  579. dtls=yes
  580. # Check for the known-broken versions of GnuTLS,
  581. if test "$with_gnutls_version_check" != "no"; then
  582. AC_MSG_CHECKING([for known-broken versions of GnuTLS])
  583. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <gnutls/gnutls.h>],
  584. [#if GNUTLS_VERSION_NUMBER >= 0x030603 && GNUTLS_VERSION_NUMBER <= 0x03060c
  585. #error Bad GnuTLS
  586. #endif
  587. ])],
  588. [],
  589. [AC_MSG_RESULT(yes)
  590. AC_MSG_ERROR([DTLS is insecure in GnuTLS v3.6.3 through v3.6.12.]
  591. [See https://gitlab.com/gnutls/gnutls/issues/960]
  592. [Add --without-gnutls-version-check to configure args to avoid this check (DTLS]
  593. [will still be disabled at runtime), or build with another version.])])
  594. AC_MSG_RESULT(no)
  595. fi
  596. AC_CHECK_FUNC(gnutls_system_key_add_x509,
  597. [AC_DEFINE(HAVE_GNUTLS_SYSTEM_KEYS, 1, [From GnuTLS 3.4.0])], [])
  598. AC_CHECK_FUNC(gnutls_pkcs11_add_provider,
  599. [PKG_CHECK_MODULES(P11KIT, p11-kit-1,
  600. [AC_DEFINE(HAVE_P11KIT, 1, [Have. P11. Kit.])
  601. pkcs11_support=GnuTLS
  602. AC_SUBST(P11KIT_PC, p11-kit-1)],
  603. [:])], [])
  604. # From GnuTLS 3.6.13
  605. AC_CHECK_FUNC(gnutls_hkdf_expand, [have_hkdf=yes], [have_hkdf=no])
  606. LIBS="-ltspi $oldlibs"
  607. AC_MSG_CHECKING([for Trousers tss library])
  608. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  609. #include <trousers/tss.h>
  610. #include <trousers/trousers.h>],[
  611. int err = Tspi_Context_Create((void *)0);
  612. Trspi_Error_String(err);])],
  613. [AC_MSG_RESULT(yes)
  614. AC_SUBST([TSS_LIBS], [-ltspi])
  615. AC_SUBST([TSS_CFLAGS], [])
  616. AC_DEFINE(HAVE_TROUSERS, 1, [Have Trousers TSS library])],
  617. [AC_MSG_RESULT(no)])
  618. LIBS="$oldlibs"
  619. CFLAGS="$oldcflags"
  620. if test "$have_hkdf" = "yes"; then
  621. PKG_CHECK_MODULES(HOGWEED, [hogweed],
  622. [AC_MSG_CHECKING([For hogweed built-in mini-gmp])
  623. LIBS="$oldlibs $HOGWEED_LIBS"
  624. CFLAGS="$oldcflags $HOGWEED_CFLAGS"
  625. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <nettle/ecc.h>],
  626. [mpz_clear((void *)0);])],
  627. [AC_MSG_RESULT(yes)
  628. AC_SUBST(HPKE_CFLAGS, ['$(HOGWEED_FLAGS)'])
  629. AC_SUBST(HPKE_LIBS, ['$(HOGWEED_LIBS)'])
  630. hpke=yes],
  631. [AC_MSG_RESULT(no)
  632. PKG_CHECK_MODULES(GMP, [gmp],
  633. [hpke=yes
  634. AC_SUBST(HPKE_CFLAGS, ['$(HOGWEED_FLAGS) $(GMP_CFLAGS)'])
  635. AC_SUBST(HPKE_LIBS, ['$(HOGWEED_LIBS) $(GMP_LIBS)'])],
  636. [AC_MSG_CHECKING([for gmp without pkgconfig])
  637. LIBS="$LIBS -lgmp"
  638. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <gmp.h>],
  639. [mpz_clear((void *)0);])],
  640. [AC_MSG_RESULT(yes)
  641. AC_SUBST(HPKE_CFLAGS, ['$(HOGWEED_FLAGS)'])
  642. AC_SUBST(HPKE_LIBS, ['$(HOGWEED_LIBS) -lgmp'])
  643. hpke=yes],
  644. [AC_MSG_RESULT(no)])
  645. ])
  646. ])
  647. LIBS="$oldlibs"
  648. CFLAGS="$oldcflags"],
  649. [:])
  650. fi
  651. PKG_CHECK_MODULES(TASN1, [libtasn1], [have_tasn1=yes], [have_tasn1=no])
  652. if test "$have_tasn1" = "yes"; then
  653. if test "$with_gnutls_tss2" = "yes" -o "$with_gnutls_tss2" = "tss2-esys" -o "$with_gnutls_tss2" = ""; then
  654. PKG_CHECK_MODULES(TSS2_ESYS, [tss2-esys tss2-mu tss2-tctildr],
  655. [AC_DEFINE(HAVE_TSS2, 1, [Have TSS2])
  656. AC_SUBST(TPM2_CFLAGS, ['$(TASN1_CFLAGS) $(TSS2_ESYS_CFLAGS)'])
  657. AC_SUBST(TPM2_LIBS, ['$(TASN1_LIBS) $(TSS2_ESYS_LIBS)'])
  658. tss2lib=tss2-esys],
  659. [:])
  660. fi
  661. if test "$tss2lib" = "none"; then
  662. if test "$with_gnutls_tss2" = "yes" -o "$with_gnutls_tss2" = "ibmtss" -o "$with_gnutls_tss2" = ""; then
  663. # The Fedora 'tss2-devel' package puts headers in /usr/include/ibmtss/
  664. # and the library is named libibmtss.so. The Ubuntu libtss-dev package
  665. # puts headers in /usr/include/${host}/tss2/ and the library is named
  666. # libtss.so. Neither ships a pkg-config file at the time I write this.
  667. AC_CHECK_LIB([tss], [TSS_Create], [tss2inc=tss2
  668. tss2lib=tss],
  669. AC_CHECK_LIB([ibmtss], [TSS_Create],
  670. [tss2inc=ibmtss
  671. tss2lib=ibmtss], []))
  672. if test "$tss2lib" != "none"; then
  673. AC_MSG_CHECKING([For <${tss2inc}/tss.h>])
  674. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#define TPM_POSIX
  675. #include <${tss2inc}/tss.h>
  676. ],[])],
  677. [AC_MSG_RESULT(yes)
  678. AC_DEFINE_UNQUOTED(HAVE_TSS2, $tss2inc, [TSS2 library])
  679. AC_SUBST(TSS2_LIBS, [-l$tss2lib])
  680. AC_SUBST(TPM2_CFLAGS, ['$(TASN1_CFLAGS) -DTPM_POSIX'])
  681. AC_SUBST(TPM2_LIBS, ['$(TASN1_LIBS) $(TSS2_LIBS)'])],
  682. [AC_MSG_RESULT(no)
  683. tss2lib=none])
  684. fi
  685. fi
  686. fi
  687. fi
  688. AC_DEFINE(OPENCONNECT_GNUTLS, 1, [Using GnuTLS])
  689. AC_SUBST(SSL_PC, [gnutls])
  690. AC_SUBST(SSL_LIBS, ['$(GNUTLS_LIBS) $(TPM2_LIBS) $(HPKE_LIBS)'])
  691. AC_SUBST(SSL_CFLAGS, ['$(GNUTLS_CFLAGS) $(TPM2_CFLAGS) $(HPKE_CFLAGS)'])
  692. ;;
  693. *)
  694. # This should never happen
  695. AC_MSG_ERROR([No SSL library selected])
  696. ;;
  697. esac
  698. case x"$with_gnutls_tss2" in
  699. xtss2-esys)
  700. if test "$tss2lib" != "tss2-esys"; then
  701. AC_MSG_ERROR([tss2-esys requested but not found])
  702. fi
  703. ;;
  704. xibmtss|xtss)
  705. if test "$tss2lib" != "ibmtss" -a "$tss2lib" != "tss"; then
  706. AC_MSG_ERROR([ibmtss requested but not found: $tss2lib])
  707. fi
  708. ;;
  709. x|xno)
  710. ;;
  711. xyes)
  712. if test "$tss2lib" = "none" -a "$with_gnutls_tss2" = "yes"; then
  713. AC_MSG_ERROR([No TSS2 library found])
  714. fi
  715. ;;
  716. *)
  717. AC_MSG_ERROR([Unknown value for gnutls-tss2])
  718. ;;
  719. esac
  720. AM_CONDITIONAL(OPENCONNECT_SYSTEM_KEYS, [ test "$ac_cv_func_gnutls_system_key_add_x509" = "yes" ])
  721. AM_CONDITIONAL(OPENCONNECT_TSS2_ESYS, [ test "$tss2lib" = "tss2-esys" ])
  722. AM_CONDITIONAL(OPENCONNECT_TSS2_IBM, [ test "$tss2lib" = "ibmtss" -o "$tss2lib" = "tss" ])
  723. AC_PATH_PROG(SWTPM, swtpm)
  724. SWTPM_IOCTL=""
  725. TPM2_STARTUP=""
  726. TSSTARTUP=""
  727. if test "$SWTPM" != ""; then
  728. AC_PATH_PROG(SWTPM_IOCTL, swtpm_ioctl)
  729. AC_PATH_PROG(TPM2_STARTUP, tpm2_startup)
  730. AC_PATH_PROG(TSSTARTUP, tsstartup)
  731. fi
  732. # The Intel/TCG TSS can only *create* keys
  733. AC_PATH_PROG(TPM2TSS_GENKEY, tpm2tss-genkey)
  734. # James's one can import them too.
  735. AC_PATH_PROG(CREATE_TPM2_KEY, create_tpm2_key)
  736. AC_ARG_ENABLE([hwtpm-test],
  737. AS_HELP_STRING([--enable-hwtpm-test], [Test TPM support using real TPMv2 [default=no]]),
  738. [test_hwtpm=$enableval], [test_hwtpm=no])
  739. if test "$test_hwtpm" = "yes" -a "$TPM2TSS_GENKEY$CREATE_TPM2_KEY" = ""; then
  740. AC_MSG_ERROR([Hardware TPM test requires tpm2tss-genkey and/or create_tpm2_key tools])
  741. fi
  742. AM_CONDITIONAL(TEST_HWTPM, [ test "$test_hwtpm" = "yes" ])
  743. AM_CONDITIONAL(TEST_SWTPM, [ test "$SWTPM_IOCTL" != "" -a \( "$TPM2_STARTUP" != "" -o "$TSSTARTUP" != "" \) ])
  744. AM_CONDITIONAL(TEST_TPM2_CREATE, [ test "$TPM2TSS_GENKEY" != "" ])
  745. AM_CONDITIONAL(TEST_TPM2_IMPORT, [ test "$CREATE_TPM2_KEY" != "" ])
  746. test_pkcs11=
  747. if test "$pkcs11_support" != ""; then
  748. AC_CHECK_PROG(test_pkcs11, softhsm2-util, yes)
  749. fi
  750. AM_CONDITIONAL(TEST_PKCS11, [ test "$test_pkcs11" = "yes" ])
  751. # The test is OpenSSL-only for now.
  752. AM_CONDITIONAL(CHECK_DTLS, [ test "$ssl_library" = "OpenSSL" ])
  753. AC_ARG_ENABLE([dtls-xfail],
  754. AS_HELP_STRING([--enable-dtls-xfail], [Only for gitlab CI. Do not use]))
  755. AM_CONDITIONAL(DTLS_XFAIL, [test "$enable_dtls_xfail" = "yes" ])
  756. AC_ARG_ENABLE([dsa-tests],
  757. AS_HELP_STRING([--disable-dsa-tests], [Disable DSA keys in self-test]),
  758. [], [enable_dsa_tests=yes])
  759. AM_CONDITIONAL(TEST_DSA, [test "$enable_dsa_tests" = "yes"])
  760. AC_ARG_ENABLE([ppp-tests],
  761. AS_HELP_STRING([--enable-ppp-tests], [Enable PPP tests (which require socat and pppd, and must run as root)]),
  762. [enable_ppp_tests=yes])
  763. AC_ARG_ENABLE([flask-tests],
  764. AS_HELP_STRING([--disable-flask-tests], [Disable Flask-based tests (which require Python 3.6+ and the Flask module)]),
  765. [], [enable_flask_tests=yes])
  766. AM_CONDITIONAL(OPENCONNECT_GNUTLS, [ test "$ssl_library" = "GnuTLS" ])
  767. AM_CONDITIONAL(OPENCONNECT_OPENSSL, [ test "$ssl_library" = "OpenSSL" ])
  768. AM_CONDITIONAL(OPENCONNECT_ESP, [ test "$esp" != "" ])
  769. AM_CONDITIONAL(OPENCONNECT_DTLS, [ test "$dtls" != "" ])
  770. if test "$esp" != ""; then
  771. AC_DEFINE(HAVE_ESP, 1, [Build with ESP support])
  772. fi
  773. if test "$dtls" != ""; then
  774. AC_DEFINE(HAVE_DTLS, 1, [Build with DTLS support])
  775. fi
  776. if test "$hpke" != ""; then
  777. AC_DEFINE(HAVE_HPKE_SUPPORT, 1, [Support Cisco external browser HPKE (ECDH+HKDF+AES-256-GCM)])
  778. fi
  779. AC_ARG_WITH(lz4,
  780. AS_HELP_STRING([--without-lz4], [disable support for LZ4 compression]),
  781. test_for_lz4=$withval,
  782. test_for_lz4=yes)
  783. lz4_pkg=no
  784. if test "$test_for_lz4" = yes; then
  785. PKG_CHECK_MODULES([LIBLZ4], [liblz4], [
  786. AC_SUBST(LIBLZ4_PC, liblz4)
  787. AC_DEFINE([HAVE_LZ4], [], [LZ4 was found])
  788. lz4_pkg=yes
  789. oldLIBS="$LIBS"
  790. LIBS="$LIBLZ4_LIBS $LIBS"
  791. oldCFLAGS="$CFLAGS"
  792. CFLAGS="$CFLAGS $LIBLZ4_CFLAGS"
  793. AC_MSG_CHECKING([for LZ4_compress_default()])
  794. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  795. #include <lz4.h>],[
  796. LZ4_compress_default("", (char *)0, 0, 0);])],
  797. [AC_MSG_RESULT(yes)
  798. AC_DEFINE([HAVE_LZ4_COMPRESS_DEFAULT], [], [From LZ4 r129])
  799. ],
  800. [AC_MSG_RESULT(no)])
  801. LIBS="$oldLIBS"
  802. CFLAGS="$oldCFLAGS"
  803. ],
  804. [
  805. AC_MSG_WARN([[
  806. ***
  807. *** lz4 not found.
  808. *** ]])
  809. ])
  810. fi
  811. # For some bizarre reason now that we use AM_ICONV, the mingw32 build doesn't
  812. # manage to set EGREP properly in the created ./libtool script. Make sure it's
  813. # found.
  814. AC_PROG_EGREP
  815. # Needs to happen after we default to static/shared libraries based on OpenSSL
  816. LT_INIT
  817. if test "$use_openbsd_libtool" = "true" && test -x /usr/bin/libtool; then
  818. echo using OpenBSD libtool
  819. LIBTOOL=/usr/bin/libtool
  820. fi
  821. AM_CONDITIONAL(OPENBSD_LIBTOOL, [ test "$use_openbsd_libtool" = "true" ])
  822. AX_CHECK_VSCRIPT
  823. PKG_CHECK_MODULES(LIBXML2, libxml-2.0)
  824. AC_ARG_WITH([builtin-json],
  825. AS_HELP_STRING([--with-builtin-json],
  826. [Build with builtin json-parser library [default=auto]]))
  827. json=
  828. AS_IF([test "$with_builtin_json" != "yes"],
  829. [PKG_CHECK_MODULES(JSON, json-parser,
  830. [AC_SUBST(JSON_PC, [json-parser])
  831. json=system], [:])
  832. ])
  833. AS_IF([test "$with_builtin_json" != "no" && test "$json" = "" ],
  834. [json=builtin
  835. oldLIBS="$LIBS"
  836. AC_SEARCH_LIBS(pow, [m])
  837. LIBS="$oldLIBS"
  838. AC_SUBST([JSON_LIBS], [$ac_cv_search_pow])
  839. AC_SUBST([JSON_CFLAGS], ['-I$(srcdir)/json'])
  840. ])
  841. AS_IF([test "$json" = ""],
  842. AC_MSG_ERROR(No json-parser package found and --without-builtin-json specified)
  843. )
  844. AM_CONDITIONAL(BUILTIN_JSON, [test "$json" = "builtin"])
  845. PKG_CHECK_MODULES(ZLIB, zlib, [AC_SUBST(ZLIB_PC, [zlib])],
  846. [oldLIBS="$LIBS"
  847. LIBS="-lz $LIBS"
  848. AC_MSG_CHECKING([for zlib without pkg-config])
  849. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  850. #include <zlib.h>],[
  851. z_stream zs;
  852. deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
  853. -12, 9, Z_DEFAULT_STRATEGY);])],
  854. [AC_MSG_RESULT(yes)
  855. AC_SUBST([ZLIB_LIBS], [-lz])
  856. AC_SUBST([ZLIB_CFLAGS], [])],
  857. [AC_MSG_RESULT(no)
  858. AC_MSG_ERROR(Could not build against zlib)])
  859. LIBS="$oldLIBS"])
  860. AC_ARG_WITH([libproxy],
  861. AS_HELP_STRING([--without-libproxy],
  862. [Build without libproxy library [default=auto]]))
  863. AS_IF([test "x$with_libproxy" != "xno"], [
  864. PKG_CHECK_MODULES(LIBPROXY, libproxy-1.0,
  865. [AC_SUBST(LIBPROXY_PC, libproxy-1.0)
  866. AC_DEFINE([LIBPROXY_HDR], ["proxy.h"], [libproxy header file])
  867. libproxy_pkg=yes],
  868. libproxy_pkg=no)
  869. ], [libproxy_pkg=disabled])
  870. dnl Libproxy *can* exist without a .pc file, and its header may be called
  871. dnl libproxy.h in that case.
  872. if (test "$libproxy_pkg" = "no"); then
  873. AC_MSG_CHECKING([for libproxy])
  874. oldLIBS="$LIBS"
  875. LIBS="-lproxy $LIBS"
  876. AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <libproxy.h>],
  877. [(void)px_proxy_factory_new();])],
  878. [AC_MSG_RESULT(yes (with libproxy.h))
  879. AC_DEFINE([LIBPROXY_HDR], ["libproxy.h"], [libproxy header file])
  880. AC_SUBST([LIBPROXY_LIBS], [-lproxy])
  881. libproxy_pkg=yes],
  882. [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <proxy.h>],
  883. [(void)px_proxy_factory_new();])],
  884. [AC_MSG_RESULT(yes (with proxy.h))
  885. AC_DEFINE([LIBPROXY_HDR], ["proxy.h"], [libproxy header file])
  886. AC_SUBST([LIBPROXY_LIBS], [-lproxy])
  887. libproxy_pkg=yes],
  888. [AC_MSG_RESULT(no)])])
  889. LIBS="$oldLIBS"
  890. fi
  891. AC_ARG_WITH([stoken],
  892. AS_HELP_STRING([--without-stoken],
  893. [Build without libstoken library [default=auto]]))
  894. AS_IF([test "x$with_stoken" != "xno"], [
  895. PKG_CHECK_MODULES(LIBSTOKEN, stoken,
  896. [AC_SUBST(LIBSTOKEN_PC, stoken)
  897. AC_DEFINE([HAVE_LIBSTOKEN], 1, [Have libstoken])
  898. libstoken_pkg=yes],
  899. libstoken_pkg=no)
  900. ], [libstoken_pkg=disabled])
  901. AM_CONDITIONAL(OPENCONNECT_STOKEN, [test "$libstoken_pkg" = "yes"])
  902. AC_ARG_WITH([libpcsclite],
  903. AS_HELP_STRING([--without-libpcsclite],
  904. [Build without libpcsclite library (for Yubikey support) [default=auto]]))
  905. AS_IF([test "x$with_libpcsclite" != "xno"], [
  906. if test "$system_pcsc_libs" != ""; then
  907. AC_SUBST(LIBPCSCLITE_LIBS, "$system_pcsc_libs")
  908. AC_SUBST(LIBPCSCLITE_CFLAGS, "$system_pcsc_cflags")
  909. AC_SUBST(system_pcsc_libs)
  910. libpcsclite_pkg=yes
  911. else
  912. PKG_CHECK_MODULES(LIBPCSCLITE, libpcsclite,
  913. [AC_SUBST(LIBPCSCLITE_PC, libpcsclite)
  914. libpcsclite_pkg=yes],
  915. libpcsclite_pkg=no)
  916. fi
  917. ], [libpcsclite_pkg=disabled])
  918. if test "$libpcsclite_pkg" = "yes"; then
  919. AC_DEFINE([HAVE_LIBPCSCLITE], 1, [Have libpcsclite])
  920. fi
  921. AM_CONDITIONAL(OPENCONNECT_LIBPCSCLITE, [test "$libpcsclite_pkg" = "yes"])
  922. AC_CHECK_FUNC(epoll_create1, [AC_DEFINE(HAVE_EPOLL, 1, [Have epoll])], [])
  923. AC_ARG_WITH([libpskc],
  924. AS_HELP_STRING([--without-libpskc],
  925. [Build without libpskc library [default=auto]]))
  926. AS_IF([test "x$with_libpskc" != "xno"], [
  927. PKG_CHECK_MODULES(LIBPSKC, [libpskc >= 2.2.0],
  928. [AC_SUBST(LIBPSKC_PC, libpskc)
  929. AC_DEFINE([HAVE_LIBPSKC], 1, [Have libpskc])
  930. libpskc_pkg=yes],
  931. libpskc_pkg=no)])
  932. linked_gssapi=no
  933. AC_ARG_WITH([gssapi],
  934. AS_HELP_STRING([--without-gssapi],
  935. [Build without GSSAPI support [default=auto]]))
  936. AC_DEFUN([GSSAPI_CHECK_BUILD],[
  937. gss_old_libs="$LIBS"
  938. LIBS="$LIBS ${GSSAPI_LIBS}"
  939. AC_MSG_CHECKING([GSSAPI compilation with "${GSSAPI_LIBS}"])
  940. AC_LINK_IFELSE([AC_LANG_PROGRAM([
  941. #include <stdlib.h>
  942. #include GSSAPI_HDR],[
  943. OM_uint32 major, minor;
  944. gss_buffer_desc b = GSS_C_EMPTY_BUFFER;
  945. gss_ctx_id_t ctx = GSS_C_NO_CONTEXT;
  946. gss_init_sec_context(&minor, GSS_C_NO_CREDENTIAL, &ctx, GSS_C_NO_NAME, GSS_C_NO_OID,
  947. GSS_C_MUTUAL_FLAG, GSS_C_INDEFINITE, GSS_C_NO_CHANNEL_BINDINGS, NULL, NULL,
  948. NULL, NULL, NULL);])],
  949. [linked_gssapi=yes
  950. AC_MSG_RESULT(yes)],
  951. [linked_gssapi=no
  952. AC_MSG_RESULT(no)])
  953. LIBS="$gss_old_libs"
  954. ])
  955. # Attempt to work out how to build with GSSAPI. Mostly, krb5-config will
  956. # exist and work. Tested on FreeBSD 9, OpenBSD 5.5, NetBSD 6.1.4. Solaris
  957. # has krb5-config but it doesn't do GSSAPI so hard-code the results there.
  958. # Older OpenBSD (I tested 5.2) lacks krb5-config so leave that as an example.
  959. if test "$with_gssapi" != "no"; then
  960. found_gssapi=no
  961. if test "${with_gssapi}" != "yes" -a "${with_gssapi}" != "" ; then
  962. gssapi_root="${with_gssapi}"
  963. else
  964. gssapi_root=""
  965. fi
  966. # First: if they specify GSSAPI_LIBS and/or GSSAPI_CFLAGS then use them.
  967. if test "$GSSAPI_LIBS$GSSAPI_CFLAGS" != ""; then
  968. found_gssapi=yes
  969. fi
  970. # Second: try finding a viable krb5-config that supports gssapi
  971. if test "$found_gssapi" = "no"; then
  972. if test -n "${gssapi_root}"; then
  973. krb5path="${gssapi_root}/bin:$PATH"
  974. else
  975. krb5path="/usr/kerberos/bin:$PATH"
  976. fi
  977. if test -n "$host_alias"; then
  978. AC_PATH_PROG(KRB5_CONFIG, [${host_alias}-krb5-config], [], [$krb5path])
  979. fi
  980. if test "$KRB5_CONFIG" = ""; then
  981. AC_PATH_PROG(KRB5_CONFIG, [krb5-config], [], [$krb5path])
  982. fi
  983. if test "$KRB5_CONFIG" != ""; then
  984. AC_MSG_CHECKING([whether $KRB5_CONFIG supports gssapi])
  985. if "${KRB5_CONFIG}" --cflags gssapi > /dev/null 2>/dev/null; then
  986. AC_MSG_RESULT(yes)
  987. found_gssapi=yes
  988. GSSAPI_LIBS="`"${KRB5_CONFIG}" --libs gssapi`"
  989. GSSAPI_CFLAGS="`"${KRB5_CONFIG}" --cflags gssapi`"
  990. else
  991. AC_MSG_RESULT(no)
  992. fi
  993. fi
  994. fi
  995. # Third: look for <gssapi.h> or <gssapi/gssapi.h> in some likely places,
  996. # and we'll worry about how to *link* it in a moment...
  997. if test "$found_gssapi" = "no"; then
  998. if test -n "${gssapi_root}"; then
  999. if test -r "${with_gssapi}/include/gssapi.h" -o \
  1000. -r "${with_gssapi}/include/gssapi/gssapi.h"; then
  1001. GSSAPI_CFLAGS="-I\"${with_gssapi}/include\""
  1002. fi
  1003. else
  1004. if test -r /usr/kerberos/include/gssapi.h -o \
  1005. -r /usr/kerberos/include/gssapi/gssapi.h; then
  1006. GSSAPI_CFLAGS=-I/usr/kerberos/include
  1007. elif test -r /usr/include/kerberosV/gssapi.h -o \
  1008. -r /usr/include/kerberosV/gssapi/gssapi.h; then
  1009. # OpenBSD 5.2 puts it here
  1010. GSSAPI_CFLAGS=-I/usr/include/kerberosV
  1011. else
  1012. # Maybe it'll Just Work
  1013. GSSAPI_CFLAGS=
  1014. fi
  1015. fi
  1016. fi
  1017. oldcflags="$CFLAGS"
  1018. CFLAGS="$CFLAGS ${GSSAPI_CFLAGS}"
  1019. # OK, now see if we've correctly managed to find gssapi.h at least...
  1020. gssapi_hdr=
  1021. AC_CHECK_HEADER([gssapi/gssapi.h],
  1022. [gssapi_hdr="<gssapi/gssapi.h>"],
  1023. [AC_CHECK_HEADER([gssapi.h],
  1024. [gssapi_hdr="<gssapi.h>"],
  1025. [AC_MSG_WARN([Cannot find <gssapi/gssapi.h> or <gssapi.h>])])])
  1026. # Finally, unless we've already failed, see if we can link it.
  1027. linked_gssapi=no
  1028. if test -n "${gssapi_hdr}"; then
  1029. AC_DEFINE_UNQUOTED(GSSAPI_HDR, $gssapi_hdr, [GSSAPI header])
  1030. if test "$found_gssapi" = "yes"; then
  1031. # We think we have GSSAPI_LIBS already so try it...
  1032. GSSAPI_CHECK_BUILD
  1033. else
  1034. LFLAG=
  1035. if test -n "$gssapi_root"; then
  1036. LFLAG="-L\"${gssapi_root}/lib$libsuff\""
  1037. fi
  1038. # Solaris, HPUX, etc.
  1039. GSSAPI_LIBS="$LFLAG -lgss"
  1040. GSSAPI_CHECK_BUILD
  1041. if test "$linked_gssapi" = "no"; then
  1042. GSSAPI_LIBS="$LFLAG -lgssapi"
  1043. GSSAPI_CHECK_BUILD
  1044. fi
  1045. if test "$linked_gssapi" = "no"; then
  1046. GSSAPI_LIBS="$LFLAG -lgssapi_krb5"
  1047. GSSAPI_CHECK_BUILD
  1048. fi
  1049. if test "$linked_gssapi" = "no"; then
  1050. # OpenBSD 5.2 at least
  1051. GSSAPI_LIBS="$LFLAG -lgssapi -lkrb5 -lcrypto"
  1052. GSSAPI_CHECK_BUILD
  1053. fi
  1054. if test "$linked_gssapi" = "no"; then
  1055. # MIT
  1056. GSSAPI_LIBS="$LFLAG -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err"
  1057. GSSAPI_CHECK_BUILD
  1058. fi
  1059. if test "$linked_gssapi" = "no"; then
  1060. # Heimdal
  1061. GSSAPI_LIBS="$LFLAG -lkrb5 -lcrypto -lasn1 -lcom_err -lroken -lgssapi"
  1062. GSSAPI_CHECK_BUILD
  1063. fi
  1064. if test "$linked_gssapi" = "no"; then
  1065. AC_MSG_WARN([Cannot find GSSAPI. Try setting GSSAPI_LIBS and GSSAPI_CFLAGS manually])
  1066. fi
  1067. fi
  1068. fi
  1069. CFLAGS="$oldcflags"
  1070. if test "$linked_gssapi" = "yes"; then
  1071. AC_DEFINE([HAVE_GSSAPI], 1, [Have GSSAPI support])
  1072. AC_SUBST(GSSAPI_CFLAGS)
  1073. AC_SUBST(GSSAPI_LIBS)
  1074. elif test "$with_gssapi" = ""; then
  1075. AC_MSG_WARN([Building without GSSAPI support]);
  1076. unset GSSAPI_CFLAGS
  1077. unset GSSAPI_LIBS
  1078. else
  1079. AC_MSG_ERROR([GSSAPI support requested but not found. Try setting GSSAPI_LIBS/GSSAPI_CFLAGS])
  1080. fi
  1081. fi
  1082. AM_CONDITIONAL(OPENCONNECT_GSSAPI, [test "$linked_gssapi" = "yes"])
  1083. AC_ARG_WITH([java],
  1084. AS_HELP_STRING([--with-java(=DIR)],
  1085. [Build JNI bindings using jni.h from DIR [default=no]]),
  1086. [], [with_java=no])
  1087. if test "$with_java" = "yes"; then
  1088. AX_JNI_INCLUDE_DIR
  1089. for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS; do
  1090. JNI_CFLAGS="$JNI_CFLAGS -I$JNI_INCLUDE_DIR"
  1091. done
  1092. elif test "$with_java" = "no"; then
  1093. JNI_CFLAGS=""
  1094. else
  1095. JNI_CFLAGS="-I$with_java"
  1096. fi
  1097. if test "x$JNI_CFLAGS" != "x"; then
  1098. oldCFLAGS="$CFLAGS"
  1099. CFLAGS="$CFLAGS $JNI_CFLAGS"
  1100. AC_MSG_CHECKING([jni.h usability])
  1101. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <jni.h>],
  1102. [jint foo = 0; (void)foo;])],
  1103. AC_MSG_RESULT([yes]),
  1104. [AC_MSG_RESULT([no])
  1105. AC_MSG_ERROR([unable to compile JNI test program])])
  1106. CFLAGS="$oldCFLAGS"
  1107. AC_SUBST(JNI_CFLAGS, [$JNI_CFLAGS])
  1108. fi
  1109. AM_CONDITIONAL(OPENCONNECT_JNI, [test "$JNI_CFLAGS" != ""])
  1110. AC_ARG_ENABLE([jni-standalone],
  1111. AS_HELP_STRING([--enable-jni-standalone],
  1112. [build JNI stubs directly into libopenconnect.so [default=no]]),
  1113. [jni_standalone=$enableval],
  1114. [jni_standalone=no])
  1115. AM_CONDITIONAL(JNI_STANDALONE, [test $jni_standalone = yes])
  1116. symver_java=
  1117. if test "$jni_standalone" = "yes" ; then
  1118. symver_java=$(sed -n '/JNIEXPORT/{s/^JNIEXPORT.*\(Java_.*\) *(/\1;/ p}' ${srcdir}/jni.c)
  1119. # Remove the newlines between each item.
  1120. symver_java=$(echo $symver_java)
  1121. fi
  1122. AC_SUBST(SYMVER_JAVA, $symver_java)
  1123. AC_ARG_ENABLE([insecure-debugging],
  1124. AS_HELP_STRING([--enable-insecure-debugging],
  1125. [Enable --servercert=ACCEPT option, and don't logout on SIGINT]),
  1126. [insecure_debugging=yes],[insecure_debugging=no])
  1127. if test "$insecure_debugging" = "yes"; then
  1128. oldcflags="$CFLAGS"
  1129. CFLAGS="$CFLAGS -DINSECURE_DEBUGGING"
  1130. fi
  1131. AC_CHECK_HEADER([if_tun.h],
  1132. [AC_DEFINE([IF_TUN_HDR], ["if_tun.h"], [if_tun.h include path])],
  1133. [AC_CHECK_HEADER([linux/if_tun.h],
  1134. [AC_DEFINE([IF_TUN_HDR], ["linux/if_tun.h"])],
  1135. [AC_CHECK_HEADER([net/if_tun.h],
  1136. [AC_DEFINE([IF_TUN_HDR], ["net/if_tun.h"])],
  1137. [AC_CHECK_HEADER([net/tun/if_tun.h],
  1138. [AC_DEFINE([IF_TUN_HDR], ["net/tun/if_tun.h"])])])])])
  1139. AC_CHECK_HEADER([net/if_utun.h], AC_DEFINE([HAVE_NET_UTUN_H], 1, [Have net/if_utun.h]), ,
  1140. [#include <sys/types.h>])
  1141. AC_ARG_ENABLE([vhost-net],
  1142. AS_HELP_STRING([--enable-vhost-net],
  1143. [Build vhost-net support for tun device acceleration [default=no]]),
  1144. [have_vhost=$enableval])
  1145. if test "$have_vhost" = "yes"; then
  1146. AC_MSG_CHECKING([for vhost-net support])
  1147. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  1148. #include <linux/if_tun.h>
  1149. #include <linux/virtio_net.h>
  1150. #include <linux/vhost.h>
  1151. #include <sys/eventfd.h>
  1152. struct foo {
  1153. struct vring_desc desc;
  1154. struct vring_avail avail;
  1155. struct vring_used used;
  1156. struct virtio_net_hdr_mrg_rxbuf h;
  1157. };
  1158. ],[
  1159. (void)eventfd(0, EFD_CLOEXEC|EFD_NONBLOCK);
  1160. (void)VHOST_NET_F_VIRTIO_NET_HDR;
  1161. (void)VIRTIO_F_VERSION_1;
  1162. (void)TUNSETSNDBUF;
  1163. __sync_synchronize();
  1164. ])],
  1165. [have_vhost=yes
  1166. AC_DEFINE([HAVE_VHOST], 1, [Have vhost])
  1167. AC_MSG_RESULT([yes])],
  1168. [have_vhost=no
  1169. AC_MSG_RESULT([no])])
  1170. fi
  1171. AM_CONDITIONAL(OPENCONNECT_VHOST, [test "$have_vhost" = "yes"])
  1172. AC_CHECK_HEADER([alloca.h], AC_DEFINE([HAVE_ALLOCA_H], 1, [Have alloca.h]))
  1173. AC_CHECK_HEADER([endian.h],
  1174. [AC_DEFINE([ENDIAN_HDR], [<endian.h>], [endian header include path])],
  1175. [AC_CHECK_HEADER([sys/endian.h],
  1176. [AC_DEFINE([ENDIAN_HDR], [<sys/endian.h>])],
  1177. [AC_CHECK_HEADER([sys/isa_defs.h],
  1178. [AC_DEFINE([ENDIAN_HDR], [<sys/isa_defs.h>])])])])
  1179. build_www=yes
  1180. AC_ARG_ENABLE([docs],
  1181. [AS_HELP_STRING([--enable-docs],
  1182. [enable militant API assertions])],
  1183. [build_www=$enableval],
  1184. [])
  1185. if test "${build_www}" = "yes"; then
  1186. AC_PATH_PROGS(PYTHON, [python3 python2 python], [], $PATH:/bin:/usr/bin)
  1187. if test -z "${ac_cv_path_PYTHON}"; then
  1188. AC_MSG_NOTICE([Python not found; not building HTML pages])
  1189. build_www=no
  1190. fi
  1191. fi
  1192. if test "${build_www}" = "yes"; then
  1193. AC_MSG_CHECKING([if groff can create UTF-8 XHTML])
  1194. AC_PATH_PROGS_FEATURE_CHECK([GROFF], [groff],
  1195. [$ac_path_GROFF -t -K UTF-8 -mandoc -Txhtml /dev/null > /dev/null 2>&1 &&
  1196. ac_cv_path_GROFF=$ac_path_GROFF])
  1197. if test -n "$ac_cv_path_GROFF"; then
  1198. AC_MSG_RESULT(yes)
  1199. AC_SUBST(GROFF, ${ac_cv_path_GROFF})
  1200. else
  1201. AC_MSG_RESULT([no. Not building HTML pages])
  1202. build_www=no
  1203. fi
  1204. fi
  1205. AM_CONDITIONAL(BUILD_WWW, [test "${build_www}" = "yes"])
  1206. # Checks for tests
  1207. PKG_CHECK_MODULES([CWRAP], [uid_wrapper, socket_wrapper], have_cwrap=yes, have_cwrap=no)
  1208. AM_CONDITIONAL(HAVE_CWRAP, test "x$have_cwrap" != xno)
  1209. have_python36_flask=no
  1210. if test "$enable_flask_tests" = "yes" -a -n "${ac_cv_path_PYTHON}"; then
  1211. AC_MSG_CHECKING([for Python 3.6+ with Flask module])
  1212. python3 -c 'import sys; assert sys.version_info >= (3,6); import flask' 2>/dev/null
  1213. if test $? -ne 0 ; then
  1214. AC_MSG_RESULT(not found)
  1215. else
  1216. have_python36_flask=yes
  1217. AC_MSG_RESULT(found)
  1218. fi
  1219. fi
  1220. AM_CONDITIONAL(HAVE_PYTHON36_FLASK, test "$have_python36_flask" = yes)
  1221. have_python37_dataclasses=no
  1222. if test "$enable_flask_tests" = "yes" -a -n "${ac_cv_path_PYTHON}"; then
  1223. AC_MSG_CHECKING([for Python 3.7+ or 3.6 with dataclasses backport])
  1224. python3 -c 'import sys; assert sys.version_info >= (3,6); import dataclasses' 2>/dev/null
  1225. if test $? -ne 0 ; then
  1226. AC_MSG_RESULT(not found)
  1227. else
  1228. have_python37_dataclasses=yes
  1229. AC_MSG_RESULT(found)
  1230. fi
  1231. fi
  1232. AM_CONDITIONAL(HAVE_PYTHON37_DATACLASSES, test "$have_python37_dataclasses" = yes)
  1233. if test "$enable_ppp_tests" = "yes"; then
  1234. AC_PATH_PROGS(SOCAT, [socat], [], $PATH:/bin:/usr/bin)
  1235. AC_PATH_PROGS(PPPD, [pppd], [], $PATH:/bin:/usr/bin:/sbin:/usr/sbin/)
  1236. if test -z "${ac_cv_path_SOCAT}" -o -z "${ac_cv_path_PPPD}"; then
  1237. AC_MSG_WARN([socat and/or pppd not found; disabling PPP tests])
  1238. enable_ppp_tests=no
  1239. fi
  1240. fi
  1241. AM_CONDITIONAL(TEST_PPP, [test "$enable_ppp_tests" = "yes"])
  1242. have_netns=no
  1243. AC_PATH_PROG(NUTTCP, nuttcp)
  1244. if test -n "$ac_cv_path_NUTTCP"; then
  1245. AC_PATH_PROG(IP, ip, [], $PATH:/sbin:/usr/sbin)
  1246. if test -n "$ac_cv_path_IP"; then
  1247. AC_MSG_CHECKING([For network namespaces])
  1248. NETNS=openconnect-configure-test-$$
  1249. if ip netns add $NETNS >/dev/null 2>/dev/null; then
  1250. ip netns delete $NETNS
  1251. have_netns=yes
  1252. fi
  1253. AC_MSG_RESULT($have_netns)
  1254. fi
  1255. fi
  1256. AM_CONDITIONAL(HAVE_NETNS, test "x$have_netns" != xno)
  1257. AC_ARG_WITH(asan-broken-tests,
  1258. AS_HELP_STRING([--without-asan-broken-tests], [disable any tests that cannot be run under asan]),
  1259. enable_asan_broken_tests=$withval,
  1260. enable_asan_broken_tests=yes)
  1261. AC_MSG_CHECKING([whether to enable broken in asan tests])
  1262. AC_MSG_RESULT([${enable_asan_broken_tests}])
  1263. AM_CONDITIONAL(DISABLE_ASAN_BROKEN_TESTS, test "x$enable_asan_broken_tests" = xno)
  1264. AC_SUBST([CONFIG_STATUS_DEPENDENCIES],
  1265. ['$(top_srcdir)/po/LINGUAS \
  1266. $(top_srcdir)/openconnect.h \
  1267. $(top_srcdir)/libopenconnect.map.in \
  1268. $(top_srcdir)/openconnect.8.in \
  1269. $(top_srcdir)/tests/softhsm2.conf.in \
  1270. $(top_srcdir)/tests/configs/test-user-cert.config.in \
  1271. $(top_srcdir)/tests/configs/test-user-pass.config.in'])
  1272. RAWLINGUAS=`sed -e "/^#/d" -e "s/#.*//" "${srcdir}/po/LINGUAS"`
  1273. # Remove newlines
  1274. LINGUAS=`echo $RAWLINGUAS`
  1275. AC_SUBST(LINGUAS)
  1276. APIMAJOR="`sed -n 's/^#define OPENCONNECT_API_VERSION_MAJOR \(.*\)/\1/p' ${srcdir}/openconnect.h`"
  1277. APIMINOR="`sed -n 's/^#define OPENCONNECT_API_VERSION_MINOR \(.*\)/\1/p' ${srcdir}/openconnect.h`"
  1278. AC_SUBST(APIMAJOR)
  1279. AC_SUBST(APIMINOR)
  1280. # We want version.c to depend on the files that would affect the
  1281. # output of version.sh. But we cannot assume that they'll exist,
  1282. # and we cannot use $(wildcard) in a non-GNU makefile. So we just
  1283. # depend on the files which happen to exist at configure time.
  1284. GITVERSIONDEPS=
  1285. for a in ${srcdir}/.git/index ${srcdir}/.git/packed-refs \
  1286. ${srcdir}/.git/refs/tags ${srcdir}/.git/HEAD; do
  1287. if test -r $a ; then
  1288. GITVERSIONDEPS="$GITVERSIONDEPS $a"
  1289. fi
  1290. done
  1291. AC_SUBST(GITVERSIONDEPS)
  1292. AC_SUBST(OCSERV_USER, $(whoami))
  1293. AC_SUBST(OCSERV_GROUP, $(groups|cut -f 1 -d ' '))
  1294. AC_CONFIG_FILES(Makefile openconnect.pc po/Makefile www/Makefile \
  1295. libopenconnect.map openconnect.8 www/styles/Makefile \
  1296. www/inc/Makefile www/images/Makefile tests/Makefile \
  1297. tests/softhsm2.conf tests/configs/test-user-cert.config \
  1298. tests/configs/test-user-pass.config)
  1299. AC_OUTPUT
  1300. AC_DEFUN([SUMMARY],
  1301. [pretty="$2"
  1302. if test "$pretty" = "openssl"; then
  1303. pretty=OpenSSL
  1304. elif test "$pretty" = "gnutls" -o "$pretty" = "both"; then
  1305. pretty=GnuTLS
  1306. elif test "$pretty" = ""; then
  1307. pretty=no
  1308. fi
  1309. echo "AS_HELP_STRING([$1:],[$pretty])"])
  1310. echo "BUILD OPTIONS:"
  1311. SUMMARY([SSL library], [$ssl_library])
  1312. SUMMARY([[PKCS#11 support]], [$pkcs11_support])
  1313. if test "$ssl_library" = "GnuTLS"; then
  1314. SUMMARY([TSS2 library], [$tss2lib])
  1315. fi
  1316. SUMMARY([DTLS support], [$dtls])
  1317. SUMMARY([ESP support], [$esp])
  1318. SUMMARY([HPKE support], [$hpke])
  1319. SUMMARY([libproxy support], [$libproxy_pkg])
  1320. SUMMARY([RSA SecurID support], [$libstoken_pkg])
  1321. SUMMARY([PSKC OATH file support], [$libpskc_pkg])
  1322. SUMMARY([GSSAPI support], [$linked_gssapi])
  1323. SUMMARY([vhost-net support], [$have_vhost])
  1324. SUMMARY([Yubikey support], [$libpcsclite_pkg])
  1325. SUMMARY([JSON parser], [$json])
  1326. SUMMARY([LZ4 compression], [$lz4_pkg])
  1327. SUMMARY([Java bindings], [$with_java])
  1328. SUMMARY([Build docs], [$build_www])
  1329. SUMMARY([Unit tests], [$have_cwrap])
  1330. SUMMARY([Net namespace tests], [$have_netns])
  1331. SUMMARY([DSA tests], [$enable_dsa_tests])
  1332. SUMMARY([PPP tests], [$enable_ppp_tests])
  1333. SUMMARY([Flask tests], [$have_python36_flask])
  1334. SUMMARY([Insecure debugging], [$insecure_debugging])
  1335. SUMMARY([NSIS installer], [$build_nsis])
  1336. if test "$ssl_library" = "OpenSSL"; then
  1337. AC_MSG_WARN([[
  1338. ***
  1339. *** Be sure to run "make check" to verify OpenSSL DTLS support
  1340. *** ]])
  1341. fi