fix: Makefile Windows 检测兼容 Msys2/MINGW 环境
uname -s 在 Msys2 上返回 MINGW64_NT-* 而非 Windows, 添加 findstring 匹配确保静态链接选项生效
This commit is contained in:
@@ -7,10 +7,14 @@ LIB_SRC = dynamics_lib.f90
|
||||
|
||||
UNAME_S := $(shell uname -s 2>/dev/null || echo Windows)
|
||||
|
||||
ifeq ($(UNAME_S),Windows)
|
||||
STATIC_FLAGS = -static
|
||||
else
|
||||
STATIC_FLAGS =
|
||||
# Windows 检测:Msys2/MINGW 也视为 Windows
|
||||
IS_WINDOWS := $(findstring MINGW,$(UNAME_S))
|
||||
ifneq ($(IS_WINDOWS),)
|
||||
UNAME_S := Windows
|
||||
endif
|
||||
IS_WINDOWS := $(findstring MSYS,$(UNAME_S))
|
||||
ifneq ($(IS_WINDOWS),)
|
||||
UNAME_S := Windows
|
||||
endif
|
||||
|
||||
# DLL 输出到 engines/release/
|
||||
@@ -23,8 +27,9 @@ else ifeq ($(UNAME_S),Darwin)
|
||||
DLL_TARGET = $(DLL_DIR)/dynamics_f90.dylib
|
||||
DLL_FLAGS = -dynamiclib
|
||||
else
|
||||
# Windows: 完全静态链接,避免依赖 libgfortran-5.dll
|
||||
DLL_TARGET = $(DLL_DIR)/dynamics_f90.dll
|
||||
DLL_FLAGS = -shared -fPIC
|
||||
DLL_FLAGS = -shared -fPIC -static
|
||||
endif
|
||||
|
||||
.PHONY: all dll clean
|
||||
@@ -34,7 +39,7 @@ all: dll
|
||||
dll: $(DLL_TARGET)
|
||||
|
||||
$(DLL_TARGET): $(LIB_SRC) | $(DLL_DIR)
|
||||
$(FC) $(FFLAGS) $(STATIC_FLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC)
|
||||
$(FC) $(FFLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC)
|
||||
@echo " === Fortran DLL built: $@ ==="
|
||||
|
||||
$(DLL_DIR):
|
||||
|
||||
Reference in New Issue
Block a user