2 # Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
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
9 # Reads one or more template files and runs it through Text::Template
11 # It is assumed that this scripts is called with -Mconfigdata, a module
12 # that holds configuration data in %config
18 use lib "$FindBin::Bin/perl";
19 use OpenSSL::fallback "$FindBin::Bin/../external/perl/MODULES.txt";
21 use OpenSSL::Template;
23 # We actually expect to get the following hash tables from configdata:
30 # We just do a minimal test to see that we got what we expected.
31 # $config{target} must exist as an absolute minimum.
32 die "You must run this script with -Mconfigdata\n"
33 if !exists($config{target});
35 # Check options ######################################################
40 # declares ORIGINATOR as the originating script.
43 my @autowarntext = ("WARNING: do not edit!",
45 . (defined($opts{o}) ? " by ".$opts{o} : "")
46 . (scalar(@ARGV) > 0 ? " from ".join(", ",@ARGV) : ""));
48 # Template setup #####################################################
50 my @template_settings =
52 ? map { { TYPE => 'FILE', SOURCE => $_, FILENAME => $_ } } @ARGV
53 : ( { TYPE => 'FILEHANDLE', SOURCE => \*STDIN, FILENAME => '<stdin>' } );
55 # Engage! ############################################################
57 my $prepend = <<"_____";
58 use File::Spec::Functions;
60 $prepend .= <<"_____" if defined $target{perl_platform};
61 use lib "$FindBin::Bin/../Configurations";
62 use lib '$config{builddir}';
66 foreach (@template_settings) {
67 my $template = OpenSSL::Template->new(%$_);
68 $template->fill_in(%$_,
70 HASH => { config => \%config,
72 disabled => \%disabled,
73 withargs => \%withargs,
74 unified_info => \%unified_info,
75 autowarntext => \@autowarntext },
77 # To ensure that global variables and functions
78 # defined in one template stick around for the
79 # next, making them combinable
80 PACKAGE => 'OpenSSL::safe');