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