This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add USE_CPLUSPLUS build option to win32 makefiles
authorSteve Hay <steve.m.hay@googlemail.com>
Thu, 22 Jan 2015 13:47:42 +0000 (13:47 +0000)
committerSteve Hay <steve.m.hay@googlemail.com>
Tue, 27 Jan 2015 08:37:29 +0000 (08:37 +0000)
With thanks to Craig A. Berry and Daniel Dragan for finding the d_cplusplus
and extern_C options, respectively.

win32/Makefile
win32/config_sh.PL
win32/makefile.mk

index 71481b5..8076ce6 100644 (file)
@@ -133,6 +133,11 @@ CCTYPE             = MSVC60
 #__ICC         = define
 
 #
+# Uncomment this if you want to build everything in C++ mode
+#
+#USE_CPLUSPLUS = define
+
+#
 # uncomment next line if you want debug version of perl (big,slow)
 # If not enabled, we automatically try to use maximum optimization
 # with all compilers that are known to have a working optimizer.
@@ -505,6 +510,9 @@ EXTRACFLAGS = -nologo -GF -W3
 !IF "$(__ICC)" == "define"
 EXTRACFLAGS    = $(EXTRACFLAGS) -Qstd=c99
 !ENDIF
+!IF "$(USE_CPLUSPLUS)" == "define"
+EXTRACFLAGS    = $(EXTRACFLAGS) $(CXX_FLAG)
+!ENDIF
 CFLAGS         = $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) \
                $(PCHFLAGS) $(OPTIMIZE)
 LINK_FLAGS     = -nologo -nodefaultlib $(LINK_DBG) \
@@ -791,6 +799,7 @@ CFG_VARS    =                                       \
                "cc=$(CC)"                              \
                "ld=$(LINK32)"                          \
                "ccflags=$(EXTRACFLAGS) $(OPTIMIZE:"=\") $(DEFINES) $(BUILDOPT)"        \
+               "usecplusplus=$(USE_CPLUSPLUS)"         \
                "cf_email=$(EMAIL)"                     \
                "d_mymalloc=$(PERL_MALLOC)"             \
                "libs=$(LIBFILES)"                      \
@@ -879,6 +888,7 @@ config.w32 : $(CFGSH_TMPL)
        @echo #undef UVXf>>$@
        @echo #undef USE_64_BIT_INT>>$@
        @echo #undef Size_t_size>>$@
+       @echo #undef USE_CPLUSPLUS>>$@
 !IF "$(USE_LARGE_FILES)"=="define"
        @echo #define Off_t __int64>>$@
        @echo #define LSEEKSIZE ^8>>$@
@@ -930,6 +940,11 @@ config.w32 : $(CFGSH_TMPL)
        @echo #define UVXf "lX">>$@
        @echo #undef USE_64_BIT_INT>>$@
 !ENDIF
+!IF "$(USE_CPLUSPLUS)"=="define"
+       @echo #define USE_CPLUSPLUS>>$@
+!ELSE
+       @echo #undef USE_CPLUSPLUS>>$@
+!ENDIF
        @echo #endif>>$@
 
 ..\git_version.h : $(MINIPERL) ..\make_patchnum.pl
index 60fb4ed..98255a8 100644 (file)
@@ -286,6 +286,11 @@ if ($opt{useithreads} eq 'define' && $opt{ccflags} =~ /-DPERL_IMPLICIT_SYS\b/) {
     $opt{d_pseudofork} = 'define';
 }
 
+if ($opt{usecplusplus} eq 'define') {
+    $opt{d_cplusplus} = 'define';
+    $opt{extern_C} = 'extern "C"';
+}
+
 #if the fields above are defined, they override the defaults in the premade
 #config file
 while (<>) {
index 5ca5caa..f275a8e 100644 (file)
@@ -153,6 +153,11 @@ CCTYPE             *= GCC
 #__ICC         *= define
 
 #
+# Uncomment this if you want to build everything in C++ mode
+#
+#USE_CPLUSPLUS *= define
+
+#
 # uncomment next line if you want debug version of perl (big,slow)
 # If not enabled, we automatically try to use maximum optimization
 # with all compilers that are known to have a working optimizer.
@@ -481,6 +486,9 @@ LINK_DBG    = -s
 .ENDIF
 
 EXTRACFLAGS    =
+.IF "$(USE_CPLUSPLUS)" == "define"
+EXTRACFLAGS    += $(CXX_FLAG)
+.ENDIF
 CFLAGS         = $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) $(OPTIMIZE)
 LINK_FLAGS     = $(LINK_DBG) -L"$(INST_COREDIR)" -L"$(CCLIBDIR)"
 OBJOUT_FLAG    = -o
@@ -612,7 +620,10 @@ LIBFILES   = $(LIBBASEFILES) $(LIBC)
 
 EXTRACFLAGS    = -nologo -GF -W3
 .IF "$(__ICC)" == "define"
-EXTRACFLAGS    = $(EXTRACFLAGS) -Qstd=c99
+EXTRACFLAGS    += -Qstd=c99
+.ENDIF
+.IF "$(USE_CPLUSPLUS)" == "define"
+EXTRACFLAGS    += $(CXX_FLAG)
 .ENDIF
 CFLAGS         = $(EXTRACFLAGS) $(INCLUDES) $(DEFINES) $(LOCDEFS) \
                $(PCHFLAGS) $(OPTIMIZE)
@@ -937,6 +948,7 @@ CFG_VARS    =                                       \
                cc=$(CC)                        ~       \
                ld=$(LINK32)                    ~       \
                ccflags=$(EXTRACFLAGS) $(OPTIMIZE) $(DEFINES) $(BUILDOPT)       ~       \
+               usecplusplus=$(USE_CPLUSPLUS)   ~       \
                cf_email=$(EMAIL)               ~       \
                d_mymalloc=$(PERL_MALLOC)       ~       \
                libs=$(LIBFILES:f)              ~       \
@@ -1062,6 +1074,7 @@ config.w32 : $(CFGSH_TMPL)
        @echo #undef NVff>>$@
        @echo #undef NVgf>>$@
        @echo #undef USE_LONG_DOUBLE>>$@
+       @echo #undef USE_CPLUSPLUS>>$@
 .IF "$(USE_LARGE_FILES)"=="define"
        @echo #define Off_t $(INT64)>>$@
        @echo #define LSEEKSIZE ^8>>$@
@@ -1164,6 +1177,11 @@ config.w32 : $(CFGSH_TMPL)
        @echo #define NVgf "g">>$@
        @echo #undef USE_LONG_DOUBLE>>$@
 .ENDIF
+.IF "$(USE_CPLUSPLUS)"=="define"
+       @echo #define USE_CPLUSPLUS>>$@
+.ELSE
+       @echo #undef USE_CPLUSPLUS>>$@
+.ENDIF
        @echo #endif>>$@
 
 ..\git_version.h : $(MINIPERL) ..\make_patchnum.pl