You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.4 KiB
91 lines
2.4 KiB
# Compiler and flags |
|
CXX = g++ |
|
CXXFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14 \ |
|
-I./src \ |
|
-isystem./ext/tomlc17/src \ |
|
-isystem./ext/raylib/src \ |
|
-isystem./ext/raygui/src \ |
|
-isystem./ext/raygui/styles |
|
LDFLAGS = -L./ext/raylib/src -lraylib -lm -lpthread -ldl -lrt -lX11 |
|
|
|
# Directories |
|
SRC_DIR = src |
|
BUILD_DIR = build |
|
RAYLIB_DIR = ext/raylib/src |
|
TARGET = orbit_sim |
|
TEST_DIR = tests |
|
TEST_TARGET = orbit_test |
|
|
|
# Source files (exclude old mission planning files) |
|
CPP_SOURCES := $(wildcard $(SRC_DIR)/*.cpp) |
|
C_SOURCES = ext/tomlc17/src/tomlc17.c |
|
TEST_SOURCES := $(wildcard $(TEST_DIR)/*.cpp) |
|
|
|
# Object files |
|
CPP_OBJECTS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o) |
|
C_OBJECTS = $(BUILD_DIR)/tomlc17.o |
|
TEST_OBJECTS := $(patsubst $(TEST_DIR)/%.cpp, $(BUILD_DIR)/%.o, $(TEST_SOURCES)) |
|
|
|
# Default target (updates ctags if available) |
|
all: raylib $(BUILD_DIR) $(TARGET) |
|
@command -v ctags >/dev/null 2>&1 && ctags -R tests/ src/ || true |
|
|
|
# Build raylib |
|
raylib: |
|
@if [ ! -f $(RAYLIB_DIR)/libraylib.a ]; then \ |
|
echo "Building raylib..."; \ |
|
cd $(RAYLIB_DIR) && $(MAKE) PLATFORM=PLATFORM_DESKTOP; \ |
|
fi |
|
|
|
# Create build directory |
|
$(BUILD_DIR): |
|
mkdir -p $(BUILD_DIR) |
|
|
|
# Link the executable |
|
$(TARGET): $(C_OBJECTS) $(CPP_OBJECTS) raylib |
|
$(CXX) $(C_OBJECTS) $(CPP_OBJECTS) -o $(TARGET) $(LDFLAGS) |
|
|
|
# Compile C++ source files |
|
$(CPP_OBJECTS): $(BUILD_DIR)/%.o : $(SRC_DIR)/%.cpp |
|
$(CXX) $(CXXFLAGS) -c $< -o $@ |
|
|
|
# Compile C source files |
|
$(C_OBJECTS): $(BUILD_DIR)/%.o : $(C_SOURCES) |
|
$(CC) -Wall -Wextra -g -ggdb3 -std=c99 -I./src -I./ext/tomlc17/src -c $< -o $@ |
|
|
|
# Clean build files |
|
clean: |
|
rm -rf $(BUILD_DIR) $(TARGET) $(TEST_TARGET) |
|
|
|
# Clean everything including raylib |
|
clean-all: clean |
|
cd $(RAYLIB_DIR) && $(MAKE) clean |
|
|
|
# Rebuild |
|
rebuild: clean all |
|
|
|
# Run the simulation |
|
run: $(TARGET) |
|
./$(TARGET) |
|
|
|
$(TEST_OBJECTS): $(BUILD_DIR)/%.o : $(TEST_DIR)/%.cpp |
|
$(CXX) $(CXXFLAGS) -c $< -o $@ |
|
|
|
# Build automated test suite |
|
test-build: $(BUILD_DIR) $(C_OBJECTS) $(CPP_OBJECTS) $(TEST_OBJECTS) |
|
$(CXX) $(C_OBJECTS) $(TEST_OBJECTS) \ |
|
build/test_utilities.o \ |
|
build/physics.o \ |
|
build/orbital_mechanics.o \ |
|
build/simulation.o \ |
|
build/config_loader.o \ |
|
build/config_validator.o \ |
|
build/maneuver.o \ |
|
build/spacecraft.o \ |
|
-o $(TEST_TARGET) -lCatch2Main -lCatch2 -lm |
|
|
|
# Run automated test suite |
|
test: test-build |
|
./$(TEST_TARGET) |
|
|
|
.PHONY: all clean clean-all rebuild run test test-build raylib ctags
|
|
|