fix: support MSYS2 builds on gmake
uname -s under MSYS2 never reports Windows_NT, so build.sh picked bmake.mk and gmake.mk's platform branches silently fell through to the Linux path (.so + -ldl), breaking the link. Detect MINGW/MSYS/ UCRT/CLANG uname prefixes in build.sh and route to gmake.mk; export UNAME_S once so make doesn't call uname again. gmake.mk, test/gmake.mk, and module_template/gmake.mk now derive Windows-vs-Unix from uname instead of $(OS), with the cmd.exe/batch command path reserved for environments without a POSIX shell (MSYS2 keeps mkdir -p/rm -rf).
This commit is contained in:
1 parent
270808e602
commit
b860b0d607
8 files changed
+100
-37
No files matched your search
+32
-15
@@ -2,9 +2,21 @@ CC := cc
|
||||
CFLAGS = -Wall -Wpedantic -I../include -std=c89
|
||||
LDFLAGS = -L../bin/debug -lstk
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
SHELL := cmd.exe
|
||||
.SHELLFLAGS := /c
|
||||
ifeq ($(UNAME_S),)
|
||||
UNAME_S := $(shell uname -s)
|
||||
endif
|
||||
ifneq (,$(filter MINGW% MSYS% UCRT% CLANG% CYGWIN%,$(UNAME_S)))
|
||||
IS_WINDOWS := 1
|
||||
IS_POSIX_SHELL := 1
|
||||
else ifeq ($(OS),Windows_NT)
|
||||
IS_WINDOWS := 1
|
||||
IS_POSIX_SHELL :=
|
||||
else
|
||||
IS_WINDOWS :=
|
||||
IS_POSIX_SHELL := 1
|
||||
endif
|
||||
|
||||
ifeq ($(IS_WINDOWS),1)
|
||||
MODULE_EXT = .dll
|
||||
EXE_EXT = .exe
|
||||
else
|
||||
@@ -13,6 +25,11 @@ else
|
||||
LDFLAGS += -Wl,-rpath,../bin/debug
|
||||
endif
|
||||
|
||||
ifneq ($(IS_POSIX_SHELL),1)
|
||||
SHELL := cmd.exe
|
||||
.SHELLFLAGS := /c
|
||||
endif
|
||||
|
||||
.PHONY: all test clean
|
||||
|
||||
all: test
|
||||
@@ -27,28 +44,28 @@ test_mod_dep$(MODULE_EXT): test_mod_dep.c
|
||||
$(CC) $(CFLAGS) -fPIC -shared -o $@ test_mod_dep.c
|
||||
|
||||
setup:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
ifeq ($(IS_POSIX_SHELL),1)
|
||||
@mkdir -p mods
|
||||
@cp -f test_mod$(MODULE_EXT) mods/ 2>/dev/null || true
|
||||
@cp -f test_mod_dep$(MODULE_EXT) mods/ 2>/dev/null || true
|
||||
else
|
||||
@if not exist mods mkdir mods
|
||||
@if exist test_mod.dll copy /Y test_mod.dll mods\ >nul 2>&1
|
||||
@if exist test_mod_dep.dll copy /Y test_mod_dep.dll mods\ >nul 2>&1
|
||||
else
|
||||
@mkdir -p mods
|
||||
@cp -f test_mod.so mods/ 2>/dev/null || true
|
||||
@cp -f test_mod_dep.so mods/ 2>/dev/null || true
|
||||
endif
|
||||
|
||||
test: test_program$(EXE_EXT) test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT) setup
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@set PATH=../bin/debug;%PATH% && cmd /C "test_program.exe"
|
||||
ifeq ($(IS_POSIX_SHELL),1)
|
||||
@./test_program$(EXE_EXT)
|
||||
else
|
||||
@./test_program
|
||||
@set PATH=../bin/debug;%PATH% && cmd /C "test_program.exe"
|
||||
endif
|
||||
|
||||
clean:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
ifeq ($(IS_POSIX_SHELL),1)
|
||||
@rm -f test_program$(EXE_EXT) test_mod$(MODULE_EXT) test_mod_dep$(MODULE_EXT)
|
||||
@rm -rf mods
|
||||
else
|
||||
@del /Q test_program.exe test_mod.dll test_mod_dep.dll 2>nul || true
|
||||
@rmdir /S /Q mods 2>nul || true
|
||||
else
|
||||
@rm -f test_program test_mod.so test_mod_dep.so
|
||||
@rm -rf mods
|
||||
endif
|
||||
Reference in new issue
Block a user