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