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