[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Mon Apr 25 16:06:16 UTC 2016


The branch master has been updated
       via  2036fd50466b0586326bbc260a4f77020467531a (commit)
       via  8d34daf0ce3bd2fc08dda0f1b0d1213dec452a1d (commit)
      from  79356a83b78a2d936dcd022847465d9ebf6c67b1 (commit)


- Log -----------------------------------------------------------------
commit 2036fd50466b0586326bbc260a4f77020467531a
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Apr 21 21:08:42 2016 +0200

    Document the enhancements for DEPEND and INCLUDE and use a better example
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>

commit 8d34daf0ce3bd2fc08dda0f1b0d1213dec452a1d
Author: Richard Levitte <levitte at openssl.org>
Date:   Thu Apr 21 14:30:08 2016 +0200

    Build system: add include directories and dependencies for generators
    
    In the case of generating a file like this:
    
        GENERATE[foo.S]=mkfoo.pl arg1 arg2
    
    the 'mkfoo.pl' generator itself might need to include other files,
    such as perl modules within our source tree.  We can reuse already
    existing syntax for it, like this:
    
        INCLUDE[mkfoo.pl]=module/path
    
    or:
    
        DEPEND[mkfoo.pl]=modules/mymodule.pm
    
    This change implements the support for such constructs, and for the
    DEPEND statement, for any value that indicates a perl module (.pm
    file), it will automatically infer an INCLUDE statement for its
    directory, just like it does for C header files, so you won't have do
    write this:
    
        DEPEND[mkfoo.pl]=modules/mymodule.pm
        INCLUDE[mkfoo.pl]=modules
    
    Reviewed-by: Emilia Käsper <emilia at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 Configurations/README                | 27 +++++++++---
 Configurations/README.design         | 80 ++++++++++++++++++++++++++----------
 Configurations/common.tmpl           |  3 ++
 Configurations/descrip.mms.tmpl      |  5 ++-
 Configurations/unix-Makefile.tmpl    |  9 ++--
 Configurations/windows-makefile.tmpl |  7 ++--
 Configure                            | 30 ++++++++++----
 7 files changed, 117 insertions(+), 44 deletions(-)

diff --git a/Configurations/README b/Configurations/README
index 3534ea6..8451b44 100644
--- a/Configurations/README
+++ b/Configurations/README
@@ -379,6 +379,18 @@ item muct be the generator file.  It is, however, entirely up to the
 build file template to define exactly how those command lines should
 be handled, how the output is captured and so on.
 
+Sometimes, the generator file itself depends on other files, for
+example if it is a perl script that depends on other perl modules.
+This can be expressed using DEPEND like this:
+
+    DEPEND[asm/something.pl]=../perlasm/Foo.pm
+
+There may also be cases where the exact file isn't easily specified,
+but an inclusion directory still needs to be specified.  INCLUDE can
+be used in that case:
+
+    INCLUDE[asm/something.pl]=../perlasm
+
 NOTE: GENERATE lines are limited to one command only per GENERATE.
 
 As a last resort, it's possible to have raw build file lines, between
@@ -498,6 +510,8 @@ They are all expected to return a string with the lines they produce.
 
                         generatesrc(src => "PATH/TO/tobegenerated",
                                     generator => [ "generatingfile", ... ]
+                                    generator_incs => [ "INCL/PATH", ... ]
+                                    generator_deps => [ "dep1", ... ]
                                     generator => [ "generatingfile", ... ]
                                     incs => [ "INCL/PATH", ... ],
                                     deps => [ "dep1", ... ],
@@ -509,11 +523,14 @@ They are all expected to return a string with the lines they produce.
                   expected to be the file to generate from.
                   generatesrc() is expected to analyse and figure out
                   exactly how to apply that file and how to capture
-                  the result.  'incs' and 'deps' are include
-                  directories and files that are used if $(CC) used as
-                  an intermediary step when generating the end product
-                  (the file indicated by 'src').  'intent' indicates
-                  what the generated file is going to be used for.
+                  the result.  'generator_incs' and 'generator_deps'
+                  are include directories and files that the generator
+                  file itself depends on.  'incs' and 'deps' are
+                  include directories and files that are used if $(CC)
+                  is used as an intermediary step when generating the
+                  end product (the file indicated by 'src').  'intent'
+                  indicates what the generated file is going to be
+                  used for.
 
     src2obj     - function that produces build file lines to build an
                   object file from source files and associated data.
diff --git a/Configurations/README.design b/Configurations/README.design
index d905937..5777e72 100644
--- a/Configurations/README.design
+++ b/Configurations/README.design
@@ -91,6 +91,7 @@ depends on the library 'libssl' to function properly.
     
     GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)"
     DEPEND[buildinf.h]=../Makefile
+    DEPEND[../util/mkbuildinf.pl]=../util/Foo.pm
 
 This is the build.info file in 'crypto', and it tells us a little more
 about what's needed to produce 'libcrypto'.  LIBS is used again to
@@ -104,7 +105,8 @@ source files, 'crypto/aes.c', 'crypto/evp.c' and 'crypto/cversion.c'.
 It also shows us that building the object file inferred from
 'crypto/cversion.c' depends on 'crypto/buildinf.h'.  Finally, it 
 also shows the possibility to declare how some files are generated
-using some script, in this case a perl script.
+using some script, in this case a perl script, and how such scripts
+can be declared to depend on other files, in this case a perl module.
 
 Two things are worth an extra note:
 
@@ -159,6 +161,7 @@ information comes down to this:
     
     GENERATE[crypto/buildinf.h]=util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)"
     DEPEND[crypto/buildinf.h]=Makefile
