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