d2bf8fb67a
- Add test target to both bmake.mk and gmake.mk Makefiles - Add test-related artifacts to .gitignore (excluding DLLs/shared libs) - Create test directory with cross-platform Makefiles (bmake.mk, gmake.mk) - Implement cross-platform test program with signal handling (test.c) - Add test module source for compilation (test_mod.c) - Set up automated test environment with mods/ directory - Support both POSIX and Windows platforms The test infrastructure allows running integration tests via 'make test' and demonstrates stk library functionality with dynamic module loading. Generated DLLs/shared libraries are excluded from version control.
56 lines
1.3 KiB
Makefile
56 lines
1.3 KiB
Makefile
include config.mk
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
SHELL := cmd.exe
|
|
FULL_LIB := $(LIB_NAME).dll
|
|
LDFLAGS_PLAT :=
|
|
CFLAGS_PLAT :=
|
|
MKDIR = if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
|
|
RMDIR = if exist $(subst /,\,$(1)) rd /s /q $(subst /,\,$(1))
|
|
else
|
|
FULL_LIB := lib$(LIB_NAME).so
|
|
LDFLAGS_PLAT := -ldl
|
|
CFLAGS_PLAT := -fPIC
|
|
MKDIR = mkdir -p $(1)
|
|
RMDIR = rm -rf $(1)
|
|
endif
|
|
|
|
RELEASE_LDFLAGS := -s
|
|
CFLAGS_BASE := -Wall -Wpedantic -I$(INC_DIR) -std=c89 $(CFLAGS_PLAT)
|
|
|
|
.PHONY: all debug release clean test
|
|
|
|
all: debug
|
|
|
|
debug: $(BIN_DIR)/debug/$(FULL_LIB)
|
|
release: $(BIN_DIR)/release/$(FULL_LIB)
|
|
|
|
# Debug Rules
|
|
$(BIN_DIR)/debug/$(FULL_LIB): $(SRCS:src/%.c=obj/debug/%.o)
|
|
@$(call MKDIR,$(@D))
|
|
$(CC) -shared -o $@ $^ $(LDFLAGS_PLAT)
|
|
|
|
obj/debug/%.o: src/%.c
|
|
@$(call MKDIR,$(@D))
|
|
$(CC) $(CFLAGS_BASE) -g -O0 -MMD -MP -c $< -o $@
|
|
|
|
# Release Rules
|
|
$(BIN_DIR)/release/$(FULL_LIB): $(SRCS:src/%.c=obj/release/%.o)
|
|
@$(call MKDIR,$(@D))
|
|
$(CC) -shared $(RELEASE_LDFLAGS) -o $@ $^ $(LDFLAGS_PLAT)
|
|
|
|
obj/release/%.o: src/%.c
|
|
@$(call MKDIR,$(@D))
|
|
$(CC) $(CFLAGS_BASE) -O2 -MMD -MP -c $< -o $@
|
|
|
|
-include $(wildcard obj/debug/*.d)
|
|
-include $(wildcard obj/release/*.d)
|
|
|
|
clean:
|
|
@$(call RMDIR,$(OBJ_DIR))
|
|
@$(call RMDIR,$(BIN_DIR))
|
|
|
|
test: debug
|
|
@echo "=== Building and running stk tests ==="
|
|
@$(MAKE) -C test -f gmake.mk
|