include ../Makefile.common

CXXFLAGS += -I../glfw/include
LDFLAGS += -L../glfw -lglfw

CXXFLAGS += -I../trimeshloader/include
LDFLAGS += -L../trimeshloader -ltrimeshloader

CXXFLAGS += -I../physfs
LDFLAGS += -L../physfs -lphysfs

CXXFLAGS += -I../ftgl
LDFLAGS += -L../ftgl -lftgl

CXXFLAGS += -I../freetype/include
LDFLAGS += -L../freetype -lfreetype

CXXFLAGS += -I../corona/src
LDFLAGS += -L../corona -lcorona

CXXFLAGS += -I../glew/include
LDFLAGS += -L../glew -lglew

CXXFLAGS += -I../squirrel/include
LDFLAGS += -L../squirrel -lsquirrel

CXXFLAGS += -I../ode/include
LDFLAGS += -L../ode -lode

CXXFLAGS += -I../tinyxml
LDFLAGS += -L../tinyxml -ltinyxml

CXXFLAGS += -I../libpng
LDFLAGS += -L../libpng -lpng

LDFLAGS += -L../zlib -lz

ifeq ($(OS),WIN32)
	LDFLAGS += -lglu32 -lwinmm -lole32 -lws2_32 -lopengl32
else
	LDFLAGS += -lm -lGL -lGLU  -lX11 -lXxf86vm -lXext #-lopenal -Wl,-rpath=. -L/usr/X11R6/lib
endif

SRC = $(wildcard */*.cpp) $(wildcard *.cpp)
INC = $(wildcard */*.h) $(wildcard *.h)
OBJ = $(patsubst %.cpp,%.o,$(SRC) )
DEP = $(patsubst %.cpp,%.d,$(SRC) )
GCH = $(patsubst %.h,%.h.gch,$(INC) )

NAME = redcore$(EXT)

all: $(NAME)

$(NAME): $(OBJ)
	@echo Linking $@...
	@g++ -o $(NAME) $(OBJ) $(LDFLAGS)
	@echo done

obj: $(OBJ) 
	@echo done

clean:
	-@$(RMSUB) *.o
	-@$(RMSUB) *.d
	-@$(RMSUB) Utilities$(SLASH)*.o
	-@$(RMSUB) Utilities$(SLASH)*.d
	-@$(RMSUB) Math$(SLASH)*.o
	-@$(RMSUB) Math$(SLASH)*.d
	-@$(RM) $(NAME)

-include $(SRC:%.cpp=%.d)

%.h.gch: %.h
	@echo Compiling $@ ...
	@$(CXX) $(CXXFLAGS) -o $@ $<
