Search code examples
linuxautoconf

error: possibly undefined macro: AS_IF


I'm trying to compile the TPM2.0-TSS project but get errors while creating the configure script:

$ git clone https://github.com/01org/TPM2.0-TSS.git
Cloning into 'TPM2.0-TSS'...
remote: Counting objects: 6522, done.
remote: Total 6522 (delta 0), reused 0 (delta 0), pack-reused 6522
Receiving objects: 100% (6522/6522), 13.99 MiB | 4.44 MiB/s, done.
Resolving deltas: 100% (5081/5081), done.
$
$
$ cd TPM2.0-TSS/
$ ./bootstrap 
Generating file lists: src_vars.mk
libtoolize: putting auxiliary files in '.'.
libtoolize: linking file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: linking file 'm4/libtool.m4'
libtoolize: linking file 'm4/ltoptions.m4'
libtoolize: linking file 'm4/ltsugar.m4'
libtoolize: linking file 'm4/ltversion.m4'
libtoolize: linking file 'm4/lt~obsolete.m4'
configure.ac:14: error: possibly undefined macro: AS_IF
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:28: error: possibly undefined macro: AC_SUBST
configure.ac:31: error: possibly undefined macro: AC_MSG_ERROR
configure:12158: error: possibly undefined macro: AC_MSG_WARN
autoreconf: /usr/bin/autoconf failed with exit status: 1
$

A strange thing is, that when I call bootstap a second time, it succeeds.

$ ./bootstrap 
Generating file lists: src_vars.mk
configure.ac:4: installing './compile'
configure.ac:5: installing './config.guess'
configure.ac:5: installing './config.sub'
configure.ac:6: installing './install-sh'
configure.ac:6: installing './missing'
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
$

There are a couple of other posts with similar errors, and they were solved by installing pkg-config - but pkg-config is already installed in my system.


Solution

  • Finally following the hint of INSTALL.md and installing autoconf-archive (info) solved the problem:

    $ sudo apt -y update
    $ sudo apt -y install \
      autoconf-archive \
      libcmocka0 \
      libcmocka-dev \
      build-essential \
      git \
      pkg-config \
      gcc \
      g++ \
      m4 \
      libtool \
      automake \
      autoconf
    

    Further more, check whether the PKG_CONFIG variable is set:

    $ env | grep PKG_CONFIG 
    PKG_CONFIG=[...]/system/buildroot-x86/output/host/usr/bin/pkg-config
    PKG_CONFIG_PATH=[...]/TPM2.0-TSS-INSTALL/lib/pkgconfig/
    $
    $ unset PKG_CONFIG
    $ unset PKG_CONFIG_PATH
    $
    $ env | grep PKG_CONFIG 
    $