# engines/src/fortran/Makefile # 编译 DLL 到 engines/release/(主程序通过 ctypes 直接调用) FC = gfortran FFLAGS = -O3 -march=native -Wall -Wextra LIB_SRC = dynamics_lib.f90 UNAME_S := $(shell uname -s 2>/dev/null || echo Windows) # 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/ DLL_DIR = ../../release ifeq ($(UNAME_S),Linux) DLL_TARGET = $(DLL_DIR)/dynamics_f90.so DLL_FLAGS = -shared -fPIC 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 -static endif .PHONY: all dll clean all: dll dll: $(DLL_TARGET) $(DLL_TARGET): $(LIB_SRC) | $(DLL_DIR) $(FC) $(FFLAGS) $(DLL_FLAGS) -o $@ $(LIB_SRC) @echo " === Fortran DLL built: $@ ===" $(DLL_DIR): mkdir -p $(DLL_DIR) clean: rm -f $(DLL_TARGET)