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