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