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