Configuration: Simplify the way vms information is retrieved
[openssl.git] / Configurations / 10-main.conf
index a6efb5725a6350a791be44884f2e9b1e5e5a4f3a..8c6ee7f0e374144f8f27aa2046a8d4b58f0c20e5 100644 (file)
@@ -74,6 +74,35 @@ sub vc_wince_info {
     return $vc_wince_info;
 }
 
+# Helper functions for the VMS configs
+my $vms_info = {};
+sub vms_info {
+    unless (%$vms_info) {
+        my $pointer_size = shift;
+        my $pointer_size_str = $pointer_size == 0 ? "" : "$pointer_size";
+
+        $vms_info->{disable_warns} = [ ];
+        if ($pointer_size == 64) {
+            `PIPE CC /NOCROSS_REFERENCE /NOLIST /NOOBJECT /WARNINGS = DISABLE = ( MAYLOSEDATA3, EMPTYFILE ) NL: 2> NL:`;
+            if ($? == 0) {
+                push @{$vms_info->{disable_warns}}, "MAYLOSEDATA3";
+            }
+        }
+
+        unless ($disabled{zlib}) {
+            my $default_zlib = 'GNV$LIBZSHR' . $pointer_size_str;
+            if (defined($disabled{"zlib-dynamic"})) {
+                $vms_info->{zlib} = $withargs{zlib_lib} || "$default_zlib/SHARE";
+            } else {
+                $vms_info->{def_zlib} = $withargs{zlib_lib} || $default_zlib;
+                # In case the --with-zlib-lib value contains something like
+                # /SHARE or /LIB or so at the end, remove it.
+                $vms_info->{def_zlib} =~ s|/.*$||g;
+            }
+        }
+    }
+    return $vms_info;
+}
 
 %targets = (
 
@@ -96,7 +125,7 @@ sub vc_wince_info {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
         cflags           => picker(default => "-Wall -DOPENSSL_SYS_VOS -D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN",
-                                   debug   => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG",
+                                   debug   => "-O0 -g",
                                    release => "-O3"),
         thread_scheme    => "(unknown)",
         sys_id           => "VOS",
@@ -206,8 +235,7 @@ sub vc_wince_info {
         # -m32 should be safe to add as long as driver recognizes
         # -mcpu=ultrasparc
         inherit_from     => [ "solaris-sparcv7-gcc", asm("sparcv9_asm") ],
-        cflags           => add_before(picker(default => "-m32 -mcpu=ultrasparc",
-                                              debug   => "-DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -O -g -pedantic -ansi -Wshadow -Wno-long-long -D__EXTENSIONS__")),
+        cflags           => add_before("-m32 -mcpu=ultrasparc"),
     },
     "solaris64-sparcv9-gcc" => {
         inherit_from     => [ "solaris-sparcv9-gcc" ],
@@ -225,7 +253,7 @@ sub vc_wince_info {
         inherit_from     => [ "solaris-common" ],
         cc               => "cc",
         cflags           => add_before(picker(default => "-xstrconst -Xa -DB_ENDIAN -DBN_DIV2W",
-                                              debug   => "-g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG",
+                                              debug   => "-g",
                                               release => "-xO5 -xdepend"),
                                        threads("-D_REENTRANT")),
         lflags           => add(threads("-mt")),
@@ -586,7 +614,7 @@ sub vc_wince_info {
         inherit_from     => [ "BASE_unix" ],
         cc               => "gcc",
         cflags           => combine(picker(default => "-Wall",
-                                           debug   => "-O0 -g -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG",
+                                           debug   => "-O0 -g",
                                            release => "-O3"),
                                     threads("-pthread")),
         ex_libs          => add("-ldl"),
@@ -1224,13 +1252,10 @@ sub vc_wince_info {
         coutflag         => "/Fo",
         rc               => "rc",
         rcoutflag        => "/fo",
-        lib_cflags       => sub { join(" ",
-                                       ($disabled{shared} ? "/Zl" : ()),
-                                       "/Zi /Fdlib") },
+        lib_cflags       => add("/Zi /Fdlib"),
         dso_cflags       => "/Zi",
         bin_cflags       => "/Zi /Fdapp",
         lflags           => add("/debug"),
-        shared_cflag     => "-D_WINDLL",
         shared_ldflag    => "/dll",
         shared_target    => "win-shared", # meaningless except it gives Configure a hint
         thread_scheme    => "winthreads",
@@ -1241,14 +1266,29 @@ sub vc_wince_info {
         cflags           => add(picker(default => "-DUNICODE -D_UNICODE",
                                        debug   =>
                                        sub {
-                                           ($disabled{shared} ? "/MT" : "/MD")
-                                               ."d /Od -DDEBUG -D_DEBUG";
+                                           ($disabled{shared} ? "" : "/MDd")
+                                               ." /Od -DDEBUG -D_DEBUG";
                                        },
                                        release =>
                                        sub {
-                                           ($disabled{shared} ? "/MT" : "/MD")
+                                           ($disabled{shared} ? "" : "/MD")
                                                ." /Ox /O2 /Ob2";
                                        })),
+        lib_cflags       => add(sub { $disabled{shared} ? "/MT /Zl" : () }),
+        # Following might/should appears controversial, i.e. defining
+        # /MDd without evaluating $disabled{shared}. It works in
+        # non-shared build because static library is compiled with /Zl
+        # and bares no reference to specific RTL. And it works in
+        # shared build because multiple /MDd options are not prohibited.
+        # But why /MDd in static build? Well, basically this is just a
+        # reference point, which allows to catch eventual errors that
+        # would prevent those who want to wrap OpenSSL into own .DLL.
+        # Why not /MD in release build then? Well, some are likely to
+        # prefer [non-debug] openssl.exe to be free from Micorosoft RTL
+        # redistributable.
+        bin_cflags       => add(picker(debug   => "/MDd",
+                                       release => sub { $disabled{shared} ? "/MT" : () },
+                                      )),
         bin_lflags       => add("/subsystem:console /opt:ref"),
         ex_libs          => sub {
             my @ex_libs = ();
@@ -1274,8 +1314,10 @@ sub vc_wince_info {
         asflags          => "-d debug",
         asoutflag        => "-o",
         sys_id           => "WIN64I",
-        bn_asm_src       => sub { my $r=join(" ",@_); $r=~s|bn-ia64.s|bn_asm.c|; $r; },
+        bn_asm_src       => sub { return undef unless @_;
+                                  my $r=join(" ",@_); $r=~s|bn-ia64.s|bn_asm.c|; $r; },
         perlasm_scheme   => "ias",
+        multilib         => "-ia64",
     },
     "VC-WIN64A" => {
         inherit_from     => [ "VC-WIN64-common", asm("x86_64_asm"),
@@ -1287,12 +1329,13 @@ sub vc_wince_info {
         bn_asm_src       => sub { return undef unless @_;
                                   my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; },
         perlasm_scheme   => "auto",
+        multilib         => "-x64",
     },
     "VC-WIN32" => {
         # x86 Win32 target defaults to ANSI API, if you want UNICODE,
         # configure with 'perl Configure VC-WIN32 -DUNICODE -D_UNICODE'
         inherit_from     => [ "VC-noCE-common", asm("x86_asm"),
-                              sub { $disabled{shared} ? () : "x86_uplink" } ],
+                              sub { $disabled{shared} ? () : "uplink_common" } ],
         as               => sub { my $ver=`nasm -v 2>NUL`;
                                   my $vew=`nasmw -v 2>NUL`;
                                   return $ver ge $vew ? "nasm" : "nasmw" },
@@ -1626,7 +1669,7 @@ sub vc_wince_info {
     "vxworks-ppc750-debug" => {
         inherit_from     => [ "BASE_unix" ],
         cc               => "ccppc",
-        cflags           => "-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DBN_DEBUG -DREF_DEBUG -DCONF_DEBUG -DBN_CTX_DEBUG -DPEDANTIC -DDEBUG_SAFESTACK -DDEBUG -g",
+        cflags           => "-ansi -nostdinc -DPPC750 -D_REENTRANT -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -DCPU=PPC604 -I\$(WIND_BASE)/target/h -DPEDANTIC -DDEBUG -g",
         sys_id           => "VXWORKS",
         lflags           => "-r",
     },
@@ -1703,6 +1746,7 @@ sub vc_wince_info {
                                    debug   => "/DEBUG/TRACEBACK",
                                    release => "/NODEBUG/NOTRACEBACK"),
         shared_target    => "vms-shared",
+        dso_scheme       => "vms",
         thread_scheme    => "pthreads",
 
         apps_aux_src     => "vms_decc_init.c",
@@ -1722,37 +1766,101 @@ sub vc_wince_info {
     #},
     "vms-alpha" => {
         inherit_from     => [ "vms-generic" ],
+        cflags           => add(sub { my @warnings =
+                                          @{vms_info(0)->{disable_warns}};
+                                      @warnings
+                                          ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : (); }),
+        defines          =>
+                    add(sub {
+                            return vms_info(0)->{def_zlib}
+                                ? "LIBZ=\"\"\"".vms_info(0)->{def_zlib}."\"\"\"" : ();
+                            }),
+        ex_libs          => add(sub { return vms_info(0)->{zlib} || (); }),
         #as               => "???",
         #debug_aflags     => "/NOOPTIMIZE/DEBUG",
         #release_aflags   => "/OPTIMIZE/NODEBUG",
         bn_opts          => "SIXTY_FOUR_BIT RC4_INT RC4_CHUNK_LL DES_PTR BF_PTR",
     },
-    "vms-alpha-P32" => {
-       inherit_from     => [ "vms-alpha" ],
-       cflags           => add("/POINTER_SIZE=32"),
-       ex_libs          => sub { join(",", map { s|SHR([\./])|SHR32$1|g; $_ } @_) },
-    },
-    "vms-alpha-P64" => {
-       inherit_from     => [ "vms-alpha" ],
-       cflags           => add("/POINTER_SIZE=64"),
-       ex_libs          => sub { join(",", map { s|SHR([\./])|SHR64$1|g; $_ } @_) },
+    "vms-alpha-p32" => {
+        inherit_from     => [ "vms-generic" ],
+        cflags           =>
+            add("/POINTER_SIZE=32",
+                sub { my @warnings =
+                          @{vms_info(32)->{disable_warns}};
+                      @warnings
+                          ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : ();
+                } ),
+        defines          =>
+                    add(sub {
+                            return vms_info(32)->{def_zlib}
+                                ? "LIBZ=\"\"\"".vms_info(32)->{def_zlib}."\"\"\"" : ();
+                            }),
+        ex_libs          => add(sub { return vms_info(32)->{zlib} || (); }),
+    },
+    "vms-alpha-p64" => {
+        inherit_from     => [ "vms-generic" ],
+        cflags           =>
+            add("/POINTER_SIZE=64=ARGV",
+                sub { my @warnings =
+                          @{vms_info(64)->{disable_warns}};
+                      @warnings
+                          ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : ();
+                } ),
+        defines          =>
+                    add(sub {
+                            return vms_info(64)->{def_zlib}
+                                ? "LIBZ=\"\"\"".vms_info(64)->{def_zlib}."\"\"\"" : ();
+                            }),
+        ex_libs          => add(sub { return vms_info(64)->{zlib} || (); }),
     },
     "vms-ia64" => {
         inherit_from     => [ "vms-generic" ],
+        cflags           => add(sub { my @warnings =
+                                          @{vms_info(0)->{disable_warns}};
+                                      @warnings
+                                          ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : (); }),
+        defines          =>
+                    add(sub {
+                            return vms_info(0)->{def_zlib}
+                                ? "LIBZ=\"\"\"".vms_info(0)->{def_zlib}."\"\"\"" : ();
+                            }),
+        ex_libs          => add(sub { return vms_info(0)->{zlib} || (); }),
         #as               => "I4S",
         #debug_aflags     => "/NOOPTIMIZE/DEBUG",
         #release_aflags   => "/OPTIMIZE/NODEBUG",
         bn_opts          => "SIXTY_FOUR_BIT RC4_INT RC4_CHUNK_LL DES_PTR BF_PTR",
     },
-    "vms-ia64-P32" => {
-       inherit_from     => [ "vms-ia64" ],
-       cflags           => add("/POINTER_SIZE=32"),
-       ex_libs          => sub { join(",", map { s|SHR([\./])|SHR32$1|g; $_ } @_) },
-    },
-    "vms-ia64-P64" => {
-       inherit_from     => [ "vms-ia64" ],
-       cflags           => add("/POINTER_SIZE=64"),
-       ex_libs          => sub { join(",", map { s|SHR([\./])|SHR64$1|g; $_ } @_) },
+    "vms-ia64-p32" => {
+        inherit_from     => [ "vms-generic" ],
+        cflags           =>
+            add("/POINTER_SIZE=32",
+                sub { my @warnings =
+                          @{vms_info(32)->{disable_warns}};
+                      @warnings
+                          ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : ();
+                } ),
+        defines          =>
+                    add(sub {
+                            return vms_info(32)->{def_zlib}
+                                ? "LIBZ=\"\"\"".vms_info(32)->{def_zlib}."\"\"\"" : ();
+                            }),
+        ex_libs          => add(sub { return vms_info(32)->{zlib} || (); }),
+    },
+    "vms-ia64-p64" => {
+        inherit_from     => [ "vms-generic" ],
+        cflags           =>
+            add("/POINTER_SIZE=64=ARGV",
+                sub { my @warnings =
+                          @{vms_info(64)->{disable_warns}};
+                      @warnings
+                          ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : ();
+                } ),
+        defines          =>
+                    add(sub {
+                            return vms_info(64)->{def_zlib}
+                                ? "LIBZ=\"\"\"".vms_info(64)->{def_zlib}."\"\"\"" : ();
+                            }),
+        ex_libs          => add(sub { return vms_info(64)->{zlib} || (); }),
     },
 
 );