

4.4 Output variables explained

In the previous sections we saw that checks were done in configure. Now we’ll explain how information from these checks can be passed on for make to use in its rules.

If AC_PROG_CC macro finds a C compiler to use, it will set the ‘CCoutput variable. This means that wherever the the string ‘@CC@’ occurs in an input file, it will be replaced with the name of a C compiler when the configure script creates the output file. Here is the input file, and Makefile is the output file.

When you run autoreconf, the automake command will see that CC is an output variable, and add the line ‘CC=@CC@’ to the ‘’ it creates. This is how the generated Makefile is able to use the compiler that the configure script found. automake will also give an error if AC_PROG_CC is not used in, because C source files were used in (in hello_SOURCES).

AC_CHECK_LIB, used to check for a library, sets the following output variables:


make passes this value as an argument to the linker or compiler when building the program. In our example, AC_CHECK_LIB sets this to ‘-lgmp’.


This contains command-line flags to be passed to the compiler which set preprocessor symbols. AC_CHECK_LIB adds ‘-DHAVE_LIBGMP=1’ to this variable.

You can see the values of these variables being used by the Makefile in the following output:

$ make hello
\"1.0\" -DHAVE_LIBGMP=1 -I.     -g -O2 -MT hello.o -MD -MP -MF 
.deps/hello.Tpo -c -o hello.o hello.c
mv -f .deps/hello.Tpo .deps/hello.Po
gcc  -g -O2   -o hello hello.o  -lgmp
