11@ echo off
22REM Helper script to install latest stdlib in the local MinGW installation
33
4+ setlocal
5+
46set ORIG = %cd%
57set ROOT = %~dp0 ..
68
9+ set GCCVER = 11.2.0
10+ set PREFIX = %ROOT% \mingw64
11+ set INCLUDE_PATH = lib\gcc\x86_64-w64-mingw32\%GCCVER% \finclude\
12+
713echo Installation root is %ROOT%
814
915cd %ROOT%
1016
1117if NOT EXIST %ROOT% \mingw64 echo mingw64 installation not found && exit /b 1
1218
1319if NOT EXIST %ROOT% \stdlib git clone https://github.com/fortran-lang/stdlib.git
20+ if %errorlevel% neq 0 exit /b %errorlevel%
1421
1522cd stdlib
1623git reset --hard
@@ -20,8 +27,31 @@ git pull
2027echo [install] >> fpm.toml
2128echo library = true >> fpm.toml
2229
23- fpm install --profile release --prefix %cd% \..\mingw64 --includedir lib\gcc\x86_64-w64-mingw32\10.3.0\finclude --verbose --flag " -DWITH_QP=1"
30+ REM Check output directory exists
31+ if not exist " %PREFIX% \%INCLUDE_PATH% " (
32+ echo setup-stdlib error: Cannot find module include directory " %PREFIX% \%INCLUDE_PATH% "
33+ exit /B 3
34+ )
35+
36+ fpm install --profile release --prefix %PREFIX% --includedir %INCLUDE_PATH% --verbose --flag " -DWITH_QP=1"
37+ if %errorlevel% neq 0 exit /b %errorlevel%
38+
39+ del /Q %PREFIX% \%INCLUDE_PATH% \test*.mod
40+
41+ REM Check installation
42+ set LIB_OUT = " %PREFIX% \lib\libstdlib.a"
43+ if not exist %LIB_OUT% (
44+ echo Installation failed: cannot find %LIB_OUT%
45+ exit /B 2
46+ )
47+ set INC_OUT = " %PREFIX% \%INCLUDE_PATH% \stdlib_version.mod"
48+ if not exist %INC_OUT% (
49+ echo Installation failed: cannot find %INC_OUT%
50+ exit /B 2
51+ )
52+
53+ echo stdlib built and installed successfully
2454
25- del /Q %ROOT% \mingw64\lib\gcc\x86_64-w64-mingw32\10.3.0\finclude\test*.mod
55+ cd %ORIG%
2656
27- cd %ORIG%
57+ endlocal
0 commit comments