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