CIS4307: Mailing Homeworks

The following instructions are so that we simplify our lives when doing or grading homeworks.

For each homework you should create a separate directory with simple names such as lab1, lab2, ....
Suppose that you are doing homework 3 and you are in directory lab3. In directory lab3 you should create a README file containing documentation for your program. In directory lab3 you should also create a Makefile so that you can do a recompile by just saying

make
Inside of the Makefile you should have support for a clean command so that you can say:
make clean
to remove the images, all object files, all *~ files, and possibly the "core" file.

Once you are satisfied with your homework and ready to send it to the TA, do the following:

  1. Use the "make clean" command to remove all object, core, and image files.

  2. Change to the parent directory with "cd .."

  3. Tar the homework directory with the command
    tar -cvf yourLoginName-lab3.tar lab3

  4. Get into pine and send to the TA your tar file as an attachment. [I have done this between roma and snowhite and between snowhite and thunder without any problem. The attachment will be in binary and not visible, but it will transfer as an attachment without any problem.]

The TA, or I, will just have to save the message, and execute the commands:

tar -xvf yourLoginName-lab3.tar
cd lab3
make
to see what you have done.

Here is an example of a Makefile I have used:



.SUFFIXES: .o .c .h
PROFILE = -g -Wall
CFLAGS = -D_REENTRANT -DDEBUG $(PROFILE)
CC = gcc
THREADS = -lpthread
LIB = 

TGTS = pqueuepmain
SOURCES = pqueuepmain.c pqueuep.c queuep.c
HEADERS = pqueuep.h queuep.h

OBJS = $(SRCS:.c=.o)

default: all

all: $(TGTS)

${TGTS} : ${OBJS} ${HEADERS} ${LIB} 
	${CC} ${CFLAGS} -o $@ ${OBJS} ${LIB} ${THREADS}

.c.o :
	${CC} ${CFLAGS} -c $< 
clean :
	/bin/rm -f core *.o *~ $(TGTS)


Note that the indented lines must start with a tab. Beware that since HTML gets confused with "<" I had to represent it here as "& lt ;".

To use this Makefile in your homeworks you just need to change appropriately SOURCES HEADERS and TGTS to the values right in your case [respectively, the sources, headers, and image files]. Also, if you are not using threads, you can define THREADS as follows

THREADS =

Often in our c source programs we include .h files. A useful feature of the gcc compiler is that it can help us track such dependencies so that if some .h files are modified the .c files that include them are re-compiled. The Unix shell command

        % gcc -MM *.[ch] > profiles
will write to the file profiles all the dependencies. You can then use that information in building the Makefile.

If you are using the emacs editor instead of pico, with the added complexity you will get many advantages. For example, you will be able to use the TAGS facility to find easily the definition of symbols. In my Makefiles I add the lines

TAGS:
        etags -t *.[ch]
and modify the all: and clean: lines to be:
all: TAGS $(TGTS)
clean :
	/bin/rm -f core TAGS *.o *~ $(TGTS)

I am not an expert on "make" so you may come up with better Makefiles.


As you develop your program it is prudent, before making modifications or extensions to a partially working version, to save that working version. Thus, if lab3 is the directory that contains the partially working version, before modifying it, copy it to a parallel directory, say, old. Then if your modifications don't work, and you are all confused, you can go back to something you were confortable with.

ingargiola@cis.temple.edu