########################################################
# Makefile for CSCI 435 
# Author: Gary M. Zoppetti
########################################################

########################################################
# Variable definitions
########################################################
# C++ compiler
CXX := g++
#CXX := clang++

# Include directories, prefaced with "-I"
INCDIRS  := 

# C++ compiler flags
# Use the first for debugging, the second for release
CXXFLAGS := -g -Wall $(INCDIRS)
#CXXFLAGS := -O3 -Wall $(INCDIRS)

# Linker. For C++ should be $(CXX).
LINK := $(CXX)

# Linker flags. Usually none.
LDFLAGS := 

# Library paths, prefaced with "-L". Usually none.
LDPATHS := 

# Libraries used, prefaced with "-l".
LDLIBS := -lfl

GENERATED := LineCount.cc Numbers.cc PascalComment.cc \
	     PascalLexer.cc Username.cc WordCount.cc \
	     WordCountOrig.cc

#############################################################
# Rules
#   Rules have the form
#   target : prerequisites
#   	  recipe
#############################################################

% : %.o
	$(LINK) $(LDFLAGS) $^ -o $@ $(LDLIBS)

%.o : %.cc
	$(CXX) $(CXXFLAGS) -c $< -o $@

%.cc : %.l
	flex --nounput -o $@ $<

PascalDriver : PascalDriver.o PascalLexer.o

WordCountOrigDriver : WordCountOrigDriver.o WordCountOrig.o

#############################################################

.PHONY : clean
clean :
	$(RM) a.out core
	$(RM) *.o *.d *~
	$(RM) LineCount PascalDriver Username \
		WordCount WordCount1Line WordCountOrig \
                Numbers WordCountOrigDriver
	$(RM) $(GENERATED)

#############################################################
