MKDEP(1)

NAME
mkdep - print dependencies in the Right Way for make(1)

SYNOPSIS
mkdep path
mkdep pp_command sourcefile ...

DESCRIPTION
Mkdep does what cpp -M should do, but no compiler gets it right, they all strip the leading path of the *.o files.

The first synopsis form just creates the needed .depend files in all the subdirectories of path.

The second synopsis form does the hard work of emitting the dependencies instructions for sourcefile in the right format expected by make(1), including the path information.

Mkdep expects pp_command to be the correct invocation for the preprocessor command adequate for sourcefile, and also expects this command to emit lines of the form
	# lineno "filename"
for each files which is included by the named sourcefile.

For C, the typical idiom is to add in all your Makefiles:

	depend:
		cd sub1 && $(MAKE) -$(MAKEFLAGS) $@
		cd sub2 && $(MAKE) -$(MAKEFLAGS) $@
		# repeat for each subdirectory
		mkdep "$(CC) -E $(CPPFLAGS)" *.c > .depend

SEE ALSO
cc(1), make(1).

BUGS
Since Makefile is read in full before any command is executed, there is no way to prevent make(1) to report an error if the .depend file was not created beforehand; hence the first form of mkdep should be used before any attempt is done to use this feature in any Makefile.

The current version hardcodes the .o suffix, so it cannot be used for e.g. flex(1) or yacc(1) source files.

AUTHOR
Mkdep.c was written by Kees J. Bot and Jorrit N. Herder.