Sun Studio 12 Update 1: C++ User's Guide

A.2.144 –xM

Runs only the C++ preprocessor on the named C++ programs, requesting that the preprocessor generate makefile dependencies and send the result to the standard output (see make(1) for details about make files and dependencies).

However, -xM only reports dependencies of the included headers and not the associated template definition files. You can use the .KEEP_STATE feature in your makefile to generate all the dependencies in the .make.state file which the make utility creates.

A.2.144.1 Examples

For example:


#include <unistd.h>
void main(void)
{}

generates this output:


e.o: e.c
e.o: /usr/include/unistd.h
e.o: /usr/include/sys/types.h
e.o: /usr/include/sys/machtypes.h
e.o: /usr/include/sys/select.h
e.o: /usr/include/sys/time.h
e.o: /usr/include/sys/types.h
e.o: /usr/include/sys/time.h
e.o: /usr/include/sys/unistd.h

Interactions

If you specify -xM and -xMF, the compiler writes all makefile dependency information to the file specified with -xMF. This file is overwritten each time the preprocessor writes to it.

See also

make(1S) (for details about makefiles and dependencies)