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