In the previous sections we saw that checks were done in
we’ll explain how information from these checks can be passed on for
make to use in its rules.
AC_PROG_CC macro finds a C compiler to use, it will set the
‘CC’ output 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
the output file. Here Makefile.in is the input file, and
Makefile is the output file.
When you run
will see that
CC is an output
add the line
‘CC=@CC@’ to the ‘Makefile.in’ 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 configure.ac, because
C source files were used in Makefile.am (in
AC_CHECK_LIB, used to check for a library, sets the following
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
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 gcc -DPACKAGE_NAME=\"hello\" -DPACKAGE_TARNAME=\"hello\" -DPACK AGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"hello\ 1.0\" -DPACKAGE_B UGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"hello\" -DVERSION= \"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