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
Once you are satisfied with your homework and ready to send it to the TA, do the following:
The TA, or I, will just have to save the message, and execute the commands:
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)
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
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] > profileswill 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.
ingargiola@cis.temple.edu