Reduce optimization in hppa builds
[openssl.git] / Configurations / unix-Makefile.tmpl
index 1f4697f52a3c08a896a70552e2f54fc684e42113..4c24cae7ab62ee9e0e16b8a66b71fdf24dd5d488 100644 (file)
@@ -3,14 +3,21 @@
 ##
 ## {- join("\n## ", @autowarntext) -}
 {-
+     use OpenSSL::Util;
+
      our $makedep_scheme = $config{makedep_scheme};
      our $makedepcmd = platform->makedepcmd();
 
      sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
 
      # Shared AIX support is special. We put libcrypto[64].so.ver into
-     # libcrypto.a and use libcrypto_a.a as static one.
-     sub sharedaix  { !$disabled{shared} && $config{target} =~ /^aix/ }
+     # libcrypto.a and use libcrypto_a.a as static one, unless using
+     # shared_target style aix-solib.  In that mode, create
+     # libcrypto.so as a link-import library that inserts runtime
+     # dependencies on libcrypto.so.ver, and the static library is
+     # named libcrypto.a.
+     sub sharedaix  { !$disabled{shared} && $target{shared_target} =~ /^aix(?!-solib$)/ }
+     sub sharedaix_solib  { !$disabled{shared} && $target{shared_target} =~ /^aix-solib$/ }
 
      our $sover_dirname = platform->shlib_version_as_filename();
 
@@ -18,8 +25,9 @@
      # to. You're welcome.
      sub dependmagic {
          my $target = shift;
+         my $help = shift;
 
-         return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
+         return "$target: build_generated ## $help\n\t\"\$(MAKE)\" depend && \"\$(MAKE)\" _$target\n_$target";
      }
 
      our $COLUMNS = $ENV{COLUMNS};
@@ -65,6 +73,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 +97,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,
@@ -169,15 +185,37 @@ INSTALL_MODULES={-
              fill_lines(" ", $COLUMNS - 16,
                         map { platform->dso($_) }
                         grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
-                               && !$unified_info{attributes}->{modules}->{$_}->{engine} }
+                               && !$unified_info{attributes}->{modules}->{$_}->{engine}
+                               && !$unified_info{attributes}->{modules}->{$_}->{fips} }
+                        @{$unified_info{modules}}))
+-}
+INSTALL_FIPSMODULE={-
+        join(" \\\n" . ' ' x 16,
+             fill_lines(" ", $COLUMNS - 16,
+                        map { platform->dso($_) }
+                        grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
+                               && $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($_) }
                         grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
                         @{$unified_info{programs}}))
 -}
