Source: swtpm
Version: 0.10.1+ds-1
Tags: patch upstream
User: [email protected]
Usertags: ftcbfs
Hi Luca,
thanks for your work on swtpm and in particular for adding nocheck
support. This made it almost cross buildable. Unfortunately,
configure.ac hard codes the build architecture pkg-config in a lot of
places. I'm attaching a patch to make it use the recommended
PKG_CHECK_MODULES macro instead. Please consider applying it. It should
be suitable for upstream inclusion and also help other cross
distributions such as Yocto or PtxDist.
Helmut
--- swtpm-0.10.1+ds.orig/configure.ac
+++ swtpm-0.10.1+ds/configure.ac
@@ -141,6 +141,8 @@
AC_SUBST([LOCALSTATEDIR])
AC_SUBST([BINDIR])
+PKG_PROG_PKG_CONFIG
+
cryptolib=openssl
AC_ARG_WITH([openssl],
@@ -149,8 +151,7 @@
[],
[])
-case "$cryptolib" in
-openssl)
+AS_IF([test "$cryptolib" = openssl],[
AC_CHECK_LIB(crypto,
[AES_set_encrypt_key],
[true],
@@ -158,8 +159,7 @@
AC_CHECK_HEADERS([openssl/aes.h],[],
AC_MSG_ERROR(Is openssl-devel/libssl-dev installed?))
AC_MSG_RESULT([Building with openssl crypto library])
- LIBCRYPTO_LIBS=$(pkg-config --libs libcrypto)
- AC_SUBST([LIBCRYPTO_LIBS])
+ PKG_CHECK_MODULES([LIBCRYPTO],[libcrypto])
AC_CHECK_HEADERS([openssl/fips.h],
[AC_DEFINE_UNQUOTED([HAVE_OPENSSL_FIPS_H], 1,
[whether openssl/fips.h is available])]
@@ -169,14 +169,9 @@
[AC_DEFINE_UNQUOTED([HAVE_OPENSSL_FIPS_MODE_SET_API], 1,
[whether FIPS_mode_set API is available])]
)
- ;;
-esac
+])
-LIBTASN1_LIBS=$(pkg-config --libs libtasn1)
-if test $? -ne 0; then
- AC_MSG_ERROR("Is libtasn1-devel installed? -- could not get libs for libtasn1")
-fi
-AC_SUBST([LIBTASN1_LIBS])
+PKG_CHECK_MODULES([LIBTASN1],[libtasn1])
PKG_CHECK_MODULES(
[LIBTPMS],
@@ -199,76 +194,33 @@
[with_cuse=check]
)
-if test "$with_cuse" != "no"; then
- LIBFUSE_CFLAGS=$(pkg-config fuse --cflags 2>/dev/null)
- if test $? -ne 0; then
+AS_IF([test "$with_cuse" != no],[
+ PKG_CHECK_MODULES([LIBFUSE],[fuse],[
+ with_cuse=yes
+ AC_DEFINE_UNQUOTED([WITH_CUSE], 1,
+ [whether to build with CUSE interface])
+ PKG_CHECK_MODULES([GTHREAD],[gthread-2.0])
+ ],[
if test "$with_cuse" = "yes"; then
AC_MSG_ERROR("Is fuse-devel installed? -- could not get cflags for libfuse")
else
with_cuse=no
fi
- else
- with_cuse=yes
- fi
-fi
+ ])
+])
dnl with_cuse is now yes or no
-if test "$with_cuse" != "no"; then
- LIBFUSE_LIBS=$(pkg-config fuse --libs)
- if test $? -ne 0; then
- AC_MSG_ERROR("Is fuse-devel installed? -- could not get libs for libfuse")
- fi
- AC_SUBST([LIBFUSE_CFLAGS])
- AC_SUBST([LIBFUSE_LIBS])
- AC_DEFINE_UNQUOTED([WITH_CUSE], 1,
- [whether to build with CUSE interface])
-
- GTHREAD_LIBS=$(pkg-config --libs gthread-2.0)
- if test $? -ne 0; then
- AC_MSG_ERROR("Is glib-2.0 installed? -- could not get libs for gthread-2.0")
- fi
- AC_SUBST([GTHREAD_LIBS])
-fi
AM_CONDITIONAL([WITH_CUSE],[test "$with_cuse" = "yes"])
AC_MSG_RESULT($with_cuse)
-JSON_GLIB_CFLAGS=$(pkg-config --cflags json-glib-1.0)
-if test $? -ne 0; then
- AC_MSG_ERROR("Is libjson-glib-dev/json-glib-devel installed? -- could not get cflags")
-fi
-AC_SUBST([JSON_GLIB_CFLAGS])
-
-JSON_GLIB_LIBS=$(pkg-config --libs json-glib-1.0)
-if test $? -ne 0; then
- AC_MSG_ERROR("Is libjson-glib-dev/json-glib-devel installed? -- could not get libs")
-fi
-AC_SUBST([JSON_GLIB_LIBS])
+PKG_CHECK_MODULES([JSON_GLIB],[json-glib-1.0])
-GLIB_CFLAGS=$(pkg-config --cflags glib-2.0)
-if test $? -ne 0; then
- AC_MSG_ERROR("Is libglib-2.0-dev/glib2-devel installed? -- could not get cflags")
-fi
-AC_SUBST([GLIB_CFLAGS])
+PKG_CHECK_MODULES([GLIB],[glib-2.0])
-GLIB_LIBS=$(pkg-config --libs glib-2.0)
-if test $? -ne 0; then
- AC_MSG_ERROR("Is libglib-2.0-dev/glib2-devel installed? -- could not get libs")
-fi
-AC_SUBST([GLIB_LIBS])
-
-GMP_CFLAGS=$(pkg-config --cflags gmp)
-if test $? -ne 0; then
+PKG_CHECK_MODULES([GMP],[gmp],,[
dnl Older gmp development packages did not provide pkg-config file
- AC_MSG_WARN("Is libgmp-dev/gmp-devel installed? -- could not get cflags; assuming it is installed")
-fi
-AC_SUBST([GMP_CFLAGS])
-
-GMP_LIBS=$(pkg-config --libs gmp)
-if test $? -ne 0; then
- AC_MSG_WARN("Is libgmp-dev/gmp-devel installed? -- could not get libs; assuming -lgmp")
- GMP_LIBS="-lgmp"
-fi
-AC_SUBST([GMP_LIBS])
+ AC_MSG_WARN("Is libgmp-dev/gmp-devel installed? -- could not get cflags nor libs; assuming it is installed as -lgmp")
+])
AC_MSG_CHECKING([for whether to build with chardev interface])
case $host_os in
@@ -289,16 +241,15 @@
[with_gnutls=check]
)
-if test "x$with_gnutls" != "xno"; then
- GNUTLS_LDFLAGS=$(pkg-config --libs gnutls)
- if test $? -ne 0; then
+AS_IF([test "x$with_gnutls" != "xno"],[
+ PKG_CHECK_MODULES([GNUTLS],[gnutls],,[
if test "x$with_gnutls" = "xyes"; then
AC_MSG_ERROR("Is gnutls installed? -- could not get libs for gnutls")
else
with_gnutls=no
fi
- fi
-fi
+ ])
+])
if test "x$with_gnutls" != "xno"; then
AC_PATH_PROG([GNUTLS_CERTTOOL], certtool)
@@ -309,30 +260,22 @@
with_gnutls=no
fi
fi
- dnl certtool changed how it takes private key passwords
- dnl 3.3.29 is too old (RHEL 7); we need at least gnutls 3.4.0
- AC_MSG_CHECKING([for gnutls 3.4.0 or later])
- $(pkg-config gnutls --atleast-version=3.4.0)
- if test $? -ne 0; then
- AC_MSG_ERROR([gnutls 3.4.0 is required])
- fi
- AC_MSG_RESULT([yes])
fi
-if test "x$with_gnutls" != "xno"; then
+AS_IF([test "x$with_gnutls" != "xno"],[
+ dnl certtool changed how it takes private key passwords
+ dnl 3.3.29 is too old (RHEL 7); we need at least gnutls 3.4.0
+ PKG_CHECK_MODULES([GNUTLS],[gnutls >= 3.4.0])
ORIG_CFLAGS="$CFLAGS"
- GNUTLS_CFLAGS=$(pkg-config gnutls --cflags)
- CFLAGS="$CFLAGS $GNUTLS_CFLAGS $GNUTLS_LDFLAGS"
- AC_CHECK_LIB([gnutls], [gnutls_load_file], [
- GNUTLS_LIBS=$(pkg-config gnutls --libs)
- ],
+ CFLAGS="$CFLAGS $GNUTLS_CFLAGS $GNUTLS_LIBS"
+ AC_CHECK_LIB([gnutls], [gnutls_load_file],,
[if test "x$with_gnutls" = "xyes"; then
AC_MSG_ERROR([GNUTLS >= 3.1.0 library not found: libgnutls.so])
else
with_gnutls="no"
fi])
CFLAGS="$ORIG_CFLAGS"
-fi
+])
if test "x$with_gnutls" != "xno"; then
ORIG_CFLAGS="$CFLAGS"
@@ -551,7 +494,6 @@
dnl Simulate the following for systems with pkg-config < 0.28:
dnl PKG_CHECK_VAR([libtpms_cryptolib], [libtpms], [cryptolib],
dnl [], AC_MSG_ERROR([Could not determine libtpms crypto library.]))
-PKG_PROG_PKG_CONFIG
AC_MSG_CHECKING([Checking the crypto library libtpms is linked to])
libtpms_cryptolib=`$PKG_CONFIG --variable cryptolib libtpms`
@@ -596,19 +538,12 @@
AC_MSG_RESULT([$with_seccomp])
)
-if test "$with_seccomp" != "no"; then
- LIBSECCOMP_CFLAGS=$(pkg-config libseccomp --cflags 2>/dev/null)
- if test $? -ne 0; then
- AC_MSG_ERROR("Is libseccomp-devel installed? -- could not get cflags for libseccomp")
- else
- with_libseccomp=yes
- fi
- LIBSECCOMP_LIBS=$(pkg-config --libs libseccomp)
- AC_SUBST([LIBSECCOMP_LIBS])
- AC_SUBST([LIBSECCOMP_CFLAGS])
+AS_IF([test "$with_seccomp" != "no"],[
+ PKG_CHECK_MODULES([LIBSECCOMP],[libseccomp])
+ with_libseccomp=yes
AC_DEFINE_UNQUOTED([WITH_SECCOMP], 1,
[whether to build in seccomp profile (Linux only)])
-fi
+])
MY_CFLAGS="$CFLAGS"
MY_LDFLAGS="$LDFLAGS"