2023-05-03 18:29:00 +08:00
|
|
|
#! /usr/bin/env perl
|
|
|
|
# Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
|
|
# this file except in compliance with the License. You can obtain a copy
|
|
|
|
# in the file LICENSE in the source distribution or at
|
|
|
|
# https://www.openssl.org/source/license.html
|
|
|
|
|
|
|
|
# All variables are supposed to come from Makefile, in environment variable
|
|
|
|
# form, or passed as variable assignments on the command line.
|
|
|
|
# The result is a Perl module creating the package OpenSSL::safe::installdata.
|
|
|
|
|
|
|
|
use File::Spec;
|
2024-06-20 20:30:16 +08:00
|
|
|
use List::Util qw(pairs);
|
2023-05-03 18:29:00 +08:00
|
|
|
|
|
|
|
# These are expected to be set up as absolute directories
|
2024-06-20 20:30:16 +08:00
|
|
|
my @absolutes = qw(PREFIX libdir);
|
2023-05-03 18:29:00 +08:00
|
|
|
# These may be absolute directories, and if not, they are expected to be set up
|
2024-06-20 20:30:16 +08:00
|
|
|
# as subdirectories to PREFIX or LIBDIR. The order of the pairs is important,
|
|
|
|
# since the LIBDIR subdirectories depend on the calculation of LIBDIR from
|
|
|
|
# PREFIX.
|
|
|
|
my @subdirs = pairs (PREFIX => [ qw(BINDIR LIBDIR INCLUDEDIR APPLINKDIR) ],
|
|
|
|
LIBDIR => [ qw(ENGINESDIR MODULESDIR PKGCONFIGDIR
|
|
|
|
CMAKECONFIGDIR) ]);
|
|
|
|
# For completeness, other expected variables
|
|
|
|
my @others = qw(VERSION LDLIBS);
|
|
|
|
|
|
|
|
my %all = ( );
|
|
|
|
foreach (@absolutes) { $all{$_} = 1 }
|
|
|
|
foreach (@subdirs) { foreach (@{$_->[1]}) { $all{$_} = 1 } }
|
|
|
|
foreach (@others) { $all{$_} = 1 }
|
|
|
|
print STDERR "DEBUG: all keys: ", join(", ", sort keys %all), "\n";
|
2023-05-03 18:29:00 +08:00
|
|
|
|
|
|
|
my %keys = ();
|
|
|
|
foreach (@ARGV) {
|
|
|
|
(my $k, my $v) = m|^([^=]*)=(.*)$|;
|
|
|
|
$keys{$k} = 1;
|
|
|
|
$ENV{$k} = $v;
|
|
|
|
}
|
Add exporters for CMake
CMake's older package finder, FindOpenSSL.cmake, does a best guess effort
and doesn't always get it right.
By CMake's own documentation, that's what such modules are (best effort
attempts), and package producers are (strongly) encouraged to help out by
producing and installing <PackageName>Config.cmake files to get a more
deterministic configuration.
The resulting OpenSSLConfig.cmake tries to mimic the result from CMake's
FindOpenSSL.cmake, by using the same variable and imported target names.
It also adds a few extra variables of its own, such as:
OPENSSL_MODULES_DIR Indicates the default installation directory
for OpenSSL loadable modules, such as providers.
OPENSSL_RUNTIME_DIR Indicates the default runtime directory, where
for example the openssl program is located.
OPENSSL_PROGRAM Is the full directory-and-filename of the
openssl program.
The imported targets OpenSSL::Crypto and OpenSSL::SSL are as precisely
specified as possible, so for example, they are specified with the both the
import library and the DLL on Windows, which should make life easier on that
platform.
For the moment, one of the following must be done in your CMake project for
this CMake configuration to take priority over CMake's FindOpenSSL.cmake:
- The variable CMAKE_FIND_PACKAGE_PREFER_CONFIG must be set to true prior
to the 'find_package(OpenSSL)' call.
- The 'find_package' call itself must use the "Full Signature". If you
don't know any better, simply add the 'CONFIG' option, i.e. from this
example:
find_package(OpenSSL 3.0 REQUIRED)
to this:
find_package(OpenSSL 3.0 REQUIRED CONFIG)
Just as with the 'pkg-config' exporters, two variants of the .cmake files
are produced:
- Those in 'exporters/' are installed in the location that 'pkg-config'
itself prefers for installed packages.
- Those in the top directory are to be used when it's desirable to build
directly against an OpenSSL build tree.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20878)
2023-05-03 18:36:09 +08:00
|
|
|
|
2024-06-20 20:30:16 +08:00
|
|
|
# warn if there are missing values, and also if there are unexpected values
|
|
|
|
foreach my $k (sort keys %all) {
|
|
|
|
warn "No value given for $k\n" unless $keys{$k};
|
2023-05-03 18:29:00 +08:00
|
|
|
}
|
|
|
|
foreach my $k (sort keys %keys) {
|
2024-06-20 20:30:16 +08:00
|
|
|
warn "Unknown variable $k\n" unless $all{$k};
|
|
|
|
}
|
|
|
|
|
|
|
|
# This shouldn't be needed, but just in case we get relative paths that
|
|
|
|
# should be absolute, make sure they actually are.
|
|
|
|
foreach my $k (@absolutes) {
|
2023-05-03 18:29:00 +08:00
|
|
|
my $v = $ENV{$k} || '.';
|
2024-06-20 20:30:16 +08:00
|
|
|
print STDERR "DEBUG: $k = $v => ";
|
|
|
|
$v = File::Spec->rel2abs($v) if $v;
|
|
|
|
$ENV{$k} = $v;
|
|
|
|
print STDERR "$k = $ENV{$k}\n";
|
|
|
|
}
|
Add exporters for CMake
CMake's older package finder, FindOpenSSL.cmake, does a best guess effort
and doesn't always get it right.
By CMake's own documentation, that's what such modules are (best effort
attempts), and package producers are (strongly) encouraged to help out by
producing and installing <PackageName>Config.cmake files to get a more
deterministic configuration.
The resulting OpenSSLConfig.cmake tries to mimic the result from CMake's
FindOpenSSL.cmake, by using the same variable and imported target names.
It also adds a few extra variables of its own, such as:
OPENSSL_MODULES_DIR Indicates the default installation directory
for OpenSSL loadable modules, such as providers.
OPENSSL_RUNTIME_DIR Indicates the default runtime directory, where
for example the openssl program is located.
OPENSSL_PROGRAM Is the full directory-and-filename of the
openssl program.
The imported targets OpenSSL::Crypto and OpenSSL::SSL are as precisely
specified as possible, so for example, they are specified with the both the
import library and the DLL on Windows, which should make life easier on that
platform.
For the moment, one of the following must be done in your CMake project for
this CMake configuration to take priority over CMake's FindOpenSSL.cmake:
- The variable CMAKE_FIND_PACKAGE_PREFER_CONFIG must be set to true prior
to the 'find_package(OpenSSL)' call.
- The 'find_package' call itself must use the "Full Signature". If you
don't know any better, simply add the 'CONFIG' option, i.e. from this
example:
find_package(OpenSSL 3.0 REQUIRED)
to this:
find_package(OpenSSL 3.0 REQUIRED CONFIG)
Just as with the 'pkg-config' exporters, two variants of the .cmake files
are produced:
- Those in 'exporters/' are installed in the location that 'pkg-config'
itself prefers for installed packages.
- Those in the top directory are to be used when it's desirable to build
directly against an OpenSSL build tree.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20878)
2023-05-03 18:36:09 +08:00
|
|
|
|
2024-06-20 20:30:16 +08:00
|
|
|
# Absolute paths for the subdir variables are computed. This provides
|
|
|
|
# the usual form of values for names that have become norm, known as GNU
|
|
|
|
# installation paths.
|
|
|
|
# For the benefit of those that need it, the subdirectories are preserved
|
|
|
|
# as they are, using the same variable names, suffixed with '_REL_{var}',
|
|
|
|
# if they are indeed subdirectories. The '{var}' part of the name tells
|
|
|
|
# which other variable value they are relative to.
|
|
|
|
foreach my $pair (@subdirs) {
|
|
|
|
my ($var, $subdir_vars) = @$pair;
|
|
|
|
foreach my $k (@$subdir_vars) {
|
|
|
|
my $v = $ENV{$k} || '.';
|
|
|
|
print STDERR "DEBUG: $k = $v => ";
|
Add exporters for CMake
CMake's older package finder, FindOpenSSL.cmake, does a best guess effort
and doesn't always get it right.
By CMake's own documentation, that's what such modules are (best effort
attempts), and package producers are (strongly) encouraged to help out by
producing and installing <PackageName>Config.cmake files to get a more
deterministic configuration.
The resulting OpenSSLConfig.cmake tries to mimic the result from CMake's
FindOpenSSL.cmake, by using the same variable and imported target names.
It also adds a few extra variables of its own, such as:
OPENSSL_MODULES_DIR Indicates the default installation directory
for OpenSSL loadable modules, such as providers.
OPENSSL_RUNTIME_DIR Indicates the default runtime directory, where
for example the openssl program is located.
OPENSSL_PROGRAM Is the full directory-and-filename of the
openssl program.
The imported targets OpenSSL::Crypto and OpenSSL::SSL are as precisely
specified as possible, so for example, they are specified with the both the
import library and the DLL on Windows, which should make life easier on that
platform.
For the moment, one of the following must be done in your CMake project for
this CMake configuration to take priority over CMake's FindOpenSSL.cmake:
- The variable CMAKE_FIND_PACKAGE_PREFER_CONFIG must be set to true prior
to the 'find_package(OpenSSL)' call.
- The 'find_package' call itself must use the "Full Signature". If you
don't know any better, simply add the 'CONFIG' option, i.e. from this
example:
find_package(OpenSSL 3.0 REQUIRED)
to this:
find_package(OpenSSL 3.0 REQUIRED CONFIG)
Just as with the 'pkg-config' exporters, two variants of the .cmake files
are produced:
- Those in 'exporters/' are installed in the location that 'pkg-config'
itself prefers for installed packages.
- Those in the top directory are to be used when it's desirable to build
directly against an OpenSSL build tree.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20878)
2023-05-03 18:36:09 +08:00
|
|
|
if (File::Spec->file_name_is_absolute($v)) {
|
2024-06-20 20:30:16 +08:00
|
|
|
my $kr = "${k}_REL_${var}";
|
|
|
|
$ENV{$kr} = File::Spec->abs2rel($v, $ENV{$var});
|
|
|
|
print STDERR "$kr = $ENV{$kr}\n";
|
Add exporters for CMake
CMake's older package finder, FindOpenSSL.cmake, does a best guess effort
and doesn't always get it right.
By CMake's own documentation, that's what such modules are (best effort
attempts), and package producers are (strongly) encouraged to help out by
producing and installing <PackageName>Config.cmake files to get a more
deterministic configuration.
The resulting OpenSSLConfig.cmake tries to mimic the result from CMake's
FindOpenSSL.cmake, by using the same variable and imported target names.
It also adds a few extra variables of its own, such as:
OPENSSL_MODULES_DIR Indicates the default installation directory
for OpenSSL loadable modules, such as providers.
OPENSSL_RUNTIME_DIR Indicates the default runtime directory, where
for example the openssl program is located.
OPENSSL_PROGRAM Is the full directory-and-filename of the
openssl program.
The imported targets OpenSSL::Crypto and OpenSSL::SSL are as precisely
specified as possible, so for example, they are specified with the both the
import library and the DLL on Windows, which should make life easier on that
platform.
For the moment, one of the following must be done in your CMake project for
this CMake configuration to take priority over CMake's FindOpenSSL.cmake:
- The variable CMAKE_FIND_PACKAGE_PREFER_CONFIG must be set to true prior
to the 'find_package(OpenSSL)' call.
- The 'find_package' call itself must use the "Full Signature". If you
don't know any better, simply add the 'CONFIG' option, i.e. from this
example:
find_package(OpenSSL 3.0 REQUIRED)
to this:
find_package(OpenSSL 3.0 REQUIRED CONFIG)
Just as with the 'pkg-config' exporters, two variants of the .cmake files
are produced:
- Those in 'exporters/' are installed in the location that 'pkg-config'
itself prefers for installed packages.
- Those in the top directory are to be used when it's desirable to build
directly against an OpenSSL build tree.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20878)
2023-05-03 18:36:09 +08:00
|
|
|
} else {
|
2024-06-20 20:30:16 +08:00
|
|
|
my $kr = "${k}_REL_${var}";
|
|
|
|
$ENV{$kr} = $v;
|
|
|
|
$ENV{$k} = File::Spec->rel2abs($v, $ENV{$var});
|
|
|
|
print STDERR "$k = $ENV{$k} , $kr = $v\n";
|
Add exporters for CMake
CMake's older package finder, FindOpenSSL.cmake, does a best guess effort
and doesn't always get it right.
By CMake's own documentation, that's what such modules are (best effort
attempts), and package producers are (strongly) encouraged to help out by
producing and installing <PackageName>Config.cmake files to get a more
deterministic configuration.
The resulting OpenSSLConfig.cmake tries to mimic the result from CMake's
FindOpenSSL.cmake, by using the same variable and imported target names.
It also adds a few extra variables of its own, such as:
OPENSSL_MODULES_DIR Indicates the default installation directory
for OpenSSL loadable modules, such as providers.
OPENSSL_RUNTIME_DIR Indicates the default runtime directory, where
for example the openssl program is located.
OPENSSL_PROGRAM Is the full directory-and-filename of the
openssl program.
The imported targets OpenSSL::Crypto and OpenSSL::SSL are as precisely
specified as possible, so for example, they are specified with the both the
import library and the DLL on Windows, which should make life easier on that
platform.
For the moment, one of the following must be done in your CMake project for
this CMake configuration to take priority over CMake's FindOpenSSL.cmake:
- The variable CMAKE_FIND_PACKAGE_PREFER_CONFIG must be set to true prior
to the 'find_package(OpenSSL)' call.
- The 'find_package' call itself must use the "Full Signature". If you
don't know any better, simply add the 'CONFIG' option, i.e. from this
example:
find_package(OpenSSL 3.0 REQUIRED)
to this:
find_package(OpenSSL 3.0 REQUIRED CONFIG)
Just as with the 'pkg-config' exporters, two variants of the .cmake files
are produced:
- Those in 'exporters/' are installed in the location that 'pkg-config'
itself prefers for installed packages.
- Those in the top directory are to be used when it's desirable to build
directly against an OpenSSL build tree.
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20878)
2023-05-03 18:36:09 +08:00
|
|
|
}
|
|
|
|
}
|
2023-05-03 18:29:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
print <<_____;
|
|
|
|
package OpenSSL::safe::installdata;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Exporter;
|
|
|
|
our \@ISA = qw(Exporter);
|
2024-06-20 20:30:16 +08:00
|
|
|
our \@EXPORT = qw(
|
|
|
|
_____
|
|
|
|
|
|
|
|
foreach my $k (@absolutes) {
|
|
|
|
print " \$$k\n";
|
|
|
|
}
|
|
|
|
foreach my $pair (@subdirs) {
|
|
|
|
my ($var, $subdir_vars) = @$pair;
|
|
|
|
foreach my $k (@$subdir_vars) {
|
|
|
|
my $k2 = "${k}_REL_${var}";
|
|
|
|
print " \$$k \$$k2\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print <<_____;
|
|
|
|
\$VERSION \@LDLIBS
|
|
|
|
);
|
|
|
|
|
|
|
|
_____
|
|
|
|
|
|
|
|
foreach my $k (@absolutes) {
|
|
|
|
print "our \$$k" . ' ' x (27 - length($k)) . "= '$ENV{$k}';\n";
|
|
|
|
}
|
|
|
|
foreach my $pair (@subdirs) {
|
|
|
|
my ($var, $subdir_vars) = @$pair;
|
|
|
|
foreach my $k (@$subdir_vars) {
|
|
|
|
my $k2 = "${k}_REL_${var}";
|
|
|
|
print "our \$$k" . ' ' x (27 - length($k)) . "= '$ENV{$k}';\n";
|
|
|
|
print "our \$$k2" . ' ' x (27 - length($k2)) . "= '$ENV{$k2}';\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print <<_____;
|
|
|
|
our \$VERSION = '$ENV{VERSION}';
|
|
|
|
our \@LDLIBS =
|
2023-05-03 18:29:00 +08:00
|
|
|
# Unix and Windows use space separation, VMS uses comma separation
|
|
|
|
split(/ +| *, */, '$ENV{LDLIBS}');
|
|
|
|
|
|
|
|
1;
|
|
|
|
_____
|