+INSTALL_EXPORTERS_PKGCONFIG={-
+        join(" \\\n" . ' ' x 28,
+             fill_lines(" ", $COLUMNS - 28,
+                        grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'pkg-config'}
+                        sort keys %{$unified_info{generate}}))
+-}
+INSTALL_EXPORTERS_CMAKE={-
+        join(" \\\n" . ' ' x 24,
+             fill_lines(" ", $COLUMNS - 24,
+                        grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'cmake'}
+                        sort keys %{$unified_info{generate}}))
+-}
 BIN_SCRIPTS={-
         join(" \\\n" . ' ' x 12,
              fill_lines(" ", $COLUMNS - 12,
@@ -196,6 +234,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,
@@ -262,14 +316,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
@@ -282,6 +329,17 @@ MODULESDIR=$(libdir)/ossl-modules
 # libraries and applications
 LIBRPATH=$(libdir)
 
+BINDIR={- our $bindir = $config{bindir};
+          unless ($bindir) {
+              $bindir = "bin$target{multibin}";
+          }
+          file_name_is_absolute($bindir) ? "" : $bindir -}
+bindir={- file_name_is_absolute($bindir)
+          ? $bindir : '$(INSTALLTOP)/$(BINDIR)' -}
+
+PKGCONFIGDIR=$(libdir)/pkgconfig
+CMAKECONFIGDIR=$(libdir)/cmake/OpenSSL
+
 MANDIR=$(INSTALLTOP)/share/man
 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
 HTMLDIR=$(DOCDIR)/html
@@ -467,18 +525,23 @@ LANG=C
 
 # The main targets ###################################################
 
-{- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
-{- dependmagic('build_libs'); -}: build_libs_nodep
-{- dependmagic('build_modules'); -}: build_modules_nodep
-{- dependmagic('build_programs'); -}: build_programs_nodep
+##@ Software
 
+{- dependmagic('build_sw', 'Build all the software (default target)'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
+{- dependmagic('build_libs', 'Build the libraries libssl and libcrypto'); -}: build_libs_nodep
+{- dependmagic('build_modules', 'Build the modules (i.e. providers and engines)'); -}: build_modules_nodep
+{- dependmagic('build_programs', 'Build the openssl executables and scripts'); -}: build_programs_nodep
+
+all: build_sw {- "build_docs" if !$disabled{docs}; -} ## Build software and documentation
+
+##@ Documentation
 build_generated_pods: $(GENERATED_PODS)
-build_docs: build_man_docs build_html_docs
-build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7)
-build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
+build_docs: build_man_docs build_html_docs ## Create documentation
+build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) ## Create manpages
+build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) ## Create HTML documentation
 
 build_generated: $(GENERATED_MANDATORY)
-build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
+build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
 build_modules_nodep: $(MODULES)
 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
 
@@ -494,10 +557,16 @@ build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
        @echo "         then make will fail..."
        @ : {- output_on() if $disabled{makedepend}; "" -}
 
-all: build_sw build_docs
+##@ Help
+.PHONY: help
+help: ## Show this help screen
+       @$(PERL) $(SRCDIR)/util/help.pl $(BLDDIR)/Makefile
 
-test: tests
-{- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils
+##@ Testing
+test: tests ## Run tests (alias of "tests")
+{- dependmagic('tests', 'Run tests'); -}: build_programs_nodep build_modules_nodep link-utils
+       "$(MAKE)" run_tests
+run_tests: FORCE
        @ : {- output_off() if $disabled{tests}; "" -}
        ( SRCTOP=$(SRCDIR) \
          BLDTOP=$(BLDDIR) \
@@ -509,17 +578,14 @@ test: tests
        @echo "Tests are not supported with your chosen Configure options"
        @ : {- output_on() if !$disabled{tests}; "" -}
 
-list-tests:
+list-tests: ## List available tests that can be invoked via "make test TESTS=<name>"
        @ : {- 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}; "" -}
 
-install: install_sw install_ssldirs install_docs
-
-uninstall: uninstall_docs uninstall_sw
+##@ Workspace cleaning
 
 libclean:
        @set -e; for s in $(SHLIB_INFO); do \
@@ -544,7 +610,7 @@ libclean:
        $(RM) $(LIBS)
        $(RM) *{- platform->defext() -}
 
-clean: libclean
+clean: libclean ## Clean the workspace, keep the configuration
        $(RM) $(HTMLDOCS1)
        $(RM) $(HTMLDOCS3)
        $(RM) $(HTMLDOCS5)
@@ -553,121 +619,143 @@ 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) openssl.pc libcrypto.pc libssl.pc
+       $(RM) providers/fips*.new
        -find . -type l \! -name '.*' -exec $(RM) {} \;
 
-distclean: clean
+distclean: clean ## Clean and remove the configuration
+       $(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}; "" -}
 
 # Install helper targets #############################################
+##@ Installation
+
+install: install_sw install_ssldirs {- "install_docs" if !$disabled{docs}; -} {- $disabled{fips} ? "" : "install_fips" -} ## Install software and documentation, create OpenSSL directories
+
+uninstall: {- "uninstall_docs" if !$disabled{docs}; -} uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -} ## Uninstall software and documentation
 
-install_sw: install_dev install_engines install_modules install_runtime
+install_sw: install_dev install_engines install_modules install_runtime ## Install just the software and libraries
 
-uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
+uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev ## Uninstall the software and libraries
 
-install_docs: install_man_docs install_html_docs
+install_docs: install_man_docs install_html_docs ## Install manpages and HTML documentation
 
-uninstall_docs: uninstall_man_docs uninstall_html_docs
-       $(RM) -r $(DESTDIR)$(DOCDIR)
+uninstall_docs: uninstall_man_docs uninstall_html_docs ## Uninstall manpages and HTML documentation
+       $(RM) -r "$(DESTDIR)$(DOCDIR)"
 
-install_fips: install_sw
+{- output_off() if $disabled{fips}; "" -}
+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_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) "fipsinstall $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
-       @$(PERL) $(BLDDIR)/util/wrap.pl $(BLDDIR)/apps/openssl fipsinstall \
-               -module $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME) \
-               -out $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf \
-               -macopt 'hexkey:$(FIPSKEY)'
+       @$(ECHO) "install $(INSTALL_FIPSMODULECONF) -> $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
+       @cp $(INSTALL_FIPSMODULECONF) "$(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
 
