Makefile not working

Mar 15, 2013 at 4:04pm
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
Mar 15, 2013 at 4:22pm
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.
Mar 15, 2013 at 4:30pm
@farmergeoff2003
If you really want to do makefiles - you could start here.
http://www.gnu.org/software/make/manual/make.html
Mar 15, 2013 at 4:56pm
Thanks, I don't want to do it but its a requirement.
Mar 15, 2013 at 5:30pm
@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.
Mar 15, 2013 at 5:42pm
Ah, that makes sense ne555.
Just now read about phony targets. Thanks.
Mar 15, 2013 at 6:27pm
So @ne555, how do you do what you suggest?
Mar 16, 2013 at 1:29am
Topic archived. No new replies allowed.