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