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