VirtualBox

source: vbox/trunk/src/libs/libtpms-0.9.6/configure.ac@ 103630

Last change on this file since 103630 was 98878, checked in by vboxsync, 21 months ago

libs/libtpms-0.9.6: Applied and adjusted our libtpms changes to 0.9.6, bugref:10378

File size: 12.2 KB
Line 
1#
2# configure.in
3#
4# See the LICENSE file for the license associated with this file.
5
6AC_INIT([libtpms],[0.9.6])
7AC_PREREQ([2.69])
8AC_CONFIG_SRCDIR(Makefile.am)
9AC_CONFIG_AUX_DIR([.])
10AC_CONFIG_HEADERS([config.h])
11
12AC_CONFIG_MACRO_DIR([m4])
13AC_CANONICAL_TARGET
14AM_INIT_AUTOMAKE([foreign 1.6 subdir-objects])
15AM_SILENT_RULES([yes])
16
17LIBTPMS_VER_MAJOR=`echo $PACKAGE_VERSION | awk -F. '{print $1}'`
18LIBTPMS_VER_MINOR=`echo $PACKAGE_VERSION | awk -F. '{print $2}'`
19LIBTPMS_VER_MICRO=`echo $PACKAGE_VERSION | awk -F. '{print $3}'`
20LIBTPMS_VERSION=$PACKAGE_VERSION
21LIBTPMS_VERSION_INFO=`expr $LIBTPMS_VER_MAJOR + $LIBTPMS_VER_MINOR`:$LIBTPMS_VER_MICRO:$LIBTPMS_VER_MINOR
22
23AC_SUBST([LIBTPMS_VER_MAJOR])
24AC_SUBST([LIBTPMS_VER_MINOR])
25AC_SUBST([LIBTPMS_VER_MICRO])
26AC_SUBST([LIBTPMS_VERSION])
27AC_SUBST([LIBTPMS_VERSION_INFO])
28
29DEBUG=""
30AC_MSG_CHECKING([for debug-enabled build])
31AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],[create a debug build]),
32 [if test "$enableval" = "yes"; then
33 DEBUG="yes"
34 AC_MSG_RESULT([yes])
35 else
36 DEBUG="no"
37 AC_MSG_RESULT([no])
38 fi],
39 [DEBUG="no",
40 AC_MSG_RESULT([no])])
41
42if test "$DEBUG" = "yes"; then
43 CFLAGS="$CFLAGS -O0 -g -DDEBUG"
44fi
45
46debug_defines=
47if test "$DEBUG" = "yes"; then
48 debug_defines="-DTPM_DEBUG"
49 # Enable the following only if ABSOLUTELY necessary
50 # volatile state will be written and behavior changes
51 #"-DTPM_VOLATILE_STORE"
52fi
53AC_SUBST(DEBUG_DEFINES, $debug_defines)
54
55# AX_CHECK_LINK_FLAG needs autoconf 2.64 or later
56have_version_script="no"
57m4_if(
58 m4_version_compare(
59 m4_defn([AC_AUTOCONF_VERSION]),
60 [2.64]),
61 -1,
62 [],
63 [AX_CHECK_LINK_FLAG([-Wl,--version-script=$srcdir/src/test.syms],
64 [have_version_script="yes"],
65 [])]
66)
67
68AM_CONDITIONAL([HAVE_VERSION_SCRIPT], [test "x$have_version_script" = "xyes"])
69
70AC_ARG_WITH([tpm1],
71 AS_HELP_STRING([--with-tpm1], [build libtpms with TPM 1.2 support]), [], [with_tpm1=yes])
72AM_CONDITIONAL([WITH_TPM1], [test "x$with_tpm1" != "xno"])
73AS_IF([test "x$with_tpm1" != "xno"], [
74 AC_DEFINE([WITH_TPM1], [1], [With TPM 1.2 support])
75 AC_SUBST([WITH_TPM1], [1])
76])
77
78AC_ARG_WITH([tpm2],
79 AS_HELP_STRING([--with-tpm2],[build libtpms with TPM2 support]),
80 [],
81 [with_tpm2=yes]
82)
83AS_IF([test "x$with_tpm2" = xyes], [
84 AC_MSG_RESULT([Building with TPM2 support])
85 AC_DEFINE_UNQUOTED([WITH_TPM2], 1, [whether to support TPM2])
86 AC_SUBST([WITH_TPM2], [1])
87 AM_CONDITIONAL(WITH_TPM2, true)
88 cryptolib=openssl
89], [
90 AM_CONDITIONAL(WITH_TPM2, false)
91 cryptolib=freebl
92])
93
94AC_SUBST(cryptolib, $cryptolib)
95
96AC_ARG_WITH([openssl],
97 AS_HELP_STRING([--with-openssl],[build libtpms with openssl library]),
98 [AC_CHECK_LIB(crypto,
99 [AES_set_encrypt_key],
100 [],
101 AC_MSG_ERROR(Faulty openssl crypto library))
102 AC_CHECK_HEADERS([openssl/aes.h],[],
103 AC_MSG_ERROR(Is openssl-devel/libssl-dev installed?))
104 AC_MSG_RESULT([Building with openssl crypto library])
105 cryptolib=openssl
106 ]
107)
108
109case "$cryptolib" in
110freebl)
111 AM_CONDITIONAL(LIBTPMS_USE_FREEBL, true)
112 AM_CONDITIONAL(LIBTPMS_USE_OPENSSL, false)
113 AC_DEFINE([USE_FREEBL_CRYPTO_LIBRARY],
114 [1],
115 [use freebl crypto library])
116
117 CFLAGS_save=$CFLAGS
118
119 AC_CHECK_HEADERS([gmp.h],[],
120 AC_MSG_ERROR(gmp-devel/libgmp-dev is bad))
121
122 CFLAGS="$(nspr-config --cflags)"
123 if test $? -ne 0; then
124 AC_MSG_ERROR(Could not find nspr-config. Is nspr-devel/libnspr4-dev installed?)
125 fi
126 CPPFLAGS=$CFLAGS
127 AC_CHECK_HEADERS([plbase64.h],[],
128 AC_MSG_ERROR(You must install nspr-devel/libnspr4-dev))
129
130 CFLAGS="$(nss-config --cflags) $CFLAGS"
131 if test $? -ne 0; then
132 AC_MSG_ERROR(Could not find nss-config. Is nss-devel/libnss3-dev installed?)
133 fi
134 CPPFLAGS="$CPPFLAGS $CFLAGS"
135 AC_CHECK_HEADERS([sslerr.h],[],
136 AC_MSG_ERROR(nss-devel/libnss3-dev is bad))
137
138 # Check for missing headers
139 AC_CHECK_HEADERS([blapi.h],[],
140 AC_MSG_ERROR(nss-softokn-freebl-devel/libnss3-dev is missing blapi.h))
141 # Check for missing freebl library or missing library functions
142 LIBS_save="$LIBS"
143 LIBS="$(nss-config --libs) $(nspr-config --libs)"
144 AC_SEARCH_LIBS([AES_CreateContext], [freebl],[],
145 AC_MSG_ERROR("Could not find AES_CreateContext(). Is nss-softokn-freebl-devel/libnss3-dev installed?"),
146 [])
147 LIBS="$LIBS_save"
148 CFLAGS="$CFLAGS_save $CFLAGS"
149 enable_use_openssl_functions=no
150 ;;
151openssl)
152 AM_CONDITIONAL(LIBTPMS_USE_FREEBL, false)
153 AM_CONDITIONAL(LIBTPMS_USE_OPENSSL, true)
154 AC_DEFINE([USE_OPENSSL_CRYPTO_LIBRARY],
155 [1],
156 [use openssl crypto library])
157 LIBCRYPTO_EXTRA_CFLAGS="-DOPENSSL_SUPPRESS_DEPRECATED"
158 AC_SUBST([LIBCRYPTO_EXTRA_CFLAGS])
159 ;;
160esac
161
162use_openssl_functions_for=""
163use_openssl_functions_symmetric=0
164use_openssl_functions_ec=0
165use_openssl_functions_ecdsa=0
166use_openssl_functions_rsa=0
167AC_ARG_ENABLE(use-openssl-functions,
168 AS_HELP_STRING([--disable-use-openssl-functions],
169 [Use TPM 2 crypot code rather than OpenSSL crypto functions]),
170)
171AS_IF([test "x$enable_use_openssl_functions" != "xno"], [
172 if test "x$cryptolib" != "xopenssl"; then
173 AC_MSG_ERROR([OpenSSL crypto function usage requires openssl as crypto library])
174 fi
175 LIBS_save=$LIBS
176 # Check for symmetric key crypto functions
177 not_found=0
178 AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_new],, not_found=1)
179 AC_CHECK_LIB([crypto], [EVP_EncryptInit_ex],, not_found=1)
180 AC_CHECK_LIB([crypto], [EVP_aes_128_cbc],, not_found=1)
181 AC_CHECK_LIB([crypto], [EVP_des_ede3_cbc],, not_found=1)
182 AC_CHECK_LIB([crypto], [EVP_camellia_128_cbc],, not_found=1)
183 AC_CHECK_LIB([crypto], [DES_random_key],, not_found=1)
184 AC_CHECK_LIB([crypto], [EVP_CIPHER_CTX_iv],, not_found=1)
185 if test "x$not_found" = "x0"; then
186 use_openssl_functions_symmetric=1
187 use_openssl_functions_for="symmetric (AES, TDES) "
188 fi
189 # Check for EC crypto support
190 not_found=0
191 AC_CHECK_LIB([crypto], [EC_KEY_set_group],, not_found=1)
192 AC_CHECK_LIB([crypto], [EC_KEY_generate_key],, not_found=1)
193 AC_CHECK_LIB([crypto], [EC_KEY_get0_private_key],, not_found=1)
194 if test "x$not_found" = "x0"; then
195 use_openssl_functions_ec=1
196 use_openssl_functions_for="${use_openssl_functions_for}general elliptic curve (EC) "
197 fi
198 # Check for ECDSA crypto support
199 not_found=0
200 AC_CHECK_LIB([crypto], [ECDSA_SIG_new],, not_found=1)
201 AC_CHECK_LIB([crypto], [ECDSA_SIG_set0],, not_found=1)
202 AC_CHECK_LIB([crypto], [ECDSA_do_verify],, not_found=1)
203 AC_CHECK_LIB([crypto], [ECDSA_do_sign],, not_found=1)
204 AC_CHECK_LIB([crypto], [EC_KEY_set_group],, not_found=1)
205 if test "x$not_found" = "x0"; then
206 use_openssl_functions_ecdsa=1
207 use_openssl_functions_for="${use_openssl_functions_for}elliptic curve (ECDSA) "
208 fi
209 # Check for RSA crypto functions
210 not_found=0
211 AC_CHECK_LIB([crypto], [RSA_set0_key],, not_found=1)
212 AC_CHECK_LIB([crypto], [RSA_set0_factors],, not_found=1)
213 AC_CHECK_LIB([crypto], [RSA_set0_crt_params],, not_found=1)
214 AC_CHECK_LIB([crypto], [RSA_generate_key_ex],, not_found=1)
215 AC_CHECK_LIB([crypto], [EVP_PKEY_CTX_new],, not_found=1)
216 AC_CHECK_LIB([crypto], [EVP_PKEY_assign],, not_found=1)
217 AC_CHECK_LIB([crypto], [EVP_PKEY_encrypt_init],, not_found=1)
218 AC_CHECK_LIB([crypto], [EVP_PKEY_encrypt],, not_found=1)
219 AC_CHECK_LIB([crypto], [EVP_PKEY_decrypt_init],, not_found=1)
220 AC_CHECK_LIB([crypto], [EVP_PKEY_decrypt],, not_found=1)
221 AC_CHECK_LIB([crypto], [EVP_PKEY_sign_init],, not_found=1)
222 AC_CHECK_LIB([crypto], [EVP_PKEY_sign],, not_found=1)
223 AC_CHECK_LIB([crypto], [EVP_PKEY_verify_init],, not_found=1)
224 AC_CHECK_LIB([crypto], [EVP_PKEY_verify],, not_found=1)
225 AC_CHECK_LIB([crypto], [EVP_get_digestbyname],, not_found=1)
226 # OpenSSL 3.0 turned some #defines into functions
227 AX_CHECK_DEFINE([<openssl/rsa.h>], [EVP_PKEY_CTX_set0_rsa_oaep_label],,
228 AC_CHECK_LIB([crypto], [EVP_PKEY_CTX_set0_rsa_oaep_label],, not_found=1)
229 )
230 AX_CHECK_DEFINE([<openssl/rsa.h>], [EVP_PKEY_CTX_set_rsa_padding],,
231 AC_CHECK_LIB([crypto], [EVP_PKEY_CTX_set_rsa_padding],, not_found=1)
232 )
233 AX_CHECK_DEFINE([<openssl/rsa.h>], [EVP_PKEY_CTX_set_rsa_oaep_md],,
234 AC_CHECK_LIB([crypto], [EVP_PKEY_CTX_set_rsa_oaep_md],, not_found=1)
235 )
236 AX_CHECK_DEFINE([<openssl/evp.h>], [EVP_PKEY_CTX_set_signature_md],,
237 AC_CHECK_LIB([crypto], [EVP_PKEY_CTX_set_signature_md],, not_found=1)
238 )
239 if test "x$not_found" = "x0"; then
240 use_openssl_functions_rsa=1
241 use_openssl_functions_for="${use_openssl_functions_for}RSA "
242 fi
243 LIBS=$LIBS_save
244])
245CFLAGS="$CFLAGS -DUSE_OPENSSL_FUNCTIONS_SYMMETRIC=$use_openssl_functions_symmetric"
246CFLAGS="$CFLAGS -DUSE_OPENSSL_FUNCTIONS_EC=$use_openssl_functions_ec"
247CFLAGS="$CFLAGS -DUSE_OPENSSL_FUNCTIONS_ECDSA=$use_openssl_functions_ecdsa"
248CFLAGS="$CFLAGS -DUSE_OPENSSL_FUNCTIONS_RSA=$use_openssl_functions_rsa"
249
250AC_ARG_ENABLE([sanitizers], AS_HELP_STRING([--enable-sanitizers], [Enable address sanitizing]),
251 [SANITIZERS="-fsanitize=address,undefined"], [])
252AC_ARG_ENABLE([fuzzer], AS_HELP_STRING([--enable-fuzzer], [Enable fuzzer]),
253 [FUZZER="$SANITIZERS -fsanitize=fuzzer"
254 AM_CONDITIONAL(WITH_FUZZER, true)],
255 [AM_CONDITIONAL(WITH_FUZZER, false)])
256AC_SUBST([SANITIZERS])
257AC_SUBST([FUZZER])
258
259AM_CONDITIONAL([WITH_FUZZING_ENGINE], [test "x$LIB_FUZZING_ENGINE" != "x"])
260AC_SUBST([LIB_FUZZING_ENGINE])
261
262AC_ARG_ENABLE([test-coverage],
263 AS_HELP_STRING([--enable-test-coverage], [Enable test coverage flags]),
264 [COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage" COVERAGE_LDFLAGS="-fprofile-arcs"])
265
266LT_INIT
267AC_PROG_CC
268AC_PROG_CXX
269AC_PROG_INSTALL
270LT_INIT
271
272#AM_GNU_GETTEXT_VERSION([0.15])
273#AM_GNU_GETTEXT([external])
274
275AC_C_CONST
276AC_C_INLINE
277
278AC_TYPE_SIZE_T
279
280AC_CHECK_LIB(c, clock_gettime, LIBRT_LIBS="", LIBRT_LIBS="-lrt")
281AC_SUBST([LIBRT_LIBS])
282
283AC_ARG_ENABLE([hardening],
284 AS_HELP_STRING([--disable-hardening], [Disable hardening flags]))
285
286if test "x$enable_hardening" != "xno"; then
287 # Some versions of gcc fail with -Wstack-protector,
288 # some with -Wstack-protector-strong enabled
289 if ! $CC -fstack-protector-strong $srcdir/include/libtpms/tpm_error.h 2>/dev/null; then
290 if $CC -fstack-protector $srcdir/include/libtpms/tpm_error.h 2>/dev/null; then
291 HARDENING_CFLAGS="-fstack-protector "
292 fi
293 else
294 HARDENING_CFLAGS="-fstack-protector-strong "
295 fi
296
297 dnl Only support -D_FORTIFY_SOURCE=2 and have higher levels passed in by user
298 dnl since they may create more overhead
299 if $CC $CFLAGS -Werror -D_FORTIFY_SOURCE=2 $srcdir/include/libtpms/tpm_library.h 2>/dev/null; then
300 HARDENING_CFLAGS="$HARDENING_CFLAGS -D_FORTIFY_SOURCE=2"
301 fi
302 dnl Check linker for 'relro' and 'now'
303 save_CFLAGS="$CFLAGS"
304 CFLAGS="-Wl,-z,relro -Werror"
305 AC_MSG_CHECKING([whether linker supports -Wl,-z,relro])
306 AC_LINK_IFELSE(
307 [AC_LANG_SOURCE([[int main() { return 0; }]])],
308 [HARDENING_LDFLAGS="$HARDENING_LDFLAGS -Wl,-z,relro"
309 AC_MSG_RESULT(yes)],
310 [AC_MSG_RESULT(no)]
311 )
312 CFLAGS="-Wl,-z,now -Werror"
313 AC_MSG_CHECKING([whether linker supports -Wl,-z,now])
314 AC_LINK_IFELSE(
315 [AC_LANG_SOURCE([[int main() { return 0; }]])],
316 [HARDENING_LDFLAGS="$HARDENING_LDFLAGS -Wl,-z,now"
317 AC_MSG_RESULT(yes)],
318 [AC_MSG_RESULT(no)]
319 )
320 CFLAGS="$save_CFLAGS"
321 AC_SUBST([HARDENING_CFLAGS])
322 AC_SUBST([HARDENING_LDFLAGS])
323fi
324
325AM_CFLAGS="$CFLAGS $COVERAGE_CFLAGS -Wall -Werror -Wreturn-type -Wsign-compare -Wno-self-assign -Wmissing-prototypes"
326AM_CFLAGS="$AM_CFLAGS"
327AM_LDFLAGS="$LDFLAGS $COVERAGE_LDFLAGS"
328
329AC_SUBST([AM_CFLAGS])
330AC_SUBST([AM_LDFLAGS])
331
332AC_CONFIG_FILES(Makefile \
333 dist/libtpms.spec \
334 include/Makefile \
335 include/libtpms/Makefile \
336 include/libtpms/tpm_library.h \
337 man/Makefile \
338 man/man3/Makefile \
339 src/Makefile \
340 libtpms.pc \
341 tests/Makefile)
342PKG_INSTALLDIR()
343AC_OUTPUT
344
345if test -z "$enable_debug" ; then
346 enable_debug="no"
347fi
348if test -z "$with_tpm2"; then
349 with_tpm2=no
350fi
351
352echo
353echo "AM_CFLAGS=$AM_CFLAGS"
354echo "HARDENING_CFLAGS=$HARDENING_CFLAGS"
355echo "HARDENING_LDFLAGS=$HARDENING_LDFLAGS"
356echo "AM_LDFLAGS=$AM_LDFLAGS"
357echo
358echo "Version to build : $PACKAGE_VERSION"
359echo "Crypto library : $cryptolib"
360echo "Debug build : $enable_debug"
361echo "With TPM1.2 support : $with_tpm1"
362echo "With TPM2 support : $with_tpm2"
363echo "HAVE_VERSION_SCRIPT : $have_version_script"
364echo "Use openssl crypto for : $use_openssl_functions_for"
365echo
366echo
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette