In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/ca30c090c37b4fcb6ced9e51748937223401d2f7?hp=9f42613cff9529b84706745e7fee949fab7b9613>

- Log -----------------------------------------------------------------
commit ca30c090c37b4fcb6ced9e51748937223401d2f7
Author: Daniel Dragan <bul...@hotmail.com>
Date:   Sun Aug 14 04:34:37 2016 -0400

    automatically detect GCC vs VC and set VC ver number on Win32
    
    This fixes a bug, if you use gmake, without a GCC in PATH (but you do have
    a VC in PATH) GNUMakefile is unusable because target info fatally errors.
    I usually keep a strawberry perl's /c/bin dir in PATH for dmake and gmake
    on my VC builds, but in 1 build config, I installed gmake to my C:/Windows
    dir and did not have SP's /c/bin dir in my PATH, so GNUMakefile was broken
    in that case. This patch fixes the bug.
    
    -move the gcc -dumpversion shell outs to the GCC only section in both mkfs
     dont run gcc -dumpversion on a VC build
    -dont have a default CCTYPE anymore, autodetect it, if user supplies CCTYPE
     explicitly on cmd line to make tool, then dont do autodetection (its
     faster by 50-100ms to manually specify CCTYPE not call gcc.exe and cl.exe
     with the auto detect code), "FREE" detection is unimplemented but seems
     to make no difference with VC except for an old rare "free" VC 2003
     I personally use a paid VC 2003.
    -silence console messages and warnings from a missing gcc.exe causing
     "gcc -dumpmachine" to warn or fatally error, gmake doesn't care about
     exit code, dmake does
    -on dmake, use := instead of *= or =, otherwise the long for loop shell
     line runs dozens of times (multiple eval problem)
    -on dmake, since GCCBIN macro doesn't exist and dmake mfk is "simpler"
     than gmake just call gcc.exe always and not a prefixed version of GCC for
     the GCCTARGET macro, it isn't used outside the autodetection code anyways
     and if a user neglected to specify CCTYPE it is assumed they neglected to
     specify GCCCROSS too
-----------------------------------------------------------------------

Summary of changes:
 win32/GNUmakefile | 36 ++++++++++++++++++++++++++++++------
 win32/makefile.mk | 16 +++++++++++++++-
 2 files changed, 45 insertions(+), 7 deletions(-)

diff --git a/win32/GNUmakefile b/win32/GNUmakefile
index 76fb57f..d4d4818 100644
--- a/win32/GNUmakefile
+++ b/win32/GNUmakefile
@@ -36,10 +36,6 @@ ifeq ($(GCCBIN),i686-w64-mingw32-gcc)
 GCCCROSS := i686-w64-mingw32
 endif
 
-GCCTARGET := $(shell $(GCCBIN) -dumpmachine)
-GCCVER1   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc 
-dumpversion') do echo %%i)
-GCCVER2   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc 
-dumpversion') do echo %%j)
-GCCVER3   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc 
-dumpversion') do echo %%k)
 
 ##
 ## Build configuration.  Edit the values below to suit your needs.
@@ -178,7 +174,7 @@ USE_LARGE_FILES     := define
 # Visual C++ 2013 Express Edition (aka Visual C++ 12.0) (free version)
 #CCTYPE                := MSVC120FREE
 # MinGW or mingw-w64 with gcc-3.4.5 or later
-CCTYPE         := GCC
+#CCTYPE                := GCC
 
 #
 # If you are using Intel C++ Compiler uncomment this
@@ -355,6 +351,27 @@ BUILDOPT   += -DWIN32_NO_REGISTRY
 endif
 
 ifeq ($(CCTYPE),GCC)
