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