]>
git.ipfire.org Git - thirdparty/openssl.git/blob - configdata.pm.in
1 #! {- $config{HASHBANGPERL} -}
4 # We must make sourcedir() return an absolute path, because configdata.pm
5 # may be loaded as a module from any script in any directory, making
6 # relative paths untrustable. Because the result is used with 'use lib',
7 # we must ensure that it returns a Unix style path. Mixing File::Spec
8 # and File::Spec::Unix does just that.
15 # Make the path absolute at all times
16 $path = abs_path
($path);
19 # Convert any path of the VMS form VOLUME:[DIR1.DIR2]FILE to the
20 # Unix form /VOLUME/DIR1/DIR2/FILE, which is what VMS perl supports
23 # Start with spliting the native path
24 (my $vol, my $dirs, my $file) = File
::Spec
->splitpath($path);
25 my @dirs = File
::Spec
->splitdir($dirs);
27 # Reassemble it as a Unix path
29 $dirs = File
::Spec
::Unix
->catdir('', $vol, @dirs);
30 $path = File
::Spec
::Unix
->catpath('', $dirs, $file);
36 return _fixup_path
(File
::Spec
->catdir($config{sourcedir
}, @_))
39 return _fixup_path
(File
::Spec
->catfile($config{sourcedir
}, @_))
41 use lib sourcedir
('util', 'perl');
50 our @ISA = qw(Exporter);
52 %config %target %disabled %withargs %unified_info
53 @disablables @disablables_int
56 our %config = ({- dump_data(\%config, indent => 0); -});
57 our %target = ({- dump_data(\%target, indent => 0); -});
58 our @disablables = ({- dump_data(\@disablables, indent => 0) -});
59 our @disablables_int = ({- dump_data(\@disablables_int, indent => 0) -});
60 our %disabled = ({- dump_data(\%disabled, indent => 0); -});
61 our %withargs = ({- dump_data(\%withargs, indent => 0); -});
62 our %unified_info = ({- dump_data(\%unified_info, indent => 0); -});
64 # Unexported, only used by OpenSSL::Test::Utils::available_protocols()
65 our %available_protocols = (
66 tls => [{- dump_data(\@tls, indent => 0) -}],
67 dtls => [{- dump_data(\@dtls, indent => 0) -}],
70 # The following data is only used when this files is use as a script
71 my @makevars = ({- dump_data(\@makevars, indent => 0); -});
72 my %disabled_info = ({- dump_data(\%disabled_info, indent => 0); -});
73 my @user_crossable = qw( {- join (' ', @user_crossable) -} );
75 # If run directly, we can give some answers, and even reconfigure
78 use File::Spec::Functions;
83 use lib '{- sourcedir('util', 'perl') -}';
84 use OpenSSL::fallback '{- sourcefile('external', 'perl', 'MODULES.txt') -}';
86 my $here = dirname($0);
88 if (scalar @ARGV == 0) {
89 # With no arguments, re-create the build file
90 # We do that in two steps, where the first step emits perl
93 my $buildfile = $target{build_file};
94 my $buildfile_template = "$buildfile.in";
96 'WARNING: do not edit!',
97 "Generated by configdata.pm from "
98 .join(", ", @{$config{build_file_templates}}),
99 "via $buildfile_template"
104 disabled => \%disabled,
105 withargs => \%withargs,
106 unified_info => \%unified_info,
107 autowarntext => \@autowarntext,
111 use lib '{- sourcedir('Configurations') -}';
114 print 'Creating ',$buildfile_template,"\n";
115 open my $buildfile_template_fh, ">$buildfile_template"
116 or die "Trying to create $buildfile_template: $!";
117 foreach (@{$config{build_file_templates}}) {
118 copy($_, $buildfile_template_fh)
119 or die "Trying to copy $_ into $buildfile_template: $!";
121 gentemplate(output => $buildfile_template_fh, %gendata);
122 close $buildfile_template_fh;
124 use OpenSSL::Template;
126 my $prepend = <<'_____';
127 use File::Spec::Functions;
128 use lib '{- sourcedir('util', 'perl') -}';
129 use lib '{- sourcedir('Configurations') -}';
130 use lib '{- $config{builddir} -}';
134 print 'Creating ',$buildfile,"\n";
135 open BUILDFILE, ">$buildfile.new"
136 or die "Trying to create $buildfile.new: $!";
137 my $tmpl = OpenSSL::Template->new(TYPE => 'FILE',
138 SOURCE => $buildfile_template);
139 $tmpl->fill_in(FILENAME => $_,
140 OUTPUT => \*BUILDFILE,
143 # To ensure that global variables and functions
144 # defined in one template stick around for the
145 # next, making them combinable
146 PACKAGE => 'OpenSSL::safe')
147 or die $Text::Template::ERROR;
149 rename("$buildfile.new", $buildfile)
150 or die "Trying to rename $buildfile.new to $buildfile: $!";
160 my $makevars = undef;
161 my $buildparams = undef;
167 GetOptions('dump|d' => \$dump,
168 'command-line|c' => \$cmdline,
169 'options|o' => \$options,
170 'target|t' => \$target,
171 'environment|e' => \$envvars,
172 'make-variables|m' => \$makevars,
173 'build-parameters|b' => \$buildparams,
174 'reconfigure|reconf|r' => \$reconf,
175 'verbose|v' => \$verbose,
176 'query|q=s' => \$query,
179 or die "Errors in command line arguments\n";
181 # We allow extra arguments with --query. That allows constructs like
183 # ./configdata.pm --query 'get_sources(@ARGV)' file1 file2 file3
184 if (!$query && scalar @ARGV > 0) {
185 print STDERR <<"_____";
186 Unrecognised arguments.
187 For more information, do '$0 --help'
193 pod2usage(-exitval => 0,
197 pod2usage(-exitval => 0,
200 if ($dump || $cmdline) {
201 print "\nCommand line (with current working directory = $here):\n\n";
204 catfile($config{sourcedir}, 'Configure'),
205 @{$config{perlargv}}), "\n";
206 print "\nPerl information:\n\n";
207 print ' ',$config{perl_cmd},"\n";
208 print ' ',$config{perl_version},' for ',$config{perl_archname},"\n";
210 if ($dump || $options) {
213 foreach my $what (@disablables) {
214 $longest = length($what) if $longest < length($what);
215 $longest2 = length($disabled{$what})
216 if $disabled{$what} && $longest2 < length($disabled{$what});
218 print "\nEnabled features:\n\n";
219 foreach my $what (@disablables) {
220 print " $what\n" unless $disabled{$what};
222 print "\nDisabled features:\n\n";
223 foreach my $what (@disablables) {
224 if ($disabled{$what}) {
225 print " $what", ' ' x ($longest - length($what) + 1),
226 "[$disabled{$what}]", ' ' x ($longest2 - length($disabled{$what}) + 1);
227 print $disabled_info{$what}->{macro}
228 if $disabled_info{$what}->{macro};
230 join(', ', @{$disabled_info{$what}->{skipped}}),
232 if $disabled_info{$what}->{skipped};
237 if ($dump || $target) {
238 print "\nConfig target attributes:\n\n";
239 foreach (sort keys %target) {
240 next if $_ =~ m|^_| || $_ eq 'template';
244 (my $x = $_) =~ s|([\\\$\@"])|\\$1|g; "\"$x\""
250 print ' ', $_, ' => ';
251 if (ref($target{$_}) eq "ARRAY") {
252 print '[ ', join(', ', $quotify->(@{$target{$_}})), " ],\n";
254 print $quotify->($target{$_}), ",\n"
258 if ($dump || $envvars) {
259 print "\nRecorded environment:\n\n";
260 foreach (sort keys %{$config{perlenv}}) {
261 print ' ',$_,' = ',($config{perlenv}->{$_} || ''),"\n";
264 if ($dump || $makevars) {
265 print "\nMakevars:\n\n";
266 foreach my $var (@makevars) {
268 $prefix = $config{CROSS_COMPILE}
269 if grep { $var eq $_ } @user_crossable;
271 print ' ',$var,' ' x (16 - length $var),'= ',
272 (ref $config{$var} eq 'ARRAY'
273 ? join(' ', @{$config{$var}})
274 : $prefix.$config{$var}),
276 if defined $config{$var};
279 my @buildfile = ($config{builddir}, $config{build_file});
280 unshift @buildfile, $here
281 unless file_name_is_absolute($config{builddir});
282 my $buildfile = canonpath(catdir(@buildfile));
285 NOTE: These variables only represent the configuration view. The build file
286 template may have processed these variables further, please have a look at the
287 build file for more exact data:
291 if ($dump || $buildparams) {
292 my @buildfile = ($config{builddir}, $config{build_file});
293 unshift @buildfile, $here
294 unless file_name_is_absolute($config{builddir});
295 print "\nbuild file:\n\n";
296 print " ", canonpath(catfile(@buildfile)),"\n";
298 print "\nbuild file templates:\n\n";
299 foreach (@{$config{build_file_templates}}) {
302 unless file_name_is_absolute($config{sourcedir});
303 print ' ',canonpath(catfile(@tmpl)),"\n";
308 print 'Reconfiguring with: ', join(' ',@{$config{perlargv}}), "\n";
309 foreach (sort keys %{$config{perlenv}}) {
310 print ' ',$_,' = ',($config{perlenv}->{$_} || ""),"\n";
315 exec $^X,catfile($config{sourcedir}, 'Configure'),'reconf';
318 use OpenSSL::Config::Query;
320 my $confquery = OpenSSL::Config::Query->new(info => \%unified_info,
322 my $result = eval "\$confquery->$query";
324 # We may need a result class with a printing function at some point.
325 # Until then, we assume that we get a scalar, or a list or a hash table
326 # with scalar values and simply print them in some orderly fashion.
327 if (ref $result eq 'ARRAY') {
328 print "$_\n" foreach @$result;
329 } elsif (ref $result eq 'HASH') {
330 print "$_ : \\\n ", join(" \\\n ", @{$result->{$_}}), "\n"
331 foreach sort keys %$result;
332 } elsif (ref $result eq 'SCALAR') {
344 configdata.pm - configuration data for OpenSSL builds
350 perl configdata.pm [options]
358 This module can be used in two modes, interactively and as a module containing
359 all the data recorded by OpenSSL's Configure script.
361 When used interactively, simply run it as any perl script.
362 If run with no arguments, it will rebuild the build file (Makefile or
364 With at least one option, it will instead get the information you ask for, or
365 re-run the configuration process.
366 See L</OPTIONS> below for more information.
368 When loaded as a module, you get a few databanks with useful information to
369 perform build related tasks. The databanks are:
371 %config Configured things.
372 %target The OpenSSL config target with all inheritances
374 %disabled The features that are disabled.
375 @disablables The list of features that can be disabled.
376 %withargs All data given through --with-THING options.
377 %unified_info All information that was computed from the build.info
386 Print a brief help message and exit.
390 Print the manual page and exit.
392 =item B<--dump> | B<-d>
394 Print all relevant configuration data. This is equivalent to B<--command-line>
395 B<--options> B<--target> B<--environment> B<--make-variables>
396 B<--build-parameters>.
398 =item B<--command-line> | B<-c>
400 Print the current configuration command line.
402 =item B<--options> | B<-o>
404 Print the features, both enabled and disabled, and display defined macro and
405 skipped directories where applicable.
407 =item B<--target> | B<-t>
409 Print the config attributes for this config target.
411 =item B<--environment> | B<-e>
413 Print the environment variables and their values at the time of configuration.
415 =item B<--make-variables> | B<-m>
417 Print the main make variables generated in the current configuration
419 =item B<--build-parameters> | B<-b>
421 Print the build parameters, i.e. build file and build file templates.
423 =item B<--reconfigure> | B<--reconf> | B<-r>
425 Re-run the configuration process.
427 =item B<--verbose> | B<-v>