]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Build: make it possible to assign macro definitions for specific outputs
authorRichard Levitte <levitte@openssl.org>
Fri, 14 Oct 2016 14:56:34 +0000 (16:56 +0200)
committerRichard Levitte <levitte@openssl.org>
Mon, 5 Nov 2018 07:13:04 +0000 (08:13 +0100)
Sometimes, some specific program or object file might need an extra
macro definition of its own.  This allows that to be easily done.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7553)

Configurations/README
Configurations/README.design
Configurations/common.tmpl
Configure

index 9fd4922fd0e3583612d84023abbe9f01d91db705..1c67f75a7b1d12e7ca17d4a0480afcbfda605fa3 100644 (file)
@@ -467,6 +467,10 @@ include paths the build of their source files should use:
 
     INCLUDE[foo]=include
 
+It's also possible to specify C macros that should be defined:
+
+    DEFINE[foo]=FOO BAR=1
+
 In some cases, one might want to generate some source files from
 others, that's done as follows:
 
index 8c50a92b203eb3f2dad97323c1c5288d9102c538..c0b05bd5b29726374e723dfe2239f3fa6b0ef826 100644 (file)
@@ -41,9 +41,10 @@ end products.  There are variants for them with '_NO_INST' as suffix
 (PROGRAM_NO_INST etc) to specify end products that shouldn't get
 installed.
 
-The variables SOURCE, DEPEND and INCLUDE are indexed by a produced
-file, and their values are the source used to produce that particular
-produced file, extra dependencies, and include directories needed.
+The variables SOURCE, DEPEND, INCLUDE and DEFINE are indexed by a
+produced file, and their values are the source used to produce that
+particular produced file, extra dependencies, include directories
+needed, or C macros to be defined.
 
 All their values in all the build.info throughout the source tree are
 collected together and form a set of programs, libraries, engines and
index 4a086559c140799303de2fcd8f2768a3b59f40e9..b7d2a0777e011753cb38e1064914c6f68f791555 100644 (file)
@@ -85,6 +85,7 @@
                              deps => $unified_info{depends}->{$src},
                              incs => [ @{$unified_info{includes}->{$obj}},
                                        @{$unified_info{includes}->{$bin}} ],
+                             defs => $unified_info{defines}->{$obj},
                              %opts);
          foreach (@{$unified_info{depends}->{$src}}) {
              dogenerate($_, $obj, $bin, %opts);
                          deps => $unified_info{depends}->{$obj},
                          incs => [ @{$unified_info{includes}->{$obj}},
                                    @{$unified_info{includes}->{$bin}} ],
+                         defs => $unified_info{defines}->{$obj},
                          %opts);
          foreach ((@{$unified_info{sources}->{$obj}},
                    @{$unified_info{depends}->{$obj}})) {
index 53d5549eafdeb4857e8ebb6a37a641c4bfda138e..094898cc5695b4aad2ab65b88ab9d516f9978295 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1722,6 +1722,7 @@ if ($builder eq "unified") {
         my %sources = ();
         my %shared_sources = ();
         my %includes = ();
+        my %defines = ();
         my %depends = ();
         my %renames = ();
         my %sharednames = ();
@@ -1837,6 +1838,9 @@ if ($builder eq "unified") {
             qr/^\s*INCLUDE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
             => sub { push @{$includes{$1}}, tokenize($2)
                          if !@skip || $skip[$#skip] > 0 },
+            qr/^\s*DEFINE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
+            => sub { push @{$defines{$1}}, tokenize($2)
+                         if !@skip || $skip[$#skip] > 0 },
             qr/^\s*DEPEND\[((?:\\.|[^\\\]])*)\]\s*=\s*(.*)\s*$/
             => sub { push @{$depends{$1}}, tokenize($2)
                          if !@skip || $skip[$#skip] > 0 },
@@ -2169,6 +2173,27 @@ EOF
                     unless grep { $_ eq $ib } @{$unified_info{includes}->{$ddest}->{build}};
             }
         }
+
+        foreach (keys %defines) {
+            my $dest = $_;
+            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 (@{$defines{$dest}}) {
+                m|^([^=]*)(=.*)?$|;
+                die "0 length macro name not permitted\n" if $1 eq "";
+                die "$1 defined more than once\n"
+                    if defined $unified_info{defines}->{$ddest}->{$1};
+                $unified_info{defines}->{$ddest}->{$1} = $2;
+            }
+        }
     }
 
     my $ordinals_text = join(', ', sort keys %ordinals);
@@ -2311,6 +2336,12 @@ EOF
             }
         }
     }
+    # Defines
+    foreach my $dest (sort keys %{$unified_info{defines}}) {
+        $unified_info{defines}->{$dest}
+            = [ map { $_.$unified_info{defines}->{$dest}->{$_} }
+                sort keys %{$unified_info{defines}->{$dest}} ];
+    }
     # Includes
     foreach my $dest (sort keys %{$unified_info{includes}}) {
         if (defined($unified_info{includes}->{$dest}->{build})) {