-uninstall_fips: uninstall_sw
+uninstall_fips:
        @$(ECHO) "*** Uninstalling FIPS module configuration"
-       @$(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
-       @$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf
+       $(RM) "$(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
+       @$(ECHO) "*** Uninstalling FIPS module"
+       $(RM) "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
+{- if ($disabled{fips}) { output_on(); } else { output_off(); } "" -}
+install_fips:
+       @$(ECHO) "The 'install_fips' target requires the 'enable-fips' option"
+
+uninstall_fips:
+       @$(ECHO) "The 'uninstall_fips' target requires the 'enable-fips' option"
+{- output_on() if !$disabled{fips}; "" -}
+
 
 install_ssldirs:
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/certs"
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/private"
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/misc"
        @set -e; for x in dummy $(MISC_SCRIPTS); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                x1=`echo "$$x" | cut -f1 -d:`; \
                x2=`echo "$$x" | cut -f2 -d:`; \
                fn=`basename $$x1`; \
                $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
-               cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
-               chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
-               mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
-                     $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
+               cp $$x1 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \
+               chmod 755 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \
+               mv -f "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new" \
+                     "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
                if [ "$$x1" != "$$x2" ]; then \
                        ln=`basename "$$x2"`; \
                        : {- output_off() unless windowsdll(); "" -}; \
                        $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
-                       cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
+                       cp "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn" "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \
                        : {- output_on() unless windowsdll();
                             output_off() if windowsdll(); "" -}; \
                        $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
-                       ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
+                       ln -sf $$fn "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \
                        : {- output_on() if windowsdll(); "" -}; \
                fi; \
        done
        @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
-       @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
-       @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
-       @mv -f  $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
+       @cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new"
+       @chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new"
+       @mv -f  "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
        @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
                $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
-               cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
-               chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
+               cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
+               chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
        fi
        @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
-       @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
-       @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
-       @mv -f  $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
+       @cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new"
+       @chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new"
+       @mv -f  "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
        @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
                $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
