at master 7.4 kB view raw
1From 6a426b8093cf6633425d08a2d33ed24d200473a0 Mon Sep 17 00:00:00 2001 2From: Alyssa Ross <hi@alyssa.is> 3Date: Sun, 9 Feb 2025 08:51:32 +0100 4Subject: [PATCH] build: use pkg-config to find tss2-esys 5 6Otherwise, tss2-esys's dependencies (other tss2 libraries, OpenSSL) 7won't be linked when tss2-esys is a static library. 8--- 9Link: https://dev.gnupg.org/D606 10 11 configure | 131 +++++++++++++++++++++++++++++---------------------- 12 configure.ac | 5 +- 13 2 files changed, 76 insertions(+), 60 deletions(-) 14 15diff --git a/configure b/configure 16index 59f027d..f53c99d 100755 17--- a/configure 18+++ b/configure 19@@ -669,12 +669,12 @@ TEST_LIBTSS_FALSE 20 TEST_LIBTSS_TRUE 21 HAVE_LIBTSS_FALSE 22 HAVE_LIBTSS_TRUE 23-LIBTSS_CFLAGS 24-LIBTSS_LIBS 25 SWTPM 26 TSSSTARTUP 27 TPMSERVER 28 TSS_INCLUDE 29+LIBTSS_LIBS 30+LIBTSS_CFLAGS 31 W32SOCKLIBS 32 NETLIBS 33 CROSS_COMPILING_FALSE 34@@ -1005,7 +1005,9 @@ PKG_CONFIG_LIBDIR 35 SQLITE3_CFLAGS 36 SQLITE3_LIBS 37 LIBGNUTLS_CFLAGS 38-LIBGNUTLS_LIBS' 39+LIBGNUTLS_LIBS 40+LIBTSS_CFLAGS 41+LIBTSS_LIBS' 42 43 44 # Initialize some variables set by options. 45@@ -1771,6 +1773,9 @@ Some influential environment variables: 46 C compiler flags for LIBGNUTLS, overriding pkg-config 47 LIBGNUTLS_LIBS 48 linker flags for LIBGNUTLS, overriding pkg-config 49+ LIBTSS_CFLAGS 50+ C compiler flags for LIBTSS, overriding pkg-config 51+ LIBTSS_LIBS linker flags for LIBTSS, overriding pkg-config 52 53 Use these variables to override the choices made by `configure' or to help 54 it to find libraries and programs with nonstandard names/locations. 55@@ -15465,64 +15470,77 @@ else 56 fi 57 58 elif test "$with_tss" = intel; then 59- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing Esys_Initialize" >&5 60-$as_echo_n "checking for library containing Esys_Initialize... " >&6; } 61-if ${ac_cv_search_Esys_Initialize+:} false; then : 62- $as_echo_n "(cached) " >&6 63-else 64- ac_func_search_save_LIBS=$LIBS 65-cat confdefs.h - <<_ACEOF >conftest.$ac_ext 66-/* end confdefs.h. */ 67 68-/* Override any GCC internal prototype to avoid an error. 69- Use char because int might match the return type of a GCC 70- builtin and then its argument prototype would still apply. */ 71-#ifdef __cplusplus 72-extern "C" 73-#endif 74-char Esys_Initialize (); 75-int 76-main () 77-{ 78-return Esys_Initialize (); 79- ; 80- return 0; 81-} 82-_ACEOF 83-for ac_lib in '' tss2-esys; do 84- if test -z "$ac_lib"; then 85- ac_res="none required" 86- else 87- ac_res=-l$ac_lib 88- LIBS="-l$ac_lib $ac_func_search_save_LIBS" 89- fi 90- if ac_fn_c_try_link "$LINENO"; then : 91- ac_cv_search_Esys_Initialize=$ac_res 92-fi 93-rm -f core conftest.err conftest.$ac_objext \ 94- conftest$ac_exeext 95- if ${ac_cv_search_Esys_Initialize+:} false; then : 96- break 97-fi 98-done 99-if ${ac_cv_search_Esys_Initialize+:} false; then : 100+pkg_failed=no 101+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBTSS" >&5 102+$as_echo_n "checking for LIBTSS... " >&6; } 103 104+if test -n "$LIBTSS_CFLAGS"; then 105+ pkg_cv_LIBTSS_CFLAGS="$LIBTSS_CFLAGS" 106+ elif test -n "$PKG_CONFIG"; then 107+ if test -n "$PKG_CONFIG" && \ 108+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"tss2-esys tss2-mu tss2-rc tss2-tctildr\""; } >&5 109+ ($PKG_CONFIG --exists --print-errors "tss2-esys tss2-mu tss2-rc tss2-tctildr") 2>&5 110+ ac_status=$? 111+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 112+ test $ac_status = 0; }; then 113+ pkg_cv_LIBTSS_CFLAGS=`$PKG_CONFIG --cflags "tss2-esys tss2-mu tss2-rc tss2-tctildr" 2>/dev/null` 114+ test "x$?" != "x0" && pkg_failed=yes 115 else 116- ac_cv_search_Esys_Initialize=no 117+ pkg_failed=yes 118 fi 119-rm conftest.$ac_ext 120-LIBS=$ac_func_search_save_LIBS 121+ else 122+ pkg_failed=untried 123 fi 124-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_Esys_Initialize" >&5 125-$as_echo "$ac_cv_search_Esys_Initialize" >&6; } 126-ac_res=$ac_cv_search_Esys_Initialize 127-if test "$ac_res" != no; then : 128- test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" 129- have_libtss=Intel 130+if test -n "$LIBTSS_LIBS"; then 131+ pkg_cv_LIBTSS_LIBS="$LIBTSS_LIBS" 132+ elif test -n "$PKG_CONFIG"; then 133+ if test -n "$PKG_CONFIG" && \ 134+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"tss2-esys tss2-mu tss2-rc tss2-tctildr\""; } >&5 135+ ($PKG_CONFIG --exists --print-errors "tss2-esys tss2-mu tss2-rc tss2-tctildr") 2>&5 136+ ac_status=$? 137+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 138+ test $ac_status = 0; }; then 139+ pkg_cv_LIBTSS_LIBS=`$PKG_CONFIG --libs "tss2-esys tss2-mu tss2-rc tss2-tctildr" 2>/dev/null` 140+ test "x$?" != "x0" && pkg_failed=yes 141 else 142- as_fn_error $? "Intel TPM Software Stack requested but not found" "$LINENO" 5 143+ pkg_failed=yes 144+fi 145+ else 146+ pkg_failed=untried 147 fi 148 149+ 150+ 151+if test $pkg_failed = yes; then 152+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 153+$as_echo "no" >&6; } 154+ 155+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then 156+ _pkg_short_errors_supported=yes 157+else 158+ _pkg_short_errors_supported=no 159+fi 160+ if test $_pkg_short_errors_supported = yes; then 161+ LIBTSS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "tss2-esys tss2-mu tss2-rc tss2-tctildr" 2>&1` 162+ else 163+ LIBTSS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "tss2-esys tss2-mu tss2-rc tss2-tctildr" 2>&1` 164+ fi 165+ # Put the nasty error message in config.log where it belongs 166+ echo "$LIBTSS_PKG_ERRORS" >&5 167+ 168+ as_fn_error $? "Intel TPM Software Stack requested but not found" "$LINENO" 5 169+elif test $pkg_failed = untried; then 170+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 171+$as_echo "no" >&6; } 172+ as_fn_error $? "Intel TPM Software Stack requested but not found" "$LINENO" 5 173+else 174+ LIBTSS_CFLAGS=$pkg_cv_LIBTSS_CFLAGS 175+ LIBTSS_LIBS=$pkg_cv_LIBTSS_LIBS 176+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 177+$as_echo "yes" >&6; } 178+ have_libtss=Intel 179+fi 180 else 181 as_fn_error $? "Invalid TPM Software Stack requested: $with_tss" "$LINENO" 5 182 fi 183@@ -15616,7 +15634,6 @@ $as_echo "$as_me: WARNING: Need Esys_TR_GetTpmHandle API (usually requires Intel 184 185 fi 186 187- LIBTSS_LIBS="$LIBS -ltss2-mu -ltss2-rc -ltss2-tctildr" 188 189 $as_echo "#define HAVE_INTEL_TSS 1" >>confdefs.h 190 191diff --git a/configure.ac b/configure.ac 192index dc44465..92880e6 100644 193--- a/configure.ac 194+++ b/configure.ac 195@@ -1574,8 +1574,8 @@ if test "$build_tpm2d" = "yes"; then 196 AC_SEARCH_LIBS([TSS_Create],[tss ibmtss],have_libtss=IBM, 197 [AC_MSG_ERROR([IBM TPM Software Stack requested but not found])]) 198 elif test "$with_tss" = intel; then 199- AC_SEARCH_LIBS([Esys_Initialize],[tss2-esys],have_libtss=Intel, 200- [AC_MSG_ERROR([Intel TPM Software Stack requested but not found])]) 201+ PKG_CHECK_MODULES([LIBTSS], [tss2-esys tss2-mu tss2-rc tss2-tctildr],have_libtss=Intel, 202+ [AC_MSG_ERROR([Intel TPM Software Stack requested but not found])]) 203 else 204 AC_MSG_ERROR([Invalid TPM Software Stack requested: $with_tss]) 205 fi 206@@ -1605,7 +1605,6 @@ if test "$build_tpm2d" = "yes"; then 207 AC_MSG_WARN([Need Esys_TR_GetTpmHandle API (usually requires Intel TSS 2.4.0 or later, disabling TPM support)]) 208 have_libtss=no 209 ]) 210- LIBTSS_LIBS="$LIBS -ltss2-mu -ltss2-rc -ltss2-tctildr" 211 AC_DEFINE(HAVE_INTEL_TSS, 1, [Defined if we have the Intel TSS]) 212 fi 213 LIBS="$_save_libs" 214-- 2152.47.2 216