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