blob: facb4dbbed35e62e717f5c0b1bbb24f87a4a56df [file] [log] [blame]
Philip Triccac054cf92018-11-11 11:06:00 -08001# SPDX-License-Identifier: BSD-2
Philip Tricca8ffb6542018-03-04 19:51:53 -08002# Copyright (c) 2015 - 2018 Intel Corporation
3# Copyright (c) 2018 Fraunhofer SIT sponsored by Infineon Technologies AG
4# All rights reserved.
Philip Triccac054cf92018-11-11 11:06:00 -08005
Philip Tricca1a94dd82017-08-16 14:32:55 -07006AC_INIT([tpm2-tss],
Tadeusz Struk2e655bb2018-09-25 10:37:16 -07007 [2.1.0],
Philip Triccadc1f15d2018-03-04 19:53:25 -08008 [https://github.com/tpm2-software/tpm2-tss/issues],
Philip Triccad97ed642017-08-25 14:19:27 -07009 [],
Philip Triccadc1f15d2018-03-04 19:53:25 -080010 [https://github.com/tpm2-software/tpm2-tss])
Philip Triccaa509a682015-09-14 15:34:52 -070011AC_CONFIG_MACRO_DIR([m4])
Philip Tricca74037d32018-11-04 16:17:19 -080012: ${CFLAGS=""}
Philip Tricca35ac9cf2015-08-05 17:03:52 -070013AC_PROG_CC
Philip Triccaffbd61a2015-09-25 00:27:57 -070014LT_INIT()
Philip Tricca71aa9852015-08-25 00:26:22 -070015AM_INIT_AUTOMAKE([foreign
16 subdir-objects])
Andreas Fuchs3c965e72017-11-24 16:16:20 +010017m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) #Backward compatible setting of "silent-rules"
18
Andreas Fuchsbc169cb2018-04-10 12:02:10 +020019AC_CONFIG_FILES([Makefile Doxyfile])
Philip Tricca1a94dd82017-08-16 14:32:55 -070020
21# propagate configure arguments to distcheck
22AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],[$ac_configure_args])
23
Safayet N Ahmed1354f492018-11-03 16:02:49 -040024AC_CANONICAL_HOST
25
26# Check OS and set library and compile flags accordingly
27case "${host_os}" in
28 *nto-qnx*)
29 ADD_COMPILER_FLAG([-D_QNX_SOURCE])
30 LIBDL_LDFLAGS=""
31 LIBSOCKET_LDFLAGS="-lsocket"
32 ;;
33 *)
34 LIBDL_LDFLAGS="-ldl"
35 LIBSOCKET_LDFLAGS=""
36 ;;
37esac
38AC_SUBST([LIBDL_LDFLAGS])
39AC_SUBST([LIBSOCKET_LDFLAGS])
40
Philip Tricca4334dee2016-08-09 19:56:28 -070041AC_ARG_ENABLE([unit],
42 [AS_HELP_STRING([--enable-unit],
43 [build cmocka unit tests (default is no)])],
44 [enable_unit=$enableval],
45 [enable_unit=no])
Philip Tricca38db7552018-02-27 07:58:25 -080046m4_define([cmocka_min_version], [1.0])
47m4_define([cmocka_err], [Unit test enabled, but cmocka missing or version requirements not met. cmocka version must be >= cmocka_min_version])
Philip Tricca4334dee2016-08-09 19:56:28 -070048AS_IF([test "x$enable_unit" != xno],
49 [PKG_CHECK_MODULES([CMOCKA],
Philip Tricca38db7552018-02-27 07:58:25 -080050 [cmocka >= cmocka_min_version],
Philip Tricca4334dee2016-08-09 19:56:28 -070051 [AC_DEFINE([HAVE_CMOCKA],
Philip Tricca38db7552018-02-27 07:58:25 -080052 [1])],
53 [AC_MSG_ERROR([cmocka_err])])])
Philip Tricca4334dee2016-08-09 19:56:28 -070054AM_CONDITIONAL([UNIT], [test "x$enable_unit" != xno])
Philip Tricca77683c72017-12-04 16:05:52 -080055
Juergen Reppff821bd2017-12-11 15:21:42 +010056AC_ARG_ENABLE([esapi],
57 [AS_HELP_STRING([--enable-esapi],
58 [build the esapi layer (default is yes)])],
59 [enable_esapi=$enableval],
60 [enable_esapi=yes])
Juergen Reppbebbc7a2018-06-22 14:03:12 +020061
Juergen Reppbebbc7a2018-06-22 14:03:12 +020062AM_CONDITIONAL(ESAPI, test "x$enable_esapi" = "xyes")
63
Tadeusz Struk3f2489b2018-08-22 10:01:11 -070064AC_ARG_ENABLE([tcti-device-async],
65 AS_HELP_STRING([--enable-tcti-device-async],
66 [Enable asynchronus operation on TCTI device
67 (note: This needs to be supported by the kernel driver). default is no]),
68 [enable_tcti_device_async=$enableval],
69 [enable_tcti_device_async=no])
70AS_IF([test "x$enable_tcti_device_async" = "xyes"],
71 AC_DEFINE([TCTI_ASYNC],[1]))
72
Tadeusz Strukfa423ad2018-11-27 13:20:38 -080073AC_ARG_ENABLE([tcti-partial-reads],
74 AS_HELP_STRING([--enable-tcti-partial-reads],
75 [Enable partial reads for TCTI device
76 (note: This needs to be supported by the kernel driver). default is no]),
77 [enable_tcti_partial_reads=$enableval],
78 [enable_tcti_partial_reads=no])
79AS_IF([test "x$enable_tcti_partial_reads" = "xyes"],
80 AC_DEFINE([TCTI_PARTIAL_READ],[1]))
81
Juergen Reppbebbc7a2018-06-22 14:03:12 +020082AC_ARG_WITH([crypto],
83 [AS_HELP_STRING([--with-crypto={gcrypt,ossl}],
Tadeusz Struka5ff71a2018-10-23 16:04:25 -070084 [sets the ESAPI crypto backend (default is OpenSSL)])],
Juergen Reppbebbc7a2018-06-22 14:03:12 +020085 [],
Tadeusz Struka5ff71a2018-10-23 16:04:25 -070086 [with_crypto=ossl])
Juergen Reppbebbc7a2018-06-22 14:03:12 +020087
88AM_CONDITIONAL(ESYS_OSSL, test "x$with_crypto" = "xossl")
89AM_CONDITIONAL(ESYS_GCRYPT, test "x$with_crypto" = "xgcrypt")
90
91AS_IF([test "x$with_crypto" != "xgcrypt"],
92 AS_IF([test "x$with_crypto" != "xossl"],
93 AC_MSG_ERROR([Bad value for --with-crypto $with_crypto])))
94
95AS_IF([test "x$enable_esapi" != xno -a "x$with_crypto" = "xgcrypt"],
Philip Tricca8eecfd32018-01-31 06:28:27 -080096 [AC_CHECK_HEADER([gcrypt.h],
97 [],
98 [AC_MSG_ERROR([Missing required header: gcrypt.h.])])])
Juergen Reppbebbc7a2018-06-22 14:03:12 +020099
100AS_IF([test "x$enable_esapi" != xno -a "x$with_cryptor" = "xgcrypt"],
Philip Tricca8eecfd32018-01-31 06:28:27 -0800101 [AC_CHECK_LIB([gcrypt],
102 [gcry_mac_open],
103 [],
104 [AC_MSG_ERROR([Missing required library: gcrypt.])])])
Juergen Reppbebbc7a2018-06-22 14:03:12 +0200105
106AS_IF([test "x$enable_esapi" != xno -a "x$with_crypto" = "xossl"],
107 [AC_CHECK_HEADER([openssl/ssl.h],
108 [],
109 [AC_MSG_ERROR([Missing required header: openssl/ssl.h.])])])
110
111AS_IF([test "x$enable_esapi" != xno -a "x$with_crypto" = "xossl"],
112 AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"]))
113
114AS_IF([test "x$enable_esapi" != xno -a "x$with_crypto" = "xossl"],
115 AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]))
Juergen Reppff821bd2017-12-11 15:21:42 +0100116
117AC_ARG_WITH([tctidefaultmodule],
118 [AS_HELP_STRING([--with-tctidefaultmodule],
Andreas Fuchs037c8782018-03-21 18:52:38 +0100119[The default TCTI module for ESAPI. (Default: libtss2-tcti-default.so])],
120 [AC_DEFINE_UNQUOTED([ESYS_TCTI_DEFAULT_MODULE],
Andreas Fuchsfefb6b02018-08-29 13:30:35 +0200121 ["$with_tctidefaultmodule"],
Andreas Fuchs037c8782018-03-21 18:52:38 +0100122 ["The default TCTI library file"])],
123 [])
Juergen Reppff821bd2017-12-11 15:21:42 +0100124
125AC_ARG_WITH([tctidefaultconfig],
126 [AS_HELP_STRING([--with-tctidefaultconfig],
127 [The default tcti module's configuration.])],
Andreas Fuchs037c8782018-03-21 18:52:38 +0100128 [AC_DEFINE_UNQUOTED([ESYS_TCTI_DEFAULT_CONFIG],
Andreas Fuchsfefb6b02018-08-29 13:30:35 +0200129 ["$with_tctidefaultconfig"],
Andreas Fuchs037c8782018-03-21 18:52:38 +0100130 ["The default TCTIs configuration string"])],
131 [])
132
Andreas Fuchs2b085e92018-05-02 16:42:47 +0200133AC_ARG_ENABLE([tcti-device],
134 [AS_HELP_STRING([--enable-tcti-device],
135 [build the tcti-device module (default is yes)])],
136 [enable_tcti_device=$enableval],
137 [enable_tcti_device=yes])
138AM_CONDITIONAL([ENABLE_TCTI_DEVICE], [test "x$enable_tcti_device" != xno])
139
140AC_ARG_ENABLE([tcti-mssim],
141 [AS_HELP_STRING([--enable-tcti-mssim],
142 [build the tcti-mssim module (default is yes)])],
143 [enable_tcti_mssim=$enableval],
144 [enable_tcti_mssim=yes])
145AM_CONDITIONAL([ENABLE_TCTI_MSSIM], [test "x$enable_tcti_mssim" != xno])
146
Philip Tricca99d41422017-06-18 15:11:50 -0700147#
Javier Martinez Canillas0075f882018-04-13 12:49:37 +0200148# udev
149#
150AC_ARG_WITH([udevrulesdir],
151 [AS_HELP_STRING([--with-udevrulesdir=DIR],[udev rules directory])],
152 [],
153 [with_udevrulesdir=${libdir}/udev/rules.d])
154AX_NORMALIZE_PATH([with_udevrulesdir])
155AC_SUBST([udevrulesdir], [$with_udevrulesdir])
156AC_ARG_WITH([udevrulesprefix],
157 [AS_HELP_STRING([--with-udevrulesprefix=XY],[prefix for udev rules file])],
158 [AC_SUBST([udevrulesprefix],[$with_udevrulesprefix])])
159AM_CONDITIONAL(WITH_UDEVRULESPREFIX, [test -n "$with_udevrulesprefix"])
160#
Philip Tricca99075432018-04-25 19:02:05 -0700161# enable integration tests and check for simulator binary
Philip Tricca99d41422017-06-18 15:11:50 -0700162#
Philip Tricca99075432018-04-25 19:02:05 -0700163AC_ARG_ENABLE([integration],
164 [AS_HELP_STRING([--enable-integration],
165 [build and execute integration tests (default is no)])],
166 [enable_integration=$enableval],
167 [enable_integration=no])
168AS_IF([test "x$enable_integration" = "xyes"],
Philip Tricca154b81d2018-07-06 12:41:07 -0700169 [ERROR_IF_NO_PROG([tpm_server])
Jonas Witschel8b9285d2018-12-27 23:53:21 +0100170 ERROR_IF_NO_PROG([ss])
Philip Tricca35ab16e2018-07-06 13:03:17 -0700171 ERROR_IF_NO_PROG([ps])
172 ERROR_IF_NO_PROG([echo])
173 ERROR_IF_NO_PROG([kill])
Jonas Witschel303412c2018-12-27 23:55:55 +0100174 ERROR_IF_NO_PROG([stdbuf])
Philip Tricca35ab16e2018-07-06 13:03:17 -0700175 ERROR_IF_NO_PROG([sleep])
176 ERROR_IF_NO_PROG([cat])
177 ERROR_IF_NO_PROG([realpath])
178 ERROR_IF_NO_PROG([dirname])
179 ERROR_IF_NO_PROG([basename])
180 ERROR_IF_NO_PROG([mktemp])
181 ERROR_IF_NO_PROG([od])
182 ERROR_IF_NO_PROG([awk])
183 ERROR_IF_NO_PROG([expr])
184 ERROR_IF_NO_PROG([grep])
185 ERROR_IF_NO_PROG([env])
186 ERROR_IF_NO_PROG([rm])
Philip Tricca99075432018-04-25 19:02:05 -0700187 PKG_CHECK_MODULES([LIBCRYPTO],[libcrypto])
188 AC_CHECK_HEADER(uthash.h, [], [AC_MSG_ERROR([Can not find uthash.h. Please install uthash-dev])])
Tadeusz Struk91e7bd62018-07-23 11:30:02 -0700189 AS_IF([test "x$enable_tcti_mssim" = xno],
190 AC_MSG_ERROR([Integration tests can not be enabled without the TCTI_MSSIM module]))
Philip Tricca99075432018-04-25 19:02:05 -0700191 AC_SUBST([ENABLE_INTEGRATION], [$enable_integration])])
192AM_CONDITIONAL([ENABLE_INTEGRATION],[test "x$enable_integration" = "xyes"])
Tadeusz Struk1bc0f082018-04-18 11:53:26 -0700193
David R. Bild1e49b4c2017-11-28 18:09:42 -0600194gl_LD_VERSION_SCRIPT
195
Andreas Fuchs80e84852018-02-27 22:45:09 +0100196AC_ARG_WITH([maxloglevel],
197 [AS_HELP_STRING([--with-maxloglevel={none,error,warning,info,debug,trace}],
Andreas Fuchsbc490762018-01-03 14:36:38 +0100198 [sets the maximum log level (default is trace)])],
199 [],
Andreas Fuchs80e84852018-02-27 22:45:09 +0100200 [with_maxloglevel=trace])
Philip Triccafeae8b12018-11-04 19:53:12 -0800201AS_CASE(["x$with_maxloglevel"],
202 ["xnone"],
203 [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [0], ["Logging disabled"])],
204 ["xerror"],
205 [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [2], ["Error log level"])],
206 ["xwarning"],
207 [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [3], ["Warning log level"])],
208 ["xinfo"],
209 [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [4], ["Info log level"])],
210 ["xdebug"],
211 [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [5], ["Debug log level"])],
212 ["xtrace"],
213 [AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [6], ["Trace log level"])],
214 [AC_MSG_ERROR([Bad value for --with-maxloglevel])])
Andreas Fuchsbc490762018-01-03 14:36:38 +0100215
Tadeusz Struka3260d82017-09-11 12:06:13 -0700216AC_ARG_ENABLE([debug],
217 [AS_HELP_STRING([--enable-debug],
218 [build with debug info (default is no)])],
219 [enable_debug=$enableval],
220 [enable_debug=no])
Philip Tricca6d5985b2018-11-04 15:58:19 -0800221AS_IF([test "x$enable_debug" = "xyes"], ADD_COMPILER_FLAG([-ggdb3 -Og]))
Philip Tricca085755d2018-11-11 12:43:29 -0800222AC_ARG_ENABLE([defaultflags],
Philip Tricca6751b3c2018-11-20 00:19:13 -0800223 [AS_HELP_STRING([--disable-defaultflags],
224 [Disable default preprocessor, compiler, and linker flags.])],
Philip Tricca085755d2018-11-11 12:43:29 -0800225 [enable_defaultflags=$enableval],
226 [enable_defaultflags=yes])
227AS_IF([test "x$enable_defaultflags" = "xyes"],
228 [
229 ADD_PREPROC_FLAG([-D_DEFAULT_SOURCE])
230 ADD_PREPROC_FLAG([-D_BSD_SOURCE])
231 ADD_PREPROC_FLAG([-D_POSIX_SOURCE])
232 AS_IF([test "x$enable_debug" = "xno"],
233 [
234 ADD_PREPROC_FLAG([-U_FORTIFY_SOURCE])
235 ADD_PREPROC_FLAG([-D_FORTIFY_SOURCE=2])
236 ADD_COMPILER_FLAG([-g -O2])
237 ])
238 ADD_COMPILER_FLAG([-std=c99])
239 ADD_COMPILER_FLAG([-Wall])
240 ADD_COMPILER_FLAG([-Wextra])
241 ADD_COMPILER_FLAG([-Wformat-security])
242 ADD_COMPILER_FLAG([-Werror])
243 ADD_COMPILER_FLAG([-fstack-protector-all])
244 ADD_COMPILER_FLAG([-fpic])
245 ADD_COMPILER_FLAG([-fPIC])
246 # work around GCC bug #53119
247 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
248 ADD_COMPILER_FLAG([-Wno-missing-braces])
William Roberts22727172018-12-07 10:34:53 -0800249 ADD_COMPILER_FLAG([-Wstrict-overflow=5])
Philip Tricca085755d2018-11-11 12:43:29 -0800250 ADD_LINK_FLAG([-Wl,--no-undefined])
251 ADD_LINK_FLAG([-Wl,-z,noexecstack])
252 ADD_LINK_FLAG([-Wl,-z,now])
253 ADD_LINK_FLAG([-Wl,-z,relro])
254 ])
Philip Triccab43de642017-03-04 21:29:10 -0800255
Philip Tricca99075432018-04-25 19:02:05 -0700256AC_SUBST([PATH])
257
Philip Triccaf8915802017-03-14 17:01:50 -0700258
Juergen Reppac598362018-07-17 13:36:38 +0200259dnl --------- Physical TPM device -----------------------
260
261AC_ARG_WITH([ptpm],
Tadeusz Strukc6a4a7d2018-08-21 13:21:22 -0700262 [AS_HELP_STRING([--with-ptpm=<device>],[TPM device])],
Juergen Reppac598362018-07-17 13:36:38 +0200263 [AS_IF([test \( -w "$with_ptpm" \) -a \( -r "$with_ptpm" \)],
264 [AC_MSG_RESULT([success])
265 AC_SUBST([PTPM],[$with_ptpm])
266 AX_NORMALIZE_PATH([with_ptpm])
267 with_ptpm_set=yes],
268 [AC_MSG_ERROR([TPM device provided does not exist or is not writable])])],
269 [with_ptpm_set=no])
270AM_CONDITIONAL([PTPM],[test "x$with_ptpm_set" = "xyes"])
271
272AC_ARG_WITH([ptpmtests],
273 [AS_HELP_STRING([--with-ptpmtests=<case>],[Comma-separated values of possible tests: destructive,mandatory,optional] default is mandatory)],
274 [AS_IF([test "x" == x$(echo $with_ptpmtests | sed 's/destructive//g' | sed 's/mandatory//g' | sed 's/optional//g' | sed 's/,//g') ],
275 [AC_MSG_RESULT([success])
276 with_ptpmtests_set=yes],
277 [AC_MSG_ERROR([Illegal test type for pTPM tests.])])],
278 [with_ptpmtests="mandatory"])
279
280if echo $with_ptpmtests | grep destructive > /dev/null; then
281 enable_ptpm_destructive="yes"
282fi
283AM_CONDITIONAL([PTPMDESTRUCTIVE],[test "x$enable_ptpm_destructive" = "xyes"])
284
285if echo $with_ptpmtests | grep optional > /dev/null; then
286 enable_ptpm_optional="yes"
287fi
288AM_CONDITIONAL([PTPMOPTIONAL],[test "x$enable_ptpm_optional" = "xyes"])
289
290if echo $with_ptpmtests | grep mandatory > /dev/null; then
291 enable_ptpm_mandatory="yes"
292fi
293AM_CONDITIONAL([PTPMMANDATORY],[test "x$enable_ptpm_mandatory" = "xyes"])
294
295AM_CONDITIONAL([TESTPTPM],[test "x$with_ptpm_set" = "xyes" -a "x$with_ptpm_set" = "xyes"])
296
Andreas Fuchs2968c712018-02-01 18:22:47 +0100297dnl --------- Doxy Gen -----------------------
Andreas Fuchsbc169cb2018-04-10 12:02:10 +0200298DX_DOXYGEN_FEATURE(ON)
299DX_DOT_FEATURE(OFF)
Andreas Fuchs2968c712018-02-01 18:22:47 +0100300DX_HTML_FEATURE(ON)
301DX_CHM_FEATURE(OFF)
302DX_CHI_FEATURE(OFF)
303DX_MAN_FEATURE(ON)
Jonas Witscheldd54f332018-11-14 22:17:34 +0100304DX_RTF_FEATURE(ON)
Andreas Fuchs2968c712018-02-01 18:22:47 +0100305DX_XML_FEATURE(OFF)
306DX_PDF_FEATURE(OFF)
307DX_PS_FEATURE(OFF)
Jonas Witscheldd54f332018-11-14 22:17:34 +0100308DX_INIT_DOXYGEN($PACKAGE_NAME, [Doxyfile], [doxygen-doc])
Andreas Fuchse5273b32018-04-26 16:16:24 +0200309AM_CONDITIONAL(DOXYMAN, [test $DX_FLAG_man -eq 1])
Andreas Fuchs2968c712018-02-01 18:22:47 +0100310
Jonas Witscheldd672362018-11-17 15:25:41 +0100311AS_IF([test "x$enable_doxygen_doc" != xno],
Tadeusz Struk81eacdd2018-11-12 11:57:02 -0800312 [ERROR_IF_NO_PROG([doxygen])])
313
Andreas Fuchs61cb7fb2017-11-22 10:23:01 +0100314AX_CODE_COVERAGE
Jonas Witschel648fa842019-01-07 22:15:06 +0100315m4_ifdef([_AX_CODE_COVERAGE_RULES],
316 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [true])],
317 [AM_CONDITIONAL(AUTOCONF_CODE_COVERAGE_2019_01_06, [false])])
Joshua Lockb7b42322019-01-25 16:10:14 +0000318AX_ADD_AM_MACRO_STATIC([])
Andreas Fuchs61cb7fb2017-11-22 10:23:01 +0100319
Philip Triccad1952b42015-08-05 15:52:10 -0700320AC_OUTPUT
Juergen Reppff821bd2017-12-11 15:21:42 +0100321
Andreas Fuchs2b085e92018-05-02 16:42:47 +0200322AM_COND_IF([ENABLE_TCTI_DEVICE], [],
323 [AM_COND_IF([ENABLE_TCTI_MSSIM], [],
324 [AC_MSG_WARN("No build-in TCTI module enabled")])])
325
Juergen Reppff821bd2017-12-11 15:21:42 +0100326AC_MSG_RESULT([
327 $PACKAGE_NAME $VERSION
328 esapi: $enable_esapi
329 tctidefaultmodule: $with_tctidefaultmodule
330 tctidefaultconfig: $with_tctidefaultconfig
331 unit: $enable_unit
332 debug: $enable_debug
Philip Triccafb0b72f2018-03-04 19:39:24 -0800333 maxloglevel: $with_maxloglevel
Andreas Fuchs2968c712018-02-01 18:22:47 +0100334 doxygen: $DX_FLAG_doc $enable_doxygen_doc
Tadeusz Struk3f2489b2018-08-22 10:01:11 -0700335 tcti-device-async: $enable_tcti_device_async
Tadeusz Strukfa423ad2018-11-27 13:20:38 -0800336 tcti-partial-read: $enable_tcti_partial_reads
Tadeusz Struka5ff71a2018-10-23 16:04:25 -0700337 crypto backend: $with_crypto
Juergen Reppff821bd2017-12-11 15:21:42 +0100338])