Reputation: 2735
I have this file:
main.c
A.h
A.c
B.h
B.c
X.h
and in main.c I include A and in A.h I include B and in B.h I include X.h How could I write makefile for this? please tell me about dependency diagram of this example
Upvotes: 0
Views: 275
Reputation: 1116
Try this:
main: main.o A.o B.o
gcc -o main main.o A.o B.o
%.o: %.c
gcc -c $<
While compiling the .c files you don't have to worry about dependencies yet, only when linking the executable.
Upvotes: 1