From 065190a973c9534b93e3ff99b789bcc945032dfd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 5 Jun 2024 17:11:10 +0900 Subject: [PATCH] [Bug #20524] win32: Try to configure GMP if available --- win32/Makefile.sub | 12 ++++++------ win32/configure.bat | 11 +++++++++++ win32/setup.mak | 15 +++++++++++++-- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/win32/Makefile.sub b/win32/Makefile.sub index b125bf5555..55a489aaf4 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -297,9 +297,7 @@ CXXFLAGS = $(CFLAGS) !if !defined(LDFLAGS) LDFLAGS = -incremental:no -debug -opt:ref -opt:icf !endif -!if !defined(XLDFLAGS) -XLDFLAGS = -stack:$(STACK) -!endif +XLDFLAGS = -stack:$(STACK) $(XLDFLAGS) !if !defined(RFLAGS) RFLAGS = -r !endif @@ -1147,7 +1145,8 @@ miniruby: miniruby$(EXEEXT) miniruby$(EXEEXT): @echo $(LIBS) $(ECHO) linking $(@:\=/) - $(Q) $(PURIFY) $(CC) $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(LIBS) -Fe$@ -link $(LDFLAGS) + $(Q) $(PURIFY) $(CC) $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(LIBS) \ + $(OUTFLAG)$@ -link $(LDFLAGS) $(XLDFLAGS) @$(RM) miniruby.lib miniruby.exp $(Q) miniruby.exe -v $(Q) $(LDSHARED_1) @@ -1217,7 +1216,8 @@ $(LIBRUBY_SO): $(LIBRUBY_A) $(DLDOBJS) $(RUBYDEF) $(RUBY_SO_NAME).res !endif $(ECHO) linking shared-library $(@:\=/) $(Q) $(LDSHARED) $(DLDOBJS) $(LIBRUBY_A) \ - $(RUBY_SO_NAME).res $(SOLIBS) $(EXTSOLIBS) $(LIBS) -Fe$@ -link $(LDFLAGS) \ + $(RUBY_SO_NAME).res $(SOLIBS) $(EXTSOLIBS) $(LIBS) \ + $(OUTFLAG)$@ -link $(LDFLAGS) $(XLDFLAGS) \ $(LIBRUBY_DLDFLAGS) @$(RM) dummy.lib dummy.exp !if defined(LDSHARED_0) @@ -1430,7 +1430,7 @@ rubyspec-capiext: $(RUBYSPEC_CAPIEXT_EXTS) $(Q)$(MAKEDIRS) $(@D) $(Q)echo> $*.def EXPORTS $(Q)echo>> $*.def Init_$(*F) - $(Q)$(LDSHARED) -Fe$(@) $(INCFLAGS) $(CFLAGS) $(CPPFLAGS) $< $(LIBRUBYARG) -link $(DLDFLAGS) $(LIBS) $(LOCAL_LIBS) -implib:$*.lib -pdb:$*.pdb -def:$*.def + $(Q)$(LDSHARED) -Fe$(@) $(INCFLAGS) $(CFLAGS) $(CPPFLAGS) $< $(LIBRUBYARG) -link $(DLDFLAGS) $(XLDFLAGS) $(LIBS) $(LOCAL_LIBS) -implib:$*.lib -pdb:$*.pdb -def:$*.def !if defined(LDSHARED_0) $(Q)$(LDSHARED_0) $(Q)$(LDSHARED_1) diff --git a/win32/configure.bat b/win32/configure.bat index 7253ade28b..dd1a917adc 100755 --- a/win32/configure.bat +++ b/win32/configure.bat @@ -7,6 +7,9 @@ for %%I in (%0) do if /%%~dpI/ == /%CD%\/ ( exit /b 999 ) +set XINCFLAGS= +set XLDFLAGS= + echo> ~tmp~.mak #### echo>> ~tmp~.mak conf = %0 echo>> ~tmp~.mak $(conf): nul @@ -48,7 +51,9 @@ if "%1" == "--with-git" goto :git if "%1" == "--without-git" goto :nogit if "%1" == "--without-ext" goto :witharg if "%1" == "--without-extensions" goto :witharg +if "%1" == "--with-opt-dir" goto :opt-dir if "%1" == "--with-gmp" goto :gmp +if "%1" == "--with-gmp-dir" goto :gmp-dir if "%opt:~0,10%" == "--without-" goto :withoutarg if "%opt:~0,7%" == "--with-" goto :witharg if "%1" == "-h" goto :help @@ -217,6 +222,10 @@ goto :loop ; shift shift goto :loop ; +:gmp-dir +:opt-dir + set XINCFLAGS=%XINCFLAGS% -I%2/include + set XLDFLAGS=%XLDFLAGS% -libpath:%2/lib :witharg echo>>confargs.tmp %1=%2\ set witharg=1 @@ -263,6 +272,8 @@ cl -EP confargs.c > ~setup~.mak 2>nul if exist pathlist.tmp echo>>~setup~.mak PATH = $(pathlist:;=/bin;)$(PATH) if exist pathlist.tmp echo>>~setup~.mak INCLUDE = $(pathlist:;=/include;) if exist pathlist.tmp echo>>~setup~.mak LIB = $(pathlist:;=/lib;) +echo>>~setup~.mak XINCFLAGS = %XINCFLAGS% +echo>>~setup~.mak XLDFLAGS = %XLDFLAGS% type>>~setup~.mak ~tmp~.mak del *.tmp > nul del ~tmp~.mak > nul diff --git a/win32/setup.mak b/win32/setup.mak index 8c27994821..632e6cad53 100644 --- a/win32/setup.mak +++ b/win32/setup.mak @@ -62,6 +62,12 @@ ENABLE_DEBUG_ENV = $(ENABLE_DEBUG_ENV) !if defined(RJIT_SUPPORT) RJIT_SUPPORT = $(RJIT_SUPPORT) !endif +!if defined(XINCFLAGS) +CPPFLAGS = $(XINCFLAGS) +!endif +!if defined(XLDFLAGS) +XLDFLAGS = $(XLDFLAGS) +!endif # TOOLS << @@ -79,8 +85,13 @@ RJIT_SUPPORT = $(RJIT_SUPPORT) @echo HAVE_GIT = $(HAVE_GIT)>> $(MAKEFILE) !endif -!if "$(WITH_GMP)" == "yes" - @echo>>$(MAKEFILE) USE_GMP = 1 +!if "$(WITH_GMP)" != "no" + @($(CC) $(XINCFLAGS) < nul && (echo USE_GMP = yes) || (echo USE_GMP = no)) >>$(MAKEFILE) +#include +mpz_t x; +int main(void) {mpz_init(x); return 0;} +<< + @$(WIN32DIR:/=\)\rm.bat conftest.* !endif -osname-section-: