# Quick and dirty makefile

#CFLAGS = -Wall -g -pthread
CFLAGS = -Wall -g
CXXFLAGS = -Wall -g -O3 -DNDEBUG
#CXXFLAGS = -Wall -g -O0
#LDFLAGS = -g -pthread
LDFLAGS = -g

BINNAME=mother
MKDEPEND=$(CXX) -M

#all: asteroid mother
all: hal

asteroid:
	g++ $(CFLAGS) asteroid.cpp player.cpp $(OSFLAG) -o $(BINNAME)


mother_OBJS = main.o commlink.o world.o screen.o tracking.o number1.o event.o

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

%.d: %.cpp
	$(MKDEPEND) $(CXXFLAGS) $< >$@
#$(MKDEPEND) $(CXXFLAGS) $< | sed -e "s:[.]/::g" >$@

hal: $(mother_OBJS)
	$(CXX) $(LDFLAGS) $^ -o $@

.PHONY: test
test: WorldCoordsTest IntervalTest TrackingTest


#.PHONY: WorldCoordsTest
WorldCoordsTest: WorldCoordsTest.cpp world.o commlink.o tracking.o event.o
	$(CXX) $(CXXFLAGS) -fno-access-control $(CPPFLAGS) $^ -o $@
#	./WorldCoordsTest

.PHONY: IntervalTest
IntervalTest: IntervalTest.cpp
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $^ -o $@
	./IntervalTest

.PHONY: TrackingTest
TrackingTest: TrackingTest.cpp number1.o commlink.o world.o screen.o tracking.o captain.o
	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $^ -o $@
	./TrackingTest

clean:
	rm -f $(BINNAME) $(mother_OBJS) *.d core* vgcore* WorldCoordsTest

# include autogenerated dependencies
-include $(mother_OBJS:.o=.d)

