Build file templates: Replace the use of Makefile.shared
authorRichard Levitte <levitte@openssl.org>
Mon, 4 Dec 2017 13:27:58 +0000 (14:27 +0100)
committerRichard Levitte <levitte@openssl.org>
Tue, 12 Dec 2017 16:18:07 +0000 (17:18 +0100)
Because this also includes handling all sorts of non-object files when
linking a program, shared library or DSO, this also includes allowing
general recognition of files such as .res files (compiled from .rc
files), or .def / .map / .opt files (for export and possibly
versioning of public symbols only).

This does mean that there's a tangible change for all build file
templates: they must now recognise and handle the `.o` extension,
which is used internally to recognise object files internally.  This
extension was removed by common.tmpl before this change, but would
mean that the platform specific templates wouldn't know if "foo.map"
was originally "foo.map.o" (i.e. an object file in its own right) or
"foo.map" (an export definition file that should be treated as such,
not as an object file).

For the sake of simplifying things, we also modify util/mkdef.pl to
produce .def (Windows) and .opt (VMS) files that don't need additional
hackery.

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

Configurations/common.tmpl
Configurations/descrip.mms.tmpl
Configurations/unix-Makefile.tmpl
Configurations/windows-makefile.tmpl
util/mkdef.pl

index a03beb657d0c87aaf99457b07717528bdc94ef84..79e1746d2dd4767a4d04265ebdb1a7e9e3a60f45 100644 (file)
  sub doobj {
      my $obj = shift;
      return "" if $cache{$obj};
-     (my $obj_no_o = $obj) =~ s|\.o$||;
      my $bin = shift;
      my %opts = @_;
      if (@{$unified_info{sources}->{$obj}}) {
-         $OUT .= src2obj(obj => $obj_no_o,
+         $OUT .= src2obj(obj => $obj,
                          product => $bin,
                          srcs => $unified_info{sources}->{$obj},
                          deps => $unified_info{depends}->{$obj},
              ? (ordinals => $unified_info{ordinals}->{$lib}) : ();
          $OUT .= libobj2shlib(shlib => $unified_info{sharednames}->{$lib},
                               lib => $lib,
-                              objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
-                                        (@{$unified_info{sources}->{$lib}},
-                                         @{$unified_info{shared_sources}->{$lib}}) ],
+                              objs => [ @{$unified_info{shared_sources}->{$lib}},
+                                        @{$unified_info{sources}->{$lib}} ],
                               deps => [ reducedepends(resolvedepends($lib)) ],
                               installed => is_installed($lib),
                               %ordinals);
-         foreach (@{$unified_info{shared_sources}->{$lib}}) {
-             doobj($_, $lib, intent => "lib", installed => is_installed($lib));
+         foreach ((@{$unified_info{shared_sources}->{$lib}},
+                   @{$unified_info{sources}->{$lib}})) {
+             # If this is somehow a compiled object, take care of it that way
+             # Otherwise, it might simply be generated
+             if (defined $unified_info{sources}->{$_}) {
+                 doobj($_, $lib, intent => "lib", installed => is_installed($lib));
+             } else {
+                 dogenerate($_, undef, undef, intent => "lib");
+             }
          }
      }
      $OUT .= obj2lib(lib => $lib,
-                     objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
-                               @{$unified_info{sources}->{$lib}} ]);
+                     objs => [ @{$unified_info{sources}->{$lib}} ]);
      foreach (@{$unified_info{sources}->{$lib}}) {
          doobj($_, $lib, intent => "lib", installed => is_installed($lib));
      }
      my $lib = shift;
      return "" if $cache{$lib};
      $OUT .= obj2dso(lib => $lib,
-                     objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
-                               (@{$unified_info{sources}->{$lib}},
-                                @{$unified_info{shared_sources}->{$lib}}) ],
+                     objs => [ @{$unified_info{sources}->{$lib}},
+                               @{$unified_info{shared_sources}->{$lib}} ],
                      deps => [ resolvedepends($lib) ],
                      installed => is_installed($lib));
      foreach ((@{$unified_info{sources}->{$lib}},
      return "" if $cache{$bin};
      my $deps = [ reducedepends(resolvedepends($bin)) ];
      $OUT .= obj2bin(bin => $bin,
-                     objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
-                               @{$unified_info{sources}->{$bin}} ],
+                     objs => [ @{$unified_info{sources}->{$bin}} ],
                      deps => $deps,
                      installed => is_installed($bin));
      foreach (@{$unified_info{sources}->{$bin}}) {
index cfa055b72d4eb96d3c95fa386a11f170e4b09d44..0a1ca6419cf5dc1b42ea04b41213109e6ee39948 100644 (file)
@@ -337,7 +337,7 @@ uninstall : uninstall_docs uninstall_sw
 # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly.
 libclean :
         {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
-        {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*,$_.OPT;*" } @shlibs) || "@ !" -}
+        {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
 
 clean : libclean
         {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
@@ -589,7 +589,7 @@ EOF
 
   sub src2obj {
       my %args = @_;
-      my $obj = $args{obj};
+      (my $obj = $args{obj}) =~ s|\.o$||;
       my $deps = join(", -\n\t\t", @{$args{srcs}}, @{$args{deps}});
 
       # Because VMS C isn't very good at combining a /INCLUDE path with
@@ -662,8 +662,10 @@ EOF
       my $libd = dirname($lib);
       my $libn = basename($lib);
       (my $mkdef_key = $libn) =~ s/^${osslprefix_q}lib([^0-9]*)\d*/$1/i;
+      my @defs = grep { $_ =~ /\.opt$/ } @{$args{objs}};
       my @deps = compute_lib_depends(@{$args{deps}});
-      my $deps = join(", -\n\t\t", @deps);
+      die "More than one symbol vector" if scalar @defs > 1;
+      my $deps = join(", -\n\t\t", @defs, @deps);
       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
       my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
       my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir},
@@ -672,6 +674,7 @@ EOF
       my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
                                              "util", "mkdef.pl")),
                              rel2abs($config{builddir}));
+      my $shared_def = join(",", map { "$_/OPT" } @defs);
       my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
                                                      "VMS", "translatesyms.pl")),
                                      rel2abs($config{builddir}));
