]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - Configurations/unix-Makefile.tmpl
Makefile: Add SRCS list of all .c (and any .cc and .cpp) files
[thirdparty/openssl.git] / Configurations / unix-Makefile.tmpl
index 3f78d6d5de8d9bde1f19ec0830b3248d61ef48dd..c74d539f4a38f16ff91a72bea84dca7f8276a02e 100644 (file)
@@ -3,6 +3,8 @@
 ##
 ## {- join("\n## ", @autowarntext) -}
 {-
+     use OpenSSL::Util;
+
      our $makedep_scheme = $config{makedep_scheme};
      our $makedepcmd = platform->makedepcmd();
 
@@ -65,6 +67,7 @@ BLDDIR={- $config{builddir} -}
 FIPSKEY={- $config{FIPSKEY} -}
 
 VERSION={- "$config{full_version}" -}
+VERSION_NUMBER={- "$config{version}" -}
 MAJOR={- $config{major} -}
 MINOR={- $config{minor} -}
 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
@@ -88,14 +91,21 @@ SHLIB_INFO={- join(" \\\n" . ' ' x 11,
 MODULES={- join(" \\\n" . ' ' x 8,
                 fill_lines(" ", $COLUMNS - 8,
                            map { platform->dso($_) }
+                           # Drop all modules that are dependencies, they will
+                           # be processed through their dependents
+                           grep { my $x = $_;
+                                  !grep { grep { $_ eq $x } @$_ }
+                                        values %{$unified_info{depends}} }
                            @{$unified_info{modules}})) -}
-FIPSMODULENAME={- # We do some extra checking here, as there should be only one
-                  use File::Basename;
-                  my @fipsmodules =
-                      grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
-                             && $unified_info{attributes}->{modules}->{$_}->{fips} }
-                      @{$unified_info{modules}};
-                  die "More that one FIPS module" if scalar @fipsmodules > 1;
+FIPSMODULE={- # We do some extra checking here, as there should be only one
+              use File::Basename;
+              our @fipsmodules =
+                  grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
+                         && $unified_info{attributes}->{modules}->{$_}->{fips} }
+                  @{$unified_info{modules}};
+              die "More that one FIPS module" if scalar @fipsmodules > 1;
+              join(" ", map { platform->dso($_) } @fipsmodules) -}
+FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1;
                   join(" ", map { basename(platform->dso($_)) } @fipsmodules) -}
 
 PROGRAMS={- join(" \\\n" . ' ' x 9,
@@ -164,23 +174,24 @@ INSTALL_ENGINES={-
                                && $unified_info{attributes}->{modules}->{$_}->{engine} }
                         @{$unified_info{modules}}))
 -}
-INSTALL_FIPS={-
+INSTALL_MODULES={-
         join(" \\\n" . ' ' x 16,
              fill_lines(" ", $COLUMNS - 16,
                         map { platform->dso($_) }
                         grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
-                               && $unified_info{attributes}->{modules}->{$_}->{fips} }
+                               && !$unified_info{attributes}->{modules}->{$_}->{engine}
+                               && !$unified_info{attributes}->{modules}->{$_}->{fips} }
                         @{$unified_info{modules}}))
 -}
-INSTALL_MODULES={-
+INSTALL_FIPSMODULE={-
         join(" \\\n" . ' ' x 16,
              fill_lines(" ", $COLUMNS - 16,
                         map { platform->dso($_) }
                         grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
-                               && !$unified_info{attributes}->{modules}->{$_}->{engine}
-                               && !$unified_info{attributes}->{modules}->{$_}->{fips} }
+                               && $unified_info{attributes}->{modules}->{$_}->{fips} }
                         @{$unified_info{modules}}))
 -}
+INSTALL_FIPSMODULECONF=providers/fipsmodule.cnf
 INSTALL_PROGRAMS={-
         join(" \\\n" . ' ' x 16,
              fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) }
@@ -205,6 +216,22 @@ MISC_SCRIPTS={-
                                && $unified_info{attributes}->{scripts}->{$_}->{misc} }
                         @{$unified_info{scripts}}))
 -}
