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