@@ -686,19 +689,12 @@ EOF
                              "WRITE OPT_FILE \"$x\"" } @deps)
           || "\@ !";
       return <<"EOF"
-$shlib.EXE : $lib.OLB $deps $ordinalsfile
-        \$(PERL) $mkdef_pl "$mkdef_key" "VMS" > $shlib.SYMVEC-tmp
-        \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $shlib.SYMVEC-tmp > $shlib.SYMVEC
-        DELETE $shlib.SYMVEC-tmp;*
-        OPEN/WRITE/SHARE=READ OPT_FILE $shlib.OPT
-        WRITE OPT_FILE "IDENTIFICATION=""V$config{version}"""
-        TYPE $shlib.SYMVEC /OUTPUT=OPT_FILE:
-        WRITE OPT_FILE "$lib.OLB/LIBRARY"
-        $write_opt
-        CLOSE OPT_FILE
-        LINK \$(LDFLAGS)/SHARE=\$\@ $shlib.OPT/OPT \$(EX_LIBS)
-        DELETE $shlib.SYMVEC;*
-        PURGE $shlib.EXE,$shlib.OPT,$shlib.MAP
+$shlib.EXE : $lib.OLB $deps
+        \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
+        LINK \$(LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,$lib.OLB/LIBRARY
+             \$(EX_LIBS)
+        DELETE $defs[0]-translated;*
+        PURGE $shlib.EXE,$shlib.MAP
 EOF
         . ($config{target} =~ m|alpha| ? "" : <<"EOF"
         SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
@@ -711,7 +707,7 @@ EOF
       my $libd = dirname($lib);
       my $libn = basename($lib);
       (my $libn_nolib = $libn) =~ s/^lib//;
-      my @objs = map { "$_.OBJ" } @{$args{objs}};
+      my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
       my @deps = compute_lib_depends(@{$args{deps}});
       my $deps = join(", -\n\t\t", @objs, @deps);
       my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
@@ -750,9 +746,10 @@ EOF
   sub obj2lib {
       my %args = @_;
       (my $lib = $args{lib}) =~ s/\.a$//;
-      my $objs = join(", -\n\t\t", map { $_.".OBJ" } (@{$args{objs}}));
-      my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_.OBJ" }
-                                    @{$args{objs}}));
+      my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
+      my $objs = join(", -\n\t\t", @objs);
+      my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_" }
+                                   @objs));
       return <<"EOF";
 $lib.OLB : $objs
         LIBRARY/CREATE/OBJECT $lib.OLB
