Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoconf check for program and fail if not found

Tags:

linux

autoconf

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.

like image 797
Adam Magaluk Avatar asked Sep 20 '11 19:09

Adam Magaluk


2 Answers

I found this to be the shortest approach.

AC_CHECK_PROG(FFMPEG_CHECK,ffmpeg,yes)
AS_IF([test x"$FFMPEG_CHECK" != x"yes"], [AC_MSG_ERROR([Please install ffmpeg before configuring.])])
like image 169
Adam Magaluk Avatar answered Sep 29 '22 04:09

Adam Magaluk


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
like image 42
Dirk Eddelbuettel Avatar answered Sep 29 '22 06:09

Dirk Eddelbuettel