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