# Copyright (C) 2010 Deveaux Duncan
# 
# This file is part of Hikou no mizu.
# 
# Hikou no mizu is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# Hikou no mizu is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.

#Phony targets
.PHONY : clean, mrproper

#Implicit rules deactivation
.SUFFIXES :

#Variables definition
CXX = g++
CXXFLAGS = -W -Wall

RM = rm -rf

#Main executable creation : "hikouNoMizu"
all : main.o GameEngine.o PhysicsEngine.o SoundEngine.o ImageManager.o FontManager.o SoundBufferManager.o MainMenu.o CharactersMenu.o ArenaMenu.o Fight.o Configuration.o ConfWriter.o ConfReader.o Directory.o PlayerKeys.o Arena.o Platform.o Player.o Condition.o Human.o AI.o Animation.o AnimationManager.o Button.o TextButton.o ImageButton.o Menu.o TextMenu.o FightInterface.o tinyxml.o tinystr.o tinyxmlerror.o tinyxmlparser.o
	$(CXX) -o ../hikouNoMizu main.o GameEngine.o PhysicsEngine.o SoundEngine.o ImageManager.o FontManager.o SoundBufferManager.o MainMenu.o CharactersMenu.o ArenaMenu.o Fight.o Configuration.o ConfWriter.o ConfReader.o Directory.o PlayerKeys.o Arena.o Platform.o Player.o Condition.o Human.o AI.o Animation.o AnimationManager.o Button.o TextButton.o ImageButton.o Menu.o TextMenu.o FightInterface.o tinyxml.o tinystr.o tinyxmlerror.o tinyxmlparser.o -L/usr/local/lib -lsfml-audio -lsfml-graphics -lsfml-window -lsfml-system

main.o : main.cpp Configuration/Configuration.hpp Engines/GameEngine.hpp
	$(CXX) -I. -c main.cpp -o main.o $(CXXFLAGS)

##Engines
GameEngine.o : Engines/GameEngine.cpp Engines/GameEngine.hpp Screens/MainMenu/MainMenu.hpp Screens/CharactersMenu/CharactersMenu.hpp Screens/ArenaMenu/ArenaMenu.hpp Screens/Fight/Fight.hpp Screens/Screen.hpp
	$(CXX) -I. -c Engines/GameEngine.cpp -o GameEngine.o $(CXXFLAGS)

PhysicsEngine.o : Engines/Physics/PhysicsEngine.cpp Engines/Physics/PhysicsEngine.hpp
	$(CXX) -I. -c Engines/Physics/PhysicsEngine.cpp -o PhysicsEngine.o $(CXXFLAGS)

SoundEngine.o : Engines/Sound/SoundEngine.cpp Engines/Sound/SoundEngine.hpp
	$(CXX) -I. -c Engines/Sound/SoundEngine.cpp -o SoundEngine.o $(CXXFLAGS)

#Resources
ImageManager.o : Engines/Resources/ImageManager.cpp Engines/Resources/ImageManager.hpp
	$(CXX) -I. -c Engines/Resources/ImageManager.cpp -o ImageManager.o $(CXXFLAGS)

FontManager.o : Engines/Resources/FontManager.cpp Engines/Resources/FontManager.hpp
	$(CXX) -I. -c Engines/Resources/FontManager.cpp -o FontManager.o $(CXXFLAGS)

SoundBufferManager.o : Engines/Resources/SoundBufferManager.cpp Engines/Resources/SoundBufferManager.hpp
	$(CXX) -I. -c Engines/Resources/SoundBufferManager.cpp -o SoundBufferManager.o $(CXXFLAGS)

##Screens
MainMenu.o : Screens/MainMenu/MainMenu.cpp Screens/MainMenu/MainMenu.hpp Screens/Screen.hpp Engines/GameEngine.hpp Engines/Resources/FontManager.hpp GUI/Complex/Menu/TextMenu.hpp
	$(CXX) -I. -c Screens/MainMenu/MainMenu.cpp -o MainMenu.o $(CXXFLAGS)

CharactersMenu.o : Screens/CharactersMenu/CharactersMenu.cpp Screens/CharactersMenu/CharactersMenu.hpp Screens/Screen.hpp Engines/GameEngine.hpp Engines/Resources/FontManager.hpp GUI/Complex/Menu/TextMenu.hpp
	$(CXX) -I. -c Screens/CharactersMenu/CharactersMenu.cpp -o CharactersMenu.o $(CXXFLAGS)

ArenaMenu.o : Screens/ArenaMenu/ArenaMenu.cpp Screens/ArenaMenu/ArenaMenu.hpp Screens/Screen.hpp Engines/GameEngine.hpp Engines/Resources/FontManager.hpp GUI/Complex/Menu/TextMenu.hpp
	$(CXX) -I. -c Screens/ArenaMenu/ArenaMenu.cpp -o ArenaMenu.o

Fight.o : Screens/Fight/Fight.cpp Screens/Fight/Fight.hpp Screens/Screen.hpp Engines/GameEngine.hpp Engines/Physics/PhysicsEngine.hpp Engines/Sound/SoundEngine.hpp GUI/Complex/FightInterface.hpp Arena/Arena.hpp Player/Human.hpp Player/AI.hpp
	$(CXX) -I. -c Screens/Fight/Fight.cpp -o Fight.o $(CXXFLAGS)

##Configuration
Configuration.o : Configuration/Configuration.cpp Configuration/Configuration.hpp Configuration/ConfWriter.hpp Configuration/ConfReader.hpp Tools/Directory.hpp Tools/PlayerKeys.hpp
	$(CXX) -I. -c Configuration/Configuration.cpp -o Configuration.o $(CXXFLAGS)

