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