summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2023-05-03 12:29:00 +0200
committerRichard Levitte <levitte@openssl.org>2023-11-15 08:22:29 +0100
commit2ac569a67b9d0980efa2d8061a6a61e0645f37a7 (patch)
treed10a44241363b75c52cdc14c839ae6ee8ff77503 /util
parentfe487609c17dac049f867f230e09ee090b65e966 (diff)
Clean up exporters, specifically those we have for pkg-config
The pkg-config exporters were a special hack, all in Configurations/unix-Makefile.tmpl, and this was well and good as long as that was the only main package interface configuration system that we cared about. Things have changed, though, so we move the pkg-config production to be templatable in a more flexible manner. Additional templates for other interface configuration systems can then be added fairly easily. Two variants of the .pc 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)
Diffstat (limited to 'util')
-rw-r--r--util/mkinstallvars.pl63
1 files changed, 63 insertions, 0 deletions
diff --git a/util/mkinstallvars.pl b/util/mkinstallvars.pl
new file mode 100644
index 0000000000..d0688cfd0b
--- /dev/null
+++ b/util/mkinstallvars.pl
@@ -0,0 +1,63 @@
+#! /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;
+
+# These are expected to be set up as absolute directories
+my @absolutes = qw(PREFIX);
+# These may be absolute directories, and if not, they are expected to be set up
+# as subdirectories to PREFIX
+my @subdirs = qw(BINDIR LIBDIR INCLUDEDIR ENGINESDIR MODULESDIR APPLINKDIR);
+
+my %keys = ();
+foreach (@ARGV) {
+ (my $k, my $v) = m|^([^=]*)=(.*)$|;
+ $keys{$k} = 1;
+ $ENV{$k} = $v;
+}
+foreach my $k (sort keys %keys) {
+ my $v = $ENV{$k};
+ $v = File::Spec->rel2abs($v) if $v && grep { $k eq $_ } @absolutes;
+ $ENV{$k} = $v;
+}
+foreach my $k (sort keys %keys) {
+ my $v = $ENV{$k} || '.';
+ $v = File::Spec->rel2abs($v, $ENV{PREFIX})
+ if ($v && !File::Spec->file_name_is_absolute($v)
+ && grep { $k eq $_ } @subdirs);
+ $ENV{$k} = $v;
+}
+
+print <<_____;
+package OpenSSL::safe::installdata;
+
+use strict;
+use warnings;
+use Exporter;
+our \@ISA = qw(Exporter);
+our \@EXPORT = qw(\$PREFIX \$BINDIR \$LIBDIR \$INCLUDEDIR \$APPLINKDIR
+ \$ENGINESDIR \$MODULESDIR \$VERSION \$LDLIBS);
+
+our \$PREFIX = '$ENV{PREFIX}';
+our \$BINDIR = '$ENV{BINDIR}';
+our \$LIBDIR = '$ENV{LIBDIR}';
+our \$INCLUDEDIR = '$ENV{INCLUDEDIR}';
+our \$ENGINESDIR = '$ENV{ENGINESDIR}';
+our \$MODULESDIR = '$ENV{MODULESDIR}';
+our \$APPLINKDIR = '$ENV{APPLINKDIR}';
+our \$VERSION = '$ENV{VERSION}';
+our \@LDLIBS =
+ # Unix and Windows use space separation, VMS uses comma separation
+ split(/ +| *, */, '$ENV{LDLIBS}');
+
+1;
+_____