1e1051a39Sopenharmony_ci#! {- $config{HASHBANGPERL} -}
2e1051a39Sopenharmony_ci# -*- mode: perl -*-
3e1051a39Sopenharmony_ci{-
4e1051a39Sopenharmony_ci # We must make sourcedir() return an absolute path, because configdata.pm
5e1051a39Sopenharmony_ci # may be loaded as a module from any script in any directory, making
6e1051a39Sopenharmony_ci # relative paths untrustable.  Because the result is used with 'use lib',
7e1051a39Sopenharmony_ci # we must ensure that it returns a Unix style path.  Mixing File::Spec
8e1051a39Sopenharmony_ci # and File::Spec::Unix does just that.
9e1051a39Sopenharmony_ci use File::Spec::Unix;
10e1051a39Sopenharmony_ci use File::Spec;
11e1051a39Sopenharmony_ci use Cwd qw(abs_path);
12e1051a39Sopenharmony_ci sub _fixup_path {
13e1051a39Sopenharmony_ci     my $path = shift;
14e1051a39Sopenharmony_ci
15e1051a39Sopenharmony_ci     # Make the path absolute at all times
16e1051a39Sopenharmony_ci     $path = abs_path($path);
17e1051a39Sopenharmony_ci
18e1051a39Sopenharmony_ci     if ($^O eq 'VMS') {
19e1051a39Sopenharmony_ci         # Convert any path of the VMS form VOLUME:[DIR1.DIR2]FILE to the
20e1051a39Sopenharmony_ci         # Unix form /VOLUME/DIR1/DIR2/FILE, which is what VMS perl supports
21e1051a39Sopenharmony_ci         # for 'use lib'.
22e1051a39Sopenharmony_ci
23e1051a39Sopenharmony_ci         # Start with spliting the native path
24e1051a39Sopenharmony_ci         (my $vol, my $dirs, my $file) = File::Spec->splitpath($path);
25e1051a39Sopenharmony_ci         my @dirs = File::Spec->splitdir($dirs);
26e1051a39Sopenharmony_ci
27e1051a39Sopenharmony_ci         # Reassemble it as a Unix path
28e1051a39Sopenharmony_ci         $vol =~ s|:$||;
29e1051a39Sopenharmony_ci         $dirs = File::Spec::Unix->catdir('', $vol, @dirs);
30e1051a39Sopenharmony_ci         $path = File::Spec::Unix->catpath('', $dirs, $file);
31e1051a39Sopenharmony_ci     }
32e1051a39Sopenharmony_ci
33e1051a39Sopenharmony_ci     return $path;
34e1051a39Sopenharmony_ci }
35e1051a39Sopenharmony_ci sub sourcedir {
36e1051a39Sopenharmony_ci     return _fixup_path(File::Spec->catdir($config{sourcedir}, @_))
37e1051a39Sopenharmony_ci }
38e1051a39Sopenharmony_ci sub sourcefile {
39e1051a39Sopenharmony_ci     return _fixup_path(File::Spec->catfile($config{sourcedir}, @_))
40e1051a39Sopenharmony_ci }
41e1051a39Sopenharmony_ci use lib sourcedir('util', 'perl');
42e1051a39Sopenharmony_ci use OpenSSL::Util;
43e1051a39Sopenharmony_ci-}
44e1051a39Sopenharmony_cipackage configdata;
45e1051a39Sopenharmony_ci
46e1051a39Sopenharmony_ciuse strict;
47e1051a39Sopenharmony_ciuse warnings;
48e1051a39Sopenharmony_ci
49e1051a39Sopenharmony_ciuse Exporter;
50e1051a39Sopenharmony_ciour @ISA = qw(Exporter);
51e1051a39Sopenharmony_ciour @EXPORT = qw(
52e1051a39Sopenharmony_ci    %config %target %disabled %withargs %unified_info
53e1051a39Sopenharmony_ci    @disablables @disablables_int
54e1051a39Sopenharmony_ci);
55e1051a39Sopenharmony_ci
56e1051a39Sopenharmony_ciour %config = ({- dump_data(\%config, indent => 0); -});
57e1051a39Sopenharmony_ciour %target = ({- dump_data(\%target, indent => 0); -});
58e1051a39Sopenharmony_ciour @disablables = ({- dump_data(\@disablables, indent => 0) -});
59e1051a39Sopenharmony_ciour @disablables_int = ({- dump_data(\@disablables_int, indent => 0) -});
60e1051a39Sopenharmony_ciour %disabled = ({- dump_data(\%disabled, indent => 0); -});
61e1051a39Sopenharmony_ciour %withargs = ({- dump_data(\%withargs, indent => 0); -});
62e1051a39Sopenharmony_ciour %unified_info = ({- dump_data(\%unified_info, indent => 0); -});
63e1051a39Sopenharmony_ci
64e1051a39Sopenharmony_ci# Unexported, only used by OpenSSL::Test::Utils::available_protocols()
65e1051a39Sopenharmony_ciour %available_protocols = (
66e1051a39Sopenharmony_ci    tls  => [{- dump_data(\@tls, indent => 0) -}],
67e1051a39Sopenharmony_ci    dtls => [{- dump_data(\@dtls, indent => 0) -}],
68e1051a39Sopenharmony_ci);
69e1051a39Sopenharmony_ci
70e1051a39Sopenharmony_ci# The following data is only used when this files is use as a script
71e1051a39Sopenharmony_cimy @makevars = ({- dump_data(\@makevars, indent => 0); -});
72e1051a39Sopenharmony_cimy %disabled_info = ({- dump_data(\%disabled_info, indent => 0); -});
73e1051a39Sopenharmony_cimy @user_crossable = qw( {- join (' ', @user_crossable) -} );
74e1051a39Sopenharmony_ci
75e1051a39Sopenharmony_ci# If run directly, we can give some answers, and even reconfigure
76e1051a39Sopenharmony_ciunless (caller) {
77e1051a39Sopenharmony_ci    use Getopt::Long;
78e1051a39Sopenharmony_ci    use File::Spec::Functions;
79e1051a39Sopenharmony_ci    use File::Basename;
80e1051a39Sopenharmony_ci    use File::Compare qw(compare_text);
81e1051a39Sopenharmony_ci    use File::Copy;
82e1051a39Sopenharmony_ci    use Pod::Usage;
83e1051a39Sopenharmony_ci
84e1051a39Sopenharmony_ci    use lib '{- sourcedir('util', 'perl') -}';
85e1051a39Sopenharmony_ci    use OpenSSL::fallback '{- sourcefile('external', 'perl', 'MODULES.txt') -}';
86e1051a39Sopenharmony_ci
87e1051a39Sopenharmony_ci    my $here = dirname($0);
88e1051a39Sopenharmony_ci
89e1051a39Sopenharmony_ci    if (scalar @ARGV == 0) {
90e1051a39Sopenharmony_ci        # With no arguments, re-create the build file
91e1051a39Sopenharmony_ci        # We do that in two steps, where the first step emits perl
92e1051a39Sopenharmony_ci        # snipets.
93e1051a39Sopenharmony_ci
94e1051a39Sopenharmony_ci        my $buildfile = $config{build_file};
95e1051a39Sopenharmony_ci        my $buildfile_template = "$buildfile.in";
96e1051a39Sopenharmony_ci        my @autowarntext = (
97e1051a39Sopenharmony_ci            'WARNING: do not edit!',
98e1051a39Sopenharmony_ci            "Generated by configdata.pm from "
99e1051a39Sopenharmony_ci            .join(", ", @{$config{build_file_templates}}),
100e1051a39Sopenharmony_ci            "via $buildfile_template"
101e1051a39Sopenharmony_ci        );
102e1051a39Sopenharmony_ci        my %gendata = (
103e1051a39Sopenharmony_ci            config => \%config,
104e1051a39Sopenharmony_ci            target => \%target,
105e1051a39Sopenharmony_ci            disabled => \%disabled,
106e1051a39Sopenharmony_ci            withargs => \%withargs,
107e1051a39Sopenharmony_ci            unified_info => \%unified_info,
108e1051a39Sopenharmony_ci            autowarntext => \@autowarntext,
109e1051a39Sopenharmony_ci            );
110e1051a39Sopenharmony_ci
111e1051a39Sopenharmony_ci        use lib '.';
112e1051a39Sopenharmony_ci        use lib '{- sourcedir('Configurations') -}';
113e1051a39Sopenharmony_ci        use gentemplate;
114e1051a39Sopenharmony_ci
115e1051a39Sopenharmony_ci        open my $buildfile_template_fh, ">$buildfile_template"
116e1051a39Sopenharmony_ci            or die "Trying to create $buildfile_template: $!";
117e1051a39Sopenharmony_ci        foreach (@{$config{build_file_templates}}) {
118e1051a39Sopenharmony_ci            copy($_, $buildfile_template_fh)
119e1051a39Sopenharmony_ci                or die "Trying to copy $_ into $buildfile_template: $!";
120e1051a39Sopenharmony_ci        }
121e1051a39Sopenharmony_ci        gentemplate(output => $buildfile_template_fh, %gendata);
122e1051a39Sopenharmony_ci        close $buildfile_template_fh;
123e1051a39Sopenharmony_ci        print 'Created ',$buildfile_template,"\n";
124e1051a39Sopenharmony_ci
125e1051a39Sopenharmony_ci        use OpenSSL::Template;
126e1051a39Sopenharmony_ci
127e1051a39Sopenharmony_ci        my $prepend = <<'_____';
128e1051a39Sopenharmony_ciuse File::Spec::Functions;
129e1051a39Sopenharmony_ciuse lib '{- sourcedir('util', 'perl') -}';
130e1051a39Sopenharmony_ciuse lib '{- sourcedir('Configurations') -}';
131e1051a39Sopenharmony_ciuse lib '{- $config{builddir} -}';
132e1051a39Sopenharmony_ciuse platform;
133e1051a39Sopenharmony_ci_____
134e1051a39Sopenharmony_ci
135e1051a39Sopenharmony_ci        my $tmpl;
136e1051a39Sopenharmony_ci        open BUILDFILE, ">$buildfile.new"
137e1051a39Sopenharmony_ci            or die "Trying to create $buildfile.new: $!";
138e1051a39Sopenharmony_ci        $tmpl = OpenSSL::Template->new(TYPE => 'FILE',
139e1051a39Sopenharmony_ci                                       SOURCE => $buildfile_template);
140e1051a39Sopenharmony_ci        $tmpl->fill_in(FILENAME => $_,
141e1051a39Sopenharmony_ci                       OUTPUT => \*BUILDFILE,
142e1051a39Sopenharmony_ci                       HASH => \%gendata,
143e1051a39Sopenharmony_ci                       PREPEND => $prepend,
144e1051a39Sopenharmony_ci                       # To ensure that global variables and functions
145e1051a39Sopenharmony_ci                       # defined in one template stick around for the
146e1051a39Sopenharmony_ci                       # next, making them combinable
147e1051a39Sopenharmony_ci                       PACKAGE => 'OpenSSL::safe')
148e1051a39Sopenharmony_ci            or die $Text::Template::ERROR;
149e1051a39Sopenharmony_ci        close BUILDFILE;
150e1051a39Sopenharmony_ci        rename("$buildfile.new", $buildfile)
151e1051a39Sopenharmony_ci            or die "Trying to rename $buildfile.new to $buildfile: $!";
152e1051a39Sopenharmony_ci        print 'Created ',$buildfile,"\n";
153e1051a39Sopenharmony_ci
154e1051a39Sopenharmony_ci        my $configuration_h =
155e1051a39Sopenharmony_ci            catfile('include', 'openssl', 'configuration.h');
156e1051a39Sopenharmony_ci        my $configuration_h_in =
157e1051a39Sopenharmony_ci            catfile($config{sourcedir}, 'include', 'openssl', 'configuration.h.in');
158e1051a39Sopenharmony_ci        open CONFIGURATION_H, ">${configuration_h}.new"
159e1051a39Sopenharmony_ci            or die "Trying to create ${configuration_h}.new: $!";
160e1051a39Sopenharmony_ci        $tmpl = OpenSSL::Template->new(TYPE => 'FILE',
161e1051a39Sopenharmony_ci                                       SOURCE => $configuration_h_in);
162e1051a39Sopenharmony_ci        $tmpl->fill_in(FILENAME => $_,
163e1051a39Sopenharmony_ci                       OUTPUT => \*CONFIGURATION_H,
164e1051a39Sopenharmony_ci                       HASH => \%gendata,
165e1051a39Sopenharmony_ci                       PREPEND => $prepend,
166e1051a39Sopenharmony_ci                       # To ensure that global variables and functions
167e1051a39Sopenharmony_ci                       # defined in one template stick around for the
168e1051a39Sopenharmony_ci                       # next, making them combinable
169e1051a39Sopenharmony_ci                       PACKAGE => 'OpenSSL::safe')
170e1051a39Sopenharmony_ci            or die $Text::Template::ERROR;
171e1051a39Sopenharmony_ci        close CONFIGURATION_H;
172e1051a39Sopenharmony_ci
173e1051a39Sopenharmony_ci        # When using stat() on Windows, we can get it to perform better by
174e1051a39Sopenharmony_ci        # avoid some data.  This doesn't affect the mtime field, so we're not
175e1051a39Sopenharmony_ci        # losing anything...
176e1051a39Sopenharmony_ci        ${^WIN32_SLOPPY_STAT} = 1;
177e1051a39Sopenharmony_ci
178e1051a39Sopenharmony_ci        my $update_configuration_h = 0;
179e1051a39Sopenharmony_ci        if (-f $configuration_h) {
180e1051a39Sopenharmony_ci            my $configuration_h_mtime = (stat($configuration_h))[9];
181e1051a39Sopenharmony_ci            my $configuration_h_in_mtime = (stat($configuration_h_in))[9];
182e1051a39Sopenharmony_ci
183e1051a39Sopenharmony_ci            # If configuration.h.in was updated after the last configuration.h,
184e1051a39Sopenharmony_ci            # or if configuration.h.new differs configuration.h, we update
185e1051a39Sopenharmony_ci            # configuration.h
186e1051a39Sopenharmony_ci            if ($configuration_h_mtime < $configuration_h_in_mtime
187e1051a39Sopenharmony_ci                || compare_text("${configuration_h}.new", $configuration_h) != 0) {
188e1051a39Sopenharmony_ci                $update_configuration_h = 1;
189e1051a39Sopenharmony_ci            } else {
190e1051a39Sopenharmony_ci                # If nothing has changed, let's just drop the new one and
191e1051a39Sopenharmony_ci                # pretend like nothing happened
192e1051a39Sopenharmony_ci                unlink "${configuration_h}.new"
193e1051a39Sopenharmony_ci            }
194e1051a39Sopenharmony_ci        } else {
195e1051a39Sopenharmony_ci            $update_configuration_h = 1;
196e1051a39Sopenharmony_ci        }
197e1051a39Sopenharmony_ci
198e1051a39Sopenharmony_ci        if ($update_configuration_h) {
199e1051a39Sopenharmony_ci            rename("${configuration_h}.new", $configuration_h)
200e1051a39Sopenharmony_ci                or die "Trying to rename ${configuration_h}.new to $configuration_h: $!";
201e1051a39Sopenharmony_ci            print 'Created ',$configuration_h,"\n";
202e1051a39Sopenharmony_ci        }
203e1051a39Sopenharmony_ci
204e1051a39Sopenharmony_ci        exit(0);
205e1051a39Sopenharmony_ci    }
206e1051a39Sopenharmony_ci
207e1051a39Sopenharmony_ci    my $dump = undef;
208e1051a39Sopenharmony_ci    my $cmdline = undef;
209e1051a39Sopenharmony_ci    my $options = undef;
210e1051a39Sopenharmony_ci    my $target = undef;
211e1051a39Sopenharmony_ci    my $envvars = undef;
212e1051a39Sopenharmony_ci    my $makevars = undef;
213e1051a39Sopenharmony_ci    my $buildparams = undef;
214e1051a39Sopenharmony_ci    my $reconf = undef;
215e1051a39Sopenharmony_ci    my $verbose = undef;
216e1051a39Sopenharmony_ci    my $query = undef;
217e1051a39Sopenharmony_ci    my $help = undef;
218e1051a39Sopenharmony_ci    my $man = undef;
219e1051a39Sopenharmony_ci    GetOptions('dump|d'                 => \$dump,
220e1051a39Sopenharmony_ci               'command-line|c'         => \$cmdline,
221e1051a39Sopenharmony_ci               'options|o'              => \$options,
222e1051a39Sopenharmony_ci               'target|t'               => \$target,
223e1051a39Sopenharmony_ci               'environment|e'          => \$envvars,
224e1051a39Sopenharmony_ci               'make-variables|m'       => \$makevars,
225e1051a39Sopenharmony_ci               'build-parameters|b'     => \$buildparams,
226e1051a39Sopenharmony_ci               'reconfigure|reconf|r'   => \$reconf,
227e1051a39Sopenharmony_ci               'verbose|v'              => \$verbose,
228e1051a39Sopenharmony_ci               'query|q=s'              => \$query,
229e1051a39Sopenharmony_ci               'help'                   => \$help,
230e1051a39Sopenharmony_ci               'man'                    => \$man)
231e1051a39Sopenharmony_ci        or die "Errors in command line arguments\n";
232e1051a39Sopenharmony_ci
233e1051a39Sopenharmony_ci    # We allow extra arguments with --query.  That allows constructs like
234e1051a39Sopenharmony_ci    # this:
235e1051a39Sopenharmony_ci    # ./configdata.pm --query 'get_sources(@ARGV)' file1 file2 file3
236e1051a39Sopenharmony_ci    if (!$query && scalar @ARGV > 0) {
237e1051a39Sopenharmony_ci        print STDERR <<"_____";
238e1051a39Sopenharmony_ciUnrecognised arguments.
239e1051a39Sopenharmony_ciFor more information, do '$0 --help'
240e1051a39Sopenharmony_ci_____
241e1051a39Sopenharmony_ci        exit(2);
242e1051a39Sopenharmony_ci    }
243e1051a39Sopenharmony_ci
244e1051a39Sopenharmony_ci    if ($help) {
245e1051a39Sopenharmony_ci        pod2usage(-exitval => 0,
246e1051a39Sopenharmony_ci                  -verbose => 1);
247e1051a39Sopenharmony_ci    }
248e1051a39Sopenharmony_ci    if ($man) {
249e1051a39Sopenharmony_ci        pod2usage(-exitval => 0,
250e1051a39Sopenharmony_ci                  -verbose => 2);
251e1051a39Sopenharmony_ci    }
252e1051a39Sopenharmony_ci    if ($dump || $cmdline) {
253e1051a39Sopenharmony_ci        print "\nCommand line (with current working directory = $here):\n\n";
254e1051a39Sopenharmony_ci        print '    ',join(' ',
255e1051a39Sopenharmony_ci                          $config{PERL},
256e1051a39Sopenharmony_ci                          catfile($config{sourcedir}, 'Configure'),
257e1051a39Sopenharmony_ci                          @{$config{perlargv}}), "\n";
258e1051a39Sopenharmony_ci        print "\nPerl information:\n\n";
259e1051a39Sopenharmony_ci        print '    ',$config{perl_cmd},"\n";
260e1051a39Sopenharmony_ci        print '    ',$config{perl_version},' for ',$config{perl_archname},"\n";
261e1051a39Sopenharmony_ci    }
262e1051a39Sopenharmony_ci    if ($dump || $options) {
263e1051a39Sopenharmony_ci        my $longest = 0;
264e1051a39Sopenharmony_ci        my $longest2 = 0;
265e1051a39Sopenharmony_ci        foreach my $what (@disablables) {
266e1051a39Sopenharmony_ci            $longest = length($what) if $longest < length($what);
267e1051a39Sopenharmony_ci            $longest2 = length($disabled{$what})
268e1051a39Sopenharmony_ci                if $disabled{$what} && $longest2 < length($disabled{$what});
269e1051a39Sopenharmony_ci        }
270e1051a39Sopenharmony_ci        print "\nEnabled features:\n\n";
271e1051a39Sopenharmony_ci        foreach my $what (@disablables) {
272e1051a39Sopenharmony_ci            print "    $what\n" unless $disabled{$what};
273e1051a39Sopenharmony_ci        }
274e1051a39Sopenharmony_ci        print "\nDisabled features:\n\n";
275e1051a39Sopenharmony_ci        foreach my $what (@disablables) {
276e1051a39Sopenharmony_ci            if ($disabled{$what}) {
277e1051a39Sopenharmony_ci                print "    $what", ' ' x ($longest - length($what) + 1),
278e1051a39Sopenharmony_ci                    "[$disabled{$what}]", ' ' x ($longest2 - length($disabled{$what}) + 1);
279e1051a39Sopenharmony_ci                print $disabled_info{$what}->{macro}
280e1051a39Sopenharmony_ci                    if $disabled_info{$what}->{macro};
281e1051a39Sopenharmony_ci                print ' (skip ',
282e1051a39Sopenharmony_ci                    join(', ', @{$disabled_info{$what}->{skipped}}),
283e1051a39Sopenharmony_ci                    ')'
284e1051a39Sopenharmony_ci                    if $disabled_info{$what}->{skipped};
285e1051a39Sopenharmony_ci                print "\n";
286e1051a39Sopenharmony_ci            }
287e1051a39Sopenharmony_ci        }
288e1051a39Sopenharmony_ci    }
289e1051a39Sopenharmony_ci    if ($dump || $target) {
290e1051a39Sopenharmony_ci        print "\nConfig target attributes:\n\n";
291e1051a39Sopenharmony_ci        foreach (sort keys %target) {
292e1051a39Sopenharmony_ci            next if $_ =~ m|^_| || $_ eq 'template';
293e1051a39Sopenharmony_ci            my $quotify = sub {
294e1051a39Sopenharmony_ci                map {
295e1051a39Sopenharmony_ci                    if (defined $_) {
296e1051a39Sopenharmony_ci                        (my $x = $_) =~ s|([\\\$\@"])|\\$1|g; "\"$x\""
297e1051a39Sopenharmony_ci                    } else {
298e1051a39Sopenharmony_ci                        "undef";
299e1051a39Sopenharmony_ci                    }
300e1051a39Sopenharmony_ci                } @_;
301e1051a39Sopenharmony_ci            };
302e1051a39Sopenharmony_ci            print '    ', $_, ' => ';
303e1051a39Sopenharmony_ci            if (ref($target{$_}) eq "ARRAY") {
304e1051a39Sopenharmony_ci                print '[ ', join(', ', $quotify->(@{$target{$_}})), " ],\n";
305e1051a39Sopenharmony_ci            } else {
306e1051a39Sopenharmony_ci                print $quotify->($target{$_}), ",\n"
307e1051a39Sopenharmony_ci            }
308e1051a39Sopenharmony_ci        }
309e1051a39Sopenharmony_ci    }
310e1051a39Sopenharmony_ci    if ($dump || $envvars) {
311e1051a39Sopenharmony_ci        print "\nRecorded environment:\n\n";
312e1051a39Sopenharmony_ci        foreach (sort keys %{$config{perlenv}}) {
313e1051a39Sopenharmony_ci            print '    ',$_,' = ',($config{perlenv}->{$_} || ''),"\n";
314e1051a39Sopenharmony_ci        }
315e1051a39Sopenharmony_ci    }
316e1051a39Sopenharmony_ci    if ($dump || $makevars) {
317e1051a39Sopenharmony_ci        print "\nMakevars:\n\n";
318e1051a39Sopenharmony_ci        foreach my $var (@makevars) {
319e1051a39Sopenharmony_ci            my $prefix = '';
320e1051a39Sopenharmony_ci            $prefix = $config{CROSS_COMPILE}
321e1051a39Sopenharmony_ci                if grep { $var eq $_ } @user_crossable;
322e1051a39Sopenharmony_ci            $prefix //= '';
323e1051a39Sopenharmony_ci            print '    ',$var,' ' x (16 - length $var),'= ',
324e1051a39Sopenharmony_ci                (ref $config{$var} eq 'ARRAY'
325e1051a39Sopenharmony_ci                 ? join(' ', @{$config{$var}})
326e1051a39Sopenharmony_ci                 : $prefix.$config{$var}),
327e1051a39Sopenharmony_ci                "\n"
328e1051a39Sopenharmony_ci                if defined $config{$var};
329e1051a39Sopenharmony_ci        }
330e1051a39Sopenharmony_ci
331e1051a39Sopenharmony_ci        my @buildfile = ($config{builddir}, $config{build_file});
332e1051a39Sopenharmony_ci        unshift @buildfile, $here
333e1051a39Sopenharmony_ci            unless file_name_is_absolute($config{builddir});
334e1051a39Sopenharmony_ci        my $buildfile = canonpath(catdir(@buildfile));
335e1051a39Sopenharmony_ci        print <<"_____";
336e1051a39Sopenharmony_ci
337e1051a39Sopenharmony_ciNOTE: These variables only represent the configuration view.  The build file
338e1051a39Sopenharmony_citemplate may have processed these variables further, please have a look at the
339e1051a39Sopenharmony_cibuild file for more exact data:
340e1051a39Sopenharmony_ci    $buildfile
341e1051a39Sopenharmony_ci_____
342e1051a39Sopenharmony_ci    }
343e1051a39Sopenharmony_ci    if ($dump || $buildparams) {
344e1051a39Sopenharmony_ci        my @buildfile = ($config{builddir}, $config{build_file});
345e1051a39Sopenharmony_ci        unshift @buildfile, $here
346e1051a39Sopenharmony_ci            unless file_name_is_absolute($config{builddir});
347e1051a39Sopenharmony_ci        print "\nbuild file:\n\n";
348e1051a39Sopenharmony_ci        print "    ", canonpath(catfile(@buildfile)),"\n";
349e1051a39Sopenharmony_ci
350e1051a39Sopenharmony_ci        print "\nbuild file templates:\n\n";
351e1051a39Sopenharmony_ci        foreach (@{$config{build_file_templates}}) {
352e1051a39Sopenharmony_ci            my @tmpl = ($_);
353e1051a39Sopenharmony_ci            unshift @tmpl, $here
354e1051a39Sopenharmony_ci                unless file_name_is_absolute($config{sourcedir});
355e1051a39Sopenharmony_ci            print '    ',canonpath(catfile(@tmpl)),"\n";
356e1051a39Sopenharmony_ci        }
357e1051a39Sopenharmony_ci    }
358e1051a39Sopenharmony_ci    if ($reconf) {
359e1051a39Sopenharmony_ci        if ($verbose) {
360e1051a39Sopenharmony_ci            print 'Reconfiguring with: ', join(' ',@{$config{perlargv}}), "\n";
361e1051a39Sopenharmony_ci            foreach (sort keys %{$config{perlenv}}) {
362e1051a39Sopenharmony_ci                print '    ',$_,' = ',($config{perlenv}->{$_} || ""),"\n";
363e1051a39Sopenharmony_ci            }
364e1051a39Sopenharmony_ci        }
365e1051a39Sopenharmony_ci
366e1051a39Sopenharmony_ci        chdir $here;
367e1051a39Sopenharmony_ci        exec $^X,catfile($config{sourcedir}, 'Configure'),'reconf';
368e1051a39Sopenharmony_ci    }
369e1051a39Sopenharmony_ci    if ($query) {
370e1051a39Sopenharmony_ci        use OpenSSL::Config::Query;
371e1051a39Sopenharmony_ci
372e1051a39Sopenharmony_ci        my $confquery = OpenSSL::Config::Query->new(info => \%unified_info,
373e1051a39Sopenharmony_ci                                                    config => \%config);
374e1051a39Sopenharmony_ci        my $result = eval "\$confquery->$query";
375e1051a39Sopenharmony_ci
376e1051a39Sopenharmony_ci        # We may need a result class with a printing function at some point.
377e1051a39Sopenharmony_ci        # Until then, we assume that we get a scalar, or a list or a hash table
378e1051a39Sopenharmony_ci        # with scalar values and simply print them in some orderly fashion.
379e1051a39Sopenharmony_ci        if (ref $result eq 'ARRAY') {
380e1051a39Sopenharmony_ci            print "$_\n" foreach @$result;
381e1051a39Sopenharmony_ci        } elsif (ref $result eq 'HASH') {
382e1051a39Sopenharmony_ci            print "$_ : \\\n  ", join(" \\\n  ", @{$result->{$_}}), "\n"
383e1051a39Sopenharmony_ci                foreach sort keys %$result;
384e1051a39Sopenharmony_ci        } elsif (ref $result eq 'SCALAR') {
385e1051a39Sopenharmony_ci            print "$$result\n";
386e1051a39Sopenharmony_ci        }
387e1051a39Sopenharmony_ci    }
388e1051a39Sopenharmony_ci}
389e1051a39Sopenharmony_ci
390e1051a39Sopenharmony_ci1;
391e1051a39Sopenharmony_ci
392e1051a39Sopenharmony_ci__END__
393e1051a39Sopenharmony_ci
394e1051a39Sopenharmony_ci=head1 NAME
395e1051a39Sopenharmony_ci
396e1051a39Sopenharmony_ciconfigdata.pm - configuration data for OpenSSL builds
397e1051a39Sopenharmony_ci
398e1051a39Sopenharmony_ci=head1 SYNOPSIS
399e1051a39Sopenharmony_ci
400e1051a39Sopenharmony_ciInteractive:
401e1051a39Sopenharmony_ci
402e1051a39Sopenharmony_ci  perl configdata.pm [options]
403e1051a39Sopenharmony_ci
404e1051a39Sopenharmony_ciAs data bank module:
405e1051a39Sopenharmony_ci
406e1051a39Sopenharmony_ci  use configdata;
407e1051a39Sopenharmony_ci
408e1051a39Sopenharmony_ci=head1 DESCRIPTION
409e1051a39Sopenharmony_ci
410e1051a39Sopenharmony_ciThis module can be used in two modes, interactively and as a module containing
411e1051a39Sopenharmony_ciall the data recorded by OpenSSL's Configure script.
412e1051a39Sopenharmony_ci
413e1051a39Sopenharmony_ciWhen used interactively, simply run it as any perl script.
414e1051a39Sopenharmony_ciIf run with no arguments, it will rebuild the build file (Makefile or
415e1051a39Sopenharmony_cicorresponding).
416e1051a39Sopenharmony_ciWith at least one option, it will instead get the information you ask for, or
417e1051a39Sopenharmony_cire-run the configuration process.
418e1051a39Sopenharmony_ciSee L</OPTIONS> below for more information.
419e1051a39Sopenharmony_ci
420e1051a39Sopenharmony_ciWhen loaded as a module, you get a few databanks with useful information to
421e1051a39Sopenharmony_ciperform build related tasks.  The databanks are:
422e1051a39Sopenharmony_ci
423e1051a39Sopenharmony_ci    %config             Configured things.
424e1051a39Sopenharmony_ci    %target             The OpenSSL config target with all inheritances
425e1051a39Sopenharmony_ci                        resolved.
426e1051a39Sopenharmony_ci    %disabled           The features that are disabled.
427e1051a39Sopenharmony_ci    @disablables        The list of features that can be disabled.
428e1051a39Sopenharmony_ci    %withargs           All data given through --with-THING options.
429e1051a39Sopenharmony_ci    %unified_info       All information that was computed from the build.info
430e1051a39Sopenharmony_ci                        files.
431e1051a39Sopenharmony_ci
432e1051a39Sopenharmony_ci=head1 OPTIONS
433e1051a39Sopenharmony_ci
434e1051a39Sopenharmony_ci=over 4
435e1051a39Sopenharmony_ci
436e1051a39Sopenharmony_ci=item B<--help>
437e1051a39Sopenharmony_ci
438e1051a39Sopenharmony_ciPrint a brief help message and exit.
439e1051a39Sopenharmony_ci
440e1051a39Sopenharmony_ci=item B<--man>
441e1051a39Sopenharmony_ci
442e1051a39Sopenharmony_ciPrint the manual page and exit.
443e1051a39Sopenharmony_ci
444e1051a39Sopenharmony_ci=item B<--dump> | B<-d>
445e1051a39Sopenharmony_ci
446e1051a39Sopenharmony_ciPrint all relevant configuration data.  This is equivalent to B<--command-line>
447e1051a39Sopenharmony_ciB<--options> B<--target> B<--environment> B<--make-variables>
448e1051a39Sopenharmony_ciB<--build-parameters>.
449e1051a39Sopenharmony_ci
450e1051a39Sopenharmony_ci=item B<--command-line> | B<-c>
451e1051a39Sopenharmony_ci
452e1051a39Sopenharmony_ciPrint the current configuration command line.
453e1051a39Sopenharmony_ci
454e1051a39Sopenharmony_ci=item B<--options> | B<-o>
455e1051a39Sopenharmony_ci
456e1051a39Sopenharmony_ciPrint the features, both enabled and disabled, and display defined macro and
457e1051a39Sopenharmony_ciskipped directories where applicable.
458e1051a39Sopenharmony_ci
459e1051a39Sopenharmony_ci=item B<--target> | B<-t>
460e1051a39Sopenharmony_ci
461e1051a39Sopenharmony_ciPrint the config attributes for this config target.
462e1051a39Sopenharmony_ci
463e1051a39Sopenharmony_ci=item B<--environment> | B<-e>
464e1051a39Sopenharmony_ci
465e1051a39Sopenharmony_ciPrint the environment variables and their values at the time of configuration.
466e1051a39Sopenharmony_ci
467e1051a39Sopenharmony_ci=item B<--make-variables> | B<-m>
468e1051a39Sopenharmony_ci
469e1051a39Sopenharmony_ciPrint the main make variables generated in the current configuration
470e1051a39Sopenharmony_ci
471e1051a39Sopenharmony_ci=item B<--build-parameters> | B<-b>
472e1051a39Sopenharmony_ci
473e1051a39Sopenharmony_ciPrint the build parameters, i.e. build file and build file templates.
474e1051a39Sopenharmony_ci
475e1051a39Sopenharmony_ci=item B<--reconfigure> | B<--reconf> | B<-r>
476e1051a39Sopenharmony_ci
477e1051a39Sopenharmony_ciRe-run the configuration process.
478e1051a39Sopenharmony_ci
479e1051a39Sopenharmony_ci=item B<--verbose> | B<-v>
480e1051a39Sopenharmony_ci
481e1051a39Sopenharmony_ciVerbose output.
482e1051a39Sopenharmony_ci
483e1051a39Sopenharmony_ci=back
484e1051a39Sopenharmony_ci
485e1051a39Sopenharmony_ci=cut
486e1051a39Sopenharmony_ci
487e1051a39Sopenharmony_ciEOF
488