diff --git a/makefile b/makefile new file mode 100644 index 0000000..242309e --- /dev/null +++ b/makefile @@ -0,0 +1,75 @@ +#usage +# make CFG=release + +CPP = g++ +CC = gcc +CPPFLAGS += -std=c++11 -Wall -Wextra -pedantic-errors +INCLUDE = -isystem lib/json-parser/ -Isrc + +LIB = `pkg-config --libs sfml-all` lib/json-parser/json.a + +ifeq ($(CFG),) +CFG=debug +endif + +ifeq ($(CFG),debug) +CPPFLAGS += -ggdb -DDEBUG +else +CPPFLAGS += -O2 +endif +CPPFLAGS += $(INCLUDE) + + +VPATH=src:src/board/:src/config/:src/graphics/:src/log/:src/util/ +TARGET=chesscpp.bin + +SRC = \ + Queen.cpp \ + Board.cpp \ + Pawn.cpp \ + Position.cpp \ + Bishop.cpp \ + King.cpp \ + Rook.cpp \ + Knight.cpp \ + Piece.cpp \ + Logger.cpp \ + Main.cpp \ + Graphics.cpp \ + Application.cpp \ + AppStateGame.cpp + +OBJ = $(patsubst %.cpp, objs.$(CFG)/%.o, ${SRC}) +DEP = $(patsubst %.cpp, deps.$(CFG)/%.d, ${SRC}) + +all: bin.$(CFG)/${TARGET} + +bin.$(CFG)/${TARGET}: ${OBJ} + mkdir -p $(dir $@) + $(CPP) $^ $(LIBDIR) $(LIB) -o $@ + +test: + echo $(OBJ) + echo $(DEP) + + +deps.$(CFG)/%.d: %.cpp + mkdir -p $(dir $@) + $(CPP) -MM -MP $(CPPFLAGS) $< | perl -pe 's#^(.*\.o)#deps.$(CFG)/$$1 objs.$(CFG)/$$1#' > $@ + +objs.$(CFG)/%.o: %.cpp + mkdir -p $(dir $@) + $(CPP) -c $(CPPFLAGS) $< -o $@ + +.PHONY: clean deps + +clean: + -rm -r objs.debug deps.debug bin.debug + -rm -r objs.release deps.release bin.release + + + +# Unless "make clean" is called, include the dependency files +# which are auto-generated. Don't fail if they are missing +# (-include), since they will be missing in the first invocation! +-include ${DEP} diff --git a/src/chesspp/AppState.hpp b/src/AppState.hpp similarity index 100% rename from src/chesspp/AppState.hpp rename to src/AppState.hpp diff --git a/src/chesspp/AppStateGame.cpp b/src/AppStateGame.cpp similarity index 100% rename from src/chesspp/AppStateGame.cpp rename to src/AppStateGame.cpp diff --git a/src/chesspp/AppStateGame.hpp b/src/AppStateGame.hpp similarity index 97% rename from src/chesspp/AppStateGame.hpp rename to src/AppStateGame.hpp index c96407a..523ecb0 100644 --- a/src/chesspp/AppStateGame.hpp +++ b/src/AppStateGame.hpp @@ -1,6 +1,6 @@ #ifndef _APPSTATEGAME_H #define _APPSTATEGAME_H -#include "../SFML.hpp" +#include "SFML.hpp" #include "TextureManager.hpp" #include "graphics/Graphics.hpp" #include "config/Configuration.hpp" diff --git a/src/chesspp/Application.cpp b/src/Application.cpp similarity index 100% rename from src/chesspp/Application.cpp rename to src/Application.cpp diff --git a/src/chesspp/Application.hpp b/src/Application.hpp similarity index 100% rename from src/chesspp/Application.hpp rename to src/Application.hpp diff --git a/src/chesspp/Exception.hpp b/src/Exception.hpp similarity index 100% rename from src/chesspp/Exception.hpp rename to src/Exception.hpp diff --git a/src/Main.cpp b/src/Main.cpp index 3226a3b..94d51d0 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1,6 +1,6 @@ #include -#include "chesspp/Application.hpp" +#include "Application.hpp" int main() { diff --git a/src/chesspp/ResourceManager.hpp b/src/ResourceManager.hpp similarity index 100% rename from src/chesspp/ResourceManager.hpp rename to src/ResourceManager.hpp diff --git a/src/chesspp/SFMLEvent.hpp b/src/SFMLEvent.hpp similarity index 98% rename from src/chesspp/SFMLEvent.hpp rename to src/SFMLEvent.hpp index a8ace94..3197a9b 100644 --- a/src/chesspp/SFMLEvent.hpp +++ b/src/SFMLEvent.hpp @@ -1,7 +1,7 @@ #ifndef _EVENT_H #define _EVENT_H -#include "../SFML.hpp" +#include "SFML.hpp" namespace chesspp { diff --git a/src/chesspp/TextureManager.hpp b/src/TextureManager.hpp similarity index 98% rename from src/chesspp/TextureManager.hpp rename to src/TextureManager.hpp index 11a1759..1b00e80 100644 --- a/src/chesspp/TextureManager.hpp +++ b/src/TextureManager.hpp @@ -1,7 +1,7 @@ #ifndef _TEXTUREMANAGER_H #define _TEXTUREMANAGER_H #include "ResourceManager.hpp" -#include "../SFML.hpp" +#include "SFML.hpp" #ifdef _DEBUG #include diff --git a/src/chesspp/board/Bishop.cpp b/src/board/Bishop.cpp similarity index 100% rename from src/chesspp/board/Bishop.cpp rename to src/board/Bishop.cpp diff --git a/src/chesspp/board/Bishop.hpp b/src/board/Bishop.hpp similarity index 100% rename from src/chesspp/board/Bishop.hpp rename to src/board/Bishop.hpp diff --git a/src/chesspp/board/Board.cpp b/src/board/Board.cpp similarity index 100% rename from src/chesspp/board/Board.cpp rename to src/board/Board.cpp diff --git a/src/chesspp/board/Board.hpp b/src/board/Board.hpp similarity index 100% rename from src/chesspp/board/Board.hpp rename to src/board/Board.hpp diff --git a/src/chesspp/board/King.cpp b/src/board/King.cpp similarity index 100% rename from src/chesspp/board/King.cpp rename to src/board/King.cpp diff --git a/src/chesspp/board/King.hpp b/src/board/King.hpp similarity index 100% rename from src/chesspp/board/King.hpp rename to src/board/King.hpp diff --git a/src/chesspp/board/Knight.cpp b/src/board/Knight.cpp similarity index 100% rename from src/chesspp/board/Knight.cpp rename to src/board/Knight.cpp diff --git a/src/chesspp/board/Knight.hpp b/src/board/Knight.hpp similarity index 100% rename from src/chesspp/board/Knight.hpp rename to src/board/Knight.hpp diff --git a/src/chesspp/board/OnValidity.txt b/src/board/OnValidity.txt similarity index 100% rename from src/chesspp/board/OnValidity.txt rename to src/board/OnValidity.txt diff --git a/src/chesspp/board/Pawn.cpp b/src/board/Pawn.cpp similarity index 100% rename from src/chesspp/board/Pawn.cpp rename to src/board/Pawn.cpp diff --git a/src/chesspp/board/Pawn.hpp b/src/board/Pawn.hpp similarity index 100% rename from src/chesspp/board/Pawn.hpp rename to src/board/Pawn.hpp diff --git a/src/chesspp/board/Piece.cpp b/src/board/Piece.cpp similarity index 100% rename from src/chesspp/board/Piece.cpp rename to src/board/Piece.cpp diff --git a/src/chesspp/board/Piece.hpp b/src/board/Piece.hpp similarity index 99% rename from src/chesspp/board/Piece.hpp rename to src/board/Piece.hpp index e1da06f..9e09a64 100644 --- a/src/chesspp/board/Piece.hpp +++ b/src/board/Piece.hpp @@ -9,7 +9,7 @@ // textureX = givenValX // textureY = givenValY + ( this->color == WHITE ? 0 : 80 ) -#include "../log/Logger.hpp" +#include "log/Logger.hpp" // The contigousness of this container does not matter // It could be sorted for std::lower_bound? I don't think time is an issue diff --git a/src/chesspp/board/Position.cpp b/src/board/Position.cpp similarity index 100% rename from src/chesspp/board/Position.cpp rename to src/board/Position.cpp diff --git a/src/chesspp/board/Position.hpp b/src/board/Position.hpp similarity index 100% rename from src/chesspp/board/Position.hpp rename to src/board/Position.hpp diff --git a/src/chesspp/board/Queen.cpp b/src/board/Queen.cpp similarity index 100% rename from src/chesspp/board/Queen.cpp rename to src/board/Queen.cpp diff --git a/src/chesspp/board/Queen.hpp b/src/board/Queen.hpp similarity index 100% rename from src/chesspp/board/Queen.hpp rename to src/board/Queen.hpp diff --git a/src/chesspp/board/Rook.cpp b/src/board/Rook.cpp similarity index 100% rename from src/chesspp/board/Rook.cpp rename to src/board/Rook.cpp diff --git a/src/chesspp/board/Rook.hpp b/src/board/Rook.hpp similarity index 100% rename from src/chesspp/board/Rook.hpp rename to src/board/Rook.hpp diff --git a/src/chesspp/config/Configuration.hpp b/src/config/Configuration.hpp similarity index 98% rename from src/chesspp/config/Configuration.hpp rename to src/config/Configuration.hpp index 28ce72f..0a7c42a 100644 --- a/src/chesspp/config/Configuration.hpp +++ b/src/config/Configuration.hpp @@ -15,9 +15,9 @@ #endif -#include "../Exception.hpp" -#include "../util/JsonReader.hpp" -#include "../log/logger.hpp" +#include "Exception.hpp" +#include "util/JsonReader.hpp" +#include "log/Logger.hpp" namespace chesspp { diff --git a/src/chesspp/graphics/Graphics.cpp b/src/graphics/Graphics.cpp similarity index 100% rename from src/chesspp/graphics/Graphics.cpp rename to src/graphics/Graphics.cpp diff --git a/src/chesspp/graphics/Graphics.hpp b/src/graphics/Graphics.hpp similarity index 88% rename from src/chesspp/graphics/Graphics.hpp rename to src/graphics/Graphics.hpp index ecdd8e2..96a6d94 100644 --- a/src/chesspp/graphics/Graphics.hpp +++ b/src/graphics/Graphics.hpp @@ -1,11 +1,11 @@ #ifndef _GRAPHICS_H #define _GRAPHICS_H -#include "../../SFML.hpp" -#include "../TextureManager.hpp" -#include "../config/Configuration.hpp" -#include "../board/Piece.hpp" -#include "../log/Logger.hpp" +#include "SFML.hpp" +#include "TextureManager.hpp" +#include "config/Configuration.hpp" +#include "board/Piece.hpp" +#include "log/Logger.hpp" #ifdef _DEBUG #include diff --git a/src/chesspp/log/Logger.cpp b/src/log/Logger.cpp similarity index 100% rename from src/chesspp/log/Logger.cpp rename to src/log/Logger.cpp diff --git a/src/chesspp/log/Logger.hpp b/src/log/Logger.hpp similarity index 100% rename from src/chesspp/log/Logger.hpp rename to src/log/Logger.hpp diff --git a/src/chesspp/util/JsonReader.hpp b/src/util/JsonReader.hpp similarity index 99% rename from src/chesspp/util/JsonReader.hpp rename to src/util/JsonReader.hpp index 70eb354..8f21927 100644 --- a/src/chesspp/util/JsonReader.hpp +++ b/src/util/JsonReader.hpp @@ -7,7 +7,7 @@ #include #include -#include "../Exception.hpp" +#include "Exception.hpp" namespace chesspp {