Cpp makedepend
From wikinotes
Makedepend is a more automated way of writing makefiles. Rather than modifying the sourcefile, AND the makefile when modifying dependencies, makedepend reads your sourcefiles and generates the dependencies for you.
(all lines with file.o, followed by it's dependencies, and it's compile-instructions)
makedepend is run **BY** the command make. running make runs makedepend
makefile indentation **MUST USE TABS** not spaces
Examples
g++
## make ## PROG = helloworld ## executable name OBJS = helloworld.cpp ## prog's source (.cpp), header (.h), and all required objects (.o) CC = g++ ## compiler to use DEBUG = -g ## flag to allow gdb CFLAGS = -Wall $(DEBUG) ## compilation flags LFLAGS = -Wall $(DEBUG) ## library flags ## makedepend SRCS = helloworld.cpp ## a list of srcs (.cpp/.h) to check for #includes in BINDIR = bin dummy_build_folder := $(shell mkdir -p $(BINDIR)) ## instructions to compile the program, ## and each object file. $(PROG): $(OBJS) $(CC) $(CFLAGS) -o bin/$(PROG) $(OBJS) .C.o: $(CC) $(CFLAGS) -c $*.C ## Instructions for 'make clean', building dependencies, etc. clean: rm -f *.o $(PROG) depend: makedepend -- $(CFLAGS) -c -- $(SRCS) # DO NOT DELETEclang++
## make ## PROG = helloworld ## executable name OBJS = helloworld.cpp ## prog's source (.cpp), header (.h), and all required objects (.o) CC = clang++ ## compiler to use DEBUG = -g ## flag to allow gdb CFLAGS = $(DEBUG) ## compilation flags LFLAGS = $(DEBUG) ## library flags ## makedepend SRCS = helloworld.cpp ## a list of srcs (.cpp/.h) to check for #includes in BINDIR = bin dummy_build_folder := $(shell mkdir -p $(BINDIR)) ## instructions to compile the program, ## and each object file. $(PROG): $(OBJS) $(CC) $(CFLAGS) -o bin/$(PROG) $(OBJS) .C.o: $(CC) $(CFLAGS) -c $*.C ## Instructions for 'make clean', building dependencies, etc. clean: rm -f *.o $(PROG) depend: makedepend -- $(CFLAGS) -c -- $(SRCS) # DO NOT DELETE