ConfWriter.o : Configuration/ConfWriter.cpp Configuration/ConfWriter.hpp
	$(CXX) -I. -c Configuration/ConfWriter.cpp -o ConfWriter.o $(CXXFLAGS)

ConfReader.o : Configuration/ConfReader.cpp Configuration/ConfReader.hpp
	$(CXX) -I. -c Configuration/ConfReader.cpp -o ConfReader.o $(CXXFLAGS)

##Tools
Directory.o : Tools/Directory.cpp Tools/Directory.hpp
	$(CXX) -I. -c Tools/Directory.cpp -o Directory.o $(CXXFLAGS)

PlayerKeys.o : Tools/PlayerKeys.cpp Tools/PlayerKeys.hpp
	$(CXX) -I. -c Tools/PlayerKeys.cpp -o PlayerKeys.o $(CXXFLAGS)

##Arena
Arena.o : Arena/Arena.cpp Arena/Arena.hpp Arena/Platform.hpp Engines/Physics/PhysicsEngine.hpp
	$(CXX) -I. -c Arena/Arena.cpp -o Arena.o $(CXXFLAGS)

Platform.o : Arena/Platform.cpp Arena/Platform.hpp Engines/Physics/PhysicsObject.hpp
	$(CXX) -I. -c Arena/Platform.cpp -o Platform.o $(CXXFLAGS)

##Players
Player.o : Player/Player.cpp Player/Player.hpp Engines/Physics/PhysicsObject.hpp Engines/Physics/PhysicsEngine.hpp Engines/Sound/SoundEngine.hpp Animation/AnimationManager.hpp
	$(CXX) -I. -c Player/Player.cpp -o Player.o $(CXXFLAGS)

Condition.o : Player/Condition.cpp Player/Condition.hpp
	$(CXX) -I. -c Player/Condition.cpp -o Condition.o $(CXXFLAGS)

Human.o : Player/Human.cpp Player/Human.hpp Player/Player.hpp
	$(CXX) -I. -c Player/Human.cpp -o Human.o $(CXXFLAGS)

AI.o : Player/AI.cpp Player/AI.hpp Player/Player.hpp
	$(CXX) -I. -c Player/AI.cpp -o AI.o $(CXXFLAGS)

##Animation
Animation.o : Animation/Animation.cpp Animation/Animation.hpp Engines/Resources/ImageManager.hpp
	$(CXX) -I. -c Animation/Animation.cpp -o Animation.o $(CXXFLAGS)

AnimationManager.o : Animation/AnimationManager.cpp Animation/AnimationManager.hpp Animation/Animation.hpp extlibs/TinyXML/tinyxml.h
	$(CXX) -I. -c Animation/AnimationManager.cpp -o AnimationManager.o $(CXXFLAGS)

##GUI
#Basic
Button.o : GUI/Basic/Buttons/Button.cpp GUI/Basic/Buttons/Button.hpp
	$(CXX) -I. -c GUI/Basic/Buttons/Button.cpp -o Button.o $(CXXFLAGS)

TextButton.o : GUI/Basic/Buttons/TextButton.cpp GUI/Basic/Buttons/TextButton.hpp GUI/Basic/Buttons/Button.hpp
	$(CXX) -I. -c GUI/Basic/Buttons/TextButton.cpp -o TextButton.o $(CXXFLAGS)

ImageButton.o : GUI/Basic/Buttons/ImageButton.cpp GUI/Basic/Buttons/ImageButton.hpp GUI/Basic/Buttons/Button.hpp
	$(CXX) -I. -c GUI/Basic/Buttons/ImageButton.cpp -o ImageButton.o $(CXXFLAGS)

#Complex
Menu.o : GUI/Complex/Menu/Menu.cpp GUI/Complex/Menu/Menu.hpp extlibs/TinyXML/tinyxml.h
	$(CXX) -I. -c GUI/Complex/Menu/Menu.cpp -o Menu.o $(CXXFLAGS)

TextMenu.o : GUI/Complex/Menu/TextMenu.cpp GUI/Complex/Menu/TextMenu.hpp GUI/Complex/Menu/Menu.hpp GUI/Basic/Buttons/TextButton.hpp
	$(CXX) -I. -c GUI/Complex/Menu/TextMenu.cpp -o TextMenu.o $(CXXFLAGS)

FightInterface.o : GUI/Complex/FightInterface.cpp GUI/Complex/FightInterface.hpp Player/Player.hpp
	$(CXX) -I. -c GUI/Complex/FightInterface.cpp -o FightInterface.o $(CXXFLAGS)

##extlibs
tinystr.o : extlibs/TinyXML/tinystr.cpp extlibs/TinyXML/tinystr.h
	$(CXX) -I. -c extlibs/TinyXML/tinystr.cpp -o tinystr.o $(CXXFLAGS)

tinyxml.o : extlibs/TinyXML/tinyxml.cpp extlibs/TinyXML/tinyxml.h extlibs/TinyXML/tinystr.h
	$(CXX) -I. -c extlibs/TinyXML/tinyxml.cpp -o tinyxml.o $(CXXFLAGS)

tinyxmlerror.o : extlibs/TinyXML/tinyxmlerror.cpp extlibs/TinyXML/tinyxml.h
	$(CXX) -I. -c extlibs/TinyXML/tinyxmlerror.cpp -o tinyxmlerror.o $(CXXFLAGS)

tinyxmlparser.o : extlibs/TinyXML/tinyxmlparser.cpp extlibs/TinyXML/tinyxml.h
	$(CXX) -I. -c extlibs/TinyXML/tinyxmlparser.cpp -o tinyxmlparser.o $(CXXFLAGS)

#Temporary files deletion
clean :
	$(RM) *.o

#Temporary files and main executable deletion
mrproper : clean
	$(RM) ../hikouNoMizu