Razican
Razican

Reputation: 727

How can I set a constant in autoconf checking for a program?

I am using autotools and I have a configure.ac script that says this:

AC_CHECK_PROG(RASPIVID, raspivid, yes)

However, the generated config.h file does not show a RASPIVID constant. Am I doing something wrong?

Upvotes: 2

Views: 566

Answers (1)

user539810
user539810

Reputation:

The AC_CHECK_PROG macro does not do anything with config.h by itself. From the manual:

AC_CHECK_PROG (variable, prog-to-check-for, value-if-found, [value-if-not-found], [path = '$PATH'], [reject])

Check whether program prog-to-check-for exists in path. If it is found, set variable to value-if-found, otherwise to value-if-not-found, if given. Always pass over reject (an absolute file name) even if it is the first found in the search path; in that case, set variable using the absolute file name of the prog-to-check-for found that is not reject. If variable was already set, do nothing. Calls AC_SUBST for variable. The result of this test can be overridden by setting the variable variable or the cache variable ac_cv_prog_variable.

So AC_CHECK_PROG(RASPIVID, raspivid, yes) will check whether raspivid exists. If it does, it will set the shell variable RASPIVID to the value yes, so you could perform a test after the AC_CHECK_PROG invocation such as:

AC_CHECK_PROG([RASPIVID], [raspivid], [yes])
AS_IF([test "x$RASPIVID" = xyes],
    [AC_DEFINE([HAVE_RASPIVID], [1], [raspivid is available.])])

AC_SUBST will be called already as mentioned in the documentation, so you can use $(RASPIVID) in a makefile or whatever the output file(s) may be.

Upvotes: 3

Related Questions