configure.ac 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. # SPDX-License-Identifier: BSD-2-Clause
  2. # Copyright (c) 2015 - 2020 Intel Corporation
  3. # Copyright (c) 2018 - 2020 Fraunhofer SIT sponsored by Infineon Technologies AG
  4. # All rights reserved.
  5. AC_INIT([tpm2-tss],
  6. [m4_esyscmd_s([git describe --tags --always --dirty])],
  7. [https://github.com/tpm2-software/tpm2-tss/issues],
  8. [],
  9. [https://github.com/tpm2-software/tpm2-tss])
  10. AC_CONFIG_MACRO_DIR([m4])
  11. AM_INIT_AUTOMAKE([foreign
  12. subdir-objects])
  13. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) #Backward compatible setting of "silent-rules"
  14. AC_CONFIG_HEADERS([config.h])
  15. AC_CONFIG_FILES([Makefile Doxyfile lib/tss2-sys.pc lib/tss2-esys.pc lib/tss2-mu.pc lib/tss2-tcti-device.pc lib/tss2-tcti-mssim.pc lib/tss2-tcti-swtpm.pc lib/tss2-tcti-libtpms.pc lib/tss2-tcti-pcap.pc lib/tss2-rc.pc lib/tss2-tctildr.pc lib/tss2-fapi.pc lib/tss2-tcti-cmd.pc])
  16. # propagate configure arguments to distcheck
  17. AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],[$ac_configure_args])
  18. AC_CANONICAL_HOST
  19. AX_IS_RELEASE(dash-version)
  20. AX_CHECK_ENABLE_DEBUG([info])
  21. AC_PROG_CC
  22. AC_PROG_CXX
  23. AC_PROG_LN_S
  24. AC_USE_SYSTEM_EXTENSIONS
  25. LT_INIT()
  26. LT_LIB_DLLOAD
  27. PKG_INSTALLDIR()
  28. # Check OS and set library and compile flags accordingly
  29. case "${host_os}" in
  30. *nto-qnx*)
  31. HOSTOS='QNX'
  32. ADD_COMPILER_FLAG([-D_QNX_SOURCE])
  33. LIBSOCKET_LDFLAGS="-lsocket"
  34. ;;
  35. *bsd* | *BSD*)
  36. HOSTOS='BSD'
  37. LIBSOCKET_LDFLAGS=""
  38. ;;
  39. *)
  40. #Assume linux
  41. HOSTOS='Linux'
  42. LIBSOCKET_LDFLAGS=""
  43. ;;
  44. esac
  45. AC_SUBST([LIBSOCKET_LDFLAGS])
  46. AC_SUBST([HOSTOS])
  47. AM_CONDITIONAL(HOSTOS_LINUX, [test x"$HOSTOS" = xLinux])
  48. # runstatedir is only defined in the yet unreleased Autoconf 2.70
  49. AC_ARG_WITH([runstatedir],
  50. AS_HELP_STRING([--with-runstatedir=<dir>],
  51. [replacement for --runstatedir in Autoconf <2.70]),
  52. [runstatedir="$withval"])
  53. AS_IF([test -z "$runstatedir"], [runstatedir="${localstatedir}/run"])
  54. AC_SUBST([runstatedir])
  55. AX_RECURSIVE_EVAL([$sysconfdir], [SYSCONFDIR])
  56. AC_DEFINE_UNQUOTED([SYSCONFDIR], ["$SYSCONFDIR"], [System config dir])
  57. AC_ARG_WITH([userstatedir],
  58. [AS_HELP_STRING([--with-userstatedir=<dir>],
  59. [sets the relative path in the user's home (default is ".local/share")])],,
  60. [with_userstatedir=.local/share])
  61. AC_SUBST(userstatedir, $with_userstatedir)
  62. AC_ARG_WITH([sysusersdir],
  63. [AS_HELP_STRING([--with-sysusersdir=<dir>],
  64. [sets the sysusers.d directory (default is "${sysconfdir}/sysusers.d")])],,
  65. [with_sysusersdir="${sysconfdir}/sysusers.d"])
  66. AC_SUBST(sysusersdir, $with_sysusersdir)
  67. AC_ARG_WITH([tmpfilesdir],
  68. [AS_HELP_STRING([--with-tmpfilesdir=<dir>],
  69. [sets the tmpfiles.d directory (default is "${sysconfdir}/tmpfiles.d")])],,
  70. [with_tmpfilesdir="${sysconfdir}/tmpfiles.d"])
  71. AC_SUBST(tmpfilesdir, $with_tmpfilesdir)
  72. AC_ARG_ENABLE([unit],
  73. [AS_HELP_STRING([--enable-unit],
  74. [build cmocka unit tests])],,
  75. [enable_unit=no])
  76. m4_define([cmocka_min_version], [1.0])
  77. m4_define([cmocka_err], [Unit test enabled, but cmocka missing or version requirements not met. cmocka version must be >= cmocka_min_version])
  78. AS_IF([test "x$enable_unit" != xno],
  79. [PKG_CHECK_MODULES([CMOCKA],
  80. [cmocka >= cmocka_min_version],,
  81. [AC_MSG_ERROR([cmocka_err])])])
  82. AM_CONDITIONAL([UNIT], [test "x$enable_unit" != xno])
  83. AS_IF([test "x$enable_unit" != xno],
  84. [AC_DEFINE(UNIT, 1, [Enable for UNIT testing])])
  85. AC_ARG_ENABLE([esys],
  86. [AS_HELP_STRING([--disable-esys],
  87. [don't build the esys layer])],,
  88. [enable_esys=yes])
  89. AM_CONDITIONAL(ESYS, test "x$enable_esys" = "xyes")
  90. AC_CHECK_FUNC([strndup],[],[AC_MSG_ERROR([strndup function not found])])
  91. AC_CHECK_FUNCS([reallocarray])
  92. AC_ARG_ENABLE([fapi],
  93. [AS_HELP_STRING([--enable-fapi],
  94. [build the fapi layer (default is yes)])],
  95. [enable_fapi=$enableval],
  96. [enable_fapi=yes])
  97. AM_CONDITIONAL(FAPI, test "x$enable_fapi" = "xyes")
  98. AC_ARG_ENABLE([fapi-async-tests],
  99. AS_HELP_STRING([--enable-fapi-async-tests],
  100. [Force fapi to spin asynchronously. (NOT FOR PRODUCTION!)]),,
  101. [enable_fapi_async_tests=no])
  102. AS_IF([test "x$enable_fapi_async_tests" = "xyes"],
  103. [AC_DEFINE([TEST_FAPI_ASYNC], [1], [FAPI forced async spinning])])
  104. AS_IF([test "x$enable_fapi_async_tests" = "xyes"],
  105. [AC_MSG_WARN("FAPI compiled with asynchronous spinning testing. NOT FOR PRODUCTION!")])
  106. AC_ARG_WITH([crypto],
  107. [AS_HELP_STRING([--with-crypto={ossl,mbed}],
  108. [sets the ESYS crypto backend (default is OpenSSL)])],,
  109. [with_crypto=ossl])
  110. AM_CONDITIONAL(ESYS_OSSL, test "x$with_crypto" = "xossl")
  111. AM_CONDITIONAL(ESYS_MBED, test "x$with_crypto" = "xmbed")
  112. m4_define([ossl_min_version], [1.1.0])
  113. m4_define([ossl_err], [OpenSSL libcrypto is missing or version requirements not met. OpenSSL version must be >= ossl_min_version])
  114. AS_IF([test "x$enable_esys" = xyes],
  115. [AS_IF([test "x$with_crypto" = xossl], [
  116. PKG_CHECK_MODULES([CRYPTO],
  117. [libcrypto >= ossl_min_version],,
  118. [AC_MSG_ERROR([ossl_err])])
  119. AC_DEFINE([OSSL], [1], [OpenSSL cryptographic backend])
  120. AC_CHECK_LIB(crypto,[EVP_sm3], [
  121. AC_DEFINE([HAVE_EVP_SM3], [1], [Support EVP_sm3 in openssl])],
  122. [])
  123. TSS2_ESYS_CFLAGS_CRYPTO="$CRYPTO_CFLAGS"
  124. TSS2_ESYS_LDFLAGS_CRYPTO="$CRYPTO_LIBS"
  125. ], [test "x$with_crypto" = xmbed], [
  126. AC_CHECK_HEADER(mbedtls/md.h, [], [AC_MSG_ERROR([Missing required mbedTLS library])])
  127. AC_DEFINE([MBED], [1], [mbedTLS cryptographic backend])
  128. TSS2_ESYS_CFLAGS_CRYPTO="$LIBMBED_CFLAGS"
  129. TSS2_ESYS_LDFLAGS_CRYPTO="-lmbedcrypto"
  130. ], [AC_MSG_ERROR([Bad value for --with-crypto $with_crypto])])])
  131. AC_SUBST([TSS2_ESYS_CFLAGS_CRYPTO])
  132. AC_SUBST([TSS2_ESYS_LDFLAGS_CRYPTO])
  133. AS_IF([test "x$enable_fapi" != xno && test "x$enable_esys" = "xno"],
  134. [AC_MSG_ERROR([ESYS has to be enabled to compile FAPI.])])
  135. AS_IF([test "x$enable_fapi" != xno && test "x$with_crypto" != "xossl"],
  136. [AC_MSG_ERROR([FAPI has to be compiled with OpenSSL])])
  137. AS_IF([test "x$enable_fapi" = xyes ],
  138. [PKG_CHECK_MODULES([JSONC], [json-c])])
  139. AS_IF([test "x$enable_fapi" = xyes ],
  140. [PKG_CHECK_MODULES([CURL], [libcurl])])
  141. AC_ARG_WITH([tctidefaultmodule],
  142. [AS_HELP_STRING([--with-tctidefaultmodule],
  143. [The default TCTI module for ESYS. (Default: libtss2-tcti-default.so)])],
  144. [AC_DEFINE_UNQUOTED([ESYS_TCTI_DEFAULT_MODULE],
  145. ["$with_tctidefaultmodule"],
  146. ["The default TCTI library file"])],
  147. [with_tctidefaultmodule=libtss2-tcti-default.so])
  148. AC_ARG_WITH([tctidefaultconfig],
  149. [AS_HELP_STRING([--with-tctidefaultconfig],
  150. [The default tcti module's configuration.])],
  151. [AC_DEFINE_UNQUOTED([ESYS_TCTI_DEFAULT_CONFIG],
  152. ["$with_tctidefaultconfig"],
  153. ["The default TCTIs configuration string"])])
  154. AC_ARG_ENABLE([tcti-device],
  155. [AS_HELP_STRING([--disable-tcti-device],
  156. [don't build the tcti-device module])],,
  157. [enable_tcti_device=yes])
  158. AM_CONDITIONAL([ENABLE_TCTI_DEVICE], [test "x$enable_tcti_device" != xno])
  159. AS_IF([test "x$enable_tcti_device" = "xyes"],
  160. [AC_DEFINE([TCTI_DEVICE],[1], [TCTI FOR DEV TPM])])
  161. AC_ARG_ENABLE([tcti-mssim],
  162. [AS_HELP_STRING([--disable-tcti-mssim],
  163. [don't build the tcti-mssim module])],,
  164. [enable_tcti_mssim=yes])
  165. AM_CONDITIONAL([ENABLE_TCTI_MSSIM], [test "x$enable_tcti_mssim" != xno])
  166. AS_IF([test "x$enable_tcti_mssim" = "xyes"],
  167. [AC_DEFINE([TCTI_MSSIM],[1], [TCTI FOR MS SIMULATOR])])
  168. AC_ARG_ENABLE([tcti-swtpm],
  169. [AS_HELP_STRING([--disable-tcti-swtpm],
  170. [don't build the tcti-swtpm module])],,
  171. [enable_tcti_swtpm=yes])
  172. AM_CONDITIONAL([ENABLE_TCTI_SWTPM], [test "x$enable_tcti_swtpm" != xno])
  173. AS_IF([test "x$enable_tcti_swtpm" = "xyes"], [AC_DEFINE([TCTI_SWTPM],[1], [TCTI FOR SWTPM])])
  174. AC_ARG_ENABLE([tcti-pcap],
  175. [AS_HELP_STRING([--disable-tcti-pcap],
  176. [don't build the tcti-pcap module])],,
  177. [enable_tcti_pcap=yes])
  178. AM_CONDITIONAL([ENABLE_TCTI_PCAP], [test "x$enable_tcti_pcap" != xno])
  179. AC_ARG_ENABLE([tcti-libtpms],
  180. [AS_HELP_STRING([--disable-tcti-libtpms],
  181. [don't build the tcti-libtpms module])],
  182. [AS_IF([test "x$enable_tcti_libtpms" = "xyes"],
  183. [AC_CHECK_HEADER(libtpms/tpm_library.h, [], [AC_MSG_ERROR([library libtpms missing])])])],
  184. [AC_CHECK_HEADER(libtpms/tpm_library.h, [enable_tcti_libtpms=yes],
  185. [enable_tcti_libtpms=no]
  186. [AC_MSG_WARN([library libtpms missing])])])
  187. AM_CONDITIONAL([ENABLE_TCTI_LIBTPMS], [test "x$enable_tcti_libtpms" != xno])
  188. AC_ARG_ENABLE([tcti-cmd],
  189. [AS_HELP_STRING([--disable-tcti-cmd],
  190. [don't build the tcti-cmd module])],,
  191. [enable_tcti_cmd=yes])
  192. AM_CONDITIONAL([ENABLE_TCTI_CMD], [test "x$enable_tcti_cmd" != xno])
  193. AS_IF([test "x$enable_tcti_cmd" = "xyes"],
  194. [AC_DEFINE([TCTI_CMD],[1], [TCTI FOR COMMAND BASED ACCESS TO TPM2 DEVICE])])
  195. AC_ARG_ENABLE([tcti-fuzzing],
  196. [AS_HELP_STRING([--enable-tcti-fuzzing],
  197. [build the tcti-fuzzing module])],,
  198. [enable_tcti_fuzzing=no])
  199. AM_CONDITIONAL([ENABLE_TCTI_FUZZING], [test "x$enable_tcti_fuzzing" != xno])
  200. AS_IF([test "x$enable_tcti_fuzzing" = "xyes"],
  201. [AC_DEFINE([TCTI_FUZZING],[1], [TCTI FOR FUZZING])])
  202. AC_ARG_ENABLE([nodl],
  203. [AS_HELP_STRING([--enable-nodl],
  204. [link against TCTIs directly, do not use dlopen])],
  205. [],
  206. [enable_nodl=no])
  207. AM_CONDITIONAL([NO_DL], [test "x$enable_nodl" = "xyes"])
  208. AS_IF([test "x$enable_nodl" = "xyes"],
  209. [AC_DEFINE([NO_DL],[1], [disable use of dlopen])])
  210. #
  211. # udev
  212. #
  213. AC_ARG_WITH([udevrulesdir],
  214. [AS_HELP_STRING([--with-udevrulesdir=DIR],[udev rules directory])],,
  215. [with_udevrulesdir=${libdir}/udev/rules.d])
  216. AX_NORMALIZE_PATH([with_udevrulesdir])
  217. AC_SUBST([udevrulesdir], [$with_udevrulesdir])
  218. AC_ARG_WITH([udevrulesprefix],
  219. [AS_HELP_STRING([--with-udevrulesprefix=XY],[prefix for udev rules file])],
  220. [AC_SUBST([udevrulesprefix],[$with_udevrulesprefix])])
  221. AM_CONDITIONAL(WITH_UDEVRULESPREFIX, [test -n "$with_udevrulesprefix"])
  222. dnl --------- Physical TPM device for testing -----------------------
  223. AC_ARG_WITH([device],
  224. [AS_HELP_STRING([--with-device=<device>],[TPM device for testing])],
  225. [AS_IF([test -w "$with_device" && test -r "$with_device"],
  226. [AC_MSG_RESULT([success])
  227. AX_NORMALIZE_PATH([with_device])
  228. with_device_set=yes],
  229. [AC_MSG_ERROR([TPM device provided does not exist or is not writable])])],
  230. [with_device_set=no])
  231. AM_CONDITIONAL([TESTDEVICE],[test "x$with_device_set" = xyes])
  232. AC_ARG_WITH([devicetests],
  233. [AS_HELP_STRING([--with-devicetests=<case>],[Comma-separated values of possible tests: destructive,mandatory,optional] default is mandatory)],
  234. [AS_IF([test "x" = x$(echo $with_devicetests | sed 's/destructive//g' | sed 's/mandatory//g' | sed 's/optional//g' | sed 's/,//g') ],
  235. [AC_MSG_RESULT([success])
  236. with_devicetests_set=yes],
  237. [AC_MSG_ERROR([Illegal test type for device tests.])])],
  238. [with_devicetests="mandatory"])
  239. if echo $with_devicetests | grep destructive > /dev/null; then
  240. enable_device_destructive="yes"
  241. fi
  242. AM_CONDITIONAL([DEVICEDESTRUCTIVE],[test "x$enable_device_destructive" = "xyes"])
  243. if echo $with_devicetests | grep optional > /dev/null; then
  244. enable_device_optional="yes"
  245. fi
  246. AM_CONDITIONAL([DEVICEOPTIONAL],[test "x$enable_device_optional" = "xyes"])
  247. if echo $with_devicetests | grep mandatory > /dev/null; then
  248. enable_device_mandatory="yes"
  249. fi
  250. AM_CONDITIONAL([DEVICEMANDATORY],[test "x$enable_device_mandatory" = "xyes"])
  251. #
  252. # enable integration tests and check for simulator binary
  253. #
  254. AC_ARG_ENABLE([integration],
  255. [AS_HELP_STRING([--enable-integration],
  256. [build and execute integration tests])],,
  257. [enable_integration=no])
  258. AS_IF([test "x$enable_integration" = "xyes"],
  259. [AS_IF([test "$HOSTOS" = "Linux"],
  260. [ERROR_IF_NO_PROG([ss])],
  261. [ERROR_IF_NO_PROG([sockstat])])
  262. ERROR_IF_NO_PROG([echo])
  263. ERROR_IF_NO_PROG([kill])
  264. ERROR_IF_NO_PROG([stdbuf])
  265. ERROR_IF_NO_PROG([sleep])
  266. ERROR_IF_NO_PROG([cat])
  267. ERROR_IF_NO_PROG([realpath])
  268. ERROR_IF_NO_PROG([dirname])
  269. ERROR_IF_NO_PROG([basename])
  270. ERROR_IF_NO_PROG([mktemp])
  271. ERROR_IF_NO_PROG([od])
  272. ERROR_IF_NO_PROG([awk])
  273. ERROR_IF_NO_PROG([expr])
  274. ERROR_IF_NO_PROG([grep])
  275. ERROR_IF_NO_PROG([env])
  276. ERROR_IF_NO_PROG([rm])
  277. AS_IF([test "x$with_crypto" != xossl || test "x$enable_esys" != xyes],
  278. [PKG_CHECK_MODULES([CRYPTO],[libcrypto])])
  279. AC_CHECK_HEADER(uthash.h, [], [AC_MSG_ERROR([Can not find uthash.h. Please install uthash-dev])])
  280. # choose tcti for testing and look for TPM simulator binary
  281. integration_tcti="none"
  282. integration_args=""
  283. AS_IF([test "x$with_device_set" = xyes],
  284. [# use device if --with-device was passed
  285. integration_tcti=device
  286. integration_args="--device=$with_device"
  287. AC_MSG_WARN([Using physical TPM for integration testing])])
  288. AS_IF([test "x$integration_tcti" = "xnone" && test "x$enable_tcti_swtpm" != xyes && test "x$enable_tcti_mssim" != xyes],
  289. [AC_MSG_ERROR([No suitable TCTI for testing enabled. Please use option --enable-tcti-swtpm (recommended) or --enable-tcti-mssim (fallback) to enable a suitable TCTI or disable testing with --disable-integration.])])
  290. AS_IF([test "x$integration_tcti" = "xnone" && test "x$enable_tcti_swtpm" = "xyes"],
  291. [# check for swtpm binary
  292. AC_CHECK_PROG([result_swtpm], [swtpm], [yes], [no])
  293. AS_IF([test "x$result_swtpm" = "xyes"],
  294. [integration_tcti=swtpm],
  295. [AC_MSG_WARN([Executable swtpm not found in PATH.])])])
  296. AS_IF([test "x$integration_tcti" = "xnone" && test "x$enable_tcti_mssim" = "xyes"],
  297. [# check for mssim binary
  298. AC_MSG_NOTICE([Falling back to testing with tcti-mssim.])
  299. AC_CHECK_PROG([result_tpm_server], [tpm_server], [yes], [no])
  300. AS_IF([test "x$result_tpm_server" = "xyes"],
  301. [integration_tcti=mssim
  302. AC_DEFINE([INTEGRATION_TCTI_MSSIM], [1], [use mssim TCTI for integration tests])],
  303. [AC_MSG_WARN([Executable tpm_server not found in PATH (fallback)])])])
  304. AS_IF([test "x$integration_tcti" = "xnone"],
  305. [AC_MSG_ERROR([No simulator executable found in PATH for testing TCTI.])])
  306. AC_SUBST([INTEGRATION_TCTI], [$integration_tcti])
  307. AC_SUBST([INTEGRATION_ARGS], [$integration_args])
  308. AC_SUBST([ENABLE_INTEGRATION], [$enable_integration])])
  309. AM_CONDITIONAL([ENABLE_INTEGRATION],[test "x$enable_integration" = "xyes"])
  310. #
  311. # sanitizer compiler flags
  312. #
  313. AC_ARG_WITH([sanitizer],
  314. [AS_HELP_STRING([--with-sanitizer={none,address,undefined}],
  315. [build with the given sanitizer])],,
  316. [with_sanitizer=none])
  317. AS_CASE(["x$with_sanitizer"],
  318. ["xnone"],
  319. [],
  320. ["xaddress"],
  321. [
  322. SANITIZER_CFLAGS="-fsanitize=address -fno-omit-frame-pointer"
  323. SANITIZER_LDFLAGS="-lasan"
  324. ],
  325. ["xundefined"],
  326. [
  327. SANITIZER_CFLAGS="-fsanitize=undefined"
  328. SANITIZER_LDFLAGS="-lubsan"
  329. ],
  330. ["xundefined,address"],
  331. [
  332. SANITIZER_CFLAGS="-fsanitize=undefined,address -fno-omit-frame-pointer"
  333. SANITIZER_LDFLAGS="-lasan -lubsan"
  334. ],
  335. [AC_MSG_ERROR([Bad value for --with-sanitizer])])
  336. AC_SUBST([SANITIZER_CFLAGS])
  337. AC_SUBST([SANITIZER_LDFLAGS])
  338. #
  339. # fuzz testing
  340. #
  341. AC_ARG_WITH([fuzzing],
  342. [AS_HELP_STRING([--with-fuzzing={none,libfuzzer,ossfuzz}],
  343. [fuzzing to build with (default is none)])],,
  344. [with_fuzzing=none])
  345. AS_CASE(["x$with_fuzzing"],
  346. ["xnone"],
  347. [],
  348. ["xlibfuzzer"],
  349. [ADD_FUZZING_FLAG([-fsanitize=fuzzer])],
  350. ["xossfuzz"],
  351. [AS_IF([test "x$LIB_FUZZING_ENGINE" = "x"],
  352. [AC_MSG_ERROR([OSS Fuzz testing requires LIB_FUZZING_ENGINE environment variable be set])])
  353. ADD_FUZZING_FLAG([-lFuzzingEngine])],
  354. [AC_MSG_ERROR([Bad value for --with-fuzzing])])
  355. AM_CONDITIONAL([ENABLE_FUZZING],[test "x$with_fuzzing" != "xnone"])
  356. AS_IF([test "x$with_fuzzing" != "xnone"],
  357. [AS_IF([test "x$enable_tcti_fuzzing" = xno],
  358. [AC_MSG_ERROR([Fuzz tests can not be enabled without the TCTI_FUZZING module])])
  359. AS_IF([test "x$GEN_FUZZ" != "x1"],
  360. [AC_MSG_ERROR([Fuzz tests can not be enabled without "GEN_FUZZ=1" variable])])])
  361. AX_VALGRIND_CHECK
  362. gl_LD_VERSION_SCRIPT
  363. AC_ARG_ENABLE([log-file],
  364. [AS_HELP_STRING([--disable-log-file],
  365. [write logging to stderr only])],,
  366. [enable_log_file=yes])
  367. AS_IF([test "x$enable_log_file" != xno],
  368. [AC_DEFINE([LOG_FILE_ENABLED],[1], [Support for writing to a log file is enabled])])
  369. AC_ARG_WITH([maxloglevel],
  370. [AS_HELP_STRING([--with-maxloglevel={none,error,warning,info,debug,trace}],
  371. [sets the maximum log level (default is trace)])],,
  372. [with_maxloglevel=trace])
  373. AS_CASE(["x$with_maxloglevel"],
  374. ["xnone"],
  375. [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [0], ["Logging disabled"])],
  376. ["xerror"],
  377. [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [2], ["Error log level"])],
  378. ["xwarning"],
  379. [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [3], ["Warning log level"])],
  380. ["xinfo"],
  381. [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [4], ["Info log level"])],
  382. ["xdebug"],
  383. [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [5], ["Debug log level"])],
  384. ["xtrace"],
  385. [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [6], ["Trace log level"])],
  386. [AC_MSG_ERROR([Bad value for --with-maxloglevel])])
  387. AC_ARG_ENABLE([defaultflags],
  388. [AS_HELP_STRING([--disable-defaultflags],
  389. [Disable default preprocessor, compiler, and linker flags.])],,
  390. [enable_defaultflags=yes])
  391. AS_IF([test "x$enable_defaultflags" = "xyes"],
  392. [
  393. AS_IF([test "x$enable_debug" = "xno"],
  394. [ADD_COMPILER_FLAG([-O2])
  395. AX_ADD_FORTIFY_SOURCE])
  396. ADD_COMPILER_FLAG([-std=c99])
  397. ADD_COMPILER_FLAG([-Wall])
  398. ADD_COMPILER_FLAG([-Wextra])
  399. ADD_COMPILER_FLAG([-Wformat-security])
  400. AS_IF([test "x$ax_is_release" = "xno"],
  401. [ADD_COMPILER_FLAG([-Werror])])
  402. ADD_COMPILER_FLAG([-fstack-protector-all])
  403. ADD_COMPILER_FLAG([-fpic])
  404. ADD_COMPILER_FLAG([-fPIC])
  405. # work around GCC bug #53119
  406. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
  407. ADD_COMPILER_FLAG([-Wno-missing-braces])
  408. ADD_COMPILER_FLAG([-Wstrict-overflow=5])
  409. ADD_LINK_FLAG([-Wl,--no-undefined])
  410. ADD_LINK_FLAG([-Wl,-z,noexecstack])
  411. ADD_LINK_FLAG([-Wl,-z,now])
  412. ADD_LINK_FLAG([-Wl,-z,relro])
  413. ])
  414. AC_ARG_ENABLE([weakcrypto],
  415. [AS_HELP_STRING([--disable-weakcrypto],
  416. [Disable crypto algorithms considered weak])],,
  417. [enable_weakcrypto=no])
  418. AS_IF([test "x$enable_weakcrypto" = "xyes"],
  419. [AC_DEFINE([DISABLE_WEAK_CRYPTO],[1],[DISABLE WEAK CRYPTO ALGORITHMS])])
  420. AC_ARG_ENABLE([self-generated-certificate],
  421. [AS_HELP_STRING([--enable-self-generated-certificate],
  422. [Alllow usage of self generated root certifcate])],,
  423. [enable_self_generated_certificate=no])
  424. AS_IF([test "x$enable_self_generated_certificate" = xyes],
  425. [AC_DEFINE([SELF_GENERATED_CERTIFICATE], [1], [Allow usage of self generated root certificate])],
  426. [AS_IF([test "x$integration_tcti" != "xdevice"], [AC_DEFINE([FAPI_TEST_EK_CERT_LESS], [1], [Perform integration tests without EK certificate verification])])])
  427. AS_IF([test "x$enable_integration" = "xyes" && test "x$enable_self_generated_certificate" != "xyes" && test "x$integration_tcti" != "xdevice"],
  428. [AC_MSG_WARN([Running integration tests without EK certificate verification, use --enable-self-generated-certificate for full test coverage])])
  429. # Check for systemd helper tools used by make install
  430. AC_CHECK_PROG(systemd_sysusers, systemd-sysusers, yes)
  431. AM_CONDITIONAL(SYSD_SYSUSERS, test "x$systemd_sysusers" = "xyes")
  432. AC_CHECK_PROG(systemd_tmpfiles, systemd-tmpfiles, yes)
  433. AM_CONDITIONAL(SYSD_TMPFILES, test "x$systemd_tmpfiles" = "xyes")
  434. # Check all tools used by make install
  435. AS_IF([test "$HOSTOS" = "Linux"],
  436. [ AC_CHECK_PROG(useradd, useradd, yes)
  437. AC_CHECK_PROG(groupadd, groupadd, yes)
  438. AC_CHECK_PROG(adduser, adduser, yes)
  439. AC_CHECK_PROG(addgroup, addgroup, yes)
  440. AS_IF([test "x$addgroup" != "xyes" && test "x$groupadd" != "xyes" ],
  441. [AC_MSG_ERROR([addgroup or groupadd are needed.])])
  442. AS_IF([test "x$adduser" != "xyes" && test "x$useradd" != "xyes" ],
  443. [AC_MSG_ERROR([adduser or useradd are needed.])])])
  444. AC_SUBST([PATH])
  445. dnl --------- Doxy Gen -----------------------
  446. DX_DOXYGEN_FEATURE(ON)
  447. DX_DOT_FEATURE(OFF)
  448. DX_HTML_FEATURE(ON)
  449. DX_CHM_FEATURE(OFF)
  450. DX_CHI_FEATURE(OFF)
  451. DX_MAN_FEATURE(ON)
  452. DX_RTF_FEATURE(ON)
  453. DX_XML_FEATURE(OFF)
  454. DX_PDF_FEATURE(OFF)
  455. DX_PS_FEATURE(OFF)
  456. DX_INIT_DOXYGEN($PACKAGE_NAME, [Doxyfile], [doxygen-doc])
  457. AM_CONDITIONAL(DOXYMAN, [test $DX_FLAG_doc -eq 1])
  458. AS_IF([test $DX_FLAG_doc -ne 1],
  459. [AS_IF([test "x$enable_doxygen_doc" = xyes],
  460. [ERROR_IF_NO_PROG([doxygen])])])
  461. AX_CODE_COVERAGE
  462. m4_ifdef([_AX_CODE_COVERAGE_RULES],
  463. [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
  464. [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
  465. AX_ADD_AM_MACRO_STATIC([])
  466. AM_COND_IF([ENABLE_TCTI_DEVICE], [],
  467. [AM_COND_IF([ENABLE_TCTI_MSSIM], [],
  468. [AM_COND_IF([ENABLE_TCTI_SWTPM], [],
  469. [AM_COND_IF([ENABLE_TCTI_FUZZING], [],
  470. [AC_MSG_WARN("No build-in TCTI module enabled")])])])])
  471. AM_COND_IF([ENABLE_TCTI_FUZZING], [
  472. AM_COND_IF([ENABLE_TCTI_DEVICE],
  473. AC_MSG_ERROR([Fuzzing TCTI is meant to be built as the only TCTI: use --disable-tcti-device --disable-tcti-mssim --disable-tcti-swtpm]))
  474. AM_COND_IF([ENABLE_TCTI_MSSIM],
  475. AC_MSG_ERROR([Fuzzing TCTI is meant to be built as the only TCTI: use --disable-tcti-device --disable-tcti-mssim --disable-tcti-swtpm]))
  476. AM_COND_IF([ENABLE_TCTI_SWTPM],
  477. AC_MSG_ERROR([Fuzzing TCTI is meant to be built as the only TCTI: use --disable-tcti-device --disable-tcti-mssim --disable-tcti-swtpm]))
  478. AS_CASE([$CC],
  479. [*clang*], [AC_MSG_NOTICE("Building fuzzing tests with $CC")],
  480. [AC_MSG_ERROR("Fuzzing TCTI can only be used with clang")])
  481. ], [])
  482. AC_OUTPUT
  483. AC_MSG_RESULT([
  484. $PACKAGE_NAME $VERSION
  485. esys: $enable_esys
  486. fapi: $enable_fapi
  487. tctidefaultmodule: $with_tctidefaultmodule
  488. tctidefaultconfig: $with_tctidefaultconfig
  489. unit: $enable_unit
  490. integration: $enable_integration
  491. testing backend: $integration_tcti
  492. fuzzing: $with_fuzzing
  493. debug: $enable_debug
  494. maxloglevel: $with_maxloglevel
  495. doxygen: $DX_FLAG_doc $enable_doxygen_doc
  496. crypto backend: $with_crypto
  497. sysconfdir: $sysconfdir
  498. localstatedir: $localstatedir
  499. runstatedir: $runstatedir
  500. sysusersdir: $sysusersdir
  501. tmpfilesdir: $tmpfilesdir
  502. userstatedir: [\$HOME/]$with_userstatedir
  503. ])