# Makefile for Word Frequency program.
#
# Written by J. Senning - 1/24/98

# Set up for the C compiler.  Note that the default value of $(CC) is
# `cc' so this is not strictly necessary.  However, it never hurts to
# explicitly state it.  Also, the values for CFLAGS and LDFLAGS default
# to empty strings so we do need to set them.  The "-O" in CFLAGS tells
# to C compiler to perform some optimizations.  The "-s" in LDFLAGS tells
# the linking loader to strip all unnecessary information from the
# executable, making it as small as possible.

CC	= cc
CFLAGS	= -O
LDFLAGS	= -s

# Here is a pretty standard way to declare the names of the files that
# are part of this program.  In this case the file "wordtable.h" is
# included by both "wordtable.c" and "wordfreq.c".  Also notice how the
# list of object files can be automatically generated from the list of
# source files by replacing the ".c" with a ".o".  The LIBS symbol is
# given here, but since no special libraries are required it is left
# blank.  The symbol OUT is used to hold the name of the executable.

HDRS	= wordtable.h
SRCS	= wordfreq.c wordtable.c
OBJS	= $(SRCS:.c=.o)
LIBS	=
OUT	= wordfreq

# Make knows how to automatically build the object files from the source
# files.  In addition, due to the line below that starts with "$(OBJS)",
# make also knows that the object files depend not only on the source files
# (this is implicit) but also on the files listed in HDRS.
#
# VERY IMPORTANT NOTE:  the command to link the program (starts with "$(CC)")
# __MUST__ begin with a tab character (ctrl-I): spaces will not work.

$(OUT):	$(OBJS)
	$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

$(OBJS):	$(HDRS)

# The following targets are used to clean up after the program is built.
# The first, "clean", will remove all the object files.  The second,
# "clobber", will not only remove the object files but also the executable.
# Note that these use the full path for the "rm" command to make sure that
# the system version gets run.  Also, as noted above, the commands (here
# they are the rm commands) must begin with a tab character (ctrl-I).

clean:
	/bin/rm -f $(OBJS)

clobber:
	/bin/rm -f $(OBJS) $(OUT)

# End of Makefile
