CSCI 3294 (Unix Power Tools), Fall 2009:
Homework 6
- Credit:
- 20 points.
Read about the following topics
in the list of suggested readings,
either in one of the suggested readings or
in another book or reference.
(This is the topic for October 12.)
Do the following (sort-of-)programming problem.
Turn in your finished makefile by sending mail
to bmassing@cs.trinity.edu, with the file as an attachment.
Please use a subject line that mentions the course number and
the assignment (e.g., ``csci 3294 homework 6'').
You can do this assignment on any system that provides the
needed functionality, but I will check it on one of the department's
Fedora 11 Linux machines, so you should probably make sure it works
in that environment before turning it in.
- (20 points)
Suppose you have a C program consisting of the following
files:
- some-defs.h
containing macro and constant definitions.
- foo.h
containing constants and
prototype definitions for function foo.
- foo.c
containing code for function foo.
This file contains #include directives to
include some-defs.h and foo.h.
- bar.h
containing constants and
prototype definitions for function bar.
- bar.c
containing code for function bar.
This file contains #include directives to
include some-defs.h and bar.h.
- main.c
containing code for the main program,
which calls functions foo and bar.
This file also contains #include directives to
include some-defs.h,
foo.h, and bar.h.
Write a makefile that:
- When you type make main, creates executable
main from the source files,
compiling just the parts of this program that
need to be recompiled (because either source code has
changed or an #include'd file has changed).
Compile using any C compiler (cc or gcc)
but using the flags -Wall, -pedantic,
and -O.
- When you type make clean, deletes all
the object files for the program.
- When you type make xclean, deletes all
the object files for the program and the executable.
You can make use of the implicit rules defined by
make if they will help. (They probably will.)
Here are some test files you can use to test your
makefile:
Be advised that the command touch
can be used to change a file's timestamp without opening
it in an editor, etc. (This may be helpful in testing.)
Berna Massingill
2009-10-14