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