diff --git a/test/gmake.mk b/test/gmake.mk index 6411b27..cb9c5a2 100644 --- a/test/gmake.mk +++ b/test/gmake.mk @@ -2,42 +2,46 @@ CC := cc CFLAGS = -Wall -Wpedantic -I../include -std=c89 LDFLAGS = -L../bin/debug -lstk -UNAME_S := $(shell uname -s) - ifeq ($(OS),Windows_NT) MODULE_EXT = .dll + EXE_EXT = .exe else - LDFLAGS += -Wl,-rpath,../bin/debug MODULE_EXT = .so + EXE_EXT = + LDFLAGS += -Wl,-rpath,../bin/debug endif .PHONY: all test clean all: test -test_program: test.c - $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) +test_program$(EXE_EXT): test.c + $(CC) $(CFLAGS) -o $@ test.c $(LDFLAGS) test_mod$(MODULE_EXT): test_mod.c - $(CC) $(CFLAGS) -fPIC -shared -o $@ $< + $(CC) $(CFLAGS) -fPIC -shared -o $@ test_mod.c setup: +ifeq ($(OS),Windows_NT) + @if not exist mods mkdir mods + @if exist test_mod.dll copy /Y test_mod.dll mods\ >nul 2>&1 +else @mkdir -p mods - @cp -f test_mod$(MODULE_EXT) mods/ 2>/dev/null || true - @echo " Test environment ready: mods/ directory with test_mod$(MODULE_EXT)" + @cp -f test_mod.so mods/ 2>/dev/null || true +endif -run: test_program test_mod$(MODULE_EXT) setup - @echo "Running integration test (CTRL+C to exit)..." +test: test_program$(EXE_EXT) test_mod$(MODULE_EXT) setup +ifeq ($(OS),Windows_NT) + @set PATH=../bin/debug;%PATH% && cmd /C "test_program.exe" +else @./test_program - -test: test_program test_mod$(MODULE_EXT) setup - @echo "=== stk Integration Test ===" - @echo "1. Starting test program" - @echo "2. Will load test_mod$(MODULE_EXT) from mods/" - @echo "3. Press CTRL+C to exit" - @echo "=============================" - @./test_program || echo "Test completed." +endif clean: - rm -f test_program test_mod$(MODULE_EXT) - rm -rf mods/ +ifeq ($(OS),Windows_NT) + @del /Q test_program.exe test_mod.dll 2>nul || true + @rmdir /S /Q mods 2>nul || true +else + @rm -f test_program test_mod.so + @rm -rf mods +endif