prereqs generates Make prerequisites for Go binaries. It works much like the traditional makedepend tool for C.
Given the path to a Go package, prereqs will traverse the package's dependency graph to determine what files impact its compilation. It then outputs a Makefile that expresses these dependencies. For example:
$ prereqs ./pkg/cmd/foo # Code generated by prereqs. DO NOT EDIT! bin/foo: ./pkg/cmd/foo/foo.go ./some/dep.go ./some/other_dep.go ./pkg/cmd/foo/foo.go: ./some/dep.go: ./some/other_dep.go:
The intended usage is automatic dependency generation from another Makefile:
bin/target: prereqs ./pkg/cmd/target > bin/target.d go build -o $@ ./pkg/cmd/target include bin/target.d
Notice that depended-upon files are mentioned not only in the prerequisites list but also as a rule with no prerequisite or recipe. This prevents Make from complaining if the prerequisite is deleted. See  for details on the approach.