CXX = g++
OPTFLAGS = -O2
DBGFLAGS =
CXXFLAGS = -std=c++11 -Wall -Wextra $(OPTFLAGS) $(DBGFLAGS)
LIB_BOOST_TEST = -l:libboost_unit_test_framework.a

.PHONY: all
all: run_matching run_matching_dbg test_mwmatching

run_matching: run_matching.cpp mwmatching.h
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $<

run_matching_dbg: OPTFLAGS = -Og
run_matching_dbg: DBGFLAGS = -g -fsanitize=address -fsanitize=undefined
run_matching_dbg: run_matching.cpp mwmatching.h
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $<

test_mwmatching: OPTFLAGS = -O1
test_mwmatching: DBGFLAGS = -fsanitize=address -fsanitize=undefined
test_mwmatching: test_mwmatching.cpp mwmatching.h
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIB_BOOST_TEST)

test_datastruct: OPTFLAGS = -O1
test_datastruct: DBGFLAGS = -fsanitize=address -fsanitize=undefined
test_datastruct: test_datastruct.cpp datastruct.h
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIB_BOOST_TEST)

.PHONY: clean
clean:
	$(RM) run_matching run_matching_dbg test_mwmatching