Tesseract-Engine/Makefile

127 lines
4.3 KiB
Makefile
Raw Normal View History

2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Compiler and Base Flags
# ------------------------------------------------------------------------------
CXX := g++
2025-01-01 07:36:53 +00:00
CXXFLAGS := -Wall -Wextra -std=c++17 -g -DDEBUG -DTIMERS
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Detect Platform
# ------------------------------------------------------------------------------
ifeq ($(OS),Windows_NT)
# -------------------- Windows --------------------
EXE_EXT := .exe
# Example paths (adjust if you have your libs somewhere else):
# Include directories for GLFW, GLEW, etc.
GLFW_INCLUDE := C:/libs/glfw/include
GLEW_INCLUDE := C:/libs/glew/include
# Library search paths
LIB_PATHS := -LC:/libs/glfw/lib \
-LC:/libs/glew/lib \
-Llib
# Libraries to link against (adjust if needed)
LIBS := -lglfw3 -lopengl32 -lgdi32 -limm32 -lole32 -loleaut32 -luuid \
-lwinmm -lglew32 -lglu32 -lyaml-cpp -llua54
# A Windows-compatible "mkdir" command:
define MKDIR_P
if not exist "$(1)" mkdir "$(1)" >nul 2>&1
endef
else
# -------------------- Linux (or other Unix-likes) --------------------
EXE_EXT :=
# If libs are installed system-wide, you usually only need -lGL, -lGLEW, etc.
# But you can still point to custom paths if needed:
GLFW_INCLUDE := /usr/include
GLEW_INCLUDE := /usr/include
# Library search paths (often not needed if system-wide)
LIB_PATHS :=
# Libraries on Linux
LIBS := -lglfw -lGL -lGLEW -lGLU -lyaml-cpp -llua
# A Linux-compatible "mkdir -p" command:
define MKDIR_P
mkdir -p "$(1)"
endef
endif
# ------------------------------------------------------------------------------
# Directories
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
SRC_DIR := src
VENDOR_DIRS := vendor/imgui-docking vendor/stb
BUILD_DIR := build
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Include Directories
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
INCLUDE_DIRS := \
$(SRC_DIR) \
$(VENDOR_DIRS) \
$(GLFW_INCLUDE) \
$(GLEW_INCLUDE) \
vendor/stb/include \
vendor/lua \
vendor/gcml
2025-01-04 02:45:31 +00:00
# Add them to compiler flags:
CXXFLAGS += $(foreach inc,$(INCLUDE_DIRS),-I$(inc))
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Source Files
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
SRC_FILES := $(wildcard $(SRC_DIR)/*.cpp) \
$(wildcard $(SRC_DIR)/**/*.cpp)
VENDOR_SRC := $(foreach dir, $(VENDOR_DIRS), $(wildcard $(dir)/*.cpp))
STB_SRC := $(wildcard vendor/stb/src/*.cpp) # If stb has .cpp files
ALL_SRC := $(SRC_FILES) $(VENDOR_SRC) $(STB_SRC)
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Object Files
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
OBJ_FILES := $(patsubst %.cpp, $(BUILD_DIR)/%.o, $(ALL_SRC))
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Target
# ------------------------------------------------------------------------------
TARGET := TesseractEngine$(EXE_EXT)
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Phony Targets
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
.PHONY: all clean
# Default target
2025-01-04 02:45:31 +00:00
all: $(TARGET)
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Link all object files to create the executable
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
$(TARGET): $(OBJ_FILES)
@echo Linking $@...
2025-01-04 02:45:31 +00:00
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIB_PATHS) $(LIBS)
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Pattern rule to compile .cpp files to .o files
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
$(BUILD_DIR)/%.o: %.cpp
2025-01-04 02:45:31 +00:00
@$(call MKDIR_P,$(dir $@))
@echo Compiling $<...
$(CXX) $(CXXFLAGS) -c $< -o $@
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
# Clean build artifacts
2025-01-04 02:45:31 +00:00
# ------------------------------------------------------------------------------
clean:
@echo Cleaning up...
2025-01-04 02:45:31 +00:00
rm -rf "$(BUILD_DIR)"
rm -f "$(TARGET)"