Home | History | Annotate | Line # | Download | only in Configurations
      1 ##
      2 ## Makefile for OpenSSL
      3 ##
      4 ## {- join("\n## ", @autowarntext) -}
      5 {-
      6      use Time::Piece;
      7 
      8      use OpenSSL::Util;
      9 
     10      our $makedep_scheme = $config{makedep_scheme};
     11      our $makedepcmd = platform->makedepcmd();
     12 
     13      sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
     14 
     15      # Shared AIX support is special. We put libcrypto[64].so.ver into
     16      # libcrypto.a and use libcrypto_a.a as static one, unless using
     17      # shared_target style aix-solib.  In that mode, create
     18      # libcrypto.so as a link-import library that inserts runtime
     19      # dependencies on libcrypto.so.ver, and the static library is
     20      # named libcrypto.a.
     21      sub sharedaix  { !$disabled{shared} && $target{shared_target} =~ /^aix(?!-solib$)/ }
     22      sub sharedaix_solib  { !$disabled{shared} && $target{shared_target} =~ /^aix-solib$/ }
     23 
     24      our $sover_dirname = platform->shlib_version_as_filename();
     25 
     26      # This makes sure things get built in the order they need
     27      # to. You're welcome.
     28      sub dependmagic {
     29          my $target = shift;
     30          my $help = shift;
     31 
     32          return "$target: build_generated ## $help\n\t\"\$(MAKE)\" depend && \"\$(MAKE)\" _$target\n_$target";
     33      }
     34 
     35      our $COLUMNS = $ENV{COLUMNS};
     36      if ($COLUMNS =~ /^\d+$/) {
     37          $COLUMNS = int($COLUMNS) - 2; # 2 to leave space for ending ' \'
     38      } else {
     39          $COLUMNS = 76;
     40      }
     41 
     42      sub fill_lines {
     43          my $item_sep = shift;                  # string
     44          my $line_length = shift;               # number of chars
     45 
     46          my @result = ();
     47          my $resultpos = 0;
     48 
     49          foreach (@_) {
     50              my $fill_line = $result[$resultpos] // '';
     51              my $newline =
     52                  ($fill_line eq '' ? '' : $fill_line . $item_sep) . $_;
     53 
     54              if (length($newline) > $line_length) {
     55                  # If this is a single item and the intended result line
     56                  # is empty, we put it there anyway
     57                  if ($fill_line eq '') {
     58                      $result[$resultpos++] = $newline;
     59                  } else {
     60                      $result[++$resultpos] = $_;
     61                  }
     62              } else {
     63                  $result[$resultpos] = $newline;
     64              }
     65          }
     66          return @result;
     67      }
     68      '';
     69 -}
     70 PLATFORM={- $config{target} -}
     71 OPTIONS={- $config{options} -}
     72 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
     73 SRCDIR={- $config{sourcedir} -}
     74 BLDDIR={- $config{builddir} -}
     75 FIPSKEY={- $config{FIPSKEY} -}
     76 
     77 VERSION={- "$config{full_version}" -}
     78 VERSION_NUMBER={- "$config{version}" -}
     79 RELEASE_DATE={- my $t = localtime;
     80 		if ($config{"release_date"}) {
     81 			# Provide the user with a more meaningful error message
     82 			# than the default internal parsing error from
     83 			# `Time::Piece->strptime(..)`.
     84 			eval { $t = Time::Piece->strptime($config{"release_date"}, "%d %b %Y"); } ||
     85 				die "Parsing \$config{release_date} ('$config{release_date}') failed: $@";
     86 		}
     87 		$t->strftime("%Y-%m-%d") -}
     88 MAJOR={- $config{major} -}
     89 MINOR={- $config{minor} -}
     90 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
     91 SHLIB_TARGET={- $target{shared_target} -}
     92 
     93 LIBS={- join(" \\\n" . ' ' x 5,
     94              fill_lines(" ", $COLUMNS - 5,
     95                         map { platform->staticlib($_) // () }
     96                         @{$unified_info{libraries}})) -}
     97 SHLIBS={- join(" \\\n" . ' ' x 7,
     98                fill_lines(" ", $COLUMNS - 7,
     99                           map { platform->sharedlib($_) // () }
    100                           @{$unified_info{libraries}})) -}
    101 SHLIB_INFO={- join(" \\\n" . ' ' x 11,
    102                    fill_lines(" ", $COLUMNS - 11,
    103                           map { my $x = platform->sharedlib($_);
    104                                 my $y = platform->sharedlib_simple($_) // '';
    105                                 my $z = platform->sharedlib_import($_) // '';
    106                                 $x ? "\"$x;$y;$z\"" : () }
    107                           @{$unified_info{libraries}})) -}
    108 MODULES={- join(" \\\n" . ' ' x 8,
    109                 fill_lines(" ", $COLUMNS - 8,
    110                            map { platform->dso($_) }
    111                            # Drop all modules that are dependencies, they will
    112                            # be processed through their dependents
    113                            grep { my $x = $_;
    114                                   !grep { grep { $_ eq $x } @$_ }
    115                                         values %{$unified_info{depends}} }
    116                            @{$unified_info{modules}})) -}
    117 FIPSMODULE={- # We do some extra checking here, as there should be only one
    118               use File::Basename;
    119               our @fipsmodules =
    120                   grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
    121                          && $unified_info{attributes}->{modules}->{$_}->{fips} }
    122                   @{$unified_info{modules}};
    123               die "More that one FIPS module" if scalar @fipsmodules > 1;
    124               join(" ", map { platform->dso($_) } @fipsmodules) -}
    125 FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1;
    126                   join(" ", map { basename(platform->dso($_)) } @fipsmodules) -}
    127 
    128 PROGRAMS={- join(" \\\n" . ' ' x 9,
    129                  fill_lines(" ", $COLUMNS - 9,
    130                             map { platform->bin($_) }
    131                             @{$unified_info{programs}})) -}
    132 SCRIPTS={- join(" \\\n" . ' ' x 8,
    133                 fill_lines(" ", $COLUMNS - 8, @{$unified_info{scripts}})) -}
    134 {- output_off() if $disabled{makedepend}; "" -}
    135 DEPS={- join(" \\\n" . ' ' x 5,
    136              fill_lines(" ", $COLUMNS - 5,
    137                         map { platform->isobj($_) ? platform->dep($_) : () }
    138                         grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
    139                         keys %{$unified_info{sources}})); -}
    140 {- output_on() if $disabled{makedepend}; "" -}
    141 GENERATED_MANDATORY={- join(" \\\n" . ' ' x 20,
    142                             fill_lines(" ", $COLUMNS - 20,
    143                                        @{$unified_info{depends}->{""}})) -}
    144 GENERATED_PODS={- # common0.tmpl provides @generated
    145                   join(" \\\n" . ' ' x 15,
    146                        fill_lines(" ", $COLUMNS - 15,
    147                                   map { my $x = $_;
    148                                         (
    149                                           grep {
    150                                                  $unified_info{attributes}->{depends}
    151                                                  ->{$x}->{$_}->{pod} // 0
    152                                                }
    153                                               keys %{$unified_info{attributes}->{depends}->{$x}}
    154                                         ) ? $x : ();
    155                                       }
    156                                       @generated)) -}
    157 GENERATED={- # common0.tmpl provides @generated
    158              join(" \\\n" . ' ' x 5,
    159                   fill_lines(" ", $COLUMNS - 5,
    160                              map { platform->convertext($_) } @generated )) -}
    161 
    162 INSTALL_LIBS={-
    163         join(" \\\n" . ' ' x 13,
    164              fill_lines(" ", $COLUMNS - 13,
    165                         map { platform->staticlib($_) // () }
    166                         grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
    167                         @{$unified_info{libraries}}))
    168 -}
    169 INSTALL_SHLIBS={-
    170         join(" \\\n" . ' ' x 15,
    171              fill_lines(" ", $COLUMNS - 15,
    172                         map { platform->sharedlib($_) // () }
    173                         grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
    174                         @{$unified_info{libraries}}))
    175 -}
    176 INSTALL_SHLIB_INFO={-
    177         join(" \\\n" . ' ' x 19,
    178              fill_lines(" ", $COLUMNS - 19,
    179                         map { my $x = platform->sharedlib($_);
    180                               my $y = platform->sharedlib_simple($_) // '';
    181                               my $z = platform->sharedlib_import($_) // '';
    182                               $x ? "\"$x;$y;$z\"" : () }
    183                         grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
    184                         @{$unified_info{libraries}}))
    185 -}
    186 INSTALL_ENGINES={-
    187         join(" \\\n" . ' ' x 16,
    188              fill_lines(" ", $COLUMNS - 16,
    189                         map { platform->dso($_) }
    190                         grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
    191                                && $unified_info{attributes}->{modules}->{$_}->{engine} }
    192                         @{$unified_info{modules}}))
    193 -}
    194 INSTALL_MODULES={-
    195         join(" \\\n" . ' ' x 16,
    196              fill_lines(" ", $COLUMNS - 16,
    197                         map { platform->dso($_) }
    198                         grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
    199                                && !$unified_info{attributes}->{modules}->{$_}->{engine}
    200                                && !$unified_info{attributes}->{modules}->{$_}->{fips} }
    201                         @{$unified_info{modules}}))
    202 -}
    203 INSTALL_FIPSMODULE={-
    204         join(" \\\n" . ' ' x 16,
    205              fill_lines(" ", $COLUMNS - 16,
    206                         map { platform->dso($_) }
    207                         grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
    208                                && $unified_info{attributes}->{modules}->{$_}->{fips} }
    209                         @{$unified_info{modules}}))
    210 -}
    211 INSTALL_FIPSMODULECONF=providers/fipsmodule.cnf
    212 INSTALL_PROGRAMS={-
    213         join(" \\\n" . ' ' x 16,
    214              fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) }
    215                         grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
    216                         @{$unified_info{programs}}))
    217 -}
    218 INSTALL_EXPORTERS_PKGCONFIG={-
    219         join(" \\\n" . ' ' x 28,
    220              fill_lines(" ", $COLUMNS - 28,
    221                         grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'pkg-config'}
    222                         sort keys %{$unified_info{generate}}))
    223 -}
    224 INSTALL_EXPORTERS_CMAKE={-
    225         join(" \\\n" . ' ' x 24,
    226              fill_lines(" ", $COLUMNS - 24,
    227                         grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'cmake'}
    228                         sort keys %{$unified_info{generate}}))
    229 -}
    230 BIN_SCRIPTS={-
    231         join(" \\\n" . ' ' x 12,
    232              fill_lines(" ", $COLUMNS - 12,
    233                         map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname};
    234                               $x ? "$_:$x" : $_ }
    235                         grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
    236                                && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
    237                         @{$unified_info{scripts}}))
    238 -}
    239 MISC_SCRIPTS={-
    240         join(" \\\n" . ' ' x 13,
    241              fill_lines(" ", $COLUMNS - 13,
    242                         map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname};
    243                               $x ? "$_:$x" : $_ }
    244                         grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
    245                                && $unified_info{attributes}->{scripts}->{$_}->{misc} }
    246                         @{$unified_info{scripts}}))
    247 -}
    248 IMAGEDOCS1={-
    249         join(" \\\n" . ' ' x 10,
    250              fill_lines(" ", $COLUMNS - 10,
    251                         @{$unified_info{imagedocs}->{man1}})) -}
    252 IMAGEDOCS3={-
    253         join(" \\\n" . ' ' x 10,
    254              fill_lines(" ", $COLUMNS - 10,
    255                         @{$unified_info{imagedocs}->{man3}})) -}
    256 IMAGEDOCS5={-
    257         join(" \\\n" . ' ' x 10,
    258              fill_lines(" ", $COLUMNS - 10,
    259                         @{$unified_info{imagedocs}->{man5}})) -}
    260 IMAGEDOCS7={-
    261         join(" \\\n" . ' ' x 10,
    262              fill_lines(" ", $COLUMNS - 10,
    263                         @{$unified_info{imagedocs}->{man7}})) -}
    264 HTMLDOCS1={-
    265         join(" \\\n" . ' ' x 10,
    266              fill_lines(" ", $COLUMNS - 10,
    267                         @{$unified_info{htmldocs}->{man1}})) -}
    268 HTMLDOCS3={-
    269         join(" \\\n" . ' ' x 10,
    270              fill_lines(" ", $COLUMNS - 10,
    271                         @{$unified_info{htmldocs}->{man3}})) -}
    272 HTMLDOCS5={-
    273         join(" \\\n" . ' ' x 10,
    274              fill_lines(" ", $COLUMNS - 10,
    275                         @{$unified_info{htmldocs}->{man5}})) -}
    276 HTMLDOCS7={-
    277         join(" \\\n" . ' ' x 10,
    278              fill_lines(" ", $COLUMNS - 10,
    279                         @{$unified_info{htmldocs}->{man7}})) -}
    280 MANDOCS1={-
    281         join(" \\\n" . ' ' x 9,
    282              fill_lines(" ", $COLUMNS - 9,
    283                         @{$unified_info{mandocs}->{man1}})) -}
    284 MANDOCS3={-
    285         join(" \\\n" . ' ' x 9,
    286              fill_lines(" ", $COLUMNS - 9,
    287                         @{$unified_info{mandocs}->{man3}})) -}
    288 MANDOCS5={-
    289         join(" \\\n" . ' ' x 9,
    290              fill_lines(" ", $COLUMNS - 9,
    291                         @{$unified_info{mandocs}->{man5}})) -}
    292 MANDOCS7={-
    293         join(" \\\n" . ' ' x 9,
    294              fill_lines(" ", $COLUMNS - 9,
    295                         @{$unified_info{mandocs}->{man7}})) -}
    296 
    297 APPS_OPENSSL="{- use File::Spec::Functions;
    298                  catfile("apps","openssl") -}"
    299 
    300 # DESTDIR is for package builders so that they can configure for, say,
    301 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
    302 # Normally it is left empty.
    303 DESTDIR=
    304 
    305 # Do not edit these manually. Use Configure with --prefix or --openssldir
    306 # to change this!  Short explanation in the top comment in Configure
    307 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
    308 	      #
    309 	      our $prefix = $config{prefix} || "/usr/local";
    310               $prefix -}
    311 OPENSSLDIR={- #
    312 	      # The logic here is that if no --openssldir was given,
    313 	      # OPENSSLDIR will get the value from $prefix plus "/ssl".
    314 	      # If --openssldir was given and the value is an absolute
    315 	      # path, OPENSSLDIR will get its value without change.
    316 	      # If the value from --openssldir is a relative path,
    317 	      # OPENSSLDIR will get $prefix with the --openssldir
    318 	      # value appended as a subdirectory.
    319 	      #
    320               use File::Spec::Functions;
    321               our $openssldir =
    322                   $config{openssldir} ?
    323                       (file_name_is_absolute($config{openssldir}) ?
    324                            $config{openssldir}
    325                            : catdir($prefix, $config{openssldir}))
    326                       : catdir($prefix, "ssl");
    327               $openssldir -}
    328 LIBDIR={- our $libdir = $config{libdir};
    329           unless ($libdir) {
    330               $libdir = "lib$target{multilib}";
    331           }
    332           file_name_is_absolute($libdir) ? "" : $libdir -}
    333 # $(libdir) is chosen to be compatible with the GNU coding standards
    334 libdir={- file_name_is_absolute($libdir)
    335           ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
    336 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
    337 MODULESDIR=$(libdir)/ossl-modules
    338 
    339 # Convenience variable for those who want to set the rpath in shared
    340 # libraries and applications
    341 LIBRPATH=$(libdir)
    342 
    343 BINDIR={- our $bindir = $config{bindir};
    344           unless ($bindir) {
    345               $bindir = "bin$target{multibin}";
    346           }
    347           file_name_is_absolute($bindir) ? "" : $bindir -}
    348 bindir={- file_name_is_absolute($bindir)
    349           ? $bindir : '$(INSTALLTOP)/$(BINDIR)' -}
    350 
    351 PKGCONFIGDIR=$(libdir)/pkgconfig
    352 CMAKECONFIGDIR=$(libdir)/cmake/OpenSSL
    353 
    354 MANDIR=$(INSTALLTOP)/share/man
    355 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
    356 HTMLDIR=$(DOCDIR)/html
    357 
    358 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
    359 # appended after the manpage file section number.  "ssl" is popular,
    360 # resulting in files such as config.5ssl rather than config.5.
    361 MANSUFFIX=ossl
    362 HTMLSUFFIX=html
    363 
    364 # For "optional" echo messages, to get "real" silence
    365 ECHO = echo
    366 
    367 ##### User defined commands and flags ################################
    368 
    369 # We let the C compiler driver to take care of .s files. This is done in
    370 # order to be excused from maintaining a separate set of architecture
    371 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
    372 # gcc, then the driver will automatically translate it to -xarch=v8plus
    373 # and pass it down to assembler.  In any case, we do not define AS or
    374 # ASFLAGS for this reason.
    375 
    376 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
    377 CC=$(CROSS_COMPILE){- $config{CC} -}
    378 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
    379 CPPFLAGS={- our $cppflags1 = join(" ",
    380                                   (map { "-D".$_} @{$config{CPPDEFINES}}),
    381                                   (map { "-I".$_} @{$config{CPPINCLUDES}}),
    382                                   @{$config{CPPFLAGS}}) -}
    383 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
    384 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
    385 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
    386 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
    387 OBJCOPY={- $config{OBJCOPY} -}
    388 
    389 MAKEDEPEND={- $config{makedepcmd} -}
    390 
    391 PERL={- $config{PERL} -}
    392 
    393 AR=$(CROSS_COMPILE){- $config{AR} -}
    394 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
    395 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
    396 RC= $(CROSS_COMPILE){- $config{RC} -}
    397 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
    398 
    399 RM= rm -f
    400 RMDIR= rmdir
    401 TAR= {- $target{TAR} || "tar" -}
    402 TARFLAGS= {- $target{TARFLAGS} -}
    403 
    404 BASENAME=       openssl
    405 NAME=           $(BASENAME)-$(VERSION)
    406 # Relative to $(SRCDIR)
    407 TARFILE=        ../$(NAME).tar
    408 
    409 ##### Project flags ##################################################
    410 
    411 # Variables starting with CNF_ are common variables for all product types
    412 
    413 CNF_CPPFLAGS={- our $cppflags2 =
    414                     join(' ', $target{cppflags} || (),
    415                               (map { "-D".$_} @{$target{defines}},
    416                                               @{$config{defines}}),
    417                               (map { "-I".$_} @{$target{includes}},
    418                                               @{$config{includes}}),
    419                               @{$config{cppflags}}) -}
    420 CNF_CFLAGS={- join(' ', $target{cflags} || (),
    421                         @{$config{cflags}}) -}
    422 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
    423                           @{$config{cxxflags}}) -}
    424 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
    425                          @{$config{lflags}}) -}
    426 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
    427                          @{$config{ex_libs}}) -}
    428 
    429 # Variables starting with LIB_ are used to build library object files
    430 # and shared libraries.
    431 # Variables starting with DSO_ are used to build DSOs and their object files.
    432 # Variables starting with BIN_ are used to build programs and their object
    433 # files.
    434 
    435 LIB_CPPFLAGS={- our $lib_cppflags =
    436                 join(' ', $target{lib_cppflags} || (),
    437                           $target{shared_cppflag} || (),
    438                           (map { '-D'.$_ }
    439                                @{$target{lib_defines} || ()},
    440                                @{$target{shared_defines} || ()},
    441                                @{$config{lib_defines} || ()},
    442                                @{$config{shared_defines} || ()}),
    443                           (map { '-I'.quotify1($_) }
    444                                @{$target{lib_includes}},
    445                                @{$target{shared_includes}},
    446                                @{$config{lib_includes}},
    447                                @{$config{shared_includes}}),
    448                           @{$config{lib_cppflags}},
    449                           @{$config{shared_cppflag}});
    450                 join(' ', $lib_cppflags,
    451                           (map { '-D'.$_ }
    452                                'OPENSSLDIR="\"$(OPENSSLDIR)\""',
    453                                'ENGINESDIR="\"$(ENGINESDIR)\""',
    454                                'MODULESDIR="\"$(MODULESDIR)\""'),
    455                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
    456 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
    457                         $target{shared_cflag} || (),
    458                         @{$config{lib_cflags}},
    459                         @{$config{shared_cflag}},
    460                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
    461 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
    462                           $target{shared_cxxflag} || (),
    463                           @{$config{lib_cxxflags}},
    464                           @{$config{shared_cxxflag}},
    465                           '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
    466 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
    467                          $config{shared_ldflag} || (),
    468                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
    469 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
    470 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
    471                           $target{module_cppflags} || (),
    472                           (map { '-D'.$_ }
    473                                @{$target{dso_defines}},
    474                                @{$target{module_defines}},
    475                                @{$config{dso_defines} || ()},
    476                                @{$config{module_defines} || ()}),
    477                           (map { '-I'.quotify1($_) }
    478                                @{$target{dso_includes}},
    479                                @{$target{module_includes}},
    480                                @{$config{dso_includes}},
    481                                @{$config{module_includes}}),
    482                           @{$config{dso_cppflags}},
    483                           @{$config{module_cppflags}},
    484                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
    485 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
    486                         $target{module_cflags} || (),
    487                         @{$config{dso_cflags}},
    488                         @{$config{module_cflags}},
    489                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
    490 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
    491                           $target{module_cxxflags} || (),
    492                           @{$config{dso_cxxflags}},
    493                           @{$config{module_cxxflag}},
    494                           '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
    495 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
    496                          $target{module_ldflags} || (),
    497                          @{$config{dso_ldflags}},
    498                          @{$config{module_ldflags}},
    499                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
    500 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
    501 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
    502                           (map { '-D'.$_ } @{$config{bin_defines} || ()}),
    503                           @{$config{bin_cppflags}},
    504                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
    505 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
    506                         @{$config{bin_cflags}},
    507                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
    508 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
    509                           @{$config{bin_cxxflags}},
    510                           '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
    511 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
    512                          @{$config{bin_lflags}},
    513                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
    514 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
    515 
    516 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
    517 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
    518               $cppflags2 =~ s|([\\"])|\\$1|g;
    519               $lib_cppflags =~ s|([\\"])|\\$1|g;
    520               join(' ', $lib_cppflags || (), $cppflags2 || (),
    521                         $cppflags1 || ()) -}
    522 
    523 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
    524 
    525 # For x86 assembler: Set PROCESSOR to 386 if you want to support
    526 # the 80386.
    527 PROCESSOR= {- $config{processor} -}
    528 
    529 # We want error [and other] messages in English. Trouble is that make(1)
    530 # doesn't pass macros down as environment variables unless there already
    531 # was corresponding variable originally set. In other words we can only
    532 # reassign environment variables, but not set new ones, not in portable
    533 # manner that is. That's why we reassign several, just to be sure...
    534 LC_ALL=C
    535 LC_MESSAGES=C
    536 LANG=C
    537 
    538 # The main targets ###################################################
    539 
    540 ##@ Software
    541 
    542 {- dependmagic('build_sw', 'Build all the software (default target)'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
    543 {- dependmagic('build_libs', 'Build the libraries libssl and libcrypto'); -}: build_libs_nodep
    544 {- dependmagic('build_modules', 'Build the modules (i.e. providers and engines)'); -}: build_modules_nodep
    545 {- dependmagic('build_programs', 'Build the openssl executables and scripts'); -}: build_programs_nodep
    546 
    547 all: build_sw {- "build_docs" if !$disabled{docs}; -} ## Build software and documentation
    548 debuginfo: $(SHLIBS)
    549 	@set -e; for i in $(SHLIBS); do \
    550 		$(OBJCOPY) --only-keep-debug $$i $$i.debug; \
    551 		$(OBJCOPY) --strip-debug --add-gnu-debuglink=$$i.debug $$i; \
    552 	done;
    553 
    554 ##@ Documentation
    555 build_generated_pods: $(GENERATED_PODS)
    556 build_docs: build_man_docs build_html_docs ## Create documentation
    557 build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) ## Create manpages
    558 build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) ## Create HTML documentation
    559 
    560 build_generated: $(GENERATED_MANDATORY)
    561 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
    562 build_modules_nodep: $(MODULES)
    563 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
    564 
    565 # Kept around for backward compatibility
    566 build_apps build_tests: build_programs
    567 
    568 # Convenience target to prebuild all generated files, not just the mandatory
    569 # ones
    570 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
    571 	@ : {- output_off() if $disabled{makedepend}; "" -}
    572 	@echo "Warning: consider configuring with no-makedepend, because if"
    573 	@echo "         target system doesn't have $(PERL),"
    574 	@echo "         then make will fail..."
    575 	@ : {- output_on() if $disabled{makedepend}; "" -}
    576 
    577 ##@ Help
    578 .PHONY: help
    579 help: ## Show this help screen
    580 	@$(PERL) $(SRCDIR)/util/help.pl $(BLDDIR)/Makefile
    581 
    582 ##@ Testing
    583 test: tests ## Run tests (alias of "tests")
    584 {- dependmagic('tests', 'Run tests'); -}: build_programs_nodep build_modules_nodep link-utils
    585 	"$(MAKE)" run_tests
    586 run_tests: FORCE
    587 	@ : {- output_off() if $disabled{tests}; "" -}
    588 	( SRCTOP=$(SRCDIR) \
    589 	  BLDTOP=$(BLDDIR) \
    590 	  PERL="$(PERL)" \
    591 	  FIPSKEY="$(FIPSKEY)" \
    592 	  EXE_EXT={- platform->binext() -} \
    593 	  $(PERL) $(SRCDIR)/test/run_tests.pl $(TESTS) )
    594 	@ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
    595 	@echo "Tests are not supported with your chosen Configure options"
    596 	@ : {- output_on() if !$disabled{tests}; "" -}
    597 
    598 list-tests: ## List available tests that can be invoked via "make test TESTS=<name>"
    599 	@ : {- output_off() if $disabled{tests}; "" -}
    600 	"$(MAKE)" run_tests TESTS=list
    601 	@ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
    602 	@echo "Tests are not supported with your chosen Configure options"
    603 	@ : {- output_on() if !$disabled{tests}; "" -}
    604 
    605 ##@ Workspace cleaning
    606 
    607 libclean:
    608 	@set -e; for s in $(SHLIB_INFO); do \
    609 		if [ "$$s" = ";" ]; then continue; fi; \
    610 		s1=`echo "$$s" | cut -f1 -d";"`; \
    611 		s2=`echo "$$s" | cut -f2 -d";"`; \
    612 		s3=`echo "$$s" | cut -f3 -d";"`; \
    613 		$(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
    614 		$(RM) apps/$$s1; \
    615 		$(RM) test/$$s1; \
    616 		$(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
    617 		$(RM) $$s1; \
    618 		if [ "$$s2" != "" ]; then \
    619 			$(ECHO) $(RM) $$s2; \
    620 			$(RM) $$s2; \
    621 		fi; \
    622 		if [ "$$s3" != "" ]; then \
    623 			$(ECHO) $(RM) $$s3; \
    624 			$(RM) $$s3; \
    625 		fi; \
    626 	done
    627 	$(RM) $(LIBS)
    628 	$(RM) *{- platform->defext() -}
    629 
    630 clean: libclean ## Clean the workspace, keep the configuration
    631 	$(RM) $(HTMLDOCS1)
    632 	$(RM) $(HTMLDOCS3)
    633 	$(RM) $(HTMLDOCS5)
    634 	$(RM) $(HTMLDOCS7)
    635 	$(RM) $(MANDOCS1)
    636 	$(RM) $(MANDOCS3)
    637 	$(RM) $(MANDOCS5)
    638 	$(RM) $(MANDOCS7)
    639 	$(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(FIPSMODULE) $(SCRIPTS)
    640 	$(RM) $(GENERATED_MANDATORY) $(GENERATED)
    641 	-find . -name '*{- platform->depext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
    642 	-find . -name '*{- platform->objext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
    643 	$(RM) core
    644 	$(RM) tags TAGS doc-nits md-nits
    645 	$(RM) -r test/test-runs
    646 	$(RM) providers/fips*.new
    647 	-find . -type l \! -name '.*' -exec $(RM) {} \;
    648 
    649 distclean: clean ## Clean and remove the configuration
    650 	$(RM) include/openssl/configuration.h
    651 	$(RM) configdata.pm
    652 	$(RM) Makefile
    653 
    654 # We check if any depfile is newer than Makefile and decide to
    655 # concatenate only if that is true.
    656 depend: Makefile
    657 	@: {- output_off() if $disabled{makedepend}; "" -}
    658 	@$(PERL) $(SRCDIR)/util/add-depends.pl "{- $makedep_scheme -}"
    659 	@: {- output_on() if $disabled{makedepend}; "" -}
    660 
    661 # Install helper targets #############################################
    662 ##@ Installation
    663 
    664 install: install_sw install_ssldirs {- "install_docs" if !$disabled{docs}; -} {- $disabled{fips} ? "" : "install_fips" -} ## Install software and documentation, create OpenSSL directories
    665 
    666 uninstall: {- "uninstall_docs" if !$disabled{docs}; -} uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -} ## Uninstall software and documentation
    667 
    668 install_sw: install_dev install_engines install_modules install_runtime ## Install just the software and libraries
    669 
    670 uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev ## Uninstall the software and libraries
    671 
    672 install_docs: install_man_docs install_html_docs ## Install manpages and HTML documentation
    673 
    674 uninstall_docs: uninstall_man_docs uninstall_html_docs ## Uninstall manpages and HTML documentation
    675 	$(RM) -r "$(DESTDIR)$(DOCDIR)"
    676 
    677 {- output_off() if $disabled{fips}; "" -}
    678 install_fips: build_sw $(INSTALL_FIPSMODULECONF)
    679 	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
    680 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MODULESDIR)"
    681 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)"
    682 	@$(ECHO) "*** Installing FIPS module"
    683 	@$(ECHO) "install $(INSTALL_FIPSMODULE) -> $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
    684 	@cp "$(INSTALL_FIPSMODULE)" "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new"
    685 	@chmod 755 "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new"
    686 	@mv -f "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new" \
    687 	       "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
    688 	@$(ECHO) "*** Installing FIPS module configuration"
    689 	@$(ECHO) "install $(INSTALL_FIPSMODULECONF) -> $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
    690 	@cp $(INSTALL_FIPSMODULECONF) "$(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
    691 
    692 uninstall_fips:
    693 	@$(ECHO) "*** Uninstalling FIPS module configuration"
    694 	$(RM) "$(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
    695 	@$(ECHO) "*** Uninstalling FIPS module"
    696 	$(RM) "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
    697 {- if ($disabled{fips}) { output_on(); } else { output_off(); } "" -}
    698 install_fips:
    699 	@$(ECHO) "The 'install_fips' target requires the 'enable-fips' option"
    700 
    701 uninstall_fips:
    702 	@$(ECHO) "The 'uninstall_fips' target requires the 'enable-fips' option"
    703 {- output_on() if !$disabled{fips}; "" -}
    704 
    705 
    706 install_ssldirs:
    707 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/certs"
    708 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/private"
    709 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/misc"
    710 	@set -e; for x in dummy $(MISC_SCRIPTS); do \
    711 		if [ "$$x" = "dummy" ]; then continue; fi; \
    712 		x1=`echo "$$x" | cut -f1 -d:`; \
    713 		x2=`echo "$$x" | cut -f2 -d:`; \
    714 		fn=`basename $$x1`; \
    715 		$(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
    716 		cp $$x1 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \
    717 		chmod 755 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \
    718 		mv -f "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new" \
    719 		      "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
    720 		if [ "$$x1" != "$$x2" ]; then \
    721 			ln=`basename "$$x2"`; \
    722 			: {- output_off() unless windowsdll(); "" -}; \
    723 			$(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
    724 			cp "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn" "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \
    725 			: {- output_on() unless windowsdll();
    726 			     output_off() if windowsdll(); "" -}; \
    727 			$(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
    728 			ln -sf $$fn "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \
    729 			: {- output_on() if windowsdll(); "" -}; \
    730 		fi; \
    731 	done
    732 	@$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
    733 	@cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new"
    734 	@chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new"
    735 	@mv -f  "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
    736 	@if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
    737 		$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
    738 		cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
    739 		chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
    740 	fi
    741 	@$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
    742 	@cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new"
    743 	@chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new"
    744 	@mv -f  "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
    745 	@if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
    746 		$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
    747 		cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
    748 		chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
    749 	fi
    750 
    751 install_dev: install_runtime_libs
    752 	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
    753 	@$(ECHO) "*** Installing development files"
    754 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)/include/openssl"
    755 	@ : {- output_off() if $disabled{uplink}; "" -}
    756 	@$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
    757 	@cp $(SRCDIR)/ms/applink.c "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
    758 	@chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
    759 	@ : {- output_on() if $disabled{uplink}; "" -}
    760 	@set -e; for i in $(SRCDIR)/include/openssl/*.h \
    761 			  $(BLDDIR)/include/openssl/*.h; do \
    762 		fn=`basename $$i`; \
    763 		$(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
    764 		cp $$i "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
    765 		chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
    766 	done
    767 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)"
    768 	@set -e; for l in $(INSTALL_LIBS); do \
    769 		fn=`basename $$l`; \
    770 		$(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
    771 		cp $$l "$(DESTDIR)$(libdir)/$$fn.new"; \
    772 		$(RANLIB) "$(DESTDIR)$(libdir)/$$fn.new"; \
    773 		chmod 644 "$(DESTDIR)$(libdir)/$$fn.new"; \
    774 		mv -f "$(DESTDIR)$(libdir)/$$fn.new" \
    775 		      "$(DESTDIR)$(libdir)/$$fn"; \
    776 	done
    777 	@ : {- output_off() if $disabled{shared}; "" -}
    778 	@set -e; for s in $(INSTALL_SHLIB_INFO); do \
    779 		s1=`echo "$$s" | cut -f1 -d";"`; \
    780 		s2=`echo "$$s" | cut -f2 -d";"`; \
    781 		s3=`echo "$$s" | cut -f3 -d";"`; \
    782 		fn1=`basename "$$s1"`; \
    783 		fn2=`basename "$$s2"`; \
    784 		fn3=`basename "$$s3"`; \
    785 		: {- output_off(); output_on() unless windowsdll() or sharedaix() or sharedaix_solib(); "" -}; \
    786 		if [ "$$fn2" != "" ]; then \
    787 			$(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
    788 			ln -sf $$fn1 "$(DESTDIR)$(libdir)/$$fn2"; \
    789 		fi; \
    790 		: {- output_off() unless windowsdll() or sharedaix() or sharedaix_solib(); output_on() if windowsdll() or sharedaix_solib(); "" -}; \
    791 		if [ "$$fn3" != "" ]; then \
    792 			$(ECHO) "install $$s3 -> $(DESTDIR)$(libdir)/$$fn3"; \
    793 			cp $$s3 "$(DESTDIR)$(libdir)/$$fn3.new"; \
    794 			chmod 755 "$(DESTDIR)$(libdir)/$$fn3.new"; \
    795 			mv -f "$(DESTDIR)$(libdir)/$$fn3.new" \
    796 			      "$(DESTDIR)$(libdir)/$$fn3"; \
    797 		fi; \
    798 		: {- output_off() if windowsdll() or sharedaix_solib(); output_on() if sharedaix(); "" -}; \
    799 		a="$(DESTDIR)$(libdir)/$$fn2"; \
    800 		$(ECHO) "install $$s1 -> $$a"; \
    801 		if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
    802 			mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
    803 			cp -f $$a $$a.new; \
    804 			for so in `$(AR) t $$a`; do \
    805 				$(AR) x $$a $$so; \
    806 				chmod u+w $$so; \
    807 				strip -X32_64 -e $$so; \
    808 				$(AR) r $$a.new $$so; \
    809 			done; \
    810 		)); fi; \
    811 		$(AR) r $$a.new $$s1; \
    812 		mv -f $$a.new $$a; \
    813 		: {- output_off() if sharedaix(); output_on(); "" -}; \
    814 	done
    815 	@ : {- output_on() if $disabled{shared}; "" -}
    816 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(PKGCONFIGDIR)"
    817 	@for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \
    818 		fn=`basename $$e`; \
    819 		$(ECHO) "install $$e -> $(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
    820 		cp $$e "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
    821 		chmod 644 "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
    822 	done
    823 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(CMAKECONFIGDIR)"
    824 	@for e in $(INSTALL_EXPORTERS_CMAKE); do \
    825 		fn=`basename $$e`; \
    826 		$(ECHO) "install $$e -> $(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \
    827 		cp $$e "$(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \
    828 		chmod 644 "$(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \
    829 	done
    830 
    831 uninstall_dev: uninstall_runtime_libs
    832 	@$(ECHO) "*** Uninstalling development files"
    833 	@ : {- output_off() if $disabled{uplink}; "" -}
    834 	@$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
    835 	@$(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
    836 	@ : {- output_on() if $disabled{uplink}; "" -}
    837 	@set -e; for i in $(SRCDIR)/include/openssl/*.h \
    838 			  $(BLDDIR)/include/openssl/*.h; do \
    839 		fn=`basename $$i`; \
    840 		$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
    841 		$(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
    842 	done
    843 	-$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include/openssl"
    844 	-$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include"
    845 	@set -e; for l in $(INSTALL_LIBS); do \
    846 		fn=`basename $$l`; \
    847 		$(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
    848 		$(RM) "$(DESTDIR)$(libdir)/$$fn"; \
    849 	done
    850 	@ : {- output_off() if $disabled{shared}; "" -}
    851 	@set -e; for s in $(INSTALL_SHLIB_INFO); do \
    852 		s1=`echo "$$s" | cut -f1 -d";"`; \
    853 		s2=`echo "$$s" | cut -f2 -d";"`; \
    854 		s3=`echo "$$s" | cut -f3 -d";"`; \
    855 		fn1=`basename "$$s1"`; \
    856 		fn2=`basename "$$s2"`; \
    857 		fn3=`basename "$$s3"`; \
    858 		: {- output_off() if windowsdll(); "" -}; \
    859 		$(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
    860 		$(RM) "$(DESTDIR)$(libdir)/$$fn1"; \
    861 		if [ -n "$$fn2" ]; then \
    862 			$(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
    863 			$(RM) "$(DESTDIR)$(libdir)/$$fn2"; \
    864 		fi; \
    865 		: {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
    866 		if [ -n "$$fn3" ]; then \
    867 			$(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn3"; \
    868 			$(RM) "$(DESTDIR)$(libdir)/$$fn3"; \
    869 		fi; \
    870 		: {- output_on() unless windowsdll(); "" -}; \
    871 	done
    872 	@ : {- output_on() if $disabled{shared}; "" -}
    873 	@for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \
    874 		fn=`basename "$$e"`; \
    875 		$(RM) "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
    876 	done
    877 	@for e in $(INSTALL_EXPORTERS_CMAKE); do \
    878 		fn=`basename "$$e"`; \
    879 		$(RM) "$(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \
    880 	done
    881 	-$(RMDIR) "$(DESTDIR)$(PKGCONFIGDIR)"
    882 	-$(RMDIR) "$(DESTDIR)$(CMAKECONFIGDIR)"
    883 	-$(RMDIR) "$(DESTDIR)$(libdir)/cmake"
    884 	-$(RMDIR) "$(DESTDIR)$(libdir)"
    885 
    886 _install_modules_deps: install_runtime_libs build_modules
    887 
    888 install_engines: _install_modules_deps
    889 	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
    890 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(ENGINESDIR)/"
    891 	@$(ECHO) "*** Installing engines"
    892 	@set -e; for e in dummy $(INSTALL_ENGINES); do \
    893 		if [ "$$e" = "dummy" ]; then continue; fi; \
    894 		fn=`basename $$e`; \
    895 		$(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
    896 		cp $$e "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \
    897 		chmod 755 "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \
    898 		mv -f "$(DESTDIR)$(ENGINESDIR)/$$fn.new" \
    899 		      "$(DESTDIR)$(ENGINESDIR)/$$fn"; \
    900 	done
    901 
    902 uninstall_engines:
    903 	@$(ECHO) "*** Uninstalling engines"
    904 	@set -e; for e in dummy $(INSTALL_ENGINES); do \
    905 		if [ "$$e" = "dummy" ]; then continue; fi; \
    906 		fn=`basename $$e`; \
    907 		$(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
    908 		$(RM) "$(DESTDIR)$(ENGINESDIR)/$$fn"; \
    909 	done
    910 	-$(RMDIR) "$(DESTDIR)$(ENGINESDIR)"
    911 
    912 install_modules: _install_modules_deps
    913 	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
    914 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MODULESDIR)/"
    915 	@$(ECHO) "*** Installing modules"
    916 	@set -e; for e in dummy $(INSTALL_MODULES); do \
    917 		if [ "$$e" = "dummy" ]; then continue; fi; \
    918 		fn=`basename $$e`; \
    919 		$(ECHO) "install $$e -> $(DESTDIR)$(MODULESDIR)/$$fn"; \
    920 		cp $$e "$(DESTDIR)$(MODULESDIR)/$$fn.new"; \
    921 		chmod 755 "$(DESTDIR)$(MODULESDIR)/$$fn.new"; \
    922 		mv -f "$(DESTDIR)$(MODULESDIR)/$$fn.new" \
    923 		      "$(DESTDIR)$(MODULESDIR)/$$fn"; \
    924 	done
    925 
    926 uninstall_modules:
    927 	@$(ECHO) "*** Uninstalling modules"
    928 	@set -e; for e in dummy $(INSTALL_MODULES); do \
    929 		if [ "$$e" = "dummy" ]; then continue; fi; \
    930 		fn=`basename $$e`; \
    931 		$(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$$fn"; \
    932 		$(RM) "$(DESTDIR)$(MODULESDIR)/$$fn"; \
    933 	done
    934 	-$(RMDIR) "$(DESTDIR)$(MODULESDIR)"
    935 
    936 install_runtime: install_programs
    937 
    938 install_runtime_libs: build_libs
    939 	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
    940 	@ : {- output_off() if windowsdll(); "" -}
    941 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)"
    942 	@ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
    943 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(bindir)/"
    944 	@ : {- output_on() unless windowsdll(); "" -}
    945 	@$(ECHO) "*** Installing runtime libraries"
    946 	@set -e; for s in dummy $(INSTALL_SHLIBS); do \
    947 		if [ "$$s" = "dummy" ]; then continue; fi; \
    948 		fn=`basename $$s`; \
    949 		: {- output_off() unless windowsdll(); "" -}; \
    950 		$(ECHO) "install $$s -> $(DESTDIR)$(bindir)/$$fn"; \
    951 		cp $$s "$(DESTDIR)$(bindir)/$$fn.new"; \
    952 		chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
    953 		mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
    954 		      "$(DESTDIR)$(bindir)/$$fn"; \
    955 		: {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
    956 		$(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
    957 		cp $$s "$(DESTDIR)$(libdir)/$$fn.new"; \
    958 		chmod 755 "$(DESTDIR)$(libdir)/$$fn.new"; \
    959 		mv -f "$(DESTDIR)$(libdir)/$$fn.new" \
    960 		      "$(DESTDIR)$(libdir)/$$fn"; \
    961 		: {- output_on() if windowsdll(); "" -}; \
    962 	done
    963 
    964 install_programs: install_runtime_libs build_programs
    965 	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
    966 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(bindir)"
    967 	@$(ECHO) "*** Installing runtime programs"
    968 	@set -e; for x in dummy $(INSTALL_PROGRAMS); do \
    969 		if [ "$$x" = "dummy" ]; then continue; fi; \
    970 		fn=`basename $$x`; \
    971 		$(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \
    972 		cp $$x "$(DESTDIR)$(bindir)/$$fn.new"; \
    973 		chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
    974 		mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
    975 		      "$(DESTDIR)$(bindir)/$$fn"; \
    976 	done
    977 	@set -e; for x in dummy $(BIN_SCRIPTS); do \
    978 		if [ "$$x" = "dummy" ]; then continue; fi; \
    979 		fn=`basename $$x`; \
    980 		$(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \
    981 		cp $$x "$(DESTDIR)$(bindir)/$$fn.new"; \
    982 		chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
    983 		mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
    984 		      "$(DESTDIR)$(bindir)/$$fn"; \
    985 	done
    986 
    987 uninstall_runtime: uninstall_programs uninstall_runtime_libs
    988 
    989 uninstall_programs:
    990 	@$(ECHO) "*** Uninstalling runtime programs"
    991 	@set -e; for x in dummy $(INSTALL_PROGRAMS); \
    992 	do  \
    993 		if [ "$$x" = "dummy" ]; then continue; fi; \
    994 		fn=`basename $$x`; \
    995 		$(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
    996 		$(RM) "$(DESTDIR)$(bindir)/$$fn"; \
    997 	done;
    998 	@set -e; for x in dummy $(BIN_SCRIPTS); \
    999 	do  \
   1000 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1001 		fn=`basename $$x`; \
   1002 		$(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
   1003 		$(RM) "$(DESTDIR)$(bindir)/$$fn"; \
   1004 	done
   1005 	-$(RMDIR) "$(DESTDIR)$(bindir)"
   1006 
   1007 uninstall_runtime_libs:
   1008 	@$(ECHO) "*** Uninstalling runtime libraries"
   1009 	@ : {- output_off() unless windowsdll(); "" -}
   1010 	@set -e; for s in dummy $(INSTALL_SHLIBS); do \
   1011 		if [ "$$s" = "dummy" ]; then continue; fi; \
   1012 		fn=`basename $$s`; \
   1013 		$(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
   1014 		$(RM) "$(DESTDIR)$(bindir)/$$fn"; \
   1015 	done
   1016 	@ : {- output_on() unless windowsdll(); "" -}
   1017 
   1018 
   1019 install_man_docs: build_man_docs
   1020 	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
   1021 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man1"
   1022 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man3"
   1023 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man5"
   1024 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man7"
   1025 	@$(ECHO) "*** Installing manpages"
   1026 	@set -e; for x in dummy $(MANDOCS1); do \
   1027 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1028 		fn=`basename $$x`; \
   1029 		$(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
   1030 		cp $$x "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
   1031 		chmod 644 "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
   1032 		$(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man1"; \
   1033 	done
   1034 	@set -e; for x in dummy $(MANDOCS3); do \
   1035 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1036 		fn=`basename $$x`; \
   1037 		$(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
   1038 		cp $$x "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
   1039 		chmod 644 "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
   1040 		$(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man3"; \
   1041 	done
   1042 	@set -e; for x in dummy $(MANDOCS5); do \
   1043 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1044 		fn=`basename $$x`; \
   1045 		$(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
   1046 		cp $$x "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
   1047 		chmod 644 "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
   1048 		$(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man5"; \
   1049 	done
   1050 	@set -e; for x in dummy $(MANDOCS7); do \
   1051 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1052 		fn=`basename $$x`; \
   1053 		$(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
   1054 		cp $$x "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
   1055 		chmod 644 "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
   1056 		$(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man7"; \
   1057 	done
   1058 
   1059 uninstall_man_docs: build_man_docs
   1060 	@$(ECHO) "*** Uninstalling manpages"
   1061 	@set -e; for x in dummy $(MANDOCS1); do \
   1062 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1063 		fn=`basename $$x`; \
   1064 		$(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
   1065 		$(RM) "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
   1066 		$(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man1"; \
   1067 	done
   1068 	@set -e; for x in dummy $(MANDOCS3); do \
   1069 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1070 		fn=`basename $$x`; \
   1071 		$(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
   1072 		$(RM) "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
   1073 		$(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man3"; \
   1074 	done
   1075 	@set -e; for x in dummy $(MANDOCS5); do \
   1076 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1077 		fn=`basename $$x`; \
   1078 		$(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
   1079 		$(RM) "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
   1080 		$(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man5"; \
   1081 	done
   1082 	@set -e; for x in dummy $(MANDOCS7); do \
   1083 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1084 		fn=`basename $$x`; \
   1085 		$(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
   1086 		$(RM) "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
   1087 		$(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man7"; \
   1088 	done
   1089 
   1090 install_html_docs: install_image_docs build_html_docs
   1091 	@[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
   1092 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man1"
   1093 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man3"
   1094 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man5"
   1095 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man7"
   1096 	@$(ECHO) "*** Installing HTML manpages"
   1097 	@set -e; for x in dummy $(HTMLDOCS1); do \
   1098 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1099 		fn=`basename $$x`; \
   1100 		$(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
   1101 		cp $$x "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
   1102 		chmod 644 "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
   1103 	done
   1104 	@set -e; for x in dummy $(HTMLDOCS3); do \
   1105 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1106 		fn=`basename $$x`; \
   1107 		$(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
   1108 		cp $$x "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
   1109 		chmod 644 "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
   1110 	done
   1111 	@set -e; for x in dummy $(HTMLDOCS5); do \
   1112 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1113 		fn=`basename $$x`; \
   1114 		$(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
   1115 		cp $$x "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
   1116 		chmod 644 "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
   1117 	done
   1118 	@set -e; for x in dummy $(HTMLDOCS7); do \
   1119 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1120 		fn=`basename $$x`; \
   1121 		$(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
   1122 		cp $$x "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
   1123 		chmod 644 "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
   1124 	done
   1125 
   1126 uninstall_html_docs: uninstall_image_docs
   1127 	@$(ECHO) "*** Uninstalling HTML manpages"
   1128 	@set -e; for x in dummy $(HTMLDOCS1); do \
   1129 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1130 		fn=`basename $$x`; \
   1131 		$(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
   1132 		$(RM) "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
   1133 	done
   1134 	@set -e; for x in dummy $(HTMLDOCS3); do \
   1135 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1136 		fn=`basename $$x`; \
   1137 		$(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
   1138 		$(RM) "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
   1139 	done
   1140 	@set -e; for x in dummy $(HTMLDOCS5); do \
   1141 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1142 		fn=`basename $$x`; \
   1143 		$(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
   1144 		$(RM) "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
   1145 	done
   1146 	@set -e; for x in dummy $(HTMLDOCS7); do \
   1147 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1148 		fn=`basename $$x`; \
   1149 		$(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
   1150 		$(RM) "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
   1151 	done
   1152 
   1153 install_image_docs:
   1154 	@$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man7/img"
   1155 	@set -e; for x in dummy $(IMAGEDOCS7); do \
   1156 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1157 		fn=`basename $$x`; \
   1158 		$(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
   1159 		cp $(SRCDIR)/$$x "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
   1160 		chmod 644 "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
   1161 	done
   1162 
   1163 uninstall_image_docs:
   1164 	@set -e; for x in dummy $(IMAGEDOCS7); do \
   1165 		if [ "$$x" = "dummy" ]; then continue; fi; \
   1166 		fn=`basename $$x`; \
   1167 		$(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
   1168 		$(RM) "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
   1169 	done
   1170 
   1171 # Developer targets (note: these are only available on Unix) #########
   1172 ##@ Code maintenance
   1173 
   1174 # It's important that generate_buildinfo comes after ordinals, as ordinals
   1175 # is sensitive to build.info changes.
   1176 update: generate errors ordinals generate_buildinfo ## Update errors, ordinals and build info
   1177 
   1178 .PHONY: generate generate_apps generate_crypto_bn generate_crypto_objects \
   1179           generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
   1180 generate: generate_apps generate_crypto_bn generate_crypto_objects \
   1181           generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
   1182 
   1183 .PHONY: generate_buildinfo generate_doc_buildinfo
   1184 generate_buildinfo: generate_doc_buildinfo
   1185 
   1186 .PHONY: doc-nits md-nits
   1187 doc-nits: build_generated_pods ## Evaluate OpenSSL documentation
   1188 	$(PERL) $(SRCDIR)/util/find-doc-nits -c -n -l -e -i
   1189 
   1190 # This uses "mdl", the markdownlint application, which is written in ruby.
   1191 # The source is at https://github.com/markdownlint/markdownlint
   1192 # If you have ruby installed, "gem install mdl" should work.
   1193 # Another option is at https://snapcraft.io/install/mdl/debian
   1194 # Finally, there's a Node.js version, which we haven't tried, that
   1195 # can be found at https://github.com/DavidAnson/markdownlint
   1196 md-nits: ## Evaluate markdown files via "mdl"
   1197 	mdl -s $(SRCDIR)/util/markdownlint.rb .
   1198 
   1199 # Test coverage is a good idea for the future
   1200 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
   1201 #	...
   1202 
   1203 .PHONY: lint
   1204 lint: ## Evaluate C code via "splint"
   1205 	@( cd $(SRCDIR); \
   1206            echo splint -DLINT -posixlib -preproc -D__gnuc_va_list=void \
   1207 	   -I. -Iinclude -Iapps/include $(CRYPTOHEADERS) $(SSLHEADERS) $(SRCS) )
   1208 
   1209 CLANG_FORMAT_DIFF = clang-format-diff
   1210 
   1211 .PHONY: check-format check-clang-format-diff-cmd
   1212 check-clang-format-diff-cmd:
   1213 	@if ! command -v "$(CLANG_FORMAT_DIFF)" >/dev/null; then \
   1214 		echo "Unable to find ${CLANG_FORMAT_DIFF}";\
   1215 		echo "Please set the CLANG_FORMAT_DIFF variable to your clang-format-diff command";\
   1216 		exit 1;\
   1217 	fi
   1218 
   1219 check-format: check-clang-format-diff-cmd ## Evaluate C code according to OpenSSL coding standards
   1220 	( cd $(SRCDIR); git diff -U0 --no-prefix --no-color | $(CLANG_FORMAT_DIFF) )
   1221 
   1222 generate_apps:
   1223 	( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
   1224 				< apps/openssl.cnf > apps/openssl-vms.cnf )
   1225 
   1226 generate_crypto_bn:
   1227 	( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
   1228 
   1229 generate_crypto_objects:
   1230 	( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
   1231 				crypto/objects/objects.txt \
   1232 				crypto/objects/obj_mac.num \
   1233 				> crypto/objects/obj_mac.new && \
   1234 	    mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
   1235 	( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
   1236 				crypto/objects/objects.txt \
   1237 				crypto/objects/obj_mac.num \
   1238 				> include/openssl/obj_mac.h )
   1239 	( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
   1240 				include/openssl/obj_mac.h \
   1241 				> crypto/objects/obj_dat.h )
   1242 	( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
   1243 				crypto/objects/obj_mac.num \
   1244 				crypto/objects/obj_xref.txt \
   1245 				> crypto/objects/obj_xref.h )
   1246 	( cd $(SRCDIR);	sed -e '1,8d' crypto/objects/obj_compat.h >> include/openssl/obj_mac.h )
   1247 
   1248 generate_crypto_conf:
   1249 	( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
   1250 			        > crypto/conf/conf_def.h )
   1251 
   1252 generate_crypto_asn1:
   1253 	( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
   1254 			        > crypto/asn1/charmap.h )
   1255 
   1256 generate_fuzz_oids:
   1257 	( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
   1258 				crypto/objects/obj_dat.h \
   1259 				> fuzz/oids.txt )
   1260 
   1261 generate_doc_buildinfo:
   1262 	( $(PERL) -I$(BLDDIR) -Mconfigdata \
   1263                 $(SRCDIR)/util/dofile.pl -o Makefile \
   1264                         $(SRCDIR)/doc/build.info.in \
   1265                         > $(SRCDIR)/doc/build.info.new; \
   1266           if ( test -e $(SRCDIR)/doc/build.info \
   1267                && cmp $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info \
   1268                   > /dev/null ); \
   1269           then \
   1270                 rm $(SRCDIR)/doc/build.info.new; \
   1271           else \
   1272                 mv $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info; \
   1273           fi )
   1274 
   1275 generate_fips_sources: providers/fips.module.sources.new
   1276 providers/fips.module.sources.new: configdata.pm
   1277 	rm -rf sources-tmp
   1278 	mkdir sources-tmp
   1279 	( \
   1280 	  srcdir=`cd $(SRCDIR); pwd`; \
   1281 	  cd sources-tmp \
   1282 	  && $$srcdir/Configure --banner=Configured enable-fips -O0 \
   1283 	  && ./configdata.pm --query 'get_sources("providers/fips")' > sources1 \
   1284 	  && "$(MAKE)" -sj 4 build_generated providers/fips.so \
   1285 	  && find . -name '*.d' | xargs cat > dep1 \
   1286           && "$(MAKE)" distclean \
   1287 	  && $$srcdir/Configure --banner=Configured enable-fips no-asm -O0 \
   1288 	  && ./configdata.pm --query 'get_sources("providers/fips")' > sources2 \
   1289 	  && "$(MAKE)" -sj 4 build_generated providers/fips.so \
   1290 	  && find . -name '*.d' | xargs cat > dep2 \
   1291 	  && cat sources1 sources2 \
   1292 	     | grep -v ' : \\$$' | grep -v util/providers.num \
   1293 	     | sed -e 's/^ *//' -e 's/ *\\$$//' \
   1294 	     | sort | uniq > sources \
   1295 	  && cat dep1 dep2 \
   1296 	     | $(PERL) -p -e 's/\\\n//' \
   1297 	     | sed -e 's/^.*: *//' -e 's/  */ /g' \
   1298 	     | fgrep -f sources \
   1299 	     | tr ' ' '\n' \
   1300 	     | sort | uniq > deps.raw \
   1301 	  && cat deps.raw \
   1302 	     | xargs ./configdata.pm --query 'get_sources(@ARGV)' \
   1303 	     | $(PERL) -p -e 's/\\\n//' \
   1304 	     | sed -e 's/\./\\\./g' -e 's/ : */:/' -e 's/^/s:/' -e 's/$$/:/' \
   1305 	     > deps.sed \
   1306 	  && cat deps.raw | sed -f deps.sed > deps \
   1307 	)
   1308 	( \
   1309 	  cat sources-tmp/sources sources-tmp/deps \
   1310 	     | $(PERL) -p -e 's:^ *\Q../\E:: ;' \
   1311 			  -e 's:^\Q$(SRCDIR)/\E:: if "$(SRCDIR)" ne "." ;' \
   1312 			  -e 'my $$x; do { $$x = $$_; s:(^|/)((?!\Q../\E)[^/]*/)\Q..\E($$|/):$$1: } while ($$x ne $$_) ;' ; \
   1313 	  cd $(SRCDIR); \
   1314 	  for x in crypto/bn/asm/*.pl crypto/bn/asm/*.S \
   1315 		   crypto/aes/asm/*.pl crypto/aes/asm/*.S \
   1316 		   crypto/ec/asm/*.pl \
   1317 		   crypto/modes/asm/*.pl \
   1318 		   crypto/sha/asm/*.pl \
   1319 		   crypto/*cpuid.pl crypto/*cpuid.S \
   1320 		   crypto/*cap.c; do \
   1321 	    echo "$$x"; \
   1322 	  done \
   1323 	) | grep -v sm2p256 | sort | uniq > providers/fips.module.sources.new
   1324 	rm -rf sources-tmp
   1325 
   1326 # Set to -force to force a rebuild
   1327 ERROR_REBUILD=
   1328 errors:
   1329 	( b=`pwd`; set -e; cd $(SRCDIR); \
   1330           $(PERL) util/ck_errf.pl -strict -internal; \
   1331           $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
   1332 	( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
   1333           for E in *.ec ; do \
   1334               $(PERL) ../util/ck_errf.pl -strict \
   1335                 -conf $$E `basename $$E .ec`.c; \
   1336               $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
   1337                 -conf $$E `basename $$E .ec`.c ; \
   1338           done )
   1339 
   1340 {- use File::Basename;
   1341 
   1342    my @sslheaders_tmpl =
   1343        qw( include/openssl/ssl.h
   1344            include/openssl/ssl2.h
   1345            include/openssl/ssl3.h
   1346            include/openssl/sslerr.h
   1347            include/openssl/tls1.h
   1348            include/openssl/dtls1.h
   1349            include/openssl/srtp.h
   1350            include/openssl/quic.h
   1351            include/openssl/sslerr_legacy.h );
   1352    my @cryptoheaders_tmpl =
   1353        qw( include/internal/dso.h
   1354            include/internal/o_dir.h
   1355            include/internal/err.h
   1356            include/internal/evp.h
   1357            include/internal/pem.h
   1358            include/internal/asn1.h
   1359            include/internal/sslconf.h );
   1360    my @cryptoskipheaders = ( @sslheaders_tmpl,
   1361        qw( include/openssl/conf_api.h
   1362            include/openssl/ebcdic.h
   1363            include/openssl/opensslconf.h
   1364            include/openssl/symhacks.h ) );
   1365    our %cryptoheaders = ();
   1366    our %sslheaders = ();
   1367    foreach my $d ( qw( include/openssl include/internal ) ) {
   1368        my @header_patterns =
   1369            map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' );
   1370        foreach my $f ( map { glob($_) } @header_patterns ) {
   1371            my $base = basename($f);
   1372            my $base_in = basename($f, '.in');
   1373            my $dir = catfile($config{sourcedir}, $d);
   1374            if ($base ne $base_in) {
   1375                # We have a .h.in file, which means the header file is in the
   1376                # build tree.
   1377                $base = $base_in;
   1378                $dir = catfile($config{builddir}, $d);
   1379            }
   1380            my $new_f = catfile($dir, $base);
   1381            my $fn = "$d/$base";
   1382            # The logic to add files to @cryptoheaders is a bit complex.  The
   1383            # file to be added must be either in the public header directory
   1384            # or one of the pre-declared internal headers, and must under no
   1385            # circumstances be one of those that must be skipped.
   1386            $cryptoheaders{$new_f} = 1
   1387                if (($d eq 'include/openssl'
   1388                     || ( grep { $_ eq $fn } @cryptoheaders_tmpl ))
   1389                    && !( grep { $_ eq $fn } @cryptoskipheaders ));
   1390            # The logic to add files to @sslheaders is much simpler...
   1391            $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl;
   1392        }
   1393    }
   1394    "";
   1395 -}
   1396 SRCS={-
   1397 sub uniq { my %seen; grep !$seen{$_}++, @_; }
   1398 sub flat(@) { return map { ref eq 'ARRAY' ? @$_ : $_ } @_; }
   1399 join(" \\\n" . ' ' x 5, fill_lines(" ", $COLUMNS - 5,
   1400      uniq(grep /\.(c|cc|cpp)$/,
   1401           flat (map { $unified_info{sources}->{$_} }
   1402                 (sort keys %{$unified_info{sources}})))))
   1403 -}
   1404 CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
   1405                       fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -}
   1406 SSLHEADERS={- join(" \\\n" . ' ' x 11,
   1407                    fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
   1408 
   1409 renumber: build_generated
   1410 	$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
   1411                 --ordinals $(SRCDIR)/util/libcrypto.num \
   1412                 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
   1413                 --renumber \
   1414                 $(CRYPTOHEADERS)
   1415 	$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
   1416                 --ordinals $(SRCDIR)/util/libssl.num \
   1417                 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
   1418                 --renumber \
   1419                 $(SSLHEADERS)
   1420 
   1421 .PHONY: ordinals
   1422 ordinals: build_generated
   1423 	$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
   1424                 --ordinals $(SRCDIR)/util/libcrypto.num \
   1425                 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
   1426                 $(CRYPTOHEADERS)
   1427 	$(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
   1428                 --ordinals $(SRCDIR)/util/libssl.num \
   1429                 --symhacks $(SRCDIR)/include/openssl/symhacks.h \
   1430                 $(SSLHEADERS)
   1431 
   1432 test_ordinals:
   1433 	"$(MAKE)" run_tests TESTS=test_ordinals
   1434 
   1435 tags TAGS: FORCE
   1436 	rm -f TAGS tags
   1437 	-( cd $(SRCDIR); util/ctags.sh )
   1438 	-etags `find . -name '*.[ch]' -o -name '*.pm'`
   1439 
   1440 providers/fips.checksum.new: providers/fips.module.sources.new
   1441 	@which unifdef > /dev/null || \
   1442 	( echo >&2 "ERROR: unifdef not in your \$$PATH, FIPS checksums not calculated"; \
   1443 	  false )
   1444 	( sources=`pwd`/providers/fips.module.sources.new; \
   1445 	  cd $(SRCDIR) \
   1446 	  && cat $$sources \
   1447 	         | xargs ./util/fips-checksums.sh ) \
   1448 	         > providers/fips-sources.checksums.new \
   1449 	&& sha256sum providers/fips-sources.checksums.new \
   1450 	     | sed -e 's|\.new||' > providers/fips.checksum.new
   1451 
   1452 fips-checksums: providers/fips.checksum.new
   1453 
   1454 $(SRCDIR)/providers/fips.checksum: providers/fips.checksum.new
   1455 	cp -p providers/fips.module.sources.new $(SRCDIR)/providers/fips.module.sources
   1456 	cp -p providers/fips-sources.checksums.new $(SRCDIR)/providers/fips-sources.checksums
   1457 	cp -p providers/fips.checksum.new $(SRCDIR)/providers/fips.checksum
   1458 
   1459 update-fips-checksums: $(SRCDIR)/providers/fips.checksum
   1460 
   1461 diff-fips-checksums: fips-checksums
   1462 	diff -u $(SRCDIR)/providers/fips.module.sources providers/fips.module.sources.new
   1463 	diff -u $(SRCDIR)/providers/fips-sources.checksums providers/fips-sources.checksums.new
   1464 	diff -u $(SRCDIR)/providers/fips.checksum providers/fips.checksum.new
   1465 
   1466 # Release targets (note: only available on Unix) #####################
   1467 
   1468 tar:
   1469 	(cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
   1470 
   1471 # Helper targets #####################################################
   1472 
   1473 link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/apps/openssl.cnf
   1474 
   1475 $(BLDDIR)/util/opensslwrap.sh: Makefile
   1476 	@if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
   1477 	    mkdir -p "$(BLDDIR)/util"; \
   1478 	    ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \
   1479 	fi
   1480 
   1481 $(BLDDIR)/apps/openssl.cnf: Makefile
   1482 	@if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
   1483 	    mkdir -p "$(BLDDIR)/apps"; \
   1484 	    ln -sf "../$(SRCDIR)/apps/`basename "$@"`" "$(BLDDIR)/apps"; \
   1485 	fi
   1486 
   1487 FORCE:
   1488 
   1489 # Building targets ###################################################
   1490 
   1491 Makefile: configdata.pm \
   1492           {- join(" \\\n" . ' ' x 10,
   1493                   fill_lines(" ", $COLUMNS - 10,
   1494                              @{$config{build_file_templates}})) -}
   1495 	@echo "Detected changed: $?"
   1496 	$(PERL) configdata.pm
   1497 	@echo "**************************************************"
   1498 	@echo "***                                            ***"
   1499 	@echo "***   Please run the same make command again   ***"
   1500 	@echo "***                                            ***"
   1501 	@echo "**************************************************"
   1502 	@false
   1503 
   1504 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \
   1505                {- join(" \\\n" . ' ' x 15,
   1506                        fill_lines(" ", $COLUMNS - 15,
   1507                                   @{$config{build_infos}},
   1508                                   @{$config{conf_files}})) -}
   1509 	@echo "Detected changed: $?"
   1510 	$(PERL) configdata.pm -r
   1511 	@echo "**************************************************"
   1512 	@echo "***                                            ***"
   1513 	@echo "***   Please run the same make command again   ***"
   1514 	@echo "***                                            ***"
   1515 	@echo "**************************************************"
   1516 	@false
   1517 
   1518 reconfigure reconf:
   1519 	$(PERL) configdata.pm -r
   1520 
   1521 {-
   1522   use File::Basename;
   1523   use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
   1524 
   1525   # Helper function to convert dependencies in platform agnostic form to
   1526   # dependencies in platform form.
   1527   sub compute_platform_depends {
   1528       map { my $x = $_;
   1529 
   1530             grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
   1531             or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
   1532             or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
   1533             or platform->convertext($x); } @_;
   1534   }
   1535 
   1536   # Helper function to figure out dependencies on libraries
   1537   # It takes a list of library names and outputs a list of dependencies
   1538   sub compute_lib_depends {
   1539       # Depending on shared libraries:
   1540       # On Windows POSIX layers, we depend on {libname}.dll.a
   1541       # On Unix platforms, we depend on {shlibname}.so
   1542       return map { platform->sharedlib_simple($_)
   1543                    // platform->sharedlib_import($_)
   1544                    // platform->sharedlib($_)
   1545                    // platform->staticlib($_)
   1546                  } @_;
   1547   }
   1548 
   1549   sub generatetarget {
   1550       my %args = @_;
   1551       my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
   1552       return <<"EOF";
   1553 $args{target}: $deps
   1554 EOF
   1555   }
   1556 
   1557   sub generatesrc {
   1558       my %args = @_;
   1559       my $gen0 = $args{generator}->[0];
   1560       my $gen_args = join('', map { " $_" }
   1561                               @{$args{generator}}[1..$#{$args{generator}}]);
   1562       my $gen_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
   1563       my $incs = join("", map { " -I".$_ } @{$args{incs}});
   1564       my $defs = join("", map { " -D".$_ } @{$args{defs}});
   1565       my $deps = join(" ", compute_platform_depends(@{$args{generator_deps}},
   1566                                                     @{$args{deps}}));
   1567 
   1568       if ($args{src} =~ /\.html$/) {
   1569           #
   1570           # HTML generator
   1571           #
   1572           my $title = basename($args{src}, ".html");
   1573           my $pod = $gen0;
   1574           return <<"EOF";
   1575 $args{src}: $pod
   1576 	\$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
   1577 EOF
   1578       } elsif ($args{src} =~ /\.(\d)$/) {
   1579           #
   1580           # Man-page generator
   1581           #
   1582           my $section = $1;
   1583           my $name = uc basename($args{src}, ".$section");
   1584           my $pod = $gen0;
   1585           return <<"EOF";
   1586 $args{src}: $pod
   1587 	pod2man --name=$name --section=$section\$(MANSUFFIX) --center=OpenSSL \\
   1588 		--date=\$(RELEASE_DATE) --release=\$(VERSION) \\
   1589 		$pod >\$\@
   1590 EOF
   1591       } elsif (platform->isdef($args{src})) {
   1592           #
   1593           # Linker script-ish generator
   1594           #
   1595           my $target = platform->def($args{src});
   1596           (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
   1597           my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
   1598           my $ord_name = $args{generator}->[1] || $args{product};
   1599           return <<"EOF";
   1600 $target: $gen0 $deps \$(SRCDIR)/util/mkdef.pl
   1601 	\$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --type $args{intent} --ordinals $gen0  --name $ord_name --OS $mkdef_os > $target
   1602 EOF
   1603       } elsif (platform->isasm($args{src})
   1604                || platform->iscppasm($args{src})) {
   1605           #
   1606           # Assembler generator
   1607           #
   1608           my $cppflags = {
   1609               shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
   1610               lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
   1611               dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
   1612               bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
   1613           } -> {$args{intent}};
   1614 
   1615           my $generator;
   1616           if ($gen0 =~ /\.pl$/) {
   1617               $generator = 'CC="$(CC)" $(PERL)'.$gen_incs.' '.$gen0.$gen_args
   1618                   .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)';
   1619           } elsif ($gen0 =~ /\.m4$/) {
   1620               $generator = 'm4 -B 8192'.$gen_incs.' '.$gen0.$gen_args.' >'
   1621           } elsif ($gen0 =~ /\.S$/) {
   1622               $generator = undef;
   1623           } else {
   1624               die "Generator type for $args{src} unknown: $gen0\n";
   1625           }
   1626 
   1627           if (defined($generator)) {
   1628               return <<"EOF";
   1629 $args{src}: $gen0 $deps
   1630 	$generator \$@
   1631 EOF
   1632           }
   1633           return <<"EOF";
   1634 $args{src}: $gen0 $deps
   1635 	\$(CC) $incs $cppflags $defs -E $gen0 | \\
   1636 	\$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
   1637 EOF
   1638       } elsif ($gen0 =~ m|^.*\.in$|) {
   1639           #
   1640           # "dofile" generator (file.in -> file)
   1641           #
   1642           my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
   1643                                                "util", "dofile.pl")),
   1644                                rel2abs($config{builddir}));
   1645           my @perlmodules = ();
   1646           my %perlmoduleincs = ();
   1647           my %perlmoduledeps = ();
   1648           foreach my $x (('configdata.pm', @{$args{deps}})) {
   1649               # Compute (i)nclusion directory, (m)odule name and (d)ependency
   1650               my $i, $m, $d;
   1651               if ($x =~ /\|/) {
   1652                   $i = $`;
   1653                   $d = $';
   1654 
   1655                   # Massage the module part to become a real perl module spec
   1656                   $m = $d;
   1657                   $m =~ s|\.pm$||;
   1658                   # Directory specs are :: in perl package names
   1659                   $m =~ s|/|::|g;
   1660 
   1661                   # Full file name of the dependency
   1662                   $d = catfile($i, $d) if $i;
   1663               } elsif ($x =~ /\.pm$/) {
   1664                   $i = dirname($x);
   1665                   $m = basename($x, '.pm');
   1666                   $d = $x;
   1667               } else {
   1668                   # All other dependencies are simply collected
   1669                   $d = $x;
   1670               }
   1671               push @perlmodules, '"-M'.$m.'"' if $m;
   1672               $perlmoduledeps{$d} = 1;
   1673               $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i;
   1674           }
   1675 
   1676           # Because of the special treatment of dependencies, we need to
   1677           # recompute $deps completely
   1678           my $deps
   1679               = join(" ", compute_platform_depends(@{$args{generator_deps}},
   1680                                                    sort keys %perlmoduledeps));
   1681           my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules);
   1682 
   1683           return <<"EOF";
   1684 $args{src}: $gen0 $deps
   1685 	\$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@
   1686 EOF
   1687       } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
   1688           #
   1689           # Generic generator using OpenSSL programs
   1690           #
   1691 
   1692           # Redo $gen0, to ensure that we have the proper extension where
   1693           # necessary.
   1694           $gen0 = platform->bin($gen0);
   1695           # Use $(PERL) to execute wrap.pl directly to avoid calling env
   1696           return <<"EOF";
   1697 $args{src}: $gen0 $deps \$(BLDDIR)/util/wrap.pl
   1698 	\$(PERL) \$(BLDDIR)/util/wrap.pl $gen0$gen_args > \$@
   1699 EOF
   1700       } else {
   1701           #
   1702           # Generic generator using Perl
   1703           #
   1704           return <<"EOF";
   1705 $args{src}: $gen0 $deps
   1706 	\$(PERL)$gen_incs $gen0$gen_args > \$@
   1707 EOF
   1708       }
   1709   }
   1710 
   1711   # Should one wonder about the end of the Perl snippet, it's because this
   1712   # second regexp eats up line endings as well, if the removed path is the
   1713   # last in the line.  We may therefore need to put back a line ending.
   1714   sub src2obj {
   1715       my %args = @_;
   1716       my $obj = platform->convertext($args{obj});
   1717       my $dep = platform->dep($args{obj});
   1718       my @srcs = @{$args{srcs}};
   1719       my $srcs = join(" ",  @srcs);
   1720       my $deps = join(" ", @srcs, @{$args{deps}});
   1721       my $incs = join("", map { " -I".$_ } @{$args{incs}});
   1722       my $defs = join("", map { " -D".$_ } @{$args{defs}});
   1723       my $cmd;
   1724       my $cmdflags;
   1725       my $cmdcompile;
   1726       if (grep /\.rc$/, @srcs) {
   1727           $cmd = '$(RC)';
   1728           $cmdflags = '$(RCFLAGS)';
   1729           $cmdcompile = '';
   1730       } elsif (grep /\.(cc|cpp)$/, @srcs) {
   1731           $cmd = '$(CXX)';
   1732           $cmdcompile = ' -c';
   1733           $cmdflags = {
   1734               shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
   1735               lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
   1736               dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
   1737               bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
   1738           } -> {$args{intent}};
   1739       } else {
   1740           $cmd = '$(CC)';
   1741           $cmdcompile = ' -c';
   1742           $cmdflags = {
   1743               shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
   1744               lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
   1745               dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
   1746               bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
   1747           } -> {$args{intent}};
   1748       }
   1749       my $recipe;
   1750       # extension-specific rules
   1751       if (grep /\.s$/, @srcs) {
   1752           $recipe .= <<"EOF";
   1753 $obj: $deps
   1754 	$cmd $cmdflags -c -o \$\@ $srcs
   1755 EOF
   1756       } elsif (grep /\.S$/, @srcs) {
   1757           # Originally there was multi-step rule with $(CC) -E file.S
   1758           # followed by $(CC) -c file.s. It compensated for one of
   1759           # legacy platform compiler's inability to handle .S files.
   1760           # The platform is long discontinued by vendor so there is
   1761           # hardly a point to drag it along...
   1762           $recipe .= <<"EOF";
   1763 $obj: $deps
   1764 	$cmd $incs $defs $cmdflags -c -o \$\@ $srcs
   1765 EOF
   1766       } elsif ($makedep_scheme eq 'gcc' && !grep /\.rc$/, @srcs) {
   1767           $recipe .= <<"EOF";
   1768 $obj: $deps
   1769 	$cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -c -o \$\@ $srcs
   1770 	\@touch $dep.tmp
   1771 	\@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
   1772 		rm -f $dep.tmp; \\
   1773 	else \\
   1774 		mv $dep.tmp $dep; \\
   1775 	fi
   1776 EOF
   1777       } else {
   1778           $recipe .= <<"EOF";
   1779 $obj: $deps
   1780 	$cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
   1781 EOF
   1782           if ($makedep_scheme eq 'makedepend') {
   1783               $recipe .= <<"EOF";
   1784 	\$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
   1785 	    > $dep
   1786 EOF
   1787           }
   1788       }
   1789       return $recipe;
   1790   }
   1791   # We *know* this routine is only called when we've configure 'shared'.
   1792   sub obj2shlib {
   1793       my %args = @_;
   1794       my @linkdirs = ();
   1795       my @linklibs = ();
   1796       foreach (@{$args{deps}}) {
   1797           if (platform->isstaticlib($_)) {
   1798               push @linklibs, platform->convertext($_);
   1799           } else {
   1800               my $d = "-L" . dirname($_);
   1801               my $l = basename($_);
   1802               $l =~ s/^lib//;
   1803               $l = "-l" . $l;
   1804               push @linklibs, $l;
   1805               push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
   1806           }
   1807       }
   1808       my $linkflags = join("", map { $_." " } @linkdirs);
   1809       my $linklibs = join("", map { $_." " } @linklibs);
   1810       my @objs = map { platform->convertext($_) }
   1811                  grep { !platform->isdef($_) }
   1812                  @{$args{objs}};
   1813       my @defs = map { platform->def($_) }
   1814                  grep { platform->isdef($_) }
   1815                  @{$args{objs}};
   1816       my @deps = compute_lib_depends(@{$args{deps}});
   1817       die "More than one exported symbol map" if scalar @defs > 1;
   1818 
   1819       my $full = platform->sharedlib($args{lib});
   1820       # $import is for Windows and subsystems thereof, where static import
   1821       # libraries for DLLs are a thing.  On platforms that have this mechanism,
   1822       # $import has the name of this import library.  On platforms that don't
   1823       # have this mechanism, $import will be |undef|.
   1824       # It's also used on AIX in solib mode, which creates import libraries
   1825       # for the shared libraries.
   1826       my $import = platform->sharedlib_import($args{lib});
   1827       # $simple is for platforms where full shared library names include the
   1828       # shared library version, and there's a simpler name that doesn't include
   1829       # that version.  On such platforms, $simple has the simpler name.  On
   1830       # other platforms, it will be |undef|.
   1831       my $simple = platform->sharedlib_simple($args{lib});
   1832 
   1833       my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef;
   1834       my $shared_soname = "";
   1835       $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
   1836           if defined $target{shared_sonameflag};
   1837       my $shared_imp = "";
   1838       $shared_imp .= ' '.$target{shared_impflag}.basename($import)
   1839           if defined $target{shared_impflag} && defined $import;
   1840       my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
   1841 
   1842       # There is at least one platform where the compiler-as-linker needs to
   1843       # have one object file directly on the command line.  That won't hurt
   1844       # any other platform, so we do that for everyone when there's an argfile
   1845       # to be had.  This depends heavily on splice, which removes elements from
   1846       # the given array, and returns them so they can be captured.
   1847       my @argfileobjs = $argfile
   1848           ? splice(@objs, 1)
   1849           : ();
   1850       my $argfilecmds = $argfile
   1851           ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs)
   1852           : undef;
   1853       my $argfiledeps = $argfile
   1854           ? join(" \\\n" . ' ' x (length($argfile) + 2),
   1855                  fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs))
   1856           : undef;
   1857       my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps);
   1858       my @fullobjs = (
   1859           @objs,
   1860           ($argfile ? $target{shared_argfileflag}.$argfile : ())
   1861       );
   1862       my $fulldeps =
   1863           join(" \\\n" . ' ' x (length($full) + 2),
   1864                fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps));
   1865       my $fullobjs =
   1866           join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs));
   1867 
   1868       my $recipe = '';
   1869 
   1870       if (defined $simple && $simple ne $full) {
   1871           if (sharedaix()) {
   1872               $recipe .= <<"EOF";
   1873 $simple: $full
   1874 	rm -f $simple && \\
   1875 	\$(AR) r $simple $full
   1876 EOF
   1877           } else {
   1878               $recipe .= <<"EOF";
   1879 $simple: $full
   1880 	rm -f $simple && \\
   1881 	ln -s $full $simple
   1882 EOF
   1883           }
   1884       }
   1885       if (defined $import) {
   1886           if (sharedaix_solib()) {
   1887               $recipe .= <<"EOF";
   1888 $import: $full $defs[0]
   1889 	rm -f $import && \\
   1890 	echo \\#!$full > $import && \\
   1891         cat $defs[0] >>$import
   1892 EOF
   1893           } else {
   1894       $recipe .= <<"EOF";
   1895 $import: $full
   1896 EOF
   1897           }
   1898       }
   1899       $recipe .= <<"EOF";
   1900 $full: $fulldeps
   1901 	\$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
   1902 		-o $full$shared_def \\
   1903 		$fullobjs \\
   1904 		$linklibs \$(LIB_EX_LIBS)
   1905 EOF
   1906       if (windowsdll()) {
   1907           $recipe .= <<"EOF";
   1908 	rm -f apps/$full
   1909 	rm -f fuzz/$full
   1910 	cp -p $full apps/
   1911 	cp -p $full fuzz/
   1912 EOF
   1913           if (!$disabled{tests}) {
   1914             $recipe .= <<"EOF";
   1915 	rm -f test/$full
   1916 	cp -p $full test/
   1917 EOF
   1918           }
   1919       }
   1920       $recipe .= <<"EOF" if defined $argfile;
   1921 $argfile: $argfiledeps
   1922 	\$(RM) $argfile
   1923 	$argfilecmds
   1924 EOF
   1925       return $recipe;
   1926   }
   1927   sub obj2dso {
   1928       my %args = @_;
   1929       my $dso = platform->dso($args{module});
   1930       my @linkdirs = ();
   1931       my @linklibs = ();
   1932       foreach (@{$args{deps}}) {
   1933           next unless defined $_;
   1934           if (platform->isstaticlib($_)) {
   1935               push @linklibs, platform->convertext($_);
   1936           } else {
   1937               my $d = "-L" . dirname($_);
   1938               my $l = basename($_);
   1939               $l =~ s/^lib//;
   1940               $l = "-l" . $l;
   1941               push @linklibs, $l;
   1942               push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
   1943           }
   1944       }
   1945       my $linkflags = join("", map { $_." " } @linkdirs);
   1946       my $linklibs = join("", map { $_." " } @linklibs);
   1947       my @objs = map { platform->convertext($_) }
   1948                  grep { !platform->isdef($_) }
   1949                  @{$args{objs}};
   1950       my @defs = map { platform->def($_) }
   1951                  grep { platform->isdef($_) }
   1952                  @{$args{objs}};
   1953       my @deps = compute_lib_depends(@{$args{deps}});
   1954       my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
   1955       # Next line needs to become "less magic" (see PR #11950)
   1956       $shared_def .= ' '.$target{shared_fipsflag} if (defined $target{shared_fipsflag} && $shared_def =~ m/providers\/fips/);
   1957       my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
   1958       my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
   1959                       fill_lines(' ', $COLUMNS - length($dso) - 2,
   1960                                  @objs, @defs, @deps));
   1961 
   1962       return <<"EOF";
   1963 $dso: $deps
   1964 	\$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
   1965 		-o $dso$shared_def \\
   1966 		$objs \\
   1967 		$linklibs\$(DSO_EX_LIBS)
   1968 EOF
   1969   }
   1970   sub obj2lib {
   1971       my %args = @_;
   1972       my $lib = platform->staticlib($args{lib});
   1973       my @objs = map { platform->obj($_) } @{$args{objs}};
   1974       my $deps = join(" \\\n" . ' ' x (length($lib) + 2),
   1975                       fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
   1976       my $max_per_call = 500;
   1977       my @objs_grouped;
   1978       push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs;
   1979       my $fill_lib =
   1980           join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped));
   1981       return <<"EOF";
   1982 $lib: $deps
   1983 	\$(RM) $lib
   1984 	$fill_lib
   1985 	\$(RANLIB) \$\@ || echo Never mind.
   1986 EOF
   1987   }
   1988   sub obj2bin {
   1989       my %args = @_;
   1990       my $bin = platform->bin($args{bin});
   1991       my @objs = map { platform->obj($_) } @{$args{objs}};
   1992       my @deps = compute_lib_depends(@{$args{deps}});
   1993       my $objs = join(" \\\n" . ' ' x (length($bin) + 2),
   1994                       fill_lines(' ', $COLUMNS - length($bin) - 2, @objs));
   1995       my @linkdirs = ();
   1996       my @linklibs = ();
   1997       foreach (@{$args{deps}}) {
   1998           next unless defined $_;
   1999           if (platform->isstaticlib($_)) {
   2000               push @linklibs, platform->convertext($_);
   2001           } else {
   2002               my $d = "-L" . dirname($_);
   2003               my $l = basename($_);
   2004               $l =~ s/^lib//;
   2005               $l = "-l" . $l;
   2006               push @linklibs, $l;
   2007               push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
   2008           }
   2009       }
   2010       my $linkflags = join("", map { $_." " } @linkdirs);
   2011       my $linklibs = join("", map { $_." " } @linklibs);
   2012       my $cmd = '$(CC)';
   2013       my $cmdflags = '$(BIN_CFLAGS)';
   2014       if (grep /_cc\.o$/, @{$args{objs}}) {
   2015           $cmd = '$(CXX)';
   2016           $cmdflags = '$(BIN_CXXFLAGS)';
   2017       }
   2018 
   2019       my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
   2020       my $deps = join(" \\\n" . ' ' x (length($bin) + 2),
   2021                       fill_lines(' ', $COLUMNS - length($bin) - 2,
   2022                                  @objs, @deps));
   2023 
   2024       return <<"EOF";
   2025 $bin: $deps
   2026 	rm -f $bin
   2027 	\$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
   2028 		-o $bin \\
   2029 		$objs \\
   2030 		$linklibs\$(BIN_EX_LIBS)
   2031 EOF
   2032   }
   2033   sub in2script {
   2034       my %args = @_;
   2035       my $script = $args{script};
   2036       my $sources = join(" ", @{$args{sources}});
   2037       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
   2038                                            "util", "dofile.pl")),
   2039                            rel2abs($config{builddir}));
   2040       return <<"EOF";
   2041 $script: $sources configdata.pm
   2042 	\$(RM) "$script"
   2043 	\$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
   2044 	    "-o$target{build_file}" $sources > "$script"
   2045 	chmod a+x $script
   2046 EOF
   2047   }
   2048   sub generatedir {
   2049       my %args = @_;
   2050       my $dir = $args{dir};
   2051       my @deps = compute_platform_depends(@{$args{deps}});
   2052       my @comments = ();
   2053 
   2054       # We already have a 'test' target, and the top directory is just plain
   2055       # silly
   2056       return if $dir eq "test" || $dir eq ".";
   2057 
   2058       foreach my $type (("dso", "lib", "bin", "script")) {
   2059           next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
   2060           # For lib object files, we could update the library.  However, it
   2061           # was decided that it's enough to build the directory local object
   2062           # files, so we don't need to add any actions, and the dependencies
   2063           # are already taken care of.
   2064           if ($type ne "lib") {
   2065               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
   2066                   if (dirname($prod) eq $dir) {
   2067                       push @deps, compute_platform_depends($prod);
   2068                   } else {
   2069                       push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
   2070                   }
   2071               }
   2072           }
   2073       }
   2074 
   2075       my $target = "$dir $dir/";
   2076       my $deps = join(" \\\n\t",
   2077                       fill_lines(' ', $COLUMNS - 8, @deps));
   2078       my $comments = join("\n", "", @comments);
   2079       return <<"EOF";
   2080 $target: \\
   2081 	$deps$comments
   2082 EOF
   2083   }
   2084   ""    # Important!  This becomes part of the template result.
   2085 -}
   2086