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