@@ -765,7 +762,7 @@ EOF
       my $bin = $args{bin};
       my $bind = dirname($bin);
       my $binn = basename($bin);
-      my @objs = map { "$_.OBJ" } @{$args{objs}};
+      my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
       my $objs = join(",", @objs);
       my @deps = compute_lib_depends(@{$args{deps}});
       my $deps = join(", -\n\t\t", @objs, @deps);
index 08ad527c2b2668041a5c1d01ace0f58df7c0a83f..7f8a322cc420f1556d339305509070eb5ff2d0ee 100644 (file)
@@ -869,7 +869,7 @@ EOF
   # last in the line.  We may therefore need to put back a line ending.
   sub src2obj {
       my %args = @_;
-      my $obj = $args{obj};
+      (my $obj = $args{obj}) =~ s|\.o$||;
       my @srcs = map { if ($unified_info{generate}->{$_}) {
                            (my $x = $_) =~ s/\.S$/.s/; $x
                        } else {
@@ -884,26 +884,30 @@ EOF
               $incs .= " -I".$withargs{zlib_include};
           }
       }
-      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}};
+      my $cmd = '$(CC)';
+      my $cmdflags = '$(CFLAGS) -c';
+      my $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
+      if (grep /\.rc$/, @srcs) {
+          $cmd = '$(RC)';
+          $cmdflags = '$(RCFLAGS)';
+          $makedepprog = undef;
+      } elsif (grep /\.(cc|cpp)$/, @srcs) {
+          $cmd = '$(CXX)';
+          $cmdflags = '$(CXXFLAGS) -c';
+          $cmdflags .= ' ' . { lib => '$(LIB_CXXFLAGS)',
+                               dso => '$(DSO_CXXFLAGS)',
+                               bin => '$(BIN_CXXFLAGS)' } -> {$args{intent}};
       } else {
-          $cflags .= ' ' . { lib => '$(LIB_CFLAGS)',
-                             dso => '$(DSO_CFLAGS)',
-                             bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
+          $cmdflags .= ' ' . { 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/) {
+      if (defined $makedepprog && $makedepprog !~ /\/makedepend/) {
           $recipe .= <<"EOF";
-       $cc $incs $cflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
+       $cmd $incs $cmdflags -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; \\
@@ -913,11 +917,11 @@ EOF
 EOF
       } else {
           $recipe .= <<"EOF";
-       $cc $incs $cflags -c -o \$\@ $srcs
+       $cmd $incs $cmdflags -o \$\@ $srcs
 EOF
-          if (!$disabled{makedepend} && $makedepprog =~ /\/makedepend/) {
+          if (defined $makedepprog  && $makedepprog =~ /\/makedepend/) {
               $recipe .= <<"EOF";
-       -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cflags -- $srcs \\
+       -\$(MAKEDEPEND) -f- -o"|\$\@" -- $incs $cmdflags -- $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 \\
@@ -944,71 +948,78 @@ EOF
                                     my $f = basename($_);
                                     (my $l = $f) =~ s/^lib//;
                                     " -L$d -l$l" } @{$args{deps}});
-      my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
-      my $shlib_target = $target{shared_target};
-      my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
+      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
+                 grep { $_ =~ m|\.o$| }
+                 @{$args{objs}};
+      my @defs = grep { $_ =~ /\.(def|map)$/ } @{$args{objs}};
+      my @deps = compute_lib_depends(@{$args{deps}});
+      die "More than one exported symbol map" if scalar @defs > 1;
+      my $objs = join(" ", @objs);
+      my $deps = join(" ", @objs, @defs, @deps);
       my $target = shlib_simple($lib);
       my $target_full = shlib($lib);
-      return <<"EOF"
-# With a build on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
+      my $shared_soname = "";
+      $shared_soname .= ' '.$target{shared_sonameflag}.basename($target_full)
+          if defined $target{shared_sonameflag};
+      my $shared_imp = "";
+      $shared_imp .= ' '.$target{shared_impflag}.basename($target)
+          if defined $target{shared_impflag};
+      my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
+      my $recipe = <<"EOF";
+# When building on a Windows POSIX layer (Cygwin or Mingw), we know for a fact
 # that two files get produced, {shlibname}.dll and {libname}.dll.a.
 # With all other Unix platforms, we often build a shared library with the
 # SO version built into the file name and a symlink without the SO version
 # It's not necessary to have both as targets.  The choice falls on the
 # simplest, {libname}\$(SHLIB_EXT_IMPORT) for Windows POSIX layers and
 # {libname}\$(SHLIB_EXT_SIMPLE) for the Unix platforms.
-$target: $lib$libext $deps $ordinalsfile
-       \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
-               ECHO=\$(ECHO) \\
-               PLATFORM=\$(PLATFORM) \\
-               PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$libd" \\
-               INSTALLTOP='\$(INSTALLTOP)' LIBDIR='\$(LIBDIR)' \\
-               LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
-               LIBNAME=$libname SHLIBVERSION=\$(SHLIB_VERSION_NUMBER) \\
-               STLIBNAME=$lib$libext \\
-               SHLIBNAME=$target SHLIBNAME_FULL=$target_full \\
-               CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(LIB_CFLAGS)' \\
-               LDFLAGS='\$(LDFLAGS)' SHARED_LDFLAGS='\$(LIB_LDFLAGS)' \\
-               RC='\$(RC)' SHARED_RCFLAGS='\$(RCFLAGS)' \\
-               link_shlib.$shlib_target
+$target: $deps
+       \$(CC) \$(CFLAGS) \$(LIB_CFLAGS) \$(LIB_LDFLAGS)$shared_soname$shared_imp \\
+               -o $target_full$shared_def $objs \\
+                \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
 EOF
-         . (windowsdll() ? <<"EOF" : "");
+      if (windowsdll()) {
+          $recipe .= <<"EOF";
        rm -f apps/$shlib'\$(SHLIB_EXT)'
        rm -f test/$shlib'\$(SHLIB_EXT)'
+       rm -f fuzz/$shlib'\$(SHLIB_EXT)'
        cp -p $shlib'\$(SHLIB_EXT)' apps/
        cp -p $shlib'\$(SHLIB_EXT)' test/
+       cp -p $shlib'\$(SHLIB_EXT)' fuzz/
 EOF
+      } else {
+          $recipe .= <<"EOF";
+       rm -f $target
+       ln -s $target_full $target
+EOF
+      }
   }
   sub obj2dso {
       my %args = @_;
       my $dso = $args{lib};
       my $dsod = dirname($dso);
       my $dson = basename($dso);
-      my $shlibdeps = join("", map { my $d = dirname($_);
-                                     my $f = basename($_);
-                                     (my $l = $f) =~ s/^lib//;
-                                     " -L$d -l$l" } @{$args{deps}});
-      my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
-      my $shlib_target = $target{shared_target};
-      my $objs = join(" ", map { $_.$objext } @{$args{objs}});
+      my $linklibs = join("", map { my $d = dirname($_);
+                                    my $f = basename($_);
+                                    (my $l = $f) =~ s/^lib//;
+                                    " -L$d -l$l" } @{$args{deps}});
+      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
+      my @deps = compute_lib_depends(@{$args{deps}});
+      my $objs = join(" ", @objs);
+      my $deps = join(" ", @deps);
       my $target = dso($dso);
       return <<"EOF";
 $target: $objs $deps
-       \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
-               PLATFORM=\$(PLATFORM) \\
-               PERL="\$(PERL)" SRCDIR='\$(SRCDIR)' DSTDIR="$dsod" \\
-               LIBDEPS='\$(PLIB_LDFLAGS) '"$shlibdeps"' \$(EX_LIBS)' \\
-               SHLIBNAME_FULL=$target LDFLAGS='\$(LDFLAGS)' \\
-               CC='\$(CC)' CFLAGS='\$(CFLAGS) \$(DSO_CFLAGS)' \\
-               SHARED_LDFLAGS='\$(DSO_LDFLAGS)' \\
-               LIBEXTRAS="$objs" \\
-               link_dso.$shlib_target
+       \$(CC) \$(CFLAGS) \$(DSO_CFLAGS) \$(DSO_LDFLAGS) \\
+               -o $target $objs \\
+                \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
 EOF
   }
   sub obj2lib {
       my %args = @_;
       (my $lib = $args{lib}) =~ s/\.a$//;
-      my $objs = join(" ", map { $_.$objext } @{$args{objs}});
+      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
+      my $objs = join(" ", @objs);
       return <<"EOF";
 $lib$libext: $objs
        \$(AR) \$\@ \$\?
@@ -1020,7 +1031,8 @@ EOF
       my $bin = $args{bin};
       my $bind = dirname($bin);
       my $binn = basename($bin);
-      my $objs = join(" ", map { $_.$objext } @{$args{objs}});
+      my $objs = join(" ", map { (my $x = $_) =~ s|\.o$|$objext|; $x }
+                           @{$args{objs}});
       my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
       my $linklibs = join("", map { if ($_ =~ /\.a$/) {
                                         " $_";
@@ -1032,23 +1044,17 @@ EOF
                                         " -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)';
+      my $cmd = '$(CC)';
+      my $cmdflags = '$(CFLAGS) $(BIN_CFLAGS)';
+      if (grep /_cc\.o$/, @{$args{objs}}) {
+          $cmd = '$(CXX)';
+          $cmdflags = '$(CXXFLAGS) $(BIN_CXXFLAGS)';
       }
       return <<"EOF";
 $bin$exeext: $objs $deps
-       \$(RM) $bin$exeext
-       \$(MAKE) -f \$(SRCDIR)/Makefile.shared -e \\
-               PERL="\$(PERL)" SRCDIR=\$(SRCDIR) \\
-               APPNAME=$bin$exeext OBJECTS="$objs" \\
-               LIBDEPS='\$(PLIB_LDFLAGS) '"$linklibs"' \$(EX_LIBS)' \\
-               CC='$cc' CFLAGS='$cflags' \\
-               LDFLAGS='\$(LDFLAGS)' \\
-               link_app.$shlib_target
+       rm -f $bin$exeext
+       $cmd $cmdflags \$(LDFLAGS) \$(BIN_LDFLAGS) -o $bin$exeext $objs \\
+               \$(PLIB_LDFLAGS) $linklibs \$(EX_LIBS)
 EOF
   }
   sub in2script {
index db79cd3ce1d09f74756d62c88b3bf9f9344555ae..ee534b39218b73ca428432b9c6418c1bdaceadd9 100644 (file)
@@ -4,6 +4,7 @@
 ## {- join("\n## ", @autowarntext) -}
 {-
  our $objext = $target{obj_extension} || ".obj";
+ our $resext = $target{res_extension} || ".res";
  our $depext = $target{dep_extension} || ".d";
  our $exeext = $target{exe_extension} || ".exe";
  our $libext = $target{lib_extension} || ".lib";
@@ -445,7 +446,6 @@ EOF
 
  sub src2obj {
      my %args = @_;
-     my $obj = $args{obj};
      my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
                     } ( @{$args{srcs}} );
      my $srcs = '"'.join('" "',  @srcs).'"';
@@ -460,6 +460,13 @@ EOF
                     dso => '$(DSO_CFLAGS)',
                     bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
      my $makedepprog = $config{makedepprog};
+     if ($srcs[0] =~ /\.rc$/) {
+         return <<"EOF";
+$args{obj}: $deps
+       \$(RC) \$(RCOUTFLAG)\$\@ $srcs
+EOF
+     }
+     (my $obj = $args{obj}) =~ s|\.o$||;
      if ($srcs[0] =~ /\.asm$/) {
          return <<"EOF";
 $obj$objext: $deps
@@ -494,13 +501,15 @@ EOF
      my $lib = $args{lib};
      my $shlib = $args{shlib};
      (my $mkdef_key = $lib) =~ s/^lib//i;
-     my $objs = join("\n", map { $_.$objext } @{$args{objs}});
-     my $linklibs = join("",
-                        map { "\n$_" } compute_lib_depends(@{$args{deps}}));
-     my $deps = join(" ",
-                    (map { $_.$objext } @{$args{objs}}),
-                    compute_lib_depends(@{$args{deps}}));
-     my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
+     my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
+                grep { $_ =~ m|\.o$| }
+                @{$args{objs}};
+     my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
+     my @deps = compute_lib_depends(@{$args{deps}});
+     die "More than one exported symbols list" if scalar @defs > 1;
+     my $linklibs = join("", map { "$_\n" } @deps);
+     my $objs = join("\n", @objs);
+     my $deps = join(" ", @objs, @defs, @deps);
      my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
                                            "util", "mkdef.pl")),
                            rel2abs($config{builddir}));
@@ -508,17 +517,14 @@ EOF
                                           "util", "mkrc.pl")),
                           rel2abs($config{builddir}));
      my $target = shlib_import($lib);
+     my $shared_def = join("", map { " /def:$_" } @defs);
      return <<"EOF"
-$target: $deps "$ordinalsfile" "$mkdef_pl"
-       "\$(PERL)" "$mkdef_pl" "$mkdef_key" 32 > $shlib.def
-       "\$(PERL)" -i.tmp -pe "s|^LIBRARY\\s+${mkdef_key}32|LIBRARY $shlib|;" $shlib.def
-       DEL $shlib.def.tmp
-       "\$(PERL)" "$mkrc_pl" $shlib$shlibext > $shlib.rc
-       \$(RC) \$(RCOUTFLAG)$shlib.res $shlib.rc
+$target: $deps
        IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest
        \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
-               /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1)
-$objs $shlib.res$linklibs \$(EX_LIBS)
+               /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext$shared_def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1)
+$objs
+$linklibs\$(EX_LIBS)
 <<
        IF EXIST $shlib$shlibext.manifest \\
           \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext
@@ -534,12 +540,11 @@ EOF
      my %args = @_;
      my $dso = $args{lib};
      my $dso_n = basename($dso);
-     my $objs = join("\n", map { $_.$objext } @{$args{objs}});
-     my $linklibs = join("",
-                        map { "\n$_" } compute_lib_depends(@{$args{deps}}));
-     my $deps = join(" ",
-                    (map { $_.$objext } @{$args{objs}}),
-                    compute_lib_depends(@{$args{deps}}));
+     my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
+     my @deps = compute_lib_depends(@{$args{deps}});
+     my $objs = join("\n", @objs);
+     my $linklibs = join("", map { "$_\n" } @deps);
+     my $deps = join(" ", @objs, @deps);
      return <<"EOF";
 $dso$dsoext: $deps
        IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
@@ -549,7 +554,8 @@ EXPORTS
     bind_engine                @1
     v_check            @2
 <<
-$objs$linklibs \$(EX_LIBS)
+$objs
+$linklibs \$(EX_LIBS)
 <<
        IF EXIST $dso$dsoext.manifest \\
           \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
@@ -565,29 +571,31 @@ EOF
      return "" unless $disabled{"shared"} || $lib =~ /\.a$/;
 
      $lib =~ s/\.a$//;
-     my $objs = join("\n", map { $_.$objext } @{$args{objs}});
-     my $deps = join(" ", map { $_.$objext } @{$args{objs}});
+     my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
+     my $objs = join("\n", @objs);
+     my $deps = join(" ", @objs);
      return <<"EOF";
 $lib$libext: $deps
        \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
-\$**
+$objs
 <<
 EOF
  }
  sub obj2bin {
      my %args = @_;
      my $bin = $args{bin};
-     my $objs = join("\n", map { $_.$objext } @{$args{objs}});
-     my $linklibs = join("",
-                        map { "\n$_" } compute_lib_depends(@{$args{deps}}));
-     my $deps = join(" ",
-                    (map { $_.$objext } @{$args{objs}}),
-                    compute_lib_depends(@{$args{deps}}));
+     my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
+     my @deps = compute_lib_depends(@{$args{deps}});
+     my $objs = join("\n", @objs);
+     my $linklibs = join("", map { "$_\n" } @deps);
+     my $deps = join(" ", @objs, @deps);
      return <<"EOF";
 $bin$exeext: $deps
        IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
        \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
-$objs setargv.obj$linklibs \$(EX_LIBS)
+$objs
+setargv.obj
+$linklibs\$(EX_LIBS)
 <<
        IF EXIST $bin$exeext.manifest \\
           \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
index 1e0da1c87baba4208a9c426d8083905d1e957040..828ddc0f156fd66dcfde9744ce94b8daf773e709 100755 (executable)
@@ -228,16 +228,9 @@ foreach (@ARGV, split(/ /, $config{options}))
                $zlib = 1;
        }
 
