tpm2-software / tpm2-tss-engine

OpenSSL Engine for TPM2 devices
https://tpm2-software.github.io
BSD 3-Clause "New" or "Revised" License
148 stars 97 forks source link

Compiling issue while adding tpm2-tss-engine as Buildroot package #272

Closed Sourabh-ALTEN closed 1 year ago

Sourabh-ALTEN commented 1 year ago

Hello,

I am trying to add tpm2-tss-engine as a Buildroot package and below is the tpm2-tss-engine.mk file

################################################################################
#
# tpm2-tss-engine
#
################################################################################

TPM2_TSS_ENGINE_VERSION = 1.2.0
TPM2_TSS_ENGINE_SITE = https://github.com/tpm2-software/tpm2-tss-engine/releases/download/$(TPM2_TSS_ENGINE_VERSION)
TPM2_TSS_ENGINE_LICENSE = BSD-3-Clause
TPM2_TSS_ENGINE_LICENSE_FILES = LICENSE
TPM2_TSS_ENGINE_DEPENDENCIES = libqrencode tpm2-tss host-pkgconf host-autoconf-archive
TPM2_TSS_ENGINE_AUTORECONF = YES
TPM2_TSS_ENGINE_AUTORECONF_OPTS = -I $(HOST_DIR)/share/autoconf-archive
TPM2_TSS_ENGINE_CONF_OPTS = \
        --disable-defaultflags \
        --disable-doxygen-doc \
        --disable-plymouth \
        --without-initramfstoolsdir \
        --without-mkinitcpiodir

# uses C99 code but forgets to pass -std=c99 when --disable-defaultflags is used
TPM2_TSS_ENGINE_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -std=c99"

# do not build man pages
TPM2_TSS_ENGINE_CONF_ENV += ac_cv_path_PANDOC=''

$(eval $(autotools-package))

Source code is being downloaded from Git and building. But in the next step I am getting below error:

>>> tpm2-tss-engine 1.2.0 Building
PATH="/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin:/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"  /usr/bin/make -j17  -C /home/[...]/tmp/br.test.standard/build/tpm2-tss-engine-1.2.0/
make[2]: Nothing to be done for 'all'.
>>> tpm2-tss-engine 1.2.0 Installing to target
PATH="/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin:/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"  /usr/bin/make -j17 DESTDIR=/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target install -C /home/[...]/tmp/br.test.standard/build/tpm2-tss-engine-1.2.0/
([ -e /home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin/../aarch64-buildroot-linux-gnu/sysroot/usr/lib/engines-1.1 ] || \
         /usr/bin/mkdir -p /home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin/../aarch64-buildroot-linux-gnu/sysroot/usr/lib/engines-1.1)
 /usr/bin/mkdir -p '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/bin'
 /usr/bin/mkdir -p '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/share/bash-completion/completions'
 /usr/bin/mkdir -p '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/include'
 /usr/bin/mkdir -p '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin/../aarch64-buildroot-linux-gnu/sysroot/usr/lib/engines-1.1'
 /usr/bin/mkdir -p '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/share/man/man1'
 /usr/bin/mkdir -p '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/share/man/man3'
 /bin/bash ./libtool   --mode=install /usr/bin/install -c   libtpm2tss.la '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin/../aarch64-buildroot-linux-gnu/sysroot/usr/lib/engines-1.1'
  /bin/bash ./libtool   --mode=install /usr/bin/install -c tpm2tss-genkey '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/bin'
 /usr/bin/install -c -m 644 bash-completion/tpm2tss-genkey '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/share/bash-completion/completions'
 /usr/bin/install -c -m 644 include/tpm2-tss-engine.h '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/include'
 /usr/bin/install -c -m 644 man/man1/tpm2tss-genkey.1 '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/share/man/man1'
 /usr/bin/install -c -m 644 man/man3/tpm2tss_tpm2data_write.3 man/man3/tpm2tss_rsa_makekey.3 man/man3/tpm2tss_rsa_genkey.3 man/man3/tpm2tss_ecc_makekey.3 man/man3/tpm2tss_ecc_genkey.3 man/man3/tpm2tss_ecc_getappdata.3 man/man3/tpm2tss_tpm2data_read.3 man/man3/tpm2tss_ecc_setappdata.3 '/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/share/man/man3'
libtool: install: /usr/bin/install -c .libs/libtpm2tss.so /home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin/../aarch64-buildroot-linux-gnu/sysroot/usr/lib/engines-1.1/libtpm2tss.so
libtool: install: /usr/bin/install -c tpm2tss-genkey /home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/usr/bin/tpm2tss-genkey
libtool: install: /usr/bin/install -c .libs/libtpm2tss.lai /home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin/../aarch64-buildroot-linux-gnu/sysroot/usr/lib/engines-1.1/libtpm2tss.la
/usr/bin/make  install-exec-hook
(cd /home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target/home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin/../aarch64-buildroot-linux-gnu/sysroot/usr/lib/engines-1.1 && \
         ln -s -f libtpm2tss.so tpm2tss.so)
libtool: warning: remember to run 'libtool --finish /home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/host/bin/../aarch64-buildroot-linux-gnu/sysroot/usr/lib/engines-1.1'
tpm2-tss-engine: installs files in /home/[...]/tmp/br.test.standard/per-package/tpm2-tss-engine/target//home/[...]/tmp/br.test.standard
make[1]: *** [package/pkg-generic.mk:390: /home/[...]/tmp/br.test.standard/build/tpm2-tss-engine-1.2.0/.stamp_target_installed] Error 1
make: *** [Makefile:23: _all] Error 2

I have also added libtool (BR2_PACKAGE_LIBTOOL) in the make menuconfig. I am not sure what the actual error is.

Can anyone please let me know how to resolve the above issue?

Thank you, Sourabh

Sourabh-ALTEN commented 1 year ago

Update:

The above issue is fixed by adding --with-enginesdir=/usr/lib/engines-1.1 to TPM2_TSS_ENGINE_CONF_OPTS options.