0

I'm trying to build cgminer on a RISC-V 64 system. I had compiled it fine on aarch64 (Raspberry pi).

After installing libusb-dev and libusb1.1-1.dev, and running ldconfig, I still get this error from the configure script:

    checking whether NULL can be used in arbitrary expressions... yes^M
    checking for egrep... (cached) /usr/bin/grep -E^M
    checking for syslog.h... yes^M
    checking for size_t... yes^M
    checking for working alloca.h... yes^M
    checking for alloca... yes^M
    checking for pthread_create in -lpthread... yes^M
    checking for library containing addstr... -lncurses^M
    ./configure: line 10668: syntax error near unexpected token `LIBUSB,'^M
    ./configure: line 10668: `                      PKG_CHECK_MODULES(LIBUSB, libusb-1.0, AC_DEFINE(HAVE_LIBUSB, 1, [Define if you have libusb-1.0]), AC_MSG_ERROR([Could not find usb library - please install libusb-1.0]))'

At various points before this, autogen.sh urged me to re-run autoupdate, which I did. The autogen.sh script in general did not want to run to completion either.

Has anyone seen a syntax error in an automatically generated configure script before?

s_question
  • 21
  • 2

1 Answers1

0

The configure script has been generated from configure.ac on a system without the pkg.m4 file installed, so the PKG_CHECK_MODULES macro has not been expanded into shell code and the generated configure script is broken because it contains non-shell syntax.

(The presence ^M characters also point to some kind of Windows line ending weirdness, which might or might not become an actual problem once you fix the PKG_CHECK_MODULES error.)

The fix to properly expand the PKG_CHECK_MODULES macro consists of two parts:

  • Upstream cgminer should fix the configure.ac file to include the line

    m4_pattern_forbid([PKG_CHECK_MODULES])dnl
    

    The line before the PKG_CHECK_MODULES([LIBUSB], ...) line would be a good place for that.

    This makes it impossible for autoreconf to generate such a broken configure file again.

  • You can install pkg.m4 and re-run autoreconf to regenerate configure from configure.ac. Then the PKG_CHECK_MODULES will be expanded into the proper shell code which can then work as intended.

    pkg.m4 is probably part of a -dev or -m4 development subpackage for the pkgconf or pkgconfig package.

It is always a good idea to m4_pattern_forbid any non-AC_* and non-AM_* macro used in configure.ac, so if this configure.ac does not do that for PKG_CHECK_MODULES, it might also fail to do that for other macros, so you might run into the same error with some other macro later. The fix is the same: Add a m4_pattern_forbid line to prevent the generation of broken configure files, and then regenerate configure with the appropriate *.m4 files installed.

ndim
  • 35,870
  • 12
  • 47
  • 57