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