From: Richard Levitte Date: Sun, 13 Oct 2019 10:33:15 +0000 (+0200) Subject: Building: Add modules with DEPENDs to GENERATEd files X-Git-Tag: openssl-3.0.0-alpha1~1149 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=70d9675342efbc9fe518e082c44f3ad80a1e4671;p=oweals%2Fopenssl.git Building: Add modules with DEPENDs to GENERATEd files For files GENERATEd from templates (.in files), any perl module (.pm file) that the file depends on will automatically be used. This means that these two lines: GENERATE[foo]=foo.in DEPEND[foo]=whatever.pm will emit this command in a Makefile (or corresponding): foo: foo.in whatever.pm configdata.pm $(PERL) -I. -Ipathto -Mwhatever -Mconfigdata $(SRCDIR)/util/dofile.pl \\ foo.in > foo Note that configdata.pm is automatically added, since util/dofile.pl itself depends on it. Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/10162) --- diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl index e177f2202e..28e7663a54 100644 --- a/Configurations/descrip.mms.tmpl +++ b/Configurations/descrip.mms.tmpl @@ -775,10 +775,14 @@ EOF my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, "util", "dofile.pl")), rel2abs($config{builddir})); + my @modules = ( 'configdata.pm', + grep { $_ =~ m|\.pm$| } @{$args{deps}} ); + my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules; + @modules = map { '"-M'.basename($_, '.pm').'"' } @modules; + my $modules = join(' ', '', sort keys %moduleincs, @modules); return <<"EOF"; $target : $args{generator}->[0] $deps - \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\ - "-o$target{build_file}" $generator > \$\@ + \$(PERL)$modules $dofile "-o$target{build_file}" $generator > \$\@ EOF } else { return <<"EOF"; diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 7c44a04224..ebdc82b684 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -966,10 +966,14 @@ EOF my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, "util", "dofile.pl")), rel2abs($config{builddir})); + my @modules = ( 'configdata.pm', + grep { $_ =~ m|\.pm$| } @{$args{deps}} ); + my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules; + @modules = map { "-M".basename($_, '.pm') } @modules; + my $modules = join(' ', '', sort keys %moduleincs, @modules); return <<"EOF"; -$args{src}: $args{generator}->[0] $deps - \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ - "-o$target{build_file}" $generator > \$@ +$args{src}: $args{generator}->[0] $deps \$(BLDDIR)/configdata.pm + \$(PERL)$modules "$dofile" "-o$target{build_file}" $generator > \$@ EOF } else { return <<"EOF"; diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index 4a83d0cee6..19e3f4e0ee 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -558,10 +558,14 @@ EOF my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, "util", "dofile.pl")), rel2abs($config{builddir})); + my @modules = ( 'configdata.pm', + grep { $_ =~ m|\.pm$| } @{$args{deps}} ); + my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules; + @modules = map { "-M".basename($_, '.pm') } @modules; + my $modules = join(' ', '', sort keys %moduleincs, @modules); return <<"EOF"; $target: "$args{generator}->[0]" $deps - "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ - "-o$target{build_file}" $generator > \$@ + "\$(PERL)"$modules "$dofile" "-o$target{build_file}" $generator > \$@ EOF } else { return <<"EOF"; diff --git a/build.info b/build.info index 83dc6ed164..5e63b440df 100644 --- a/build.info +++ b/build.info @@ -11,13 +11,9 @@ DEPEND[libssl]=libcrypto # unconditionally before anything else. DEPEND[]=include/openssl/opensslconf.h include/crypto/bn_conf.h \ include/crypto/dso_conf.h doc/man7/openssl_user_macros.pod -DEPEND[include/openssl/opensslconf.h]=configdata.pm GENERATE[include/openssl/opensslconf.h]=include/openssl/opensslconf.h.in -DEPEND[include/crypto/bn_conf.h]=configdata.pm GENERATE[include/crypto/bn_conf.h]=include/crypto/bn_conf.h.in -DEPEND[include/crypto/dso_conf.h]=configdata.pm GENERATE[include/crypto/dso_conf.h]=include/crypto/dso_conf.h.in -DEPEND[doc/man7/openssl_user_macros.pod]=configdata.pm GENERATE[doc/man7/openssl_user_macros.pod]=doc/man7/openssl_user_macros.pod.in IF[{- defined $target{shared_defflag} -}] diff --git a/doc/internal/man7/build.info.pod b/doc/internal/man7/build.info.pod index 996e6293ad..742f78ce39 100644 --- a/doc/internal/man7/build.info.pod +++ b/doc/internal/man7/build.info.pod @@ -441,7 +441,9 @@ file as last argument. For Is where this is applicable, any B statement for the same I will be given to the I as its -inclusion directories. +inclusion directories. Likewise, any B statement for the same +I will be given to the I as an extra file or module +to load, where this is applicable. The build file generators must be able to recognise the I. Currently, they at least recognise files ending in C<.pl>, and will