diff --git a/.gitignore b/.gitignore index 9e4ebd2..cc8fe6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ *.exe .vscode/ -Release/ -Makefile -Makefile.mk \ No newline at end of file +Release/ \ No newline at end of file diff --git a/Makefile b/Makefile index 93474e1..f7c3d03 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,56 @@ -ifeq ($(OS),Windows_NT) +# Object files OBJS = $(wildcard src/*.cpp) + +# Output executable OBJ_NAME = cataurant.exe + +# Compiler and linker flags +COMPILER_FLAGS = -std=c++17 + +# Information and icons RESOURCES_SCRIPT = cataurant.rc RESOURCES_FILE = cataurant.res -COMPILER_FLAGS = -std=c++17 -static-libgcc -static-libstdc++ -LINKER_FLAGS = -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -INCLUDE_DIR = -Iinclude/64bit -LIB_DIR = -Llib/64bit -compile: - windres $(RESOURCES_SCRIPT) -O coff -o $(RESOURCES_FILE) - g++ $(COMPILER_FLAGS) $(INCLUDE_DIR) $(LIB_DIR) $(OBJS) $(LINKER_FLAGS) -o $(OBJ_NAME) $(RESOURCES_FILE) + +# Platform-specific settings +ifeq ($(OS),Windows_NT) + COMPILER_FLAGS += -static-libgcc -static-libstdc++ + LINKER_FLAGS = -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf + ifdef PROCESSOR_ARCHITEW6432 + # 32-bit process on 64-bit Windows (targeting 32-bit build) + INCLUDE_DIR = -Iinclude/32bit + LIB_DIR = -Llib/32bit + compile: + windres $(RESOURCES_SCRIPT) -O coff -o $(RESOURCES_FILE) + g++ $(COMPILER_FLAGS) $(INCLUDE_DIR) $(LIB_DIR) $(OBJS) $(LINKER_FLAGS) -o $(OBJ_NAME) $(RESOURCES_FILE) + else + ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) + # 64-bit Windows + INCLUDE_DIR = -Iinclude/64bit + LIB_DIR = -Llib/64bit + compile: + windres $(RESOURCES_SCRIPT) -O coff -o $(RESOURCES_FILE) + g++ $(COMPILER_FLAGS) $(INCLUDE_DIR) $(LIB_DIR) $(OBJS) $(LINKER_FLAGS) -o $(OBJ_NAME) $(RESOURCES_FILE) + else + # 32-bit Windows + INCLUDE_DIR = -Iinclude/32bit + LIB_DIR = -Llib/32bit + compile: + windres $(RESOURCES_SCRIPT) -O coff -o $(RESOURCES_FILE) + g++ $(COMPILER_FLAGS) $(INCLUDE_DIR) $(LIB_DIR) $(OBJS) $(LINKER_FLAGS) -o $(OBJ_NAME) $(RESOURCES_FILE) + endif + endif else -OBJS = $(wildcard src/*.cpp) -OBJ_NAME = cataurant.exe -COMPILER_FLAGS = -std=c++17 -LINKER_FLAGS = -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -compile: - g++ $(COMPILER_FLAGS) $(OBJS) $(LINKER_FLAGS) -o $(OBJ_NAME) -endif \ No newline at end of file + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Darwin) + # macOS + INCLUDE_DIR = -I/opt/homebrew/include/SDL2 + LIB_DIR = -L/opt/homebrew/lib + compile: + g++ $(COMPILER_FLAGS) $(INCLUDE_DIR) $(OBJS) $(LIB_DIR) -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -o $(OBJ_NAME) + else + # Linux + INCLUDE_DIR = -I/usr/include/SDL2 + compile: + g++ $(COMPILER_FLAGS) $(INCLUDE_DIR) $(OBJS) -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -o $(OBJ_NAME) + endif +endif diff --git a/src/button.h b/src/button.h index f8194ce..d07ff7a 100644 --- a/src/button.h +++ b/src/button.h @@ -2,7 +2,7 @@ #define _BUTTON_H // SDL libraries -#if defined(_WIN64) || defined(_WIN32) +#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__) #include #include #else diff --git a/src/const.h b/src/const.h index 5ec9de5..6aa0e03 100644 --- a/src/const.h +++ b/src/const.h @@ -2,7 +2,7 @@ #define _CONST_H // SDL LIBRARIES -#if defined(_WIN64) || defined(_WIN32) +#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__) #include #else #include diff --git a/src/game.h b/src/game.h index a0861d4..512975b 100644 --- a/src/game.h +++ b/src/game.h @@ -6,7 +6,7 @@ #include #include // SDL libraries -#if defined(_WIN64) || defined(_WIN32) +#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__) #include #include #include diff --git a/src/res.h b/src/res.h index cc236b1..03efab0 100644 --- a/src/res.h +++ b/src/res.h @@ -4,7 +4,7 @@ // C++ libraries #include // SDL libraries -#if defined(_WIN64) || defined(_WIN32) +#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__) #include #include #include diff --git a/src/seller.h b/src/seller.h index f7c520b..15fc394 100644 --- a/src/seller.h +++ b/src/seller.h @@ -4,7 +4,7 @@ // C++ libraries #include // SDL libraries -#if defined(_WIN64) || defined(_WIN32) +#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__) #include #include #else diff --git a/src/texture.h b/src/texture.h index 96a5500..a5dda86 100644 --- a/src/texture.h +++ b/src/texture.h @@ -4,7 +4,7 @@ // C++ libraries #include // SDL libraries -#if defined(_WIN64) || defined(_WIN32) +#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__) #include #include #include diff --git a/src/ui.h b/src/ui.h index 8a9bb4f..48cc17b 100644 --- a/src/ui.h +++ b/src/ui.h @@ -4,7 +4,7 @@ // C++ libraries #include // SDL libraries -#if defined(_WIN64) || defined(_WIN32) +#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__) #include #include #else