PAC_C_DEPENDS

Determine how to use the C compiler to generate dependency information

Synopsis

PAC_C_DEPENDS

Output Effects

Sets the following shell variables and call AC_SUBST for them

C_DEPEND_OPT
Compiler options needed to create dependencies
C_DEPEND_OUT
Shell redirection for dependency file (may be empty)
C_DEPEND_PREFIX
Empty (null) or true; this is used to handle systems that do not provide dependency information
C_DEPEND_MV
Command to move created dependency file Also creates a Depends file in the top directory (!).

In addition, the variable C_DEPEND_DIR must be set to indicate the directory in which the dependency files should live.

Notes

A typical Make rule that exploits this macro is
 #
 # Dependency processing
 .SUFFIXES: .dep
 DEP_SOURCES = ${SOURCES:%.c=.dep/%.dep}
 C_DEPEND_DIR = .dep
 Depends: ${DEP_SOURCES}
         @-rm -f Depends
         cat .dep/*.dep >Depends
 .dep/%.dep:%.c
         @if [ ! -d .dep ] ; then mkdir .dep ; fi
         @@C_DEPEND_PREFIX@ ${C_COMPILE} @C_DEPEND_OPT@ $< @C_DEPEND_OUT@
         @@C_DEPEND_MV@

 depends-clean:
         @-rm -f *.dep ${srcdir}/*.dep Depends ${srcdir}/Depends
         @-touch Depends

For each file foo.c, this creates a file foo.dep and creates a file Depends that contains all of the *.dep files.

For your convenience, the autoconf variable C_DO_DEPENDS names a file that may contain this code (you must have dependsrule or dependsrule.in in the same directory as the other auxillery configure scripts (set with dnl AC_CONFIG_AUX_DIR). If you use dependsrule.in, you must have dependsrule in AC_OUTPUT before this Makefile.