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