+    DEPEND[util/mkbuildinf.pl]=util/Foo.pm
 
 
 A few notes worth mentioning:
@@ -169,13 +172,14 @@ PROGRAMS may be used to declare programs only.
 
 ENGINES may be used to declare engines only.
 
-The indexes for SOURCE, INCLUDE and ORDINALS must only be end product
-files, such as libraries, programs or engines.  The values of SOURCE
+The indexes for SOURCE and ORDINALS must only be end product files,
+such as libraries, programs or engines.  The values of SOURCE
 variables must only be source files (possibly generated)
 
-DEPEND shows a relationship between different produced files, such
-as a program depending on a library, or between an object file and
-some extra source file.
+INCLUDE and DEPEND shows a relationship between different files
+(usually produced files) or between files and directories, such as a
+program depending on a library, or between an object file and some
+extra source file.
 
 When Configure processes the build.info files, it will take it as
 truth without question, and will therefore perform very few checks.
@@ -266,6 +270,10 @@ section above would be digested into a %unified_info table:
                     [
                         "libcrypto",
                     ],
+                "util/mkbuildinf.pl" =>
+                    [
+                        "util/Foo.pm",
+                    ],
             },
         "engines" =>
             [
@@ -300,6 +308,10 @@ section above would be digested into a %unified_info table:
                     [
                         "include",
                     ],
+                "util/mkbuildinf.pl" =>
+                    [
+                        "util",
+                    ],
             }
         "libraries" =>
             [
@@ -403,6 +415,8 @@ etc.
 
                         generatesrc(src => "PATH/TO/tobegenerated",
                                     generator => [ "generatingfile", ... ]
+                                    generator_incs => [ "INCL/PATH", ... ]
+                                    generator_deps => [ "dep1", ... ]
                                     incs => [ "INCL/PATH", ... ],
                                     deps => [ "dep1", ... ],
                                     intent => one of "libs", "dso", "bin" );
@@ -413,11 +427,14 @@ etc.
                   expected to be the file to generate from.
                   generatesrc() is expected to analyse and figure out
                   exactly how to apply that file and how to capture
-                  the result.  'incs' and 'deps' are include
-                  directories and files that are used if $(CC) used as
-                  an intermediary step when generating the end product
-                  (the file indicated by 'src').  'intent' indicates
-                  what the generated file is going to be used for.
+                  the result.  'generator_incs' and 'generator_deps'
+                  are include directories and files that the generator
+                  file itself depends on.  'incs' and 'deps' are
+                  include directories and files that are used if $(CC)
+                  is used as an intermediary step when generating the
+                  end product (the file indicated by 'src').  'intent'
+                  indicates what the generated file is going to be
+                  used for.
 
     src2obj     - function that produces build file lines to build an
                   object file from source files and associated data.
@@ -538,7 +555,7 @@ programs and all intermediate files, using the rule generating
 functions defined in the build-file template.
 
 As an example with the smaller build.info set we've seen as an
-example, producing the rules to build 'libssl' would result in the
+example, producing the rules to build 'libcrypto' would result in the
 following calls:
 
     # Note: libobj2shlib will only be called if shared libraries are
@@ -548,20 +565,41 @@ following calls:
     # to the implementation to decide which to use as input.
     # Note 3: common.tmpl peals off the ".o" extension from all object
     # files, as the platform at hand may have a different one.
-    libobj2shlib(shlib => "libssl",
-                 lib => "libssl",
-                 objs => [ "ssl/tls" ],
-                 deps => [ "libcrypto" ]
-                 ordinals => [ "ssl", "util/libssl.num" ]);
+    libobj2shlib(shlib => "libcrypto",
+                 lib => "libcrypto",
+                 objs => [ "crypto/aes", "crypto/evp", "crypto/cversion" ],
+                 deps => [  ]
+                 ordinals => [ "crypto", "util/libcrypto.num" ]);
+
+    obj2lib(lib => "libcrypto"
+            objs => [ "crypto/aes", "crypto/evp", "crypto/cversion" ]);
 
-    obj2lib(lib => "libssl"
-            objs => [ "ssl/tls" ]);
+    src2obj(obj => "crypto/aes"
+            srcs => [ "crypto/aes.c" ],
+            deps => [ ],
+            incs => [ "include" ],
+            intent => "lib");
 
-    src2obj(obj => "ssl/tls"
-            srcs => [ "ssl/tls.c" ],
+    src2obj(obj => "crypto/evp"
+            srcs => [ "crypto/evp.c" ],
             deps => [ ],
             incs => [ "include" ],
             intent => "lib");
 
+    src2obj(obj => "crypto/cversion"
+            srcs => [ "crypto/cversion.c" ],
+            deps => [ "crypto/buildinf.h" ],
+            incs => [ "include" ],
+            intent => "lib");
+
+    generatesrc(src => "crypto/buildinf.h",
+                generator => [ "util/mkbuildinf.pl", "\"$(CC)",
+                               "$(CFLAGS)\"", "\"$(PLATFORM)\"" ],
+                generator_incs => [ "util" ],
+                generator_deps => [ "util/Foo.pm" ],
+                incs => [ ],
+                deps => [ ],
+                intent => "lib");
+
 The returned strings from all those calls are then concatenated
 together and written to the resulting build-file.
diff --git a/Configurations/common.tmpl b/Configurations/common.tmpl
index cdcaf53..af1746a 100644
--- a/Configurations/common.tmpl
+++ b/Configurations/common.tmpl
@@ -42,8 +42,11 @@
      my $bin = shift;
      my %opts = @_;
      if ($unified_info{generate}->{$src}) {
+         my $script = $unified_info{generate}->{$src}->[0];
          $OUT .= generatesrc(src => $src,
                              generator => $unified_info{generate}->{$src},
+                             generator_incs => $unified_info{includes}->{$script},
+                             generator_deps => $unified_info{depends}->{$script},
                              deps => $unified_info{depends}->{$src},
                              incs => [ @{$unified_info{includes}->{$bin}},
                                        @{$unified_info{includes}->{$obj}} ],
diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl
index 2e58b1a..416f0ed 100644
--- a/Configurations/descrip.mms.tmpl
+++ b/Configurations/descrip.mms.tmpl
@@ -441,12 +441,13 @@ configdata.pm : {- join(" ", sourcefile("Configurations", "descrip.mms.tmpl"), s
   sub generatesrc {
       my %args = @_;
       my $generator = join(" ", @{$args{generator}});
-      my $deps = join(", -\n\t\t", @{$args{deps}});
+      my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
+      my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
 
       if ($args{src} !~ /\.[sS]$/) {
           return <<"EOF";
 $args{src} : $args{generator}->[0] $deps
-	\$(PERL) $generator > \$@
+	\$(PERL)$generator_incs $generator > \$@
 EOF
       } else {
           die "No method to generate assembler source present.\n";
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl
index 1676b71..900c09f 100644
--- a/Configurations/unix-Makefile.tmpl
+++ b/Configurations/unix-Makefile.tmpl
@@ -808,19 +808,20 @@ configdata.pm: $(SRCDIR)/Configurations/unix-Makefile.tmpl $(SRCDIR)/Configurati
   sub generatesrc {
       my %args = @_;
       my $generator = join(" ", @{$args{generator}});
+      my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
       my $incs = join("", map { " -I".$_ } @{$args{incs}});
-      my $deps = join(" ", @{$args{deps}});
+      my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
 
       if ($args{src} !~ /\.[sS]$/) {
           return <<"EOF";
 $args{src}: $args{generator}->[0] $deps
-	\$(PERL) $generator > \$@
+	\$(PERL)$generator_incs $generator > \$@
 EOF
       } else {
           if ($args{generator}->[0] =~ /\.pl$/) {
-              $generator = 'CC="$(CC)" $(PERL) '.$generator;
+              $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
           } elsif ($args{generator}->[0] =~ /\.m4$/) {
-              $generator = 'm4 -B 8192 '.$generator.' >'
+              $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
           } elsif ($args{generator}->[0] =~ /\.S$/) {
               $generator = undef;
           } else {
diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl
index c3233ee..159d57c 100644
--- a/Configurations/windows-makefile.tmpl
+++ b/Configurations/windows-makefile.tmpl
@@ -252,17 +252,18 @@ configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure
       my %args = @_;
       (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
       my $generator = join(" ", @{$args{generator}});
+      my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
       my $incs = join("", map { " /I ".$_ } @{$args{incs}});
-      my $deps = join(" ", @{$args{deps}});
+      my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
 
       if ($target !~ /\.asm$/) {
           return <<"EOF";
 $target: $args{generator}->[0] $deps
-	\$(PERL) $generator > \$@
+	\$(PERL)$generator_incs $generator > \$@
 EOF
       } else {
           if ($args{generator}->[0] =~ /\.pl$/) {
-              $generator = '$(PERL) '.$generator;
+              $generator = '$(PERL)'.$generator_incs.' '.$generator;
           } elsif ($args{generator}->[0] =~ /\.S$/) {
               $generator = undef;
           } else {
diff --git a/Configure b/Configure
index 4a870c0..b32cb94 100755
--- a/Configure
+++ b/Configure
@@ -1612,9 +1612,15 @@ EOF
 
         foreach (keys %depends) {
             my $dest = $_;
-            my $ddest = cleanfile($buildd, $_, $blddir);
-            if ($unified_info{rename}->{$ddest}) {
-                $ddest = $unified_info{rename}->{$ddest};
+            my $ddest = cleanfile($sourced, $_, $blddir);
+
+            # If the destination doesn't exist in source, it can only be
+            # a generated file in the build tree.
+            if (! -f $ddest) {
+                $ddest = cleanfile($buildd, $_, $blddir);
+                if ($unified_info{rename}->{$ddest}) {
+                    $ddest = $unified_info{rename}->{$ddest};
+                }
             }
             foreach (@{$depends{$dest}}) {
                 my $d = cleanfile($sourced, $_, $blddir);
@@ -1635,9 +1641,9 @@ EOF
                     $d = $unified_info{rename}->{$d};
                 }
                 $unified_info{depends}->{$ddest}->{$d} = 1;
-                # If we depend on a header file, let's make sure it
-                # can get included
-                if ($d =~ /\.h$/) {
+                # If we depend on a header file or a perl module, let's make
+                # sure it can get included
+                if ($d =~ /\.(h|pm)$/) {
                     my $i = dirname($d);
                     push @{$unified_info{includes}->{$ddest}}, $i
                         unless grep { $_ eq $i } @{$unified_info{includes}->{$ddest}};
@@ -1647,9 +1653,15 @@ EOF
 
         foreach (keys %includes) {
             my $dest = $_;
-            my $ddest = cleanfile($buildd, $_, $blddir);
-            if ($unified_info{rename}->{$ddest}) {
-                $ddest = $unified_info{rename}->{$ddest};
+            my $ddest = cleanfile($sourced, $_, $blddir);
+
+            # If the destination doesn't exist in source, it can only be
+            # a generated file in the build tree.
+            if (! -f $ddest) {
+                $ddest = cleanfile($buildd, $_, $blddir);
+                if ($unified_info{rename}->{$ddest}) {
+                    $ddest = $unified_info{rename}->{$ddest};
+                }
             }
             foreach (@{$includes{$dest}}) {
                 my $i = cleandir($sourced, $_, $blddir);


More information about the openssl-commits mailing list