# To compile, run 'make' in the same directory as this file

####################
# Allegro location #
####################

TARGET = LINUX
#TARGET = MACOSX
#TARGET = MINGW32

ALLEGRODIR = allegro
# The -g flag adds debugging support
CFLAGS = -Wall -g -Iinclude -I$(ALLEGRODIR)/include

ifeq ($(TARGET), LINUX)
	CFLAGS += -pthread -mtune=pentium -DALLEGRO_NO_ASM 
	LFLAGS += -Wl,--export-dynamic $(ALLEGRODIR)/lib/liballeg-4.3.10.so $(ALLEGRODIR)/lib/liballeg_unsharable.a -lm
endif
ifeq ($(TARGET), MACOSX)
	CFLAGS += -pipe -dynamic -DALLEGRO_NO_ASM
	LFLAGS += $(ALLEGRODIR)/lib/macosx/liballeg-4.3.dylib $(ALLEGRODIR)/lib/macosx/liballeg-main.a -framework Cocoa
endif
ifeq ($(TARGET), MINGW32)
	CFLAGS += -mtune=i586 -DALLEGRO_NO_ASM
	LFLAGS += -Wl,--subsystem,windows $(ALLEGRODIR)/lib/mingw32/liballeg.a -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lole32 -ldinput -lddraw -ldxguid -lwinmm -ldsound
endif

#########################
# Settings for the apps # 
#########################

DEMOOBJS = obj/DemoApp.o obj/DemoHelper.o obj/Vector2.o obj/Maps.o

# The names of the apps
DEMOAPP = bin/DemoApp.exe

# This is the first target. It will be built when you run 'make' or 'make all'
all: $(DEMOAPP) docs

# Rules for linking the test apps
$(DEMOAPP): $(DEMOOBJS)
	$(CXX) $(DEMOOBJS) -o $(DEMOAPP) $(LFLAGS)

# Compile each source file of the apps
obj/DemoApp.o: src/DemoApp.cpp
	$(CXX) $(CFLAGS) -c src/DemoApp.cpp -o obj/DemoApp.o

obj/DemoHelper.o: src/DemoHelper.cpp
	$(CXX) $(CFLAGS) -c src/DemoHelper.cpp -o obj/DemoHelper.o

obj/Vector2.o: src/Vector2.cpp
	$(CXX) $(CFLAGS) -c src/Vector2.cpp -o obj/Vector2.o

obj/Maps.o: src/Maps.cpp
	$(CXX) $(CFLAGS) -c src/Maps.cpp -o obj/Maps.o
	
	
clean: 
	rm -rf bin/*.exe docs/* obj/*

docs: 
	doxygen
