Search code examples
linuxautoconf

Autoconf check for program and fail if not found


I'm creating a project and using GNU Autoconf tools to do the configuring and making. I've set up all my library checking and header file checking but can't seem to figure out how to check if an executable exists on the system and fail if it doesn't exist.

I've tried:

AC_CHECK_PROG(TEST,testprogram,testprogram,AC_MSG_ERROR(Cannot find testprogram.))

When I configure it runs and outputs:

Checking for testprogram... find: `testprogram. 15426 5 ': No such file or directory

but does not fail.


Solution

  • Try this which is what I just lifted from a project of mine, it looks for something called quantlib-config in the path:

    # borrowed from a check for gnome in GNU gretl: def. a check for quantlib-config
    AC_DEFUN(AC_PROG_QUANTLIB, [AC_CHECK_PROG(QUANTLIB,quantlib-config,yes)])
    AC_PROG_QUANTLIB
    if test x"${QUANTLIB}" == x"yes" ; then
        # use quantlib-config for QL settings
        [.... more stuff omitted here ...]
    else
        AC_MSG_ERROR([Please install QuantLib before trying to build RQuantLib.])
    fi