Configurations/unix-Makefile.tmpl: Don't specify headers twice
[openssl.git] / Configurations / unix-Makefile.tmpl
index cb6263c911b4aeb795c8d29994402f775e9c7980..7eb4ea76a6f0f659a7c0c4429d442f46ac946b4d 100644 (file)
@@ -1062,7 +1062,7 @@ errors:
 
 {- use File::Basename;
 
-   our @sslheaders =
+   my @sslheaders_tmpl =
        qw( include/openssl/ssl.h
            include/openssl/ssl2.h
            include/openssl/ssl3.h
@@ -1070,7 +1070,7 @@ errors:
            include/openssl/tls1.h
            include/openssl/dtls1.h
            include/openssl/srtp.h );
-   our @cryptoheaders =
+   my @cryptoheaders_tmpl =
        qw( include/internal/dso.h
            include/internal/o_dir.h
            include/internal/err.h
@@ -1078,33 +1078,55 @@ errors:
            include/internal/pem.h
            include/internal/asn1.h
            include/internal/sslconf.h );
-   our @cryptoskipheaders = ( @sslheaders,
+   my @cryptoskipheaders = ( @sslheaders_tmpl,
        qw( include/openssl/conf_api.h
            include/openssl/ebcdic.h
            include/openssl/opensslconf.h
            include/openssl/symhacks.h ) );
-   foreach my $f ( glob(catfile($config{sourcedir},
-                                'include','openssl','*.h')) ) {
-       my $fn = "include/openssl/" . basename($f);
-       push @cryptoheaders, $fn unless grep { $_ eq $fn } @cryptoskipheaders;
+   our %cryptoheaders = ();
+   our %sslheaders = ();
+   foreach my $d ( qw( include/openssl include/internal ) ) {
+       my @header_patterns =
+           map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' );
+       foreach my $f ( map { glob($_) } @header_patterns ) {
+           my $base = basename($f);
+           my $base_in = basename($f, '.in');
+           my $dir = catfile($config{sourcedir}, $d);
+           if ($base ne $base_in) {
+               # We have a .h.in file, which means the header file is in the
+               # build tree.
+               $base = $base_in;
+               $dir = catfile($config{builddir}, $d);
+           }
+           my $new_f = catfile($dir, $base);
+           my $fn = "$d/$base";
+           # The logic to add files to @cryptoheaders is a bit complex.  The
+           # file to be added must be either in the public header directory
+           # or one of the pre-declared internal headers, and must under no
+           # circumstances be one of those that must be skipped.
+           $cryptoheaders{$new_f} = 1
+               if (($d eq 'include/openssl'
+                    || ( grep { $_ eq $fn } @cryptoheaders_tmpl ))
+                   && !( grep { $_ eq $fn } @cryptoskipheaders ));
+           # The logic to add files to @sslheaders is much simpler...
+           $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl;
+       }
    }
    "";
 -}
 CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
-                      fill_lines(" ", $COLUMNS - 14, sort @cryptoheaders)) -}
+                      fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -}
 SSLHEADERS={- join(" \\\n" . ' ' x 11,
-                   fill_lines(" ", $COLUMNS - 11, sort @sslheaders)) -}
-ordinals:
-       ( cd $(SRCDIR); \
-          $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
-                  --ordinals util/libcrypto.num \
-                  --symhacks include/openssl/symhacks.h \
-                  $(CRYPTOHEADERS) )
-       ( cd $(SRCDIR); \
-          $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
-                  --ordinals util/libssl.num \
-                  --symhacks include/openssl/symhacks.h \
-                  $(SSLHEADERS))
+                   fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
+ordinals: build_generated
+       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
+                --ordinals $(SRCDIR)/util/libcrypto.num \
+                --symhacks $(SRCDIR)/include/openssl/symhacks.h \
+                $(CRYPTOHEADERS)
+       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
+                --ordinals $(SRCDIR)/util/libssl.num \
+                --symhacks $(SRCDIR)/include/openssl/symhacks.h \
+                $(SSLHEADERS)
 
 test_ordinals:
        ( cd test; \
@@ -1510,13 +1532,14 @@ EOF
       my @objs = map { platform->obj($_) } @{$args{objs}};
       my $deps = join(" \\\n" . ' ' x (length($lib) + 2),
                       fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
-      my $max_per_call = 250;
+      my $max_per_call = 500;
       my @objs_grouped;
       push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs;
       my $fill_lib =
           join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped));
       return <<"EOF";
 $lib: $deps
+       \$(RM) $lib
        $fill_lib
        \$(RANLIB) \$\@ || echo Never mind.
 EOF