|
|
You are suppose to know how to write a Makefile
already. If you don't, you should learn it as soon as
possible because your Makefile must work in all
your project submissions. There are a few tutorials on
make on the web. Here are links to some of them.
I have not really read through these pages so I cannot
guarantee their correctness.
|
|
Windows Makefiles
|
Please be aware that if you transfer a Makefile from a Windows
environment to a UNIX environment, chances are, it will not work.
The reason is that a line in a text file in Windows ends with "\r\n"
while a line in a text file in UNIX ends with just "\n". The extra
"\r" can confuse make on UNIX machines. But I'm sure you can
write a small program to fix that.
|
|
Compiling Your Code
|
If you are writing your program in C, you should use gcc
as your compiler, rather than cc. Gcc supports
function prototypes and other ANSI extensions, which you should
use in your programs.
The option -Wall turns on most of the useful
gcc/g++ warnings.
Compiling with this option will find many simple mistakes in your programs.
On many platforms you also need to link the network and socket
libraries to your program.
|
|
Compilation Requirements
|
We will evaluate your submission by copying all the files you have
submitted into an empty directory and then enter the make
command specified in each homework specification.
This will the be only method we will use to compile your code.
So, please do not use a visual tool to compile your code.
You may lose quite a few points if we have to debug your
Makefile in order to get your code to compile. You may
receive a score of zero if we cannot get your Makefile
to work.
Here are some additional requirements:
- You are required to use
separate compilation
to compile your source code. You must divide your source code into
separate source files in a logical way.
Even if everything can fit in a single source file, you must
force yourself to cut it up or you will lose a lot of points!
- You must not put the bulk of your code in header files!
Header files are not where you are suppose to put your source code
because you will lose the ability to debug your code.
- When the following command is invoked at the UNIX prompt:
make clean
all binary files created during compilation
(.o files and executable files) must be removed.
|
|
Additional Hints
|
How do you make sure that make would work? It's actually
very simple.
- Don't create a Makefile until the last minute! Create
one first time you need to compile your code.
- If you do your development on Windows and expect your code to
just compile and run on
nunki.usc.edu,
you will soon find out
how unrealistic your assumption is. I would leave at least
2 days for porting for small projects and 5 days for porting
large projects.
- Write a rule in your Makefile to generate a submittable
file in the right format. Do this early! You can also think of
this as generating a backup copy of what you have done so far.
Copy the backup copy to another place in case you accidentically
erase all your files.
- Testing! Verify your submissions.
Create an empty directory on nunki.usc.edu,
unpack your test submission, and type make in it!
If it doesn't work, fix it right away.
- Have a working copy ready for submission. When it's 2 hours away
from the deadline and your code is not completing working, you
should probably consider doing the following.
- Fix your code so that it compiles and runs.
- Create a submission from your working code and keep it as
a backup in case you can't fix your bugs when deadline comes.
- Repeat this as you fix more bugs.
|
|