# Makefile to quickly build the tests:
# > make -f Make
# Normally you should use configure and make to build and install:
# > ./configure && make
# > cd test
# > make
#
# requires Boost.Regex and std::regex
#
# Boost.regex normally includes libboost_regex-mt, if not change LIBBOOST below

CXX       = c++ -std=c++11
REFLEX    = ../bin/reflex
REFLAGS   =
LIBREFLEX =../lib/libreflex.a
YACC      = bison -y
INCPCRE2  = /opt/local/include
LIBPCRE2  = -L/opt/local/lib -lpcre2-8
INCBOOST  = /opt/local/include
# LIBBOOST  = -L/opt/local/lib -lboost_regex
# LIBBOOST  = -L/opt/homebrew/lib -lboost_regex-mt
LIBBOOST  = -L/opt/local/lib -lboost_regex-mt
CXXOFLAGS = -O2
CXXWFLAGS = -Wall -Wunused -Wextra
CXXIFLAGS = -I. -I../include -I $(INCPCRE2) -I $(INCBOOST)
CXXMFLAGS =
CXXFLAGS  = $(CXXWFLAGS) $(CXXOFLAGS) $(CXXIFLAGS) $(CXXMFLAGS)

all:		test_bits test_ranges lorem streams test rtest ptest btest stest

lorem:		lorem.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX) $(LIBPCRE2) $(LIBBOOST)
		./lorem

streams:	streams.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX)
		./streams

test:		test.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX) $(LIBPCRE2) $(LIBBOOST)
		./test '(a|b)*abb' 'ababb'

rtest:		rtest.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX)
		./rtest

lazytest:	lazytest.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX)
		./lazytest

ptest:		ptest.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX) $(LIBPCRE2)
		./ptest

btest:		btest.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX) $(LIBBOOST)
		./btest

stest:		stest.cpp
		$(CXX) -std=c++11 $(CXXFLAGS) -o $@ $< $(LIBREFLEX)
		./stest

test_bits:	test_bits.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX)
		./test_bits

test_ranges:	test_ranges.cpp
		$(CXX) $(CXXFLAGS) -o $@ $< $(LIBREFLEX)
		./test_ranges

.PHONY:		clean

clean:
		-rm -rf *.dSYM
		-rm -f *.o *.gch *.log
		-rm -f lex.yy.h lex.yy.cpp y.tab.h y.tab.c
		-rm -rf *.dSYM
		-rm -f *.o *.gch *.log
		-rm -f lex.yy.h lex.yy.cpp y.tab.h y.tab.c reflex.*.cpp reflex.*.gv reflex.*.txt
		-rm -f a.out test_regex_history dump.gv dump.pdf dump.cpp
		-rm -f lorem streams test rtest lazytest ptest btest stest test_bits test_ranges
