Win32: configure without an intermediate makefile

This batch file used `nmake` on the old `command.com` to extract the
parent directory name of this file and to get around the command line
argument length limit.  However, Windows 9X support as a build host
ended over a decade ago, and this file now utilizes the functionality
of `cmd.exe` already.
This commit is contained in:
Nobuyoshi Nakada 2026-01-08 19:40:56 +09:00
parent e89db8567c
commit b61e18d76b
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2026-01-09 03:57:40 +00:00
2 changed files with 20 additions and 20 deletions

View File

@ -3,15 +3,24 @@
set PROMPT=$E[94m+$E[m$S
set witharg=
for %%I in (%0) do if /%%~dpI/ == /%CD%\/ (
if "%~dp0" == "%CD%\" (
echo don't run in win32 directory.
exit /b 999
) else if "%0" == "%~nx0" (
set "WIN32DIR=%~$PATH:0"
) else if "%0" == "%~n0" (
set "WIN32DIR=%~$PATH:0"
) else (
set "WIN32DIR=%0"
)
set "WIN32DIR=%WIN32DIR:\=/%:/:"
call set "WIN32DIR=%%WIN32DIR:%~x0:/:=:/:%%"
call set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%"
set "WIN32DIR=%WIN32DIR:~0,-3%"
set XINCFLAGS=
set XLDFLAGS=
set conf=%0
set pathlist=
set config_make=confargs~%RANDOM%.mak
set confargs=%config_make:.mak=.c%
@ -305,19 +314,8 @@ goto :exit
) >> %config_make%
del %confargs% > nul
set setup_make=%config_make:confargs=setup%
(
echo #### -*- makefile -*-
echo conf = %conf%
echo $^(conf^): nul
echo @del %setup_make%
echo @$^(MAKE^) -l$^(MAKEFLAGS^) -f $^(@D^)/setup.mak \
echo WIN32DIR=$^(@D:\=/^) config_make=%config_make%
echo -@move /y Makefile Makefile.old ^> nul 2^> nul
echo @ren Makefile.new Makefile
) > %setup_make%
nmake -alf %setup_make% MAKEFILE=Makefile.new
exit /b %ERRORLEVEL%
nmake -al -f %WIN32DIR%/setup.mak "WIN32DIR=%WIN32DIR%" ^
config_make=%config_make% ^
MAKEFILE=Makefile.new MAKEFILE_BACK=Makefile.old MAKEFILE_NEW=Makefile
:exit
@endlocal

View File

@ -40,7 +40,7 @@ x64-mswin64: -prologue- -x64- -epilogue-
-generic-: -osname-
-basic-vars-: nul
@type << > $(MAKEFILE)
@rem <<$(MAKEFILE)
### Makefile for ruby $(TARGET_OS) ###
MAKE = nmake
srcdir = $(srcdir:\=/)
@ -146,8 +146,8 @@ main(void)
<<
@( \
$(CC) -O2 $@.c && .\$@ || \
set bug=%ERRORLEVEL% \
echo This compiler has an optimization bug \
(set bug=%ERRORLEVEL% & \
echo This compiler has an optimization bug) \
) & $(WIN32DIR:/=\)\rm.bat $@.* & exit /b %bug%
-version-: nul verconf.mk
@ -272,4 +272,6 @@ AS = $(AS) -nologo
$(BANG)include $$(srcdir)/win32/Makefile.sub
<<
@$(COMSPEC) /C $(srcdir:/=\)\win32\rm.bat config.h config.status
-@move /y $(MAKEFILE_NEW) $(MAKEFILE_BACK) > nul 2> nul
@ren $(MAKEFILE) $(MAKEFILE_NEW)
@echo type 'nmake' to make ruby.