1REM Download and install Perl
2setlocal
3echo on
4if %1 == "" goto help
5set PERL_VERSION=5.31.10
6set INST_DRV=c:
7set INST_TOP=c:\perl-msvc
8rd /q /s %INST_TOP%
9curl https://www.cpan.org/src/5.0/perl-%PERL_VERSION%.tar.gz -o perl-%PERL_VERSION%.tar.gz
10if %errorlevel% neq 0 goto build_error
11tar xzf perl-%PERL_VERSION%.tar.gz
12if %errorlevel% neq 0 goto build_error
13cd perl-%PERL_VERSION%\win32
14if %errorlevel% neq 0 goto build_error
15(echo CCTYPE=%1 && echo INST_DRV=%INST_DRV% && echo INST_TOP=%INST_TOP% && type Makefile | findstr /r /v "^CCTYPE" | findstr /r /v "^INST_DRV" | findstr /r /v "^INST_TOP") > Makefile2
16if %errorlevel% neq 0 goto build_error
17del Makefile
18if %errorlevel% neq 0 goto build_error
19ren Makefile2 Makefile
20if %errorlevel% neq 0 goto build_error
21findstr /r "^CCTYPE" Makefile
22findstr /r "^INST_DRV" Makefile
23findstr /r "^INST_TOP" Makefile
24@rem For mt.exe
25@rem dir /b /s "C:\Program Files (x86)" | findstr /i /e "\mt.exe"
26set "PATH=%PATH%;C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64"
27nmake "BUILDOPTEXTRA=/wd4244 /wd4267"
28if %errorlevel% neq 0 goto build_error
29nmake install
30if %errorlevel% neq 0 goto build_error
31set PATH=%INST_TOP%\bin;%PATH%
32where perl
33perl -v
34cd ..\..
35set INST_DRV=
36set INST_TOP=
37goto done
38
39:build_error
40endlocal
41set e=%errorlevel%
42exit /b %e%
43
44:help
45endlocal
46echo "Compiler type argument has not been specified"
47exit /b 1
48
49:done
50endlocal
51