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