Aryan
Aryan

Reputation: 2735

Makefile dependency chart

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

Answers (1)

Ulrich Schmidt-Goertz
Ulrich Schmidt-Goertz

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

Related Questions