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