# A Makefile to build sbs

# The CFLAGS variable contains a set of compiler flags 
# -g means include information for a debugger
# -Wall means print out all warnings
# Your submitted progam should compile cleanly with no warning messages.
# -ansi -pedantic are not required for this programs submitted for 209

CFLAGS = -g -Wall

# The standard set of variables found in most Makefiles
# LIBS and INCLUDES are empty because we do not need any special libraries 
# or include paths.
CC = gcc
LIBS = 
INCLUDES =
OBJS = sbs.o db.o init.o add.o helpers.o commit.o list.o update.o
SRCS = sbs.c db.c init.c add.c helpers.c commit.c list.c update.c

HDRS =  db.h sbs.h

# The first target is the default target.  If you type "make" this is the
# rule that will be evaluated.  This target depends on sbs which is the
# next target.  (Note that if you want to compile more than one program
# using the same Makefile, list all targets as dependencies in the default
# target.)

all: sbs dbfind

# The variable $@ has the value of the target. In this case $@ = pusage
sbs: ${OBJS}
	${CC} ${CFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS}

dbfind: db.h db.o dbfind.o
	${CC} ${CFLAGS} -o $@ db.o dbfind.o

# This rule tells make how to create .o files (which are dependencies in
# the previous rule).  Since sbs depends on "sbs.o", make looks
# for a file called "sbs.c" in the current directory and uses this
# rule to compile the file.  The variable $< has the value of the .c
# file that it found.  

.c.o:
	${CC} ${CFLAGS} ${INCLUDES} -c $<

# To ensure that when you change a header file the dependencies are properly
# accounted for, run make depend when ever you add a new source file or some 
# #include statements in a file.
depend: 
	makedepend ${SRCS}

# An easy way to keep your directory clean
clean:
	rm ${OBJS} dbfind.o core *~

# A handy rule to package up your code.
tar:
	tar cf sbs.tar ${SRCS} ${HDRS} dbfind.c Makefile

# A favourite rule of mine.  It creates a postscript file and simplifies 
# printing your code.  It saves on paper by combining all the files into one 
# before printing.
print:
	more Makefile $(HDRS) $(SRCS) | enscript -2r -p listing.ps

# DO NOT DELETE

