2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 our $objext = $target{obj_extension} || ".o";
7 our $depext = $target{dep_extension} || ".d";
8 our $exeext = $target{exe_extension} || "";
9 our $libext = $target{lib_extension} || ".a";
10 our $shlibext = $target{shared_extension} || ".so";
11 our $shlibvariant = $target{shlib_variant} || "";
12 our $shlibextsimple = $target{shared_extension_simple} || ".so";
13 our $shlibextimport = $target{shared_import_extension} || "";
14 our $dsoext = $target{dso_extension} || ".so";
15 our $makedepprog = $disabled{makedepend} ? undef : $config{makedepprog};
17 # $mingw_installroot and $mingw_commonroot is relevant for mingw only.
18 my $build_scheme = $target{build_scheme};
19 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
20 my $mingw_installenv = $install_flavour eq "WOW" ? "ProgramFiles(x86)"
22 my $mingw_commonenv = $install_flavour eq "WOW" ? "CommonProgramFiles(x86)"
23 : "CommonProgramW6432";
24 our $mingw_installroot =
25 defined($ENV{$mingw_installenv}) ? $mingw_installenv : 'ProgramFiles';
26 our $mingw_commonroot =
27 defined($ENV{$mingw_commonenv}) ? $mingw_commonenv : 'CommonProgramFiles';
28 my $mingw_installdflt =
29 $install_flavour eq "WOW" ? "C:/Program Files (x86)"
31 my $mingw_commondflt = "$mingw_installdflt/Common Files";
33 # expand variables early
34 $mingw_installroot = $ENV{$mingw_installroot} // $mingw_installdflt;
35 $mingw_commonroot = $ENV{$mingw_commonroot} // $mingw_commondflt;
37 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
39 # Shared AIX support is special. We put libcrypto[64].so.ver into
40 # libcrypto.a and use libcrypto_a.a as static one.
41 sub sharedaix { !$disabled{shared} && $config{target} =~ /^aix/ }
43 our $sover_dirname = $config{shlib_version_number};
44 $sover_dirname =~ s|\.|_|g
45 if $config{target} =~ /^mingw/;
47 # shlib and shlib_simple both take a static library name and figure
48 # out what the shlib name should be.
50 # When OpenSSL is configured "no-shared", these functions will just
51 # return empty lists, making them suitable to join().
53 # With Windows DLL producers, shlib($libname) will return the shared
54 # library name (which usually is different from the static library
55 # name) with the default shared extension appended to it, while
56 # shlib_simple($libname) will return the static library name with
57 # the shared extension followed by ".a" appended to it. The former
58 # result is used as the runtime shared library while the latter is
59 # used as the DLL import library.
61 # On all Unix systems, shlib($libname) will return the library name
62 # with the default shared extension, while shlib_simple($libname)
63 # will return the name from shlib($libname) with any SO version number
64 # removed. On some systems, they may therefore return the exact same
68 return () if $disabled{shared} || $lib =~ /\.a$/;
69 return $unified_info{sharednames}->{$lib}. $shlibvariant. '$(SHLIB_EXT)';
73 return () if $disabled{shared} || $lib =~ /\.a$/;
76 return $lib . '$(SHLIB_EXT_IMPORT)';
78 return $lib . '$(SHLIB_EXT_SIMPLE)';
81 # Easy fixing of static library names
83 (my $lib = shift) =~ s/\.a$//;
84 return $lib . $libext;
87 # dso is a complement to shlib / shlib_simple that returns the
88 # given libname with the simple shared extension (possible SO version
89 # removed). This differs from shlib_simple() by being unconditional.
93 return $engine . $dsoext;
95 # This makes sure things get built in the order they need
100 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
104 PLATFORM={- $config{target} -}
105 OPTIONS={- $config{options} -}
106 CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
107 SRCDIR={- $config{sourcedir} -}
108 BLDDIR={- $config{builddir} -}
110 VERSION={- $config{version} -}
111 MAJOR={- $config{major} -}
112 MINOR={- $config{minor} -}
113 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
114 SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -}
115 SHLIB_MAJOR={- $config{shlib_major} -}
116 SHLIB_MINOR={- $config{shlib_minor} -}
117 SHLIB_TARGET={- $target{shared_target} -}
118 SHLIB_EXT={- $shlibext -}
119 SHLIB_EXT_SIMPLE={- $shlibextsimple -}
120 SHLIB_EXT_IMPORT={- $shlibextimport -}
122 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
123 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
124 SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{libraries}}) -}
125 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
126 PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{programs}}) -}
127 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
128 {- output_off() if $disabled{makedepend}; "" -}
129 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
130 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
131 keys %{$unified_info{sources}}); -}
132 {- output_on() if $disabled{makedepend}; "" -}
133 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}}) -}
134 GENERATED={- # common0.tmpl provides @generated
135 join(" ", @generated ) -}
137 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
138 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
139 INSTALL_SHLIB_INFO={- join(" ", map { "\"".shlib($_).";".shlib_simple($_)."\"" } @{$unified_info{install}->{libraries}}) -}
140 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
141 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } @{$unified_info{install}->{programs}}) -}
142 {- output_off() if $disabled{apps}; "" -}
143 BIN_SCRIPTS=$(BLDDIR)/tools/c_rehash
144 MISC_SCRIPTS=$(BLDDIR)/apps/CA.pl $(BLDDIR)/apps/tsget.pl:tsget
145 {- output_on() if $disabled{apps}; "" -}
147 APPS_OPENSSL={- use File::Spec::Functions;
148 catfile("apps","openssl") -}
150 # DESTDIR is for package builders so that they can configure for, say,
151 # /usr/ and yet have everything installed to /tmp/somedir/usr/.
152 # Normally it is left empty.
155 {- output_off() if $config{target} =~ /^mingw/; "" -}
156 # Do not edit these manually. Use Configure with --prefix or --openssldir
157 # to change this! Short explanation in the top comment in Configure
158 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
160 our $prefix = $config{prefix} || "/usr/local";
163 # The logic here is that if no --openssldir was given,
164 # OPENSSLDIR will get the value from $prefix plus "/ssl".
165 # If --openssldir was given and the value is an absolute
166 # path, OPENSSLDIR will get its value without change.
167 # If the value from --openssldir is a relative path,
168 # OPENSSLDIR will get $prefix with the --openssldir
169 # value appended as a subdirectory.
171 use File::Spec::Functions;
173 $config{openssldir} ?
174 (file_name_is_absolute($config{openssldir}) ?
176 : catdir($prefix, $config{openssldir}))
177 : catdir($prefix, "ssl");
179 LIBDIR={- our $libdir = $config{libdir};
182 # if $prefix/lib$target{multilib} is not an existing
183 # directory, then assume that it's not searched by linker
184 # automatically, in which case adding $target{multilib} suffix
185 # causes more grief than we're ready to tolerate, so don't...
187 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
188 $libdir = "lib$multilib";
190 file_name_is_absolute($libdir) ? "" : $libdir -}
191 # $(libdir) is chosen to be compatible with the GNU coding standards
192 libdir={- file_name_is_absolute($libdir)
193 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
194 ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
196 # Convenience variable for those who want to set the rpath in shared
197 # libraries and applications
199 {- output_on() if $config{target} =~ /^mingw/;
200 output_off() if $config{target} !~ /^mingw/;
202 # Do not edit these manually. Use Configure with --prefix or --openssldir
203 # to change this! Short explanation in the top comment in Configure
204 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
206 use File::Spec::Win32;
207 my $prefix_default = "$mingw_installroot/OpenSSL";
209 File::Spec::Win32->canonpath($config{prefix}
211 our ($prefix_dev, $prefix_dir, $prefix_file) =
212 File::Spec::Win32->splitpath($prefix, 1);
214 $prefix_dir =~ s|\\|/|g;
216 INSTALLTOP_dir={- my $x = File::Spec::Win32->canonpath($prefix_dir);
220 # The logic here is that if no --openssldir was given,
221 # OPENSSLDIR will get the value "$mingw_commonroot/SSL".
222 # If --openssldir was given and the value is an absolute
223 # path, OPENSSLDIR will get its value without change.
224 # If the value from --openssldir is a relative path,
225 # OPENSSLDIR will get $prefix with the --openssldir
226 # value appended as a subdirectory.
228 use File::Spec::Win32;
230 $config{openssldir} ?
231 (File::Spec::Win32->file_name_is_absolute($config{openssldir}) ?
232 File::Spec::Win32->canonpath($config{openssldir})
233 : File::Spec::Win32->catdir($prefix, $config{openssldir}))
234 : File::Spec::Win32->canonpath("$mingw_commonroot/SSL");
235 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
236 File::Spec::Win32->splitpath($openssldir, 1);
237 $openssldir =~ s|\\|/|g;
238 $openssldir_dir =~ s|\\|/|g;
240 OPENSSLDIR_dir={- my $x = File::Spec::Win32->canonpath($openssldir_dir);
243 LIBDIR={- our $libdir = $config{libdir} || "lib";
244 File::Spec::Win32->file_name_is_absolute($libdir) ? "" : $libdir -}
245 ENGINESDIR_dev={- use File::Spec::Win32;
247 File::Spec::Win32->catdir($prefix,$libdir,
248 "engines-$sover_dirname");
249 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
250 File::Spec::Win32->splitpath($enginesdir, 1);
251 $enginesdir =~ s|\\|/|g;
252 $enginesdir_dir =~ s|\\|/|g;
254 ENGINESDIR_dir={- my $x = File::Spec::Win32->canonpath($enginesdir_dir);
257 # In a Windows environment, $(DESTDIR) is harder to contatenate with other
258 # directory variables, because both may contain devices. What we do here is
259 # to adapt INSTALLTOP, OPENSSLDIR and ENGINESDIR depending on if $(DESTDIR)
260 # has a value or not, to ensure that concatenation will always work further
262 ifneq "$(DESTDIR)" ""
263 INSTALLTOP=$(INSTALLTOP_dir)
264 OPENSSLDIR=$(OPENSSLDIR_dir)
265 ENGINESDIR=$(ENGINESDIR_dir)
267 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
268 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
269 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
272 # $(libdir) is chosen to be compatible with the GNU coding standards
273 libdir={- File::Spec::Win32->file_name_is_absolute($libdir)
274 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
275 {- output_on() if $config{target} !~ /^mingw/; "" -}
277 MANDIR=$(INSTALLTOP)/share/man
278 DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
279 HTMLDIR=$(DOCDIR)/html
281 # MANSUFFIX is for the benefit of anyone who may want to have a suffix
282 # appended after the manpage file section number. "ssl" is popular,
283 # resulting in files such as config.5ssl rather than config.5.
287 # For "optional" echo messages, to get "real" silence
290 ##### User defined commands and flags ################################
292 # We let the C compiler driver to take care of .s files. This is done in
293 # order to be excused from maintaining a separate set of architecture
294 # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
295 # gcc, then the driver will automatically translate it to -xarch=v8plus
296 # and pass it down to assembler. In any case, we do not define AS or
297 # ASFLAGS for this reason.
299 CROSS_COMPILE={- $config{CROSS_COMPILE} -}
300 CC=$(CROSS_COMPILE){- $config{CC} -}
301 CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
302 CPPFLAGS={- our $cppflags1 = join(" ",
303 (map { "-D".$_} @{$config{CPPDEFINES}}),
304 (map { "-I".$_} @{$config{CPPINCLUDES}}),
305 @{$config{CPPFLAGS}}) -}
306 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
307 CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
308 LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
309 EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
311 MAKEDEPEND={- $config{makedepprog} -}
313 PERL={- $config{PERL} -}
315 AR=$(CROSS_COMPILE){- $config{AR} -}
316 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
317 RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
318 RC= $(CROSS_COMPILE){- $config{RC} -}
319 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
323 TAR= {- $target{TAR} || "tar" -}
324 TARFLAGS= {- $target{TARFLAGS} -}
327 NAME= $(BASENAME)-$(VERSION)
328 # Relative to $(SRCDIR)
329 TARFILE= ../$(NAME).tar
331 ##### Project flags ##################################################
333 # Variables starting with CNF_ are common variables for all product types
335 CNF_CPPFLAGS={- our $cppflags2 =
336 join(' ', $target{cppflags} || (),
337 (map { "-D".$_} @{$target{defines}},
338 @{$config{defines}}),
339 (map { "-I".$_} @{$target{includes}},
340 @{$config{includes}}),
341 @{$config{cppflags}}) -}
342 CNF_CFLAGS={- join(' ', $target{cflags} || (),
343 @{$config{cflags}}) -}
344 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
345 @{$config{cxxflags}}) -}
346 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
347 @{$config{lflags}}) -}
348 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
349 @{$config{ex_libs}}) -}
351 # Variables starting with LIB_ are used to build library object files
352 # and shared libraries.
353 # Variables starting with DSO_ are used to build DSOs and their object files.
354 # Variables starting with BIN_ are used to build programs and their object
357 LIB_CPPFLAGS={- our $lib_cppflags =
358 join(' ', $target{lib_cppflags} || (),
359 $target{shared_cppflag} || (),
361 @{$config{lib_defines} || ()},
362 @{$config{shared_defines} || ()}),
363 @{$config{lib_cppflags}},
364 @{$config{shared_cppflag}});
365 join(' ', $lib_cppflags,
367 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
368 'ENGINESDIR="\"$(ENGINESDIR)\""'),
369 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
370 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
371 $target{shared_cflag} || (),
372 @{$config{lib_cflags}},
373 @{$config{shared_cflag}},
374 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
375 LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
376 $target{shared_cxxflag} || (),
377 @{$config{lib_cxxflags}},
378 @{$config{shared_cxxflag}},
379 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
380 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
381 $config{shared_ldflag} || (),
382 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
383 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
384 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
385 $target{module_cppflags} || (),
387 @{$config{dso_defines} || ()},
388 @{$config{module_defines} || ()}),
389 @{$config{dso_cppflags}},
390 @{$config{module_cppflags}},
391 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
392 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
393 $target{module_cflags} || (),
394 @{$config{dso_cflags}},
395 @{$config{module_cflags}},
396 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
397 DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
398 $target{module_cxxflags} || (),
399 @{$config{dso_cxxflags}},
400 @{$config{module_cxxflag}},
401 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
402 DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
403 $target{module_ldflags} || (),
404 @{$config{dso_ldflags}},
405 @{$config{module_ldflags}},
406 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
407 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
408 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
409 (map { '-D'.$_ } @{$config{bin_defines} || ()}),
410 @{$config{bin_cppflags}},
411 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
412 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
413 @{$config{bin_cflags}},
414 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
415 BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
416 @{$config{bin_cxxflags}},
417 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
418 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
419 @{$config{bin_lflags}},
420 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
421 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
423 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
424 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
425 $cppflags2 =~ s|([\\"])|\\$1|g;
426 $lib_cppflags =~ s|([\\"])|\\$1|g;
427 join(' ', $lib_cppflags || (), $cppflags2 || (),
430 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
432 # For x86 assembler: Set PROCESSOR to 386 if you want to support
434 PROCESSOR= {- $config{processor} -}
436 # We want error [and other] messages in English. Trouble is that make(1)
437 # doesn't pass macros down as environment variables unless there already
438 # was corresponding variable originally set. In other words we can only
439 # reassign environment variables, but not set new ones, not in portable
440 # manner that is. That's why we reassign several, just to be sure...
445 # The main targets ###################################################
447 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep link-utils
448 {- dependmagic('build_libs'); -}: build_libs_nodep
449 {- dependmagic('build_engines'); -}: build_engines_nodep
450 {- dependmagic('build_programs'); -}: build_programs_nodep
452 build_generated: $(GENERATED_MANDATORY)
453 build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
454 build_engines_nodep: $(ENGINES)
455 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
457 # Kept around for backward compatibility
458 build_apps build_tests: build_programs
460 # Convenience target to prebuild all generated files, not just the mandatory
462 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
463 @ : {- output_off() if $disabled{makedepend}; "" -}
464 @echo "Warning: consider configuring with no-makedepend, because if"
465 @echo " target system doesn't have $(PERL),"
466 @echo " then make will fail..."
467 @ : {- output_on() if $disabled{makedepend}; "" -}
470 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep link-utils
471 @ : {- output_off() if $disabled{tests}; "" -}
473 mkdir -p test-runs; \
474 SRCTOP=../$(SRCDIR) \
475 BLDTOP=../$(BLDDIR) \
478 EXE_EXT={- $exeext -} \
479 OPENSSL_ENGINES=`cd ../$(BLDDIR)/engines 2>/dev/null && pwd` \
480 OPENSSL_DEBUG_MEMORY=on \
481 $(PERL) ../$(SRCDIR)/test/run_tests.pl $(TESTS) )
482 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
483 @echo "Tests are not supported with your chosen Configure options"
484 @ : {- output_on() if !$disabled{tests}; "" -}
487 @ : {- output_off() if $disabled{tests}; "" -}
488 @SRCTOP="$(SRCDIR)" \
489 $(PERL) $(SRCDIR)/test/run_tests.pl list
490 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
491 @echo "Tests are not supported with your chosen Configure options"
492 @ : {- output_on() if !$disabled{tests}; "" -}
494 install: install_sw install_ssldirs install_docs
496 uninstall: uninstall_docs uninstall_sw
499 @set -e; for s in $(SHLIB_INFO); do \
500 if [ "$$s" = ";" ]; then continue; fi; \
501 s1=`echo "$$s" | cut -f1 -d";"`; \
502 s2=`echo "$$s" | cut -f2 -d";"`; \
503 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
506 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
508 if [ "$$s1" != "$$s2" ]; then \
509 $(ECHO) $(RM) $$s2; \
517 $(RM) $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
518 $(RM) $(GENERATED_MANDATORY) $(GENERATED)
519 -$(RM) `find . -name '*{- $depext -}' \! -name '.*' \! -type d -print`
520 -$(RM) `find . -name '*{- $objext -}' \! -name '.*' \! -type d -print`
522 $(RM) tags TAGS doc-nits
523 $(RM) -r test/test-runs
524 $(RM) openssl.pc libcrypto.pc libssl.pc
525 -$(RM) `find . -type l \! -name '.*' -print`
532 # We check if any depfile is newer than Makefile and decide to
533 # concatenate only if that is true.
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}; "" -}
541 # Install helper targets #############################################
543 install_sw: install_dev install_engines install_runtime
545 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
547 install_docs: install_man_docs install_html_docs
549 uninstall_docs: uninstall_man_docs uninstall_html_docs
550 $(RM) -r $(DESTDIR)$(DOCDIR)
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(); "" -}; \
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; \
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; \
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 \
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; \
613 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
614 @set -e; for l in $(INSTALL_LIBS); do \
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; \
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; \
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.$$$$; \
646 for so in `$(AR) t $$a`; do \
649 strip -X32_64 -e $$so; \
650 $(AR) r $$a.new $$so; \
653 $(AR) r $$a.new $$s1; \
655 : {- output_off() if sharedaix(); output_on(); "" -}; \
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
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 \
678 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
679 $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
681 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
682 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
683 @set -e; for l in $(INSTALL_LIBS); do \
685 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
686 $(RM) $(DESTDIR)$(libdir)/$$fn; \
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; \
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(); "" -}; \
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)
713 install_engines: install_runtime_libs build_engines
714 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
715 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
716 @$(ECHO) "*** Installing engines"
717 @set -e; for e in dummy $(INSTALL_ENGINES); do \
718 if [ "$$e" = "dummy" ]; then continue; fi; \
720 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
721 cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
722 chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
723 mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
724 $(DESTDIR)$(ENGINESDIR)/$$fn; \
728 @$(ECHO) "*** Uninstalling engines"
729 @set -e; for e in dummy $(INSTALL_ENGINES); do \
730 if [ "$$e" = "dummy" ]; then continue; fi; \
732 if [ "$$fn" = '{- dso("ossltest") -}' ]; then \
735 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
736 $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
738 -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
740 install_runtime: install_programs
742 install_runtime_libs: build_libs
743 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
744 @ : {- output_off() if windowsdll(); "" -}
745 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
746 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
747 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
748 @ : {- output_on() unless windowsdll(); "" -}
749 @$(ECHO) "*** Installing runtime libraries"
750 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
751 if [ "$$s" = "dummy" ]; then continue; fi; \
753 : {- output_off() unless windowsdll(); "" -}; \
754 $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
755 cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
756 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
757 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
758 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
759 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
760 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
761 cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
762 chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
763 mv -f $(DESTDIR)$(libdir)/$$fn.new \
764 $(DESTDIR)$(libdir)/$$fn; \
765 : {- output_on() if windowsdll(); "" -}; \
768 install_programs: install_runtime_libs build_programs
769 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
770 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
771 @$(ECHO) "*** Installing runtime programs"
772 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
773 if [ "$$x" = "dummy" ]; then continue; fi; \
775 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
776 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
777 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
778 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
779 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
781 @set -e; for x in dummy $(BIN_SCRIPTS); do \
782 if [ "$$x" = "dummy" ]; then continue; fi; \
784 $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
785 cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
786 chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
787 mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
788 $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
791 uninstall_runtime: uninstall_programs uninstall_runtime_libs
794 @$(ECHO) "*** Uninstalling runtime programs"
795 @set -e; for x in dummy $(INSTALL_PROGRAMS); \
797 if [ "$$x" = "dummy" ]; then continue; fi; \
799 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
800 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
802 @set -e; for x in dummy $(BIN_SCRIPTS); \
804 if [ "$$x" = "dummy" ]; then continue; fi; \
806 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
807 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
809 -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
811 uninstall_runtime_libs:
812 @$(ECHO) "*** Uninstalling runtime libraries"
813 @ : {- output_off() unless windowsdll(); "" -}
814 @set -e; for s in dummy $(INSTALL_SHLIBS); do \
815 if [ "$$s" = "dummy" ]; then continue; fi; \
817 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
818 $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
820 @ : {- output_on() unless windowsdll(); "" -}
824 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
825 @$(ECHO) "*** Installing manpages"
826 $(PERL) $(SRCDIR)/util/process_docs.pl \
827 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX)
830 @$(ECHO) "*** Uninstalling manpages"
831 $(PERL) $(SRCDIR)/util/process_docs.pl \
832 --destdir=$(DESTDIR)$(MANDIR) --type=man --suffix=$(MANSUFFIX) \
836 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
837 @$(ECHO) "*** Installing HTML manpages"
838 $(PERL) $(SRCDIR)/util/process_docs.pl \
839 --destdir=$(DESTDIR)$(HTMLDIR) --type=html
842 @$(ECHO) "*** Uninstalling manpages"
843 $(PERL) $(SRCDIR)/util/process_docs.pl \
844 --destdir=$(DESTDIR)$(HTMLDIR) --type=html --remove
847 # Developer targets (note: these are only available on Unix) #########
849 update: generate errors ordinals
851 generate: generate_apps generate_crypto_bn generate_crypto_objects \
852 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
856 (cd $(SRCDIR); $(PERL) util/find-doc-nits -n -p ) >doc-nits
857 @if [ -s doc-nits ] ; then cat doc-nits ; exit 1; \
858 else echo 'doc-nits: no errors.'; rm doc-nits ; fi
860 # Test coverage is a good idea for the future
861 #coverage: $(PROGRAMS) $(TESTPROGRAMS)
865 lint -DLINT $(INCLUDES) $(SRCS)
868 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
869 < apps/openssl.cnf > apps/openssl-vms.cnf )
872 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
874 generate_crypto_objects:
875 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
876 crypto/objects/objects.txt \
877 crypto/objects/obj_mac.num \
878 > crypto/objects/obj_mac.new && \
879 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
880 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
881 crypto/objects/objects.txt \
882 crypto/objects/obj_mac.num \
883 > include/openssl/obj_mac.h )
884 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
885 include/openssl/obj_mac.h \
886 > crypto/objects/obj_dat.h )
887 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
888 crypto/objects/obj_mac.num \
889 crypto/objects/obj_xref.txt \
890 > crypto/objects/obj_xref.h )
892 generate_crypto_conf:
893 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
894 > crypto/conf/conf_def.h )
896 generate_crypto_asn1:
897 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
898 > crypto/asn1/charmap.h )
901 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
902 crypto/objects/obj_dat.h \
905 # Set to -force to force a rebuild
908 ( b=`pwd`; set -e; cd $(SRCDIR); \
909 $(PERL) util/ck_errf.pl -strict -internal; \
910 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
911 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
913 $(PERL) ../util/ck_errf.pl -strict \
914 -conf $$E `basename $$E .ec`.c; \
915 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
916 -conf $$E `basename $$E .ec`.c ; \
920 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl crypto update )
921 ( b=`pwd`; cd $(SRCDIR); $(PERL) -I$$b util/mkdef.pl ssl update )
925 SRCTOP=../$(SRCDIR) \
926 BLDTOP=../$(BLDDIR) \
927 $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
932 -etags `find . -name '*.[ch]' -o -name '*.pm'`
934 # Release targets (note: only available on Unix) #####################
937 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
939 # Helper targets #####################################################
941 link-utils: $(BLDDIR)/util/opensslwrap.sh
943 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
944 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
945 mkdir -p "$(BLDDIR)/util"; \
946 ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
951 # Building targets ###################################################
953 libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { shlib_simple($_) } @{$unified_info{libraries}}) -}
955 @ ( echo 'prefix=$(INSTALLTOP)'; \
956 echo 'exec_prefix=$${prefix}'; \
957 if [ -n "$(LIBDIR)" ]; then \
958 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
960 echo 'libdir=$(libdir)'; \
962 echo 'includedir=$${prefix}/include'; \
963 echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
965 echo 'Name: OpenSSL-libcrypto'; \
966 echo 'Description: OpenSSL cryptography library'; \
967 echo 'Version: '$(VERSION); \
968 echo 'Libs: -L$${libdir} -lcrypto'; \
969 echo 'Libs.private: $(LIB_EX_LIBS)'; \
970 echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
973 @ ( echo 'prefix=$(INSTALLTOP)'; \
974 echo 'exec_prefix=$${prefix}'; \
975 if [ -n "$(LIBDIR)" ]; then \
976 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
978 echo 'libdir=$(libdir)'; \
980 echo 'includedir=$${prefix}/include'; \
982 echo 'Name: OpenSSL-libssl'; \
983 echo 'Description: Secure Sockets Layer and cryptography libraries'; \
984 echo 'Version: '$(VERSION); \
985 echo 'Requires.private: libcrypto'; \
986 echo 'Libs: -L$${libdir} -lssl'; \
987 echo 'Cflags: -I$${includedir}' ) > libssl.pc
990 @ ( echo 'prefix=$(INSTALLTOP)'; \
991 echo 'exec_prefix=$${prefix}'; \
992 if [ -n "$(LIBDIR)" ]; then \
993 echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
995 echo 'libdir=$(libdir)'; \
997 echo 'includedir=$${prefix}/include'; \
999 echo 'Name: OpenSSL'; \
1000 echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
1001 echo 'Version: '$(VERSION); \
1002 echo 'Requires: libssl libcrypto' ) > openssl.pc
1004 configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
1005 @echo "Detected changed: $?"
1006 $(PERL) configdata.pm -r
1007 @echo "**************************************************"
1009 @echo "*** Please run the same make command again ***"
1011 @echo "**************************************************"
1015 $(PERL) configdata.pm -r
1019 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
1021 # Helper function to figure out dependencies on libraries
1022 # It takes a list of library names and outputs a list of dependencies
1023 sub compute_lib_depends {
1024 if ($disabled{shared}) {
1025 return map { lib($_) } @_;
1028 # Depending on shared libraries:
1029 # On Windows POSIX layers, we depend on {libname}.dll.a
1030 # On Unix platforms, we depend on {shlibname}.so
1031 return map { $_ =~ /\.a$/ ? $`.$libext : shlib_simple($_) } @_;
1036 my $generator = join(" ", @{$args{generator}});
1037 my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
1038 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1039 my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
1041 if ($args{src} !~ /\.[sS]$/) {
1042 if ($args{generator}->[0] =~ m|^.*\.in$|) {
1043 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1044 "util", "dofile.pl")),
1045 rel2abs($config{builddir}));
1047 $args{src}: $args{generator}->[0] $deps
1048 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1049 "-o$target{build_file}" $generator > \$@
1053 $args{src}: $args{generator}->[0] $deps
1054 \$(PERL)$generator_incs $generator > \$@
1058 if ($args{generator}->[0] =~ /\.pl$/) {
1059 $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator;
1060 } elsif ($args{generator}->[0] =~ /\.m4$/) {
1061 $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
1062 } elsif ($args{generator}->[0] =~ /\.S$/) {
1065 die "Generator type for $args{src} unknown: $generator\n";
1069 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1070 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1071 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1072 } -> {$args{intent}};
1073 if (defined($generator)) {
1075 $args{src}: $args{generator}->[0] $deps
1080 $args{src}: $args{generator}->[0] $deps
1081 \$(CC) $incs $cppflags -E $args{generator}->[0] | \\
1082 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
1087 # Should one wonder about the end of the Perl snippet, it's because this
1088 # second regexp eats up line endings as well, if the removed path is the
1089 # last in the line. We may therefore need to put back a line ending.
1092 (my $obj = $args{obj}) =~ s|\.o$||;
1093 my @srcs = @{$args{srcs}};
1094 my $srcs = join(" ", @srcs);
1095 my $deps = join(" ", @srcs, @{$args{deps}});
1096 my $incs = join("", map { " -I".$_ } @{$args{incs}});
1100 if (grep /\.rc$/, @srcs) {
1102 $cmdflags = '$(RCFLAGS)';
1104 } elsif (grep /\.(cc|cpp)$/, @srcs) {
1106 $cmdcompile = ' -c';
1108 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
1109 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
1110 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
1111 } -> {$args{intent}};
1114 $cmdcompile = ' -c';
1116 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
1117 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
1118 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
1119 } -> {$args{intent}};
1122 # extension-specific rules
1123 if (grep /\.s$/, @srcs) {
1126 $cmd $cmdflags -c -o \$\@ $srcs
1128 } elsif (grep /\.S$/, @srcs) {
1129 # Originally there was mutli-step rule with $(CC) -E file.S
1130 # followed by $(CC) -c file.s. It compensated for one of
1131 # legacy platform compiler's inability to handle .S files.
1132 # The platform is long discontinued by vendor so there is
1133 # hardly a point to drag it along...
1136 $cmd $incs $cmdflags -c -o \$\@ $srcs
1138 } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
1139 && !grep /\.rc$/, @srcs) {
1142 $cmd $incs $cmdflags -MMD -MF $obj$depext.tmp -MT \$\@ -c -o \$\@ $srcs
1143 \@touch $obj$depext.tmp
1144 \@if cmp $obj$depext.tmp $obj$depext > /dev/null 2> /dev/null; then \\
1145 rm -f $obj$depext.tmp; \\
1147 mv $obj$depext.tmp $obj$depext; \\
1153 $cmd $incs $cmdflags $cmdcompile -o \$\@ $srcs
1155 if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
1157 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
1164 # We *know* this routine is only called when we've configure 'shared'.
1167 my $lib = $args{lib};
1168 my $shlib = $args{shlib};
1169 my $libd = dirname($lib);
1170 my $libn = basename($lib);
1171 (my $libname = $libn) =~ s/^lib//;
1173 foreach (@{args{deps}}) {
1174 my $d = dirname($_);
1175 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1177 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1178 my $linklibs = join("", map { my $f = basename($_);
1179 (my $l = $f) =~ s/^lib//;
1180 " -l$l" } @{$args{deps}});
1181 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1182 grep { $_ !~ m/\.(?:def|map)$/ }
1184 my @defs = grep { $_ =~ /\.(?:def|map)$/ } @{$args{objs}};
1185 my @deps = compute_lib_depends(@{$args{deps}});
1186 die "More than one exported symbol map" if scalar @defs > 1;
1187 my $objs = join(" ", @objs);
1188 my $deps = join(" ", @objs, @defs, @deps);
1189 my $simple = shlib_simple($lib);
1190 my $full = shlib($lib);
1191 my $target = "$simple $full";
1192 my $shared_soname = "";
1193 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
1194 if defined $target{shared_sonameflag};
1195 my $shared_imp = "";
1196 $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
1197 if defined $target{shared_impflag};
1198 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
1199 my $recipe = <<"EOF";
1201 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
1202 -o $full$shared_def $objs \\
1203 $linklibs \$(LIB_EX_LIBS)
1207 rm -f apps/$shlib'\$(SHLIB_EXT)'
1208 rm -f test/$shlib'\$(SHLIB_EXT)'
1209 rm -f fuzz/$shlib'\$(SHLIB_EXT)'
1210 cp -p $shlib'\$(SHLIB_EXT)' apps/
1211 cp -p $shlib'\$(SHLIB_EXT)' test/
1212 cp -p $shlib'\$(SHLIB_EXT)' fuzz/
1214 } elsif (sharedaix()) {
1217 \$(AR) r $simple $full
1221 if [ '$simple' != '$full' ]; then \\
1223 ln -s $full $simple; \\
1230 my $dso = $args{lib};
1231 my $dsod = dirname($dso);
1232 my $dson = basename($dso);
1234 foreach (@{args{deps}}) {
1235 my $d = dirname($_);
1236 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1238 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1239 my $linklibs = join("", map { my $f = basename($_);
1240 (my $l = $f) =~ s/^lib//;
1241 " -l$l" } @{$args{deps}});
1242 my @objs = map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1243 grep { $_ !~ m/\.(?:def|map)$/ }
1245 my @deps = compute_lib_depends(@{$args{deps}});
1246 my $objs = join(" ", @objs);
1247 my $deps = join(" ", @deps);
1248 my $target = dso($dso);
1250 $target: $objs $deps
1251 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
1253 $linklibs \$(DSO_EX_LIBS)
1258 (my $lib = $args{lib}) =~ s/\.a$//;
1259 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
1260 my $objs = join(" ", @objs);
1263 \$(AR) \$(ARFLAGS) \$\@ \$\?
1264 \$(RANLIB) \$\@ || echo Never mind.
1269 my $bin = $args{bin};
1270 my $bind = dirname($bin);
1271 my $binn = basename($bin);
1272 my $objs = join(" ", map { (my $x = $_) =~ s|\.o$||; "$x$objext" }
1274 my $deps = join(" ",compute_lib_depends(@{$args{deps}}));
1276 foreach (@{args{deps}}) {
1277 next if $_ =~ /\.a$/;
1278 my $d = dirname($_);
1279 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
1281 my $linkflags = join("", map { "-L$_ " } @linkdirs);
1282 my $linklibs = join("", map { if ($_ =~ s/\.a$//) {
1285 my $f = basename($_);
1286 (my $l = $f) =~ s/^lib//;
1291 my $cmdflags = '$(BIN_CFLAGS)';
1292 if (grep /_cc\.o$/, @{$args{objs}}) {
1294 $cmdflags = '$(BIN_CXXFLAGS)';
1297 $bin$exeext: $objs $deps
1299 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
1300 -o $bin$exeext $objs \\
1301 $linklibs \$(BIN_EX_LIBS)
1306 my $script = $args{script};
1307 my $sources = join(" ", @{$args{sources}});
1308 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1309 "util", "dofile.pl")),
1310 rel2abs($config{builddir}));
1313 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1314 "-o$target{build_file}" $sources > "$script"
1320 my $dir = $args{dir};
1321 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
1323 my %extinfo = ( dso => $dsoext,
1327 # We already have a 'test' target, and the top directory is just plain
1329 return if $dir eq "test" || $dir eq ".";
1331 foreach my $type (("dso", "lib", "bin", "script")) {
1332 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1333 # For lib object files, we could update the library. However, it
1334 # was decided that it's enough to build the directory local object
1335 # files, so we don't need to add any actions, and the dependencies
1336 # are already taken care of.
1337 if ($type ne "lib") {
1338 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1339 if (dirname($prod) eq $dir) {
1340 push @deps, $prod.$extinfo{$type};
1342 push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
1348 my $deps = join(" ", @deps);
1349 my $actions = join("\n", "", @actions);
1351 $dir $dir/: $deps$actions
1354 "" # Important! This becomes part of the template result.