summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-03-02 16:12:22 +0100
committerRichard Levitte <levitte@openssl.org>2016-03-09 11:22:07 +0100
commit2fe730362812e3c7d364197449a9439e3cb5915b (patch)
treee6a3b5ffabb9c5e9fa76c3f9839104d7f3a3ec90
parent7c0e1aa6e2b24d76169573703b1455ef178667d9 (diff)
Unified - extract settings from util/pl/VC-32.pl and make the config settings
This introduces the settings loutflag and aroutflag, because different Windows tools that do the same thing have different ways to specify the output file. The Borland C++ config is commented away for the monent, perhaps permanently. Reviewed-by: Rich Salz <rsalz@openssl.org>
-rw-r--r--Configurations/00-base-templates.conf10
-rw-r--r--Configurations/10-main.conf212
-rw-r--r--Configurations/windows-makefile.tmpl26
3 files changed, 212 insertions, 36 deletions
diff --git a/Configurations/00-base-templates.conf b/Configurations/00-base-templates.conf
index 4308c5c1d8..cbb5675db6 100644
--- a/Configurations/00-base-templates.conf
+++ b/Configurations/00-base-templates.conf
@@ -89,7 +89,15 @@
}
return (); },
- build_scheme => [ "mk1mf" ],
+ ld => "link",
+ lflags => "/nologo",
+ loutflag => "/out:",
+ ar => "lib",
+ arflags => "/nologo",
+ aroutflag => "/out:",
+
+ build_file => "makefile",
+ build_scheme => [ "unified", "windows" ],
},
BASE_VMS => {
diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf
index 576ac45ce7..fa9af88e42 100644
--- a/Configurations/10-main.conf
+++ b/Configurations/10-main.conf
@@ -17,6 +17,79 @@ sub combine {
return sub { add(@stuff)->(); }
}
+# Helper functions for the Windows configs
+my $vc_win64a_info = {};
+sub vc_win64a_info {
+ unless (%$vc_win64a_info) {
+ if (`nasm -v 2>NUL` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {
+ $vc_win64a_info = { as => "nasm",
+ asflags => "-f win64 -DNEAR -Ox -g",
+ asoutflag => "-o" };
+ } else {
+ $vc_win64a_info = { as => "ml64",
+ asflags => "/c /Cp /Cx /Zi",
+ asoutflag => "/Fo" };
+ }
+ }
+ return $vc_win64a_info;
+}
+
+my $vc_wince_info = {};
+sub vc_wince_info {
+ unless (%$vc_wince_info) {
+ # sanity check
+ die '%OSVERSION% is not defined' if (!defined($ENV{'OSVERSION'}));
+ die '%PLATFORM% is not defined' if (!defined($ENV{'PLATFORM'}));
+ die '%TARGETCPU% is not defined' if (!defined($ENV{'TARGETCPU'}));
+
+ #
+ # Idea behind this is to mimic flags set by eVC++ IDE...
+ #
+ my $wcevers = $ENV{'OSVERSION'}; # WCENNN
+ die '%OSVERSION% value is insane'
+ if ($wcevers !~ /^WCE([1-9])([0-9]{2})$/);
+ my $wcecdefs = "-D_WIN32_WCE=$1$2 -DUNDER_CE=$1$2"; # -D_WIN32_WCE=NNN
+ my $wcelflag = "/subsystem:windowsce,$1.$2"; # ...,N.NN
+
+ my $wceplatf = $ENV{'PLATFORM'};
+ my $wceplatf =~ tr/a-z0-9 /A-Z0-9_/d;
+ my $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
+
+ my $wcetgt = $ENV{'TARGETCPU'}; # just shorter name...
+ SWITCH: for($wcetgt) {
+ /^X86/ && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
+ $wcelflag.=" /machine:X86"; last; };
+ /^ARMV4[IT]/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
+ $wcecdefs.=" -DTHUMB -D_THUMB_" if($wcetgt=~/T$/);
+ $wcecdefs.=" -QRarch4T -QRinterwork-return";
+ $wcelflag.=" /machine:THUMB"; last; };
+ /^ARM/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
+ $wcelflag.=" /machine:ARM"; last; };
+ /^MIPSIV/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
+ $wcecdefs.=" -D_MIPS64 -QMmips4 -QMn32";
+ $wcelflag.=" /machine:MIPSFPU"; last; };
+ /^MIPS16/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
+ $wcecdefs.=" -DMIPSII -QMmips16";
+ $wcelflag.=" /machine:MIPS16"; last; };
+ /^MIPSII/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
+ $wcecdefs.=" -QMmips2";
+ $wcelflag.=" /machine:MIPS"; last; };
+ /^R4[0-9]{3}/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000";
+ $wcelflag.=" /machine:MIPS"; last; };
+ /^SH[0-9]/ && do { $wcecdefs.=" -D$wcetgt -D_${wcetgt}_ -DSHx";
+ $wcecdefs.=" -Qsh4" if ($wcetgt =~ /^SH4/);
+ $wcelflag.=" /machine:$wcetgt"; last; };
+ { $wcecdefs.=" -D$wcetgt -D_${wcetgt}_";
+ $wcelflag.=" /machine:$wcetgt"; last; };
+ }
+
+ $vc_wince_info = { cflags => $wcecdefs,
+ lflags => $wcelflag };
+ }
+ return $vc_wince_info;
+}
+
+
%targets = (
#### Basic configs that should work on any 32-bit box
@@ -1155,60 +1228,153 @@ sub combine {
# positives in some situations. Disabling it altogether masks both
# legitimate and false cases, but as we compile on multiple platforms,
# we rely on other compilers to catch legitimate cases.
+#
+# Also note that we force threads no matter what. Configuring "no-threads"
+# is ignored.
"VC-common" => {
inherit_from => [ "BASE_Windows" ],
template => 1,
cc => "cl",
cflags => "-W3 -wd4090 -Gs0 -GF -Gy -nologo -DOPENSSL_SYS_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE",
+ coutflag => "/Fo",
+ lib_cflags => "/Zl /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",
dso_scheme => "win32",
},
+ "VC-noCE-common" => {
+ inherit_from => [ "VC-common", "uplink_common" ],
+ cflags => add(picker(default => "-DUNICODE -D_UNICODE",
+ debug =>
+ sub {
+ ($disabled{shared} ? "/MT" : "/MD")
+ ."d /Od -DDEBUG -D_DEBUG";
+ },
+ release =>
+ sub {
+ ($disabled{shared} ? "/MT" : "/MD")
+ ." /Ox /O2 /Ob2";
+ })),
+ bin_lflags => add("/subsystem:console /opt:ref"),
+ ex_libs => sub {
+ my @ex_libs = ();
+ push @ex_libs, 'ws2_32.lib' unless $disabled{sock};
+ push @ex_libs, 'gdi32.lib advapi32.lib crypt32.lib user32.lib';
+ return join(" ", @ex_libs);
+ },
+ },
+ "VC-WIN64-common" => {
+ inherit_from => [ "VC-noCE-common" ],
+ ex_libs => sub {
+ my @ex_libs = ();
+ push @ex_libs, 'bufferoverflowu.lib' if (`cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
+ return join(" ", @_, @ex_libs);
+ },
+ bn_ops => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
+ build_scheme => add("VC-W64", { separator => undef }),
+ },
"VC-WIN64I" => {
- inherit_from => [ "VC-common", asm("ia64_asm") ],
- cflags => add("-DUNICODE -D_UNICODE"),
+ inherit_from => [ "VC-WIN64-common", asm("ia64_asm") ],
+ as => "ias",
+ asflags => "-d debug",
+ asoutflag => "-o",
sys_id => "WIN64I",
- bn_ops => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
- bn_obj => sub { my $r=join(" ",@_); $r=~s/bn\-//; $r; },
- rc4_obj => "",
+ rc4_asm_src => "",
perlasm_scheme => "ias",
- build_scheme => add("VC-W64", { separator => undef }),
},
"VC-WIN64A" => {
- inherit_from => [ "VC-common", asm("x86_64_asm") ],
- cflags => add("-DUNICODE -D_UNICODE"),
+ inherit_from => [ "VC-WIN64-common", asm("x86_64_asm") ],
+ as => sub { vc_win64a_info()->{as} },
+ asflags => sub { vc_win64a_info()->{asflags} },
+ asoutflag => sub { vc_win64a_info()->{asoutflag} },
sys_id => "WIN64A",
- bn_ops => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
- bn_obj => sub { my $r=join(" ",@_); $r=~s/x86_64\-gcc/bn_asm/; $r; },
+ bn_asm_src => sub { return undef unless @_;
+ my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; },
perlasm_scheme => "auto",
- build_scheme => add("VC-W64", { separator => undef }),
},
"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-common", asm("x86_asm") ],
+ inherit_from => [ "VC-noCE-common", asm("x86_asm") ],
+ as => sub { my $ver=`nasm -v 2>NUL`;
+ my $vew=`nasmw -v 2>NUL`;
+ return $ver ge $vew ? "nasm" : "nasmw" },
+ asflags => "-f win32",
+ asoutflag => "-o",
+ ex_libs => sub {
+ my @ex_libs = ();
+ # WIN32 UNICODE build gets linked with unicows.lib for
+ # backward compatibility with Win9x.
+ push @ex_libs, 'unicows.lib'
+ if (grep { $_ eq "UNICODE" } @user_defines);
+ return join(" ", @ex_libs, @_);
+ },
sys_id => "WIN32",
bn_ops => "BN_LLONG EXPORT_VAR_AS_FN",
perlasm_scheme => "win32n",
build_scheme => add("VC-W32", { separator => undef }),
},
"VC-CE" => {
- inherit_from => [ "BASE_Windows" ],
+ inherit_from => [ "VC-common" ],
+ as => "ml",
+ asflags => "/nologo /Cp /coff /c /Cx /Zi",
+ asoutflag => "/Fo",
cc => "cl",
+ cflags =>
+ picker(default =>
+ combine('/W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYS_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT',
+ sub { vc_wince_info()->{cflags}; },
+ sub { defined($ENV{'WCECOMPAT'})
+ ? '-I$(WCECOMPAT)/include' : (); },
+ sub { defined($ENV{'PORTSDK_LIBPATH'})
+ ? '-I$(PORTSDK_LIBPATH)/../../include' : (); },
+ sub { `cl 2>&1` =~ /Version ([0-9]+)\./ && $1>=14
+ ? ($disabled{shared} ? " /MT" : " /MD")
+ : " /MC"; }),
+ debug => "/Od -DDEBUG -D_DEBUG",
+ release => "/O1i"),
+ lflags => combine("/nologo /opt:ref",
+ sub { vc_wince_info()->{lflags}; },
+ sub { defined($ENV{PORTSDK_LIBPATH})
+ ? "/entry:mainCRTstartup" : (); }),
sys_id => "WINCE",
bn_ops => "BN_LLONG EXPORT_VAR_AS_FN",
- dso_scheme => "win32",
+ ex_libs => sub {
+ my @ex_libs = ();
+ push @ex_libs, 'ws2.lib' unless $disabled{sock};
+ push @ex_libs, 'crypt32.lib';
+ if (defined($ENV{WCECOMPAT})) {
+ my $x = '$(WCECOMPAT)/lib';
+ if (-f "$x/$ENV{TARGETCPU}/wcecompatex.lib") {
+ $x .= '/$(TARGETCPU)/wcecompatex.lib';
+ } else {
+ $x .= '/wcecompatex.lib';
+ }
+ push @ex_libs, $x;
+ }
+ push @ex_libs, '$(PORTSDK_LIBPATH)/portlib.lib'
+ if (defined($ENV{'PORTSDK_LIBPATH'}));
+ push @ex_libs, ' /nodefaultlib coredll.lib corelibc.lib'
+ if ($ENV{'TARGETCPU'} eq "X86");
+ return @ex_libs;
+ },
build_scheme => add("VC-WCE", { separator => undef }),
},
-#### Borland C++ 4.5
- "BC-32" => {
- inherit_from => [ "BASE_Windows" ],
- cc => "bcc32",
- sys_id => "WIN32",
- bn_ops => "BN_LLONG EXPORT_VAR_AS_FN",
- dso_scheme => "win32",
- build_scheme => add("BC", { separator => undef }),
- },
+###### Borland C++ 4.5
+## "BC-32" => {
+## inherit_from => [ "BASE_Windows" ],
+## cc => "bcc32",
+## sys_id => "WIN32",
+## bn_ops => "BN_LLONG EXPORT_VAR_AS_FN",
+## dso_scheme => "win32",
+## build_scheme => add("BC", { separator => undef }),
+## },
#### MinGW
"mingw" => {
diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl
index 2f3e244294..6f3c8483e2 100644
--- a/Configurations/windows-makefile.tmpl
+++ b/Configurations/windows-makefile.tmpl
@@ -94,11 +94,13 @@ COUTFLAG={- $target{coutflag} || "/Fo" -}
LD={- $target{ld} || "link" -}
LDFLAGS={- $target{lflags} -}
LDOUTFLAG={- $target{loutflag} || "/out:" -}
-EX_LIBS={- $config{ex_libs} -}
-SHARED_CFLAGS={- $target{shared_cflag} || "" -}
+EX_LIBS={- $target{ex_libs} -}
+LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -}
SHARED_LDFLAGS={- $target{shared_ldflag} || "" -}
-DSO_CFLAGS={- $target{shared_cflag} || "" -}
+DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -}
+DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -}
BIN_CFLAGS={- $target{bin_cflags} -}
+BIN_LDFLAGS={- $target{bin_lflags} -}
PERL={- $config{perl} -}
@@ -115,8 +117,7 @@ PROCESSOR= {- $config{processor} -}
# The main targets ###################################################
-all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep \
- depend link-utils
+all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep depend
build_libs: configdata.pm build_libs_nodep depend
build_libs_nodep: $(LIBS)
@@ -127,7 +128,7 @@ build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
build_tests: configdata.pm build_tests_nodep depend
build_tests_nodep: $(TESTPROGS)
-test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend rehash
+test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend
set SRCTOP=$(SRCDIR)
set BLDTOP=$(BLDDIR)
set PERL=$(PERL)
@@ -173,7 +174,7 @@ configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure
my $srcs = join(" ", @srcs);
my $deps = join(" ", @srcs, @{$args{deps}});
my $incs = join("", map { " /I ".$_ } @{$args{incs}});
- my $ecflags = { lib => '$(SHARED_CFLAGS)',
+ my $ecflags = { lib => '$(LIB_CFLAGS)',
dso => '$(DSO_CFLAGS)',
bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
my $makedepprog = $config{makedepprog};
@@ -221,8 +222,8 @@ EOF
return <<"EOF"
$target: $deps $ordinalsfile
\$(PERL) $mkdef_pl "$mkdef_key" 32 > $shlib.def
- \$(LD) \$(LDFLAGS) \\
- /dll /implib:$target \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<<
+ \$(LD) \$(LDFLAGS) \$(SHARED_LDFLAGS) \\
+ /implib:$target \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<<
$objs$linklibs \$(EX_LIBS)
<<
EOF
@@ -230,6 +231,7 @@ EOF
sub obj2dso {
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}}));
@@ -238,8 +240,8 @@ EOF
compute_lib_depends(@{$args{deps}}));
return <<"EOF";
$dso$dsoext: $deps
- \$(LD) \$(LDFLAGS) /dll \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
-LIBRARY $dso
+ \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
+LIBRARY $dso_n
EXPORTS
bind_engine @1
v_check @2
@@ -271,7 +273,7 @@ EOF
compute_lib_depends(@{$args{deps}}));
return <<"EOF";
$bin$exeext: $deps
- \$(LD) \$(LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
+ \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
$objs setargv.obj$linklibs \$(EX_LIBS)
<<
EOF