From: Richard Levitte Date: Wed, 12 Oct 2016 13:30:08 +0000 (+0200) Subject: Add support for C++ in Configure X-Git-Tag: OpenSSL_1_1_1-pre1~3388 X-Git-Url: https://git.openssl.org/?p=openssl.git;a=commitdiff_plain;h=ea241958501b65d2fc70ecc1642bd1af70a0db9d;ds=sidebyside 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 --- diff --git a/Configurations/README b/Configurations/README index da64e8c79b..0b82dedca9 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/Configure b/Configure index bfb9dbf4dc..024b93fb3a 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" :