# Lets specify compiler
CC = g++
CFLAGS = -c
AR = ar
ARFLAGS = -rvs

# Source files.  We keep header files separate from the cpp files.
# Recall that we will compile cpp files, but we do not compile
# the header files.
HEADER = util.h
CPP = util.cpp

# Program name
LIBNAME = libutil.a

# Object files
OBJ = $(CPP:.cpp=.o)

all: $(LIBNAME)

$(LIBNAME): $(OBJ)
	$(AR) $(ARFLAGS) $(LIBNAME) $(OBJ)

%.o: %.cpp $(HEADER)
	$(CC) $(CFLAGS) -o $@ $<

# Target clean is phony, since it doesn't
# create a file called clean.  Notice that other
# targets --- all and message --- create file
# message.
.PHONY: clean

# We will use target clean to delete both the object files
# and the program.
clean:
	rm $(LIBNAME) $(OBJ)
