]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - Configurations/windows-makefile.tmpl
Refactor linker script generation
[thirdparty/openssl.git] / Configurations / windows-makefile.tmpl
index fd662b8edae76554856511cd9673c043fd8c7c8e..fb7ddca01690cf596610c52020691844f6c734fb 100644 (file)
@@ -6,6 +6,7 @@
  our $objext = $target{obj_extension} || ".obj";
  our $resext = $target{res_extension} || ".res";
  our $depext = $target{dep_extension} || ".d";
+ our $defext = $target{dep_extension} || ".def";
  our $exeext = $target{exe_extension} || ".exe";
  our $libext = $target{lib_extension} || ".lib";
  our $shlibext = $target{shared_extension} || ".dll";
@@ -89,12 +90,15 @@ DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
 {- output_on() if $disabled{makedepend}; "" -}
 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
 GENERATED={- # common0.tmpl provides @generated
-             join(" ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; $x }
+             join(" ", map { my $x = $_;
+                             $x =~ s|\.[sS]$|.asm|;
+                             $x =~ s|\.ld$|$defext|;
+                             $x }
                        @generated) -}
 
 INSTALL_LIBS={- join(" ", map { quotify1(lib($_)) } @{$unified_info{install}->{libraries}}) -}
-INSTALL_SHLIBS={- join(" ", map { quotify1(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
-INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify1(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
+INSTALL_SHLIBS={- join(" ", map { quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
+INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
 INSTALL_ENGINES={- join(" ", map { quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
 INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
 INSTALL_PROGRAMS={- join(" ", map { quotify1($_.$exeext) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
@@ -321,15 +325,15 @@ build_apps build_tests: build_programs
 # Convenience target to prebuild all generated files, not just the mandatory
 # ones
 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
-       @rem {- output_off() if $disabled{makedepend}; "" -}
+       @{- output_off() if $disabled{makedepend}; "" -}
        @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
        @$(ECHO) "         target system doesn't have $(PERL),"
        @$(ECHO) "         then make will fail..."
-       @rem {- output_on() if $disabled{makedepend}; "" -}
+       @{- output_on() if $disabled{makedepend}; "" -}
 
 test: tests
 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
-       @rem {- output_off() if $disabled{tests}; "" -}
+       @{- output_off() if $disabled{tests}; "" -}
        -mkdir $(BLDDIR)\test\test-runs
        set SRCTOP=$(SRCDIR)
        set BLDTOP=$(BLDDIR)
@@ -338,17 +342,17 @@ test: tests
        set OPENSSL_ENGINES=$(MAKEDIR)\engines
        set OPENSSL_DEBUG_MEMORY=on
        "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
-       @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
+       @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
        @$(ECHO) "Tests are not supported with your chosen Configure options"
-       @rem {- output_on() if !$disabled{tests}; "" -}
+       @{- output_on() if !$disabled{tests}; "" -}
 
 list-tests:
-       @rem {- output_off() if $disabled{tests}; "" -}
+       @{- output_off() if $disabled{tests}; "" -}
        @set SRCTOP=$(SRCDIR)
        @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
-       @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
+       @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
        @$(ECHO) "Tests are not supported with your chosen Configure options"
-       @rem {- output_on() if !$disabled{tests}; "" -}
+       @{- output_on() if !$disabled{tests}; "" -}
 
 install: install_sw install_ssldirs install_docs
 
@@ -375,9 +379,9 @@ distclean: clean
        -del /Q /F makefile
 
 depend:
-       @ rem {- output_off() if $disabled{makedepend}; "" -}
+       @ {- output_off() if $disabled{makedepend}; "" -}
        @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
-       @ rem {- output_on() if $disabled{makedepend}; "" -}
+       @ {- output_on() if $disabled{makedepend}; "" -}
 
 # Install helper targets #############################################
 
@@ -410,10 +414,10 @@ install_dev:
        @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
        @$(ECHO) "*** Installing development files"
        @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
-       @rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
+       @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
        @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
                                       "$(INSTALLTOP)\include\openssl"
-       @rem {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
+       @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
        @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
                                       "$(SRCDIR)\include\openssl\*.h" \
                                       "$(INSTALLTOP)\include\openssl"
@@ -496,7 +500,6 @@ reconfigure reconf:
 
   sub generatesrc {
       my %args = @_;
-      (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
       my ($gen0, @gens) = @{$args{generator}};
       my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
       my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
@@ -504,7 +507,17 @@ reconfigure reconf:
       my $deps = @{$args{deps}} ?
           '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
 
-      if ($target !~ /\.asm$/) {
+      if ($args{src} =~ /\.ld$/) {
+          (my $target = $args{src}) =~ s/\.ld$/$defext/;
+          my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
+                                              "util", "mkdef.pl")),
+                              rel2abs($config{builddir}));
+          return <<"EOF";
+$target: $args{generator}->[0] $deps
+       \$(PERL) $mkdef $args{generator}->[1] 32 > $target
+EOF
+      } elsif ($args{src} !~ /\.[sS]$/) {
+          my $target = $args{src};
           if ($args{generator}->[0] =~ m|^.*\.in$|) {
               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
                                                    "util", "dofile.pl")),
@@ -521,6 +534,7 @@ $target: "$args{generator}->[0]" $deps
 EOF
          }
       } else {
+          (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
           if ($args{generator}->[0] =~ /\.pl$/) {
               $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
           } elsif ($args{generator}->[0] =~ /\.S$/) {
@@ -531,6 +545,7 @@ EOF
 
           my $cppflags = $incs;
           $cppflags .= {
+              shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
               lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
               dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
               bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
@@ -568,14 +583,17 @@ EOF
      my $srcs = '"'.join('" "',  @srcs).'"';
      my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
      my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
-     my $cflags = { lib => ' $(LIB_CFLAGS)',
+     my $cflags = { shlib => ' $(LIB_CFLAGS)',
+                   lib => ' $(LIB_CFLAGS)',
                    dso => ' $(DSO_CFLAGS)',
                    bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
      $cflags .= $incs;
-     $cflags .= { lib => ' $(LIB_CPPFLAGS)',
+     $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
+                 lib => ' $(LIB_CPPFLAGS)',
                  dso => ' $(DSO_CPPFLAGS)',
                  bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
-     my $asflags = { lib => ' $(LIB_ASFLAGS)',
+     my $asflags = { shlib => ' $(LIB_ASFLAGS)',
+                    lib => ' $(LIB_ASFLAGS)',
                     dso => ' $(DSO_ASFLAGS)',
                     bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
      my $makedepprog = $config{makedepprog};
@@ -612,14 +630,16 @@ EOF
  # On Unix, we build shlibs from static libs, so we're ignoring the
  # object file array.  We *know* this routine is only called when we've
  # configure 'shared'.
- sub libobj2shlib {
+ sub obj2shlib {
      my %args = @_;
      my $lib = $args{lib};
      my $shlib = $args{shlib};
      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
                 grep { $_ =~ m/\.(?:o|res)$/ }
                 @{$args{objs}};
-     my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
+     my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
+                grep { $_ =~ /\.ld$/ }
+                @{$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);
@@ -742,8 +762,6 @@ EOF
               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
                   if (dirname($prod) eq $dir) {
                       push @deps, $prod.$extinfo{$type};
-                  } else {
-                      push @actions, "\t@rem No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
                   }
               }
           }