Next: Adding a configure flag, Previous: Adding a check for a library, Up: Tutorial [Contents][Index]
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
‘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
script creates
the output file. Here Makefile.in 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 ‘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
hello_SOURCES
).
AC_CHECK_LIB
, used to check for a library, sets the following
output variables:
LIBS
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’.
DEFS
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 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
Next: Adding a configure flag, Previous: Adding a check for a library, Up: Tutorial [Contents][Index]