Exam Study - 2007.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:

Im unsure how the MakeFile works any help would be great. This is a past exam that was held at the uni 2007. So its is not an assignment just a guide to what i need to learn any help would be great.

Thanks

  1. Relevant commands, code, scripts, algorithms:

QUESTION 4 (20 marks)
Consider the following Makefile:

1        # Makefile for my application
2
3        CC=gcc
4
5        source= main.c getSales.c processSales.c
6
7        objects=$(source:.c=.o)
8
9        myapp: $(objects)
10             $(CC) -o myapp $(objects)
11
12       clean:
13       /bin/rm *.o *  myapp
14
15       PHONY: clean
16
17       main.o: defs.h processSales.h
18       getSales.o: defs.h processSales.h
19       processSales.o: processSales.h

(a) Assuming initially that only the *.c and *.h files exist, what command(s) will be executed when
the command make myapp is run?
(4 marks)
(b) What is the effect of the following command?
make -n
(2 marks)
(c) What is the effect of the following command?
make clean
(2 marks)
(d) Explain line 15 below:
PHONY: clean
(2 marks)
(e) The make program has implicit rules that allow it to recognise and use RCS tools. Assume
that you have moved all the source files into an RCS repository so that only the makefile and
the RCS repository exist in the directory. What commands will be executed now if make is
run?
(4 marks)
(f) What extra commands need to be added to the clean target so that source files will be
(possibly) saved in the RCS repository when the command make clean is run?
(2 marks)
Page 6 of 7

PAGE 7
(g) Now, assume that the functionality of myapp has been expanded with a new function
sort.c which has a header file sort.h needed by main.c and sort.c. Rewrite the
makefile to reflect these changes.

  1. The attempts at a solution (include all code and scripts):

I have no attempts as i missed the lecture that was on and i have googled it but cant find enough to get the hang of it.

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

USQ - Australia - CSC2408 - Zhongwei Zhang

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).