]> git.ipfire.org Git - thirdparty/openssl.git/blame_incremental - Configurations/unix-Makefile.tmpl
Fix typos found by codespell
[thirdparty/openssl.git] / Configurations / unix-Makefile.tmpl
... / ...
CommitLineData
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-}
63PLATFORM={- $config{target} -}
64OPTIONS={- $config{options} -}
65CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
66SRCDIR={- $config{sourcedir} -}
67BLDDIR={- $config{builddir} -}
68FIPSKEY={- $config{FIPSKEY} -}
69
70VERSION={- "$config{full_version}" -}
71VERSION_NUMBER={- "$config{version}" -}
72MAJOR={- $config{major} -}
73MINOR={- $config{minor} -}
74SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
75SHLIB_TARGET={- $target{shared_target} -}
76
77LIBS={- join(" \\\n" . ' ' x 5,
78 fill_lines(" ", $COLUMNS - 5,
79 map { platform->staticlib($_) // () }
80 @{$unified_info{libraries}})) -}
81SHLIBS={- join(" \\\n" . ' ' x 7,
82 fill_lines(" ", $COLUMNS - 7,
83 map { platform->sharedlib($_) // () }
84 @{$unified_info{libraries}})) -}
85SHLIB_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}})) -}
92MODULES={- 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}})) -}
101FIPSMODULE={- # 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) -}
109FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1;
110 join(" ", map { basename(platform->dso($_)) } @fipsmodules) -}
111
112PROGRAMS={- join(" \\\n" . ' ' x 9,
113 fill_lines(" ", $COLUMNS - 9,
114 map { platform->bin($_) }
115 @{$unified_info{programs}})) -}
116SCRIPTS={- join(" \\\n" . ' ' x 8,
117 fill_lines(" ", $COLUMNS - 8, @{$unified_info{scripts}})) -}
118{- output_off() if $disabled{makedepend}; "" -}
119DEPS={- 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}; "" -}
125GENERATED_MANDATORY={- join(" \\\n" . ' ' x 20,
126 fill_lines(" ", $COLUMNS - 20,
127 @{$unified_info{depends}->{""}})) -}
128GENERATED_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)) -}
141GENERATED={- # common0.tmpl provides @generated
142 join(" \\\n" . ' ' x 5,
143 fill_lines(" ", $COLUMNS - 5,
144 map { platform->convertext($_) } @generated )) -}
145
146INSTALL_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-}
153INSTALL_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-}
160INSTALL_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-}
170INSTALL_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-}
178INSTALL_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-}
187INSTALL_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-}
195INSTALL_FIPSMODULECONF=providers/fipsmodule.cnf
196INSTALL_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-}
202BIN_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-}
211MISC_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-}
220IMAGEDOCS1={-
221 join(" \\\n" . ' ' x 10,
222 fill_lines(" ", $COLUMNS - 10,
223 @{$unified_info{imagedocs}->{man1}})) -}
224IMAGEDOCS3={-
225 join(" \\\n" . ' ' x 10,
226 fill_lines(" ", $COLUMNS - 10,
227 @{$unified_info{imagedocs}->{man3}})) -}
228IMAGEDOCS5={-
229 join(" \\\n" . ' ' x 10,
230 fill_lines(" ", $COLUMNS - 10,
231 @{$unified_info{imagedocs}->{man5}})) -}
232IMAGEDOCS7={-
233 join(" \\\n" . ' ' x 10,
234 fill_lines(" ", $COLUMNS - 10,
235 @{$unified_info{imagedocs}->{man7}})) -}
236HTMLDOCS1={-
237 join(" \\\n" . ' ' x 10,
238 fill_lines(" ", $COLUMNS - 10,
239 @{$unified_info{htmldocs}->{man1}})) -}
240HTMLDOCS3={-
241 join(" \\\n" . ' ' x 10,
242 fill_lines(" ", $COLUMNS - 10,
243 @{$unified_info{htmldocs}->{man3}})) -}
244HTMLDOCS5={-
245 join(" \\\n" . ' ' x 10,
246 fill_lines(" ", $COLUMNS - 10,
247 @{$unified_info{htmldocs}->{man5}})) -}
248HTMLDOCS7={-
249 join(" \\\n" . ' ' x 10,
250 fill_lines(" ", $COLUMNS - 10,
251 @{$unified_info{htmldocs}->{man7}})) -}
252MANDOCS1={-
253 join(" \\\n" . ' ' x 9,
254 fill_lines(" ", $COLUMNS - 9,
255 @{$unified_info{mandocs}->{man1}})) -}
256MANDOCS3={-
257 join(" \\\n" . ' ' x 9,
258 fill_lines(" ", $COLUMNS - 9,
259 @{$unified_info{mandocs}->{man3}})) -}
260MANDOCS5={-
261 join(" \\\n" . ' ' x 9,
262 fill_lines(" ", $COLUMNS - 9,
263 @{$unified_info{mandocs}->{man5}})) -}
264MANDOCS7={-
265 join(" \\\n" . ' ' x 9,
266 fill_lines(" ", $COLUMNS - 9,
267 @{$unified_info{mandocs}->{man7}})) -}
268
269APPS_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.
275DESTDIR=
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
279INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
280 #
281 our $prefix = $config{prefix} || "/usr/local";
282 $prefix -}
283OPENSSLDIR={- #
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 -}
300LIBDIR={- 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
306libdir={- file_name_is_absolute($libdir)
307 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
308ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
309MODULESDIR=$(libdir)/ossl-modules
310
311# Convenience variable for those who want to set the rpath in shared
312# libraries and applications
313LIBRPATH=$(libdir)
314
315BINDIR={- our $bindir = $config{bindir};
316 unless ($bindir) {
317 $bindir = "bin$target{multibin}";
318 }
319 file_name_is_absolute($bindir) ? "" : $bindir -}
320bindir={- file_name_is_absolute($bindir)
321 ? $bindir : '$(INSTALLTOP)/$(BINDIR)' -}
322
323MANDIR=$(INSTALLTOP)/share/man
324DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
325HTMLDIR=$(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.
330MANSUFFIX=ossl
331HTMLSUFFIX=html
332
333# For "optional" echo messages, to get "real" silence
334ECHO = 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
345CROSS_COMPILE={- $config{CROSS_COMPILE} -}
346CC=$(CROSS_COMPILE){- $config{CC} -}
347CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
348CPPFLAGS={- our $cppflags1 = join(" ",
349 (map { "-D".$_} @{$config{CPPDEFINES}}),
350 (map { "-I".$_} @{$config{CPPINCLUDES}}),
351 @{$config{CPPFLAGS}}) -}
352CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
353CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
354LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
355EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
356
357MAKEDEPEND={- $config{makedepcmd} -}
358
359PERL={- $config{PERL} -}
360
361AR=$(CROSS_COMPILE){- $config{AR} -}
362ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
363RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
364RC= $(CROSS_COMPILE){- $config{RC} -}
365RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
366
367RM= rm -f
368RMDIR= rmdir
369TAR= {- $target{TAR} || "tar" -}
370TARFLAGS= {- $target{TARFLAGS} -}
371
372BASENAME= openssl
373NAME= $(BASENAME)-$(VERSION)
374# Relative to $(SRCDIR)
375TARFILE= ../$(NAME).tar
376
377##### Project flags ##################################################
378
379# Variables starting with CNF_ are common variables for all product types
380
381CNF_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}}) -}
388CNF_CFLAGS={- join(' ', $target{cflags} || (),
389 @{$config{cflags}}) -}
390CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
391 @{$config{cxxflags}}) -}
392CNF_LDFLAGS={- join(' ', $target{lflags} || (),
393 @{$config{lflags}}) -}
394CNF_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
403LIB_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)') -}
424LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
425 $target{shared_cflag} || (),
426 @{$config{lib_cflags}},
427 @{$config{shared_cflag}},
428 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
429LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
430 $target{shared_cxxflag} || (),
431 @{$config{lib_cxxflags}},
432 @{$config{shared_cxxflag}},
433 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
434LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
435 $config{shared_ldflag} || (),
436 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
437LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
438DSO_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)') -}
453DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
454 $target{module_cflags} || (),
455 @{$config{dso_cflags}},
456 @{$config{module_cflags}},
457 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
458DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
459 $target{module_cxxflags} || (),
460 @{$config{dso_cxxflags}},
461 @{$config{module_cxxflag}},
462 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
463DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
464 $target{module_ldflags} || (),
465 @{$config{dso_ldflags}},
466 @{$config{module_ldflags}},
467 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
468DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
469BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
470 (map { '-D'.$_ } @{$config{bin_defines} || ()}),
471 @{$config{bin_cppflags}},
472 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
473BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
474 @{$config{bin_cflags}},
475 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
476BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
477 @{$config{bin_cxxflags}},
478 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
479BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
480 @{$config{bin_lflags}},
481 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
482BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
483
484# CPPFLAGS_Q is used for one thing only: to build up buildinf.h
485CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
486 $cppflags2 =~ s|([\\"])|\\$1|g;
487 $lib_cppflags =~ s|([\\"])|\\$1|g;
488 join(' ', $lib_cppflags || (), $cppflags2 || (),
489 $cppflags1 || ()) -}
490
491PERLASM_SCHEME= {- $target{perlasm_scheme} -}
492
493# For x86 assembler: Set PROCESSOR to 386 if you want to support
494# the 80386.
495PROCESSOR= {- $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...
502LC_ALL=C
503LC_MESSAGES=C
504LANG=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
515all: build_sw build_docs ## Build software and documentation
516
517##@ Documentation
518build_generated_pods: $(GENERATED_PODS)
519build_docs: build_man_docs build_html_docs ## Create documentation
520build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) ## Create manpages
521build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) ## Create HTML documentation
522
523build_generated: $(GENERATED_MANDATORY)
524build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
525build_modules_nodep: $(MODULES)
526build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
527
528# Kept around for backward compatibility
529build_apps build_tests: build_programs
530
531# Convenience target to prebuild all generated files, not just the mandatory
532# ones
533build_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
542help: ## Show this help screen
543 @$(PERL) $(SRCDIR)/util/help.pl $(BLDDIR)/Makefile
544
545##@ Testing
546test: tests ## Run tests (alias of "tests")
547{- dependmagic('tests', 'Run tests'); -}: build_programs_nodep build_modules_nodep link-utils run_tests
548run_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
560list-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
569libclean:
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
592clean: 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
612distclean: 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.
619depend: 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
627install: install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -} ## Install software and documentation, create OpenSSL directories
628
629uninstall: uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -} ## Uninstall software and documentation
630
631install_sw: install_dev install_engines install_modules install_runtime ## Install just the software and libraries
632
633uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev ## Uninstall the software and libraries
634
635install_docs: install_man_docs install_html_docs ## Install manpages and HTML documentation
636
637uninstall_docs: uninstall_man_docs uninstall_html_docs ## Uninstall manpages and HTML documentation
638 $(RM) -r $(DESTDIR)$(DOCDIR)
639
640{- output_off() if $disabled{fips}; "" -}
641install_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
655uninstall_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(); } "" -}
661install_fips:
662 @$(ECHO) "The 'install_fips' target requires the 'enable-fips' option"
663
664uninstall_fips:
665 @$(ECHO) "The 'uninstall_fips' target requires the 'enable-fips' option"
666{- output_on() if !$disabled{fips}; "" -}
667
668
669install_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
714install_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
790uninstall_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
840install_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
854uninstall_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
864install_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
878uninstall_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
888install_runtime: install_programs
889
890install_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
916install_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
939uninstall_runtime: uninstall_programs uninstall_runtime_libs
940
941uninstall_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
959uninstall_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
971install_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
1011uninstall_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
1042install_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
1078uninstall_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
1105install_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
1115uninstall_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 maintenance
1125
1126# It's important that generate_buildinfo comes after ordinals, as ordinals
1127# is sensitive to build.info changes.
1128update: 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
1132generate: 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
1136generate_buildinfo: generate_doc_buildinfo
1137
1138.PHONY: doc-nits md-nits
1139doc-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
1148md-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
1156lint: ## 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
1162check-format: ## Evaluate C code according to OpenSSL coding standards
1163 ( cd $(SRCDIR); $(PERL) util/check-format.pl \
1164 $(SRCS) \$(CRYPTOHEADERS) $(SSLHEADERS) )
1165
1166generate_apps:
1167 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
1168 < apps/openssl.cnf > apps/openssl-vms.cnf )
1169
1170generate_crypto_bn:
1171 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
1172
1173generate_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
1192generate_crypto_conf:
1193 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
1194 > crypto/conf/conf_def.h )
1195
1196generate_crypto_asn1:
1197 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
1198 > crypto/asn1/charmap.h )
1199
1200generate_fuzz_oids:
1201 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
1202 crypto/objects/obj_dat.h \
1203 > fuzz/oids.txt )
1204
1205generate_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
1219generate_fips_sources: providers/fips.module.sources.new
1220providers/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
1271ERROR_REBUILD=
1272errors:
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-}
1341SRCS={-
1342sub uniq { my %seen; grep !$seen{$_}++, @_; }
1343sub flat(@) { return map { ref eq 'ARRAY' ? @$_ : $_ } @_; }
1344join(" \\\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-}
1349CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
1350 fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -}
1351SSLHEADERS={- join(" \\\n" . ' ' x 11,
1352 fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
1353
1354renumber: 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
1377ordinals: build_generated $(SRCDIR)/util/libcrypto.num $(SRCDIR)/util/libssl.num
1378
1379test_ordinals:
1380 $(MAKE) run_tests TESTS=test_ordinals
1381
1382tags TAGS: FORCE
1383 rm -f TAGS tags
1384 -( cd $(SRCDIR); util/ctags.sh )
1385 -etags `find . -name '*.[ch]' -o -name '*.pm'`
1386
1387providers/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
1399fips-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
1406update-fips-checksums: $(SRCDIR)/providers/fips.checksum
1407
1408diff-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
1415tar:
1416 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
1417
1418# Helper targets #####################################################
1419
1420link-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
1434FORCE:
1435
1436# Building targets ###################################################
1437
1438libcrypto.pc libssl.pc openssl.pc: Makefile $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
1439
1440libcrypto.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
1459libssl.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
1476openssl.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
1491Makefile: 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
1504configdata.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
1518reconfigure 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
1554EOF
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"
1577EOF
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 >\$\@
1589EOF
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
1601EOF
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 \$@
1630EOF
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' > \$@
1636EOF
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 = ();
1645 my %perlmoduleincs = ();
1646 my %perlmoduledeps = ();
1647 foreach my $x (('configdata.pm', @{$args{deps}})) {
1648 # Compute (i)nclusion directory, (m)odule name and (d)ependency
1649 my $i, $m, $d;
1650 if ($x =~ /\|/) {
1651 $i = $`;
1652 $d = $';
1653
1654 # Massage the module part to become a real perl module spec
1655 $m = $d;
1656 $m =~ s|\.pm$||;
1657 # Directory specs are :: in perl package names
1658 $m =~ s|/|::|g;
1659
1660 # Full file name of the dependency
1661 $d = catfile($i, $d) if $i;
1662 } elsif ($x =~ /\.pm$/) {
1663 $i = dirname($x);
1664 $m = basename($x, '.pm');
1665 $d = $x;
1666 } else {
1667 # All other dependencies are simply collected
1668 $d = $x;
1669 }
1670 push @perlmodules, '"-M'.$m.'"' if $m;
1671 $perlmoduledeps{$d} = 1;
1672 $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i;
1673 }
1674
1675 # Because of the special treatment of dependencies, we need to
1676 # recompute $deps completely
1677 my $deps
1678 = join(" ", compute_platform_depends(@{$args{generator_deps}},
1679 sort keys %perlmoduledeps));
1680 my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules);
1681
1682 return <<"EOF";
1683$args{src}: $gen0 $deps
1684 \$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@
1685EOF
1686 } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
1687 #
1688 # Generic generator using OpenSSL programs
1689 #
1690
1691 # Redo $gen0, to ensure that we have the proper extension where
1692 # necessary.
1693 $gen0 = platform->bin($gen0);
1694 # Use $(PERL) to execute wrap.pl directly to avoid calling env
1695 return <<"EOF";
1696$args{src}: $gen0 $deps \$(BLDDIR)/util/wrap.pl
1697 \$(PERL) \$(BLDDIR)/util/wrap.pl $gen0$gen_args > \$@
1698EOF
1699 } else {
1700 #
1701 # Generic generator using Perl
1702 #
1703 return <<"EOF";
1704$args{src}: $gen0 $deps
1705 \$(PERL)$gen_incs $gen0$gen_args > \$@
1706EOF
1707 }
1708 }
1709
1710 # Should one wonder about the end of the Perl snippet, it's because this
1711 # second regexp eats up line endings as well, if the removed path is the
1712 # last in the line. We may therefore need to put back a line ending.
1713 sub src2obj {
1714 my %args = @_;
1715 my $obj = platform->convertext($args{obj});
1716 my $dep = platform->dep($args{obj});
1717 my @srcs = @{$args{srcs}};
1718 my $srcs = join(" ", @srcs);
1719 my $deps = join(" ", @srcs, @{$args{deps}});
1720 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1721 my $defs = join("", map { " -D".$_ } @{$args{defs}});
1722 my $cmd;
1723 my $cmdflags;
1724 my $cmdcompile;
1725 if (grep /\.rc$/, @srcs) {
1726 $cmd = '$(RC)';
1727 $cmdflags = '$(RCFLAGS)';
1728 $cmdcompile = '';
1729 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1730 $cmd = '$(CXX)';
1731 $cmdcompile = ' -c';
1732 $cmdflags = {
1733 shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1734 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1735 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1736 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1737 } -> {$args{intent}};
1738 } else {
1739 $cmd = '$(CC)';
1740 $cmdcompile = ' -c';
1741 $cmdflags = {
1742 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1743 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1744 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1745 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1746 } -> {$args{intent}};
1747 }
1748 my $recipe;
1749 # extension-specific rules
1750 if (grep /\.s$/, @srcs) {
1751 $recipe .= <<"EOF";
1752$obj: $deps
1753 $cmd $cmdflags -c -o \$\@ $srcs
1754EOF
1755 } elsif (grep /\.S$/, @srcs) {
1756 # Originally there was multi-step rule with $(CC) -E file.S
1757 # followed by $(CC) -c file.s. It compensated for one of
1758 # legacy platform compiler's inability to handle .S files.
1759 # The platform is long discontinued by vendor so there is
1760 # hardly a point to drag it along...
1761 $recipe .= <<"EOF";
1762$obj: $deps
1763 $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
1764EOF
1765 } elsif ($makedep_scheme eq 'gcc' && !grep /\.rc$/, @srcs) {
1766 $recipe .= <<"EOF";
1767$obj: $deps
1768 $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs
1769 \@touch $dep.tmp
1770 \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
1771 rm -f $dep.tmp; \\
1772 else \\
1773 mv $dep.tmp $dep; \\
1774 fi
1775EOF
1776 } else {
1777 $recipe .= <<"EOF";
1778$obj: $deps
1779 $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
1780EOF
1781 if ($makedep_scheme eq 'makedepend') {
1782 $recipe .= <<"EOF";
1783 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1784 > $dep
1785EOF
1786 }
1787 }
1788 return $recipe;
1789 }
1790 # We *know* this routine is only called when we've configure 'shared'.
1791 sub obj2shlib {
1792 my %args = @_;
1793 my @linkdirs = ();
1794 my @linklibs = ();
1795 foreach (@{$args{deps}}) {
1796 if (platform->isstaticlib($_)) {
1797 push @linklibs, platform->convertext($_);
1798 } else {
1799 my $d = "-L" . dirname($_);
1800 my $l = basename($_);
1801 $l =~ s/^lib//;
1802 $l = "-l" . $l;
1803 push @linklibs, $l;
1804 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1805 }
1806 }
1807 my $linkflags = join("", map { $_." " } @linkdirs);
1808 my $linklibs = join("", map { $_." " } @linklibs);
1809 my @objs = map { platform->convertext($_) }
1810 grep { !platform->isdef($_) }
1811 @{$args{objs}};
1812 my @defs = map { platform->def($_) }
1813 grep { platform->isdef($_) }
1814 @{$args{objs}};
1815 my @deps = compute_lib_depends(@{$args{deps}});
1816 die "More than one exported symbol map" if scalar @defs > 1;
1817
1818 my $full = platform->sharedlib($args{lib});
1819 # $import is for Windows and subsystems thereof, where static import
1820 # libraries for DLLs are a thing. On platforms that have this mechanism,
1821 # $import has the name of this import library. On platforms that don't
1822 # have this mechanism, $import will be |undef|.
1823 my $import = platform->sharedlib_import($args{lib});
1824 # $simple is for platforms where full shared library names include the
1825 # shared library version, and there's a simpler name that doesn't include
1826 # that version. On such platforms, $simple has the simpler name. On
1827 # other platforms, it will be |undef|.
1828 my $simple = platform->sharedlib_simple($args{lib});
1829
1830 my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef;
1831 my $shared_soname = "";
1832 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
1833 if defined $target{shared_sonameflag};
1834 my $shared_imp = "";
1835 $shared_imp .= ' '.$target{shared_impflag}.basename($import)
1836 if defined $target{shared_impflag} && defined $import;
1837 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1838
1839 # There is at least one platform where the compiler-as-linker needs to
1840 # have one object file directly on the command line. That won't hurt
1841 # any other platform, so we do that for everyone when there's an argfile
1842 # to be had. This depends heavily on splice, which removes elements from
1843 # the given array, and returns them so they can be captured.
1844 my @argfileobjs = $argfile
1845 ? splice(@objs, 1)
1846 : ();
1847 my $argfilecmds = $argfile
1848 ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs)
1849 : undef;
1850 my $argfiledeps = $argfile
1851 ? join(" \\\n" . ' ' x (length($argfile) + 2),
1852 fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs))
1853 : undef;
1854 my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps);
1855 my @fullobjs = (
1856 @objs,
1857 ($argfile ? $target{shared_argfileflag}.$argfile : ())
1858 );
1859 my $fulldeps =
1860 join(" \\\n" . ' ' x (length($full) + 2),
1861 fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps));
1862 my $fullobjs =
1863 join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs));
1864
1865 my $recipe = '';
1866
1867 if (defined $simple && $simple ne $full) {
1868 if (sharedaix()) {
1869 $recipe .= <<"EOF";
1870$simple: $full
1871 rm -f $simple && \\
1872 \$(AR) r $simple $full
1873EOF
1874 } else {
1875 $recipe .= <<"EOF";
1876$simple: $full
1877 rm -f $simple && \\
1878 ln -s $full $simple
1879EOF
1880 }
1881 }
1882 if (defined $import) {
1883 $recipe .= <<"EOF";
1884$import: $full
1885EOF
1886 }
1887 $recipe .= <<"EOF";
1888$full: $fulldeps
1889 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1890 -o $full$shared_def \\
1891 $fullobjs \\
1892 $linklibs \$(LIB_EX_LIBS)
1893EOF
1894 if (windowsdll()) {
1895 $recipe .= <<"EOF";
1896 rm -f apps/$full
1897 rm -f fuzz/$full
1898 cp -p $full apps/
1899 cp -p $full fuzz/
1900EOF
1901 if (!$disabled{tests}) {
1902 $recipe .= <<"EOF";
1903 rm -f test/$full
1904 cp -p $full test/
1905EOF
1906 }
1907 }
1908 $recipe .= <<"EOF" if defined $argfile;
1909$argfile: $argfiledeps
1910 \$(RM) $argfile
1911 $argfilecmds
1912EOF
1913 return $recipe;
1914 }
1915 sub obj2dso {
1916 my %args = @_;
1917 my $dso = platform->dso($args{module});
1918 my @linkdirs = ();
1919 my @linklibs = ();
1920 foreach (@{$args{deps}}) {
1921 next unless defined $_;
1922 if (platform->isstaticlib($_)) {
1923 push @linklibs, platform->convertext($_);
1924 } else {
1925 my $d = "-L" . dirname($_);
1926 my $l = basename($_);
1927 $l =~ s/^lib//;
1928 $l = "-l" . $l;
1929 push @linklibs, $l;
1930 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1931 }
1932 }
1933 my $linkflags = join("", map { $_." " } @linkdirs);
1934 my $linklibs = join("", map { $_." " } @linklibs);
1935 my @objs = map { platform->convertext($_) }
1936 grep { !platform->isdef($_) }
1937 @{$args{objs}};
1938 my @defs = map { platform->def($_) }
1939 grep { platform->isdef($_) }
1940 @{$args{objs}};
1941 my @deps = compute_lib_depends(@{$args{deps}});
1942 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1943 # Next line needs to become "less magic" (see PR #11950)
1944 $shared_def .= ' '.$target{shared_fipsflag} if (defined $target{shared_fipsflag} && $shared_def =~ m/providers\/fips/);
1945 my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
1946 my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
1947 fill_lines(' ', $COLUMNS - length($dso) - 2,
1948 @objs, @defs, @deps));
1949
1950 return <<"EOF";
1951$dso: $deps
1952 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1953 -o $dso$shared_def \\
1954 $objs \\
1955 $linklibs\$(DSO_EX_LIBS)
1956EOF
1957 }
1958 sub obj2lib {
1959 my %args = @_;
1960 my $lib = platform->staticlib($args{lib});
1961 my @objs = map { platform->obj($_) } @{$args{objs}};
1962 my $deps = join(" \\\n" . ' ' x (length($lib) + 2),
1963 fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
1964 my $max_per_call = 500;
1965 my @objs_grouped;
1966 push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs;
1967 my $fill_lib =
1968 join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped));
1969 return <<"EOF";
1970$lib: $deps
1971 \$(RM) $lib
1972 $fill_lib
1973 \$(RANLIB) \$\@ || echo Never mind.
1974EOF
1975 }
1976 sub obj2bin {
1977 my %args = @_;
1978 my $bin = platform->bin($args{bin});
1979 my @objs = map { platform->obj($_) } @{$args{objs}};
1980 my @deps = compute_lib_depends(@{$args{deps}});
1981 my $objs = join(" \\\n" . ' ' x (length($bin) + 2),
1982 fill_lines(' ', $COLUMNS - length($bin) - 2, @objs));
1983 my @linkdirs = ();
1984 my @linklibs = ();
1985 foreach (@{$args{deps}}) {
1986 next unless defined $_;
1987 if (platform->isstaticlib($_)) {
1988 push @linklibs, platform->convertext($_);
1989 } else {
1990 my $d = "-L" . dirname($_);
1991 my $l = basename($_);
1992 $l =~ s/^lib//;
1993 $l = "-l" . $l;
1994 push @linklibs, $l;
1995 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1996 }
1997 }
1998 my $linkflags = join("", map { $_." " } @linkdirs);
1999 my $linklibs = join("", map { $_." " } @linklibs);
2000 my $cmd = '$(CC)';
2001 my $cmdflags = '$(BIN_CFLAGS)';
2002 if (grep /_cc\.o$/, @{$args{objs}}) {
2003 $cmd = '$(CXX)';
2004 $cmdflags = '$(BIN_CXXFLAGS)';
2005 }
2006
2007 my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
2008 my $deps = join(" \\\n" . ' ' x (length($bin) + 2),
2009 fill_lines(' ', $COLUMNS - length($bin) - 2,
2010 @objs, @deps));
2011
2012 return <<"EOF";
2013$bin: $deps
2014 rm -f $bin
2015 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
2016 -o $bin \\
2017 $objs \\
2018 $linklibs\$(BIN_EX_LIBS)
2019EOF
2020 }
2021 sub in2script {
2022 my %args = @_;
2023 my $script = $args{script};
2024 my $sources = join(" ", @{$args{sources}});
2025 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
2026 "util", "dofile.pl")),
2027 rel2abs($config{builddir}));
2028 return <<"EOF";
2029$script: $sources configdata.pm
2030 \$(RM) "$script"
2031 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
2032 "-o$target{build_file}" $sources > "$script"
2033 chmod a+x $script
2034EOF
2035 }
2036 sub generatedir {
2037 my %args = @_;
2038 my $dir = $args{dir};
2039 my @deps = compute_platform_depends(@{$args{deps}});
2040 my @comments = ();
2041
2042 # We already have a 'test' target, and the top directory is just plain
2043 # silly
2044 return if $dir eq "test" || $dir eq ".";
2045
2046 foreach my $type (("dso", "lib", "bin", "script")) {
2047 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
2048 # For lib object files, we could update the library. However, it
2049 # was decided that it's enough to build the directory local object
2050 # files, so we don't need to add any actions, and the dependencies
2051 # are already taken care of.
2052 if ($type ne "lib") {
2053 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
2054 if (dirname($prod) eq $dir) {
2055 push @deps, compute_platform_depends($prod);
2056 } else {
2057 push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
2058 }
2059 }
2060 }
2061 }
2062
2063 my $target = "$dir $dir/";
2064 my $deps = join(" \\\n\t",
2065 fill_lines(' ', $COLUMNS - 8, @deps));
2066 my $comments = join("\n", "", @comments);
2067 return <<"EOF";
2068$target: \\
2069 $deps$comments
2070EOF
2071 }
2072 "" # Important! This becomes part of the template result.
2073-}