Commit b9b36448 authored by Richard Levitte's avatar Richard Levitte Committed by Richard Levitte
Browse files

Configure: Redo the logic for finding build file templates



Build file templates would be looked up like this if the user gave us
an additional directory to look for configuration files and build file
templates:

    $OPENSSL_LOCAL_CONFIG_DIR/$OSTYPE-Makefile.tmpl
    $SOURCEDIR/Configurations/$OSTYPE-Makefile.tmpl
    $OPENSSL_LOCAL_CONFIG_DIR/Makefile.tmpl
    $SOURCEDIR/Configurations/Makefile.tmpl

So for example, if the user created his own Makefile.tmpl and tried to
use it with a unixly config, it would never be user because we have a
unix-Makefile.tmpl in our Configurations directory.  This is clearly
wrong, and this change makes it look in this order instead:

    $OPENSSL_LOCAL_CONFIG_DIR/$OSTYPE-Makefile.tmpl
    $OPENSSL_LOCAL_CONFIG_DIR/Makefile.tmpl
    $SOURCEDIR/Configurations/$OSTYPE-Makefile.tmpl
    $SOURCEDIR/Configurations/Makefile.tmpl

Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(cherry picked from commit 79822c3c)
parent eac33e1c
Loading
Loading
Loading
Loading
+30 −17
Original line number Diff line number Diff line
@@ -1283,26 +1283,39 @@ my $buildinfo_debug = defined($ENV{CONFIGURE_DEBUG_BUILDINFO});
if ($builder eq "unified") {
    # Store the name of the template file we will build the build file from
    # in %config.  This may be useful for the build file itself.
    my $build_file_template;
    my @build_file_template_names =
	( $builder_platform."-".$target{build_file}.".tmpl",
	  $target{build_file}.".tmpl" );
    my @build_file_templates = ();

    for my $filename (( $builder_platform."-".$target{build_file}.".tmpl",
                        $target{build_file}.".tmpl" )) {
    # First, look in the user provided directory, if given
    if (defined $ENV{$local_config_envname}) {
	@build_file_templates =
	    map {
		if ($^O eq 'VMS') {
		    # VMS environment variables are logical names,
		    # which can be used as is
                $build_file_template = $local_config_envname . ':' . $filename;
		    $local_config_envname . ':' . $_;
		} else {
                $build_file_template = catfile($ENV{$local_config_envname},
                                               $filename);
		    catfile($ENV{$local_config_envname}, $_);
		}
	    }
	    @build_file_template_names;
    }
    # Then, look in our standard directory
    push @build_file_templates,
	( map { catfile($srcdir, "Configurations", $_) }
	  @build_file_template_names );

    my $build_file_template;
    for $_ (@build_file_templates) {
	$build_file_template = $_;
        last if -f $build_file_template;

        $build_file_template = catfile($srcdir, "Configurations", $filename);

        last if -f $build_file_template;
        $build_file_template = undef;
    }
    if (!defined $build_file_template) {
	die "*** Couldn't find any of:\n", join("\n", @build_file_templates), "\n";
    }
    $config{build_file_template} = $build_file_template;