blob: 60de73a816876a32526c8783cdfb6c94e4f21d44 [file] [log] [blame]
Philip Tricca8ffb6542018-03-04 19:51:53 -08001#;**********************************************************************;
2# Copyright (c) 2015 - 2018 Intel Corporation
3# Copyright (c) 2018 Fraunhofer SIT sponsored by Infineon Technologies AG
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8#
9# 1. Redistributions of source code must retain the above copyright notice,
10# this list of conditions and the following disclaimer.
11#
12# 2. Redistributions in binary form must reproduce the above copyright notice,
13# this list of conditions and the following disclaimer in the documentation
14# and/or other materials provided with the distribution.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26# THE POSSIBILITY OF SUCH DAMAGE.
27#;**********************************************************************;
Philip Tricca1a94dd82017-08-16 14:32:55 -070028AC_INIT([tpm2-tss],
Philip Tricca5cdd1152018-05-04 14:17:11 -070029 [2.0.0_rc0],
Philip Triccadc1f15d2018-03-04 19:53:25 -080030 [https://github.com/tpm2-software/tpm2-tss/issues],
Philip Triccad97ed642017-08-25 14:19:27 -070031 [],
Philip Triccadc1f15d2018-03-04 19:53:25 -080032 [https://github.com/tpm2-software/tpm2-tss])
Philip Triccaa509a682015-09-14 15:34:52 -070033AC_CONFIG_MACRO_DIR([m4])
Tadeusz Struk3980bad2018-04-04 10:30:01 -070034${CFLAGS=""}
Philip Tricca35ac9cf2015-08-05 17:03:52 -070035AC_PROG_CC
Philip Triccaffbd61a2015-09-25 00:27:57 -070036LT_INIT()
Philip Tricca71aa9852015-08-25 00:26:22 -070037AM_INIT_AUTOMAKE([foreign
38 subdir-objects])
Andreas Fuchs3c965e72017-11-24 16:16:20 +010039m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) #Backward compatible setting of "silent-rules"
40
Andreas Fuchsbc169cb2018-04-10 12:02:10 +020041AC_CONFIG_FILES([Makefile Doxyfile])
Philip Tricca1a94dd82017-08-16 14:32:55 -070042
43# propagate configure arguments to distcheck
44AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],[$ac_configure_args])
45
Philip Tricca4334dee2016-08-09 19:56:28 -070046AC_ARG_ENABLE([unit],
47 [AS_HELP_STRING([--enable-unit],
48 [build cmocka unit tests (default is no)])],
49 [enable_unit=$enableval],
50 [enable_unit=no])
Philip Tricca38db7552018-02-27 07:58:25 -080051m4_define([cmocka_min_version], [1.0])
52m4_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 -070053AS_IF([test "x$enable_unit" != xno],
54 [PKG_CHECK_MODULES([CMOCKA],
Philip Tricca38db7552018-02-27 07:58:25 -080055 [cmocka >= cmocka_min_version],
Philip Tricca4334dee2016-08-09 19:56:28 -070056 [AC_DEFINE([HAVE_CMOCKA],
Philip Tricca38db7552018-02-27 07:58:25 -080057 [1])],
58 [AC_MSG_ERROR([cmocka_err])])])
Philip Tricca4334dee2016-08-09 19:56:28 -070059AM_CONDITIONAL([UNIT], [test "x$enable_unit" != xno])
Philip Tricca77683c72017-12-04 16:05:52 -080060
Juergen Reppff821bd2017-12-11 15:21:42 +010061AC_ARG_ENABLE([esapi],
62 [AS_HELP_STRING([--enable-esapi],
63 [build the esapi layer (default is yes)])],
64 [enable_esapi=$enableval],
65 [enable_esapi=yes])
66AS_IF([test "x$enable_esapi" != xno],
Philip Tricca8eecfd32018-01-31 06:28:27 -080067 [AC_CHECK_HEADER([gcrypt.h],
68 [],
69 [AC_MSG_ERROR([Missing required header: gcrypt.h.])])])
Juergen Reppff821bd2017-12-11 15:21:42 +010070AS_IF([test "x$enable_esapi" != xno],
Philip Tricca8eecfd32018-01-31 06:28:27 -080071 [AC_CHECK_LIB([gcrypt],
72 [gcry_mac_open],
73 [],
74 [AC_MSG_ERROR([Missing required library: gcrypt.])])])
Juergen Reppff821bd2017-12-11 15:21:42 +010075AM_CONDITIONAL([ESAPI], [test "x$enable_esapi" != xno])
76
77AC_ARG_WITH([tctidefaultmodule],
78 [AS_HELP_STRING([--with-tctidefaultmodule],
Andreas Fuchs037c8782018-03-21 18:52:38 +010079[The default TCTI module for ESAPI. (Default: libtss2-tcti-default.so])],
80 [AC_DEFINE_UNQUOTED([ESYS_TCTI_DEFAULT_MODULE],
81 [$with_tctidefaultmodule],
82 ["The default TCTI library file"])],
83 [])
Juergen Reppff821bd2017-12-11 15:21:42 +010084
85AC_ARG_WITH([tctidefaultconfig],
86 [AS_HELP_STRING([--with-tctidefaultconfig],
87 [The default tcti module's configuration.])],
Andreas Fuchs037c8782018-03-21 18:52:38 +010088 [AC_DEFINE_UNQUOTED([ESYS_TCTI_DEFAULT_CONFIG],
89 [$with_tctidefaultconfig],
90 ["The default TCTIs configuration string"])],
91 [])
92
Andreas Fuchs2b085e92018-05-02 16:42:47 +020093AC_ARG_ENABLE([tcti-device],
94 [AS_HELP_STRING([--enable-tcti-device],
95 [build the tcti-device module (default is yes)])],
96 [enable_tcti_device=$enableval],
97 [enable_tcti_device=yes])
98AM_CONDITIONAL([ENABLE_TCTI_DEVICE], [test "x$enable_tcti_device" != xno])
99
100AC_ARG_ENABLE([tcti-mssim],
101 [AS_HELP_STRING([--enable-tcti-mssim],
102 [build the tcti-mssim module (default is yes)])],
103 [enable_tcti_mssim=$enableval],
104 [enable_tcti_mssim=yes])
105AM_CONDITIONAL([ENABLE_TCTI_MSSIM], [test "x$enable_tcti_mssim" != xno])
106
Philip Tricca99d41422017-06-18 15:11:50 -0700107#
Javier Martinez Canillas0075f882018-04-13 12:49:37 +0200108# udev
109#
110AC_ARG_WITH([udevrulesdir],
111 [AS_HELP_STRING([--with-udevrulesdir=DIR],[udev rules directory])],
112 [],
113 [with_udevrulesdir=${libdir}/udev/rules.d])
114AX_NORMALIZE_PATH([with_udevrulesdir])
115AC_SUBST([udevrulesdir], [$with_udevrulesdir])
116AC_ARG_WITH([udevrulesprefix],
117 [AS_HELP_STRING([--with-udevrulesprefix=XY],[prefix for udev rules file])],
118 [AC_SUBST([udevrulesprefix],[$with_udevrulesprefix])])
119AM_CONDITIONAL(WITH_UDEVRULESPREFIX, [test -n "$with_udevrulesprefix"])
120#
Philip Tricca99075432018-04-25 19:02:05 -0700121# enable integration tests and check for simulator binary
Philip Tricca99d41422017-06-18 15:11:50 -0700122#
Philip Tricca99075432018-04-25 19:02:05 -0700123AC_ARG_ENABLE([integration],
124 [AS_HELP_STRING([--enable-integration],
125 [build and execute integration tests (default is no)])],
126 [enable_integration=$enableval],
127 [enable_integration=no])
128AS_IF([test "x$enable_integration" = "xyes"],
129 [AC_CHECK_PROG([tpm_server], [tpm_server], [yes], [no])
130 AS_IF([test "x$tpm_server" != "xyes"],
131 [AC_MSG_ERROR([Integration tests enabled but tpm_server not found, try setting PATH])])
132 PKG_CHECK_MODULES([LIBCRYPTO],[libcrypto])
133 AC_CHECK_HEADER(uthash.h, [], [AC_MSG_ERROR([Can not find uthash.h. Please install uthash-dev])])
134 AC_SUBST([ENABLE_INTEGRATION], [$enable_integration])])
135AM_CONDITIONAL([ENABLE_INTEGRATION],[test "x$enable_integration" = "xyes"])
Tadeusz Struk1bc0f082018-04-18 11:53:26 -0700136
David R. Bild1e49b4c2017-11-28 18:09:42 -0600137gl_LD_VERSION_SCRIPT
138
Philip Tricca08206512017-12-28 14:56:07 -0800139AX_ADD_COMPILER_FLAG([-std=c99])
Andreas Fuchs67ef8c22018-03-29 15:22:32 +0200140AX_ADD_COMPILER_FLAG([-Wall])
141AX_ADD_COMPILER_FLAG([-Wextra])
Philip Tricca27447812017-03-08 14:29:49 -0800142AX_ADD_COMPILER_FLAG([-Wformat-security])
Andreas Fuchs67ef8c22018-03-29 15:22:32 +0200143AX_ADD_COMPILER_FLAG([-Werror])
Philip Tricca27447812017-03-08 14:29:49 -0800144AX_ADD_COMPILER_FLAG([-fstack-protector-all])
145AX_ADD_COMPILER_FLAG([-fpic])
146AX_ADD_COMPILER_FLAG([-fPIC])
Tadeusz Struka3260d82017-09-11 12:06:13 -0700147
Philip Tricca08206512017-12-28 14:56:07 -0800148AX_ADD_PREPROC_FLAG([-D_DEFAULT_SOURCE])
Lu Gongabc63b32018-01-10 09:43:14 +0800149AX_ADD_PREPROC_FLAG([-D_BSD_SOURCE])
Jia Zhang58782642018-01-19 11:24:34 +0800150AX_ADD_PREPROC_FLAG([-D_POSIX_SOURCE])
Philip Tricca08206512017-12-28 14:56:07 -0800151
Andreas Fuchs80e84852018-02-27 22:45:09 +0100152AC_ARG_WITH([maxloglevel],
153 [AS_HELP_STRING([--with-maxloglevel={none,error,warning,info,debug,trace}],
Andreas Fuchsbc490762018-01-03 14:36:38 +0100154 [sets the maximum log level (default is trace)])],
155 [],
Andreas Fuchs80e84852018-02-27 22:45:09 +0100156 [with_maxloglevel=trace])
157AS_IF([test "x$with_maxloglevel" = "xnone"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800158 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [0], ["Logging disabled"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100159AS_IF([test "x$with_maxloglevel" = "xerror"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800160 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [2], ["Error log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100161AS_IF([test "x$with_maxloglevel" = "xwarning"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800162 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [3], ["Warning log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100163AS_IF([test "x$with_maxloglevel" = "xinfo"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800164 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [4], ["Info log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100165AS_IF([test "x$with_maxloglevel" = "xdebug"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800166 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [5], ["Debug log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100167AS_IF([test "x$with_maxloglevel" = "xtrace"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800168 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [6], ["Trace log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100169AC_MSG_ERROR([Bad value for --with-maxloglevel])))))))
Andreas Fuchsbc490762018-01-03 14:36:38 +0100170
Tadeusz Struka3260d82017-09-11 12:06:13 -0700171AC_ARG_ENABLE([debug],
172 [AS_HELP_STRING([--enable-debug],
173 [build with debug info (default is no)])],
174 [enable_debug=$enableval],
175 [enable_debug=no])
Tadeusz Struk3980bad2018-04-04 10:30:01 -0700176AS_IF([test "x$enable_debug" = "xyes"], AX_ADD_COMPILER_FLAG([-ggdb3 -Og]))
Tadeusz Struka3260d82017-09-11 12:06:13 -0700177AS_IF([test "x$enable_debug" = "xno"], [AX_ADD_PREPROC_FLAG([-U_FORTIFY_SOURCE])
Tadeusz Struk3980bad2018-04-04 10:30:01 -0700178 AX_ADD_PREPROC_FLAG([-D_FORTIFY_SOURCE=2])
179 AX_ADD_COMPILER_FLAG([-g -O2])])
Philip Tricca27447812017-03-08 14:29:49 -0800180AX_ADD_LINK_FLAG([-Wl,--no-undefined])
181AX_ADD_LINK_FLAG([-Wl,-z,noexecstack])
182AX_ADD_LINK_FLAG([-Wl,-z,now])
183AX_ADD_LINK_FLAG([-Wl,-z,relro])
Philip Triccab43de642017-03-04 21:29:10 -0800184
Philip Tricca99075432018-04-25 19:02:05 -0700185AC_SUBST([PATH])
186
Philip Triccaf8915802017-03-14 17:01:50 -0700187# work around GCC bug #53119
188# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
189AX_ADD_COMPILER_FLAG([-Wno-missing-braces])
190
Andreas Fuchs2968c712018-02-01 18:22:47 +0100191dnl --------- Doxy Gen -----------------------
Andreas Fuchsbc169cb2018-04-10 12:02:10 +0200192DX_DOXYGEN_FEATURE(ON)
193DX_DOT_FEATURE(OFF)
Andreas Fuchs2968c712018-02-01 18:22:47 +0100194DX_HTML_FEATURE(ON)
195DX_CHM_FEATURE(OFF)
196DX_CHI_FEATURE(OFF)
197DX_MAN_FEATURE(ON)
198DX_RTF_FEATURE(OFF)
199DX_XML_FEATURE(OFF)
200DX_PDF_FEATURE(OFF)
201DX_PS_FEATURE(OFF)
Andreas Fuchse5273b32018-04-26 16:16:24 +0200202DX_INIT_DOXYGEN($PACKAGE_NAME, [Doxyfile], [doc/doxygen])
203AM_CONDITIONAL(DOXYMAN, [test $DX_FLAG_man -eq 1])
Andreas Fuchs2968c712018-02-01 18:22:47 +0100204
Andreas Fuchs61cb7fb2017-11-22 10:23:01 +0100205AX_CODE_COVERAGE
206
Philip Triccad1952b42015-08-05 15:52:10 -0700207AC_OUTPUT
Juergen Reppff821bd2017-12-11 15:21:42 +0100208
Andreas Fuchs2b085e92018-05-02 16:42:47 +0200209AM_COND_IF([ENABLE_TCTI_DEVICE], [],
210 [AM_COND_IF([ENABLE_TCTI_MSSIM], [],
211 [AC_MSG_WARN("No build-in TCTI module enabled")])])
212
Juergen Reppff821bd2017-12-11 15:21:42 +0100213AC_MSG_RESULT([
214 $PACKAGE_NAME $VERSION
215 esapi: $enable_esapi
216 tctidefaultmodule: $with_tctidefaultmodule
217 tctidefaultconfig: $with_tctidefaultconfig
218 unit: $enable_unit
219 debug: $enable_debug
220 simulatorbin: $with_simulatorbin
Philip Triccafb0b72f2018-03-04 19:39:24 -0800221 maxloglevel: $with_maxloglevel
Andreas Fuchs2968c712018-02-01 18:22:47 +0100222 doxygen: $DX_FLAG_doc $enable_doxygen_doc
Juergen Reppff821bd2017-12-11 15:21:42 +0100223])
224