Have all relevant config targets use the env() function rather than $ENV
authorRichard Levitte <levitte@openssl.org>
Wed, 29 Nov 2017 16:41:10 +0000 (17:41 +0100)
committerRichard Levitte <levitte@openssl.org>
Thu, 7 Dec 2017 23:36:21 +0000 (00:36 +0100)
This way, any of the relevant environment variables for the platform
being configured are preserved and don't have to be recalled manually
when reconfiguring.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4818)

Configurations/10-main.conf

index f8f4bd194c5506279ff84d673341be315c8ee96c..28cfd30021d83b8e5f442c1cb60841e8555c98d4 100644 (file)
@@ -53,14 +53,14 @@ my $vc_wince_info = {};
 sub vc_wince_info {
     unless (%$vc_wince_info) {
         # sanity check
-        $die->('%OSVERSION% is not defined') if (!defined($ENV{'OSVERSION'}));
-        $die->('%PLATFORM% is not defined')  if (!defined($ENV{'PLATFORM'}));
-        $die->('%TARGETCPU% is not defined') if (!defined($ENV{'TARGETCPU'}));
+        $die->('%OSVERSION% is not defined') if (!defined(env('OSVERSION')));
+        $die->('%PLATFORM% is not defined')  if (!defined(env('PLATFORM')));
+        $die->('%TARGETCPU% is not defined') if (!defined(env('TARGETCPU')));
 
         #
         # Idea behind this is to mimic flags set by eVC++ IDE...
         #
-        my $wcevers = $ENV{'OSVERSION'};                    # WCENNN
+        my $wcevers = env('OSVERSION');                     # WCENNN
        my $wcevernum;
        my $wceverdotnum;
        if ($wcevers =~ /^WCE([1-9])([0-9]{2})$/) {
@@ -74,12 +74,12 @@ sub vc_wince_info {
         my $wcecdefs = "-D_WIN32_WCE=$wcevernum -DUNDER_CE=$wcevernum"; # -D_WIN32_WCE=NNN
         my $wcelflag = "/subsystem:windowsce,$wceverdotnum";        # ...,N.NN
 
-        my $wceplatf =  $ENV{'PLATFORM'};
+        my $wceplatf =  env('PLATFORM');
 
         $wceplatf =~ tr/a-z0-9 /A-Z0-9_/;
         $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
 
-        my $wcetgt = $ENV{'TARGETCPU'};                     # just shorter name...
+        my $wcetgt = env('TARGETCPU');                      # just shorter name...
       SWITCH: for($wcetgt) {
           /^X86/        && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
                                 $wcelflag.=" /machine:X86";     last; };
@@ -1407,9 +1407,9 @@ sub vms_info {
             picker(default =>
                    combine('/W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYS_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT',
                            sub { vc_wince_info()->{cflags}; },
-                           sub { defined($ENV{'WCECOMPAT'})
+                           sub { defined(env('WCECOMPAT'))
                                      ? '-I$(WCECOMPAT)/include' : (); },
-                           sub { defined($ENV{'PORTSDK_LIBPATH'})
+                           sub { defined(env('PORTSDK_LIBPATH'))
                                      ? '-I$(PORTSDK_LIBPATH)/../../include' : (); },
                            sub { `cl 2>&1` =~ /Version ([0-9]+)\./ && $1>=14
                                      ? ($disabled{shared} ? " /MT" : " /MD")
@@ -1418,7 +1418,7 @@ sub vms_info {
                    release => "/O1i"),
         lflags           => combine("/nologo /opt:ref",
                                     sub { vc_wince_info()->{lflags}; },
-                                    sub { defined($ENV{PORTSDK_LIBPATH})
+                                    sub { defined(env('PORTSDK_LIBPATH'))
                                               ? "/entry:mainCRTstartup" : (); }),
         sys_id           => "WINCE",
         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
@@ -1426,9 +1426,9 @@ sub vms_info {
             my @ex_libs = ();
             push @ex_libs, 'ws2.lib' unless $disabled{sock};
             push @ex_libs, 'crypt32.lib';
-            if (defined($ENV{WCECOMPAT})) {
+            if (defined(env('WCECOMPAT'))) {
                 my $x = '$(WCECOMPAT)/lib';
-                if (-f "$x/$ENV{TARGETCPU}/wcecompatex.lib") {
+                if (-f "$x/env('TARGETCPU')/wcecompatex.lib") {
                     $x .= '/$(TARGETCPU)/wcecompatex.lib';
                 } else {
                     $x .= '/wcecompatex.lib';
@@ -1436,9 +1436,9 @@ sub vms_info {
                 push @ex_libs, $x;
             }
             push @ex_libs, '$(PORTSDK_LIBPATH)/portlib.lib'
-                if (defined($ENV{'PORTSDK_LIBPATH'}));
+                if (defined(env('PORTSDK_LIBPATH')));
             push @ex_libs, ' /nodefaultlib coredll.lib corelibc.lib'
-                if ($ENV{'TARGETCPU'} eq "X86");
+                if (env('TARGETCPU') eq "X86");
             return @ex_libs;
         }),
         build_scheme     => add("VC-WCE", { separator => undef }),
@@ -1738,35 +1738,35 @@ sub vms_info {
 #### uClinux
     "uClinux-dist" => {
         inherit_from     => [ "BASE_unix" ],
-        cc               => "$ENV{'CC'}",
+        cc               => sub { env('CC') },
         cflags           => combine("\$(CFLAGS)",
                                     threads("-D_REENTRANT")),
         plib_lflags      => "\$(LDFLAGS)",
         ex_libs          => add("\$(LDLIBS)"),
         bn_ops           => "BN_LLONG",
         thread_scheme    => "pthreads",
-        dso_scheme       => "$ENV{'LIBSSL_dlfcn'}",
+        dso_scheme       => sub { env('LIBSSL_dlfcn') },
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
         shared_ldflag    => "-shared",
         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
-        ranlib           => "$ENV{'RANLIB'}",
+        ranlib           => sub { env('RANLIB') },
     },
     "uClinux-dist64" => {
         inherit_from     => [ "BASE_unix" ],
-        cc               => "$ENV{'CC'}",
+        cc               => sub { env('CC') },
         cflags           => combine("\$(CFLAGS)",
                                     threads("-D_REENTRANT")),
         plib_lflags      => "\$(LDFLAGS)",
         ex_libs          => add("\$(LDLIBS)"),
         bn_ops           => "SIXTY_FOUR_BIT_LONG",
         thread_scheme    => "pthreads",
-        dso_scheme       => "$ENV{'LIBSSL_dlfcn'}",
+        dso_scheme       => sub { env('LIBSSL_dlfcn') },
         shared_target    => "linux-shared",
         shared_cflag     => "-fPIC",
         shared_ldflag    => "-shared",
         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
-        ranlib           => "$ENV{'RANLIB'}",
+        ranlib           => sub { env('RANLIB') },
     },
 
     ##### VMS