-               cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
-               chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
+               cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
+               chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
        fi
 
 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}}); "" -}
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)/include/openssl"
+       @ : {- 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}}); "" -}
+       @cp $(SRCDIR)/ms/applink.c "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
+       @chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
+       @ : {- output_on() if $disabled{uplink}; "" -}
        @set -e; for i in $(SRCDIR)/include/openssl/*.h \
                          $(BLDDIR)/include/openssl/*.h; do \
                fn=`basename $$i`; \
                $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
-               cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
-               chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
+               cp $$i "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
+               chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
        done
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)"
        @set -e; for l in $(INSTALL_LIBS); do \
                fn=`basename $$l`; \
                $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
-               cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
-               $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
-               chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
-               mv -f $(DESTDIR)$(libdir)/$$fn.new \
-                     $(DESTDIR)$(libdir)/$$fn; \
+               cp $$l "$(DESTDIR)$(libdir)/$$fn.new"; \
+               $(RANLIB) "$(DESTDIR)$(libdir)/$$fn.new"; \
+               chmod 644 "$(DESTDIR)$(libdir)/$$fn.new"; \
+               mv -f "$(DESTDIR)$(libdir)/$$fn.new" \
+                     "$(DESTDIR)$(libdir)/$$fn"; \
        done
        @ : {- output_off() if $disabled{shared}; "" -}
        @set -e; for s in $(INSTALL_SHLIB_INFO); do \
@@ -677,21 +765,21 @@ install_dev: install_runtime_libs
                fn1=`basename "$$s1"`; \
                fn2=`basename "$$s2"`; \
                fn3=`basename "$$s3"`; \
-               : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
+               : {- output_off(); output_on() unless windowsdll() or sharedaix() or sharedaix_solib(); "" -}; \
                if [ "$$fn2" != "" ]; then \
                        $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
-                       ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
+                       ln -sf $$fn1 "$(DESTDIR)$(libdir)/$$fn2"; \
                fi; \
-               : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
+               : {- output_off() unless windowsdll() or sharedaix() or sharedaix_solib(); output_on() if windowsdll() or sharedaix_solib(); "" -}; \
                if [ "$$fn3" != "" ]; then \
                        $(ECHO) "install $$s3 -> $(DESTDIR)$(libdir)/$$fn3"; \
-                       cp $$s3 $(DESTDIR)$(libdir)/$$fn3.new; \
-                       chmod 755 $(DESTDIR)$(libdir)/$$fn3.new; \
-                       mv -f $(DESTDIR)$(libdir)/$$fn3.new \
-                             $(DESTDIR)$(libdir)/$$fn3; \
+                       cp $$s3 "$(DESTDIR)$(libdir)/$$fn3.new"; \
+                       chmod 755 "$(DESTDIR)$(libdir)/$$fn3.new"; \
+                       mv -f "$(DESTDIR)$(libdir)/$$fn3.new" \
+                             "$(DESTDIR)$(libdir)/$$fn3"; \
                fi; \
-               : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
-               a=$(DESTDIR)$(libdir)/$$fn2; \
+               : {- output_off() if windowsdll() or sharedaix_solib(); output_on() if sharedaix(); "" -}; \
+               a="$(DESTDIR)$(libdir)/$$fn2"; \
                $(ECHO) "install $$s1 -> $$a"; \
                if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
                        mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
@@ -708,35 +796,39 @@ install_dev: install_runtime_libs
                : {- output_off() if sharedaix(); output_on(); "" -}; \
        done
        @ : {- output_on() if $disabled{shared}; "" -}
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
-       @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
-       @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
-       @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
-       @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
-       @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
-       @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
-       @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
-       @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
-       @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(PKGCONFIGDIR)"
+       @for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \
+               fn=`basename $$e`; \
+               $(ECHO) "install $$e -> $(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
+               cp $$e "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
+               chmod 644 "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
+       done
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(CMAKECONFIGDIR)
+       @for e in $(INSTALL_EXPORTERS_CMAKE); do \
+               fn=`basename $$e`; \
+               $(ECHO) "install $$e -> $(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \
+               cp $$e $(DESTDIR)$(CMAKECONFIGDIR)/$$fn; \
+               chmod 644 $(DESTDIR)$(CMAKECONFIGDIR)/$$fn; \
+       done
 
 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}}); "" -}
+       @$(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
+       @ : {- output_on() if $disabled{uplink}; "" -}
        @set -e; for i in $(SRCDIR)/include/openssl/*.h \
                          $(BLDDIR)/include/openssl/*.h; do \
                fn=`basename $$i`; \
                $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
-               $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
+               $(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
        done
-       -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
-       -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
+       -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include/openssl"
+       -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include"
        @set -e; for l in $(INSTALL_LIBS); do \
                fn=`basename $$l`; \
                $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
-               $(RM) $(DESTDIR)$(libdir)/$$fn; \
+               $(RM) "$(DESTDIR)$(libdir)/$$fn"; \
        done
        @ : {- output_off() if $disabled{shared}; "" -}
        @set -e; for s in $(INSTALL_SHLIB_INFO); do \
@@ -748,39 +840,45 @@ uninstall_dev: uninstall_runtime_libs
                fn3=`basename "$$s3"`; \
                : {- output_off() if windowsdll(); "" -}; \
                $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
-               $(RM) $(DESTDIR)$(libdir)/$$fn1; \
+               $(RM) "$(DESTDIR)$(libdir)/$$fn1"; \
                if [ -n "$$fn2" ]; then \
                        $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
-                       $(RM) $(DESTDIR)$(libdir)/$$fn2; \
+                       $(RM) "$(DESTDIR)$(libdir)/$$fn2"; \
                fi; \
                : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
                if [ -n "$$fn3" ]; then \
                        $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn3"; \
-                       $(RM) $(DESTDIR)$(libdir)/$$fn3; \
+                       $(RM) "$(DESTDIR)$(libdir)/$$fn3"; \
                fi; \
                : {- output_on() unless windowsdll(); "" -}; \
        done
        @ : {- output_on() if $disabled{shared}; "" -}
-       $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
-       $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
-       $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
-       -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
-       -$(RMDIR) $(DESTDIR)$(libdir)
+       @for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \
+               fn=`basename "$$e"`; \
+               $(RM) "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
+       done
+       @for e in $(INSTALL_EXPORTERS_CMAKE); do \
+               fn=`basename "$$e"`; \
+               $(RM) "$(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \
+       done
+       -$(RMDIR) "$(DESTDIR)$(PKGCONFIGDIR)"
+       -$(RMDIR) "$(DESTDIR)$(CMAKECONFIGDIR)"
+       -$(RMDIR) "$(DESTDIR)$(libdir)"
 
 _install_modules_deps: install_runtime_libs build_modules
 
 install_engines: _install_modules_deps
        @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(ENGINESDIR)/"
        @$(ECHO) "*** Installing engines"
        @set -e; for e in dummy $(INSTALL_ENGINES); do \
                if [ "$$e" = "dummy" ]; then continue; fi; \
                fn=`basename $$e`; \
                $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
-               cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
-               chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
-               mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
-                     $(DESTDIR)$(ENGINESDIR)/$$fn; \
+               cp $$e "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \
+               chmod 755 "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \
+               mv -f "$(DESTDIR)$(ENGINESDIR)/$$fn.new" \
+                     "$(DESTDIR)$(ENGINESDIR)/$$fn"; \
        done
 
 uninstall_engines:
@@ -789,22 +887,22 @@ uninstall_engines:
                if [ "$$e" = "dummy" ]; then continue; fi; \
                fn=`basename $$e`; \
                $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
-               $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
+               $(RM) "$(DESTDIR)$(ENGINESDIR)/$$fn"; \
        done
-       -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
+       -$(RMDIR) "$(DESTDIR)$(ENGINESDIR)"
 
 install_modules: _install_modules_deps
        @[ -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)$(MODULESDIR)/"
        @$(ECHO) "*** Installing modules"
        @set -e; for e in dummy $(INSTALL_MODULES); do \
                if [ "$$e" = "dummy" ]; then continue; fi; \
                fn=`basename $$e`; \
                $(ECHO) "install $$e -> $(DESTDIR)$(MODULESDIR)/$$fn"; \
-               cp $$e $(DESTDIR)$(MODULESDIR)/$$fn.new; \
-               chmod 755 $(DESTDIR)$(MODULESDIR)/$$fn.new; \
-               mv -f $(DESTDIR)$(MODULESDIR)/$$fn.new \
-                     $(DESTDIR)$(MODULESDIR)/$$fn; \
+               cp $$e "$(DESTDIR)$(MODULESDIR)/$$fn.new"; \
+               chmod 755 "$(DESTDIR)$(MODULESDIR)/$$fn.new"; \
+               mv -f "$(DESTDIR)$(MODULESDIR)/$$fn.new" \
+                     "$(DESTDIR)$(MODULESDIR)/$$fn"; \
        done
 
 uninstall_modules:
@@ -813,59 +911,59 @@ uninstall_modules:
                if [ "$$e" = "dummy" ]; then continue; fi; \
                fn=`basename $$e`; \
                $(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$$fn"; \
-               $(RM) $(DESTDIR)$(MODULESDIR)/$$fn; \
+               $(RM) "$(DESTDIR)$(MODULESDIR)/$$fn"; \
        done
-       -$(RMDIR) $(DESTDIR)$(MODULESDIR)
+       -$(RMDIR) "$(DESTDIR)$(MODULESDIR)"
 
 install_runtime: install_programs
 
 install_runtime_libs: build_libs
        @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
        @ : {- output_off() if windowsdll(); "" -}
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)"
        @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(bindir)/"
        @ : {- output_on() unless windowsdll(); "" -}
        @$(ECHO) "*** Installing runtime libraries"
        @set -e; for s in dummy $(INSTALL_SHLIBS); do \
                if [ "$$s" = "dummy" ]; then continue; fi; \
                fn=`basename $$s`; \
                : {- output_off() unless windowsdll(); "" -}; \
-               $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
-                     $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "install $$s -> $(DESTDIR)$(bindir)/$$fn"; \
+               cp $$s "$(DESTDIR)$(bindir)/$$fn.new"; \
+               chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
+               mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
+                     "$(DESTDIR)$(bindir)/$$fn"; \
                : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
                $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
-               cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
-               chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
-               mv -f $(DESTDIR)$(libdir)/$$fn.new \
-                     $(DESTDIR)$(libdir)/$$fn; \
+               cp $$s "$(DESTDIR)$(libdir)/$$fn.new"; \
+               chmod 755 "$(DESTDIR)$(libdir)/$$fn.new"; \
+               mv -f "$(DESTDIR)$(libdir)/$$fn.new" \
+                     "$(DESTDIR)$(libdir)/$$fn"; \
                : {- output_on() if windowsdll(); "" -}; \
        done
 
 install_programs: install_runtime_libs build_programs
        @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(bindir)"
        @$(ECHO) "*** Installing runtime programs"
        @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
-               $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
-                     $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \
+               cp $$x "$(DESTDIR)$(bindir)/$$fn.new"; \
+               chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
+               mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
+                     "$(DESTDIR)$(bindir)/$$fn"; \
        done
        @set -e; for x in dummy $(BIN_SCRIPTS); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
-               $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
-               mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
-                     $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \
+               cp $$x "$(DESTDIR)$(bindir)/$$fn.new"; \
+               chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
+               mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
+                     "$(DESTDIR)$(bindir)/$$fn"; \
        done
 
 uninstall_runtime: uninstall_programs uninstall_runtime_libs
@@ -876,17 +974,17 @@ uninstall_programs:
        do  \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
-               $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
+               $(RM) "$(DESTDIR)$(bindir)/$$fn"; \
        done;
        @set -e; for x in dummy $(BIN_SCRIPTS); \
        do  \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
-               $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
+               $(RM) "$(DESTDIR)$(bindir)/$$fn"; \
        done
-       -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
+       -$(RMDIR) "$(DESTDIR)$(bindir)"
 
 uninstall_runtime_libs:
        @$(ECHO) "*** Uninstalling runtime libraries"
@@ -894,155 +992,182 @@ uninstall_runtime_libs:
        @set -e; for s in dummy $(INSTALL_SHLIBS); do \
                if [ "$$s" = "dummy" ]; then continue; fi; \
                fn=`basename $$s`; \
-               $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
-               $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
+               $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
+               $(RM) "$(DESTDIR)$(bindir)/$$fn"; \
        done
        @ : {- output_on() unless windowsdll(); "" -}
 
 
 install_man_docs: build_man_docs
        @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man1
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man3
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man5
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man7
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man1"
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man3"
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man5"
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man7"
        @$(ECHO) "*** Installing manpages"
        @set -e; for x in dummy $(MANDOCS1); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
-               cp $$x $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
-               chmod 644 $(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; \
                fn=`basename $$x`; \
                $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
-               cp $$x $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
-               chmod 644 $(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; \
                fn=`basename $$x`; \
                $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
-               cp $$x $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
-               chmod 644 $(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; \
                fn=`basename $$x`; \
                $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
-               cp $$x $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
-               chmod 644 $(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); \
+               $(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); \
+               $(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); \
+               $(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); \
+               $(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
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man5
-       @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man7
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man1"
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man3"
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man5"
+       @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man7"
        @$(ECHO) "*** Installing HTML manpages"
        @set -e; for x in dummy $(HTMLDOCS1); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
-               cp $$x $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
-               chmod 644 $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
+               cp $$x "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
+               chmod 644 "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
        done
        @set -e; for x in dummy $(HTMLDOCS3); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
-               cp $$x $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
-               chmod 644 $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
+               cp $$x "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
+               chmod 644 "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
        done
        @set -e; for x in dummy $(HTMLDOCS5); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
-               cp $$x $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
-               chmod 644 $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
+               cp $$x "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
+               chmod 644 "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
        done
        @set -e; for x in dummy $(HTMLDOCS7); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
-               cp $$x $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
-               chmod 644 $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
+               cp $$x "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
+               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; \
                fn=`basename $$x`; \
                $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
-               $(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
+               $(RM) "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
        done
        @set -e; for x in dummy $(HTMLDOCS3); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
-               $(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
+               $(RM) "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
        done
        @set -e; for x in dummy $(HTMLDOCS5); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
-               $(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
+               $(RM) "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
        done
        @set -e; for x in dummy $(HTMLDOCS7); do \
                if [ "$$x" = "dummy" ]; then continue; fi; \
                fn=`basename $$x`; \
                $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
-               $(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
+               $(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) #########
+##@ Code maintenance
 
 # It's important that generate_buildinfo comes after ordinals, as ordinals
 # is sensitive to build.info changes.
-update: generate errors ordinals generate_buildinfo
+update: generate errors ordinals generate_buildinfo ## Update errors, ordinals and build info
 
+.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
-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
+.PHONY: doc-nits md-nits
+doc-nits: build_generated_pods ## Evaluate OpenSSL documentation
+       $(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
@@ -1050,15 +1175,23 @@ cmd-nits: build_generated apps/openssl build_generated_pods
 # Another option is at https://snapcraft.io/install/mdl/debian
 # Finally, there's a Node.js version, which we haven't tried, that
 # can be found at https://github.com/DavidAnson/markdownlint
-md-nits:
-       mdl -s util/markdownlint.rb .
+md-nits: ## Evaluate markdown files via "mdl"
+       mdl -s $(SRCDIR)/util/markdownlint.rb .
 
 # Test coverage is a good idea for the future
 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
 #      ...
 
-lint:
-       lint -DLINT $(INCLUDES) $(SRCS)
+.PHONY: lint
+lint: ## Evaluate C code via "splint"
+       @( cd $(SRCDIR); \
+           echo splint -DLINT -posixlib -preproc -D__gnuc_va_list=void \
+          -I. -Iinclude -Iapps/include $(CRYPTOHEADERS) $(SSLHEADERS) $(SRCS) )
+
+.PHONY: check-format
+check-format: ## Evaluate C code according to OpenSSL coding standards
+       ( cd $(SRCDIR); $(PERL) util/check-format.pl \
+                       $(SRCS) \$(CRYPTOHEADERS) $(SSLHEADERS) )
 
 generate_apps:
        ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
@@ -1084,7 +1217,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 \
@@ -1113,6 +1246,57 @@ generate_doc_buildinfo:
                 mv $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info; \
           fi )
 
+generate_fips_sources: providers/fips.module.sources.new
+providers/fips.module.sources.new: configdata.pm
+       rm -rf sources-tmp
+       mkdir sources-tmp
+       ( \
+         srcdir=`cd $(SRCDIR); pwd`; \
+         cd sources-tmp \
+         && $$srcdir/Configure --banner=Configured enable-fips -O0 \
+         && ./configdata.pm --query 'get_sources("providers/fips")' > sources1 \
+         && "$(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 \
+       )
+       ( \
+         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 \
+                  crypto/*cpuid.pl crypto/*cpuid.S \
+                  crypto/*cap.c; do \
+           echo "$$x"; \
+         done \
+       ) | grep -v sm2p256 | sort | uniq > providers/fips.module.sources.new
+       rm -rf sources-tmp
+
 # Set to -force to force a rebuild
 ERROR_REBUILD=
 errors:
@@ -1137,6 +1321,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
@@ -1147,7 +1332,8 @@ errors:
            include/internal/asn1.h
            include/internal/sslconf.h );
    my @cryptoskipheaders = ( @sslheaders_tmpl,
-       qw( include/openssl/conf_api.h
+       qw( include/openssl/asn1_mac.h
+           include/openssl/conf_api.h
            include/openssl/ebcdic.h
            include/openssl/opensslconf.h
            include/openssl/symhacks.h ) );
@@ -1182,31 +1368,76 @@ 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)) -}
+
+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)
+
+.PHONY: ordinals
 ordinals: build_generated
-       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
+       $(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 \
+       $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
                 --ordinals $(SRCDIR)/util/libssl.num \
                 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
                 $(SSLHEADERS)
 
 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 .
+       -( cd $(SRCDIR); util/ctags.sh )
        -etags `find . -name '*.[ch]' -o -name '*.pm'`
 
+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 )
+       ( sources=`pwd`/providers/fips.module.sources.new; \
+         cd $(SRCDIR) \
+         && cat $$sources \
+                | xargs ./util/fips-checksums.sh ) \
+                > providers/fips-sources.checksums.new \
+       && sha256sum providers/fips-sources.checksums.new \
+            | sed -e 's|\.new||' > providers/fips.checksum.new
+
+fips-checksums: providers/fips.checksum.new
+
+$(SRCDIR)/providers/fips.checksum: providers/fips.checksum.new
+       cp -p providers/fips.module.sources.new $(SRCDIR)/providers/fips.module.sources
+       cp -p providers/fips-sources.checksums.new $(SRCDIR)/providers/fips-sources.checksums
+       cp -p providers/fips.checksum.new $(SRCDIR)/providers/fips.checksum
+
+update-fips-checksums: $(SRCDIR)/providers/fips.checksum
+
+diff-fips-checksums: fips-checksums
+       diff -u $(SRCDIR)/providers/fips.module.sources providers/fips.module.sources.new
+       diff -u $(SRCDIR)/providers/fips-sources.checksums providers/fips-sources.checksums.new
+       diff -u $(SRCDIR)/providers/fips.checksum providers/fips.checksum.new
+
 # Release targets (note: only available on Unix) #####################
 
 tar:
@@ -1214,16 +1445,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"; \
@@ -1233,61 +1463,22 @@ 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:
-       @ ( echo 'prefix=$(INSTALLTOP)'; \
-           echo 'exec_prefix=$${prefix}'; \
-           if [ -n "$(LIBDIR)" ]; then \
-               echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
-           else \
-               echo 'libdir=$(libdir)'; \
-           fi; \
-           echo 'includedir=$${prefix}/include'; \
-           echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
-           echo ''; \
-           echo 'Name: OpenSSL-libcrypto'; \
-           echo 'Description: OpenSSL cryptography library'; \
-           echo 'Version: '$(VERSION); \
-           echo 'Libs: -L$${libdir} -lcrypto'; \
-           echo 'Libs.private: $(LIB_EX_LIBS)'; \
-           echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
-
-libssl.pc:
-       @ ( echo 'prefix=$(INSTALLTOP)'; \
-           echo 'exec_prefix=$${prefix}'; \
-           if [ -n "$(LIBDIR)" ]; then \
-               echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
-           else \
-               echo 'libdir=$(libdir)'; \
-           fi; \
-           echo 'includedir=$${prefix}/include'; \
-           echo ''; \
-           echo 'Name: OpenSSL-libssl'; \
-           echo 'Description: Secure Sockets Layer and cryptography libraries'; \
-           echo 'Version: '$(VERSION); \
-           echo 'Requires.private: libcrypto'; \
-           echo 'Libs: -L$${libdir} -lssl'; \
-           echo 'Cflags: -I$${includedir}' ) > libssl.pc
-
-openssl.pc:
-       @ ( echo 'prefix=$(INSTALLTOP)'; \
-           echo 'exec_prefix=$${prefix}'; \
-           if [ -n "$(LIBDIR)" ]; then \
-               echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
-           else \
-               echo 'libdir=$(libdir)'; \
-           fi; \
-           echo 'includedir=$${prefix}/include'; \
-           echo ''; \
-           echo 'Name: OpenSSL'; \
-           echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
-           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: $?"
@@ -1306,6 +1497,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 {
@@ -1314,13 +1516,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
@@ -1334,7 +1537,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$/) {
           #
@@ -1364,13 +1568,14 @@ 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})) {
+      } elsif (platform->isasm($args{src})
+               || platform->iscppasm($args{src})) {
           #
           # Assembler generator
           #
@@ -1411,38 +1616,54 @@ 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 = ();
+          my %perlmoduleincs = ();
+          my %perlmoduledeps = ();
+          foreach my $x (('configdata.pm', @{$args{deps}})) {
+              # Compute (i)nclusion directory, (m)odule name and (d)ependency
+              my $i, $m, $d;
+              if ($x =~ /\|/) {
+                  $i = $`;
+                  $d = $';
+
+                  # Massage the module part to become a real perl module spec
+                  $m = $d;
+                  $m =~ s|\.pm$||;
+                  # Directory specs are :: in perl package names
+                  $m =~ s|/|::|g;
+
+                  # Full file name of the dependency
+                  $d = catfile($i, $d) if $i;
+              } elsif ($x =~ /\.pm$/) {
+                  $i = dirname($x);
+                  $m = basename($x, '.pm');
+                  $d = $x;
+              } else {
+                  # All other dependencies are simply collected
+                  $d = $x;
+              }
+              push @perlmodules, '"-M'.$m.'"' if $m;
+              $perlmoduledeps{$d} = 1;
+              $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i;
+          }
+
+          # Because of the special treatment of dependencies, we need to
+          # recompute $deps completely
+          my $deps
+              = join(" ", compute_platform_depends(@{$args{generator_deps}},
+                                                   sort keys %perlmoduledeps));
+          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
@@ -1574,6 +1795,8 @@ EOF
       # libraries for DLLs are a thing.  On platforms that have this mechanism,
       # $import has the name of this import library.  On platforms that don't
       # have this mechanism, $import will be |undef|.
+      # It's also used on AIX in solib mode, which creates import libraries
+      # for the shared libraries.
       my $import = platform->sharedlib_import($args{lib});
       # $simple is for platforms where full shared library names include the
       # shared library version, and there's a simpler name that doesn't include
@@ -1634,9 +1857,18 @@ EOF
           }
       }
       if (defined $import) {
+          if (sharedaix_solib()) {
+              $recipe .= <<"EOF";
+$import: $full $defs[0]
+       rm -f $import && \\
+       echo \\#!$full > $import && \\
+        cat $defs[0] >>$import
+EOF
+          } else {
       $recipe .= <<"EOF";
 $import: $full
 EOF
+          }
       }
       $recipe .= <<"EOF";
 $full: $fulldeps
@@ -1695,7 +1927,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,
@@ -1780,7 +2012,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
@@ -1789,11 +2022,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
@@ -1808,7 +2038,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}});
                   }