2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 our $makedepprog = platform->makedepprog();
8 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
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/ }
14 our $sover_dirname = platform->shlib_version_as_filename();
16 # This makes sure things get built in the order they need
21 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
25 PLATFORM={- $config{target} -}
26 OPTIONS={- $config{options} -}
27 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
28 SRCDIR={- $config{sourcedir} -}
29 BLDDIR={- $config{builddir} -}
31 VERSION={- "$config{full_version}" -}
32 MAJOR={- $config{major} -}
33 MINOR={- $config{minor} -}
34 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
35 SHLIB_TARGET={- $target{shared_target} -}
37 LIBS={- join(" ", map { platform->staticlib($_) // () } @{$unified_info{libraries}}) -}
38 SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
39 SHLIB_INFO={- join(" ", map { my $x = platform->sharedlib($_);
40 my $y = platform->sharedlib_simple($_);
41 $x ? "\"$x;$y\"" : () }
42 @{$unified_info{libraries}}) -}
43 MODULES={- join(" ", map { platform->dso($_) } @{$unified_info{modules}}) -}
44 PROGRAMS={- join(" ", map { platform->bin($_) } @{$unified_info{programs}}) -}
45 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
46 {- output_off() if $disabled{makedepend}; "" -}
47 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
48 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
49 keys %{$unified_info{sources}}); -}
50 {- output_on() if $disabled{makedepend}; "" -}
51 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
52 GENERATED={- # common0.tmpl provides @generated
53 join(" ", map { platform->convertext($_) } @generated ) -}
56 join(" ", map { platform->staticlib($_) // () }
57 grep { !$unified_info{attributes}->{$_}->{noinst} }
58 @{$unified_info{libraries}})
61 join(" ", map { platform->sharedlib($_) // () }
62 grep { !$unified_info{attributes}->{$_}->{noinst} }
63 @{$unified_info{libraries}})
66 join(" ", map { my $x = platform->sharedlib($_);
67 my $y = platform->sharedlib_simple($_);
68 $x ? "\"$x;$y\"" : () }
69 grep { !$unified_info{attributes}->{$_}->{noinst} }
70 @{$unified_info{libraries}})
73 join(" ", map { platform->dso($_) }
74 grep { !$unified_info{attributes}->{$_}->{noinst}
75 && $unified_info{attributes}->{$_}->{engine} }
76 @{$unified_info{modules}})
79 join(" ", map { platform->bin($_) }
80 grep { !$unified_info{attributes}->{$_}->{noinst} }
81 @{$unified_info{programs}})
84 join(" ", map { my $x = $unified_info{attributes}->{$_}->{linkname};
86 grep { !$unified_info{attributes}->{$_}->{noinst}
87 && !$unified_info{attributes}->{$_}->{misc} }
88 @{$unified_info{scripts}})
91 join(" ", map { my $x = $unified_info{attributes}->{$_}->{linkname};
93 grep { !$unified_info{attributes}->{$_}->{noinst}
94 && $unified_info{attributes}->{$_}->{misc} }
95 @{$unified_info{scripts}})
98 APPS_OPENSSL={- use File::Spec::Functions;
99 catfile("apps","openssl") -}
101 # DESTDIR is for package builders so that they can configure for, say,
102 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
103 # Normally it is left empty.
106 # Do not edit these manually. Use Configure with --prefix or --openssldir
107 # to change this! Short explanation in the top comment in Configure
108 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
110 our $prefix = $config{prefix} || "/usr/local";
113 # The logic here is that if no --openssldir was given,
114 # OPENSSLDIR will get the value from $prefix plus "/ssl".
115 # If --openssldir was given and the value is an absolute
116 # path, OPENSSLDIR will get its value without change.
117 # If the value from --openssldir is a relative path,
118 # OPENSSLDIR will get $prefix with the --openssldir
119 # value appended as a subdirectory.
121 use File::Spec::Functions;
123 $config{openssldir} ?
124 (file_name_is_absolute($config{openssldir}) ?
126 : catdir($prefix, $config{openssldir}))
127 : catdir($prefix, "ssl");
129 LIBDIR={- our $libdir = $config{libdir};
132 # if $prefix/lib$target{multilib} is not an existing
133 # directory, then assume that it's not searched by linker
134 # automatically, in which case adding $target{multilib} suffix
135 # causes more grief than we're ready to tolerate, so don't...
137 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
138 $libdir = "lib$multilib";
140 file_name_is_absolute($libdir) ? "" : $libdir -}
141 # $(libdir) is chosen to be compatible with the GNU coding standards
142 libdir={- file_name_is_absolute($libdir)
143 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
144 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
146 # Convenience variable for those who want to set the rpath in shared
147 # libraries and applications
150 MANDIR=$(INSTALLTOP)/share/man
151 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
152 HTMLDIR=$(DOCDIR)/html
154 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
155 # appended after the manpage file section number. "ssl" is popular,
156 # resulting in files such as config.5ssl rather than config.5.
160 # For "optional" echo messages, to get "real" silence
163 ##### User defined commands and flags ################################
165 # We let the C compiler driver to take care of .s files. This is done in
166 # order to be excused from maintaining a separate set of architecture
167 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
168 # gcc, then the driver will automatically translate it to -xarch=v8plus
169 # and pass it down to assembler. In any case, we do not define AS or
170 # ASFLAGS for this reason.
172 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
173 CC=$(CROSS_COMPILE){- $config{CC} -}
174 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
175 CPPFLAGS={- our $cppflags1 = join(" ",
176 (map { "-D".$_} @{$config{CPPDEFINES}}),
177 (map { "-I".$_} @{$config{CPPINCLUDES}}),
178 @{$config{CPPFLAGS}}) -}
179 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
180 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
181 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
182 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
184 MAKEDEPEND={- $config{makedepprog} -}
186 PERL={- $config{PERL} -}
188 AR=$(CROSS_COMPILE){- $config{AR} -}
189 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
190 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
191 RC= $(CROSS_COMPILE){- $config{RC} -}
192 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
196 TAR= {- $target{TAR} || "tar" -}
197 TARFLAGS= {- $target{TARFLAGS} -}
200 NAME= $(BASENAME)-$(VERSION)
201 # Relative to $(SRCDIR)
202 TARFILE= ../$(NAME).tar
204 ##### Project flags ##################################################
206 # Variables starting with CNF_ are common variables for all product types
208 CNF_CPPFLAGS={- our $cppflags2 =
209 join(' ', $target{cppflags} || (),
210 (map { "-D".$_} @{$target{defines}},
211 @{$config{defines}}),
212 (map { "-I".$_} @{$target{includes}},
213 @{$config{includes}}),
214 @{$config{cppflags}}) -}
215 CNF_CFLAGS={- join(' ', $target{cflags} || (),
216 @{$config{cflags}}) -}
217 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
218 @{$config{cxxflags}}) -}
219 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
220 @{$config{lflags}}) -}
221 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
222 @{$config{ex_libs}}) -}
224 # Variables starting with LIB_ are used to build library object files
225 # and shared libraries.
226 # Variables starting with DSO_ are used to build DSOs and their object files.
227 # Variables starting with BIN_ are used to build programs and their object
230 LIB_CPPFLAGS={- our $lib_cppflags =
231 join(' ', $target{lib_cppflags} || (),
232 $target{shared_cppflag} || (),
234 @{$config{lib_defines} || ()},
235 @{$config{shared_defines} || ()}),
236 @{$config{lib_cppflags}},
237 @{$config{shared_cppflag}});
238 join(' ', $lib_cppflags,
240 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
241 'ENGINESDIR="\"$(ENGINESDIR)\""'),
242 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
243 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
244 $target{shared_cflag} || (),
245 @{$config{lib_cflags}},
246 @{$config{shared_cflag}},
247 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
248 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
249 $target{shared_cxxflag} || (),
250 @{$config{lib_cxxflags}},
251 @{$config{shared_cxxflag}},
252 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
253 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
254 $config{shared_ldflag} || (),
255 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
256 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
257 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
258 $target{module_cppflags} || (),
260 @{$config{dso_defines} || ()},
261 @{$config{module_defines} || ()}),
262 @{$config{dso_cppflags}},
263 @{$config{module_cppflags}},
264 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
265 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
266 $target{module_cflags} || (),
267 @{$config{dso_cflags}},
268 @{$config{module_cflags}},
269 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
270 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
271 $target{module_cxxflags} || (),
272 @{$config{dso_cxxflags}},
273 @{$config{module_cxxflag}},
274 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
275 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
276 $target{module_ldflags} || (),
277 @{$config{dso_ldflags}},
278 @{$config{module_ldflags}},
279 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
280 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
281 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
282 (map { '-D'.$_ } @{$config{bin_defines} || ()}),
283 @{$config{bin_cppflags}},
284 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
285 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
286 @{$config{bin_cflags}},
287 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
288 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
289 @{$config{bin_cxxflags}},
290 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
291 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
292 @{$config{bin_lflags}},
293 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
294 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
296 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
297 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
298 $cppflags2 =~ s|([\\"])|\\$1|g;
299 $lib_cppflags =~ s|([\\"])|\\$1|g;
300 join(' ', $lib_cppflags || (), $cppflags2 || (),
303 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
305 # For x86 assembler: Set PROCESSOR to 386 if you want to support
307 PROCESSOR= {- $config{processor} -}
309 # We want error [and other] messages in English. Trouble is that make(1)
310 # doesn't pass macros down as environment variables unless there already
311 # was corresponding variable originally set. In other words we can only
312 # reassign environment variables, but not set new ones, not in portable
313 # manner that is. That's why we reassign several, just to be sure...
318 # The main targets ###################################################
320 {- dependmagic('all'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
321 {- dependmagic('build_libs'); -}: build_libs_nodep
322 {- dependmagic('build_modules'); -}: build_modules_nodep
323 {- dependmagic('build_programs'); -}: build_programs_nodep
325 build_generated: $(GENERATED_MANDATORY)
326 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
327 build_modules_nodep: $(MODULES)
328 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
330 # Kept around for backward compatibility
331 build_apps build_tests: build_programs
333 # Convenience target to prebuild all generated files, not just the mandatory
335 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
336 @ : {- output_off() if $disabled{makedepend}; "" -}
337 @echo "Warning: consider configuring with no-makedepend, because if"
338 @echo " target system doesn't have $(PERL),"
339 @echo " then make will fail..."
340 @ : {- output_on() if $disabled{makedepend}; "" -}
343 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils
344 @ : {- output_off() if $disabled{tests}; "" -}
346 mkdir -p test-runs; \
347 SRCTOP=../$(SRCDIR) \
348 BLDTOP=../$(BLDDIR) \
351 EXE_EXT={- platform->binext() -} \
352 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
353 OPENSSL_DEBUG_MEMORY=on \
354 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
355 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
356 @echo "Tests are not supported with your chosen Configure options"
357 @ : {- output_on() if !$disabled{tests}; "" -}
360 @ : {- output_off() if $disabled{tests}; "" -}
361 @SRCTOP="$(SRCDIR)" \
362 $(PERL) $(SRCDIR)/test/run_tests.pl list
363 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
364 @echo "Tests are not supported with your chosen Configure options"
365 @ : {- output_on() if !$disabled{tests}; "" -}
367 install: install_sw install_ssldirs install_docs
369 uninstall: uninstall_docs uninstall_sw
372 @set -e; for s in $(SHLIB_INFO); do \
373 if [ "$$s" = ";" ]; then continue; fi; \
374 s1=`echo "$$s" | cut -f1 -d";"`; \
375 s2=`echo "$$s" | cut -f2 -d";"`; \
376 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
379 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
381 if [ "$$s1" != "$$s2" ]; then \
382 $(ECHO) $(RM) $$s2; \
387 $(RM) *{- platform->defext() -}
390 $(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(SCRIPTS)
391 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
392 -$(RM) `find . -name .git -prune -o -name '*{- platform->depext() -}' -print`
393 -$(RM) `find . -name .git -prune -o -name '*{- platform->objext() -}' -print`
395 $(RM) tags TAGS doc-nits
396 $(RM) -r test/test-runs
397 $(RM) openssl.pc libcrypto.pc libssl.pc
398 -$(RM) `find . -name .git -prune -o -type l -print`
405 # We check if any depfile is newer than Makefile and decide to
406 # concatenate only if that is true.
408 @: {- output_off() if $disabled{makedepend}; "" -}
409 @$(PERL) $(SRCDIR)/util/add-depends.pl {-
410 defined $makedepprog && $makedepprog =~ /\/makedepend/
411 ? 'makedepend' : 'gcc' -}
412 @: {- output_on() if $disabled{makedepend}; "" -}
414 # Install helper targets #############################################
416 install_sw: install_dev install_engines install_runtime
418 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
420 install_docs: install_man_docs install_html_docs
422 uninstall_docs: uninstall_man_docs uninstall_html_docs
423 $(RM) -r -v $(DESTDIR)$(DOCDIR)
426 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
427 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
428 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
429 @set -e; for x in dummy $(MISC_SCRIPTS); do \
430 if [ "$$x" = "dummy" ]; then continue; fi; \
431 x1=`echo "$$x" | cut -f1 -d:`; \
432 x2=`echo "$$x" | cut -f2 -d:`; \
433 fn=`basename $$x1`; \
434 $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
435 cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
436 chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
437 mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
438 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
439 if [ "$$x1" != "$$x2" ]; then \
440 ln=`basename "$$x2"`; \
441 : {- output_off() unless windowsdll(); "" -}; \
442 $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
443 cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
444 : {- output_on() unless windowsdll();
445 output_off() if windowsdll(); "" -}; \
446 $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
447 ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
448 : {- output_on() if windowsdll(); "" -}; \
451 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
452 @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
453 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
454 @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
455 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
456 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
457 cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
458 chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
460 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
461 @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
462 @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
463 @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
464 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
465 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
466 cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
467 chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
470 install_dev: install_runtime_libs
471 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
472 @$(ECHO) "*** Installing development files"
473 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
474 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
475 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
476 @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
477 @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
478 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
479 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
480 $(BLDDIR)/include/openssl/*.h; do \
482 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
483 cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
484 chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
486 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
487 @set -e; for l in $(INSTALL_LIBS); do \
489 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
490 cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
491 $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
492 chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
493 mv -f $(DESTDIR)$(libdir)/$$fn.new \
494 $(DESTDIR)$(libdir)/$$fn; \
496 @ : {- output_off() if $disabled{shared}; "" -}
497 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
498 s1=`echo "$$s" | cut -f1 -d";"`; \
499 s2=`echo "$$s" | cut -f2 -d";"`; \
500 fn1=`basename $$s1`; \
501 fn2=`basename $$s2`; \
502 : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
503 if [ "$$fn1" != "$$fn2" ]; then \
504 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
505 ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
507 : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
508 $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
509 cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
510 chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
511 mv -f $(DESTDIR)$(libdir)/$$fn2.new \
512 $(DESTDIR)$(libdir)/$$fn2; \
513 : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
514 a=$(DESTDIR)$(libdir)/$$fn2; \
515 $(ECHO) "install $$s1 -> $$a"; \
516 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
517 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
519 for so in `$(AR) t $$a`; do \
522 strip -X32_64 -e $$so; \
523 $(AR) r $$a.new $$so; \
526 $(AR) r $$a.new $$s1; \
528 : {- output_off() if sharedaix(); output_on(); "" -}; \
530 @ : {- output_on() if $disabled{shared}; "" -}
531 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
532 @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
533 @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
534 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
535 @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
536 @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
537 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
538 @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
539 @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
540 @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
542 uninstall_dev: uninstall_runtime_libs
543 @$(ECHO) "*** Uninstalling development files"
544 @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
545 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
546 @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
547 @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
548 @set -e; for i in $(SRCDIR)/include/openssl/*.h \
549 $(BLDDIR)/include/openssl/*.h; do \
551 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
552 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
554 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
555 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
556 @set -e; for l in $(INSTALL_LIBS); do \
558 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
559 $(RM) $(DESTDIR)$(libdir)/$$fn; \
561 @ : {- output_off() if $disabled{shared}; "" -}
562 @set -e; for s in $(INSTALL_SHLIB_INFO); do \
563 s1=`echo "$$s" | cut -f1 -d";"`; \
564 s2=`echo "$$s" | cut -f2 -d";"`; \
565 fn1=`basename $$s1`; \
566 fn2=`basename $$s2`; \
567 : {- output_off() if windowsdll(); "" -}; \
568 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
569 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
570 if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \
571 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
572 $(RM) $(DESTDIR)$(libdir)/$$fn1; \
574 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
575 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
576 $(RM) $(DESTDIR)$(libdir)/$$fn2; \
577 : {- output_on() unless windowsdll(); "" -}; \
579 @ : {- output_on() if $disabled{shared}; "" -}
580 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
581 $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
582 $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
583 -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
584 -$(RMDIR) $(DESTDIR)$(libdir)
586 install_engines: install_runtime_libs build_modules
587 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
588 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
589 @$(ECHO) "*** Installing ENGINE modules"
590 @set -e; for e in dummy $(INSTALL_ENGINES); do \
591 if [ "$$e" = "dummy" ]; then continue; fi; \
593 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
594 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
595 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
596 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
597 $(DESTDIR)$(ENGINESDIR)/$$fn; \
601 @$(ECHO) "*** Uninstalling ENGINE modules"
602 @set -e; for e in dummy $(INSTALL_ENGINES); do \
603 if [ "$$e" = "dummy" ]; then continue; fi; \
605 if [ "$$fn" = '{- platform->dso("ossltest") -}' ]; then \
608 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
609 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
611 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
613 install_runtime: install_programs
615 install_runtime_libs: build_libs
616 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
617 @ : {- output_off() if windowsdll(); "" -}
618 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
619 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
620 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
621 @ : {- output_on() unless windowsdll(); "" -}
622 @$(ECHO) "*** Installing runtime libraries"
623 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
624 if [ "$$s" = "dummy" ]; then continue; fi; \
626 : {- output_off() unless windowsdll(); "" -}; \
627 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
628 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
629 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
630 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
631 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
632 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
633 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
634 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
635 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
636 mv -f $(DESTDIR)$(libdir)/$$fn.new \
637 $(DESTDIR)$(libdir)/$$fn; \
638 : {- output_on() if windowsdll(); "" -}; \
641 install_programs: install_runtime_libs build_programs
642 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
643 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
644 @$(ECHO) "*** Installing runtime programs"
645 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
646 if [ "$$x" = "dummy" ]; then continue; fi; \
648 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
649 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
650 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
651 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
652 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
654 @set -e; for x in dummy $(BIN_SCRIPTS); do \
655 if [ "$$x" = "dummy" ]; then continue; fi; \
657 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
658 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
659 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
660 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
661 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
664 uninstall_runtime: uninstall_programs uninstall_runtime_libs
667 @$(ECHO) "*** Uninstalling runtime programs"
668 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
670 if [ "$$x" = "dummy" ]; then continue; fi; \
672 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
673 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
675 @set -e; for x in dummy $(BIN_SCRIPTS); \
677 if [ "$$x" = "dummy" ]; then continue; fi; \
679 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
680 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
682 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
684 uninstall_runtime_libs:
685 @$(ECHO) "*** Uninstalling runtime libraries"
686 @ : {- output_off() unless windowsdll(); "" -}
687 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
688 if [ "$$s" = "dummy" ]; then continue; fi; \
690 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
691 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
693 @ : {- output_on() unless windowsdll(); "" -}
697 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
698 @$(ECHO) "*** Installing manpages"
699 $(PERL) $(SRCDIR)/util/process_docs.pl \
700 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
703 @$(ECHO) "*** Uninstalling manpages"
704 $(PERL) $(SRCDIR)/util/process_docs.pl \
705 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
709 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
710 @$(ECHO) "*** Installing HTML manpages"
711 $(PERL) $(SRCDIR)/util/process_docs.pl \
712 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
715 @$(ECHO) "*** Uninstalling manpages"
716 $(PERL) $(SRCDIR)/util/process_docs.pl \
717 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
720 # Developer targets (note: these are only available on Unix) #########
722 update: generate errors ordinals
724 generate: generate_apps generate_crypto_bn generate_crypto_objects \
725 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
728 doc-nits: build_generated
729 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
730 @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
731 else echo 'doc-nits: no errors.'; rm doc-nits ; fi
733 # Test coverage is a good idea for the future
734 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
738 lint -DLINT $(INCLUDES) $(SRCS)
741 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
742 < apps/openssl.cnf > apps/openssl-vms.cnf )
745 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
747 generate_crypto_objects:
748 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
749 crypto/objects/objects.txt \
750 crypto/objects/obj_mac.num \
751 > crypto/objects/obj_mac.new && \
752 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
753 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
754 crypto/objects/objects.txt \
755 crypto/objects/obj_mac.num \
756 > include/openssl/obj_mac.h )
757 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
758 include/openssl/obj_mac.h \
759 > crypto/objects/obj_dat.h )
760 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
761 crypto/objects/obj_mac.num \
762 crypto/objects/obj_xref.txt \
763 > crypto/objects/obj_xref.h )
765 generate_crypto_conf:
766 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
767 > crypto/conf/conf_def.h )
769 generate_crypto_asn1:
770 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
771 > crypto/asn1/charmap.h )
774 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
775 crypto/objects/obj_dat.h \
778 # Set to -force to force a rebuild
781 ( b=`pwd`; set -e; cd $(SRCDIR); \
782 $(PERL) util/ck_errf.pl -strict -internal; \
783 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
784 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
786 $(PERL) ../util/ck_errf.pl -strict \
787 -conf $$E `basename $$E .ec`.c; \
788 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
789 -conf $$E `basename $$E .ec`.c ; \
792 {- use File::Basename;
795 qw( include/openssl/ssl.h
796 include/openssl/ssl2.h
797 include/openssl/ssl3.h
798 include/openssl/sslerr.h
799 include/openssl/tls1.h
800 include/openssl/dtls1.h
801 include/openssl/srtp.h );
803 qw( include/internal/dso.h
804 include/internal/o_dir.h
805 include/internal/o_str.h
806 include/internal/err.h
807 include/internal/sslconf.h );
808 our @cryptoskipheaders = ( @sslheaders,
809 qw( include/openssl/conf_api.h
810 include/openssl/ebcdic.h
811 include/openssl/opensslconf.h
812 include/openssl/symhacks.h ) );
813 foreach my $f ( glob(catfile($config{sourcedir},
814 'include','openssl','*.h')) ) {
815 my $fn = "include/openssl/" . basename($f);
816 push @cryptoheaders, $fn unless grep { $_ eq $fn } @cryptoskipheaders;
820 CRYPTOHEADERS={- join(" \\\n\t", sort @cryptoheaders) -}
821 SSLHEADERS={- join(" \\\n\t", sort @sslheaders) -}
824 $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
825 --ordinals util/libcrypto.num \
826 --symhacks include/openssl/symhacks.h \
829 $(PERL) util/mknum.pl --version $(VERSION) --no-warnings \
830 --ordinals util/libssl.num \
831 --symhacks include/openssl/symhacks.h \
836 SRCTOP=../$(SRCDIR) \
837 BLDTOP=../$(BLDDIR) \
838 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
843 -etags `find . -name '*.[ch]' -o -name '*.pm'`
845 # Release targets (note: only available on Unix) #####################
848 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
850 # Helper targets #####################################################
852 link-utils: $(BLDDIR)/util/opensslwrap.sh
854 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
855 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
856 mkdir -p "$(BLDDIR)/util"; \
857 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
862 # Building targets ###################################################
864 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // () } @{$unified_info{libraries}}) -}
866 @ ( echo 'prefix=$(INSTALLTOP)'; \
867 echo 'exec_prefix=$${prefix}'; \
868 if [ -n "$(LIBDIR)" ]; then \
869 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
871 echo 'libdir=$(libdir)'; \
873 echo 'includedir=$${prefix}/include'; \
874 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
876 echo 'Name: OpenSSL-libcrypto'; \
877 echo 'Description: OpenSSL cryptography library'; \
878 echo 'Version: '$(VERSION); \
879 echo 'Libs: -L$${libdir} -lcrypto'; \
880 echo 'Libs.private: $(LIB_EX_LIBS)'; \
881 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
884 @ ( echo 'prefix=$(INSTALLTOP)'; \
885 echo 'exec_prefix=$${prefix}'; \
886 if [ -n "$(LIBDIR)" ]; then \
887 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
889 echo 'libdir=$(libdir)'; \
891 echo 'includedir=$${prefix}/include'; \
893 echo 'Name: OpenSSL-libssl'; \
894 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
895 echo 'Version: '$(VERSION); \
896 echo 'Requires.private: libcrypto'; \
897 echo 'Libs: -L$${libdir} -lssl'; \
898 echo 'Cflags: -I$${includedir}' ) > libssl.pc
901 @ ( echo 'prefix=$(INSTALLTOP)'; \
902 echo 'exec_prefix=$${prefix}'; \
903 if [ -n "$(LIBDIR)" ]; then \
904 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
906 echo 'libdir=$(libdir)'; \
908 echo 'includedir=$${prefix}/include'; \
910 echo 'Name: OpenSSL'; \
911 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
912 echo 'Version: '$(VERSION); \
913 echo 'Requires: libssl libcrypto' ) > openssl.pc
915 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
916 @echo "Detected changed: $?"
917 $(PERL) configdata.pm -r
918 @echo "**************************************************"
920 @echo "*** Please run the same make command again ***"
922 @echo "**************************************************"
926 $(PERL) configdata.pm -r
930 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
932 # Helper function to figure out dependencies on libraries
933 # It takes a list of library names and outputs a list of dependencies
934 sub compute_lib_depends {
935 # Depending on shared libraries:
936 # On Windows POSIX layers, we depend on {libname}.dll.a
937 # On Unix platforms, we depend on {shlibname}.so
938 return map { platform->sharedlib_simple($_) // platform->staticlib($_) } @_;
943 my $generator = join(" ", @{$args{generator}});
944 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
945 my $incs = join("", map { " -I".$_ } @{$args{incs}});
946 my $defs = join("", map { " -D".$_ } @{$args{defs}});
947 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
949 if (platform->isdef($args{src})) {
950 my $target = platform->def($args{src});
951 (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
952 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
953 my $ord_name = $args{generator}->[1] || $args{product};
955 $target: $args{generator}->[0] $deps \$(SRCDIR)/util/mkdef.pl
956 \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS $mkdef_os > $target
958 } elsif (!platform->isasm($args{src})) {
959 if ($args{generator}->[0] =~ m|^.*\.in$|) {
960 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
961 "util", "dofile.pl")),
962 rel2abs($config{builddir}));
964 $args{src}: $args{generator}->[0] $deps
965 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
966 "-o$target{build_file}" $generator > \$@
970 $args{src}: $args{generator}->[0] $deps
971 \$(PERL)$generator_incs $generator > \$@
975 if ($args{generator}->[0] =~ /\.pl$/) {
976 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
977 } elsif ($args{generator}->[0] =~ /\.m4$/) {
978 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
979 } elsif ($args{generator}->[0] =~ /\.S$/) {
982 die "Generator type for $args{src} unknown: $generator\n";
986 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
987 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
988 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
989 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
990 } -> {$args{intent}};
991 if (defined($generator)) {
993 $args{src}: $args{generator}->[0] $deps
998 $args{src}: $args{generator}->[0] $deps
999 \$(CC) $incs $cppflags $defs -E $args{generator}->[0] | \\
1000 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
1005 # Should one wonder about the end of the Perl snippet, it's because this
1006 # second regexp eats up line endings as well, if the removed path is the
1007 # last in the line. We may therefore need to put back a line ending.
1010 my $obj = platform->obj($args{obj});
1011 my $dep = platform->dep($args{obj});
1012 my @srcs = @{$args{srcs}};
1013 my $srcs = join(" ", @srcs);
1014 my $deps = join(" ", @srcs, @{$args{deps}});
1015 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1016 my $defs = join("", map { " -D".$_ } @{$args{defs}});
1020 if (grep /\.rc$/, @srcs) {
1022 $cmdflags = '$(RCFLAGS)';
1024 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1026 $cmdcompile = ' -c';
1028 shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1029 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1030 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1031 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1032 } -> {$args{intent}};
1035 $cmdcompile = ' -c';
1037 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1038 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1039 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1040 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1041 } -> {$args{intent}};
1044 # extension-specific rules
1045 if (grep /\.s$/, @srcs) {
1048 $cmd $cmdflags -c -o \$\@ $srcs
1050 } elsif (grep /\.S$/, @srcs) {
1051 # Originally there was mutli-step rule with $(CC) -E file.S
1052 # followed by $(CC) -c file.s. It compensated for one of
1053 # legacy platform compiler's inability to handle .S files.
1054 # The platform is long discontinued by vendor so there is
1055 # hardly a point to drag it along...
1058 $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
1060 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
1061 && !grep /\.rc$/, @srcs) {
1064 $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs
1066 \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
1069 mv $dep.tmp $dep; \\
1075 $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
1077 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1079 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1086 # We *know* this routine is only called when we've configure 'shared'.
1090 foreach (@{args{deps}}) {
1091 my $d = dirname($_);
1092 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1094 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1095 my $linklibs = join("", map { my $f = basename($_);
1096 (my $l = $f) =~ s/^lib//;
1097 " -l$l" } @{$args{deps}});
1098 my @objs = map { platform->obj($_) }
1099 grep { !platform->isdef($_) }
1101 my @defs = map { platform->def($_) }
1102 grep { platform->isdef($_) }
1104 my @deps = compute_lib_depends(@{$args{deps}});
1105 die "More than one exported symbol map" if scalar @defs > 1;
1106 my $objs = join(" ", @objs);
1107 my $deps = join(" ", @objs, @defs, @deps);
1108 my $simple = platform->sharedlib_simple($args{lib});
1109 my $full = platform->sharedlib($args{lib});
1110 my $shared_soname = "";
1111 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
1112 if defined $target{shared_sonameflag};
1113 my $shared_imp = "";
1114 $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
1115 if defined $target{shared_impflag};
1116 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1117 my $recipe = <<"EOF";
1123 \$(AR) r $simple $full
1125 } elsif ($simple ne $full) {
1133 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1134 -o $full$shared_def $objs \\
1135 $linklibs \$(LIB_EX_LIBS)
1151 my $dso = platform->dso($args{lib});
1153 foreach (@{args{deps}}) {
1154 my $d = dirname($_);
1155 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1157 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1158 my $linklibs = join("", map { my $f = basename($_);
1159 (my $l = $f) =~ s/^lib//;
1160 " -l$l" } @{$args{deps}});
1161 my @objs = map { platform->obj($_) }
1162 grep { !platform->isdef($_) }
1164 my @defs = map { platform->def($_) }
1165 grep { platform->isdef($_) }
1167 my @deps = compute_lib_depends(@{$args{deps}});
1168 my $objs = join(" ", @objs);
1169 my $deps = join(" ", @objs, @defs, @deps);
1170 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1173 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1174 -o $dso$shared_def $objs \\
1175 $linklibs \$(DSO_EX_LIBS)
1180 my $lib = platform->staticlib($args{lib});
1181 my @objs = map { platform->obj($_) } @{$args{objs}};
1182 my $objs = join(" ", @objs);
1185 \$(AR) \$(ARFLAGS) \$\@ \$\?
1186 \$(RANLIB) \$\@ || echo Never mind.
1191 my $bin = platform->bin($args{bin});
1192 my $objs = join(" ", map { platform->obj($_) } @{$args{objs}});
1193 my $deps = join(" ", compute_lib_depends(@{$args{deps}}));
1195 foreach (@{args{deps}}) {
1196 next if $_ =~ /\.a$/;
1197 my $d = dirname($_);
1198 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1200 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1201 my $linklibs = join("", map { if ($_ =~ m/\.a$/) {
1202 " ".platform->staticlib($_);
1204 my $f = basename($_);
1205 (my $l = $f) =~ s/^lib//;
1210 my $cmdflags = '$(BIN_CFLAGS)';
1211 if (grep /_cc\.o$/, @{$args{objs}}) {
1213 $cmdflags = '$(BIN_CXXFLAGS)';
1218 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1220 $linklibs \$(BIN_EX_LIBS)
1225 my $script = $args{script};
1226 my $sources = join(" ", @{$args{sources}});
1227 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1228 "util", "dofile.pl")),
1229 rel2abs($config{builddir}));
1232 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1233 "-o$target{build_file}" $sources > "$script"
1239 my $dir = $args{dir};
1240 my @deps = map { platform->convertext($_) } @{$args{deps}};
1242 my %extinfo = ( dso => platform->dsoext(),
1243 lib => platform->libext(),
1244 bin => platform->binext() );
1246 # We already have a 'test' target, and the top directory is just plain
1248 return if $dir eq "test" || $dir eq ".";
1250 foreach my $type (("dso", "lib", "bin", "script")) {
1251 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1252 # For lib object files, we could update the library. However, it
1253 # was decided that it's enough to build the directory local object
1254 # files, so we don't need to add any actions, and the dependencies
1255 # are already taken care of.
1256 if ($type ne "lib") {
1257 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1258 if (dirname($prod) eq $dir) {
1259 push @deps, $prod.$extinfo{$type};
1261 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1267 my $deps = join(" ", @deps);
1268 my $actions = join("\n", "", @actions);
1270 $dir $dir/: $deps$actions
1273 "" # Important! This becomes part of the template result.