+GCCTARGET      := $(shell $(GCCBIN) -dumpmachine)
+endif
+
+#no explicit CCTYPE given, do auto detection
+ifeq ($(CCTYPE),)
+GCCTARGET      := $(shell $(GCCBIN) -dumpmachine 2>NUL)
+#do we have a GCC?
+ifneq ($(GCCTARGET),)
+CCTYPE         := GCC
+else
+#use var to capture 1st line only, not 8th token of lines 2 & 3 in cl.exe 
output
+#rmving the cmd /c causes the var2b undef4echo but!4"set MSVCVER", cmd.exe bug?
+MSVCVER                := $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ 
" \
+       %%i in ('cl ^2^>^&1') do if not defined MSVCVER set /A "MSVCVER=%%i-6") 
\
+       & cmd /c echo %%MSVCVER%%)
+CCTYPE         := MSVC$(MSVCVER)0
+endif
+endif
+
+
+ifeq ($(CCTYPE),GCC)
 ifeq ($(GCCTARGET),x86_64-w64-mingw32)
 WIN64 := define
 PROCESSOR_ARCHITECTURE := x64
@@ -483,6 +500,10 @@ BUILDOPT        += -D__USE_MINGW_ANSI_STDIO
 MINIBUILDOPT    += -D__USE_MINGW_ANSI_STDIO
 endif
 
+GCCVER1   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc 
-dumpversion') do echo %%i)
+GCCVER2   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc 
-dumpversion') do echo %%j)
+GCCVER3   := $(shell for /f "delims=. tokens=1,2,3" %%i in ('gcc 
-dumpversion') do echo %%k)
+
 # If you are using GCC, 4.3 or later by default we add the -fwrapv option.
 # See https://rt.perl.org/Ticket/Display.html?id=121505
 #
@@ -1083,15 +1104,18 @@ CFG_VARS        =                                       
\
 all : info rebasePE Extensions_nonxs $(PERLSTATIC)
 
 info :
+       @echo # CCTYPE=$(CCTYPE)
+ifeq ($(CCTYPE),GCC)
        @echo # GCCBIN=$(GCCBIN)
        @echo # GCCVER=$(GCCVER1).$(GCCVER2).$(GCCVER3)
        @echo # GCCTARGET=$(GCCTARGET)
        @echo # GCCCROSS=$(GCCCROSS)
+endif
        @echo # WIN64=$(WIN64)
        @echo # ARCHITECTURE=$(ARCHITECTURE)
        @echo # ARCHNAME=$(ARCHNAME)
        @echo # MAKE=$(PLMAKE)
-ifeq ($(GCCTARGET),)
+ifeq ($(CCTYPE),)
        @echo Unable to detect gcc and/or architecture!
        @exit 1
 endif
diff --git a/win32/makefile.mk b/win32/makefile.mk
index 391112b..478da43 100644
--- a/win32/makefile.mk
+++ b/win32/makefile.mk
@@ -146,7 +146,7 @@ USE_LARGE_FILES     *= define
 # Visual C++ 2013 Express Edition (aka Visual C++ 12.0) (free version)
 #CCTYPE                = MSVC120FREE
 # MinGW or mingw-w64 with gcc-3.4.5 or later
-CCTYPE         *= GCC
+#CCTYPE                = GCC
 
 #
 # If you are using GCC, 4.3 or later by default we add the -fwrapv option.
@@ -355,6 +355,20 @@ BUILDOPT   += -DPERL_IMPLICIT_SYS
 BUILDOPT       += -DWIN32_NO_REGISTRY
 .ENDIF
 
+#no explicit CCTYPE given, do auto detection
+.IF "$(CCTYPE)" == ""
+GCCTARGET      *= $(shell gcc -dumpmachine 2>NUL & exit /b 0)
+#do we have a GCC?
+.IF "$(GCCTARGET)" != ""
+CCTYPE         = GCC
+else
+#use var to capture 1st line only, not 8th token of lines 2 & 3 in cl.exe 
output
+MSVCVER                := $(shell (set MSVCVER=) & (for /f "tokens=8 delims=.^ 
" \
+       %i in ('cl ^2^>^&1') do @if not defined MSVCVER set /A "MSVCVER=%i-6"))
+CCTYPE         := MSVC$(MSVCVER)0
+endif
+endif
+
 PROCESSOR_ARCHITECTURE *= x86
 
 .IF "$(WIN64)" == "undef"

--
Perl5 Master Repository

Reply via email to