#
# Makefile for UN*X-like systems
#

# Change this line if you want a different compiler
CPP = c++ -Wall -W -I. -Icxxtest
CXX = g++ 
CXXFLAGS = -g -Wall -W -I. 

# If you want to use python, specify USE_PYTHON=1 on the command line
ifdef USE_PYTHON
	TESTGEN = ./cxxtest/cxxtestgen.py
else
	TESTGEN = ./cxxtest/cxxtestgen.pl
endif

TARGETS = error_printer stdio_printer
TESTS = *Test.h
CODE = ByteData.cxx Modules.cxx StateFile.cxx
OBJS = $(CODE:cxx=o)

TESTER = StateFileTest.cpp
TESTEROBJ = $(TESTER:cpp=o)

lib: $(OBJS)
	ar rcs libstatefile.a $(OBJS)

all: $(OBJS) $(TARGETS)

tester: $(TESTEROBJ) $(OBJS)
	$(CPP) -o $@ $(OBJS) $(TESTEROBJ)
clean:
	rm -f *~ *.o *.obj $(TARGETS)
	rm -f tests.cpp error_printer.cpp stdio_printer.cpp
	rm -f libstatefile.a

run: error_printer
	./error_printer


error_printer.cpp: $(TESTS) 
	$(TESTGEN) -o $@ --error-printer $(TESTS)

stdio_printer.cpp: $(TESTS)
	$(TESTGEN) -o $@ --runner=StdioPrinter $(TESTS)

tests.cpp: $(TESTS)
	$(TESTGEN) -o $@ $(TESTS)

%: %.cpp
	$(CPP) -o $@ $< $(OBJS)

%.o : %.cxx
	@rm -f $*.o
	$(CXX) $(CXXFLAGS) $*.cxx -c

%.o: %.cpp
	@rm -f $*.o
	$(CXX) $(CXXFLAGS) $*.cpp -c

#
# Local Variables:
# compile-command: "make -fMakefile.unix"
# End:
#
