Moving to static linking core.

This commit is contained in:
Ulysse Cura 2026-07-17 15:30:53 +02:00
parent af6a048bd3
commit bd624b53ea
1 changed files with 12 additions and 8 deletions

View File

@ -20,7 +20,11 @@ CORE_CFLAGS = -std=c17 --pedantic -g -fPIC -DASSET_FILENAME=$(BUILD_DIR)/$(ASSET
-Wold-style-definition # DEVELOPEMENT
CORE_INCLUDE_DIRS = $(CORE_DIR)/headers
CORE_LDFLAGS = $(shell pkg-config --libs sdl2 SDL2_image)
CORE_AR = ar
CORE_ARFLAGS =
# Used in final linking.
CORE_DEPS_FLAGS = $(shell pkg-config --libs sdl2 SDL2_image)
# Deduce objects
CORE_OBJECTS = $(CORE_SOURCES:%.c=$(BUILD_DIR)/$(CORE_DIR)/%.o)
@ -29,11 +33,11 @@ CORE_OBJECTS = $(CORE_SOURCES:%.c=$(BUILD_DIR)/$(CORE_DIR)/%.o)
CURRENT_CORE_FILE := 0
# Build core target
build_core: core_setup count_core_build $(BUILD_DIR)/libCore.so core_end
build_core: core_setup count_core_build $(BUILD_DIR)/$(CORE_OUTPUT) core_end
# Core build directories
core_setup:
@echo "Building libCore.so (1/3)"
@echo "Building $(CORE_OUTPUT)"
$(Q)mkdir -p $(dir $(CORE_OBJECTS))
# Count nb of files to build
@ -41,9 +45,9 @@ count_core_build:
$(eval export TOTAL_CORE_FILES := $(shell echo $$(($$(make -n $(CORE_OBJECTS) 2>/dev/null | grep -c "Building") + 1))))
# Link core target
$(BUILD_DIR)/libCore.so: $(CORE_OBJECTS)
$(BUILD_DIR)/$(CORE_OUTPUT): $(CORE_OBJECTS)
@echo -e "[100%] $(YELLOW)Linking libCore.so$(RESET)"
$(Q)$(CORE_CC) -shared $(CORE_OBJECTS) -o $@ $(CORE_LDFLAGS)
$(Q)$(CORE_AR) rcs $(CORE_ARFLAGS) $@ $^
# Build .o files
$(BUILD_DIR)/$(CORE_DIR)/%.o: $(CORE_DIR)/%.c
@ -53,8 +57,8 @@ $(BUILD_DIR)/$(CORE_DIR)/%.o: $(CORE_DIR)/%.c
$(Q)$(CORE_CC) $(CORE_CFLAGS) $(CORE_INCLUDE_DIRS:%=-I%) -MMD -MP -c $< -o $@
# Print ending message
core_end: $(BUILD_DIR)/libCore.so
@echo "Built target libCore.so"
core_end:
@echo "Built target $(CORE_OUTPUT)"
# Source files dependencies
-include $(SOURCE_OBJECTS:.o=.d)
-include $(CORE_OBJECTS:.o=.d)