blob: 7ee78c7f441cacece2a70b8692a65927ae628b54 [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 Triccad97ed642017-08-25 14:19:27 -070029 [2.0.0-dev],
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
Philip Tricca99d41422017-06-18 15:11:50 -070093#
Javier Martinez Canillas0075f882018-04-13 12:49:37 +020094# udev
95#
96AC_ARG_WITH([udevrulesdir],
97 [AS_HELP_STRING([--with-udevrulesdir=DIR],[udev rules directory])],
98 [],
99 [with_udevrulesdir=${libdir}/udev/rules.d])
100AX_NORMALIZE_PATH([with_udevrulesdir])
101AC_SUBST([udevrulesdir], [$with_udevrulesdir])
102AC_ARG_WITH([udevrulesprefix],
103 [AS_HELP_STRING([--with-udevrulesprefix=XY],[prefix for udev rules file])],
104 [AC_SUBST([udevrulesprefix],[$with_udevrulesprefix])])
105AM_CONDITIONAL(WITH_UDEVRULESPREFIX, [test -n "$with_udevrulesprefix"])
106#
Philip Tricca99075432018-04-25 19:02:05 -0700107# enable integration tests and check for simulator binary
Philip Tricca99d41422017-06-18 15:11:50 -0700108#
Philip Tricca99075432018-04-25 19:02:05 -0700109AC_ARG_ENABLE([integration],
110 [AS_HELP_STRING([--enable-integration],
111 [build and execute integration tests (default is no)])],
112 [enable_integration=$enableval],
113 [enable_integration=no])
114AS_IF([test "x$enable_integration" = "xyes"],
115 [AC_CHECK_PROG([tpm_server], [tpm_server], [yes], [no])
116 AS_IF([test "x$tpm_server" != "xyes"],
117 [AC_MSG_ERROR([Integration tests enabled but tpm_server not found, try setting PATH])])
118 PKG_CHECK_MODULES([LIBCRYPTO],[libcrypto])
119 AC_CHECK_HEADER(uthash.h, [], [AC_MSG_ERROR([Can not find uthash.h. Please install uthash-dev])])
120 AC_SUBST([ENABLE_INTEGRATION], [$enable_integration])])
121AM_CONDITIONAL([ENABLE_INTEGRATION],[test "x$enable_integration" = "xyes"])
Tadeusz Struk1bc0f082018-04-18 11:53:26 -0700122
David R. Bild1e49b4c2017-11-28 18:09:42 -0600123gl_LD_VERSION_SCRIPT
124
Philip Tricca08206512017-12-28 14:56:07 -0800125AX_ADD_COMPILER_FLAG([-std=c99])
Andreas Fuchs67ef8c22018-03-29 15:22:32 +0200126AX_ADD_COMPILER_FLAG([-Wall])
127AX_ADD_COMPILER_FLAG([-Wextra])
Philip Tricca27447812017-03-08 14:29:49 -0800128AX_ADD_COMPILER_FLAG([-Wformat-security])
Andreas Fuchs67ef8c22018-03-29 15:22:32 +0200129AX_ADD_COMPILER_FLAG([-Werror])
Philip Tricca27447812017-03-08 14:29:49 -0800130AX_ADD_COMPILER_FLAG([-fstack-protector-all])
131AX_ADD_COMPILER_FLAG([-fpic])
132AX_ADD_COMPILER_FLAG([-fPIC])
Tadeusz Struka3260d82017-09-11 12:06:13 -0700133
Philip Tricca08206512017-12-28 14:56:07 -0800134AX_ADD_PREPROC_FLAG([-D_DEFAULT_SOURCE])
Lu Gongabc63b32018-01-10 09:43:14 +0800135AX_ADD_PREPROC_FLAG([-D_BSD_SOURCE])
Jia Zhang58782642018-01-19 11:24:34 +0800136AX_ADD_PREPROC_FLAG([-D_POSIX_SOURCE])
Philip Tricca08206512017-12-28 14:56:07 -0800137
Andreas Fuchs80e84852018-02-27 22:45:09 +0100138AC_ARG_WITH([maxloglevel],
139 [AS_HELP_STRING([--with-maxloglevel={none,error,warning,info,debug,trace}],
Andreas Fuchsbc490762018-01-03 14:36:38 +0100140 [sets the maximum log level (default is trace)])],
141 [],
Andreas Fuchs80e84852018-02-27 22:45:09 +0100142 [with_maxloglevel=trace])
143AS_IF([test "x$with_maxloglevel" = "xnone"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800144 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [0], ["Logging disabled"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100145AS_IF([test "x$with_maxloglevel" = "xerror"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800146 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [2], ["Error log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100147AS_IF([test "x$with_maxloglevel" = "xwarning"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800148 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [3], ["Warning log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100149AS_IF([test "x$with_maxloglevel" = "xinfo"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800150 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [4], ["Info log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100151AS_IF([test "x$with_maxloglevel" = "xdebug"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800152 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [5], ["Debug log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100153AS_IF([test "x$with_maxloglevel" = "xtrace"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800154 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [6], ["Trace log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100155AC_MSG_ERROR([Bad value for --with-maxloglevel])))))))
Andreas Fuchsbc490762018-01-03 14:36:38 +0100156
Tadeusz Struka3260d82017-09-11 12:06:13 -0700157AC_ARG_ENABLE([debug],
158 [AS_HELP_STRING([--enable-debug],
159 [build with debug info (default is no)])],
160 [enable_debug=$enableval],
161 [enable_debug=no])
Tadeusz Struk3980bad2018-04-04 10:30:01 -0700162AS_IF([test "x$enable_debug" = "xyes"], AX_ADD_COMPILER_FLAG([-ggdb3 -Og]))
Tadeusz Struka3260d82017-09-11 12:06:13 -0700163AS_IF([test "x$enable_debug" = "xno"], [AX_ADD_PREPROC_FLAG([-U_FORTIFY_SOURCE])
Tadeusz Struk3980bad2018-04-04 10:30:01 -0700164 AX_ADD_PREPROC_FLAG([-D_FORTIFY_SOURCE=2])
165 AX_ADD_COMPILER_FLAG([-g -O2])])
Philip Tricca27447812017-03-08 14:29:49 -0800166AX_ADD_LINK_FLAG([-Wl,--no-undefined])
167AX_ADD_LINK_FLAG([-Wl,-z,noexecstack])
168AX_ADD_LINK_FLAG([-Wl,-z,now])
169AX_ADD_LINK_FLAG([-Wl,-z,relro])
Philip Triccab43de642017-03-04 21:29:10 -0800170
Philip Tricca99075432018-04-25 19:02:05 -0700171AC_SUBST([PATH])
172
Philip Triccaf8915802017-03-14 17:01:50 -0700173# work around GCC bug #53119
174# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
175AX_ADD_COMPILER_FLAG([-Wno-missing-braces])
176
Andreas Fuchs2968c712018-02-01 18:22:47 +0100177dnl --------- Doxy Gen -----------------------
Andreas Fuchsbc169cb2018-04-10 12:02:10 +0200178DX_DOXYGEN_FEATURE(ON)
179DX_DOT_FEATURE(OFF)
Andreas Fuchs2968c712018-02-01 18:22:47 +0100180DX_HTML_FEATURE(ON)
181DX_CHM_FEATURE(OFF)
182DX_CHI_FEATURE(OFF)
183DX_MAN_FEATURE(ON)
184DX_RTF_FEATURE(OFF)
185DX_XML_FEATURE(OFF)
186DX_PDF_FEATURE(OFF)
187DX_PS_FEATURE(OFF)
Andreas Fuchse5273b32018-04-26 16:16:24 +0200188DX_INIT_DOXYGEN($PACKAGE_NAME, [Doxyfile], [doc/doxygen])
189AM_CONDITIONAL(DOXYMAN, [test $DX_FLAG_man -eq 1])
Andreas Fuchs2968c712018-02-01 18:22:47 +0100190
Andreas Fuchs61cb7fb2017-11-22 10:23:01 +0100191AX_CODE_COVERAGE
192
Philip Triccad1952b42015-08-05 15:52:10 -0700193AC_OUTPUT
Juergen Reppff821bd2017-12-11 15:21:42 +0100194
195AC_MSG_RESULT([
196 $PACKAGE_NAME $VERSION
197 esapi: $enable_esapi
198 tctidefaultmodule: $with_tctidefaultmodule
199 tctidefaultconfig: $with_tctidefaultconfig
200 unit: $enable_unit
201 debug: $enable_debug
202 simulatorbin: $with_simulatorbin
Philip Triccafb0b72f2018-03-04 19:39:24 -0800203 maxloglevel: $with_maxloglevel
Andreas Fuchs2968c712018-02-01 18:22:47 +0100204 doxygen: $DX_FLAG_doc $enable_doxygen_doc
Juergen Reppff821bd2017-12-11 15:21:42 +0100205])
206