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