Makefile not working

Could anyone point out why this makefile only executes the first entry, compiling only the first program listed? Thank you!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
###########################################################
#
# Simple Makefile for Operating Systems Project 2
#
###########################################################
vowcon:
	 g++ -o vowcon vowcon.cpp -pthread
osproj2c:
	 g++ -o osproj2c osproj2c.cpp -pthread
osproj2b:
	 g++ -o osproj2b osproj2b.cpp -pthread
osproj2a:
	gcc -o osproj2a osproj2a.c -pthread
clean:
	rm osproj2a osproj2b osproj2c osproj2d vowcon
afaik, make will use the first target specified as the default. Since vowcon doesn't specify any other target, all it will execute is vowcon.
What you can do is specify the other projects as dependencies of vowcon.

1
2
3
4
5
6
7
8
9
10
vowcon: osproj2c
	 g++ -o vowcon vowcon.cpp -pthread
osproj2c: osproj2b
	 g++ -o osproj2c osproj2c.cpp -pthread
osproj2b: osproj21
	 g++ -o osproj2b osproj2b.cpp -pthread
osproj2a:
	gcc -o osproj2a osproj2a.c -pthread
clean:
	rm osproj2a osproj2b osproj2c osproj2d vowcon


That way, vowcon requires osproj2c to be built which requires osproj2b to be built which requires osproj2a to be built.
@farmergeoff2003
If you really want to do makefiles - you could start here.
http://www.gnu.org/software/make/manual/make.html
Thanks, I don't want to do it but its a requirement.
@Thumper: don't use artificial dependencies.
You'll recompile `vowcon' for changes in `osproj2c', which makes no sense

Instead, you could use a phony `all' target.
Ah, that makes sense ne555.
Just now read about phony targets. Thanks.
So @ne555, how do you do what you suggest?
Topic archived. No new replies allowed.