

# Constants used by the build system
# -----------------------------------------------------------------------------
RM := rm -rf

QT_PATH_WIN32_BIN := /c/Qt-4.6.4/bin
QT_PATH_WIN32_INCLUDE := /c/Qt-4.6.4/include
QT_PATH_WIN32_LIB := /c/Qt-4.6.4/lib

QT_PATH_LINUX_BIN := /usr/bin
QT_PATH_LINUX_INCLUDE := /usr/include/qt4
QT_PATH_LINUX_LIB := /usr/lib/x86_64-linux-gnu


# All of the sources participating in the build are defined here
# -----------------------------------------------------------------------------
-include objects.mk
-include src/subdir.mk

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
endif

# Add inputs and outputs from these tool invocations to the build variables 
# -----------------------------------------------------------------------------

# All Target
all:
	@echo
	@echo "Please use one of the following options :"
	@echo
	@echo " make use_qt_win (for building with QT and OpenGL (QT / win32/64)"
	@echo " make use_qt_linux (for building with QT and OpenGL (QT / linux)"
	@echo " make use_glut (for building with the GLUT library (linux))"
	@echo


# Build entries
# -----------------------------------------------------------------------------

say_use_qt_win:
	@echo "Building with QT and Opengl (win)"
	@echo 
use_qt_win: LIBS_RT = ${LIBS_GLQT_WIN}
use_qt_win: INCPATH_RT = ${INCPATH_QT_WIN}
#use_qt_win: DEFINITIONS = -DUSE_QT=1 -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
use_qt_win: DEFINITIONS = -DUSE_QT=1 -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -D_WIN32 -DWIN32 -DQ_OS_WIN32
use_qt_win: OPTIMIZE = -O2
use_qt_win: MOC_PATH = $(QT_PATH_WIN32_BIN)
use_qt_win: 
	@echo "Using QT lib path : $(QT_PATH_WIN_LIB)"
	@echo "Using QT include path : $(QT_PATH_WIN_INCLUDE)"
	@echo "Using QT moc path : $(MOC_PATH)"
use_qt_win: say_use_qt_win snake_qt_win

say_use_qt_linux:
	@echo "Building with QT and Opengl (Linux)"
	@echo 
	@echo "Using QT lib path : $(QT_PATH_LINUX_LIB)"
	@echo "Using QT include path : $(QT_PATH_LINUX_INCLUDE)"
	@echo "Using QT moc path : $(MOC_PATH)"
	@echo
use_qt_linux: LIBS_RT = ${LIBS_GLQT_LINUX}
use_qt_linux: INCPATH_RT = ${INCPATH_QT_LINUX}
#use_qt_linux: DEFINITIONS = -DUSE_QT=1 -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
use_qt_linux: DEFINITIONS = -DUSE_QT=1 -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
use_qt_linux: OPTIMIZE = -O2
use_qt_linux: MOC_PATH = $(QT_PATH_LINUX_BIN)
use_qt_linux: 
use_qt_linux: say_use_qt_linux snake_qt_linux

say_use_glut:
	@echo "Building with the GLUT library (linux)"
	@echo	
use_glut: LIBS_RT = ${LIBS_GLUT}
use_glut: INCPATH_RT = ${INCPATH_GLUT}
use_glut: DEFINITIONS = -DUSE_GLUT=1
use_glut: OPTIMIZE = -O2
#use_glut: OPTIMIZE = -g
use_glut: say_use_glut snake_glut 
	
	
# Tool invocations
# -----------------------------------------------------------------------------

snake_qt_win: $(MOCCPPS) $(OBJS_QT) $(USER_OBJS)
	@echo 
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	g++ $(OPTIMIZE) -Wall -L $(QT_PATH_WIN32_LIB) -L/usr/local/lib/ -L/usr/lib/ $(DEFINITIONS) -o"snake" $(OBJS_QT) $(USER_OBJS) $(LIBS_RT)
	@echo 'Finished building target: $@'
	@echo ' '

snake_qt_linux: $(MOCCPPS) $(OBJS_QT) $(USER_OBJS)
	@echo 
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	g++ $(OPTIMIZE) -Wall -L$(QT_PATH_LINUX_LIB) -L/usr/local/lib/ -L/usr/lib/ $(DEFINITIONS) -o"snake" $(OBJS_QT) $(USER_OBJS) $(LIBS_RT)
	@echo 'Finished building target: $@'
	@echo ' '
	
snake_glut: $(OBJS_GLUT) $(USER_OBJS)
	@echo 
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	g++ $(OPTIMIZE) -Wall -L/usr/local/lib/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/ $(DEFINITIONS) -o"snake" $(OBJS_GLUT) $(USER_OBJS) $(LIBS_RT)
	@echo 'Finished building target: $@'
	@echo ' '


# Other Targets
# -----------------------------------------------------------------------------
clean:
	-$(RM) $(OBJS_QT)$(OBJS_GLUT)$(C++_DEPS)$(C_DEPS)$(CC_DEPS)$(CPP_DEPS)$(EXECUTABLES)$(CXX_DEPS)$(C_UPPER_DEPS) snake snake.exe
	-$(RM) ./src/moc_*.cpp
	-@echo ' '

.PHONY: all clean dependents
.SECONDARY:

