Reputation: 151
I am trying to convert a hello.c to hello stepwise by first preprocessing then compiling, then assembling then linking. However only the first command of my makefile is being executed:
Osheens-MacBook-Air-1115:Assignment0.1 osheensachdev$ ls
hello.c makefile
Osheens-MacBook-Air-1115:Assignment0.1 osheensachdev$ cat makefile
hello.i : hello.c
gcc -E hello.c -o hello.i
hello.s : hello.i
gcc -S hello.i -o hello.s
hello.o : hello.s
gcc -c hello.s -o hello.o
hello : hello.o
$ld hello.o -e main hello
clean:
rm hello.i hello.s hello.o hello
Osheens-MacBook-Air-1115:Assignment0.1 osheensachdev$ make
gcc -E hello.c -o hello.i
Osheens-MacBook-Air-1115:Assignment0.1 osheensachdev$ make
make: `hello.i' is up to date.
I've searched online about chained files and didn't find anything specific about why this shouldn't work.
I've also specified the target: [dependancies]
so I don't see why this shouldn't work.
Upvotes: 1
Views: 1018
Reputation: 18901
The first target of a Makefile is the default target.
This is why you see in many Makefiles a all
target at the top which is intended to "make everything":
all: build test
build: <prerequisites>
test: <prerequisites>
Since you didn't specify one, Make builds hello.i
only (plus everything needed to build this target):
hello.i
doesn't exist yet.hello.i
needs hello.c
. Make hello.c
first.hello.c
is "made" already. Nothing to do.hello.i
i.e., run gcc -E hello.c -o hello.i
.Then you ran Make again (without any specific target)
hello.i
exists already. Nothing to do.I suspect that you wanted to make "hello", i.e., your program.
Either:
make hello
Upvotes: 2