]>
Commit | Line | Data |
---|---|---|
2ac569a6 RL |
1 | #! /usr/bin/env perl |
2 | # Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. | |
3 | # | |
4 | # Licensed under the Apache License 2.0 (the "License"). You may not use | |
5 | # this file except in compliance with the License. You can obtain a copy | |
6 | # in the file LICENSE in the source distribution or at | |
7 | # https://www.openssl.org/source/license.html | |
8 | ||
9 | # All variables are supposed to come from Makefile, in environment variable | |
10 | # form, or passed as variable assignments on the command line. | |
11 | # The result is a Perl module creating the package OpenSSL::safe::installdata. | |
12 | ||
13 | use File::Spec; | |
14 | ||
15 | # These are expected to be set up as absolute directories | |
16 | my @absolutes = qw(PREFIX); | |
17 | # These may be absolute directories, and if not, they are expected to be set up | |
18 | # as subdirectories to PREFIX | |
c768cceb RL |
19 | my @subdirs = qw(BINDIR LIBDIR INCLUDEDIR APPLINKDIR ENGINESDIR MODULESDIR |
20 | PKGCONFIGDIR CMAKECONFIGDIR); | |
2ac569a6 RL |
21 | |
22 | my %keys = (); | |
23 | foreach (@ARGV) { | |
24 | (my $k, my $v) = m|^([^=]*)=(.*)$|; | |
25 | $keys{$k} = 1; | |
26 | $ENV{$k} = $v; | |
27 | } | |
c768cceb | 28 | |
2ac569a6 RL |
29 | foreach my $k (sort keys %keys) { |
30 | my $v = $ENV{$k}; | |
31 | $v = File::Spec->rel2abs($v) if $v && grep { $k eq $_ } @absolutes; | |
32 | $ENV{$k} = $v; | |
33 | } | |
34 | foreach my $k (sort keys %keys) { | |
35 | my $v = $ENV{$k} || '.'; | |
c768cceb RL |
36 | |
37 | # Absolute paths for the subdir variables are computed. This provides | |
38 | # the usual form of values for names that have become norm, known as GNU | |
39 | # installation paths. | |
40 | # For the benefit of those that need it, the subdirectories are preserved | |
41 | # as they are, using the same variable names, suffixed with '_REL', if they | |
42 | # are indeed subdirectories. | |
43 | if (grep { $k eq $_ } @subdirs) { | |
44 | if (File::Spec->file_name_is_absolute($v)) { | |
45 | $ENV{"${k}_REL"} = File::Spec->abs2rel($v, $ENV{PREFIX}); | |
46 | } else { | |
47 | $ENV{"${k}_REL"} = $v; | |
48 | $v = File::Spec->rel2abs($v, $ENV{PREFIX}); | |
49 | } | |
50 | } | |
2ac569a6 RL |
51 | $ENV{$k} = $v; |
52 | } | |
53 | ||
54 | print <<_____; | |
55 | package OpenSSL::safe::installdata; | |
56 | ||
57 | use strict; | |
58 | use warnings; | |
59 | use Exporter; | |
60 | our \@ISA = qw(Exporter); | |
c768cceb RL |
61 | our \@EXPORT = qw(\$PREFIX |
62 | \$BINDIR \$BINDIR_REL | |
63 | \$LIBDIR \$LIBDIR_REL | |
64 | \$INCLUDEDIR \$INCLUDEDIR_REL | |
65 | \$APPLINKDIR \$APPLINKDIR_REL | |
66 | \$ENGINESDIR \$ENGINESDIR_REL | |
67 | \$MODULESDIR \$MODULESDIR_REL | |
68 | \$PKGCONFIGDIR \$PKGCONFIGDIR_REL | |
69 | \$CMAKECONFIGDIR \$CMAKECONFIGDIR_REL | |
70 | \$VERSION \@LDLIBS); | |
71 | ||
72 | our \$PREFIX = '$ENV{PREFIX}'; | |
73 | our \$BINDIR = '$ENV{BINDIR}'; | |
74 | our \$BINDIR_REL = '$ENV{BINDIR_REL}'; | |
75 | our \$LIBDIR = '$ENV{LIBDIR}'; | |
76 | our \$LIBDIR_REL = '$ENV{LIBDIR_REL}'; | |
77 | our \$INCLUDEDIR = '$ENV{INCLUDEDIR}'; | |
78 | our \$INCLUDEDIR_REL = '$ENV{INCLUDEDIR_REL}'; | |
79 | our \$APPLINKDIR = '$ENV{APPLINKDIR}'; | |
80 | our \$APPLINKDIR_REL = '$ENV{APPLINKDIR_REL}'; | |
81 | our \$ENGINESDIR = '$ENV{ENGINESDIR}'; | |
82 | our \$ENGINESDIR_REL = '$ENV{ENGINESDIR_REL}'; | |
83 | our \$MODULESDIR = '$ENV{MODULESDIR}'; | |
84 | our \$MODULESDIR_REL = '$ENV{MODULESDIR_REL}'; | |
85 | our \$PKGCONFIGDIR = '$ENV{PKGCONFIGDIR}'; | |
86 | our \$PKGCONFIGDIR_REL = '$ENV{PKGCONFIGDIR_REL}'; | |
87 | our \$CMAKECONFIGDIR = '$ENV{CMAKECONFIGDIR}'; | |
88 | our \$CMAKECONFIGDIR_REL = '$ENV{CMAKECONFIGDIR_REL}'; | |
89 | our \$VERSION = '$ENV{VERSION}'; | |
90 | our \@LDLIBS = | |
2ac569a6 RL |
91 | # Unix and Windows use space separation, VMS uses comma separation |
92 | split(/ +| *, */, '$ENV{LDLIBS}'); | |
93 | ||
94 | 1; | |
95 | _____ |