-       $do_ssl=1 if $_ eq "libssl";
-       if ($_ eq "ssl") {
-               $do_ssl=1;
-               $libname=$_
-       }
-       $do_crypto=1 if $_ eq "libcrypto";
-       if ($_ eq "crypto") {
-               $do_crypto=1;
-               $libname=$_;
-       }
+       $do_crypto=1 if $_ eq "libcrypto" || $_ eq "crypto";
+       $do_ssl=1 if $_ eq "libssl" || $_ eq "ssl";
+
        $do_update=1 if $_ eq "update";
        $do_rewrite=1 if $_ eq "rewrite";
        $do_ctest=1 if $_ eq "ctest";
@@ -252,6 +245,8 @@ foreach (@ARGV, split(/ /, $config{options}))
        }
 
        }
+$libname = $unified_info{sharednames}->{libcrypto} if $do_crypto;
+$libname = $unified_info{sharednames}->{libssl} if $do_ssl;
 
 if (!$libname) {
        if ($do_ssl) {
@@ -1210,9 +1205,6 @@ sub print_def_file
         my $prevnum = 0;
         my $symvtextcount = 0;
 
-       if ($W32)
-               { $libname.="32"; }
-
         if ($W32)
                 {
                 print OUT <<"EOF";
@@ -1229,6 +1221,7 @@ EOF
         elsif ($VMS)
                 {
                 print OUT <<"EOF";
+IDENTIFICATION=$version
 CASE_SENSITIVE=YES
 SYMBOL_VECTOR=(-
 EOF