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