+IMAGEDOCS1={-
+        join(" \\\n" . ' ' x 10,
+             fill_lines(" ", $COLUMNS - 10,
+                        @{$unified_info{imagedocs}->{man1}})) -}
+IMAGEDOCS3={-
+        join(" \\\n" . ' ' x 10,
+             fill_lines(" ", $COLUMNS - 10,
+                        @{$unified_info{imagedocs}->{man3}})) -}
+IMAGEDOCS5={-
+        join(" \\\n" . ' ' x 10,
+             fill_lines(" ", $COLUMNS - 10,
+                        @{$unified_info{imagedocs}->{man5}})) -}
+IMAGEDOCS7={-
+        join(" \\\n" . ' ' x 10,
+             fill_lines(" ", $COLUMNS - 10,
+                        @{$unified_info{imagedocs}->{man7}})) -}
 HTMLDOCS1={-
         join(" \\\n" . ' ' x 10,
              fill_lines(" ", $COLUMNS - 10,
@@ -271,14 +298,7 @@ OPENSSLDIR={- #
               $openssldir -}
 LIBDIR={- our $libdir = $config{libdir};
           unless ($libdir) {
-              #
-              # if $prefix/lib$target{multilib} is not an existing
-              # directory, then assume that it's not searched by linker
-              # automatically, in which case adding $target{multilib} suffix
-              # causes more grief than we're ready to tolerate, so don't...
-              our $multilib =
-                  -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
-              $libdir = "lib$multilib";
+              $libdir = "lib$target{multilib}";
           }
           file_name_is_absolute($libdir) ? "" : $libdir -}
 # $(libdir) is chosen to be compatible with the GNU coding standards
@@ -506,7 +526,8 @@ build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
 all: build_sw build_docs
 
 test: tests
-{- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils
+{- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils run_tests
+run_tests:
        @ : {- output_off() if $disabled{tests}; "" -}
        ( SRCTOP=$(SRCDIR) \
          BLDTOP=$(BLDDIR) \
@@ -520,8 +541,7 @@ test: tests
 
 list-tests:
        @ : {- output_off() if $disabled{tests}; "" -}
-       @SRCTOP="$(SRCDIR)" \
-        $(PERL) $(SRCDIR)/test/run_tests.pl list
+       $(MAKE) run_tests TESTS=list
        @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
        @echo "Tests are not supported with your chosen Configure options"
        @ : {- output_on() if !$disabled{tests}; "" -}
@@ -562,23 +582,25 @@ clean: libclean
        $(RM) $(MANDOCS3)
        $(RM) $(MANDOCS5)
        $(RM) $(MANDOCS7)
-       $(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(SCRIPTS)
+       $(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(FIPSMODULE) $(SCRIPTS)
        $(RM) $(GENERATED_MANDATORY) $(GENERATED)
        -find . -name '*{- platform->depext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
        -find . -name '*{- platform->objext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
        $(RM) core
-       $(RM) tags TAGS doc-nits cmd-nits md-nits
+       $(RM) tags TAGS doc-nits md-nits
        $(RM) -r test/test-runs
+       $(RM) providers/fips*.new
        $(RM) openssl.pc libcrypto.pc libssl.pc
        -find . -type l \! -name '.*' -exec $(RM) {} \;
 
 distclean: clean
+       $(RM) include/openssl/configuration.h
        $(RM) configdata.pm
        $(RM) Makefile
 
 # We check if any depfile is newer than Makefile and decide to
 # concatenate only if that is true.
-depend:
+depend: Makefile
        @: {- output_off() if $disabled{makedepend}; "" -}
        @$(PERL) $(SRCDIR)/util/add-depends.pl "{- $makedep_scheme -}"
        @: {- output_on() if $disabled{makedepend}; "" -}
@@ -595,18 +617,19 @@ uninstall_docs: uninstall_man_docs uninstall_html_docs
        $(RM) -r $(DESTDIR)$(DOCDIR)
 
 {- output_off() if $disabled{fips}; "" -}
-install_fips: build_sw providers/fipsmodule.cnf
+install_fips: build_sw $(INSTALL_FIPSMODULECONF)
        @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
        @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)
        @$(ECHO) "*** Installing FIPS module"
-       @$(ECHO) "install $(INSTALL_FIPS) -> $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
-       @cp "$(INSTALL_FIPS)" $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new
+       @$(ECHO) "install $(INSTALL_FIPSMODULE) -> $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
+       @cp "$(INSTALL_FIPSMODULE)" $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new
        @chmod 755 $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new
        @mv -f $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new \
               $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)
        @$(ECHO) "*** Installing FIPS module configuration"
-       @$(ECHO) "install providers/fipsmodule.cnf -> $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
-       @cp providers/fipsmodule.cnf $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf
+       @$(ECHO) "install $(INSTALL_FIPSMODULECONF) -> $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
+       @cp $(INSTALL_FIPSMODULECONF) $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf
 
 uninstall_fips:
        @$(ECHO) "*** Uninstalling FIPS module configuration"
@@ -671,11 +694,11 @@ install_dev: install_runtime_libs
        @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
        @$(ECHO) "*** Installing development files"
        @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
-       @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
+       @ : {- output_off() if $disabled{uplink}; "" -}
        @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
        @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
        @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
-       @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
+       @ : {- output_on() if $disabled{uplink}; "" -}
        @set -e; for i in $(SRCDIR)/include/openssl/*.h \
                          $(BLDDIR)/include/openssl/*.h; do \
                fn=`basename $$i`; \
@@ -745,10 +768,10 @@ install_dev: install_runtime_libs
 
 uninstall_dev: uninstall_runtime_libs
        @$(ECHO) "*** Uninstalling development files"
-       @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
+       @ : {- output_off() if $disabled{uplink}; "" -}
        @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
        @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
-       @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
+       @ : {- output_on() if $disabled{uplink}; "" -}
        @set -e; for i in $(SRCDIR)/include/openssl/*.h \
                          $(BLDDIR)/include/openssl/*.h; do \
                fn=`basename $$i`; \
@@ -937,6 +960,7 @@ install_man_docs: build_man_docs
                $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
                cp $$x $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
                chmod 644 $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
+               $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man1; \
        done
        @set -e; for x in dummy $(MANDOCS3); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
@@ -944,6 +968,7 @@ install_man_docs: build_man_docs
                $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
                cp $$x $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
                chmod 644 $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
+               $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man3; \
        done
        @set -e; for x in dummy $(MANDOCS5); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
@@ -951,6 +976,7 @@ install_man_docs: build_man_docs
                $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
                cp $$x $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
                chmod 644 $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
+               $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man5; \
        done
        @set -e; for x in dummy $(MANDOCS7); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
@@ -958,36 +984,41 @@ install_man_docs: build_man_docs
                $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
                cp $$x $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
                chmod 644 $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
+               $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man7; \
        done
 
-uninstall_man_docs:
+uninstall_man_docs: build_man_docs
        @$(ECHO) "*** Uninstalling manpages"
        @set -e; for x in dummy $(MANDOCS1); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
                $(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
+               $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man1; \
        done
        @set -e; for x in dummy $(MANDOCS3); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
                $(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
+               $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man3; \
        done
        @set -e; for x in dummy $(MANDOCS5); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
                $(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
+               $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man5; \
        done
        @set -e; for x in dummy $(MANDOCS7); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
                $(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
+               $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) $(DESTDIR)$(MANDIR)/man7; \
        done
 
-install_html_docs: build_html_docs
+install_html_docs: install_image_docs build_html_docs
        @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
        @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man1
        @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man3
@@ -1023,7 +1054,7 @@ install_html_docs: build_html_docs
                chmod 644 $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
        done
 
-uninstall_html_docs:
+uninstall_html_docs: uninstall_image_docs
        @$(ECHO) "*** Uninstalling HTML manpages"
        @set -e; for x in dummy $(HTMLDOCS1); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
@@ -1050,23 +1081,41 @@ uninstall_html_docs:
                $(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
        done
 
+install_image_docs:
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man7/img
+       @set -e; for x in dummy $(IMAGEDOCS7); do \
+               if [ "$$x" = "dummy" ]; then continue; fi; \
+               fn=`basename $$x`; \
+               $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
+               cp $(SRCDIR)/$$x $(DESTDIR)$(HTMLDIR)/man7/img/$$fn; \
+               chmod 644 $(DESTDIR)$(HTMLDIR)/man7/img/$$fn; \
+       done
+
+uninstall_image_docs:
+       @set -e; for x in dummy $(IMAGEDOCS7); do \
+               if [ "$$x" = "dummy" ]; then continue; fi; \
+               fn=`basename $$x`; \
+               $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
+               $(RM) $(DESTDIR)$(HTMLDIR)/man7/img/$$fn; \
+       done
+
 # Developer targets (note: these are only available on Unix) #########
 
 # It's important that generate_buildinfo comes after ordinals, as ordinals
 # is sensitive to build.info changes.
 update: generate errors ordinals generate_buildinfo
 
+.PHONY: generate generate_apps generate_crypto_bn generate_crypto_objects \
+          generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
 generate: generate_apps generate_crypto_bn generate_crypto_objects \
           generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
 
+.PHONY: generate_buildinfo generate_doc_buildinfo
 generate_buildinfo: generate_doc_buildinfo
 
-.PHONY: doc-nits cmd-nits md-nits
+.PHONY: doc-nits md-nits
 doc-nits: build_generated_pods
-       $(PERL) $(SRCDIR)/util/find-doc-nits -n -l -e
-
-cmd-nits: build_generated apps/openssl build_generated_pods
-       $(PERL) $(SRCDIR)/util/find-doc-nits -c
+       $(PERL) $(SRCDIR)/util/find-doc-nits -c -n -l -e
 
 # This uses "mdl", the markdownlint application, which is written in ruby.
 # The source is at https://github.com/markdownlint/markdownlint
@@ -1108,7 +1157,7 @@ generate_crypto_objects:
                                crypto/objects/obj_mac.num \
                                crypto/objects/obj_xref.txt \
                                > crypto/objects/obj_xref.h )
-       ( cd $(SRCDIR); cat crypto/objects/obj_compat.h >> include/openssl/obj_mac.h )
+       ( cd $(SRCDIR); sed -e '1,8d' crypto/objects/obj_compat.h >> include/openssl/obj_mac.h )
 
 generate_crypto_conf:
        ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
@@ -1138,33 +1187,50 @@ generate_doc_buildinfo:
           fi )
 
 generate_fips_sources: providers/fips.module.sources.new
-providers/fips.module.sources.new: \
-                $(SRCDIR)/Configure \
-                {- join(" \\\n" . ' ' x 16,
-                        fill_lines(" ", $COLUMNS - 16,
-                                   @{$config{build_file_templates}},
-                                   @{$config{build_infos}},
-                                   @{$config{conf_files}})) -}
+providers/fips.module.sources.new: configdata.pm
        rm -rf sources-tmp
        mkdir sources-tmp
        ( \
          srcdir=`cd $(SRCDIR); pwd`; \
          cd sources-tmp \
-         && $$srcdir/Configure enable-fips \
+         && $$srcdir/Configure --banner=Configured enable-fips -O0 \
          && ./configdata.pm --query 'get_sources("providers/fips")' > sources1 \
-         && $$srcdir/Configure enable-fips no-asm \
+         && $(MAKE) -sj 4 build_generated providers/fips.so \
+         && find . -name '*.d' | xargs cat > dep1 \
+          && $(MAKE) distclean \
+         && $$srcdir/Configure --banner=Configured enable-fips no-asm -O0 \
          && ./configdata.pm --query 'get_sources("providers/fips")' > sources2 \
+         && $(MAKE) -sj 4 build_generated providers/fips.so \
+         && find . -name '*.d' | xargs cat > dep2 \
+         && cat sources1 sources2 \
+            | grep -v ' : \\$$' | grep -v util/providers.num \
+            | sed -e 's/^ *//' -e 's/ *\\$$//' \
+            | sort | uniq > sources \
+         && cat dep1 dep2 \
+            | $(PERL) -p -e 's/\\\n//' \
+            | sed -e 's/^.*: *//' -e 's/  */ /g' \
+            | fgrep -f sources \
+            | tr ' ' '\n' \
+            | sort | uniq > deps.raw \
+         && cat deps.raw \
+            | xargs ./configdata.pm --query 'get_sources(@ARGV)' \
+            | $(PERL) -p -e 's/\\\n//' \
+            | sed -e 's/\./\\\./g' -e 's/ : */:/' -e 's/^/s:/' -e 's/$$/:/' \
+            > deps.sed \
+         && cat deps.raw | sed -f deps.sed > deps \
        )
        ( \
-         srcdir2=`if [ "$(SRCDIR)" = "." ]; then echo ".."; elif echo "$(SRCDIR)" | grep '^/' > /dev/null; then echo "$(SRCDIR)"; else echo "../$(SRCDIR)"; fi`; \
-         cat sources-tmp/sources1 sources-tmp/sources2 \
-         | grep -v ' : \\$$' | sed -e 's| \\$$||' -e "s|^  $$srcdir2/||"; \
+         cat sources-tmp/sources sources-tmp/deps \
+            | $(PERL) -p -e 's:^ *\Q../\E:: ;' \
+                         -e 's:^\Q$(SRCDIR)/\E:: if "$(SRCDIR)" ne "." ;' \
+                         -e 'my $$x; do { $$x = $$_; s:(^|/)((?!\Q../\E)[^/]*/)\Q..\E($$|/):$$1: } while ($$x ne $$_) ;' ; \
          cd $(SRCDIR); \
          for x in crypto/bn/asm/*.pl crypto/bn/asm/*.S \
                   crypto/aes/asm/*.pl crypto/aes/asm/*.S \
                   crypto/ec/asm/*.pl \
                   crypto/modes/asm/*.pl \
-                  crypto/sha/asm/*.pl; do \
+                  crypto/sha/asm/*.pl \
+                  crypto/x86_64cpuid.pl; do \
            echo "$$x"; \
          done \
        ) | sort | uniq > providers/fips.module.sources.new
@@ -1194,6 +1260,7 @@ errors:
            include/openssl/tls1.h
            include/openssl/dtls1.h
            include/openssl/srtp.h
+           include/openssl/quic.h
            include/openssl/sslerr_legacy.h );
    my @cryptoheaders_tmpl =
        qw( include/internal/dso.h
@@ -1239,32 +1306,53 @@ errors:
    }
    "";
 -}
+SRCS={-
+sub uniq { my %seen; grep !$seen{$_}++, @_; }
+sub flat(@) { return map { ref eq 'ARRAY' ? @$_ : $_ } @_; }
+join(" \\\n" . ' ' x 5, fill_lines(" ", $COLUMNS - 5,
+     uniq(grep /\.(c|cc|cpp)$/,
+          flat (map { $unified_info{sources}->{$_} }
+                (sort keys %{$unified_info{sources}})))))
+-}
 CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
                       fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -}
 SSLHEADERS={- join(" \\\n" . ' ' x 11,
                    fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
-ordinals: build_generated
-       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
+
+renumber: build_generated
+       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
+                --ordinals $(SRCDIR)/util/libcrypto.num \
+                --symhacks $(SRCDIR)/include/openssl/symhacks.h \
+                --renumber \
+                $(CRYPTOHEADERS)
+       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
+                --ordinals $(SRCDIR)/util/libssl.num \
+                --symhacks $(SRCDIR)/include/openssl/symhacks.h \
+                --renumber \
+                $(SSLHEADERS)
+
+$(SRCDIR)/util/libcrypto.num: $(CRYPTOHEADERS) $(SRCDIR)/include/openssl/symhacks.h
+       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
                 --ordinals $(SRCDIR)/util/libcrypto.num \
                 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
                 $(CRYPTOHEADERS)
-       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
+$(SRCDIR)/util/libssl.num: $(SSLHEADERS) $(SRCDIR)/include/openssl/symhacks.h
+       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
                 --ordinals $(SRCDIR)/util/libssl.num \
                 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
                 $(SSLHEADERS)
+.PHONY: ordinals
+ordinals: build_generated $(SRCDIR)/util/libcrypto.num $(SRCDIR)/util/libssl.num
 
 test_ordinals:
-       ( cd test; \
-         SRCTOP=../$(SRCDIR) \
-         BLDTOP=../$(BLDDIR) \
-           $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
+       $(MAKE) run_tests TESTS=test_ordinals
 
 tags TAGS: FORCE
        rm -f TAGS tags
        -ctags -R .
        -etags `find . -name '*.[ch]' -o -name '*.pm'`
 
-providers/fips.checksum.new: generate_fips_sources
+providers/fips.checksum.new: providers/fips.module.sources.new
        @which unifdef > /dev/null || \
        ( echo >&2 "ERROR: unifdef not in your \$$PATH, FIPS checksums not calculated"; \
          false )
@@ -1297,16 +1385,15 @@ tar:
 
 # Helper targets #####################################################
 
-link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/wrap.pl \
-            $(BLDDIR)/apps/openssl.cnf
+link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/apps/openssl.cnf
 
-$(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/wrap.pl: configdata.pm
+$(BLDDIR)/util/opensslwrap.sh: Makefile
        @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
            mkdir -p "$(BLDDIR)/util"; \
            ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \
        fi
 
-$(BLDDIR)/apps/openssl.cnf: configdata.pm
+$(BLDDIR)/apps/openssl.cnf: Makefile
        @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
            mkdir -p "$(BLDDIR)/apps"; \
            ln -sf "../$(SRCDIR)/apps/`basename "$@"`" "$(BLDDIR)/apps"; \
@@ -1316,7 +1403,8 @@ FORCE:
 
 # Building targets ###################################################
 
-libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
+libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
+
 libcrypto.pc:
        @ ( echo 'prefix=$(INSTALLTOP)'; \
            echo 'exec_prefix=$${prefix}'; \
@@ -1327,6 +1415,7 @@ libcrypto.pc:
            fi; \
            echo 'includedir=$${prefix}/include'; \
            echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
+           echo 'modulesdir=$${libdir}/ossl-modules'; \
            echo ''; \
            echo 'Name: OpenSSL-libcrypto'; \
            echo 'Description: OpenSSL cryptography library'; \
@@ -1367,10 +1456,22 @@ openssl.pc:
            echo 'Version: '$(VERSION); \
            echo 'Requires: libssl libcrypto' ) > openssl.pc
 
+Makefile: configdata.pm \
+          {- join(" \\\n" . ' ' x 10,
+                  fill_lines(" ", $COLUMNS - 10,
+                             @{$config{build_file_templates}})) -}
+       @echo "Detected changed: $?"
+       $(PERL) configdata.pm
+       @echo "**************************************************"
+       @echo "***                                            ***"
+       @echo "***   Please run the same make command again   ***"
+       @echo "***                                            ***"
+       @echo "**************************************************"
+       @false
+
 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \
                {- join(" \\\n" . ' ' x 15,
                        fill_lines(" ", $COLUMNS - 15,
-                                  @{$config{build_file_templates}},
                                   @{$config{build_infos}},
                                   @{$config{conf_files}})) -}
        @echo "Detected changed: $?"
@@ -1389,6 +1490,17 @@ reconfigure reconf:
   use File::Basename;
   use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
 
+  # Helper function to convert dependencies in platform agnostic form to
+  # dependencies in platform form.
+  sub compute_platform_depends {
+      map { my $x = $_;
+
+            grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
+            or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
+            or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
+            or platform->convertext($x); } @_;
+  }
+
   # Helper function to figure out dependencies on libraries
   # It takes a list of library names and outputs a list of dependencies
   sub compute_lib_depends {
@@ -1397,13 +1509,14 @@ reconfigure reconf:
       # On Unix platforms, we depend on {shlibname}.so
       return map { platform->sharedlib_simple($_)
                    // platform->sharedlib_import($_)
+                   // platform->sharedlib($_)
                    // platform->staticlib($_)
                  } @_;
   }
 
   sub generatetarget {
       my %args = @_;
-      my $deps = join(" ", @{$args{deps}});
+      my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
       return <<"EOF";
 $args{target}: $deps
 EOF
@@ -1417,7 +1530,8 @@ EOF
       my $gen_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
       my $incs = join("", map { " -I".$_ } @{$args{incs}});
       my $defs = join("", map { " -D".$_ } @{$args{defs}});
-      my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
+      my $deps = join(" ", compute_platform_depends(@{$args{generator_deps}},
+                                                    @{$args{deps}}));
 
       if ($args{src} =~ /\.html$/) {
           #
@@ -1447,11 +1561,11 @@ EOF
           #
           my $target = platform->def($args{src});
           (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
-          my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
+          my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
           my $ord_name = $args{generator}->[1] || $args{product};
           return <<"EOF";
 $target: $gen0 $deps \$(SRCDIR)/util/mkdef.pl
-       \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $gen0  --name $ord_name --OS $mkdef_os > $target
+       \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --type $args{intent} --ordinals $gen0  --name $ord_name --OS $mkdef_os > $target
 EOF
       } elsif (platform->isasm($args{src})) {
           #
@@ -1494,38 +1608,22 @@ 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;
-          $deps = join(' ', $deps, @modules);
-          @modules = map { "-M".basename($_, '.pm') } @modules;
-          my $modules = join(' ', '', sort keys %moduleincs, @modules);
+          my @perlmodules = ( 'configdata.pm',
+                              grep { $_ =~ m|\.pm$| } @{$args{deps}} );
+          my %perlmoduleincs = map { '"-I'.dirname($_).'"' => 1 } @perlmodules;
+          $deps = join(' ', $deps, compute_platform_depends(@perlmodules));
+          @perlmodules = map { "-M".basename($_, '.pm') } @perlmodules;
+          my $perlmodules = join(' ', '', sort keys %perlmoduleincs, @perlmodules);
           return <<"EOF";
 $args{src}: $gen0 $deps
-       \$(PERL)$modules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@
+       \$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@
 EOF
       } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
           #
           # Generic generator using OpenSSL programs
           #
 
-          # Redo $deps, because programs aren't expected to have deps of their
-          # own.  This is a little more tricky, though, because running programs
-          # may have dependencies on all sorts of files, so we search through
-          # our database of programs and modules to see if our dependencies
-          # are one of those.
-          $deps = join(' ', map { my $x = $_;
-                                  if (grep { $x eq $_ }
-                                          @{$unified_info{programs}}) {
-                                      platform->bin($x);
-                                  } elsif (grep { $x eq $_ }
-                                          @{$unified_info{modules}}) {
-                                      platform->dso($x);
-                                  } else {
-                                      $x;
-                                  }
-                                } @{$args{deps}});
-          # Also redo $gen0, to ensure that we have the proper extension where
+          # Redo $gen0, to ensure that we have the proper extension where
           # necessary.
           $gen0 = platform->bin($gen0);
           # Use $(PERL) to execute wrap.pl directly to avoid calling env
@@ -1778,7 +1876,7 @@ EOF
       my @deps = compute_lib_depends(@{$args{deps}});
       my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
       # Next line needs to become "less magic" (see PR #11950)
-      $shared_def .= ' '.$target{shared_fipsflag} if (m/providers\/fips/ && defined $target{shared_fipsflag});
+      $shared_def .= ' '.$target{shared_fipsflag} if (defined $target{shared_fipsflag} && $shared_def =~ m/providers\/fips/);
       my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
       my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
                       fill_lines(' ', $COLUMNS - length($dso) - 2,
@@ -1863,7 +1961,8 @@ EOF
                                            "util", "dofile.pl")),
                            rel2abs($config{builddir}));
       return <<"EOF";
-$script: $sources
+$script: $sources configdata.pm
+       \$(RM) "$script"
        \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
            "-o$target{build_file}" $sources > "$script"
        chmod a+x $script
@@ -1872,11 +1971,8 @@ EOF
   sub generatedir {
       my %args = @_;
       my $dir = $args{dir};
-      my @deps = map { platform->convertext($_) } @{$args{deps}};
+      my @deps = compute_platform_depends(@{$args{deps}});
       my @comments = ();
-      my %extinfo = ( dso => platform->dsoext(),
-                      lib => platform->libext(),
-                      bin => platform->binext() );
 
       # We already have a 'test' target, and the top directory is just plain
       # silly
@@ -1891,7 +1987,7 @@ EOF
           if ($type ne "lib") {
               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
                   if (dirname($prod) eq $dir) {
-                      push @deps, $prod.$extinfo{$type};
+                      push @deps, compute_platform_depends($prod);
                   } else {
                       push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
                   }