Build resource files

We need to compile with [brcc32.exe][1] and link with [ilink32.exe][2].
The latter expects the `.res` files to be given in the final comma-
separated section in the command line (after the `.def` file).

[1]: http://docwiki.embarcadero.com/RADStudio/Sydney/en/BRCC32.EXE,_the_Resource_Compiler
[2]: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_ILINK32_and_ILINK64_on_the_Command_Line#Command-Line_Elements

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/13540)
This commit is contained in:
Tanzinul Islam 2020-12-09 00:29:14 +00:00 committed by Dmitry Belyavskiy
parent 5fee3fe276
commit 6afb36342d
6 changed files with 32 additions and 15 deletions

View File

@ -108,8 +108,6 @@ my %targets=(
return ();
},
RC => "rc",
rcoutflag => "/fo",
MT => "mt",
MTFLAGS => "-nologo",
mtinflag => "-manifest ",

View File

@ -1288,6 +1288,8 @@ my %targets = (
ARFLAGS => "/nologo",
aroutflag => "/out:",
ar_resp_delim => "\n",
RC => "rc",
rcoutflag => "/fo",
defines => add("OPENSSL_SYS_WIN32", "WIN32_LEAN_AND_MEAN",
"UNICODE", "_UNICODE",
"_CRT_SECURE_NO_DEPRECATE",
@ -1301,6 +1303,7 @@ my %targets = (
shared_ldflag => "/dll",
shared_target => "win-shared", # meaningless except it gives Configure a hint
lddefflag => "/def:",
ldresflag => " ",
ld_implib_flag => "/implib:",
thread_scheme => "winthreads",
dso_scheme => "win32",

View File

@ -38,10 +38,14 @@ my %targets = (
AR => "tlib",
ARFLAGS => "/P256 /N /u",
ar_resp_delim => " &\n",
RC => "brcc32",
RCFLAGS => '-i"$(BDS)\include\windows\sdk"',
rcoutflag => "-fo",
shared_target => "win-shared",
shared_ldflag => "-Tpd c0d32.obj",
dso_lflags => "-Tpd c0d32.obj",
lddefflag => ",",
ldresflag => ",",
ld_implib_rule => 'implib $< $**',
dso_scheme => "win32",
}

View File

@ -848,7 +848,10 @@ EOF
my %args = @_;
my $lib = $args{lib};
my @objs = map { platform->convertext($_) }
grep { platform->isobj($_) || platform->isres($_) }
grep { platform->isobj($_) }
@{$args{objs}};
my @ress = map { platform->convertext($_) }
grep { platform->isres($_) }
@{$args{objs}};
my @defs = map { platform->def($_) }
grep { platform->isdef($_) }
@ -857,10 +860,11 @@ EOF
die "More than one exported symbols list" if scalar @defs > 1;
my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
my $objs = join($target{ld_resp_delim}, @objs);
my $deps = join(" ", @objs, @defs, @deps);
my $ress = join($target{ld_resp_delim}, @ress);
my $deps = join(" ", @objs, @ress, @defs, @deps);
my $import = platform->sharedlib_import($lib);
my $dll = platform->sharedlib($lib);
my $shared_def = join("", map { " $target{lddefflag}$_" } @defs);
my $shared_def = $target{lddefflag} . join("", @defs);
my $implib_rule = $target{ld_implib_rule} || "";
my $implib_flag = $target{ld_implib_flag}
? "$target{ld_implib_flag}$import"
@ -875,7 +879,7 @@ $dll: $deps
IF EXIST $full.manifest DEL /F /Q $full.manifest
IF EXIST \$@ DEL /F /Q \$@
\$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) @<< $implib_flag || (DEL /Q \$(\@B).* $import; EXIT 1)
$objs$target{ld_resp_delim}\$(LDOUTFLAG)$dll$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(LIB_EX_LIBS)$shared_def
$objs$target{ld_resp_delim}\$(LDOUTFLAG)$dll$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(LIB_EX_LIBS)$target{ld_resp_delim}$shared_def$target{ldresflag}$ress
<<
IF EXIST $dll.manifest \\
\$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
@ -892,21 +896,26 @@ EOF
my $dso = platform->dso($args{module});
my $dso_n = platform->dsoname($args{module});
my @objs = map { platform->convertext($_) }
grep { platform->isobj($_) || platform->isres($_) }
grep { platform->isobj($_) }
@{$args{objs}};
my @ress = map { platform->convertext($_) }
grep { platform->isres($_) }
@{$args{objs}};
my @defs = map { platform->def($_) }
grep { platform->isdef($_) }
@{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
die "More than one exported symbols list" if scalar @defs > 1;
my $objs = join($target{ld_resp_delim}, @objs);
my $ress = join($target{ld_resp_delim}, @ress);
my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
my $deps = join(" ", @objs, @defs, @deps);
my $shared_def = join("", map { " $target{lddefflag}$_" } @defs);
my $deps = join(" ", @objs, @ress, @defs, @deps);
my $shared_def = $target{lddefflag} . join("", @defs);
return <<"EOF";
$dso: $deps
IF EXIST $dso.manifest DEL /F /Q $dso.manifest
\$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) @<< || (DEL /Q \$(\@B).* $dso_n.*; EXIT 1)
$objs$target{ld_resp_delim}\$(LDOUTFLAG)$dso$target{ldpostoutflag}$target{ld_resp_delim}$linklibs \$(DSO_EX_LIBS)$shared_def
$objs$target{ld_resp_delim}\$(LDOUTFLAG)$dso$target{ldpostoutflag}$target{ld_resp_delim}$linklibs \$(DSO_EX_LIBS)$target{ld_resp_delim}$shared_def$target{ldresflag}$ress
<<
IF EXIST $dso.manifest \\
\$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
@ -929,17 +938,20 @@ EOF
my %args = @_;
my $bin = platform->bin($args{bin});
my @objs = map { platform->convertext($_) }
grep { platform->isobj($_) || platform->isres($_) }
grep { platform->isobj($_) }
@{$args{objs}};
my @ress = map { platform->convertext($_) }
grep { platform->isres($_) }
@{$args{objs}};
my @deps = compute_lib_depends(@{$args{deps}});
my $objs = join($target{ld_resp_delim}, @objs);
my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
my $deps = join(" ", @objs, @deps);
my $deps = join(" ", @objs, @ress, @deps);
return <<"EOF";
$bin: $deps
IF EXIST $bin.manifest DEL /F /Q $bin.manifest
\$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) @<<
$objs$target{ld_resp_delim}\$(LDOUTFLAG)$bin$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(BIN_EX_LIBS)
$objs$target{ld_resp_delim}\$(LDOUTFLAG)$bin$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(BIN_EX_LIBS)$target{ldresflag}$target{ldresflag}$ress
<<
IF EXIST $bin.manifest \\
\$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin

View File

@ -71,7 +71,7 @@ IF[{- !$disabled{apps} -}]
# always depend on a changed configuration.
DEPEND[progs.c]=../configdata.pm
IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}]
IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-|BC-)/ -}]
GENERATE[openssl.rc]=../util/mkrc.pl openssl
SOURCE[openssl]=openssl.rc
ENDIF

View File

@ -79,7 +79,7 @@ IF[{- defined $target{shared_defflag} -}]
GENERATE[libssl.ld]=util/libssl.num libssl
ENDIF
IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-)/ -}]
IF[{- $config{target} =~ /^(?:Cygwin|mingw|VC-|BC-)/ -}]
GENERATE[libcrypto.rc]=util/mkrc.pl libcrypto
GENERATE[libssl.rc]=util/mkrc.pl libssl