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?
The
configurescript has been generated fromconfigure.acon a system without thepkg.m4file installed, so thePKG_CHECK_MODULESmacro has not been expanded into shell code and the generatedconfigurescript is broken because it contains non-shell syntax.(The presence
^Mcharacters also point to some kind of Windows line ending weirdness, which might or might not become an actual problem once you fix thePKG_CHECK_MODULESerror.)The fix to properly expand the
PKG_CHECK_MODULESmacro consists of two parts:Upstream cgminer should fix the
configure.acfile to include the lineThe line before the
PKG_CHECK_MODULES([LIBUSB], ...)line would be a good place for that.This makes it impossible for
autoreconfto generate such a brokenconfigurefile again.You can install
pkg.m4and re-runautoreconfto regenerateconfigurefromconfigure.ac. Then thePKG_CHECK_MODULESwill be expanded into the proper shell code which can then work as intended.pkg.m4is probably part of a-devor-m4development subpackage for thepkgconforpkgconfigpackage.It is always a good idea to
m4_pattern_forbidany non-AC_*and non-AM_*macro used inconfigure.ac, so if thisconfigure.acdoes not do that forPKG_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 am4_pattern_forbidline to prevent the generation of brokenconfigurefiles, and then regenerateconfigurewith the appropriate*.m4files installed.