blob: bec9923a107a743fdee45bd2c12e3deeb4ecd76f [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 Tricca2c695cd2018-05-21 15:42:12 -070029 [2.0.0_rc2],
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])])
Philip Tricca65aa40f2018-05-10 17:03:04 -0700132 AC_CHECK_PROG([netstat], [netstat], [yes], [no])
133 AS_IF([test "x$netstat" != "xyes"],
134 [AC_MSG_ERROR([Integration tests enabled but netstat executable not found.])])
Philip Tricca99075432018-04-25 19:02:05 -0700135 PKG_CHECK_MODULES([LIBCRYPTO],[libcrypto])
136 AC_CHECK_HEADER(uthash.h, [], [AC_MSG_ERROR([Can not find uthash.h. Please install uthash-dev])])
137 AC_SUBST([ENABLE_INTEGRATION], [$enable_integration])])
138AM_CONDITIONAL([ENABLE_INTEGRATION],[test "x$enable_integration" = "xyes"])
Tadeusz Struk1bc0f082018-04-18 11:53:26 -0700139
David R. Bild1e49b4c2017-11-28 18:09:42 -0600140gl_LD_VERSION_SCRIPT
141
Philip Tricca08206512017-12-28 14:56:07 -0800142AX_ADD_COMPILER_FLAG([-std=c99])
Andreas Fuchs67ef8c22018-03-29 15:22:32 +0200143AX_ADD_COMPILER_FLAG([-Wall])
144AX_ADD_COMPILER_FLAG([-Wextra])
Philip Tricca27447812017-03-08 14:29:49 -0800145AX_ADD_COMPILER_FLAG([-Wformat-security])
Andreas Fuchs67ef8c22018-03-29 15:22:32 +0200146AX_ADD_COMPILER_FLAG([-Werror])
Philip Tricca27447812017-03-08 14:29:49 -0800147AX_ADD_COMPILER_FLAG([-fstack-protector-all])
148AX_ADD_COMPILER_FLAG([-fpic])
149AX_ADD_COMPILER_FLAG([-fPIC])
Tadeusz Struka3260d82017-09-11 12:06:13 -0700150
Philip Tricca08206512017-12-28 14:56:07 -0800151AX_ADD_PREPROC_FLAG([-D_DEFAULT_SOURCE])
Lu Gongabc63b32018-01-10 09:43:14 +0800152AX_ADD_PREPROC_FLAG([-D_BSD_SOURCE])
Jia Zhang58782642018-01-19 11:24:34 +0800153AX_ADD_PREPROC_FLAG([-D_POSIX_SOURCE])
Philip Tricca08206512017-12-28 14:56:07 -0800154
Andreas Fuchs80e84852018-02-27 22:45:09 +0100155AC_ARG_WITH([maxloglevel],
156 [AS_HELP_STRING([--with-maxloglevel={none,error,warning,info,debug,trace}],
Andreas Fuchsbc490762018-01-03 14:36:38 +0100157 [sets the maximum log level (default is trace)])],
158 [],
Andreas Fuchs80e84852018-02-27 22:45:09 +0100159 [with_maxloglevel=trace])
160AS_IF([test "x$with_maxloglevel" = "xnone"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800161 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [0], ["Logging disabled"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100162AS_IF([test "x$with_maxloglevel" = "xerror"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800163 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [2], ["Error log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100164AS_IF([test "x$with_maxloglevel" = "xwarning"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800165 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [3], ["Warning log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100166AS_IF([test "x$with_maxloglevel" = "xinfo"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800167 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [4], ["Info log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100168AS_IF([test "x$with_maxloglevel" = "xdebug"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800169 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [5], ["Debug log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100170AS_IF([test "x$with_maxloglevel" = "xtrace"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800171 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [6], ["Trace log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100172AC_MSG_ERROR([Bad value for --with-maxloglevel])))))))
Andreas Fuchsbc490762018-01-03 14:36:38 +0100173
Tadeusz Struka3260d82017-09-11 12:06:13 -0700174AC_ARG_ENABLE([debug],
175 [AS_HELP_STRING([--enable-debug],
176 [build with debug info (default is no)])],
177 [enable_debug=$enableval],
178 [enable_debug=no])
Tadeusz Struk3980bad2018-04-04 10:30:01 -0700179AS_IF([test "x$enable_debug" = "xyes"], AX_ADD_COMPILER_FLAG([-ggdb3 -Og]))
Tadeusz Struka3260d82017-09-11 12:06:13 -0700180AS_IF([test "x$enable_debug" = "xno"], [AX_ADD_PREPROC_FLAG([-U_FORTIFY_SOURCE])
Tadeusz Struk3980bad2018-04-04 10:30:01 -0700181 AX_ADD_PREPROC_FLAG([-D_FORTIFY_SOURCE=2])
182 AX_ADD_COMPILER_FLAG([-g -O2])])
Philip Tricca27447812017-03-08 14:29:49 -0800183AX_ADD_LINK_FLAG([-Wl,--no-undefined])
184AX_ADD_LINK_FLAG([-Wl,-z,noexecstack])
185AX_ADD_LINK_FLAG([-Wl,-z,now])
186AX_ADD_LINK_FLAG([-Wl,-z,relro])
Philip Triccab43de642017-03-04 21:29:10 -0800187
Philip Tricca99075432018-04-25 19:02:05 -0700188AC_SUBST([PATH])
189
Philip Triccaf8915802017-03-14 17:01:50 -0700190# work around GCC bug #53119
191# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
192AX_ADD_COMPILER_FLAG([-Wno-missing-braces])
193
Andreas Fuchs2968c712018-02-01 18:22:47 +0100194dnl --------- Doxy Gen -----------------------
Andreas Fuchsbc169cb2018-04-10 12:02:10 +0200195DX_DOXYGEN_FEATURE(ON)
196DX_DOT_FEATURE(OFF)
Andreas Fuchs2968c712018-02-01 18:22:47 +0100197DX_HTML_FEATURE(ON)
198DX_CHM_FEATURE(OFF)
199DX_CHI_FEATURE(OFF)
200DX_MAN_FEATURE(ON)
201DX_RTF_FEATURE(OFF)
202DX_XML_FEATURE(OFF)
203DX_PDF_FEATURE(OFF)
204DX_PS_FEATURE(OFF)
Andreas Fuchse5273b32018-04-26 16:16:24 +0200205DX_INIT_DOXYGEN($PACKAGE_NAME, [Doxyfile], [doc/doxygen])
206AM_CONDITIONAL(DOXYMAN, [test $DX_FLAG_man -eq 1])
Andreas Fuchs2968c712018-02-01 18:22:47 +0100207
Andreas Fuchs61cb7fb2017-11-22 10:23:01 +0100208AX_CODE_COVERAGE
209
Philip Triccad1952b42015-08-05 15:52:10 -0700210AC_OUTPUT
Juergen Reppff821bd2017-12-11 15:21:42 +0100211
Andreas Fuchs2b085e92018-05-02 16:42:47 +0200212AM_COND_IF([ENABLE_TCTI_DEVICE], [],
213 [AM_COND_IF([ENABLE_TCTI_MSSIM], [],
214 [AC_MSG_WARN("No build-in TCTI module enabled")])])
215
Juergen Reppff821bd2017-12-11 15:21:42 +0100216AC_MSG_RESULT([
217 $PACKAGE_NAME $VERSION
218 esapi: $enable_esapi
219 tctidefaultmodule: $with_tctidefaultmodule
220 tctidefaultconfig: $with_tctidefaultconfig
221 unit: $enable_unit
222 debug: $enable_debug
223 simulatorbin: $with_simulatorbin
Philip Triccafb0b72f2018-03-04 19:39:24 -0800224 maxloglevel: $with_maxloglevel
Andreas Fuchs2968c712018-02-01 18:22:47 +0100225 doxygen: $DX_FLAG_doc $enable_doxygen_doc
Juergen Reppff821bd2017-12-11 15:21:42 +0100226])
227