]>
Commit | Line | Data |
---|---|---|
1 | ## | |
2 | ## Makefile for OpenSSL | |
3 | ## | |
4 | ## {- join("\n## ", @autowarntext) -} | |
5 | {- | |
6 | our $makedepprog = platform->makedepprog(); | |
7 | ||
8 | sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ } | |
9 | ||
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 | ||
14 | our $sover_dirname = platform->shlib_version_as_filename(); | |
15 | ||
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 | } | |
23 | ||
24 | our $COLUMNS = $ENV{COLUMNS}; | |
25 | if ($COLUMNS =~ /^\d+$/) { | |
26 | $COLUMNS = int($COLUMNS) - 2; # 2 to leave space for ending ' \' | |
27 | } else { | |
28 | $COLUMNS = 76; | |
29 | } | |
30 | ||
31 | sub fill_lines { | |
32 | my $item_sep = shift; # string | |
33 | my $line_length = shift; # number of chars | |
34 | ||
35 | my @result = (); | |
36 | my $resultpos = 0; | |
37 | ||
38 | foreach (@_) { | |
39 | my $fill_line = $result[$resultpos] // ''; | |
40 | my $newline = | |
41 | ($fill_line eq '' ? '' : $fill_line . $item_sep) . $_; | |
42 | ||
43 | if (length($newline) > $line_length) { | |
44 | # If this is a single item and the intended result line | |
45 | # is empty, we put it there anyway | |
46 | if ($fill_line eq '') { | |
47 | $result[$resultpos++] = $newline; | |
48 | } else { | |
49 | $result[++$resultpos] = $_; | |
50 | } | |
51 | } else { | |
52 | $result[$resultpos] = $newline; | |
53 | } | |
54 | } | |
55 | return @result; | |
56 | } | |
57 | ''; | |
58 | -} | |
59 | PLATFORM={- $config{target} -} | |
60 | OPTIONS={- $config{options} -} | |
61 | CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -}) | |
62 | SRCDIR={- $config{sourcedir} -} | |
63 | BLDDIR={- $config{builddir} -} | |
64 | FIPSKEY={- $config{FIPSKEY} -} | |
65 | ||
66 | VERSION={- "$config{full_version}" -} | |
67 | MAJOR={- $config{major} -} | |
68 | MINOR={- $config{minor} -} | |
69 | SHLIB_VERSION_NUMBER={- $config{shlib_version} -} | |
70 | SHLIB_TARGET={- $target{shared_target} -} | |
71 | ||
72 | LIBS={- join(" \\\n" . ' ' x 5, | |
73 | fill_lines(" ", $COLUMNS - 5, | |
74 | map { platform->staticlib($_) // () } | |
75 | @{$unified_info{libraries}})) -} | |
76 | SHLIBS={- join(" \\\n" . ' ' x 7, | |
77 | fill_lines(" ", $COLUMNS - 7, | |
78 | map { platform->sharedlib($_) // () } | |
79 | @{$unified_info{libraries}})) -} | |
80 | SHLIB_INFO={- join(" \\\n" . ' ' x 11, | |
81 | fill_lines(" ", $COLUMNS - 11, | |
82 | map { my $x = platform->sharedlib($_); | |
83 | my $y = platform->sharedlib_simple($_) // ''; | |
84 | my $z = platform->sharedlib_import($_) // ''; | |
85 | $x ? "\"$x;$y;$z\"" : () } | |
86 | @{$unified_info{libraries}})) -} | |
87 | MODULES={- join(" \\\n" . ' ' x 8, | |
88 | fill_lines(" ", $COLUMNS - 8, | |
89 | map { platform->dso($_) } | |
90 | @{$unified_info{modules}})) -} | |
91 | FIPSMODULENAME={- # We do some extra checking here, as there should be only one | |
92 | my @fipsmodules = | |
93 | grep { !$unified_info{attributes}->{modules}->{$_}->{noinst} | |
94 | && $unified_info{attributes}->{modules}->{$_}->{fips} } | |
95 | @{$unified_info{modules}}; | |
96 | die "More that one FIPS module" if scalar @fipsmodules > 1; | |
97 | join(" ", map { basename platform->dso($_) } @fipsmodules) -} | |
98 | ||
99 | PROGRAMS={- join(" \\\n" . ' ' x 9, | |
100 | fill_lines(" ", $COLUMNS - 9, | |
101 | map { platform->bin($_) } | |
102 | @{$unified_info{programs}})) -} | |
103 | SCRIPTS={- join(" \\\n" . ' ' x 8, | |
104 | fill_lines(" ", $COLUMNS - 8, @{$unified_info{scripts}})) -} | |
105 | {- output_off() if $disabled{makedepend}; "" -} | |
106 | DEPS={- join(" \\\n" . ' ' x 5, | |
107 | fill_lines(" ", $COLUMNS - 5, | |
108 | map { platform->isobj($_) ? platform->dep($_) : () } | |
109 | grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } | |
110 | keys %{$unified_info{sources}})); -} | |
111 | {- output_on() if $disabled{makedepend}; "" -} | |
112 | GENERATED_MANDATORY={- join(" \\\n" . ' ' x 20, | |
113 | fill_lines(" ", $COLUMNS - 20, | |
114 | @{$unified_info{depends}->{""}})) -} | |
115 | GENERATED_PODS={- # common0.tmpl provides @generated | |
116 | join(" \\\n" . ' ' x 15, | |
117 | fill_lines(" ", $COLUMNS - 15, | |
118 | map { my $x = $_; | |
119 | ( | |
120 | grep { | |
121 | $unified_info{attributes}->{depends} | |
122 | ->{$x}->{$_}->{pod} // 0 | |
123 | } | |
124 | keys %{$unified_info{attributes}->{depends}->{$x}} | |
125 | ) ? $x : (); | |
126 | } | |
127 | @generated)) -} | |
128 | GENERATED={- # common0.tmpl provides @generated | |
129 | join(" \\\n" . ' ' x 5, | |
130 | fill_lines(" ", $COLUMNS - 5, | |
131 | map { platform->convertext($_) } @generated )) -} | |
132 | ||
133 | INSTALL_LIBS={- | |
134 | join(" \\\n" . ' ' x 13, | |
135 | fill_lines(" ", $COLUMNS - 13, | |
136 | map { platform->staticlib($_) // () } | |
137 | grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} } | |
138 | @{$unified_info{libraries}})) | |
139 | -} | |
140 | INSTALL_SHLIBS={- | |
141 | join(" \\\n" . ' ' x 15, | |
142 | fill_lines(" ", $COLUMNS - 15, | |
143 | map { platform->sharedlib($_) // () } | |
144 | grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} } | |
145 | @{$unified_info{libraries}})) | |
146 | -} | |
147 | INSTALL_SHLIB_INFO={- | |
148 | join(" \\\n" . ' ' x 19, | |
149 | fill_lines(" ", $COLUMNS - 19, | |
150 | map { my $x = platform->sharedlib($_); | |
151 | my $y = platform->sharedlib_simple($_) // ''; | |
152 | my $z = platform->sharedlib_import($_) // ''; | |
153 | $x ? "\"$x;$y;$z\"" : () } | |
154 | grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} } | |
155 | @{$unified_info{libraries}})) | |
156 | -} | |
157 | INSTALL_ENGINES={- | |
158 | join(" \\\n" . ' ' x 16, | |
159 | fill_lines(" ", $COLUMNS - 16, | |
160 | map { platform->dso($_) } | |
161 | grep { !$unified_info{attributes}->{modules}->{$_}->{noinst} | |
162 | && $unified_info{attributes}->{modules}->{$_}->{engine} } | |
163 | @{$unified_info{modules}})) | |
164 | -} | |
165 | INSTALL_MODULES={- | |
166 | join(" \\\n" . ' ' x 16, | |
167 | fill_lines(" ", $COLUMNS - 16, | |
168 | map { platform->dso($_) } | |
169 | grep { !$unified_info{attributes}->{modules}->{$_}->{noinst} | |
170 | && !$unified_info{attributes}->{modules}->{$_}->{engine} } | |
171 | @{$unified_info{modules}})) | |
172 | -} | |
173 | INSTALL_PROGRAMS={- | |
174 | join(" \\\n" . ' ' x 16, | |
175 | fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) } | |
176 | grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} } | |
177 | @{$unified_info{programs}})) | |
178 | -} | |
179 | BIN_SCRIPTS={- | |
180 | join(" \\\n" . ' ' x 12, | |
181 | fill_lines(" ", $COLUMNS - 12, | |
182 | map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname}; | |
183 | $x ? "$_:$x" : $_ } | |
184 | grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst} | |
185 | && !$unified_info{attributes}->{scripts}->{$_}->{misc} } | |
186 | @{$unified_info{scripts}})) | |
187 | -} | |
188 | MISC_SCRIPTS={- | |
189 | join(" \\\n" . ' ' x 13, | |
190 | fill_lines(" ", $COLUMNS - 13, | |
191 | map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname}; | |
192 | $x ? "$_:$x" : $_ } | |
193 | grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst} | |
194 | && $unified_info{attributes}->{scripts}->{$_}->{misc} } | |
195 | @{$unified_info{scripts}})) | |
196 | -} | |
197 | HTMLDOCS1={- | |
198 | join(" \\\n" . ' ' x 10, | |
199 | fill_lines(" ", $COLUMNS - 10, | |
200 | @{$unified_info{htmldocs}->{man1}})) -} | |
201 | HTMLDOCS3={- | |
202 | join(" \\\n" . ' ' x 10, | |
203 | fill_lines(" ", $COLUMNS - 10, | |
204 | @{$unified_info{htmldocs}->{man3}})) -} | |
205 | HTMLDOCS5={- | |
206 | join(" \\\n" . ' ' x 10, | |
207 | fill_lines(" ", $COLUMNS - 10, | |
208 | @{$unified_info{htmldocs}->{man5}})) -} | |
209 | HTMLDOCS7={- | |
210 | join(" \\\n" . ' ' x 10, | |
211 | fill_lines(" ", $COLUMNS - 10, | |
212 | @{$unified_info{htmldocs}->{man7}})) -} | |
213 | MANDOCS1={- | |
214 | join(" \\\n" . ' ' x 9, | |
215 | fill_lines(" ", $COLUMNS - 9, | |
216 | @{$unified_info{mandocs}->{man1}})) -} | |
217 | MANDOCS3={- | |
218 | join(" \\\n" . ' ' x 9, | |
219 | fill_lines(" ", $COLUMNS - 9, | |
220 | @{$unified_info{mandocs}->{man3}})) -} | |
221 | MANDOCS5={- | |
222 | join(" \\\n" . ' ' x 9, | |
223 | fill_lines(" ", $COLUMNS - 9, | |
224 | @{$unified_info{mandocs}->{man5}})) -} | |
225 | MANDOCS7={- | |
226 | join(" \\\n" . ' ' x 9, | |
227 | fill_lines(" ", $COLUMNS - 9, | |
228 | @{$unified_info{mandocs}->{man7}})) -} | |
229 | ||
230 | APPS_OPENSSL="{- use File::Spec::Functions; | |
231 | catfile("apps","openssl") -}" | |
232 | ||
233 | # DESTDIR is for package builders so that they can configure for, say, | |
234 | # /usr/ and yet have everything installed to /tmp/somedir/usr/. | |
235 | # Normally it is left empty. | |
236 | DESTDIR= | |
237 | ||
238 | # Do not edit these manually. Use Configure with --prefix or --openssldir | |
239 | # to change this! Short explanation in the top comment in Configure | |
240 | INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet | |
241 | # | |
242 | our $prefix = $config{prefix} || "/usr/local"; | |
243 | $prefix -} | |
244 | OPENSSLDIR={- # | |
245 | # The logic here is that if no --openssldir was given, | |
246 | # OPENSSLDIR will get the value from $prefix plus "/ssl". | |
247 | # If --openssldir was given and the value is an absolute | |
248 | # path, OPENSSLDIR will get its value without change. | |
249 | # If the value from --openssldir is a relative path, | |
250 | # OPENSSLDIR will get $prefix with the --openssldir | |
251 | # value appended as a subdirectory. | |
252 | # | |
253 | use File::Spec::Functions; | |
254 | our $openssldir = | |
255 | $config{openssldir} ? | |
256 | (file_name_is_absolute($config{openssldir}) ? | |
257 | $config{openssldir} | |
258 | : catdir($prefix, $config{openssldir})) | |
259 | : catdir($prefix, "ssl"); | |
260 | $openssldir -} | |
261 | LIBDIR={- our $libdir = $config{libdir}; | |
262 | unless ($libdir) { | |
263 | # | |
264 | # if $prefix/lib$target{multilib} is not an existing | |
265 | # directory, then assume that it's not searched by linker | |
266 | # automatically, in which case adding $target{multilib} suffix | |
267 | # causes more grief than we're ready to tolerate, so don't... | |
268 | our $multilib = | |
269 | -d "$prefix/lib$target{multilib}" ? $target{multilib} : ""; | |
270 | $libdir = "lib$multilib"; | |
271 | } | |
272 | file_name_is_absolute($libdir) ? "" : $libdir -} | |
273 | # $(libdir) is chosen to be compatible with the GNU coding standards | |
274 | libdir={- file_name_is_absolute($libdir) | |
275 | ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -} | |
276 | ENGINESDIR=$(libdir)/engines-{- $sover_dirname -} | |
277 | MODULESDIR=$(libdir)/ossl-modules | |
278 | ||
279 | # Convenience variable for those who want to set the rpath in shared | |
280 | # libraries and applications | |
281 | LIBRPATH=$(libdir) | |
282 | ||
283 | MANDIR=$(INSTALLTOP)/share/man | |
284 | DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME) | |
285 | HTMLDIR=$(DOCDIR)/html | |
286 | ||
287 | # MANSUFFIX is for the benefit of anyone who may want to have a suffix | |
288 | # appended after the manpage file section number. "ssl" is popular, | |
289 | # resulting in files such as config.5ssl rather than config.5. | |
290 | MANSUFFIX= | |
291 | HTMLSUFFIX=html | |
292 | ||
293 | # For "optional" echo messages, to get "real" silence | |
294 | ECHO = echo | |
295 | ||
296 | ##### User defined commands and flags ################################ | |
297 | ||
298 | # We let the C compiler driver to take care of .s files. This is done in | |
299 | # order to be excused from maintaining a separate set of architecture | |
300 | # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC | |
301 | # gcc, then the driver will automatically translate it to -xarch=v8plus | |
302 | # and pass it down to assembler. In any case, we do not define AS or | |
303 | # ASFLAGS for this reason. | |
304 | ||
305 | CROSS_COMPILE={- $config{CROSS_COMPILE} -} | |
306 | CC=$(CROSS_COMPILE){- $config{CC} -} | |
307 | CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -} | |
308 | CPPFLAGS={- our $cppflags1 = join(" ", | |
309 | (map { "-D".$_} @{$config{CPPDEFINES}}), | |
310 | (map { "-I".$_} @{$config{CPPINCLUDES}}), | |
311 | @{$config{CPPFLAGS}}) -} | |
312 | CFLAGS={- join(' ', @{$config{CFLAGS}}) -} | |
313 | CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -} | |
314 | LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -} | |
315 | EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -} | |
316 | ||
317 | MAKEDEPEND={- $config{makedepprog} -} | |
318 | ||
319 | PERL={- $config{PERL} -} | |
320 | ||
321 | AR=$(CROSS_COMPILE){- $config{AR} -} | |
322 | ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -} | |
323 | RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -} | |
324 | RC= $(CROSS_COMPILE){- $config{RC} -} | |
325 | RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -} | |
326 | ||
327 | RM= rm -f | |
328 | RMDIR= rmdir | |
329 | TAR= {- $target{TAR} || "tar" -} | |
330 | TARFLAGS= {- $target{TARFLAGS} -} | |
331 | ||
332 | BASENAME= openssl | |
333 | NAME= $(BASENAME)-$(VERSION) | |
334 | # Relative to $(SRCDIR) | |
335 | TARFILE= ../$(NAME).tar | |
336 | ||
337 | ##### Project flags ################################################## | |
338 | ||
339 | # Variables starting with CNF_ are common variables for all product types | |
340 | ||
341 | CNF_CPPFLAGS={- our $cppflags2 = | |
342 | join(' ', $target{cppflags} || (), | |
343 | (map { "-D".$_} @{$target{defines}}, | |
344 | @{$config{defines}}), | |
345 | (map { "-I".$_} @{$target{includes}}, | |
346 | @{$config{includes}}), | |
347 | @{$config{cppflags}}) -} | |
348 | CNF_CFLAGS={- join(' ', $target{cflags} || (), | |
349 | @{$config{cflags}}) -} | |
350 | CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (), | |
351 | @{$config{cxxflags}}) -} | |
352 | CNF_LDFLAGS={- join(' ', $target{lflags} || (), | |
353 | @{$config{lflags}}) -} | |
354 | CNF_EX_LIBS={- join(' ', $target{ex_libs} || (), | |
355 | @{$config{ex_libs}}) -} | |
356 | ||
357 | # Variables starting with LIB_ are used to build library object files | |
358 | # and shared libraries. | |
359 | # Variables starting with DSO_ are used to build DSOs and their object files. | |
360 | # Variables starting with BIN_ are used to build programs and their object | |
361 | # files. | |
362 | ||
363 | LIB_CPPFLAGS={- our $lib_cppflags = | |
364 | join(' ', $target{lib_cppflags} || (), | |
365 | $target{shared_cppflag} || (), | |
366 | (map { '-D'.$_ } | |
367 | @{$target{lib_defines} || ()}, | |
368 | @{$target{shared_defines} || ()}, | |
369 | @{$config{lib_defines} || ()}, | |
370 | @{$config{shared_defines} || ()}), | |
371 | (map { '-I'.quotify1($_) } | |
372 | @{$target{lib_includes}}, | |
373 | @{$target{shared_includes}}, | |
374 | @{$config{lib_includes}}, | |
375 | @{$config{shared_includes}}), | |
376 | @{$config{lib_cppflags}}, | |
377 | @{$config{shared_cppflag}}); | |
378 | join(' ', $lib_cppflags, | |
379 | (map { '-D'.$_ } | |
380 | 'OPENSSLDIR="\"$(OPENSSLDIR)\""', | |
381 | 'ENGINESDIR="\"$(ENGINESDIR)\""', | |
382 | 'MODULESDIR="\"$(MODULESDIR)\""'), | |
383 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} | |
384 | LIB_CFLAGS={- join(' ', $target{lib_cflags} || (), | |
385 | $target{shared_cflag} || (), | |
386 | @{$config{lib_cflags}}, | |
387 | @{$config{shared_cflag}}, | |
388 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} | |
389 | LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (), | |
390 | $target{shared_cxxflag} || (), | |
391 | @{$config{lib_cxxflags}}, | |
392 | @{$config{shared_cxxflag}}, | |
393 | '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} | |
394 | LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (), | |
395 | $config{shared_ldflag} || (), | |
396 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} | |
397 | LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) | |
398 | DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (), | |
399 | $target{module_cppflags} || (), | |
400 | (map { '-D'.$_ } | |
401 | @{$target{dso_defines}}, | |
402 | @{$target{module_defines}}, | |
403 | @{$config{dso_defines} || ()}, | |
404 | @{$config{module_defines} || ()}), | |
405 | (map { '-I'.quotify1($_) } | |
406 | @{$target{dso_includes}}, | |
407 | @{$target{module_includes}}, | |
408 | @{$config{dso_includes}}, | |
409 | @{$config{module_includes}}), | |
410 | @{$config{dso_cppflags}}, | |
411 | @{$config{module_cppflags}}, | |
412 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} | |
413 | DSO_CFLAGS={- join(' ', $target{dso_cflags} || (), | |
414 | $target{module_cflags} || (), | |
415 | @{$config{dso_cflags}}, | |
416 | @{$config{module_cflags}}, | |
417 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} | |
418 | DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (), | |
419 | $target{module_cxxflags} || (), | |
420 | @{$config{dso_cxxflags}}, | |
421 | @{$config{module_cxxflag}}, | |
422 | '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} | |
423 | DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (), | |
424 | $target{module_ldflags} || (), | |
425 | @{$config{dso_ldflags}}, | |
426 | @{$config{module_ldflags}}, | |
427 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} | |
428 | DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) | |
429 | BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (), | |
430 | (map { '-D'.$_ } @{$config{bin_defines} || ()}), | |
431 | @{$config{bin_cppflags}}, | |
432 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} | |
433 | BIN_CFLAGS={- join(' ', $target{bin_cflags} || (), | |
434 | @{$config{bin_cflags}}, | |
435 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} | |
436 | BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (), | |
437 | @{$config{bin_cxxflags}}, | |
438 | '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} | |
439 | BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (), | |
440 | @{$config{bin_lflags}}, | |
441 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} | |
442 | BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) | |
443 | ||
444 | # CPPFLAGS_Q is used for one thing only: to build up buildinf.h | |
445 | CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g; | |
446 | $cppflags2 =~ s|([\\"])|\\$1|g; | |
447 | $lib_cppflags =~ s|([\\"])|\\$1|g; | |
448 | join(' ', $lib_cppflags || (), $cppflags2 || (), | |
449 | $cppflags1 || ()) -} | |
450 | ||
451 | PERLASM_SCHEME= {- $target{perlasm_scheme} -} | |
452 | ||
453 | # For x86 assembler: Set PROCESSOR to 386 if you want to support | |
454 | # the 80386. | |
455 | PROCESSOR= {- $config{processor} -} | |
456 | ||
457 | # We want error [and other] messages in English. Trouble is that make(1) | |
458 | # doesn't pass macros down as environment variables unless there already | |
459 | # was corresponding variable originally set. In other words we can only | |
460 | # reassign environment variables, but not set new ones, not in portable | |
461 | # manner that is. That's why we reassign several, just to be sure... | |
462 | LC_ALL=C | |
463 | LC_MESSAGES=C | |
464 | LANG=C | |
465 | ||
466 | # The main targets ################################################### | |
467 | ||
468 | {- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils | |
469 | {- dependmagic('build_libs'); -}: build_libs_nodep | |
470 | {- dependmagic('build_modules'); -}: build_modules_nodep | |
471 | {- dependmagic('build_programs'); -}: build_programs_nodep | |
472 | ||
473 | build_generated_pods: $(GENERATED_PODS) | |
474 | build_docs: build_man_docs build_html_docs | |
475 | build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) | |
476 | build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) | |
477 | ||
478 | build_generated: $(GENERATED_MANDATORY) | |
479 | build_libs_nodep: libcrypto.pc libssl.pc openssl.pc | |
480 | build_modules_nodep: $(MODULES) | |
481 | build_programs_nodep: $(PROGRAMS) $(SCRIPTS) | |
482 | ||
483 | # Kept around for backward compatibility | |
484 | build_apps build_tests: build_programs | |
485 | ||
486 | # Convenience target to prebuild all generated files, not just the mandatory | |
487 | # ones | |
488 | build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs | |
489 | @ : {- output_off() if $disabled{makedepend}; "" -} | |
490 | @echo "Warning: consider configuring with no-makedepend, because if" | |
491 | @echo " target system doesn't have $(PERL)," | |
492 | @echo " then make will fail..." | |
493 | @ : {- output_on() if $disabled{makedepend}; "" -} | |
494 | ||
495 | all: build_sw build_docs | |
496 | ||
497 | test: tests | |
498 | {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils | |
499 | @ : {- output_off() if $disabled{tests}; "" -} | |
500 | ( SRCTOP=$(SRCDIR) \ | |
501 | BLDTOP=$(BLDDIR) \ | |
502 | PERL="$(PERL)" \ | |
503 | FIPSKEY="$(FIPSKEY)" \ | |
504 | EXE_EXT={- platform->binext() -} \ | |
505 | $(PERL) $(SRCDIR)/test/run_tests.pl $(TESTS) ) | |
506 | @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} | |
507 | @echo "Tests are not supported with your chosen Configure options" | |
508 | @ : {- output_on() if !$disabled{tests}; "" -} | |
509 | ||
510 | list-tests: | |
511 | @ : {- output_off() if $disabled{tests}; "" -} | |
512 | @SRCTOP="$(SRCDIR)" \ | |
513 | $(PERL) $(SRCDIR)/test/run_tests.pl list | |
514 | @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} | |
515 | @echo "Tests are not supported with your chosen Configure options" | |
516 | @ : {- output_on() if !$disabled{tests}; "" -} | |
517 | ||
518 | install: install_sw install_ssldirs install_docs | |
519 | ||
520 | uninstall: uninstall_docs uninstall_sw | |
521 | ||
522 | libclean: | |
523 | @set -e; for s in $(SHLIB_INFO); do \ | |
524 | if [ "$$s" = ";" ]; then continue; fi; \ | |
525 | s1=`echo "$$s" | cut -f1 -d";"`; \ | |
526 | s2=`echo "$$s" | cut -f2 -d";"`; \ | |
527 | s3=`echo "$$s" | cut -f3 -d";"`; \ | |
528 | $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\ | |
529 | $(RM) apps/$$s1; \ | |
530 | $(RM) test/$$s1; \ | |
531 | $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\ | |
532 | $(RM) $$s1; \ | |
533 | if [ "$$s2" != "" ]; then \ | |
534 | $(ECHO) $(RM) $$s2; \ | |
535 | $(RM) $$s2; \ | |
536 | fi; \ | |
537 | if [ "$$s3" != "" ]; then \ | |
538 | $(ECHO) $(RM) $$s3; \ | |
539 | $(RM) $$s3; \ | |
540 | fi; \ | |
541 | done | |
542 | $(RM) $(LIBS) | |
543 | $(RM) *{- platform->defext() -} | |
544 | ||
545 | clean: libclean | |
546 | $(RM) $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) | |
547 | $(RM) $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) | |
548 | $(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(SCRIPTS) | |
549 | $(RM) $(GENERATED_MANDATORY) $(GENERATED) | |
550 | -find . -name '*{- platform->depext() -}' \! -name '.*' \! -type d -exec $(RM) {} \; | |
551 | -find . -name '*{- platform->objext() -}' \! -name '.*' \! -type d -exec $(RM) {} \; | |
552 | $(RM) core | |
553 | $(RM) tags TAGS doc-nits cmd-nits md-nits | |
554 | $(RM) -r test/test-runs | |
555 | $(RM) openssl.pc libcrypto.pc libssl.pc | |
556 | -find . -type l \! -name '.*' -exec $(RM) {} \; | |
557 | $(RM) $(TARFILE) | |
558 | ||
559 | distclean: clean | |
560 | $(RM) configdata.pm | |
561 | $(RM) Makefile | |
562 | ||
563 | # We check if any depfile is newer than Makefile and decide to | |
564 | # concatenate only if that is true. | |
565 | depend: | |
566 | @: {- output_off() if $disabled{makedepend}; "" -} | |
567 | @$(PERL) $(SRCDIR)/util/add-depends.pl {- | |
568 | defined $makedepprog && $makedepprog =~ /\/makedepend/ | |
569 | ? 'makedepend' : 'gcc' -} | |
570 | @: {- output_on() if $disabled{makedepend}; "" -} | |
571 | ||
572 | # Install helper targets ############################################# | |
573 | ||
574 | install_sw: install_dev install_engines install_modules install_runtime | |
575 | ||
576 | uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev | |
577 | ||
578 | install_docs: install_man_docs install_html_docs | |
579 | ||
580 | uninstall_docs: uninstall_man_docs uninstall_html_docs | |
581 | $(RM) -r $(DESTDIR)$(DOCDIR) | |
582 | ||
583 | install_fips: install_sw | |
584 | @$(ECHO) "*** Installing FIPS module configuration" | |
585 | @$(ECHO) "fipsinstall $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf" | |
586 | @openssl fipsinstall -module $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME) \ | |
587 | -out $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf \ | |
588 | -macopt 'key:$(FIPSKEY)' | |
589 | ||
590 | uninstall_fips: uninstall_sw | |
591 | @$(ECHO) "*** Uninstalling FIPS module configuration" | |
592 | @$(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf" | |
593 | @$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf | |
594 | ||
595 | install_ssldirs: | |
596 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs | |
597 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private | |
598 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc | |
599 | @set -e; for x in dummy $(MISC_SCRIPTS); do \ | |
600 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
601 | x1=`echo "$$x" | cut -f1 -d:`; \ | |
602 | x2=`echo "$$x" | cut -f2 -d:`; \ | |
603 | fn=`basename $$x1`; \ | |
604 | $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ | |
605 | cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \ | |
606 | chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \ | |
607 | mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \ | |
608 | $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \ | |
609 | if [ "$$x1" != "$$x2" ]; then \ | |
610 | ln=`basename "$$x2"`; \ | |
611 | : {- output_off() unless windowsdll(); "" -}; \ | |
612 | $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ | |
613 | cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \ | |
614 | : {- output_on() unless windowsdll(); | |
615 | output_off() if windowsdll(); "" -}; \ | |
616 | $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ | |
617 | ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \ | |
618 | : {- output_on() if windowsdll(); "" -}; \ | |
619 | fi; \ | |
620 | done | |
621 | @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist" | |
622 | @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new | |
623 | @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new | |
624 | @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist | |
625 | @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \ | |
626 | $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \ | |
627 | cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \ | |
628 | chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \ | |
629 | fi | |
630 | @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist" | |
631 | @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new | |
632 | @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new | |
633 | @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist | |
634 | @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \ | |
635 | $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \ | |
636 | cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \ | |
637 | chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \ | |
638 | fi | |
639 | ||
640 | install_dev: install_runtime_libs | |
641 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
642 | @$(ECHO) "*** Installing development files" | |
643 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl | |
644 | @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -} | |
645 | @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" | |
646 | @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c | |
647 | @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c | |
648 | @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -} | |
649 | @set -e; for i in $(SRCDIR)/include/openssl/*.h \ | |
650 | $(BLDDIR)/include/openssl/*.h; do \ | |
651 | fn=`basename $$i`; \ | |
652 | $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ | |
653 | cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ | |
654 | chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ | |
655 | done | |
656 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir) | |
657 | @set -e; for l in $(INSTALL_LIBS); do \ | |
658 | fn=`basename $$l`; \ | |
659 | $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \ | |
660 | cp $$l $(DESTDIR)$(libdir)/$$fn.new; \ | |
661 | $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \ | |
662 | chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \ | |
663 | mv -f $(DESTDIR)$(libdir)/$$fn.new \ | |
664 | $(DESTDIR)$(libdir)/$$fn; \ | |
665 | done | |
666 | @ : {- output_off() if $disabled{shared}; "" -} | |
667 | @set -e; for s in $(INSTALL_SHLIB_INFO); do \ | |
668 | s1=`echo "$$s" | cut -f1 -d";"`; \ | |
669 | s2=`echo "$$s" | cut -f2 -d";"`; \ | |
670 | s3=`echo "$$s" | cut -f3 -d";"`; \ | |
671 | fn1=`basename "$$s1"`; \ | |
672 | fn2=`basename "$$s2"`; \ | |
673 | fn3=`basename "$$s3"`; \ | |
674 | : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \ | |
675 | if [ "$$fn2" != "" ]; then \ | |
676 | $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \ | |
677 | ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \ | |
678 | fi; \ | |
679 | : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \ | |
680 | if [ "$$fn3" != "" ]; then \ | |
681 | $(ECHO) "install $$s3 -> $(DESTDIR)$(libdir)/$$fn3"; \ | |
682 | cp $$s3 $(DESTDIR)$(libdir)/$$fn3.new; \ | |
683 | chmod 755 $(DESTDIR)$(libdir)/$$fn3.new; \ | |
684 | mv -f $(DESTDIR)$(libdir)/$$fn3.new \ | |
685 | $(DESTDIR)$(libdir)/$$fn3; \ | |
686 | fi; \ | |
687 | : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \ | |
688 | a=$(DESTDIR)$(libdir)/$$fn2; \ | |
689 | $(ECHO) "install $$s1 -> $$a"; \ | |
690 | if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \ | |
691 | mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \ | |
692 | cp -f $$a $$a.new; \ | |
693 | for so in `$(AR) t $$a`; do \ | |
694 | $(AR) x $$a $$so; \ | |
695 | chmod u+w $$so; \ | |
696 | strip -X32_64 -e $$so; \ | |
697 | $(AR) r $$a.new $$so; \ | |
698 | done; \ | |
699 | )); fi; \ | |
700 | $(AR) r $$a.new $$s1; \ | |
701 | mv -f $$a.new $$a; \ | |
702 | : {- output_off() if sharedaix(); output_on(); "" -}; \ | |
703 | done | |
704 | @ : {- output_on() if $disabled{shared}; "" -} | |
705 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig | |
706 | @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc" | |
707 | @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig | |
708 | @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc | |
709 | @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc" | |
710 | @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig | |
711 | @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc | |
712 | @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc" | |
713 | @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig | |
714 | @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc | |
715 | ||
716 | uninstall_dev: uninstall_runtime_libs | |
717 | @$(ECHO) "*** Uninstalling development files" | |
718 | @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -} | |
719 | @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" | |
720 | @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c | |
721 | @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -} | |
722 | @set -e; for i in $(SRCDIR)/include/openssl/*.h \ | |
723 | $(BLDDIR)/include/openssl/*.h; do \ | |
724 | fn=`basename $$i`; \ | |
725 | $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ | |
726 | $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \ | |
727 | done | |
728 | -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl | |
729 | -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include | |
730 | @set -e; for l in $(INSTALL_LIBS); do \ | |
731 | fn=`basename $$l`; \ | |
732 | $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \ | |
733 | $(RM) $(DESTDIR)$(libdir)/$$fn; \ | |
734 | done | |
735 | @ : {- output_off() if $disabled{shared}; "" -} | |
736 | @set -e; for s in $(INSTALL_SHLIB_INFO); do \ | |
737 | s1=`echo "$$s" | cut -f1 -d";"`; \ | |
738 | s2=`echo "$$s" | cut -f2 -d";"`; \ | |
739 | s3=`echo "$$s" | cut -f3 -d";"`; \ | |
740 | fn1=`basename "$$s1"`; \ | |
741 | fn2=`basename "$$s2"`; \ | |
742 | fn3=`basename "$$s3"`; \ | |
743 | : {- output_off() if windowsdll(); "" -}; \ | |
744 | $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \ | |
745 | $(RM) $(DESTDIR)$(libdir)/$$fn1; \ | |
746 | if [ -n "$$fn2" ]; then \ | |
747 | $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \ | |
748 | $(RM) $(DESTDIR)$(libdir)/$$fn2; \ | |
749 | fi; \ | |
750 | : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \ | |
751 | if [ -n "$$fn3" ]; then \ | |
752 | $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn3"; \ | |
753 | $(RM) $(DESTDIR)$(libdir)/$$fn3; \ | |
754 | fi; \ | |
755 | : {- output_on() unless windowsdll(); "" -}; \ | |
756 | done | |
757 | @ : {- output_on() if $disabled{shared}; "" -} | |
758 | $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc | |
759 | $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc | |
760 | $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc | |
761 | -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig | |
762 | -$(RMDIR) $(DESTDIR)$(libdir) | |
763 | ||
764 | _install_modules_deps: install_runtime_libs build_modules | |
765 | ||
766 | install_engines: _install_modules_deps | |
767 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
768 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/ | |
769 | @$(ECHO) "*** Installing engines" | |
770 | @set -e; for e in dummy $(INSTALL_ENGINES); do \ | |
771 | if [ "$$e" = "dummy" ]; then continue; fi; \ | |
772 | fn=`basename $$e`; \ | |
773 | $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \ | |
774 | cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \ | |
775 | chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \ | |
776 | mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \ | |
777 | $(DESTDIR)$(ENGINESDIR)/$$fn; \ | |
778 | done | |
779 | ||
780 | uninstall_engines: | |
781 | @$(ECHO) "*** Uninstalling engines" | |
782 | @set -e; for e in dummy $(INSTALL_ENGINES); do \ | |
783 | if [ "$$e" = "dummy" ]; then continue; fi; \ | |
784 | fn=`basename $$e`; \ | |
785 | $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \ | |
786 | $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \ | |
787 | done | |
788 | -$(RMDIR) $(DESTDIR)$(ENGINESDIR) | |
789 | ||
790 | install_modules: _install_modules_deps | |
791 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
792 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)/ | |
793 | @$(ECHO) "*** Installing modules" | |
794 | @set -e; for e in dummy $(INSTALL_MODULES); do \ | |
795 | if [ "$$e" = "dummy" ]; then continue; fi; \ | |
796 | fn=`basename $$e`; \ | |
797 | $(ECHO) "install $$e -> $(DESTDIR)$(MODULESDIR)/$$fn"; \ | |
798 | cp $$e $(DESTDIR)$(MODULESDIR)/$$fn.new; \ | |
799 | chmod 755 $(DESTDIR)$(MODULESDIR)/$$fn.new; \ | |
800 | mv -f $(DESTDIR)$(MODULESDIR)/$$fn.new \ | |
801 | $(DESTDIR)$(MODULESDIR)/$$fn; \ | |
802 | done | |
803 | ||
804 | uninstall_modules: | |
805 | @$(ECHO) "*** Uninstalling modules" | |
806 | @set -e; for e in dummy $(INSTALL_MODULES); do \ | |
807 | if [ "$$e" = "dummy" ]; then continue; fi; \ | |
808 | fn=`basename $$e`; \ | |
809 | $(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$$fn"; \ | |
810 | $(RM) $(DESTDIR)$(MODULESDIR)/$$fn; \ | |
811 | done | |
812 | -$(RMDIR) $(DESTDIR)$(MODULESDIR) | |
813 | ||
814 | install_runtime: install_programs | |
815 | ||
816 | install_runtime_libs: build_libs | |
817 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
818 | @ : {- output_off() if windowsdll(); "" -} | |
819 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir) | |
820 | @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -} | |
821 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin | |
822 | @ : {- output_on() unless windowsdll(); "" -} | |
823 | @$(ECHO) "*** Installing runtime libraries" | |
824 | @set -e; for s in dummy $(INSTALL_SHLIBS); do \ | |
825 | if [ "$$s" = "dummy" ]; then continue; fi; \ | |
826 | fn=`basename $$s`; \ | |
827 | : {- output_off() unless windowsdll(); "" -}; \ | |
828 | $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ | |
829 | cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
830 | chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
831 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ | |
832 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
833 | : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \ | |
834 | $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \ | |
835 | cp $$s $(DESTDIR)$(libdir)/$$fn.new; \ | |
836 | chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \ | |
837 | mv -f $(DESTDIR)$(libdir)/$$fn.new \ | |
838 | $(DESTDIR)$(libdir)/$$fn; \ | |
839 | : {- output_on() if windowsdll(); "" -}; \ | |
840 | done | |
841 | ||
842 | install_programs: install_runtime_libs build_programs | |
843 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
844 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin | |
845 | @$(ECHO) "*** Installing runtime programs" | |
846 | @set -e; for x in dummy $(INSTALL_PROGRAMS); do \ | |
847 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
848 | fn=`basename $$x`; \ | |
849 | $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ | |
850 | cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
851 | chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
852 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ | |
853 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
854 | done | |
855 | @set -e; for x in dummy $(BIN_SCRIPTS); do \ | |
856 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
857 | fn=`basename $$x`; \ | |
858 | $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ | |
859 | cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
860 | chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \ | |
861 | mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \ | |
862 | $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
863 | done | |
864 | ||
865 | uninstall_runtime: uninstall_programs uninstall_runtime_libs | |
866 | ||
867 | uninstall_programs: | |
868 | @$(ECHO) "*** Uninstalling runtime programs" | |
869 | @set -e; for x in dummy $(INSTALL_PROGRAMS); \ | |
870 | do \ | |
871 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
872 | fn=`basename $$x`; \ | |
873 | $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ | |
874 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
875 | done; | |
876 | @set -e; for x in dummy $(BIN_SCRIPTS); \ | |
877 | do \ | |
878 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
879 | fn=`basename $$x`; \ | |
880 | $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ | |
881 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
882 | done | |
883 | -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin | |
884 | ||
885 | uninstall_runtime_libs: | |
886 | @$(ECHO) "*** Uninstalling runtime libraries" | |
887 | @ : {- output_off() unless windowsdll(); "" -} | |
888 | @set -e; for s in dummy $(INSTALL_SHLIBS); do \ | |
889 | if [ "$$s" = "dummy" ]; then continue; fi; \ | |
890 | fn=`basename $$s`; \ | |
891 | $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \ | |
892 | $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \ | |
893 | done | |
894 | @ : {- output_on() unless windowsdll(); "" -} | |
895 | ||
896 | ||
897 | install_man_docs: build_man_docs | |
898 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
899 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man1 | |
900 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man3 | |
901 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man5 | |
902 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man7 | |
903 | @$(ECHO) "*** Installing manpages" | |
904 | @set -e; for x in dummy $(MANDOCS1); do \ | |
905 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
906 | fn=`basename $$x`; \ | |
907 | $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \ | |
908 | cp $$x $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \ | |
909 | chmod 644 $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \ | |
910 | done | |
911 | @set -e; for x in dummy $(MANDOCS3); do \ | |
912 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
913 | fn=`basename $$x`; \ | |
914 | $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \ | |
915 | cp $$x $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \ | |
916 | chmod 644 $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \ | |
917 | done | |
918 | @set -e; for x in dummy $(MANDOCS5); do \ | |
919 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
920 | fn=`basename $$x`; \ | |
921 | $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \ | |
922 | cp $$x $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \ | |
923 | chmod 644 $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \ | |
924 | done | |
925 | @set -e; for x in dummy $(MANDOCS7); do \ | |
926 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
927 | fn=`basename $$x`; \ | |
928 | $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \ | |
929 | cp $$x $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \ | |
930 | chmod 644 $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \ | |
931 | done | |
932 | ||
933 | uninstall_man_docs: | |
934 | @$(ECHO) "*** Uninstalling manpages" | |
935 | @set -e; for x in dummy $(MANDOCS1); do \ | |
936 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
937 | fn=`basename $$x`; \ | |
938 | $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \ | |
939 | $(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \ | |
940 | done | |
941 | @set -e; for x in dummy $(MANDOCS3); do \ | |
942 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
943 | fn=`basename $$x`; \ | |
944 | $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \ | |
945 | $(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \ | |
946 | done | |
947 | @set -e; for x in dummy $(MANDOCS5); do \ | |
948 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
949 | fn=`basename $$x`; \ | |
950 | $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \ | |
951 | $(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \ | |
952 | done | |
953 | @set -e; for x in dummy $(MANDOCS7); do \ | |
954 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
955 | fn=`basename $$x`; \ | |
956 | $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \ | |
957 | $(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \ | |
958 | done | |
959 | ||
960 | install_html_docs: build_html_docs | |
961 | @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) | |
962 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man1 | |
963 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man3 | |
964 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man5 | |
965 | @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man7 | |
966 | @$(ECHO) "*** Installing HTML manpages" | |
967 | @set -e; for x in dummy $(HTMLDOCS1); do \ | |
968 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
969 | fn=`basename $$x`; \ | |
970 | $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \ | |
971 | cp $$x $(DESTDIR)$(HTMLDIR)/man1/$$fn; \ | |
972 | chmod 644 $(DESTDIR)$(HTMLDIR)/man1/$$fn; \ | |
973 | done | |
974 | @set -e; for x in dummy $(HTMLDOCS3); do \ | |
975 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
976 | fn=`basename $$x`; \ | |
977 | $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \ | |
978 | cp $$x $(DESTDIR)$(HTMLDIR)/man3/$$fn; \ | |
979 | chmod 644 $(DESTDIR)$(HTMLDIR)/man3/$$fn; \ | |
980 | done | |
981 | @set -e; for x in dummy $(HTMLDOCS5); do \ | |
982 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
983 | fn=`basename $$x`; \ | |
984 | $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \ | |
985 | cp $$x $(DESTDIR)$(HTMLDIR)/man5/$$fn; \ | |
986 | chmod 644 $(DESTDIR)$(HTMLDIR)/man5/$$fn; \ | |
987 | done | |
988 | @set -e; for x in dummy $(HTMLDOCS7); do \ | |
989 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
990 | fn=`basename $$x`; \ | |
991 | $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \ | |
992 | cp $$x $(DESTDIR)$(HTMLDIR)/man7/$$fn; \ | |
993 | chmod 644 $(DESTDIR)$(HTMLDIR)/man7/$$fn; \ | |
994 | done | |
995 | ||
996 | uninstall_html_docs: | |
997 | @$(ECHO) "*** Uninstalling HTML manpages" | |
998 | @set -e; for x in dummy $(HTMLDOCS1); do \ | |
999 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
1000 | fn=`basename $$x`; \ | |
1001 | $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \ | |
1002 | $(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn; \ | |
1003 | done | |
1004 | @set -e; for x in dummy $(HTMLDOCS3); do \ | |
1005 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
1006 | fn=`basename $$x`; \ | |
1007 | $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \ | |
1008 | $(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn; \ | |
1009 | done | |
1010 | @set -e; for x in dummy $(HTMLDOCS5); do \ | |
1011 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
1012 | fn=`basename $$x`; \ | |
1013 | $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \ | |
1014 | $(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn; \ | |
1015 | done | |
1016 | @set -e; for x in dummy $(HTMLDOCS7); do \ | |
1017 | if [ "$$x" = "dummy" ]; then continue; fi; \ | |
1018 | fn=`basename $$x`; \ | |
1019 | $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \ | |
1020 | $(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn; \ | |
1021 | done | |
1022 | ||
1023 | # Developer targets (note: these are only available on Unix) ######### | |
1024 | ||
1025 | update: generate errors ordinals | |
1026 | ||
1027 | generate: generate_apps generate_crypto_bn generate_crypto_objects \ | |
1028 | generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids | |
1029 | ||
1030 | .PHONY: doc-nits cmd-nits md-nits | |
1031 | doc-nits: build_generated_pods | |
1032 | $(PERL) $(SRCDIR)/util/find-doc-nits -n -l -e | |
1033 | ||
1034 | cmd-nits: build_generated apps/openssl build_generated_pods | |
1035 | $(PERL) $(SRCDIR)/util/find-doc-nits -c | |
1036 | ||
1037 | # This uses "mdl", the markdownlint application, which is written in ruby. | |
1038 | # The source is at https://github.com/markdownlint/markdownlint | |
1039 | # If you have ruby installed, "gem install mdl" should work. | |
1040 | # Another option is at https://snapcraft.io/install/mdl/debian | |
1041 | # Finally, there's a Node.js version, which we haven't tried, that | |
1042 | # can be found at https://github.com/DavidAnson/markdownlint | |
1043 | md-nits: | |
1044 | mdl -s util/markdownlint.rb . NOTES-Windows.txt | |
1045 | ||
1046 | # Test coverage is a good idea for the future | |
1047 | #coverage: $(PROGRAMS) $(TESTPROGRAMS) | |
1048 | # ... | |
1049 | ||
1050 | lint: | |
1051 | lint -DLINT $(INCLUDES) $(SRCS) | |
1052 | ||
1053 | generate_apps: | |
1054 | ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \ | |
1055 | < apps/openssl.cnf > apps/openssl-vms.cnf ) | |
1056 | ||
1057 | generate_crypto_bn: | |
1058 | ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h ) | |
1059 | ||
1060 | generate_crypto_objects: | |
1061 | ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \ | |
1062 | crypto/objects/objects.txt \ | |
1063 | crypto/objects/obj_mac.num \ | |
1064 | > crypto/objects/obj_mac.new && \ | |
1065 | mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num ) | |
1066 | ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \ | |
1067 | crypto/objects/objects.txt \ | |
1068 | crypto/objects/obj_mac.num \ | |
1069 | > include/openssl/obj_mac.h ) | |
1070 | ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \ | |
1071 | include/openssl/obj_mac.h \ | |
1072 | > crypto/objects/obj_dat.h ) | |
1073 | ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \ | |
1074 | crypto/objects/obj_mac.num \ | |
1075 | crypto/objects/obj_xref.txt \ | |
1076 | > crypto/objects/obj_xref.h ) | |
1077 | ( cd $(SRCDIR); cat crypto/objects/obj_compat.h >> include/openssl/obj_mac.h ) | |
1078 | ||
1079 | generate_crypto_conf: | |
1080 | ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \ | |
1081 | > crypto/conf/conf_def.h ) | |
1082 | ||
1083 | generate_crypto_asn1: | |
1084 | ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \ | |
1085 | > crypto/asn1/charmap.h ) | |
1086 | ||
1087 | generate_fuzz_oids: | |
1088 | ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \ | |
1089 | crypto/objects/obj_dat.h \ | |
1090 | > fuzz/oids.txt ) | |
1091 | ||
1092 | # Set to -force to force a rebuild | |
1093 | ERROR_REBUILD= | |
1094 | errors: | |
1095 | ( b=`pwd`; set -e; cd $(SRCDIR); \ | |
1096 | $(PERL) util/ck_errf.pl -strict -internal; \ | |
1097 | $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal ) | |
1098 | ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \ | |
1099 | for E in *.ec ; do \ | |
1100 | $(PERL) ../util/ck_errf.pl -strict \ | |
1101 | -conf $$E `basename $$E .ec`.c; \ | |
1102 | $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \ | |
1103 | -conf $$E `basename $$E .ec`.c ; \ | |
1104 | done ) | |
1105 | ||
1106 | {- use File::Basename; | |
1107 | ||
1108 | my @sslheaders_tmpl = | |
1109 | qw( include/openssl/ssl.h | |
1110 | include/openssl/ssl2.h | |
1111 | include/openssl/ssl3.h | |
1112 | include/openssl/sslerr.h | |
1113 | include/openssl/tls1.h | |
1114 | include/openssl/dtls1.h | |
1115 | include/openssl/srtp.h | |
1116 | include/openssl/sslerr_legacy.h ); | |
1117 | my @cryptoheaders_tmpl = | |
1118 | qw( include/internal/dso.h | |
1119 | include/internal/o_dir.h | |
1120 | include/internal/err.h | |
1121 | include/internal/evp.h | |
1122 | include/internal/pem.h | |
1123 | include/internal/asn1.h | |
1124 | include/internal/sslconf.h ); | |
1125 | my @cryptoskipheaders = ( @sslheaders_tmpl, | |
1126 | qw( include/openssl/conf_api.h | |
1127 | include/openssl/ebcdic.h | |
1128 | include/openssl/opensslconf.h | |
1129 | include/openssl/symhacks.h ) ); | |
1130 | our %cryptoheaders = (); | |
1131 | our %sslheaders = (); | |
1132 | foreach my $d ( qw( include/openssl include/internal ) ) { | |
1133 | my @header_patterns = | |
1134 | map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' ); | |
1135 | foreach my $f ( map { glob($_) } @header_patterns ) { | |
1136 | my $base = basename($f); | |
1137 | my $base_in = basename($f, '.in'); | |
1138 | my $dir = catfile($config{sourcedir}, $d); | |
1139 | if ($base ne $base_in) { | |
1140 | # We have a .h.in file, which means the header file is in the | |
1141 | # build tree. | |
1142 | $base = $base_in; | |
1143 | $dir = catfile($config{builddir}, $d); | |
1144 | } | |
1145 | my $new_f = catfile($dir, $base); | |
1146 | my $fn = "$d/$base"; | |
1147 | # The logic to add files to @cryptoheaders is a bit complex. The | |
1148 | # file to be added must be either in the public header directory | |
1149 | # or one of the pre-declared internal headers, and must under no | |
1150 | # circumstances be one of those that must be skipped. | |
1151 | $cryptoheaders{$new_f} = 1 | |
1152 | if (($d eq 'include/openssl' | |
1153 | || ( grep { $_ eq $fn } @cryptoheaders_tmpl )) | |
1154 | && !( grep { $_ eq $fn } @cryptoskipheaders )); | |
1155 | # The logic to add files to @sslheaders is much simpler... | |
1156 | $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl; | |
1157 | } | |
1158 | } | |
1159 | ""; | |
1160 | -} | |
1161 | CRYPTOHEADERS={- join(" \\\n" . ' ' x 14, | |
1162 | fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -} | |
1163 | SSLHEADERS={- join(" \\\n" . ' ' x 11, | |
1164 | fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -} | |
1165 | ordinals: build_generated | |
1166 | $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \ | |
1167 | --ordinals $(SRCDIR)/util/libcrypto.num \ | |
1168 | --symhacks $(SRCDIR)/include/openssl/symhacks.h \ | |
1169 | $(CRYPTOHEADERS) | |
1170 | $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \ | |
1171 | --ordinals $(SRCDIR)/util/libssl.num \ | |
1172 | --symhacks $(SRCDIR)/include/openssl/symhacks.h \ | |
1173 | $(SSLHEADERS) | |
1174 | ||
1175 | test_ordinals: | |
1176 | ( cd test; \ | |
1177 | SRCTOP=../$(SRCDIR) \ | |
1178 | BLDTOP=../$(BLDDIR) \ | |
1179 | $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals ) | |
1180 | ||
1181 | tags TAGS: FORCE | |
1182 | rm -f TAGS tags | |
1183 | -ctags -R . | |
1184 | -etags `find . -name '*.[ch]' -o -name '*.pm'` | |
1185 | ||
1186 | # Release targets (note: only available on Unix) ##################### | |
1187 | ||
1188 | tar: | |
1189 | (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)') | |
1190 | ||
1191 | # Helper targets ##################################################### | |
1192 | ||
1193 | link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/wrap.pl | |
1194 | ||
1195 | $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/wrap.pl: configdata.pm | |
1196 | @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ | |
1197 | mkdir -p "$(BLDDIR)/util"; \ | |
1198 | ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \ | |
1199 | fi | |
1200 | ||
1201 | FORCE: | |
1202 | ||
1203 | # Building targets ################################################### | |
1204 | ||
1205 | libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -} | |
1206 | libcrypto.pc: | |
1207 | @ ( echo 'prefix=$(INSTALLTOP)'; \ | |
1208 | echo 'exec_prefix=$${prefix}'; \ | |
1209 | if [ -n "$(LIBDIR)" ]; then \ | |
1210 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ | |
1211 | else \ | |
1212 | echo 'libdir=$(libdir)'; \ | |
1213 | fi; \ | |
1214 | echo 'includedir=$${prefix}/include'; \ | |
1215 | echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \ | |
1216 | echo ''; \ | |
1217 | echo 'Name: OpenSSL-libcrypto'; \ | |
1218 | echo 'Description: OpenSSL cryptography library'; \ | |
1219 | echo 'Version: '$(VERSION); \ | |
1220 | echo 'Libs: -L$${libdir} -lcrypto'; \ | |
1221 | echo 'Libs.private: $(LIB_EX_LIBS)'; \ | |
1222 | echo 'Cflags: -I$${includedir}' ) > libcrypto.pc | |
1223 | ||
1224 | libssl.pc: | |
1225 | @ ( echo 'prefix=$(INSTALLTOP)'; \ | |
1226 | echo 'exec_prefix=$${prefix}'; \ | |
1227 | if [ -n "$(LIBDIR)" ]; then \ | |
1228 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ | |
1229 | else \ | |
1230 | echo 'libdir=$(libdir)'; \ | |
1231 | fi; \ | |
1232 | echo 'includedir=$${prefix}/include'; \ | |
1233 | echo ''; \ | |
1234 | echo 'Name: OpenSSL-libssl'; \ | |
1235 | echo 'Description: Secure Sockets Layer and cryptography libraries'; \ | |
1236 | echo 'Version: '$(VERSION); \ | |
1237 | echo 'Requires.private: libcrypto'; \ | |
1238 | echo 'Libs: -L$${libdir} -lssl'; \ | |
1239 | echo 'Cflags: -I$${includedir}' ) > libssl.pc | |
1240 | ||
1241 | openssl.pc: | |
1242 | @ ( echo 'prefix=$(INSTALLTOP)'; \ | |
1243 | echo 'exec_prefix=$${prefix}'; \ | |
1244 | if [ -n "$(LIBDIR)" ]; then \ | |
1245 | echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \ | |
1246 | else \ | |
1247 | echo 'libdir=$(libdir)'; \ | |
1248 | fi; \ | |
1249 | echo 'includedir=$${prefix}/include'; \ | |
1250 | echo ''; \ | |
1251 | echo 'Name: OpenSSL'; \ | |
1252 | echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \ | |
1253 | echo 'Version: '$(VERSION); \ | |
1254 | echo 'Requires: libssl libcrypto' ) > openssl.pc | |
1255 | ||
1256 | configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \ | |
1257 | {- join(" \\\n" . ' ' x 15, | |
1258 | fill_lines(" ", $COLUMNS - 15, | |
1259 | @{$config{build_file_templates}}, | |
1260 | @{$config{build_infos}}, | |
1261 | @{$config{conf_files}})) -} | |
1262 | @echo "Detected changed: $?" | |
1263 | $(PERL) configdata.pm -r | |
1264 | @echo "**************************************************" | |
1265 | @echo "*** ***" | |
1266 | @echo "*** Please run the same make command again ***" | |
1267 | @echo "*** ***" | |
1268 | @echo "**************************************************" | |
1269 | @false | |
1270 | ||
1271 | reconfigure reconf: | |
1272 | $(PERL) configdata.pm -r | |
1273 | ||
1274 | {- | |
1275 | use File::Basename; | |
1276 | use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; | |
1277 | ||
1278 | # Helper function to figure out dependencies on libraries | |
1279 | # It takes a list of library names and outputs a list of dependencies | |
1280 | sub compute_lib_depends { | |
1281 | # Depending on shared libraries: | |
1282 | # On Windows POSIX layers, we depend on {libname}.dll.a | |
1283 | # On Unix platforms, we depend on {shlibname}.so | |
1284 | return map { platform->sharedlib_simple($_) | |
1285 | // platform->sharedlib_import($_) | |
1286 | // platform->staticlib($_) | |
1287 | } @_; | |
1288 | } | |
1289 | ||
1290 | sub generatesrc { | |
1291 | my %args = @_; | |
1292 | my $generator = join(" ", @{$args{generator}}); | |
1293 | my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}}); | |
1294 | my $incs = join("", map { " -I".$_ } @{$args{incs}}); | |
1295 | my $defs = join("", map { " -D".$_ } @{$args{defs}}); | |
1296 | my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}}); | |
1297 | ||
1298 | if ($args{src} =~ /\.html$/) { | |
1299 | my $title = basename($args{src}, ".html"); | |
1300 | my $pod = $args{generator}->[0]; | |
1301 | return <<"EOF"; | |
1302 | $args{src}: $pod | |
1303 | \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc" | |
1304 | EOF | |
1305 | } elsif ($args{src} =~ /\.(\d)$/) { | |
1306 | my $section = $1; | |
1307 | my $name = uc basename($args{src}, ".$section"); | |
1308 | my $pod = $args{generator}->[0]; | |
1309 | return <<"EOF"; | |
1310 | $args{src}: $pod | |
1311 | pod2man --name=$name --section=$section --center=OpenSSL \\ | |
1312 | --release=\$(VERSION) $pod >\$\@ | |
1313 | EOF | |
1314 | } elsif (platform->isdef($args{src})) { | |
1315 | my $target = platform->def($args{src}); | |
1316 | (my $mkdef_os = $target{shared_target}) =~ s|-shared$||; | |
1317 | my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : ''; | |
1318 | my $ord_name = $args{generator}->[1] || $args{product}; | |
1319 | return <<"EOF"; | |
1320 | $target: $args{generator}->[0] $deps \$(SRCDIR)/util/mkdef.pl | |
1321 | \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS $mkdef_os > $target | |
1322 | EOF | |
1323 | } elsif (!platform->isasm($args{src})) { | |
1324 | if ($args{generator}->[0] =~ m|^.*\.in$|) { | |
1325 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, | |
1326 | "util", "dofile.pl")), | |
1327 | rel2abs($config{builddir})); | |
1328 | my @modules = ( 'configdata.pm', | |
1329 | grep { $_ =~ m|\.pm$| } @{$args{deps}} ); | |
1330 | my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules; | |
1331 | @modules = map { "-M".basename($_, '.pm') } @modules; | |
1332 | my $modules = join(' ', '', sort keys %moduleincs, @modules); | |
1333 | return <<"EOF"; | |
1334 | $args{src}: $args{generator}->[0] $deps \$(BLDDIR)/configdata.pm | |
1335 | \$(PERL)$modules "$dofile" "-o$target{build_file}" $generator > \$@ | |
1336 | EOF | |
1337 | } else { | |
1338 | return <<"EOF"; | |
1339 | $args{src}: $args{generator}->[0] $deps | |
1340 | \$(PERL)$generator_incs $generator > \$@ | |
1341 | EOF | |
1342 | } | |
1343 | } else { | |
1344 | my $cppflags = { | |
1345 | shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', | |
1346 | lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', | |
1347 | dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', | |
1348 | bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' | |
1349 | } -> {$args{intent}}; | |
1350 | ||
1351 | if ($args{generator}->[0] =~ /\.pl$/) { | |
1352 | $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator | |
1353 | .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)'; | |
1354 | } elsif ($args{generator}->[0] =~ /\.m4$/) { | |
1355 | $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >' | |
1356 | } elsif ($args{generator}->[0] =~ /\.S$/) { | |
1357 | $generator = undef; | |
1358 | } else { | |
1359 | die "Generator type for $args{src} unknown: $generator\n"; | |
1360 | } | |
1361 | ||
1362 | if (defined($generator)) { | |
1363 | return <<"EOF"; | |
1364 | $args{src}: $args{generator}->[0] $deps | |
1365 | $generator \$@ | |
1366 | EOF | |
1367 | } | |
1368 | return <<"EOF"; | |
1369 | $args{src}: $args{generator}->[0] $deps | |
1370 | \$(CC) $incs $cppflags $defs -E $args{generator}->[0] | \\ | |
1371 | \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@ | |
1372 | EOF | |
1373 | } | |
1374 | } | |
1375 | ||
1376 | # Should one wonder about the end of the Perl snippet, it's because this | |
1377 | # second regexp eats up line endings as well, if the removed path is the | |
1378 | # last in the line. We may therefore need to put back a line ending. | |
1379 | sub src2obj { | |
1380 | my %args = @_; | |
1381 | my $obj = platform->convertext($args{obj}); | |
1382 | my $dep = platform->dep($args{obj}); | |
1383 | my @srcs = @{$args{srcs}}; | |
1384 | my $srcs = join(" ", @srcs); | |
1385 | my $deps = join(" ", @srcs, @{$args{deps}}); | |
1386 | my $incs = join("", map { " -I".$_ } @{$args{incs}}); | |
1387 | my $defs = join("", map { " -D".$_ } @{$args{defs}}); | |
1388 | my $cmd; | |
1389 | my $cmdflags; | |
1390 | my $cmdcompile; | |
1391 | if (grep /\.rc$/, @srcs) { | |
1392 | $cmd = '$(RC)'; | |
1393 | $cmdflags = '$(RCFLAGS)'; | |
1394 | $cmdcompile = ''; | |
1395 | } elsif (grep /\.(cc|cpp)$/, @srcs) { | |
1396 | $cmd = '$(CXX)'; | |
1397 | $cmdcompile = ' -c'; | |
1398 | $cmdflags = { | |
1399 | shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)', | |
1400 | lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)', | |
1401 | dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)', | |
1402 | bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)' | |
1403 | } -> {$args{intent}}; | |
1404 | } else { | |
1405 | $cmd = '$(CC)'; | |
1406 | $cmdcompile = ' -c'; | |
1407 | $cmdflags = { | |
1408 | shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', | |
1409 | lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', | |
1410 | dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', | |
1411 | bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' | |
1412 | } -> {$args{intent}}; | |
1413 | } | |
1414 | my $recipe; | |
1415 | # extension-specific rules | |
1416 | if (grep /\.s$/, @srcs) { | |
1417 | $recipe .= <<"EOF"; | |
1418 | $obj: $deps | |
1419 | $cmd $cmdflags -c -o \$\@ $srcs | |
1420 | EOF | |
1421 | } elsif (grep /\.S$/, @srcs) { | |
1422 | # Originally there was mutli-step rule with $(CC) -E file.S | |
1423 | # followed by $(CC) -c file.s. It compensated for one of | |
1424 | # legacy platform compiler's inability to handle .S files. | |
1425 | # The platform is long discontinued by vendor so there is | |
1426 | # hardly a point to drag it along... | |
1427 | $recipe .= <<"EOF"; | |
1428 | $obj: $deps | |
1429 | $cmd $incs $defs $cmdflags -c -o \$\@ $srcs | |
1430 | EOF | |
1431 | } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/ | |
1432 | && !grep /\.rc$/, @srcs) { | |
1433 | $recipe .= <<"EOF"; | |
1434 | $obj: $deps | |
1435 | $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs | |
1436 | \@touch $dep.tmp | |
1437 | \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\ | |
1438 | rm -f $dep.tmp; \\ | |
1439 | else \\ | |
1440 | mv $dep.tmp $dep; \\ | |
1441 | fi | |
1442 | EOF | |
1443 | } else { | |
1444 | $recipe .= <<"EOF"; | |
1445 | $obj: $deps | |
1446 | $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs | |
1447 | EOF | |
1448 | if (defined $makedepprog && $makedepprog =~ /\/makedepend/) { | |
1449 | $recipe .= <<"EOF"; | |
1450 | \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\ | |
1451 | > $dep | |
1452 | EOF | |
1453 | } | |
1454 | } | |
1455 | return $recipe; | |
1456 | } | |
1457 | # We *know* this routine is only called when we've configure 'shared'. | |
1458 | sub obj2shlib { | |
1459 | my %args = @_; | |
1460 | my @linkdirs = (); | |
1461 | my @linklibs = (); | |
1462 | foreach (@{$args{deps}}) { | |
1463 | if (platform->isstaticlib($_)) { | |
1464 | push @linklibs, platform->convertext($_); | |
1465 | } else { | |
1466 | my $d = "-L" . dirname($_); | |
1467 | my $l = basename($_); | |
1468 | $l =~ s/^lib//; | |
1469 | $l = "-l" . $l; | |
1470 | push @linklibs, $l; | |
1471 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; | |
1472 | } | |
1473 | } | |
1474 | my $linkflags = join("", map { $_." " } @linkdirs); | |
1475 | my $linklibs = join("", map { $_." " } @linklibs); | |
1476 | my @objs = map { platform->convertext($_) } | |
1477 | grep { !platform->isdef($_) } | |
1478 | @{$args{objs}}; | |
1479 | my @defs = map { platform->def($_) } | |
1480 | grep { platform->isdef($_) } | |
1481 | @{$args{objs}}; | |
1482 | my @deps = compute_lib_depends(@{$args{deps}}); | |
1483 | die "More than one exported symbol map" if scalar @defs > 1; | |
1484 | ||
1485 | my $full = platform->sharedlib($args{lib}); | |
1486 | # $import is for Windows and subsystems thereof, where static import | |
1487 | # libraries for DLLs are a thing. On platforms that have this mechanism, | |
1488 | # $import has the name of this import library. On platforms that don't | |
1489 | # have this mechanism, $import will be |undef|. | |
1490 | my $import = platform->sharedlib_import($args{lib}); | |
1491 | # $simple is for platforms where full shared library names include the | |
1492 | # shared library version, and there's a simpler name that doesn't include | |
1493 | # that version. On such platforms, $simple has the simpler name. On | |
1494 | # other platforms, it will be |undef|. | |
1495 | my $simple = platform->sharedlib_simple($args{lib}); | |
1496 | ||
1497 | my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef; | |
1498 | my $shared_soname = ""; | |
1499 | $shared_soname .= ' '.$target{shared_sonameflag}.basename($full) | |
1500 | if defined $target{shared_sonameflag}; | |
1501 | my $shared_imp = ""; | |
1502 | $shared_imp .= ' '.$target{shared_impflag}.basename($import) | |
1503 | if defined $target{shared_impflag} && defined $import; | |
1504 | my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); | |
1505 | ||
1506 | # There is at least one platform where the compiler-as-linker needs to | |
1507 | # have one object file directly on the command line. That won't hurt | |
1508 | # any other platform, so we do that for everyone when there's an argfile | |
1509 | # to be had. This depends heavily on splice, which removes elements from | |
1510 | # the given array, and returns them so they can be captured. | |
1511 | my @argfileobjs = $argfile | |
1512 | ? splice(@objs, 1) | |
1513 | : (); | |
1514 | my $argfilecmds = $argfile | |
1515 | ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs) | |
1516 | : undef; | |
1517 | my $argfiledeps = $argfile | |
1518 | ? join(" \\\n" . ' ' x (length($argfile) + 2), | |
1519 | fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs)) | |
1520 | : undef; | |
1521 | my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps); | |
1522 | my @fullobjs = ( | |
1523 | @objs, | |
1524 | ($argfile ? $target{shared_argfileflag}.$argfile : ()) | |
1525 | ); | |
1526 | my $fulldeps = | |
1527 | join(" \\\n" . ' ' x (length($full) + 2), | |
1528 | fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps)); | |
1529 | my $fullobjs = | |
1530 | join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs)); | |
1531 | ||
1532 | my $recipe = ''; | |
1533 | ||
1534 | if (defined $simple) { | |
1535 | if (sharedaix()) { | |
1536 | $recipe .= <<"EOF"; | |
1537 | $simple: $full | |
1538 | rm -f $simple && \\ | |
1539 | \$(AR) r $simple $full | |
1540 | EOF | |
1541 | } else { | |
1542 | $recipe .= <<"EOF"; | |
1543 | $simple: $full | |
1544 | rm -f $simple && \\ | |
1545 | ln -s $full $simple | |
1546 | EOF | |
1547 | } | |
1548 | } | |
1549 | if (defined $import) { | |
1550 | $recipe .= <<"EOF"; | |
1551 | $import: $full | |
1552 | EOF | |
1553 | } | |
1554 | $recipe .= <<"EOF"; | |
1555 | $full: $fulldeps | |
1556 | \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\ | |
1557 | -o $full$shared_def \\ | |
1558 | $fullobjs \\ | |
1559 | $linklibs \$(LIB_EX_LIBS) | |
1560 | EOF | |
1561 | if (windowsdll()) { | |
1562 | $recipe .= <<"EOF"; | |
1563 | rm -f apps/$full | |
1564 | rm -f test/$full | |
1565 | rm -f fuzz/$full | |
1566 | cp -p $full apps/ | |
1567 | cp -p $full test/ | |
1568 | cp -p $full fuzz/ | |
1569 | EOF | |
1570 | } | |
1571 | $recipe .= <<"EOF" if defined $argfile; | |
1572 | $argfile: $argfiledeps | |
1573 | \$(RM) $argfile | |
1574 | $argfilecmds | |
1575 | EOF | |
1576 | return $recipe; | |
1577 | } | |
1578 | sub obj2dso { | |
1579 | my %args = @_; | |
1580 | my $dso = platform->dso($args{module}); | |
1581 | my @linkdirs = (); | |
1582 | my @linklibs = (); | |
1583 | foreach (@{$args{deps}}) { | |
1584 | next unless defined $_; | |
1585 | if (platform->isstaticlib($_)) { | |
1586 | push @linklibs, platform->convertext($_); | |
1587 | } else { | |
1588 | my $d = "-L" . dirname($_); | |
1589 | my $l = basename($_); | |
1590 | $l =~ s/^lib//; | |
1591 | $l = "-l" . $l; | |
1592 | push @linklibs, $l; | |
1593 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; | |
1594 | } | |
1595 | } | |
1596 | my $linkflags = join("", map { $_." " } @linkdirs); | |
1597 | my $linklibs = join("", map { $_." " } @linklibs); | |
1598 | my @objs = map { platform->convertext($_) } | |
1599 | grep { !platform->isdef($_) } | |
1600 | @{$args{objs}}; | |
1601 | my @defs = map { platform->def($_) } | |
1602 | grep { platform->isdef($_) } | |
1603 | @{$args{objs}}; | |
1604 | my @deps = compute_lib_depends(@{$args{deps}}); | |
1605 | my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); | |
1606 | # TODO(3.0): next line needs to become "less magic" (see PR #11950) | |
1607 | $shared_def .= ' '.$target{shared_fipsflag} if (m/providers\/fips/ && defined $target{shared_fipsflag}); | |
1608 | my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs)); | |
1609 | my $deps = join(" \\\n" . ' ' x (length($dso) + 2), | |
1610 | fill_lines(' ', $COLUMNS - length($dso) - 2, | |
1611 | @objs, @defs, @deps)); | |
1612 | ||
1613 | return <<"EOF"; | |
1614 | $dso: $deps | |
1615 | \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\ | |
1616 | -o $dso$shared_def \\ | |
1617 | $objs \\ | |
1618 | $linklibs\$(DSO_EX_LIBS) | |
1619 | EOF | |
1620 | } | |
1621 | sub obj2lib { | |
1622 | my %args = @_; | |
1623 | my $lib = platform->staticlib($args{lib}); | |
1624 | my @objs = map { platform->obj($_) } @{$args{objs}}; | |
1625 | my $deps = join(" \\\n" . ' ' x (length($lib) + 2), | |
1626 | fill_lines(' ', $COLUMNS - length($lib) - 2, @objs)); | |
1627 | my $max_per_call = 500; | |
1628 | my @objs_grouped; | |
1629 | push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs; | |
1630 | my $fill_lib = | |
1631 | join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped)); | |
1632 | return <<"EOF"; | |
1633 | $lib: $deps | |
1634 | \$(RM) $lib | |
1635 | $fill_lib | |
1636 | \$(RANLIB) \$\@ || echo Never mind. | |
1637 | EOF | |
1638 | } | |
1639 | sub obj2bin { | |
1640 | my %args = @_; | |
1641 | my $bin = platform->bin($args{bin}); | |
1642 | my @objs = map { platform->obj($_) } @{$args{objs}}; | |
1643 | my @deps = compute_lib_depends(@{$args{deps}}); | |
1644 | my $objs = join(" \\\n" . ' ' x (length($bin) + 2), | |
1645 | fill_lines(' ', $COLUMNS - length($bin) - 2, @objs)); | |
1646 | my @linkdirs = (); | |
1647 | my @linklibs = (); | |
1648 | foreach (@{$args{deps}}) { | |
1649 | next unless defined $_; | |
1650 | if (platform->isstaticlib($_)) { | |
1651 | push @linklibs, platform->convertext($_); | |
1652 | } else { | |
1653 | my $d = "-L" . dirname($_); | |
1654 | my $l = basename($_); | |
1655 | $l =~ s/^lib//; | |
1656 | $l = "-l" . $l; | |
1657 | push @linklibs, $l; | |
1658 | push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; | |
1659 | } | |
1660 | } | |
1661 | my $linkflags = join("", map { $_." " } @linkdirs); | |
1662 | my $linklibs = join("", map { $_." " } @linklibs); | |
1663 | my $cmd = '$(CC)'; | |
1664 | my $cmdflags = '$(BIN_CFLAGS)'; | |
1665 | if (grep /_cc\.o$/, @{$args{objs}}) { | |
1666 | $cmd = '$(CXX)'; | |
1667 | $cmdflags = '$(BIN_CXXFLAGS)'; | |
1668 | } | |
1669 | ||
1670 | my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs)); | |
1671 | my $deps = join(" \\\n" . ' ' x (length($bin) + 2), | |
1672 | fill_lines(' ', $COLUMNS - length($bin) - 2, | |
1673 | @objs, @deps)); | |
1674 | ||
1675 | return <<"EOF"; | |
1676 | $bin: $deps | |
1677 | rm -f $bin | |
1678 | \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\ | |
1679 | -o $bin \\ | |
1680 | $objs \\ | |
1681 | $linklibs\$(BIN_EX_LIBS) | |
1682 | EOF | |
1683 | } | |
1684 | sub in2script { | |
1685 | my %args = @_; | |
1686 | my $script = $args{script}; | |
1687 | my $sources = join(" ", @{$args{sources}}); | |
1688 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, | |
1689 | "util", "dofile.pl")), | |
1690 | rel2abs($config{builddir})); | |
1691 | return <<"EOF"; | |
1692 | $script: $sources | |
1693 | \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ | |
1694 | "-o$target{build_file}" $sources > "$script" | |
1695 | chmod a+x $script | |
1696 | EOF | |
1697 | } | |
1698 | sub generatedir { | |
1699 | my %args = @_; | |
1700 | my $dir = $args{dir}; | |
1701 | my @deps = map { platform->convertext($_) } @{$args{deps}}; | |
1702 | my @comments = (); | |
1703 | my %extinfo = ( dso => platform->dsoext(), | |
1704 | lib => platform->libext(), | |
1705 | bin => platform->binext() ); | |
1706 | ||
1707 | # We already have a 'test' target, and the top directory is just plain | |
1708 | # silly | |
1709 | return if $dir eq "test" || $dir eq "."; | |
1710 | ||
1711 | foreach my $type (("dso", "lib", "bin", "script")) { | |
1712 | next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); | |
1713 | # For lib object files, we could update the library. However, it | |
1714 | # was decided that it's enough to build the directory local object | |
1715 | # files, so we don't need to add any actions, and the dependencies | |
1716 | # are already taken care of. | |
1717 | if ($type ne "lib") { | |
1718 | foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { | |
1719 | if (dirname($prod) eq $dir) { | |
1720 | push @deps, $prod.$extinfo{$type}; | |
1721 | } else { | |
1722 | push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); | |
1723 | } | |
1724 | } | |
1725 | } | |
1726 | } | |
1727 | ||
1728 | my $target = "$dir $dir/"; | |
1729 | my $deps = join(" \\\n\t", | |
1730 | fill_lines(' ', $COLUMNS - 8, @deps)); | |
1731 | my $comments = join("\n", "", @comments); | |
1732 | return <<"EOF"; | |
1733 | $target: \\ | |
1734 | $deps$comments | |
1735 | EOF | |
1736 | } | |
1737 | "" # Important! This becomes part of the template result. | |
1738 | -} |