Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change MacOS library path #4

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
*.exe
.vscode/
Release/
Makefile
Makefile.mk
Release/
66 changes: 51 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
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
2 changes: 1 addition & 1 deletion src/button.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _BUTTON_H

// SDL libraries
#if defined(_WIN64) || defined(_WIN32)
#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__)
#include <SDL.h>
#include <SDL_ttf.h>
#else
Expand Down
2 changes: 1 addition & 1 deletion src/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define _CONST_H

// SDL LIBRARIES
#if defined(_WIN64) || defined(_WIN32)
#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__)
#include <SDL.h>
#else
#include <SDL2/SDL.h>
Expand Down
2 changes: 1 addition & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <vector>
#include <ctime>
// SDL libraries
#if defined(_WIN64) || defined(_WIN32)
#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__)
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
Expand Down
2 changes: 1 addition & 1 deletion src/res.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// C++ libraries
#include <vector>
// SDL libraries
#if defined(_WIN64) || defined(_WIN32)
#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__)
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
Expand Down
2 changes: 1 addition & 1 deletion src/seller.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// C++ libraries
#include <iostream>
// SDL libraries
#if defined(_WIN64) || defined(_WIN32)
#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__)
#include <SDL.h>
#include <SDL_image.h>
#else
Expand Down
2 changes: 1 addition & 1 deletion src/texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// C++ libraries
#include <iostream>
// SDL libraries
#if defined(_WIN64) || defined(_WIN32)
#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__)
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
Expand Down
2 changes: 1 addition & 1 deletion src/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// C++ libraries
#include <iostream>
// SDL libraries
#if defined(_WIN64) || defined(_WIN32)
#if defined(_WIN64) || defined(_WIN32) || defined(__APPLE__)
#include <SDL.h>
#include <SDL_ttf.h>
#else
Expand Down
Loading