configure.ac 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445
  1. dnl OpenVPN -- An application to securely tunnel IP networks
  2. dnl over a single UDP port, with support for SSL/TLS-based
  3. dnl session authentication and key exchange,
  4. dnl packet encryption, packet authentication, and
  5. dnl packet compression.
  6. dnl
  7. dnl Copyright (C) 2002-2018 OpenVPN Inc <sales@openvpn.net>
  8. dnl Copyright (C) 2006-2012 Alon Bar-Lev <alon.barlev@gmail.com>
  9. dnl
  10. dnl This program is free software; you can redistribute it and/or modify
  11. dnl it under the terms of the GNU General Public License as published by
  12. dnl the Free Software Foundation; either version 2 of the License, or
  13. dnl (at your option) any later version.
  14. dnl
  15. dnl This program is distributed in the hope that it will be useful,
  16. dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. dnl GNU General Public License for more details.
  19. dnl
  20. dnl You should have received a copy of the GNU General Public License along
  21. dnl with this program; if not, write to the Free Software Foundation, Inc.,
  22. dnl 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23. dnl Process this file with autoconf to produce a configure script.
  24. AC_PREREQ(2.59)
  25. m4_include(version.m4)
  26. AC_INIT([PRODUCT_NAME], [PRODUCT_VERSION], [PRODUCT_BUGREPORT], [PRODUCT_TARNAME])
  27. m4_include(compat.m4)
  28. AC_DEFINE([OPENVPN_VERSION_RESOURCE], [PRODUCT_VERSION_RESOURCE], [Version in windows resource format])
  29. AC_SUBST([OPENVPN_VERSION_MAJOR], [PRODUCT_VERSION_MAJOR], [OpenVPN major version])
  30. AC_SUBST([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor version])
  31. AC_SUBST([OPENVPN_VERSION_PATCH], [PRODUCT_VERSION_PATCH], [OpenVPN patch level - may be a string or integer])
  32. AC_DEFINE([OPENVPN_VERSION_MAJOR], [PRODUCT_VERSION_MAJOR], [OpenVPN major version - integer])
  33. AC_DEFINE([OPENVPN_VERSION_MINOR], [PRODUCT_VERSION_MINOR], [OpenVPN minor version - integer])
  34. AC_DEFINE([OPENVPN_VERSION_PATCH], ["PRODUCT_VERSION_PATCH"], [OpenVPN patch level - may be a string or integer])
  35. AC_CONFIG_AUX_DIR([.])
  36. AC_CONFIG_HEADERS([config.h include/openvpn-plugin.h])
  37. AC_CONFIG_SRCDIR([src/openvpn/syshead.h])
  38. AC_CONFIG_MACRO_DIR([m4])
  39. dnl Initialize automake. automake < 1.12 didn't have serial-tests and
  40. dnl gives an error if it sees this, but for automake >= 1.13
  41. dnl serial-tests is required so we have to include it. Solution is to
  42. dnl test for the version of automake (by running an external command)
  43. dnl and provide it if necessary. Note we have to do this entirely using
  44. dnl m4 macros since automake queries this macro by running
  45. dnl 'autoconf --trace ...'.
  46. m4_define([serial_tests], [
  47. m4_esyscmd([automake --version |
  48. head -1 |
  49. awk '{split ($NF,a,"."); if (a[1] == 1 && a[2] >= 12) { print "serial-tests" }}'
  50. ])
  51. ])
  52. AM_INIT_AUTOMAKE(foreign serial_tests) dnl NB: Do not [quote] this parameter.
  53. AC_CANONICAL_HOST
  54. AC_USE_SYSTEM_EXTENSIONS
  55. AC_ARG_ENABLE(
  56. [lzo],
  57. [AS_HELP_STRING([--disable-lzo], [disable LZO compression support @<:@default=yes@:>@])],
  58. ,
  59. [enable_lzo="yes"]
  60. )
  61. AC_ARG_ENABLE(lz4,
  62. [ --disable-lz4 Disable LZ4 compression support],
  63. [enable_lz4="$enableval"],
  64. [enable_lz4="yes"]
  65. )
  66. AC_ARG_ENABLE(comp-stub,
  67. [ --enable-comp-stub Don't compile compression support but still allow limited interoperability with compression-enabled peers],
  68. [enable_comp_stub="$enableval"],
  69. [enable_comp_stub="no"]
  70. )
  71. AC_ARG_ENABLE(
  72. [crypto],
  73. [AS_HELP_STRING([--disable-crypto], [disable crypto support @<:@default=yes@:>@])],
  74. ,
  75. [enable_crypto="yes"]
  76. )
  77. AC_ARG_ENABLE(
  78. [ofb-cfb],
  79. [AS_HELP_STRING([--disable-ofb-cfb], [disable support for OFB and CFB cipher modes @<:@default=yes@:>@])],
  80. ,
  81. [enable_crypto_ofb_cfb="yes"]
  82. )
  83. AC_ARG_ENABLE(
  84. [x509-alt-username],
  85. [AS_HELP_STRING([--enable-x509-alt-username], [enable the --x509-username-field feature @<:@default=no@:>@])],
  86. ,
  87. [enable_x509_alt_username="no"]
  88. )
  89. AC_ARG_ENABLE(
  90. [server],
  91. [AS_HELP_STRING([--disable-server], [disable server support only (but retain client support) @<:@default=yes@:>@])],
  92. ,
  93. [enable_server="yes"]
  94. )
  95. AC_ARG_ENABLE(
  96. [plugins],
  97. [AS_HELP_STRING([--disable-plugins], [disable plug-in support @<:@default=yes@:>@])],
  98. ,
  99. [enable_plugins="yes"]
  100. )
  101. AC_ARG_ENABLE(
  102. [management],
  103. [AS_HELP_STRING([--disable-management], [disable management server support @<:@default=yes@:>@])],
  104. ,
  105. [enable_management="yes"]
  106. )
  107. AC_ARG_ENABLE(
  108. [pkcs11],
  109. [AS_HELP_STRING([--enable-pkcs11], [enable pkcs11 support @<:@default=no@:>@])],
  110. ,
  111. [enable_pkcs11="no"]
  112. )
  113. AC_ARG_ENABLE(
  114. [fragment],
  115. [AS_HELP_STRING([--disable-fragment], [disable internal fragmentation support (--fragment) @<:@default=yes@:>@])],
  116. ,
  117. [enable_fragment="yes"]
  118. )
  119. AC_ARG_ENABLE(
  120. [multihome],
  121. [AS_HELP_STRING([--disable-multihome], [disable multi-homed UDP server support (--multihome) @<:@default=yes@:>@])],
  122. ,
  123. [enable_multihome="yes"]
  124. )
  125. AC_ARG_ENABLE(
  126. [port-share],
  127. [AS_HELP_STRING([--disable-port-share], [disable TCP server port-share support (--port-share) @<:@default=yes@:>@])],
  128. ,
  129. [enable_port_share="yes"]
  130. )
  131. AC_ARG_ENABLE(
  132. [debug],
  133. [AS_HELP_STRING([--disable-debug], [disable debugging support (disable gremlin and verb 7+ messages) @<:@default=yes@:>@])],
  134. ,
  135. [enable_debug="yes"]
  136. )
  137. AC_ARG_ENABLE(
  138. [small],
  139. [AS_HELP_STRING([--enable-small], [enable smaller executable size (disable OCC, usage message, and verb 4 parm list) @<:@default=no@:>@])],
  140. ,
  141. [enable_small="no"]
  142. )
  143. AC_ARG_ENABLE(
  144. [iproute2],
  145. [AS_HELP_STRING([--enable-iproute2], [enable support for iproute2 @<:@default=no@:>@])],
  146. ,
  147. [enable_iproute2="no"]
  148. )
  149. AC_ARG_ENABLE(
  150. [def-auth],
  151. [AS_HELP_STRING([--disable-def-auth], [disable deferred authentication @<:@default=yes@:>@])],
  152. ,
  153. [enable_def_auth="yes"]
  154. )
  155. AC_ARG_ENABLE(
  156. [pf],
  157. [AS_HELP_STRING([--disable-pf], [disable internal packet filter @<:@default=yes@:>@])],
  158. ,
  159. [enable_pf="yes"]
  160. )
  161. AC_ARG_ENABLE(
  162. [plugin-auth-pam],
  163. [AS_HELP_STRING([--disable-plugin-auth-pam], [disable auth-pam plugin @<:@default=platform specific@:>@])],
  164. ,
  165. [
  166. case "$host" in
  167. *-*-openbsd*) enable_plugin_auth_pam="no";;
  168. *-mingw*) enable_plugin_auth_pam="no";;
  169. *) enable_plugin_auth_pam="yes";;
  170. esac
  171. ]
  172. )
  173. AC_ARG_ENABLE(
  174. [plugin-down-root],
  175. [AS_HELP_STRING([--disable-plugin-down-root], [disable down-root plugin @<:@default=platform specific@:>@])],
  176. ,
  177. [
  178. case "$host" in
  179. *-mingw*) enable_plugin_down_root="no";;
  180. *) enable_plugin_down_root="yes";;
  181. esac
  182. ]
  183. )
  184. AC_ARG_ENABLE(
  185. [pam-dlopen],
  186. [AS_HELP_STRING([--enable-pam-dlopen], [dlopen libpam @<:@default=no@:>@])],
  187. ,
  188. [enable_pam_dlopen="no"]
  189. )
  190. AC_ARG_ENABLE(
  191. [strict],
  192. [AS_HELP_STRING([--enable-strict], [enable strict compiler warnings (debugging option) @<:@default=no@:>@])],
  193. ,
  194. [enable_strict="no"]
  195. )
  196. AC_ARG_ENABLE(
  197. [pedantic],
  198. [AS_HELP_STRING([--enable-pedantic], [enable pedantic compiler warnings, will not generate a working executable (debugging option) @<:@default=no@:>@])],
  199. ,
  200. [enable_pedantic="no"]
  201. )
  202. AC_ARG_ENABLE(
  203. [werror],
  204. [AS_HELP_STRING([--enable-werror], [promote compiler warnings to errors, will cause builds to fail if the compiler issues warnings (debugging option) @<:@default=no@:>@])],
  205. ,
  206. [enable_werror="no"]
  207. )
  208. AC_ARG_ENABLE(
  209. [strict-options],
  210. [AS_HELP_STRING([--enable-strict-options], [enable strict options check between peers (debugging option) @<:@default=no@:>@])],
  211. ,
  212. [enable_strict_options="no"]
  213. )
  214. AC_ARG_ENABLE(
  215. [selinux],
  216. [AS_HELP_STRING([--enable-selinux], [enable SELinux support @<:@default=no@:>@])],
  217. ,
  218. [enable_selinux="no"]
  219. )
  220. AC_ARG_ENABLE(
  221. [systemd],
  222. [AS_HELP_STRING([--enable-systemd], [enable systemd suppport @<:@default=no@:>@])],
  223. ,
  224. [enable_systemd="no"]
  225. )
  226. AC_ARG_ENABLE(
  227. [async-push],
  228. [AS_HELP_STRING([--enable-async-push], [enable async-push support for plugins providing deferred authentication @<:@default=no@:>@])],
  229. ,
  230. [enable_async_push="no"]
  231. )
  232. AC_ARG_WITH(
  233. [special-build],
  234. [AS_HELP_STRING([--with-special-build=STRING], [specify special build string])],
  235. [test -n "${withval}" && AC_DEFINE_UNQUOTED([CONFIGURE_SPECIAL_BUILD], ["${withval}"], [special build string])]
  236. )
  237. AC_ARG_WITH(
  238. [mem-check],
  239. [AS_HELP_STRING([--with-mem-check=TYPE], [build with debug memory checking, TYPE=no|dmalloc|valgrind|ssl @<:@default=no@:>@])],
  240. [
  241. case "${withval}" in
  242. dmalloc|valgrind|ssl|no) ;;
  243. *) AC_MSG_ERROR([bad value ${withval} for --mem-check]) ;;
  244. esac
  245. ],
  246. [with_mem_check="no"]
  247. )
  248. AC_ARG_WITH(
  249. [crypto-library],
  250. [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|mbedtls @<:@default=openssl@:>@])],
  251. [
  252. case "${withval}" in
  253. openssl|mbedtls) ;;
  254. *) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;;
  255. esac
  256. ],
  257. [with_crypto_library="openssl"]
  258. )
  259. AC_ARG_VAR([PLUGINDIR], [Path of plug-in directory @<:@default=LIBDIR/openvpn/plugins@:>@])
  260. if test -n "${PLUGINDIR}"; then
  261. plugindir="${PLUGINDIR}"
  262. else
  263. plugindir="\${libdir}/openvpn/plugins"
  264. fi
  265. AC_DEFINE_UNQUOTED([TARGET_ALIAS], ["${host}"], [A string representing our host])
  266. case "$host" in
  267. *-*-linux*)
  268. AC_DEFINE([TARGET_LINUX], [1], [Are we running on Linux?])
  269. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["L"], [Target prefix])
  270. ;;
  271. *-*-solaris*)
  272. AC_DEFINE([TARGET_SOLARIS], [1], [Are we running on Solaris?])
  273. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["S"], [Target prefix])
  274. CPPFLAGS="$CPPFLAGS -D_XPG4_2"
  275. ;;
  276. *-*-openbsd*)
  277. AC_DEFINE([TARGET_OPENBSD], [1], [Are we running on OpenBSD?])
  278. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["O"], [Target prefix])
  279. ;;
  280. *-*-freebsd*)
  281. AC_DEFINE([TARGET_FREEBSD], [1], [Are we running on FreeBSD?])
  282. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["F"], [Target prefix])
  283. ;;
  284. *-*-netbsd*)
  285. AC_DEFINE([TARGET_NETBSD], [1], [Are we running NetBSD?])
  286. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["N"], [Target prefix])
  287. ;;
  288. *-*-darwin*)
  289. AC_DEFINE([TARGET_DARWIN], [1], [Are we running on Mac OS X?])
  290. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["M"], [Target prefix])
  291. have_tap_header="yes"
  292. ac_cv_type_struct_in_pktinfo=no
  293. ;;
  294. *-mingw*)
  295. AC_DEFINE([TARGET_WIN32], [1], [Are we running WIN32?])
  296. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["W"], [Target prefix])
  297. CPPFLAGS="${CPPFLAGS} -DWIN32_LEAN_AND_MEAN"
  298. CPPFLAGS="${CPPFLAGS} -DNTDDI_VERSION=NTDDI_VISTA -D_WIN32_WINNT=_WIN32_WINNT_VISTA"
  299. WIN32=yes
  300. ;;
  301. *-*-dragonfly*)
  302. AC_DEFINE([TARGET_DRAGONFLY], [1], [Are we running on DragonFlyBSD?])
  303. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["D"], [Target prefix])
  304. ;;
  305. *-aix*)
  306. AC_DEFINE([TARGET_AIX], [1], [Are we running AIX?])
  307. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["A"], [Target prefix])
  308. ROUTE="/usr/sbin/route"
  309. have_tap_header="yes"
  310. ac_cv_header_net_if_h="no" # exists, but breaks things
  311. ;;
  312. *)
  313. AC_DEFINE_UNQUOTED([TARGET_PREFIX], ["X"], [Target prefix])
  314. have_tap_header="yes"
  315. ;;
  316. esac
  317. PKG_PROG_PKG_CONFIG
  318. AC_PROG_CPP
  319. AC_PROG_INSTALL
  320. AC_PROG_LN_S
  321. AC_PROG_SED
  322. AC_PROG_MAKE_SET
  323. AC_ARG_VAR([IFCONFIG], [full path to ipconfig utility])
  324. AC_ARG_VAR([ROUTE], [full path to route utility])
  325. AC_ARG_VAR([IPROUTE], [full path to ip utility])
  326. AC_ARG_VAR([NETSTAT], [path to netstat utility]) # tests
  327. AC_ARG_VAR([MAN2HTML], [path to man2html utility])
  328. AC_ARG_VAR([GIT], [path to git utility])
  329. AC_ARG_VAR([SYSTEMD_ASK_PASSWORD], [path to systemd-ask-password utility])
  330. AC_ARG_VAR([SYSTEMD_UNIT_DIR], [Path of systemd unit directory @<:@default=LIBDIR/systemd/system@:>@])
  331. AC_ARG_VAR([TMPFILES_DIR], [Path of tmpfiles directory @<:@default=LIBDIR/tmpfiles.d@:>@])
  332. AC_PATH_PROGS([IFCONFIG], [ifconfig],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
  333. AC_PATH_PROGS([ROUTE], [route],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
  334. AC_PATH_PROGS([IPROUTE], [ip],, [$PATH:/usr/local/sbin:/usr/sbin:/sbin])
  335. AC_PATH_PROGS([SYSTEMD_ASK_PASSWORD], [systemd-ask-password],, [$PATH:/usr/local/bin:/usr/bin:/bin])
  336. AC_CHECK_PROGS([NETSTAT], [netstat], [netstat], [$PATH:/usr/local/sbin:/usr/sbin:/sbin:/etc]) # tests
  337. AC_CHECK_PROGS([MAN2HTML], [man2html])
  338. AC_CHECK_PROGS([GIT], [git]) # optional
  339. AC_DEFINE_UNQUOTED([IFCONFIG_PATH], ["$IFCONFIG"], [Path to ifconfig tool])
  340. AC_DEFINE_UNQUOTED([IPROUTE_PATH], ["$IPROUTE"], [Path to iproute tool])
  341. AC_DEFINE_UNQUOTED([ROUTE_PATH], ["$ROUTE"], [Path to route tool])
  342. AC_DEFINE_UNQUOTED([SYSTEMD_ASK_PASSWORD_PATH], ["$SYSTEMD_ASK_PASSWORD"], [Path to systemd-ask-password tool])
  343. # Set -std=c99 unless user already specified a -std=
  344. case "${CFLAGS}" in
  345. *-std=*) ;;
  346. *) CFLAGS="${CFLAGS} -std=c99" ;;
  347. esac
  348. #
  349. # Libtool
  350. #
  351. ifdef(
  352. [LT_INIT],
  353. [
  354. LT_INIT([win32-dll])
  355. LT_LANG([Windows Resource])
  356. ],
  357. [
  358. AC_LIBTOOL_WIN32_DLL
  359. AC_LIBTOOL_RC
  360. AC_PROG_LIBTOOL
  361. ]
  362. )
  363. AC_C_CONST
  364. AC_C_INLINE
  365. AC_C_VOLATILE
  366. AC_TYPE_OFF_T
  367. AC_TYPE_PID_T
  368. AC_TYPE_SIZE_T
  369. AC_TYPE_UID_T
  370. AC_TYPE_INT8_T
  371. AC_TYPE_INT16_T
  372. AC_TYPE_INT32_T
  373. AC_TYPE_INT64_T
  374. AC_TYPE_UINT8_T
  375. AC_TYPE_UINT16_T
  376. AC_TYPE_UINT32_T
  377. AC_TYPE_UINT64_T
  378. AC_TYPE_SIGNAL
  379. AX_CPP_VARARG_MACRO_ISO
  380. AX_CPP_VARARG_MACRO_GCC
  381. AX_TYPE_SOCKLEN_T
  382. AX_EMPTY_ARRAY
  383. AC_CHECK_SIZEOF([unsigned int])
  384. AC_CHECK_SIZEOF([unsigned long])
  385. AC_CHECK_HEADERS([ \
  386. stdio.h stdarg.h limits.h \
  387. time.h errno.h fcntl.h io.h direct.h \
  388. ctype.h sys/types.h sys/socket.h \
  389. signal.h unistd.h dlfcn.h \
  390. netinet/in.h netinet/in_systm.h \
  391. netinet/tcp.h arpa/inet.h netdb.h \
  392. windows.h winsock2.h ws2tcpip.h \
  393. versionhelpers.h \
  394. ])
  395. AC_CHECK_HEADERS([ \
  396. sys/time.h sys/ioctl.h sys/stat.h \
  397. sys/mman.h sys/file.h sys/wait.h \
  398. unistd.h signal.h libgen.h stropts.h \
  399. syslog.h pwd.h grp.h \
  400. sys/sockio.h sys/uio.h linux/sockios.h \
  401. linux/types.h sys/poll.h sys/epoll.h err.h \
  402. ])
  403. SOCKET_INCLUDES="
  404. #ifdef HAVE_STDLIB_H
  405. #include <stdlib.h>
  406. #endif
  407. #ifdef HAVE_SYS_TYPES_H
  408. #include <sys/types.h>
  409. #endif
  410. #ifdef HAVE_SYS_SOCKET_H
  411. #include <sys/socket.h>
  412. #endif
  413. #ifdef HAVE_NET_IF_H
  414. #include <net/if.h>
  415. #endif
  416. #ifdef HAVE_NETINET_IN_H
  417. #include <netinet/in.h>
  418. #endif
  419. #ifdef HAVE_WINDOWS_H
  420. #include <windows.h>
  421. #endif
  422. #ifdef HAVE_WINSOCK2_H
  423. #include <winsock2.h>
  424. #endif
  425. #ifdef HAVE_WS2TCPIP_H
  426. #include <ws2tcpip.h>
  427. #endif
  428. #ifdef HAVE_NETINET_IN_SYSTM_H
  429. #include <netinet/in_systm.h>
  430. #endif
  431. #ifdef HAVE_NETINET_IP_H
  432. #include <netinet/ip.h>
  433. #endif
  434. "
  435. AC_CHECK_HEADERS(
  436. [net/if.h netinet/ip.h resolv.h sys/un.h net/if_utun.h sys/kern_control.h],
  437. ,
  438. ,
  439. [[${SOCKET_INCLUDES}]]
  440. )
  441. AC_CHECK_TYPES(
  442. [in_addr_t],
  443. ,
  444. [AC_DEFINE([in_addr_t], [uint32_t], [Workaround missing in_addr_t])],
  445. [[${SOCKET_INCLUDES}]]
  446. )
  447. AC_CHECK_TYPES(
  448. [in_port_t],
  449. ,
  450. [AC_DEFINE([in_port_t], [uint16_t], [Workaround missing in_port_t])],
  451. [[${SOCKET_INCLUDES}]]
  452. )
  453. AC_CHECK_TYPE(
  454. [struct iphdr],
  455. [AC_DEFINE([HAVE_IPHDR], [1], [struct iphdr needed for IPv6 support])],
  456. ,
  457. [[${SOCKET_INCLUDES}]]
  458. )
  459. AC_CHECK_TYPE(
  460. [struct sock_extended_err],
  461. [AC_DEFINE([HAVE_SOCK_EXTENDED_ERR], [1], [struct sock_extended_err needed for extended socket error support])],
  462. ,
  463. [[${SOCKET_INCLUDES}]]
  464. )
  465. AC_CHECK_TYPE(
  466. [struct msghdr],
  467. [AC_DEFINE([HAVE_MSGHDR], [1], [struct msghdr needed for extended socket error support])],
  468. ,
  469. [[${SOCKET_INCLUDES}]]
  470. )
  471. AC_CHECK_TYPE(
  472. [struct cmsghdr],
  473. [AC_DEFINE([HAVE_CMSGHDR], [1], [struct cmsghdr needed for extended socket error support])],
  474. ,
  475. [[${SOCKET_INCLUDES}]]
  476. )
  477. AC_CHECK_TYPE(
  478. [struct in_pktinfo],
  479. [AC_DEFINE([HAVE_IN_PKTINFO], [1], [struct in_pktinfo needed for IP_PKTINFO support])],
  480. ,
  481. [[${SOCKET_INCLUDES}]]
  482. )
  483. AC_CHECK_TYPE(
  484. [sa_family_t],
  485. [AC_DEFINE([HAVE_SA_FAMILY_T], [1], [sa_family_t, needed to hold AF_* info])],
  486. ,
  487. [[${SOCKET_INCLUDES}]]
  488. )
  489. AC_CHECK_MEMBER(
  490. [struct in_pktinfo.ipi_spec_dst],
  491. [AC_DEFINE([HAVE_IPI_SPEC_DST], [1], [struct in_pktinfo.ipi_spec_dst needed for IP_PKTINFO support])],
  492. ,
  493. [[${SOCKET_INCLUDES}]]
  494. )
  495. AC_CHECK_TYPE(
  496. [struct sockaddr_in6],
  497. ,
  498. [AC_MSG_ERROR([struct sockaddr_in6 not found, needed for ipv6 transport support.])],
  499. [[${SOCKET_INCLUDES}]]
  500. )
  501. AC_CHECK_DECLS(
  502. [SO_MARK],
  503. ,
  504. ,
  505. [[${SOCKET_INCLUDES}]]
  506. )
  507. AC_CHECKING([anonymous union support])
  508. AC_COMPILE_IFELSE(
  509. [AC_LANG_PROGRAM(
  510. [[
  511. struct mystruct {
  512. union {
  513. int m1;
  514. char m2;
  515. };
  516. };
  517. ]],
  518. [[
  519. struct mystruct s;
  520. s.m1 = 1; s.m2 = 2;
  521. ]]
  522. )],
  523. [
  524. AC_MSG_RESULT([yes])
  525. AC_DEFINE([HAVE_ANONYMOUS_UNION_SUPPORT], [], [Compiler supports anonymous unions])
  526. ],
  527. [AC_MSG_RESULT([no])]
  528. )
  529. saved_LDFLAGS="$LDFLAGS"
  530. LDFLAGS="$LDFLAGS -Wl,--wrap=exit"
  531. AC_MSG_CHECKING([linker supports --wrap])
  532. AC_LINK_IFELSE(
  533. [AC_LANG_PROGRAM(
  534. [[
  535. void exit(int);
  536. void __real_exit(int);
  537. void __wrap_exit(int i) {
  538. __real_exit(i);
  539. }
  540. ]],
  541. [[
  542. exit(0);
  543. ]]
  544. )],
  545. [
  546. AC_MSG_RESULT([yes])
  547. have_ld_wrap_support=yes
  548. ],
  549. [AC_MSG_RESULT([no])],
  550. )
  551. LDFLAGS="$saved_LDFLAGS"
  552. dnl We emulate signals in Windows
  553. AC_CHECK_DECLS(
  554. [SIGHUP],
  555. ,
  556. [AC_DEFINE([SIGHUP], [1], [SIGHUP replacement])],
  557. [[
  558. #ifdef HAVE_SIGNAL_H
  559. #include <signal.h>
  560. #endif
  561. ]]
  562. )
  563. AC_CHECK_DECLS(
  564. [SIGINT],
  565. ,
  566. [AC_DEFINE([SIGINT], [2], [SIGINT replacement])],
  567. [[
  568. #ifdef HAVE_SIGNAL_H
  569. #include <signal.h>
  570. #endif
  571. ]]
  572. )
  573. AC_CHECK_DECLS(
  574. [SIGUSR1],
  575. ,
  576. [AC_DEFINE([SIGUSR1], [10], [SIGUSR1 replacement])],
  577. [[
  578. #ifdef HAVE_SIGNAL_H
  579. #include <signal.h>
  580. #endif
  581. ]]
  582. )
  583. AC_CHECK_DECLS(
  584. [SIGUSR2],
  585. ,
  586. [AC_DEFINE([SIGUSR2], [12], [SIGUSR2 replacement])],
  587. [[
  588. #ifdef HAVE_SIGNAL_H
  589. #include <signal.h>
  590. #endif
  591. ]]
  592. )
  593. AC_CHECK_DECLS(
  594. [SIGTERM],
  595. ,
  596. [AC_DEFINE([SIGTERM], [15], [SIGTERM replacement])],
  597. [[
  598. #ifdef HAVE_SIGNAL_H
  599. #include <signal.h>
  600. #endif
  601. ]]
  602. )
  603. AC_FUNC_FORK
  604. AC_CHECK_FUNCS([ \
  605. daemon chroot getpwnam setuid nice system getpid dup dup2 \
  606. getpass syslog openlog mlockall getgrnam setgid \
  607. setgroups stat flock readv writev time gettimeofday \
  608. ctime memset vsnprintf strdup \
  609. setsid chdir putenv getpeername unlink \
  610. chsize ftruncate execve getpeereid umask basename dirname access \
  611. epoll_create \
  612. ])
  613. AC_CHECK_LIB(
  614. [dl],
  615. [dlopen],
  616. [DL_LIBS="-ldl"]
  617. )
  618. AC_SUBST([DL_LIBS])
  619. AC_CHECK_LIB(
  620. [nsl],
  621. [inet_ntoa],
  622. [SOCKETS_LIBS="${SOCKETS_LIBS} -lnsl"]
  623. )
  624. AC_CHECK_LIB(
  625. [socket],
  626. [socket],
  627. [SOCKETS_LIBS="${SOCKETS_LIBS} -lsocket"]
  628. )
  629. AC_CHECK_LIB(
  630. [resolv],
  631. [gethostbyname],
  632. [SOCKETS_LIBS="${SOCKETS_LIBS} -lresolv"]
  633. )
  634. AC_SUBST([SOCKETS_LIBS])
  635. old_LIBS="${LIBS}"
  636. LIBS="${LIBS} ${SOCKETS_LIBS}"
  637. AC_CHECK_FUNCS([sendmsg recvmsg])
  638. # Windows use stdcall for winsock so we cannot auto detect these
  639. m4_define(
  640. [SOCKET_FUNCS],
  641. [socket recv recvfrom send sendto listen dnl
  642. accept connect bind select gethostbyname inet_ntoa]dnl
  643. )
  644. m4_define(
  645. [SOCKET_OPT_FUNCS],
  646. [setsockopt getsockopt getsockname poll]dnl
  647. )
  648. if test "${WIN32}" = "yes"; then
  649. # normal autoconf function checking does not find inet_ntop/inet_pton
  650. # because they need to include the actual header file and link ws2_32.dll
  651. LIBS="${LIBS} -lws2_32"
  652. AC_MSG_CHECKING([for MinGW inet_ntop()/inet_pton()])
  653. AC_LINK_IFELSE(
  654. [AC_LANG_PROGRAM(
  655. [[
  656. #include <ws2tcpip.h>
  657. ]],
  658. [[
  659. int r = (int) inet_ntop (0, NULL, NULL, 0);
  660. r += inet_pton(AF_INET, NULL, NULL);
  661. return r;
  662. ]]
  663. )],
  664. [AC_MSG_RESULT([OK])
  665. AC_DEFINE([HAVE_INET_NTOP],[1],[MinGW inet_ntop])
  666. AC_DEFINE([HAVE_INET_PTON],[1],[MinGW inet_pton])
  667. ],
  668. [AC_MSG_RESULT([not found])]
  669. )
  670. m4_foreach(
  671. [F],
  672. m4_split(SOCKET_FUNCS SOCKET_OPT_FUNCS),
  673. m4_define([UF], [[m4_join([_], [HAVE], m4_toupper(F))]])
  674. AC_DEFINE([UF], [1], [Win32 builtin])
  675. )
  676. else
  677. AC_CHECK_FUNCS([inet_ntop inet_pton])
  678. AC_CHECK_FUNCS(
  679. SOCKET_FUNCS,
  680. ,
  681. [AC_MSG_ERROR([Required library function not found])]
  682. )
  683. AC_CHECK_FUNCS(SOCKET_OPT_FUNCS)
  684. fi
  685. LIBS="${old_LIBS}"
  686. # we assume res_init() always exist, but need to find out *where*...
  687. AC_SEARCH_LIBS(__res_init, resolv bind, ,
  688. AC_SEARCH_LIBS(res_9_init, resolv bind, ,
  689. AC_SEARCH_LIBS(res_init, resolv bind, , )))
  690. AC_ARG_VAR([TAP_CFLAGS], [C compiler flags for tap])
  691. old_CFLAGS="${CFLAGS}"
  692. CFLAGS="${CFLAGS} ${TAP_CFLAGS}"
  693. AC_CHECK_HEADERS(
  694. [ \
  695. net/if_tun.h net/tun/if_tun.h \
  696. linux/if_tun.h \
  697. tap-windows.h \
  698. ],
  699. [have_tap_header="yes"]
  700. )
  701. AC_CHECK_DECLS(
  702. [TUNSETPERSIST],
  703. [AC_DEFINE([ENABLE_FEATURE_TUN_PERSIST], [1], [We have persist tun capability])],
  704. ,
  705. [[
  706. #ifdef HAVE_LINUX_IF_TUN_H
  707. #include <linux/if_tun.h>
  708. #endif
  709. ]]
  710. )
  711. CFLAGS="${old_CFLAGS}"
  712. test "${have_tap_header}" = "yes" || AC_MSG_ERROR([no tap header could be found])
  713. AC_CHECK_LIB(
  714. [selinux],
  715. [setcon],
  716. [SELINUX_LIBS="-lselinux"]
  717. )
  718. AC_SUBST([SELINUX_LIBS])
  719. AC_ARG_VAR([LIBPAM_CFLAGS], [C compiler flags for libpam])
  720. AC_ARG_VAR([LIBPAM_LIBS], [linker flags for libpam])
  721. if test -z "${LIBPAM_LIBS}"; then
  722. AC_CHECK_LIB(
  723. [pam],
  724. [pam_start],
  725. [LIBPAM_LIBS="-lpam"]
  726. )
  727. fi
  728. case "${with_mem_check}" in
  729. valgrind)
  730. AC_CHECK_HEADERS(
  731. [valgrind/memcheck.h],
  732. [
  733. CFLAGS="${CFLAGS} -g -fno-inline"
  734. AC_DEFINE(
  735. [USE_VALGRIND],
  736. [1],
  737. [Use valgrind memory debugging library]
  738. )
  739. ],
  740. [AC_MSG_ERROR([valgrind headers not found.])]
  741. )
  742. ;;
  743. dmalloc)
  744. AC_CHECK_HEADERS(
  745. [dmalloc.h],
  746. [AC_CHECK_LIB(
  747. [dmalloc],
  748. [malloc],
  749. [
  750. LIBS="${LIBS} -ldmalloc"
  751. AC_DEFINE(
  752. [DMALLOC],
  753. [1],
  754. [Use dmalloc memory debugging library]
  755. )
  756. ],
  757. [AC_MSG_ERROR([dmalloc library not found.])]
  758. )],
  759. [AC_MSG_ERROR([dmalloc headers not found.])]
  760. )
  761. ;;
  762. ssl)
  763. AC_CHECK_LIB(
  764. [ssl],
  765. [CRYPTO_mem_ctrl],
  766. [
  767. AC_DEFINE(
  768. [CRYPTO_MDEBUG],
  769. [1],
  770. [Use memory debugging function in OpenSSL]
  771. )
  772. AC_MSG_NOTICE([NOTE: OpenSSL library must be compiled with CRYPTO_MDEBUG])
  773. ],
  774. [AC_MSG_ERROR([Memory Debugging function in OpenSSL library not found.])]
  775. )
  776. ;;
  777. esac
  778. PKG_CHECK_MODULES(
  779. [PKCS11_HELPER],
  780. [libpkcs11-helper-1 >= 1.11],
  781. [have_pkcs11_helper="yes"],
  782. []
  783. )
  784. if test "${enable_crypto}" = "yes" -a "${with_crypto_library}" = "openssl"; then
  785. AC_ARG_VAR([OPENSSL_CFLAGS], [C compiler flags for OpenSSL])
  786. AC_ARG_VAR([OPENSSL_LIBS], [linker flags for OpenSSL])
  787. if test -z "${OPENSSL_CFLAGS}" -a -z "${OPENSSL_LIBS}"; then
  788. # if the user did not explicitly specify flags, try to autodetect
  789. PKG_CHECK_MODULES(
  790. [OPENSSL],
  791. [libcrypto >= 0.9.8, libssl >= 0.9.8],
  792. [have_openssl="yes"],
  793. [have_openssl="no"] # Provide if-not-found to prevent erroring out
  794. )
  795. OPENSSL_LIBS=${OPENSSL_LIBS:--lssl -lcrypto}
  796. fi
  797. saved_CFLAGS="${CFLAGS}"
  798. saved_LIBS="${LIBS}"
  799. CFLAGS="${CFLAGS} ${OPENSSL_CFLAGS}"
  800. LIBS="${LIBS} ${OPENSSL_LIBS}"
  801. AC_CHECK_FUNCS([SSL_CTX_new EVP_CIPHER_CTX_set_key_length],
  802. ,
  803. [AC_MSG_ERROR([openssl check failed])]
  804. )
  805. have_openssl_engine="yes"
  806. AC_CHECK_FUNCS(
  807. [ \
  808. ENGINE_load_builtin_engines \
  809. ENGINE_register_all_complete \
  810. ENGINE_cleanup \
  811. ],
  812. ,
  813. [have_openssl_engine="no"; break]
  814. )
  815. if test "${have_openssl_engine}" = "no"; then
  816. AC_CHECK_DECL( [ENGINE_cleanup], [have_openssl_engine="yes"],,
  817. [[
  818. #include <openssl/engine.h>
  819. ]]
  820. )
  821. fi
  822. if test "${have_openssl_engine}" = "yes"; then
  823. AC_DEFINE([HAVE_OPENSSL_ENGINE], [1], [OpenSSL engine support available])
  824. fi
  825. have_crypto_aead_modes="yes"
  826. AC_CHECK_FUNCS(
  827. [EVP_aes_256_gcm],
  828. ,
  829. [have_crypto_aead_modes="no"; break]
  830. )
  831. AC_CHECK_FUNCS(
  832. [ \
  833. HMAC_CTX_new \
  834. HMAC_CTX_free \
  835. HMAC_CTX_reset \
  836. EVP_MD_CTX_new \
  837. EVP_MD_CTX_free \
  838. EVP_MD_CTX_reset \
  839. EVP_CIPHER_CTX_reset \
  840. SSL_CTX_get_default_passwd_cb \
  841. SSL_CTX_get_default_passwd_cb_userdata \
  842. SSL_CTX_set_security_level \
  843. X509_get0_notBefore \
  844. X509_get0_notAfter \
  845. X509_get0_pubkey \
  846. X509_STORE_get0_objects \
  847. X509_OBJECT_free \
  848. X509_OBJECT_get_type \
  849. EVP_PKEY_id \
  850. EVP_PKEY_get0_RSA \
  851. EVP_PKEY_get0_DSA \
  852. EVP_PKEY_get0_EC_KEY \
  853. RSA_set_flags \
  854. RSA_bits \
  855. RSA_get0_key \
  856. RSA_set0_key \
  857. DSA_get0_pqg \
  858. DSA_bits \
  859. RSA_meth_new \
  860. RSA_meth_free \
  861. RSA_meth_set_pub_enc \
  862. RSA_meth_set_pub_dec \
  863. RSA_meth_set_priv_enc \
  864. RSA_meth_set_priv_dec \
  865. RSA_meth_set_init \
  866. RSA_meth_set_sign \
  867. RSA_meth_set_finish \
  868. RSA_meth_set0_app_data \
  869. RSA_meth_get0_app_data \
  870. EC_GROUP_order_bits
  871. ]
  872. )
  873. CFLAGS="${saved_CFLAGS}"
  874. LIBS="${saved_LIBS}"
  875. have_crypto="yes"
  876. AC_DEFINE([ENABLE_CRYPTO_OPENSSL], [1], [Use OpenSSL library])
  877. CRYPTO_CFLAGS="${OPENSSL_CFLAGS}"
  878. CRYPTO_LIBS="${OPENSSL_LIBS}"
  879. elif test "${enable_crypto}" = "yes" -a "${with_crypto_library}" = "mbedtls"; then
  880. AC_ARG_VAR([MBEDTLS_CFLAGS], [C compiler flags for mbedtls])
  881. AC_ARG_VAR([MBEDTLS_LIBS], [linker flags for mbedtls])
  882. saved_CFLAGS="${CFLAGS}"
  883. saved_LIBS="${LIBS}"
  884. if test -z "${MBEDTLS_CFLAGS}" -a -z "${MBEDTLS_LIBS}"; then
  885. # if the user did not explicitly specify flags, try to autodetect
  886. LIBS="${LIBS} -lmbedtls -lmbedx509 -lmbedcrypto"
  887. AC_CHECK_LIB(
  888. [mbedtls],
  889. [mbedtls_ssl_init],
  890. [MBEDTLS_LIBS="-lmbedtls -lmbedx509 -lmbedcrypto"],
  891. [AC_MSG_ERROR([Could not find mbed TLS.])],
  892. [${PKCS11_HELPER_LIBS}]
  893. )
  894. fi
  895. CFLAGS="${MBEDTLS_CFLAGS} ${PKCS11_HELPER_CFLAGS} ${CFLAGS}"
  896. LIBS="${MBEDTLS_LIBS} ${PKCS11_HELPER_LIBS} ${LIBS}"
  897. AC_MSG_CHECKING([mbedtls version])
  898. AC_COMPILE_IFELSE(
  899. [AC_LANG_PROGRAM(
  900. [[
  901. #include <mbedtls/version.h>
  902. ]],
  903. [[
  904. #if MBEDTLS_VERSION_NUMBER < 0x02000000 || MBEDTLS_VERSION_NUMBER >= 0x03000000
  905. #error invalid version
  906. #endif
  907. ]]
  908. )],
  909. [AC_MSG_RESULT([ok])],
  910. [AC_MSG_ERROR([mbed TLS 2.y.z required])]
  911. )
  912. mbedtls_with_pkcs11="no"
  913. AC_COMPILE_IFELSE(
  914. [AC_LANG_PROGRAM(
  915. [[
  916. #include <mbedtls/config.h>
  917. ]],
  918. [[
  919. #ifndef MBEDTLS_PKCS11_C
  920. #error pkcs11 wrapper missing
  921. #endif
  922. ]]
  923. )],
  924. mbedtls_with_pkcs11="yes")
  925. AC_MSG_CHECKING([mbedtls pkcs11 support])
  926. if test "${enable_pkcs11}" = "yes"; then
  927. if test "${mbedtls_with_pkcs11}" = "yes"; then
  928. AC_MSG_RESULT([ok])
  929. else
  930. AC_MSG_ERROR([mbedtls has no pkcs11 wrapper compiled in])
  931. fi
  932. else
  933. if test "${mbedtls_with_pkcs11}" != "yes"; then
  934. AC_MSG_RESULT([ok])
  935. else
  936. AC_MSG_ERROR([mbed TLS compiled with PKCS11, while OpenVPN is not])
  937. fi
  938. fi
  939. have_crypto_aead_modes="yes"
  940. AC_CHECK_FUNCS(
  941. [ \
  942. mbedtls_cipher_write_tag \
  943. mbedtls_cipher_check_tag \
  944. ],
  945. ,
  946. [have_crypto_aead_modes="no"; break]
  947. )
  948. CFLAGS="${saved_CFLAGS}"
  949. LIBS="${saved_LIBS}"
  950. have_crypto="yes"
  951. AC_DEFINE([ENABLE_CRYPTO_MBEDTLS], [1], [Use mbed TLS library])
  952. CRYPTO_CFLAGS="${MBEDTLS_CFLAGS}"
  953. CRYPTO_LIBS="${MBEDTLS_LIBS}"
  954. elif test "${enable_crypto}" = "yes"; then
  955. AC_MSG_ERROR([Invalid crypto library: ${with_crypto_library}])
  956. fi
  957. AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
  958. AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
  959. have_lzo="yes"
  960. if test -z "${LZO_LIBS}"; then
  961. AC_CHECK_LIB(
  962. [lzo2],
  963. [lzo1x_1_15_compress],
  964. [LZO_LIBS="-llzo2"],
  965. [AC_CHECK_LIB(
  966. [lzo],
  967. [lzo1x_1_15_compress],
  968. [LZO_LIBS="-llzo"],
  969. [have_lzo="no"]
  970. )]
  971. )
  972. fi
  973. if test "${have_lzo}" = "yes"; then
  974. saved_CFLAGS="${CFLAGS}"
  975. CFLAGS="${CFLAGS} ${LZO_CFLAGS}"
  976. AC_CHECK_HEADERS(
  977. [lzo/lzoutil.h],
  978. ,
  979. [AC_CHECK_HEADERS(
  980. [lzoutil.h],
  981. ,
  982. [AC_MSG_ERROR([lzoutil.h is missing])]
  983. )]
  984. )
  985. AC_CHECK_HEADERS(
  986. [lzo/lzo1x.h],
  987. ,
  988. [AC_CHECK_HEADERS(
  989. [lzo1x.h],
  990. ,
  991. [AC_MSG_ERROR([lzo1x.h is missing])]
  992. )]
  993. )
  994. CFLAGS="${saved_CFLAGS}"
  995. fi
  996. dnl
  997. dnl check for LZ4 library
  998. dnl
  999. AC_ARG_VAR([LZ4_CFLAGS], [C compiler flags for lz4])
  1000. AC_ARG_VAR([LZ4_LIBS], [linker flags for lz4])
  1001. if test "$enable_lz4" = "yes" && test "$enable_comp_stub" = "no"; then
  1002. if test -z "${LZ4_CFLAGS}" -a -z "${LZ4_LIBS}"; then
  1003. # if the user did not explicitly specify flags, try to autodetect
  1004. PKG_CHECK_MODULES([LZ4],
  1005. [liblz4 >= 1.7.1 liblz4 < 100],
  1006. [have_lz4="yes"],
  1007. [LZ4_LIBS="-llz4"] # If this fails, we will do another test next.
  1008. # We also add set LZ4_LIBS otherwise the
  1009. # linker will not know about the lz4 library
  1010. )
  1011. fi
  1012. saved_CFLAGS="${CFLAGS}"
  1013. saved_LIBS="${LIBS}"
  1014. CFLAGS="${CFLAGS} ${LZ4_CFLAGS}"
  1015. LIBS="${LIBS} ${LZ4_LIBS}"
  1016. # If pkgconfig check failed or LZ4_CFLAGS/LZ4_LIBS env vars
  1017. # are used, check the version directly in the LZ4 include file
  1018. if test "${have_lz4}" != "yes"; then
  1019. AC_CHECK_HEADERS([lz4.h],
  1020. [have_lz4h="yes"],
  1021. [])
  1022. if test "${have_lz4h}" = "yes" ; then
  1023. AC_MSG_CHECKING([additionally if system LZ4 version >= 1.7.1])
  1024. AC_COMPILE_IFELSE(
  1025. [AC_LANG_PROGRAM([[
  1026. #include <lz4.h>
  1027. ]],
  1028. [[
  1029. /* Version encoding: MMNNPP (Major miNor Patch) - see lz4.h for details */
  1030. #if LZ4_VERSION_NUMBER < 10701L
  1031. #error LZ4 is too old
  1032. #endif
  1033. ]]
  1034. )],
  1035. [
  1036. AC_MSG_RESULT([ok])
  1037. have_lz4="yes"
  1038. ],
  1039. [AC_MSG_RESULT([system LZ4 library is too old])]
  1040. )
  1041. fi
  1042. fi
  1043. # Double check we have a few needed functions
  1044. if test "${have_lz4}" = "yes" ; then
  1045. AC_CHECK_LIB([lz4],
  1046. [LZ4_compress_default],
  1047. [],
  1048. [have_lz4="no"])
  1049. AC_CHECK_LIB([lz4],
  1050. [LZ4_decompress_safe],
  1051. [],
  1052. [have_lz4="no"])
  1053. fi
  1054. if test "${have_lz4}" != "yes" ; then
  1055. AC_MSG_RESULT([ usable LZ4 library or header not found, using version in src/compat/compat-lz4.*])
  1056. AC_DEFINE([NEED_COMPAT_LZ4], [1], [use copy of LZ4 source in compat/])
  1057. LZ4_LIBS=""
  1058. fi
  1059. OPTIONAL_LZ4_CFLAGS="${LZ4_CFLAGS}"
  1060. OPTIONAL_LZ4_LIBS="${LZ4_LIBS}"
  1061. AC_DEFINE(ENABLE_LZ4, [1], [Enable LZ4 compression library])
  1062. CFLAGS="${saved_CFLAGS}"
  1063. LIBS="${saved_LIBS}"
  1064. fi
  1065. dnl
  1066. dnl Check for systemd
  1067. dnl
  1068. AM_CONDITIONAL([ENABLE_SYSTEMD], [test "${enable_systemd}" = "yes"])
  1069. if test "$enable_systemd" = "yes" ; then
  1070. PKG_CHECK_MODULES([libsystemd], [systemd libsystemd],
  1071. [],
  1072. [PKG_CHECK_MODULES([libsystemd], [libsystemd-daemon])]
  1073. )
  1074. PKG_CHECK_EXISTS( [libsystemd > 216],
  1075. [AC_DEFINE([SYSTEMD_NEWER_THAN_216], [1],
  1076. [systemd is newer than v216])]
  1077. )
  1078. AC_CHECK_HEADERS(systemd/sd-daemon.h,
  1079. ,
  1080. [
  1081. AC_MSG_ERROR([systemd development headers not found.])
  1082. ])
  1083. saved_LIBS="${LIBS}"
  1084. LIBS="${LIBS} ${libsystemd_LIBS}"
  1085. AC_CHECK_FUNCS([sd_booted], [], [AC_MSG_ERROR([systemd library is missing sd_booted()])])
  1086. OPTIONAL_SYSTEMD_LIBS="${libsystemd_LIBS}"
  1087. AC_DEFINE(ENABLE_SYSTEMD, 1, [Enable systemd integration])
  1088. LIBS="${saved_LIBS}"
  1089. if test -n "${SYSTEMD_UNIT_DIR}"; then
  1090. systemdunitdir="${SYSTEMD_UNIT_DIR}"
  1091. else
  1092. systemdunitdir="\${libdir}/systemd/system"
  1093. fi
  1094. if test -n "${TMPFILES_DIR}"; then
  1095. tmpfilesdir="${TMPFILES_DIR}"
  1096. else
  1097. tmpfilesdir="\${libdir}/tmpfiles.d"
  1098. fi
  1099. fi
  1100. AC_MSG_CHECKING([git checkout])
  1101. GIT_CHECKOUT="no"
  1102. if test -n "${GIT}" -a -d "${srcdir}/.git"; then
  1103. AC_DEFINE([HAVE_CONFIG_VERSION_H], [1], [extra version available in config-version.h])
  1104. GIT_CHECKOUT="yes"
  1105. fi
  1106. AC_MSG_RESULT([${GIT_CHECKOUT}])
  1107. if test -n "${SP_PLATFORM_WINDOWS}"; then
  1108. AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['\\\\'], [Path separator]) #"
  1109. AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["\\\\"], [Path separator]) #"
  1110. else
  1111. AC_DEFINE_UNQUOTED([PATH_SEPARATOR], ['/'], [Path separator])
  1112. AC_DEFINE_UNQUOTED([PATH_SEPARATOR_STR], ["/"], [Path separator])
  1113. fi
  1114. dnl enable --x509-username-field feature if requested
  1115. if test "${enable_x509_alt_username}" = "yes"; then
  1116. if test "${with_crypto_library}" = "mbedtls" ; then
  1117. AC_MSG_ERROR([mbed TLS does not support the --x509-username-field feature])
  1118. fi
  1119. AC_DEFINE([ENABLE_X509ALTUSERNAME], [1], [Enable --x509-username-field feature])
  1120. fi
  1121. test "${ac_cv_header_sys_uio_h}" = "yes" && AC_DEFINE([HAVE_IOVEC], [1], [struct iovec needed for IPv6 support])
  1122. test "${enable_server}" = "no" && AC_DEFINE([ENABLE_CLIENT_ONLY], [1], [Enable client capability only])
  1123. test "${enable_management}" = "yes" && AC_DEFINE([ENABLE_MANAGEMENT], [1], [Enable management server capability])
  1124. test "${enable_multihome}" = "yes" && AC_DEFINE([ENABLE_MULTIHOME], [1], [Enable multi-homed UDP server capability])
  1125. test "${enable_debug}" = "yes" && AC_DEFINE([ENABLE_DEBUG], [1], [Enable debugging support])
  1126. test "${enable_small}" = "yes" && AC_DEFINE([ENABLE_SMALL], [1], [Enable smaller executable size])
  1127. test "${enable_fragment}" = "yes" && AC_DEFINE([ENABLE_FRAGMENT], [1], [Enable internal fragmentation support])
  1128. test "${enable_port_share}" = "yes" && AC_DEFINE([ENABLE_PORT_SHARE], [1], [Enable TCP Server port sharing])
  1129. test "${enable_def_auth}" = "yes" && AC_DEFINE([ENABLE_DEF_AUTH], [1], [Enable deferred authentication])
  1130. test "${enable_pf}" = "yes" && AC_DEFINE([ENABLE_PF], [1], [Enable internal packet filter])
  1131. test "${enable_strict_options}" = "yes" && AC_DEFINE([ENABLE_STRICT_OPTIONS_CHECK], [1], [Enable strict options check between peers])
  1132. if test "${enable_crypto}" = "yes"; then
  1133. test "${have_crypto}" != "yes" && AC_MSG_ERROR([${with_crypto_library} crypto is required but missing])
  1134. test "${enable_crypto_ofb_cfb}" = "yes" && AC_DEFINE([ENABLE_OFB_CFB_MODE], [1], [Enable OFB and CFB cipher modes])
  1135. test "${have_crypto_aead_modes}" = "yes" && AC_DEFINE([HAVE_AEAD_CIPHER_MODES], [1], [Use crypto library])
  1136. OPTIONAL_CRYPTO_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${CRYPTO_CFLAGS}"
  1137. OPTIONAL_CRYPTO_LIBS="${OPTIONAL_CRYPTO_LIBS} ${CRYPTO_LIBS}"
  1138. AC_DEFINE([ENABLE_CRYPTO], [1], [Enable crypto library])
  1139. fi
  1140. if test "${enable_plugins}" = "yes"; then
  1141. OPTIONAL_DL_LIBS="${DL_LIBS}"
  1142. AC_DEFINE([ENABLE_PLUGIN], [1], [Enable plug-in support])
  1143. else
  1144. enable_plugin_auth_pam="no"
  1145. enable_plugin_down_root="no"
  1146. fi
  1147. if test "${enable_iproute2}" = "yes"; then
  1148. test -z "${IPROUTE}" && AC_MSG_ERROR([ip utility is required but missing])
  1149. AC_DEFINE([ENABLE_IPROUTE], [1], [enable iproute2 support])
  1150. else
  1151. if test "${WIN32}" != "yes"; then
  1152. test -z "${ROUTE}" && AC_MSG_ERROR([route utility is required but missing])
  1153. test -z "${IFCONFIG}" && AC_MSG_ERROR([ifconfig utility is required but missing])
  1154. fi
  1155. fi
  1156. if test "${enable_selinux}" = "yes"; then
  1157. test -z "${SELINUX_LIBS}" && AC_MSG_ERROR([libselinux required but missing])
  1158. OPTIONAL_SELINUX_LIBS="${SELINUX_LIBS}"
  1159. AC_DEFINE([ENABLE_SELINUX], [1], [SELinux support])
  1160. fi
  1161. if test "${enable_lzo}" = "yes"; then
  1162. test "${have_lzo}" != "yes" && AC_MSG_ERROR([lzo enabled but missing])
  1163. OPTIONAL_LZO_CFLAGS="${LZO_CFLAGS}"
  1164. OPTIONAL_LZO_LIBS="${LZO_LIBS}"
  1165. AC_DEFINE([ENABLE_LZO], [1], [Enable LZO compression library])
  1166. fi
  1167. if test "${enable_comp_stub}" = "yes"; then
  1168. test "${enable_lzo}" = "yes" && AC_MSG_ERROR([Cannot have both comp stub and lzo enabled (use --disable-lzo)])
  1169. test "${enable_lz4}" = "yes" && AC_MSG_ERROR([Cannot have both comp stub and LZ4 enabled (use --disable-lz4)])
  1170. AC_DEFINE([ENABLE_COMP_STUB], [1], [Enable compression stub capability])
  1171. fi
  1172. if test "${enable_pkcs11}" = "yes"; then
  1173. test "${have_pkcs11_helper}" != "yes" && AC_MSG_ERROR([PKCS11 enabled but libpkcs11-helper is missing])
  1174. test "${enable_crypto}" != "yes" && AC_MSG_ERROR([PKCS11 can be enabled only if crypto is enabled])
  1175. OPTIONAL_PKCS11_HELPER_CFLAGS="${PKCS11_HELPER_CFLAGS}"
  1176. OPTIONAL_PKCS11_HELPER_LIBS="${PKCS11_HELPER_LIBS}"
  1177. AC_DEFINE([ENABLE_PKCS11], [1], [Enable PKCS11])
  1178. PKG_CHECK_MODULES(
  1179. [P11KIT],
  1180. [p11-kit-1],
  1181. [proxy_module="`$PKG_CONFIG --variable=proxy_module p11-kit-1`"
  1182. AC_DEFINE_UNQUOTED([DEFAULT_PKCS11_MODULE], "${proxy_module}", [p11-kit proxy])],
  1183. []
  1184. )
  1185. fi
  1186. AC_DEFUN([ACL_CHECK_ADD_COMPILE_FLAGS], [
  1187. old_cflags="$CFLAGS"
  1188. CFLAGS="$1 $CFLAGS"
  1189. AC_MSG_CHECKING([whether the compiler acceppts $1])
  1190. AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [AC_MSG_RESULT([yes])],
  1191. [AC_MSG_RESULT([no]); CFLAGS="$old_cflags"])]
  1192. )
  1193. ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-function])
  1194. ACL_CHECK_ADD_COMPILE_FLAGS([-Wno-unused-parameter])
  1195. ACL_CHECK_ADD_COMPILE_FLAGS([-Wall])
  1196. if test "${enable_pedantic}" = "yes"; then
  1197. enable_strict="yes"
  1198. CFLAGS="${CFLAGS} -pedantic"
  1199. AC_DEFINE([PEDANTIC], [1], [Enable pedantic mode])
  1200. fi
  1201. if test "${enable_strict}" = "yes"; then
  1202. CFLAGS="${CFLAGS} -Wsign-compare -Wuninitialized"
  1203. fi
  1204. if test "${enable_werror}" = "yes"; then
  1205. CFLAGS="${CFLAGS} -Werror"
  1206. fi
  1207. if test "${WIN32}" = "yes"; then
  1208. test -z "${MAN2HTML}" && AC_MSG_ERROR([man2html is required for win32])
  1209. fi
  1210. if test "${enable_plugin_auth_pam}" = "yes"; then
  1211. PLUGIN_AUTH_PAM_CFLAGS="${LIBPAM_CFLAGS}"
  1212. if test "${enable_pam_dlopen}" = "yes"; then
  1213. AC_DEFINE([USE_PAM_DLOPEN], [1], [dlopen libpam])
  1214. PLUGIN_AUTH_PAM_LIBS="${DL_LIBS}"
  1215. else
  1216. test -z "${LIBPAM_LIBS}" && AC_MSG_ERROR([libpam required but missing])
  1217. PLUGIN_AUTH_PAM_LIBS="${LIBPAM_LIBS}"
  1218. fi
  1219. fi
  1220. if test "${enable_async_push}" = "yes"; then
  1221. case "$host" in
  1222. *-*-freebsd*)
  1223. PKG_CHECK_MODULES(
  1224. [OPTIONAL_INOTIFY],
  1225. [libinotify],
  1226. [
  1227. AC_DEFINE([HAVE_SYS_INOTIFY_H])
  1228. AC_DEFINE([ENABLE_ASYNC_PUSH], [1], [Enable async push])
  1229. ]
  1230. )
  1231. ;;
  1232. *)
  1233. AC_CHECK_HEADERS(
  1234. [sys/inotify.h],
  1235. AC_DEFINE([ENABLE_ASYNC_PUSH], [1], [Enable async push]),
  1236. AC_MSG_ERROR([inotify.h not found.])
  1237. )
  1238. ;;
  1239. esac
  1240. fi
  1241. CONFIGURE_DEFINES="`set | grep '^enable_.*=' ; set | grep '^with_.*='`"
  1242. AC_DEFINE_UNQUOTED([CONFIGURE_DEFINES], ["`echo ${CONFIGURE_DEFINES}`"], [Configuration settings])
  1243. TAP_WIN_COMPONENT_ID="PRODUCT_TAP_WIN_COMPONENT_ID"
  1244. TAP_WIN_MIN_MAJOR="PRODUCT_TAP_WIN_MIN_MAJOR"
  1245. TAP_WIN_MIN_MINOR="PRODUCT_TAP_WIN_MIN_MINOR"
  1246. AC_DEFINE_UNQUOTED([TAP_WIN_COMPONENT_ID], ["${TAP_WIN_COMPONENT_ID}"], [The tap-windows id])
  1247. AC_DEFINE_UNQUOTED([TAP_WIN_MIN_MAJOR], [${TAP_WIN_MIN_MAJOR}], [The tap-windows version number is required for OpenVPN])
  1248. AC_DEFINE_UNQUOTED([TAP_WIN_MIN_MINOR], [${TAP_WIN_MIN_MINOR}], [The tap-windows version number is required for OpenVPN])
  1249. AC_SUBST([TAP_WIN_COMPONENT_ID])
  1250. AC_SUBST([TAP_WIN_MIN_MAJOR])
  1251. AC_SUBST([TAP_WIN_MIN_MINOR])
  1252. AC_SUBST([OPTIONAL_DL_LIBS])
  1253. AC_SUBST([OPTIONAL_SELINUX_LIBS])
  1254. AC_SUBST([OPTIONAL_CRYPTO_CFLAGS])
  1255. AC_SUBST([OPTIONAL_CRYPTO_LIBS])
  1256. AC_SUBST([OPTIONAL_LZO_CFLAGS])
  1257. AC_SUBST([OPTIONAL_LZO_LIBS])
  1258. AC_SUBST([OPTIONAL_LZ4_CFLAGS])
  1259. AC_SUBST([OPTIONAL_LZ4_LIBS])
  1260. AC_SUBST([OPTIONAL_SYSTEMD_LIBS])
  1261. AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS])
  1262. AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
  1263. AC_SUBST([OPTIONAL_INOTIFY_CFLAGS])
  1264. AC_SUBST([OPTIONAL_INOTIFY_LIBS])
  1265. AC_SUBST([PLUGIN_AUTH_PAM_CFLAGS])
  1266. AC_SUBST([PLUGIN_AUTH_PAM_LIBS])
  1267. AM_CONDITIONAL([WIN32], [test "${WIN32}" = "yes"])
  1268. AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"])
  1269. AM_CONDITIONAL([ENABLE_PLUGIN_AUTH_PAM], [test "${enable_plugin_auth_pam}" = "yes"])
  1270. AM_CONDITIONAL([ENABLE_PLUGIN_DOWN_ROOT], [test "${enable_plugin_down_root}" = "yes"])
  1271. AM_CONDITIONAL([ENABLE_CRYPTO], [test "${enable_crypto}" = "yes"])
  1272. AM_CONDITIONAL([HAVE_LD_WRAP_SUPPORT], [test "${have_ld_wrap_support}" = "yes"])
  1273. sampledir="\$(docdir)/sample"
  1274. AC_SUBST([plugindir])
  1275. AC_SUBST([sampledir])
  1276. AC_SUBST([systemdunitdir])
  1277. AC_SUBST([tmpfilesdir])
  1278. TEST_LDFLAGS="${OPTIONAL_CRYPTO_LIBS} ${OPTIONAL_PKCS11_HELPER_LIBS} -lcmocka -L\$(top_builddir)/vendor/dist/lib -Wl,-rpath,\$(top_builddir)/vendor/dist/lib"
  1279. TEST_CFLAGS="${OPTIONAL_CRYPTO_CFLAGS} ${OPTIONAL_PKCS11_HELPER_CFLAGS} -I\$(top_srcdir)/include -I\$(top_builddir)/vendor/dist/include"
  1280. AC_SUBST([TEST_LDFLAGS])
  1281. AC_SUBST([TEST_CFLAGS])
  1282. # Check if cmake is available and cmocka git submodule is initialized,
  1283. # needed for unit testing
  1284. AC_CHECK_PROGS([CMAKE], [cmake])
  1285. if test -n "${CMAKE}"; then
  1286. if test -f "${srcdir}/vendor/cmocka/CMakeLists.txt"; then
  1287. AM_CONDITIONAL([CMOCKA_INITIALIZED], [true])
  1288. else
  1289. AM_CONDITIONAL([CMOCKA_INITIALIZED], [false])
  1290. AC_MSG_RESULT([!! WARNING !! The cmoka git submodule has not been initialized or updated. Unit testing cannot be performed.])
  1291. fi
  1292. else
  1293. AC_MSG_RESULT([!! WARNING !! CMake is NOT available. Unit testing cannot be performed.])
  1294. AM_CONDITIONAL([CMOCKA_INITIALIZED], [false])
  1295. fi
  1296. AC_CONFIG_FILES([
  1297. version.sh
  1298. Makefile
  1299. build/Makefile
  1300. build/msvc/Makefile
  1301. build/msvc/msvc-generate/Makefile
  1302. distro/Makefile
  1303. distro/systemd/Makefile
  1304. include/Makefile
  1305. src/Makefile
  1306. src/compat/Makefile
  1307. src/openvpn/Makefile
  1308. src/openvpnserv/Makefile
  1309. src/plugins/Makefile
  1310. src/plugins/auth-pam/Makefile
  1311. src/plugins/down-root/Makefile
  1312. tests/Makefile
  1313. tests/unit_tests/Makefile
  1314. tests/unit_tests/example_test/Makefile
  1315. tests/unit_tests/openvpn/Makefile
  1316. tests/unit_tests/plugins/Makefile
  1317. tests/unit_tests/plugins/auth-pam/Makefile
  1318. vendor/Makefile
  1319. sample/Makefile
  1320. doc/Makefile
  1321. ])
  1322. AC_CONFIG_FILES([tests/t_client.sh], [chmod +x tests/t_client.sh])
  1323. AC_OUTPUT