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