[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Wed Oct 12 14:40:19 UTC 2016


The branch master has been updated
       via  16b42d4d35af2f8439bcce2f374bd47365850162 (commit)
       via  7763472fe8fe42a1c830fcc9d35ca11fd9e6fcab (commit)
       via  ea241958501b65d2fc70ecc1642bd1af70a0db9d (commit)
      from  6dcba070a94b1ead92f3e327cf207a0b7db6596f (commit)


- Log -----------------------------------------------------------------
commit 16b42d4d35af2f8439bcce2f374bd47365850162
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Oct 12 15:33:13 2016 +0200

    Add C++ settings in the Linux config targets
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

commit 7763472fe8fe42a1c830fcc9d35ca11fd9e6fcab
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Oct 12 15:30:43 2016 +0200

    Add support for C++ in Configurations/unix-Makefile.tmpl
    
    Note that it relies on a trick from Configure, where file names for
    object files made from C++ source get '.cc' replaced with '_cc.o' to
    recognise them.  This is needed so the correct compiler is used when
    linking binaries.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

commit ea241958501b65d2fc70ecc1642bd1af70a0db9d
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Oct 12 15:30:08 2016 +0200

    Add support for C++ in Configure
    
    A note: this will form object file names by changing '.cc' to
    '_cc.o'.  This will permit other configuration code to recognise these
    object files were built for C++ rather than C.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 Configurations/10-main.conf       |  1 +
 Configurations/README             | 12 ++++++++++--
 Configurations/unix-Makefile.tmpl | 35 ++++++++++++++++++++++++++++-------
 Configure                         | 30 +++++++++++++++++++++++-------
 4 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
index fc673a1..f5c7899 100644
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -622,6 +622,7 @@ sub vms_info {
     "linux-generic32" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
+        cxx              => "g++",
         cflags           => combine(picker(default => "-Wall",
                                            debug   => "-O0 -g",
                                            release => "-O3"),
diff --git a/Configurations/README b/Configurations/README
index da64e8c..0b82ded 100644
--- a/Configurations/README
+++ b/Configurations/README
@@ -17,12 +17,20 @@ In each table entry, the following keys are significant:
         sys_id          => System identity for systems where that
                            is difficult to determine automatically.
 
-        cc              => The compiler command, usually one of "cc",
+        cc              => The C compiler command, usually one of "cc",
                            "gcc" or "clang".  This command is normally
                            also used to link object files and
                            libraries into the final program.
+        cxx             => The C++ compiler command, usually one of
+                           "c++", "g++" or "clang++".  This command is
+                           also used when linking a program where at
+                           least one of the object file is made from
+                           C++ source.
         cflags          => Flags that are used at all times when
-                           compiling.
+                           compiling C object files.
+        cxxflags        => Flags that are used at all times when
+                           compiling C++ object files.  If unset, it
+                           gets the same value as cflags.
         defines         => As an alternative, macro definitions may be
                            present here instead of in `cflags'.  If
                            given here, they MUST be as an array of the
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index b610b58..7f6caea 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -169,10 +169,13 @@ CROSS_COMPILE= {- $config{cross_compile_prefix} -}
 CC= $(CROSS_COMPILE){- $target{cc} -}
 CFLAGS={- our $cflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cflags} -} {- $config{cflags} -}
 CFLAGS_Q={- $cflags2 =~ s|([\\"])|\\$1|g; $cflags2 -} {- $config{cflags} -}
+CXX= $(CROSS_COMPILE){- $target{cxx} -}
+CXXFLAGS={- our $cxxflags2 = join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}}),"-DOPENSSLDIR=\"\\\"\$(OPENSSLDIR)\\\"\"","-DENGINESDIR=\"\\\"\$(ENGINESDIR)\\\"\"") -} {- $target{cxxflags} -} {- $config{cxxflags} -}
 LDFLAGS= {- $target{lflags} -}
 PLIB_LDFLAGS= {- $target{plib_lflags} -}
 EX_LIBS= {- $target{ex_libs} -} {- $config{ex_libs} -}
 LIB_CFLAGS={- $target{shared_cflag} || "" -}
+LIB_CXXFLAGS={- $target{shared_cxxflag} || "" -}
 LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag}
                # Unlike other OSes (like Solaris, Linux, Tru64,
                # IRIX) BSD run-time linkers (tested OpenBSD, NetBSD
@@ -188,8 +191,10 @@ LIB_LDFLAGS={- $target{shared_ldflag}." ".$config{shared_ldflag}
                . ($config{target} =~ m|^BSD-| && $prefix !~ m|^/usr/.*$|
                   ? " -Wl,-rpath,\$\$(LIBRPATH)" : "") -}
 DSO_CFLAGS={- $target{shared_cflag} || "" -}
+DSO_CXXFLAGS={- $target{shared_cxxflag} || "" -}
 DSO_LDFLAGS=$(LIB_LDFLAGS)
 BIN_CFLAGS={- $target{bin_cflags} -}
+BIN_CXXFLAGS={- $target{bin_cxxflag} || "" -}
 
 PERL={- $config{perl} -}
 
@@ -944,16 +949,26 @@ EOF
               $incs .= " -I".$withargs{zlib_include};
           }
       }
-      my $ecflags = { lib => '$(LIB_CFLAGS)',
-                      dso => '$(DSO_CFLAGS)',
-                      bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
+      my $cc = '$(CC)';
+      my $cflags = '$(CFLAGS)';
+      if (grep /\.(cc|cpp)$/, @srcs) {
+          $cc = '$(CXX)';
+          $cflags = '$(CXXFLAGS)';
+          $cflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
+                             dso => '$(DSO_CXXFLAGS)',
+                             bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
+      } else {
+          $cflags .= ' ' . { lib => '$(LIB_CFLAGS)',
+                             dso => '$(DSO_CFLAGS)',
+                             bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
+      }
       my $makedepprog = $config{makedepprog};
       my $recipe = <<"EOF";
 $obj$objext: $deps
 EOF
       if (!$disabled{makedepend} && $makedepprog !~ /\/makedepend/) {
           $recipe .= <<"EOF";
-	\$(CC) $incs \$(CFLAGS) $ecflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
+	$cc $incs $cflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
 	\@touch $obj$depext.tmp
 	\@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
 		rm -f $obj$depext.tmp; \\
@@ -963,11 +978,11 @@ EOF
 EOF
       } else {
           $recipe .= <<"EOF";
-	\$(CC) $incs \$(CFLAGS) $ecflags -c -o \$\@ $srcs
+	$cc $incs $cflags -c -o \$\@ $srcs
 EOF
           if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
               $recipe .= <<"EOF";
-	-\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs \$(CFLAGS) $ecflags -- $srcs \\
+	-\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cflags -- $srcs \\
 	    >$obj$depext.tmp 2>/dev/null
 	-\$(PERL) -i -pe 's/^.*\\|//; s/ \\/(\\\\.|[^ ])*//; \$\$_ = undef if (/: *\$\$/ || /^(#.*| *)\$\$/); \$\$_.="\\n" unless !defined(\$\$_) or /\\R\$\$/g;' $obj$depext.tmp
 	\@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
@@ -1078,6 +1093,12 @@ EOF
                                     (my $l = $f) =~ s/^lib//;
                                     " -L$d -l$l" } @{$args{deps}});
       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
+      my $cc = '$(CC)';
+      my $cflags = '$(CFLAGS) $(BIN_CFLAGS)';
+      if (grep /_cc$/, @{$args{objs}}) {
+          $cc = '$(CXX)';
+          $cflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
+      }
       return <<"EOF";
 $bin$exeext: $objs $deps
 	\$(RM) $bin$exeext
@@ -1085,7 +1106,7 @@ $bin$exeext: $objs $deps
 		PERL="\$(PERL)" SRCDIR=\$(SRCDIR) \\
 		APPNAME=$bin$exeext OBJECTS="$objs" \\
 		LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
-		CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(BIN_CFLAGS)' \\
+		CC='$cc' CFLAGS='$cflags' \\
 		LDFLAGS='\$(LDFLAGS)' LIBRPATH='\$(INSTALLTOP)/\$(LIBDIR)' \\
 		link_app.$shlib_target
 EOF
diff --git a/Configure b/Configure
index bfb9dbf..024b93f 100755
--- a/Configure
+++ b/Configure
@@ -222,6 +222,8 @@ if (grep /^reconf(igure)?$/, @argvcopy) {
 	    if defined($configdata::config{cross_compile_prefix});
 	$ENV{CC} = $configdata::config{cc}
 	    if defined($configdata::config{cc});
+	$ENV{CXX} = $configdata::config{cxx}
+	    if defined($configdata::config{cxx});
 	$ENV{BUILDFILE} = $configdata::config{build_file}
 	    if defined($configdata::config{build_file});
 	$ENV{$local_config_envname} = $configdata::config{local_config_dir}
@@ -231,6 +233,7 @@ if (grep /^reconf(igure)?$/, @argvcopy) {
 	print "    CROSS_COMPILE = ",$ENV{CROSS_COMPILE},"\n"
 	    if $ENV{CROSS_COMPILE};
 	print "    CC = ",$ENV{CC},"\n" if $ENV{CC};
+	print "    CXX = ",$ENV{CXX},"\n" if $ENV{CXX};
 	print "    BUILDFILE = ",$ENV{BUILDFILE},"\n" if $ENV{BUILDFILE};
 	print "    $local_config_envname = ",$ENV{$local_config_envname},"\n"
 	    if $ENV{$local_config_envname};
@@ -927,6 +930,7 @@ my %conf_files = map { $_ => 1 } (@{$target{_conf_fname_int}});
 $config{conf_files} = [ sort keys %conf_files ];
 %target = ( %{$table{DEFAULTS}}, %target );
 
+$target{cxxflags}=$target{cflags} unless defined $target{cxxflags};
 $target{exe_extension}="";
 $target{exe_extension}=".exe" if ($config{target} eq "DJGPP"
                                   || $config{target} =~ /^(?:Cygwin|mingw)/);
@@ -962,6 +966,7 @@ $target{build_file} = $ENV{BUILDFILE} || $target{build_file} || "Makefile";
 
 # Cache information necessary for reconfiguration
 $config{cc} = $target{cc};
+$config{cxx} = $target{cxx};
 $config{build_file} = $target{build_file};
 
 # For cflags, lflags, plib_lflags, ex_libs and defines, add the debug_
@@ -969,6 +974,7 @@ $config{build_file} = $target{build_file};
 # Do it in such a way that no spurious space is appended (hence the grep).
 $config{defines} = [];
 $config{cflags} = "";
+$config{cxxflags} = "";
 $config{ex_libs} = "";
 $config{shared_ldflag} = "";
 
@@ -1747,9 +1753,11 @@ EOF
                 if (! -f $s) {
                     $s = cleanfile($buildd, $_, $blddir);
                 }
-                # We recognise C and asm files
-                if ($s =~ /\.[csS]\b$/) {
-                    (my $o = $_) =~ s/\.[csS]\b$/.o/;
+                # We recognise C++, C and asm files
+                if ($s =~ /\.(cc|cpp|c|s|S)$/) {
+                    my $o = $_;
+                    $o =~ s/\.[csS]$/.o/; # C and assembler
+                    $o =~ s/\.(cc|cpp)$/_cc.o/; # C++
                     $o = cleanfile($buildd, $o, $blddir);
                     $unified_info{sources}->{$ddest}->{$o} = 1;
                     $unified_info{sources}->{$o}->{$s} = 1;
@@ -1773,9 +1781,11 @@ EOF
                 if (! -f $s) {
                     $s = cleanfile($buildd, $_, $blddir);
                 }
-                # We recognise C and asm files
-                if ($s =~ /\.[csS]\b$/) {
-                    (my $o = $_) =~ s/\.[csS]\b$/.o/;
+                # We recognise C++, C and asm files
+                if ($s =~ /\.(cc|cpp|c|s|S)$/) {
+                    my $o = $_;
+                    $o =~ s/\.[csS]$/.o/; # C and assembler
+                    $o =~ s/\.(cc|cpp)$/_cc.o/; # C++
                     $o = cleanfile($buildd, $o, $blddir);
                     $unified_info{shared_sources}->{$ddest}->{$o} = 1;
                     $unified_info{sources}->{$o}->{$s} = 1;
@@ -1898,7 +1908,9 @@ EOF
 foreach (grep /_(asm|aux)_src$/, keys %target) {
     my $src = $_;
     (my $obj = $_) =~ s/_(asm|aux)_src$/_obj/;
-    ($target{$obj} = $target{$src}) =~ s/\.[csS]\b/.o/g;
+    $target{$obj} = $target{$src};
+    $target{$obj} =~ s/\.[csS]\b/.o/g; # C and assembler
+    $target{$obj} =~ s/\.(cc|cpp)\b/_cc.o/g; # C++
 }
 
 # Write down our configuration where it fits #########################
@@ -2033,6 +2045,10 @@ print "PERLVERSION   =$Config{version} for $Config{archname}\n";
 print "HASHBANGPERL  =$config{hashbangperl}\n";
 print "CC            =$config{cross_compile_prefix}$target{cc}\n";
 print "CFLAG         =$target{cflags} $config{cflags}\n";
+print "CXX           =$config{cross_compile_prefix}$target{cxx}\n"
+    if defined $target{cxx};
+print "CXXFLAG       =$target{cxxflags} $config{cxxflags}\n"
+    if defined $target{cxx};
 print "DEFINES       =",join(" ", @{$target{defines}}, @{$config{defines}}),"\n";
 #print "RANLIB        =", $target{ranlib} eq '$(CROSS_COMPILE)ranlib' ?
 #                             "$config{cross_compile_prefix}ranlib" :


More information about the openssl-commits mailing list