Skip to content

Instantly share code, notes, and snippets.

@wulfgarpro
Last active January 23, 2017 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wulfgarpro/218b12c88af975067078348dfaf2775a to your computer and use it in GitHub Desktop.
Save wulfgarpro/218b12c88af975067078348dfaf2775a to your computer and use it in GitHub Desktop.
makefile header dependency target
SRCS = a.c
depend: .depend
.depend: $(SRCS)
rm -f ./.depend
$(CC) $(CFLAGS) -MM $^ -MF ./.depend;
include .depend
# -MM outputs source file header dependecies, excluding system headers;
# the output syntax is the preprocessor syntax that make can use to define
# all source file dependencies, and that is why it's included at the end
# -MF specifies the file to output to when used with -MM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment