blob: 6696e35753e8167156b3fe100c3ca4d9e504027e [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],
30 [https://github.com/01org/tpm2-tss/issues],
31 [],
32 [https://github.com/01org/tpm2-tss])
Philip Triccaa509a682015-09-14 15:34:52 -070033AC_CONFIG_MACRO_DIR([m4])
Philip Tricca35ac9cf2015-08-05 17:03:52 -070034AC_PROG_CC
Philip Triccaffbd61a2015-09-25 00:27:57 -070035LT_INIT()
Philip Tricca71aa9852015-08-25 00:26:22 -070036AM_INIT_AUTOMAKE([foreign
37 subdir-objects])
Andreas Fuchs3c965e72017-11-24 16:16:20 +010038m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) #Backward compatible setting of "silent-rules"
39
Andreas Fuchs2968c712018-02-01 18:22:47 +010040AC_CONFIG_FILES([Makefile doc/Doxyfile])
Philip Tricca1a94dd82017-08-16 14:32:55 -070041
42# propagate configure arguments to distcheck
43AC_SUBST([DISTCHECK_CONFIGURE_FLAGS],[$ac_configure_args])
44
Philip Tricca4334dee2016-08-09 19:56:28 -070045AC_ARG_ENABLE([unit],
46 [AS_HELP_STRING([--enable-unit],
47 [build cmocka unit tests (default is no)])],
48 [enable_unit=$enableval],
49 [enable_unit=no])
Philip Tricca38db7552018-02-27 07:58:25 -080050m4_define([cmocka_min_version], [1.0])
51m4_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 -070052AS_IF([test "x$enable_unit" != xno],
53 [PKG_CHECK_MODULES([CMOCKA],
Philip Tricca38db7552018-02-27 07:58:25 -080054 [cmocka >= cmocka_min_version],
Philip Tricca4334dee2016-08-09 19:56:28 -070055 [AC_DEFINE([HAVE_CMOCKA],
Philip Tricca38db7552018-02-27 07:58:25 -080056 [1])],
57 [AC_MSG_ERROR([cmocka_err])])])
Philip Tricca4334dee2016-08-09 19:56:28 -070058AM_CONDITIONAL([UNIT], [test "x$enable_unit" != xno])
Philip Tricca77683c72017-12-04 16:05:52 -080059
60# Uriparser library required by simulator TCTI library.
61PKG_CHECK_MODULES([URIPARSER],[liburiparser])
62
Juergen Reppff821bd2017-12-11 15:21:42 +010063AC_ARG_ENABLE([esapi],
64 [AS_HELP_STRING([--enable-esapi],
65 [build the esapi layer (default is yes)])],
66 [enable_esapi=$enableval],
67 [enable_esapi=yes])
68AS_IF([test "x$enable_esapi" != xno],
Philip Tricca8eecfd32018-01-31 06:28:27 -080069 [AC_CHECK_HEADER([gcrypt.h],
70 [],
71 [AC_MSG_ERROR([Missing required header: gcrypt.h.])])])
Juergen Reppff821bd2017-12-11 15:21:42 +010072AS_IF([test "x$enable_esapi" != xno],
Philip Tricca8eecfd32018-01-31 06:28:27 -080073 [AC_CHECK_LIB([gcrypt],
74 [gcry_mac_open],
75 [],
76 [AC_MSG_ERROR([Missing required library: gcrypt.])])])
Juergen Reppff821bd2017-12-11 15:21:42 +010077AM_CONDITIONAL([ESAPI], [test "x$enable_esapi" != xno])
78
79AC_ARG_WITH([tctidefaultmodule],
80 [AS_HELP_STRING([--with-tctidefaultmodule],
81 [The default tcti module for an Esys context.])],
82 [],
83 [with_tctidefaultmodule=Socket])
84AC_SUBST([TCTI_DEFAULT_MODULE], [$with_tctidefaultmodule])
85
86AC_ARG_WITH([tctidefaultconfig],
87 [AS_HELP_STRING([--with-tctidefaultconfig],
88 [The default tcti module's configuration.])],
89 [],
90 [with_tctidefaultconfig="tcp://127.0.0.1:2321"])
91AC_SUBST([TCTI_DEFAULT_CONFIG], [$with_tctidefaultconfig])
Philip Tricca99d41422017-06-18 15:11:50 -070092#
93# simulator binary
94#
95AC_MSG_CHECKING([Checking for simulator binary: $with_simulatorbin])
96AC_ARG_WITH([simulatorbin],
97 [AS_HELP_STRING([--with-simulatorbin=tpm_server],[simulator executable])],
98 [AS_IF([test \( -f "$with_simulatorbin" \) -a \( -x "$with_simulatorbin" \)],
99 [AC_MSG_RESULT([success])
100 AC_SUBST([SIMULATOR_BIN],[$with_simulatorbin])
101 AX_NORMALIZE_PATH([with_simulatorbin])
102 with_simulatorbin_set=yes],
103 [AC_MSG_ERROR([TPM simulator binary provided does not exist])])],
104 [with_simulatorbin_set=no])
105AM_CONDITIONAL([SIMULATOR_BIN],[test "x$with_simulatorbin_set" = "xyes"])
Philip Triccab43de642017-03-04 21:29:10 -0800106
Tadeusz Struk15220e82018-01-24 09:51:53 -0800107AS_IF([test "x$with_simulatorbin_set" == xyes],
Philip Tricca5c1b1402018-02-02 13:09:12 -0800108 [PKG_CHECK_MODULES([LIBCRYPTO],[libcrypto])])
Tadeusz Struk15220e82018-01-24 09:51:53 -0800109
David R. Bild1e49b4c2017-11-28 18:09:42 -0600110gl_LD_VERSION_SCRIPT
111
Philip Tricca27447812017-03-08 14:29:49 -0800112AX_ADD_COMPILER_FLAG([-Wall])
113AX_ADD_COMPILER_FLAG([-Werror])
Philip Tricca08206512017-12-28 14:56:07 -0800114AX_ADD_COMPILER_FLAG([-std=c99])
Philip Tricca27447812017-03-08 14:29:49 -0800115AX_ADD_COMPILER_FLAG([-Wformat])
116AX_ADD_COMPILER_FLAG([-Wformat-security])
117AX_ADD_COMPILER_FLAG([-fstack-protector-all])
118AX_ADD_COMPILER_FLAG([-fpic])
119AX_ADD_COMPILER_FLAG([-fPIC])
Tadeusz Struka3260d82017-09-11 12:06:13 -0700120
Philip Tricca08206512017-12-28 14:56:07 -0800121AX_ADD_PREPROC_FLAG([-D_DEFAULT_SOURCE])
Lu Gongabc63b32018-01-10 09:43:14 +0800122AX_ADD_PREPROC_FLAG([-D_BSD_SOURCE])
Jia Zhang58782642018-01-19 11:24:34 +0800123AX_ADD_PREPROC_FLAG([-D_POSIX_SOURCE])
Philip Tricca08206512017-12-28 14:56:07 -0800124
Andreas Fuchs80e84852018-02-27 22:45:09 +0100125AC_ARG_WITH([maxloglevel],
126 [AS_HELP_STRING([--with-maxloglevel={none,error,warning,info,debug,trace}],
Andreas Fuchsbc490762018-01-03 14:36:38 +0100127 [sets the maximum log level (default is trace)])],
128 [],
Andreas Fuchs80e84852018-02-27 22:45:09 +0100129 [with_maxloglevel=trace])
130AS_IF([test "x$with_maxloglevel" = "xnone"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800131 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [0], ["Logging disabled"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100132AS_IF([test "x$with_maxloglevel" = "xerror"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800133 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [2], ["Error log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100134AS_IF([test "x$with_maxloglevel" = "xwarning"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800135 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [3], ["Warning log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100136AS_IF([test "x$with_maxloglevel" = "xinfo"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800137 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [4], ["Info log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100138AS_IF([test "x$with_maxloglevel" = "xdebug"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800139 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [5], ["Debug log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100140AS_IF([test "x$with_maxloglevel" = "xtrace"],
Tadeusz Strukae55ab92018-02-28 11:56:31 -0800141 AC_DEFINE_UNQUOTED([MAXLOGLEVEL], [6], ["Trace log level"]),
Andreas Fuchs80e84852018-02-27 22:45:09 +0100142AC_MSG_ERROR([Bad value for --with-maxloglevel])))))))
Andreas Fuchsbc490762018-01-03 14:36:38 +0100143
Tadeusz Struka3260d82017-09-11 12:06:13 -0700144AC_ARG_ENABLE([debug],
145 [AS_HELP_STRING([--enable-debug],
146 [build with debug info (default is no)])],
147 [enable_debug=$enableval],
148 [enable_debug=no])
149AS_IF([test "x$enable_debug" = "xyes"], AX_ADD_COMPILER_FLAG([-ggdb3 -O0]))
150AS_IF([test "x$enable_debug" = "xno"], [AX_ADD_PREPROC_FLAG([-U_FORTIFY_SOURCE])
151 AX_ADD_PREPROC_FLAG([-D_FORTIFY_SOURCE=2])])
Philip Tricca27447812017-03-08 14:29:49 -0800152AX_ADD_LINK_FLAG([-Wl,--no-undefined])
153AX_ADD_LINK_FLAG([-Wl,-z,noexecstack])
154AX_ADD_LINK_FLAG([-Wl,-z,now])
155AX_ADD_LINK_FLAG([-Wl,-z,relro])
Philip Triccab43de642017-03-04 21:29:10 -0800156
Philip Triccaf8915802017-03-14 17:01:50 -0700157# work around GCC bug #53119
158# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
159AX_ADD_COMPILER_FLAG([-Wno-missing-braces])
160
Andreas Fuchs2968c712018-02-01 18:22:47 +0100161dnl --------- Doxy Gen -----------------------
162DX_INIT_DOXYGEN($PACKAGE_NAME, [doc/Doxyfile], [doc/doxy])
163DX_HTML_FEATURE(ON)
164DX_CHM_FEATURE(OFF)
165DX_CHI_FEATURE(OFF)
166DX_MAN_FEATURE(ON)
167DX_RTF_FEATURE(OFF)
168DX_XML_FEATURE(OFF)
169DX_PDF_FEATURE(OFF)
170DX_PS_FEATURE(OFF)
171
172
Andreas Fuchs61cb7fb2017-11-22 10:23:01 +0100173AX_CODE_COVERAGE
174
Philip Triccad1952b42015-08-05 15:52:10 -0700175AC_OUTPUT
Juergen Reppff821bd2017-12-11 15:21:42 +0100176
177AC_MSG_RESULT([
178 $PACKAGE_NAME $VERSION
179 esapi: $enable_esapi
180 tctidefaultmodule: $with_tctidefaultmodule
181 tctidefaultconfig: $with_tctidefaultconfig
182 unit: $enable_unit
183 debug: $enable_debug
184 simulatorbin: $with_simulatorbin
185 loglevel: $with_loglevel
Andreas Fuchs2968c712018-02-01 18:22:47 +0100186 doxygen: $DX_FLAG_doc $enable_doxygen_doc
Juergen Reppff821bd2017-12-11 15:21:42 +0100187])
188