Commit b3e5db40 authored by Richard Levitte's avatar Richard Levitte
Browse files

VMS: Make sure to include MAIN from static libraries if needed

parent 4db40c94
Loading
Loading
Loading
Loading
+27 −8
Original line number Diff line number Diff line
@@ -756,21 +756,38 @@ EOF
      my $bind = dirname($bin);
      my $binn = basename($bin);
      my @objs = map { "$_.OBJ" } @{$args{objs}};
      my $objs = join(",", @objs);
      my @deps = compute_lib_depends(@{$args{deps}});
      my $deps = join(", -\n\t\t", @objs, @deps);

      my $olb_count = scalar grep(m|\.OLB$|, @deps);
      my $analyse_objs = "@ !";
      if ($olb_count > 0) {
          my $analyse_quals =
              $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
          $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
      }
      # The "[]" hack is because in .OPT files, each line inherits the
      # previous line's file spec as default, so if no directory spec
      # is present in the current line and the previous line has one that
      # doesn't apply, you're in for a surprise.
      my $write_opt1 =
          join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
                                 "WRITE OPT_FILE \"$x" } @objs).
                                 "\@ WRITE OPT_FILE \"$x" } @objs).
          "\"";
      my $write_opt2 =
          join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
                             $x =~ s|(\.EXE)|$1/SHARE|;
                             $x =~ s|(\.OLB)|$1/LIB|;
                             "WRITE OPT_FILE \"$x\"" } @deps)
          join("\n\t", map { my @lines = ();
                             my $x = $_ =~ /\[/ ? $_ : "[]".$_;
                             if ($x =~ m|\.EXE$|) {
                                 push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
                             } elsif ($x =~ m|\.OLB$|) {
                                 (my $l = $x) =~ s/\W/_/g;
                                 push @lines, 
                                     "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB\$(INCLUDE_MAIN_$l)\"",
                                     "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
                             }
                             @lines
                           } @deps)
          || "\@ !";
      # The linking commands looks a bit complex, but it's for good reason.
      # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
@@ -792,10 +809,12 @@ EOF
      # and let it break the build.
      return <<"EOF"
$bin.EXE : $deps
        OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
        $analyse_objs
        @ OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
        $write_opt1
        $write_opt2
        CLOSE OPT_FILE
        @ CLOSE OPT_FILE
        TYPE $bin.opt ! For debugging
        - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
                    LINK \$(LDFLAGS)/EXEC=\$\@ $bin.OPT/OPT \$(EX_LIBS) ; -
               link_status = \$status ; link_severity = link_status .AND. 7
+7 −0
Original line number Diff line number Diff line
@@ -15,6 +15,13 @@ IF[{- !$disabled{tests} -}]
  INCLUDE[libtestutil.a]=../include
  DEPEND[libtestutil.a]=../libcrypto

  # Special hack for descrip.mms to include the MAIN object module
  # explicitely.  This will only be done if there isn't a MAIN in the
  # program's object modules already.
  BEGINRAW[descrip.mms]
INCLUDE_MAIN___test_libtestutil_OLB = /INCLUDE=MAIN
  ENDRAW[descrip.mms]

  PROGRAMS_NO_INST=\
          aborttest test_test \
          sanitytest exdatatest bntest \