summaryrefslogtreecommitdiffstats
path: root/Configurations/platform
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2018-10-23 15:09:57 +0200
committerRichard Levitte <levitte@openssl.org>2019-01-21 19:31:32 +0100
commit9dd4ed28eb5972f62723985429b57f42eefda124 (patch)
tree6c5d9d1cba152032d08725e885a532f82332beae /Configurations/platform
parentc162a8c344f12b2e0e788920358f51181ddf168f (diff)
Rework building: Unix changes to handle extensions and product names
Add platform::Unix, which is a generic Unix module to support product name and extensions functionlity. However, this isn't quite enough, as mingw and Cygwin builds are done using the same templates, but since shared libraries work as on Windows and are named accordingly, platform::mingw and platform::Cygwin were also added to provide the necessary tweaks. This reworks Configurations/unix-Makefile.tmpl to work out product names in platform::Unix et al terms. In this one, we currently do care about the *_extension config attributes, and the modules adapt accordingly where it matters. This change also affected crypto/include/internal/dso_conf.h.in, since the DSO extension is meant to be the same as the short shared library extension, which isn't '.so' everywhere. 'shared_extension' attributes that had the value '.so.\$(SHLIB_VERSION_NUMBER)' are removed, platform::Unix provides an extension where the shared library version number is hard-coded instead. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/7473)
Diffstat (limited to 'Configurations/platform')
-rw-r--r--Configurations/platform/Cygwin.pm22
-rw-r--r--Configurations/platform/Unix.pm70
-rw-r--r--Configurations/platform/mingw.pm45
3 files changed, 137 insertions, 0 deletions
diff --git a/Configurations/platform/Cygwin.pm b/Configurations/platform/Cygwin.pm
new file mode 100644
index 0000000000..bc62e9db40
--- /dev/null
+++ b/Configurations/platform/Cygwin.pm
@@ -0,0 +1,22 @@
+package platform::Cygwin;
+
+use strict;
+use warnings;
+use Carp;
+
+use vars qw(@ISA);
+
+require platform::mingw;
+@ISA = qw(platform::mingw);
+
+# Assume someone set @INC right before loading this module
+use configdata;
+
+sub sharedname {
+ my $class = shift;
+ my $lib = platform::mingw->sharedname(@_);
+ $lib =~ s|^lib|cyg| if defined $lib;
+ return $lib;
+}
+
+1;
diff --git a/Configurations/platform/Unix.pm b/Configurations/platform/Unix.pm
new file mode 100644
index 0000000000..7f69cacdd4
--- /dev/null
+++ b/Configurations/platform/Unix.pm
@@ -0,0 +1,70 @@
+package platform::Unix;
+
+use strict;
+use warnings;
+use Carp;
+
+use vars qw(@ISA);
+
+require platform::BASE;
+@ISA = qw(platform::BASE);
+
+# Assume someone set @INC right before loading this module
+use configdata;
+
+sub binext { $target{exe_extension} || '' }
+sub dsoext { $target{dso_extension} || '.so' }
+# Because these are also used in scripts and not just Makefile, we must
+# convert $(SHLIB_VERSION_NUMBER) to the actual number.
+sub shlibext { (my $x = $target{shared_extension}
+ || '.so.$(SHLIB_VERSION_NUMBER)')
+ =~ s|\.\$\(SHLIB_VERSION_NUMBER\)
+ |.$config{shlib_version}|x;
+ $x; }
+sub libext { $target{lib_extension} || '.a' }
+sub defext { $target{def_extension} || '.ld' }
+sub objext { $target{obj_extension} || '.o' }
+sub depext { $target{obj_extension} || '.d' }
+
+# Other extra that aren't defined in platform::BASE
+sub shlibextsimple { (my $x = $target{shared_extension} || '.so')
+ =~ s|\.\$\(SHLIB_VERSION_NUMBER\)||;
+ $x; }
+sub shlibvariant { $target{shlib_variant} || "" }
+sub makedepprog { $disabled{makedepend} ? undef : $config{makedepprog} }
+
+# No conversion of assembler extension on Unix
+sub asm {
+ return $_[1];
+}
+
+# At some point, we might decide that static libraries are called something
+# other than the default...
+sub staticname {
+ # Non-installed libraries are *always* static, and their names remain
+ # the same, except for the mandatory extension
+ my $in_libname = platform::BASE->staticname($_[1]);
+ return $in_libname
+ unless ( grep { platform::BASE->staticname($_) eq $in_libname }
+ @{$unified_info{install}->{libraries}} );
+
+ # We currently return the same name anyway... but we might choose to
+ # append '_static' or '_a' some time in the future.
+ return platform::BASE->staticname($_[1]);
+}
+
+sub sharedname {
+ return platform::BASE::__concat(platform::BASE->sharedname($_[1]),
+ ($_[0]->shlibvariant() // ''));
+}
+
+sub sharedname_simple {
+ return platform::BASE::__isshared($_[1]) ? $_[1] : undef;
+}
+
+sub sharedlib_simple {
+ return platform::BASE::__concat($_[0]->sharedname_simple($_[1]),
+ $_[0]->shlibextsimple());
+}
+
+1;
diff --git a/Configurations/platform/mingw.pm b/Configurations/platform/mingw.pm
new file mode 100644
index 0000000000..5788a36e77
--- /dev/null
+++ b/Configurations/platform/mingw.pm
@@ -0,0 +1,45 @@
+package platform::mingw;
+
+use strict;
+use warnings;
+use Carp;
+
+use vars qw(@ISA);
+
+require platform::Unix;
+@ISA = qw(platform::Unix);
+
+# Assume someone set @INC right before loading this module
+use configdata;
+
+sub binext { '.exe' }
+sub objext { '.obj' }
+sub libext { '.a' }
+sub dsoext { '.dll' }
+sub defext { '.def' }
+sub shlibext { '.dll' }
+sub shlibextimport { $target{shared_import_extension} || '.dll.a' }
+sub shlibextsimple { undef }
+sub makedepprog { $disabled{makedepend} ? undef : $config{makedepprog} }
+
+(my $sover_filename = $config{shlib_version}) =~ s|\.|_|g;
+sub shlib_version_as_filename {
+ return $sover_filename;
+}
+sub sharedname {
+ return platform::BASE::__concat(platform::BASE->sharedname($_[1]),
+ "-",
+ $_[0]->shlib_version_as_filename(),
+ ($config{target} eq "mingw64"
+ ? "-x64" : ""));
+}
+
+# With Mingw and other DLL producers, there isn't really any "simpler"
+# shared library name. However, there is a static import library, so
+# we return that instead.
+sub sharedlib_simple {
+ return platform::BASE::__concat(platform::BASE->sharedname($_[1]),
+ $_[0]->shlibextimport());
+}
+
+1;