[Bug #20524] win32: Try to configure GMP if available

This commit is contained in:
Nobuyoshi Nakada 2024-06-05 17:11:10 +09:00
parent f8abd24b1f
commit 065190a973
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
3 changed files with 30 additions and 8 deletions

View File

@ -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)

View File

@ -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

View File

@ -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) <<conftest.c -link $(XLDFLAGS) gmp.lib > nul && (echo USE_GMP = yes) || (echo USE_GMP = no)) >>$(MAKEFILE)
#include <gmp.h>
mpz_t x;
int main(void) {mpz_init(x); return 0;}
<<
@$(WIN32DIR:/=\)\rm.bat conftest.*
!endif
-osname-section-: