Codebase list afflib / e33bbe4
Imported Upstream version 3.5.10+dfsg Cristian Greco 14 years ago
310 changed file(s) with 109296 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
Binary diff not shown
0 The primary author of AFF is:
1
2 Simson L. Garfinkel <simsong@acm.org>
3
4 Special thanks also to those who have contributed bug reports and fixes:
5
6 Jean-Francois Beckers
7 Sebastien Coutaz
8 Eric C.
9 Timothy Lyons
10 Nicolas (kwizart)
11 Joachim Metz
12 David Collett (PyFlag), for the PyAFF integration
13
14 The AFF Project has received substantial financial support from
15 Basis Technology Corporation.
16
17 We would also like to thank the following organizations for their
18 interest and support:
19
20 National Institutes of Standards and Technology
21 I.D.E.A.L. Technology Corporation
22 Naval Postgraduate School
23 US Department of Defense
24
0 AFFLIB Buglist and future development plans
1
2
3 PERFORMANCE IMPROVEMENTS:
4 * Cache the results of vstat
5 * Store TOC sorted and find entries with binary search.
6 (A 1TB TOC has 62,500 pages or 100K segments; with fixed size records that would be 8,000,000, which is not much.)
7 * aff_write_seg() shouldn't be calling af_rewind_seg after every call
8 * af_write() shouldn't be calling lseek() and write() so many times.
9 - move to scatter/gather writing.
10 - look at the TOC to know how much space is available.
11 - Make the TOC always used. Trust the TOC.
12
13
14 BUGS:
15 * Test all programs with file://-style URLs. You can't test for existence of a file with
16 access(). This is an issue for -z in afcopy.
17 * image_size not set for AFM files; does it need to be set, or is it generated on the fly?
18 * afcrypto should note if a file can't be decrypted.
19 * library doesn't automatically write SHA1s and SHA256s; need to be selectable.
20 * combine affix and afrecover into a single executable.
21 * combine afconvert and afcopy into a single executable.
22 * better error handling in aimage?
23 * Graacefully handle expat not installed?
24 * improve performance of
25 - cache memory selection size - * Automatically increase cache to use 1/2 of physical RAM?
26 - cache algorithm
27
28 FEATURES:
29
30 library:
31 * Add support for http://mingw.org/
32 * badflag needs to be reimplemented as a bitfield.
33 * Since we have the TOC, is there EVER a case in which we need to scan the whole file?
34 If not, perhaps we can take out those scan routines.
35 * Keep track of sectors that have been touched and output.
36 * Some kind of sector map array. (Bit array? Byte array?)
37 * A 1TB disk has 2 billion sectors and 62,500 AFF pages; do we need to store this in a better
38 data structure than an unsorted linear list?
39
40 aimage:
41 * Have aimage update more often
42 * Final report on bytes written is wrong.
43 * Fix imaging over the network
44 * Keep a log of everything imaged, # of bad blocks, MD5, etc.
45 * Image from an SSL tcp connection.
46 * notify user of kernel error messages; write them to segment
47 * Report if drive is wiped
48 * -A mode needs some work; it sometimes compresses too much.
49 * Digitally sign the AFFs
50
51 afcat:
52 * option - BADFLAG or BLANK errors
53 * Option to output a specific sector or a range of sectors
54 * Multiple ranges of bytes
55
56 afcompare:
57 * Make SIGINFO work
58 * -d - just compare data
59 * -s3 - just check to see if the named segments got written.
60 - Just compare MD5s!
61
62 afcopy:
63 * don't copy the file if it won't fit.
64 * preserve timestamps
65 * have the file names .aff.new, and rename to .aff after complete.
66 * if there are _md5/_sha1/_sha256 segments, read all of those segments first and verify them.
67 * if AFFLIB_PASSPHRASE is set and a file is copied, the resultant file is broken.
68
69 afconvert:
70 * This didn't work: afconvert -q -o /project3/1028.raw /project2/p3/1028.aff
71
72 afupload:
73 * Uploading shouldn't decrypt first.
74
75 ================================================================
0 /*
1 * AFFLIB(tm)
2 *
3 * Copyright (c) 2005, 2006, 2007
4 * Simson L. Garfinkel and Basis Technology Corp.
5 * All rights reserved.
6 *
7 * This code is derrived from software contributed by
8 * Simson L. Garfinkel
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by Simson L. Garfinkel
21 * and Basis Technology Corp.
22 * 4. Neither the name of Simson L. Garfinkel, Basis Technology, or other
23 * contributors to this program may be used to endorse or promote
24 * products derived from this software without specific prior written
25 * permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY SIMSON L. GARFINKEL, BASIS TECHNOLOGY,
28 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
29 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 * DISCLAIMED. IN NO EVENT SHALL SIMSON L. GARFINKEL, BASIS TECHNOLOGY,
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
35 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * SUCH DAMAGE.
40 *
41 * AFF and AFFLIB is a trademark of Simson Garfinkel and Basis Technology Corp.
42 */
0 2010-03-19 Simson L. Garfinkel <simsong@Silver-SSD.local>
1
2 * configure.ac: updated version to 3.5.10
3
4 * tools/aff_bom.h: removed non-PD terms in copyright statement.
5
6 * tools/aff_bom.cpp: removed non-PD terms in copyright statement.
7
8 2010-03-14 Simson Garfinkel <simsong@Silver-Surfer.local>
9
10 * configure.ac: increased version number to 3.5.9
11
12 * lib/vnode_raw.cpp: now sets af->imagesectorsize when
13 AF_SECTORSIZE is requested.
14
15 * (raw_filesize): moved added support for af_figure_media to
16 raw_filesize().
17
18 * (raw_open): modified to call raw_filesize() to figure size of
19 the media
20
21 * bulk_extractor should now work with raw devices.
22
23 2010-02-23 Simson L. Garfinkel <simsong@Silver-SSD.local>
24
25 * configure.ac: increased version to 3.5.8
26
27 * tools/test_signing.sh (echo): removed ./ from command names.
28
29 * tools/afconvert.cpp (main): removed TERM dependency from
30 afconvert.
31
32 2010-01-17 Simson L. Garfinkel <simsong@Silver-SSD.local>
33
34 * lib/afflib_pages.cpp: removed 'shouldfree' comment, because the
35 variable is gone.
36
37 2010-01-16 Simson L. Garfinkel <simsong@Silver-SSD.local>
38
39 * configure.ac: updated version to 3.5.6
40
41 2010-01-15 simsong <simsong@domex.nps.edu>
42
43 * lib/vnode_ewf.cpp (ewf_get_seg): ewf_get_seg had segnum as an uint64_t; should have been a uint_64_t.
44
45 2010-01-03 Simson L. Garfinkel <simsong@Silver-SSD.local>
46
47 * configure.ac: now properly handles linux systems that have
48 libewf installed but not uuid-dev
49
50 2009-12-24 Simson L. Garfinkel <simsong@Silver-SSD.local>
51
52 * configure.ac: incremented version to 3.5.5
53
54 * tools/afverify.cpp (process): modified to only complain of an
55 unsigned file if the unsigned segments are data segments.
56
57 * tools/afverify.cpp (verify_bom_signature): fixed bug in
58 verification of XML signatures. I have no idea why this was
59 here. Added better error checking.
60
61 2009-12-24 Simson L. Garfinkel <simsong@Silver-SSD.local>
62
63 * tools/test_*.sh: modified to use mkstemp to create proper
64 temporary files.
65
66 * lib/afflib_pages.cpp (af_read_sizes): corrected to properly
67 calculate the size of the last page
68
69 2009-12-23 simsong <simsong@domex.nps.edu>
70
71 * lib/afflib.cpp (af_get_imagesize): added memset(&vni,0,...) to af_get_imagesize()
72
73 2009-12-20 Simson L. Garfinkel <simsong@Silver-SSD.local>
74
75 * lib/afflib.cpp (af_invalidate_vni_cache): created new function,
76 since invalidation was happening in more than one place
77
78 2009-12-19 simsong <simsong@domex.nps.edu>
79
80 * tools/afcrypto.cpp (main): added -E option which just prints the number of segments that would be encrypted.
81
82 2009-12-16 Simson Garfinkel <simsong@Silver-Surfer.local>
83
84 * lib/afflib.cpp (af_open_with): modified so that a valid AFFILE
85 is returned even if the passphrase is invalid
86
87 2009-12-14 Simson Garfinkel <simsong@Silver-Surfer.local>
88
89 * lib/vnode_aff.cpp (aff_vstat): wasn't setting cannot_decrypt:1; fixed.
90
91 * tools/afconvert.cpp (convert): fixed so that it handles file:// notation.
92
93 2009-12-13 Simson L. Garfinkel <simsong@Silver-SSD.local>
94
95 * configure.ac: upgraded version count to 3.5.4
96
97 * tools/afverify.cpp (main): added OpenSSL_add_all_digests().
98 (usage): added debug to print if SHA256 isn't working.
99
100 2009-12-13 Simson Garfinkel <simsong@Silver-Surfer.local>
101
102 * tools/test_recovery.sh (PATH): now stores tempfiles in /tmp
103
104 * tools/test_afsegment.sh (echo): now stores tempfiles in /tmp/
105
106 * tools/test_passphrase.sh: now stores tempfiles in /tmp, rather
107 than in the current directory.
108
109 * tools/afconvert.cpp (convert): fixed utimes() so that it is
110 applied to the af_output_filename.
111
112 * tools/afcrypto.cpp (main): added option -j to print total number
113 of encrypted segments and -J to print total number of unencrypted segments.
114
115 2009-12-05 Simson Garfinkel <simsong@23.sub-75-210-229.myvzw.com>
116
117 * lib/vnode_aff.cpp (aff_close): forgot to close aff_toc_free,
118 causing memory leak. Fixed.
119
120 2009-12-05 Simson Garfinkel <simsong@Silver-Surfer.local>
121
122 * lib/vnode_ewf.cpp (ewf_get_seg): same bug as below
123
124 * lib/vnode_qemu.cpp (qemu_get_seg): bug in qemu_get_seg should
125 have set *datalen to 8 when called with *datalen=0. Fixed.
126
127 * tools/afcompare.cpp (compare_aff_aff): fixed handling when
128 images have different pagesize but same sectorsize.
129
130 * lib/vnode_raw.cpp (raw_get_seg): added check for seek beyond end
131 of file
132
133 2009-11-26 Simson Garfinkel <simsong@t>
134
135 * MASSIVE UPDATE: fixed many compiler warnings from signness and
136 bad printf formats.
137
138 * lib/afflib.h: af_read now returns ssize_t
139
140 2009-11-26 Simson Garfinkel <simsong@Silver-Surfer.local>
141
142 * tools/afcrypto.cpp: now reports the number of encrypted pages
143
144 * lib/vnode_aff.cpp (aff_vstat): now calculates the number of
145 encrypted pages.
146
147 * lib/afflib.cpp (af_seek): reworked so that there would be no
148 sign problems
149
150 * configure.ac (AFFUSE_BIN): turned on -Wall. enabled
151 _FORTIFY_SOURCE=2 in the Makefiles. What happened to that?
152
153 2009-11-25 Simson Garfinkel <simsong@205.2.242.10.in-addr.arpa>
154
155 * configure.ac: updated to version 3.5.3
156
157 2009-11-25 Simson Garfinkel <simsong@Silver-Surfer.local>
158
159 * lib/crypto.cpp (af_get_affkey_using_keyfile): fixed swapped
160 memset arguments.
161
162 * lib/vnode_s3.cpp (s3_get_next_seg): fixed swapped memset arguments.
163
164 * lib/s3_glue.cpp (encode): fixed swapped memset arguments.
165
166 2009-11-01 Simson L. Garfinkel <simsong@imac2.local>
167
168 * configure.ac: also checks ${prefix} for installed libraries
169
170 2009-10-22 Simson Garfinkel <simsong@142.sub-75-226-173.myvzw.com>
171
172 * configure.ac: updated to version 3.5.2
173
174 2009-10-20 Simson Garfinkel <simsong@Silver-Surver.local>
175
176 * win32/Makefile.am (the_release): added libeay32.dll to zipfile
177
178 2009-10-09 Simson Garfinkel <simsong@domex.nps.edu>
179
180 * Removed AFF_SIGS since it is now determined on the fly.
181
182
183 * configure.ac: remove SHA256 detection from configure script; this is now done at runtime.
184
185 * lib/afflib_pages.cpp (af_update_page): modified write_sha256 block to use the EVP system.
186
187 * lib/afflib.cpp (af_initialize): removed SHA256 validation vectors from af_initialize() because AFFLIB now uses the EVP system for SHA256.
188
189 2009-10-04 Simson Garfinkel <simsong@m.ern.nps.edu>
190
191 * tools/afinfo.cpp (print_info): fixed bug in which auto_decrypt
192 was being set even if it was not previously set.
193
194 * lib/afflib.cpp (af_set_option): now returns the previous version
195 of the option that is set.
196
197 2009-10-03 Simson Garfinkel <simsong@Silver-Surver.local>
198
199 * tools/afdiskprint.cpp: added O_BINARY define for Windows.
200
201 2009-09-30 Simson Garfinkel <simsong@t>
202
203 * configure.ac: updated version number to 3.4.2
204
205 * tools/afdiskprint.cpp: added #include <algorithm> because STL
206 isn't very S on Linux.
207
208 2009-09-22 Simson Garfinkel <slgarfin@hamming.uc.nps.edu>
209
210 * lib/vnode_aff.cpp (aff_open): failure to obtain exclusive lock
211 now generates warning rather than error.
212
213 * tools/afdiskprint.cpp (main): added #ifdef HAVE_SRANDOMDEV for
214 compilation on linux
215
216 2009-09-17 Simson Garfinkel <simsong@Silver-Surver.local>
217
218 * configure.ac: increased version number to 3.4.0
219
220 * tools/afdiskprint.cpp (diskprint_verify): added diskprint.
221
222 2009-08-22 Simson Garfinkel <simsong@79.sub-70-198-200.myvzw.com>
223
224 * configure.ac: increased version number to 3.3.8
225
226 2009-08-20 Simson Garfinkel <simsong@65.sub-75-195-141.myvzw.com>
227
228 * lib/*.cpp and tools/*.cpp (info_file): warnings removed for GCC 4.2.1
229 * Updated many format strings to handle GCC 4.2.1
230
231 2009-08-08 Simson Garfinkel <simsong@imac2.local>
232
233 * tools/affix.cpp (fix): changed truncate() to ftruncate(), as we
234 have a valid win32 cover for ftruncate.
235
236 * tools/afconvert.cpp (convert): made call to utimes() conditional
237 because we don't always have it.
238
239 * lib/Makefile.am (AFFLIB_SOURCES): removed aftimer.cpp, since the
240 class is now entirely defined in the aftimer.h
241
242 2009-07-22 Simson Garfinkel <simsong@Snow3-2.local>
243
244 * configure.ac: now specifically tells the user to install an up-to-date version of OpenSSL if SHA256 is missing.
245
246 Version number upped to 3.3.7
247
248 2009-05-19 Simson Garfinkel <simsong@m.ern.nps.edu>
249
250 * configure.ac: upped version number to 3.3.6
251
252 * Fixed bug in handling of fixed-size AFD files.
253
254 2009-05-03 Simson Garfinkel <simsong@imac2.local>
255
256 * changed version number to 3.3.5
257
258 * Modified configure.ac so lack of SHA256 is no longer fatal
259
260 2009-03-17 Simson L. Garfinkel <simsong@domex.nps.edu>
261
262 * tools/afxml.cpp (xml_info): changed name= to image_filename= in affinfo attribute.
263
264 2009-03-05 Simson Garfinkel <simsong@Silver-Surfer.local>
265
266 2009-02-21 Simson Garfinkel <simsong@t>
267
268 * configure.ac: added AC_CHECK_LIB([rt],[aio_error64]) to configure.ac
269
270 2009-02-11 Simson Garfinkel <simsong@Silver-Surfer.local>
271
272 * configure.ac: support added for VMDK and DMG files.
273 Version number will be incremented to to 3.4 when they are stable.
274
275 2009-02-10 Simson Garfinkel <simsong@Silver-Surfer.local>
276
277 * lib/afflib.cpp (af_open_with): Now, if it can't allocate
278 AFFLIB_CACHE_PAGES_DEFAULT, try to allocate just 2 pages.
279
280 * lib/afflib.h (AFFLIB_CACHE_PAGES_DEFAULT): Default page cache
281 size increased from 2 pages to 32, increasing memory requirements
282 from 32MB to 512MB. This will make AFFLIB run dramatically faster
283 in most situations. It will, however, require lowering when AFF is
284 running in reduced memory configurations.
285
286 2009-01-27 Simson Garfinkel <simsong@Silver-Surfer.local>
287
288 * lib/afflib.cpp: created function to set acquisition date in a
289 standardized way.
290
291 * tools/afconvert.cpp (usage): removed -Z option from usage
292 because it was never implemented.
293
294 2008-12-30 Simson Garfinkel <simsong@m.ern.nps.edu>
295
296 * lib/Makefile.am (AFFLIB_SOURCES): moved display_as_quad to
297 af_display_as_quad() and added to library.
298
299 2008-10-28 Simson L. Garfinkel <simsong@domex.nps.edu>
300
301 * lib/afflib_stream.cpp (af_read): if reading through a short page, return (0) for attempts to read additional bytes. (Previously generated a crash...) What's the correct behavior? SHould we advance to the beginning of the next page? I don't know.
302
303 2008-10-12 Simson Garfinkel <simsong@137.sub-75-221-230.myvzw.com>
304
305 * man/Makefile.am: created man page for afcat
306
307 2008-09-29 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
308
309 * configure.ac: incremented version counter to 3.3.4
310
311 * pyaff/pyaff.c: changed #include from afflib/afflib.h to lib/afflib.h
312
313 2008-09-23 Simson Garfinkel <simsong@imac2.local>
314
315 * lib/afflib_i.h (struct af_figure_media_buf): incremented
316 max_read_blocks from 4 bytes to 8 bytes because that's what Apple returns!!!
317
318 2008-09-10 Simson Garfinkel <simsong@imac2.local>
319
320 * configure.ac: upped version counter to 3.3.3
321
322 * Added include <cstring> to all CPP files that had include <string>
323
324 2008-09-04 Simson Garfinkel <simsong@Silver-Surfer.local>
325
326 * configure.ac (AFFUSE_BIN): removed printing of modified cflags
327
328 * lib/s3.cpp (s3_df): removed af_commas, as it was already in afflib_utils.cpp
329 (s3_ls): changed af_commas to PRId64
330
331 2008-09-03 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
332
333 * configure.ac: fixed support for QEMU under Linux (added -lrt ---
334 what a weird place to put it), and also fixed autoconf problem of
335 qemu support being required even when it was turned off.
336
337 2008-08-25 Simson L. Garfinkel <simsong@domex.nps.edu>
338
339 * lib/afflib.h (struct af_vnode_info):
340
341 * lib/afflib.cpp (af_get_imagesize): updated for new af_vnode_info name
342
343 * lib/afflib.h (struct af_vnode_info): encrypted_count and
344 signed_count changed to segment_count_encrypted and
345 segment_count_signed; page_count_total and segment_count_total added.
346
347 2008-08-26 Simson Garfinkel <simsong@m.ern.nps.edu>
348
349 * configure.ac: removed QEMU support by default; it needs more work.
350
351 2008-08-17 Simson Garfinkel <simsong@199.122.224.10.in-addr.arpa>
352
353 * configure.ac: made OpenSSL error on Mac fatal.
354
355 * lib/Makefile.am (libafflib_la_SOURCES): s3_glue is now not included
356 in AFFLIB SOURCES if MAYBE_S3 is false.
357
358 2008-08-17 Simson Garfinkel <simsong@94.24.242.10.in-addr.arpa>
359
360 * lib/afflib_stream.cpp (af_set_maxsize): changed call from
361 af_get_imagesize() to access of af->image_size.
362
363 * lib/afflib.cpp (af_seek): changed called to af_get_imagesize()
364 to af->image_size
365 (af_get_imagesize): removed locking, as the individual elements of
366 the af structure are not accessed.
367
368 2008-08-17 Simson Garfinkel <simsong@Silver-Surfer.local>
369
370 * lib/afflib.cpp (af_update_segf): modified to clear af->vni_cache
371
372 * lib/afflib.cpp (af_vstat): added support for caching results.
373
374 * lib/afflib_stream.cpp (af_write): modified to clear af->vni_cache
375
376 * lib/afflib_stream.cpp (af_read): modified to use af->image_size
377 rather than a calculated image_size.
378
379 2008-08-13 Simson Garfinkel <simsong@Silver-Surfer.local>
380
381 * lib/vnode_ewf.cpp (ewf_get_seg): now takes imagesize from
382 af->image_size, since it was already set.
383 (ewf_bytes_per_sector): refactored all libewf_get_bytes_per_sector
384 into this function.
385
386 2008-08-11 Simson Garfinkel <simsong@0.sub-70-211-150.myvzw.com>
387
388 * configure.ac: increased version number to 3.2.7
389
390 * lib/s3.cpp: changed include err.h to include afflib_i.h for
391 cases where users want s3 but don't have err.h (like Solaris)
392
393 2008-08-07 Simson Garfinkel <simsong@imac2.local>
394
395 * configure.ac: version increased to 3.2.6
396
397 * lib/vnode_ewf.cpp (ewf_close): modified to use the second
398 argument for libewf if LIBEWF_VERSION>=20080501
399
400 2008-07-22 Simson Garfinkel <simsong@112.sub-75-199-16.myvzw.com>
401
402 * configure.ac: upped version to 3.2.5, as 3.2.4 wouldn't compile
403 on machines without EVP_SHA256.
404
405 2008-07-20 Simson Garfinkel <simsong@imac2.local>
406
407 * lib/afflib.cpp (af_make_gid): returns -1 if an error, 0 if GID
408 exists, and if one is made.
409
410 * lib/crypto.cpp: (af_sign_all_unsigned_segments): Now returns the
411 number of unsigned segments that were signed.
412
413 * tools/afsign.cpp (afsign):
414
415 * lib/crypto.cpp (af_is_signature_segment): af_is_signed_segment
416 changed to af_is_signature_segment because that's what it is doing.
417
418 2008-07-18 Simson Garfinkel <simsong@imac2.local>
419
420 * lib/vnode_ewf.cpp (ewf_get_seg): fixed case of data==0 and
421 datalen==0 generating an error.
422 (ewf_get_seg): fixed requesting of invalid pages
423
424 2008-07-18 Simson Garfinkel <simsong@m.ern.nps.edu>
425
426 * tools/afcopy.cpp (main): changed -s option to -k for consistency
427 with afsign.
428
429 2008-07-16 Simson Garfinkel <simsong@m.ern.nps.edu>
430
431 * lib/vnode_aff.cpp (aff_vstat): removed has_encrypted and
432 has_signed from the vni information; use the encrypted_count and
433 signed_count. Sorry about breaking backward compatibility with the
434 binary API; nobody is using this yet.
435
436 * tools/afsign.cpp (afsign): bug in signing of signature pages fixed.
437
438 2008-07-15 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
439
440 * configure.ac: increased version number to 3.2.4
441
442 2008-07-14 Simson Garfinkel <simsong@m.ern.nps.edu>
443
444 * lib/vnode_aff.cpp (aff_open): added flock to vnode_aff, so that
445 multiple writers to an AFF file will now block rather
446 than corrupt the file
447
448 2008-07-10 Simson Garfinkel <simsong@copy.ern.nps.edu>
449
450 * tools/afinfo.cpp (figure_media): added -A option to print XML
451 output of media params.
452
453 2008-07-09 Simson L. Garfinkel <simsong@domex.nps.edu>
454
455 * tools/afxml.cpp: suppreses XML output of encrypted segments
456
457 * tools/afinfo.cpp (info_file): color was too hard to do; we just use bold now for decrypted data
458
459 2008-07-08 Simson L. Garfinkel <simsong@domex.nps.edu>
460
461 * tools/afxml.cpp (xml_info): fixed bug in afxml where last 2 chars of md5_hex were not reported because not large enough buffer was allocated
462
463 * lib/afflib_util.cpp (af_hexbuf):
464
465 2008-07-07 Simson Garfinkel <simsong@m.ern.nps.edu>
466
467 * tools/afsegment.cpp (main): added -x to print segment as hex string
468
469 2008-07-05 Simson Garfinkel <simsong@imac2.local>
470
471 * lib/Makefile.am (#aftest_LDFLAGS): lib/s3 binary no longer made
472 if S3 is not enabled.
473
474 2008-07-03 Simson Garfinkel <simsong@image.ern.nps.edu>
475
476 * tools/afsegment.cpp (process): better error messages when
477 segment doesn't exist
478
479 2008-07-03 Simson L. Garfinkel <simsong@domex.nps.edu>
480
481 * tools/afinfo.cpp (info_file): fixed printing so color is left as
482 red, not black
483 (info_file): only reports missing pages can't be computed if -d
484 flag is present.
485
486 2008-07-02 Simson Garfinkel <simsong@Silver-Surfer.local>
487
488 * lib/afflib_i.h (AF_VNODE_NO_SEALING): added flags for
489 AF_VNODE_NO_SIGNING and AF_VNODE_NO_SEALING so that AFF
490 implementations that do not support encryption can declare
491 this. Added appropriate macros for checking these variables.
492
493 2008-06-29 Simson Garfinkel <simsong@imac2.local>
494
495 * configure.ac: incremented version to 3.2.3
496
497 * tools/afconvert.cpp (convert): fixed bug in which converting .aff file
498 to a .afd file caused crash
499
500 2008-06-27 Simson Garfinkel <simsong@m.ern.nps.edu>
501
502 * lib/afflib.cpp: added locking to all of the functions; still
503 need to add it to afflib_streams.
504
505 * lib/afflib_util.cpp: moved eff, af_err, errx, warn and warnx to
506 this file.
507
508 2008-06-24 Simson Garfinkel <simsong@Silver-Surfer.local>
509
510 * tools/affix.cpp (fix): adds an AF_IMAGE_GID if one doesn't exist.
511 (fix): fixed error in which O_RDWR flag was being passed as a mode
512 to af_open_with(). This prevented the -y option from operating
513 properly.
514
515 * tools/afconvert.cpp (convert): adds an AF_IMAGE_GID if one doesn't exist.
516
517 * tools/afcopy.cpp (afcopy): adds an AF_IMAGE_GID if one doesn't exist.
518
519
520 * lib/afflib.cpp (af_make_gid): added af_make_gid (removed from aimage)
521
522 2008-06-20 Simson Garfinkel <simsong@Silver-Surfer.local>
523
524 * configure.ac: incremented version number to 3.2.2
525
526 2008-06-18 Simson Garfinkel <simsong@Silver-Surfer.local>
527
528 * Makefile.am: added threaded_hash.h to the list of installed .h files
529
530 2008-06-10 Simson Garfinkel <simsong@Obsidian.local>
531
532 * lib/aff_toc.cpp: simplified to make toc mandatory.
533
534 2008-06-02 Simson Garfinkel <simsong@copy.ern.nps.edu>
535
536 * lib/afflib.cpp (af_open_with): fixed error in wiping password
537 when open mode is read-only and password is provided. (If no
538 encryption segment is present, do not use a password.)
539
540 2008-05-28 Simson L. Garfinkel <simsong@domex.nps.edu>
541
542 * tools/afinfo.cpp (info_file): now states that bold is something that was decrypted
543
544 2008-05-30 Simson Garfinkel <simsong@Obsidian.local>
545
546 * tools/afinfo.cpp (info_file): decrypted data now shows in red
547 and bold
548
549 * lib/afflib_i.h (struct _AFFILE): fixed definition of struct
550 _AFFILE to be compatible with C (was just compatible with C++).
551
552 2008-05-29 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
553
554 * lib/vnode_ewf.cpp (ewf_get_seg): modifid once again to work with
555 wide char
556
557 2008-05-21 Simson Garfinkel <simsong@Obsidian.local>
558
559 * lib/vnode_afd.cpp (afd_open): now refuses to open a .afd
560 directory with no aff files.
561
562 * tools/afcrypto.cpp (main): AFCRYPTO will now only encrypt AFD
563 and AFM files.
564
565 2008-05-20 Simson Garfinkel <simsong@Obsidian.local>
566
567 * tools/*.cpp (recover): changed err() to af_err() after every af_open().
568
569 * lib/vnode_aff.cpp (aff_get_next_seg): detects truncated files
570 and will not allowed them to be opened.
571
572 2008-05-19 Simson Garfinkel <simsong@Obsidian.local>
573
574 * tools/affix.cpp (usage): removed -b option; wasn't using it.
575
576 2008-05-17 Simson Garfinkel <simsong@Obsidian.local>
577
578 * lib/afflib.cpp (af_update_segf): changed padding to 01 for 1 pad
579 byte, 02 02 for two pad bytes, etc., in keeping with PKCS7.
580
581 * lib/afflib.h (AFFLIB_TRACEFILE): changed AFFLIB_TRACE to AFFLIB_TRACEFILE
582
583 2008-05-13 Simson L. Garfinkel <simsong@domex.nps.edu>
584
585 * tools/afxml.cpp (xml_info): for some reason, XML sometimes had a ^C at the end. Changed malloc to calloc to zero buffer and avoid the problem.
586
587 2008-05-12 Simson Garfinkel <simsong@m.ern.nps.edu>
588
589 * lib/aftest.cpp (lzma_test): changed more char *'s to const char *.
590
591 * lib/afflib_i.h (struct af_vnode): changed char *name to const
592 char *name; wonder why I didn't see this before.
593
594 2008-05-08 Simson Garfinkel <simsong@Obsidian.local>
595
596 * configure.ac: fixed script so that setting the environment
597 variable AFF_NOOPT to any value will prevent optimization
598
599 2008-05-07 Simson Garfinkel <simsong@imac2.local>
600
601 * lib/crypto.cpp (af_get_aes_key_from_passphrase): fixed error in
602 kversion checking; additional work on encryption compatibility
603 between Mac and Linux
604
605 2008-04-28 Simson Garfinkel <simsong@Obsidian.local>
606
607 * tools/afinfo.cpp: updated copyright notice.
608
609 * tools/aff_bom.cpp: added public domain disclaimer
610
611 * tools/aff_bom.h: added public domain disclaimer
612
613 * tools/afcrypto.cpp: corrected copyright notice
614
615 * tools/afcompare.cpp: updated copyright notice
616
617 * tools/afconvert.cpp: updated copyright notice.
618
619 2008-04-26 Simson Garfinkel <simsong@imac2.local>
620
621 * tools/afcopy.cpp (afcopy): removed debugging.
622
623 2008-04-25 Simson Garfinkel <simsong@imac2.local>
624
625 * lib/afflib.h (AF_XML_AFFBOM): AF_XML_CUSTODY_CHAIN renamed
626 AF_XML_AFFBOM and changed from "custody_chain" to "affbom"
627
628 2008-04-23 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
629
630 * lib/crypto.cpp (af_get_aes_key_from_passphrase): added code to
631 fix compiler problem on Linux/GCC 4.0/64-bit machines in which
632 unsigned long foo:32 took up 8 bytes (instead of 4).
633
634 * Added to code to handle reading incorrectly-generated 56-byte affkey segments
635
636 2008-04-21 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
637
638 * lib/vnode_ewf.cpp (ewf_get_seg): changes made to support the
639 circa 2007 version of libewf
640
641 * tools/afcrypto.cpp (main): changed output to make easier to parse and more useful.
642
643 * lib/vnode_aff.cpp (aff_vstat): added signed_count and encrypted_count.
644
645 2008-04-14 Simson Garfinkel <simsong@Obsidian.local>
646
647 * lib/vnode_raw.cpp (raw_read): replaced fseek() with fseeko().
648
649 * lib/vnode_aff.cpp (af_truncate_blank): replaced fseek() with
650 fseeko()
651
652 * lib/vnode_aff.cpp (aff_update_seg): replaced fseek() with fseeko(). (Shouldn't
653 matter here, but it might).
654
655 * lib/vnode_raw.cpp (raw_write): changed fseek() to fseeko().
656
657 2008-03-27 Simson Garfinkel <simsong@Obsidian.local>
658
659 * Added debian system provided by Joachim Metz
660
661 * configure.ac: incremented version counter to 3.1.5
662
663 * lib/afflib.cpp (af_get_imagesize): now sets errno=1 if it can't
664 determine imagesize because of encryption.
665
666 * afflib.pc.in (prefix): added file
667
668 2008-03-24 Simson Garfinkel <simsong@Obsidian.local>
669
670 * lib/vnode_ewf.cpp (ewf_get_seg): updated to handle with libewf
671 returning -1 for error and 1 for success.
672
673 2008-03-12 Simson Garfinkel <simsong@m.ern.nps.edu>
674
675 * afflib.spec.in (BuildRequires): fixed subdirectory problem in specfile.
676
677 2008-03-09 Simson Garfinkel <simsong@m.ern.nps.edu>
678
679 * configure.ac:
680
681 2008-03-09 Simson Garfinkel <simsong@imac2.local>
682
683 * configure.ac: updated to AFFLIB-3.1.3
684
685 2008-03-09 System Administrator <simsong@Obsidian.lan>
686
687 * lib/Makefile.am (install-exec-hook): fixed shell script syntax error
688
689 2008-03-05 Simson Garfinkel <simsong@imac2.local>
690
691 * lib/vnode_ewf.cpp: updated for libewf 20080305
692
693 2008-03-02 Simson Garfinkel <simsong@imac2.local>
694
695 * afflib.spec.in (BuildRequires): added missing include files
696
697 * Makefile.am (pkginclude_HEADERS): removed duplicate afflib_sha256.h
698
699 2008-02-28 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
700
701 * tools/afrecover.cpp (recover): fixed bug in printf statement.
702
703 2008-02-26 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
704
705 * Here's how to turn on executable property in the SVN repository:
706 svn propset svn:executable ON test_tools.sh
707 More at http://svnbook.red-bean.com/en/1.0/re23.html
708
709 2008-02-26 Simson Garfinkel <simsong@imac2.local>
710
711 * lib/afflib.cpp (af_update_segf): fixed annoying bug which caused
712 signing of encrypted data being written to generate segmentation
713 errors under some conditions.
714
715 * configure.ac: better reporting of dependencies for aff signatures
716
717 2008-02-26 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
718
719 * tools/afsegment.cpp (usage): usage fixed, removing space after
720 -s and -p options (apparently getopt on Linux can't handle it.)
721
722 * lib/crypto.cpp (af_sig_verify_seg): #ifdef USE_AFFSGIS changed
723 to #ifdef USE_AFFSIGS
724
725 * lib/utils.cpp: C++ utilities moved into the aff namespace.
726
727 * tools/afverify.cpp (main): version flag changed from -v to -V
728 for consistency with other tools.
729
730 * lib/afflib_os.cpp (af_figure_media): fixed another int64 reference
731
732 2008-02-26 Simson Garfinkel <simsong@m.ern.nps.edu>
733
734 * tools/afverify.cpp (usage): corrected usage.
735
736 2008-02-25 Simson Garfinkel <simsong@m.ern.nps.edu>
737
738 * configure.ac: now properly handles libexpat once again
739
740 * lib/afflib_i.h: removed lots of the #ifdefs for openssl/*.h and replaced if #ifdef HAVE_LIBSSL
741
742 * lib & tools: moved utils.cpp from tools directory to lib directory
743
744 * Makefile.am (pkginclude_HEADERS): added lib/aftimer.h to the list of installed headers
745
746 2008-02-24 Simson Garfinkel <simsong@imac2.local>
747
748 * lib/afflib.cpp (af_get_imagesize): changed int64 to int64_t and
749 uint64 to uint64_t for compliance with C99 standard.
750
751 * aimage removed for AFF; it is now going to be its own distribution
752
753 2008-02-12 SImson L. Garfinkel <simsong@copy.ern.nps.edu>
754
755 * aimage/gui.cpp (my_refresh): changed screen update so it now happens every 128K bytes.
756
757 2008-02-10 SImson L. Garfinkel <simsong@copy.ern.nps.edu>
758
759 * tools/afcat.cpp (sig_info): added SIGINFO (^t) to afcat to print current page
760
761 2008-02-10 Charlie Root <simsong@copy.ern.nps.edu>
762
763 * lib/vnode_raw.cpp (raw_open): modified raw so that it will write as well
764
765 2008-02-20 Simson Garfinkel <simsong@m.ern.nps.edu>
766
767 * lib/afflib_i.h ("C"): put everything inside an extern "C".; removed legacy uint64 and int64 types.
768
769 * tools/Makefile.am (bin_PROGRAMS): added test_tools to being to get some more automated testing.
770
771 * tools/afsign.cpp (afsign): improved error message when certificate file cannot be loaded
772
773 * tools/afsegment.cpp (usage): fixed usage so that version number is -V (as the option was implemented)
774
775 2008-02-13 Simson Garfinkel <simsong@imac2.local>
776
777 * configure.ac: revamped to allow you to specify where expat is located
778
779 2008-02-08 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
780
781 * tools/afcat.cpp (afcat): now warns if it can't cat because it
782 doesn't have the encryption keyx
783
784 * lib/afflib.h: moved af_vstat() into afflib.h.
785 * lib/afflib.h: moved actually AFFILE definition into afflib_i.h
786
787 2008-02-06 SImson L. Garfinkel <simsong@copy.ern.nps.edu>
788
789 * aimage/gui.cpp (my_refresh): Now prints names of input and
790 output files on display.
791
792 * aimage/aimage.cpp: You can now specify "%d" or "%02d" or any
793 %...d format in the output filename; %d is incremented until the
794 file doesn't exist.
795
796 2008-01-29 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
797
798 * lib/aftest.cpp (main): made default to run all tests
799 (main): now erases the test files after creating them.
800
801 * Makefile.am (prerelease): added "make distcheck" to prelease target
802
803 2008-01-28 Simson Garfinkel
804 * Released 3.0.5 - doesn't compile due to noinst_ issue in
805 Makefile.am
806 * Released 3.0.6, which is the same as 3.0.5 but doesn't install
807 libraries.
808
809 2007-12-24 Simson Garfinkel <simsong@imac2.local>
810
811 * afflib.spec.in (Name): Joachim Metz contributed this file.
812
813 2007-12-18 Simson Garfinkel <simsong@Obsidian.local>
814
815 * lib/vnode_afd.h (AFD_DEFAULT_MAXSIZE): Changed from 600 to 608
816 (so that it is now a multiple of 16; not strictly needed, but it
817 makes things a bit cleaner.)
818
819 * lib/afflib.cpp (af_update_segf): fixed crasher on update when
820 af->crypto->encrypt was not present.
821
822 * tools/affuse.c (main): improved error messages for when affuse
823 can't run.
824
825 2007-12-14 Simson Garfinkel <simsong@Obsidian.local>
826
827 * configure.ac: changed config.h to affconfig.h to minimize
828 name space collisions.
829
830 * lib/Makefile.am (lib_LTLIBRARIES): libafflib.la is now an
831 installed library.
832
833 2007-11-27 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
834
835 * tools/afxml.cpp (okay_to_print): added ', ", and & to the list
836 of characters that cannot be output in XML
837
838 * lib/afflib.cpp (af_open_with): opening a read-only AFF file that
839 has no encryption works, even if you specify an encryption password.
840
841 * tools/afinfo.cpp (display_as_hex): displayed image GID in hex
842
843 2007-11-26 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
844
845 * REMOVED lib/sha256.c --- the implementation had bugs. (That's
846 what I get for including a non-validated crypto algorithm.) AFF
847 now requires SHA256 but it should compile without it
848
849 * tools/afsegment.cpp (main): now handles case when optarg==0
850 (which happened with afsegment -d seg instead of affsegment -dseg)
851 (usage): added : to "d" in getopt.
852
853 2007-11-24 Simson Garfinkel <simsong@imac2.local>
854
855 * lib/crypto.cpp: refactored AFF compilation error message
856
857 2007-11-16 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
858
859 * lib/vnode_aff.cpp (aff_identify_file): fixed parsing of file:// URLs.
860
861 2007-11-14 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
862
863 * lib/afflib.h: af_is_badsector now takes const unsigned char
864 *buf; taking non-const was an error
865
866 2007-11-13 Simson L. Garfinkel <simsong@domex.local>
867
868 * lib/afflib_sha256.h: minor tweaks to deal with the problem with
869 SHA256() and EVP_sha256() are present but not in the #include file.
870
871 2007-11-07 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
872
873 * tools/afsegment.cpp (main): -q renamed to be -Q (because -q
874 should be quiet)
875 (main): only prints filename if there is more than one file
876 (main): only prints segname if there is more than one seg
877
878 2007-10-31 Simson Garfinkel <simsong@imac2.local>
879
880 * tools/utils.cpp: added #ifdef AFF_SIGS so that bom class won't
881 be compiled if not compiling with AFFSIGS
882 added #include <afflib_i.h> to get #ifdef AFF_SIGS
883
884 2007-10-29 Simson Garfinkel <simsong@imac2.local>
885
886 * tools/afinfo.cpp (info_file): aes_segs now initialized to
887 0. (Strangely, the uninitialized value was causing problems when
888 running with MSC.)
889
890 * lib/vnode_s3.cpp (s3_cantopen): added "return -1" to s3_cantopen()
891
892 * lib/vnode_aff.cpp (aff_get_next_seg): ENOBUFS error on
893 incomplete reads changed to E2BIG, since there is no ENOBUFS on windows.
894
895 2007-10-23 Simson Garfinkel <simsong@m-ern-nps-edu.local>
896
897 * tools/afverify.cpp: moved #include "expat.h" to after the #ifdef USE_AFFSIGS
898
899 2007-10-25 Simson Garfinkel <simsong@imac2.local>
900
901 * lib/afflib_pages.cpp (af_update_page): lots of code that
902 required signatures made #ifdef USE_AFFSIGS for compiling under
903 Windows without OpenSSL
904
905 * lib/afflib_util.cpp (af_parse_url): index() changed to strchr()
906 for Win32.
907
908 2007-10-24 Simson Garfinkel <simsong@imac2.local>
909
910 * lib/afflib.h: significant changes for compiling under win32.
911 - added u_int and others for compiling under win32.
912 - affkey_aes256 structure had an element with the same name;
913 structure renamed to affkey.
914
915 2007-10-20 Simson Garfinkel <simsong@imac2.local>
916
917 * lib/vnode_afm.cpp (afm_split_raw_setup): modified so that
918 ap->aff->image_size only needs to equal ap->sr->image_size if
919 ap->aff->image_size has already been set
920
921 2007-10-18 Simson Garfinkel <simsong@imac2.local>
922
923 * lib/vnode_split_raw.cpp (split_raw_get_seg): fixed bug in that
924 *datalen was not set properly if it was smaller than the size of
925 the segment, even if data==0. Fixed.
926
927 2007-10-16 Simson Garfinkel <simsong@imac2.local>
928
929 * lib/vnode_split_raw.cpp (split_raw_update_seg): was returning
930 the number of bytes written; now returns 0 if write is successful,
931 -1 if it is not.
932
933 2007-10-14 Simson Garfinkel <simsong@imac2.local>
934
935 * aimage/aimage.cpp (usage): --sign and -s now used to specify
936 private and public key used for signing.
937
938 * aimage/aimage.cpp (usage): --setseg used to be -s; changed to -g
939 so that we can use -s for signing.
940
941 2007-09-25 Simson Garfinkel <simsong@m-ern-nps-edu.local>
942
943 * tools/utils.cpp (get_seglist): fixed uninitialized variables in
944 get_seglist which was causing indeterminate behavior in get_seglist.
945
946 2007-09-16 Simson Garfinkel <simsong@Obsidian.local>
947
948 * BUGLIST.txt (library): removed need to check for af->writing,
949 because it's gone.
950
951 2007-09-15 Simson Garfinkel <simsong@Obsidian.local>
952
953 * lib/afflib.h: removed af->writing, because it wasn't good for
954 POSIX compatibility.
955
956 2007-09-14 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
957
958 * tools/afcopy.cpp (main): -c option (verify compression) removed
959 from usage because it was never implemented. New -c will specify
960 an X.509 certificate.
961
962 2007-09-12 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
963
964 * MULTIPLE FILES: changed most "const void *" pointers on update
965 and write routines to "const u_char *".
966
967 2007-09-02 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
968
969
970 * lib/aff_toc.cpp (aff_toc_del): fixed double-del problem; thanks
971 to Jason Shiffer for bringing this to our attention.
972
973 2007-08-29 Simson Garfinkel <simsong@m.ern.nps.edu>
974
975 * lib/Makefile.am, tools/Makefile.am, configure.ac (affuse_LDADD):
976 first steps for using libtool and shared libraries
977
978 * lib/afflib.cpp (af_open_with): added support for AFFLIB_PASSPHRASE
979
980 2007-08-27 Simson Garfinkel <simsong@m.ern.nps.edu>
981
982 * aimage/aimage.cpp (process_option): made opt_maxsize an int64;
983 added support for dvd and dvddl from luca at palazzo.name.
984
985 2007-08-20 Simson Garfinkel <simsong@Obsidian.local>
986
987 * lib/aftest.cpp (aestest): now sets page size in test files.
988
989 * lib/afflib.cpp (af_update_seg): af_update_seg() didn't check to
990 make sure that writing was enabled. Now it does.
991
992 2007-08-20 Simson Garfinkel <simsong@m.ern.nps.edu>
993
994 * lib/afflib_stream.cpp (af_write): Now sets pagesize to
995 AFF_DEFAULT_PAGESIZE (1024*1024*16) if a write is attempted
996 without a pagesize being previously set.
997
998 2007-08-18 Simson Garfinkel <simsong@Obsidian.local>
999
1000 * configure.ac: increased version to 2.4.0
1001
1002 * lib/aff_db.cpp (af_backspace): af_backspace will no longer
1003 backspace from the first segment in the file.
1004
1005 * lib/vnode_aff.cpp (aff_write_ignore): BUG --- if first segment
1006 was deleted, entire file got wiped. Whoops! fixed this.
1007
1008 * tools/afcopy.cpp (afcopy): bugfix - removed af_close(out.af);
1009 when zapping; file wasn't open.
1010
1011 2007-08-17 Simson Garfinkel <simsong@Obsidian.local>
1012
1013 * lib/vnode_s3.cpp (s3_open): revised for URL parsing in afflib.cpp
1014
1015 * lib/vnode_aff.cpp (aff_create): moved af_make_badflag to afflib.cpp
1016 (aff_get_next_seg): now sets errno to ENOBUFS if buffer isn't
1017 large enough to hold requested data.
1018
1019 2007-08-16 Simson Garfinkel <simsong@Obsidian.local>
1020
1021 * lib/vnode_aff.cpp (aff_open): changed all occurances of af_toc
1022 to aff_toc since the TOC is an AFF-file specific thing.
1023
1024 * tools/afinfo.cpp (usage): changed -p option (validate the hash
1025 of each page) to -v
1026
1027 2007-08-12 Simson Garfinkel <simsong@Obsidian.local>
1028
1029 * tools/afinfo.cpp (print_info): added two spaces to the "data
1030 length" printout.
1031
1032 2007-08-11 Simson Garfinkel <simsong@Obsidian.local>
1033
1034 * tools/afinfo.cpp (info_file): fixed printing of missing pages
1035 with -a when there was no device sector size.
1036
1037 * lib/afflib.cpp: added support for openssl/fips_sha.h
1038
1039 * S3 support is now disabled by default.
1040
1041 2007-08-11 Simson Garfinkel <simsong@m.ern.nps.edu>
1042
1043 * lib/s3_glue.cpp: removed main() if USE_S3 was not defined. What
1044 was I thinking?
1045
1046 2007-07-29 Simson Garfinkel <simsong@Obsidian.local>
1047
1048 * tools/afcopy.cpp (main): Removed -p option; now just has -X1
1049 through -X9 and -L for recompressing; these are the same flags as aimage.
1050
1051 * lib/afflib.cpp (af_open): attempts to open a file for writing
1052 with an invalid name now sets EINVAL.
1053
1054
1055 2007-07-26 Simson Garfinkel <simsong>
1056
1057 * tools/afxml.cpp (xml_info): removed use of af_backspace() so
1058 this will now work with S3.
1059 (xml_info): hex is now printed with coding='base16', decimal
1060 numbers now printed coding='base10'
1061 (xml_info): printable data now just printed, rather than encoded
1062
1063 2007-07-25 Simson Garfinkel <simsong>
1064
1065 * lib/afflib_stream.cpp (af_write): added check for valid
1066 image_pagesize in af_write if the write bypass is not used.
1067
1068 * lib/vnode_aff.cpp (aff_update_seg): removed stale "append" comment.
1069
1070 2007-07-19 Simson Garfinkel <simsong>
1071
1072 * lib/afflib.cpp (af_seek): af_seek w/ SEEK_CUR didn't work. It
1073 was doing SEEK_CUR as SEEK_SET. This is now fixed. SEEK_END was
1074 working.
1075 (af_seek): added automatic detection of random access, which now
1076 changes the af_update_seg algorithm.
1077
1078 * lib/vnode_aff.cpp (aff_write_ignore): modified so that if an
1079 IGNORE segment is written before another IGNORE, they are
1080 combined. Likewise, if one is written after an IGNORE, they are
1081 combined.
1082 (aff_update_seg): modified so that new objects smaller than 4096
1083 will not be dropped into deleted segments larger than 4096 bytes
1084 to prevent fragmentation.
1085
1086 2007-07-18 Simson Garfinkel <simsong>
1087
1088 * lib/vnode_aff.cpp (aff_update_seg): if the last segment is NULL,
1089 it is now erased before writing.
1090
1091 (aff_del_seg): now we use this on Windows, since _chsize_s() is a
1092 good analog for ftruncate()
1093
1094 * lib/aftest.cpp (reverse_test): reverse test now reads data to
1095 verify it is correct
1096
1097 2007-07-17 Simson Garfinkel <simsong>
1098
1099 * lib/s3.cpp: applied patches from Ted Romer. The 'cat' and 'cp'
1100 commands in s3.cpp had a bug where they neglect to skip over the
1101 command name in argv, with the result that cat always tries to
1102 look for the key 'cat' and 'cp' always tries to copy the file
1103 'cp'.
1104
1105 This patch fixes that, and also modifies cat and rmdir to accept
1106 multiple arguments.
1107
1108 2007-07-16 Simson L. Garfinkel <simsong@t.eecs.harvard.edu>
1109
1110 * lib/aftest.cpp (sparse_test): added read-at-end and
1111 read-beyond-end of sparse file tests to aftest -6
1112
1113 * lib/afflib_stream.cpp (af_read): removed break so that reads on
1114 pages that don't exist return NULs rather than errors.
1115
1116 2007-07-14 Simson L. Garfinkel <simsong>
1117
1118 * lib/vnode_s3.cpp: changed AF_IDENTIFY_AFD to AF_IDENTIFY_S3
1119 Modified system so that if s3 support is not compiled in, s3:///
1120 names generate an error.
1121
1122 * lib/afflib_i.h: changed from int64 to int64_t and from uint64 to uint64_t.
1123
1124 2007-07-13 Simson L. Garfinkel <simsong>
1125
1126 * Removed #define UNIX. Now we have #ifdef HAVE_POPEN (which is
1127 what we really wanted, anyway)
1128
1129 * Added support for uint64_t; uint64 now is a typedef for it.
1130 * Added support for int64_t; int64 now is a typedef for it.
1131
1132 2007-07-11 Simson L. Garfinkel <simsong>
1133
1134 * tools/afcopy.cpp (afcopy): cleaned up printing a bit
1135 (afcopy): fixed -y option, which apparently didn't work
1136
1137 * lib/afflib_pages.cpp (af_read_sizes): removed &arg from
1138 af_get_next_seg call. This change makes af_read_sizes()
1139 dramatically faster on s3 because the calls can be satisfied by
1140 reading the directory, rather than the need to read every
1141 individual segment.
1142
1143
1144 2007-07-10 Simson L. Garfinkel <simsong>
1145
1146 * configure.ac: S3 support is now disabled by default.
1147
1148 * lib/afflib.cpp (af_version): added af_version()
1149
1150 * lib/afflib.h: moved #include <inttypes.h> to its own major
1151 block, as prelude to moving over to C99 standards.
1152
1153 2007-07-04 Simson Garfinkel <simsong>
1154
1155 * configure.ac: added isatty()
1156
1157 * lib/afflib_i.h: moved af_identify_file_type() and
1158 af_identify_file_name() from afflib.h to afflib_i.h so that people
1159 wouldn't be tempted to call them .
1160
1161 2007-07-01 Simson Garfinkel <simsong>
1162
1163 * tools/afinfo.cpp (info_file): changed %qd to %"I64d" for Win32 compat.
1164
1165 * tools/afstats.cpp (main): changed final return() to exit() for
1166 Microsoft happieness.
1167
1168 * tools/affix.cpp (main): added final exit().
1169
1170 * tools/afconvert.cpp: changed final return() to exit() for
1171 microsoft happiness
1172
1173 * tools/afcopy.cpp (afcopy): changed final return to exit() for
1174 Microsoft happieness.
1175
1176 * win32/openssl/sha.c: replaced sha1 implementation with
1177 pass-through to Microsoft CryptoAPI.
1178
1179 * win32/openssl/md5.c: replaced md5 implementation with
1180 pass-through to Microsoft CryptoAPI.
1181
1182 2007-06-29 Simson L. Garfinkel <simsong>
1183
1184 * aimage/gui.cpp (gui_startup): corrected bug of
1185 #ifdef HAVE_LIBCURSES; should have been
1186 #ifdef HAVE_LIBNCURSES
1187
1188 * aimage/imager.cpp, aimage/gui.cpp, aimage/aimage.cpp: added support for SHA256
1189
1190 * lib/afflib.h (AF_SHA256): added AF_SHA256
1191
1192 2007-06-26 Simson L. Garfinkel <simsong>
1193
1194 * Makefile.am (SUBDIRS): added win32 back to the configure.ac and
1195 Makefile, so that the win32 stuff would be included in the distribution
1196
1197 2007-06-21 Simson L. Garfinkel <simsong>
1198
1199 * aimage/gui.cpp (comma_printw): modifications to gui.cpp and
1200 aimage.cpp so that it will compile and run in batch if ncurses and
1201 termcap are not installed.
1202
1203 2007-06-10 U-AMD64\Simson Garfinkel <Simson Garfinkel>
1204
1205 * aimage/imager.cpp (start_recover_scan): added #ifdef for
1206 HAVE_SRANDOMDEV to allow for complication under Cygwin (and other
1207 systems that don't have srandomdev()
1208
1209 2007-05-30 Simson L. Garfinkel <simsong>
1210
1211 * configure.ac: added -D_FILE_OFFSET_BITS=64 to CPPFLAGS when FUSE
1212 is enabled. fixed compilation for AFFUSE
1213
1214 2007-05-30 Simson Garfinkel <simsong>
1215
1216 * lib/vnode_aff.cpp (aff_get_seg): no longer scans the whole file
1217 looking for a segment. If it is not in the ToC, it doesn't
1218 exist. Not that this means that we can't have simultaneous access
1219 to a single AFF file by a writer and a reader anymore.
1220
1221 * tools/afinfo.cpp (print_info): added -X flag to print segment names without data contents.
1222
1223 * lib/afflib_pages.cpp (af_get_page): only fills buffer with "bad flag" if a buffer is provided.
1224
1225 2007-05-29 Simson Garfinkel <simsong>
1226
1227 * aimage/imager.cpp (start_imaging): only writes out AF_IMAGE_GID if segment doesn't exist.
1228 Appends to AF_ACQUISITION_DATE segment if it already exists.
1229 Added \n to AF_ACQUISITION_DATE segment contents.
1230
1231 2007-05-25 Simson L. Garfinkel <simsong>
1232
1233 * tools/afinfo.cpp (info_file): fixed rounding error in
1234 calculation of missing pages
1235
1236 2007-05-23 Simson L. Garfinkel <simsong>
1237
1238 * tools/afinfo.cpp (info_file): added Missing Pages to printout
1239
1240 2007-05-14 Simson L. Garfinkel <simsong>
1241
1242 * tools/afsegment.cpp (main): modified output format so that it
1243 prints filename:segname and then the contents on every line
1244
1245 2007-05-11 Simson L. Garfinkel <simsong>
1246
1247 * tools/afsegment.cpp (usage): changed afcat to afsegment in usage()
1248 (main): added -q option which prints value as 64-bit quad
1249
1250 2007-05-02 Simson L. Garfinkel <simsong>
1251
1252 * lib/afflib.h: changed af_ext_is to return "int" instead of bool.
1253
1254 2007-04-30 Simson L. Garfinkel <simsong>
1255
1256 * lib/s3.cpp (s3_bandwidth): removed s3_debug call from s3
1257 bandwidth test
1258
1259 2007-04-29 Simson L. Garfinkel <simsong>
1260
1261 * aimage/aimage.cpp: minor update to getlock(), although this code
1262 is still not being called.
1263
1264 2007-04-29 Simson L. Garfinkel <simsong>
1265
1266 * lib/vnode_raw.cpp (raw_popen): moved hasmeta() to af_hasmeta()
1267 and put in afflib_util.cpp.
1268
1269 2007-04-29 Simson Garfinkel <simsong>
1270
1271 * tools/afcopy.cpp (afcopy): command string parameter fname no
1272 longer used as format string in warn().
1273
1274 * tools/afxml.cpp (xml_info): command string no longer used as
1275 format string in warn().
1276
1277 * aimage/aimage.cpp (getlock): command line parameter no longer
1278 used as format string in err()
1279
1280 * tools/afinfo.cpp (main): command line parameter no longer used
1281 as format string in err().
1282
1283 * lib/aftest.cpp (figure): err(1,fn) changed to err(1,"%s",fn) in
1284 multiple places
1285
1286 * lib/s3.cpp (s3_cp): fixed * Format String Injection in s3 *
1287 reported by V3Security
1288
1289 * lib/vnode_raw.cpp (raw_popen): added metacharacter testing here
1290 as well
1291
1292 2007-04-25 Simson L. Garfinkel <simsong>
1293
1294 * configure.ac: version 2.2.8
1295
1296 * aimage/aimage_os.cpp (ident): fixed minor compile-under-linux problems
1297
1298 2007-04-17 Simson Garfinkel <simsong>
1299
1300 * aimage/imager.cpp (write_data): doesn't seek if we don't know offset
1301
1302 * tests/verify.py (runtest): modified test to put file in /tmp
1303
1304 * aimage/ident.cpp (get_params): added metacharacter checking
1305 filename before popen.
1306
1307 * tools/afconvert.cpp (convert): added meta character filtering
1308 per VSecurity.
1309
1310 2007-04-16 Simson Garfinkel <simsong>
1311
1312 * tools/afxml.cpp (xml_info): added name sanitization to AFF XML
1313 names per VSecurity report
1314
1315 * aimage/imager.cpp (image_loop): fixed important bug when imaging
1316 from /dev/random (or presumably a network connection) which caused
1317 page 0 to be repeatedly rewritten.
1318
1319 * lib/vnode_raw.cpp: added |AF_VNODE_TYPE_RELIABLE to vnode type
1320
1321 * lib/vnode_aff.cpp: added |AF_VNODE_TYPE_RELIABLE to vnode type
1322
1323 * lib/vnode_afd.cpp: added |AF_VNODE_TYPE_RELIABLE to vnode type
1324
1325 * lib/vnode_split_raw.cpp: added
1326 |AF_VNODE_TYPE_RELIABLE|AF_VNODE_MAXSIZE_MULTIPLE to vnode type
1327
1328 * lib/vnode_afm.cpp: added
1329 |AF_VNODE_TYPE_RELIABLE|AF_VNODE_MAXSIZE_MULTIPLE to vnode type
1330
1331 * configure.ac: cleaned up enable_fuse so that it doesn't generate
1332 errors on Macintosh; removed OPENSSL alert
1333
1334 2007-04-11 Simson L. Garfinkel <simsong>
1335
1336 * lib/afflib.h: prototypes for af_read() and the like changes from
1337 "unsigned count" to "size_t count"
1338
1339 * lib/s3_glue.cpp (quote_plus): added quoting of '%'
1340
1341 2007-04-04 Simson L. Garfinkel <simsong>
1342
1343 * aimage/ident.cpp (get_params): fixed strlcat() & strlcpy() order
1344
1345 2007-04-03 Simson L. Garfinkel <simsong>
1346
1347 * lib/s3.cpp (strlcat): added strlcpy and strlcat to s3.cpp
1348
1349 2007-04-02 Simson Garfinkel <simsong>
1350
1351 * aimage/ident.cpp (get_params): changed occurances of strcpy() to
1352 strlcpy() and strcat() to strlcat() per VSecurity report.
1353
1354 * lib/vnode_ewf.cpp (ewf_open): Now checks to make sure that there
1355 are at least 4 characters available in the fname buffer after the
1356 trailing '.', per VSecurity report.
1357
1358 * lib/s3.cpp (s3_bandwidth): all occurances of sprintf() changed
1359 to snprintf per VSecurity report.
1360
1361 * tools/afinfo.cpp (main): changed err(1,infile) to
1362 err(1,"%s",infile) to defend against string format vulnerability
1363 per VSecurity report.
1364
1365 * tools/afcopy.cpp (afcopy): changed err(1,infile) to
1366 err(1,"%s",infile) to defend against string format vulnerability
1367 per VSecurity report.
1368
1369 * tools/afconvert.cpp (convert): changed err(1,infile) to
1370 err(1,"%s",infile) to defend against string format vulnerability
1371 per VSecurity report.
1372
1373 * tools/afcompare.cpp (main): replaced all occurances of sprintf()
1374 with snprintf(), all occurances of strcpy() with strlcpy(), and
1375 all occurances of strcat() with strlcat().
1376
1377 * lib/vnode_ewf.cpp (ewf_get_next_seg): replaced both strcpy()
1378 calls with strlcpy() per VSecurity report
1379
1380 * lib/vnode_s3.cpp (s3_open): added maximal size to both memcpy()
1381 calls, per VSecurity report.
1382
1383 * lib/s3.cpp (s3_ls): replaced strcpy() with strlcpy() per
1384 VSecurity report.
1385
1386 2007-03-28 Simson L. Garfinkel <simsong>
1387
1388 * aimage/aimage.cpp: added option "skip" / -k to the longopts[]
1389 array. It wasn't there before, and it should have been.
1390
1391 * lib/afflib_pages.cpp (af_update_page): moved acbi.compressed=1
1392 out of the if statement in the event that the compress2() call fails.
1393
1394 2007-03-20 <simsong>
1395
1396 * lib/s3.cpp (s3_bandwidth): s3 bandwidth test now verifies MD5 returned
1397
1398 2007-03-07 Simson L. Garfinkel <simsong>
1399
1400 * tools/affuse.cpp (main): Olivier Castan provided a fuse
1401 implementation for us. Thanks! We also have changes of his in
1402 configure.ac, Makefile.am.
1403
1404 2007-03-01 Simson L. Garfinkel <simsong>
1405
1406 * configure.ac: Now compiles under stock MacOS without expat installed
1407
1408 2007-02-05 Simson L. Garfinkel <simsong>
1409
1410 * tools/afcopy.cpp (usage): fixed formatting
1411
1412 2007-02-05 Simson Garfinkel <simsong>
1413
1414 * aimage/imager.cpp: patches to aimage to fix imaging over a
1415 network provided by Suessmilch Bernd
1416
1417 2007-02-01 Simson Garfinkel <simsong>
1418
1419 * fixed bugs in the caching system; caching now works.
1420
1421 2007-01-24 Simson Garfinkel <simsong>
1422
1423 * lib/afflib.h: moved #include <sys/types.h> from afflib_i.h to afflib.h
1424
1425 * lib/afflib.h: Moved #ifndef PACKAGE_TARNAME from afflib.h to afflib_i.h
1426
1427 * lib/afflib.cpp (af_eof): uses results from af_vstat() instead of
1428 calling af_imagesize() again (which would be another call to vstat)
1429
1430 2007-01-23 Simson Garfinkel <simsong>
1431
1432 * lib/aff_toc.cpp (af_toc_build): changed malloc(0) to
1433 malloc(sizeof(af_toc_mem)) as on Borland C++, malloc(0) returns a
1434 NULL pointer.
1435
1436 * lib/afflib.cpp (af_open_with): fixed memory leak in error condition.
1437
1438 * lib/vnode_aff.cpp (aff_open): added "b" to opens for running
1439 under windows.
1440
1441 * lib/vnode_raw.cpp (raw_get_seg): added support for phantom
1442 segments AF_PAGESIZE and AF_IMAGESIZE. This fixes the bug with
1443 afconvert that had been previously reported.
1444
1445 2007-01-11 Simson L. Garfinkel <simsong>
1446
1447 * lib/vnode_afd.cpp: moved definitions of F_OK and R_OK to this file.
1448
1449 * lib/afflib_pages.cpp: added #include to malloc.h for
1450 valloc. Perhaps it should go in afflib_i.h?
1451
1452 * aimage/aimage_os.cpp (ident): fixed handling if ident is not defined
1453
1454 * tools/unix4win32.cpp: removed this file because it shouldn't be
1455 needed anymore; warn, warnx, err and errx are now provided by
1456 afflib.
1457
1458 * lib/afflib_i.h: created proper configure macros for HAVE_ERR,
1459 HAVE_ERRX, HAVE_WARN and HAVE_WARNX to handle the presence of
1460 absence of these on multiple platforms.
1461
1462 2006-12-27 Simson L. Garfinkel <simsong>
1463
1464 * lib/s3_glue.cpp (request): Added CURLOPT_TIMEOUT 60*60 (1 hour)
1465 to S3 transactions.
1466
1467 2006-12-14 Simson L. Garfinkel <simsong>
1468
1469 * lib/afflib_pages.cpp (af_read_sizes): modified af_read_sizes so
1470 that if an image file doesn't have an IMAGESIZE segment, the
1471 imagesize is determined by reading all of the segments
1472
1473 2006-11-28 Simson L. Garfinkel <simsong>
1474
1475 2006-11-27 Simson L. Garfinkel <simsong>
1476
1477 * lib/s3_glue.cpp (canonical_string): added support for BAD_STL,
1478 so that on pair, where STL is out-of-date, we can still compile
1479
1480 * lib/vnode_afd.cpp (afd_add_file): wasn't setting sectorsize on
1481 AFD subfiles. This caused problems with files that had sector
1482 sizes of 1024 bytes...
1483
1484 * (afd_add_file): files now added to array before new file is set up.
1485
1486 2006-11-25 Simson L. Garfinkel <simsong>
1487
1488 * lib/vnode_afd.cpp (afd_update_seg): corrected multiple
1489 definitions of AFFILE *af2, which might cause compiling problems
1490 under Windows
1491
1492 * lib/afflib_i.h: Added AFFLIB_TRACE environment variable; right
1493 now it just traces seek and read
1494
1495 * lib/afflib.h: retyped af_seek to take an int64 instead of a uint64
1496
1497 * lib/vnode_s3.cpp (s3_open): All S3 environment variables are now
1498 defined in s3_glue.h
1499
1500 2006-11-18 Simson L. Garfinkel <simsong>
1501
1502 * aimage/aimage.cpp (debug_list): changed -L option (Log file) to
1503 -G so that -L could be used for LZMA compression.
1504
1505 2006-10-31 Simson L. Garfinkel <simsong>
1506
1507 * lib/s3_glue.cpp (request): changed CURLOPT_INFILESIZE_LARGE to
1508 CURLOPT_INFILESIZE. This limits maximum requests to 2GB in length,
1509 but I don't think that this will be a significant problem, and the
1510 LARGE was causing problems on Linux.
1511
1512 2006-10-27 Simson L. Garfinkel <simsong>
1513
1514 * lib/afflib_pages.cpp (af_set_pagesize): no longer complains if
1515 pagesize it being set to what it already is
1516
1517 * tools/afcopy.cpp: added -z (opt_zap) to overwrite existing files.
1518
1519 2006-10-26 Simson L. Garfinkel <simsong>
1520
1521 * lib/afflib_pages.cpp: fixed bytes==0 bug in af_get_page. Now if
1522 bytes==0, it probes for the page existence and then returns.
1523
1524 * lib/s3_glue.cpp (request): Added up to 3 retries for S3 "500"
1525 internal errors.
1526
1527 2006-10-22 Simson L. Garfinkel <simsong>
1528
1529 * lib/afflib.cpp (af_identify_type): Added flag to allow user to
1530 specify if file must exist or not.
1531
1532 * lib/vnode_s3.cpp (s3_get_seg): Now uses "HEAD" to probe length
1533 of segment without downloading segment. Note that the
1534 Content-Length: header needs to be decoded.
1535
1536 2006-10-21 Simson L. Garfinkel <simsong>
1537
1538 * aimage/aimage.cpp (process_config_questions): Now has conditional detection
1539 of readline; if it isn't present, defaults to fgets()
1540
1541
1542 2006-10-20 Simson L. Garfinkel <simsong>
1543
1544 * Moved AFFLIB to gnu build environment (autoconf, automake,
1545 configure, etc.). Apparently I can now edit this file by doing a
1546 C-x 4 a. How cool! More information at:
1547 http://gnu.j1b.org/software/emacs/manual/html_node/Change-Log.html
1548
1549 Release 1.8.0:
1550 - Added support for storing files on Amazon S3.
1551 Set Environment variable AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
1552 Set variable AWS_DEFAULT_BUCKET.
1553 Filename syntax is s3://bucket/filename.aff
1554 or:
1555 s3:///foo/bar/baz/filename.aff
1556
1557 Bucket is getenv("AWS_DEFAULT_BUCKET") unless otherwise specified.
1558 Buckets are automatically created if they do not exist (and if nobody else has created
1559 that bucket yet.)
1560
1561 Remember, there is a limit of 100 buckets per customer.
1562
1563 - Moved af_read_sizes(af) from each open to af_open(). This means that I need
1564 to re-validate all of the various implementations.
1565
1566 - API simplification: The "append" flag has been dropped from af_update_seg() and
1567 af_update_segq(). None of my code ever had append==0, and to make S3 handle it
1568 sensibly would have required a second round-trip to the server.
1569
1570 - Removed errors from LZMA routines
1571
1572 Release 1.7.1:
1573 - Fixed isdigit() call, which isn't available under Linux
1574
1575
1576 Release 1.7.0:
1577
1578 - Moved AFFINFO mailing list to Google Groups. Actualy, to two groups
1579 on Google Groups: aff-users and aff-announce. Everybody on AFFINFO
1580 has been subscribed to aff-announce.
1581
1582 - Added a new compression algorithm, AF_PAGE_COMP_ALG_ZERO. This algorithm
1583 detects a page of all 0s and simply notes that fact, rather than passing
1584 the sectors through zlib.
1585
1586 - Added a new comparession algorithm, AF_PAGE_COMP_ALG_LZMA, which implements
1587 the LZMA compression algorithm. Validated LZMA against a terrabyte of compressed
1588 page images and found no errors in decompression. LZMA averages are,
1589 on average, 1/3 to 1/10th the size of the ZLIB-compressed images.
1590
1591 library:
1592 - AFFLIB now maintains a two-page cache for every open AFFILE; this
1593 can be expanded at runtime to any number by setting
1594 AFFLIB_CACHE_PAGES environment variable to the number of pages that
1595 you want to keep in memory. Since pages are typically 16MB, setting
1596 this variable to 16 will dedicate 256MB to each open AFF file
1597 (assuming that you are reading the file through the page system; the
1598 memory only gets dedicated when the bytes actually get read.)
1599
1600 - You can also set the AFFLIB_CACHE_STATS environment variable to 1,
1601 which will put on STDERR the cache information every time you close
1602 a file.
1603
1604 - Renamed "af_is_badblock" to "af_is_badsector".
1605
1606 - Removed logfile from AFFILE structure. It was just being used for
1607 debugging, and not in a particularly effective way. (af_seek and
1608 af_write no longer reference it. )
1609
1610 - Fixed linking under MacOS for strlcpy problem.
1611
1612 - Integrated LZMA library
1613
1614 - Got AFFLIB (but not the tools) to compile under MS VC6++. Because the Microsoft
1615 compiler is pretty picky about some things, a whole bunch of signed/unsigned errors
1616 were found and fixed. (not that they would have ever mattered, but...)
1617 LZMA is not included in the Windows release currently
1618
1619 afcopy:
1620 - Created new tool, afcopy, which copies an AFF file segment-by-segment,
1621 and verifies each segment after it is copied by reading the resulting file.
1622 afcopy thus validates all writes and has the side-effect of compressing files,
1623 so the resulting file may be smaller than the original.
1624
1625 - Added "-p" option to afcopy to preen (recompress with LZMA).
1626
1627 afcompare:
1628 - Added -p option to report on preening
1629 - Added -r option to compare directories recurisvely
1630 - Added -j option to just do the data
1631
1632
1633 Release 1.6.33:
1634 - Fixed to compile under Kubuntu 6.0.6
1635
1636 Release 1.6.32:
1637 - pages in AFFILES now have MD5s stored automatically as well. So when
1638 "page3" is written, "page3_md5" is also written.
1639 - afinfo
1640 - when it sees any segment with "md5" in its name that is 16-bytes long, the segment is printed
1641 in hex. Likewise when a segment has "sha1" in its name and is 20-bytes long.
1642 - New "-p" option checks the hash for every page.
1643 - aimage: MacOS 10.4 demsg now requires root to run; aimage no longer sends dmesg error to stderr.
1644 Instead, errors go to /dev/null, and if there is no dmesg output, no dmesg segment is created.
1645
1646 Release 1.6.31:
1647 Make release now clearly requires gmake and errors if Berkeley Make is used
1648
1649 Release 1.6.30:
1650 Removed dependency on #include <warn.h> from building the library.
1651
1652 Release 1.6.29:
1653 Fixed "reverse" option (-V) on aimage so that it actually works.
1654
1655 Release 1.6.28:
1656 Typedef for "u64" defined under linux so that afflib will compile under Slackware
1657
1658 Release 1.6.27:
1659 - Compiles under Cygwin
1660 - Aimage now has a -Y (--batch) option which prints
1661 line-by-line output, so that the program can be easily
1662 incorporated into other programs.
1663
1664 Release 1.6.24:
1665 AFFLIB no longer assumes that <warnx.h> is installed on cygwin.
1666
1667 Release 1.6.24:
1668 Library and some of the tools now compiles under CYGWIN.
1669 Programs that rely on termcap don't compile. This includes
1670 aimage and afconvert.
1671
1672
1673 Release 1.6.22:
1674 afxml now displays the same values without base64 encoding as afinfo
1675
1676 Release 1.6.20:
1677 Library should now compile on NetBSD and OpenBSD. Let me know if it doesn't
1678
1679 Release 1.6.19:
1680 Library (but nothing else) now compiles on solaris with GCC
1681
1682 Release 1.6.18:
1683 Now compiles with either Berkeley make or gmake
1684
1685 Release 1.6.17:
1686 af_read:
1687 - returns 0 if attempt made to read a file with no bytes.
1688 - returns -1 if attempt made to read a file with no pagesize defined.
1689
1690 aimage:
1691 - Erases screen junk of amount of freespace on disk goes from 1000MB to 999MB
1692
1693 Release 1.6.16:
1694 aimage:
1695 - Fixed a bug in report printing without going back into \r\l mode.
1696 - fixed error handling when disk fills up.
1697
1698 Release 1.6.15:
1699 - Removed aff file in tools directory. Sorry about that.
1700
1701 Release 1.6.14:
1702 afxml:
1703 - metadata segments that just had an arg and no data are now reported as
1704 <segname>###</segname>, rather than <segname arg=### />
1705 aimage:
1706 - minor cosmetic improvements
1707
1708
1709 Release 1.6.13:
1710 lib:
1711 - error message on split_raw_setup clarified
1712 - af_open now returns 0 if it can't open the file
1713
1714 aimage:
1715 - now has flags to suppress inclusion of dmesg and ethernet address in AFF file.
1716 - scaled_atoi now checks its parameters better.
1717 - cleaned up display on 25x80 display
1718 - cleaned up display when imaging multiple drives
1719 - --setseg now works
1720 - now handles improperly-mastered CDROMs
1721
1722
1723 Release 1.6.12:
1724 lib:
1725 - fixed badflag handling (badflags were only 4 bytes due to
1726 variable sector size changes.)
1727
1728 Release 1.6.11:
1729 vnode_afm:
1730 af_callback now gets propigated from afm layer to split_raw layer
1731 on af_write.
1732 lib:
1733 AFFLIB now has a "parent" pointer which is set for AFM and AFD.
1734 callback now uses the parent instead of self if parent is set
1735 aimage:
1736 -v now prints the version number and exits.
1737 -V now scans in reverse.
1738
1739
1740 Release 1.6.9:
1741 aimage:
1742 - Whoops. Broke update logic in 1.6.8. Fixed
1743
1744 Release 1.6.8:
1745 aimage:
1746 - remove foo.000 and foo.afm from release
1747
1748 Release 1.6.7:
1749 lib:
1750 - Fixed release system so that release X can't be made if release X is already on the server
1751 - Fixed bug in vnode_raw implementation resulting from move to 64-bit math
1752
1753 aimage:
1754 - modified aimage so that it only updates the screen (and queries the timer)
1755 every million bytes read
1756 - by default, no log file is written
1757
1758 afinfo:
1759 - prints hex digits as DDDD EEEE FFFF now
1760 - fixed behavior of sha1 printing --- it breaks by two lines by default
1761
1762
1763 Release 1.6.6:
1764 lib:
1765 - moved check on change of imagesize on close from aff_close to af_close.
1766 Now check is done for AFM files in addition to AFF files. This fixes the
1767 bug of the AF_IMAGESIZE segment not being written by aimage with AFM files.
1768 - renamed af->image_size_orig to af->image_size_in_file to make it more clear what it does
1769 - created new segment type "aff_file_type" which holds AFF for AFF files, AFM for AFM files,
1770 and AFD for AFD files.
1771 - created aff_create() and afm_create() functions which are automatically
1772 called by the corresponding _open() functions when a file is created.
1773 - removed af_set_maxsize64; af_set_maxsize now requires a 64-bit argument
1774 - created new function, af_set_sectorsize()
1775 - sectorsize no longer hard-coded to be 512.
1776 - removed af_demand_sizes; sizes are now assumed read when the file is opened
1777 - no longer calls err() in af_open
1778 - Virus hiding claim removed from FAQ
1779
1780 TOOLS:
1781 - all tools take "-v" to print their version number. Tools that were using
1782 -v for "verbose' have been changed
1783
1784 afcat:
1785 - checks for -1 return from af_read
1786
1787 afconvert:
1788 - all math involving pages changed to 64-bits
1789 - now honors opt_quiet
1790
1791 afinfo:
1792 - -d command now returns pagesize in addition to page number
1793 - -w command now implemented properly
1794
1795 aimage:
1796 - error message with -E omitted no longer misleading
1797 - Checks for ifconfig in path before running ifconfig
1798
1799 afcompare:
1800 - -v no longer is verbose
1801 - -a prints things that are the same
1802 - -b prints sector numbers that were different
1803 - -c prints contents of sectors that are different.
1804
1805
1806 Release 1.6.5:
1807 afconvert:
1808 - 'm' and 'k' changed back to mod 1024, not mod 1000
1809 - imagesize segment now written when converting from raw to afm
1810
1811 aimage:
1812 - SIGINFO #ifdefed so that it only is included if SIGINFO is defined.
1813
1814
1815 Release 1.6.4:
1816 - afconvert and afinfo fixed to handle 0 read bytes from af_read()
1817
1818 Release 1.6.3:
1819 - af_set_sizes() call removed.
1820 - fixed bug in af_cat
1821 - several bugs in AFM implementation fixed.
1822
1823
1824 Release 1.6.2
1825 - fixed bug in af_imagesize which was affecting afcat
1826 - fixed bug in parsing of -M option in afconvert
1827 - fixed af_eof() for AFF implementation.
1828
1829 Release 1.6.1:
1830 vnode_afd:
1831 - Support for AFD was inadvertantly broken in 1.6.0; it's fixed in 1.6.1
1832
1833 Release 1.6.0:
1834 vnode_split_raw.cpp:
1835 - integrated code from Joel Weber with these significant changes:
1836 - Removed dependency on AFF/AFD/AFM implementation
1837 - changed implementation to use lseek() to write empty files, rather than repeated writes of buffers...
1838 - modified split_raw_get_seg so that it called af_segname_page_number() rather than parsing by hand.
1839 - created afm_update_seg() so that we could remove call to afm_identify_file in split_raw_update_seg
1840 - fixed a bug whereby 256K of raw files were created if maxsize was smaller than ZERO_BUFFER_SIZE,
1841 which was hard-coded to 256K
1842 - removed raw_file_size from split_raw_private, as it was redundent with maxfilesize in the AFFILE structure.
1843
1844 vnode_afm.cpp:
1845 - integrated code form Joel Weber with these significant changes:
1846 - Opens two sub-files, one for the AFM metadata (through a coerced aff_open()), and one
1847 for the split_raw implementation.
1848 - Note: there is still a bug that AFM files can't be opened for extending;
1849
1850 lib:
1851 - added af_has_pages() to allow higher-level programs to know if the underlying
1852 vnode implementation supports pages or not.
1853 - af_vnode_info: added has_pages flag so that an implementation can tell the higher
1854 layers if it supports pages or not.
1855 - vnode_raw: made it so that af_popen() now tells the higher layers that pages are not
1856 supported.
1857 - af_vnode_info: added use_eof and at_eof flags, to support EOF reporting on af_popen.
1858 - awaiting af_read() & af_write() bypass, pending code from nemo
1859
1860 afcat:
1861 - Outputs NULs for bad blocks unless -b is given.
1862
1863 afconvert:
1864 - Added version to usage.
1865 - Fixed conversion of gzip'ed and bzip'ed raw images
1866 - Calls af_has_pages to see if the input vnode implementation supports pages or not.
1867 If it doesn't, then it just reads from the beginning of the image to the end.
1868 - Implemented -O (outdir) flag
1869
1870 afinfo:
1871 - Now honors -w flag
1872 - Output squished to fit MD5s and SHA1s.
1873
1874 aimage:
1875 - Properly prints free space on FreeBSD, MacOS and Linux
1876 - Prints MD5 & SHA1 as groups of 4 upper-case letters.
1877 - Now stores sectorsize in "sectorsize" segment
1878 - Now stores number of sectors that the device has in "devicesectors" segment
1879 - --pagesize= option now allows suffix of b, k, m or g
1880 - ACQUISTION_TIME now correct (it was being saved as a 64-bit number but reported as a
1881 32-bit number in afinfo.)
1882
1883
1884
1885 Release 1.5.13:
1886 Encase support works for multiple encase files.
1887 .E01, .E02 ... .E99
1888
1889 Release 1.5.12:
1890 aimage:
1891 - now allows --maxsize=cd and --maxsize=bigcd
1892 - --no_hash (-H) avoids hash calculation
1893
1894 Release 1.5.10:
1895 makefiles:
1896 - Finally implemented a single makefile along the lines
1897 of the "Recursive Make considered Harmful" paper, but improved,
1898 with targets that work in both the subdirectories and in the root directory.
1899 Currently it only works with gmake, which is only a problem under FreeBSD.
1900
1901 Release engineering:
1902 - added a "tests" directory and moved end-to-end testing there.
1903 afconvert, afcat, and aimage are now automatically tested as part of the release
1904 process.
1905
1906 aimage:
1907 - no longer dumps core when not given an output file.
1908 - Doesn't waste left-most column of screen
1909 - Displays elapsed time when running.
1910 - Now displays elapsed time while imaging
1911 - Now displays aimage version
1912 - Saves total time to image a disk in the AFF file.
1913 - Properly indicates free space left on capture disk.
1914
1915 Release 1.5.9:
1916 - Fixed bug in release system which was giving incorrect filenames
1917 - fixed bug in AFD which wasn't setting image size properly in the sub AFF files
1918 - fixed bug in AFD support where maxsize wasn't being set on default.
1919 Now it defaults to 600M
1920
1921 Release 1.5.8:
1922 - Fixed progname bug (progname appears to only exist under
1923 freeBSD)
1924
1925 Release 1.5.7:
1926 - fixed a few bugs regarding AFD performance
1927
1928 afcompare:
1929 - -v flag (verbose) implemented. When run without -v, doesn't report similarities.
1930 - corrected a bug when a data segment was in one file but not another.
1931
1932
1933 Release 1.5.6:
1934 - More options added to afcat for handling segments.
1935 aimage:
1936 - aimage now puts now information into aff files.
1937
1938
1939
1940 Release 1.5.5:
1941 lib:
1942 - Eliminated bug when an afd file was opened read-only of the library
1943 giving error messages that it was unable to copy over metadata from
1944 the first AFF file to the other AFF files.
1945 - AFFLIB is now tolerant of a trailing / on .afd names.
1946 - Stores AFFLIB version in the AFF file when new files are created.
1947
1948 afcat:
1949 - now prints AFFLIB version number.
1950 - now prints a warning on STDOUT if a page is skipped; suppress with -q
1951 - no longer clobbers output file without warning
1952 - no longer give errors about not being able to "update"
1953 information when it cats out an AFD file.
1954
1955
1956 afcompare:
1957 - now prints AFFLIB version number
1958
1959 afinfo:
1960 - Now prints AFFLIB version number.
1961 - Option -v no longer validates hash codes
1962 - Option -m validates MD5 codes
1963 - Option -s validates SHA1 codes
1964 - No longer prints the total compression efficiency
1965
1966 afstats:
1967 - Now prints AFFLIB version number
1968
1969 afxml:
1970 - Now prints AFFLIB version number
1971 - Puts AFFLIB version number as a comment in XML output
1972
1973 release:
1974 - fixed bug of executables in release tar file
1975
1976 aimage:
1977 - ETA acronym removed; now says "Done in:"
1978
1979
1980
1981
1982 Release 1.5.4:
1983 afconvert:
1984 - significant changes in option parsing to make it more reliable.
1985 - Now properly handles creating files with non-standard AFF segment sizes
1986 - change to "-z" option so that it zaps the output file, not the input file
1987 (to make consistent with other af commands.)
1988
1989 release engineering:
1990 - auotmatic validation of afconvert and afcat as part of the release cycle
1991
1992 Release 1.5.3:
1993 aimage
1994 - Minor patch so it should write afd files...
1995
1996
1997 Release 1.5.1:
1998 - fixed suffixing for -M command in aimage
1999 aimage:
2000 - Now reads serial numbers of USB memory sticks using sysctl -a.
2001 - NOTE: Be sure that ther eis only one USB memory stick in the system when you do this,
2002 because we can't figure out how to match the stick up with the S/N other than the
2003 manufacturer's name.
2004
2005 Release 1.5
2006 lib:
2007 - Initial support of EVF file format. (Only works on Intel right now, not PPC)
2008
2009 afconvert:
2010 - rewrote to use vnode support
2011
2012 aimage:
2013 - Initial support for split files
2014
2015 Release 1.4.1:
2016 aimage:
2017 - fixed bug when encountering errors and imaging from a device.
2018 (The error is that additional bad blocks were being written into the file with
2019 out proper BAD SECTOR headers. No real data was corrupted, but in some cases
2020 random data appeared in the image file which should not have been written.)
2021 - Improved error recovery. Previously, 5 attempts were made to read the sectors that failed, after
2022 which the program gave up. Now it skips forward and tries to read the next set of sectors. It repeats
2023 this whole process until there is a bad region that is equal 2.5 times the size of the
2024 default read (256K).
2025
2026 lib:
2027 - fixed bug in which small pages were written out with too much data
2028 - fixed bug in af_get_page in which invalid data was being left uninitialized rather than
2029 being initialized with the bad_block flag
2030
2031
2032 -Release 1.4
2033 Terminology change: data segments are renamed "pages" to eliminate confusion with AFF segments.
2034
2035 lib:
2036 - Implemented a "vnode" abstraction to make it easy to work with multiple file systems.
2037 - Found and fixed at least 10 major bugs. None of them would have caused data corruption,
2038 but some would have caused the library to go into an infinite loop or to crash.
2039 - Support for "AFD" files --- these are directories of AFF files. This will allow AFF
2040 to work with file systems that do not support files larger than 2^32 characters
2041 (such as FAT32).
2042
2043
2044 Known bugs:
2045 AImage: bad block flags are not being properly written out in AFF files.
2046
2047 afinfo:
2048 - prints more information about AFF files in an easy-to-read format
2049
2050 afcompare:
2051 - Now compares two AFF files, or an AFF and a RAW file.
2052
2053 -Release 1.3.4
2054 aimage:'
2055 - Dramatic restructing of the program.
2056 - You can now batch multiple aimage commands on a single command line.
2057 The program surveys total amount of data to copy and a grand-total ETA.
2058 - New -A option will write out a segment with compression, a segment without
2059 compression, and then will go with the fastest approach.
2060 - Better graphics
2061 - Prints a certificate when the imaging is finished
2062
2063 lib:
2064 - Removed call to fpurge(), which was incorrect.
2065 - renamed aff_ to aff_toc, becuase it really is building a
2066 table of contents.
2067
2068 -Release 1.3.3
2069 lib:
2070 - Improved error handling in writing segments.
2071 - More information is now provided to segment writing callback function.
2072
2073 aimage:
2074 - Removed the --info command, since it was just for debugging.
2075 - Made --make-config a flag that creates the config file if it doesn't exist,
2076 but it uses the name provided by --config.
2077 - Revamped config file.
2078 - removed some global variables that weren't being used; folded others into the
2079 imager class.
2080 - fixed bug in aimage when reading from devices whose length cannot be determined
2081 (e.g. /dev/zero, (tapes, TCP connections)
2082
2083 aconvert:
2084 - No longer core-dumps if the file that it is asked to convert doesn't exist.
2085
2086 January 9, 2006 - Release 1.3.3
2087 aimage:
2088 - added a -A flag which makes aimage compress or not compress, whichever is faster.
2089
2090
2091 January 9, 2006 - Release 1.3.2
2092 Overall:
2093
2094 aimage:
2095 - Some curses testing code was left in. It's been removed.
2096
2097 January 8, 2006 - Release 1.3.1.
2098 Overall:
2099 - Moved source for aimage to aimage/ directory
2100 - Move source for tools to tools/ directory
2101
2102 aimage:
2103 - On Linux, now reads the serial number of USB drives that are being imaged
2104 using the /proc file system.
2105
2106 tools:
2107
2108
2109
2110 December 31, 2005 - Release 1.3.0
2111 overall:
2112 - Moved library source code into lib/ subdirectory.
2113 One big makefile still makes it all, see
2114 "Recursive make considered harmful."
2115 http://www.canb.auug.org.au/~millerp/rmch/recu-make-cons-harm.html
2116
2117 afcat:
2118 - Now only outputs the segments containing data.
2119 It does this by first scanning and making a list of all the data segments;
2120 It then seeks to the location of each one in the virtual file, reads
2121 the segment worth of data, and sends it to stdout.
2122
2123 afconvert:
2124 - When outputing with the -o option, now outputs an AFF file if file ends
2125 '.aff' and outputs raw if file does not end .aff
2126 - The -x (no compression) flag now works.
2127 - The -X (set compression level) flag has been implemented.
2128 - As a result, you can now batch compress a set of uncompressed AFF files
2129
2130 Release 1.2.9
2131 afconvert:
2132 - fixed crashing bug when converting raw files to aff files
2133 - fixed crashing bug when converting aff files to raw files.
2134
2135
2136 December 21, 2005 - Release 1.2.8
2137
2138 library:
2139 - AF_BADBLOCKS is now initialized to 8 bytes of NULs, rather than
2140 a 0-length segment.
2141 - fixed corruption bug in af_del_seg().
2142 - Added (tm).
2143
2144 aimage:
2145 - Fixed calculation of free space on the disk for FreeBSD.
2146 - Made display more attractive.
2147 - Added support for automatically rescanning scsi bus.
2148 You can now scan the scsi bus and image by specifying "scsi1", for
2149 example, to image from scsi bus 1. (FreeBSD only.)
2150 - Added optional preview to let you see the data as it is recorded.
2151 This is great for spotting drives that have been 'sanitized' or
2152 cleared.
2153 - Displays size of target disk in GB/MB/KB
2154 - Doesn't compute hash for raw image if the image is invalid
2155 (if aimage did an lseek.)
2156 - Now captures ATA serial number even if disk can't be imaged.
2157 - Prints final report of image results
2158
2159 afconvert:
2160 - fixed crashing bug in afconvert.
2161 - Corrected incorrect "progname" in many utilities.
2162
2163 afinfo:
2164 - More tolerant of errors in aff file.
2165
2166 affix:
2167 - Initial Release
2168 - Can fix a file that is not properly terminated by removing junk at end.
2169 This is useful if a computer crashes while aimage is being run.
2170
2171 December 6, 2005 - Release 1.2.7
2172 - Minor fixes for makedepend problems that people on various platforms had
2173
2174 November 18, 2005 - Release 1.2.5
2175 - Implemented segment directory; list of all segments is now kept
2176 in memory, rather than read on-the-fly from the disk. This
2177 dramatically improves performance on random-access test.
2178 Library falls back to old method of scanning the file for
2179 each segment if the segment list is too large to hold in memory.
2180 Time for aftest -3 improves on my laptop from TK seconds to 27 seconds.
2181
2182
2183 November 18, 2005 - Release 1.2.4
2184 - redesigned afflib for improved performance.
2185 - afconvert can now convert from one AFF to another AFF.
2186
2187 October 21, 2005 - Release 1.2.1
2188 - Added a whole bunch of segment names.
2189 - Found a nasty bug in updating of segments under certain circumstances
2190 - Lots of new features in aimage
2191
2192 October 20, 2005 - Release 1.2.0
2193 - created atest for heavy-duty testing of af_seek()
2194 - support for reading drive SN under Linux and FreeBSD
2195 - found bug in af_seek()
2196
2197 October 11, 2005 - Release 1.1.1
2198 - Modified af_open() so it read data_segsize on open.
2199 - changed af_setsize() to af_set_sizes(). Now it doesn't allow you to change the
2200 data segment size if it has already been set.
2201 - Modified convert to handle gzipped files with gzcat.
2202 - Fixed but in aconvert where infiles were not being closed.
2203 - removed fancy image size calculation from ainfo, as it wasn't right for compressed files.
2204 - Added -Wall and found lots of signage bugs
2205 - Cleanly compiles on Linux; supports > 2GB files
2206
2207
2208 September 11, 2005 - Release 1.1
2209 - Added support for writing files with af_write().
2210 - New files now automatically get bad block flag created
2211 - fixed afflib for AMD64 architectures.
2212 - ainfo wasn't calculating SHA-1 properly for -v option on AMD64. Fixed.
2213 ainfo wasn't printing compression overhead properly. Fixed. Also fixed
2214 small buffer overflow in printing of SHA-1 values.
2215 - changed "radio" typo to "ratio."
2216 - aconvert now aborts (and deletes AFF file) if ^C is pressed or if
2217 a write fails.
2218 - aconvert now refuses to convert an AFF file. Added af_identify(fname) to
2219 return true if a file is probably an AFF file and false if it is not.
2220
2221 August 14, 2005 - Release 1.0.1
2222 - changed minor bug in aconvert in handling of multiple files
2223
2224 August 13, 2005 - Release 1.0
2225
2226 Initial Release of AFFLIB. Includes library description, README, basic
2227 library functionality, and four utilities.
2228
2229
2230 ================================================================
2231 Copyright 2005, 2006, 2007, 2008 Simson L. Garfinkel
2232 Copying and distribution of this file, with or without modification, are
2233 permitted provided the copyright notice and this notice are preserved.
2234
2235 #
2236 # Local Variables:
2237 # mode: flyspell
2238 # mode: auto-fill
2239 # End:
2240 #
0 Install this file with:
1
2 ./configure && make && make install
3
4
5 To disable optimization, do this:
6
7 ./configure 'CXXFLAGS=-O0 -g' 'CFLAGS=-O0 -g'
0 SUBDIRS = lib tools lzma443 win32 tests doc pyaff man
1
2 pkgconfigdir = $(libdir)/pkgconfig
3
4 pkgconfig_DATA = afflib.pc
5
6 include_HEADERS =
7 pkginclude_HEADERS = lib/afflib.h lib/afflib_i.h lib/aftimer.h lib/utils.h lib/threaded_hash.h
8
9 ACLOCAL_AMFLAGS = -I m4
10
11 RELEASE_USER = simsong@
12 RELEASE_HOST = www.afflib.org
13 RELEASE_DIR = afflib.org/
14
15 RELEASE_LOC = $(RELEASE_DIR)/downloads/
16 CHANGES_LOC = $(RELEASE_DIR)/ChangeLog.txt
17 RELEASE_FN = $(PACKAGE)_version.txt
18 RELEASE_PATH = $(RELEASE_LOC)/$(RELEASE_FN)
19 RELEASE_SSH = $(RELEASE_USER)$(RELEASE_HOST):$(RELEASE_LOC)
20 RELEASE = $(PACKAGE)-$(VERSION)
21
22 AM_CFLAGS = -Wall
23 AM_CPPFLAGS = -Wall
24
25
26 release:
27 make prerelease
28 make distcheck
29 make the_release
30 make distribute_release
31
32 prerelease:
33 @echo Building and uploading the release...
34 @echo Making release $(RELEASE)
35 @echo
36 echo
37 wget http://$(RELEASE_HOST)/downloads/$(RELEASE_FN)
38 @echo Version `cat $(RELEASE_FN)` is on the server.
39 python checkversion.py $(RELEASE_FN) $(RELEASE)
40 /bin/rm $(RELEASE_FN)
41
42 getrelease:
43 @echo testing release on your system
44 wget http://$(PACKAGE).tar.gz
45 tar xfz $(PACKAGE).tar.gz
46 (cd afflib-*;./configure;make;make test_crypto)
47
48 the_release:
49 gpg --detach-sign $(RELEASE).tar.gz
50
51 distribute_release:
52 scp $(RELEASE).tar.gz{,.sig} $(RELEASE_SSH)
53 ssh $(RELEASE_HOST) 'cd $(RELEASE_LOC);/bin/rm $(PACKAGE).tar.gz;ln -s $(RELEASE).tar.gz $(PACKAGE).tar.gz'
54 ssh $(RELEASE_HOST) 'echo $(RELEASE).tar.gz > $(RELEASE_PATH)'
55 @echo Release $(RELEASE) uploaded to server
56
57 DEBIAN_FILES = \
58 debian/afflib.install \
59 debian/afflib.dirs \
60 debian/afflib.docs \
61 debian/afflib.postinst.debhelper \
62 debian/afflib.postrm.debhelper \
63 debian/afflib-default.ex \
64 debian/afflib-dev.dirs \
65 debian/afflib-dev.docs \
66 debian/afflib-dev.install \
67 debian/afflib-tools.dirs \
68 debian/afflib-tools.docs \
69 debian/afflib-tools.install \
70 debian/afflib.doc-base.EX \
71 debian/changelog \
72 debian/changelog.in \
73 debian/compat \
74 debian/control \
75 debian/copyright \
76 debian/cron.d.ex \
77 debian/emacsen-install.ex \
78 debian/emacsen-startup.ex \
79 debian/emacsen-remove.ex \
80 debian/init.d.ex \
81 debian/manpage.1.ex \
82 debian/manpage.sgml.ex \
83 debian/manpage.xml.ex \
84 debian/menu.ex \
85 debian/rules \
86 debian/postinst.ex \
87 debian/postrm.ex \
88 debian/preinst.ex \
89 debian/prerm.ex \
90 debian/shlibs.local.ex \
91 debian/shlibs.local.ex.in \
92 debian/watch.ex
93
94 DOCS = BUGLIST.txt README_Linux.txt README_Win32.txt \
95 doc/crypto_doc.txt \
96 doc/crypto_design.txt \
97 doc/announce_1.7.txt \
98 doc/announce_1.8.txt \
99 doc/announce_2.2.txt
100
101 EXTRA_DIST = $(DOCS) \
102 $(DEBIAN_FILES) \
103 acx_pthread.m4 \
104 afflib.spec.in \
105 afflib.spec \
106 afflib.pc.in \
107 afflib.pubkey.asc \
108 misc/expat-2.0.1.tar.gz \
109 tests/encrypted.iso \
110 tests/encrypted.aff
111
112 #
113 # Note: don't forget to run autoreconf when significant changes are made
114 #
0 # Makefile.in generated by automake 1.10 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16
17 VPATH = @srcdir@
18 pkgdatadir = $(datadir)/@PACKAGE@
19 pkglibdir = $(libdir)/@PACKAGE@
20 pkgincludedir = $(includedir)/@PACKAGE@
21 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
22 install_sh_DATA = $(install_sh) -c -m 644
23 install_sh_PROGRAM = $(install_sh) -c
24 install_sh_SCRIPT = $(install_sh) -c
25 INSTALL_HEADER = $(INSTALL_DATA)
26 transform = $(program_transform_name)
27 NORMAL_INSTALL = :
28 PRE_INSTALL = :
29 POST_INSTALL = :
30 NORMAL_UNINSTALL = :
31 PRE_UNINSTALL = :
32 POST_UNINSTALL = :
33 build_triplet = @build@
34 host_triplet = @host@
35 subdir = .
36 DIST_COMMON = README $(am__configure_deps) $(include_HEADERS) \
37 $(pkginclude_HEADERS) $(srcdir)/Makefile.am \
38 $(srcdir)/Makefile.in $(srcdir)/affconfig.h.in \
39 $(srcdir)/afflib.pc.in $(srcdir)/afflib.spec.in \
40 $(top_srcdir)/configure $(top_srcdir)/debian/changelog.in \
41 $(top_srcdir)/debian/shlibs.local.ex.in AUTHORS COPYING \
42 ChangeLog INSTALL NEWS compile config.guess config.sub depcomp \
43 install-sh ltmain.sh missing
44 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
45 am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
46 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
47 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
48 $(ACLOCAL_M4)
49 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
50 configure.lineno config.status.lineno
51 mkinstalldirs = $(install_sh) -d
52 CONFIG_HEADER = affconfig.h
53 CONFIG_CLEAN_FILES = debian/changelog debian/shlibs.local.ex \
54 afflib.spec afflib.pc
55 SOURCES =
56 DIST_SOURCES =
57 RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
58 html-recursive info-recursive install-data-recursive \
59 install-dvi-recursive install-exec-recursive \
60 install-html-recursive install-info-recursive \
61 install-pdf-recursive install-ps-recursive install-recursive \
62 installcheck-recursive installdirs-recursive pdf-recursive \
63 ps-recursive uninstall-recursive
64 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
65 am__vpath_adj = case $$p in \
66 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
67 *) f=$$p;; \
68 esac;
69 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
70 am__installdirs = "$(DESTDIR)$(pkgconfigdir)" \
71 "$(DESTDIR)$(includedir)" "$(DESTDIR)$(pkgincludedir)"
72 pkgconfigDATA_INSTALL = $(INSTALL_DATA)
73 DATA = $(pkgconfig_DATA)
74 includeHEADERS_INSTALL = $(INSTALL_HEADER)
75 pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
76 HEADERS = $(include_HEADERS) $(pkginclude_HEADERS)
77 RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
78 distclean-recursive maintainer-clean-recursive
79 ETAGS = etags
80 CTAGS = ctags
81 DIST_SUBDIRS = $(SUBDIRS)
82 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
83 distdir = $(PACKAGE)-$(VERSION)
84 top_distdir = $(distdir)
85 am__remove_distdir = \
86 { test ! -d $(distdir) \
87 || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
88 && rm -fr $(distdir); }; }
89 DIST_ARCHIVES = $(distdir).tar.gz
90 GZIP_ENV = --best
91 distuninstallcheck_listfiles = find . -type f -print
92 distcleancheck_listfiles = find . -type f -print
93 ACLOCAL = @ACLOCAL@
94 AFFUSE_BIN = @AFFUSE_BIN@
95 ALLOCA = @ALLOCA@
96 AMTAR = @AMTAR@
97 AR = @AR@
98 AUTOCONF = @AUTOCONF@
99 AUTOHEADER = @AUTOHEADER@
100 AUTOMAKE = @AUTOMAKE@
101 AWK = @AWK@
102 CC = @CC@
103 CCDEPMODE = @CCDEPMODE@
104 CFLAGS = @CFLAGS@
105 CPP = @CPP@
106 CPPFLAGS = @CPPFLAGS@
107 CURL_CONFIG = @CURL_CONFIG@
108 CXX = @CXX@
109 CXXCPP = @CXXCPP@
110 CXXDEPMODE = @CXXDEPMODE@
111 CXXFLAGS = @CXXFLAGS@
112 CYGPATH_W = @CYGPATH_W@
113 DEFS = @DEFS@
114 DEPDIR = @DEPDIR@
115 DSYMUTIL = @DSYMUTIL@
116 DUMPBIN = @DUMPBIN@
117 ECHO_C = @ECHO_C@
118 ECHO_N = @ECHO_N@
119 ECHO_T = @ECHO_T@
120 EGREP = @EGREP@
121 EXEEXT = @EXEEXT@
122 FGREP = @FGREP@
123 FUSE_CFLAGS = @FUSE_CFLAGS@
124 FUSE_LIBS = @FUSE_LIBS@
125 GREP = @GREP@
126 INSTALL = @INSTALL@
127 INSTALL_DATA = @INSTALL_DATA@
128 INSTALL_PROGRAM = @INSTALL_PROGRAM@
129 INSTALL_SCRIPT = @INSTALL_SCRIPT@
130 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
131 LD = @LD@
132 LDFLAGS = @LDFLAGS@
133 LIBOBJS = @LIBOBJS@
134 LIBS = @LIBS@
135 LIBTOOL = @LIBTOOL@
136 LIPO = @LIPO@
137 LN_S = @LN_S@
138 LTLIBOBJS = @LTLIBOBJS@
139 MAINT = @MAINT@
140 MAKEINFO = @MAKEINFO@
141 MKDIR_P = @MKDIR_P@
142 NM = @NM@
143 NMEDIT = @NMEDIT@
144 OBJEXT = @OBJEXT@
145 OTOOL = @OTOOL@
146 OTOOL64 = @OTOOL64@
147 PACKAGE = @PACKAGE@
148 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
149 PACKAGE_NAME = @PACKAGE_NAME@
150 PACKAGE_STRING = @PACKAGE_STRING@
151 PACKAGE_TARNAME = @PACKAGE_TARNAME@
152 PACKAGE_VERSION = @PACKAGE_VERSION@
153 PATH_SEPARATOR = @PATH_SEPARATOR@
154 PTHREAD_CC = @PTHREAD_CC@
155 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
156 PTHREAD_LIBS = @PTHREAD_LIBS@
157 PYTHON = @PYTHON@
158 PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
159 PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
160 PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
161 PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
162 PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
163 PYTHON_PLATFORM = @PYTHON_PLATFORM@
164 PYTHON_PREFIX = @PYTHON_PREFIX@
165 PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
166 PYTHON_VERSION = @PYTHON_VERSION@
167 RANLIB = @RANLIB@
168 S3_BIN = @S3_BIN@
169 SED = @SED@
170 SET_MAKE = @SET_MAKE@
171 SHELL = @SHELL@
172 STRIP = @STRIP@
173 VERSION = @VERSION@
174 abs_builddir = @abs_builddir@
175 abs_srcdir = @abs_srcdir@
176 abs_top_builddir = @abs_top_builddir@
177 abs_top_srcdir = @abs_top_srcdir@
178 ac_ct_CC = @ac_ct_CC@
179 ac_ct_CXX = @ac_ct_CXX@
180 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
181 ac_prefix_program = @ac_prefix_program@
182 acx_pthread_config = @acx_pthread_config@
183 am__include = @am__include@
184 am__leading_dot = @am__leading_dot@
185 am__quote = @am__quote@
186 am__tar = @am__tar@
187 am__untar = @am__untar@
188 bindir = @bindir@
189 build = @build@
190 build_alias = @build_alias@
191 build_cpu = @build_cpu@
192 build_os = @build_os@
193 build_vendor = @build_vendor@
194 builddir = @builddir@
195 datadir = @datadir@
196 datarootdir = @datarootdir@
197 docdir = @docdir@
198 dvidir = @dvidir@
199 exec_prefix = @exec_prefix@
200 host = @host@
201 host_alias = @host_alias@
202 host_cpu = @host_cpu@
203 host_os = @host_os@
204 host_vendor = @host_vendor@
205 htmldir = @htmldir@
206 includedir = @includedir@
207 infodir = @infodir@
208 install_sh = @install_sh@
209 libdir = @libdir@
210 libexecdir = @libexecdir@
211 localedir = @localedir@
212 localstatedir = @localstatedir@
213 lt_ECHO = @lt_ECHO@
214 mandir = @mandir@
215 mkdir_p = @mkdir_p@
216 oldincludedir = @oldincludedir@
217 pdfdir = @pdfdir@
218 pkgpyexecdir = @pkgpyexecdir@
219 pkgpythondir = @pkgpythondir@
220 prefix = @prefix@
221 program_transform_name = @program_transform_name@
222 psdir = @psdir@
223 pyexecdir = @pyexecdir@
224 pythondir = @pythondir@
225 sbindir = @sbindir@
226 sharedstatedir = @sharedstatedir@
227 srcdir = @srcdir@
228 sysconfdir = @sysconfdir@
229 target_alias = @target_alias@
230 top_builddir = @top_builddir@
231 top_srcdir = @top_srcdir@
232 SUBDIRS = lib tools lzma443 win32 tests doc pyaff man
233 pkgconfigdir = $(libdir)/pkgconfig
234 pkgconfig_DATA = afflib.pc
235 include_HEADERS =
236 pkginclude_HEADERS = lib/afflib.h lib/afflib_i.h lib/aftimer.h lib/utils.h lib/threaded_hash.h
237 ACLOCAL_AMFLAGS = -I m4
238 RELEASE_USER = simsong@
239 RELEASE_HOST = www.afflib.org
240 RELEASE_DIR = afflib.org/
241 RELEASE_LOC = $(RELEASE_DIR)/downloads/
242 CHANGES_LOC = $(RELEASE_DIR)/ChangeLog.txt
243 RELEASE_FN = $(PACKAGE)_version.txt
244 RELEASE_PATH = $(RELEASE_LOC)/$(RELEASE_FN)
245 RELEASE_SSH = $(RELEASE_USER)$(RELEASE_HOST):$(RELEASE_LOC)
246 RELEASE = $(PACKAGE)-$(VERSION)
247 AM_CFLAGS = -Wall
248 AM_CPPFLAGS = -Wall
249 DEBIAN_FILES = \
250 debian/afflib.install \
251 debian/afflib.dirs \
252 debian/afflib.docs \
253 debian/afflib.postinst.debhelper \
254 debian/afflib.postrm.debhelper \
255 debian/afflib-default.ex \
256 debian/afflib-dev.dirs \
257 debian/afflib-dev.docs \
258 debian/afflib-dev.install \
259 debian/afflib-tools.dirs \
260 debian/afflib-tools.docs \
261 debian/afflib-tools.install \
262 debian/afflib.doc-base.EX \
263 debian/changelog \
264 debian/changelog.in \
265 debian/compat \
266 debian/control \
267 debian/copyright \
268 debian/cron.d.ex \
269 debian/emacsen-install.ex \
270 debian/emacsen-startup.ex \
271 debian/emacsen-remove.ex \
272 debian/init.d.ex \
273 debian/manpage.1.ex \
274 debian/manpage.sgml.ex \
275 debian/manpage.xml.ex \
276 debian/menu.ex \
277 debian/rules \
278 debian/postinst.ex \
279 debian/postrm.ex \
280 debian/preinst.ex \
281 debian/prerm.ex \
282 debian/shlibs.local.ex \
283 debian/shlibs.local.ex.in \
284 debian/watch.ex
285
286 DOCS = BUGLIST.txt README_Linux.txt README_Win32.txt \
287 doc/crypto_doc.txt \
288 doc/crypto_design.txt \
289 doc/announce_1.7.txt \
290 doc/announce_1.8.txt \
291 doc/announce_2.2.txt
292
293 EXTRA_DIST = $(DOCS) \
294 $(DEBIAN_FILES) \
295 acx_pthread.m4 \
296 afflib.spec.in \
297 afflib.spec \
298 afflib.pc.in \
299 afflib.pubkey.asc \
300 misc/expat-2.0.1.tar.gz \
301 tests/encrypted.iso \
302 tests/encrypted.aff
303
304 all: affconfig.h
305 $(MAKE) $(AM_MAKEFLAGS) all-recursive
306
307 .SUFFIXES:
308 am--refresh:
309 @:
310 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
311 @for dep in $?; do \
312 case '$(am__configure_deps)' in \
313 *$$dep*) \
314 echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
315 cd $(srcdir) && $(AUTOMAKE) --gnu \
316 && exit 0; \
317 exit 1;; \
318 esac; \
319 done; \
320 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
321 cd $(top_srcdir) && \
322 $(AUTOMAKE) --gnu Makefile
323 .PRECIOUS: Makefile
324 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
325 @case '$?' in \
326 *config.status*) \
327 echo ' $(SHELL) ./config.status'; \
328 $(SHELL) ./config.status;; \
329 *) \
330 echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
331 cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
332 esac;
333
334 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
335 $(SHELL) ./config.status --recheck
336
337 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
338 cd $(srcdir) && $(AUTOCONF)
339 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
340 cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
341
342 affconfig.h: stamp-h1
343 @if test ! -f $@; then \
344 rm -f stamp-h1; \
345 $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
346 else :; fi
347
348 stamp-h1: $(srcdir)/affconfig.h.in $(top_builddir)/config.status
349 @rm -f stamp-h1
350 cd $(top_builddir) && $(SHELL) ./config.status affconfig.h
351 $(srcdir)/affconfig.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
352 cd $(top_srcdir) && $(AUTOHEADER)
353 rm -f stamp-h1
354 touch $@
355
356 distclean-hdr:
357 -rm -f affconfig.h stamp-h1
358 debian/changelog: $(top_builddir)/config.status $(top_srcdir)/debian/changelog.in
359 cd $(top_builddir) && $(SHELL) ./config.status $@
360 debian/shlibs.local.ex: $(top_builddir)/config.status $(top_srcdir)/debian/shlibs.local.ex.in
361 cd $(top_builddir) && $(SHELL) ./config.status $@
362 afflib.spec: $(top_builddir)/config.status $(srcdir)/afflib.spec.in
363 cd $(top_builddir) && $(SHELL) ./config.status $@
364 afflib.pc: $(top_builddir)/config.status $(srcdir)/afflib.pc.in
365 cd $(top_builddir) && $(SHELL) ./config.status $@
366
367 mostlyclean-libtool:
368 -rm -f *.lo
369
370 clean-libtool:
371 -rm -rf .libs _libs
372
373 distclean-libtool:
374 -rm -f libtool
375 install-pkgconfigDATA: $(pkgconfig_DATA)
376 @$(NORMAL_INSTALL)
377 test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
378 @list='$(pkgconfig_DATA)'; for p in $$list; do \
379 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
380 f=$(am__strip_dir) \
381 echo " $(pkgconfigDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
382 $(pkgconfigDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgconfigdir)/$$f"; \
383 done
384
385 uninstall-pkgconfigDATA:
386 @$(NORMAL_UNINSTALL)
387 @list='$(pkgconfig_DATA)'; for p in $$list; do \
388 f=$(am__strip_dir) \
389 echo " rm -f '$(DESTDIR)$(pkgconfigdir)/$$f'"; \
390 rm -f "$(DESTDIR)$(pkgconfigdir)/$$f"; \
391 done
392 install-includeHEADERS: $(include_HEADERS)
393 @$(NORMAL_INSTALL)
394 test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
395 @list='$(include_HEADERS)'; for p in $$list; do \
396 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
397 f=$(am__strip_dir) \
398 echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
399 $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
400 done
401
402 uninstall-includeHEADERS:
403 @$(NORMAL_UNINSTALL)
404 @list='$(include_HEADERS)'; for p in $$list; do \
405 f=$(am__strip_dir) \
406 echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
407 rm -f "$(DESTDIR)$(includedir)/$$f"; \
408 done
409 install-pkgincludeHEADERS: $(pkginclude_HEADERS)
410 @$(NORMAL_INSTALL)
411 test -z "$(pkgincludedir)" || $(MKDIR_P) "$(DESTDIR)$(pkgincludedir)"
412 @list='$(pkginclude_HEADERS)'; for p in $$list; do \
413 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
414 f=$(am__strip_dir) \
415 echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
416 $(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
417 done
418
419 uninstall-pkgincludeHEADERS:
420 @$(NORMAL_UNINSTALL)
421 @list='$(pkginclude_HEADERS)'; for p in $$list; do \
422 f=$(am__strip_dir) \
423 echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
424 rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
425 done
426
427 # This directory's subdirectories are mostly independent; you can cd
428 # into them and run `make' without going through this Makefile.
429 # To change the values of `make' variables: instead of editing Makefiles,
430 # (1) if the variable is set in `config.status', edit `config.status'
431 # (which will cause the Makefiles to be regenerated when you run `make');
432 # (2) otherwise, pass the desired values on the `make' command line.
433 $(RECURSIVE_TARGETS):
434 @failcom='exit 1'; \
435 for f in x $$MAKEFLAGS; do \
436 case $$f in \
437 *=* | --[!k]*);; \
438 *k*) failcom='fail=yes';; \
439 esac; \
440 done; \
441 dot_seen=no; \
442 target=`echo $@ | sed s/-recursive//`; \
443 list='$(SUBDIRS)'; for subdir in $$list; do \
444 echo "Making $$target in $$subdir"; \
445 if test "$$subdir" = "."; then \
446 dot_seen=yes; \
447 local_target="$$target-am"; \
448 else \
449 local_target="$$target"; \
450 fi; \
451 (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
452 || eval $$failcom; \
453 done; \
454 if test "$$dot_seen" = "no"; then \
455 $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
456 fi; test -z "$$fail"
457
458 $(RECURSIVE_CLEAN_TARGETS):
459 @failcom='exit 1'; \
460 for f in x $$MAKEFLAGS; do \
461 case $$f in \
462 *=* | --[!k]*);; \
463 *k*) failcom='fail=yes';; \
464 esac; \
465 done; \
466 dot_seen=no; \
467 case "$@" in \
468 distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
469 *) list='$(SUBDIRS)' ;; \
470 esac; \
471 rev=''; for subdir in $$list; do \
472 if test "$$subdir" = "."; then :; else \
473 rev="$$subdir $$rev"; \
474 fi; \
475 done; \
476 rev="$$rev ."; \
477 target=`echo $@ | sed s/-recursive//`; \
478 for subdir in $$rev; do \
479 echo "Making $$target in $$subdir"; \
480 if test "$$subdir" = "."; then \
481 local_target="$$target-am"; \
482 else \
483 local_target="$$target"; \
484 fi; \
485 (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
486 || eval $$failcom; \
487 done && test -z "$$fail"
488 tags-recursive:
489 list='$(SUBDIRS)'; for subdir in $$list; do \
490 test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
491 done
492 ctags-recursive:
493 list='$(SUBDIRS)'; for subdir in $$list; do \
494 test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
495 done
496
497 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
498 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
499 unique=`for i in $$list; do \
500 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
501 done | \
502 $(AWK) ' { files[$$0] = 1; } \
503 END { for (i in files) print i; }'`; \
504 mkid -fID $$unique
505 tags: TAGS
506
507 TAGS: tags-recursive $(HEADERS) $(SOURCES) affconfig.h.in $(TAGS_DEPENDENCIES) \
508 $(TAGS_FILES) $(LISP)
509 tags=; \
510 here=`pwd`; \
511 if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
512 include_option=--etags-include; \
513 empty_fix=.; \
514 else \
515 include_option=--include; \
516 empty_fix=; \
517 fi; \
518 list='$(SUBDIRS)'; for subdir in $$list; do \
519 if test "$$subdir" = .; then :; else \
520 test ! -f $$subdir/TAGS || \
521 tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
522 fi; \
523 done; \
524 list='$(SOURCES) $(HEADERS) affconfig.h.in $(LISP) $(TAGS_FILES)'; \
525 unique=`for i in $$list; do \
526 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
527 done | \
528 $(AWK) ' { files[$$0] = 1; } \
529 END { for (i in files) print i; }'`; \
530 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
531 test -n "$$unique" || unique=$$empty_fix; \
532 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
533 $$tags $$unique; \
534 fi
535 ctags: CTAGS
536 CTAGS: ctags-recursive $(HEADERS) $(SOURCES) affconfig.h.in $(TAGS_DEPENDENCIES) \
537 $(TAGS_FILES) $(LISP)
538 tags=; \
539 here=`pwd`; \
540 list='$(SOURCES) $(HEADERS) affconfig.h.in $(LISP) $(TAGS_FILES)'; \
541 unique=`for i in $$list; do \
542 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
543 done | \
544 $(AWK) ' { files[$$0] = 1; } \
545 END { for (i in files) print i; }'`; \
546 test -z "$(CTAGS_ARGS)$$tags$$unique" \
547 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
548 $$tags $$unique
549
550 GTAGS:
551 here=`$(am__cd) $(top_builddir) && pwd` \
552 && cd $(top_srcdir) \
553 && gtags -i $(GTAGS_ARGS) $$here
554
555 distclean-tags:
556 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
557
558 distdir: $(DISTFILES)
559 $(am__remove_distdir)
560 test -d $(distdir) || mkdir $(distdir)
561 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
562 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
563 list='$(DISTFILES)'; \
564 dist_files=`for file in $$list; do echo $$file; done | \
565 sed -e "s|^$$srcdirstrip/||;t" \
566 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
567 case $$dist_files in \
568 */*) $(MKDIR_P) `echo "$$dist_files" | \
569 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
570 sort -u` ;; \
571 esac; \
572 for file in $$dist_files; do \
573 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
574 if test -d $$d/$$file; then \
575 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
576 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
577 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
578 fi; \
579 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
580 else \
581 test -f $(distdir)/$$file \
582 || cp -p $$d/$$file $(distdir)/$$file \
583 || exit 1; \
584 fi; \
585 done
586 list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
587 if test "$$subdir" = .; then :; else \
588 test -d "$(distdir)/$$subdir" \
589 || $(MKDIR_P) "$(distdir)/$$subdir" \
590 || exit 1; \
591 distdir=`$(am__cd) $(distdir) && pwd`; \
592 top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
593 (cd $$subdir && \
594 $(MAKE) $(AM_MAKEFLAGS) \
595 top_distdir="$$top_distdir" \
596 distdir="$$distdir/$$subdir" \
597 am__remove_distdir=: \
598 am__skip_length_check=: \
599 distdir) \
600 || exit 1; \
601 fi; \
602 done
603 -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
604 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
605 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
606 ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
607 || chmod -R a+r $(distdir)
608 dist-gzip: distdir
609 tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
610 $(am__remove_distdir)
611
612 dist-bzip2: distdir
613 tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
614 $(am__remove_distdir)
615
616 dist-tarZ: distdir
617 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
618 $(am__remove_distdir)
619
620 dist-shar: distdir
621 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
622 $(am__remove_distdir)
623
624 dist-zip: distdir
625 -rm -f $(distdir).zip
626 zip -rq $(distdir).zip $(distdir)
627 $(am__remove_distdir)
628
629 dist dist-all: distdir
630 tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
631 $(am__remove_distdir)
632
633 # This target untars the dist file and tries a VPATH configuration. Then
634 # it guarantees that the distribution is self-contained by making another
635 # tarfile.
636 distcheck: dist
637 case '$(DIST_ARCHIVES)' in \
638 *.tar.gz*) \
639 GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
640 *.tar.bz2*) \
641 bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
642 *.tar.Z*) \
643 uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
644 *.shar.gz*) \
645 GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
646 *.zip*) \
647 unzip $(distdir).zip ;;\
648 esac
649 chmod -R a-w $(distdir); chmod a+w $(distdir)
650 mkdir $(distdir)/_build
651 mkdir $(distdir)/_inst
652 chmod a-w $(distdir)
653 dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
654 && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
655 && cd $(distdir)/_build \
656 && ../configure --srcdir=.. --prefix="$$dc_install_base" \
657 $(DISTCHECK_CONFIGURE_FLAGS) \
658 && $(MAKE) $(AM_MAKEFLAGS) \
659 && $(MAKE) $(AM_MAKEFLAGS) dvi \
660 && $(MAKE) $(AM_MAKEFLAGS) check \
661 && $(MAKE) $(AM_MAKEFLAGS) install \
662 && $(MAKE) $(AM_MAKEFLAGS) installcheck \
663 && $(MAKE) $(AM_MAKEFLAGS) uninstall \
664 && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
665 distuninstallcheck \
666 && chmod -R a-w "$$dc_install_base" \
667 && ({ \
668 (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
669 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
670 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
671 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
672 distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
673 } || { rm -rf "$$dc_destdir"; exit 1; }) \
674 && rm -rf "$$dc_destdir" \
675 && $(MAKE) $(AM_MAKEFLAGS) dist \
676 && rm -rf $(DIST_ARCHIVES) \
677 && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
678 $(am__remove_distdir)
679 @(echo "$(distdir) archives ready for distribution: "; \
680 list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
681 sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
682 distuninstallcheck:
683 @cd $(distuninstallcheck_dir) \
684 && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
685 || { echo "ERROR: files left after uninstall:" ; \
686 if test -n "$(DESTDIR)"; then \
687 echo " (check DESTDIR support)"; \
688 fi ; \
689 $(distuninstallcheck_listfiles) ; \
690 exit 1; } >&2
691 distcleancheck: distclean
692 @if test '$(srcdir)' = . ; then \
693 echo "ERROR: distcleancheck can only run from a VPATH build" ; \
694 exit 1 ; \
695 fi
696 @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
697 || { echo "ERROR: files left in build directory after distclean:" ; \
698 $(distcleancheck_listfiles) ; \
699 exit 1; } >&2
700 check-am: all-am
701 check: check-recursive
702 all-am: Makefile $(DATA) $(HEADERS) affconfig.h
703 installdirs: installdirs-recursive
704 installdirs-am:
705 for dir in "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(includedir)" "$(DESTDIR)$(pkgincludedir)"; do \
706 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
707 done
708 install: install-recursive
709 install-exec: install-exec-recursive
710 install-data: install-data-recursive
711 uninstall: uninstall-recursive
712
713 install-am: all-am
714 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
715
716 installcheck: installcheck-recursive
717 install-strip:
718 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
719 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
720 `test -z '$(STRIP)' || \
721 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
722 mostlyclean-generic:
723
724 clean-generic:
725
726 distclean-generic:
727 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
728
729 maintainer-clean-generic:
730 @echo "This command is intended for maintainers to use"
731 @echo "it deletes files that may require special tools to rebuild."
732 clean: clean-recursive
733
734 clean-am: clean-generic clean-libtool mostlyclean-am
735
736 distclean: distclean-recursive
737 -rm -f $(am__CONFIG_DISTCLEAN_FILES)
738 -rm -f Makefile
739 distclean-am: clean-am distclean-generic distclean-hdr \
740 distclean-libtool distclean-tags
741
742 dvi: dvi-recursive
743
744 dvi-am:
745
746 html: html-recursive
747
748 info: info-recursive
749
750 info-am:
751
752 install-data-am: install-includeHEADERS install-pkgconfigDATA \
753 install-pkgincludeHEADERS
754
755 install-dvi: install-dvi-recursive
756
757 install-exec-am:
758
759 install-html: install-html-recursive
760
761 install-info: install-info-recursive
762
763 install-man:
764
765 install-pdf: install-pdf-recursive
766
767 install-ps: install-ps-recursive
768
769 installcheck-am:
770
771 maintainer-clean: maintainer-clean-recursive
772 -rm -f $(am__CONFIG_DISTCLEAN_FILES)
773 -rm -rf $(top_srcdir)/autom4te.cache
774 -rm -f Makefile
775 maintainer-clean-am: distclean-am maintainer-clean-generic
776
777 mostlyclean: mostlyclean-recursive
778
779 mostlyclean-am: mostlyclean-generic mostlyclean-libtool
780
781 pdf: pdf-recursive
782
783 pdf-am:
784
785 ps: ps-recursive
786
787 ps-am:
788
789 uninstall-am: uninstall-includeHEADERS uninstall-pkgconfigDATA \
790 uninstall-pkgincludeHEADERS
791
792 .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
793 install-strip
794
795 .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
796 all all-am am--refresh check check-am clean clean-generic \
797 clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
798 dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
799 distclean-generic distclean-hdr distclean-libtool \
800 distclean-tags distcleancheck distdir distuninstallcheck dvi \
801 dvi-am html html-am info info-am install install-am \
802 install-data install-data-am install-dvi install-dvi-am \
803 install-exec install-exec-am install-html install-html-am \
804 install-includeHEADERS install-info install-info-am \
805 install-man install-pdf install-pdf-am install-pkgconfigDATA \
806 install-pkgincludeHEADERS install-ps install-ps-am \
807 install-strip installcheck installcheck-am installdirs \
808 installdirs-am maintainer-clean maintainer-clean-generic \
809 mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
810 ps ps-am tags tags-recursive uninstall uninstall-am \
811 uninstall-includeHEADERS uninstall-pkgconfigDATA \
812 uninstall-pkgincludeHEADERS
813
814
815 release:
816 make prerelease
817 make distcheck
818 make the_release
819 make distribute_release
820
821 prerelease:
822 @echo Building and uploading the release...
823 @echo Making release $(RELEASE)
824 @echo
825 echo
826 wget http://$(RELEASE_HOST)/downloads/$(RELEASE_FN)
827 @echo Version `cat $(RELEASE_FN)` is on the server.
828 python checkversion.py $(RELEASE_FN) $(RELEASE)
829 /bin/rm $(RELEASE_FN)
830
831 getrelease:
832 @echo testing release on your system
833 wget http://$(PACKAGE).tar.gz
834 tar xfz $(PACKAGE).tar.gz
835 (cd afflib-*;./configure;make;make test_crypto)
836
837 the_release:
838 gpg --detach-sign $(RELEASE).tar.gz
839
840 distribute_release:
841 scp $(RELEASE).tar.gz{,.sig} $(RELEASE_SSH)
842 ssh $(RELEASE_HOST) 'cd $(RELEASE_LOC);/bin/rm $(PACKAGE).tar.gz;ln -s $(RELEASE).tar.gz $(PACKAGE).tar.gz'
843 ssh $(RELEASE_HOST) 'echo $(RELEASE).tar.gz > $(RELEASE_PATH)'
844 @echo Release $(RELEASE) uploaded to server
845
846 #
847 # Note: don't forget to run autoreconf when significant changes are made
848 #
849 # Tell versions [3.59,3.63) of GNU make to not export all variables.
850 # Otherwise a system limit (for SysV at least) may be exceeded.
851 .NOEXPORT:
0 September 30, 2009
1 Version 3.5.0 Released.
2 Major features:
3 - Simultaneous release of AFFLIB, Bloom, and bulk_extractor for MacOS, Linux and Windows
4 - bulk_extractor ported to Java.
5 - Single ZIP file for Windows Release
6
7 May 20, 2008
8 Version 3.2.1: Cleanup release of 3.2.0; important new features:
9 - Detects truncated files and does not allow them to be opened.
10 - affix now fixes truncated files
11 - afcrypto will only encrypt AFF and AFD file types.
12 - AFFLIB will no longer open a .afd directory containing no AFF files.
13
14 April 14, 2008
15 Version 3.1.6 released. Corrects bug in handling of raw files larger than 4GB.
16
17 ================================================================
18 November 26, 2007
19
20 AFFLIB 3.0.2 is withdrawn
21 AFFLIB 3.0.3 is released
22
23 Dear AFF Users:
24
25 AFFLIB 3.0.3 has been released. This version fixes a bug in the AFF
26 encryption routines that was inadvertantly introduced between
27 AFFLIB 3.0.1 and AFFLIB 3.0.2. As a result, AFFLIB 3.0.2 has been withdrawn.
28
29 The bug in AFFLIB 3.0.2 resulted from a bug in a version of SHA256
30 that was bundled into AFFLIB between version 3.0.1 and 3.0.2. Both
31 SHA256 and AES256 are required for AFF encryption. Unfortunately, the
32 version of SHA256 that was bundled had a data-dependent bug. This bug
33 only affected systems which did not have a system-installed SHA256
34 implementation.
35
36 As a result of this bug, all private implementations of cryptographic
37 functions have been stripped from AFFLIB. If you do not have an
38 OpenSSL library that has SHA256, you will not be able to use AFF
39 encryption.
40
41 The practical result is that some users will not be able to use AFF
42 encryption without first updating their openssl library.
43
44 ATTENTION MACINTOSH USERS: APPLE'S 10.4 and 10.5 OPERATING SYSTEMS
45 SHIP WITH A VERSION OF OPENSSL THAT IS OUT-OF-DATE AND DOES NOT
46 INCLUDE SHA256. If you are using a Macintosh, you must download a copy
47 of OpenSSL that has SHA256 to use AFF encryption. You can easily
48 download a modern OpenSSL implementation using the Macports or fink
49 system.
50
51 I apologize for this problem. To prevent it from happening, we've
52 improved the validation of AFFLIB that runs both when AFFLIB is built
53 and each time it runs.
54
55
56
57
58
59 ================================================================
60 August 18, 2007
61 AFFLIB Release 2.4.0
62
63 I'm pleased to announce the general availability of AFFLIB Release
64 2.4.0. This release
65
66
67
68 ================================================================
69 OLD NEWS FOLLOWS
70 ================================================================
71 November 1, 2006
72
73 AFFLIB Maintenance Release 2.0.1
74 * Fixes a number of errors when AFFLIB was being run under Cygwin or Borland C++.
75
76 AFFLIB Release 2.0
77
78 Key features of this release include:
79
80 * Now uses the GNU build tools (autoconf & automake)
81 - Will probe for readline and other features
82 - Special addition to search for libraries in multiple locations
83
84 * aimage2.0 released
85 - -L now enables LZMA compression; use -G for logfile output
0 The Advanced Forensic Format
1 Library and Tools
2
3 Simson L. Garfinkel
4 Naval Postgraduate School
5 2009
6
7
8 The Advanced Forensic Format (AFF) is an emerging standard for storing
9 computer forensic information. Critical features of AFF include:
10
11 - AFF allows you to store both computer forensic data and associated
12 metadata in one or more files.
13
14 - AFF allows files to be digital singed, to provide for
15 chain-of-custody and long-term file integrity.
16
17 - AFF allows for forensic disk images to stored encrypted and
18 decrypted on-the-fly for processing. This allows disk images
19 containing privacy sensitive material to be stored on the Internet.
20
21 - AFF is an open format unencumbered by copyright or patent
22 protection. The AFFLIB library that implements AFF is available
23 for use in both Open Source and proprietary tools.
24
25 AFF Library and Toolkit is a set of programs for working with computer
26 forensic information. Using these tools you can:
27
28 * Interconvert disk images between a variety of formats, including:
29
30 - raw or "dd"
31 - splitraw (in which a single image is split between mulitple files)
32 - EnCase or "E01" format
33 - AFF format (in which the entire disk image is stored in a single file.)
34 - AFD format (in which a disk image is stored in mulitple AFF files
35 stored in a single directory.)
36 - AFM format (in which an AFF file is used to annotate a raw file.)
37
38 * Compare disk images and report the data or metadata that is different.
39
40 * Copy disk images from one location to another, with full
41 verification of data, metadata, and the automatic generation of a
42 chain-of-custody segment.
43
44 * Find errors in an AFF file and fix them.
45
46 * Print information about a file.
47
48 * Print detailed statistics about a file
49
50 * Generate an XML representation of a disk image's metadata (for
51 example, acquisition time or the serial number of the acquisition
52 device.)
53
54 * Produce an XML "diskprint" which allows a disk image to be rapidly
55 fingerprinted without having the computer the SHA1 of the entire
56 disk.
57
58
59 AFFLIB and Toolkit is provided in source code form for Linux, MacOS
60 and Windows. We have also created a Windows zipfile that contains:
61
62 * precompiled versions of the AFFLIB tools and all of the libraries
63 necessary to run them.
64
65 * bulk_extractor.jar - A Java port of our system that automatically
66 extracts email addresses, dates, and other information from a file
67 and produces a histogram of the contents.
68
69
70 The AFF library can be downloaded from http://afflib.org/.
71
72 The pre-compiled AFF for Windows can be downloaded from
73 http://afflib.org/windows.
74
75 ====
76 AFFLIB with SleuthKit:
77
78 TSK officially supports a subset of the image formats that AFFLIB
79 supports. To use the other image formats, specify the image type as
80 "afflib". For example:
81
82
83 # fls -o 63 -i afflib foo.vmdk
84
85
86
87 ================
88 Note: AFF and AFFLIB are trademarks of Simson L. Garfinkel and Basis
89 Technology, Inc.
90
91
92 # Local Variables:
93 # mode: auto-fill
94 # mode: flyspell
95 # End:
0 #!/bin/sh
1 # INSTALLING ON Ubuntu/Kbuntu/Debian LINUX
2 #
3
4 if [ -r /usr/bin/apt-get ] ;
5 then
6
7 echo you are running on a system with apt-get.
8
9 # Edit /etc/apt/sources.list and uncomment the lines with "universe"
10 apt-get update
11
12 # General build tools:
13 apt-get -y install make gcc g++
14
15 # Libraries required for AFFLIB:
16 apt-get -y install zlib1g-dev libssl-dev libncurses5-dev
17 apt-get -y install libcurl4-openssl-dev libexpat1-dev libreadline5-dev
18
19 # Libraries if you want to make a release:
20 apt-get -y install automake1.9 autoconf libtool
21 exit 0
22 fi
23
24 if [ -r /usr/bin/yum ] ;
25 then
26 #================================================================
27 #INSTALLOING ON FEDORA CORE 6:
28 #
29 # When you build Linux, tell it that you want developer tools.
30 #
31 yum upgrade all
32 yum install libssl-dev libncurses5-dev
33 exit 0
34 fi
35
0 Using AFF Tool Under Microsoft Windows (Win32)
1
2
3 There are two ways to use AFFLIB with Windows: you can download the
4 pre-compiled executables, or you can compile your own. The advantage
5 of the pre-compiled executables is that they work. The advantage of
6 compiling the executables yourself is that you can modify them.
7
8 Downloading and Installing
9 ==========================
10 You can download the current version of AFF Tools from:
11
12 http://afflib.org/downloads/afflib_windows.zip
13
14 The ZIP file contains:
15 * pre-compiled executables for AFF Tools
16 * lib32eay.dll, the OpenSSL DLL (cryptography support for AFFLIB)
17 * bulk_extractor jar and bat file. (Use the bat file to run the jar file)
18
19 Install these tools by:
20
21 1. Unzip the archive into the c:\afflib directory.
22 2. Add c:\afflib to your system PATH directory by:
23 a. Opening the System control panel.
24 b. Clicking the "Environment Variables" button.
25 c. Adding "c:\afflib;" to the beginning of the PATH environment variable.
26
27
28 Working with the tools
29 ======================
30
31 If you are working with an encrypted disk image, set the environment
32 variable AFFLIB_PASSPHRASE to be the passphrase that should be used
33 for decryption.
34
35 % set AFFLIB_PASSPHRASE="this_is_my_passphrase"
36
37 Displaying the metadata with a disk image:
38
39 % afinfo.exe filename.aff
40
41
42 To convert an AFF file into a RAW file, use:
43
44 % afconvert.exe -e raw filename.aff
45
46
47 To reliably copy an AFF file from one location to another:
48
49 % afcopy.exe file1.aff d:\dest\path\file2.aff
50
51
52 To compare two AFF files:
53
54 % afcompare file1.aff file2.aff
55
56
57 To fix a corrupted AFF file:
58
59 % affix badfile.aff
60
61
62 To print statistics about a file:
63
64 % afstats.exe filename.aff
65
66
67
68
69 Diskprint
70 =================
71 An exciting feature in AFF 3.5 is the ability to rapidly calculate and
72 verify the "print" of a disk image. A print is constructed by
73 computing the SHA-256 of the beginning, end, and several randomly
74 chosen parts of the disk image.
75
76 To calculate the diskprint and store it in a file:
77
78 % afdiskprint myfile.iso > myfile.xml
79
80 To verify a diskprint
81
82 % afdiskprint -x myfile.xml myfile.iso
83
84
85
86 Bulk Extractor
87 ==============
88 In the ZIP file you will also find bulk_extractor.jar, a port of the
89 bulk_extractor to Java which actually runs 2x faster than the original
90 C version. (Unlike the C version, bulk_extractor.jar can only process
91 raw disk images, not EnCase or AFF files.)
92
93 To run bulk_extractor, you must have java on your system. Then type:
94
95 % java -jar bulk_extractor.jar diskimage.raw
96
97 You will probably want to extract the output to a file:
98
99 % java -jar bulk_extractor.jar ubnist1.casper-rw.gen3.raw > output.txt
100
101 The bulk extractor will report all of the email addresses, URLs,
102 domain names, and timestamps on the disk images. The current version
103 can handle a variety of Unicode encodings but it cannot handle
104 compressed regions.
105
106
107 Verifying the AFFLIB Digital Signature
108 ===============================
109 Some organizations require that dgital signatures be verified on programs that are downloaded.
110
111 Some AFF distributions are now signed with the AFFLIB privat key. You
112 can verify the distribution by downloading a copy of the public key
113 from the AFFLIB website or the GPG key server.
114
115 The public key can be downloaded from the website:
116
117 http://afflib.org/pubkey.asc
118
119 You can also download the key directly from the GPG keyserver with
120 this command:
121
122 $ gpg --keyserver subkeys.pgp.net --recv-keys 805B3DB0
123 gpg: requesting key 805B3DB0 from hkp server subkeys.pgp.net
124 gpg: /home/simsong/.gnupg/trustdb.gpg: trustdb created
125 gpg: key 805B3DB0: public key "AFFLIB Distribution (Simson L. Garfinkel)" imported
126 gpg: Total number processed: 1
127 gpg: imported: 1
128 $
129
0 # ===========================================================================
1 # http://autoconf-archive.cryp.to/ac_python_devel.html
2 # ===========================================================================
3 #
4 # SYNOPSIS
5 #
6 # AC_PYTHON_DEVEL([version])
7 #
8 # DESCRIPTION
9 #
10 # Note: Defines as a precious variable "PYTHON_VERSION". Don't override it
11 # in your configure.ac.
12 #
13 # This macro checks for Python and tries to get the include path to
14 # 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS)
15 # output variables. It also exports $(PYTHON_EXTRA_LIBS) and
16 # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
17 #
18 # You can search for some particular version of Python by passing a
19 # parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please
20 # note that you *have* to pass also an operator along with the version to
21 # match, and pay special attention to the single quotes surrounding the
22 # version number. Don't use "PYTHON_VERSION" for this: that environment
23 # variable is declared as precious and thus reserved for the end-user.
24 #
25 # This macro should work for all versions of Python >= 2.1.0. As an end
26 # user, you can disable the check for the python version by setting the
27 # PYTHON_NOVERSIONCHECK environment variable to something else than the
28 # empty string.
29 #
30 # If you need to use this macro for an older Python version, please
31 # contact the authors. We're always open for feedback.
32 #
33 # LICENSE
34 #
35 # Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de>
36 # Copyright (c) 2009 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
37 # Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net>
38 # Copyright (c) 2009 Andrew Collier <colliera@ukzn.ac.za>
39 # Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org>
40 # Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org>
41 #
42 # This program is free software: you can redistribute it and/or modify it
43 # under the terms of the GNU General Public License as published by the
44 # Free Software Foundation, either version 3 of the License, or (at your
45 # option) any later version.
46 #
47 # This program is distributed in the hope that it will be useful, but
48 # WITHOUT ANY WARRANTY; without even the implied warranty of
49 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
50 # Public License for more details.
51 #
52 # You should have received a copy of the GNU General Public License along
53 # with this program. If not, see <http://www.gnu.org/licenses/>.
54 #
55 # As a special exception, the respective Autoconf Macro's copyright owner
56 # gives unlimited permission to copy, distribute and modify the configure
57 # scripts that are the output of Autoconf when processing the Macro. You
58 # need not follow the terms of the GNU General Public License when using
59 # or distributing such scripts, even though portions of the text of the
60 # Macro appear in them. The GNU General Public License (GPL) does govern
61 # all other use of the material that constitutes the Autoconf Macro.
62 #
63 # This special exception to the GPL applies to versions of the Autoconf
64 # Macro released by the Autoconf Archive. When you make and distribute a
65 # modified version of the Autoconf Macro, you may extend this special
66 # exception to the GPL to apply to your modified version as well.
67
68 AC_DEFUN([AC_PYTHON_DEVEL],[
69 #
70 # Allow the use of a (user set) custom python version
71 #
72 AC_ARG_VAR([PYTHON_VERSION],[The installed Python
73 version to use, for example '2.3'. This string
74 will be appended to the Python interpreter
75 canonical name.])
76
77 AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
78 if test -z "$PYTHON"; then
79 AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
80 PYTHON_VERSION=""
81 fi
82
83 #
84 # Check for a version of Python >= 2.1.0
85 #
86 AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
87 ac_supports_python_ver=`$PYTHON -c "import sys; \
88 ver = sys.version.split ()[[0]]; \
89 print (ver >= '2.1.0')"`
90 if test "$ac_supports_python_ver" != "True"; then
91 if test -z "$PYTHON_NOVERSIONCHECK"; then
92 AC_MSG_RESULT([no])
93 AC_MSG_FAILURE([
94 This version of the AC@&t@_PYTHON_DEVEL macro
95 doesn't work properly with versions of Python before
96 2.1.0. You may need to re-run configure, setting the
97 variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
98 PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
99 Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
100 to something else than an empty string.
101 ])
102 else
103 AC_MSG_RESULT([skip at user request])
104 fi
105 else
106 AC_MSG_RESULT([yes])
107 fi
108
109 #
110 # if the macro parameter ``version'' is set, honour it
111 #
112 if test -n "$1"; then
113 AC_MSG_CHECKING([for a version of Python $1])
114 ac_supports_python_ver=`$PYTHON -c "import sys; \
115 ver = sys.version.split ()[[0]]; \
116 print (ver $1)"`
117 if test "$ac_supports_python_ver" = "True"; then
118 AC_MSG_RESULT([yes])
119 else
120 AC_MSG_RESULT([no])
121 AC_MSG_ERROR([this package requires Python $1.
122 If you have it installed, but it isn't the default Python
123 interpreter in your system path, please pass the PYTHON_VERSION
124 variable to configure. See ``configure --help'' for reference.
125 ])
126 PYTHON_VERSION=""
127 fi
128 fi
129
130 #
131 # Check if you have distutils, else fail
132 #
133 AC_MSG_CHECKING([for the distutils Python package])
134 ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
135 if test -z "$ac_distutils_result"; then
136 AC_MSG_RESULT([yes])
137 else
138 AC_MSG_RESULT([no])
139 AC_MSG_ERROR([cannot import Python module "distutils".
140 Please check your Python installation. The error was:
141 $ac_distutils_result])
142 PYTHON_VERSION=""
143 fi
144
145 #
146 # Check for Python include path
147 #
148 AC_MSG_CHECKING([for Python include path])
149 if test -z "$PYTHON_CPPFLAGS"; then
150 python_path=`$PYTHON -c "import distutils.sysconfig; \
151 print (distutils.sysconfig.get_python_inc ());"`
152 if test -n "${python_path}"; then
153 python_path="-I$python_path"
154 fi
155 PYTHON_CPPFLAGS=$python_path
156 fi
157 AC_MSG_RESULT([$PYTHON_CPPFLAGS])
158 AC_SUBST([PYTHON_CPPFLAGS])
159
160 #
161 # Check for Python library path
162 #
163 AC_MSG_CHECKING([for Python library path])
164 if test -z "$PYTHON_LDFLAGS"; then
165 # (makes two attempts to ensure we've got a version number
166 # from the interpreter)
167 ac_python_version=`cat<<EOD | $PYTHON -
168
169 # join all versioning strings, on some systems
170 # major/minor numbers could be in different list elements
171 from distutils.sysconfig import *
172 ret = ''
173 for e in get_config_vars ('VERSION'):
174 if (e != None):
175 ret += e
176 print (ret)
177 EOD`
178
179 if test -z "$ac_python_version"; then
180 if test -n "$PYTHON_VERSION"; then
181 ac_python_version=$PYTHON_VERSION
182 else
183 ac_python_version=`$PYTHON -c "import sys; \
184 print (sys.version[[:3]])"`
185 fi
186 fi
187
188 # Make the versioning information available to the compiler
189 AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
190 [If available, contains the Python version number currently in use.])
191
192 # First, the library directory:
193 ac_python_libdir=`cat<<EOD | $PYTHON -
194
195 # There should be only one
196 import distutils.sysconfig
197 for e in distutils.sysconfig.get_config_vars ('LIBDIR'):
198 if e != None:
199 print (e)
200 break
201 EOD`
202
203 # Before checking for libpythonX.Y, we need to know
204 # the extension the OS we're on uses for libraries
205 # (we take the first one, if there's more than one fix me!):
206 ac_python_soext=`$PYTHON -c \
207 "import distutils.sysconfig; \
208 print (distutils.sysconfig.get_config_vars('SO')[[0]])"`
209
210 # Now, for the library:
211 ac_python_soname=`$PYTHON -c \
212 "import distutils.sysconfig; \
213 print (distutils.sysconfig.get_config_vars('LDLIBRARY')[[0]])"`
214
215 # Strip away extension from the end to canonicalize its name:
216 ac_python_library=`echo "$ac_python_soname" | sed "s/${ac_python_soext}$//"`
217
218 # This small piece shamelessly adapted from PostgreSQL python macro;
219 # credits goes to momjian, I think. I'd like to put the right name
220 # in the credits, if someone can point me in the right direction... ?
221 #
222 if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
223 -a x"$ac_python_library" != x"$ac_python_soname"
224 then
225 # use the official shared library
226 ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
227 PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
228 else
229 # old way: use libpython from python_configdir
230 ac_python_libdir=`$PYTHON -c \
231 "from distutils.sysconfig import get_python_lib as f; \
232 import os; \
233 print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
234 PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
235 fi
236
237 if test -z "PYTHON_LDFLAGS"; then
238 AC_MSG_ERROR([
239 Cannot determine location of your Python DSO. Please check it was installed with
240 dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand.
241 ])
242 fi
243 fi
244 AC_MSG_RESULT([$PYTHON_LDFLAGS])
245 AC_SUBST([PYTHON_LDFLAGS])
246
247 #
248 # Check for site packages
249 #
250 AC_MSG_CHECKING([for Python site-packages path])
251 if test -z "$PYTHON_SITE_PKG"; then
252 PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
253 print (distutils.sysconfig.get_python_lib(0,0));"`
254 fi
255 AC_MSG_RESULT([$PYTHON_SITE_PKG])
256 AC_SUBST([PYTHON_SITE_PKG])
257
258 #
259 # libraries which must be linked in when embedding
260 #
261 AC_MSG_CHECKING(python extra libraries)
262 if test -z "$PYTHON_EXTRA_LIBS"; then
263 PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
264 conf = distutils.sysconfig.get_config_var; \
265 print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"`
266 fi
267 AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
268 AC_SUBST(PYTHON_EXTRA_LIBS)
269
270 #
271 # linking flags needed when embedding
272 #
273 AC_MSG_CHECKING(python extra linking flags)
274 if test -z "$PYTHON_EXTRA_LDFLAGS"; then
275 PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
276 conf = distutils.sysconfig.get_config_var; \
277 print (conf('LINKFORSHARED'))"`
278 fi
279 AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
280 AC_SUBST(PYTHON_EXTRA_LDFLAGS)
281
282 #
283 # final check to see if everything compiles alright
284 #
285 AC_MSG_CHECKING([consistency of all components of python development environment])
286 # save current global flags
287 ac_save_LIBS="$LIBS"
288 ac_save_CPPFLAGS="$CPPFLAGS"
289 LIBS="$LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS $PYTHON_EXTRA_LIBS"
290 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
291 AC_LANG_PUSH([C])
292 AC_LINK_IFELSE([
293 AC_LANG_PROGRAM([[#include <Python.h>]],
294 [[Py_Initialize();]])
295 ],[pythonexists=yes],[pythonexists=no])
296 AC_LANG_POP([C])
297 # turn back to default flags
298 CPPFLAGS="$ac_save_CPPFLAGS"
299 LIBS="$ac_save_LIBS"
300
301 AC_MSG_RESULT([$pythonexists])
302
303 if test ! "x$pythonexists" = "xyes"; then
304 AC_MSG_FAILURE([
305 Could not link test program to Python. Maybe the main Python library has been
306 installed in some non-standard library path. If so, pass it to configure,
307 via the LDFLAGS environment variable.
308 Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
309 ============================================================================
310 ERROR!
311 You probably have to install the development version of the Python package
312 for your distribution. The exact name of this package varies among them.
313 ============================================================================
314 ])
315 PYTHON_VERSION=""
316 fi
317
318 #
319 # all done!
320 #
321 ])
322 # ===========================================================================
323 # http://autoconf-archive.cryp.to/ac_python_module.html
324 # ===========================================================================
325 #
326 # SYNOPSIS
327 #
328 # AC_PYTHON_MODULE(modname[, fatal])
329 #
330 # DESCRIPTION
331 #
332 # Checks for Python module.
333 #
334 # If fatal is non-empty then absence of a module will trigger an error.
335 #
336 # LICENSE
337 #
338 # Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
339 #
340 # Copying and distribution of this file, with or without modification, are
341 # permitted in any medium without royalty provided the copyright notice
342 # and this notice are preserved.
343
344 AC_DEFUN([AC_PYTHON_MODULE],[
345 if test -z $PYTHON;
346 then
347 PYTHON="python"
348 fi
349 PYTHON_NAME=`basename $PYTHON`
350 AC_MSG_CHECKING($PYTHON_NAME module: $1)
351 $PYTHON -c "import $1" 2>/dev/null
352 if test $? -eq 0;
353 then
354 AC_MSG_RESULT(yes)
355 eval AS_TR_CPP(HAVE_PYMOD_$1)=yes
356 else
357 AC_MSG_RESULT(no)
358 eval AS_TR_CPP(HAVE_PYMOD_$1)=no
359 #
360 if test -n "$2"
361 then
362 AC_MSG_ERROR(failed to find required module $1)
363 exit 1
364 fi
365 fi
366 ])
367 # ===========================================================================
368 # http://autoconf-archive.cryp.to/az_python.html
369 # ===========================================================================
370 #
371 # SYNOPSIS
372 #
373 # AZ_PYTHON_DEFAULT
374 # AZ_PYTHON_ENABLE
375 # AZ_PYTHON_WITH
376 # AZ_PYTHON_PATH
377 # AZ_PYTHON_VERSION_ENSURE( [2.2] )
378 # AZ_PYTHON_CSPEC
379 # AZ_PYTHON_LSPEC
380 #
381 # DESCRIPTION
382 #
383 # This file provides autoconf support for those applications that want to
384 # embed python. It supports all pythons >= 2.2 which is the first official
385 # release containing distutils. Version 2.2 of python was released
386 # December 21, 2001. Since it actually executes the python, cross platform
387 # configuration will probably not work. Also, most of the platforms
388 # supported are consistent until you look into MacOSX. The python included
389 # with it is installed as a framework which is a very different
390 # environment to set up the normal tools such as gcc and libtool to deal
391 # with. Therefore, once we establish which python that we are going to
392 # use, we use its distutils to actually compile and link our modules or
393 # applications.
394 #
395 # At this time, it does NOT support linking with Python statically. It
396 # does support dynamic linking.
397 #
398 # This set of macros help define $PYTHON, $PYTHON_USE, $PYTHON_CSPEC and
399 # $PYTHON_LSPEC. $PYTHON defines the full executable path for the Python
400 # being linked to and is used within these macros to determine if that has
401 # been specified or found. These macros do execute this python version so
402 # it must be present on the system at configure time.
403 #
404 # $PYTHON_USE is an automake variable that defines whether Python support
405 # should be included or not in your application. $PYTHON_CSPEC is a
406 # variable that supplies additional CFLAGS for the compilation of the
407 # application/shared library. $PYTHON_LSPEC is a variable that supplies
408 # additional LDFLAGS for linking the application/shared library.
409 #
410 # The following is an example of how to set up for python usage within
411 # your application in your configure.in:
412 #
413 # AZ_PYTHON_DEFAULT( )
414 # AZ_PYTHON_ENABLE( ) # Optional
415 # AZ_PYTHON_WITH( ) # Optional
416 # AZ_PYTHON_PATH( ) # or AZ_PYTHON_INSIST( )
417 # # if $PYTHON is not defined, then the following do nothing.
418 # AZ_PYTHON_VERSION_ENSURE( [2.2] )
419 # AZ_PYTHON_CSPEC
420 # AZ_PYTHON_LSPEC
421 #
422 # The AZ_PYTHON_DEFAULT sets the $PYTHON_USE to false. Thereby, excluding
423 # it if it was optional.
424 #
425 # The AZ_PYTHON_ENABLE looks for the optional configure parameters of
426 # --enable-python/--disable-python and establishes the $PYTHON and
427 # $PYTHON_USE variables accordingly.
428 #
429 # The AZ_PYTHON_WITH looks for the optional configure parameters of
430 # --with-python/--without-python and establishes the $PYTHON and
431 # $PYTHON_USE variables accordingly.
432 #
433 # The AZ_PYTHON_PATH looks for python assuming that none has been
434 # previously found or defined and issues an error if it does not find it.
435 # If it does find it, it establishes the $PYTHON and $PYTHON_USE variables
436 # accordingly. AZ_PYTHON_INSIST could be used here instead if you want to
437 # insist that Python support be included using the --enable-python or
438 # --with-python checks previously done.
439 #
440 # The AZ_PYTHON_VERSION_ENSURE issues an error if the Python previously
441 # found is not of version 2.2 or greater.
442 #
443 # Once that these macros have be run, we can use PYTHON_USE within the
444 # makefile.am file to conditionally add the Python support such as:
445 #
446 # Makefile.am example showing optional inclusion of directories:
447 #
448 # if PYTHON_USE
449 # plugins = plugins
450 # src = src
451 # else
452 # plugins =
453 # src =
454 # endif
455 #
456 # SUBDIRS = . $(plugins) $(src)
457 #
458 # Makefile.am example showing optional shared library build:
459 #
460 # if PYTHON_USE
461 # lib_LTLIBRARIES = libElemList.la
462 # libElemList_la_SOURCES = libElemList.c
463 # libElemList_la_CFLAGS = @PYTHON_CSPEC@
464 # libElemList_la_LDFLAGS = @PYTHON_LSPEC@
465 # endif
466 #
467 # Makefile.am example showing optional program build:
468 #
469 # if PYTHON_USE
470 # bin_PROGRAMS = runFunc
471 # runFunc_SOURCES = runFunc.c
472 # runFunc_CFLAGS = @PYTHON_CSPEC@
473 # runFunc_LDFLAGS = @PYTHON_LSPEC@
474 # endif
475 #
476 # The above compiles the modules only if PYTHON_USE was specified as true.
477 # Also, the else portion of the if was optional.
478 #
479 # LICENSE
480 #
481 # Copyright (c) 2008 Robert White <kranki@mac.com>
482 # Copyright (c) 2008 Dustin J. Mitchell <dustin@cs.uchicago.edu>
483 #
484 # Copying and distribution of this file, with or without modification, are
485 # permitted in any medium without royalty provided the copyright notice
486 # and this notice are preserved.
487
488 # AZ_PYTHON_DEFAULT( )
489 # -----------------
490 # Sets the default to not include Python support.
491
492 AC_DEFUN([AZ_PYTHON_DEFAULT],
493 [
494 az_python_use=false
495 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
496 ])
497
498
499
500 # AZ_PYTHON_ENABLE( [path] )
501 # -----------------------------------------------------------------
502 # Handles the various --enable-python commands.
503 # Input:
504 # $1 is the optional search path for the python executable if needed
505 # Ouput:
506 # PYTHON_USE (AM_CONDITIONAL) is true if python executable found
507 # and --enable-python was requested; otherwise false.
508 # $PYTHON contains the full executable path to python if PYTHON_ENABLE_USE
509 # is true.
510 #
511 # Example:
512 # AZ_PYTHON_ENABLE( )
513 # or
514 # AZ_PYTHON_ENABLE( "/usr/bin" )
515
516 AC_DEFUN([AZ_PYTHON_ENABLE],
517 [
518 AC_ARG_VAR([PYTHON],[Python Executable Path])
519
520 # unless PYTHON was supplied to us (as a precious variable),
521 # see if --enable-python[=PythonExecutablePath], --enable-python,
522 # --disable-python or --enable-python=no was given.
523 if test -z "$PYTHON"
524 then
525 AC_MSG_CHECKING(for --enable-python)
526 AC_ARG_ENABLE(
527 python,
528 AC_HELP_STRING([--enable-python@<:@=PYTHON@:>@],
529 [absolute path name of Python executable]
530 ),
531 [
532 if test "$enableval" = "yes"
533 then
534 # "yes" was specified, but we don't have a path
535 # for the executable.
536 # So, let's searth the PATH Environment Variable.
537 AC_MSG_RESULT(yes)
538 AC_PATH_PROG(
539 [PYTHON],
540 python,
541 [],
542 $1
543 )
544 if test -z "$PYTHON"
545 then
546 AC_MSG_ERROR(no path to python found)
547 fi
548 az_python_use=true
549 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
550 AZ_PYTHON_PREFIX( )
551 elif test "$enableval" = "no"
552 then
553 AC_MSG_RESULT(no)
554 az_python_use=false
555 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
556 else
557 # $enableval must be the executable path then.
558 AC_SUBST([PYTHON], ["${enableval}"])
559 AC_MSG_RESULT($withval)
560 az_python_use=true
561 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
562 AZ_PYTHON_PREFIX( )
563 fi
564 ],
565 [
566 # --with-python was not specified.
567 AC_MSG_RESULT(no)
568 az_python_use=false
569 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
570 ]
571 )
572 fi
573
574 ])
575
576
577
578 # AZ_PYTHON_CSPEC( )
579 # -----------------
580 # Set up the c compiler options to compile Python
581 # embedded programs/libraries in $PYTHON_CSPEC if
582 # $PYTHON has been defined.
583
584 AC_DEFUN([AZ_PYTHON_CSPEC],
585 [
586 AC_ARG_VAR( [PYTHON], [Python Executable Path] )
587 if test -n "$PYTHON"
588 then
589 az_python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
590 if test -z "$az_python_prefix"
591 then
592 AC_MSG_ERROR([Python Prefix is not known])
593 fi
594 az_python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
595 az_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`
596 az_python_includespec="-I${az_python_prefix}/include/python${az_python_version}"
597 if test x"$python_prefix" != x"$python_execprefix"; then
598 az_python_execspec="-I${az_python_execprefix}/include/python${az_python_version}"
599 az_python_includespec="${az_python_includespec} $az_python_execspec"
600 fi
601 az_python_ccshared=`${PYTHON} -c "import distutils.sysconfig; print distutils.sysconfig.get_config_var('CFLAGSFORSHARED')"`
602 az_python_cspec="${az_python_ccshared} ${az_python_includespec}"
603 AC_SUBST([PYTHON_CSPEC], [${az_python_cspec}])
604 AC_MSG_NOTICE([PYTHON_CSPEC=${az_python_cspec}])
605 fi
606 ])
607
608
609
610 # AZ_PYTHON_INSIST( )
611 # -----------------
612 # Look for Python and set the output variable 'PYTHON'
613 # to 'python' if found, empty otherwise.
614
615 AC_DEFUN([AZ_PYTHON_PATH],
616 [
617 AC_ARG_VAR( [PYTHON], [Python Executable Path] )
618 if test -z "$PYTHON"
619 then
620 AC_MSG_ERROR([Python Executable not found])
621 fi
622 ])
623
624
625
626 # AZ_PYTHON_LSPEC( )
627 # -----------------
628 # Set up the linker options to link Python embedded
629 # programs/libraries in $PYTHON_LSPEC if $PYTHON
630 # has been defined.
631
632 AC_DEFUN([AZ_PYTHON_LSPEC],
633 [
634 AC_ARG_VAR( [PYTHON], [Python Executable Path] )
635 if test -n "$PYTHON"
636 then
637 AZ_PYTHON_RUN([
638 import sys
639 import distutils.sysconfig
640 strUseFrameWork = "--enable-framework"
641 dictConfig = distutils.sysconfig.get_config_vars( )
642 strConfigArgs = dictConfig.get("CONFIG_ARGS")
643 strLinkSpec = dictConfig.get('LDFLAGS')
644 if -1 == strConfigArgs.find(strUseFrameWork):
645 strLibPL = dictConfig.get("LIBPL")
646 if strLibPL and (strLibPL != ""):
647 strLinkSpec += " -L%s" % (strLibPL)
648 strSys = dictConfig.get("SYSLIBS")
649 if strSys and (strSys != ""):
650 strLinkSpec += " %s" % (strSys)
651 strSHL = dictConfig.get("SHLIBS")
652 if strSHL and (strSHL != ""):
653 strLinkSpec += " %s" % (strSHL)
654 # Construct the Python Library Name.
655 strTmplte = " -lpython%d.%d"
656 if (sys.platform == "win32") or (sys.platform == "os2emx"):
657 strTmplte = " -lpython%d%d"
658 strWrk = strTmplte % ( (sys.hexversion >> 24),
659 ((sys.hexversion >> 16) & 0xff))
660 strLinkSpec += strWrk
661 else:
662 # This is not ideal since it changes the search path
663 # for Frameworks which could have side-effects on
664 # other included Frameworks. However, it is necessary
665 # where someone has installed more than one frameworked
666 # Python. Frameworks are really only used in MacOSX.
667 strLibFW = dictConfig.get("PYTHONFRAMEWORKPREFIX")
668 if strLibFW and (strLibFW != ""):
669 strLinkSpec += " -F%s" % (strLibFW)
670 strLinkSpec += " %s" % (dictConfig.get('LINKFORSHARED'))
671 print strLinkSpec
672 ])
673 AC_SUBST([PYTHON_LSPEC], [${az_python_output}])
674 AC_MSG_NOTICE([PYTHON_LSPEC=${az_python_output}])
675 fi
676 ])
677
678
679
680 # AZ_PYTHON_PATH( )
681 # -----------------
682 # Look for Python and set the output variable 'PYTHON'
683 # to 'python' if found, empty otherwise.
684
685 AC_DEFUN([AZ_PYTHON_PATH],
686 [
687 AC_ARG_VAR( [PYTHON], [Python Executable Path] )
688 AC_PATH_PROG( PYTHON, python, [], $1 )
689 if test -z "$PYTHON"
690 then
691 AC_MSG_ERROR([Python Executable not found])
692 else
693 az_python_use=true
694 fi
695 AM_CONDITIONAL(PYTHON_USE, test "$az_python_use" = "true")
696 ])
697
698
699
700 # AZ_PYTHON_PREFIX( )
701 # -------------------
702 # Use the values of $prefix and $exec_prefix for the corresponding
703 # values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.
704
705 AC_DEFUN([AZ_PYTHON_PREFIX],
706 [
707 if test -z "$PYTHON"
708 then
709 AC_MSG_ERROR([Python Executable Path is not known])
710 fi
711 ax_python_prefix=`${PYTHON} -c "import sys; print sys.prefix"`
712 ax_python_execprefix=`${PYTHON} -c "import sys; print sys.exec_prefix"`
713 AC_SUBST([PYTHON_PREFIX], ["${ax_python_prefix}"])
714 AC_SUBST([PYTHON_EXECPREFIX], ["${ax_python_execprefix}"])
715 ])
716
717
718
719 # AZ_PYTHON_RUN( PYTHON_PROGRAM )
720 # -----------------
721 # Run a Python Test Program saving its output
722 # in az_python_output and its condition code
723 # in az_python_cc.
724
725 AC_DEFUN([AZ_PYTHON_RUN],
726 [
727 AC_ARG_VAR( [PYTHON], [Python Executable Path] )
728 if test -z "$PYTHON"
729 then
730 AC_MSG_ERROR([Python Executable not found])
731 else
732 cat >conftest.py <<_ACEOF
733 $1
734 _ACEOF
735 az_python_output=`$PYTHON conftest.py`
736 az_python_cc=$?
737 rm conftest.py
738 if test -f "conftest.pyc"
739 then
740 rm conftest.pyc
741 fi
742 fi
743 ])
744
745
746
747 # AZ_PYTHON_VERSION_CHECK( VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE] )
748 # -----------------------------------------------------------------------------
749 # Run ACTION-IF-TRUE if the Python interpreter has version >= VERSION.
750 # Run ACTION-IF-FALSE otherwise.
751 # This test uses sys.hexversion instead of the string equivalant (first
752 # word of sys.version), in order to cope with versions such as 2.2c1.
753 # hexversion has been introduced in Python 1.5.2; it's probably not
754 # worth to support older versions (1.5.1 was released on October 31, 1998).
755
756 AC_DEFUN([AZ_PYTHON_VERSION_CHECK],
757 [
758 AC_ARG_VAR( [PYTHON], [Python Executable Path] )
759 if test -n "$PYTHON"
760 then
761 AC_MSG_CHECKING([whether $PYTHON version >= $1])
762 AZ_PYTHON_RUN([
763 import sys, string
764 # split strings by '.' and convert to numeric. Append some zeros
765 # because we need at least 4 digits for the hex conversion.
766 minver = map(int, string.split('$1', '.')) + [[0, 0, 0]]
767 minverhex = 0
768 for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]]
769 if sys.hexversion >= minverhex:
770 sys.exit( 0 )
771 else:
772 sys.exit( 1 )
773 ])
774 if test $az_python_cc -eq 0
775 then
776 $2
777 m4_ifvaln(
778 [$3],
779 [else $3]
780 )
781 fi
782 fi
783 ])
784
785
786
787 # AZ_PYTHON_VERSION_ENSURE( VERSION )
788 # -----------------
789 # Insure that the Python Interpreter Version
790 # is greater than or equal to the VERSION
791 # parameter.
792
793 AC_DEFUN([AZ_PYTHON_VERSION_ENSURE],
794 [
795 AZ_PYTHON_VERSION_CHECK(
796 [$1],
797 [AC_MSG_RESULT(yes)],
798 [AC_MSG_ERROR(too old)]
799 )
800 ])
801
802
803
804 # AZ_PYTHON_WITH( [path] )
805 # -----------------------------------------------------------------
806 # Handles the various --with-python commands.
807 # Input:
808 # $1 is the optional search path for the python executable if needed
809 # Ouput:
810 # PYTHON_USE (AM_CONDITIONAL) is true if python executable found
811 # and --with-python was requested; otherwise false.
812 # $PYTHON contains the full executable path to python if PYTHON_USE
813 # is true.
814 #
815 # Example:
816 # AZ_PYTHON_WITH( )
817 # or
818 # AZ_PYTHON_WITH("/usr/bin")
819
820 AC_DEFUN([AZ_PYTHON_WITH],
821 [
822 AC_ARG_VAR([PYTHON],[Python Executable Path])
823
824 # unless PYTHON was supplied to us (as a precious variable),
825 # see if --with-python[=PythonExecutablePath], --with-python,
826 # --without-python or --with-python=no was given.
827 if test -z "$PYTHON"
828 then
829 AC_MSG_CHECKING(for --with-python)
830 AC_ARG_WITH(
831 python,
832 AC_HELP_STRING([--with-python@<:@=PYTHON@:>@],
833 [absolute path name of Python executable]
834 ),
835 [
836 if test "$withval" = "yes"
837 then
838 # "yes" was specified, but we don't have a path
839 # for the executable.
840 # So, let's searth the PATH Environment Variable.
841 AC_MSG_RESULT(yes)
842 AC_PATH_PROG(
843 [PYTHON],
844 python,
845 [],
846 $1
847 )
848 if test -z "$PYTHON"
849 then
850 AC_MSG_ERROR(no path to python found)
851 fi
852 az_python_use=true
853 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
854 AZ_PYTHON_PREFIX( )
855 elif test "$withval" = "no"
856 then
857 AC_MSG_RESULT(no)
858 az_python_use=false
859 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
860 else
861 # $withval must be the executable path then.
862 AC_SUBST([PYTHON], ["${withval}"])
863 AC_MSG_RESULT($withval)
864 az_python_use=true
865 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
866 AZ_PYTHON_PREFIX( )
867 fi
868 ],
869 [
870 # --with-python was not specified.
871 AC_MSG_RESULT(no)
872 az_python_use=false
873 AM_CONDITIONAL(PYTHON_USE, test x"$az_python_use" = x"true")
874 ]
875 )
876 fi
877
878 ])
0 # generated automatically by aclocal 1.10 -*- Autoconf -*-
1
2 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 # 2005, 2006 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
7
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 # PARTICULAR PURPOSE.
12
13 m4_if(m4_PACKAGE_VERSION, [2.61],,
14 [m4_fatal([this file was generated for autoconf 2.61.
15 You have another version of autoconf. If you want to use that,
16 you should regenerate the build system entirely.], [63])])
17
18 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
19 #
20 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
21 # 2006, 2007, 2008 Free Software Foundation, Inc.
22 # Written by Gordon Matzigkeit, 1996
23 #
24 # This file is free software; the Free Software Foundation gives
25 # unlimited permission to copy and/or distribute it, with or without
26 # modifications, as long as this notice is preserved.
27
28 m4_define([_LT_COPYING], [dnl
29 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
30 # 2006, 2007, 2008 Free Software Foundation, Inc.
31 # Written by Gordon Matzigkeit, 1996
32 #
33 # This file is part of GNU Libtool.
34 #
35 # GNU Libtool is free software; you can redistribute it and/or
36 # modify it under the terms of the GNU General Public License as
37 # published by the Free Software Foundation; either version 2 of
38 # the License, or (at your option) any later version.
39 #
40 # As a special exception to the GNU General Public License,
41 # if you distribute this file as part of a program or library that
42 # is built using GNU Libtool, you may include this file under the
43 # same distribution terms that you use for the rest of that program.
44 #
45 # GNU Libtool is distributed in the hope that it will be useful,
46 # but WITHOUT ANY WARRANTY; without even the implied warranty of
47 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48 # GNU General Public License for more details.
49 #
50 # You should have received a copy of the GNU General Public License
51 # along with GNU Libtool; see the file COPYING. If not, a copy
52 # can be downloaded from http://www.gnu.org/licenses/gpl.html, or
53 # obtained by writing to the Free Software Foundation, Inc.,
54 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
55 ])
56
57 # serial 56 LT_INIT
58
59
60 # LT_PREREQ(VERSION)
61 # ------------------
62 # Complain and exit if this libtool version is less that VERSION.
63 m4_defun([LT_PREREQ],
64 [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
65 [m4_default([$3],
66 [m4_fatal([Libtool version $1 or higher is required],
67 63)])],
68 [$2])])
69
70
71 # _LT_CHECK_BUILDDIR
72 # ------------------
73 # Complain if the absolute build directory name contains unusual characters
74 m4_defun([_LT_CHECK_BUILDDIR],
75 [case `pwd` in
76 *\ * | *\ *)
77 AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
78 esac
79 ])
80
81
82 # LT_INIT([OPTIONS])
83 # ------------------
84 AC_DEFUN([LT_INIT],
85 [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
86 AC_BEFORE([$0], [LT_LANG])dnl
87 AC_BEFORE([$0], [LT_OUTPUT])dnl
88 AC_BEFORE([$0], [LTDL_INIT])dnl
89 m4_require([_LT_CHECK_BUILDDIR])dnl
90
91 dnl Autoconf doesn't catch unexpanded LT_ macros by default:
92 m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
93 m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
94 dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
95 dnl unless we require an AC_DEFUNed macro:
96 AC_REQUIRE([LTOPTIONS_VERSION])dnl
97 AC_REQUIRE([LTSUGAR_VERSION])dnl
98 AC_REQUIRE([LTVERSION_VERSION])dnl
99 AC_REQUIRE([LTOBSOLETE_VERSION])dnl
100 m4_require([_LT_PROG_LTMAIN])dnl
101
102 dnl Parse OPTIONS
103 _LT_SET_OPTIONS([$0], [$1])
104
105 # This can be used to rebuild libtool when needed
106 LIBTOOL_DEPS="$ltmain"
107
108 # Always use our own libtool.
109 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
110 AC_SUBST(LIBTOOL)dnl
111
112 _LT_SETUP
113
114 # Only expand once:
115 m4_define([LT_INIT])
116 ])# LT_INIT
117
118 # Old names:
119 AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
120 AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
121 dnl aclocal-1.4 backwards compatibility:
122 dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
123 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
124
125
126 # _LT_CC_BASENAME(CC)
127 # -------------------
128 # Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
129 m4_defun([_LT_CC_BASENAME],
130 [for cc_temp in $1""; do
131 case $cc_temp in
132 compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
133 distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
134 \-*) ;;
135 *) break;;
136 esac
137 done
138 cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
139 ])
140
141
142 # _LT_FILEUTILS_DEFAULTS
143 # ----------------------
144 # It is okay to use these file commands and assume they have been set
145 # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
146 m4_defun([_LT_FILEUTILS_DEFAULTS],
147 [: ${CP="cp -f"}
148 : ${MV="mv -f"}
149 : ${RM="rm -f"}
150 ])# _LT_FILEUTILS_DEFAULTS
151
152
153 # _LT_SETUP
154 # ---------
155 m4_defun([_LT_SETUP],
156 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
157 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
158 _LT_DECL([], [host_alias], [0], [The host system])dnl
159 _LT_DECL([], [host], [0])dnl
160 _LT_DECL([], [host_os], [0])dnl
161 dnl
162 _LT_DECL([], [build_alias], [0], [The build system])dnl
163 _LT_DECL([], [build], [0])dnl
164 _LT_DECL([], [build_os], [0])dnl
165 dnl
166 AC_REQUIRE([AC_PROG_CC])dnl
167 AC_REQUIRE([LT_PATH_LD])dnl
168 AC_REQUIRE([LT_PATH_NM])dnl
169 dnl
170 AC_REQUIRE([AC_PROG_LN_S])dnl
171 test -z "$LN_S" && LN_S="ln -s"
172 _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
173 dnl
174 AC_REQUIRE([LT_CMD_MAX_LEN])dnl
175 _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
176 _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
177 dnl
178 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
179 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
180 m4_require([_LT_CMD_RELOAD])dnl
181 m4_require([_LT_CHECK_MAGIC_METHOD])dnl
182 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
183 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
184
185 _LT_CONFIG_LIBTOOL_INIT([
186 # See if we are running on zsh, and set the options which allow our
187 # commands through without removal of \ escapes INIT.
188 if test -n "\${ZSH_VERSION+set}" ; then
189 setopt NO_GLOB_SUBST
190 fi
191 ])
192 if test -n "${ZSH_VERSION+set}" ; then
193 setopt NO_GLOB_SUBST
194 fi
195
196 _LT_CHECK_OBJDIR
197
198 m4_require([_LT_TAG_COMPILER])dnl
199 _LT_PROG_ECHO_BACKSLASH
200
201 case $host_os in
202 aix3*)
203 # AIX sometimes has problems with the GCC collect2 program. For some
204 # reason, if we set the COLLECT_NAMES environment variable, the problems
205 # vanish in a puff of smoke.
206 if test "X${COLLECT_NAMES+set}" != Xset; then
207 COLLECT_NAMES=
208 export COLLECT_NAMES
209 fi
210 ;;
211 esac
212
213 # Sed substitution that helps us do robust quoting. It backslashifies
214 # metacharacters that are still active within double-quoted strings.
215 sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
216
217 # Same as above, but do not quote variable references.
218 double_quote_subst='s/\([["`\\]]\)/\\\1/g'
219
220 # Sed substitution to delay expansion of an escaped shell variable in a
221 # double_quote_subst'ed string.
222 delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
223
224 # Sed substitution to delay expansion of an escaped single quote.
225 delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
226
227 # Sed substitution to avoid accidental globbing in evaled expressions
228 no_glob_subst='s/\*/\\\*/g'
229
230 # Global variables:
231 ofile=libtool
232 can_build_shared=yes
233
234 # All known linkers require a `.a' archive for static linking (except MSVC,
235 # which needs '.lib').
236 libext=a
237
238 with_gnu_ld="$lt_cv_prog_gnu_ld"
239
240 old_CC="$CC"
241 old_CFLAGS="$CFLAGS"
242
243 # Set sane defaults for various variables
244 test -z "$CC" && CC=cc
245 test -z "$LTCC" && LTCC=$CC
246 test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
247 test -z "$LD" && LD=ld
248 test -z "$ac_objext" && ac_objext=o
249
250 _LT_CC_BASENAME([$compiler])
251
252 # Only perform the check for file, if the check method requires it
253 test -z "$MAGIC_CMD" && MAGIC_CMD=file
254 case $deplibs_check_method in
255 file_magic*)
256 if test "$file_magic_cmd" = '$MAGIC_CMD'; then
257 _LT_PATH_MAGIC
258 fi
259 ;;
260 esac
261
262 # Use C for the default configuration in the libtool script
263 LT_SUPPORTED_TAG([CC])
264 _LT_LANG_C_CONFIG
265 _LT_LANG_DEFAULT_CONFIG
266 _LT_CONFIG_COMMANDS
267 ])# _LT_SETUP
268
269
270 # _LT_PROG_LTMAIN
271 # ---------------
272 # Note that this code is called both from `configure', and `config.status'
273 # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
274 # `config.status' has no value for ac_aux_dir unless we are using Automake,
275 # so we pass a copy along to make sure it has a sensible value anyway.
276 m4_defun([_LT_PROG_LTMAIN],
277 [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
278 _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
279 ltmain="$ac_aux_dir/ltmain.sh"
280 ])# _LT_PROG_LTMAIN
281
282
283
284 # So that we can recreate a full libtool script including additional
285 # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
286 # in macros and then make a single call at the end using the `libtool'
287 # label.
288
289
290 # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
291 # ----------------------------------------
292 # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
293 m4_define([_LT_CONFIG_LIBTOOL_INIT],
294 [m4_ifval([$1],
295 [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
296 [$1
297 ])])])
298
299 # Initialize.
300 m4_define([_LT_OUTPUT_LIBTOOL_INIT])
301
302
303 # _LT_CONFIG_LIBTOOL([COMMANDS])
304 # ------------------------------
305 # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
306 m4_define([_LT_CONFIG_LIBTOOL],
307 [m4_ifval([$1],
308 [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
309 [$1
310 ])])])
311
312 # Initialize.
313 m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
314
315
316 # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
317 # -----------------------------------------------------
318 m4_defun([_LT_CONFIG_SAVE_COMMANDS],
319 [_LT_CONFIG_LIBTOOL([$1])
320 _LT_CONFIG_LIBTOOL_INIT([$2])
321 ])
322
323
324 # _LT_FORMAT_COMMENT([COMMENT])
325 # -----------------------------
326 # Add leading comment marks to the start of each line, and a trailing
327 # full-stop to the whole comment if one is not present already.
328 m4_define([_LT_FORMAT_COMMENT],
329 [m4_ifval([$1], [
330 m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
331 [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
332 )])
333
334
335
336
337
338 # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
339 # -------------------------------------------------------------------
340 # CONFIGNAME is the name given to the value in the libtool script.
341 # VARNAME is the (base) name used in the configure script.
342 # VALUE may be 0, 1 or 2 for a computed quote escaped value based on
343 # VARNAME. Any other value will be used directly.
344 m4_define([_LT_DECL],
345 [lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
346 [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
347 [m4_ifval([$1], [$1], [$2])])
348 lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
349 m4_ifval([$4],
350 [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
351 lt_dict_add_subkey([lt_decl_dict], [$2],
352 [tagged?], [m4_ifval([$5], [yes], [no])])])
353 ])
354
355
356 # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
357 # --------------------------------------------------------
358 m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
359
360
361 # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
362 # ------------------------------------------------
363 m4_define([lt_decl_tag_varnames],
364 [_lt_decl_filter([tagged?], [yes], $@)])
365
366
367 # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
368 # ---------------------------------------------------------
369 m4_define([_lt_decl_filter],
370 [m4_case([$#],
371 [0], [m4_fatal([$0: too few arguments: $#])],
372 [1], [m4_fatal([$0: too few arguments: $#: $1])],
373 [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
374 [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
375 [lt_dict_filter([lt_decl_dict], $@)])[]dnl
376 ])
377
378
379 # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
380 # --------------------------------------------------
381 m4_define([lt_decl_quote_varnames],
382 [_lt_decl_filter([value], [1], $@)])
383
384
385 # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
386 # ---------------------------------------------------
387 m4_define([lt_decl_dquote_varnames],
388 [_lt_decl_filter([value], [2], $@)])
389
390
391 # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
392 # ---------------------------------------------------
393 m4_define([lt_decl_varnames_tagged],
394 [_$0(m4_quote(m4_default([$1], [[, ]])),
395 m4_quote(m4_if([$2], [],
396 m4_quote(lt_decl_tag_varnames),
397 m4_quote(m4_shift($@)))),
398 m4_split(m4_normalize(m4_quote(_LT_TAGS))))])
399 m4_define([_lt_decl_varnames_tagged], [lt_combine([$1], [$2], [_], $3)])
400
401
402 # lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
403 # ------------------------------------------------
404 m4_define([lt_decl_all_varnames],
405 [_$0(m4_quote(m4_default([$1], [[, ]])),
406 m4_if([$2], [],
407 m4_quote(lt_decl_varnames),
408 m4_quote(m4_shift($@))))[]dnl
409 ])
410 m4_define([_lt_decl_all_varnames],
411 [lt_join($@, lt_decl_varnames_tagged([$1],
412 lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
413 ])
414
415
416 # _LT_CONFIG_STATUS_DECLARE([VARNAME])
417 # ------------------------------------
418 # Quote a variable value, and forward it to `config.status' so that its
419 # declaration there will have the same value as in `configure'. VARNAME
420 # must have a single quote delimited value for this to work.
421 m4_define([_LT_CONFIG_STATUS_DECLARE],
422 [$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
423
424
425 # _LT_CONFIG_STATUS_DECLARATIONS
426 # ------------------------------
427 # We delimit libtool config variables with single quotes, so when
428 # we write them to config.status, we have to be sure to quote all
429 # embedded single quotes properly. In configure, this macro expands
430 # each variable declared with _LT_DECL (and _LT_TAGDECL) into:
431 #
432 # <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
433 m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
434 [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
435 [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
436
437
438 # _LT_LIBTOOL_TAGS
439 # ----------------
440 # Output comment and list of tags supported by the script
441 m4_defun([_LT_LIBTOOL_TAGS],
442 [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
443 available_tags="_LT_TAGS"dnl
444 ])
445
446
447 # _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
448 # -----------------------------------
449 # Extract the dictionary values for VARNAME (optionally with TAG) and
450 # expand to a commented shell variable setting:
451 #
452 # # Some comment about what VAR is for.
453 # visible_name=$lt_internal_name
454 m4_define([_LT_LIBTOOL_DECLARE],
455 [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
456 [description])))[]dnl
457 m4_pushdef([_libtool_name],
458 m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
459 m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
460 [0], [_libtool_name=[$]$1],
461 [1], [_libtool_name=$lt_[]$1],
462 [2], [_libtool_name=$lt_[]$1],
463 [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
464 m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
465 ])
466
467
468 # _LT_LIBTOOL_CONFIG_VARS
469 # -----------------------
470 # Produce commented declarations of non-tagged libtool config variables
471 # suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
472 # script. Tagged libtool config variables (even for the LIBTOOL CONFIG
473 # section) are produced by _LT_LIBTOOL_TAG_VARS.
474 m4_defun([_LT_LIBTOOL_CONFIG_VARS],
475 [m4_foreach([_lt_var],
476 m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
477 [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
478
479
480 # _LT_LIBTOOL_TAG_VARS(TAG)
481 # -------------------------
482 m4_define([_LT_LIBTOOL_TAG_VARS],
483 [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
484 [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
485
486
487 # _LT_TAGVAR(VARNAME, [TAGNAME])
488 # ------------------------------
489 m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
490
491
492 # _LT_CONFIG_COMMANDS
493 # -------------------
494 # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
495 # variables for single and double quote escaping we saved from calls
496 # to _LT_DECL, we can put quote escaped variables declarations
497 # into `config.status', and then the shell code to quote escape them in
498 # for loops in `config.status'. Finally, any additional code accumulated
499 # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
500 m4_defun([_LT_CONFIG_COMMANDS],
501 [AC_PROVIDE_IFELSE([LT_OUTPUT],
502 dnl If the libtool generation code has been placed in $CONFIG_LT,
503 dnl instead of duplicating it all over again into config.status,
504 dnl then we will have config.status run $CONFIG_LT later, so it
505 dnl needs to know what name is stored there:
506 [AC_CONFIG_COMMANDS([libtool],
507 [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
508 dnl If the libtool generation code is destined for config.status,
509 dnl expand the accumulated commands and init code now:
510 [AC_CONFIG_COMMANDS([libtool],
511 [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
512 ])#_LT_CONFIG_COMMANDS
513
514
515 # Initialize.
516 m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
517 [
518
519 # The HP-UX ksh and POSIX shell print the target directory to stdout
520 # if CDPATH is set.
521 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
522
523 sed_quote_subst='$sed_quote_subst'
524 double_quote_subst='$double_quote_subst'
525 delay_variable_subst='$delay_variable_subst'
526 _LT_CONFIG_STATUS_DECLARATIONS
527 LTCC='$LTCC'
528 LTCFLAGS='$LTCFLAGS'
529 compiler='$compiler_DEFAULT'
530
531 # Quote evaled strings.
532 for var in lt_decl_all_varnames([[ \
533 ]], lt_decl_quote_varnames); do
534 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
535 *[[\\\\\\\`\\"\\\$]]*)
536 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
537 ;;
538 *)
539 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
540 ;;
541 esac
542 done
543
544 # Double-quote double-evaled strings.
545 for var in lt_decl_all_varnames([[ \
546 ]], lt_decl_dquote_varnames); do
547 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
548 *[[\\\\\\\`\\"\\\$]]*)
549 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
550 ;;
551 *)
552 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
553 ;;
554 esac
555 done
556
557 # Fix-up fallback echo if it was mangled by the above quoting rules.
558 case \$lt_ECHO in
559 *'\\\[$]0 --fallback-echo"')dnl "
560 lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
561 ;;
562 esac
563
564 _LT_OUTPUT_LIBTOOL_INIT
565 ])
566
567
568 # LT_OUTPUT
569 # ---------
570 # This macro allows early generation of the libtool script (before
571 # AC_OUTPUT is called), incase it is used in configure for compilation
572 # tests.
573 AC_DEFUN([LT_OUTPUT],
574 [: ${CONFIG_LT=./config.lt}
575 AC_MSG_NOTICE([creating $CONFIG_LT])
576 cat >"$CONFIG_LT" <<_LTEOF
577 #! $SHELL
578 # Generated by $as_me.
579 # Run this file to recreate a libtool stub with the current configuration.
580
581 lt_cl_silent=false
582 SHELL=\${CONFIG_SHELL-$SHELL}
583 _LTEOF
584
585 cat >>"$CONFIG_LT" <<\_LTEOF
586 AS_SHELL_SANITIZE
587 _AS_PREPARE
588
589 exec AS_MESSAGE_FD>&1
590 exec AS_MESSAGE_LOG_FD>>config.log
591 {
592 echo
593 AS_BOX([Running $as_me.])
594 } >&AS_MESSAGE_LOG_FD
595
596 lt_cl_help="\
597 \`$as_me' creates a local libtool stub from the current configuration,
598 for use in further configure time tests before the real libtool is
599 generated.
600
601 Usage: $[0] [[OPTIONS]]
602
603 -h, --help print this help, then exit
604 -V, --version print version number, then exit
605 -q, --quiet do not print progress messages
606 -d, --debug don't remove temporary files
607
608 Report bugs to <bug-libtool@gnu.org>."
609
610 lt_cl_version="\
611 m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
612 m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
613 configured by $[0], generated by m4_PACKAGE_STRING.
614
615 Copyright (C) 2008 Free Software Foundation, Inc.
616 This config.lt script is free software; the Free Software Foundation
617 gives unlimited permision to copy, distribute and modify it."
618
619 while test $[#] != 0
620 do
621 case $[1] in
622 --version | --v* | -V )
623 echo "$lt_cl_version"; exit 0 ;;
624 --help | --h* | -h )
625 echo "$lt_cl_help"; exit 0 ;;
626 --debug | --d* | -d )
627 debug=: ;;
628 --quiet | --q* | --silent | --s* | -q )
629 lt_cl_silent=: ;;
630
631 -*) AC_MSG_ERROR([unrecognized option: $[1]
632 Try \`$[0] --help' for more information.]) ;;
633
634 *) AC_MSG_ERROR([unrecognized argument: $[1]
635 Try \`$[0] --help' for more information.]) ;;
636 esac
637 shift
638 done
639
640 if $lt_cl_silent; then
641 exec AS_MESSAGE_FD>/dev/null
642 fi
643 _LTEOF
644
645 cat >>"$CONFIG_LT" <<_LTEOF
646 _LT_OUTPUT_LIBTOOL_COMMANDS_INIT
647 _LTEOF
648
649 cat >>"$CONFIG_LT" <<\_LTEOF
650 AC_MSG_NOTICE([creating $ofile])
651 _LT_OUTPUT_LIBTOOL_COMMANDS
652 AS_EXIT(0)
653 _LTEOF
654 chmod +x "$CONFIG_LT"
655
656 # configure is writing to config.log, but config.lt does its own redirection,
657 # appending to config.log, which fails on DOS, as config.log is still kept
658 # open by configure. Here we exec the FD to /dev/null, effectively closing
659 # config.log, so it can be properly (re)opened and appended to by config.lt.
660 if test "$no_create" != yes; then
661 lt_cl_success=:
662 test "$silent" = yes &&
663 lt_config_lt_args="$lt_config_lt_args --quiet"
664 exec AS_MESSAGE_LOG_FD>/dev/null
665 $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
666 exec AS_MESSAGE_LOG_FD>>config.log
667 $lt_cl_success || AS_EXIT(1)
668 fi
669 ])# LT_OUTPUT
670
671
672 # _LT_CONFIG(TAG)
673 # ---------------
674 # If TAG is the built-in tag, create an initial libtool script with a
675 # default configuration from the untagged config vars. Otherwise add code
676 # to config.status for appending the configuration named by TAG from the
677 # matching tagged config vars.
678 m4_defun([_LT_CONFIG],
679 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
680 _LT_CONFIG_SAVE_COMMANDS([
681 m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
682 m4_if(_LT_TAG, [C], [
683 # See if we are running on zsh, and set the options which allow our
684 # commands through without removal of \ escapes.
685 if test -n "${ZSH_VERSION+set}" ; then
686 setopt NO_GLOB_SUBST
687 fi
688
689 cfgfile="${ofile}T"
690 trap "$RM -f \"$cfgfile\"; exit 1" 1 2 15
691 $RM -f "$cfgfile"
692
693 cat <<_LT_EOF >> "$cfgfile"
694 #! $SHELL
695
696 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
697 # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
698 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
699 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
700 #
701 _LT_COPYING
702 _LT_LIBTOOL_TAGS
703
704 # ### BEGIN LIBTOOL CONFIG
705 _LT_LIBTOOL_CONFIG_VARS
706 _LT_LIBTOOL_TAG_VARS
707 # ### END LIBTOOL CONFIG
708
709 _LT_EOF
710
711 case $host_os in
712 aix3*)
713 cat <<\_LT_EOF >> "$cfgfile"
714 # AIX sometimes has problems with the GCC collect2 program. For some
715 # reason, if we set the COLLECT_NAMES environment variable, the problems
716 # vanish in a puff of smoke.
717 if test "X${COLLECT_NAMES+set}" != Xset; then
718 COLLECT_NAMES=
719 export COLLECT_NAMES
720 fi
721 _LT_EOF
722 ;;
723 esac
724
725 _LT_PROG_LTMAIN
726
727 # We use sed instead of cat because bash on DJGPP gets confused if
728 # if finds mixed CR/LF and LF-only lines. Since sed operates in
729 # text mode, it properly converts lines to CR/LF. This bash problem
730 # is reportedly fixed, but why not run on old versions too?
731 sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
732 || (rm -f "$cfgfile"; exit 1)
733
734 _LT_PROG_XSI_SHELLFNS
735
736 sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
737 || (rm -f "$cfgfile"; exit 1)
738
739 mv -f "$cfgfile" "$ofile" ||
740 (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
741 chmod +x "$ofile"
742 ],
743 [cat <<_LT_EOF >> "$ofile"
744
745 dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
746 dnl in a comment (ie after a #).
747 # ### BEGIN LIBTOOL TAG CONFIG: $1
748 _LT_LIBTOOL_TAG_VARS(_LT_TAG)
749 # ### END LIBTOOL TAG CONFIG: $1
750 _LT_EOF
751 ])dnl /m4_if
752 ],
753 [m4_if([$1], [], [
754 PACKAGE='$PACKAGE'
755 VERSION='$VERSION'
756 TIMESTAMP='$TIMESTAMP'
757 RM='$RM'
758 ofile='$ofile'], [])
759 ])dnl /_LT_CONFIG_SAVE_COMMANDS
760 ])# _LT_CONFIG
761
762
763 # LT_SUPPORTED_TAG(TAG)
764 # ---------------------
765 # Trace this macro to discover what tags are supported by the libtool
766 # --tag option, using:
767 # autoconf --trace 'LT_SUPPORTED_TAG:$1'
768 AC_DEFUN([LT_SUPPORTED_TAG], [])
769
770
771 # C support is built-in for now
772 m4_define([_LT_LANG_C_enabled], [])
773 m4_define([_LT_TAGS], [])
774
775
776 # LT_LANG(LANG)
777 # -------------
778 # Enable libtool support for the given language if not already enabled.
779 AC_DEFUN([LT_LANG],
780 [AC_BEFORE([$0], [LT_OUTPUT])dnl
781 m4_case([$1],
782 [C], [_LT_LANG(C)],
783 [C++], [_LT_LANG(CXX)],
784 [Java], [_LT_LANG(GCJ)],
785 [Fortran 77], [_LT_LANG(F77)],
786 [Fortran], [_LT_LANG(FC)],
787 [Windows Resource], [_LT_LANG(RC)],
788 [m4_ifdef([_LT_LANG_]$1[_CONFIG],
789 [_LT_LANG($1)],
790 [m4_fatal([$0: unsupported language: "$1"])])])dnl
791 ])# LT_LANG
792
793
794 # _LT_LANG(LANGNAME)
795 # ------------------
796 m4_defun([_LT_LANG],
797 [m4_ifdef([_LT_LANG_]$1[_enabled], [],
798 [LT_SUPPORTED_TAG([$1])dnl
799 m4_append([_LT_TAGS], [$1 ])dnl
800 m4_define([_LT_LANG_]$1[_enabled], [])dnl
801 _LT_LANG_$1_CONFIG($1)])dnl
802 ])# _LT_LANG
803
804
805 # _LT_LANG_DEFAULT_CONFIG
806 # -----------------------
807 m4_defun([_LT_LANG_DEFAULT_CONFIG],
808 [AC_PROVIDE_IFELSE([AC_PROG_CXX],
809 [LT_LANG(CXX)],
810 [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
811
812 AC_PROVIDE_IFELSE([AC_PROG_F77],
813 [LT_LANG(F77)],
814 [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
815
816 AC_PROVIDE_IFELSE([AC_PROG_FC],
817 [LT_LANG(FC)],
818 [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
819
820 dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
821 dnl pulling things in needlessly.
822 AC_PROVIDE_IFELSE([AC_PROG_GCJ],
823 [LT_LANG(GCJ)],
824 [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
825 [LT_LANG(GCJ)],
826 [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
827 [LT_LANG(GCJ)],
828 [m4_ifdef([AC_PROG_GCJ],
829 [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
830 m4_ifdef([A][M_PROG_GCJ],
831 [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
832 m4_ifdef([LT_PROG_GCJ],
833 [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
834
835 AC_PROVIDE_IFELSE([LT_PROG_RC],
836 [LT_LANG(RC)],
837 [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
838 ])# _LT_LANG_DEFAULT_CONFIG
839
840 # Obsolete macros:
841 AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
842 AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
843 AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
844 AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
845 dnl aclocal-1.4 backwards compatibility:
846 dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
847 dnl AC_DEFUN([AC_LIBTOOL_F77], [])
848 dnl AC_DEFUN([AC_LIBTOOL_FC], [])
849 dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
850
851
852 # _LT_TAG_COMPILER
853 # ----------------
854 m4_defun([_LT_TAG_COMPILER],
855 [AC_REQUIRE([AC_PROG_CC])dnl
856
857 _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
858 _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
859 _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
860 _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
861
862 # If no C compiler was specified, use CC.
863 LTCC=${LTCC-"$CC"}
864
865 # If no C compiler flags were specified, use CFLAGS.
866 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
867
868 # Allow CC to be a program name with arguments.
869 compiler=$CC
870 ])# _LT_TAG_COMPILER
871
872
873 # _LT_COMPILER_BOILERPLATE
874 # ------------------------
875 # Check for compiler boilerplate output or warnings with
876 # the simple compiler test code.
877 m4_defun([_LT_COMPILER_BOILERPLATE],
878 [m4_require([_LT_DECL_SED])dnl
879 ac_outfile=conftest.$ac_objext
880 echo "$lt_simple_compile_test_code" >conftest.$ac_ext
881 eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
882 _lt_compiler_boilerplate=`cat conftest.err`
883 $RM -r conftest*
884 ])# _LT_COMPILER_BOILERPLATE
885
886
887 # _LT_LINKER_BOILERPLATE
888 # ----------------------
889 # Check for linker boilerplate output or warnings with
890 # the simple link test code.
891 m4_defun([_LT_LINKER_BOILERPLATE],
892 [m4_require([_LT_DECL_SED])dnl
893 ac_outfile=conftest.$ac_objext
894 echo "$lt_simple_link_test_code" >conftest.$ac_ext
895 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
896 _lt_linker_boilerplate=`cat conftest.err`
897 $RM -r conftest*
898 ])# _LT_LINKER_BOILERPLATE
899
900 # _LT_REQUIRED_DARWIN_CHECKS
901 # -------------------------
902 m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
903 case $host_os in
904 rhapsody* | darwin*)
905 AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
906 AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
907 AC_CHECK_TOOL([LIPO], [lipo], [:])
908 AC_CHECK_TOOL([OTOOL], [otool], [:])
909 AC_CHECK_TOOL([OTOOL64], [otool64], [:])
910 _LT_DECL([], [DSYMUTIL], [1],
911 [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
912 _LT_DECL([], [NMEDIT], [1],
913 [Tool to change global to local symbols on Mac OS X])
914 _LT_DECL([], [LIPO], [1],
915 [Tool to manipulate fat objects and archives on Mac OS X])
916 _LT_DECL([], [OTOOL], [1],
917 [ldd/readelf like tool for Mach-O binaries on Mac OS X])
918 _LT_DECL([], [OTOOL64], [1],
919 [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
920
921 AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
922 [lt_cv_apple_cc_single_mod=no
923 if test -z "${LT_MULTI_MODULE}"; then
924 # By default we will add the -single_module flag. You can override
925 # by either setting the environment variable LT_MULTI_MODULE
926 # non-empty at configure time, or by adding -multi_module to the
927 # link flags.
928 rm -rf libconftest.dylib*
929 echo "int foo(void){return 1;}" > conftest.c
930 echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
931 -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
932 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
933 -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
934 _lt_result=$?
935 if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
936 lt_cv_apple_cc_single_mod=yes
937 else
938 cat conftest.err >&AS_MESSAGE_LOG_FD
939 fi
940 rm -rf libconftest.dylib*
941 rm -f conftest.*
942 fi])
943 AC_CACHE_CHECK([for -exported_symbols_list linker flag],
944 [lt_cv_ld_exported_symbols_list],
945 [lt_cv_ld_exported_symbols_list=no
946 save_LDFLAGS=$LDFLAGS
947 echo "_main" > conftest.sym
948 LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
949 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
950 [lt_cv_ld_exported_symbols_list=yes],
951 [lt_cv_ld_exported_symbols_list=no])
952 LDFLAGS="$save_LDFLAGS"
953 ])
954 case $host_os in
955 rhapsody* | darwin1.[[012]])
956 _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
957 darwin1.*)
958 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
959 darwin*) # darwin 5.x on
960 # if running on 10.5 or later, the deployment target defaults
961 # to the OS version, if on x86, and 10.4, the deployment
962 # target defaults to 10.4. Don't you love it?
963 case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
964 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
965 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
966 10.[[012]]*)
967 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
968 10.*)
969 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
970 esac
971 ;;
972 esac
973 if test "$lt_cv_apple_cc_single_mod" = "yes"; then
974 _lt_dar_single_mod='$single_module'
975 fi
976 if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
977 _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
978 else
979 _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
980 fi
981 if test "$DSYMUTIL" != ":"; then
982 _lt_dsymutil='~$DSYMUTIL $lib || :'
983 else
984 _lt_dsymutil=
985 fi
986 ;;
987 esac
988 ])
989
990
991 # _LT_DARWIN_LINKER_FEATURES
992 # --------------------------
993 # Checks for linker and compiler features on darwin
994 m4_defun([_LT_DARWIN_LINKER_FEATURES],
995 [
996 m4_require([_LT_REQUIRED_DARWIN_CHECKS])
997 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
998 _LT_TAGVAR(hardcode_direct, $1)=no
999 _LT_TAGVAR(hardcode_automatic, $1)=yes
1000 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
1001 _LT_TAGVAR(whole_archive_flag_spec, $1)=''
1002 _LT_TAGVAR(link_all_deplibs, $1)=yes
1003 _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
1004 if test "$GCC" = "yes"; then
1005 output_verbose_link_cmd=echo
1006 _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
1007 _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
1008 _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
1009 _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
1010 m4_if([$1], [CXX],
1011 [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
1012 _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
1013 _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
1014 fi
1015 ],[])
1016 else
1017 _LT_TAGVAR(ld_shlibs, $1)=no
1018 fi
1019 ])
1020
1021 # _LT_SYS_MODULE_PATH_AIX
1022 # -----------------------
1023 # Links a minimal program and checks the executable
1024 # for the system default hardcoded library path. In most cases,
1025 # this is /usr/lib:/lib, but when the MPI compilers are used
1026 # the location of the communication and MPI libs are included too.
1027 # If we don't find anything, use the default library path according
1028 # to the aix ld manual.
1029 m4_defun([_LT_SYS_MODULE_PATH_AIX],
1030 [m4_require([_LT_DECL_SED])dnl
1031 AC_LINK_IFELSE(AC_LANG_PROGRAM,[
1032 lt_aix_libpath_sed='
1033 /Import File Strings/,/^$/ {
1034 /^0/ {
1035 s/^0 *\(.*\)$/\1/
1036 p
1037 }
1038 }'
1039 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
1040 # Check for a 64-bit object if we didn't find anything.
1041 if test -z "$aix_libpath"; then
1042 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
1043 fi],[])
1044 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
1045 ])# _LT_SYS_MODULE_PATH_AIX
1046
1047
1048 # _LT_SHELL_INIT(ARG)
1049 # -------------------
1050 m4_define([_LT_SHELL_INIT],
1051 [ifdef([AC_DIVERSION_NOTICE],
1052 [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
1053 [AC_DIVERT_PUSH(NOTICE)])
1054 $1
1055 AC_DIVERT_POP
1056 ])# _LT_SHELL_INIT
1057
1058
1059 # _LT_PROG_ECHO_BACKSLASH
1060 # -----------------------
1061 # Add some code to the start of the generated configure script which
1062 # will find an echo command which doesn't interpret backslashes.
1063 m4_defun([_LT_PROG_ECHO_BACKSLASH],
1064 [_LT_SHELL_INIT([
1065 # Check that we are running under the correct shell.
1066 SHELL=${CONFIG_SHELL-/bin/sh}
1067
1068 case X$lt_ECHO in
1069 X*--fallback-echo)
1070 # Remove one level of quotation (which was required for Make).
1071 ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
1072 ;;
1073 esac
1074
1075 ECHO=${lt_ECHO-echo}
1076 if test "X[$]1" = X--no-reexec; then
1077 # Discard the --no-reexec flag, and continue.
1078 shift
1079 elif test "X[$]1" = X--fallback-echo; then
1080 # Avoid inline document here, it may be left over
1081 :
1082 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
1083 # Yippee, $ECHO works!
1084 :
1085 else
1086 # Restart under the correct shell.
1087 exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
1088 fi
1089
1090 if test "X[$]1" = X--fallback-echo; then
1091 # used as fallback echo
1092 shift
1093 cat <<_LT_EOF
1094 [$]*
1095 _LT_EOF
1096 exit 0
1097 fi
1098
1099 # The HP-UX ksh and POSIX shell print the target directory to stdout
1100 # if CDPATH is set.
1101 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1102
1103 if test -z "$lt_ECHO"; then
1104 if test "X${echo_test_string+set}" != Xset; then
1105 # find a string as large as possible, as long as the shell can cope with it
1106 for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
1107 # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
1108 if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
1109 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
1110 then
1111 break
1112 fi
1113 done
1114 fi
1115
1116 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
1117 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
1118 test "X$echo_testing_string" = "X$echo_test_string"; then
1119 :
1120 else
1121 # The Solaris, AIX, and Digital Unix default echo programs unquote
1122 # backslashes. This makes it impossible to quote backslashes using
1123 # echo "$something" | sed 's/\\/\\\\/g'
1124 #
1125 # So, first we look for a working echo in the user's PATH.
1126
1127 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
1128 for dir in $PATH /usr/ucb; do
1129 IFS="$lt_save_ifs"
1130 if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
1131 test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
1132 echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
1133 test "X$echo_testing_string" = "X$echo_test_string"; then
1134 ECHO="$dir/echo"
1135 break
1136 fi
1137 done
1138 IFS="$lt_save_ifs"
1139
1140 if test "X$ECHO" = Xecho; then
1141 # We didn't find a better echo, so look for alternatives.
1142 if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
1143 echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
1144 test "X$echo_testing_string" = "X$echo_test_string"; then
1145 # This shell has a builtin print -r that does the trick.
1146 ECHO='print -r'
1147 elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
1148 test "X$CONFIG_SHELL" != X/bin/ksh; then
1149 # If we have ksh, try running configure again with it.
1150 ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
1151 export ORIGINAL_CONFIG_SHELL
1152 CONFIG_SHELL=/bin/ksh
1153 export CONFIG_SHELL
1154 exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
1155 else
1156 # Try using printf.
1157 ECHO='printf %s\n'
1158 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
1159 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
1160 test "X$echo_testing_string" = "X$echo_test_string"; then
1161 # Cool, printf works
1162 :
1163 elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
1164 test "X$echo_testing_string" = 'X\t' &&
1165 echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
1166 test "X$echo_testing_string" = "X$echo_test_string"; then
1167 CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
1168 export CONFIG_SHELL
1169 SHELL="$CONFIG_SHELL"
1170 export SHELL
1171 ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
1172 elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
1173 test "X$echo_testing_string" = 'X\t' &&
1174 echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
1175 test "X$echo_testing_string" = "X$echo_test_string"; then
1176 ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
1177 else
1178 # maybe with a smaller string...
1179 prev=:
1180
1181 for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
1182 if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
1183 then
1184 break
1185 fi
1186 prev="$cmd"
1187 done
1188
1189 if test "$prev" != 'sed 50q "[$]0"'; then
1190 echo_test_string=`eval $prev`
1191 export echo_test_string
1192 exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
1193 else
1194 # Oops. We lost completely, so just stick with echo.
1195 ECHO=echo
1196 fi
1197 fi
1198 fi
1199 fi
1200 fi
1201 fi
1202
1203 # Copy echo and quote the copy suitably for passing to libtool from
1204 # the Makefile, instead of quoting the original, which is used later.
1205 lt_ECHO=$ECHO
1206 if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
1207 lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
1208 fi
1209
1210 AC_SUBST(lt_ECHO)
1211 ])
1212 _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
1213 _LT_DECL([], [ECHO], [1],
1214 [An echo program that does not interpret backslashes])
1215 ])# _LT_PROG_ECHO_BACKSLASH
1216
1217
1218 # _LT_ENABLE_LOCK
1219 # ---------------
1220 m4_defun([_LT_ENABLE_LOCK],
1221 [AC_ARG_ENABLE([libtool-lock],
1222 [AS_HELP_STRING([--disable-libtool-lock],
1223 [avoid locking (might break parallel builds)])])
1224 test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
1225
1226 # Some flags need to be propagated to the compiler or linker for good
1227 # libtool support.
1228 case $host in
1229 ia64-*-hpux*)
1230 # Find out which ABI we are using.
1231 echo 'int i;' > conftest.$ac_ext
1232 if AC_TRY_EVAL(ac_compile); then
1233 case `/usr/bin/file conftest.$ac_objext` in
1234 *ELF-32*)
1235 HPUX_IA64_MODE="32"
1236 ;;
1237 *ELF-64*)
1238 HPUX_IA64_MODE="64"
1239 ;;
1240 esac
1241 fi
1242 rm -rf conftest*
1243 ;;
1244 *-*-irix6*)
1245 # Find out which ABI we are using.
1246 echo '[#]line __oline__ "configure"' > conftest.$ac_ext
1247 if AC_TRY_EVAL(ac_compile); then
1248 if test "$lt_cv_prog_gnu_ld" = yes; then
1249 case `/usr/bin/file conftest.$ac_objext` in
1250 *32-bit*)
1251 LD="${LD-ld} -melf32bsmip"
1252 ;;
1253 *N32*)
1254 LD="${LD-ld} -melf32bmipn32"
1255 ;;
1256 *64-bit*)
1257 LD="${LD-ld} -melf64bmip"
1258 ;;
1259 esac
1260 else
1261 case `/usr/bin/file conftest.$ac_objext` in
1262 *32-bit*)
1263 LD="${LD-ld} -32"
1264 ;;
1265 *N32*)
1266 LD="${LD-ld} -n32"
1267 ;;
1268 *64-bit*)
1269 LD="${LD-ld} -64"
1270 ;;
1271 esac
1272 fi
1273 fi
1274 rm -rf conftest*
1275 ;;
1276
1277 x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
1278 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
1279 # Find out which ABI we are using.
1280 echo 'int i;' > conftest.$ac_ext
1281 if AC_TRY_EVAL(ac_compile); then
1282 case `/usr/bin/file conftest.o` in
1283 *32-bit*)
1284 case $host in
1285 x86_64-*kfreebsd*-gnu)
1286 LD="${LD-ld} -m elf_i386_fbsd"
1287 ;;
1288 x86_64-*linux*)
1289 LD="${LD-ld} -m elf_i386"
1290 ;;
1291 ppc64-*linux*|powerpc64-*linux*)
1292 LD="${LD-ld} -m elf32ppclinux"
1293 ;;
1294 s390x-*linux*)
1295 LD="${LD-ld} -m elf_s390"
1296 ;;
1297 sparc64-*linux*)
1298 LD="${LD-ld} -m elf32_sparc"
1299 ;;
1300 esac
1301 ;;
1302 *64-bit*)
1303 case $host in
1304 x86_64-*kfreebsd*-gnu)
1305 LD="${LD-ld} -m elf_x86_64_fbsd"
1306 ;;
1307 x86_64-*linux*)
1308 LD="${LD-ld} -m elf_x86_64"
1309 ;;
1310 ppc*-*linux*|powerpc*-*linux*)
1311 LD="${LD-ld} -m elf64ppc"
1312 ;;
1313 s390*-*linux*|s390*-*tpf*)
1314 LD="${LD-ld} -m elf64_s390"
1315 ;;
1316 sparc*-*linux*)
1317 LD="${LD-ld} -m elf64_sparc"
1318 ;;
1319 esac
1320 ;;
1321 esac
1322 fi
1323 rm -rf conftest*
1324 ;;
1325
1326 *-*-sco3.2v5*)
1327 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
1328 SAVE_CFLAGS="$CFLAGS"
1329 CFLAGS="$CFLAGS -belf"
1330 AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
1331 [AC_LANG_PUSH(C)
1332 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
1333 AC_LANG_POP])
1334 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
1335 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
1336 CFLAGS="$SAVE_CFLAGS"
1337 fi
1338 ;;
1339 sparc*-*solaris*)
1340 # Find out which ABI we are using.
1341 echo 'int i;' > conftest.$ac_ext
1342 if AC_TRY_EVAL(ac_compile); then
1343 case `/usr/bin/file conftest.o` in
1344 *64-bit*)
1345 case $lt_cv_prog_gnu_ld in
1346 yes*) LD="${LD-ld} -m elf64_sparc" ;;
1347 *)
1348 if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
1349 LD="${LD-ld} -64"
1350 fi
1351 ;;
1352 esac
1353 ;;
1354 esac
1355 fi
1356 rm -rf conftest*
1357 ;;
1358 esac
1359
1360 need_locks="$enable_libtool_lock"
1361 ])# _LT_ENABLE_LOCK
1362
1363
1364 # _LT_CMD_OLD_ARCHIVE
1365 # -------------------
1366 m4_defun([_LT_CMD_OLD_ARCHIVE],
1367 [AC_CHECK_TOOL(AR, ar, false)
1368 test -z "$AR" && AR=ar
1369 test -z "$AR_FLAGS" && AR_FLAGS=cru
1370 _LT_DECL([], [AR], [1], [The archiver])
1371 _LT_DECL([], [AR_FLAGS], [1])
1372
1373 AC_CHECK_TOOL(STRIP, strip, :)
1374 test -z "$STRIP" && STRIP=:
1375 _LT_DECL([], [STRIP], [1], [A symbol stripping program])
1376
1377 AC_CHECK_TOOL(RANLIB, ranlib, :)
1378 test -z "$RANLIB" && RANLIB=:
1379 _LT_DECL([], [RANLIB], [1],
1380 [Commands used to install an old-style archive])
1381
1382 # Determine commands to create old-style static archives.
1383 old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
1384 old_postinstall_cmds='chmod 644 $oldlib'
1385 old_postuninstall_cmds=
1386
1387 if test -n "$RANLIB"; then
1388 case $host_os in
1389 openbsd*)
1390 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
1391 ;;
1392 *)
1393 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
1394 ;;
1395 esac
1396 old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
1397 fi
1398 _LT_DECL([], [old_postinstall_cmds], [2])
1399 _LT_DECL([], [old_postuninstall_cmds], [2])
1400 _LT_TAGDECL([], [old_archive_cmds], [2],
1401 [Commands used to build an old-style archive])
1402 ])# _LT_CMD_OLD_ARCHIVE
1403
1404
1405 # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
1406 # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
1407 # ----------------------------------------------------------------
1408 # Check whether the given compiler option works
1409 AC_DEFUN([_LT_COMPILER_OPTION],
1410 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1411 m4_require([_LT_DECL_SED])dnl
1412 AC_CACHE_CHECK([$1], [$2],
1413 [$2=no
1414 m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
1415 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
1416 lt_compiler_flag="$3"
1417 # Insert the option either (1) after the last *FLAGS variable, or
1418 # (2) before a word containing "conftest.", or (3) at the end.
1419 # Note that $ac_compile itself does not contain backslashes and begins
1420 # with a dollar sign (not a hyphen), so the echo should work correctly.
1421 # The option is referenced via a variable to avoid confusing sed.
1422 lt_compile=`echo "$ac_compile" | $SED \
1423 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1424 -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
1425 -e 's:$: $lt_compiler_flag:'`
1426 (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
1427 (eval "$lt_compile" 2>conftest.err)
1428 ac_status=$?
1429 cat conftest.err >&AS_MESSAGE_LOG_FD
1430 echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
1431 if (exit $ac_status) && test -s "$ac_outfile"; then
1432 # The compiler can only warn and ignore the option if not recognized
1433 # So say no if there are warnings other than the usual output.
1434 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
1435 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
1436 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
1437 $2=yes
1438 fi
1439 fi
1440 $RM -r conftest*
1441 ])
1442
1443 if test x"[$]$2" = xyes; then
1444 m4_if([$5], , :, [$5])
1445 else
1446 m4_if([$6], , :, [$6])
1447 fi
1448 ])# _LT_COMPILER_OPTION
1449
1450 # Old name:
1451 AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
1452 dnl aclocal-1.4 backwards compatibility:
1453 dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
1454
1455
1456 # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
1457 # [ACTION-SUCCESS], [ACTION-FAILURE])
1458 # ----------------------------------------------------
1459 # Check whether the given linker option works
1460 AC_DEFUN([_LT_LINKER_OPTION],
1461 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1462 m4_require([_LT_DECL_SED])dnl
1463 AC_CACHE_CHECK([$1], [$2],
1464 [$2=no
1465 save_LDFLAGS="$LDFLAGS"
1466 LDFLAGS="$LDFLAGS $3"
1467 echo "$lt_simple_link_test_code" > conftest.$ac_ext
1468 if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
1469 # The linker can only warn and ignore the option if not recognized
1470 # So say no if there are warnings
1471 if test -s conftest.err; then
1472 # Append any errors to the config.log.
1473 cat conftest.err 1>&AS_MESSAGE_LOG_FD
1474 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
1475 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
1476 if diff conftest.exp conftest.er2 >/dev/null; then
1477 $2=yes
1478 fi
1479 else
1480 $2=yes
1481 fi
1482 fi
1483 $RM -r conftest*
1484 LDFLAGS="$save_LDFLAGS"
1485 ])
1486
1487 if test x"[$]$2" = xyes; then
1488 m4_if([$4], , :, [$4])
1489 else
1490 m4_if([$5], , :, [$5])
1491 fi
1492 ])# _LT_LINKER_OPTION
1493
1494 # Old name:
1495 AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
1496 dnl aclocal-1.4 backwards compatibility:
1497 dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
1498
1499
1500 # LT_CMD_MAX_LEN
1501 #---------------
1502 AC_DEFUN([LT_CMD_MAX_LEN],
1503 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
1504 # find the maximum length of command line arguments
1505 AC_MSG_CHECKING([the maximum length of command line arguments])
1506 AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
1507 i=0
1508 teststring="ABCD"
1509
1510 case $build_os in
1511 msdosdjgpp*)
1512 # On DJGPP, this test can blow up pretty badly due to problems in libc
1513 # (any single argument exceeding 2000 bytes causes a buffer overrun
1514 # during glob expansion). Even if it were fixed, the result of this
1515 # check would be larger than it should be.
1516 lt_cv_sys_max_cmd_len=12288; # 12K is about right
1517 ;;
1518
1519 gnu*)
1520 # Under GNU Hurd, this test is not required because there is
1521 # no limit to the length of command line arguments.
1522 # Libtool will interpret -1 as no limit whatsoever
1523 lt_cv_sys_max_cmd_len=-1;
1524 ;;
1525
1526 cygwin* | mingw*)
1527 # On Win9x/ME, this test blows up -- it succeeds, but takes
1528 # about 5 minutes as the teststring grows exponentially.
1529 # Worse, since 9x/ME are not pre-emptively multitasking,
1530 # you end up with a "frozen" computer, even though with patience
1531 # the test eventually succeeds (with a max line length of 256k).
1532 # Instead, let's just punt: use the minimum linelength reported by
1533 # all of the supported platforms: 8192 (on NT/2K/XP).
1534 lt_cv_sys_max_cmd_len=8192;
1535 ;;
1536
1537 amigaos*)
1538 # On AmigaOS with pdksh, this test takes hours, literally.
1539 # So we just punt and use a minimum line length of 8192.
1540 lt_cv_sys_max_cmd_len=8192;
1541 ;;
1542
1543 netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
1544 # This has been around since 386BSD, at least. Likely further.
1545 if test -x /sbin/sysctl; then
1546 lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
1547 elif test -x /usr/sbin/sysctl; then
1548 lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
1549 else
1550 lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
1551 fi
1552 # And add a safety zone
1553 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
1554 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
1555 ;;
1556
1557 interix*)
1558 # We know the value 262144 and hardcode it with a safety zone (like BSD)
1559 lt_cv_sys_max_cmd_len=196608
1560 ;;
1561
1562 osf*)
1563 # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
1564 # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
1565 # nice to cause kernel panics so lets avoid the loop below.
1566 # First set a reasonable default.
1567 lt_cv_sys_max_cmd_len=16384
1568 #
1569 if test -x /sbin/sysconfig; then
1570 case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
1571 *1*) lt_cv_sys_max_cmd_len=-1 ;;
1572 esac
1573 fi
1574 ;;
1575 sco3.2v5*)
1576 lt_cv_sys_max_cmd_len=102400
1577 ;;
1578 sysv5* | sco5v6* | sysv4.2uw2*)
1579 kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
1580 if test -n "$kargmax"; then
1581 lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
1582 else
1583 lt_cv_sys_max_cmd_len=32768
1584 fi
1585 ;;
1586 *)
1587 lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
1588 if test -n "$lt_cv_sys_max_cmd_len"; then
1589 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
1590 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
1591 else
1592 # Make teststring a little bigger before we do anything with it.
1593 # a 1K string should be a reasonable start.
1594 for i in 1 2 3 4 5 6 7 8 ; do
1595 teststring=$teststring$teststring
1596 done
1597 SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
1598 # If test is not a shell built-in, we'll probably end up computing a
1599 # maximum length that is only half of the actual maximum length, but
1600 # we can't tell.
1601 while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
1602 = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
1603 test $i != 17 # 1/2 MB should be enough
1604 do
1605 i=`expr $i + 1`
1606 teststring=$teststring$teststring
1607 done
1608 # Only check the string length outside the loop.
1609 lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
1610 teststring=
1611 # Add a significant safety factor because C++ compilers can tack on
1612 # massive amounts of additional arguments before passing them to the
1613 # linker. It appears as though 1/2 is a usable value.
1614 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
1615 fi
1616 ;;
1617 esac
1618 ])
1619 if test -n $lt_cv_sys_max_cmd_len ; then
1620 AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
1621 else
1622 AC_MSG_RESULT(none)
1623 fi
1624 max_cmd_len=$lt_cv_sys_max_cmd_len
1625 _LT_DECL([], [max_cmd_len], [0],
1626 [What is the maximum length of a command?])
1627 ])# LT_CMD_MAX_LEN
1628
1629 # Old name:
1630 AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
1631 dnl aclocal-1.4 backwards compatibility:
1632 dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
1633
1634
1635 # _LT_HEADER_DLFCN
1636 # ----------------
1637 m4_defun([_LT_HEADER_DLFCN],
1638 [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
1639 ])# _LT_HEADER_DLFCN
1640
1641
1642 # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
1643 # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
1644 # ----------------------------------------------------------------
1645 m4_defun([_LT_TRY_DLOPEN_SELF],
1646 [m4_require([_LT_HEADER_DLFCN])dnl
1647 if test "$cross_compiling" = yes; then :
1648 [$4]
1649 else
1650 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1651 lt_status=$lt_dlunknown
1652 cat > conftest.$ac_ext <<_LT_EOF
1653 [#line __oline__ "configure"
1654 #include "confdefs.h"
1655
1656 #if HAVE_DLFCN_H
1657 #include <dlfcn.h>
1658 #endif
1659
1660 #include <stdio.h>
1661
1662 #ifdef RTLD_GLOBAL
1663 # define LT_DLGLOBAL RTLD_GLOBAL
1664 #else
1665 # ifdef DL_GLOBAL
1666 # define LT_DLGLOBAL DL_GLOBAL
1667 # else
1668 # define LT_DLGLOBAL 0
1669 # endif
1670 #endif
1671
1672 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
1673 find out it does not work in some platform. */
1674 #ifndef LT_DLLAZY_OR_NOW
1675 # ifdef RTLD_LAZY
1676 # define LT_DLLAZY_OR_NOW RTLD_LAZY
1677 # else
1678 # ifdef DL_LAZY
1679 # define LT_DLLAZY_OR_NOW DL_LAZY
1680 # else
1681 # ifdef RTLD_NOW
1682 # define LT_DLLAZY_OR_NOW RTLD_NOW
1683 # else
1684 # ifdef DL_NOW
1685 # define LT_DLLAZY_OR_NOW DL_NOW
1686 # else
1687 # define LT_DLLAZY_OR_NOW 0
1688 # endif
1689 # endif
1690 # endif
1691 # endif
1692 #endif
1693
1694 #ifdef __cplusplus
1695 extern "C" void exit (int);
1696 #endif
1697
1698 void fnord() { int i=42;}
1699 int main ()
1700 {
1701 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
1702 int status = $lt_dlunknown;
1703
1704 if (self)
1705 {
1706 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
1707 else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
1708 /* dlclose (self); */
1709 }
1710 else
1711 puts (dlerror ());
1712
1713 exit (status);
1714 }]
1715 _LT_EOF
1716 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
1717 (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
1718 lt_status=$?
1719 case x$lt_status in
1720 x$lt_dlno_uscore) $1 ;;
1721 x$lt_dlneed_uscore) $2 ;;
1722 x$lt_dlunknown|x*) $3 ;;
1723 esac
1724 else :
1725 # compilation failed
1726 $3
1727 fi
1728 fi
1729 rm -fr conftest*
1730 ])# _LT_TRY_DLOPEN_SELF
1731
1732
1733 # LT_SYS_DLOPEN_SELF
1734 # ------------------
1735 AC_DEFUN([LT_SYS_DLOPEN_SELF],
1736 [m4_require([_LT_HEADER_DLFCN])dnl
1737 if test "x$enable_dlopen" != xyes; then
1738 enable_dlopen=unknown
1739 enable_dlopen_self=unknown
1740 enable_dlopen_self_static=unknown
1741 else
1742 lt_cv_dlopen=no
1743 lt_cv_dlopen_libs=
1744
1745 case $host_os in
1746 beos*)
1747 lt_cv_dlopen="load_add_on"
1748 lt_cv_dlopen_libs=
1749 lt_cv_dlopen_self=yes
1750 ;;
1751
1752 mingw* | pw32*)
1753 lt_cv_dlopen="LoadLibrary"
1754 lt_cv_dlopen_libs=
1755 ;;
1756
1757 cygwin*)
1758 lt_cv_dlopen="dlopen"
1759 lt_cv_dlopen_libs=
1760 ;;
1761
1762 darwin*)
1763 # if libdl is installed we need to link against it
1764 AC_CHECK_LIB([dl], [dlopen],
1765 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
1766 lt_cv_dlopen="dyld"
1767 lt_cv_dlopen_libs=
1768 lt_cv_dlopen_self=yes
1769 ])
1770 ;;
1771
1772 *)
1773 AC_CHECK_FUNC([shl_load],
1774 [lt_cv_dlopen="shl_load"],
1775 [AC_CHECK_LIB([dld], [shl_load],
1776 [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
1777 [AC_CHECK_FUNC([dlopen],
1778 [lt_cv_dlopen="dlopen"],
1779 [AC_CHECK_LIB([dl], [dlopen],
1780 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
1781 [AC_CHECK_LIB([svld], [dlopen],
1782 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
1783 [AC_CHECK_LIB([dld], [dld_link],
1784 [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
1785 ])
1786 ])
1787 ])
1788 ])
1789 ])
1790 ;;
1791 esac
1792
1793 if test "x$lt_cv_dlopen" != xno; then
1794 enable_dlopen=yes
1795 else
1796 enable_dlopen=no
1797 fi
1798
1799 case $lt_cv_dlopen in
1800 dlopen)
1801 save_CPPFLAGS="$CPPFLAGS"
1802 test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
1803
1804 save_LDFLAGS="$LDFLAGS"
1805 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
1806
1807 save_LIBS="$LIBS"
1808 LIBS="$lt_cv_dlopen_libs $LIBS"
1809
1810 AC_CACHE_CHECK([whether a program can dlopen itself],
1811 lt_cv_dlopen_self, [dnl
1812 _LT_TRY_DLOPEN_SELF(
1813 lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
1814 lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
1815 ])
1816
1817 if test "x$lt_cv_dlopen_self" = xyes; then
1818 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
1819 AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
1820 lt_cv_dlopen_self_static, [dnl
1821 _LT_TRY_DLOPEN_SELF(
1822 lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
1823 lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
1824 ])
1825 fi
1826
1827 CPPFLAGS="$save_CPPFLAGS"
1828 LDFLAGS="$save_LDFLAGS"
1829 LIBS="$save_LIBS"
1830 ;;
1831 esac
1832
1833 case $lt_cv_dlopen_self in
1834 yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
1835 *) enable_dlopen_self=unknown ;;
1836 esac
1837
1838 case $lt_cv_dlopen_self_static in
1839 yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
1840 *) enable_dlopen_self_static=unknown ;;
1841 esac
1842 fi
1843 _LT_DECL([dlopen_support], [enable_dlopen], [0],
1844 [Whether dlopen is supported])
1845 _LT_DECL([dlopen_self], [enable_dlopen_self], [0],
1846 [Whether dlopen of programs is supported])
1847 _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
1848 [Whether dlopen of statically linked programs is supported])
1849 ])# LT_SYS_DLOPEN_SELF
1850
1851 # Old name:
1852 AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
1853 dnl aclocal-1.4 backwards compatibility:
1854 dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
1855
1856
1857 # _LT_COMPILER_C_O([TAGNAME])
1858 # ---------------------------
1859 # Check to see if options -c and -o are simultaneously supported by compiler.
1860 # This macro does not hard code the compiler like AC_PROG_CC_C_O.
1861 m4_defun([_LT_COMPILER_C_O],
1862 [m4_require([_LT_DECL_SED])dnl
1863 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1864 m4_require([_LT_TAG_COMPILER])dnl
1865 AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
1866 [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
1867 [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
1868 $RM -r conftest 2>/dev/null
1869 mkdir conftest
1870 cd conftest
1871 mkdir out
1872 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
1873
1874 lt_compiler_flag="-o out/conftest2.$ac_objext"
1875 # Insert the option either (1) after the last *FLAGS variable, or
1876 # (2) before a word containing "conftest.", or (3) at the end.
1877 # Note that $ac_compile itself does not contain backslashes and begins
1878 # with a dollar sign (not a hyphen), so the echo should work correctly.
1879 lt_compile=`echo "$ac_compile" | $SED \
1880 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
1881 -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
1882 -e 's:$: $lt_compiler_flag:'`
1883 (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
1884 (eval "$lt_compile" 2>out/conftest.err)
1885 ac_status=$?
1886 cat out/conftest.err >&AS_MESSAGE_LOG_FD
1887 echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
1888 if (exit $ac_status) && test -s out/conftest2.$ac_objext
1889 then
1890 # The compiler can only warn and ignore the option if not recognized
1891 # So say no if there are warnings
1892 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
1893 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
1894 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
1895 _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
1896 fi
1897 fi
1898 chmod u+w . 2>&AS_MESSAGE_LOG_FD
1899 $RM -r conftest*
1900 # SGI C++ compiler will create directory out/ii_files/ for
1901 # template instantiation
1902 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
1903 $RM out/* && rmdir out
1904 cd ..
1905 $RM -r conftest
1906 $RM -r conftest*
1907 ])
1908 _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
1909 [Does compiler simultaneously support -c and -o options?])
1910 ])# _LT_COMPILER_C_O
1911
1912
1913 # _LT_COMPILER_FILE_LOCKS([TAGNAME])
1914 # ----------------------------------
1915 # Check to see if we can do hard links to lock some files if needed
1916 m4_defun([_LT_COMPILER_FILE_LOCKS],
1917 [m4_require([_LT_ENABLE_LOCK])dnl
1918 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
1919 _LT_COMPILER_C_O([$1])
1920
1921 hard_links="nottested"
1922 if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
1923 # do not overwrite the value of need_locks provided by the user
1924 AC_MSG_CHECKING([if we can lock with hard links])
1925 hard_links=yes
1926 $RM -r conftest*
1927 ln conftest.a conftest.b 2>/dev/null && hard_links=no
1928 touch conftest.a
1929 ln conftest.a conftest.b 2>&5 || hard_links=no
1930 ln conftest.a conftest.b 2>/dev/null && hard_links=no
1931 AC_MSG_RESULT([$hard_links])
1932 if test "$hard_links" = no; then
1933 AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
1934 need_locks=warn
1935 fi
1936 else
1937 need_locks=no
1938 fi
1939 _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
1940 ])# _LT_COMPILER_FILE_LOCKS
1941
1942
1943 # _LT_CHECK_OBJDIR
1944 # ----------------
1945 m4_defun([_LT_CHECK_OBJDIR],
1946 [AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
1947 [rm -f .libs 2>/dev/null
1948 mkdir .libs 2>/dev/null
1949 if test -d .libs; then
1950 lt_cv_objdir=.libs
1951 else
1952 # MS-DOS does not allow filenames that begin with a dot.
1953 lt_cv_objdir=_libs
1954 fi
1955 rmdir .libs 2>/dev/null])
1956 objdir=$lt_cv_objdir
1957 _LT_DECL([], [objdir], [0],
1958 [The name of the directory that contains temporary libtool files])dnl
1959 m4_pattern_allow([LT_OBJDIR])dnl
1960 AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
1961 [Define to the sub-directory in which libtool stores uninstalled libraries.])
1962 ])# _LT_CHECK_OBJDIR
1963
1964
1965 # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
1966 # --------------------------------------
1967 # Check hardcoding attributes.
1968 m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
1969 [AC_MSG_CHECKING([how to hardcode library paths into programs])
1970 _LT_TAGVAR(hardcode_action, $1)=
1971 if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
1972 test -n "$_LT_TAGVAR(runpath_var, $1)" ||
1973 test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
1974
1975 # We can hardcode non-existent directories.
1976 if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
1977 # If the only mechanism to avoid hardcoding is shlibpath_var, we
1978 # have to relink, otherwise we might link with an installed library
1979 # when we should be linking with a yet-to-be-installed one
1980 ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
1981 test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
1982 # Linking always hardcodes the temporary library directory.
1983 _LT_TAGVAR(hardcode_action, $1)=relink
1984 else
1985 # We can link without hardcoding, and we can hardcode nonexisting dirs.
1986 _LT_TAGVAR(hardcode_action, $1)=immediate
1987 fi
1988 else
1989 # We cannot hardcode anything, or else we can only hardcode existing
1990 # directories.
1991 _LT_TAGVAR(hardcode_action, $1)=unsupported
1992 fi
1993 AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
1994
1995 if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
1996 test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
1997 # Fast installation is not supported
1998 enable_fast_install=no
1999 elif test "$shlibpath_overrides_runpath" = yes ||
2000 test "$enable_shared" = no; then
2001 # Fast installation is not necessary
2002 enable_fast_install=needless
2003 fi
2004 _LT_TAGDECL([], [hardcode_action], [0],
2005 [How to hardcode a shared library path into an executable])
2006 ])# _LT_LINKER_HARDCODE_LIBPATH
2007
2008
2009 # _LT_CMD_STRIPLIB
2010 # ----------------
2011 m4_defun([_LT_CMD_STRIPLIB],
2012 [m4_require([_LT_DECL_EGREP])
2013 striplib=
2014 old_striplib=
2015 AC_MSG_CHECKING([whether stripping libraries is possible])
2016 if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
2017 test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
2018 test -z "$striplib" && striplib="$STRIP --strip-unneeded"
2019 AC_MSG_RESULT([yes])
2020 else
2021 # FIXME - insert some real tests, host_os isn't really good enough
2022 case $host_os in
2023 darwin*)
2024 if test -n "$STRIP" ; then
2025 striplib="$STRIP -x"
2026 old_striplib="$STRIP -S"
2027 AC_MSG_RESULT([yes])
2028 else
2029 AC_MSG_RESULT([no])
2030 fi
2031 ;;
2032 *)
2033 AC_MSG_RESULT([no])
2034 ;;
2035 esac
2036 fi
2037 _LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
2038 _LT_DECL([], [striplib], [1])
2039 ])# _LT_CMD_STRIPLIB
2040
2041
2042 # _LT_SYS_DYNAMIC_LINKER([TAG])
2043 # -----------------------------
2044 # PORTME Fill in your ld.so characteristics
2045 m4_defun([_LT_SYS_DYNAMIC_LINKER],
2046 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
2047 m4_require([_LT_DECL_EGREP])dnl
2048 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
2049 m4_require([_LT_DECL_SED])dnl
2050 AC_MSG_CHECKING([dynamic linker characteristics])
2051 m4_if([$1],
2052 [], [
2053 if test "$GCC" = yes; then
2054 case $host_os in
2055 darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
2056 *) lt_awk_arg="/^libraries:/" ;;
2057 esac
2058 lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
2059 if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
2060 # if the path contains ";" then we assume it to be the separator
2061 # otherwise default to the standard path separator (i.e. ":") - it is
2062 # assumed that no part of a normal pathname contains ";" but that should
2063 # okay in the real world where ";" in dirpaths is itself problematic.
2064 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
2065 else
2066 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
2067 fi
2068 # Ok, now we have the path, separated by spaces, we can step through it
2069 # and add multilib dir if necessary.
2070 lt_tmp_lt_search_path_spec=
2071 lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
2072 for lt_sys_path in $lt_search_path_spec; do
2073 if test -d "$lt_sys_path/$lt_multi_os_dir"; then
2074 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
2075 else
2076 test -d "$lt_sys_path" && \
2077 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
2078 fi
2079 done
2080 lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
2081 BEGIN {RS=" "; FS="/|\n";} {
2082 lt_foo="";
2083 lt_count=0;
2084 for (lt_i = NF; lt_i > 0; lt_i--) {
2085 if ($lt_i != "" && $lt_i != ".") {
2086 if ($lt_i == "..") {
2087 lt_count++;
2088 } else {
2089 if (lt_count == 0) {
2090 lt_foo="/" $lt_i lt_foo;
2091 } else {
2092 lt_count--;
2093 }
2094 }
2095 }
2096 }
2097 if (lt_foo != "") { lt_freq[[lt_foo]]++; }
2098 if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
2099 }'`
2100 sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
2101 else
2102 sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
2103 fi])
2104 library_names_spec=
2105 libname_spec='lib$name'
2106 soname_spec=
2107 shrext_cmds=".so"
2108 postinstall_cmds=
2109 postuninstall_cmds=
2110 finish_cmds=
2111 finish_eval=
2112 shlibpath_var=
2113 shlibpath_overrides_runpath=unknown
2114 version_type=none
2115 dynamic_linker="$host_os ld.so"
2116 sys_lib_dlsearch_path_spec="/lib /usr/lib"
2117 need_lib_prefix=unknown
2118 hardcode_into_libs=no
2119
2120 # when you set need_version to no, make sure it does not cause -set_version
2121 # flags to be left without arguments
2122 need_version=unknown
2123
2124 case $host_os in
2125 aix3*)
2126 version_type=linux
2127 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
2128 shlibpath_var=LIBPATH
2129
2130 # AIX 3 has no versioning support, so we append a major version to the name.
2131 soname_spec='${libname}${release}${shared_ext}$major'
2132 ;;
2133
2134 aix[[4-9]]*)
2135 version_type=linux
2136 need_lib_prefix=no
2137 need_version=no
2138 hardcode_into_libs=yes
2139 if test "$host_cpu" = ia64; then
2140 # AIX 5 supports IA64
2141 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
2142 shlibpath_var=LD_LIBRARY_PATH
2143 else
2144 # With GCC up to 2.95.x, collect2 would create an import file
2145 # for dependence libraries. The import file would start with
2146 # the line `#! .'. This would cause the generated library to
2147 # depend on `.', always an invalid library. This was fixed in
2148 # development snapshots of GCC prior to 3.0.
2149 case $host_os in
2150 aix4 | aix4.[[01]] | aix4.[[01]].*)
2151 if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
2152 echo ' yes '
2153 echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
2154 :
2155 else
2156 can_build_shared=no
2157 fi
2158 ;;
2159 esac
2160 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
2161 # soname into executable. Probably we can add versioning support to
2162 # collect2, so additional links can be useful in future.
2163 if test "$aix_use_runtimelinking" = yes; then
2164 # If using run time linking (on AIX 4.2 or later) use lib<name>.so
2165 # instead of lib<name>.a to let people know that these are not
2166 # typical AIX shared libraries.
2167 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2168 else
2169 # We preserve .a as extension for shared libraries through AIX4.2
2170 # and later when we are not doing run time linking.
2171 library_names_spec='${libname}${release}.a $libname.a'
2172 soname_spec='${libname}${release}${shared_ext}$major'
2173 fi
2174 shlibpath_var=LIBPATH
2175 fi
2176 ;;
2177
2178 amigaos*)
2179 case $host_cpu in
2180 powerpc)
2181 # Since July 2007 AmigaOS4 officially supports .so libraries.
2182 # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
2183 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2184 ;;
2185 m68k)
2186 library_names_spec='$libname.ixlibrary $libname.a'
2187 # Create ${libname}_ixlibrary.a entries in /sys/libs.
2188 finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
2189 ;;
2190 esac
2191 ;;
2192
2193 beos*)
2194 library_names_spec='${libname}${shared_ext}'
2195 dynamic_linker="$host_os ld.so"
2196 shlibpath_var=LIBRARY_PATH
2197 ;;
2198
2199 bsdi[[45]]*)
2200 version_type=linux
2201 need_version=no
2202 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2203 soname_spec='${libname}${release}${shared_ext}$major'
2204 finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
2205 shlibpath_var=LD_LIBRARY_PATH
2206 sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
2207 sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
2208 # the default ld.so.conf also contains /usr/contrib/lib and
2209 # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
2210 # libtool to hard-code these into programs
2211 ;;
2212
2213 cygwin* | mingw* | pw32*)
2214 version_type=windows
2215 shrext_cmds=".dll"
2216 need_version=no
2217 need_lib_prefix=no
2218
2219 case $GCC,$host_os in
2220 yes,cygwin* | yes,mingw* | yes,pw32*)
2221 library_names_spec='$libname.dll.a'
2222 # DLL is installed to $(libdir)/../bin by postinstall_cmds
2223 postinstall_cmds='base_file=`basename \${file}`~
2224 dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
2225 dldir=$destdir/`dirname \$dlpath`~
2226 test -d \$dldir || mkdir -p \$dldir~
2227 $install_prog $dir/$dlname \$dldir/$dlname~
2228 chmod a+x \$dldir/$dlname~
2229 if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
2230 eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
2231 fi'
2232 postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
2233 dlpath=$dir/\$dldll~
2234 $RM \$dlpath'
2235 shlibpath_overrides_runpath=yes
2236
2237 case $host_os in
2238 cygwin*)
2239 # Cygwin DLLs use 'cyg' prefix rather than 'lib'
2240 soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2241 sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
2242 ;;
2243 mingw*)
2244 # MinGW DLLs use traditional 'lib' prefix
2245 soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2246 sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
2247 if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
2248 # It is most probably a Windows format PATH printed by
2249 # mingw gcc, but we are running on Cygwin. Gcc prints its search
2250 # path with ; separators, and with drive letters. We can handle the
2251 # drive letters (cygwin fileutils understands them), so leave them,
2252 # especially as we might pass files found there to a mingw objdump,
2253 # which wouldn't understand a cygwinified path. Ahh.
2254 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
2255 else
2256 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
2257 fi
2258 ;;
2259 pw32*)
2260 # pw32 DLLs use 'pw' prefix rather than 'lib'
2261 library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
2262 ;;
2263 esac
2264 ;;
2265
2266 *)
2267 library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
2268 ;;
2269 esac
2270 dynamic_linker='Win32 ld.exe'
2271 # FIXME: first we should search . and the directory the executable is in
2272 shlibpath_var=PATH
2273 ;;
2274
2275 darwin* | rhapsody*)
2276 dynamic_linker="$host_os dyld"
2277 version_type=darwin
2278 need_lib_prefix=no
2279 need_version=no
2280 library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext ${libname}${release}${versuffix}$shared_ext'
2281 soname_spec='${libname}${release}${major}$shared_ext'
2282 shlibpath_overrides_runpath=yes
2283 shlibpath_var=DYLD_LIBRARY_PATH
2284 shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
2285 m4_if([$1], [],[
2286 sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
2287 sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
2288 ;;
2289
2290 dgux*)
2291 version_type=linux
2292 need_lib_prefix=no
2293 need_version=no
2294 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
2295 soname_spec='${libname}${release}${shared_ext}$major'
2296 shlibpath_var=LD_LIBRARY_PATH
2297 ;;
2298
2299 freebsd1*)
2300 dynamic_linker=no
2301 ;;
2302
2303 freebsd* | dragonfly*)
2304 # DragonFly does not have aout. When/if they implement a new
2305 # versioning mechanism, adjust this.
2306 if test -x /usr/bin/objformat; then
2307 objformat=`/usr/bin/objformat`
2308 else
2309 case $host_os in
2310 freebsd[[123]]*) objformat=aout ;;
2311 *) objformat=elf ;;
2312 esac
2313 fi
2314 version_type=freebsd-$objformat
2315 case $version_type in
2316 freebsd-elf*)
2317 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
2318 need_version=no
2319 need_lib_prefix=no
2320 ;;
2321 freebsd-*)
2322 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
2323 need_version=yes
2324 ;;
2325 esac
2326 shlibpath_var=LD_LIBRARY_PATH
2327 case $host_os in
2328 freebsd2*)
2329 shlibpath_overrides_runpath=yes
2330 ;;
2331 freebsd3.[[01]]* | freebsdelf3.[[01]]*)
2332 shlibpath_overrides_runpath=yes
2333 hardcode_into_libs=yes
2334 ;;
2335 freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
2336 freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
2337 shlibpath_overrides_runpath=no
2338 hardcode_into_libs=yes
2339 ;;
2340 *) # from 4.6 on, and DragonFly
2341 shlibpath_overrides_runpath=yes
2342 hardcode_into_libs=yes
2343 ;;
2344 esac
2345 ;;
2346
2347 gnu*)
2348 version_type=linux
2349 need_lib_prefix=no
2350 need_version=no
2351 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
2352 soname_spec='${libname}${release}${shared_ext}$major'
2353 shlibpath_var=LD_LIBRARY_PATH
2354 hardcode_into_libs=yes
2355 ;;
2356
2357 hpux9* | hpux10* | hpux11*)
2358 # Give a soname corresponding to the major version so that dld.sl refuses to
2359 # link against other versions.
2360 version_type=sunos
2361 need_lib_prefix=no
2362 need_version=no
2363 case $host_cpu in
2364 ia64*)
2365 shrext_cmds='.so'
2366 hardcode_into_libs=yes
2367 dynamic_linker="$host_os dld.so"
2368 shlibpath_var=LD_LIBRARY_PATH
2369 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
2370 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2371 soname_spec='${libname}${release}${shared_ext}$major'
2372 if test "X$HPUX_IA64_MODE" = X32; then
2373 sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
2374 else
2375 sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
2376 fi
2377 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
2378 ;;
2379 hppa*64*)
2380 shrext_cmds='.sl'
2381 hardcode_into_libs=yes
2382 dynamic_linker="$host_os dld.sl"
2383 shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
2384 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
2385 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2386 soname_spec='${libname}${release}${shared_ext}$major'
2387 sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
2388 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
2389 ;;
2390 *)
2391 shrext_cmds='.sl'
2392 dynamic_linker="$host_os dld.sl"
2393 shlibpath_var=SHLIB_PATH
2394 shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
2395 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2396 soname_spec='${libname}${release}${shared_ext}$major'
2397 ;;
2398 esac
2399 # HP-UX runs *really* slowly unless shared libraries are mode 555.
2400 postinstall_cmds='chmod 555 $lib'
2401 ;;
2402
2403 interix[[3-9]]*)
2404 version_type=linux
2405 need_lib_prefix=no
2406 need_version=no
2407 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
2408 soname_spec='${libname}${release}${shared_ext}$major'
2409 dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
2410 shlibpath_var=LD_LIBRARY_PATH
2411 shlibpath_overrides_runpath=no
2412 hardcode_into_libs=yes
2413 ;;
2414
2415 irix5* | irix6* | nonstopux*)
2416 case $host_os in
2417 nonstopux*) version_type=nonstopux ;;
2418 *)
2419 if test "$lt_cv_prog_gnu_ld" = yes; then
2420 version_type=linux
2421 else
2422 version_type=irix
2423 fi ;;
2424 esac
2425 need_lib_prefix=no
2426 need_version=no
2427 soname_spec='${libname}${release}${shared_ext}$major'
2428 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
2429 case $host_os in
2430 irix5* | nonstopux*)
2431 libsuff= shlibsuff=
2432 ;;
2433 *)
2434 case $LD in # libtool.m4 will add one of these switches to LD
2435 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
2436 libsuff= shlibsuff= libmagic=32-bit;;
2437 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
2438 libsuff=32 shlibsuff=N32 libmagic=N32;;
2439 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
2440 libsuff=64 shlibsuff=64 libmagic=64-bit;;
2441 *) libsuff= shlibsuff= libmagic=never-match;;
2442 esac
2443 ;;
2444 esac
2445 shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
2446 shlibpath_overrides_runpath=no
2447 sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
2448 sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
2449 hardcode_into_libs=yes
2450 ;;
2451
2452 # No shared lib support for Linux oldld, aout, or coff.
2453 linux*oldld* | linux*aout* | linux*coff*)
2454 dynamic_linker=no
2455 ;;
2456
2457 # This must be Linux ELF.
2458 linux* | k*bsd*-gnu)
2459 version_type=linux
2460 need_lib_prefix=no
2461 need_version=no
2462 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2463 soname_spec='${libname}${release}${shared_ext}$major'
2464 finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
2465 shlibpath_var=LD_LIBRARY_PATH
2466 shlibpath_overrides_runpath=no
2467 # Some binutils ld are patched to set DT_RUNPATH
2468 save_LDFLAGS=$LDFLAGS
2469 save_libdir=$libdir
2470 eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
2471 LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
2472 AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
2473 [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
2474 [shlibpath_overrides_runpath=yes])])
2475 LDFLAGS=$save_LDFLAGS
2476 libdir=$save_libdir
2477
2478 # This implies no fast_install, which is unacceptable.
2479 # Some rework will be needed to allow for fast_install
2480 # before this can be enabled.
2481 hardcode_into_libs=yes
2482
2483 # Append ld.so.conf contents to the search path
2484 if test -f /etc/ld.so.conf; then
2485 lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
2486 sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
2487 fi
2488
2489 # We used to test for /lib/ld.so.1 and disable shared libraries on
2490 # powerpc, because MkLinux only supported shared libraries with the
2491 # GNU dynamic linker. Since this was broken with cross compilers,
2492 # most powerpc-linux boxes support dynamic linking these days and
2493 # people can always --disable-shared, the test was removed, and we
2494 # assume the GNU/Linux dynamic linker is in use.
2495 dynamic_linker='GNU/Linux ld.so'
2496 ;;
2497
2498 netbsd*)
2499 version_type=sunos
2500 need_lib_prefix=no
2501 need_version=no
2502 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
2503 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2504 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
2505 dynamic_linker='NetBSD (a.out) ld.so'
2506 else
2507 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
2508 soname_spec='${libname}${release}${shared_ext}$major'
2509 dynamic_linker='NetBSD ld.elf_so'
2510 fi
2511 shlibpath_var=LD_LIBRARY_PATH
2512 shlibpath_overrides_runpath=yes
2513 hardcode_into_libs=yes
2514 ;;
2515
2516 newsos6)
2517 version_type=linux
2518 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2519 shlibpath_var=LD_LIBRARY_PATH
2520 shlibpath_overrides_runpath=yes
2521 ;;
2522
2523 *nto* | *qnx*)
2524 version_type=qnx
2525 need_lib_prefix=no
2526 need_version=no
2527 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2528 soname_spec='${libname}${release}${shared_ext}$major'
2529 shlibpath_var=LD_LIBRARY_PATH
2530 shlibpath_overrides_runpath=no
2531 hardcode_into_libs=yes
2532 dynamic_linker='ldqnx.so'
2533 ;;
2534
2535 openbsd*)
2536 version_type=sunos
2537 sys_lib_dlsearch_path_spec="/usr/lib"
2538 need_lib_prefix=no
2539 # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
2540 case $host_os in
2541 openbsd3.3 | openbsd3.3.*) need_version=yes ;;
2542 *) need_version=no ;;
2543 esac
2544 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2545 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
2546 shlibpath_var=LD_LIBRARY_PATH
2547 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
2548 case $host_os in
2549 openbsd2.[[89]] | openbsd2.[[89]].*)
2550 shlibpath_overrides_runpath=no
2551 ;;
2552 *)
2553 shlibpath_overrides_runpath=yes
2554 ;;
2555 esac
2556 else
2557 shlibpath_overrides_runpath=yes
2558 fi
2559 ;;
2560
2561 os2*)
2562 libname_spec='$name'
2563 shrext_cmds=".dll"
2564 need_lib_prefix=no
2565 library_names_spec='$libname${shared_ext} $libname.a'
2566 dynamic_linker='OS/2 ld.exe'
2567 shlibpath_var=LIBPATH
2568 ;;
2569
2570 osf3* | osf4* | osf5*)
2571 version_type=osf
2572 need_lib_prefix=no
2573 need_version=no
2574 soname_spec='${libname}${release}${shared_ext}$major'
2575 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2576 shlibpath_var=LD_LIBRARY_PATH
2577 sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
2578 sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
2579 ;;
2580
2581 rdos*)
2582 dynamic_linker=no
2583 ;;
2584
2585 solaris*)
2586 version_type=linux
2587 need_lib_prefix=no
2588 need_version=no
2589 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2590 soname_spec='${libname}${release}${shared_ext}$major'
2591 shlibpath_var=LD_LIBRARY_PATH
2592 shlibpath_overrides_runpath=yes
2593 hardcode_into_libs=yes
2594 # ldd complains unless libraries are executable
2595 postinstall_cmds='chmod +x $lib'
2596 ;;
2597
2598 sunos4*)
2599 version_type=sunos
2600 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
2601 finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
2602 shlibpath_var=LD_LIBRARY_PATH
2603 shlibpath_overrides_runpath=yes
2604 if test "$with_gnu_ld" = yes; then
2605 need_lib_prefix=no
2606 fi
2607 need_version=yes
2608 ;;
2609
2610 sysv4 | sysv4.3*)
2611 version_type=linux
2612 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2613 soname_spec='${libname}${release}${shared_ext}$major'
2614 shlibpath_var=LD_LIBRARY_PATH
2615 case $host_vendor in
2616 sni)
2617 shlibpath_overrides_runpath=no
2618 need_lib_prefix=no
2619 runpath_var=LD_RUN_PATH
2620 ;;
2621 siemens)
2622 need_lib_prefix=no
2623 ;;
2624 motorola)
2625 need_lib_prefix=no
2626 need_version=no
2627 shlibpath_overrides_runpath=no
2628 sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
2629 ;;
2630 esac
2631 ;;
2632
2633 sysv4*MP*)
2634 if test -d /usr/nec ;then
2635 version_type=linux
2636 library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
2637 soname_spec='$libname${shared_ext}.$major'
2638 shlibpath_var=LD_LIBRARY_PATH
2639 fi
2640 ;;
2641
2642 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
2643 version_type=freebsd-elf
2644 need_lib_prefix=no
2645 need_version=no
2646 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
2647 soname_spec='${libname}${release}${shared_ext}$major'
2648 shlibpath_var=LD_LIBRARY_PATH
2649 shlibpath_overrides_runpath=yes
2650 hardcode_into_libs=yes
2651 if test "$with_gnu_ld" = yes; then
2652 sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
2653 else
2654 sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
2655 case $host_os in
2656 sco3.2v5*)
2657 sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
2658 ;;
2659 esac
2660 fi
2661 sys_lib_dlsearch_path_spec='/usr/lib'
2662 ;;
2663
2664 tpf*)
2665 # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
2666 version_type=linux
2667 need_lib_prefix=no
2668 need_version=no
2669 library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2670 shlibpath_var=LD_LIBRARY_PATH
2671 shlibpath_overrides_runpath=no
2672 hardcode_into_libs=yes
2673 ;;
2674
2675 uts4*)
2676 version_type=linux
2677 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
2678 soname_spec='${libname}${release}${shared_ext}$major'
2679 shlibpath_var=LD_LIBRARY_PATH
2680 ;;
2681
2682 *)
2683 dynamic_linker=no
2684 ;;
2685 esac
2686 AC_MSG_RESULT([$dynamic_linker])
2687 test "$dynamic_linker" = no && can_build_shared=no
2688
2689 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
2690 if test "$GCC" = yes; then
2691 variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
2692 fi
2693
2694 if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
2695 sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
2696 fi
2697 if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
2698 sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
2699 fi
2700
2701 _LT_DECL([], [variables_saved_for_relink], [1],
2702 [Variables whose values should be saved in libtool wrapper scripts and
2703 restored at link time])
2704 _LT_DECL([], [need_lib_prefix], [0],
2705 [Do we need the "lib" prefix for modules?])
2706 _LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
2707 _LT_DECL([], [version_type], [0], [Library versioning type])
2708 _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
2709 _LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
2710 _LT_DECL([], [shlibpath_overrides_runpath], [0],
2711 [Is shlibpath searched before the hard-coded library search path?])
2712 _LT_DECL([], [libname_spec], [1], [Format of library name prefix])
2713 _LT_DECL([], [library_names_spec], [1],
2714 [[List of archive names. First name is the real one, the rest are links.
2715 The last name is the one that the linker finds with -lNAME]])
2716 _LT_DECL([], [soname_spec], [1],
2717 [[The coded name of the library, if different from the real name]])
2718 _LT_DECL([], [postinstall_cmds], [2],
2719 [Command to use after installation of a shared archive])
2720 _LT_DECL([], [postuninstall_cmds], [2],
2721 [Command to use after uninstallation of a shared archive])
2722 _LT_DECL([], [finish_cmds], [2],
2723 [Commands used to finish a libtool library installation in a directory])
2724 _LT_DECL([], [finish_eval], [1],
2725 [[As "finish_cmds", except a single script fragment to be evaled but
2726 not shown]])
2727 _LT_DECL([], [hardcode_into_libs], [0],
2728 [Whether we should hardcode library paths into libraries])
2729 _LT_DECL([], [sys_lib_search_path_spec], [2],
2730 [Compile-time system search path for libraries])
2731 _LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
2732 [Run-time system search path for libraries])
2733 ])# _LT_SYS_DYNAMIC_LINKER
2734
2735
2736 # _LT_PATH_TOOL_PREFIX(TOOL)
2737 # --------------------------
2738 # find a file program which can recognize shared library
2739 AC_DEFUN([_LT_PATH_TOOL_PREFIX],
2740 [m4_require([_LT_DECL_EGREP])dnl
2741 AC_MSG_CHECKING([for $1])
2742 AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
2743 [case $MAGIC_CMD in
2744 [[\\/*] | ?:[\\/]*])
2745 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
2746 ;;
2747 *)
2748 lt_save_MAGIC_CMD="$MAGIC_CMD"
2749 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
2750 dnl $ac_dummy forces splitting on constant user-supplied paths.
2751 dnl POSIX.2 word splitting is done only on the output of word expansions,
2752 dnl not every word. This closes a longstanding sh security hole.
2753 ac_dummy="m4_if([$2], , $PATH, [$2])"
2754 for ac_dir in $ac_dummy; do
2755 IFS="$lt_save_ifs"
2756 test -z "$ac_dir" && ac_dir=.
2757 if test -f $ac_dir/$1; then
2758 lt_cv_path_MAGIC_CMD="$ac_dir/$1"
2759 if test -n "$file_magic_test_file"; then
2760 case $deplibs_check_method in
2761 "file_magic "*)
2762 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
2763 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
2764 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
2765 $EGREP "$file_magic_regex" > /dev/null; then
2766 :
2767 else
2768 cat <<_LT_EOF 1>&2
2769
2770 *** Warning: the command libtool uses to detect shared libraries,
2771 *** $file_magic_cmd, produces output that libtool cannot recognize.
2772 *** The result is that libtool may fail to recognize shared libraries
2773 *** as such. This will affect the creation of libtool libraries that
2774 *** depend on shared libraries, but programs linked with such libtool
2775 *** libraries will work regardless of this problem. Nevertheless, you
2776 *** may want to report the problem to your system manager and/or to
2777 *** bug-libtool@gnu.org
2778
2779 _LT_EOF
2780 fi ;;
2781 esac
2782 fi
2783 break
2784 fi
2785 done
2786 IFS="$lt_save_ifs"
2787 MAGIC_CMD="$lt_save_MAGIC_CMD"
2788 ;;
2789 esac])
2790 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
2791 if test -n "$MAGIC_CMD"; then
2792 AC_MSG_RESULT($MAGIC_CMD)
2793 else
2794 AC_MSG_RESULT(no)
2795 fi
2796 _LT_DECL([], [MAGIC_CMD], [0],
2797 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
2798 ])# _LT_PATH_TOOL_PREFIX
2799
2800 # Old name:
2801 AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
2802 dnl aclocal-1.4 backwards compatibility:
2803 dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
2804
2805
2806 # _LT_PATH_MAGIC
2807 # --------------
2808 # find a file program which can recognize a shared library
2809 m4_defun([_LT_PATH_MAGIC],
2810 [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
2811 if test -z "$lt_cv_path_MAGIC_CMD"; then
2812 if test -n "$ac_tool_prefix"; then
2813 _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
2814 else
2815 MAGIC_CMD=:
2816 fi
2817 fi
2818 ])# _LT_PATH_MAGIC
2819
2820
2821 # LT_PATH_LD
2822 # ----------
2823 # find the pathname to the GNU or non-GNU linker
2824 AC_DEFUN([LT_PATH_LD],
2825 [AC_REQUIRE([AC_PROG_CC])dnl
2826 AC_REQUIRE([AC_CANONICAL_HOST])dnl
2827 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
2828 m4_require([_LT_DECL_SED])dnl
2829 m4_require([_LT_DECL_EGREP])dnl
2830
2831 AC_ARG_WITH([gnu-ld],
2832 [AS_HELP_STRING([--with-gnu-ld],
2833 [assume the C compiler uses GNU ld @<:@default=no@:>@])],
2834 [test "$withval" = no || with_gnu_ld=yes],
2835 [with_gnu_ld=no])dnl
2836
2837 ac_prog=ld
2838 if test "$GCC" = yes; then
2839 # Check if gcc -print-prog-name=ld gives a path.
2840 AC_MSG_CHECKING([for ld used by $CC])
2841 case $host in
2842 *-*-mingw*)
2843 # gcc leaves a trailing carriage return which upsets mingw
2844 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
2845 *)
2846 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
2847 esac
2848 case $ac_prog in
2849 # Accept absolute paths.
2850 [[\\/]]* | ?:[[\\/]]*)
2851 re_direlt='/[[^/]][[^/]]*/\.\./'
2852 # Canonicalize the pathname of ld
2853 ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
2854 while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
2855 ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
2856 done
2857 test -z "$LD" && LD="$ac_prog"
2858 ;;
2859 "")
2860 # If it fails, then pretend we aren't using GCC.
2861 ac_prog=ld
2862 ;;
2863 *)
2864 # If it is relative, then search for the first ld in PATH.
2865 with_gnu_ld=unknown
2866 ;;
2867 esac
2868 elif test "$with_gnu_ld" = yes; then
2869 AC_MSG_CHECKING([for GNU ld])
2870 else
2871 AC_MSG_CHECKING([for non-GNU ld])
2872 fi
2873 AC_CACHE_VAL(lt_cv_path_LD,
2874 [if test -z "$LD"; then
2875 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
2876 for ac_dir in $PATH; do
2877 IFS="$lt_save_ifs"
2878 test -z "$ac_dir" && ac_dir=.
2879 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
2880 lt_cv_path_LD="$ac_dir/$ac_prog"
2881 # Check to see if the program is GNU ld. I'd rather use --version,
2882 # but apparently some variants of GNU ld only accept -v.
2883 # Break only if it was the GNU/non-GNU ld that we prefer.
2884 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
2885 *GNU* | *'with BFD'*)
2886 test "$with_gnu_ld" != no && break
2887 ;;
2888 *)
2889 test "$with_gnu_ld" != yes && break
2890 ;;
2891 esac
2892 fi
2893 done
2894 IFS="$lt_save_ifs"
2895 else
2896 lt_cv_path_LD="$LD" # Let the user override the test with a path.
2897 fi])
2898 LD="$lt_cv_path_LD"
2899 if test -n "$LD"; then
2900 AC_MSG_RESULT($LD)
2901 else
2902 AC_MSG_RESULT(no)
2903 fi
2904 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
2905 _LT_PATH_LD_GNU
2906 AC_SUBST([LD])
2907
2908 _LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
2909 ])# LT_PATH_LD
2910
2911 # Old names:
2912 AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
2913 AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
2914 dnl aclocal-1.4 backwards compatibility:
2915 dnl AC_DEFUN([AM_PROG_LD], [])
2916 dnl AC_DEFUN([AC_PROG_LD], [])
2917
2918
2919 # _LT_PATH_LD_GNU
2920 #- --------------
2921 m4_defun([_LT_PATH_LD_GNU],
2922 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
2923 [# I'd rather use --version here, but apparently some GNU lds only accept -v.
2924 case `$LD -v 2>&1 </dev/null` in
2925 *GNU* | *'with BFD'*)
2926 lt_cv_prog_gnu_ld=yes
2927 ;;
2928 *)
2929 lt_cv_prog_gnu_ld=no
2930 ;;
2931 esac])
2932 with_gnu_ld=$lt_cv_prog_gnu_ld
2933 ])# _LT_PATH_LD_GNU
2934
2935
2936 # _LT_CMD_RELOAD
2937 # --------------
2938 # find reload flag for linker
2939 # -- PORTME Some linkers may need a different reload flag.
2940 m4_defun([_LT_CMD_RELOAD],
2941 [AC_CACHE_CHECK([for $LD option to reload object files],
2942 lt_cv_ld_reload_flag,
2943 [lt_cv_ld_reload_flag='-r'])
2944 reload_flag=$lt_cv_ld_reload_flag
2945 case $reload_flag in
2946 "" | " "*) ;;
2947 *) reload_flag=" $reload_flag" ;;
2948 esac
2949 reload_cmds='$LD$reload_flag -o $output$reload_objs'
2950 case $host_os in
2951 darwin*)
2952 if test "$GCC" = yes; then
2953 reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
2954 else
2955 reload_cmds='$LD$reload_flag -o $output$reload_objs'
2956 fi
2957 ;;
2958 esac
2959 _LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
2960 _LT_DECL([], [reload_cmds], [2])dnl
2961 ])# _LT_CMD_RELOAD
2962
2963
2964 # _LT_CHECK_MAGIC_METHOD
2965 # ----------------------
2966 # how to check for library dependencies
2967 # -- PORTME fill in with the dynamic library characteristics
2968 m4_defun([_LT_CHECK_MAGIC_METHOD],
2969 [m4_require([_LT_DECL_EGREP])
2970 AC_CACHE_CHECK([how to recognize dependent libraries],
2971 lt_cv_deplibs_check_method,
2972 [lt_cv_file_magic_cmd='$MAGIC_CMD'
2973 lt_cv_file_magic_test_file=
2974 lt_cv_deplibs_check_method='unknown'
2975 # Need to set the preceding variable on all platforms that support
2976 # interlibrary dependencies.
2977 # 'none' -- dependencies not supported.
2978 # `unknown' -- same as none, but documents that we really don't know.
2979 # 'pass_all' -- all dependencies passed with no checks.
2980 # 'test_compile' -- check by making test program.
2981 # 'file_magic [[regex]]' -- check by looking for files in library path
2982 # which responds to the $file_magic_cmd with a given extended regex.
2983 # If you have `file' or equivalent on your system and you're not sure
2984 # whether `pass_all' will *always* work, you probably want this one.
2985
2986 case $host_os in
2987 aix[[4-9]]*)
2988 lt_cv_deplibs_check_method=pass_all
2989 ;;
2990
2991 beos*)
2992 lt_cv_deplibs_check_method=pass_all
2993 ;;
2994
2995 bsdi[[45]]*)
2996 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
2997 lt_cv_file_magic_cmd='/usr/bin/file -L'
2998 lt_cv_file_magic_test_file=/shlib/libc.so
2999 ;;
3000
3001 cygwin*)
3002 # func_win32_libid is a shell function defined in ltmain.sh
3003 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
3004 lt_cv_file_magic_cmd='func_win32_libid'
3005 ;;
3006
3007 mingw* | pw32*)
3008 # Base MSYS/MinGW do not provide the 'file' command needed by
3009 # func_win32_libid shell function, so use a weaker test based on 'objdump',
3010 # unless we find 'file', for example because we are cross-compiling.
3011 if ( file / ) >/dev/null 2>&1; then
3012 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
3013 lt_cv_file_magic_cmd='func_win32_libid'
3014 else
3015 lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
3016 lt_cv_file_magic_cmd='$OBJDUMP -f'
3017 fi
3018 ;;
3019
3020 darwin* | rhapsody*)
3021 lt_cv_deplibs_check_method=pass_all
3022 ;;
3023
3024 freebsd* | dragonfly*)
3025 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
3026 case $host_cpu in
3027 i*86 )
3028 # Not sure whether the presence of OpenBSD here was a mistake.
3029 # Let's accept both of them until this is cleared up.
3030 lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
3031 lt_cv_file_magic_cmd=/usr/bin/file
3032 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
3033 ;;
3034 esac
3035 else
3036 lt_cv_deplibs_check_method=pass_all
3037 fi
3038 ;;
3039
3040 gnu*)
3041 lt_cv_deplibs_check_method=pass_all
3042 ;;
3043
3044 hpux10.20* | hpux11*)
3045 lt_cv_file_magic_cmd=/usr/bin/file
3046 case $host_cpu in
3047 ia64*)
3048 lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
3049 lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
3050 ;;
3051 hppa*64*)
3052 [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
3053 lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
3054 ;;
3055 *)
3056 lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
3057 lt_cv_file_magic_test_file=/usr/lib/libc.sl
3058 ;;
3059 esac
3060 ;;
3061
3062 interix[[3-9]]*)
3063 # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
3064 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
3065 ;;
3066
3067 irix5* | irix6* | nonstopux*)
3068 case $LD in
3069 *-32|*"-32 ") libmagic=32-bit;;
3070 *-n32|*"-n32 ") libmagic=N32;;
3071 *-64|*"-64 ") libmagic=64-bit;;
3072 *) libmagic=never-match;;
3073 esac
3074 lt_cv_deplibs_check_method=pass_all
3075 ;;
3076
3077 # This must be Linux ELF.
3078 linux* | k*bsd*-gnu)
3079 lt_cv_deplibs_check_method=pass_all
3080 ;;
3081
3082 netbsd*)
3083 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
3084 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
3085 else
3086 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
3087 fi
3088 ;;
3089
3090 newos6*)
3091 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
3092 lt_cv_file_magic_cmd=/usr/bin/file
3093 lt_cv_file_magic_test_file=/usr/lib/libnls.so
3094 ;;
3095
3096 *nto* | *qnx*)
3097 lt_cv_deplibs_check_method=pass_all
3098 ;;
3099
3100 openbsd*)
3101 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
3102 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
3103 else
3104 lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
3105 fi
3106 ;;
3107
3108 osf3* | osf4* | osf5*)
3109 lt_cv_deplibs_check_method=pass_all
3110 ;;
3111
3112 rdos*)
3113 lt_cv_deplibs_check_method=pass_all
3114 ;;
3115
3116 solaris*)
3117 lt_cv_deplibs_check_method=pass_all
3118 ;;
3119
3120 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
3121 lt_cv_deplibs_check_method=pass_all
3122 ;;
3123
3124 sysv4 | sysv4.3*)
3125 case $host_vendor in
3126 motorola)
3127 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
3128 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
3129 ;;
3130 ncr)
3131 lt_cv_deplibs_check_method=pass_all
3132 ;;
3133 sequent)
3134 lt_cv_file_magic_cmd='/bin/file'
3135 lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
3136 ;;
3137 sni)
3138 lt_cv_file_magic_cmd='/bin/file'
3139 lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
3140 lt_cv_file_magic_test_file=/lib/libc.so
3141 ;;
3142 siemens)
3143 lt_cv_deplibs_check_method=pass_all
3144 ;;
3145 pc)
3146 lt_cv_deplibs_check_method=pass_all
3147 ;;
3148 esac
3149 ;;
3150
3151 tpf*)
3152 lt_cv_deplibs_check_method=pass_all
3153 ;;
3154 esac
3155 ])
3156 file_magic_cmd=$lt_cv_file_magic_cmd
3157 deplibs_check_method=$lt_cv_deplibs_check_method
3158 test -z "$deplibs_check_method" && deplibs_check_method=unknown
3159
3160 _LT_DECL([], [deplibs_check_method], [1],
3161 [Method to check whether dependent libraries are shared objects])
3162 _LT_DECL([], [file_magic_cmd], [1],
3163 [Command to use when deplibs_check_method == "file_magic"])
3164 ])# _LT_CHECK_MAGIC_METHOD
3165
3166
3167 # LT_PATH_NM
3168 # ----------
3169 # find the pathname to a BSD- or MS-compatible name lister
3170 AC_DEFUN([LT_PATH_NM],
3171 [AC_REQUIRE([AC_PROG_CC])dnl
3172 AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
3173 [if test -n "$NM"; then
3174 # Let the user override the test.
3175 lt_cv_path_NM="$NM"
3176 else
3177 lt_nm_to_check="${ac_tool_prefix}nm"
3178 if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
3179 lt_nm_to_check="$lt_nm_to_check nm"
3180 fi
3181 for lt_tmp_nm in $lt_nm_to_check; do
3182 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
3183 for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
3184 IFS="$lt_save_ifs"
3185 test -z "$ac_dir" && ac_dir=.
3186 tmp_nm="$ac_dir/$lt_tmp_nm"
3187 if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
3188 # Check to see if the nm accepts a BSD-compat flag.
3189 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
3190 # nm: unknown option "B" ignored
3191 # Tru64's nm complains that /dev/null is an invalid object file
3192 case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
3193 */dev/null* | *'Invalid file or object type'*)
3194 lt_cv_path_NM="$tmp_nm -B"
3195 break
3196 ;;
3197 *)
3198 case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
3199 */dev/null*)
3200 lt_cv_path_NM="$tmp_nm -p"
3201 break
3202 ;;
3203 *)
3204 lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
3205 continue # so that we can try to find one that supports BSD flags
3206 ;;
3207 esac
3208 ;;
3209 esac
3210 fi
3211 done
3212 IFS="$lt_save_ifs"
3213 done
3214 : ${lt_cv_path_NM=no}
3215 fi])
3216 if test "$lt_cv_path_NM" != "no"; then
3217 NM="$lt_cv_path_NM"
3218 else
3219 # Didn't find any BSD compatible name lister, look for dumpbin.
3220 AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
3221 AC_SUBST([DUMPBIN])
3222 if test "$DUMPBIN" != ":"; then
3223 NM="$DUMPBIN"
3224 fi
3225 fi
3226 test -z "$NM" && NM=nm
3227 AC_SUBST([NM])
3228 _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
3229
3230 AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
3231 [lt_cv_nm_interface="BSD nm"
3232 echo "int some_variable = 0;" > conftest.$ac_ext
3233 (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
3234 (eval "$ac_compile" 2>conftest.err)
3235 cat conftest.err >&AS_MESSAGE_LOG_FD
3236 (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
3237 (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
3238 cat conftest.err >&AS_MESSAGE_LOG_FD
3239 (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
3240 cat conftest.out >&AS_MESSAGE_LOG_FD
3241 if $GREP 'External.*some_variable' conftest.out > /dev/null; then
3242 lt_cv_nm_interface="MS dumpbin"
3243 fi
3244 rm -r -f conftest*])
3245 ])# LT_PATH_NM
3246
3247 # Old names:
3248 AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
3249 AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
3250 dnl aclocal-1.4 backwards compatibility:
3251 dnl AC_DEFUN([AM_PROG_NM], [])
3252 dnl AC_DEFUN([AC_PROG_NM], [])
3253
3254
3255 # LT_LIB_M
3256 # --------
3257 # check for math library
3258 AC_DEFUN([LT_LIB_M],
3259 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
3260 LIBM=
3261 case $host in
3262 *-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
3263 # These system don't have libm, or don't need it
3264 ;;
3265 *-ncr-sysv4.3*)
3266 AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
3267 AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
3268 ;;
3269 *)
3270 AC_CHECK_LIB(m, cos, LIBM="-lm")
3271 ;;
3272 esac
3273 AC_SUBST([LIBM])
3274 ])# LT_LIB_M
3275
3276 # Old name:
3277 AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
3278 dnl aclocal-1.4 backwards compatibility:
3279 dnl AC_DEFUN([AC_CHECK_LIBM], [])
3280
3281
3282 # _LT_COMPILER_NO_RTTI([TAGNAME])
3283 # -------------------------------
3284 m4_defun([_LT_COMPILER_NO_RTTI],
3285 [m4_require([_LT_TAG_COMPILER])dnl
3286
3287 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
3288
3289 if test "$GCC" = yes; then
3290 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
3291
3292 _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
3293 lt_cv_prog_compiler_rtti_exceptions,
3294 [-fno-rtti -fno-exceptions], [],
3295 [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
3296 fi
3297 _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
3298 [Compiler flag to turn off builtin functions])
3299 ])# _LT_COMPILER_NO_RTTI
3300
3301
3302 # _LT_CMD_GLOBAL_SYMBOLS
3303 # ----------------------
3304 m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
3305 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
3306 AC_REQUIRE([AC_PROG_CC])dnl
3307 AC_REQUIRE([LT_PATH_NM])dnl
3308 AC_REQUIRE([LT_PATH_LD])dnl
3309 m4_require([_LT_DECL_SED])dnl
3310 m4_require([_LT_DECL_EGREP])dnl
3311 m4_require([_LT_TAG_COMPILER])dnl
3312
3313 # Check for command to grab the raw symbol name followed by C symbol from nm.
3314 AC_MSG_CHECKING([command to parse $NM output from $compiler object])
3315 AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
3316 [
3317 # These are sane defaults that work on at least a few old systems.
3318 # [They come from Ultrix. What could be older than Ultrix?!! ;)]
3319
3320 # Character class describing NM global symbol codes.
3321 symcode='[[BCDEGRST]]'
3322
3323 # Regexp to match symbols that can be accessed directly from C.
3324 sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
3325
3326 # Define system-specific variables.
3327 case $host_os in
3328 aix*)
3329 symcode='[[BCDT]]'
3330 ;;
3331 cygwin* | mingw* | pw32*)
3332 symcode='[[ABCDGISTW]]'
3333 ;;
3334 hpux*)
3335 if test "$host_cpu" = ia64; then
3336 symcode='[[ABCDEGRST]]'
3337 fi
3338 ;;
3339 irix* | nonstopux*)
3340 symcode='[[BCDEGRST]]'
3341 ;;
3342 osf*)
3343 symcode='[[BCDEGQRST]]'
3344 ;;
3345 solaris*)
3346 symcode='[[BDRT]]'
3347 ;;
3348 sco3.2v5*)
3349 symcode='[[DT]]'
3350 ;;
3351 sysv4.2uw2*)
3352 symcode='[[DT]]'
3353 ;;
3354 sysv5* | sco5v6* | unixware* | OpenUNIX*)
3355 symcode='[[ABDT]]'
3356 ;;
3357 sysv4)
3358 symcode='[[DFNSTU]]'
3359 ;;
3360 esac
3361
3362 # If we're using GNU nm, then use its standard symbol codes.
3363 case `$NM -V 2>&1` in
3364 *GNU* | *'with BFD'*)
3365 symcode='[[ABCDGIRSTW]]' ;;
3366 esac
3367
3368 # Transform an extracted symbol line into a proper C declaration.
3369 # Some systems (esp. on ia64) link data and code symbols differently,
3370 # so use this general approach.
3371 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
3372
3373 # Transform an extracted symbol line into symbol name and symbol address
3374 lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
3375 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
3376
3377 # Handle CRLF in mingw tool chain
3378 opt_cr=
3379 case $build_os in
3380 mingw*)
3381 opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
3382 ;;
3383 esac
3384
3385 # Try without a prefix underscore, then with it.
3386 for ac_symprfx in "" "_"; do
3387
3388 # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
3389 symxfrm="\\1 $ac_symprfx\\2 \\2"
3390
3391 # Write the raw and C identifiers.
3392 if test "$lt_cv_nm_interface" = "MS dumpbin"; then
3393 # Fake it for dumpbin and say T for any non-static function
3394 # and D for any global variable.
3395 # Also find C++ and __fastcall symbols from MSVC++,
3396 # which start with @ or ?.
3397 lt_cv_sys_global_symbol_pipe="$AWK ['"\
3398 " {last_section=section; section=\$ 3};"\
3399 " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
3400 " \$ 0!~/External *\|/{next};"\
3401 " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
3402 " {if(hide[section]) next};"\
3403 " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
3404 " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
3405 " s[1]~/^[@?]/{print s[1], s[1]; next};"\
3406 " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
3407 " ' prfx=^$ac_symprfx]"
3408 else
3409 lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
3410 fi
3411
3412 # Check to see that the pipe works correctly.
3413 pipe_works=no
3414
3415 rm -r -f conftest*
3416 cat > conftest.$ac_ext <<_LT_EOF
3417 #ifdef __cplusplus
3418 extern "C" {
3419 #endif
3420 char nm_test_var;
3421 void nm_test_func(void);
3422 void nm_test_func(void){}
3423 #ifdef __cplusplus
3424 }
3425 #endif
3426 int main(){nm_test_var='a';nm_test_func();return(0);}
3427 _LT_EOF
3428
3429 if AC_TRY_EVAL(ac_compile); then
3430 # Now try to grab the symbols.
3431 nlist=conftest.nm
3432 if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
3433 # Try sorting and uniquifying the output.
3434 if sort "$nlist" | uniq > "$nlist"T; then
3435 mv -f "$nlist"T "$nlist"
3436 else
3437 rm -f "$nlist"T
3438 fi
3439
3440 # Make sure that we snagged all the symbols we need.
3441 if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
3442 if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
3443 cat <<_LT_EOF > conftest.$ac_ext
3444 #ifdef __cplusplus
3445 extern "C" {
3446 #endif
3447
3448 _LT_EOF
3449 # Now generate the symbol file.
3450 eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
3451
3452 cat <<_LT_EOF >> conftest.$ac_ext
3453
3454 /* The mapping between symbol names and symbols. */
3455 const struct {
3456 const char *name;
3457 void *address;
3458 }
3459 lt__PROGRAM__LTX_preloaded_symbols[[]] =
3460 {
3461 { "@PROGRAM@", (void *) 0 },
3462 _LT_EOF
3463 $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
3464 cat <<\_LT_EOF >> conftest.$ac_ext
3465 {0, (void *) 0}
3466 };
3467
3468 /* This works around a problem in FreeBSD linker */
3469 #ifdef FREEBSD_WORKAROUND
3470 static const void *lt_preloaded_setup() {
3471 return lt__PROGRAM__LTX_preloaded_symbols;
3472 }
3473 #endif
3474
3475 #ifdef __cplusplus
3476 }
3477 #endif
3478 _LT_EOF
3479 # Now try linking the two files.
3480 mv conftest.$ac_objext conftstm.$ac_objext
3481 lt_save_LIBS="$LIBS"
3482 lt_save_CFLAGS="$CFLAGS"
3483 LIBS="conftstm.$ac_objext"
3484 CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
3485 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
3486 pipe_works=yes
3487 fi
3488 LIBS="$lt_save_LIBS"
3489 CFLAGS="$lt_save_CFLAGS"
3490 else
3491 echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
3492 fi
3493 else
3494 echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
3495 fi
3496 else
3497 echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
3498 fi
3499 else
3500 echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
3501 cat conftest.$ac_ext >&5
3502 fi
3503 rm -rf conftest* conftst*
3504
3505 # Do not use the global_symbol_pipe unless it works.
3506 if test "$pipe_works" = yes; then
3507 break
3508 else
3509 lt_cv_sys_global_symbol_pipe=
3510 fi
3511 done
3512 ])
3513 if test -z "$lt_cv_sys_global_symbol_pipe"; then
3514 lt_cv_sys_global_symbol_to_cdecl=
3515 fi
3516 if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
3517 AC_MSG_RESULT(failed)
3518 else
3519 AC_MSG_RESULT(ok)
3520 fi
3521
3522 _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
3523 [Take the output of nm and produce a listing of raw symbols and C names])
3524 _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
3525 [Transform the output of nm in a proper C declaration])
3526 _LT_DECL([global_symbol_to_c_name_address],
3527 [lt_cv_sys_global_symbol_to_c_name_address], [1],
3528 [Transform the output of nm in a C name address pair])
3529 _LT_DECL([global_symbol_to_c_name_address_lib_prefix],
3530 [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
3531 [Transform the output of nm in a C name address pair when lib prefix is needed])
3532 ]) # _LT_CMD_GLOBAL_SYMBOLS
3533
3534
3535 # _LT_COMPILER_PIC([TAGNAME])
3536 # ---------------------------
3537 m4_defun([_LT_COMPILER_PIC],
3538 [m4_require([_LT_TAG_COMPILER])dnl
3539 _LT_TAGVAR(lt_prog_compiler_wl, $1)=
3540 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3541 _LT_TAGVAR(lt_prog_compiler_static, $1)=
3542
3543 AC_MSG_CHECKING([for $compiler option to produce PIC])
3544 m4_if([$1], [CXX], [
3545 # C++ specific cases for pic, static, wl, etc.
3546 if test "$GXX" = yes; then
3547 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3548 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3549
3550 case $host_os in
3551 aix*)
3552 # All AIX code is PIC.
3553 if test "$host_cpu" = ia64; then
3554 # AIX 5 now supports IA64 processor
3555 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3556 fi
3557 ;;
3558
3559 amigaos*)
3560 case $host_cpu in
3561 powerpc)
3562 # see comment about AmigaOS4 .so support
3563 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3564 ;;
3565 m68k)
3566 # FIXME: we need at least 68020 code to build shared libraries, but
3567 # adding the `-m68020' flag to GCC prevents building anything better,
3568 # like `-m68040'.
3569 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
3570 ;;
3571 esac
3572 ;;
3573
3574 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
3575 # PIC is the default for these OSes.
3576 ;;
3577 mingw* | cygwin* | os2* | pw32*)
3578 # This hack is so that the source file can tell whether it is being
3579 # built for inclusion in a dll (and should export symbols for example).
3580 # Although the cygwin gcc ignores -fPIC, still need this for old-style
3581 # (--disable-auto-import) libraries
3582 m4_if([$1], [GCJ], [],
3583 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3584 ;;
3585 darwin* | rhapsody*)
3586 # PIC is the default on this platform
3587 # Common symbols not allowed in MH_DYLIB files
3588 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
3589 ;;
3590 *djgpp*)
3591 # DJGPP does not support shared libraries at all
3592 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3593 ;;
3594 interix[[3-9]]*)
3595 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
3596 # Instead, we relocate shared libraries at runtime.
3597 ;;
3598 sysv4*MP*)
3599 if test -d /usr/nec; then
3600 _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
3601 fi
3602 ;;
3603 hpux*)
3604 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
3605 # not for PA HP-UX.
3606 case $host_cpu in
3607 hppa*64*|ia64*)
3608 ;;
3609 *)
3610 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3611 ;;
3612 esac
3613 ;;
3614 *qnx* | *nto*)
3615 # QNX uses GNU C++, but need to define -shared option too, otherwise
3616 # it will coredump.
3617 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3618 ;;
3619 *)
3620 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3621 ;;
3622 esac
3623 else
3624 case $host_os in
3625 aix[[4-9]]*)
3626 # All AIX code is PIC.
3627 if test "$host_cpu" = ia64; then
3628 # AIX 5 now supports IA64 processor
3629 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3630 else
3631 _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
3632 fi
3633 ;;
3634 chorus*)
3635 case $cc_basename in
3636 cxch68*)
3637 # Green Hills C++ Compiler
3638 # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
3639 ;;
3640 esac
3641 ;;
3642 dgux*)
3643 case $cc_basename in
3644 ec++*)
3645 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3646 ;;
3647 ghcx*)
3648 # Green Hills C++ Compiler
3649 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3650 ;;
3651 *)
3652 ;;
3653 esac
3654 ;;
3655 freebsd* | dragonfly*)
3656 # FreeBSD uses GNU C++
3657 ;;
3658 hpux9* | hpux10* | hpux11*)
3659 case $cc_basename in
3660 CC*)
3661 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3662 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3663 if test "$host_cpu" != ia64; then
3664 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3665 fi
3666 ;;
3667 aCC*)
3668 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3669 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3670 case $host_cpu in
3671 hppa*64*|ia64*)
3672 # +Z the default
3673 ;;
3674 *)
3675 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3676 ;;
3677 esac
3678 ;;
3679 *)
3680 ;;
3681 esac
3682 ;;
3683 interix*)
3684 # This is c89, which is MS Visual C++ (no shared libs)
3685 # Anyone wants to do a port?
3686 ;;
3687 irix5* | irix6* | nonstopux*)
3688 case $cc_basename in
3689 CC*)
3690 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3691 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3692 # CC pic flag -KPIC is the default.
3693 ;;
3694 *)
3695 ;;
3696 esac
3697 ;;
3698 linux* | k*bsd*-gnu)
3699 case $cc_basename in
3700 KCC*)
3701 # KAI C++ Compiler
3702 _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
3703 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3704 ;;
3705 icpc* | ecpc* )
3706 # Intel C++
3707 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3708 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3709 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3710 ;;
3711 pgCC* | pgcpp*)
3712 # Portland Group C++ compiler
3713 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3714 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
3715 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3716 ;;
3717 cxx*)
3718 # Compaq C++
3719 # Make sure the PIC flag is empty. It appears that all Alpha
3720 # Linux and Compaq Tru64 Unix objects are PIC.
3721 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3722 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3723 ;;
3724 xlc* | xlC*)
3725 # IBM XL 8.0 on PPC
3726 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3727 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
3728 _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
3729 ;;
3730 *)
3731 case `$CC -V 2>&1 | sed 5q` in
3732 *Sun\ C*)
3733 # Sun C++ 5.9
3734 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3735 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3736 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
3737 ;;
3738 esac
3739 ;;
3740 esac
3741 ;;
3742 lynxos*)
3743 ;;
3744 m88k*)
3745 ;;
3746 mvs*)
3747 case $cc_basename in
3748 cxx*)
3749 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
3750 ;;
3751 *)
3752 ;;
3753 esac
3754 ;;
3755 netbsd*)
3756 ;;
3757 *qnx* | *nto*)
3758 # QNX uses GNU C++, but need to define -shared option too, otherwise
3759 # it will coredump.
3760 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3761 ;;
3762 osf3* | osf4* | osf5*)
3763 case $cc_basename in
3764 KCC*)
3765 _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
3766 ;;
3767 RCC*)
3768 # Rational C++ 2.4.1
3769 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3770 ;;
3771 cxx*)
3772 # Digital/Compaq C++
3773 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3774 # Make sure the PIC flag is empty. It appears that all Alpha
3775 # Linux and Compaq Tru64 Unix objects are PIC.
3776 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
3777 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3778 ;;
3779 *)
3780 ;;
3781 esac
3782 ;;
3783 psos*)
3784 ;;
3785 solaris*)
3786 case $cc_basename in
3787 CC*)
3788 # Sun C++ 4.2, 5.x and Centerline C++
3789 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3790 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3791 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
3792 ;;
3793 gcx*)
3794 # Green Hills C++ Compiler
3795 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
3796 ;;
3797 *)
3798 ;;
3799 esac
3800 ;;
3801 sunos4*)
3802 case $cc_basename in
3803 CC*)
3804 # Sun C++ 4.x
3805 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3806 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3807 ;;
3808 lcc*)
3809 # Lucid
3810 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
3811 ;;
3812 *)
3813 ;;
3814 esac
3815 ;;
3816 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
3817 case $cc_basename in
3818 CC*)
3819 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3820 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3821 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3822 ;;
3823 esac
3824 ;;
3825 tandem*)
3826 case $cc_basename in
3827 NCC*)
3828 # NonStop-UX NCC 3.20
3829 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3830 ;;
3831 *)
3832 ;;
3833 esac
3834 ;;
3835 vxworks*)
3836 ;;
3837 *)
3838 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
3839 ;;
3840 esac
3841 fi
3842 ],
3843 [
3844 if test "$GCC" = yes; then
3845 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3846 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3847
3848 case $host_os in
3849 aix*)
3850 # All AIX code is PIC.
3851 if test "$host_cpu" = ia64; then
3852 # AIX 5 now supports IA64 processor
3853 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3854 fi
3855 ;;
3856
3857 amigaos*)
3858 case $host_cpu in
3859 powerpc)
3860 # see comment about AmigaOS4 .so support
3861 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3862 ;;
3863 m68k)
3864 # FIXME: we need at least 68020 code to build shared libraries, but
3865 # adding the `-m68020' flag to GCC prevents building anything better,
3866 # like `-m68040'.
3867 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
3868 ;;
3869 esac
3870 ;;
3871
3872 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
3873 # PIC is the default for these OSes.
3874 ;;
3875
3876 mingw* | cygwin* | pw32* | os2*)
3877 # This hack is so that the source file can tell whether it is being
3878 # built for inclusion in a dll (and should export symbols for example).
3879 # Although the cygwin gcc ignores -fPIC, still need this for old-style
3880 # (--disable-auto-import) libraries
3881 m4_if([$1], [GCJ], [],
3882 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3883 ;;
3884
3885 darwin* | rhapsody*)
3886 # PIC is the default on this platform
3887 # Common symbols not allowed in MH_DYLIB files
3888 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
3889 ;;
3890
3891 hpux*)
3892 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
3893 # not for PA HP-UX.
3894 case $host_cpu in
3895 hppa*64*|ia64*)
3896 # +Z the default
3897 ;;
3898 *)
3899 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3900 ;;
3901 esac
3902 ;;
3903
3904 interix[[3-9]]*)
3905 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
3906 # Instead, we relocate shared libraries at runtime.
3907 ;;
3908
3909 msdosdjgpp*)
3910 # Just because we use GCC doesn't mean we suddenly get shared libraries
3911 # on systems that don't support them.
3912 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
3913 enable_shared=no
3914 ;;
3915
3916 *nto* | *qnx*)
3917 # QNX uses GNU C++, but need to define -shared option too, otherwise
3918 # it will coredump.
3919 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
3920 ;;
3921
3922 sysv4*MP*)
3923 if test -d /usr/nec; then
3924 _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
3925 fi
3926 ;;
3927
3928 *)
3929 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
3930 ;;
3931 esac
3932 else
3933 # PORTME Check for flag to pass linker flags through the system compiler.
3934 case $host_os in
3935 aix*)
3936 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3937 if test "$host_cpu" = ia64; then
3938 # AIX 5 now supports IA64 processor
3939 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3940 else
3941 _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
3942 fi
3943 ;;
3944
3945 mingw* | cygwin* | pw32* | os2*)
3946 # This hack is so that the source file can tell whether it is being
3947 # built for inclusion in a dll (and should export symbols for example).
3948 m4_if([$1], [GCJ], [],
3949 [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
3950 ;;
3951
3952 hpux9* | hpux10* | hpux11*)
3953 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3954 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
3955 # not for PA HP-UX.
3956 case $host_cpu in
3957 hppa*64*|ia64*)
3958 # +Z the default
3959 ;;
3960 *)
3961 _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
3962 ;;
3963 esac
3964 # Is there a better lt_prog_compiler_static that works with the bundled CC?
3965 _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
3966 ;;
3967
3968 irix5* | irix6* | nonstopux*)
3969 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3970 # PIC (with -KPIC) is the default.
3971 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3972 ;;
3973
3974 linux* | k*bsd*-gnu)
3975 case $cc_basename in
3976 icc* | ecc* | ifort*)
3977 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3978 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
3979 _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
3980 ;;
3981 pgcc* | pgf77* | pgf90* | pgf95*)
3982 # Portland Group compilers (*not* the Pentium gcc compiler,
3983 # which looks to be a dead project)
3984 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3985 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
3986 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
3987 ;;
3988 ccc*)
3989 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3990 # All Alpha code is PIC.
3991 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
3992 ;;
3993 xl*)
3994 # IBM XL C 8.0/Fortran 10.1 on PPC
3995 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
3996 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
3997 _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
3998 ;;
3999 *)
4000 case `$CC -V 2>&1 | sed 5q` in
4001 *Sun\ C*)
4002 # Sun C 5.9
4003 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4004 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4005 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4006 ;;
4007 *Sun\ F*)
4008 # Sun Fortran 8.3 passes all unrecognized flags to the linker
4009 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4010 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4011 _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
4012 ;;
4013 esac
4014 ;;
4015 esac
4016 ;;
4017
4018 newsos6)
4019 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4020 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4021 ;;
4022
4023 *nto* | *qnx*)
4024 # QNX uses GNU C++, but need to define -shared option too, otherwise
4025 # it will coredump.
4026 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
4027 ;;
4028
4029 osf3* | osf4* | osf5*)
4030 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4031 # All OSF/1 code is PIC.
4032 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
4033 ;;
4034
4035 rdos*)
4036 _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
4037 ;;
4038
4039 solaris*)
4040 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4041 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4042 case $cc_basename in
4043 f77* | f90* | f95*)
4044 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
4045 *)
4046 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
4047 esac
4048 ;;
4049
4050 sunos4*)
4051 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
4052 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
4053 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4054 ;;
4055
4056 sysv4 | sysv4.2uw2* | sysv4.3*)
4057 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4058 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4059 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4060 ;;
4061
4062 sysv4*MP*)
4063 if test -d /usr/nec ;then
4064 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
4065 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4066 fi
4067 ;;
4068
4069 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
4070 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4071 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
4072 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4073 ;;
4074
4075 unicos*)
4076 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
4077 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
4078 ;;
4079
4080 uts4*)
4081 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
4082 _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
4083 ;;
4084
4085 *)
4086 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
4087 ;;
4088 esac
4089 fi
4090 ])
4091 case $host_os in
4092 # For platforms which do not support PIC, -DPIC is meaningless:
4093 *djgpp*)
4094 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
4095 ;;
4096 *)
4097 _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
4098 ;;
4099 esac
4100 AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
4101 _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
4102 [How to pass a linker flag through the compiler])
4103
4104 #
4105 # Check to make sure the PIC flag actually works.
4106 #
4107 if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
4108 _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
4109 [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
4110 [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
4111 [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
4112 "" | " "*) ;;
4113 *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
4114 esac],
4115 [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
4116 _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
4117 fi
4118 _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
4119 [Additional compiler flags for building library objects])
4120
4121 #
4122 # Check to make sure the static flag actually works.
4123 #
4124 wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
4125 _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
4126 _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
4127 $lt_tmp_static_flag,
4128 [],
4129 [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
4130 _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
4131 [Compiler flag to prevent dynamic linking])
4132 ])# _LT_COMPILER_PIC
4133
4134
4135 # _LT_LINKER_SHLIBS([TAGNAME])
4136 # ----------------------------
4137 # See if the linker supports building shared libraries.
4138 m4_defun([_LT_LINKER_SHLIBS],
4139 [AC_REQUIRE([LT_PATH_LD])dnl
4140 AC_REQUIRE([LT_PATH_NM])dnl
4141 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
4142 m4_require([_LT_DECL_EGREP])dnl
4143 m4_require([_LT_DECL_SED])dnl
4144 m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
4145 m4_require([_LT_TAG_COMPILER])dnl
4146 AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
4147 m4_if([$1], [CXX], [
4148 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4149 case $host_os in
4150 aix[[4-9]]*)
4151 # If we're using GNU nm, then we don't want the "-C" option.
4152 # -C means demangle to AIX nm, but means don't demangle with GNU nm
4153 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
4154 _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
4155 else
4156 _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
4157 fi
4158 ;;
4159 pw32*)
4160 _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
4161 ;;
4162 cygwin* | mingw*)
4163 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
4164 ;;
4165 *)
4166 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4167 ;;
4168 esac
4169 _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
4170 ], [
4171 runpath_var=
4172 _LT_TAGVAR(allow_undefined_flag, $1)=
4173 _LT_TAGVAR(always_export_symbols, $1)=no
4174 _LT_TAGVAR(archive_cmds, $1)=
4175 _LT_TAGVAR(archive_expsym_cmds, $1)=
4176 _LT_TAGVAR(compiler_needs_object, $1)=no
4177 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
4178 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
4179 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
4180 _LT_TAGVAR(hardcode_automatic, $1)=no
4181 _LT_TAGVAR(hardcode_direct, $1)=no
4182 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
4183 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4184 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
4185 _LT_TAGVAR(hardcode_libdir_separator, $1)=
4186 _LT_TAGVAR(hardcode_minus_L, $1)=no
4187 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
4188 _LT_TAGVAR(inherit_rpath, $1)=no
4189 _LT_TAGVAR(link_all_deplibs, $1)=unknown
4190 _LT_TAGVAR(module_cmds, $1)=
4191 _LT_TAGVAR(module_expsym_cmds, $1)=
4192 _LT_TAGVAR(old_archive_from_new_cmds, $1)=
4193 _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
4194 _LT_TAGVAR(thread_safe_flag_spec, $1)=
4195 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4196 # include_expsyms should be a list of space-separated symbols to be *always*
4197 # included in the symbol list
4198 _LT_TAGVAR(include_expsyms, $1)=
4199 # exclude_expsyms can be an extended regexp of symbols to exclude
4200 # it will be wrapped by ` (' and `)$', so one must not match beginning or
4201 # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
4202 # as well as any symbol that contains `d'.
4203 _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
4204 # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
4205 # platforms (ab)use it in PIC code, but their linkers get confused if
4206 # the symbol is explicitly referenced. Since portable code cannot
4207 # rely on this symbol name, it's probably fine to never include it in
4208 # preloaded symbol tables.
4209 # Exclude shared library initialization/finalization symbols.
4210 dnl Note also adjust exclude_expsyms for C++ above.
4211 extract_expsyms_cmds=
4212
4213 case $host_os in
4214 cygwin* | mingw* | pw32*)
4215 # FIXME: the MSVC++ port hasn't been tested in a loooong time
4216 # When not using gcc, we currently assume that we are using
4217 # Microsoft Visual C++.
4218 if test "$GCC" != yes; then
4219 with_gnu_ld=no
4220 fi
4221 ;;
4222 interix*)
4223 # we just hope/assume this is gcc and not c89 (= MSVC++)
4224 with_gnu_ld=yes
4225 ;;
4226 openbsd*)
4227 with_gnu_ld=no
4228 ;;
4229 esac
4230
4231 _LT_TAGVAR(ld_shlibs, $1)=yes
4232 if test "$with_gnu_ld" = yes; then
4233 # If archive_cmds runs LD, not CC, wlarc should be empty
4234 wlarc='${wl}'
4235
4236 # Set some defaults for GNU ld with shared library support. These
4237 # are reset later if shared libraries are not supported. Putting them
4238 # here allows them to be overridden if necessary.
4239 runpath_var=LD_RUN_PATH
4240 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4241 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
4242 # ancient GNU ld didn't support --whole-archive et. al.
4243 if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
4244 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
4245 else
4246 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4247 fi
4248 supports_anon_versioning=no
4249 case `$LD -v 2>&1` in
4250 *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
4251 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
4252 *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
4253 *\ 2.11.*) ;; # other 2.11 versions
4254 *) supports_anon_versioning=yes ;;
4255 esac
4256
4257 # See if GNU ld supports shared libraries.
4258 case $host_os in
4259 aix[[3-9]]*)
4260 # On AIX/PPC, the GNU linker is very broken
4261 if test "$host_cpu" != ia64; then
4262 _LT_TAGVAR(ld_shlibs, $1)=no
4263 cat <<_LT_EOF 1>&2
4264
4265 *** Warning: the GNU linker, at least up to release 2.9.1, is reported
4266 *** to be unable to reliably create shared libraries on AIX.
4267 *** Therefore, libtool is disabling shared libraries support. If you
4268 *** really care for shared libraries, you may want to modify your PATH
4269 *** so that a non-GNU linker is found, and then restart.
4270
4271 _LT_EOF
4272 fi
4273 ;;
4274
4275 amigaos*)
4276 case $host_cpu in
4277 powerpc)
4278 # see comment about AmigaOS4 .so support
4279 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4280 _LT_TAGVAR(archive_expsym_cmds, $1)=''
4281 ;;
4282 m68k)
4283 _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
4284 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4285 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4286 ;;
4287 esac
4288 ;;
4289
4290 beos*)
4291 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4292 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4293 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
4294 # support --undefined. This deserves some investigation. FIXME
4295 _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4296 else
4297 _LT_TAGVAR(ld_shlibs, $1)=no
4298 fi
4299 ;;
4300
4301 cygwin* | mingw* | pw32*)
4302 # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
4303 # as there is no search path for DLLs.
4304 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4305 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4306 _LT_TAGVAR(always_export_symbols, $1)=no
4307 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
4308 _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
4309
4310 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
4311 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
4312 # If the export-symbols file already is a .def file (1st line
4313 # is EXPORTS), use it as is; otherwise, prepend...
4314 _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
4315 cp $export_symbols $output_objdir/$soname.def;
4316 else
4317 echo EXPORTS > $output_objdir/$soname.def;
4318 cat $export_symbols >> $output_objdir/$soname.def;
4319 fi~
4320 $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
4321 else
4322 _LT_TAGVAR(ld_shlibs, $1)=no
4323 fi
4324 ;;
4325
4326 interix[[3-9]]*)
4327 _LT_TAGVAR(hardcode_direct, $1)=no
4328 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4329 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4330 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4331 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
4332 # Instead, shared libraries are loaded at an image base (0x10000000 by
4333 # default) and relocated if they conflict, which is a slow very memory
4334 # consuming and fragmenting process. To avoid this, we pick a random,
4335 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
4336 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
4337 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
4338 _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
4339 ;;
4340
4341 gnu* | linux* | tpf* | k*bsd*-gnu)
4342 tmp_diet=no
4343 if test "$host_os" = linux-dietlibc; then
4344 case $cc_basename in
4345 diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
4346 esac
4347 fi
4348 if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
4349 && test "$tmp_diet" = no
4350 then
4351 tmp_addflag=
4352 tmp_sharedflag='-shared'
4353 case $cc_basename,$host_cpu in
4354 pgcc*) # Portland Group C compiler
4355 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
4356 tmp_addflag=' $pic_flag'
4357 ;;
4358 pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
4359 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
4360 tmp_addflag=' $pic_flag -Mnomain' ;;
4361 ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
4362 tmp_addflag=' -i_dynamic' ;;
4363 efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
4364 tmp_addflag=' -i_dynamic -nofor_main' ;;
4365 ifc* | ifort*) # Intel Fortran compiler
4366 tmp_addflag=' -nofor_main' ;;
4367 xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
4368 tmp_sharedflag='-qmkshrobj'
4369 tmp_addflag= ;;
4370 esac
4371 case `$CC -V 2>&1 | sed 5q` in
4372 *Sun\ C*) # Sun C 5.9
4373 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
4374 _LT_TAGVAR(compiler_needs_object, $1)=yes
4375 tmp_sharedflag='-G' ;;
4376 *Sun\ F*) # Sun Fortran 8.3
4377 tmp_sharedflag='-G' ;;
4378 esac
4379 _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4380
4381 if test "x$supports_anon_versioning" = xyes; then
4382 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
4383 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
4384 echo "local: *; };" >> $output_objdir/$libname.ver~
4385 $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
4386 fi
4387
4388 case $cc_basename in
4389 xlf*)
4390 # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
4391 _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
4392 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4393 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
4394 _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
4395 if test "x$supports_anon_versioning" = xyes; then
4396 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
4397 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
4398 echo "local: *; };" >> $output_objdir/$libname.ver~
4399 $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
4400 fi
4401 ;;
4402 esac
4403 else
4404 _LT_TAGVAR(ld_shlibs, $1)=no
4405 fi
4406 ;;
4407
4408 netbsd*)
4409 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
4410 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
4411 wlarc=
4412 else
4413 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4414 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
4415 fi
4416 ;;
4417
4418 solaris*)
4419 if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
4420 _LT_TAGVAR(ld_shlibs, $1)=no
4421 cat <<_LT_EOF 1>&2
4422
4423 *** Warning: The releases 2.8.* of the GNU linker cannot reliably
4424 *** create shared libraries on Solaris systems. Therefore, libtool
4425 *** is disabling shared libraries support. We urge you to upgrade GNU
4426 *** binutils to release 2.9.1 or newer. Another option is to modify
4427 *** your PATH or compiler configuration so that the native linker is
4428 *** used, and then restart.
4429
4430 _LT_EOF
4431 elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4432 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4433 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
4434 else
4435 _LT_TAGVAR(ld_shlibs, $1)=no
4436 fi
4437 ;;
4438
4439 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
4440 case `$LD -v 2>&1` in
4441 *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
4442 _LT_TAGVAR(ld_shlibs, $1)=no
4443 cat <<_LT_EOF 1>&2
4444
4445 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
4446 *** reliably create shared libraries on SCO systems. Therefore, libtool
4447 *** is disabling shared libraries support. We urge you to upgrade GNU
4448 *** binutils to release 2.16.91.0.3 or newer. Another option is to modify
4449 *** your PATH or compiler configuration so that the native linker is
4450 *** used, and then restart.
4451
4452 _LT_EOF
4453 ;;
4454 *)
4455 # For security reasons, it is highly recommended that you always
4456 # use absolute paths for naming shared libraries, and exclude the
4457 # DT_RUNPATH tag from executables and libraries. But doing so
4458 # requires that you compile everything twice, which is a pain.
4459 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4460 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4461 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4462 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
4463 else
4464 _LT_TAGVAR(ld_shlibs, $1)=no
4465 fi
4466 ;;
4467 esac
4468 ;;
4469
4470 sunos4*)
4471 _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4472 wlarc=
4473 _LT_TAGVAR(hardcode_direct, $1)=yes
4474 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4475 ;;
4476
4477 *)
4478 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
4479 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4480 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
4481 else
4482 _LT_TAGVAR(ld_shlibs, $1)=no
4483 fi
4484 ;;
4485 esac
4486
4487 if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
4488 runpath_var=
4489 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
4490 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
4491 _LT_TAGVAR(whole_archive_flag_spec, $1)=
4492 fi
4493 else
4494 # PORTME fill in a description of your system's linker (not GNU ld)
4495 case $host_os in
4496 aix3*)
4497 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4498 _LT_TAGVAR(always_export_symbols, $1)=yes
4499 _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
4500 # Note: this linker hardcodes the directories in LIBPATH if there
4501 # are no directories specified by -L.
4502 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4503 if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
4504 # Neither direct hardcoding nor static linking is supported with a
4505 # broken collect2.
4506 _LT_TAGVAR(hardcode_direct, $1)=unsupported
4507 fi
4508 ;;
4509
4510 aix[[4-9]]*)
4511 if test "$host_cpu" = ia64; then
4512 # On IA64, the linker does run time linking by default, so we don't
4513 # have to do anything special.
4514 aix_use_runtimelinking=no
4515 exp_sym_flag='-Bexport'
4516 no_entry_flag=""
4517 else
4518 # If we're using GNU nm, then we don't want the "-C" option.
4519 # -C means demangle to AIX nm, but means don't demangle with GNU nm
4520 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
4521 _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
4522 else
4523 _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
4524 fi
4525 aix_use_runtimelinking=no
4526
4527 # Test if we are trying to use run time linking or normal
4528 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
4529 # need to do runtime linking.
4530 case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
4531 for ld_flag in $LDFLAGS; do
4532 if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
4533 aix_use_runtimelinking=yes
4534 break
4535 fi
4536 done
4537 ;;
4538 esac
4539
4540 exp_sym_flag='-bexport'
4541 no_entry_flag='-bnoentry'
4542 fi
4543
4544 # When large executables or shared objects are built, AIX ld can
4545 # have problems creating the table of contents. If linking a library
4546 # or program results in "error TOC overflow" add -mminimal-toc to
4547 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
4548 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
4549
4550 _LT_TAGVAR(archive_cmds, $1)=''
4551 _LT_TAGVAR(hardcode_direct, $1)=yes
4552 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4553 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
4554 _LT_TAGVAR(link_all_deplibs, $1)=yes
4555 _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
4556
4557 if test "$GCC" = yes; then
4558 case $host_os in aix4.[[012]]|aix4.[[012]].*)
4559 # We only want to do this on AIX 4.2 and lower, the check
4560 # below for broken collect2 doesn't work under 4.3+
4561 collect2name=`${CC} -print-prog-name=collect2`
4562 if test -f "$collect2name" &&
4563 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
4564 then
4565 # We have reworked collect2
4566 :
4567 else
4568 # We have old collect2
4569 _LT_TAGVAR(hardcode_direct, $1)=unsupported
4570 # It fails to find uninstalled libraries when the uninstalled
4571 # path is not listed in the libpath. Setting hardcode_minus_L
4572 # to unsupported forces relinking
4573 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4574 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4575 _LT_TAGVAR(hardcode_libdir_separator, $1)=
4576 fi
4577 ;;
4578 esac
4579 shared_flag='-shared'
4580 if test "$aix_use_runtimelinking" = yes; then
4581 shared_flag="$shared_flag "'${wl}-G'
4582 fi
4583 else
4584 # not using gcc
4585 if test "$host_cpu" = ia64; then
4586 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
4587 # chokes on -Wl,-G. The following line is correct:
4588 shared_flag='-G'
4589 else
4590 if test "$aix_use_runtimelinking" = yes; then
4591 shared_flag='${wl}-G'
4592 else
4593 shared_flag='${wl}-bM:SRE'
4594 fi
4595 fi
4596 fi
4597
4598 # It seems that -bexpall does not export symbols beginning with
4599 # underscore (_), so it is better to generate a list of symbols to export.
4600 _LT_TAGVAR(always_export_symbols, $1)=yes
4601 if test "$aix_use_runtimelinking" = yes; then
4602 # Warning - without using the other runtime loading flags (-brtl),
4603 # -berok will link without error, but may produce a broken library.
4604 _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
4605 # Determine the default libpath from the value encoded in an
4606 # empty executable.
4607 _LT_SYS_MODULE_PATH_AIX
4608 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
4609 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
4610 else
4611 if test "$host_cpu" = ia64; then
4612 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
4613 _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
4614 _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
4615 else
4616 # Determine the default libpath from the value encoded in an
4617 # empty executable.
4618 _LT_SYS_MODULE_PATH_AIX
4619 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
4620 # Warning - without using the other run time loading flags,
4621 # -berok will link without error, but may produce a broken library.
4622 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
4623 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
4624 # Exported symbols can be pulled into shared objects from archives
4625 _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
4626 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
4627 # This is similar to how AIX traditionally builds its shared libraries.
4628 _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
4629 fi
4630 fi
4631 ;;
4632
4633 amigaos*)
4634 case $host_cpu in
4635 powerpc)
4636 # see comment about AmigaOS4 .so support
4637 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
4638 _LT_TAGVAR(archive_expsym_cmds, $1)=''
4639 ;;
4640 m68k)
4641 _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
4642 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4643 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4644 ;;
4645 esac
4646 ;;
4647
4648 bsdi[[45]]*)
4649 _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
4650 ;;
4651
4652 cygwin* | mingw* | pw32*)
4653 # When not using gcc, we currently assume that we are using
4654 # Microsoft Visual C++.
4655 # hardcode_libdir_flag_spec is actually meaningless, as there is
4656 # no search path for DLLs.
4657 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
4658 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4659 # Tell ltmain to make .lib files, not .a files.
4660 libext=lib
4661 # Tell ltmain to make .dll files, not .so files.
4662 shrext_cmds=".dll"
4663 # FIXME: Setting linknames here is a bad hack.
4664 _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
4665 # The linker will automatically build a .lib file if we build a DLL.
4666 _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
4667 # FIXME: Should let the user specify the lib program.
4668 _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
4669 _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
4670 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
4671 ;;
4672
4673 darwin* | rhapsody*)
4674 _LT_DARWIN_LINKER_FEATURES($1)
4675 ;;
4676
4677 dgux*)
4678 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4679 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4680 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4681 ;;
4682
4683 freebsd1*)
4684 _LT_TAGVAR(ld_shlibs, $1)=no
4685 ;;
4686
4687 # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
4688 # support. Future versions do this automatically, but an explicit c++rt0.o
4689 # does not break anything, and helps significantly (at the cost of a little
4690 # extra space).
4691 freebsd2.2*)
4692 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
4693 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4694 _LT_TAGVAR(hardcode_direct, $1)=yes
4695 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4696 ;;
4697
4698 # Unfortunately, older versions of FreeBSD 2 do not have this feature.
4699 freebsd2*)
4700 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4701 _LT_TAGVAR(hardcode_direct, $1)=yes
4702 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4703 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4704 ;;
4705
4706 # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
4707 freebsd* | dragonfly*)
4708 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
4709 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4710 _LT_TAGVAR(hardcode_direct, $1)=yes
4711 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4712 ;;
4713
4714 hpux9*)
4715 if test "$GCC" = yes; then
4716 _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
4717 else
4718 _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
4719 fi
4720 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4721 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4722 _LT_TAGVAR(hardcode_direct, $1)=yes
4723
4724 # hardcode_minus_L: Not really in the search PATH,
4725 # but as the default location of the library.
4726 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4727 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4728 ;;
4729
4730 hpux10*)
4731 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
4732 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4733 else
4734 _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
4735 fi
4736 if test "$with_gnu_ld" = no; then
4737 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4738 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
4739 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4740 _LT_TAGVAR(hardcode_direct, $1)=yes
4741 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4742 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4743 # hardcode_minus_L: Not really in the search PATH,
4744 # but as the default location of the library.
4745 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4746 fi
4747 ;;
4748
4749 hpux11*)
4750 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
4751 case $host_cpu in
4752 hppa*64*)
4753 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4754 ;;
4755 ia64*)
4756 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
4757 ;;
4758 *)
4759 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4760 ;;
4761 esac
4762 else
4763 case $host_cpu in
4764 hppa*64*)
4765 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4766 ;;
4767 ia64*)
4768 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
4769 ;;
4770 *)
4771 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
4772 ;;
4773 esac
4774 fi
4775 if test "$with_gnu_ld" = no; then
4776 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
4777 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4778
4779 case $host_cpu in
4780 hppa*64*|ia64*)
4781 _LT_TAGVAR(hardcode_direct, $1)=no
4782 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4783 ;;
4784 *)
4785 _LT_TAGVAR(hardcode_direct, $1)=yes
4786 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4787 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4788
4789 # hardcode_minus_L: Not really in the search PATH,
4790 # but as the default location of the library.
4791 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4792 ;;
4793 esac
4794 fi
4795 ;;
4796
4797 irix5* | irix6* | nonstopux*)
4798 if test "$GCC" = yes; then
4799 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
4800 # Try to use the -exported_symbol ld option, if it does not
4801 # work, assume that -exports_file does not work either and
4802 # implicitly export all symbols.
4803 save_LDFLAGS="$LDFLAGS"
4804 LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
4805 AC_LINK_IFELSE(int foo(void) {},
4806 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
4807 )
4808 LDFLAGS="$save_LDFLAGS"
4809 else
4810 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
4811 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
4812 fi
4813 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4814 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4815 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4816 _LT_TAGVAR(inherit_rpath, $1)=yes
4817 _LT_TAGVAR(link_all_deplibs, $1)=yes
4818 ;;
4819
4820 netbsd*)
4821 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
4822 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
4823 else
4824 _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
4825 fi
4826 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4827 _LT_TAGVAR(hardcode_direct, $1)=yes
4828 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4829 ;;
4830
4831 newsos6)
4832 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4833 _LT_TAGVAR(hardcode_direct, $1)=yes
4834 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4835 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4836 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4837 ;;
4838
4839 *nto* | *qnx*)
4840 ;;
4841
4842 openbsd*)
4843 if test -f /usr/libexec/ld.so; then
4844 _LT_TAGVAR(hardcode_direct, $1)=yes
4845 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4846 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
4847 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
4848 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
4849 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
4850 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4851 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
4852 else
4853 case $host_os in
4854 openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
4855 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
4856 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4857 ;;
4858 *)
4859 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
4860 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
4861 ;;
4862 esac
4863 fi
4864 else
4865 _LT_TAGVAR(ld_shlibs, $1)=no
4866 fi
4867 ;;
4868
4869 os2*)
4870 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4871 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4872 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
4873 _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
4874 _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
4875 ;;
4876
4877 osf3*)
4878 if test "$GCC" = yes; then
4879 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
4880 _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
4881 else
4882 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
4883 _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
4884 fi
4885 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4886 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4887 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4888 ;;
4889
4890 osf4* | osf5*) # as osf3* with the addition of -msym flag
4891 if test "$GCC" = yes; then
4892 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
4893 _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
4894 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
4895 else
4896 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
4897 _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
4898 _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
4899 $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
4900
4901 # Both c and cxx compiler support -rpath directly
4902 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
4903 fi
4904 _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
4905 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
4906 ;;
4907
4908 solaris*)
4909 _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
4910 if test "$GCC" = yes; then
4911 wlarc='${wl}'
4912 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
4913 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4914 $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
4915 else
4916 case `$CC -V 2>&1` in
4917 *"Compilers 5.0"*)
4918 wlarc=''
4919 _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
4920 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4921 $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
4922 ;;
4923 *)
4924 wlarc='${wl}'
4925 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
4926 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
4927 $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
4928 ;;
4929 esac
4930 fi
4931 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
4932 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4933 case $host_os in
4934 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
4935 *)
4936 # The compiler driver will combine and reorder linker options,
4937 # but understands `-z linker_flag'. GCC discards it without `$wl',
4938 # but is careful enough not to reorder.
4939 # Supported since Solaris 2.6 (maybe 2.5.1?)
4940 if test "$GCC" = yes; then
4941 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
4942 else
4943 _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
4944 fi
4945 ;;
4946 esac
4947 _LT_TAGVAR(link_all_deplibs, $1)=yes
4948 ;;
4949
4950 sunos4*)
4951 if test "x$host_vendor" = xsequent; then
4952 # Use $CC to link under sequent, because it throws in some extra .o
4953 # files that make .init and .fini sections work.
4954 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
4955 else
4956 _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
4957 fi
4958 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
4959 _LT_TAGVAR(hardcode_direct, $1)=yes
4960 _LT_TAGVAR(hardcode_minus_L, $1)=yes
4961 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4962 ;;
4963
4964 sysv4)
4965 case $host_vendor in
4966 sni)
4967 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4968 _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
4969 ;;
4970 siemens)
4971 ## LD is ld it makes a PLAMLIB
4972 ## CC just makes a GrossModule.
4973 _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
4974 _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
4975 _LT_TAGVAR(hardcode_direct, $1)=no
4976 ;;
4977 motorola)
4978 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4979 _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
4980 ;;
4981 esac
4982 runpath_var='LD_RUN_PATH'
4983 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4984 ;;
4985
4986 sysv4.3*)
4987 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4988 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4989 _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
4990 ;;
4991
4992 sysv4*MP*)
4993 if test -d /usr/nec; then
4994 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
4995 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
4996 runpath_var=LD_RUN_PATH
4997 hardcode_runpath_var=yes
4998 _LT_TAGVAR(ld_shlibs, $1)=yes
4999 fi
5000 ;;
5001
5002 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
5003 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
5004 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5005 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5006 runpath_var='LD_RUN_PATH'
5007
5008 if test "$GCC" = yes; then
5009 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5010 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5011 else
5012 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5013 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5014 fi
5015 ;;
5016
5017 sysv5* | sco3.2v5* | sco5v6*)
5018 # Note: We can NOT use -z defs as we might desire, because we do not
5019 # link with -lc, and that would cause any symbols used from libc to
5020 # always be unresolved, which means just about no library would
5021 # ever link correctly. If we're not using GNU ld we use -z text
5022 # though, which does catch some bad symbols but isn't as heavy-handed
5023 # as -z defs.
5024 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
5025 _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
5026 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5027 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5028 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
5029 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
5030 _LT_TAGVAR(link_all_deplibs, $1)=yes
5031 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
5032 runpath_var='LD_RUN_PATH'
5033
5034 if test "$GCC" = yes; then
5035 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5036 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5037 else
5038 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5039 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
5040 fi
5041 ;;
5042
5043 uts4*)
5044 _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
5045 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5046 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5047 ;;
5048
5049 *)
5050 _LT_TAGVAR(ld_shlibs, $1)=no
5051 ;;
5052 esac
5053
5054 if test x$host_vendor = xsni; then
5055 case $host in
5056 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
5057 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
5058 ;;
5059 esac
5060 fi
5061 fi
5062 ])
5063 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
5064 test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
5065
5066 _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
5067
5068 _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
5069 _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
5070 _LT_DECL([], [extract_expsyms_cmds], [2],
5071 [The commands to extract the exported symbol list from a shared archive])
5072
5073 #
5074 # Do we need to explicitly link libc?
5075 #
5076 case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
5077 x|xyes)
5078 # Assume -lc should be added
5079 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5080
5081 if test "$enable_shared" = yes && test "$GCC" = yes; then
5082 case $_LT_TAGVAR(archive_cmds, $1) in
5083 *'~'*)
5084 # FIXME: we may have to deal with multi-command sequences.
5085 ;;
5086 '$CC '*)
5087 # Test whether the compiler implicitly links with -lc since on some
5088 # systems, -lgcc has to come before -lc. If gcc already passes -lc
5089 # to ld, don't add -lc before -lgcc.
5090 AC_MSG_CHECKING([whether -lc should be explicitly linked in])
5091 $RM -r conftest*
5092 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
5093
5094 if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
5095 soname=conftest
5096 lib=conftest
5097 libobjs=conftest.$ac_objext
5098 deplibs=
5099 wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
5100 pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
5101 compiler_flags=-v
5102 linker_flags=-v
5103 verstring=
5104 output_objdir=.
5105 libname=conftest
5106 lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
5107 _LT_TAGVAR(allow_undefined_flag, $1)=
5108 if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
5109 then
5110 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5111 else
5112 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5113 fi
5114 _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
5115 else
5116 cat conftest.err 1>&5
5117 fi
5118 $RM -r conftest*
5119 AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
5120 ;;
5121 esac
5122 fi
5123 ;;
5124 esac
5125
5126 _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
5127 [Whether or not to add -lc for building shared libraries])
5128 _LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
5129 [enable_shared_with_static_runtimes], [0],
5130 [Whether or not to disallow shared libs when runtime libs are static])
5131 _LT_TAGDECL([], [export_dynamic_flag_spec], [1],
5132 [Compiler flag to allow reflexive dlopens])
5133 _LT_TAGDECL([], [whole_archive_flag_spec], [1],
5134 [Compiler flag to generate shared objects directly from archives])
5135 _LT_TAGDECL([], [compiler_needs_object], [1],
5136 [Whether the compiler copes with passing no objects directly])
5137 _LT_TAGDECL([], [old_archive_from_new_cmds], [2],
5138 [Create an old-style archive from a shared archive])
5139 _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
5140 [Create a temporary old-style archive to link instead of a shared archive])
5141 _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
5142 _LT_TAGDECL([], [archive_expsym_cmds], [2])
5143 _LT_TAGDECL([], [module_cmds], [2],
5144 [Commands used to build a loadable module if different from building
5145 a shared archive.])
5146 _LT_TAGDECL([], [module_expsym_cmds], [2])
5147 _LT_TAGDECL([], [with_gnu_ld], [1],
5148 [Whether we are building with GNU ld or not])
5149 _LT_TAGDECL([], [allow_undefined_flag], [1],
5150 [Flag that allows shared libraries with undefined symbols to be built])
5151 _LT_TAGDECL([], [no_undefined_flag], [1],
5152 [Flag that enforces no undefined symbols])
5153 _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
5154 [Flag to hardcode $libdir into a binary during linking.
5155 This must work even if $libdir does not exist])
5156 _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
5157 [[If ld is used when linking, flag to hardcode $libdir into a binary
5158 during linking. This must work even if $libdir does not exist]])
5159 _LT_TAGDECL([], [hardcode_libdir_separator], [1],
5160 [Whether we need a single "-rpath" flag with a separated argument])
5161 _LT_TAGDECL([], [hardcode_direct], [0],
5162 [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
5163 DIR into the resulting binary])
5164 _LT_TAGDECL([], [hardcode_direct_absolute], [0],
5165 [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
5166 DIR into the resulting binary and the resulting library dependency is
5167 "absolute", i.e impossible to change by setting ${shlibpath_var} if the
5168 library is relocated])
5169 _LT_TAGDECL([], [hardcode_minus_L], [0],
5170 [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
5171 into the resulting binary])
5172 _LT_TAGDECL([], [hardcode_shlibpath_var], [0],
5173 [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
5174 into the resulting binary])
5175 _LT_TAGDECL([], [hardcode_automatic], [0],
5176 [Set to "yes" if building a shared library automatically hardcodes DIR
5177 into the library and all subsequent libraries and executables linked
5178 against it])
5179 _LT_TAGDECL([], [inherit_rpath], [0],
5180 [Set to yes if linker adds runtime paths of dependent libraries
5181 to runtime path list])
5182 _LT_TAGDECL([], [link_all_deplibs], [0],
5183 [Whether libtool must link a program against all its dependency libraries])
5184 _LT_TAGDECL([], [fix_srcfile_path], [1],
5185 [Fix the shell variable $srcfile for the compiler])
5186 _LT_TAGDECL([], [always_export_symbols], [0],
5187 [Set to "yes" if exported symbols are required])
5188 _LT_TAGDECL([], [export_symbols_cmds], [2],
5189 [The commands to list exported symbols])
5190 _LT_TAGDECL([], [exclude_expsyms], [1],
5191 [Symbols that should not be listed in the preloaded symbols])
5192 _LT_TAGDECL([], [include_expsyms], [1],
5193 [Symbols that must always be exported])
5194 _LT_TAGDECL([], [prelink_cmds], [2],
5195 [Commands necessary for linking programs (against libraries) with templates])
5196 _LT_TAGDECL([], [file_list_spec], [1],
5197 [Specify filename containing input files])
5198 dnl FIXME: Not yet implemented
5199 dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
5200 dnl [Compiler flag to generate thread safe objects])
5201 ])# _LT_LINKER_SHLIBS
5202
5203
5204 # _LT_LANG_C_CONFIG([TAG])
5205 # ------------------------
5206 # Ensure that the configuration variables for a C compiler are suitably
5207 # defined. These variables are subsequently used by _LT_CONFIG to write
5208 # the compiler configuration to `libtool'.
5209 m4_defun([_LT_LANG_C_CONFIG],
5210 [m4_require([_LT_DECL_EGREP])dnl
5211 lt_save_CC="$CC"
5212 AC_LANG_PUSH(C)
5213
5214 # Source file extension for C test sources.
5215 ac_ext=c
5216
5217 # Object file extension for compiled C test sources.
5218 objext=o
5219 _LT_TAGVAR(objext, $1)=$objext
5220
5221 # Code to be used in simple compile tests
5222 lt_simple_compile_test_code="int some_variable = 0;"
5223
5224 # Code to be used in simple link tests
5225 lt_simple_link_test_code='int main(){return(0);}'
5226
5227 _LT_TAG_COMPILER
5228 # Save the default compiler, since it gets overwritten when the other
5229 # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
5230 compiler_DEFAULT=$CC
5231
5232 # save warnings/boilerplate of simple test code
5233 _LT_COMPILER_BOILERPLATE
5234 _LT_LINKER_BOILERPLATE
5235
5236 if test -n "$compiler"; then
5237 _LT_COMPILER_NO_RTTI($1)
5238 _LT_COMPILER_PIC($1)
5239 _LT_COMPILER_C_O($1)
5240 _LT_COMPILER_FILE_LOCKS($1)
5241 _LT_LINKER_SHLIBS($1)
5242 _LT_SYS_DYNAMIC_LINKER($1)
5243 _LT_LINKER_HARDCODE_LIBPATH($1)
5244 LT_SYS_DLOPEN_SELF
5245 _LT_CMD_STRIPLIB
5246
5247 # Report which library types will actually be built
5248 AC_MSG_CHECKING([if libtool supports shared libraries])
5249 AC_MSG_RESULT([$can_build_shared])
5250
5251 AC_MSG_CHECKING([whether to build shared libraries])
5252 test "$can_build_shared" = "no" && enable_shared=no
5253
5254 # On AIX, shared libraries and static libraries use the same namespace, and
5255 # are all built from PIC.
5256 case $host_os in
5257 aix3*)
5258 test "$enable_shared" = yes && enable_static=no
5259 if test -n "$RANLIB"; then
5260 archive_cmds="$archive_cmds~\$RANLIB \$lib"
5261 postinstall_cmds='$RANLIB $lib'
5262 fi
5263 ;;
5264
5265 aix[[4-9]]*)
5266 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
5267 test "$enable_shared" = yes && enable_static=no
5268 fi
5269 ;;
5270 esac
5271 AC_MSG_RESULT([$enable_shared])
5272
5273 AC_MSG_CHECKING([whether to build static libraries])
5274 # Make sure either enable_shared or enable_static is yes.
5275 test "$enable_shared" = yes || enable_static=yes
5276 AC_MSG_RESULT([$enable_static])
5277
5278 _LT_CONFIG($1)
5279 fi
5280 AC_LANG_POP
5281 CC="$lt_save_CC"
5282 ])# _LT_LANG_C_CONFIG
5283
5284
5285 # _LT_PROG_CXX
5286 # ------------
5287 # Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
5288 # compiler, we have our own version here.
5289 m4_defun([_LT_PROG_CXX],
5290 [
5291 pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
5292 AC_PROG_CXX
5293 if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
5294 ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
5295 (test "X$CXX" != "Xg++"))) ; then
5296 AC_PROG_CXXCPP
5297 else
5298 _lt_caught_CXX_error=yes
5299 fi
5300 popdef([AC_MSG_ERROR])
5301 ])# _LT_PROG_CXX
5302
5303 dnl aclocal-1.4 backwards compatibility:
5304 dnl AC_DEFUN([_LT_PROG_CXX], [])
5305
5306
5307 # _LT_LANG_CXX_CONFIG([TAG])
5308 # --------------------------
5309 # Ensure that the configuration variables for a C++ compiler are suitably
5310 # defined. These variables are subsequently used by _LT_CONFIG to write
5311 # the compiler configuration to `libtool'.
5312 m4_defun([_LT_LANG_CXX_CONFIG],
5313 [AC_REQUIRE([_LT_PROG_CXX])dnl
5314 m4_require([_LT_FILEUTILS_DEFAULTS])dnl
5315 m4_require([_LT_DECL_EGREP])dnl
5316
5317 AC_LANG_PUSH(C++)
5318 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5319 _LT_TAGVAR(allow_undefined_flag, $1)=
5320 _LT_TAGVAR(always_export_symbols, $1)=no
5321 _LT_TAGVAR(archive_expsym_cmds, $1)=
5322 _LT_TAGVAR(compiler_needs_object, $1)=no
5323 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
5324 _LT_TAGVAR(hardcode_direct, $1)=no
5325 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
5326 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
5327 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
5328 _LT_TAGVAR(hardcode_libdir_separator, $1)=
5329 _LT_TAGVAR(hardcode_minus_L, $1)=no
5330 _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
5331 _LT_TAGVAR(hardcode_automatic, $1)=no
5332 _LT_TAGVAR(inherit_rpath, $1)=no
5333 _LT_TAGVAR(module_cmds, $1)=
5334 _LT_TAGVAR(module_expsym_cmds, $1)=
5335 _LT_TAGVAR(link_all_deplibs, $1)=unknown
5336 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
5337 _LT_TAGVAR(no_undefined_flag, $1)=
5338 _LT_TAGVAR(whole_archive_flag_spec, $1)=
5339 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
5340
5341 # Source file extension for C++ test sources.
5342 ac_ext=cpp
5343
5344 # Object file extension for compiled C++ test sources.
5345 objext=o
5346 _LT_TAGVAR(objext, $1)=$objext
5347
5348 # No sense in running all these tests if we already determined that
5349 # the CXX compiler isn't working. Some variables (like enable_shared)
5350 # are currently assumed to apply to all compilers on this platform,
5351 # and will be corrupted by setting them based on a non-working compiler.
5352 if test "$_lt_caught_CXX_error" != yes; then
5353 # Code to be used in simple compile tests
5354 lt_simple_compile_test_code="int some_variable = 0;"
5355
5356 # Code to be used in simple link tests
5357 lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
5358
5359 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
5360 _LT_TAG_COMPILER
5361
5362 # save warnings/boilerplate of simple test code
5363 _LT_COMPILER_BOILERPLATE
5364 _LT_LINKER_BOILERPLATE
5365
5366 # Allow CC to be a program name with arguments.
5367 lt_save_CC=$CC
5368 lt_save_LD=$LD
5369 lt_save_GCC=$GCC
5370 GCC=$GXX
5371 lt_save_with_gnu_ld=$with_gnu_ld
5372 lt_save_path_LD=$lt_cv_path_LD
5373 if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
5374 lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
5375 else
5376 $as_unset lt_cv_prog_gnu_ld
5377 fi
5378 if test -n "${lt_cv_path_LDCXX+set}"; then
5379 lt_cv_path_LD=$lt_cv_path_LDCXX
5380 else
5381 $as_unset lt_cv_path_LD
5382 fi
5383 test -z "${LDCXX+set}" || LD=$LDCXX
5384 CC=${CXX-"c++"}
5385 compiler=$CC
5386 _LT_TAGVAR(compiler, $1)=$CC
5387 _LT_CC_BASENAME([$compiler])
5388
5389 if test -n "$compiler"; then
5390 # We don't want -fno-exception when compiling C++ code, so set the
5391 # no_builtin_flag separately
5392 if test "$GXX" = yes; then
5393 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
5394 else
5395 _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
5396 fi
5397
5398 if test "$GXX" = yes; then
5399 # Set up default GNU C++ configuration
5400
5401 LT_PATH_LD
5402
5403 # Check if GNU C++ uses GNU ld as the underlying linker, since the
5404 # archiving commands below assume that GNU ld is being used.
5405 if test "$with_gnu_ld" = yes; then
5406 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5407 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
5408
5409 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5410 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5411
5412 # If archive_cmds runs LD, not CC, wlarc should be empty
5413 # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
5414 # investigate it a little bit more. (MM)
5415 wlarc='${wl}'
5416
5417 # ancient GNU ld didn't support --whole-archive et. al.
5418 if eval "`$CC -print-prog-name=ld` --help 2>&1" |
5419 $GREP 'no-whole-archive' > /dev/null; then
5420 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
5421 else
5422 _LT_TAGVAR(whole_archive_flag_spec, $1)=
5423 fi
5424 else
5425 with_gnu_ld=no
5426 wlarc=
5427
5428 # A generic and very simple default shared library creation
5429 # command for GNU C++ for the case where it uses the native
5430 # linker, instead of GNU ld. If possible, this setting should
5431 # overridden to take advantage of the native linker features on
5432 # the platform it is being used on.
5433 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
5434 fi
5435
5436 # Commands to make compiler produce verbose output that lists
5437 # what "hidden" libraries, object files and flags are used when
5438 # linking a shared library.
5439 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
5440
5441 else
5442 GXX=no
5443 with_gnu_ld=no
5444 wlarc=
5445 fi
5446
5447 # PORTME: fill in a description of your system's C++ link characteristics
5448 AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
5449 _LT_TAGVAR(ld_shlibs, $1)=yes
5450 case $host_os in
5451 aix3*)
5452 # FIXME: insert proper C++ library support
5453 _LT_TAGVAR(ld_shlibs, $1)=no
5454 ;;
5455 aix[[4-9]]*)
5456 if test "$host_cpu" = ia64; then
5457 # On IA64, the linker does run time linking by default, so we don't
5458 # have to do anything special.
5459 aix_use_runtimelinking=no
5460 exp_sym_flag='-Bexport'
5461 no_entry_flag=""
5462 else
5463 aix_use_runtimelinking=no
5464
5465 # Test if we are trying to use run time linking or normal
5466 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
5467 # need to do runtime linking.
5468 case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
5469 for ld_flag in $LDFLAGS; do
5470 case $ld_flag in
5471 *-brtl*)
5472 aix_use_runtimelinking=yes
5473 break
5474 ;;
5475 esac
5476 done
5477 ;;
5478 esac
5479
5480 exp_sym_flag='-bexport'
5481 no_entry_flag='-bnoentry'
5482 fi
5483
5484 # When large executables or shared objects are built, AIX ld can
5485 # have problems creating the table of contents. If linking a library
5486 # or program results in "error TOC overflow" add -mminimal-toc to
5487 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
5488 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
5489
5490 _LT_TAGVAR(archive_cmds, $1)=''
5491 _LT_TAGVAR(hardcode_direct, $1)=yes
5492 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
5493 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
5494 _LT_TAGVAR(link_all_deplibs, $1)=yes
5495 _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
5496
5497 if test "$GXX" = yes; then
5498 case $host_os in aix4.[[012]]|aix4.[[012]].*)
5499 # We only want to do this on AIX 4.2 and lower, the check
5500 # below for broken collect2 doesn't work under 4.3+
5501 collect2name=`${CC} -print-prog-name=collect2`
5502 if test -f "$collect2name" &&
5503 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
5504 then
5505 # We have reworked collect2
5506 :
5507 else
5508 # We have old collect2
5509 _LT_TAGVAR(hardcode_direct, $1)=unsupported
5510 # It fails to find uninstalled libraries when the uninstalled
5511 # path is not listed in the libpath. Setting hardcode_minus_L
5512 # to unsupported forces relinking
5513 _LT_TAGVAR(hardcode_minus_L, $1)=yes
5514 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5515 _LT_TAGVAR(hardcode_libdir_separator, $1)=
5516 fi
5517 esac
5518 shared_flag='-shared'
5519 if test "$aix_use_runtimelinking" = yes; then
5520 shared_flag="$shared_flag "'${wl}-G'
5521 fi
5522 else
5523 # not using gcc
5524 if test "$host_cpu" = ia64; then
5525 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
5526 # chokes on -Wl,-G. The following line is correct:
5527 shared_flag='-G'
5528 else
5529 if test "$aix_use_runtimelinking" = yes; then
5530 shared_flag='${wl}-G'
5531 else
5532 shared_flag='${wl}-bM:SRE'
5533 fi
5534 fi
5535 fi
5536
5537 # It seems that -bexpall does not export symbols beginning with
5538 # underscore (_), so it is better to generate a list of symbols to
5539 # export.
5540 _LT_TAGVAR(always_export_symbols, $1)=yes
5541 if test "$aix_use_runtimelinking" = yes; then
5542 # Warning - without using the other runtime loading flags (-brtl),
5543 # -berok will link without error, but may produce a broken library.
5544 _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
5545 # Determine the default libpath from the value encoded in an empty
5546 # executable.
5547 _LT_SYS_MODULE_PATH_AIX
5548 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
5549
5550 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
5551 else
5552 if test "$host_cpu" = ia64; then
5553 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
5554 _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
5555 _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
5556 else
5557 # Determine the default libpath from the value encoded in an
5558 # empty executable.
5559 _LT_SYS_MODULE_PATH_AIX
5560 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
5561 # Warning - without using the other run time loading flags,
5562 # -berok will link without error, but may produce a broken library.
5563 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
5564 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
5565 # Exported symbols can be pulled into shared objects from archives
5566 _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
5567 _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
5568 # This is similar to how AIX traditionally builds its shared
5569 # libraries.
5570 _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
5571 fi
5572 fi
5573 ;;
5574
5575 beos*)
5576 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
5577 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
5578 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
5579 # support --undefined. This deserves some investigation. FIXME
5580 _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5581 else
5582 _LT_TAGVAR(ld_shlibs, $1)=no
5583 fi
5584 ;;
5585
5586 chorus*)
5587 case $cc_basename in
5588 *)
5589 # FIXME: insert proper C++ library support
5590 _LT_TAGVAR(ld_shlibs, $1)=no
5591 ;;
5592 esac
5593 ;;
5594
5595 cygwin* | mingw* | pw32*)
5596 # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
5597 # as there is no search path for DLLs.
5598 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
5599 _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
5600 _LT_TAGVAR(always_export_symbols, $1)=no
5601 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
5602
5603 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
5604 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
5605 # If the export-symbols file already is a .def file (1st line
5606 # is EXPORTS), use it as is; otherwise, prepend...
5607 _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
5608 cp $export_symbols $output_objdir/$soname.def;
5609 else
5610 echo EXPORTS > $output_objdir/$soname.def;
5611 cat $export_symbols >> $output_objdir/$soname.def;
5612 fi~
5613 $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
5614 else
5615 _LT_TAGVAR(ld_shlibs, $1)=no
5616 fi
5617 ;;
5618 darwin* | rhapsody*)
5619 _LT_DARWIN_LINKER_FEATURES($1)
5620 ;;
5621
5622 dgux*)
5623 case $cc_basename in
5624 ec++*)
5625 # FIXME: insert proper C++ library support
5626 _LT_TAGVAR(ld_shlibs, $1)=no
5627 ;;
5628 ghcx*)
5629 # Green Hills C++ Compiler
5630 # FIXME: insert proper C++ library support
5631 _LT_TAGVAR(ld_shlibs, $1)=no
5632 ;;
5633 *)
5634 # FIXME: insert proper C++ library support
5635 _LT_TAGVAR(ld_shlibs, $1)=no
5636 ;;
5637 esac
5638 ;;
5639
5640 freebsd[[12]]*)
5641 # C++ shared libraries reported to be fairly broken before
5642 # switch to ELF
5643 _LT_TAGVAR(ld_shlibs, $1)=no
5644 ;;
5645
5646 freebsd-elf*)
5647 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5648 ;;
5649
5650 freebsd* | dragonfly*)
5651 # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
5652 # conventions
5653 _LT_TAGVAR(ld_shlibs, $1)=yes
5654 ;;
5655
5656 gnu*)
5657 ;;
5658
5659 hpux9*)
5660 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
5661 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5662 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5663 _LT_TAGVAR(hardcode_direct, $1)=yes
5664 _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
5665 # but as the default
5666 # location of the library.
5667
5668 case $cc_basename in
5669 CC*)
5670 # FIXME: insert proper C++ library support
5671 _LT_TAGVAR(ld_shlibs, $1)=no
5672 ;;
5673 aCC*)
5674 _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
5675 # Commands to make compiler produce verbose output that lists
5676 # what "hidden" libraries, object files and flags are used when
5677 # linking a shared library.
5678 #
5679 # There doesn't appear to be a way to prevent this compiler from
5680 # explicitly linking system object files so we need to strip them
5681 # from the output so that they don't get included in the library
5682 # dependencies.
5683 output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
5684 ;;
5685 *)
5686 if test "$GXX" = yes; then
5687 _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
5688 else
5689 # FIXME: insert proper C++ library support
5690 _LT_TAGVAR(ld_shlibs, $1)=no
5691 fi
5692 ;;
5693 esac
5694 ;;
5695
5696 hpux10*|hpux11*)
5697 if test $with_gnu_ld = no; then
5698 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
5699 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5700
5701 case $host_cpu in
5702 hppa*64*|ia64*)
5703 ;;
5704 *)
5705 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5706 ;;
5707 esac
5708 fi
5709 case $host_cpu in
5710 hppa*64*|ia64*)
5711 _LT_TAGVAR(hardcode_direct, $1)=no
5712 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5713 ;;
5714 *)
5715 _LT_TAGVAR(hardcode_direct, $1)=yes
5716 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
5717 _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
5718 # but as the default
5719 # location of the library.
5720 ;;
5721 esac
5722
5723 case $cc_basename in
5724 CC*)
5725 # FIXME: insert proper C++ library support
5726 _LT_TAGVAR(ld_shlibs, $1)=no
5727 ;;
5728 aCC*)
5729 case $host_cpu in
5730 hppa*64*)
5731 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5732 ;;
5733 ia64*)
5734 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5735 ;;
5736 *)
5737 _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5738 ;;
5739 esac
5740 # Commands to make compiler produce verbose output that lists
5741 # what "hidden" libraries, object files and flags are used when
5742 # linking a shared library.
5743 #
5744 # There doesn't appear to be a way to prevent this compiler from
5745 # explicitly linking system object files so we need to strip them
5746 # from the output so that they don't get included in the library
5747 # dependencies.
5748 output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
5749 ;;
5750 *)
5751 if test "$GXX" = yes; then
5752 if test $with_gnu_ld = no; then
5753 case $host_cpu in
5754 hppa*64*)
5755 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5756 ;;
5757 ia64*)
5758 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5759 ;;
5760 *)
5761 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5762 ;;
5763 esac
5764 fi
5765 else
5766 # FIXME: insert proper C++ library support
5767 _LT_TAGVAR(ld_shlibs, $1)=no
5768 fi
5769 ;;
5770 esac
5771 ;;
5772
5773 interix[[3-9]]*)
5774 _LT_TAGVAR(hardcode_direct, $1)=no
5775 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5776 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5777 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
5778 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
5779 # Instead, shared libraries are loaded at an image base (0x10000000 by
5780 # default) and relocated if they conflict, which is a slow very memory
5781 # consuming and fragmenting process. To avoid this, we pick a random,
5782 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
5783 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
5784 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
5785 _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
5786 ;;
5787 irix5* | irix6*)
5788 case $cc_basename in
5789 CC*)
5790 # SGI C++
5791 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
5792
5793 # Archives containing C++ object files must be created using
5794 # "CC -ar", where "CC" is the IRIX C++ compiler. This is
5795 # necessary to make sure instantiated templates are included
5796 # in the archive.
5797 _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
5798 ;;
5799 *)
5800 if test "$GXX" = yes; then
5801 if test "$with_gnu_ld" = no; then
5802 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
5803 else
5804 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
5805 fi
5806 fi
5807 _LT_TAGVAR(link_all_deplibs, $1)=yes
5808 ;;
5809 esac
5810 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5811 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5812 _LT_TAGVAR(inherit_rpath, $1)=yes
5813 ;;
5814
5815 linux* | k*bsd*-gnu)
5816 case $cc_basename in
5817 KCC*)
5818 # Kuck and Associates, Inc. (KAI) C++ Compiler
5819
5820 # KCC will only create a shared library if the output file
5821 # ends with ".so" (or ".sl" for HP-UX), so rename the library
5822 # to its proper name (with version) after linking.
5823 _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
5824 _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
5825 # Commands to make compiler produce verbose output that lists
5826 # what "hidden" libraries, object files and flags are used when
5827 # linking a shared library.
5828 #
5829 # There doesn't appear to be a way to prevent this compiler from
5830 # explicitly linking system object files so we need to strip them
5831 # from the output so that they don't get included in the library
5832 # dependencies.
5833 output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
5834
5835 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5836 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5837
5838 # Archives containing C++ object files must be created using
5839 # "CC -Bstatic", where "CC" is the KAI C++ compiler.
5840 _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
5841 ;;
5842 icpc* | ecpc* )
5843 # Intel C++
5844 with_gnu_ld=yes
5845 # version 8.0 and above of icpc choke on multiply defined symbols
5846 # if we add $predep_objects and $postdep_objects, however 7.1 and
5847 # earlier do not add the objects themselves.
5848 case `$CC -V 2>&1` in
5849 *"Version 7."*)
5850 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5851 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
5852 ;;
5853 *) # Version 8.0 or newer
5854 tmp_idyn=
5855 case $host_cpu in
5856 ia64*) tmp_idyn=' -i_dynamic';;
5857 esac
5858 _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5859 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
5860 ;;
5861 esac
5862 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
5863 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
5864 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5865 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
5866 ;;
5867 pgCC* | pgcpp*)
5868 # Portland Group C++ compiler
5869 case `$CC -V` in
5870 *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
5871 _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
5872 rm -rf $tpldir~
5873 $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
5874 compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
5875 _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
5876 rm -rf $tpldir~
5877 $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
5878 $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
5879 $RANLIB $oldlib'
5880 _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
5881 rm -rf $tpldir~
5882 $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
5883 $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
5884 _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
5885 rm -rf $tpldir~
5886 $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
5887 $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
5888 ;;
5889 *) # Version 6 will use weak symbols
5890 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
5891 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
5892 ;;
5893 esac
5894
5895 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
5896 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5897 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
5898 ;;
5899 cxx*)
5900 # Compaq C++
5901 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
5902 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
5903
5904 runpath_var=LD_RUN_PATH
5905 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
5906 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
5907
5908 # Commands to make compiler produce verbose output that lists
5909 # what "hidden" libraries, object files and flags are used when
5910 # linking a shared library.
5911 #
5912 # There doesn't appear to be a way to prevent this compiler from
5913 # explicitly linking system object files so we need to strip them
5914 # from the output so that they don't get included in the library
5915 # dependencies.
5916 output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
5917 ;;
5918 xl*)
5919 # IBM XL 8.0 on PPC, with GNU ld
5920 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
5921 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
5922 _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
5923 if test "x$supports_anon_versioning" = xyes; then
5924 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
5925 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
5926 echo "local: *; };" >> $output_objdir/$libname.ver~
5927 $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
5928 fi
5929 ;;
5930 *)
5931 case `$CC -V 2>&1 | sed 5q` in
5932 *Sun\ C*)
5933 # Sun C++ 5.9
5934 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
5935 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
5936 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
5937 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
5938 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
5939 _LT_TAGVAR(compiler_needs_object, $1)=yes
5940
5941 # Not sure whether something based on
5942 # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
5943 # would be better.
5944 output_verbose_link_cmd='echo'
5945
5946 # Archives containing C++ object files must be created using
5947 # "CC -xar", where "CC" is the Sun C++ compiler. This is
5948 # necessary to make sure instantiated templates are included
5949 # in the archive.
5950 _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
5951 ;;
5952 esac
5953 ;;
5954 esac
5955 ;;
5956
5957 lynxos*)
5958 # FIXME: insert proper C++ library support
5959 _LT_TAGVAR(ld_shlibs, $1)=no
5960 ;;
5961
5962 m88k*)
5963 # FIXME: insert proper C++ library support
5964 _LT_TAGVAR(ld_shlibs, $1)=no
5965 ;;
5966
5967 mvs*)
5968 case $cc_basename in
5969 cxx*)
5970 # FIXME: insert proper C++ library support
5971 _LT_TAGVAR(ld_shlibs, $1)=no
5972 ;;
5973 *)
5974 # FIXME: insert proper C++ library support
5975 _LT_TAGVAR(ld_shlibs, $1)=no
5976 ;;
5977 esac
5978 ;;
5979
5980 netbsd*)
5981 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
5982 _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
5983 wlarc=
5984 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
5985 _LT_TAGVAR(hardcode_direct, $1)=yes
5986 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
5987 fi
5988 # Workaround some broken pre-1.5 toolchains
5989 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
5990 ;;
5991
5992 *nto* | *qnx*)
5993 _LT_TAGVAR(ld_shlibs, $1)=yes
5994 ;;
5995
5996 openbsd2*)
5997 # C++ shared libraries are fairly broken
5998 _LT_TAGVAR(ld_shlibs, $1)=no
5999 ;;
6000
6001 openbsd*)
6002 if test -f /usr/libexec/ld.so; then
6003 _LT_TAGVAR(hardcode_direct, $1)=yes
6004 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6005 _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
6006 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
6007 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
6008 if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
6009 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
6010 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
6011 _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
6012 fi
6013 output_verbose_link_cmd=echo
6014 else
6015 _LT_TAGVAR(ld_shlibs, $1)=no
6016 fi
6017 ;;
6018
6019 osf3* | osf4* | osf5*)
6020 case $cc_basename in
6021 KCC*)
6022 # Kuck and Associates, Inc. (KAI) C++ Compiler
6023
6024 # KCC will only create a shared library if the output file
6025 # ends with ".so" (or ".sl" for HP-UX), so rename the library
6026 # to its proper name (with version) after linking.
6027 _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
6028
6029 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
6030 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6031
6032 # Archives containing C++ object files must be created using
6033 # the KAI C++ compiler.
6034 case $host in
6035 osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
6036 *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
6037 esac
6038 ;;
6039 RCC*)
6040 # Rational C++ 2.4.1
6041 # FIXME: insert proper C++ library support
6042 _LT_TAGVAR(ld_shlibs, $1)=no
6043 ;;
6044 cxx*)
6045 case $host in
6046 osf3*)
6047 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
6048 _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
6049 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
6050 ;;
6051 *)
6052 _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
6053 _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
6054 _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
6055 echo "-hidden">> $lib.exp~
6056 $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
6057 $RM $lib.exp'
6058 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
6059 ;;
6060 esac
6061
6062 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6063
6064 # Commands to make compiler produce verbose output that lists
6065 # what "hidden" libraries, object files and flags are used when
6066 # linking a shared library.
6067 #
6068 # There doesn't appear to be a way to prevent this compiler from
6069 # explicitly linking system object files so we need to strip them
6070 # from the output so that they don't get included in the library
6071 # dependencies.
6072 output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
6073 ;;
6074 *)
6075 if test "$GXX" = yes && test "$with_gnu_ld" = no; then
6076 _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
6077 case $host in
6078 osf3*)
6079 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
6080 ;;
6081 *)
6082 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
6083 ;;
6084 esac
6085
6086 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
6087 _LT_TAGVAR(hardcode_libdir_separator, $1)=:
6088
6089 # Commands to make compiler produce verbose output that lists
6090 # what "hidden" libraries, object files and flags are used when
6091 # linking a shared library.
6092 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6093
6094 else
6095 # FIXME: insert proper C++ library support
6096 _LT_TAGVAR(ld_shlibs, $1)=no
6097 fi
6098 ;;
6099 esac
6100 ;;
6101
6102 psos*)
6103 # FIXME: insert proper C++ library support
6104 _LT_TAGVAR(ld_shlibs, $1)=no
6105 ;;
6106
6107 sunos4*)
6108 case $cc_basename in
6109 CC*)
6110 # Sun C++ 4.x
6111 # FIXME: insert proper C++ library support
6112 _LT_TAGVAR(ld_shlibs, $1)=no
6113 ;;
6114 lcc*)
6115 # Lucid
6116 # FIXME: insert proper C++ library support
6117 _LT_TAGVAR(ld_shlibs, $1)=no
6118 ;;
6119 *)
6120 # FIXME: insert proper C++ library support
6121 _LT_TAGVAR(ld_shlibs, $1)=no
6122 ;;
6123 esac
6124 ;;
6125
6126 solaris*)
6127 case $cc_basename in
6128 CC*)
6129 # Sun C++ 4.2, 5.x and Centerline C++
6130 _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
6131 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
6132 _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
6133 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6134 $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
6135
6136 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
6137 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6138 case $host_os in
6139 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
6140 *)
6141 # The compiler driver will combine and reorder linker options,
6142 # but understands `-z linker_flag'.
6143 # Supported since Solaris 2.6 (maybe 2.5.1?)
6144 _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
6145 ;;
6146 esac
6147 _LT_TAGVAR(link_all_deplibs, $1)=yes
6148
6149 output_verbose_link_cmd='echo'
6150
6151 # Archives containing C++ object files must be created using
6152 # "CC -xar", where "CC" is the Sun C++ compiler. This is
6153 # necessary to make sure instantiated templates are included
6154 # in the archive.
6155 _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
6156 ;;
6157 gcx*)
6158 # Green Hills C++ Compiler
6159 _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6160
6161 # The C++ compiler must be used to create the archive.
6162 _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
6163 ;;
6164 *)
6165 # GNU C++ compiler with Solaris linker
6166 if test "$GXX" = yes && test "$with_gnu_ld" = no; then
6167 _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
6168 if $CC --version | $GREP -v '^2\.7' > /dev/null; then
6169 _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6170 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6171 $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
6172
6173 # Commands to make compiler produce verbose output that lists
6174 # what "hidden" libraries, object files and flags are used when
6175 # linking a shared library.
6176 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6177 else
6178 # g++ 2.7 appears to require `-G' NOT `-shared' on this
6179 # platform.
6180 _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
6181 _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
6182 $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
6183
6184 # Commands to make compiler produce verbose output that lists
6185 # what "hidden" libraries, object files and flags are used when
6186 # linking a shared library.
6187 output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
6188 fi
6189
6190 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
6191 case $host_os in
6192 solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
6193 *)
6194 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
6195 ;;
6196 esac
6197 fi
6198 ;;
6199 esac
6200 ;;
6201
6202 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
6203 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
6204 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6205 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6206 runpath_var='LD_RUN_PATH'
6207
6208 case $cc_basename in
6209 CC*)
6210 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6211 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6212 ;;
6213 *)
6214 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6215 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6216 ;;
6217 esac
6218 ;;
6219
6220 sysv5* | sco3.2v5* | sco5v6*)
6221 # Note: We can NOT use -z defs as we might desire, because we do not
6222 # link with -lc, and that would cause any symbols used from libc to
6223 # always be unresolved, which means just about no library would
6224 # ever link correctly. If we're not using GNU ld we use -z text
6225 # though, which does catch some bad symbols but isn't as heavy-handed
6226 # as -z defs.
6227 _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
6228 _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
6229 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6230 _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
6231 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
6232 _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
6233 _LT_TAGVAR(link_all_deplibs, $1)=yes
6234 _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
6235 runpath_var='LD_RUN_PATH'
6236
6237 case $cc_basename in
6238 CC*)
6239 _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6240 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6241 ;;
6242 *)
6243 _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6244 _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
6245 ;;
6246 esac
6247 ;;
6248
6249 tandem*)
6250 case $cc_basename in
6251 NCC*)
6252 # NonStop-UX NCC 3.20
6253 # FIXME: insert proper C++ library support
6254 _LT_TAGVAR(ld_shlibs, $1)=no
6255 ;;
6256 *)
6257 # FIXME: insert proper C++ library support
6258 _LT_TAGVAR(ld_shlibs, $1)=no
6259 ;;
6260 esac
6261 ;;
6262
6263 vxworks*)
6264 # FIXME: insert proper C++ library support
6265 _LT_TAGVAR(ld_shlibs, $1)=no
6266 ;;
6267
6268 *)
6269 # FIXME: insert proper C++ library support
6270 _LT_TAGVAR(ld_shlibs, $1)=no
6271 ;;
6272 esac
6273
6274 AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
6275 test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
6276
6277 _LT_TAGVAR(GCC, $1)="$GXX"
6278 _LT_TAGVAR(LD, $1)="$LD"
6279
6280 ## CAVEAT EMPTOR:
6281 ## There is no encapsulation within the following macros, do not change
6282 ## the running order or otherwise move them around unless you know exactly
6283 ## what you are doing...
6284 _LT_SYS_HIDDEN_LIBDEPS($1)
6285 _LT_COMPILER_PIC($1)
6286 _LT_COMPILER_C_O($1)
6287 _LT_COMPILER_FILE_LOCKS($1)
6288 _LT_LINKER_SHLIBS($1)
6289 _LT_SYS_DYNAMIC_LINKER($1)
6290 _LT_LINKER_HARDCODE_LIBPATH($1)
6291
6292 _LT_CONFIG($1)
6293 fi # test -n "$compiler"
6294
6295 CC=$lt_save_CC
6296 LDCXX=$LD
6297 LD=$lt_save_LD
6298 GCC=$lt_save_GCC
6299 with_gnu_ld=$lt_save_with_gnu_ld
6300 lt_cv_path_LDCXX=$lt_cv_path_LD
6301 lt_cv_path_LD=$lt_save_path_LD
6302 lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
6303 lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
6304 fi # test "$_lt_caught_CXX_error" != yes
6305
6306 AC_LANG_POP
6307 ])# _LT_LANG_CXX_CONFIG
6308
6309
6310 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
6311 # ---------------------------------
6312 # Figure out "hidden" library dependencies from verbose
6313 # compiler output when linking a shared library.
6314 # Parse the compiler output and extract the necessary
6315 # objects, libraries and library flags.
6316 m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
6317 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
6318 # Dependencies to place before and after the object being linked:
6319 _LT_TAGVAR(predep_objects, $1)=
6320 _LT_TAGVAR(postdep_objects, $1)=
6321 _LT_TAGVAR(predeps, $1)=
6322 _LT_TAGVAR(postdeps, $1)=
6323 _LT_TAGVAR(compiler_lib_search_path, $1)=
6324
6325 dnl we can't use the lt_simple_compile_test_code here,
6326 dnl because it contains code intended for an executable,
6327 dnl not a library. It's possible we should let each
6328 dnl tag define a new lt_????_link_test_code variable,
6329 dnl but it's only used here...
6330 m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
6331 int a;
6332 void foo (void) { a = 0; }
6333 _LT_EOF
6334 ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
6335 class Foo
6336 {
6337 public:
6338 Foo (void) { a = 0; }
6339 private:
6340 int a;
6341 };
6342 _LT_EOF
6343 ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
6344 subroutine foo
6345 implicit none
6346 integer*4 a
6347 a=0
6348 return
6349 end
6350 _LT_EOF
6351 ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
6352 subroutine foo
6353 implicit none
6354 integer a
6355 a=0
6356 return
6357 end
6358 _LT_EOF
6359 ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
6360 public class foo {
6361 private int a;
6362 public void bar (void) {
6363 a = 0;
6364 }
6365 };
6366 _LT_EOF
6367 ])
6368 dnl Parse the compiler output and extract the necessary
6369 dnl objects, libraries and library flags.
6370 if AC_TRY_EVAL(ac_compile); then
6371 # Parse the compiler output and extract the necessary
6372 # objects, libraries and library flags.
6373
6374 # Sentinel used to keep track of whether or not we are before
6375 # the conftest object file.
6376 pre_test_object_deps_done=no
6377
6378 for p in `eval "$output_verbose_link_cmd"`; do
6379 case $p in
6380
6381 -L* | -R* | -l*)
6382 # Some compilers place space between "-{L,R}" and the path.
6383 # Remove the space.
6384 if test $p = "-L" ||
6385 test $p = "-R"; then
6386 prev=$p
6387 continue
6388 else
6389 prev=
6390 fi
6391
6392 if test "$pre_test_object_deps_done" = no; then
6393 case $p in
6394 -L* | -R*)
6395 # Internal compiler library paths should come after those
6396 # provided the user. The postdeps already come after the
6397 # user supplied libs so there is no need to process them.
6398 if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
6399 _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
6400 else
6401 _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
6402 fi
6403 ;;
6404 # The "-l" case would never come before the object being
6405 # linked, so don't bother handling this case.
6406 esac
6407 else
6408 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
6409 _LT_TAGVAR(postdeps, $1)="${prev}${p}"
6410 else
6411 _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
6412 fi
6413 fi
6414 ;;
6415
6416 *.$objext)
6417 # This assumes that the test object file only shows up
6418 # once in the compiler output.
6419 if test "$p" = "conftest.$objext"; then
6420 pre_test_object_deps_done=yes
6421 continue
6422 fi
6423
6424 if test "$pre_test_object_deps_done" = no; then
6425 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
6426 _LT_TAGVAR(predep_objects, $1)="$p"
6427 else
6428 _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
6429 fi
6430 else
6431 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
6432 _LT_TAGVAR(postdep_objects, $1)="$p"
6433 else
6434 _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
6435 fi
6436 fi
6437 ;;
6438
6439 *) ;; # Ignore the rest.
6440
6441 esac
6442 done
6443
6444 # Clean up.
6445 rm -f a.out a.exe
6446 else
6447 echo "libtool.m4: error: problem compiling $1 test program"
6448 fi
6449
6450 $RM -f confest.$objext
6451
6452 # PORTME: override above test on systems where it is broken
6453 m4_if([$1], [CXX],
6454 [case $host_os in
6455 interix[[3-9]]*)
6456 # Interix 3.5 installs completely hosed .la files for C++, so rather than
6457 # hack all around it, let's just trust "g++" to DTRT.
6458 _LT_TAGVAR(predep_objects,$1)=
6459 _LT_TAGVAR(postdep_objects,$1)=
6460 _LT_TAGVAR(postdeps,$1)=
6461 ;;
6462
6463 linux*)
6464 case `$CC -V 2>&1 | sed 5q` in
6465 *Sun\ C*)
6466 # Sun C++ 5.9
6467
6468 # The more standards-conforming stlport4 library is
6469 # incompatible with the Cstd library. Avoid specifying
6470 # it if it's in CXXFLAGS. Ignore libCrun as
6471 # -library=stlport4 depends on it.
6472 case " $CXX $CXXFLAGS " in
6473 *" -library=stlport4 "*)
6474 solaris_use_stlport4=yes
6475 ;;
6476 esac
6477
6478 if test "$solaris_use_stlport4" != yes; then
6479 _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
6480 fi
6481 ;;
6482 esac
6483 ;;
6484
6485 solaris*)
6486 case $cc_basename in
6487 CC*)
6488 # The more standards-conforming stlport4 library is
6489 # incompatible with the Cstd library. Avoid specifying
6490 # it if it's in CXXFLAGS. Ignore libCrun as
6491 # -library=stlport4 depends on it.
6492 case " $CXX $CXXFLAGS " in
6493 *" -library=stlport4 "*)
6494 solaris_use_stlport4=yes
6495 ;;
6496 esac
6497
6498 # Adding this requires a known-good setup of shared libraries for
6499 # Sun compiler versions before 5.6, else PIC objects from an old
6500 # archive will be linked into the output, leading to subtle bugs.
6501 if test "$solaris_use_stlport4" != yes; then
6502 _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
6503 fi
6504 ;;
6505 esac
6506 ;;
6507 esac
6508 ])
6509
6510 case " $_LT_TAGVAR(postdeps, $1) " in
6511 *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
6512 esac
6513 _LT_TAGVAR(compiler_lib_search_dirs, $1)=
6514 if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
6515 _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
6516 fi
6517 _LT_TAGDECL([], [compiler_lib_search_dirs], [1],
6518 [The directories searched by this compiler when creating a shared library])
6519 _LT_TAGDECL([], [predep_objects], [1],
6520 [Dependencies to place before and after the objects being linked to
6521 create a shared library])
6522 _LT_TAGDECL([], [postdep_objects], [1])
6523 _LT_TAGDECL([], [predeps], [1])
6524 _LT_TAGDECL([], [postdeps], [1])
6525 _LT_TAGDECL([], [compiler_lib_search_path], [1],
6526 [The library search path used internally by the compiler when linking
6527 a shared library])
6528 ])# _LT_SYS_HIDDEN_LIBDEPS
6529
6530
6531 # _LT_PROG_F77
6532 # ------------
6533 # Since AC_PROG_F77 is broken, in that it returns the empty string
6534 # if there is no fortran compiler, we have our own version here.
6535 m4_defun([_LT_PROG_F77],
6536 [
6537 pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
6538 AC_PROG_F77
6539 if test -z "$F77" || test "X$F77" = "Xno"; then
6540 _lt_disable_F77=yes
6541 fi
6542 popdef([AC_MSG_ERROR])
6543 ])# _LT_PROG_F77
6544
6545 dnl aclocal-1.4 backwards compatibility:
6546 dnl AC_DEFUN([_LT_PROG_F77], [])
6547
6548
6549 # _LT_LANG_F77_CONFIG([TAG])
6550 # --------------------------
6551 # Ensure that the configuration variables for a Fortran 77 compiler are
6552 # suitably defined. These variables are subsequently used by _LT_CONFIG
6553 # to write the compiler configuration to `libtool'.
6554 m4_defun([_LT_LANG_F77_CONFIG],
6555 [AC_REQUIRE([_LT_PROG_F77])dnl
6556 AC_LANG_PUSH(Fortran 77)
6557
6558 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6559 _LT_TAGVAR(allow_undefined_flag, $1)=
6560 _LT_TAGVAR(always_export_symbols, $1)=no
6561 _LT_TAGVAR(archive_expsym_cmds, $1)=
6562 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
6563 _LT_TAGVAR(hardcode_direct, $1)=no
6564 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
6565 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
6566 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
6567 _LT_TAGVAR(hardcode_libdir_separator, $1)=
6568 _LT_TAGVAR(hardcode_minus_L, $1)=no
6569 _LT_TAGVAR(hardcode_automatic, $1)=no
6570 _LT_TAGVAR(inherit_rpath, $1)=no
6571 _LT_TAGVAR(module_cmds, $1)=
6572 _LT_TAGVAR(module_expsym_cmds, $1)=
6573 _LT_TAGVAR(link_all_deplibs, $1)=unknown
6574 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6575 _LT_TAGVAR(no_undefined_flag, $1)=
6576 _LT_TAGVAR(whole_archive_flag_spec, $1)=
6577 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
6578
6579 # Source file extension for f77 test sources.
6580 ac_ext=f
6581
6582 # Object file extension for compiled f77 test sources.
6583 objext=o
6584 _LT_TAGVAR(objext, $1)=$objext
6585
6586 # No sense in running all these tests if we already determined that
6587 # the F77 compiler isn't working. Some variables (like enable_shared)
6588 # are currently assumed to apply to all compilers on this platform,
6589 # and will be corrupted by setting them based on a non-working compiler.
6590 if test "$_lt_disable_F77" != yes; then
6591 # Code to be used in simple compile tests
6592 lt_simple_compile_test_code="\
6593 subroutine t
6594 return
6595 end
6596 "
6597
6598 # Code to be used in simple link tests
6599 lt_simple_link_test_code="\
6600 program t
6601 end
6602 "
6603
6604 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6605 _LT_TAG_COMPILER
6606
6607 # save warnings/boilerplate of simple test code
6608 _LT_COMPILER_BOILERPLATE
6609 _LT_LINKER_BOILERPLATE
6610
6611 # Allow CC to be a program name with arguments.
6612 lt_save_CC="$CC"
6613 lt_save_GCC=$GCC
6614 CC=${F77-"f77"}
6615 compiler=$CC
6616 _LT_TAGVAR(compiler, $1)=$CC
6617 _LT_CC_BASENAME([$compiler])
6618 GCC=$G77
6619 if test -n "$compiler"; then
6620 AC_MSG_CHECKING([if libtool supports shared libraries])
6621 AC_MSG_RESULT([$can_build_shared])
6622
6623 AC_MSG_CHECKING([whether to build shared libraries])
6624 test "$can_build_shared" = "no" && enable_shared=no
6625
6626 # On AIX, shared libraries and static libraries use the same namespace, and
6627 # are all built from PIC.
6628 case $host_os in
6629 aix3*)
6630 test "$enable_shared" = yes && enable_static=no
6631 if test -n "$RANLIB"; then
6632 archive_cmds="$archive_cmds~\$RANLIB \$lib"
6633 postinstall_cmds='$RANLIB $lib'
6634 fi
6635 ;;
6636 aix[[4-9]]*)
6637 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
6638 test "$enable_shared" = yes && enable_static=no
6639 fi
6640 ;;
6641 esac
6642 AC_MSG_RESULT([$enable_shared])
6643
6644 AC_MSG_CHECKING([whether to build static libraries])
6645 # Make sure either enable_shared or enable_static is yes.
6646 test "$enable_shared" = yes || enable_static=yes
6647 AC_MSG_RESULT([$enable_static])
6648
6649 _LT_TAGVAR(GCC, $1)="$G77"
6650 _LT_TAGVAR(LD, $1)="$LD"
6651
6652 ## CAVEAT EMPTOR:
6653 ## There is no encapsulation within the following macros, do not change
6654 ## the running order or otherwise move them around unless you know exactly
6655 ## what you are doing...
6656 _LT_COMPILER_PIC($1)
6657 _LT_COMPILER_C_O($1)
6658 _LT_COMPILER_FILE_LOCKS($1)
6659 _LT_LINKER_SHLIBS($1)
6660 _LT_SYS_DYNAMIC_LINKER($1)
6661 _LT_LINKER_HARDCODE_LIBPATH($1)
6662
6663 _LT_CONFIG($1)
6664 fi # test -n "$compiler"
6665
6666 GCC=$lt_save_GCC
6667 CC="$lt_save_CC"
6668 fi # test "$_lt_disable_F77" != yes
6669
6670 AC_LANG_POP
6671 ])# _LT_LANG_F77_CONFIG
6672
6673
6674 # _LT_PROG_FC
6675 # -----------
6676 # Since AC_PROG_FC is broken, in that it returns the empty string
6677 # if there is no fortran compiler, we have our own version here.
6678 m4_defun([_LT_PROG_FC],
6679 [
6680 pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
6681 AC_PROG_FC
6682 if test -z "$FC" || test "X$FC" = "Xno"; then
6683 _lt_disable_FC=yes
6684 fi
6685 popdef([AC_MSG_ERROR])
6686 ])# _LT_PROG_FC
6687
6688 dnl aclocal-1.4 backwards compatibility:
6689 dnl AC_DEFUN([_LT_PROG_FC], [])
6690
6691
6692 # _LT_LANG_FC_CONFIG([TAG])
6693 # -------------------------
6694 # Ensure that the configuration variables for a Fortran compiler are
6695 # suitably defined. These variables are subsequently used by _LT_CONFIG
6696 # to write the compiler configuration to `libtool'.
6697 m4_defun([_LT_LANG_FC_CONFIG],
6698 [AC_REQUIRE([_LT_PROG_FC])dnl
6699 AC_LANG_PUSH(Fortran)
6700
6701 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6702 _LT_TAGVAR(allow_undefined_flag, $1)=
6703 _LT_TAGVAR(always_export_symbols, $1)=no
6704 _LT_TAGVAR(archive_expsym_cmds, $1)=
6705 _LT_TAGVAR(export_dynamic_flag_spec, $1)=
6706 _LT_TAGVAR(hardcode_direct, $1)=no
6707 _LT_TAGVAR(hardcode_direct_absolute, $1)=no
6708 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
6709 _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
6710 _LT_TAGVAR(hardcode_libdir_separator, $1)=
6711 _LT_TAGVAR(hardcode_minus_L, $1)=no
6712 _LT_TAGVAR(hardcode_automatic, $1)=no
6713 _LT_TAGVAR(inherit_rpath, $1)=no
6714 _LT_TAGVAR(module_cmds, $1)=
6715 _LT_TAGVAR(module_expsym_cmds, $1)=
6716 _LT_TAGVAR(link_all_deplibs, $1)=unknown
6717 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6718 _LT_TAGVAR(no_undefined_flag, $1)=
6719 _LT_TAGVAR(whole_archive_flag_spec, $1)=
6720 _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
6721
6722 # Source file extension for fc test sources.
6723 ac_ext=${ac_fc_srcext-f}
6724
6725 # Object file extension for compiled fc test sources.
6726 objext=o
6727 _LT_TAGVAR(objext, $1)=$objext
6728
6729 # No sense in running all these tests if we already determined that
6730 # the FC compiler isn't working. Some variables (like enable_shared)
6731 # are currently assumed to apply to all compilers on this platform,
6732 # and will be corrupted by setting them based on a non-working compiler.
6733 if test "$_lt_disable_FC" != yes; then
6734 # Code to be used in simple compile tests
6735 lt_simple_compile_test_code="\
6736 subroutine t
6737 return
6738 end
6739 "
6740
6741 # Code to be used in simple link tests
6742 lt_simple_link_test_code="\
6743 program t
6744 end
6745 "
6746
6747 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6748 _LT_TAG_COMPILER
6749
6750 # save warnings/boilerplate of simple test code
6751 _LT_COMPILER_BOILERPLATE
6752 _LT_LINKER_BOILERPLATE
6753
6754 # Allow CC to be a program name with arguments.
6755 lt_save_CC="$CC"
6756 lt_save_GCC=$GCC
6757 CC=${FC-"f95"}
6758 compiler=$CC
6759 GCC=$ac_cv_fc_compiler_gnu
6760
6761 _LT_TAGVAR(compiler, $1)=$CC
6762 _LT_CC_BASENAME([$compiler])
6763
6764 if test -n "$compiler"; then
6765 AC_MSG_CHECKING([if libtool supports shared libraries])
6766 AC_MSG_RESULT([$can_build_shared])
6767
6768 AC_MSG_CHECKING([whether to build shared libraries])
6769 test "$can_build_shared" = "no" && enable_shared=no
6770
6771 # On AIX, shared libraries and static libraries use the same namespace, and
6772 # are all built from PIC.
6773 case $host_os in
6774 aix3*)
6775 test "$enable_shared" = yes && enable_static=no
6776 if test -n "$RANLIB"; then
6777 archive_cmds="$archive_cmds~\$RANLIB \$lib"
6778 postinstall_cmds='$RANLIB $lib'
6779 fi
6780 ;;
6781 aix[[4-9]]*)
6782 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
6783 test "$enable_shared" = yes && enable_static=no
6784 fi
6785 ;;
6786 esac
6787 AC_MSG_RESULT([$enable_shared])
6788
6789 AC_MSG_CHECKING([whether to build static libraries])
6790 # Make sure either enable_shared or enable_static is yes.
6791 test "$enable_shared" = yes || enable_static=yes
6792 AC_MSG_RESULT([$enable_static])
6793
6794 _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
6795 _LT_TAGVAR(LD, $1)="$LD"
6796
6797 ## CAVEAT EMPTOR:
6798 ## There is no encapsulation within the following macros, do not change
6799 ## the running order or otherwise move them around unless you know exactly
6800 ## what you are doing...
6801 _LT_SYS_HIDDEN_LIBDEPS($1)
6802 _LT_COMPILER_PIC($1)
6803 _LT_COMPILER_C_O($1)
6804 _LT_COMPILER_FILE_LOCKS($1)
6805 _LT_LINKER_SHLIBS($1)
6806 _LT_SYS_DYNAMIC_LINKER($1)
6807 _LT_LINKER_HARDCODE_LIBPATH($1)
6808
6809 _LT_CONFIG($1)
6810 fi # test -n "$compiler"
6811
6812 GCC=$lt_save_GCC
6813 CC="$lt_save_CC"
6814 fi # test "$_lt_disable_FC" != yes
6815
6816 AC_LANG_POP
6817 ])# _LT_LANG_FC_CONFIG
6818
6819
6820 # _LT_LANG_GCJ_CONFIG([TAG])
6821 # --------------------------
6822 # Ensure that the configuration variables for the GNU Java Compiler compiler
6823 # are suitably defined. These variables are subsequently used by _LT_CONFIG
6824 # to write the compiler configuration to `libtool'.
6825 m4_defun([_LT_LANG_GCJ_CONFIG],
6826 [AC_REQUIRE([LT_PROG_GCJ])dnl
6827 AC_LANG_SAVE
6828
6829 # Source file extension for Java test sources.
6830 ac_ext=java
6831
6832 # Object file extension for compiled Java test sources.
6833 objext=o
6834 _LT_TAGVAR(objext, $1)=$objext
6835
6836 # Code to be used in simple compile tests
6837 lt_simple_compile_test_code="class foo {}"
6838
6839 # Code to be used in simple link tests
6840 lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
6841
6842 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6843 _LT_TAG_COMPILER
6844
6845 # save warnings/boilerplate of simple test code
6846 _LT_COMPILER_BOILERPLATE
6847 _LT_LINKER_BOILERPLATE
6848
6849 # Allow CC to be a program name with arguments.
6850 lt_save_CC="$CC"
6851 lt_save_GCC=$GCC
6852 GCC=yes
6853 CC=${GCJ-"gcj"}
6854 compiler=$CC
6855 _LT_TAGVAR(compiler, $1)=$CC
6856 _LT_TAGVAR(LD, $1)="$LD"
6857 _LT_CC_BASENAME([$compiler])
6858
6859 # GCJ did not exist at the time GCC didn't implicitly link libc in.
6860 _LT_TAGVAR(archive_cmds_need_lc, $1)=no
6861
6862 _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
6863
6864 if test -n "$compiler"; then
6865 _LT_COMPILER_NO_RTTI($1)
6866 _LT_COMPILER_PIC($1)
6867 _LT_COMPILER_C_O($1)
6868 _LT_COMPILER_FILE_LOCKS($1)
6869 _LT_LINKER_SHLIBS($1)
6870 _LT_LINKER_HARDCODE_LIBPATH($1)
6871
6872 _LT_CONFIG($1)
6873 fi
6874
6875 AC_LANG_RESTORE
6876
6877 GCC=$lt_save_GCC
6878 CC="$lt_save_CC"
6879 ])# _LT_LANG_GCJ_CONFIG
6880
6881
6882 # _LT_LANG_RC_CONFIG([TAG])
6883 # -------------------------
6884 # Ensure that the configuration variables for the Windows resource compiler
6885 # are suitably defined. These variables are subsequently used by _LT_CONFIG
6886 # to write the compiler configuration to `libtool'.
6887 m4_defun([_LT_LANG_RC_CONFIG],
6888 [AC_REQUIRE([LT_PROG_RC])dnl
6889 AC_LANG_SAVE
6890
6891 # Source file extension for RC test sources.
6892 ac_ext=rc
6893
6894 # Object file extension for compiled RC test sources.
6895 objext=o
6896 _LT_TAGVAR(objext, $1)=$objext
6897
6898 # Code to be used in simple compile tests
6899 lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
6900
6901 # Code to be used in simple link tests
6902 lt_simple_link_test_code="$lt_simple_compile_test_code"
6903
6904 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
6905 _LT_TAG_COMPILER
6906
6907 # save warnings/boilerplate of simple test code
6908 _LT_COMPILER_BOILERPLATE
6909 _LT_LINKER_BOILERPLATE
6910
6911 # Allow CC to be a program name with arguments.
6912 lt_save_CC="$CC"
6913 lt_save_GCC=$GCC
6914 GCC=
6915 CC=${RC-"windres"}
6916 compiler=$CC
6917 _LT_TAGVAR(compiler, $1)=$CC
6918 _LT_CC_BASENAME([$compiler])
6919 _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
6920
6921 if test -n "$compiler"; then
6922 :
6923 _LT_CONFIG($1)
6924 fi
6925
6926 GCC=$lt_save_GCC
6927 AC_LANG_RESTORE
6928 CC="$lt_save_CC"
6929 ])# _LT_LANG_RC_CONFIG
6930
6931
6932 # LT_PROG_GCJ
6933 # -----------
6934 AC_DEFUN([LT_PROG_GCJ],
6935 [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
6936 [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
6937 [AC_CHECK_TOOL(GCJ, gcj,)
6938 test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
6939 AC_SUBST(GCJFLAGS)])])[]dnl
6940 ])
6941
6942 # Old name:
6943 AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
6944 dnl aclocal-1.4 backwards compatibility:
6945 dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
6946
6947
6948 # LT_PROG_RC
6949 # ----------
6950 AC_DEFUN([LT_PROG_RC],
6951 [AC_CHECK_TOOL(RC, windres,)
6952 ])
6953
6954 # Old name:
6955 AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
6956 dnl aclocal-1.4 backwards compatibility:
6957 dnl AC_DEFUN([LT_AC_PROG_RC], [])
6958
6959
6960 # _LT_DECL_EGREP
6961 # --------------
6962 # If we don't have a new enough Autoconf to choose the best grep
6963 # available, choose the one first in the user's PATH.
6964 m4_defun([_LT_DECL_EGREP],
6965 [AC_REQUIRE([AC_PROG_EGREP])dnl
6966 AC_REQUIRE([AC_PROG_FGREP])dnl
6967 test -z "$GREP" && GREP=grep
6968 _LT_DECL([], [GREP], [1], [A grep program that handles long lines])
6969 _LT_DECL([], [EGREP], [1], [An ERE matcher])
6970 _LT_DECL([], [FGREP], [1], [A literal string matcher])
6971 dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
6972 AC_SUBST([GREP])
6973 ])
6974
6975
6976 # _LT_DECL_SED
6977 # ------------
6978 # Check for a fully-functional sed program, that truncates
6979 # as few characters as possible. Prefer GNU sed if found.
6980 m4_defun([_LT_DECL_SED],
6981 [AC_PROG_SED
6982 test -z "$SED" && SED=sed
6983 Xsed="$SED -e 1s/^X//"
6984 _LT_DECL([], [SED], [1], [A sed program that does not truncate output])
6985 _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
6986 [Sed that helps us avoid accidentally triggering echo(1) options like -n])
6987 ])# _LT_DECL_SED
6988
6989 m4_ifndef([AC_PROG_SED], [
6990 # NOTE: This macro has been submitted for inclusion into #
6991 # GNU Autoconf as AC_PROG_SED. When it is available in #
6992 # a released version of Autoconf we should remove this #
6993 # macro and use it instead. #
6994
6995 m4_defun([AC_PROG_SED],
6996 [AC_MSG_CHECKING([for a sed that does not truncate output])
6997 AC_CACHE_VAL(lt_cv_path_SED,
6998 [# Loop through the user's path and test for sed and gsed.
6999 # Then use that list of sed's as ones to test for truncation.
7000 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
7001 for as_dir in $PATH
7002 do
7003 IFS=$as_save_IFS
7004 test -z "$as_dir" && as_dir=.
7005 for lt_ac_prog in sed gsed; do
7006 for ac_exec_ext in '' $ac_executable_extensions; do
7007 if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
7008 lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
7009 fi
7010 done
7011 done
7012 done
7013 IFS=$as_save_IFS
7014 lt_ac_max=0
7015 lt_ac_count=0
7016 # Add /usr/xpg4/bin/sed as it is typically found on Solaris
7017 # along with /bin/sed that truncates output.
7018 for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
7019 test ! -f $lt_ac_sed && continue
7020 cat /dev/null > conftest.in
7021 lt_ac_count=0
7022 echo $ECHO_N "0123456789$ECHO_C" >conftest.in
7023 # Check for GNU sed and select it if it is found.
7024 if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
7025 lt_cv_path_SED=$lt_ac_sed
7026 break
7027 fi
7028 while true; do
7029 cat conftest.in conftest.in >conftest.tmp
7030 mv conftest.tmp conftest.in
7031 cp conftest.in conftest.nl
7032 echo >>conftest.nl
7033 $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
7034 cmp -s conftest.out conftest.nl || break
7035 # 10000 chars as input seems more than enough
7036 test $lt_ac_count -gt 10 && break
7037 lt_ac_count=`expr $lt_ac_count + 1`
7038 if test $lt_ac_count -gt $lt_ac_max; then
7039 lt_ac_max=$lt_ac_count
7040 lt_cv_path_SED=$lt_ac_sed
7041 fi
7042 done
7043 done
7044 ])
7045 SED=$lt_cv_path_SED
7046 AC_SUBST([SED])
7047 AC_MSG_RESULT([$SED])
7048 ])#AC_PROG_SED
7049 ])#m4_ifndef
7050
7051 # Old name:
7052 AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
7053 dnl aclocal-1.4 backwards compatibility:
7054 dnl AC_DEFUN([LT_AC_PROG_SED], [])
7055
7056
7057 # _LT_CHECK_SHELL_FEATURES
7058 # ------------------------
7059 # Find out whether the shell is Bourne or XSI compatible,
7060 # or has some other useful features.
7061 m4_defun([_LT_CHECK_SHELL_FEATURES],
7062 [AC_MSG_CHECKING([whether the shell understands some XSI constructs])
7063 # Try some XSI features
7064 xsi_shell=no
7065 ( _lt_dummy="a/b/c"
7066 test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
7067 = c,a/b,, \
7068 && eval 'test $(( 1 + 1 )) -eq 2 \
7069 && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
7070 && xsi_shell=yes
7071 AC_MSG_RESULT([$xsi_shell])
7072 _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
7073
7074 AC_MSG_CHECKING([whether the shell understands "+="])
7075 lt_shell_append=no
7076 ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
7077 >/dev/null 2>&1 \
7078 && lt_shell_append=yes
7079 AC_MSG_RESULT([$lt_shell_append])
7080 _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
7081
7082 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
7083 lt_unset=unset
7084 else
7085 lt_unset=false
7086 fi
7087 _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
7088
7089 # test EBCDIC or ASCII
7090 case `echo X|tr X '\101'` in
7091 A) # ASCII based system
7092 # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
7093 lt_SP2NL='tr \040 \012'
7094 lt_NL2SP='tr \015\012 \040\040'
7095 ;;
7096 *) # EBCDIC based system
7097 lt_SP2NL='tr \100 \n'
7098 lt_NL2SP='tr \r\n \100\100'
7099 ;;
7100 esac
7101 _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
7102 _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
7103 ])# _LT_CHECK_SHELL_FEATURES
7104
7105
7106 # _LT_PROG_XSI_SHELLFNS
7107 # ---------------------
7108 # Bourne and XSI compatible variants of some useful shell functions.
7109 m4_defun([_LT_PROG_XSI_SHELLFNS],
7110 [case $xsi_shell in
7111 yes)
7112 cat << \_LT_EOF >> "$cfgfile"
7113
7114 # func_dirname file append nondir_replacement
7115 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
7116 # otherwise set result to NONDIR_REPLACEMENT.
7117 func_dirname ()
7118 {
7119 case ${1} in
7120 */*) func_dirname_result="${1%/*}${2}" ;;
7121 * ) func_dirname_result="${3}" ;;
7122 esac
7123 }
7124
7125 # func_basename file
7126 func_basename ()
7127 {
7128 func_basename_result="${1##*/}"
7129 }
7130
7131 # func_dirname_and_basename file append nondir_replacement
7132 # perform func_basename and func_dirname in a single function
7133 # call:
7134 # dirname: Compute the dirname of FILE. If nonempty,
7135 # add APPEND to the result, otherwise set result
7136 # to NONDIR_REPLACEMENT.
7137 # value returned in "$func_dirname_result"
7138 # basename: Compute filename of FILE.
7139 # value retuned in "$func_basename_result"
7140 # Implementation must be kept synchronized with func_dirname
7141 # and func_basename. For efficiency, we do not delegate to
7142 # those functions but instead duplicate the functionality here.
7143 func_dirname_and_basename ()
7144 {
7145 case ${1} in
7146 */*) func_dirname_result="${1%/*}${2}" ;;
7147 * ) func_dirname_result="${3}" ;;
7148 esac
7149 func_basename_result="${1##*/}"
7150 }
7151
7152 # func_stripname prefix suffix name
7153 # strip PREFIX and SUFFIX off of NAME.
7154 # PREFIX and SUFFIX must not contain globbing or regex special
7155 # characters, hashes, percent signs, but SUFFIX may contain a leading
7156 # dot (in which case that matches only a dot).
7157 func_stripname ()
7158 {
7159 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
7160 # positional parameters, so assign one to ordinary parameter first.
7161 func_stripname_result=${3}
7162 func_stripname_result=${func_stripname_result#"${1}"}
7163 func_stripname_result=${func_stripname_result%"${2}"}
7164 }
7165
7166 # func_opt_split
7167 func_opt_split ()
7168 {
7169 func_opt_split_opt=${1%%=*}
7170 func_opt_split_arg=${1#*=}
7171 }
7172
7173 # func_lo2o object
7174 func_lo2o ()
7175 {
7176 case ${1} in
7177 *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
7178 *) func_lo2o_result=${1} ;;
7179 esac
7180 }
7181
7182 # func_xform libobj-or-source
7183 func_xform ()
7184 {
7185 func_xform_result=${1%.*}.lo
7186 }
7187
7188 # func_arith arithmetic-term...
7189 func_arith ()
7190 {
7191 func_arith_result=$(( $[*] ))
7192 }
7193
7194 # func_len string
7195 # STRING may not start with a hyphen.
7196 func_len ()
7197 {
7198 func_len_result=${#1}
7199 }
7200
7201 _LT_EOF
7202 ;;
7203 *) # Bourne compatible functions.
7204 cat << \_LT_EOF >> "$cfgfile"
7205
7206 # func_dirname file append nondir_replacement
7207 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
7208 # otherwise set result to NONDIR_REPLACEMENT.
7209 func_dirname ()
7210 {
7211 # Extract subdirectory from the argument.
7212 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
7213 if test "X$func_dirname_result" = "X${1}"; then
7214 func_dirname_result="${3}"
7215 else
7216 func_dirname_result="$func_dirname_result${2}"
7217 fi
7218 }
7219
7220 # func_basename file
7221 func_basename ()
7222 {
7223 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
7224 }
7225
7226 dnl func_dirname_and_basename
7227 dnl A portable version of this function is already defined in general.m4sh
7228 dnl so there is no need for it here.
7229
7230 # func_stripname prefix suffix name
7231 # strip PREFIX and SUFFIX off of NAME.
7232 # PREFIX and SUFFIX must not contain globbing or regex special
7233 # characters, hashes, percent signs, but SUFFIX may contain a leading
7234 # dot (in which case that matches only a dot).
7235 # func_strip_suffix prefix name
7236 func_stripname ()
7237 {
7238 case ${2} in
7239 .*) func_stripname_result=`$ECHO "X${3}" \
7240 | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
7241 *) func_stripname_result=`$ECHO "X${3}" \
7242 | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
7243 esac
7244 }
7245
7246 # sed scripts:
7247 my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
7248 my_sed_long_arg='1s/^-[[^=]]*=//'
7249
7250 # func_opt_split
7251 func_opt_split ()
7252 {
7253 func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
7254 func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
7255 }
7256
7257 # func_lo2o object
7258 func_lo2o ()
7259 {
7260 func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
7261 }
7262
7263 # func_xform libobj-or-source
7264 func_xform ()
7265 {
7266 func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
7267 }
7268
7269 # func_arith arithmetic-term...
7270 func_arith ()
7271 {
7272 func_arith_result=`expr "$[@]"`
7273 }
7274
7275 # func_len string
7276 # STRING may not start with a hyphen.
7277 func_len ()
7278 {
7279 func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
7280 }
7281
7282 _LT_EOF
7283 esac
7284
7285 case $lt_shell_append in
7286 yes)
7287 cat << \_LT_EOF >> "$cfgfile"
7288
7289 # func_append var value
7290 # Append VALUE to the end of shell variable VAR.
7291 func_append ()
7292 {
7293 eval "$[1]+=\$[2]"
7294 }
7295 _LT_EOF
7296 ;;
7297 *)
7298 cat << \_LT_EOF >> "$cfgfile"
7299
7300 # func_append var value
7301 # Append VALUE to the end of shell variable VAR.
7302 func_append ()
7303 {
7304 eval "$[1]=\$$[1]\$[2]"
7305 }
7306
7307 _LT_EOF
7308 ;;
7309 esac
7310 ])
7311
7312 # Helper functions for option handling. -*- Autoconf -*-
7313 #
7314 # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
7315 # Written by Gary V. Vaughan, 2004
7316 #
7317 # This file is free software; the Free Software Foundation gives
7318 # unlimited permission to copy and/or distribute it, with or without
7319 # modifications, as long as this notice is preserved.
7320
7321 # serial 6 ltoptions.m4
7322
7323 # This is to help aclocal find these macros, as it can't see m4_define.
7324 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
7325
7326
7327 # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
7328 # ------------------------------------------
7329 m4_define([_LT_MANGLE_OPTION],
7330 [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
7331
7332
7333 # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
7334 # ---------------------------------------
7335 # Set option OPTION-NAME for macro MACRO-NAME, and if there is a
7336 # matching handler defined, dispatch to it. Other OPTION-NAMEs are
7337 # saved as a flag.
7338 m4_define([_LT_SET_OPTION],
7339 [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
7340 m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
7341 _LT_MANGLE_DEFUN([$1], [$2]),
7342 [m4_warning([Unknown $1 option `$2'])])[]dnl
7343 ])
7344
7345
7346 # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
7347 # ------------------------------------------------------------
7348 # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
7349 m4_define([_LT_IF_OPTION],
7350 [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
7351
7352
7353 # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
7354 # -------------------------------------------------------
7355 # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
7356 # are set.
7357 m4_define([_LT_UNLESS_OPTIONS],
7358 [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
7359 [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
7360 [m4_define([$0_found])])])[]dnl
7361 m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
7362 ])[]dnl
7363 ])
7364
7365
7366 # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
7367 # ----------------------------------------
7368 # OPTION-LIST is a space-separated list of Libtool options associated
7369 # with MACRO-NAME. If any OPTION has a matching handler declared with
7370 # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
7371 # the unknown option and exit.
7372 m4_defun([_LT_SET_OPTIONS],
7373 [# Set options
7374 m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
7375 [_LT_SET_OPTION([$1], _LT_Option)])
7376
7377 m4_if([$1],[LT_INIT],[
7378 dnl
7379 dnl Simply set some default values (i.e off) if boolean options were not
7380 dnl specified:
7381 _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
7382 ])
7383 _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
7384 ])
7385 dnl
7386 dnl If no reference was made to various pairs of opposing options, then
7387 dnl we run the default mode handler for the pair. For example, if neither
7388 dnl `shared' nor `disable-shared' was passed, we enable building of shared
7389 dnl archives by default:
7390 _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
7391 _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
7392 _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
7393 _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
7394 [_LT_ENABLE_FAST_INSTALL])
7395 ])
7396 ])# _LT_SET_OPTIONS
7397
7398
7399
7400 # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
7401 # -----------------------------------------
7402 m4_define([_LT_MANGLE_DEFUN],
7403 [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
7404
7405
7406 # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
7407 # -----------------------------------------------
7408 m4_define([LT_OPTION_DEFINE],
7409 [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
7410 ])# LT_OPTION_DEFINE
7411
7412
7413 # dlopen
7414 # ------
7415 LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
7416 ])
7417
7418 AU_DEFUN([AC_LIBTOOL_DLOPEN],
7419 [_LT_SET_OPTION([LT_INIT], [dlopen])
7420 AC_DIAGNOSE([obsolete],
7421 [$0: Remove this warning and the call to _LT_SET_OPTION when you
7422 put the `dlopen' option into LT_INIT's first parameter.])
7423 ])
7424
7425 dnl aclocal-1.4 backwards compatibility:
7426 dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
7427
7428
7429 # win32-dll
7430 # ---------
7431 # Declare package support for building win32 dll's.
7432 LT_OPTION_DEFINE([LT_INIT], [win32-dll],
7433 [enable_win32_dll=yes
7434
7435 case $host in
7436 *-*-cygwin* | *-*-mingw* | *-*-pw32*)
7437 AC_CHECK_TOOL(AS, as, false)
7438 AC_CHECK_TOOL(DLLTOOL, dlltool, false)
7439 AC_CHECK_TOOL(OBJDUMP, objdump, false)
7440 ;;
7441 esac
7442
7443 test -z "$AS" && AS=as
7444 _LT_DECL([], [AS], [0], [Assembler program])dnl
7445
7446 test -z "$DLLTOOL" && DLLTOOL=dlltool
7447 _LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
7448
7449 test -z "$OBJDUMP" && OBJDUMP=objdump
7450 _LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
7451 ])# win32-dll
7452
7453 AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
7454 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
7455 _LT_SET_OPTION([LT_INIT], [win32-dll])
7456 AC_DIAGNOSE([obsolete],
7457 [$0: Remove this warning and the call to _LT_SET_OPTION when you
7458 put the `win32-dll' option into LT_INIT's first parameter.])
7459 ])
7460
7461 dnl aclocal-1.4 backwards compatibility:
7462 dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
7463
7464
7465 # _LT_ENABLE_SHARED([DEFAULT])
7466 # ----------------------------
7467 # implement the --enable-shared flag, and supports the `shared' and
7468 # `disable-shared' LT_INIT options.
7469 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
7470 m4_define([_LT_ENABLE_SHARED],
7471 [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
7472 AC_ARG_ENABLE([shared],
7473 [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
7474 [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
7475 [p=${PACKAGE-default}
7476 case $enableval in
7477 yes) enable_shared=yes ;;
7478 no) enable_shared=no ;;
7479 *)
7480 enable_shared=no
7481 # Look at the argument we got. We use all the common list separators.
7482 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7483 for pkg in $enableval; do
7484 IFS="$lt_save_ifs"
7485 if test "X$pkg" = "X$p"; then
7486 enable_shared=yes
7487 fi
7488 done
7489 IFS="$lt_save_ifs"
7490 ;;
7491 esac],
7492 [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
7493
7494 _LT_DECL([build_libtool_libs], [enable_shared], [0],
7495 [Whether or not to build shared libraries])
7496 ])# _LT_ENABLE_SHARED
7497
7498 LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
7499 LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
7500
7501 # Old names:
7502 AC_DEFUN([AC_ENABLE_SHARED],
7503 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
7504 ])
7505
7506 AC_DEFUN([AC_DISABLE_SHARED],
7507 [_LT_SET_OPTION([LT_INIT], [disable-shared])
7508 ])
7509
7510 AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
7511 AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
7512
7513 dnl aclocal-1.4 backwards compatibility:
7514 dnl AC_DEFUN([AM_ENABLE_SHARED], [])
7515 dnl AC_DEFUN([AM_DISABLE_SHARED], [])
7516
7517
7518
7519 # _LT_ENABLE_STATIC([DEFAULT])
7520 # ----------------------------
7521 # implement the --enable-static flag, and support the `static' and
7522 # `disable-static' LT_INIT options.
7523 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
7524 m4_define([_LT_ENABLE_STATIC],
7525 [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
7526 AC_ARG_ENABLE([static],
7527 [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
7528 [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
7529 [p=${PACKAGE-default}
7530 case $enableval in
7531 yes) enable_static=yes ;;
7532 no) enable_static=no ;;
7533 *)
7534 enable_static=no
7535 # Look at the argument we got. We use all the common list separators.
7536 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7537 for pkg in $enableval; do
7538 IFS="$lt_save_ifs"
7539 if test "X$pkg" = "X$p"; then
7540 enable_static=yes
7541 fi
7542 done
7543 IFS="$lt_save_ifs"
7544 ;;
7545 esac],
7546 [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
7547
7548 _LT_DECL([build_old_libs], [enable_static], [0],
7549 [Whether or not to build static libraries])
7550 ])# _LT_ENABLE_STATIC
7551
7552 LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
7553 LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
7554
7555 # Old names:
7556 AC_DEFUN([AC_ENABLE_STATIC],
7557 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
7558 ])
7559
7560 AC_DEFUN([AC_DISABLE_STATIC],
7561 [_LT_SET_OPTION([LT_INIT], [disable-static])
7562 ])
7563
7564 AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
7565 AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
7566
7567 dnl aclocal-1.4 backwards compatibility:
7568 dnl AC_DEFUN([AM_ENABLE_STATIC], [])
7569 dnl AC_DEFUN([AM_DISABLE_STATIC], [])
7570
7571
7572
7573 # _LT_ENABLE_FAST_INSTALL([DEFAULT])
7574 # ----------------------------------
7575 # implement the --enable-fast-install flag, and support the `fast-install'
7576 # and `disable-fast-install' LT_INIT options.
7577 # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
7578 m4_define([_LT_ENABLE_FAST_INSTALL],
7579 [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
7580 AC_ARG_ENABLE([fast-install],
7581 [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
7582 [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
7583 [p=${PACKAGE-default}
7584 case $enableval in
7585 yes) enable_fast_install=yes ;;
7586 no) enable_fast_install=no ;;
7587 *)
7588 enable_fast_install=no
7589 # Look at the argument we got. We use all the common list separators.
7590 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7591 for pkg in $enableval; do
7592 IFS="$lt_save_ifs"
7593 if test "X$pkg" = "X$p"; then
7594 enable_fast_install=yes
7595 fi
7596 done
7597 IFS="$lt_save_ifs"
7598 ;;
7599 esac],
7600 [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
7601
7602 _LT_DECL([fast_install], [enable_fast_install], [0],
7603 [Whether or not to optimize for fast installation])dnl
7604 ])# _LT_ENABLE_FAST_INSTALL
7605
7606 LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
7607 LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
7608
7609 # Old names:
7610 AU_DEFUN([AC_ENABLE_FAST_INSTALL],
7611 [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
7612 AC_DIAGNOSE([obsolete],
7613 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
7614 the `fast-install' option into LT_INIT's first parameter.])
7615 ])
7616
7617 AU_DEFUN([AC_DISABLE_FAST_INSTALL],
7618 [_LT_SET_OPTION([LT_INIT], [disable-fast-install])
7619 AC_DIAGNOSE([obsolete],
7620 [$0: Remove this warning and the call to _LT_SET_OPTION when you put
7621 the `disable-fast-install' option into LT_INIT's first parameter.])
7622 ])
7623
7624 dnl aclocal-1.4 backwards compatibility:
7625 dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
7626 dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
7627
7628
7629 # _LT_WITH_PIC([MODE])
7630 # --------------------
7631 # implement the --with-pic flag, and support the `pic-only' and `no-pic'
7632 # LT_INIT options.
7633 # MODE is either `yes' or `no'. If omitted, it defaults to `both'.
7634 m4_define([_LT_WITH_PIC],
7635 [AC_ARG_WITH([pic],
7636 [AS_HELP_STRING([--with-pic],
7637 [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
7638 [pic_mode="$withval"],
7639 [pic_mode=default])
7640
7641 test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
7642
7643 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
7644 ])# _LT_WITH_PIC
7645
7646 LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
7647 LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
7648
7649 # Old name:
7650 AU_DEFUN([AC_LIBTOOL_PICMODE],
7651 [_LT_SET_OPTION([LT_INIT], [pic-only])
7652 AC_DIAGNOSE([obsolete],
7653 [$0: Remove this warning and the call to _LT_SET_OPTION when you
7654 put the `pic-only' option into LT_INIT's first parameter.])
7655 ])
7656
7657 dnl aclocal-1.4 backwards compatibility:
7658 dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
7659
7660
7661 m4_define([_LTDL_MODE], [])
7662 LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
7663 [m4_define([_LTDL_MODE], [nonrecursive])])
7664 LT_OPTION_DEFINE([LTDL_INIT], [recursive],
7665 [m4_define([_LTDL_MODE], [recursive])])
7666 LT_OPTION_DEFINE([LTDL_INIT], [subproject],
7667 [m4_define([_LTDL_MODE], [subproject])])
7668
7669 m4_define([_LTDL_TYPE], [])
7670 LT_OPTION_DEFINE([LTDL_INIT], [installable],
7671 [m4_define([_LTDL_TYPE], [installable])])
7672 LT_OPTION_DEFINE([LTDL_INIT], [convenience],
7673 [m4_define([_LTDL_TYPE], [convenience])])
7674
7675 # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
7676 #
7677 # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
7678 # Written by Gary V. Vaughan, 2004
7679 #
7680 # This file is free software; the Free Software Foundation gives
7681 # unlimited permission to copy and/or distribute it, with or without
7682 # modifications, as long as this notice is preserved.
7683
7684 # serial 5 ltsugar.m4
7685
7686 # This is to help aclocal find these macros, as it can't see m4_define.
7687 AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
7688
7689
7690 # lt_join(SEP, ARG1, [ARG2...])
7691 # -----------------------------
7692 # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
7693 # associated separator.
7694 # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
7695 # versions in m4sugar had bugs.
7696 m4_define([lt_join],
7697 [m4_if([$#], [1], [],
7698 [$#], [2], [[$2]],
7699 [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
7700 m4_define([_lt_join],
7701 [m4_if([$#$2], [2], [],
7702 [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
7703
7704
7705 # lt_car(LIST)
7706 # lt_cdr(LIST)
7707 # ------------
7708 # Manipulate m4 lists.
7709 # These macros are necessary as long as will still need to support
7710 # Autoconf-2.59 which quotes differently.
7711 m4_define([lt_car], [[$1]])
7712 m4_define([lt_cdr],
7713 [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
7714 [$#], 1, [],
7715 [m4_dquote(m4_shift($@))])])
7716 m4_define([lt_unquote], $1)
7717
7718
7719 # lt_append(MACRO-NAME, STRING, [SEPARATOR])
7720 # ------------------------------------------
7721 # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
7722 # Note that neither SEPARATOR nor STRING are expanded; they are appended
7723 # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
7724 # No SEPARATOR is output if MACRO-NAME was previously undefined (different
7725 # than defined and empty).
7726 #
7727 # This macro is needed until we can rely on Autoconf 2.62, since earlier
7728 # versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
7729 m4_define([lt_append],
7730 [m4_define([$1],
7731 m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
7732
7733
7734
7735 # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
7736 # ----------------------------------------------------------
7737 # Produce a SEP delimited list of all paired combinations of elements of
7738 # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
7739 # has the form PREFIXmINFIXSUFFIXn.
7740 m4_define([lt_combine],
7741 [m4_if([$2], [], [],
7742 [m4_if([$4], [], [],
7743 [lt_join(m4_quote(m4_default([$1], [[, ]])),
7744 lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_prefix, [$2],
7745 [m4_foreach(_Lt_suffix, lt_car([m4_shiftn(3, $@)]),
7746 [_Lt_prefix[]$3[]_Lt_suffix ])])))))])])dnl
7747 ])
7748
7749
7750 # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
7751 # -----------------------------------------------------------------------
7752 # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
7753 # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
7754 m4_define([lt_if_append_uniq],
7755 [m4_ifdef([$1],
7756 [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
7757 [lt_append([$1], [$2], [$3])$4],
7758 [$5])],
7759 [lt_append([$1], [$2], [$3])$4])])
7760
7761
7762 # lt_dict_add(DICT, KEY, VALUE)
7763 # -----------------------------
7764 m4_define([lt_dict_add],
7765 [m4_define([$1($2)], [$3])])
7766
7767
7768 # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
7769 # --------------------------------------------
7770 m4_define([lt_dict_add_subkey],
7771 [m4_define([$1($2:$3)], [$4])])
7772
7773
7774 # lt_dict_fetch(DICT, KEY, [SUBKEY])
7775 # ----------------------------------
7776 m4_define([lt_dict_fetch],
7777 [m4_ifval([$3],
7778 m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
7779 m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
7780
7781
7782 # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
7783 # -----------------------------------------------------------------
7784 m4_define([lt_if_dict_fetch],
7785 [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
7786 [$5],
7787 [$6])])
7788
7789
7790 # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
7791 # --------------------------------------------------------------
7792 m4_define([lt_dict_filter],
7793 [m4_if([$5], [], [],
7794 [lt_join(m4_quote(m4_default([$4], [[, ]])),
7795 lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
7796 [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
7797 ])
7798
7799 # ltversion.m4 -- version numbers -*- Autoconf -*-
7800 #
7801 # Copyright (C) 2004 Free Software Foundation, Inc.
7802 # Written by Scott James Remnant, 2004
7803 #
7804 # This file is free software; the Free Software Foundation gives
7805 # unlimited permission to copy and/or distribute it, with or without
7806 # modifications, as long as this notice is preserved.
7807
7808 # Generated from ltversion.in.
7809
7810 # serial 2976 ltversion.m4
7811 # This file is part of GNU Libtool
7812
7813 m4_define([LT_PACKAGE_VERSION], [2.2.4])
7814 m4_define([LT_PACKAGE_REVISION], [1.2976])
7815
7816 AC_DEFUN([LTVERSION_VERSION],
7817 [macro_version='2.2.4'
7818 macro_revision='1.2976'
7819 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
7820 _LT_DECL(, macro_revision, 0)
7821 ])
7822
7823 # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
7824 #
7825 # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
7826 # Written by Scott James Remnant, 2004.
7827 #
7828 # This file is free software; the Free Software Foundation gives
7829 # unlimited permission to copy and/or distribute it, with or without
7830 # modifications, as long as this notice is preserved.
7831
7832 # serial 4 lt~obsolete.m4
7833
7834 # These exist entirely to fool aclocal when bootstrapping libtool.
7835 #
7836 # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
7837 # which have later been changed to m4_define as they aren't part of the
7838 # exported API, or moved to Autoconf or Automake where they belong.
7839 #
7840 # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
7841 # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
7842 # using a macro with the same name in our local m4/libtool.m4 it'll
7843 # pull the old libtool.m4 in (it doesn't see our shiny new m4_define
7844 # and doesn't know about Autoconf macros at all.)
7845 #
7846 # So we provide this file, which has a silly filename so it's always
7847 # included after everything else. This provides aclocal with the
7848 # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
7849 # because those macros already exist, or will be overwritten later.
7850 # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
7851 #
7852 # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
7853 # Yes, that means every name once taken will need to remain here until
7854 # we give up compatibility with versions before 1.7, at which point
7855 # we need to keep only those names which we still refer to.
7856
7857 # This is to help aclocal find these macros, as it can't see m4_define.
7858 AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
7859
7860 m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
7861 m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
7862 m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
7863 m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
7864 m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
7865 m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
7866 m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
7867 m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
7868 m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
7869 m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
7870 m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
7871 m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
7872 m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
7873 m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
7874 m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
7875 m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
7876 m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
7877 m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
7878 m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
7879 m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
7880 m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
7881 m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
7882 m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
7883 m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
7884 m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
7885 m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
7886 m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
7887 m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
7888 m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
7889 m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
7890 m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
7891 m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
7892 m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
7893 m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
7894 m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
7895 m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
7896 m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
7897 m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
7898 m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
7899 m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
7900 m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
7901 m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
7902 m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
7903 m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
7904 m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
7905 m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
7906 m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
7907 m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
7908 m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
7909 m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
7910 m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
7911 m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
7912 m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
7913 m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
7914 m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
7915
7916 # Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
7917 #
7918 # This file is free software; the Free Software Foundation
7919 # gives unlimited permission to copy and/or distribute it,
7920 # with or without modifications, as long as this notice is preserved.
7921
7922 # AM_AUTOMAKE_VERSION(VERSION)
7923 # ----------------------------
7924 # Automake X.Y traces this macro to ensure aclocal.m4 has been
7925 # generated from the m4 files accompanying Automake X.Y.
7926 # (This private macro should not be called outside this file.)
7927 AC_DEFUN([AM_AUTOMAKE_VERSION],
7928 [am__api_version='1.10'
7929 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
7930 dnl require some minimum version. Point them to the right macro.
7931 m4_if([$1], [1.10], [],
7932 [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
7933 ])
7934
7935 # _AM_AUTOCONF_VERSION(VERSION)
7936 # -----------------------------
7937 # aclocal traces this macro to find the Autoconf version.
7938 # This is a private macro too. Using m4_define simplifies
7939 # the logic in aclocal, which can simply ignore this definition.
7940 m4_define([_AM_AUTOCONF_VERSION], [])
7941
7942 # AM_SET_CURRENT_AUTOMAKE_VERSION
7943 # -------------------------------
7944 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
7945 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
7946 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
7947 [AM_AUTOMAKE_VERSION([1.10])dnl
7948 _AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)])
7949
7950 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
7951
7952 # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
7953 #
7954 # This file is free software; the Free Software Foundation
7955 # gives unlimited permission to copy and/or distribute it,
7956 # with or without modifications, as long as this notice is preserved.
7957
7958 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
7959 # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
7960 # `$srcdir', `$srcdir/..', or `$srcdir/../..'.
7961 #
7962 # Of course, Automake must honor this variable whenever it calls a
7963 # tool from the auxiliary directory. The problem is that $srcdir (and
7964 # therefore $ac_aux_dir as well) can be either absolute or relative,
7965 # depending on how configure is run. This is pretty annoying, since
7966 # it makes $ac_aux_dir quite unusable in subdirectories: in the top
7967 # source directory, any form will work fine, but in subdirectories a
7968 # relative path needs to be adjusted first.
7969 #
7970 # $ac_aux_dir/missing
7971 # fails when called from a subdirectory if $ac_aux_dir is relative
7972 # $top_srcdir/$ac_aux_dir/missing
7973 # fails if $ac_aux_dir is absolute,
7974 # fails when called from a subdirectory in a VPATH build with
7975 # a relative $ac_aux_dir
7976 #
7977 # The reason of the latter failure is that $top_srcdir and $ac_aux_dir
7978 # are both prefixed by $srcdir. In an in-source build this is usually
7979 # harmless because $srcdir is `.', but things will broke when you
7980 # start a VPATH build or use an absolute $srcdir.
7981 #
7982 # So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
7983 # iff we strip the leading $srcdir from $ac_aux_dir. That would be:
7984 # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
7985 # and then we would define $MISSING as
7986 # MISSING="\${SHELL} $am_aux_dir/missing"
7987 # This will work as long as MISSING is not called from configure, because
7988 # unfortunately $(top_srcdir) has no meaning in configure.
7989 # However there are other variables, like CC, which are often used in
7990 # configure, and could therefore not use this "fixed" $ac_aux_dir.
7991 #
7992 # Another solution, used here, is to always expand $ac_aux_dir to an
7993 # absolute PATH. The drawback is that using absolute paths prevent a
7994 # configured tree to be moved without reconfiguration.
7995
7996 AC_DEFUN([AM_AUX_DIR_EXPAND],
7997 [dnl Rely on autoconf to set up CDPATH properly.
7998 AC_PREREQ([2.50])dnl
7999 # expand $ac_aux_dir to an absolute path
8000 am_aux_dir=`cd $ac_aux_dir && pwd`
8001 ])
8002
8003 # AM_CONDITIONAL -*- Autoconf -*-
8004
8005 # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
8006 # Free Software Foundation, Inc.
8007 #
8008 # This file is free software; the Free Software Foundation
8009 # gives unlimited permission to copy and/or distribute it,
8010 # with or without modifications, as long as this notice is preserved.
8011
8012 # serial 8
8013
8014 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
8015 # -------------------------------------
8016 # Define a conditional.
8017 AC_DEFUN([AM_CONDITIONAL],
8018 [AC_PREREQ(2.52)dnl
8019 ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
8020 [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
8021 AC_SUBST([$1_TRUE])dnl
8022 AC_SUBST([$1_FALSE])dnl
8023 _AM_SUBST_NOTMAKE([$1_TRUE])dnl
8024 _AM_SUBST_NOTMAKE([$1_FALSE])dnl
8025 if $2; then
8026 $1_TRUE=
8027 $1_FALSE='#'
8028 else
8029 $1_TRUE='#'
8030 $1_FALSE=
8031 fi
8032 AC_CONFIG_COMMANDS_PRE(
8033 [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
8034 AC_MSG_ERROR([[conditional "$1" was never defined.
8035 Usually this means the macro was only invoked conditionally.]])
8036 fi])])
8037
8038 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
8039 # Free Software Foundation, Inc.
8040 #
8041 # This file is free software; the Free Software Foundation
8042 # gives unlimited permission to copy and/or distribute it,
8043 # with or without modifications, as long as this notice is preserved.
8044
8045 # serial 9
8046
8047 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
8048 # written in clear, in which case automake, when reading aclocal.m4,
8049 # will think it sees a *use*, and therefore will trigger all it's
8050 # C support machinery. Also note that it means that autoscan, seeing
8051 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
8052
8053
8054 # _AM_DEPENDENCIES(NAME)
8055 # ----------------------
8056 # See how the compiler implements dependency checking.
8057 # NAME is "CC", "CXX", "GCJ", or "OBJC".
8058 # We try a few techniques and use that to set a single cache variable.
8059 #
8060 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
8061 # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
8062 # dependency, and given that the user is not expected to run this macro,
8063 # just rely on AC_PROG_CC.
8064 AC_DEFUN([_AM_DEPENDENCIES],
8065 [AC_REQUIRE([AM_SET_DEPDIR])dnl
8066 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
8067 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
8068 AC_REQUIRE([AM_DEP_TRACK])dnl
8069
8070 ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
8071 [$1], CXX, [depcc="$CXX" am_compiler_list=],
8072 [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
8073 [$1], UPC, [depcc="$UPC" am_compiler_list=],
8074 [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
8075 [depcc="$$1" am_compiler_list=])
8076
8077 AC_CACHE_CHECK([dependency style of $depcc],
8078 [am_cv_$1_dependencies_compiler_type],
8079 [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
8080 # We make a subdir and do the tests there. Otherwise we can end up
8081 # making bogus files that we don't know about and never remove. For
8082 # instance it was reported that on HP-UX the gcc test will end up
8083 # making a dummy file named `D' -- because `-MD' means `put the output
8084 # in D'.
8085 mkdir conftest.dir
8086 # Copy depcomp to subdir because otherwise we won't find it if we're
8087 # using a relative directory.
8088 cp "$am_depcomp" conftest.dir
8089 cd conftest.dir
8090 # We will build objects and dependencies in a subdirectory because
8091 # it helps to detect inapplicable dependency modes. For instance
8092 # both Tru64's cc and ICC support -MD to output dependencies as a
8093 # side effect of compilation, but ICC will put the dependencies in
8094 # the current directory while Tru64 will put them in the object
8095 # directory.
8096 mkdir sub
8097
8098 am_cv_$1_dependencies_compiler_type=none
8099 if test "$am_compiler_list" = ""; then
8100 am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
8101 fi
8102 for depmode in $am_compiler_list; do
8103 # Setup a source with many dependencies, because some compilers
8104 # like to wrap large dependency lists on column 80 (with \), and
8105 # we should not choose a depcomp mode which is confused by this.
8106 #
8107 # We need to recreate these files for each test, as the compiler may
8108 # overwrite some of them when testing with obscure command lines.
8109 # This happens at least with the AIX C compiler.
8110 : > sub/conftest.c
8111 for i in 1 2 3 4 5 6; do
8112 echo '#include "conftst'$i'.h"' >> sub/conftest.c
8113 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
8114 # Solaris 8's {/usr,}/bin/sh.
8115 touch sub/conftst$i.h
8116 done
8117 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
8118
8119 case $depmode in
8120 nosideeffect)
8121 # after this tag, mechanisms are not by side-effect, so they'll
8122 # only be used when explicitly requested
8123 if test "x$enable_dependency_tracking" = xyes; then
8124 continue
8125 else
8126 break
8127 fi
8128 ;;
8129 none) break ;;
8130 esac
8131 # We check with `-c' and `-o' for the sake of the "dashmstdout"
8132 # mode. It turns out that the SunPro C++ compiler does not properly
8133 # handle `-M -o', and we need to detect this.
8134 if depmode=$depmode \
8135 source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
8136 depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
8137 $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
8138 >/dev/null 2>conftest.err &&
8139 grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
8140 grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
8141 grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
8142 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
8143 # icc doesn't choke on unknown options, it will just issue warnings
8144 # or remarks (even with -Werror). So we grep stderr for any message
8145 # that says an option was ignored or not supported.
8146 # When given -MP, icc 7.0 and 7.1 complain thusly:
8147 # icc: Command line warning: ignoring option '-M'; no argument required
8148 # The diagnosis changed in icc 8.0:
8149 # icc: Command line remark: option '-MP' not supported
8150 if (grep 'ignoring option' conftest.err ||
8151 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
8152 am_cv_$1_dependencies_compiler_type=$depmode
8153 break
8154 fi
8155 fi
8156 done
8157
8158 cd ..
8159 rm -rf conftest.dir
8160 else
8161 am_cv_$1_dependencies_compiler_type=none
8162 fi
8163 ])
8164 AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
8165 AM_CONDITIONAL([am__fastdep$1], [
8166 test "x$enable_dependency_tracking" != xno \
8167 && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
8168 ])
8169
8170
8171 # AM_SET_DEPDIR
8172 # -------------
8173 # Choose a directory name for dependency files.
8174 # This macro is AC_REQUIREd in _AM_DEPENDENCIES
8175 AC_DEFUN([AM_SET_DEPDIR],
8176 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
8177 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
8178 ])
8179
8180
8181 # AM_DEP_TRACK
8182 # ------------
8183 AC_DEFUN([AM_DEP_TRACK],
8184 [AC_ARG_ENABLE(dependency-tracking,
8185 [ --disable-dependency-tracking speeds up one-time build
8186 --enable-dependency-tracking do not reject slow dependency extractors])
8187 if test "x$enable_dependency_tracking" != xno; then
8188 am_depcomp="$ac_aux_dir/depcomp"
8189 AMDEPBACKSLASH='\'
8190 fi
8191 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
8192 AC_SUBST([AMDEPBACKSLASH])dnl
8193 _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
8194 ])
8195
8196 # Generate code to set up dependency tracking. -*- Autoconf -*-
8197
8198 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
8199 # Free Software Foundation, Inc.
8200 #
8201 # This file is free software; the Free Software Foundation
8202 # gives unlimited permission to copy and/or distribute it,
8203 # with or without modifications, as long as this notice is preserved.
8204
8205 #serial 3
8206
8207 # _AM_OUTPUT_DEPENDENCY_COMMANDS
8208 # ------------------------------
8209 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
8210 [for mf in $CONFIG_FILES; do
8211 # Strip MF so we end up with the name of the file.
8212 mf=`echo "$mf" | sed -e 's/:.*$//'`
8213 # Check whether this is an Automake generated Makefile or not.
8214 # We used to match only the files named `Makefile.in', but
8215 # some people rename them; so instead we look at the file content.
8216 # Grep'ing the first line is not enough: some people post-process
8217 # each Makefile.in and add a new line on top of each file to say so.
8218 # Grep'ing the whole file is not good either: AIX grep has a line
8219 # limit of 2048, but all sed's we know have understand at least 4000.
8220 if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
8221 dirpart=`AS_DIRNAME("$mf")`
8222 else
8223 continue
8224 fi
8225 # Extract the definition of DEPDIR, am__include, and am__quote
8226 # from the Makefile without running `make'.
8227 DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
8228 test -z "$DEPDIR" && continue
8229 am__include=`sed -n 's/^am__include = //p' < "$mf"`
8230 test -z "am__include" && continue
8231 am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
8232 # When using ansi2knr, U may be empty or an underscore; expand it
8233 U=`sed -n 's/^U = //p' < "$mf"`
8234 # Find all dependency output files, they are included files with
8235 # $(DEPDIR) in their names. We invoke sed twice because it is the
8236 # simplest approach to changing $(DEPDIR) to its actual value in the
8237 # expansion.
8238 for file in `sed -n "
8239 s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
8240 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
8241 # Make sure the directory exists.
8242 test -f "$dirpart/$file" && continue
8243 fdir=`AS_DIRNAME(["$file"])`
8244 AS_MKDIR_P([$dirpart/$fdir])
8245 # echo "creating $dirpart/$file"
8246 echo '# dummy' > "$dirpart/$file"
8247 done
8248 done
8249 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
8250
8251
8252 # AM_OUTPUT_DEPENDENCY_COMMANDS
8253 # -----------------------------
8254 # This macro should only be invoked once -- use via AC_REQUIRE.
8255 #
8256 # This code is only required when automatic dependency tracking
8257 # is enabled. FIXME. This creates each `.P' file that we will
8258 # need in order to bootstrap the dependency handling code.
8259 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
8260 [AC_CONFIG_COMMANDS([depfiles],
8261 [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
8262 [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
8263 ])
8264
8265 # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
8266 # Free Software Foundation, Inc.
8267 #
8268 # This file is free software; the Free Software Foundation
8269 # gives unlimited permission to copy and/or distribute it,
8270 # with or without modifications, as long as this notice is preserved.
8271
8272 # serial 8
8273
8274 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
8275 AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
8276
8277 # Do all the work for Automake. -*- Autoconf -*-
8278
8279 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
8280 # 2005, 2006 Free Software Foundation, Inc.
8281 #
8282 # This file is free software; the Free Software Foundation
8283 # gives unlimited permission to copy and/or distribute it,
8284 # with or without modifications, as long as this notice is preserved.
8285
8286 # serial 12
8287
8288 # This macro actually does too much. Some checks are only needed if
8289 # your package does certain things. But this isn't really a big deal.
8290
8291 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
8292 # AM_INIT_AUTOMAKE([OPTIONS])
8293 # -----------------------------------------------
8294 # The call with PACKAGE and VERSION arguments is the old style
8295 # call (pre autoconf-2.50), which is being phased out. PACKAGE
8296 # and VERSION should now be passed to AC_INIT and removed from
8297 # the call to AM_INIT_AUTOMAKE.
8298 # We support both call styles for the transition. After
8299 # the next Automake release, Autoconf can make the AC_INIT
8300 # arguments mandatory, and then we can depend on a new Autoconf
8301 # release and drop the old call support.
8302 AC_DEFUN([AM_INIT_AUTOMAKE],
8303 [AC_PREREQ([2.60])dnl
8304 dnl Autoconf wants to disallow AM_ names. We explicitly allow
8305 dnl the ones we care about.
8306 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
8307 AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
8308 AC_REQUIRE([AC_PROG_INSTALL])dnl
8309 if test "`cd $srcdir && pwd`" != "`pwd`"; then
8310 # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
8311 # is not polluted with repeated "-I."
8312 AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
8313 # test to see if srcdir already configured
8314 if test -f $srcdir/config.status; then
8315 AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
8316 fi
8317 fi
8318
8319 # test whether we have cygpath
8320 if test -z "$CYGPATH_W"; then
8321 if (cygpath --version) >/dev/null 2>/dev/null; then
8322 CYGPATH_W='cygpath -w'
8323 else
8324 CYGPATH_W=echo
8325 fi
8326 fi
8327 AC_SUBST([CYGPATH_W])
8328
8329 # Define the identity of the package.
8330 dnl Distinguish between old-style and new-style calls.
8331 m4_ifval([$2],
8332 [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
8333 AC_SUBST([PACKAGE], [$1])dnl
8334 AC_SUBST([VERSION], [$2])],
8335 [_AM_SET_OPTIONS([$1])dnl
8336 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
8337 m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
8338 [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
8339 AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
8340 AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
8341
8342 _AM_IF_OPTION([no-define],,
8343 [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
8344 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
8345
8346 # Some tools Automake needs.
8347 AC_REQUIRE([AM_SANITY_CHECK])dnl
8348 AC_REQUIRE([AC_ARG_PROGRAM])dnl
8349 AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
8350 AM_MISSING_PROG(AUTOCONF, autoconf)
8351 AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
8352 AM_MISSING_PROG(AUTOHEADER, autoheader)
8353 AM_MISSING_PROG(MAKEINFO, makeinfo)
8354 AM_PROG_INSTALL_SH
8355 AM_PROG_INSTALL_STRIP
8356 AC_REQUIRE([AM_PROG_MKDIR_P])dnl
8357 # We need awk for the "check" target. The system "awk" is bad on
8358 # some platforms.
8359 AC_REQUIRE([AC_PROG_AWK])dnl
8360 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
8361 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
8362 _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
8363 [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
8364 [_AM_PROG_TAR([v7])])])
8365 _AM_IF_OPTION([no-dependencies],,
8366 [AC_PROVIDE_IFELSE([AC_PROG_CC],
8367 [_AM_DEPENDENCIES(CC)],
8368 [define([AC_PROG_CC],
8369 defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
8370 AC_PROVIDE_IFELSE([AC_PROG_CXX],
8371 [_AM_DEPENDENCIES(CXX)],
8372 [define([AC_PROG_CXX],
8373 defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
8374 AC_PROVIDE_IFELSE([AC_PROG_OBJC],
8375 [_AM_DEPENDENCIES(OBJC)],
8376 [define([AC_PROG_OBJC],
8377 defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
8378 ])
8379 ])
8380
8381
8382 # When config.status generates a header, we must update the stamp-h file.
8383 # This file resides in the same directory as the config header
8384 # that is generated. The stamp files are numbered to have different names.
8385
8386 # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
8387 # loop where config.status creates the headers, so we can generate
8388 # our stamp files there.
8389 AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
8390 [# Compute $1's index in $config_headers.
8391 _am_stamp_count=1
8392 for _am_header in $config_headers :; do
8393 case $_am_header in
8394 $1 | $1:* )
8395 break ;;
8396 * )
8397 _am_stamp_count=`expr $_am_stamp_count + 1` ;;
8398 esac
8399 done
8400 echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
8401
8402 # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
8403 #
8404 # This file is free software; the Free Software Foundation
8405 # gives unlimited permission to copy and/or distribute it,
8406 # with or without modifications, as long as this notice is preserved.
8407
8408 # AM_PROG_INSTALL_SH
8409 # ------------------
8410 # Define $install_sh.
8411 AC_DEFUN([AM_PROG_INSTALL_SH],
8412 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
8413 install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
8414 AC_SUBST(install_sh)])
8415
8416 # Copyright (C) 2003, 2005 Free Software Foundation, Inc.
8417 #
8418 # This file is free software; the Free Software Foundation
8419 # gives unlimited permission to copy and/or distribute it,
8420 # with or without modifications, as long as this notice is preserved.
8421
8422 # serial 2
8423
8424 # Check whether the underlying file-system supports filenames
8425 # with a leading dot. For instance MS-DOS doesn't.
8426 AC_DEFUN([AM_SET_LEADING_DOT],
8427 [rm -rf .tst 2>/dev/null
8428 mkdir .tst 2>/dev/null
8429 if test -d .tst; then
8430 am__leading_dot=.
8431 else
8432 am__leading_dot=_
8433 fi
8434 rmdir .tst 2>/dev/null
8435 AC_SUBST([am__leading_dot])])
8436
8437 # Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
8438 # From Jim Meyering
8439
8440 # Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
8441 # Free Software Foundation, Inc.
8442 #
8443 # This file is free software; the Free Software Foundation
8444 # gives unlimited permission to copy and/or distribute it,
8445 # with or without modifications, as long as this notice is preserved.
8446
8447 # serial 4
8448
8449 AC_DEFUN([AM_MAINTAINER_MODE],
8450 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
8451 dnl maintainer-mode is disabled by default
8452 AC_ARG_ENABLE(maintainer-mode,
8453 [ --enable-maintainer-mode enable make rules and dependencies not useful
8454 (and sometimes confusing) to the casual installer],
8455 USE_MAINTAINER_MODE=$enableval,
8456 USE_MAINTAINER_MODE=no)
8457 AC_MSG_RESULT([$USE_MAINTAINER_MODE])
8458 AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
8459 MAINT=$MAINTAINER_MODE_TRUE
8460 AC_SUBST(MAINT)dnl
8461 ]
8462 )
8463
8464 AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
8465
8466 # Check to see how 'make' treats includes. -*- Autoconf -*-
8467
8468 # Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
8469 #
8470 # This file is free software; the Free Software Foundation
8471 # gives unlimited permission to copy and/or distribute it,
8472 # with or without modifications, as long as this notice is preserved.
8473
8474 # serial 3
8475
8476 # AM_MAKE_INCLUDE()
8477 # -----------------
8478 # Check to see how make treats includes.
8479 AC_DEFUN([AM_MAKE_INCLUDE],
8480 [am_make=${MAKE-make}
8481 cat > confinc << 'END'
8482 am__doit:
8483 @echo done
8484 .PHONY: am__doit
8485 END
8486 # If we don't find an include directive, just comment out the code.
8487 AC_MSG_CHECKING([for style of include used by $am_make])
8488 am__include="#"
8489 am__quote=
8490 _am_result=none
8491 # First try GNU make style include.
8492 echo "include confinc" > confmf
8493 # We grep out `Entering directory' and `Leaving directory'
8494 # messages which can occur if `w' ends up in MAKEFLAGS.
8495 # In particular we don't look at `^make:' because GNU make might
8496 # be invoked under some other name (usually "gmake"), in which
8497 # case it prints its new name instead of `make'.
8498 if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
8499 am__include=include
8500 am__quote=
8501 _am_result=GNU
8502 fi
8503 # Now try BSD make style include.
8504 if test "$am__include" = "#"; then
8505 echo '.include "confinc"' > confmf
8506 if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
8507 am__include=.include
8508 am__quote="\""
8509 _am_result=BSD
8510 fi
8511 fi
8512 AC_SUBST([am__include])
8513 AC_SUBST([am__quote])
8514 AC_MSG_RESULT([$_am_result])
8515 rm -f confinc confmf
8516 ])
8517
8518 # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005
8519 # Free Software Foundation, Inc.
8520 #
8521 # This file is free software; the Free Software Foundation
8522 # gives unlimited permission to copy and/or distribute it,
8523 # with or without modifications, as long as this notice is preserved.
8524
8525 # serial 5
8526
8527 # AM_PROG_CC_C_O
8528 # --------------
8529 # Like AC_PROG_CC_C_O, but changed for automake.
8530 AC_DEFUN([AM_PROG_CC_C_O],
8531 [AC_REQUIRE([AC_PROG_CC_C_O])dnl
8532 AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
8533 AC_REQUIRE_AUX_FILE([compile])dnl
8534 # FIXME: we rely on the cache variable name because
8535 # there is no other way.
8536 set dummy $CC
8537 ac_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
8538 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
8539 # Losing compiler, so override with the script.
8540 # FIXME: It is wrong to rewrite CC.
8541 # But if we don't then we get into trouble of one sort or another.
8542 # A longer-term fix would be to have automake use am__CC in this case,
8543 # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
8544 CC="$am_aux_dir/compile $CC"
8545 fi
8546 dnl Make sure AC_PROG_CC is never called again, or it will override our
8547 dnl setting of CC.
8548 m4_define([AC_PROG_CC],
8549 [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
8550 ])
8551
8552 # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
8553
8554 # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
8555 # Free Software Foundation, Inc.
8556 #
8557 # This file is free software; the Free Software Foundation
8558 # gives unlimited permission to copy and/or distribute it,
8559 # with or without modifications, as long as this notice is preserved.
8560
8561 # serial 5
8562
8563 # AM_MISSING_PROG(NAME, PROGRAM)
8564 # ------------------------------
8565 AC_DEFUN([AM_MISSING_PROG],
8566 [AC_REQUIRE([AM_MISSING_HAS_RUN])
8567 $1=${$1-"${am_missing_run}$2"}
8568 AC_SUBST($1)])
8569
8570
8571 # AM_MISSING_HAS_RUN
8572 # ------------------
8573 # Define MISSING if not defined so far and test if it supports --run.
8574 # If it does, set am_missing_run to use it, otherwise, to nothing.
8575 AC_DEFUN([AM_MISSING_HAS_RUN],
8576 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
8577 AC_REQUIRE_AUX_FILE([missing])dnl
8578 test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
8579 # Use eval to expand $SHELL
8580 if eval "$MISSING --run true"; then
8581 am_missing_run="$MISSING --run "
8582 else
8583 am_missing_run=
8584 AC_MSG_WARN([`missing' script is too old or missing])
8585 fi
8586 ])
8587
8588 # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
8589 #
8590 # This file is free software; the Free Software Foundation
8591 # gives unlimited permission to copy and/or distribute it,
8592 # with or without modifications, as long as this notice is preserved.
8593
8594 # AM_PROG_MKDIR_P
8595 # ---------------
8596 # Check for `mkdir -p'.
8597 AC_DEFUN([AM_PROG_MKDIR_P],
8598 [AC_PREREQ([2.60])dnl
8599 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
8600 dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
8601 dnl while keeping a definition of mkdir_p for backward compatibility.
8602 dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
8603 dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
8604 dnl Makefile.ins that do not define MKDIR_P, so we do our own
8605 dnl adjustment using top_builddir (which is defined more often than
8606 dnl MKDIR_P).
8607 AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
8608 case $mkdir_p in
8609 [[\\/$]]* | ?:[[\\/]]*) ;;
8610 */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
8611 esac
8612 ])
8613
8614 # Helper functions for option handling. -*- Autoconf -*-
8615
8616 # Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
8617 #
8618 # This file is free software; the Free Software Foundation
8619 # gives unlimited permission to copy and/or distribute it,
8620 # with or without modifications, as long as this notice is preserved.
8621
8622 # serial 3
8623
8624 # _AM_MANGLE_OPTION(NAME)
8625 # -----------------------
8626 AC_DEFUN([_AM_MANGLE_OPTION],
8627 [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
8628
8629 # _AM_SET_OPTION(NAME)
8630 # ------------------------------
8631 # Set option NAME. Presently that only means defining a flag for this option.
8632 AC_DEFUN([_AM_SET_OPTION],
8633 [m4_define(_AM_MANGLE_OPTION([$1]), 1)])
8634
8635 # _AM_SET_OPTIONS(OPTIONS)
8636 # ----------------------------------
8637 # OPTIONS is a space-separated list of Automake options.
8638 AC_DEFUN([_AM_SET_OPTIONS],
8639 [AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
8640
8641 # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
8642 # -------------------------------------------
8643 # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
8644 AC_DEFUN([_AM_IF_OPTION],
8645 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
8646
8647 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
8648 # Free Software Foundation, Inc.
8649 #
8650 # This file is free software; the Free Software Foundation
8651 # gives unlimited permission to copy and/or distribute it,
8652 # with or without modifications, as long as this notice is preserved.
8653
8654 # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
8655 # ---------------------------------------------------------------------------
8656 # Adds support for distributing Python modules and packages. To
8657 # install modules, copy them to $(pythondir), using the python_PYTHON
8658 # automake variable. To install a package with the same name as the
8659 # automake package, install to $(pkgpythondir), or use the
8660 # pkgpython_PYTHON automake variable.
8661 #
8662 # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
8663 # locations to install python extension modules (shared libraries).
8664 # Another macro is required to find the appropriate flags to compile
8665 # extension modules.
8666 #
8667 # If your package is configured with a different prefix to python,
8668 # users will have to add the install directory to the PYTHONPATH
8669 # environment variable, or create a .pth file (see the python
8670 # documentation for details).
8671 #
8672 # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
8673 # cause an error if the version of python installed on the system
8674 # doesn't meet the requirement. MINIMUM-VERSION should consist of
8675 # numbers and dots only.
8676 AC_DEFUN([AM_PATH_PYTHON],
8677 [
8678 dnl Find a Python interpreter. Python versions prior to 1.5 are not
8679 dnl supported because the default installation locations changed from
8680 dnl $prefix/lib/site-python in 1.4 to $prefix/lib/python1.5/site-packages
8681 dnl in 1.5.
8682 m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
8683 [python python2 python2.5 python2.4 python2.3 python2.2 dnl
8684 python2.1 python2.0 python1.6 python1.5])
8685
8686 m4_if([$1],[],[
8687 dnl No version check is needed.
8688 # Find any Python interpreter.
8689 if test -z "$PYTHON"; then
8690 AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
8691 fi
8692 am_display_PYTHON=python
8693 ], [
8694 dnl A version check is needed.
8695 if test -n "$PYTHON"; then
8696 # If the user set $PYTHON, use it and don't search something else.
8697 AC_MSG_CHECKING([whether $PYTHON version >= $1])
8698 AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
8699 [AC_MSG_RESULT(yes)],
8700 [AC_MSG_ERROR(too old)])
8701 am_display_PYTHON=$PYTHON
8702 else
8703 # Otherwise, try each interpreter until we find one that satisfies
8704 # VERSION.
8705 AC_CACHE_CHECK([for a Python interpreter with version >= $1],
8706 [am_cv_pathless_PYTHON],[
8707 for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
8708 test "$am_cv_pathless_PYTHON" = none && break
8709 AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
8710 done])
8711 # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
8712 if test "$am_cv_pathless_PYTHON" = none; then
8713 PYTHON=:
8714 else
8715 AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
8716 fi
8717 am_display_PYTHON=$am_cv_pathless_PYTHON
8718 fi
8719 ])
8720
8721 if test "$PYTHON" = :; then
8722 dnl Run any user-specified action, or abort.
8723 m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
8724 else
8725
8726 dnl Query Python for its version number. Getting [:3] seems to be
8727 dnl the best way to do this; it's what "site.py" does in the standard
8728 dnl library.
8729
8730 AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
8731 [am_cv_python_version=`$PYTHON -c "import sys; print sys.version[[:3]]"`])
8732 AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
8733
8734 dnl Use the values of $prefix and $exec_prefix for the corresponding
8735 dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made
8736 dnl distinct variables so they can be overridden if need be. However,
8737 dnl general consensus is that you shouldn't need this ability.
8738
8739 AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
8740 AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
8741
8742 dnl At times (like when building shared libraries) you may want
8743 dnl to know which OS platform Python thinks this is.
8744
8745 AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
8746 [am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`])
8747 AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
8748
8749
8750 dnl Set up 4 directories:
8751
8752 dnl pythondir -- where to install python scripts. This is the
8753 dnl site-packages directory, not the python standard library
8754 dnl directory like in previous automake betas. This behavior
8755 dnl is more consistent with lispdir.m4 for example.
8756 dnl Query distutils for this directory. distutils does not exist in
8757 dnl Python 1.5, so we fall back to the hardcoded directory if it
8758 dnl doesn't work.
8759 AC_CACHE_CHECK([for $am_display_PYTHON script directory],
8760 [am_cv_python_pythondir],
8761 [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
8762 echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`])
8763 AC_SUBST([pythondir], [$am_cv_python_pythondir])
8764
8765 dnl pkgpythondir -- $PACKAGE directory under pythondir. Was
8766 dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is
8767 dnl more consistent with the rest of automake.
8768
8769 AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
8770
8771 dnl pyexecdir -- directory for installing python extension modules
8772 dnl (shared libraries)
8773 dnl Query distutils for this directory. distutils does not exist in
8774 dnl Python 1.5, so we fall back to the hardcoded directory if it
8775 dnl doesn't work.
8776 AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
8777 [am_cv_python_pyexecdir],
8778 [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
8779 echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`])
8780 AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
8781
8782 dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
8783
8784 AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
8785
8786 dnl Run any user-specified action.
8787 $2
8788 fi
8789
8790 ])
8791
8792
8793 # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
8794 # ---------------------------------------------------------------------------
8795 # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION.
8796 # Run ACTION-IF-FALSE otherwise.
8797 # This test uses sys.hexversion instead of the string equivalent (first
8798 # word of sys.version), in order to cope with versions such as 2.2c1.
8799 # hexversion has been introduced in Python 1.5.2; it's probably not
8800 # worth to support older versions (1.5.1 was released on October 31, 1998).
8801 AC_DEFUN([AM_PYTHON_CHECK_VERSION],
8802 [prog="import sys, string
8803 # split strings by '.' and convert to numeric. Append some zeros
8804 # because we need at least 4 digits for the hex conversion.
8805 minver = map(int, string.split('$2', '.')) + [[0, 0, 0]]
8806 minverhex = 0
8807 for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[[i]]
8808 sys.exit(sys.hexversion < minverhex)"
8809 AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
8810
8811 # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
8812 #
8813 # This file is free software; the Free Software Foundation
8814 # gives unlimited permission to copy and/or distribute it,
8815 # with or without modifications, as long as this notice is preserved.
8816
8817 # AM_RUN_LOG(COMMAND)
8818 # -------------------
8819 # Run COMMAND, save the exit status in ac_status, and log it.
8820 # (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
8821 AC_DEFUN([AM_RUN_LOG],
8822 [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
8823 ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
8824 ac_status=$?
8825 echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
8826 (exit $ac_status); }])
8827
8828 # Check to make sure that the build environment is sane. -*- Autoconf -*-
8829
8830 # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
8831 # Free Software Foundation, Inc.
8832 #
8833 # This file is free software; the Free Software Foundation
8834 # gives unlimited permission to copy and/or distribute it,
8835 # with or without modifications, as long as this notice is preserved.
8836
8837 # serial 4
8838
8839 # AM_SANITY_CHECK
8840 # ---------------
8841 AC_DEFUN([AM_SANITY_CHECK],
8842 [AC_MSG_CHECKING([whether build environment is sane])
8843 # Just in case
8844 sleep 1
8845 echo timestamp > conftest.file
8846 # Do `set' in a subshell so we don't clobber the current shell's
8847 # arguments. Must try -L first in case configure is actually a
8848 # symlink; some systems play weird games with the mod time of symlinks
8849 # (eg FreeBSD returns the mod time of the symlink's containing
8850 # directory).
8851 if (
8852 set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
8853 if test "$[*]" = "X"; then
8854 # -L didn't work.
8855 set X `ls -t $srcdir/configure conftest.file`
8856 fi
8857 rm -f conftest.file
8858 if test "$[*]" != "X $srcdir/configure conftest.file" \
8859 && test "$[*]" != "X conftest.file $srcdir/configure"; then
8860
8861 # If neither matched, then we have a broken ls. This can happen
8862 # if, for instance, CONFIG_SHELL is bash and it inherits a
8863 # broken ls alias from the environment. This has actually
8864 # happened. Such a system could not be considered "sane".
8865 AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
8866 alias in your environment])
8867 fi
8868
8869 test "$[2]" = conftest.file
8870 )
8871 then
8872 # Ok.
8873 :
8874 else
8875 AC_MSG_ERROR([newly created file is older than distributed files!
8876 Check your system clock])
8877 fi
8878 AC_MSG_RESULT(yes)])
8879
8880 # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
8881 #
8882 # This file is free software; the Free Software Foundation
8883 # gives unlimited permission to copy and/or distribute it,
8884 # with or without modifications, as long as this notice is preserved.
8885
8886 # AM_PROG_INSTALL_STRIP
8887 # ---------------------
8888 # One issue with vendor `install' (even GNU) is that you can't
8889 # specify the program used to strip binaries. This is especially
8890 # annoying in cross-compiling environments, where the build's strip
8891 # is unlikely to handle the host's binaries.
8892 # Fortunately install-sh will honor a STRIPPROG variable, so we
8893 # always use install-sh in `make install-strip', and initialize
8894 # STRIPPROG with the value of the STRIP variable (set by the user).
8895 AC_DEFUN([AM_PROG_INSTALL_STRIP],
8896 [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
8897 # Installed binaries are usually stripped using `strip' when the user
8898 # run `make install-strip'. However `strip' might not be the right
8899 # tool to use in cross-compilation environments, therefore Automake
8900 # will honor the `STRIP' environment variable to overrule this program.
8901 dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
8902 if test "$cross_compiling" != no; then
8903 AC_CHECK_TOOL([STRIP], [strip], :)
8904 fi
8905 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
8906 AC_SUBST([INSTALL_STRIP_PROGRAM])])
8907
8908 # Copyright (C) 2006 Free Software Foundation, Inc.
8909 #
8910 # This file is free software; the Free Software Foundation
8911 # gives unlimited permission to copy and/or distribute it,
8912 # with or without modifications, as long as this notice is preserved.
8913
8914 # _AM_SUBST_NOTMAKE(VARIABLE)
8915 # ---------------------------
8916 # Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in.
8917 # This macro is traced by Automake.
8918 AC_DEFUN([_AM_SUBST_NOTMAKE])
8919
8920 # Check how to create a tarball. -*- Autoconf -*-
8921
8922 # Copyright (C) 2004, 2005 Free Software Foundation, Inc.
8923 #
8924 # This file is free software; the Free Software Foundation
8925 # gives unlimited permission to copy and/or distribute it,
8926 # with or without modifications, as long as this notice is preserved.
8927
8928 # serial 2
8929
8930 # _AM_PROG_TAR(FORMAT)
8931 # --------------------
8932 # Check how to create a tarball in format FORMAT.
8933 # FORMAT should be one of `v7', `ustar', or `pax'.
8934 #
8935 # Substitute a variable $(am__tar) that is a command
8936 # writing to stdout a FORMAT-tarball containing the directory
8937 # $tardir.
8938 # tardir=directory && $(am__tar) > result.tar
8939 #
8940 # Substitute a variable $(am__untar) that extract such
8941 # a tarball read from stdin.
8942 # $(am__untar) < result.tar
8943 AC_DEFUN([_AM_PROG_TAR],
8944 [# Always define AMTAR for backward compatibility.
8945 AM_MISSING_PROG([AMTAR], [tar])
8946 m4_if([$1], [v7],
8947 [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
8948 [m4_case([$1], [ustar],, [pax],,
8949 [m4_fatal([Unknown tar format])])
8950 AC_MSG_CHECKING([how to create a $1 tar archive])
8951 # Loop over all known methods to create a tar archive until one works.
8952 _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
8953 _am_tools=${am_cv_prog_tar_$1-$_am_tools}
8954 # Do not fold the above two line into one, because Tru64 sh and
8955 # Solaris sh will not grok spaces in the rhs of `-'.
8956 for _am_tool in $_am_tools
8957 do
8958 case $_am_tool in
8959 gnutar)
8960 for _am_tar in tar gnutar gtar;
8961 do
8962 AM_RUN_LOG([$_am_tar --version]) && break
8963 done
8964 am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
8965 am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
8966 am__untar="$_am_tar -xf -"
8967 ;;
8968 plaintar)
8969 # Must skip GNU tar: if it does not support --format= it doesn't create
8970 # ustar tarball either.
8971 (tar --version) >/dev/null 2>&1 && continue
8972 am__tar='tar chf - "$$tardir"'
8973 am__tar_='tar chf - "$tardir"'
8974 am__untar='tar xf -'
8975 ;;
8976 pax)
8977 am__tar='pax -L -x $1 -w "$$tardir"'
8978 am__tar_='pax -L -x $1 -w "$tardir"'
8979 am__untar='pax -r'
8980 ;;
8981 cpio)
8982 am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
8983 am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
8984 am__untar='cpio -i -H $1 -d'
8985 ;;
8986 none)
8987 am__tar=false
8988 am__tar_=false
8989 am__untar=false
8990 ;;
8991 esac
8992
8993 # If the value was cached, stop now. We just wanted to have am__tar
8994 # and am__untar set.
8995 test -n "${am_cv_prog_tar_$1}" && break
8996
8997 # tar/untar a dummy directory, and stop if the command works
8998 rm -rf conftest.dir
8999 mkdir conftest.dir
9000 echo GrepMe > conftest.dir/file
9001 AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
9002 rm -rf conftest.dir
9003 if test -s conftest.tar; then
9004 AM_RUN_LOG([$am__untar <conftest.tar])
9005 grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
9006 fi
9007 done
9008 rm -rf conftest.dir
9009
9010 AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
9011 AC_MSG_RESULT([$am_cv_prog_tar_$1])])
9012 AC_SUBST([am__tar])
9013 AC_SUBST([am__untar])
9014 ]) # _AM_PROG_TAR
9015
0 # See http://autoconf-archive.cryp.to/acx_pthread.html
1 #License
2 #
3 #Copyright © 2008 Steven G. Johnson <stevenj@alum.mit.edu>
4 #
5 #This program is free software: you can redistribute it and/or modify
6 #it under the terms of the GNU General Public License as published by
7 #the Free Software Foundation, either version 3 of the License, or (at
8 #your option) any later version.
9
10 AC_DEFUN([ACX_PTHREAD], [
11 AC_REQUIRE([AC_CANONICAL_HOST])
12 AC_LANG_SAVE
13 AC_LANG_C
14 acx_pthread_ok=no
15
16 # We used to check for pthread.h first, but this fails if pthread.h
17 # requires special compiler flags (e.g. on True64 or Sequent).
18 # It gets checked for in the link test anyway.
19
20 # First of all, check if the user has set any of the PTHREAD_LIBS,
21 # etcetera environment variables, and if threads linking works using
22 # them:
23 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
24 save_CFLAGS="$CFLAGS"
25 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
26 v save_LIBS="$LIBS"
27 LIBS="$PTHREAD_LIBS $LIBS"
28 AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
29 AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
30 AC_MSG_RESULT($acx_pthread_ok)
31 if test x"$acx_pthread_ok" = xno; then
32 PTHREAD_LIBS=""
33 PTHREAD_CFLAGS=""
34 fi
35 LIBS="$save_LIBS"
36 CFLAGS="$save_CFLAGS"
37 fi
38
39 # We must check for the threads library under a number of different
40 # names; the ordering is very important because some systems
41 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
42 # libraries is broken (non-POSIX).
43
44 # Create a list of thread flags to try. Items starting with a "-" are
45 # C compiler flags, and other items are library names, except for "none"
46 # which indicates that we try without any flags at all, and "pthread-config"
47 # which is a program returning the flags for the Pth emulation library.
48
49 acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
50
51 # The ordering *is* (sometimes) important. Some notes on the
52 # individual items follow:
53
54 # pthreads: AIX (must check this before -lpthread)
55 # none: in case threads are in libc; should be tried before -Kthread and
56 # other compiler flags to prevent continual compiler warnings
57 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
58 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
59 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
60 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
61 # -pthreads: Solaris/gcc
62 # -mthreads: Mingw32/gcc, Lynx/gcc
63 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
64 # doesn't hurt to check since this sometimes defines pthreads too;
65 # also defines -D_REENTRANT)
66 # ... -mt is also the pthreads flag for HP/aCC
67 # pthread: Linux, etcetera
68 # --thread-safe: KAI C++
69 # pthread-config: use pthread-config program (for GNU Pth library)
70
71 case "${host_cpu}-${host_os}" in
72 *solaris*)
73
74 # On Solaris (at least, for some versions), libc contains stubbed
75 # (non-functional) versions of the pthreads routines, so link-based
76 # tests will erroneously succeed. (We need to link with -pthreads/-mt/
77 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
78 # a function called by this macro, so we could check for that, but
79 # who knows whether they'll stub that too in a future libc.) So,
80 # we'll just look for -pthreads and -lpthread first:
81
82 acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
83 ;;
84 esac
85
86 if test x"$acx_pthread_ok" = xno; then
87 for flag in $acx_pthread_flags; do
88
89 case $flag in
90 none)
91 AC_MSG_CHECKING([whether pthreads work without any flags])
92 ;;
93
94 -*)
95 AC_MSG_CHECKING([whether pthreads work with $flag])
96 PTHREAD_CFLAGS="$flag"
97 ;;
98
99 pthread-config)
100 AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
101 if test x"$acx_pthread_config" = xno; then continue; fi
102 PTHREAD_CFLAGS="`pthread-config --cflags`"
103 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
104 ;;
105
106 *)
107 AC_MSG_CHECKING([for the pthreads library -l$flag])
108 PTHREAD_LIBS="-l$flag"
109 ;;
110 esac
111
112 save_LIBS="$LIBS"
113 save_CFLAGS="$CFLAGS"
114 LIBS="$PTHREAD_LIBS $LIBS"
115 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
116
117 # Check for various functions. We must include pthread.h,
118 # since some functions may be macros. (On the Sequent, we
119 # need a special flag -Kthread to make this header compile.)
120 # We check for pthread_join because it is in -lpthread on IRIX
121 # while pthread_create is in libc. We check for pthread_attr_init
122 # due to DEC craziness with -lpthreads. We check for
123 # pthread_cleanup_push because it is one of the few pthread
124 # functions on Solaris that doesn't have a non-functional libc stub.
125 # We try pthread_create on general principles.
126 AC_TRY_LINK([#include <pthread.h>],
127 [pthread_t th; pthread_join(th, 0);
128 pthread_attr_init(0); pthread_cleanup_push(0, 0);
129 pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
130 [acx_pthread_ok=yes])
131
132 LIBS="$save_LIBS"
133 CFLAGS="$save_CFLAGS"
134
135 AC_MSG_RESULT($acx_pthread_ok)
136 if test "x$acx_pthread_ok" = xyes; then
137 break;
138 fi
139
140 PTHREAD_LIBS=""
141 PTHREAD_CFLAGS=""
142 done
143 fi
144
145 # Various other checks:
146 if test "x$acx_pthread_ok" = xyes; then
147 save_LIBS="$LIBS"
148 LIBS="$PTHREAD_LIBS $LIBS"
149 save_CFLAGS="$CFLAGS"
150 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
151
152 # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
153 AC_MSG_CHECKING([for joinable pthread attribute])
154 attr_name=unknown
155 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
156 AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
157 [attr_name=$attr; break])
158 done
159 AC_MSG_RESULT($attr_name)
160 if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
161 AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
162 [Define to necessary symbol if this constant
163 uses a non-standard name on your system.])
164 fi
165
166 AC_MSG_CHECKING([if more special flags are required for pthreads])
167 flag=no
168 case "${host_cpu}-${host_os}" in
169 *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
170 *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
171 esac
172 AC_MSG_RESULT(${flag})
173 if test "x$flag" != xno; then
174 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
175 fi
176
177 LIBS="$save_LIBS"
178 CFLAGS="$save_CFLAGS"
179
180 # More AIX lossage: must compile with xlc_r or cc_r
181 if test x"$GCC" != xyes; then
182 AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
183 else
184 PTHREAD_CC=$CC
185 fi
186 else
187 PTHREAD_CC="$CC"
188 fi
189
190 AC_SUBST(PTHREAD_LIBS)
191 AC_SUBST(PTHREAD_CFLAGS)
192 AC_SUBST(PTHREAD_CC)
193
194 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
195 if test x"$acx_pthread_ok" = xyes; then
196 ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
197 :
198 else
199 acx_pthread_ok=no
200 $2
201 fi
202 AC_LANG_RESTORE
203 ])dnl ACX_PTHREAD
0 /* affconfig.h.in. Generated from configure.ac by autoheader. */
1
2 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
3 systems. This function is required for `alloca.c' support on those systems.
4 */
5 #undef CRAY_STACKSEG_END
6
7 /* Define to 1 if using `alloca.c'. */
8 #undef C_ALLOCA
9
10 /* User has disabled PTHREADING */
11 #undef DISABLE_PTHREAD
12
13 /* User has disabled QEMU support */
14 #undef DISABLE_QEMU
15
16 /* Define to 1 if you have the `AES_encrypt' function. */
17 #undef HAVE_AES_ENCRYPT
18
19 /* Define to 1 if you have `alloca', as a function or macro. */
20 #undef HAVE_ALLOCA
21
22 /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
23 */
24 #undef HAVE_ALLOCA_H
25
26 /* Define to 1 if you have the <arpa/inet.h> header file. */
27 #undef HAVE_ARPA_INET_H
28
29 /* Define to 1 if you have the <assert.h> header file. */
30 #undef HAVE_ASSERT_H
31
32 /* Define to 1 if you have the `beep' function. */
33 #undef HAVE_BEEP
34
35 /* Define to 1 if you have the <cstring> header file. */
36 #undef HAVE_CSTRING
37
38 /* Define to 1 if you have the <ctype.h> header file. */
39 #undef HAVE_CTYPE_H
40
41 /* Define to 1 if you have the <curses.h> header file. */
42 #undef HAVE_CURSES_H
43
44 /* Define to 1 if you have the `des_read_pw_string' function. */
45 #undef HAVE_DES_READ_PW_STRING
46
47 /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
48 */
49 #undef HAVE_DIRENT_H
50
51 /* Define to 1 if you have the <dlfcn.h> header file. */
52 #undef HAVE_DLFCN_H
53
54 /* Define to 1 if you have the <dmalloc.h> header file. */
55 #undef HAVE_DMALLOC_H
56
57 /* Define to 1 if you have the `endwin' function. */
58 #undef HAVE_ENDWIN
59
60 /* Define to 1 if you have the `err' function. */
61 #undef HAVE_ERR
62
63 /* Define to 1 if you have the <errno.h> header file. */
64 #undef HAVE_ERRNO_H
65
66 /* Define to 1 if you have the `errx' function. */
67 #undef HAVE_ERRX
68
69 /* Define to 1 if you have the <err.h> header file. */
70 #undef HAVE_ERR_H
71
72 /* Define to 1 if you have the `err_set_exit' function. */
73 #undef HAVE_ERR_SET_EXIT
74
75 /* Define to 1 if you have the `EVP_MD_size' function. */
76 #undef HAVE_EVP_MD_SIZE
77
78 /* Define to 1 if you have the `EVP_read_pw_string' function. */
79 #undef HAVE_EVP_READ_PW_STRING
80
81 /* Define to 1 if you have the <fcntl.h> header file. */
82 #undef HAVE_FCNTL_H
83
84 /* Define to 1 if you have the `flock' function. */
85 #undef HAVE_FLOCK
86
87 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
88 #undef HAVE_FSEEKO
89
90 /* Define to 1 if you have the `fstatfs' function. */
91 #undef HAVE_FSTATFS
92
93 /* Define to 1 if you have the `ftruncate' function. */
94 #undef HAVE_FTRUNCATE
95
96 /* Define to 1 if you have the <getopt.h> header file. */
97 #undef HAVE_GETOPT_H
98
99 /* Define to 1 if you have the `getprogname' function. */
100 #undef HAVE_GETPROGNAME
101
102 /* Define to 1 if you have the `gotorc' function. */
103 #undef HAVE_GOTORC
104
105 /* Define to 1 if you have the <inttypes.h> header file. */
106 #undef HAVE_INTTYPES_H
107
108 /* Define to 1 if you have the `isalnum' function. */
109 #undef HAVE_ISALNUM
110
111 /* Define to 1 if you have the `isalphanum' function. */
112 #undef HAVE_ISALPHANUM
113
114 /* Define to 1 if you have the `isatty' function. */
115 #undef HAVE_ISATTY
116
117 /* Define to 1 if you have the `isdigit' function. */
118 #undef HAVE_ISDIGIT
119
120 /* Define to 1 if you have the `crypto' library (-lcrypto). */
121 #undef HAVE_LIBCRYPTO
122
123 /* Define to 1 if you have the `curl' library (-lcurl). */
124 #undef HAVE_LIBCURL
125
126 /* Define to 1 if you have the `ewf' library (-lewf). */
127 #undef HAVE_LIBEWF
128
129 /* Define to 1 if you have the libewf_get_bytes_per_sector function. */
130 #undef HAVE_LIBEWF_GET_BYTES_PER_SECTOR
131
132 /* Define to 1 if libewf_get_bytes_per_sector takes value as an argument. */
133 #undef HAVE_LIBEWF_GET_BYTES_PER_SECTOR_ARGUMENT_VALUE
134
135 /* Define to 1 if you have the libewf_get_chunk_size function. */
136 #undef HAVE_LIBEWF_GET_CHUNK_SIZE
137
138 /* Define to 1 if libewf_get_chunk_size takes value as an argument. */
139 #undef HAVE_LIBEWF_GET_CHUNK_SIZE_ARGUMENT_VALUE
140
141 /* Define to 1 if you have the libewf_get_media_size function. */
142 #undef HAVE_LIBEWF_GET_MEDIA_SIZE
143
144 /* Define to 1 if libewf_get_media_size takes value as an argument. */
145 #undef HAVE_LIBEWF_GET_MEDIA_SIZE_ARGUMENT_VALUE
146
147 /* Define to 1 if you have the <libewf.h> header file. */
148 #undef HAVE_LIBEWF_H
149
150 /* Define to 1 if you have the `expat' library (-lexpat). */
151 #undef HAVE_LIBEXPAT
152
153 /* Define to 1 if you have the `md' library (-lmd). */
154 #undef HAVE_LIBMD
155
156 /* Define to 1 if you have the `ncurses' library (-lncurses). */
157 #undef HAVE_LIBNCURSES
158
159 /* Define to 1 if you have the `readline' library (-lreadline). */
160 #undef HAVE_LIBREADLINE
161
162 /* Define to 1 if you have the `rt' library (-lrt). */
163 #undef HAVE_LIBRT
164
165 /* Define to 1 if you have the `ssl' library (-lssl). */
166 #undef HAVE_LIBSSL
167
168 /* Define to 1 if you have the `uuid' library (-luuid). */
169 #undef HAVE_LIBUUID
170
171 /* Define to 1 if you have the `z' library (-lz). */
172 #undef HAVE_LIBZ
173
174 /* Define to 1 if you have the <linux/fs.h> header file. */
175 #undef HAVE_LINUX_FS_H
176
177 /* Define to 1 if you have the <malloc.h> header file. */
178 #undef HAVE_MALLOC_H
179
180 /* Define to 1 if you have the `MD5' function. */
181 #undef HAVE_MD5
182
183 /* Define to 1 if you have the <memory.h> header file. */
184 #undef HAVE_MEMORY_H
185
186 /* Define to 1 if you have the `memset' function. */
187 #undef HAVE_MEMSET
188
189 /* Define to 1 if you have the `mkdir' function. */
190 #undef HAVE_MKDIR
191
192 /* Define to 1 if you have the <ncurses/term.h> header file. */
193 #undef HAVE_NCURSES_TERM_H
194
195 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
196 #undef HAVE_NDIR_H
197
198 /* Define to 1 if you have the <netinet/in.h> header file. */
199 #undef HAVE_NETINET_IN_H
200
201 /* Define to 1 if you have the <openssl/aes.h> header file. */
202 #undef HAVE_OPENSSL_AES_H
203
204 /* Define to 1 if you have the <openssl/bio.h> header file. */
205 #undef HAVE_OPENSSL_BIO_H
206
207 /* Define to 1 if you have the <openssl/evp.h> header file. */
208 #undef HAVE_OPENSSL_EVP_H
209
210 /* Define to 1 if you have the <openssl/hmac.h> header file. */
211 #undef HAVE_OPENSSL_HMAC_H
212
213 /* Define to 1 if you have the <openssl/md5.h> header file. */
214 #undef HAVE_OPENSSL_MD5_H
215
216 /* Define to 1 if you have the <openssl/pem.h> header file. */
217 #undef HAVE_OPENSSL_PEM_H
218
219 /* Define to 1 if you have the <openssl/rand.h> header file. */
220 #undef HAVE_OPENSSL_RAND_H
221
222 /* Define to 1 if you have the <openssl/rsa.h> header file. */
223 #undef HAVE_OPENSSL_RSA_H
224
225 /* Define to 1 if you have the <openssl/sha.h> header file. */
226 #undef HAVE_OPENSSL_SHA_H
227
228 /* Define to 1 if you have the <openssl/x509.h> header file. */
229 #undef HAVE_OPENSSL_X509_H
230
231 /* Define to 1 if you have the `PEM_read_bio_RSA_PUBKEY' function. */
232 #undef HAVE_PEM_READ_BIO_RSA_PUBKEY
233
234 /* Define to 1 if you have the `popen' function. */
235 #undef HAVE_POPEN
236
237 /* Define to 1 if you have the `printw' function. */
238 #undef HAVE_PRINTW
239
240 /* Define if you have POSIX threads libraries and header files. */
241 #undef HAVE_PTHREAD
242
243 /* Define to 1 if you have the `putenv' function. */
244 #undef HAVE_PUTENV
245
246 /* Build Python bindings */
247 #undef HAVE_PYTHON
248
249 /* Define to 1 if you have the `RAND_pseudo_bytes' function. */
250 #undef HAVE_RAND_PSEUDO_BYTES
251
252 /* Define to 1 if you have the <readline/readline.h> header file. */
253 #undef HAVE_READLINE_READLINE_H
254
255 /* Define to 1 if you have the `regcomp' function. */
256 #undef HAVE_REGCOMP
257
258 /* Define to 1 if you have the `setupterm' function. */
259 #undef HAVE_SETUPTERM
260
261 /* Define to 1 if you have the `SHA1' function. */
262 #undef HAVE_SHA1
263
264 /* Define to 1 if you have the <signal.h> header file. */
265 #undef HAVE_SIGNAL_H
266
267 /* Do we have sockaddr.sin_len? */
268 #undef HAVE_SOCKADDR_SIN_LEN
269
270 /* Define to 1 if you have the `srandom' function. */
271 #undef HAVE_SRANDOM
272
273 /* Define to 1 if you have the `srandomdev' function. */
274 #undef HAVE_SRANDOMDEV
275
276 /* Define to 1 if stdbool.h conforms to C99. */
277 #undef HAVE_STDBOOL_H
278
279 /* Define to 1 if you have the <stdint.h> header file. */
280 #undef HAVE_STDINT_H
281
282 /* Define to 1 if you have the <stdio.h> header file. */
283 #undef HAVE_STDIO_H
284
285 /* Define to 1 if you have the <stdlib.h> header file. */
286 #undef HAVE_STDLIB_H
287
288 /* Define to 1 if you have the `strcasecmp' function. */
289 #undef HAVE_STRCASECMP
290
291 /* Define to 1 if you have the `strchr' function. */
292 #undef HAVE_STRCHR
293
294 /* Define to 1 if you have the `strdup' function. */
295 #undef HAVE_STRDUP
296
297 /* Define to 1 if you have the `strerror' function. */
298 #undef HAVE_STRERROR
299
300 /* Define to 1 if you have the <strings.h> header file. */
301 #undef HAVE_STRINGS_H
302
303 /* Define to 1 if you have the <string.h> header file. */
304 #undef HAVE_STRING_H
305
306 /* Define to 1 if you have the `strlcat' function. */
307 #undef HAVE_STRLCAT
308
309 /* Define to 1 if you have the `strlcpy' function. */
310 #undef HAVE_STRLCPY
311
312 /* Define to 1 if you have the `strrchr' function. */
313 #undef HAVE_STRRCHR
314
315 /* Define to 1 if `st_blocks' is member of `struct stat'. */
316 #undef HAVE_STRUCT_STAT_ST_BLOCKS
317
318 /* Define to 1 if `st_rdev' is member of `struct stat'. */
319 #undef HAVE_STRUCT_STAT_ST_RDEV
320
321 /* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use
322 `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */
323 #undef HAVE_ST_BLOCKS
324
325 /* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use
326 `HAVE_STRUCT_STAT_ST_RDEV' instead. */
327 #undef HAVE_ST_RDEV
328
329 /* Define to 1 if you have the <sysexits.h> header file. */
330 #undef HAVE_SYSEXITS_H
331
332 /* Define to 1 if you have the <sys/cdefs.h> header file. */
333 #undef HAVE_SYS_CDEFS_H
334
335 /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
336 */
337 #undef HAVE_SYS_DIR_H
338
339 /* Define to 1 if you have the <sys/disk.h> header file. */
340 #undef HAVE_SYS_DISK_H
341
342 /* Define to 1 if you have the <sys/file.h> header file. */
343 #undef HAVE_SYS_FILE_H
344
345 /* Define to 1 if you have the <sys/ioctl.h> header file. */
346 #undef HAVE_SYS_IOCTL_H
347
348 /* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
349 */
350 #undef HAVE_SYS_NDIR_H
351
352 /* Define to 1 if you have the <sys/param.h> header file. */
353 #undef HAVE_SYS_PARAM_H
354
355 /* Define to 1 if you have the <sys/signal.h> header file. */
356 #undef HAVE_SYS_SIGNAL_H
357
358 /* Define to 1 if you have the <sys/socket.h> header file. */
359 #undef HAVE_SYS_SOCKET_H
360
361 /* Define to 1 if you have the <sys/stat.h> header file. */
362 #undef HAVE_SYS_STAT_H
363
364 /* Define to 1 if you have the <sys/time.h> header file. */
365 #undef HAVE_SYS_TIME_H
366
367 /* Define to 1 if you have the <sys/types.h> header file. */
368 #undef HAVE_SYS_TYPES_H
369
370 /* Define to 1 if you have the <sys/vfs.h> header file. */
371 #undef HAVE_SYS_VFS_H
372
373 /* Define to 1 if you have the <termcap.h> header file. */
374 #undef HAVE_TERMCAP_H
375
376 /* Define to 1 if you have the <term.h> header file. */
377 #undef HAVE_TERM_H
378
379 /* Define to 1 if you have the `tgetnum' function. */
380 #undef HAVE_TGETNUM
381
382 /* Define to 1 if you have the `tgetstr' function. */
383 #undef HAVE_TGETSTR
384
385 /* Define to 1 if you have the `tgoto' function. */
386 #undef HAVE_TGOTO
387
388 /* Define to 1 if you have the <time.h> header file. */
389 #undef HAVE_TIME_H
390
391 /* Define to 1 if you have the `tputs' function. */
392 #undef HAVE_TPUTS
393
394 /* Define to 1 if you have the <unistd.h> header file. */
395 #undef HAVE_UNISTD_H
396
397 /* Define to 1 if you have the `utimes' function. */
398 #undef HAVE_UTIMES
399
400 /* Define to 1 if you have the `valloc' function. */
401 #undef HAVE_VALLOC
402
403 /* Define to 1 if you have the `warn' function. */
404 #undef HAVE_WARN
405
406 /* Define to 1 if you have the `warnx' function. */
407 #undef HAVE_WARNX
408
409 /* Define to 1 if you have the <zlib.h> header file. */
410 #undef HAVE_ZLIB_H
411
412 /* Define to 1 if the system has the type `_Bool'. */
413 #undef HAVE__BOOL
414
415 /* Defined if we are inside AFFLIB */
416 #undef IN_AFFLIB
417
418 /* Define to the sub-directory in which libtool stores uninstalled libraries.
419 */
420 #undef LT_OBJDIR
421
422 /* Define to 1 if your C compiler doesn't accept -c and -o together. */
423 #undef NO_MINUS_C_MINUS_O
424
425 /* Name of package */
426 #undef PACKAGE
427
428 /* Define to the address where bug reports for this package should be sent. */
429 #undef PACKAGE_BUGREPORT
430
431 /* Define to the full name of this package. */
432 #undef PACKAGE_NAME
433
434 /* Define to the full name and version of this package. */
435 #undef PACKAGE_STRING
436
437 /* Define to the one symbol short name of this package. */
438 #undef PACKAGE_TARNAME
439
440 /* Define to the version of this package. */
441 #undef PACKAGE_VERSION
442
443 /* Define to necessary symbol if this constant uses a non-standard name on
444 your system. */
445 #undef PTHREAD_CREATE_JOINABLE
446
447 /* If using the C implementation of alloca, define if you know the
448 direction of stack growth for your system; otherwise it will be
449 automatically deduced at runtime.
450 STACK_DIRECTION > 0 => grows toward higher addresses
451 STACK_DIRECTION < 0 => grows toward lower addresses
452 STACK_DIRECTION = 0 => direction of growth unknown */
453 #undef STACK_DIRECTION
454
455 /* Define to 1 if you have the ANSI C header files. */
456 #undef STDC_HEADERS
457
458 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
459 #undef TM_IN_SYS_TIME
460
461 /* Use FUSE to mount AFF images */
462 #undef USE_FUSE
463
464 /* Use libewf to read EnCase files */
465 #undef USE_LIBEWF
466
467 /* Use QEMU image drivers */
468 #undef USE_QEMU
469
470 /* Enable support for Amazon S3 */
471 #undef USE_S3
472
473 /* Version number of package */
474 #undef VERSION
475
476 /* Number of bits in a file offset, on hosts where this is settable. */
477 #undef _FILE_OFFSET_BITS
478
479 /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
480 #undef _LARGEFILE_SOURCE
481
482 /* Define for large files, on AIX-style hosts. */
483 #undef _LARGE_FILES
484
485 /* Define to empty if `const' does not conform to ANSI C. */
486 #undef const
487
488 /* Define to `__inline__' or `__inline' if that's what the C compiler
489 calls it, or to nothing if 'inline' is not supported under any name. */
490 #ifndef __cplusplus
491 #undef inline
492 #endif
493
494 /* Define to `int' if <sys/types.h> does not define. */
495 #undef mode_t
496
497 /* Define to `long int' if <sys/types.h> does not define. */
498 #undef off_t
499
500 /* Define to `unsigned int' if <sys/types.h> does not define. */
501 #undef size_t
0 prefix=@prefix@
1 exec_prefix=@exec_prefix@
2 libdir=@libdir@
3 includedir=@includedir@/afflib
4
5 Name: afflib
6 Description: Library to support the Advanced Forensic Format
7 Version: @VERSION@
8 Requires: openssl
9 Libs: -L${libdir} -lafflib -lstdc++
10 Cflags: -I${includedir}
0 -----BEGIN PGP PUBLIC KEY BLOCK-----
1 Version: GnuPG v1.4.7 (Darwin)
2
3 mQGiBEg/lAwRBADbHamoonoDrsmYwKLgtOdle/MpfPTUp0Tk/1Bu+l8f2TlJ1XBZ
4 XaF0+X2uZ+S23T+bOPK1mjNXXGPQHLnMZZjbxvQQB7d6qjwk/rQCm2+uLbYN3jn2
5 goG9CSGatQ57fyE/zb4K0FHKWxGckEZwrc/ixLHXfI2UCp6v+hWn/5vAEwCgueFQ
6 AvHwokrJZrEUe17qaFzfEm8D/iyfD0tg+yJju7+pka+JHybVfvUd64bDvm4tSdAn
7 Qk+SRIFi3jxPOMZsKoxJ/d9RYFZWM2wWhzr616z0CludgwKLQ3FC8pDY0IMcDcRR
8 bVsbeBnRebCO3imN9RHw5G6eZ/cSxzm81+kebAncIXraBXCOZPGJ8nrDw8rdOyhe
9 rE26A/9L4eZK0GLpLTg/ohx/U7IBJ//6gxgAJTM5kfiGZ4hfR4bwZ/ue/ayRyre1
10 xupcNiPJuTvECOfYf7nXtxlrYPVzpkcjvecFy9VJUE/WIvXqts5R4EhC/ZlcuI6D
11 6+njBHlflc1JhTTG+SSCQ2EEK6Fibk96EymEQFYAfE0VVa4LDbQpQUZGTElCIERp
12 c3RyaWJ1dGlvbiAoU2ltc29uIEwuIEdhcmZpbmtlbCmIYAQTEQIAIAUCSD+UDAIb
13 AwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEN1M3GCAWz2wrlUAn1sTy3ZKyUPO
14 qoj5JBtz/ZdCtLPpAKCXkWfSHrddkx6c3Zhwbz3AlgpJ+g==
15 =WJZv
16 -----END PGP PUBLIC KEY BLOCK-----
0 Name: afflib
1 Version: 3.5.10
2 Release: 1
3 Summary: Library to support the Advanced Forensic Format
4 Group: System Environment/Libraries
5 License: BSD with advertising
6 Source: %{name}-%{version}.tar.gz
7 URL: http://www.afflib.org/
8 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
9 BuildRequires: curl-devel expat-devel ncurses-devel openssl-devel zlib-devel
10
11 # The following GPLv2 licenced packages are incompatible with BSD with advertising clause
12 # BuildRequires: fuse-devel readline-devel
13
14 %description
15 afflib is library for support of the Advanced Forensic Format (AFF).
16 AFF(R) is an open and extensible file format designed to store disk images and
17 associated metadata.
18
19 %package devel
20 Summary: Header files and libraries for developing applications for afflib
21 Group: Development/Libraries
22 Requires: afflib = %{version}-%{release}
23
24 %description devel
25 Header files and libraries for developing applications for afflib.
26
27 %package tools
28 Summary: Several tools for reading and writing AFF files
29 Group: Applications/System
30 Requires: openssl afflib = %{version}-%{release}
31 BuildRequires: openssl-devel
32
33 %description tools
34 Several tools for reading and writing AFF files.
35
36 %prep
37 %setup -q
38
39 %build
40 %configure --prefix=/usr --libdir=%{_libdir} --mandir=%{_mandir}
41 make %{?_smp_mflags}
42
43 %install
44 rm -rf ${RPM_BUILD_ROOT}
45 make DESTDIR=${RPM_BUILD_ROOT} install
46
47 %clean
48 rm -rf ${RPM_BUILD_ROOT}
49
50 %post -p /sbin/ldconfig
51
52 %postun -p /sbin/ldconfig
53
54 %files
55 %defattr(644,root,root,755)
56 %doc AUTHORS BUGLIST.txt ChangeLog COPYING NEWS README README_Linux.txt
57 %attr(755,root,root) %{_libdir}/*.so.*
58
59 %files devel
60 %defattr(644,root,root,755)
61 %doc AUTHORS BUGLIST.txt ChangeLog COPYING NEWS README README_Linux.txt
62 %doc doc/crypto_design.txt doc/crypto_doc.txt
63 %{_libdir}/*.a
64 %{_libdir}/*.la
65 %{_libdir}/*.so
66 %{_includedir}/afflib/afflib.h
67 %{_includedir}/afflib/afflib_i.h
68 %{_includedir}/afflib/afflib_sha256.h
69 %{_includedir}/afflib/aftimer.h
70 %{_includedir}/afflib/utils.h
71
72 %files tools
73 %defattr(644,root,root,755)
74 %doc AUTHORS BUGLIST.txt ChangeLog COPYING NEWS README README_Linux.txt
75 %attr(755,root,root) %{_bindir}/*
76
77 %changelog
78 * Sun Dec 9 2007 Joachim Metz <forensics@hoffmannbv.nl> 3.0.4-1
79 - Initial version
80
0 Name: afflib
1 Version: @VERSION@
2 Release: 1
3 Summary: Library to support the Advanced Forensic Format
4 Group: System Environment/Libraries
5 License: BSD with advertising
6 Source: %{name}-%{version}.tar.gz
7 URL: http://www.afflib.org/
8 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
9 BuildRequires: curl-devel expat-devel ncurses-devel openssl-devel zlib-devel
10
11 # The following GPLv2 licenced packages are incompatible with BSD with advertising clause
12 # BuildRequires: fuse-devel readline-devel
13
14 %description
15 afflib is library for support of the Advanced Forensic Format (AFF).
16 AFF(R) is an open and extensible file format designed to store disk images and
17 associated metadata.
18
19 %package devel
20 Summary: Header files and libraries for developing applications for afflib
21 Group: Development/Libraries
22 Requires: afflib = %{version}-%{release}
23
24 %description devel
25 Header files and libraries for developing applications for afflib.
26
27 %package tools
28 Summary: Several tools for reading and writing AFF files
29 Group: Applications/System
30 Requires: openssl afflib = %{version}-%{release}
31 BuildRequires: openssl-devel
32
33 %description tools
34 Several tools for reading and writing AFF files.
35
36 %prep
37 %setup -q
38
39 %build
40 %configure --prefix=/usr --libdir=%{_libdir} --mandir=%{_mandir}
41 make %{?_smp_mflags}
42
43 %install
44 rm -rf ${RPM_BUILD_ROOT}
45 make DESTDIR=${RPM_BUILD_ROOT} install
46
47 %clean
48 rm -rf ${RPM_BUILD_ROOT}
49
50 %post -p /sbin/ldconfig
51
52 %postun -p /sbin/ldconfig
53
54 %files
55 %defattr(644,root,root,755)
56 %doc AUTHORS BUGLIST.txt ChangeLog COPYING NEWS README README_Linux.txt
57 %attr(755,root,root) %{_libdir}/*.so.*
58
59 %files devel
60 %defattr(644,root,root,755)
61 %doc AUTHORS BUGLIST.txt ChangeLog COPYING NEWS README README_Linux.txt
62 %doc doc/crypto_design.txt doc/crypto_doc.txt
63 %{_libdir}/*.a
64 %{_libdir}/*.la
65 %{_libdir}/*.so
66 %{_includedir}/afflib/afflib.h
67 %{_includedir}/afflib/afflib_i.h
68 %{_includedir}/afflib/afflib_sha256.h
69 %{_includedir}/afflib/aftimer.h
70 %{_includedir}/afflib/utils.h
71
72 %files tools
73 %defattr(644,root,root,755)
74 %doc AUTHORS BUGLIST.txt ChangeLog COPYING NEWS README README_Linux.txt
75 %attr(755,root,root) %{_bindir}/*
76
77 %changelog
78 * Sun Dec 9 2007 Joachim Metz <forensics@hoffmannbv.nl> 3.0.4-1
79 - Initial version
80
0 #! /bin/sh
1 # Wrapper for compilers which do not understand `-c -o'.
2
3 scriptversion=2003-11-09.00
4
5 # Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
6 # Written by Tom Tromey <tromey@cygnus.com>.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
26
27 # This file is maintained in Automake, please report
28 # bugs to <bug-automake@gnu.org> or send patches to
29 # <automake-patches@gnu.org>.
30
31 case $1 in
32 '')
33 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
34 exit 1;
35 ;;
36 -h | --h*)
37 cat <<\EOF
38 Usage: compile [--help] [--version] PROGRAM [ARGS]
39
40 Wrapper for compilers which do not understand `-c -o'.
41 Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
42 arguments, and rename the output as expected.
43
44 If you are trying to build a whole package this is not the
45 right script to run: please start by reading the file `INSTALL'.
46
47 Report bugs to <bug-automake@gnu.org>.
48 EOF
49 exit 0
50 ;;
51 -v | --v*)
52 echo "compile $scriptversion"
53 exit 0
54 ;;
55 esac
56
57
58 prog=$1
59 shift
60
61 ofile=
62 cfile=
63 args=
64 while test $# -gt 0; do
65 case "$1" in
66 -o)
67 # configure might choose to run compile as `compile cc -o foo foo.c'.
68 # So we do something ugly here.
69 ofile=$2
70 shift
71 case "$ofile" in
72 *.o | *.obj)
73 ;;
74 *)
75 args="$args -o $ofile"
76 ofile=
77 ;;
78 esac
79 ;;
80 *.c)
81 cfile=$1
82 args="$args $1"
83 ;;
84 *)
85 args="$args $1"
86 ;;
87 esac
88 shift
89 done
90
91 if test -z "$ofile" || test -z "$cfile"; then
92 # If no `-o' option was seen then we might have been invoked from a
93 # pattern rule where we don't need one. That is ok -- this is a
94 # normal compilation that the losing compiler can handle. If no
95 # `.c' file was seen then we are probably linking. That is also
96 # ok.
97 exec "$prog" $args
98 fi
99
100 # Name of file we expect compiler to create.
101 cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
102
103 # Create the lock directory.
104 # Note: use `[/.-]' here to ensure that we don't use the same name
105 # that we are using for the .o file. Also, base the name on the expected
106 # object file name, since that is what matters with a parallel build.
107 lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
108 while true; do
109 if mkdir $lockdir > /dev/null 2>&1; then
110 break
111 fi
112 sleep 1
113 done
114 # FIXME: race condition here if user kills between mkdir and trap.
115 trap "rmdir $lockdir; exit 1" 1 2 15
116
117 # Run the compile.
118 "$prog" $args
119 status=$?
120
121 if test -f "$cofile"; then
122 mv "$cofile" "$ofile"
123 fi
124
125 rmdir $lockdir
126 exit $status
127
128 # Local Variables:
129 # mode: shell-script
130 # sh-indentation: 2
131 # eval: (add-hook 'write-file-hooks 'time-stamp)
132 # time-stamp-start: "scriptversion="
133 # time-stamp-format: "%:y-%02m-%02d.%02H"
134 # time-stamp-end: "$"
135 # End:
0 #! /bin/sh
1 # Attempt to guess a canonical system name.
2 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
4 # Inc.
5
6 timestamp='2006-07-02'
7
8 # This file is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
21 # 02110-1301, USA.
22 #
23 # As a special exception to the GNU General Public License, if you
24 # distribute this file as part of a program that contains a
25 # configuration script generated by Autoconf, you may include it under
26 # the same distribution terms that you use for the rest of that program.
27
28
29 # Originally written by Per Bothner <per@bothner.com>.
30 # Please send patches to <config-patches@gnu.org>. Submit a context
31 # diff and a properly formatted ChangeLog entry.
32 #
33 # This script attempts to guess a canonical system name similar to
34 # config.sub. If it succeeds, it prints the system name on stdout, and
35 # exits with 0. Otherwise, it exits with 1.
36 #
37 # The plan is that this can be called by configure scripts if you
38 # don't specify an explicit build system type.
39
40 me=`echo "$0" | sed -e 's,.*/,,'`
41
42 usage="\
43 Usage: $0 [OPTION]
44
45 Output the configuration name of the system \`$me' is run on.
46
47 Operation modes:
48 -h, --help print this help, then exit
49 -t, --time-stamp print date of last modification, then exit
50 -v, --version print version number, then exit
51
52 Report bugs and patches to <config-patches@gnu.org>."
53
54 version="\
55 GNU config.guess ($timestamp)
56
57 Originally written by Per Bothner.
58 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
59 Free Software Foundation, Inc.
60
61 This is free software; see the source for copying conditions. There is NO
62 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
63
64 help="
65 Try \`$me --help' for more information."
66
67 # Parse command line
68 while test $# -gt 0 ; do
69 case $1 in
70 --time-stamp | --time* | -t )
71 echo "$timestamp" ; exit ;;
72 --version | -v )
73 echo "$version" ; exit ;;
74 --help | --h* | -h )
75 echo "$usage"; exit ;;
76 -- ) # Stop option processing
77 shift; break ;;
78 - ) # Use stdin as input.
79 break ;;
80 -* )
81 echo "$me: invalid option $1$help" >&2
82 exit 1 ;;
83 * )
84 break ;;
85 esac
86 done
87
88 if test $# != 0; then
89 echo "$me: too many arguments$help" >&2
90 exit 1
91 fi
92
93 trap 'exit 1' 1 2 15
94
95 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
96 # compiler to aid in system detection is discouraged as it requires
97 # temporary files to be created and, as you can see below, it is a
98 # headache to deal with in a portable fashion.
99
100 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
101 # use `HOST_CC' if defined, but it is deprecated.
102
103 # Portable tmp directory creation inspired by the Autoconf team.
104
105 set_cc_for_build='
106 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
107 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
108 : ${TMPDIR=/tmp} ;
109 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
110 { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
111 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
112 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
113 dummy=$tmp/dummy ;
114 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
115 case $CC_FOR_BUILD,$HOST_CC,$CC in
116 ,,) echo "int x;" > $dummy.c ;
117 for c in cc gcc c89 c99 ; do
118 if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
119 CC_FOR_BUILD="$c"; break ;
120 fi ;
121 done ;
122 if test x"$CC_FOR_BUILD" = x ; then
123 CC_FOR_BUILD=no_compiler_found ;
124 fi
125 ;;
126 ,,*) CC_FOR_BUILD=$CC ;;
127 ,*,*) CC_FOR_BUILD=$HOST_CC ;;
128 esac ; set_cc_for_build= ;'
129
130 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
131 # (ghazi@noc.rutgers.edu 1994-08-24)
132 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
133 PATH=$PATH:/.attbin ; export PATH
134 fi
135
136 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
137 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
138 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
139 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
140
141 # Note: order is significant - the case branches are not exclusive.
142
143 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
144 *:NetBSD:*:*)
145 # NetBSD (nbsd) targets should (where applicable) match one or
146 # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
147 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
148 # switched to ELF, *-*-netbsd* would select the old
149 # object file format. This provides both forward
150 # compatibility and a consistent mechanism for selecting the
151 # object file format.
152 #
153 # Note: NetBSD doesn't particularly care about the vendor
154 # portion of the name. We always set it to "unknown".
155 sysctl="sysctl -n hw.machine_arch"
156 UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
157 /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
158 case "${UNAME_MACHINE_ARCH}" in
159 armeb) machine=armeb-unknown ;;
160 arm*) machine=arm-unknown ;;
161 sh3el) machine=shl-unknown ;;
162 sh3eb) machine=sh-unknown ;;
163 *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
164 esac
165 # The Operating System including object format, if it has switched
166 # to ELF recently, or will in the future.
167 case "${UNAME_MACHINE_ARCH}" in
168 arm*|i386|m68k|ns32k|sh3*|sparc|vax)
169 eval $set_cc_for_build
170 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
171 | grep __ELF__ >/dev/null
172 then
173 # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
174 # Return netbsd for either. FIX?
175 os=netbsd
176 else
177 os=netbsdelf
178 fi
179 ;;
180 *)
181 os=netbsd
182 ;;
183 esac
184 # The OS release
185 # Debian GNU/NetBSD machines have a different userland, and
186 # thus, need a distinct triplet. However, they do not need
187 # kernel version information, so it can be replaced with a
188 # suitable tag, in the style of linux-gnu.
189 case "${UNAME_VERSION}" in
190 Debian*)
191 release='-gnu'
192 ;;
193 *)
194 release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
195 ;;
196 esac
197 # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
198 # contains redundant information, the shorter form:
199 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
200 echo "${machine}-${os}${release}"
201 exit ;;
202 *:OpenBSD:*:*)
203 UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
204 echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
205 exit ;;
206 *:ekkoBSD:*:*)
207 echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
208 exit ;;
209 *:SolidBSD:*:*)
210 echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
211 exit ;;
212 macppc:MirBSD:*:*)
213 echo powerpc-unknown-mirbsd${UNAME_RELEASE}
214 exit ;;
215 *:MirBSD:*:*)
216 echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
217 exit ;;
218 alpha:OSF1:*:*)
219 case $UNAME_RELEASE in
220 *4.0)
221 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
222 ;;
223 *5.*)
224 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
225 ;;
226 esac
227 # According to Compaq, /usr/sbin/psrinfo has been available on
228 # OSF/1 and Tru64 systems produced since 1995. I hope that
229 # covers most systems running today. This code pipes the CPU
230 # types through head -n 1, so we only detect the type of CPU 0.
231 ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
232 case "$ALPHA_CPU_TYPE" in
233 "EV4 (21064)")
234 UNAME_MACHINE="alpha" ;;
235 "EV4.5 (21064)")
236 UNAME_MACHINE="alpha" ;;
237 "LCA4 (21066/21068)")
238 UNAME_MACHINE="alpha" ;;
239 "EV5 (21164)")
240 UNAME_MACHINE="alphaev5" ;;
241 "EV5.6 (21164A)")
242 UNAME_MACHINE="alphaev56" ;;
243 "EV5.6 (21164PC)")
244 UNAME_MACHINE="alphapca56" ;;
245 "EV5.7 (21164PC)")
246 UNAME_MACHINE="alphapca57" ;;
247 "EV6 (21264)")
248 UNAME_MACHINE="alphaev6" ;;
249 "EV6.7 (21264A)")
250 UNAME_MACHINE="alphaev67" ;;
251 "EV6.8CB (21264C)")
252 UNAME_MACHINE="alphaev68" ;;
253 "EV6.8AL (21264B)")
254 UNAME_MACHINE="alphaev68" ;;
255 "EV6.8CX (21264D)")
256 UNAME_MACHINE="alphaev68" ;;
257 "EV6.9A (21264/EV69A)")
258 UNAME_MACHINE="alphaev69" ;;
259 "EV7 (21364)")
260 UNAME_MACHINE="alphaev7" ;;
261 "EV7.9 (21364A)")
262 UNAME_MACHINE="alphaev79" ;;
263 esac
264 # A Pn.n version is a patched version.
265 # A Vn.n version is a released version.
266 # A Tn.n version is a released field test version.
267 # A Xn.n version is an unreleased experimental baselevel.
268 # 1.2 uses "1.2" for uname -r.
269 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
270 exit ;;
271 Alpha\ *:Windows_NT*:*)
272 # How do we know it's Interix rather than the generic POSIX subsystem?
273 # Should we change UNAME_MACHINE based on the output of uname instead
274 # of the specific Alpha model?
275 echo alpha-pc-interix
276 exit ;;
277 21064:Windows_NT:50:3)
278 echo alpha-dec-winnt3.5
279 exit ;;
280 Amiga*:UNIX_System_V:4.0:*)
281 echo m68k-unknown-sysv4
282 exit ;;
283 *:[Aa]miga[Oo][Ss]:*:*)
284 echo ${UNAME_MACHINE}-unknown-amigaos
285 exit ;;
286 *:[Mm]orph[Oo][Ss]:*:*)
287 echo ${UNAME_MACHINE}-unknown-morphos
288 exit ;;
289 *:OS/390:*:*)
290 echo i370-ibm-openedition
291 exit ;;
292 *:z/VM:*:*)
293 echo s390-ibm-zvmoe
294 exit ;;
295 *:OS400:*:*)
296 echo powerpc-ibm-os400
297 exit ;;
298 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
299 echo arm-acorn-riscix${UNAME_RELEASE}
300 exit ;;
301 arm:riscos:*:*|arm:RISCOS:*:*)
302 echo arm-unknown-riscos
303 exit ;;
304 SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
305 echo hppa1.1-hitachi-hiuxmpp
306 exit ;;
307 Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
308 # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
309 if test "`(/bin/universe) 2>/dev/null`" = att ; then
310 echo pyramid-pyramid-sysv3
311 else
312 echo pyramid-pyramid-bsd
313 fi
314 exit ;;
315 NILE*:*:*:dcosx)
316 echo pyramid-pyramid-svr4
317 exit ;;
318 DRS?6000:unix:4.0:6*)
319 echo sparc-icl-nx6
320 exit ;;
321 DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
322 case `/usr/bin/uname -p` in
323 sparc) echo sparc-icl-nx7; exit ;;
324 esac ;;
325 sun4H:SunOS:5.*:*)
326 echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
327 exit ;;
328 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
329 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
330 exit ;;
331 i86pc:SunOS:5.*:*)
332 echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
333 exit ;;
334 sun4*:SunOS:6*:*)
335 # According to config.sub, this is the proper way to canonicalize
336 # SunOS6. Hard to guess exactly what SunOS6 will be like, but
337 # it's likely to be more like Solaris than SunOS4.
338 echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
339 exit ;;
340 sun4*:SunOS:*:*)
341 case "`/usr/bin/arch -k`" in
342 Series*|S4*)
343 UNAME_RELEASE=`uname -v`
344 ;;
345 esac
346 # Japanese Language versions have a version number like `4.1.3-JL'.
347 echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
348 exit ;;
349 sun3*:SunOS:*:*)
350 echo m68k-sun-sunos${UNAME_RELEASE}
351 exit ;;
352 sun*:*:4.2BSD:*)
353 UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
354 test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
355 case "`/bin/arch`" in
356 sun3)
357 echo m68k-sun-sunos${UNAME_RELEASE}
358 ;;
359 sun4)
360 echo sparc-sun-sunos${UNAME_RELEASE}
361 ;;
362 esac
363 exit ;;
364 aushp:SunOS:*:*)
365 echo sparc-auspex-sunos${UNAME_RELEASE}
366 exit ;;
367 # The situation for MiNT is a little confusing. The machine name
368 # can be virtually everything (everything which is not
369 # "atarist" or "atariste" at least should have a processor
370 # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
371 # to the lowercase version "mint" (or "freemint"). Finally
372 # the system name "TOS" denotes a system which is actually not
373 # MiNT. But MiNT is downward compatible to TOS, so this should
374 # be no problem.
375 atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
376 echo m68k-atari-mint${UNAME_RELEASE}
377 exit ;;
378 atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
379 echo m68k-atari-mint${UNAME_RELEASE}
380 exit ;;
381 *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
382 echo m68k-atari-mint${UNAME_RELEASE}
383 exit ;;
384 milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
385 echo m68k-milan-mint${UNAME_RELEASE}
386 exit ;;
387 hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
388 echo m68k-hades-mint${UNAME_RELEASE}
389 exit ;;
390 *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
391 echo m68k-unknown-mint${UNAME_RELEASE}
392 exit ;;
393 m68k:machten:*:*)
394 echo m68k-apple-machten${UNAME_RELEASE}
395 exit ;;
396 powerpc:machten:*:*)
397 echo powerpc-apple-machten${UNAME_RELEASE}
398 exit ;;
399 RISC*:Mach:*:*)
400 echo mips-dec-mach_bsd4.3
401 exit ;;
402 RISC*:ULTRIX:*:*)
403 echo mips-dec-ultrix${UNAME_RELEASE}
404 exit ;;
405 VAX*:ULTRIX*:*:*)
406 echo vax-dec-ultrix${UNAME_RELEASE}
407 exit ;;
408 2020:CLIX:*:* | 2430:CLIX:*:*)
409 echo clipper-intergraph-clix${UNAME_RELEASE}
410 exit ;;
411 mips:*:*:UMIPS | mips:*:*:RISCos)
412 eval $set_cc_for_build
413 sed 's/^ //' << EOF >$dummy.c
414 #ifdef __cplusplus
415 #include <stdio.h> /* for printf() prototype */
416 int main (int argc, char *argv[]) {
417 #else
418 int main (argc, argv) int argc; char *argv[]; {
419 #endif
420 #if defined (host_mips) && defined (MIPSEB)
421 #if defined (SYSTYPE_SYSV)
422 printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
423 #endif
424 #if defined (SYSTYPE_SVR4)
425 printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
426 #endif
427 #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
428 printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
429 #endif
430 #endif
431 exit (-1);
432 }
433 EOF
434 $CC_FOR_BUILD -o $dummy $dummy.c &&
435 dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
436 SYSTEM_NAME=`$dummy $dummyarg` &&
437 { echo "$SYSTEM_NAME"; exit; }
438 echo mips-mips-riscos${UNAME_RELEASE}
439 exit ;;
440 Motorola:PowerMAX_OS:*:*)
441 echo powerpc-motorola-powermax
442 exit ;;
443 Motorola:*:4.3:PL8-*)
444 echo powerpc-harris-powermax
445 exit ;;
446 Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
447 echo powerpc-harris-powermax
448 exit ;;
449 Night_Hawk:Power_UNIX:*:*)
450 echo powerpc-harris-powerunix
451 exit ;;
452 m88k:CX/UX:7*:*)
453 echo m88k-harris-cxux7
454 exit ;;
455 m88k:*:4*:R4*)
456 echo m88k-motorola-sysv4
457 exit ;;
458 m88k:*:3*:R3*)
459 echo m88k-motorola-sysv3
460 exit ;;
461 AViiON:dgux:*:*)
462 # DG/UX returns AViiON for all architectures
463 UNAME_PROCESSOR=`/usr/bin/uname -p`
464 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
465 then
466 if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
467 [ ${TARGET_BINARY_INTERFACE}x = x ]
468 then
469 echo m88k-dg-dgux${UNAME_RELEASE}
470 else
471 echo m88k-dg-dguxbcs${UNAME_RELEASE}
472 fi
473 else
474 echo i586-dg-dgux${UNAME_RELEASE}
475 fi
476 exit ;;
477 M88*:DolphinOS:*:*) # DolphinOS (SVR3)
478 echo m88k-dolphin-sysv3
479 exit ;;
480 M88*:*:R3*:*)
481 # Delta 88k system running SVR3
482 echo m88k-motorola-sysv3
483 exit ;;
484 XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
485 echo m88k-tektronix-sysv3
486 exit ;;
487 Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
488 echo m68k-tektronix-bsd
489 exit ;;
490 *:IRIX*:*:*)
491 echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
492 exit ;;
493 ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
494 echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
495 exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
496 i*86:AIX:*:*)
497 echo i386-ibm-aix
498 exit ;;
499 ia64:AIX:*:*)
500 if [ -x /usr/bin/oslevel ] ; then
501 IBM_REV=`/usr/bin/oslevel`
502 else
503 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
504 fi
505 echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
506 exit ;;
507 *:AIX:2:3)
508 if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
509 eval $set_cc_for_build
510 sed 's/^ //' << EOF >$dummy.c
511 #include <sys/systemcfg.h>
512
513 main()
514 {
515 if (!__power_pc())
516 exit(1);
517 puts("powerpc-ibm-aix3.2.5");
518 exit(0);
519 }
520 EOF
521 if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
522 then
523 echo "$SYSTEM_NAME"
524 else
525 echo rs6000-ibm-aix3.2.5
526 fi
527 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
528 echo rs6000-ibm-aix3.2.4
529 else
530 echo rs6000-ibm-aix3.2
531 fi
532 exit ;;
533 *:AIX:*:[45])
534 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
535 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
536 IBM_ARCH=rs6000
537 else
538 IBM_ARCH=powerpc
539 fi
540 if [ -x /usr/bin/oslevel ] ; then
541 IBM_REV=`/usr/bin/oslevel`
542 else
543 IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
544 fi
545 echo ${IBM_ARCH}-ibm-aix${IBM_REV}
546 exit ;;
547 *:AIX:*:*)
548 echo rs6000-ibm-aix
549 exit ;;
550 ibmrt:4.4BSD:*|romp-ibm:BSD:*)
551 echo romp-ibm-bsd4.4
552 exit ;;
553 ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
554 echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
555 exit ;; # report: romp-ibm BSD 4.3
556 *:BOSX:*:*)
557 echo rs6000-bull-bosx
558 exit ;;
559 DPX/2?00:B.O.S.:*:*)
560 echo m68k-bull-sysv3
561 exit ;;
562 9000/[34]??:4.3bsd:1.*:*)
563 echo m68k-hp-bsd
564 exit ;;
565 hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
566 echo m68k-hp-bsd4.4
567 exit ;;
568 9000/[34678]??:HP-UX:*:*)
569 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
570 case "${UNAME_MACHINE}" in
571 9000/31? ) HP_ARCH=m68000 ;;
572 9000/[34]?? ) HP_ARCH=m68k ;;
573 9000/[678][0-9][0-9])
574 if [ -x /usr/bin/getconf ]; then
575 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
576 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
577 case "${sc_cpu_version}" in
578 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
579 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
580 532) # CPU_PA_RISC2_0
581 case "${sc_kernel_bits}" in
582 32) HP_ARCH="hppa2.0n" ;;
583 64) HP_ARCH="hppa2.0w" ;;
584 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
585 esac ;;
586 esac
587 fi
588 if [ "${HP_ARCH}" = "" ]; then
589 eval $set_cc_for_build
590 sed 's/^ //' << EOF >$dummy.c
591
592 #define _HPUX_SOURCE
593 #include <stdlib.h>
594 #include <unistd.h>
595
596 int main ()
597 {
598 #if defined(_SC_KERNEL_BITS)
599 long bits = sysconf(_SC_KERNEL_BITS);
600 #endif
601 long cpu = sysconf (_SC_CPU_VERSION);
602
603 switch (cpu)
604 {
605 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
606 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
607 case CPU_PA_RISC2_0:
608 #if defined(_SC_KERNEL_BITS)
609 switch (bits)
610 {
611 case 64: puts ("hppa2.0w"); break;
612 case 32: puts ("hppa2.0n"); break;
613 default: puts ("hppa2.0"); break;
614 } break;
615 #else /* !defined(_SC_KERNEL_BITS) */
616 puts ("hppa2.0"); break;
617 #endif
618 default: puts ("hppa1.0"); break;
619 }
620 exit (0);
621 }
622 EOF
623 (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
624 test -z "$HP_ARCH" && HP_ARCH=hppa
625 fi ;;
626 esac
627 if [ ${HP_ARCH} = "hppa2.0w" ]
628 then
629 eval $set_cc_for_build
630
631 # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
632 # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
633 # generating 64-bit code. GNU and HP use different nomenclature:
634 #
635 # $ CC_FOR_BUILD=cc ./config.guess
636 # => hppa2.0w-hp-hpux11.23
637 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
638 # => hppa64-hp-hpux11.23
639
640 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
641 grep __LP64__ >/dev/null
642 then
643 HP_ARCH="hppa2.0w"
644 else
645 HP_ARCH="hppa64"
646 fi
647 fi
648 echo ${HP_ARCH}-hp-hpux${HPUX_REV}
649 exit ;;
650 ia64:HP-UX:*:*)
651 HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
652 echo ia64-hp-hpux${HPUX_REV}
653 exit ;;
654 3050*:HI-UX:*:*)
655 eval $set_cc_for_build
656 sed 's/^ //' << EOF >$dummy.c
657 #include <unistd.h>
658 int
659 main ()
660 {
661 long cpu = sysconf (_SC_CPU_VERSION);
662 /* The order matters, because CPU_IS_HP_MC68K erroneously returns
663 true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
664 results, however. */
665 if (CPU_IS_PA_RISC (cpu))
666 {
667 switch (cpu)
668 {
669 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
670 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
671 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
672 default: puts ("hppa-hitachi-hiuxwe2"); break;
673 }
674 }
675 else if (CPU_IS_HP_MC68K (cpu))
676 puts ("m68k-hitachi-hiuxwe2");
677 else puts ("unknown-hitachi-hiuxwe2");
678 exit (0);
679 }
680 EOF
681 $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
682 { echo "$SYSTEM_NAME"; exit; }
683 echo unknown-hitachi-hiuxwe2
684 exit ;;
685 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
686 echo hppa1.1-hp-bsd
687 exit ;;
688 9000/8??:4.3bsd:*:*)
689 echo hppa1.0-hp-bsd
690 exit ;;
691 *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
692 echo hppa1.0-hp-mpeix
693 exit ;;
694 hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
695 echo hppa1.1-hp-osf
696 exit ;;
697 hp8??:OSF1:*:*)
698 echo hppa1.0-hp-osf
699 exit ;;
700 i*86:OSF1:*:*)
701 if [ -x /usr/sbin/sysversion ] ; then
702 echo ${UNAME_MACHINE}-unknown-osf1mk
703 else
704 echo ${UNAME_MACHINE}-unknown-osf1
705 fi
706 exit ;;
707 parisc*:Lites*:*:*)
708 echo hppa1.1-hp-lites
709 exit ;;
710 C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
711 echo c1-convex-bsd
712 exit ;;
713 C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
714 if getsysinfo -f scalar_acc
715 then echo c32-convex-bsd
716 else echo c2-convex-bsd
717 fi
718 exit ;;
719 C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
720 echo c34-convex-bsd
721 exit ;;
722 C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
723 echo c38-convex-bsd
724 exit ;;
725 C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
726 echo c4-convex-bsd
727 exit ;;
728 CRAY*Y-MP:*:*:*)
729 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
730 exit ;;
731 CRAY*[A-Z]90:*:*:*)
732 echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
733 | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
734 -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
735 -e 's/\.[^.]*$/.X/'
736 exit ;;
737 CRAY*TS:*:*:*)
738 echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
739 exit ;;
740 CRAY*T3E:*:*:*)
741 echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
742 exit ;;
743 CRAY*SV1:*:*:*)
744 echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
745 exit ;;
746 *:UNICOS/mp:*:*)
747 echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
748 exit ;;
749 F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
750 FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
751 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
752 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
753 echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
754 exit ;;
755 5000:UNIX_System_V:4.*:*)
756 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
757 FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
758 echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
759 exit ;;
760 i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
761 echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
762 exit ;;
763 sparc*:BSD/OS:*:*)
764 echo sparc-unknown-bsdi${UNAME_RELEASE}
765 exit ;;
766 *:BSD/OS:*:*)
767 echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
768 exit ;;
769 *:FreeBSD:*:*)
770 case ${UNAME_MACHINE} in
771 pc98)
772 echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
773 amd64)
774 echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
775 *)
776 echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
777 esac
778 exit ;;
779 i*:CYGWIN*:*)
780 echo ${UNAME_MACHINE}-pc-cygwin
781 exit ;;
782 i*:MINGW*:*)
783 echo ${UNAME_MACHINE}-pc-mingw32
784 exit ;;
785 i*:windows32*:*)
786 # uname -m includes "-pc" on this system.
787 echo ${UNAME_MACHINE}-mingw32
788 exit ;;
789 i*:PW*:*)
790 echo ${UNAME_MACHINE}-pc-pw32
791 exit ;;
792 x86:Interix*:[3456]*)
793 echo i586-pc-interix${UNAME_RELEASE}
794 exit ;;
795 EM64T:Interix*:[3456]*)
796 echo x86_64-unknown-interix${UNAME_RELEASE}
797 exit ;;
798 [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
799 echo i${UNAME_MACHINE}-pc-mks
800 exit ;;
801 i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
802 # How do we know it's Interix rather than the generic POSIX subsystem?
803 # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
804 # UNAME_MACHINE based on the output of uname instead of i386?
805 echo i586-pc-interix
806 exit ;;
807 i*:UWIN*:*)
808 echo ${UNAME_MACHINE}-pc-uwin
809 exit ;;
810 amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
811 echo x86_64-unknown-cygwin
812 exit ;;
813 p*:CYGWIN*:*)
814 echo powerpcle-unknown-cygwin
815 exit ;;
816 prep*:SunOS:5.*:*)
817 echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
818 exit ;;
819 *:GNU:*:*)
820 # the GNU system
821 echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
822 exit ;;
823 *:GNU/*:*:*)
824 # other systems with GNU libc and userland
825 echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
826 exit ;;
827 i*86:Minix:*:*)
828 echo ${UNAME_MACHINE}-pc-minix
829 exit ;;
830 arm*:Linux:*:*)
831 echo ${UNAME_MACHINE}-unknown-linux-gnu
832 exit ;;
833 avr32*:Linux:*:*)
834 echo ${UNAME_MACHINE}-unknown-linux-gnu
835 exit ;;
836 cris:Linux:*:*)
837 echo cris-axis-linux-gnu
838 exit ;;
839 crisv32:Linux:*:*)
840 echo crisv32-axis-linux-gnu
841 exit ;;
842 frv:Linux:*:*)
843 echo frv-unknown-linux-gnu
844 exit ;;
845 ia64:Linux:*:*)
846 echo ${UNAME_MACHINE}-unknown-linux-gnu
847 exit ;;
848 m32r*:Linux:*:*)
849 echo ${UNAME_MACHINE}-unknown-linux-gnu
850 exit ;;
851 m68*:Linux:*:*)
852 echo ${UNAME_MACHINE}-unknown-linux-gnu
853 exit ;;
854 mips:Linux:*:*)
855 eval $set_cc_for_build
856 sed 's/^ //' << EOF >$dummy.c
857 #undef CPU
858 #undef mips
859 #undef mipsel
860 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
861 CPU=mipsel
862 #else
863 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
864 CPU=mips
865 #else
866 CPU=
867 #endif
868 #endif
869 EOF
870 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
871 /^CPU/{
872 s: ::g
873 p
874 }'`"
875 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
876 ;;
877 mips64:Linux:*:*)
878 eval $set_cc_for_build
879 sed 's/^ //' << EOF >$dummy.c
880 #undef CPU
881 #undef mips64
882 #undef mips64el
883 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
884 CPU=mips64el
885 #else
886 #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
887 CPU=mips64
888 #else
889 CPU=
890 #endif
891 #endif
892 EOF
893 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
894 /^CPU/{
895 s: ::g
896 p
897 }'`"
898 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
899 ;;
900 or32:Linux:*:*)
901 echo or32-unknown-linux-gnu
902 exit ;;
903 ppc:Linux:*:*)
904 echo powerpc-unknown-linux-gnu
905 exit ;;
906 ppc64:Linux:*:*)
907 echo powerpc64-unknown-linux-gnu
908 exit ;;
909 alpha:Linux:*:*)
910 case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
911 EV5) UNAME_MACHINE=alphaev5 ;;
912 EV56) UNAME_MACHINE=alphaev56 ;;
913 PCA56) UNAME_MACHINE=alphapca56 ;;
914 PCA57) UNAME_MACHINE=alphapca56 ;;
915 EV6) UNAME_MACHINE=alphaev6 ;;
916 EV67) UNAME_MACHINE=alphaev67 ;;
917 EV68*) UNAME_MACHINE=alphaev68 ;;
918 esac
919 objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
920 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
921 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
922 exit ;;
923 parisc:Linux:*:* | hppa:Linux:*:*)
924 # Look for CPU level
925 case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
926 PA7*) echo hppa1.1-unknown-linux-gnu ;;
927 PA8*) echo hppa2.0-unknown-linux-gnu ;;
928 *) echo hppa-unknown-linux-gnu ;;
929 esac
930 exit ;;
931 parisc64:Linux:*:* | hppa64:Linux:*:*)
932 echo hppa64-unknown-linux-gnu
933 exit ;;
934 s390:Linux:*:* | s390x:Linux:*:*)
935 echo ${UNAME_MACHINE}-ibm-linux
936 exit ;;
937 sh64*:Linux:*:*)
938 echo ${UNAME_MACHINE}-unknown-linux-gnu
939 exit ;;
940 sh*:Linux:*:*)
941 echo ${UNAME_MACHINE}-unknown-linux-gnu
942 exit ;;
943 sparc:Linux:*:* | sparc64:Linux:*:*)
944 echo ${UNAME_MACHINE}-unknown-linux-gnu
945 exit ;;
946 vax:Linux:*:*)
947 echo ${UNAME_MACHINE}-dec-linux-gnu
948 exit ;;
949 x86_64:Linux:*:*)
950 echo x86_64-unknown-linux-gnu
951 exit ;;
952 i*86:Linux:*:*)
953 # The BFD linker knows what the default object file format is, so
954 # first see if it will tell us. cd to the root directory to prevent
955 # problems with other programs or directories called `ld' in the path.
956 # Set LC_ALL=C to ensure ld outputs messages in English.
957 ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
958 | sed -ne '/supported targets:/!d
959 s/[ ][ ]*/ /g
960 s/.*supported targets: *//
961 s/ .*//
962 p'`
963 case "$ld_supported_targets" in
964 elf32-i386)
965 TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
966 ;;
967 a.out-i386-linux)
968 echo "${UNAME_MACHINE}-pc-linux-gnuaout"
969 exit ;;
970 coff-i386)
971 echo "${UNAME_MACHINE}-pc-linux-gnucoff"
972 exit ;;
973 "")
974 # Either a pre-BFD a.out linker (linux-gnuoldld) or
975 # one that does not give us useful --help.
976 echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
977 exit ;;
978 esac
979 # Determine whether the default compiler is a.out or elf
980 eval $set_cc_for_build
981 sed 's/^ //' << EOF >$dummy.c
982 #include <features.h>
983 #ifdef __ELF__
984 # ifdef __GLIBC__
985 # if __GLIBC__ >= 2
986 LIBC=gnu
987 # else
988 LIBC=gnulibc1
989 # endif
990 # else
991 LIBC=gnulibc1
992 # endif
993 #else
994 #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
995 LIBC=gnu
996 #else
997 LIBC=gnuaout
998 #endif
999 #endif
1000 #ifdef __dietlibc__
1001 LIBC=dietlibc
1002 #endif
1003 EOF
1004 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
1005 /^LIBC/{
1006 s: ::g
1007 p
1008 }'`"
1009 test x"${LIBC}" != x && {
1010 echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
1011 exit
1012 }
1013 test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
1014 ;;
1015 i*86:DYNIX/ptx:4*:*)
1016 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1017 # earlier versions are messed up and put the nodename in both
1018 # sysname and nodename.
1019 echo i386-sequent-sysv4
1020 exit ;;
1021 i*86:UNIX_SV:4.2MP:2.*)
1022 # Unixware is an offshoot of SVR4, but it has its own version
1023 # number series starting with 2...
1024 # I am not positive that other SVR4 systems won't match this,
1025 # I just have to hope. -- rms.
1026 # Use sysv4.2uw... so that sysv4* matches it.
1027 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
1028 exit ;;
1029 i*86:OS/2:*:*)
1030 # If we were able to find `uname', then EMX Unix compatibility
1031 # is probably installed.
1032 echo ${UNAME_MACHINE}-pc-os2-emx
1033 exit ;;
1034 i*86:XTS-300:*:STOP)
1035 echo ${UNAME_MACHINE}-unknown-stop
1036 exit ;;
1037 i*86:atheos:*:*)
1038 echo ${UNAME_MACHINE}-unknown-atheos
1039 exit ;;
1040 i*86:syllable:*:*)
1041 echo ${UNAME_MACHINE}-pc-syllable
1042 exit ;;
1043 i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
1044 echo i386-unknown-lynxos${UNAME_RELEASE}
1045 exit ;;
1046 i*86:*DOS:*:*)
1047 echo ${UNAME_MACHINE}-pc-msdosdjgpp
1048 exit ;;
1049 i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
1050 UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
1051 if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1052 echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
1053 else
1054 echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
1055 fi
1056 exit ;;
1057 i*86:*:5:[678]*)
1058 # UnixWare 7.x, OpenUNIX and OpenServer 6.
1059 case `/bin/uname -X | grep "^Machine"` in
1060 *486*) UNAME_MACHINE=i486 ;;
1061 *Pentium) UNAME_MACHINE=i586 ;;
1062 *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1063 esac
1064 echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1065 exit ;;
1066 i*86:*:3.2:*)
1067 if test -f /usr/options/cb.name; then
1068 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1069 echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
1070 elif /bin/uname -X 2>/dev/null >/dev/null ; then
1071 UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1072 (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1073 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1074 && UNAME_MACHINE=i586
1075 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1076 && UNAME_MACHINE=i686
1077 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1078 && UNAME_MACHINE=i686
1079 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
1080 else
1081 echo ${UNAME_MACHINE}-pc-sysv32
1082 fi
1083 exit ;;
1084 pc:*:*:*)
1085 # Left here for compatibility:
1086 # uname -m prints for DJGPP always 'pc', but it prints nothing about
1087 # the processor, so we play safe by assuming i386.
1088 echo i386-pc-msdosdjgpp
1089 exit ;;
1090 Intel:Mach:3*:*)
1091 echo i386-pc-mach3
1092 exit ;;
1093 paragon:*:*:*)
1094 echo i860-intel-osf1
1095 exit ;;
1096 i860:*:4.*:*) # i860-SVR4
1097 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1098 echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
1099 else # Add other i860-SVR4 vendors below as they are discovered.
1100 echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
1101 fi
1102 exit ;;
1103 mini*:CTIX:SYS*5:*)
1104 # "miniframe"
1105 echo m68010-convergent-sysv
1106 exit ;;
1107 mc68k:UNIX:SYSTEM5:3.51m)
1108 echo m68k-convergent-sysv
1109 exit ;;
1110 M680?0:D-NIX:5.3:*)
1111 echo m68k-diab-dnix
1112 exit ;;
1113 M68*:*:R3V[5678]*:*)
1114 test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1115 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
1116 OS_REL=''
1117 test -r /etc/.relid \
1118 && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1119 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1120 && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
1121 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1122 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
1123 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1124 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1125 && { echo i486-ncr-sysv4; exit; } ;;
1126 m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1127 echo m68k-unknown-lynxos${UNAME_RELEASE}
1128 exit ;;
1129 mc68030:UNIX_System_V:4.*:*)
1130 echo m68k-atari-sysv4
1131 exit ;;
1132 TSUNAMI:LynxOS:2.*:*)
1133 echo sparc-unknown-lynxos${UNAME_RELEASE}
1134 exit ;;
1135 rs6000:LynxOS:2.*:*)
1136 echo rs6000-unknown-lynxos${UNAME_RELEASE}
1137 exit ;;
1138 PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
1139 echo powerpc-unknown-lynxos${UNAME_RELEASE}
1140 exit ;;
1141 SM[BE]S:UNIX_SV:*:*)
1142 echo mips-dde-sysv${UNAME_RELEASE}
1143 exit ;;
1144 RM*:ReliantUNIX-*:*:*)
1145 echo mips-sni-sysv4
1146 exit ;;
1147 RM*:SINIX-*:*:*)
1148 echo mips-sni-sysv4
1149 exit ;;
1150 *:SINIX-*:*:*)
1151 if uname -p 2>/dev/null >/dev/null ; then
1152 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1153 echo ${UNAME_MACHINE}-sni-sysv4
1154 else
1155 echo ns32k-sni-sysv
1156 fi
1157 exit ;;
1158 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1159 # says <Richard.M.Bartel@ccMail.Census.GOV>
1160 echo i586-unisys-sysv4
1161 exit ;;
1162 *:UNIX_System_V:4*:FTX*)
1163 # From Gerald Hewes <hewes@openmarket.com>.
1164 # How about differentiating between stratus architectures? -djm
1165 echo hppa1.1-stratus-sysv4
1166 exit ;;
1167 *:*:*:FTX*)
1168 # From seanf@swdc.stratus.com.
1169 echo i860-stratus-sysv4
1170 exit ;;
1171 i*86:VOS:*:*)
1172 # From Paul.Green@stratus.com.
1173 echo ${UNAME_MACHINE}-stratus-vos
1174 exit ;;
1175 *:VOS:*:*)
1176 # From Paul.Green@stratus.com.
1177 echo hppa1.1-stratus-vos
1178 exit ;;
1179 mc68*:A/UX:*:*)
1180 echo m68k-apple-aux${UNAME_RELEASE}
1181 exit ;;
1182 news*:NEWS-OS:6*:*)
1183 echo mips-sony-newsos6
1184 exit ;;
1185 R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1186 if [ -d /usr/nec ]; then
1187 echo mips-nec-sysv${UNAME_RELEASE}
1188 else
1189 echo mips-unknown-sysv${UNAME_RELEASE}
1190 fi
1191 exit ;;
1192 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
1193 echo powerpc-be-beos
1194 exit ;;
1195 BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
1196 echo powerpc-apple-beos
1197 exit ;;
1198 BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
1199 echo i586-pc-beos
1200 exit ;;
1201 SX-4:SUPER-UX:*:*)
1202 echo sx4-nec-superux${UNAME_RELEASE}
1203 exit ;;
1204 SX-5:SUPER-UX:*:*)
1205 echo sx5-nec-superux${UNAME_RELEASE}
1206 exit ;;
1207 SX-6:SUPER-UX:*:*)
1208 echo sx6-nec-superux${UNAME_RELEASE}
1209 exit ;;
1210 Power*:Rhapsody:*:*)
1211 echo powerpc-apple-rhapsody${UNAME_RELEASE}
1212 exit ;;
1213 *:Rhapsody:*:*)
1214 echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
1215 exit ;;
1216 *:Darwin:*:*)
1217 UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
1218 case $UNAME_PROCESSOR in
1219 unknown) UNAME_PROCESSOR=powerpc ;;
1220 esac
1221 echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
1222 exit ;;
1223 *:procnto*:*:* | *:QNX:[0123456789]*:*)
1224 UNAME_PROCESSOR=`uname -p`
1225 if test "$UNAME_PROCESSOR" = "x86"; then
1226 UNAME_PROCESSOR=i386
1227 UNAME_MACHINE=pc
1228 fi
1229 echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
1230 exit ;;
1231 *:QNX:*:4*)
1232 echo i386-pc-qnx
1233 exit ;;
1234 NSE-?:NONSTOP_KERNEL:*:*)
1235 echo nse-tandem-nsk${UNAME_RELEASE}
1236 exit ;;
1237 NSR-?:NONSTOP_KERNEL:*:*)
1238 echo nsr-tandem-nsk${UNAME_RELEASE}
1239 exit ;;
1240 *:NonStop-UX:*:*)
1241 echo mips-compaq-nonstopux
1242 exit ;;
1243 BS2000:POSIX*:*:*)
1244 echo bs2000-siemens-sysv
1245 exit ;;
1246 DS/*:UNIX_System_V:*:*)
1247 echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
1248 exit ;;
1249 *:Plan9:*:*)
1250 # "uname -m" is not consistent, so use $cputype instead. 386
1251 # is converted to i386 for consistency with other x86
1252 # operating systems.
1253 if test "$cputype" = "386"; then
1254 UNAME_MACHINE=i386
1255 else
1256 UNAME_MACHINE="$cputype"
1257 fi
1258 echo ${UNAME_MACHINE}-unknown-plan9
1259 exit ;;
1260 *:TOPS-10:*:*)
1261 echo pdp10-unknown-tops10
1262 exit ;;
1263 *:TENEX:*:*)
1264 echo pdp10-unknown-tenex
1265 exit ;;
1266 KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1267 echo pdp10-dec-tops20
1268 exit ;;
1269 XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1270 echo pdp10-xkl-tops20
1271 exit ;;
1272 *:TOPS-20:*:*)
1273 echo pdp10-unknown-tops20
1274 exit ;;
1275 *:ITS:*:*)
1276 echo pdp10-unknown-its
1277 exit ;;
1278 SEI:*:*:SEIUX)
1279 echo mips-sei-seiux${UNAME_RELEASE}
1280 exit ;;
1281 *:DragonFly:*:*)
1282 echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
1283 exit ;;
1284 *:*VMS:*:*)
1285 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1286 case "${UNAME_MACHINE}" in
1287 A*) echo alpha-dec-vms ; exit ;;
1288 I*) echo ia64-dec-vms ; exit ;;
1289 V*) echo vax-dec-vms ; exit ;;
1290 esac ;;
1291 *:XENIX:*:SysV)
1292 echo i386-pc-xenix
1293 exit ;;
1294 i*86:skyos:*:*)
1295 echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
1296 exit ;;
1297 i*86:rdos:*:*)
1298 echo ${UNAME_MACHINE}-pc-rdos
1299 exit ;;
1300 esac
1301
1302 #echo '(No uname command or uname output not recognized.)' 1>&2
1303 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
1304
1305 eval $set_cc_for_build
1306 cat >$dummy.c <<EOF
1307 #ifdef _SEQUENT_
1308 # include <sys/types.h>
1309 # include <sys/utsname.h>
1310 #endif
1311 main ()
1312 {
1313 #if defined (sony)
1314 #if defined (MIPSEB)
1315 /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
1316 I don't know.... */
1317 printf ("mips-sony-bsd\n"); exit (0);
1318 #else
1319 #include <sys/param.h>
1320 printf ("m68k-sony-newsos%s\n",
1321 #ifdef NEWSOS4
1322 "4"
1323 #else
1324 ""
1325 #endif
1326 ); exit (0);
1327 #endif
1328 #endif
1329
1330 #if defined (__arm) && defined (__acorn) && defined (__unix)
1331 printf ("arm-acorn-riscix\n"); exit (0);
1332 #endif
1333
1334 #if defined (hp300) && !defined (hpux)
1335 printf ("m68k-hp-bsd\n"); exit (0);
1336 #endif
1337
1338 #if defined (NeXT)
1339 #if !defined (__ARCHITECTURE__)
1340 #define __ARCHITECTURE__ "m68k"
1341 #endif
1342 int version;
1343 version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1344 if (version < 4)
1345 printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1346 else
1347 printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1348 exit (0);
1349 #endif
1350
1351 #if defined (MULTIMAX) || defined (n16)
1352 #if defined (UMAXV)
1353 printf ("ns32k-encore-sysv\n"); exit (0);
1354 #else
1355 #if defined (CMU)
1356 printf ("ns32k-encore-mach\n"); exit (0);
1357 #else
1358 printf ("ns32k-encore-bsd\n"); exit (0);
1359 #endif
1360 #endif
1361 #endif
1362
1363 #if defined (__386BSD__)
1364 printf ("i386-pc-bsd\n"); exit (0);
1365 #endif
1366
1367 #if defined (sequent)
1368 #if defined (i386)
1369 printf ("i386-sequent-dynix\n"); exit (0);
1370 #endif
1371 #if defined (ns32000)
1372 printf ("ns32k-sequent-dynix\n"); exit (0);
1373 #endif
1374 #endif
1375
1376 #if defined (_SEQUENT_)
1377 struct utsname un;
1378
1379 uname(&un);
1380
1381 if (strncmp(un.version, "V2", 2) == 0) {
1382 printf ("i386-sequent-ptx2\n"); exit (0);
1383 }
1384 if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1385 printf ("i386-sequent-ptx1\n"); exit (0);
1386 }
1387 printf ("i386-sequent-ptx\n"); exit (0);
1388
1389 #endif
1390
1391 #if defined (vax)
1392 # if !defined (ultrix)
1393 # include <sys/param.h>
1394 # if defined (BSD)
1395 # if BSD == 43
1396 printf ("vax-dec-bsd4.3\n"); exit (0);
1397 # else
1398 # if BSD == 199006
1399 printf ("vax-dec-bsd4.3reno\n"); exit (0);
1400 # else
1401 printf ("vax-dec-bsd\n"); exit (0);
1402 # endif
1403 # endif
1404 # else
1405 printf ("vax-dec-bsd\n"); exit (0);
1406 # endif
1407 # else
1408 printf ("vax-dec-ultrix\n"); exit (0);
1409 # endif
1410 #endif
1411
1412 #if defined (alliant) && defined (i860)
1413 printf ("i860-alliant-bsd\n"); exit (0);
1414 #endif
1415
1416 exit (1);
1417 }
1418 EOF
1419
1420 $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
1421 { echo "$SYSTEM_NAME"; exit; }
1422
1423 # Apollos put the system type in the environment.
1424
1425 test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
1426
1427 # Convex versions that predate uname can use getsysinfo(1)
1428
1429 if [ -x /usr/convex/getsysinfo ]
1430 then
1431 case `getsysinfo -f cpu_type` in
1432 c1*)
1433 echo c1-convex-bsd
1434 exit ;;
1435 c2*)
1436 if getsysinfo -f scalar_acc
1437 then echo c32-convex-bsd
1438 else echo c2-convex-bsd
1439 fi
1440 exit ;;
1441 c34*)
1442 echo c34-convex-bsd
1443 exit ;;
1444 c38*)
1445 echo c38-convex-bsd
1446 exit ;;
1447 c4*)
1448 echo c4-convex-bsd
1449 exit ;;
1450 esac
1451 fi
1452
1453 cat >&2 <<EOF
1454 $0: unable to guess system type
1455
1456 This script, last modified $timestamp, has failed to recognize
1457 the operating system you are using. It is advised that you
1458 download the most up to date version of the config scripts from
1459
1460 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
1461 and
1462 http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
1463
1464 If the version you run ($0) is already up to date, please
1465 send the following data and any information you think might be
1466 pertinent to <config-patches@gnu.org> in order to provide the needed
1467 information to handle your system.
1468
1469 config.guess timestamp = $timestamp
1470
1471 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1472 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1473 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1474 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1475
1476 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1477 /bin/uname -X = `(/bin/uname -X) 2>/dev/null`
1478
1479 hostinfo = `(hostinfo) 2>/dev/null`
1480 /bin/universe = `(/bin/universe) 2>/dev/null`
1481 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
1482 /bin/arch = `(/bin/arch) 2>/dev/null`
1483 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
1484 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1485
1486 UNAME_MACHINE = ${UNAME_MACHINE}
1487 UNAME_RELEASE = ${UNAME_RELEASE}
1488 UNAME_SYSTEM = ${UNAME_SYSTEM}
1489 UNAME_VERSION = ${UNAME_VERSION}
1490 EOF
1491
1492 exit 1
1493
1494 # Local variables:
1495 # eval: (add-hook 'write-file-hooks 'time-stamp)
1496 # time-stamp-start: "timestamp='"
1497 # time-stamp-format: "%:y-%02m-%02d"
1498 # time-stamp-end: "'"
1499 # End:
0 #! /bin/sh
1 # Configuration validation subroutine script.
2 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
4 # Inc.
5
6 timestamp='2006-09-20'
7
8 # This file is (in principle) common to ALL GNU software.
9 # The presence of a machine in this file suggests that SOME GNU software
10 # can handle that machine. It does not imply ALL GNU software can.
11 #
12 # This file is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
25 # 02110-1301, USA.
26 #
27 # As a special exception to the GNU General Public License, if you
28 # distribute this file as part of a program that contains a
29 # configuration script generated by Autoconf, you may include it under
30 # the same distribution terms that you use for the rest of that program.
31
32
33 # Please send patches to <config-patches@gnu.org>. Submit a context
34 # diff and a properly formatted ChangeLog entry.
35 #
36 # Configuration subroutine to validate and canonicalize a configuration type.
37 # Supply the specified configuration type as an argument.
38 # If it is invalid, we print an error message on stderr and exit with code 1.
39 # Otherwise, we print the canonical config type on stdout and succeed.
40
41 # This file is supposed to be the same for all GNU packages
42 # and recognize all the CPU types, system types and aliases
43 # that are meaningful with *any* GNU software.
44 # Each package is responsible for reporting which valid configurations
45 # it does not support. The user should be able to distinguish
46 # a failure to support a valid configuration from a meaningless
47 # configuration.
48
49 # The goal of this file is to map all the various variations of a given
50 # machine specification into a single specification in the form:
51 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
52 # or in some cases, the newer four-part form:
53 # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
54 # It is wrong to echo any other type of specification.
55
56 me=`echo "$0" | sed -e 's,.*/,,'`
57
58 usage="\
59 Usage: $0 [OPTION] CPU-MFR-OPSYS
60 $0 [OPTION] ALIAS
61
62 Canonicalize a configuration name.
63
64 Operation modes:
65 -h, --help print this help, then exit
66 -t, --time-stamp print date of last modification, then exit
67 -v, --version print version number, then exit
68
69 Report bugs and patches to <config-patches@gnu.org>."
70
71 version="\
72 GNU config.sub ($timestamp)
73
74 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
75 Free Software Foundation, Inc.
76
77 This is free software; see the source for copying conditions. There is NO
78 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
79
80 help="
81 Try \`$me --help' for more information."
82
83 # Parse command line
84 while test $# -gt 0 ; do
85 case $1 in
86 --time-stamp | --time* | -t )
87 echo "$timestamp" ; exit ;;
88 --version | -v )
89 echo "$version" ; exit ;;
90 --help | --h* | -h )
91 echo "$usage"; exit ;;
92 -- ) # Stop option processing
93 shift; break ;;
94 - ) # Use stdin as input.
95 break ;;
96 -* )
97 echo "$me: invalid option $1$help"
98 exit 1 ;;
99
100 *local*)
101 # First pass through any local machine types.
102 echo $1
103 exit ;;
104
105 * )
106 break ;;
107 esac
108 done
109
110 case $# in
111 0) echo "$me: missing argument$help" >&2
112 exit 1;;
113 1) ;;
114 *) echo "$me: too many arguments$help" >&2
115 exit 1;;
116 esac
117
118 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
119 # Here we must recognize all the valid KERNEL-OS combinations.
120 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
121 case $maybe_os in
122 nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
123 uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
124 storm-chaos* | os2-emx* | rtmk-nova*)
125 os=-$maybe_os
126 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
127 ;;
128 *)
129 basic_machine=`echo $1 | sed 's/-[^-]*$//'`
130 if [ $basic_machine != $1 ]
131 then os=`echo $1 | sed 's/.*-/-/'`
132 else os=; fi
133 ;;
134 esac
135
136 ### Let's recognize common machines as not being operating systems so
137 ### that things like config.sub decstation-3100 work. We also
138 ### recognize some manufacturers as not being operating systems, so we
139 ### can provide default operating systems below.
140 case $os in
141 -sun*os*)
142 # Prevent following clause from handling this invalid input.
143 ;;
144 -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
145 -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
146 -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
147 -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
148 -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
149 -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
150 -apple | -axis | -knuth | -cray)
151 os=
152 basic_machine=$1
153 ;;
154 -sim | -cisco | -oki | -wec | -winbond)
155 os=
156 basic_machine=$1
157 ;;
158 -scout)
159 ;;
160 -wrs)
161 os=-vxworks
162 basic_machine=$1
163 ;;
164 -chorusos*)
165 os=-chorusos
166 basic_machine=$1
167 ;;
168 -chorusrdb)
169 os=-chorusrdb
170 basic_machine=$1
171 ;;
172 -hiux*)
173 os=-hiuxwe2
174 ;;
175 -sco6)
176 os=-sco5v6
177 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
178 ;;
179 -sco5)
180 os=-sco3.2v5
181 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
182 ;;
183 -sco4)
184 os=-sco3.2v4
185 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
186 ;;
187 -sco3.2.[4-9]*)
188 os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
189 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
190 ;;
191 -sco3.2v[4-9]*)
192 # Don't forget version if it is 3.2v4 or newer.
193 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
194 ;;
195 -sco5v6*)
196 # Don't forget version if it is 3.2v4 or newer.
197 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
198 ;;
199 -sco*)
200 os=-sco3.2v2
201 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
202 ;;
203 -udk*)
204 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
205 ;;
206 -isc)
207 os=-isc2.2
208 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
209 ;;
210 -clix*)
211 basic_machine=clipper-intergraph
212 ;;
213 -isc*)
214 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
215 ;;
216 -lynx*)
217 os=-lynxos
218 ;;
219 -ptx*)
220 basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
221 ;;
222 -windowsnt*)
223 os=`echo $os | sed -e 's/windowsnt/winnt/'`
224 ;;
225 -psos*)
226 os=-psos
227 ;;
228 -mint | -mint[0-9]*)
229 basic_machine=m68k-atari
230 os=-mint
231 ;;
232 esac
233
234 # Decode aliases for certain CPU-COMPANY combinations.
235 case $basic_machine in
236 # Recognize the basic CPU types without company name.
237 # Some are omitted here because they have special meanings below.
238 1750a | 580 \
239 | a29k \
240 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
241 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
242 | am33_2.0 \
243 | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
244 | bfin \
245 | c4x | clipper \
246 | d10v | d30v | dlx | dsp16xx \
247 | fr30 | frv \
248 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
249 | i370 | i860 | i960 | ia64 \
250 | ip2k | iq2000 \
251 | m32c | m32r | m32rle | m68000 | m68k | m88k \
252 | maxq | mb | microblaze | mcore \
253 | mips | mipsbe | mipseb | mipsel | mipsle \
254 | mips16 \
255 | mips64 | mips64el \
256 | mips64vr | mips64vrel \
257 | mips64orion | mips64orionel \
258 | mips64vr4100 | mips64vr4100el \
259 | mips64vr4300 | mips64vr4300el \
260 | mips64vr5000 | mips64vr5000el \
261 | mips64vr5900 | mips64vr5900el \
262 | mipsisa32 | mipsisa32el \
263 | mipsisa32r2 | mipsisa32r2el \
264 | mipsisa64 | mipsisa64el \
265 | mipsisa64r2 | mipsisa64r2el \
266 | mipsisa64sb1 | mipsisa64sb1el \
267 | mipsisa64sr71k | mipsisa64sr71kel \
268 | mipstx39 | mipstx39el \
269 | mn10200 | mn10300 \
270 | mt \
271 | msp430 \
272 | nios | nios2 \
273 | ns16k | ns32k \
274 | or32 \
275 | pdp10 | pdp11 | pj | pjl \
276 | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
277 | pyramid \
278 | score \
279 | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
280 | sh64 | sh64le \
281 | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
282 | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
283 | spu | strongarm \
284 | tahoe | thumb | tic4x | tic80 | tron \
285 | v850 | v850e \
286 | we32k \
287 | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
288 | z8k)
289 basic_machine=$basic_machine-unknown
290 ;;
291 m6811 | m68hc11 | m6812 | m68hc12)
292 # Motorola 68HC11/12.
293 basic_machine=$basic_machine-unknown
294 os=-none
295 ;;
296 m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
297 ;;
298 ms1)
299 basic_machine=mt-unknown
300 ;;
301
302 # We use `pc' rather than `unknown'
303 # because (1) that's what they normally are, and
304 # (2) the word "unknown" tends to confuse beginning users.
305 i*86 | x86_64)
306 basic_machine=$basic_machine-pc
307 ;;
308 # Object if more than one company name word.
309 *-*-*)
310 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
311 exit 1
312 ;;
313 # Recognize the basic CPU types with company name.
314 580-* \
315 | a29k-* \
316 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
317 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
318 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
319 | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
320 | avr-* | avr32-* \
321 | bfin-* | bs2000-* \
322 | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
323 | clipper-* | craynv-* | cydra-* \
324 | d10v-* | d30v-* | dlx-* \
325 | elxsi-* \
326 | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
327 | h8300-* | h8500-* \
328 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
329 | i*86-* | i860-* | i960-* | ia64-* \
330 | ip2k-* | iq2000-* \
331 | m32c-* | m32r-* | m32rle-* \
332 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
333 | m88110-* | m88k-* | maxq-* | mcore-* \
334 | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
335 | mips16-* \
336 | mips64-* | mips64el-* \
337 | mips64vr-* | mips64vrel-* \
338 | mips64orion-* | mips64orionel-* \
339 | mips64vr4100-* | mips64vr4100el-* \
340 | mips64vr4300-* | mips64vr4300el-* \
341 | mips64vr5000-* | mips64vr5000el-* \
342 | mips64vr5900-* | mips64vr5900el-* \
343 | mipsisa32-* | mipsisa32el-* \
344 | mipsisa32r2-* | mipsisa32r2el-* \
345 | mipsisa64-* | mipsisa64el-* \
346 | mipsisa64r2-* | mipsisa64r2el-* \
347 | mipsisa64sb1-* | mipsisa64sb1el-* \
348 | mipsisa64sr71k-* | mipsisa64sr71kel-* \
349 | mipstx39-* | mipstx39el-* \
350 | mmix-* \
351 | mt-* \
352 | msp430-* \
353 | nios-* | nios2-* \
354 | none-* | np1-* | ns16k-* | ns32k-* \
355 | orion-* \
356 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
357 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
358 | pyramid-* \
359 | romp-* | rs6000-* \
360 | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
361 | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
362 | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
363 | sparclite-* \
364 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
365 | tahoe-* | thumb-* \
366 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
367 | tron-* \
368 | v850-* | v850e-* | vax-* \
369 | we32k-* \
370 | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
371 | xstormy16-* | xtensa-* \
372 | ymp-* \
373 | z8k-*)
374 ;;
375 # Recognize the various machine names and aliases which stand
376 # for a CPU type and a company and sometimes even an OS.
377 386bsd)
378 basic_machine=i386-unknown
379 os=-bsd
380 ;;
381 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
382 basic_machine=m68000-att
383 ;;
384 3b*)
385 basic_machine=we32k-att
386 ;;
387 a29khif)
388 basic_machine=a29k-amd
389 os=-udi
390 ;;
391 abacus)
392 basic_machine=abacus-unknown
393 ;;
394 adobe68k)
395 basic_machine=m68010-adobe
396 os=-scout
397 ;;
398 alliant | fx80)
399 basic_machine=fx80-alliant
400 ;;
401 altos | altos3068)
402 basic_machine=m68k-altos
403 ;;
404 am29k)
405 basic_machine=a29k-none
406 os=-bsd
407 ;;
408 amd64)
409 basic_machine=x86_64-pc
410 ;;
411 amd64-*)
412 basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
413 ;;
414 amdahl)
415 basic_machine=580-amdahl
416 os=-sysv
417 ;;
418 amiga | amiga-*)
419 basic_machine=m68k-unknown
420 ;;
421 amigaos | amigados)
422 basic_machine=m68k-unknown
423 os=-amigaos
424 ;;
425 amigaunix | amix)
426 basic_machine=m68k-unknown
427 os=-sysv4
428 ;;
429 apollo68)
430 basic_machine=m68k-apollo
431 os=-sysv
432 ;;
433 apollo68bsd)
434 basic_machine=m68k-apollo
435 os=-bsd
436 ;;
437 aux)
438 basic_machine=m68k-apple
439 os=-aux
440 ;;
441 balance)
442 basic_machine=ns32k-sequent
443 os=-dynix
444 ;;
445 c90)
446 basic_machine=c90-cray
447 os=-unicos
448 ;;
449 convex-c1)
450 basic_machine=c1-convex
451 os=-bsd
452 ;;
453 convex-c2)
454 basic_machine=c2-convex
455 os=-bsd
456 ;;
457 convex-c32)
458 basic_machine=c32-convex
459 os=-bsd
460 ;;
461 convex-c34)
462 basic_machine=c34-convex
463 os=-bsd
464 ;;
465 convex-c38)
466 basic_machine=c38-convex
467 os=-bsd
468 ;;
469 cray | j90)
470 basic_machine=j90-cray
471 os=-unicos
472 ;;
473 craynv)
474 basic_machine=craynv-cray
475 os=-unicosmp
476 ;;
477 cr16c)
478 basic_machine=cr16c-unknown
479 os=-elf
480 ;;
481 crds | unos)
482 basic_machine=m68k-crds
483 ;;
484 crisv32 | crisv32-* | etraxfs*)
485 basic_machine=crisv32-axis
486 ;;
487 cris | cris-* | etrax*)
488 basic_machine=cris-axis
489 ;;
490 crx)
491 basic_machine=crx-unknown
492 os=-elf
493 ;;
494 da30 | da30-*)
495 basic_machine=m68k-da30
496 ;;
497 decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
498 basic_machine=mips-dec
499 ;;
500 decsystem10* | dec10*)
501 basic_machine=pdp10-dec
502 os=-tops10
503 ;;
504 decsystem20* | dec20*)
505 basic_machine=pdp10-dec
506 os=-tops20
507 ;;
508 delta | 3300 | motorola-3300 | motorola-delta \
509 | 3300-motorola | delta-motorola)
510 basic_machine=m68k-motorola
511 ;;
512 delta88)
513 basic_machine=m88k-motorola
514 os=-sysv3
515 ;;
516 djgpp)
517 basic_machine=i586-pc
518 os=-msdosdjgpp
519 ;;
520 dpx20 | dpx20-*)
521 basic_machine=rs6000-bull
522 os=-bosx
523 ;;
524 dpx2* | dpx2*-bull)
525 basic_machine=m68k-bull
526 os=-sysv3
527 ;;
528 ebmon29k)
529 basic_machine=a29k-amd
530 os=-ebmon
531 ;;
532 elxsi)
533 basic_machine=elxsi-elxsi
534 os=-bsd
535 ;;
536 encore | umax | mmax)
537 basic_machine=ns32k-encore
538 ;;
539 es1800 | OSE68k | ose68k | ose | OSE)
540 basic_machine=m68k-ericsson
541 os=-ose
542 ;;
543 fx2800)
544 basic_machine=i860-alliant
545 ;;
546 genix)
547 basic_machine=ns32k-ns
548 ;;
549 gmicro)
550 basic_machine=tron-gmicro
551 os=-sysv
552 ;;
553 go32)
554 basic_machine=i386-pc
555 os=-go32
556 ;;
557 h3050r* | hiux*)
558 basic_machine=hppa1.1-hitachi
559 os=-hiuxwe2
560 ;;
561 h8300hms)
562 basic_machine=h8300-hitachi
563 os=-hms
564 ;;
565 h8300xray)
566 basic_machine=h8300-hitachi
567 os=-xray
568 ;;
569 h8500hms)
570 basic_machine=h8500-hitachi
571 os=-hms
572 ;;
573 harris)
574 basic_machine=m88k-harris
575 os=-sysv3
576 ;;
577 hp300-*)
578 basic_machine=m68k-hp
579 ;;
580 hp300bsd)
581 basic_machine=m68k-hp
582 os=-bsd
583 ;;
584 hp300hpux)
585 basic_machine=m68k-hp
586 os=-hpux
587 ;;
588 hp3k9[0-9][0-9] | hp9[0-9][0-9])
589 basic_machine=hppa1.0-hp
590 ;;
591 hp9k2[0-9][0-9] | hp9k31[0-9])
592 basic_machine=m68000-hp
593 ;;
594 hp9k3[2-9][0-9])
595 basic_machine=m68k-hp
596 ;;
597 hp9k6[0-9][0-9] | hp6[0-9][0-9])
598 basic_machine=hppa1.0-hp
599 ;;
600 hp9k7[0-79][0-9] | hp7[0-79][0-9])
601 basic_machine=hppa1.1-hp
602 ;;
603 hp9k78[0-9] | hp78[0-9])
604 # FIXME: really hppa2.0-hp
605 basic_machine=hppa1.1-hp
606 ;;
607 hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
608 # FIXME: really hppa2.0-hp
609 basic_machine=hppa1.1-hp
610 ;;
611 hp9k8[0-9][13679] | hp8[0-9][13679])
612 basic_machine=hppa1.1-hp
613 ;;
614 hp9k8[0-9][0-9] | hp8[0-9][0-9])
615 basic_machine=hppa1.0-hp
616 ;;
617 hppa-next)
618 os=-nextstep3
619 ;;
620 hppaosf)
621 basic_machine=hppa1.1-hp
622 os=-osf
623 ;;
624 hppro)
625 basic_machine=hppa1.1-hp
626 os=-proelf
627 ;;
628 i370-ibm* | ibm*)
629 basic_machine=i370-ibm
630 ;;
631 # I'm not sure what "Sysv32" means. Should this be sysv3.2?
632 i*86v32)
633 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
634 os=-sysv32
635 ;;
636 i*86v4*)
637 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
638 os=-sysv4
639 ;;
640 i*86v)
641 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
642 os=-sysv
643 ;;
644 i*86sol2)
645 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
646 os=-solaris2
647 ;;
648 i386mach)
649 basic_machine=i386-mach
650 os=-mach
651 ;;
652 i386-vsta | vsta)
653 basic_machine=i386-unknown
654 os=-vsta
655 ;;
656 iris | iris4d)
657 basic_machine=mips-sgi
658 case $os in
659 -irix*)
660 ;;
661 *)
662 os=-irix4
663 ;;
664 esac
665 ;;
666 isi68 | isi)
667 basic_machine=m68k-isi
668 os=-sysv
669 ;;
670 m88k-omron*)
671 basic_machine=m88k-omron
672 ;;
673 magnum | m3230)
674 basic_machine=mips-mips
675 os=-sysv
676 ;;
677 merlin)
678 basic_machine=ns32k-utek
679 os=-sysv
680 ;;
681 mingw32)
682 basic_machine=i386-pc
683 os=-mingw32
684 ;;
685 miniframe)
686 basic_machine=m68000-convergent
687 ;;
688 *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
689 basic_machine=m68k-atari
690 os=-mint
691 ;;
692 mips3*-*)
693 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
694 ;;
695 mips3*)
696 basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
697 ;;
698 monitor)
699 basic_machine=m68k-rom68k
700 os=-coff
701 ;;
702 morphos)
703 basic_machine=powerpc-unknown
704 os=-morphos
705 ;;
706 msdos)
707 basic_machine=i386-pc
708 os=-msdos
709 ;;
710 ms1-*)
711 basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
712 ;;
713 mvs)
714 basic_machine=i370-ibm
715 os=-mvs
716 ;;
717 ncr3000)
718 basic_machine=i486-ncr
719 os=-sysv4
720 ;;
721 netbsd386)
722 basic_machine=i386-unknown
723 os=-netbsd
724 ;;
725 netwinder)
726 basic_machine=armv4l-rebel
727 os=-linux
728 ;;
729 news | news700 | news800 | news900)
730 basic_machine=m68k-sony
731 os=-newsos
732 ;;
733 news1000)
734 basic_machine=m68030-sony
735 os=-newsos
736 ;;
737 news-3600 | risc-news)
738 basic_machine=mips-sony
739 os=-newsos
740 ;;
741 necv70)
742 basic_machine=v70-nec
743 os=-sysv
744 ;;
745 next | m*-next )
746 basic_machine=m68k-next
747 case $os in
748 -nextstep* )
749 ;;
750 -ns2*)
751 os=-nextstep2
752 ;;
753 *)
754 os=-nextstep3
755 ;;
756 esac
757 ;;
758 nh3000)
759 basic_machine=m68k-harris
760 os=-cxux
761 ;;
762 nh[45]000)
763 basic_machine=m88k-harris
764 os=-cxux
765 ;;
766 nindy960)
767 basic_machine=i960-intel
768 os=-nindy
769 ;;
770 mon960)
771 basic_machine=i960-intel
772 os=-mon960
773 ;;
774 nonstopux)
775 basic_machine=mips-compaq
776 os=-nonstopux
777 ;;
778 np1)
779 basic_machine=np1-gould
780 ;;
781 nsr-tandem)
782 basic_machine=nsr-tandem
783 ;;
784 op50n-* | op60c-*)
785 basic_machine=hppa1.1-oki
786 os=-proelf
787 ;;
788 openrisc | openrisc-*)
789 basic_machine=or32-unknown
790 ;;
791 os400)
792 basic_machine=powerpc-ibm
793 os=-os400
794 ;;
795 OSE68000 | ose68000)
796 basic_machine=m68000-ericsson
797 os=-ose
798 ;;
799 os68k)
800 basic_machine=m68k-none
801 os=-os68k
802 ;;
803 pa-hitachi)
804 basic_machine=hppa1.1-hitachi
805 os=-hiuxwe2
806 ;;
807 paragon)
808 basic_machine=i860-intel
809 os=-osf
810 ;;
811 pbd)
812 basic_machine=sparc-tti
813 ;;
814 pbb)
815 basic_machine=m68k-tti
816 ;;
817 pc532 | pc532-*)
818 basic_machine=ns32k-pc532
819 ;;
820 pc98)
821 basic_machine=i386-pc
822 ;;
823 pc98-*)
824 basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
825 ;;
826 pentium | p5 | k5 | k6 | nexgen | viac3)
827 basic_machine=i586-pc
828 ;;
829 pentiumpro | p6 | 6x86 | athlon | athlon_*)
830 basic_machine=i686-pc
831 ;;
832 pentiumii | pentium2 | pentiumiii | pentium3)
833 basic_machine=i686-pc
834 ;;
835 pentium4)
836 basic_machine=i786-pc
837 ;;
838 pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
839 basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
840 ;;
841 pentiumpro-* | p6-* | 6x86-* | athlon-*)
842 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
843 ;;
844 pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
845 basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
846 ;;
847 pentium4-*)
848 basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
849 ;;
850 pn)
851 basic_machine=pn-gould
852 ;;
853 power) basic_machine=power-ibm
854 ;;
855 ppc) basic_machine=powerpc-unknown
856 ;;
857 ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
858 ;;
859 ppcle | powerpclittle | ppc-le | powerpc-little)
860 basic_machine=powerpcle-unknown
861 ;;
862 ppcle-* | powerpclittle-*)
863 basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
864 ;;
865 ppc64) basic_machine=powerpc64-unknown
866 ;;
867 ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
868 ;;
869 ppc64le | powerpc64little | ppc64-le | powerpc64-little)
870 basic_machine=powerpc64le-unknown
871 ;;
872 ppc64le-* | powerpc64little-*)
873 basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
874 ;;
875 ps2)
876 basic_machine=i386-ibm
877 ;;
878 pw32)
879 basic_machine=i586-unknown
880 os=-pw32
881 ;;
882 rdos)
883 basic_machine=i386-pc
884 os=-rdos
885 ;;
886 rom68k)
887 basic_machine=m68k-rom68k
888 os=-coff
889 ;;
890 rm[46]00)
891 basic_machine=mips-siemens
892 ;;
893 rtpc | rtpc-*)
894 basic_machine=romp-ibm
895 ;;
896 s390 | s390-*)
897 basic_machine=s390-ibm
898 ;;
899 s390x | s390x-*)
900 basic_machine=s390x-ibm
901 ;;
902 sa29200)
903 basic_machine=a29k-amd
904 os=-udi
905 ;;
906 sb1)
907 basic_machine=mipsisa64sb1-unknown
908 ;;
909 sb1el)
910 basic_machine=mipsisa64sb1el-unknown
911 ;;
912 sde)
913 basic_machine=mipsisa32-sde
914 os=-elf
915 ;;
916 sei)
917 basic_machine=mips-sei
918 os=-seiux
919 ;;
920 sequent)
921 basic_machine=i386-sequent
922 ;;
923 sh)
924 basic_machine=sh-hitachi
925 os=-hms
926 ;;
927 sh64)
928 basic_machine=sh64-unknown
929 ;;
930 sparclite-wrs | simso-wrs)
931 basic_machine=sparclite-wrs
932 os=-vxworks
933 ;;
934 sps7)
935 basic_machine=m68k-bull
936 os=-sysv2
937 ;;
938 spur)
939 basic_machine=spur-unknown
940 ;;
941 st2000)
942 basic_machine=m68k-tandem
943 ;;
944 stratus)
945 basic_machine=i860-stratus
946 os=-sysv4
947 ;;
948 sun2)
949 basic_machine=m68000-sun
950 ;;
951 sun2os3)
952 basic_machine=m68000-sun
953 os=-sunos3
954 ;;
955 sun2os4)
956 basic_machine=m68000-sun
957 os=-sunos4
958 ;;
959 sun3os3)
960 basic_machine=m68k-sun
961 os=-sunos3
962 ;;
963 sun3os4)
964 basic_machine=m68k-sun
965 os=-sunos4
966 ;;
967 sun4os3)
968 basic_machine=sparc-sun
969 os=-sunos3
970 ;;
971 sun4os4)
972 basic_machine=sparc-sun
973 os=-sunos4
974 ;;
975 sun4sol2)
976 basic_machine=sparc-sun
977 os=-solaris2
978 ;;
979 sun3 | sun3-*)
980 basic_machine=m68k-sun
981 ;;
982 sun4)
983 basic_machine=sparc-sun
984 ;;
985 sun386 | sun386i | roadrunner)
986 basic_machine=i386-sun
987 ;;
988 sv1)
989 basic_machine=sv1-cray
990 os=-unicos
991 ;;
992 symmetry)
993 basic_machine=i386-sequent
994 os=-dynix
995 ;;
996 t3e)
997 basic_machine=alphaev5-cray
998 os=-unicos
999 ;;
1000 t90)
1001 basic_machine=t90-cray
1002 os=-unicos
1003 ;;
1004 tic54x | c54x*)
1005 basic_machine=tic54x-unknown
1006 os=-coff
1007 ;;
1008 tic55x | c55x*)
1009 basic_machine=tic55x-unknown
1010 os=-coff
1011 ;;
1012 tic6x | c6x*)
1013 basic_machine=tic6x-unknown
1014 os=-coff
1015 ;;
1016 tx39)
1017 basic_machine=mipstx39-unknown
1018 ;;
1019 tx39el)
1020 basic_machine=mipstx39el-unknown
1021 ;;
1022 toad1)
1023 basic_machine=pdp10-xkl
1024 os=-tops20
1025 ;;
1026 tower | tower-32)
1027 basic_machine=m68k-ncr
1028 ;;
1029 tpf)
1030 basic_machine=s390x-ibm
1031 os=-tpf
1032 ;;
1033 udi29k)
1034 basic_machine=a29k-amd
1035 os=-udi
1036 ;;
1037 ultra3)
1038 basic_machine=a29k-nyu
1039 os=-sym1
1040 ;;
1041 v810 | necv810)
1042 basic_machine=v810-nec
1043 os=-none
1044 ;;
1045 vaxv)
1046 basic_machine=vax-dec
1047 os=-sysv
1048 ;;
1049 vms)
1050 basic_machine=vax-dec
1051 os=-vms
1052 ;;
1053 vpp*|vx|vx-*)
1054 basic_machine=f301-fujitsu
1055 ;;
1056 vxworks960)
1057 basic_machine=i960-wrs
1058 os=-vxworks
1059 ;;
1060 vxworks68)
1061 basic_machine=m68k-wrs
1062 os=-vxworks
1063 ;;
1064 vxworks29k)
1065 basic_machine=a29k-wrs
1066 os=-vxworks
1067 ;;
1068 w65*)
1069 basic_machine=w65-wdc
1070 os=-none
1071 ;;
1072 w89k-*)
1073 basic_machine=hppa1.1-winbond
1074 os=-proelf
1075 ;;
1076 xbox)
1077 basic_machine=i686-pc
1078 os=-mingw32
1079 ;;
1080 xps | xps100)
1081 basic_machine=xps100-honeywell
1082 ;;
1083 ymp)
1084 basic_machine=ymp-cray
1085 os=-unicos
1086 ;;
1087 z8k-*-coff)
1088 basic_machine=z8k-unknown
1089 os=-sim
1090 ;;
1091 none)
1092 basic_machine=none-none
1093 os=-none
1094 ;;
1095
1096 # Here we handle the default manufacturer of certain CPU types. It is in
1097 # some cases the only manufacturer, in others, it is the most popular.
1098 w89k)
1099 basic_machine=hppa1.1-winbond
1100 ;;
1101 op50n)
1102 basic_machine=hppa1.1-oki
1103 ;;
1104 op60c)
1105 basic_machine=hppa1.1-oki
1106 ;;
1107 romp)
1108 basic_machine=romp-ibm
1109 ;;
1110 mmix)
1111 basic_machine=mmix-knuth
1112 ;;
1113 rs6000)
1114 basic_machine=rs6000-ibm
1115 ;;
1116 vax)
1117 basic_machine=vax-dec
1118 ;;
1119 pdp10)
1120 # there are many clones, so DEC is not a safe bet
1121 basic_machine=pdp10-unknown
1122 ;;
1123 pdp11)
1124 basic_machine=pdp11-dec
1125 ;;
1126 we32k)
1127 basic_machine=we32k-att
1128 ;;
1129 sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
1130 basic_machine=sh-unknown
1131 ;;
1132 sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
1133 basic_machine=sparc-sun
1134 ;;
1135 cydra)
1136 basic_machine=cydra-cydrome
1137 ;;
1138 orion)
1139 basic_machine=orion-highlevel
1140 ;;
1141 orion105)
1142 basic_machine=clipper-highlevel
1143 ;;
1144 mac | mpw | mac-mpw)
1145 basic_machine=m68k-apple
1146 ;;
1147 pmac | pmac-mpw)
1148 basic_machine=powerpc-apple
1149 ;;
1150 *-unknown)
1151 # Make sure to match an already-canonicalized machine name.
1152 ;;
1153 *)
1154 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
1155 exit 1
1156 ;;
1157 esac
1158
1159 # Here we canonicalize certain aliases for manufacturers.
1160 case $basic_machine in
1161 *-digital*)
1162 basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
1163 ;;
1164 *-commodore*)
1165 basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
1166 ;;
1167 *)
1168 ;;
1169 esac
1170
1171 # Decode manufacturer-specific aliases for certain operating systems.
1172
1173 if [ x"$os" != x"" ]
1174 then
1175 case $os in
1176 # First match some system type aliases
1177 # that might get confused with valid system types.
1178 # -solaris* is a basic system type, with this one exception.
1179 -solaris1 | -solaris1.*)
1180 os=`echo $os | sed -e 's|solaris1|sunos4|'`
1181 ;;
1182 -solaris)
1183 os=-solaris2
1184 ;;
1185 -svr4*)
1186 os=-sysv4
1187 ;;
1188 -unixware*)
1189 os=-sysv4.2uw
1190 ;;
1191 -gnu/linux*)
1192 os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
1193 ;;
1194 # First accept the basic system types.
1195 # The portable systems comes first.
1196 # Each alternative MUST END IN A *, to match a version number.
1197 # -sysv* is not here because it comes later, after sysvr4.
1198 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
1199 | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
1200 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
1201 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
1202 | -aos* \
1203 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
1204 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
1205 | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
1206 | -openbsd* | -solidbsd* \
1207 | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
1208 | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
1209 | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
1210 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
1211 | -chorusos* | -chorusrdb* \
1212 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
1213 | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
1214 | -uxpv* | -beos* | -mpeix* | -udk* \
1215 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
1216 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
1217 | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
1218 | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
1219 | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
1220 | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
1221 | -skyos* | -haiku* | -rdos* | -toppers*)
1222 # Remember, each alternative MUST END IN *, to match a version number.
1223 ;;
1224 -qnx*)
1225 case $basic_machine in
1226 x86-* | i*86-*)
1227 ;;
1228 *)
1229 os=-nto$os
1230 ;;
1231 esac
1232 ;;
1233 -nto-qnx*)
1234 ;;
1235 -nto*)
1236 os=`echo $os | sed -e 's|nto|nto-qnx|'`
1237 ;;
1238 -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
1239 | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
1240 | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
1241 ;;
1242 -mac*)
1243 os=`echo $os | sed -e 's|mac|macos|'`
1244 ;;
1245 -linux-dietlibc)
1246 os=-linux-dietlibc
1247 ;;
1248 -linux*)
1249 os=`echo $os | sed -e 's|linux|linux-gnu|'`
1250 ;;
1251 -sunos5*)
1252 os=`echo $os | sed -e 's|sunos5|solaris2|'`
1253 ;;
1254 -sunos6*)
1255 os=`echo $os | sed -e 's|sunos6|solaris3|'`
1256 ;;
1257 -opened*)
1258 os=-openedition
1259 ;;
1260 -os400*)
1261 os=-os400
1262 ;;
1263 -wince*)
1264 os=-wince
1265 ;;
1266 -osfrose*)
1267 os=-osfrose
1268 ;;
1269 -osf*)
1270 os=-osf
1271 ;;
1272 -utek*)
1273 os=-bsd
1274 ;;
1275 -dynix*)
1276 os=-bsd
1277 ;;
1278 -acis*)
1279 os=-aos
1280 ;;
1281 -atheos*)
1282 os=-atheos
1283 ;;
1284 -syllable*)
1285 os=-syllable
1286 ;;
1287 -386bsd)
1288 os=-bsd
1289 ;;
1290 -ctix* | -uts*)
1291 os=-sysv
1292 ;;
1293 -nova*)
1294 os=-rtmk-nova
1295 ;;
1296 -ns2 )
1297 os=-nextstep2
1298 ;;
1299 -nsk*)
1300 os=-nsk
1301 ;;
1302 # Preserve the version number of sinix5.
1303 -sinix5.*)
1304 os=`echo $os | sed -e 's|sinix|sysv|'`
1305 ;;
1306 -sinix*)
1307 os=-sysv4
1308 ;;
1309 -tpf*)
1310 os=-tpf
1311 ;;
1312 -triton*)
1313 os=-sysv3
1314 ;;
1315 -oss*)
1316 os=-sysv3
1317 ;;
1318 -svr4)
1319 os=-sysv4
1320 ;;
1321 -svr3)
1322 os=-sysv3
1323 ;;
1324 -sysvr4)
1325 os=-sysv4
1326 ;;
1327 # This must come after -sysvr4.
1328 -sysv*)
1329 ;;
1330 -ose*)
1331 os=-ose
1332 ;;
1333 -es1800*)
1334 os=-ose
1335 ;;
1336 -xenix)
1337 os=-xenix
1338 ;;
1339 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1340 os=-mint
1341 ;;
1342 -aros*)
1343 os=-aros
1344 ;;
1345 -kaos*)
1346 os=-kaos
1347 ;;
1348 -zvmoe)
1349 os=-zvmoe
1350 ;;
1351 -none)
1352 ;;
1353 *)
1354 # Get rid of the `-' at the beginning of $os.
1355 os=`echo $os | sed 's/[^-]*-//'`
1356 echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
1357 exit 1
1358 ;;
1359 esac
1360 else
1361
1362 # Here we handle the default operating systems that come with various machines.
1363 # The value should be what the vendor currently ships out the door with their
1364 # machine or put another way, the most popular os provided with the machine.
1365
1366 # Note that if you're going to try to match "-MANUFACTURER" here (say,
1367 # "-sun"), then you have to tell the case statement up towards the top
1368 # that MANUFACTURER isn't an operating system. Otherwise, code above
1369 # will signal an error saying that MANUFACTURER isn't an operating
1370 # system, and we'll never get to this point.
1371
1372 case $basic_machine in
1373 score-*)
1374 os=-elf
1375 ;;
1376 spu-*)
1377 os=-elf
1378 ;;
1379 *-acorn)
1380 os=-riscix1.2
1381 ;;
1382 arm*-rebel)
1383 os=-linux
1384 ;;
1385 arm*-semi)
1386 os=-aout
1387 ;;
1388 c4x-* | tic4x-*)
1389 os=-coff
1390 ;;
1391 # This must come before the *-dec entry.
1392 pdp10-*)
1393 os=-tops20
1394 ;;
1395 pdp11-*)
1396 os=-none
1397 ;;
1398 *-dec | vax-*)
1399 os=-ultrix4.2
1400 ;;
1401 m68*-apollo)
1402 os=-domain
1403 ;;
1404 i386-sun)
1405 os=-sunos4.0.2
1406 ;;
1407 m68000-sun)
1408 os=-sunos3
1409 # This also exists in the configure program, but was not the
1410 # default.
1411 # os=-sunos4
1412 ;;
1413 m68*-cisco)
1414 os=-aout
1415 ;;
1416 mips*-cisco)
1417 os=-elf
1418 ;;
1419 mips*-*)
1420 os=-elf
1421 ;;
1422 or32-*)
1423 os=-coff
1424 ;;
1425 *-tti) # must be before sparc entry or we get the wrong os.
1426 os=-sysv3
1427 ;;
1428 sparc-* | *-sun)
1429 os=-sunos4.1.1
1430 ;;
1431 *-be)
1432 os=-beos
1433 ;;
1434 *-haiku)
1435 os=-haiku
1436 ;;
1437 *-ibm)
1438 os=-aix
1439 ;;
1440 *-knuth)
1441 os=-mmixware
1442 ;;
1443 *-wec)
1444 os=-proelf
1445 ;;
1446 *-winbond)
1447 os=-proelf
1448 ;;
1449 *-oki)
1450 os=-proelf
1451 ;;
1452 *-hp)
1453 os=-hpux
1454 ;;
1455 *-hitachi)
1456 os=-hiux
1457 ;;
1458 i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
1459 os=-sysv
1460 ;;
1461 *-cbm)
1462 os=-amigaos
1463 ;;
1464 *-dg)
1465 os=-dgux
1466 ;;
1467 *-dolphin)
1468 os=-sysv3
1469 ;;
1470 m68k-ccur)
1471 os=-rtu
1472 ;;
1473 m88k-omron*)
1474 os=-luna
1475 ;;
1476 *-next )
1477 os=-nextstep
1478 ;;
1479 *-sequent)
1480 os=-ptx
1481 ;;
1482 *-crds)
1483 os=-unos
1484 ;;
1485 *-ns)
1486 os=-genix
1487 ;;
1488 i370-*)
1489 os=-mvs
1490 ;;
1491 *-next)
1492 os=-nextstep3
1493 ;;
1494 *-gould)
1495 os=-sysv
1496 ;;
1497 *-highlevel)
1498 os=-bsd
1499 ;;
1500 *-encore)
1501 os=-bsd
1502 ;;
1503 *-sgi)
1504 os=-irix
1505 ;;
1506 *-siemens)
1507 os=-sysv4
1508 ;;
1509 *-masscomp)
1510 os=-rtu
1511 ;;
1512 f30[01]-fujitsu | f700-fujitsu)
1513 os=-uxpv
1514 ;;
1515 *-rom68k)
1516 os=-coff
1517 ;;
1518 *-*bug)
1519 os=-coff
1520 ;;
1521 *-apple)
1522 os=-macos
1523 ;;
1524 *-atari*)
1525 os=-mint
1526 ;;
1527 *)
1528 os=-none
1529 ;;
1530 esac
1531 fi
1532
1533 # Here we handle the case where we know the os, and the CPU type, but not the
1534 # manufacturer. We pick the logical manufacturer.
1535 vendor=unknown
1536 case $basic_machine in
1537 *-unknown)
1538 case $os in
1539 -riscix*)
1540 vendor=acorn
1541 ;;
1542 -sunos*)
1543 vendor=sun
1544 ;;
1545 -aix*)
1546 vendor=ibm
1547 ;;
1548 -beos*)
1549 vendor=be
1550 ;;
1551 -hpux*)
1552 vendor=hp
1553 ;;
1554 -mpeix*)
1555 vendor=hp
1556 ;;
1557 -hiux*)
1558 vendor=hitachi
1559 ;;
1560 -unos*)
1561 vendor=crds
1562 ;;
1563 -dgux*)
1564 vendor=dg
1565 ;;
1566 -luna*)
1567 vendor=omron
1568 ;;
1569 -genix*)
1570 vendor=ns
1571 ;;
1572 -mvs* | -opened*)
1573 vendor=ibm
1574 ;;
1575 -os400*)
1576 vendor=ibm
1577 ;;
1578 -ptx*)
1579 vendor=sequent
1580 ;;
1581 -tpf*)
1582 vendor=ibm
1583 ;;
1584 -vxsim* | -vxworks* | -windiss*)
1585 vendor=wrs
1586 ;;
1587 -aux*)
1588 vendor=apple
1589 ;;
1590 -hms*)
1591 vendor=hitachi
1592 ;;
1593 -mpw* | -macos*)
1594 vendor=apple
1595 ;;
1596 -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1597 vendor=atari
1598 ;;
1599 -vos*)
1600 vendor=stratus
1601 ;;
1602 esac
1603 basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
1604 ;;
1605 esac
1606
1607 echo $basic_machine$os
1608 exit
1609
1610 # Local variables:
1611 # eval: (add-hook 'write-file-hooks 'time-stamp)
1612 # time-stamp-start: "timestamp='"
1613 # time-stamp-format: "%:y-%02m-%02d"
1614 # time-stamp-end: "'"
1615 # End:
0 #! /bin/sh
1 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.61 for AFFLIB 3.5.10.
3 #
4 # Report bugs to <bugs@afflib.org>.
5 #
6 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
7 # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
8 # This configure script is free software; the Free Software Foundation
9 # gives unlimited permission to copy, distribute and modify it.
10 ## --------------------- ##
11 ## M4sh Initialization. ##
12 ## --------------------- ##
13
14 # Be more Bourne compatible
15 DUALCASE=1; export DUALCASE # for MKS sh
16 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
17 emulate sh
18 NULLCMD=:
19 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
20 # is contrary to our usage. Disable this feature.
21 alias -g '${1+"$@"}'='"$@"'
22 setopt NO_GLOB_SUBST
23 else
24 case `(set -o) 2>/dev/null` in
25 *posix*) set -o posix ;;
26 esac
27
28 fi
29
30
31
32
33 # PATH needs CR
34 # Avoid depending upon Character Ranges.
35 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
36 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
37 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
38 as_cr_digits='0123456789'
39 as_cr_alnum=$as_cr_Letters$as_cr_digits
40
41 # The user is always right.
42 if test "${PATH_SEPARATOR+set}" != set; then
43 echo "#! /bin/sh" >conf$$.sh
44 echo "exit 0" >>conf$$.sh
45 chmod +x conf$$.sh
46 if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
47 PATH_SEPARATOR=';'
48 else
49 PATH_SEPARATOR=:
50 fi
51 rm -f conf$$.sh
52 fi
53
54 # Support unset when possible.
55 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
56 as_unset=unset
57 else
58 as_unset=false
59 fi
60
61
62 # IFS
63 # We need space, tab and new line, in precisely that order. Quoting is
64 # there to prevent editors from complaining about space-tab.
65 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
66 # splitting by setting IFS to empty value.)
67 as_nl='
68 '
69 IFS=" "" $as_nl"
70
71 # Find who we are. Look in the path if we contain no directory separator.
72 case $0 in
73 *[\\/]* ) as_myself=$0 ;;
74 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
75 for as_dir in $PATH
76 do
77 IFS=$as_save_IFS
78 test -z "$as_dir" && as_dir=.
79 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
80 done
81 IFS=$as_save_IFS
82
83 ;;
84 esac
85 # We did not find ourselves, most probably we were run as `sh COMMAND'
86 # in which case we are not to be found in the path.
87 if test "x$as_myself" = x; then
88 as_myself=$0
89 fi
90 if test ! -f "$as_myself"; then
91 echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
92 { (exit 1); exit 1; }
93 fi
94
95 # Work around bugs in pre-3.0 UWIN ksh.
96 for as_var in ENV MAIL MAILPATH
97 do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
98 done
99 PS1='$ '
100 PS2='> '
101 PS4='+ '
102
103 # NLS nuisances.
104 for as_var in \
105 LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
106 LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
107 LC_TELEPHONE LC_TIME
108 do
109 if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
110 eval $as_var=C; export $as_var
111 else
112 ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
113 fi
114 done
115
116 # Required to use basename.
117 if expr a : '\(a\)' >/dev/null 2>&1 &&
118 test "X`expr 00001 : '.*\(...\)'`" = X001; then
119 as_expr=expr
120 else
121 as_expr=false
122 fi
123
124 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
125 as_basename=basename
126 else
127 as_basename=false
128 fi
129
130
131 # Name of the executable.
132 as_me=`$as_basename -- "$0" ||
133 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
134 X"$0" : 'X\(//\)$' \| \
135 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
136 echo X/"$0" |
137 sed '/^.*\/\([^/][^/]*\)\/*$/{
138 s//\1/
139 q
140 }
141 /^X\/\(\/\/\)$/{
142 s//\1/
143 q
144 }
145 /^X\/\(\/\).*/{
146 s//\1/
147 q
148 }
149 s/.*/./; q'`
150
151 # CDPATH.
152 $as_unset CDPATH
153
154
155 if test "x$CONFIG_SHELL" = x; then
156 if (eval ":") 2>/dev/null; then
157 as_have_required=yes
158 else
159 as_have_required=no
160 fi
161
162 if test $as_have_required = yes && (eval ":
163 (as_func_return () {
164 (exit \$1)
165 }
166 as_func_success () {
167 as_func_return 0
168 }
169 as_func_failure () {
170 as_func_return 1
171 }
172 as_func_ret_success () {
173 return 0
174 }
175 as_func_ret_failure () {
176 return 1
177 }
178
179 exitcode=0
180 if as_func_success; then
181 :
182 else
183 exitcode=1
184 echo as_func_success failed.
185 fi
186
187 if as_func_failure; then
188 exitcode=1
189 echo as_func_failure succeeded.
190 fi
191
192 if as_func_ret_success; then
193 :
194 else
195 exitcode=1
196 echo as_func_ret_success failed.
197 fi
198
199 if as_func_ret_failure; then
200 exitcode=1
201 echo as_func_ret_failure succeeded.
202 fi
203
204 if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
205 :
206 else
207 exitcode=1
208 echo positional parameters were not saved.
209 fi
210
211 test \$exitcode = 0) || { (exit 1); exit 1; }
212
213 (
214 as_lineno_1=\$LINENO
215 as_lineno_2=\$LINENO
216 test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
217 test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
218 ") 2> /dev/null; then
219 :
220 else
221 as_candidate_shells=
222 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
223 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
224 do
225 IFS=$as_save_IFS
226 test -z "$as_dir" && as_dir=.
227 case $as_dir in
228 /*)
229 for as_base in sh bash ksh sh5; do
230 as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
231 done;;
232 esac
233 done
234 IFS=$as_save_IFS
235
236
237 for as_shell in $as_candidate_shells $SHELL; do
238 # Try only shells that exist, to save several forks.
239 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
240 { ("$as_shell") 2> /dev/null <<\_ASEOF
241 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
242 emulate sh
243 NULLCMD=:
244 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
245 # is contrary to our usage. Disable this feature.
246 alias -g '${1+"$@"}'='"$@"'
247 setopt NO_GLOB_SUBST
248 else
249 case `(set -o) 2>/dev/null` in
250 *posix*) set -o posix ;;
251 esac
252
253 fi
254
255
256 :
257 _ASEOF
258 }; then
259 CONFIG_SHELL=$as_shell
260 as_have_required=yes
261 if { "$as_shell" 2> /dev/null <<\_ASEOF
262 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
263 emulate sh
264 NULLCMD=:
265 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
266 # is contrary to our usage. Disable this feature.
267 alias -g '${1+"$@"}'='"$@"'
268 setopt NO_GLOB_SUBST
269 else
270 case `(set -o) 2>/dev/null` in
271 *posix*) set -o posix ;;
272 esac
273
274 fi
275
276
277 :
278 (as_func_return () {
279 (exit $1)
280 }
281 as_func_success () {
282 as_func_return 0
283 }
284 as_func_failure () {
285 as_func_return 1
286 }
287 as_func_ret_success () {
288 return 0
289 }
290 as_func_ret_failure () {
291 return 1
292 }
293
294 exitcode=0
295 if as_func_success; then
296 :
297 else
298 exitcode=1
299 echo as_func_success failed.
300 fi
301
302 if as_func_failure; then
303 exitcode=1
304 echo as_func_failure succeeded.
305 fi
306
307 if as_func_ret_success; then
308 :
309 else
310 exitcode=1
311 echo as_func_ret_success failed.
312 fi
313
314 if as_func_ret_failure; then
315 exitcode=1
316 echo as_func_ret_failure succeeded.
317 fi
318
319 if ( set x; as_func_ret_success y && test x = "$1" ); then
320 :
321 else
322 exitcode=1
323 echo positional parameters were not saved.
324 fi
325
326 test $exitcode = 0) || { (exit 1); exit 1; }
327
328 (
329 as_lineno_1=$LINENO
330 as_lineno_2=$LINENO
331 test "x$as_lineno_1" != "x$as_lineno_2" &&
332 test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
333
334 _ASEOF
335 }; then
336 break
337 fi
338
339 fi
340
341 done
342
343 if test "x$CONFIG_SHELL" != x; then
344 for as_var in BASH_ENV ENV
345 do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
346 done
347 export CONFIG_SHELL
348 exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
349 fi
350
351
352 if test $as_have_required = no; then
353 echo This script requires a shell more modern than all the
354 echo shells that I found on your system. Please install a
355 echo modern shell, or manually run the script under such a
356 echo shell if you do have one.
357 { (exit 1); exit 1; }
358 fi
359
360
361 fi
362
363 fi
364
365
366
367 (eval "as_func_return () {
368 (exit \$1)
369 }
370 as_func_success () {
371 as_func_return 0
372 }
373 as_func_failure () {
374 as_func_return 1
375 }
376 as_func_ret_success () {
377 return 0
378 }
379 as_func_ret_failure () {
380 return 1
381 }
382
383 exitcode=0
384 if as_func_success; then
385 :
386 else
387 exitcode=1
388 echo as_func_success failed.
389 fi
390
391 if as_func_failure; then
392 exitcode=1
393 echo as_func_failure succeeded.
394 fi
395
396 if as_func_ret_success; then
397 :
398 else
399 exitcode=1
400 echo as_func_ret_success failed.
401 fi
402
403 if as_func_ret_failure; then
404 exitcode=1
405 echo as_func_ret_failure succeeded.
406 fi
407
408 if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
409 :
410 else
411 exitcode=1
412 echo positional parameters were not saved.
413 fi
414
415 test \$exitcode = 0") || {
416 echo No shell found that supports shell functions.
417 echo Please tell autoconf@gnu.org about your system,
418 echo including any error possibly output before this
419 echo message
420 }
421
422
423
424 as_lineno_1=$LINENO
425 as_lineno_2=$LINENO
426 test "x$as_lineno_1" != "x$as_lineno_2" &&
427 test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
428
429 # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
430 # uniformly replaced by the line number. The first 'sed' inserts a
431 # line-number line after each line using $LINENO; the second 'sed'
432 # does the real work. The second script uses 'N' to pair each
433 # line-number line with the line containing $LINENO, and appends
434 # trailing '-' during substitution so that $LINENO is not a special
435 # case at line end.
436 # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
437 # scripts with optimization help from Paolo Bonzini. Blame Lee
438 # E. McMahon (1931-1989) for sed's syntax. :-)
439 sed -n '
440 p
441 /[$]LINENO/=
442 ' <$as_myself |
443 sed '
444 s/[$]LINENO.*/&-/
445 t lineno
446 b
447 :lineno
448 N
449 :loop
450 s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
451 t loop
452 s/-\n.*//
453 ' >$as_me.lineno &&
454 chmod +x "$as_me.lineno" ||
455 { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
456 { (exit 1); exit 1; }; }
457
458 # Don't try to exec as it changes $[0], causing all sort of problems
459 # (the dirname of $[0] is not the place where we might find the
460 # original and so on. Autoconf is especially sensitive to this).
461 . "./$as_me.lineno"
462 # Exit status is that of the last command.
463 exit
464 }
465
466
467 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
468 as_dirname=dirname
469 else
470 as_dirname=false
471 fi
472
473 ECHO_C= ECHO_N= ECHO_T=
474 case `echo -n x` in
475 -n*)
476 case `echo 'x\c'` in
477 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
478 *) ECHO_C='\c';;
479 esac;;
480 *)
481 ECHO_N='-n';;
482 esac
483
484 if expr a : '\(a\)' >/dev/null 2>&1 &&
485 test "X`expr 00001 : '.*\(...\)'`" = X001; then
486 as_expr=expr
487 else
488 as_expr=false
489 fi
490
491 rm -f conf$$ conf$$.exe conf$$.file
492 if test -d conf$$.dir; then
493 rm -f conf$$.dir/conf$$.file
494 else
495 rm -f conf$$.dir
496 mkdir conf$$.dir
497 fi
498 echo >conf$$.file
499 if ln -s conf$$.file conf$$ 2>/dev/null; then
500 as_ln_s='ln -s'
501 # ... but there are two gotchas:
502 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
503 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
504 # In both cases, we have to default to `cp -p'.
505 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
506 as_ln_s='cp -p'
507 elif ln conf$$.file conf$$ 2>/dev/null; then
508 as_ln_s=ln
509 else
510 as_ln_s='cp -p'
511 fi
512 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
513 rmdir conf$$.dir 2>/dev/null
514
515 if mkdir -p . 2>/dev/null; then
516 as_mkdir_p=:
517 else
518 test -d ./-p && rmdir ./-p
519 as_mkdir_p=false
520 fi
521
522 if test -x / >/dev/null 2>&1; then
523 as_test_x='test -x'
524 else
525 if ls -dL / >/dev/null 2>&1; then
526 as_ls_L_option=L
527 else
528 as_ls_L_option=
529 fi
530 as_test_x='
531 eval sh -c '\''
532 if test -d "$1"; then
533 test -d "$1/.";
534 else
535 case $1 in
536 -*)set "./$1";;
537 esac;
538 case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
539 ???[sx]*):;;*)false;;esac;fi
540 '\'' sh
541 '
542 fi
543 as_executable_p=$as_test_x
544
545 # Sed expression to map a string onto a valid CPP name.
546 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
547
548 # Sed expression to map a string onto a valid variable name.
549 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
550
551
552
553
554 # Check that we are running under the correct shell.
555 SHELL=${CONFIG_SHELL-/bin/sh}
556
557 case X$lt_ECHO in
558 X*--fallback-echo)
559 # Remove one level of quotation (which was required for Make).
560 ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','`
561 ;;
562 esac
563
564 ECHO=${lt_ECHO-echo}
565 if test "X$1" = X--no-reexec; then
566 # Discard the --no-reexec flag, and continue.
567 shift
568 elif test "X$1" = X--fallback-echo; then
569 # Avoid inline document here, it may be left over
570 :
571 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
572 # Yippee, $ECHO works!
573 :
574 else
575 # Restart under the correct shell.
576 exec $SHELL "$0" --no-reexec ${1+"$@"}
577 fi
578
579 if test "X$1" = X--fallback-echo; then
580 # used as fallback echo
581 shift
582 cat <<_LT_EOF
583 $*
584 _LT_EOF
585 exit 0
586 fi
587
588 # The HP-UX ksh and POSIX shell print the target directory to stdout
589 # if CDPATH is set.
590 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
591
592 if test -z "$lt_ECHO"; then
593 if test "X${echo_test_string+set}" != Xset; then
594 # find a string as large as possible, as long as the shell can cope with it
595 for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
596 # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
597 if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
598 { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
599 then
600 break
601 fi
602 done
603 fi
604
605 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
606 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
607 test "X$echo_testing_string" = "X$echo_test_string"; then
608 :
609 else
610 # The Solaris, AIX, and Digital Unix default echo programs unquote
611 # backslashes. This makes it impossible to quote backslashes using
612 # echo "$something" | sed 's/\\/\\\\/g'
613 #
614 # So, first we look for a working echo in the user's PATH.
615
616 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
617 for dir in $PATH /usr/ucb; do
618 IFS="$lt_save_ifs"
619 if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
620 test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
621 echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
622 test "X$echo_testing_string" = "X$echo_test_string"; then
623 ECHO="$dir/echo"
624 break
625 fi
626 done
627 IFS="$lt_save_ifs"
628
629 if test "X$ECHO" = Xecho; then
630 # We didn't find a better echo, so look for alternatives.
631 if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
632 echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
633 test "X$echo_testing_string" = "X$echo_test_string"; then
634 # This shell has a builtin print -r that does the trick.
635 ECHO='print -r'
636 elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
637 test "X$CONFIG_SHELL" != X/bin/ksh; then
638 # If we have ksh, try running configure again with it.
639 ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
640 export ORIGINAL_CONFIG_SHELL
641 CONFIG_SHELL=/bin/ksh
642 export CONFIG_SHELL
643 exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
644 else
645 # Try using printf.
646 ECHO='printf %s\n'
647 if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
648 echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
649 test "X$echo_testing_string" = "X$echo_test_string"; then
650 # Cool, printf works
651 :
652 elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
653 test "X$echo_testing_string" = 'X\t' &&
654 echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
655 test "X$echo_testing_string" = "X$echo_test_string"; then
656 CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
657 export CONFIG_SHELL
658 SHELL="$CONFIG_SHELL"
659 export SHELL
660 ECHO="$CONFIG_SHELL $0 --fallback-echo"
661 elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
662 test "X$echo_testing_string" = 'X\t' &&
663 echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
664 test "X$echo_testing_string" = "X$echo_test_string"; then
665 ECHO="$CONFIG_SHELL $0 --fallback-echo"
666 else
667 # maybe with a smaller string...
668 prev=:
669
670 for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
671 if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
672 then
673 break
674 fi
675 prev="$cmd"
676 done
677
678 if test "$prev" != 'sed 50q "$0"'; then
679 echo_test_string=`eval $prev`
680 export echo_test_string
681 exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
682 else
683 # Oops. We lost completely, so just stick with echo.
684 ECHO=echo
685 fi
686 fi
687 fi
688 fi
689 fi
690 fi
691
692 # Copy echo and quote the copy suitably for passing to libtool from
693 # the Makefile, instead of quoting the original, which is used later.
694 lt_ECHO=$ECHO
695 if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
696 lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
697 fi
698
699
700
701
702 exec 7<&0 </dev/null 6>&1
703
704 # Name of the host.
705 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
706 # so uname gets run too.
707 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
708
709 #
710 # Initializations.
711 #
712 ac_default_prefix=/usr/local
713 ac_clean_files=
714 ac_config_libobj_dir=.
715 LIBOBJS=
716 cross_compiling=no
717 subdirs=
718 MFLAGS=
719 MAKEFLAGS=
720 SHELL=${CONFIG_SHELL-/bin/sh}
721
722 # Identity of this package.
723 PACKAGE_NAME='AFFLIB'
724 PACKAGE_TARNAME='afflib'
725 PACKAGE_VERSION='3.5.10'
726 PACKAGE_STRING='AFFLIB 3.5.10'
727 PACKAGE_BUGREPORT='bugs@afflib.org'
728
729 # Factoring default headers for most tests.
730 ac_includes_default="\
731 #include <stdio.h>
732 #ifdef HAVE_SYS_TYPES_H
733 # include <sys/types.h>
734 #endif
735 #ifdef HAVE_SYS_STAT_H
736 # include <sys/stat.h>
737 #endif
738 #ifdef STDC_HEADERS
739 # include <stdlib.h>
740 # include <stddef.h>
741 #else
742 # ifdef HAVE_STDLIB_H
743 # include <stdlib.h>
744 # endif
745 #endif
746 #ifdef HAVE_STRING_H
747 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
748 # include <memory.h>
749 # endif
750 # include <string.h>
751 #endif
752 #ifdef HAVE_STRINGS_H
753 # include <strings.h>
754 #endif
755 #ifdef HAVE_INTTYPES_H
756 # include <inttypes.h>
757 #endif
758 #ifdef HAVE_STDINT_H
759 # include <stdint.h>
760 #endif
761 #ifdef HAVE_UNISTD_H
762 # include <unistd.h>
763 #endif"
764
765 ac_subst_vars='SHELL
766 PATH_SEPARATOR
767 PACKAGE_NAME
768 PACKAGE_TARNAME
769 PACKAGE_VERSION
770 PACKAGE_STRING
771 PACKAGE_BUGREPORT
772 exec_prefix
773 prefix
774 program_transform_name
775 bindir
776 sbindir
777 libexecdir
778 datarootdir
779 datadir
780 sysconfdir
781 sharedstatedir
782 localstatedir
783 includedir
784 oldincludedir
785 docdir
786 infodir
787 htmldir
788 dvidir
789 pdfdir
790 psdir
791 libdir
792 localedir
793 mandir
794 DEFS
795 ECHO_C
796 ECHO_N
797 ECHO_T
798 LIBS
799 build_alias
800 host_alias
801 target_alias
802 INSTALL_PROGRAM
803 INSTALL_SCRIPT
804 INSTALL_DATA
805 am__isrc
806 CYGPATH_W
807 PACKAGE
808 VERSION
809 ACLOCAL
810 AUTOCONF
811 AUTOMAKE
812 AUTOHEADER
813 MAKEINFO
814 install_sh
815 STRIP
816 INSTALL_STRIP_PROGRAM
817 mkdir_p
818 AWK
819 SET_MAKE
820 am__leading_dot
821 AMTAR
822 am__tar
823 am__untar
824 MAINTAINER_MODE_TRUE
825 MAINTAINER_MODE_FALSE
826 MAINT
827 ac_prefix_program
828 CC
829 CFLAGS
830 LDFLAGS
831 CPPFLAGS
832 ac_ct_CC
833 EXEEXT
834 OBJEXT
835 DEPDIR
836 am__include
837 am__quote
838 AMDEP_TRUE
839 AMDEP_FALSE
840 AMDEPBACKSLASH
841 CCDEPMODE
842 am__fastdepCC_TRUE
843 am__fastdepCC_FALSE
844 LIBTOOL
845 build
846 build_cpu
847 build_vendor
848 build_os
849 host
850 host_cpu
851 host_vendor
852 host_os
853 SED
854 GREP
855 EGREP
856 FGREP
857 LD
858 DUMPBIN
859 ac_ct_DUMPBIN
860 NM
861 LN_S
862 AR
863 RANLIB
864 lt_ECHO
865 DSYMUTIL
866 NMEDIT
867 LIPO
868 OTOOL
869 OTOOL64
870 CPP
871 acx_pthread_config
872 PTHREAD_CC
873 PTHREAD_LIBS
874 PTHREAD_CFLAGS
875 ALLOCA
876 LIBOBJS
877 CXX
878 CXXFLAGS
879 ac_ct_CXX
880 CXXDEPMODE
881 am__fastdepCXX_TRUE
882 am__fastdepCXX_FALSE
883 CXXCPP
884 CURL_CONFIG
885 S3_BIN
886 MAYBE_S3_TRUE
887 MAYBE_S3_FALSE
888 MAYBE_QEMU_TRUE
889 MAYBE_QEMU_FALSE
890 PYTHON
891 PYTHON_VERSION
892 PYTHON_PREFIX
893 PYTHON_EXEC_PREFIX
894 PYTHON_PLATFORM
895 pythondir
896 pkgpythondir
897 pyexecdir
898 pkgpyexecdir
899 PYTHON_CPPFLAGS
900 PYTHON_LDFLAGS
901 PYTHON_SITE_PKG
902 PYTHON_EXTRA_LIBS
903 PYTHON_EXTRA_LDFLAGS
904 HAVE_PYTHON_TRUE
905 HAVE_PYTHON_FALSE
906 FUSE_LIBS
907 FUSE_CFLAGS
908 AFFUSE_BIN
909 THREADING_TRUE
910 THREADING_FALSE
911 LTLIBOBJS'
912 ac_subst_files=''
913 ac_precious_vars='build_alias
914 host_alias
915 target_alias
916 CC
917 CFLAGS
918 LDFLAGS
919 LIBS
920 CPPFLAGS
921 CPP
922 CXX
923 CXXFLAGS
924 CCC
925 CXXCPP
926 PYTHON_VERSION'
927
928
929 # Initialize some variables set by options.
930 ac_init_help=
931 ac_init_version=false
932 # The variables have the same names as the options, with
933 # dashes changed to underlines.
934 cache_file=/dev/null
935 exec_prefix=NONE
936 no_create=
937 no_recursion=
938 prefix=NONE
939 program_prefix=NONE
940 program_suffix=NONE
941 program_transform_name=s,x,x,
942 silent=
943 site=
944 srcdir=
945 verbose=
946 x_includes=NONE
947 x_libraries=NONE
948
949 # Installation directory options.
950 # These are left unexpanded so users can "make install exec_prefix=/foo"
951 # and all the variables that are supposed to be based on exec_prefix
952 # by default will actually change.
953 # Use braces instead of parens because sh, perl, etc. also accept them.
954 # (The list follows the same order as the GNU Coding Standards.)
955 bindir='${exec_prefix}/bin'
956 sbindir='${exec_prefix}/sbin'
957 libexecdir='${exec_prefix}/libexec'
958 datarootdir='${prefix}/share'
959 datadir='${datarootdir}'
960 sysconfdir='${prefix}/etc'
961 sharedstatedir='${prefix}/com'
962 localstatedir='${prefix}/var'
963 includedir='${prefix}/include'
964 oldincludedir='/usr/include'
965 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
966 infodir='${datarootdir}/info'
967 htmldir='${docdir}'
968 dvidir='${docdir}'
969 pdfdir='${docdir}'
970 psdir='${docdir}'
971 libdir='${exec_prefix}/lib'
972 localedir='${datarootdir}/locale'
973 mandir='${datarootdir}/man'
974
975 ac_prev=
976 ac_dashdash=
977 for ac_option
978 do
979 # If the previous option needs an argument, assign it.
980 if test -n "$ac_prev"; then
981 eval $ac_prev=\$ac_option
982 ac_prev=
983 continue
984 fi
985
986 case $ac_option in
987 *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
988 *) ac_optarg=yes ;;
989 esac
990
991 # Accept the important Cygnus configure options, so we can diagnose typos.
992
993 case $ac_dashdash$ac_option in
994 --)
995 ac_dashdash=yes ;;
996
997 -bindir | --bindir | --bindi | --bind | --bin | --bi)
998 ac_prev=bindir ;;
999 -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
1000 bindir=$ac_optarg ;;
1001
1002 -build | --build | --buil | --bui | --bu)
1003 ac_prev=build_alias ;;
1004 -build=* | --build=* | --buil=* | --bui=* | --bu=*)
1005 build_alias=$ac_optarg ;;
1006
1007 -cache-file | --cache-file | --cache-fil | --cache-fi \
1008 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
1009 ac_prev=cache_file ;;
1010 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
1011 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
1012 cache_file=$ac_optarg ;;
1013
1014 --config-cache | -C)
1015 cache_file=config.cache ;;
1016
1017 -datadir | --datadir | --datadi | --datad)
1018 ac_prev=datadir ;;
1019 -datadir=* | --datadir=* | --datadi=* | --datad=*)
1020 datadir=$ac_optarg ;;
1021
1022 -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
1023 | --dataroo | --dataro | --datar)
1024 ac_prev=datarootdir ;;
1025 -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
1026 | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
1027 datarootdir=$ac_optarg ;;
1028
1029 -disable-* | --disable-*)
1030 ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
1031 # Reject names that are not valid shell variable names.
1032 expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
1033 { echo "$as_me: error: invalid feature name: $ac_feature" >&2
1034 { (exit 1); exit 1; }; }
1035 ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
1036 eval enable_$ac_feature=no ;;
1037
1038 -docdir | --docdir | --docdi | --doc | --do)
1039 ac_prev=docdir ;;
1040 -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
1041 docdir=$ac_optarg ;;
1042
1043 -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
1044 ac_prev=dvidir ;;
1045 -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
1046 dvidir=$ac_optarg ;;
1047
1048 -enable-* | --enable-*)
1049 ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
1050 # Reject names that are not valid shell variable names.
1051 expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&
1052 { echo "$as_me: error: invalid feature name: $ac_feature" >&2
1053 { (exit 1); exit 1; }; }
1054 ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`
1055 eval enable_$ac_feature=\$ac_optarg ;;
1056
1057 -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
1058 | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
1059 | --exec | --exe | --ex)
1060 ac_prev=exec_prefix ;;
1061 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
1062 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
1063 | --exec=* | --exe=* | --ex=*)
1064 exec_prefix=$ac_optarg ;;
1065
1066 -gas | --gas | --ga | --g)
1067 # Obsolete; use --with-gas.
1068 with_gas=yes ;;
1069
1070 -help | --help | --hel | --he | -h)
1071 ac_init_help=long ;;
1072 -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
1073 ac_init_help=recursive ;;
1074 -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
1075 ac_init_help=short ;;
1076
1077 -host | --host | --hos | --ho)
1078 ac_prev=host_alias ;;
1079 -host=* | --host=* | --hos=* | --ho=*)
1080 host_alias=$ac_optarg ;;
1081
1082 -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
1083 ac_prev=htmldir ;;
1084 -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
1085 | --ht=*)
1086 htmldir=$ac_optarg ;;
1087
1088 -includedir | --includedir | --includedi | --included | --include \
1089 | --includ | --inclu | --incl | --inc)
1090 ac_prev=includedir ;;
1091 -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
1092 | --includ=* | --inclu=* | --incl=* | --inc=*)
1093 includedir=$ac_optarg ;;
1094
1095 -infodir | --infodir | --infodi | --infod | --info | --inf)
1096 ac_prev=infodir ;;
1097 -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
1098 infodir=$ac_optarg ;;
1099
1100 -libdir | --libdir | --libdi | --libd)
1101 ac_prev=libdir ;;
1102 -libdir=* | --libdir=* | --libdi=* | --libd=*)
1103 libdir=$ac_optarg ;;
1104
1105 -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
1106 | --libexe | --libex | --libe)
1107 ac_prev=libexecdir ;;
1108 -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
1109 | --libexe=* | --libex=* | --libe=*)
1110 libexecdir=$ac_optarg ;;
1111
1112 -localedir | --localedir | --localedi | --localed | --locale)
1113 ac_prev=localedir ;;
1114 -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
1115 localedir=$ac_optarg ;;
1116
1117 -localstatedir | --localstatedir | --localstatedi | --localstated \
1118 | --localstate | --localstat | --localsta | --localst | --locals)
1119 ac_prev=localstatedir ;;
1120 -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
1121 | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
1122 localstatedir=$ac_optarg ;;
1123
1124 -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
1125 ac_prev=mandir ;;
1126 -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
1127 mandir=$ac_optarg ;;
1128
1129 -nfp | --nfp | --nf)
1130 # Obsolete; use --without-fp.
1131 with_fp=no ;;
1132
1133 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
1134 | --no-cr | --no-c | -n)
1135 no_create=yes ;;
1136
1137 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
1138 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
1139 no_recursion=yes ;;
1140
1141 -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
1142 | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
1143 | --oldin | --oldi | --old | --ol | --o)
1144 ac_prev=oldincludedir ;;
1145 -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
1146 | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
1147 | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
1148 oldincludedir=$ac_optarg ;;
1149
1150 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
1151 ac_prev=prefix ;;
1152 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
1153 prefix=$ac_optarg ;;
1154
1155 -program-prefix | --program-prefix | --program-prefi | --program-pref \
1156 | --program-pre | --program-pr | --program-p)
1157 ac_prev=program_prefix ;;
1158 -program-prefix=* | --program-prefix=* | --program-prefi=* \
1159 | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
1160 program_prefix=$ac_optarg ;;
1161
1162 -program-suffix | --program-suffix | --program-suffi | --program-suff \
1163 | --program-suf | --program-su | --program-s)
1164 ac_prev=program_suffix ;;
1165 -program-suffix=* | --program-suffix=* | --program-suffi=* \
1166 | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
1167 program_suffix=$ac_optarg ;;
1168
1169 -program-transform-name | --program-transform-name \
1170 | --program-transform-nam | --program-transform-na \
1171 | --program-transform-n | --program-transform- \
1172 | --program-transform | --program-transfor \
1173 | --program-transfo | --program-transf \
1174 | --program-trans | --program-tran \
1175 | --progr-tra | --program-tr | --program-t)
1176 ac_prev=program_transform_name ;;
1177 -program-transform-name=* | --program-transform-name=* \
1178 | --program-transform-nam=* | --program-transform-na=* \
1179 | --program-transform-n=* | --program-transform-=* \
1180 | --program-transform=* | --program-transfor=* \
1181 | --program-transfo=* | --program-transf=* \
1182 | --program-trans=* | --program-tran=* \
1183 | --progr-tra=* | --program-tr=* | --program-t=*)
1184 program_transform_name=$ac_optarg ;;
1185
1186 -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
1187 ac_prev=pdfdir ;;
1188 -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
1189 pdfdir=$ac_optarg ;;
1190
1191 -psdir | --psdir | --psdi | --psd | --ps)
1192 ac_prev=psdir ;;
1193 -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
1194 psdir=$ac_optarg ;;
1195
1196 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
1197 | -silent | --silent | --silen | --sile | --sil)
1198 silent=yes ;;
1199
1200 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
1201 ac_prev=sbindir ;;
1202 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
1203 | --sbi=* | --sb=*)
1204 sbindir=$ac_optarg ;;
1205
1206 -sharedstatedir | --sharedstatedir | --sharedstatedi \
1207 | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
1208 | --sharedst | --shareds | --shared | --share | --shar \
1209 | --sha | --sh)
1210 ac_prev=sharedstatedir ;;
1211 -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
1212 | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
1213 | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
1214 | --sha=* | --sh=*)
1215 sharedstatedir=$ac_optarg ;;
1216
1217 -site | --site | --sit)
1218 ac_prev=site ;;
1219 -site=* | --site=* | --sit=*)
1220 site=$ac_optarg ;;
1221
1222 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
1223 ac_prev=srcdir ;;
1224 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
1225 srcdir=$ac_optarg ;;
1226
1227 -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
1228 | --syscon | --sysco | --sysc | --sys | --sy)
1229 ac_prev=sysconfdir ;;
1230 -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
1231 | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
1232 sysconfdir=$ac_optarg ;;
1233
1234 -target | --target | --targe | --targ | --tar | --ta | --t)
1235 ac_prev=target_alias ;;
1236 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
1237 target_alias=$ac_optarg ;;
1238
1239 -v | -verbose | --verbose | --verbos | --verbo | --verb)
1240 verbose=yes ;;
1241
1242 -version | --version | --versio | --versi | --vers | -V)
1243 ac_init_version=: ;;
1244
1245 -with-* | --with-*)
1246 ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
1247 # Reject names that are not valid shell variable names.
1248 expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
1249 { echo "$as_me: error: invalid package name: $ac_package" >&2
1250 { (exit 1); exit 1; }; }
1251 ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
1252 eval with_$ac_package=\$ac_optarg ;;
1253
1254 -without-* | --without-*)
1255 ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
1256 # Reject names that are not valid shell variable names.
1257 expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&
1258 { echo "$as_me: error: invalid package name: $ac_package" >&2
1259 { (exit 1); exit 1; }; }
1260 ac_package=`echo $ac_package | sed 's/[-.]/_/g'`
1261 eval with_$ac_package=no ;;
1262
1263 --x)
1264 # Obsolete; use --with-x.
1265 with_x=yes ;;
1266
1267 -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
1268 | --x-incl | --x-inc | --x-in | --x-i)
1269 ac_prev=x_includes ;;
1270 -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
1271 | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
1272 x_includes=$ac_optarg ;;
1273
1274 -x-libraries | --x-libraries | --x-librarie | --x-librari \
1275 | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
1276 ac_prev=x_libraries ;;
1277 -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
1278 | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
1279 x_libraries=$ac_optarg ;;
1280
1281 -*) { echo "$as_me: error: unrecognized option: $ac_option
1282 Try \`$0 --help' for more information." >&2
1283 { (exit 1); exit 1; }; }
1284 ;;
1285
1286 *=*)
1287 ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
1288 # Reject names that are not valid shell variable names.
1289 expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
1290 { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
1291 { (exit 1); exit 1; }; }
1292 eval $ac_envvar=\$ac_optarg
1293 export $ac_envvar ;;
1294
1295 *)
1296 # FIXME: should be removed in autoconf 3.0.
1297 echo "$as_me: WARNING: you should use --build, --host, --target" >&2
1298 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
1299 echo "$as_me: WARNING: invalid host type: $ac_option" >&2
1300 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
1301 ;;
1302
1303 esac
1304 done
1305
1306 if test -n "$ac_prev"; then
1307 ac_option=--`echo $ac_prev | sed 's/_/-/g'`
1308 { echo "$as_me: error: missing argument to $ac_option" >&2
1309 { (exit 1); exit 1; }; }
1310 fi
1311
1312 # Be sure to have absolute directory names.
1313 for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
1314 datadir sysconfdir sharedstatedir localstatedir includedir \
1315 oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
1316 libdir localedir mandir
1317 do
1318 eval ac_val=\$$ac_var
1319 case $ac_val in
1320 [\\/$]* | ?:[\\/]* ) continue;;
1321 NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
1322 esac
1323 { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
1324 { (exit 1); exit 1; }; }
1325 done
1326
1327 # There might be people who depend on the old broken behavior: `$host'
1328 # used to hold the argument of --host etc.
1329 # FIXME: To remove some day.
1330 build=$build_alias
1331 host=$host_alias
1332 target=$target_alias
1333
1334 # FIXME: To remove some day.
1335 if test "x$host_alias" != x; then
1336 if test "x$build_alias" = x; then
1337 cross_compiling=maybe
1338 echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
1339 If a cross compiler is detected then cross compile mode will be used." >&2
1340 elif test "x$build_alias" != "x$host_alias"; then
1341 cross_compiling=yes
1342 fi
1343 fi
1344
1345 ac_tool_prefix=
1346 test -n "$host_alias" && ac_tool_prefix=$host_alias-
1347
1348 test "$silent" = yes && exec 6>/dev/null
1349
1350
1351 ac_pwd=`pwd` && test -n "$ac_pwd" &&
1352 ac_ls_di=`ls -di .` &&
1353 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
1354 { echo "$as_me: error: Working directory cannot be determined" >&2
1355 { (exit 1); exit 1; }; }
1356 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
1357 { echo "$as_me: error: pwd does not report name of working directory" >&2
1358 { (exit 1); exit 1; }; }
1359
1360
1361 # Find the source files, if location was not specified.
1362 if test -z "$srcdir"; then
1363 ac_srcdir_defaulted=yes
1364 # Try the directory containing this script, then the parent directory.
1365 ac_confdir=`$as_dirname -- "$0" ||
1366 $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1367 X"$0" : 'X\(//\)[^/]' \| \
1368 X"$0" : 'X\(//\)$' \| \
1369 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
1370 echo X"$0" |
1371 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
1372 s//\1/
1373 q
1374 }
1375 /^X\(\/\/\)[^/].*/{
1376 s//\1/
1377 q
1378 }
1379 /^X\(\/\/\)$/{
1380 s//\1/
1381 q
1382 }
1383 /^X\(\/\).*/{
1384 s//\1/
1385 q
1386 }
1387 s/.*/./; q'`
1388 srcdir=$ac_confdir
1389 if test ! -r "$srcdir/$ac_unique_file"; then
1390 srcdir=..
1391 fi
1392 else
1393 ac_srcdir_defaulted=no
1394 fi
1395 if test ! -r "$srcdir/$ac_unique_file"; then
1396 test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
1397 { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
1398 { (exit 1); exit 1; }; }
1399 fi
1400 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
1401 ac_abs_confdir=`(
1402 cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2
1403 { (exit 1); exit 1; }; }
1404 pwd)`
1405 # When building in place, set srcdir=.
1406 if test "$ac_abs_confdir" = "$ac_pwd"; then
1407 srcdir=.
1408 fi
1409 # Remove unnecessary trailing slashes from srcdir.
1410 # Double slashes in file names in object file debugging info
1411 # mess up M-x gdb in Emacs.
1412 case $srcdir in
1413 */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
1414 esac
1415 for ac_var in $ac_precious_vars; do
1416 eval ac_env_${ac_var}_set=\${${ac_var}+set}
1417 eval ac_env_${ac_var}_value=\$${ac_var}
1418 eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
1419 eval ac_cv_env_${ac_var}_value=\$${ac_var}
1420 done
1421
1422 #
1423 # Report the --help message.
1424 #
1425 if test "$ac_init_help" = "long"; then
1426 # Omit some internal or obsolete options to make the list less imposing.
1427 # This message is too long to be a string in the A/UX 3.1 sh.
1428 cat <<_ACEOF
1429 \`configure' configures AFFLIB 3.5.10 to adapt to many kinds of systems.
1430
1431 Usage: $0 [OPTION]... [VAR=VALUE]...
1432
1433 To assign environment variables (e.g., CC, CFLAGS...), specify them as
1434 VAR=VALUE. See below for descriptions of some of the useful variables.
1435
1436 Defaults for the options are specified in brackets.
1437
1438 Configuration:
1439 -h, --help display this help and exit
1440 --help=short display options specific to this package
1441 --help=recursive display the short help of all the included packages
1442 -V, --version display version information and exit
1443 -q, --quiet, --silent do not print \`checking...' messages
1444 --cache-file=FILE cache test results in FILE [disabled]
1445 -C, --config-cache alias for \`--cache-file=config.cache'
1446 -n, --no-create do not create output files
1447 --srcdir=DIR find the sources in DIR [configure dir or \`..']
1448
1449 Installation directories:
1450 --prefix=PREFIX install architecture-independent files in PREFIX
1451 [$ac_default_prefix]
1452 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
1453 [PREFIX]
1454
1455 By default, \`make install' will install all the files in
1456 \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
1457 an installation prefix other than \`$ac_default_prefix' using \`--prefix',
1458 for instance \`--prefix=\$HOME'.
1459
1460 For better control, use the options below.
1461
1462 Fine tuning of the installation directories:
1463 --bindir=DIR user executables [EPREFIX/bin]
1464 --sbindir=DIR system admin executables [EPREFIX/sbin]
1465 --libexecdir=DIR program executables [EPREFIX/libexec]
1466 --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
1467 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
1468 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
1469 --libdir=DIR object code libraries [EPREFIX/lib]
1470 --includedir=DIR C header files [PREFIX/include]
1471 --oldincludedir=DIR C header files for non-gcc [/usr/include]
1472 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
1473 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
1474 --infodir=DIR info documentation [DATAROOTDIR/info]
1475 --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
1476 --mandir=DIR man documentation [DATAROOTDIR/man]
1477 --docdir=DIR documentation root [DATAROOTDIR/doc/afflib]
1478 --htmldir=DIR html documentation [DOCDIR]
1479 --dvidir=DIR dvi documentation [DOCDIR]
1480 --pdfdir=DIR pdf documentation [DOCDIR]
1481 --psdir=DIR ps documentation [DOCDIR]
1482 _ACEOF
1483
1484 cat <<\_ACEOF
1485
1486 Program names:
1487 --program-prefix=PREFIX prepend PREFIX to installed program names
1488 --program-suffix=SUFFIX append SUFFIX to installed program names
1489 --program-transform-name=PROGRAM run sed PROGRAM on installed program names
1490
1491 System types:
1492 --build=BUILD configure for building on BUILD [guessed]
1493 --host=HOST cross-compile to build programs to run on HOST [BUILD]
1494 _ACEOF
1495 fi
1496
1497 if test -n "$ac_init_help"; then
1498 case $ac_init_help in
1499 short | recursive ) echo "Configuration of AFFLIB 3.5.10:";;
1500 esac
1501 cat <<\_ACEOF
1502
1503 Optional Features:
1504 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
1505 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
1506 --enable-maintainer-mode enable make rules and dependencies not useful
1507 (and sometimes confusing) to the casual installer
1508 --disable-dependency-tracking speeds up one-time build
1509 --enable-dependency-tracking do not reject slow dependency extractors
1510 --enable-shared[=PKGS] build shared libraries [default=yes]
1511 --enable-static[=PKGS] build static libraries [default=yes]
1512 --enable-fast-install[=PKGS]
1513 optimize for fast installation [default=yes]
1514 --disable-libtool-lock avoid locking (might break parallel builds)
1515 --disable-largefile omit support for large files
1516 --enable-libewf=yes Use libewf for reading EnCase files(default yes)
1517 --enable-s3=yes Support for Amazon's S3 service. Requires CURL and
1518 Expat.
1519
1520 --enable-python=no Build python bindings (pyaff)
1521 --enable-fuse=yes Support for FUSE, Filesystem in Userspace. (default
1522 yes)
1523 --disable-threading builds library without threading
1524 --enable-threading use threading if available
1525
1526 Optional Packages:
1527 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
1528 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
1529 --with-pic try to use only PIC/non-PIC objects [default=use
1530 both]
1531 --with-gnu-ld assume the C compiler uses GNU ld [default=no]
1532 --with-noopt Drop -O C flags
1533 --with-expat=PATH where libexpat is compiled (if it isn't installed);
1534 required for S3 and Digital Signatures
1535 --with-curl=PATH where libcurl is installed; required for S3
1536
1537 Some influential environment variables:
1538 CC C compiler command
1539 CFLAGS C compiler flags
1540 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
1541 nonstandard directory <lib dir>
1542 LIBS libraries to pass to the linker, e.g. -l<library>
1543 CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
1544 you have headers in a nonstandard directory <include dir>
1545 CPP C preprocessor
1546 CXX C++ compiler command
1547 CXXFLAGS C++ compiler flags
1548 CXXCPP C++ preprocessor
1549 PYTHON_VERSION
1550 The installed Python version to use, for example '2.3'. This
1551 string will be appended to the Python interpreter canonical
1552 name.
1553
1554 Use these variables to override the choices made by `configure' or to help
1555 it to find libraries and programs with nonstandard names/locations.
1556
1557 Report bugs to <bugs@afflib.org>.
1558 _ACEOF
1559 ac_status=$?
1560 fi
1561
1562 if test "$ac_init_help" = "recursive"; then
1563 # If there are subdirs, report their specific --help.
1564 for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
1565 test -d "$ac_dir" || continue
1566 ac_builddir=.
1567
1568 case "$ac_dir" in
1569 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
1570 *)
1571 ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
1572 # A ".." for each directory in $ac_dir_suffix.
1573 ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
1574 case $ac_top_builddir_sub in
1575 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
1576 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
1577 esac ;;
1578 esac
1579 ac_abs_top_builddir=$ac_pwd
1580 ac_abs_builddir=$ac_pwd$ac_dir_suffix
1581 # for backward compatibility:
1582 ac_top_builddir=$ac_top_build_prefix
1583
1584 case $srcdir in
1585 .) # We are building in place.
1586 ac_srcdir=.
1587 ac_top_srcdir=$ac_top_builddir_sub
1588 ac_abs_top_srcdir=$ac_pwd ;;
1589 [\\/]* | ?:[\\/]* ) # Absolute name.
1590 ac_srcdir=$srcdir$ac_dir_suffix;
1591 ac_top_srcdir=$srcdir
1592 ac_abs_top_srcdir=$srcdir ;;
1593 *) # Relative name.
1594 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
1595 ac_top_srcdir=$ac_top_build_prefix$srcdir
1596 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
1597 esac
1598 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
1599
1600 cd "$ac_dir" || { ac_status=$?; continue; }
1601 # Check for guested configure.
1602 if test -f "$ac_srcdir/configure.gnu"; then
1603 echo &&
1604 $SHELL "$ac_srcdir/configure.gnu" --help=recursive
1605 elif test -f "$ac_srcdir/configure"; then
1606 echo &&
1607 $SHELL "$ac_srcdir/configure" --help=recursive
1608 else
1609 echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
1610 fi || ac_status=$?
1611 cd "$ac_pwd" || { ac_status=$?; break; }
1612 done
1613 fi
1614
1615 test -n "$ac_init_help" && exit $ac_status
1616 if $ac_init_version; then
1617 cat <<\_ACEOF
1618 AFFLIB configure 3.5.10
1619 generated by GNU Autoconf 2.61
1620
1621 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
1622 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
1623 This configure script is free software; the Free Software Foundation
1624 gives unlimited permission to copy, distribute and modify it.
1625 _ACEOF
1626 exit
1627 fi
1628 cat >config.log <<_ACEOF
1629 This file contains any messages produced by compilers while
1630 running configure, to aid debugging if configure makes a mistake.
1631
1632 It was created by AFFLIB $as_me 3.5.10, which was
1633 generated by GNU Autoconf 2.61. Invocation command line was
1634
1635 $ $0 $@
1636
1637 _ACEOF
1638 exec 5>>config.log
1639 {
1640 cat <<_ASUNAME
1641 ## --------- ##
1642 ## Platform. ##
1643 ## --------- ##
1644
1645 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1646 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1647 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1648 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1649 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1650
1651 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1652 /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
1653
1654 /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
1655 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
1656 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1657 /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
1658 /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
1659 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
1660 /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
1661
1662 _ASUNAME
1663
1664 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1665 for as_dir in $PATH
1666 do
1667 IFS=$as_save_IFS
1668 test -z "$as_dir" && as_dir=.
1669 echo "PATH: $as_dir"
1670 done
1671 IFS=$as_save_IFS
1672
1673 } >&5
1674
1675 cat >&5 <<_ACEOF
1676
1677
1678 ## ----------- ##
1679 ## Core tests. ##
1680 ## ----------- ##
1681
1682 _ACEOF
1683
1684
1685 # Keep a trace of the command line.
1686 # Strip out --no-create and --no-recursion so they do not pile up.
1687 # Strip out --silent because we don't want to record it for future runs.
1688 # Also quote any args containing shell meta-characters.
1689 # Make two passes to allow for proper duplicate-argument suppression.
1690 ac_configure_args=
1691 ac_configure_args0=
1692 ac_configure_args1=
1693 ac_must_keep_next=false
1694 for ac_pass in 1 2
1695 do
1696 for ac_arg
1697 do
1698 case $ac_arg in
1699 -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
1700 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
1701 | -silent | --silent | --silen | --sile | --sil)
1702 continue ;;
1703 *\'*)
1704 ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
1705 esac
1706 case $ac_pass in
1707 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
1708 2)
1709 ac_configure_args1="$ac_configure_args1 '$ac_arg'"
1710 if test $ac_must_keep_next = true; then
1711 ac_must_keep_next=false # Got value, back to normal.
1712 else
1713 case $ac_arg in
1714 *=* | --config-cache | -C | -disable-* | --disable-* \
1715 | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
1716 | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
1717 | -with-* | --with-* | -without-* | --without-* | --x)
1718 case "$ac_configure_args0 " in
1719 "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
1720 esac
1721 ;;
1722 -* ) ac_must_keep_next=true ;;
1723 esac
1724 fi
1725 ac_configure_args="$ac_configure_args '$ac_arg'"
1726 ;;
1727 esac
1728 done
1729 done
1730 $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
1731 $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
1732
1733 # When interrupted or exit'd, cleanup temporary files, and complete
1734 # config.log. We remove comments because anyway the quotes in there
1735 # would cause problems or look ugly.
1736 # WARNING: Use '\'' to represent an apostrophe within the trap.
1737 # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
1738 trap 'exit_status=$?
1739 # Save into config.log some information that might help in debugging.
1740 {
1741 echo
1742
1743 cat <<\_ASBOX
1744 ## ---------------- ##
1745 ## Cache variables. ##
1746 ## ---------------- ##
1747 _ASBOX
1748 echo
1749 # The following way of writing the cache mishandles newlines in values,
1750 (
1751 for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
1752 eval ac_val=\$$ac_var
1753 case $ac_val in #(
1754 *${as_nl}*)
1755 case $ac_var in #(
1756 *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
1757 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
1758 esac
1759 case $ac_var in #(
1760 _ | IFS | as_nl) ;; #(
1761 *) $as_unset $ac_var ;;
1762 esac ;;
1763 esac
1764 done
1765 (set) 2>&1 |
1766 case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
1767 *${as_nl}ac_space=\ *)
1768 sed -n \
1769 "s/'\''/'\''\\\\'\'''\''/g;
1770 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
1771 ;; #(
1772 *)
1773 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
1774 ;;
1775 esac |
1776 sort
1777 )
1778 echo
1779
1780 cat <<\_ASBOX
1781 ## ----------------- ##
1782 ## Output variables. ##
1783 ## ----------------- ##
1784 _ASBOX
1785 echo
1786 for ac_var in $ac_subst_vars
1787 do
1788 eval ac_val=\$$ac_var
1789 case $ac_val in
1790 *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
1791 esac
1792 echo "$ac_var='\''$ac_val'\''"
1793 done | sort
1794 echo
1795
1796 if test -n "$ac_subst_files"; then
1797 cat <<\_ASBOX
1798 ## ------------------- ##
1799 ## File substitutions. ##
1800 ## ------------------- ##
1801 _ASBOX
1802 echo
1803 for ac_var in $ac_subst_files
1804 do
1805 eval ac_val=\$$ac_var
1806 case $ac_val in
1807 *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
1808 esac
1809 echo "$ac_var='\''$ac_val'\''"
1810 done | sort
1811 echo
1812 fi
1813
1814 if test -s confdefs.h; then
1815 cat <<\_ASBOX
1816 ## ----------- ##
1817 ## confdefs.h. ##
1818 ## ----------- ##
1819 _ASBOX
1820 echo
1821 cat confdefs.h
1822 echo
1823 fi
1824 test "$ac_signal" != 0 &&
1825 echo "$as_me: caught signal $ac_signal"
1826 echo "$as_me: exit $exit_status"
1827 } >&5
1828 rm -f core *.core core.conftest.* &&
1829 rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
1830 exit $exit_status
1831 ' 0
1832 for ac_signal in 1 2 13 15; do
1833 trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
1834 done
1835 ac_signal=0
1836
1837 # confdefs.h avoids OS command line length limits that DEFS can exceed.
1838 rm -f -r conftest* confdefs.h
1839
1840 # Predefined preprocessor variables.
1841
1842 cat >>confdefs.h <<_ACEOF
1843 #define PACKAGE_NAME "$PACKAGE_NAME"
1844 _ACEOF
1845
1846
1847 cat >>confdefs.h <<_ACEOF
1848 #define PACKAGE_TARNAME "$PACKAGE_TARNAME"
1849 _ACEOF
1850
1851
1852 cat >>confdefs.h <<_ACEOF
1853 #define PACKAGE_VERSION "$PACKAGE_VERSION"
1854 _ACEOF
1855
1856
1857 cat >>confdefs.h <<_ACEOF
1858 #define PACKAGE_STRING "$PACKAGE_STRING"
1859 _ACEOF
1860
1861
1862 cat >>confdefs.h <<_ACEOF
1863 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
1864 _ACEOF
1865
1866
1867 # Let the site file select an alternate cache file if it wants to.
1868 # Prefer explicitly selected file to automatically selected ones.
1869 if test -n "$CONFIG_SITE"; then
1870 set x "$CONFIG_SITE"
1871 elif test "x$prefix" != xNONE; then
1872 set x "$prefix/share/config.site" "$prefix/etc/config.site"
1873 else
1874 set x "$ac_default_prefix/share/config.site" \
1875 "$ac_default_prefix/etc/config.site"
1876 fi
1877 shift
1878 for ac_site_file
1879 do
1880 if test -r "$ac_site_file"; then
1881 { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
1882 echo "$as_me: loading site script $ac_site_file" >&6;}
1883 sed 's/^/| /' "$ac_site_file" >&5
1884 . "$ac_site_file"
1885 fi
1886 done
1887
1888 if test -r "$cache_file"; then
1889 # Some versions of bash will fail to source /dev/null (special
1890 # files actually), so we avoid doing that.
1891 if test -f "$cache_file"; then
1892 { echo "$as_me:$LINENO: loading cache $cache_file" >&5
1893 echo "$as_me: loading cache $cache_file" >&6;}
1894 case $cache_file in
1895 [\\/]* | ?:[\\/]* ) . "$cache_file";;
1896 *) . "./$cache_file";;
1897 esac
1898 fi
1899 else
1900 { echo "$as_me:$LINENO: creating cache $cache_file" >&5
1901 echo "$as_me: creating cache $cache_file" >&6;}
1902 >$cache_file
1903 fi
1904
1905 # Check that the precious variables saved in the cache have kept the same
1906 # value.
1907 ac_cache_corrupted=false
1908 for ac_var in $ac_precious_vars; do
1909 eval ac_old_set=\$ac_cv_env_${ac_var}_set
1910 eval ac_new_set=\$ac_env_${ac_var}_set
1911 eval ac_old_val=\$ac_cv_env_${ac_var}_value
1912 eval ac_new_val=\$ac_env_${ac_var}_value
1913 case $ac_old_set,$ac_new_set in
1914 set,)
1915 { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
1916 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
1917 ac_cache_corrupted=: ;;
1918 ,set)
1919 { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
1920 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
1921 ac_cache_corrupted=: ;;
1922 ,);;
1923 *)
1924 if test "x$ac_old_val" != "x$ac_new_val"; then
1925 { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
1926 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
1927 { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
1928 echo "$as_me: former value: $ac_old_val" >&2;}
1929 { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
1930 echo "$as_me: current value: $ac_new_val" >&2;}
1931 ac_cache_corrupted=:
1932 fi;;
1933 esac
1934 # Pass precious variables to config.status.
1935 if test "$ac_new_set" = set; then
1936 case $ac_new_val in
1937 *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
1938 *) ac_arg=$ac_var=$ac_new_val ;;
1939 esac
1940 case " $ac_configure_args " in
1941 *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
1942 *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
1943 esac
1944 fi
1945 done
1946 if $ac_cache_corrupted; then
1947 { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
1948 echo "$as_me: error: changes in the environment can compromise the build" >&2;}
1949 { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
1950 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
1951 { (exit 1); exit 1; }; }
1952 fi
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978 ac_ext=c
1979 ac_cpp='$CPP $CPPFLAGS'
1980 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
1981 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
1982 ac_compiler_gnu=$ac_cv_c_compiler_gnu
1983
1984
1985 am__api_version='1.10'
1986
1987 ac_aux_dir=
1988 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
1989 if test -f "$ac_dir/install-sh"; then
1990 ac_aux_dir=$ac_dir
1991 ac_install_sh="$ac_aux_dir/install-sh -c"
1992 break
1993 elif test -f "$ac_dir/install.sh"; then
1994 ac_aux_dir=$ac_dir
1995 ac_install_sh="$ac_aux_dir/install.sh -c"
1996 break
1997 elif test -f "$ac_dir/shtool"; then
1998 ac_aux_dir=$ac_dir
1999 ac_install_sh="$ac_aux_dir/shtool install -c"
2000 break
2001 fi
2002 done
2003 if test -z "$ac_aux_dir"; then
2004 { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
2005 echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
2006 { (exit 1); exit 1; }; }
2007 fi
2008
2009 # These three variables are undocumented and unsupported,
2010 # and are intended to be withdrawn in a future Autoconf release.
2011 # They can cause serious problems if a builder's source tree is in a directory
2012 # whose full name contains unusual characters.
2013 ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
2014 ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
2015 ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
2016
2017
2018 # Find a good install program. We prefer a C program (faster),
2019 # so one script is as good as another. But avoid the broken or
2020 # incompatible versions:
2021 # SysV /etc/install, /usr/sbin/install
2022 # SunOS /usr/etc/install
2023 # IRIX /sbin/install
2024 # AIX /bin/install
2025 # AmigaOS /C/install, which installs bootblocks on floppy discs
2026 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
2027 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
2028 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
2029 # OS/2's system install, which has a completely different semantic
2030 # ./install, which can be erroneously created by make from ./install.sh.
2031 { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
2032 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
2033 if test -z "$INSTALL"; then
2034 if test "${ac_cv_path_install+set}" = set; then
2035 echo $ECHO_N "(cached) $ECHO_C" >&6
2036 else
2037 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2038 for as_dir in $PATH
2039 do
2040 IFS=$as_save_IFS
2041 test -z "$as_dir" && as_dir=.
2042 # Account for people who put trailing slashes in PATH elements.
2043 case $as_dir/ in
2044 ./ | .// | /cC/* | \
2045 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
2046 ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
2047 /usr/ucb/* ) ;;
2048 *)
2049 # OSF1 and SCO ODT 3.0 have their own names for install.
2050 # Don't use installbsd from OSF since it installs stuff as root
2051 # by default.
2052 for ac_prog in ginstall scoinst install; do
2053 for ac_exec_ext in '' $ac_executable_extensions; do
2054 if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
2055 if test $ac_prog = install &&
2056 grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
2057 # AIX install. It has an incompatible calling convention.
2058 :
2059 elif test $ac_prog = install &&
2060 grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
2061 # program-specific install script used by HP pwplus--don't use.
2062 :
2063 else
2064 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
2065 break 3
2066 fi
2067 fi
2068 done
2069 done
2070 ;;
2071 esac
2072 done
2073 IFS=$as_save_IFS
2074
2075
2076 fi
2077 if test "${ac_cv_path_install+set}" = set; then
2078 INSTALL=$ac_cv_path_install
2079 else
2080 # As a last resort, use the slow shell script. Don't cache a
2081 # value for INSTALL within a source directory, because that will
2082 # break other packages using the cache if that directory is
2083 # removed, or if the value is a relative name.
2084 INSTALL=$ac_install_sh
2085 fi
2086 fi
2087 { echo "$as_me:$LINENO: result: $INSTALL" >&5
2088 echo "${ECHO_T}$INSTALL" >&6; }
2089
2090 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
2091 # It thinks the first close brace ends the variable substitution.
2092 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
2093
2094 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
2095
2096 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
2097
2098 { echo "$as_me:$LINENO: checking whether build environment is sane" >&5
2099 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; }
2100 # Just in case
2101 sleep 1
2102 echo timestamp > conftest.file
2103 # Do `set' in a subshell so we don't clobber the current shell's
2104 # arguments. Must try -L first in case configure is actually a
2105 # symlink; some systems play weird games with the mod time of symlinks
2106 # (eg FreeBSD returns the mod time of the symlink's containing
2107 # directory).
2108 if (
2109 set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
2110 if test "$*" = "X"; then
2111 # -L didn't work.
2112 set X `ls -t $srcdir/configure conftest.file`
2113 fi
2114 rm -f conftest.file
2115 if test "$*" != "X $srcdir/configure conftest.file" \
2116 && test "$*" != "X conftest.file $srcdir/configure"; then
2117
2118 # If neither matched, then we have a broken ls. This can happen
2119 # if, for instance, CONFIG_SHELL is bash and it inherits a
2120 # broken ls alias from the environment. This has actually
2121 # happened. Such a system could not be considered "sane".
2122 { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken
2123 alias in your environment" >&5
2124 echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken
2125 alias in your environment" >&2;}
2126 { (exit 1); exit 1; }; }
2127 fi
2128
2129 test "$2" = conftest.file
2130 )
2131 then
2132 # Ok.
2133 :
2134 else
2135 { { echo "$as_me:$LINENO: error: newly created file is older than distributed files!
2136 Check your system clock" >&5
2137 echo "$as_me: error: newly created file is older than distributed files!
2138 Check your system clock" >&2;}
2139 { (exit 1); exit 1; }; }
2140 fi
2141 { echo "$as_me:$LINENO: result: yes" >&5
2142 echo "${ECHO_T}yes" >&6; }
2143 test "$program_prefix" != NONE &&
2144 program_transform_name="s&^&$program_prefix&;$program_transform_name"
2145 # Use a double $ so make ignores it.
2146 test "$program_suffix" != NONE &&
2147 program_transform_name="s&\$&$program_suffix&;$program_transform_name"
2148 # Double any \ or $. echo might interpret backslashes.
2149 # By default was `s,x,x', remove it if useless.
2150 cat <<\_ACEOF >conftest.sed
2151 s/[\\$]/&&/g;s/;s,x,x,$//
2152 _ACEOF
2153 program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
2154 rm -f conftest.sed
2155
2156 # expand $ac_aux_dir to an absolute path
2157 am_aux_dir=`cd $ac_aux_dir && pwd`
2158
2159 test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
2160 # Use eval to expand $SHELL
2161 if eval "$MISSING --run true"; then
2162 am_missing_run="$MISSING --run "
2163 else
2164 am_missing_run=
2165 { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5
2166 echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
2167 fi
2168
2169 { echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
2170 echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; }
2171 if test -z "$MKDIR_P"; then
2172 if test "${ac_cv_path_mkdir+set}" = set; then
2173 echo $ECHO_N "(cached) $ECHO_C" >&6
2174 else
2175 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2176 for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
2177 do
2178 IFS=$as_save_IFS
2179 test -z "$as_dir" && as_dir=.
2180 for ac_prog in mkdir gmkdir; do
2181 for ac_exec_ext in '' $ac_executable_extensions; do
2182 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
2183 case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
2184 'mkdir (GNU coreutils) '* | \
2185 'mkdir (coreutils) '* | \
2186 'mkdir (fileutils) '4.1*)
2187 ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
2188 break 3;;
2189 esac
2190 done
2191 done
2192 done
2193 IFS=$as_save_IFS
2194
2195 fi
2196
2197 if test "${ac_cv_path_mkdir+set}" = set; then
2198 MKDIR_P="$ac_cv_path_mkdir -p"
2199 else
2200 # As a last resort, use the slow shell script. Don't cache a
2201 # value for MKDIR_P within a source directory, because that will
2202 # break other packages using the cache if that directory is
2203 # removed, or if the value is a relative name.
2204 test -d ./--version && rmdir ./--version
2205 MKDIR_P="$ac_install_sh -d"
2206 fi
2207 fi
2208 { echo "$as_me:$LINENO: result: $MKDIR_P" >&5
2209 echo "${ECHO_T}$MKDIR_P" >&6; }
2210
2211 mkdir_p="$MKDIR_P"
2212 case $mkdir_p in
2213 [\\/$]* | ?:[\\/]*) ;;
2214 */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
2215 esac
2216
2217 for ac_prog in gawk mawk nawk awk
2218 do
2219 # Extract the first word of "$ac_prog", so it can be a program name with args.
2220 set dummy $ac_prog; ac_word=$2
2221 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2222 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2223 if test "${ac_cv_prog_AWK+set}" = set; then
2224 echo $ECHO_N "(cached) $ECHO_C" >&6
2225 else
2226 if test -n "$AWK"; then
2227 ac_cv_prog_AWK="$AWK" # Let the user override the test.
2228 else
2229 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2230 for as_dir in $PATH
2231 do
2232 IFS=$as_save_IFS
2233 test -z "$as_dir" && as_dir=.
2234 for ac_exec_ext in '' $ac_executable_extensions; do
2235 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2236 ac_cv_prog_AWK="$ac_prog"
2237 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2238 break 2
2239 fi
2240 done
2241 done
2242 IFS=$as_save_IFS
2243
2244 fi
2245 fi
2246 AWK=$ac_cv_prog_AWK
2247 if test -n "$AWK"; then
2248 { echo "$as_me:$LINENO: result: $AWK" >&5
2249 echo "${ECHO_T}$AWK" >&6; }
2250 else
2251 { echo "$as_me:$LINENO: result: no" >&5
2252 echo "${ECHO_T}no" >&6; }
2253 fi
2254
2255
2256 test -n "$AWK" && break
2257 done
2258
2259 { echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
2260 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; }
2261 set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
2262 if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then
2263 echo $ECHO_N "(cached) $ECHO_C" >&6
2264 else
2265 cat >conftest.make <<\_ACEOF
2266 SHELL = /bin/sh
2267 all:
2268 @echo '@@@%%%=$(MAKE)=@@@%%%'
2269 _ACEOF
2270 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
2271 case `${MAKE-make} -f conftest.make 2>/dev/null` in
2272 *@@@%%%=?*=@@@%%%*)
2273 eval ac_cv_prog_make_${ac_make}_set=yes;;
2274 *)
2275 eval ac_cv_prog_make_${ac_make}_set=no;;
2276 esac
2277 rm -f conftest.make
2278 fi
2279 if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
2280 { echo "$as_me:$LINENO: result: yes" >&5
2281 echo "${ECHO_T}yes" >&6; }
2282 SET_MAKE=
2283 else
2284 { echo "$as_me:$LINENO: result: no" >&5
2285 echo "${ECHO_T}no" >&6; }
2286 SET_MAKE="MAKE=${MAKE-make}"
2287 fi
2288
2289 rm -rf .tst 2>/dev/null
2290 mkdir .tst 2>/dev/null
2291 if test -d .tst; then
2292 am__leading_dot=.
2293 else
2294 am__leading_dot=_
2295 fi
2296 rmdir .tst 2>/dev/null
2297
2298 if test "`cd $srcdir && pwd`" != "`pwd`"; then
2299 # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
2300 # is not polluted with repeated "-I."
2301 am__isrc=' -I$(srcdir)'
2302 # test to see if srcdir already configured
2303 if test -f $srcdir/config.status; then
2304 { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5
2305 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;}
2306 { (exit 1); exit 1; }; }
2307 fi
2308 fi
2309
2310 # test whether we have cygpath
2311 if test -z "$CYGPATH_W"; then
2312 if (cygpath --version) >/dev/null 2>/dev/null; then
2313 CYGPATH_W='cygpath -w'
2314 else
2315 CYGPATH_W=echo
2316 fi
2317 fi
2318
2319
2320 # Define the identity of the package.
2321 PACKAGE='afflib'
2322 VERSION='3.5.10'
2323
2324
2325 cat >>confdefs.h <<_ACEOF
2326 #define PACKAGE "$PACKAGE"
2327 _ACEOF
2328
2329
2330 cat >>confdefs.h <<_ACEOF
2331 #define VERSION "$VERSION"
2332 _ACEOF
2333
2334 # Some tools Automake needs.
2335
2336 ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
2337
2338
2339 AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
2340
2341
2342 AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
2343
2344
2345 AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
2346
2347
2348 MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
2349
2350 install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
2351
2352 # Installed binaries are usually stripped using `strip' when the user
2353 # run `make install-strip'. However `strip' might not be the right
2354 # tool to use in cross-compilation environments, therefore Automake
2355 # will honor the `STRIP' environment variable to overrule this program.
2356 if test "$cross_compiling" != no; then
2357 if test -n "$ac_tool_prefix"; then
2358 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
2359 set dummy ${ac_tool_prefix}strip; ac_word=$2
2360 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2361 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2362 if test "${ac_cv_prog_STRIP+set}" = set; then
2363 echo $ECHO_N "(cached) $ECHO_C" >&6
2364 else
2365 if test -n "$STRIP"; then
2366 ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
2367 else
2368 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2369 for as_dir in $PATH
2370 do
2371 IFS=$as_save_IFS
2372 test -z "$as_dir" && as_dir=.
2373 for ac_exec_ext in '' $ac_executable_extensions; do
2374 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2375 ac_cv_prog_STRIP="${ac_tool_prefix}strip"
2376 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2377 break 2
2378 fi
2379 done
2380 done
2381 IFS=$as_save_IFS
2382
2383 fi
2384 fi
2385 STRIP=$ac_cv_prog_STRIP
2386 if test -n "$STRIP"; then
2387 { echo "$as_me:$LINENO: result: $STRIP" >&5
2388 echo "${ECHO_T}$STRIP" >&6; }
2389 else
2390 { echo "$as_me:$LINENO: result: no" >&5
2391 echo "${ECHO_T}no" >&6; }
2392 fi
2393
2394
2395 fi
2396 if test -z "$ac_cv_prog_STRIP"; then
2397 ac_ct_STRIP=$STRIP
2398 # Extract the first word of "strip", so it can be a program name with args.
2399 set dummy strip; ac_word=$2
2400 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2401 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2402 if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
2403 echo $ECHO_N "(cached) $ECHO_C" >&6
2404 else
2405 if test -n "$ac_ct_STRIP"; then
2406 ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
2407 else
2408 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2409 for as_dir in $PATH
2410 do
2411 IFS=$as_save_IFS
2412 test -z "$as_dir" && as_dir=.
2413 for ac_exec_ext in '' $ac_executable_extensions; do
2414 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2415 ac_cv_prog_ac_ct_STRIP="strip"
2416 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2417 break 2
2418 fi
2419 done
2420 done
2421 IFS=$as_save_IFS
2422
2423 fi
2424 fi
2425 ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
2426 if test -n "$ac_ct_STRIP"; then
2427 { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
2428 echo "${ECHO_T}$ac_ct_STRIP" >&6; }
2429 else
2430 { echo "$as_me:$LINENO: result: no" >&5
2431 echo "${ECHO_T}no" >&6; }
2432 fi
2433
2434 if test "x$ac_ct_STRIP" = x; then
2435 STRIP=":"
2436 else
2437 case $cross_compiling:$ac_tool_warned in
2438 yes:)
2439 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
2440 whose name does not start with the host triplet. If you think this
2441 configuration is useful to you, please write to autoconf@gnu.org." >&5
2442 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
2443 whose name does not start with the host triplet. If you think this
2444 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
2445 ac_tool_warned=yes ;;
2446 esac
2447 STRIP=$ac_ct_STRIP
2448 fi
2449 else
2450 STRIP="$ac_cv_prog_STRIP"
2451 fi
2452
2453 fi
2454 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
2455
2456 # We need awk for the "check" target. The system "awk" is bad on
2457 # some platforms.
2458 # Always define AMTAR for backward compatibility.
2459
2460 AMTAR=${AMTAR-"${am_missing_run}tar"}
2461
2462 am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
2463
2464
2465
2466
2467
2468 { echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5
2469 echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6; }
2470 # Check whether --enable-maintainer-mode was given.
2471 if test "${enable_maintainer_mode+set}" = set; then
2472 enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
2473 else
2474 USE_MAINTAINER_MODE=no
2475 fi
2476
2477 { echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5
2478 echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6; }
2479 if test $USE_MAINTAINER_MODE = yes; then
2480 MAINTAINER_MODE_TRUE=
2481 MAINTAINER_MODE_FALSE='#'
2482 else
2483 MAINTAINER_MODE_TRUE='#'
2484 MAINTAINER_MODE_FALSE=
2485 fi
2486
2487 MAINT=$MAINTAINER_MODE_TRUE
2488
2489
2490
2491
2492 # Where we get installed
2493 if test "x$prefix" = xNONE; then
2494 echo $ECHO_N "checking for prefix by $ECHO_C" >&6
2495 # Extract the first word of "", so it can be a program name with args.
2496 set dummy ; ac_word=$2
2497 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2498 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2499 if test "${ac_cv_path_ac_prefix_program+set}" = set; then
2500 echo $ECHO_N "(cached) $ECHO_C" >&6
2501 else
2502 case $ac_prefix_program in
2503 [\\/]* | ?:[\\/]*)
2504 ac_cv_path_ac_prefix_program="$ac_prefix_program" # Let the user override the test with a path.
2505 ;;
2506 *)
2507 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2508 for as_dir in $PATH
2509 do
2510 IFS=$as_save_IFS
2511 test -z "$as_dir" && as_dir=.
2512 for ac_exec_ext in '' $ac_executable_extensions; do
2513 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2514 ac_cv_path_ac_prefix_program="$as_dir/$ac_word$ac_exec_ext"
2515 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2516 break 2
2517 fi
2518 done
2519 done
2520 IFS=$as_save_IFS
2521
2522 ;;
2523 esac
2524 fi
2525 ac_prefix_program=$ac_cv_path_ac_prefix_program
2526 if test -n "$ac_prefix_program"; then
2527 { echo "$as_me:$LINENO: result: $ac_prefix_program" >&5
2528 echo "${ECHO_T}$ac_prefix_program" >&6; }
2529 else
2530 { echo "$as_me:$LINENO: result: no" >&5
2531 echo "${ECHO_T}no" >&6; }
2532 fi
2533
2534
2535 if test -n "$ac_prefix_program"; then
2536 prefix=`$as_dirname -- "$ac_prefix_program" ||
2537 $as_expr X"$ac_prefix_program" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
2538 X"$ac_prefix_program" : 'X\(//\)[^/]' \| \
2539 X"$ac_prefix_program" : 'X\(//\)$' \| \
2540 X"$ac_prefix_program" : 'X\(/\)' \| . 2>/dev/null ||
2541 echo X"$ac_prefix_program" |
2542 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
2543 s//\1/
2544 q
2545 }
2546 /^X\(\/\/\)[^/].*/{
2547 s//\1/
2548 q
2549 }
2550 /^X\(\/\/\)$/{
2551 s//\1/
2552 q
2553 }
2554 /^X\(\/\).*/{
2555 s//\1/
2556 q
2557 }
2558 s/.*/./; q'`
2559 prefix=`$as_dirname -- "$prefix" ||
2560 $as_expr X"$prefix" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
2561 X"$prefix" : 'X\(//\)[^/]' \| \
2562 X"$prefix" : 'X\(//\)$' \| \
2563 X"$prefix" : 'X\(/\)' \| . 2>/dev/null ||
2564 echo X"$prefix" |
2565 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
2566 s//\1/
2567 q
2568 }
2569 /^X\(\/\/\)[^/].*/{
2570 s//\1/
2571 q
2572 }
2573 /^X\(\/\/\)$/{
2574 s//\1/
2575 q
2576 }
2577 /^X\(\/\).*/{
2578 s//\1/
2579 q
2580 }
2581 s/.*/./; q'`
2582 fi
2583 fi
2584
2585
2586 # Programs that we will be using
2587 ac_ext=c
2588 ac_cpp='$CPP $CPPFLAGS'
2589 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2590 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
2591 ac_compiler_gnu=$ac_cv_c_compiler_gnu
2592 if test -n "$ac_tool_prefix"; then
2593 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
2594 set dummy ${ac_tool_prefix}gcc; ac_word=$2
2595 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2596 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2597 if test "${ac_cv_prog_CC+set}" = set; then
2598 echo $ECHO_N "(cached) $ECHO_C" >&6
2599 else
2600 if test -n "$CC"; then
2601 ac_cv_prog_CC="$CC" # Let the user override the test.
2602 else
2603 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2604 for as_dir in $PATH
2605 do
2606 IFS=$as_save_IFS
2607 test -z "$as_dir" && as_dir=.
2608 for ac_exec_ext in '' $ac_executable_extensions; do
2609 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2610 ac_cv_prog_CC="${ac_tool_prefix}gcc"
2611 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2612 break 2
2613 fi
2614 done
2615 done
2616 IFS=$as_save_IFS
2617
2618 fi
2619 fi
2620 CC=$ac_cv_prog_CC
2621 if test -n "$CC"; then
2622 { echo "$as_me:$LINENO: result: $CC" >&5
2623 echo "${ECHO_T}$CC" >&6; }
2624 else
2625 { echo "$as_me:$LINENO: result: no" >&5
2626 echo "${ECHO_T}no" >&6; }
2627 fi
2628
2629
2630 fi
2631 if test -z "$ac_cv_prog_CC"; then
2632 ac_ct_CC=$CC
2633 # Extract the first word of "gcc", so it can be a program name with args.
2634 set dummy gcc; ac_word=$2
2635 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2636 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2637 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
2638 echo $ECHO_N "(cached) $ECHO_C" >&6
2639 else
2640 if test -n "$ac_ct_CC"; then
2641 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
2642 else
2643 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2644 for as_dir in $PATH
2645 do
2646 IFS=$as_save_IFS
2647 test -z "$as_dir" && as_dir=.
2648 for ac_exec_ext in '' $ac_executable_extensions; do
2649 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2650 ac_cv_prog_ac_ct_CC="gcc"
2651 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2652 break 2
2653 fi
2654 done
2655 done
2656 IFS=$as_save_IFS
2657
2658 fi
2659 fi
2660 ac_ct_CC=$ac_cv_prog_ac_ct_CC
2661 if test -n "$ac_ct_CC"; then
2662 { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
2663 echo "${ECHO_T}$ac_ct_CC" >&6; }
2664 else
2665 { echo "$as_me:$LINENO: result: no" >&5
2666 echo "${ECHO_T}no" >&6; }
2667 fi
2668
2669 if test "x$ac_ct_CC" = x; then
2670 CC=""
2671 else
2672 case $cross_compiling:$ac_tool_warned in
2673 yes:)
2674 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
2675 whose name does not start with the host triplet. If you think this
2676 configuration is useful to you, please write to autoconf@gnu.org." >&5
2677 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
2678 whose name does not start with the host triplet. If you think this
2679 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
2680 ac_tool_warned=yes ;;
2681 esac
2682 CC=$ac_ct_CC
2683 fi
2684 else
2685 CC="$ac_cv_prog_CC"
2686 fi
2687
2688 if test -z "$CC"; then
2689 if test -n "$ac_tool_prefix"; then
2690 # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
2691 set dummy ${ac_tool_prefix}cc; ac_word=$2
2692 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2693 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2694 if test "${ac_cv_prog_CC+set}" = set; then
2695 echo $ECHO_N "(cached) $ECHO_C" >&6
2696 else
2697 if test -n "$CC"; then
2698 ac_cv_prog_CC="$CC" # Let the user override the test.
2699 else
2700 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2701 for as_dir in $PATH
2702 do
2703 IFS=$as_save_IFS
2704 test -z "$as_dir" && as_dir=.
2705 for ac_exec_ext in '' $ac_executable_extensions; do
2706 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2707 ac_cv_prog_CC="${ac_tool_prefix}cc"
2708 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2709 break 2
2710 fi
2711 done
2712 done
2713 IFS=$as_save_IFS
2714
2715 fi
2716 fi
2717 CC=$ac_cv_prog_CC
2718 if test -n "$CC"; then
2719 { echo "$as_me:$LINENO: result: $CC" >&5
2720 echo "${ECHO_T}$CC" >&6; }
2721 else
2722 { echo "$as_me:$LINENO: result: no" >&5
2723 echo "${ECHO_T}no" >&6; }
2724 fi
2725
2726
2727 fi
2728 fi
2729 if test -z "$CC"; then
2730 # Extract the first word of "cc", so it can be a program name with args.
2731 set dummy cc; ac_word=$2
2732 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2733 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2734 if test "${ac_cv_prog_CC+set}" = set; then
2735 echo $ECHO_N "(cached) $ECHO_C" >&6
2736 else
2737 if test -n "$CC"; then
2738 ac_cv_prog_CC="$CC" # Let the user override the test.
2739 else
2740 ac_prog_rejected=no
2741 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2742 for as_dir in $PATH
2743 do
2744 IFS=$as_save_IFS
2745 test -z "$as_dir" && as_dir=.
2746 for ac_exec_ext in '' $ac_executable_extensions; do
2747 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2748 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
2749 ac_prog_rejected=yes
2750 continue
2751 fi
2752 ac_cv_prog_CC="cc"
2753 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2754 break 2
2755 fi
2756 done
2757 done
2758 IFS=$as_save_IFS
2759
2760 if test $ac_prog_rejected = yes; then
2761 # We found a bogon in the path, so make sure we never use it.
2762 set dummy $ac_cv_prog_CC
2763 shift
2764 if test $# != 0; then
2765 # We chose a different compiler from the bogus one.
2766 # However, it has the same basename, so the bogon will be chosen
2767 # first if we set CC to just the basename; use the full file name.
2768 shift
2769 ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
2770 fi
2771 fi
2772 fi
2773 fi
2774 CC=$ac_cv_prog_CC
2775 if test -n "$CC"; then
2776 { echo "$as_me:$LINENO: result: $CC" >&5
2777 echo "${ECHO_T}$CC" >&6; }
2778 else
2779 { echo "$as_me:$LINENO: result: no" >&5
2780 echo "${ECHO_T}no" >&6; }
2781 fi
2782
2783
2784 fi
2785 if test -z "$CC"; then
2786 if test -n "$ac_tool_prefix"; then
2787 for ac_prog in cl.exe
2788 do
2789 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
2790 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
2791 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2792 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2793 if test "${ac_cv_prog_CC+set}" = set; then
2794 echo $ECHO_N "(cached) $ECHO_C" >&6
2795 else
2796 if test -n "$CC"; then
2797 ac_cv_prog_CC="$CC" # Let the user override the test.
2798 else
2799 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2800 for as_dir in $PATH
2801 do
2802 IFS=$as_save_IFS
2803 test -z "$as_dir" && as_dir=.
2804 for ac_exec_ext in '' $ac_executable_extensions; do
2805 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2806 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
2807 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2808 break 2
2809 fi
2810 done
2811 done
2812 IFS=$as_save_IFS
2813
2814 fi
2815 fi
2816 CC=$ac_cv_prog_CC
2817 if test -n "$CC"; then
2818 { echo "$as_me:$LINENO: result: $CC" >&5
2819 echo "${ECHO_T}$CC" >&6; }
2820 else
2821 { echo "$as_me:$LINENO: result: no" >&5
2822 echo "${ECHO_T}no" >&6; }
2823 fi
2824
2825
2826 test -n "$CC" && break
2827 done
2828 fi
2829 if test -z "$CC"; then
2830 ac_ct_CC=$CC
2831 for ac_prog in cl.exe
2832 do
2833 # Extract the first word of "$ac_prog", so it can be a program name with args.
2834 set dummy $ac_prog; ac_word=$2
2835 { echo "$as_me:$LINENO: checking for $ac_word" >&5
2836 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
2837 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
2838 echo $ECHO_N "(cached) $ECHO_C" >&6
2839 else
2840 if test -n "$ac_ct_CC"; then
2841 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
2842 else
2843 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2844 for as_dir in $PATH
2845 do
2846 IFS=$as_save_IFS
2847 test -z "$as_dir" && as_dir=.
2848 for ac_exec_ext in '' $ac_executable_extensions; do
2849 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2850 ac_cv_prog_ac_ct_CC="$ac_prog"
2851 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
2852 break 2
2853 fi
2854 done
2855 done
2856 IFS=$as_save_IFS
2857
2858 fi
2859 fi
2860 ac_ct_CC=$ac_cv_prog_ac_ct_CC
2861 if test -n "$ac_ct_CC"; then
2862 { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
2863 echo "${ECHO_T}$ac_ct_CC" >&6; }
2864 else
2865 { echo "$as_me:$LINENO: result: no" >&5
2866 echo "${ECHO_T}no" >&6; }
2867 fi
2868
2869
2870 test -n "$ac_ct_CC" && break
2871 done
2872
2873 if test "x$ac_ct_CC" = x; then
2874 CC=""
2875 else
2876 case $cross_compiling:$ac_tool_warned in
2877 yes:)
2878 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
2879 whose name does not start with the host triplet. If you think this
2880 configuration is useful to you, please write to autoconf@gnu.org." >&5
2881 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
2882 whose name does not start with the host triplet. If you think this
2883 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
2884 ac_tool_warned=yes ;;
2885 esac
2886 CC=$ac_ct_CC
2887 fi
2888 fi
2889
2890 fi
2891
2892
2893 test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
2894 See \`config.log' for more details." >&5
2895 echo "$as_me: error: no acceptable C compiler found in \$PATH
2896 See \`config.log' for more details." >&2;}
2897 { (exit 1); exit 1; }; }
2898
2899 # Provide some information about the compiler.
2900 echo "$as_me:$LINENO: checking for C compiler version" >&5
2901 ac_compiler=`set X $ac_compile; echo $2`
2902 { (ac_try="$ac_compiler --version >&5"
2903 case "(($ac_try" in
2904 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2905 *) ac_try_echo=$ac_try;;
2906 esac
2907 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
2908 (eval "$ac_compiler --version >&5") 2>&5
2909 ac_status=$?
2910 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2911 (exit $ac_status); }
2912 { (ac_try="$ac_compiler -v >&5"
2913 case "(($ac_try" in
2914 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2915 *) ac_try_echo=$ac_try;;
2916 esac
2917 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
2918 (eval "$ac_compiler -v >&5") 2>&5
2919 ac_status=$?
2920 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2921 (exit $ac_status); }
2922 { (ac_try="$ac_compiler -V >&5"
2923 case "(($ac_try" in
2924 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2925 *) ac_try_echo=$ac_try;;
2926 esac
2927 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
2928 (eval "$ac_compiler -V >&5") 2>&5
2929 ac_status=$?
2930 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2931 (exit $ac_status); }
2932
2933 cat >conftest.$ac_ext <<_ACEOF
2934 /* confdefs.h. */
2935 _ACEOF
2936 cat confdefs.h >>conftest.$ac_ext
2937 cat >>conftest.$ac_ext <<_ACEOF
2938 /* end confdefs.h. */
2939
2940 int
2941 main ()
2942 {
2943
2944 ;
2945 return 0;
2946 }
2947 _ACEOF
2948 ac_clean_files_save=$ac_clean_files
2949 ac_clean_files="$ac_clean_files a.out a.exe b.out"
2950 # Try to create an executable without -o first, disregard a.out.
2951 # It will help us diagnose broken compilers, and finding out an intuition
2952 # of exeext.
2953 { echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
2954 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; }
2955 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
2956 #
2957 # List of possible output files, starting from the most likely.
2958 # The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
2959 # only as a last resort. b.out is created by i960 compilers.
2960 ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
2961 #
2962 # The IRIX 6 linker writes into existing files which may not be
2963 # executable, retaining their permissions. Remove them first so a
2964 # subsequent execution test works.
2965 ac_rmfiles=
2966 for ac_file in $ac_files
2967 do
2968 case $ac_file in
2969 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
2970 * ) ac_rmfiles="$ac_rmfiles $ac_file";;
2971 esac
2972 done
2973 rm -f $ac_rmfiles
2974
2975 if { (ac_try="$ac_link_default"
2976 case "(($ac_try" in
2977 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2978 *) ac_try_echo=$ac_try;;
2979 esac
2980 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
2981 (eval "$ac_link_default") 2>&5
2982 ac_status=$?
2983 echo "$as_me:$LINENO: \$? = $ac_status" >&5
2984 (exit $ac_status); }; then
2985 # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
2986 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
2987 # in a Makefile. We should not override ac_cv_exeext if it was cached,
2988 # so that the user can short-circuit this test for compilers unknown to
2989 # Autoconf.
2990 for ac_file in $ac_files ''
2991 do
2992 test -f "$ac_file" || continue
2993 case $ac_file in
2994 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )
2995 ;;
2996 [ab].out )
2997 # We found the default executable, but exeext='' is most
2998 # certainly right.
2999 break;;
3000 *.* )
3001 if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
3002 then :; else
3003 ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
3004 fi
3005 # We set ac_cv_exeext here because the later test for it is not
3006 # safe: cross compilers may not add the suffix if given an `-o'
3007 # argument, so we may need to know it at that point already.
3008 # Even if this section looks crufty: it has the advantage of
3009 # actually working.
3010 break;;
3011 * )
3012 break;;
3013 esac
3014 done
3015 test "$ac_cv_exeext" = no && ac_cv_exeext=
3016
3017 else
3018 ac_file=''
3019 fi
3020
3021 { echo "$as_me:$LINENO: result: $ac_file" >&5
3022 echo "${ECHO_T}$ac_file" >&6; }
3023 if test -z "$ac_file"; then
3024 echo "$as_me: failed program was:" >&5
3025 sed 's/^/| /' conftest.$ac_ext >&5
3026
3027 { { echo "$as_me:$LINENO: error: C compiler cannot create executables
3028 See \`config.log' for more details." >&5
3029 echo "$as_me: error: C compiler cannot create executables
3030 See \`config.log' for more details." >&2;}
3031 { (exit 77); exit 77; }; }
3032 fi
3033
3034 ac_exeext=$ac_cv_exeext
3035
3036 # Check that the compiler produces executables we can run. If not, either
3037 # the compiler is broken, or we cross compile.
3038 { echo "$as_me:$LINENO: checking whether the C compiler works" >&5
3039 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; }
3040 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
3041 # If not cross compiling, check that we can run a simple program.
3042 if test "$cross_compiling" != yes; then
3043 if { ac_try='./$ac_file'
3044 { (case "(($ac_try" in
3045 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3046 *) ac_try_echo=$ac_try;;
3047 esac
3048 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3049 (eval "$ac_try") 2>&5
3050 ac_status=$?
3051 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3052 (exit $ac_status); }; }; then
3053 cross_compiling=no
3054 else
3055 if test "$cross_compiling" = maybe; then
3056 cross_compiling=yes
3057 else
3058 { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
3059 If you meant to cross compile, use \`--host'.
3060 See \`config.log' for more details." >&5
3061 echo "$as_me: error: cannot run C compiled programs.
3062 If you meant to cross compile, use \`--host'.
3063 See \`config.log' for more details." >&2;}
3064 { (exit 1); exit 1; }; }
3065 fi
3066 fi
3067 fi
3068 { echo "$as_me:$LINENO: result: yes" >&5
3069 echo "${ECHO_T}yes" >&6; }
3070
3071 rm -f a.out a.exe conftest$ac_cv_exeext b.out
3072 ac_clean_files=$ac_clean_files_save
3073 # Check that the compiler produces executables we can run. If not, either
3074 # the compiler is broken, or we cross compile.
3075 { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
3076 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; }
3077 { echo "$as_me:$LINENO: result: $cross_compiling" >&5
3078 echo "${ECHO_T}$cross_compiling" >&6; }
3079
3080 { echo "$as_me:$LINENO: checking for suffix of executables" >&5
3081 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; }
3082 if { (ac_try="$ac_link"
3083 case "(($ac_try" in
3084 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3085 *) ac_try_echo=$ac_try;;
3086 esac
3087 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3088 (eval "$ac_link") 2>&5
3089 ac_status=$?
3090 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3091 (exit $ac_status); }; then
3092 # If both `conftest.exe' and `conftest' are `present' (well, observable)
3093 # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
3094 # work properly (i.e., refer to `conftest.exe'), while it won't with
3095 # `rm'.
3096 for ac_file in conftest.exe conftest conftest.*; do
3097 test -f "$ac_file" || continue
3098 case $ac_file in
3099 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
3100 *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
3101 break;;
3102 * ) break;;
3103 esac
3104 done
3105 else
3106 { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
3107 See \`config.log' for more details." >&5
3108 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
3109 See \`config.log' for more details." >&2;}
3110 { (exit 1); exit 1; }; }
3111 fi
3112
3113 rm -f conftest$ac_cv_exeext
3114 { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
3115 echo "${ECHO_T}$ac_cv_exeext" >&6; }
3116
3117 rm -f conftest.$ac_ext
3118 EXEEXT=$ac_cv_exeext
3119 ac_exeext=$EXEEXT
3120 { echo "$as_me:$LINENO: checking for suffix of object files" >&5
3121 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; }
3122 if test "${ac_cv_objext+set}" = set; then
3123 echo $ECHO_N "(cached) $ECHO_C" >&6
3124 else
3125 cat >conftest.$ac_ext <<_ACEOF
3126 /* confdefs.h. */
3127 _ACEOF
3128 cat confdefs.h >>conftest.$ac_ext
3129 cat >>conftest.$ac_ext <<_ACEOF
3130 /* end confdefs.h. */
3131
3132 int
3133 main ()
3134 {
3135
3136 ;
3137 return 0;
3138 }
3139 _ACEOF
3140 rm -f conftest.o conftest.obj
3141 if { (ac_try="$ac_compile"
3142 case "(($ac_try" in
3143 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3144 *) ac_try_echo=$ac_try;;
3145 esac
3146 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3147 (eval "$ac_compile") 2>&5
3148 ac_status=$?
3149 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3150 (exit $ac_status); }; then
3151 for ac_file in conftest.o conftest.obj conftest.*; do
3152 test -f "$ac_file" || continue;
3153 case $ac_file in
3154 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;
3155 *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
3156 break;;
3157 esac
3158 done
3159 else
3160 echo "$as_me: failed program was:" >&5
3161 sed 's/^/| /' conftest.$ac_ext >&5
3162
3163 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
3164 See \`config.log' for more details." >&5
3165 echo "$as_me: error: cannot compute suffix of object files: cannot compile
3166 See \`config.log' for more details." >&2;}
3167 { (exit 1); exit 1; }; }
3168 fi
3169
3170 rm -f conftest.$ac_cv_objext conftest.$ac_ext
3171 fi
3172 { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
3173 echo "${ECHO_T}$ac_cv_objext" >&6; }
3174 OBJEXT=$ac_cv_objext
3175 ac_objext=$OBJEXT
3176 { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
3177 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; }
3178 if test "${ac_cv_c_compiler_gnu+set}" = set; then
3179 echo $ECHO_N "(cached) $ECHO_C" >&6
3180 else
3181 cat >conftest.$ac_ext <<_ACEOF
3182 /* confdefs.h. */
3183 _ACEOF
3184 cat confdefs.h >>conftest.$ac_ext
3185 cat >>conftest.$ac_ext <<_ACEOF
3186 /* end confdefs.h. */
3187
3188 int
3189 main ()
3190 {
3191 #ifndef __GNUC__
3192 choke me
3193 #endif
3194
3195 ;
3196 return 0;
3197 }
3198 _ACEOF
3199 rm -f conftest.$ac_objext
3200 if { (ac_try="$ac_compile"
3201 case "(($ac_try" in
3202 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3203 *) ac_try_echo=$ac_try;;
3204 esac
3205 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3206 (eval "$ac_compile") 2>conftest.er1
3207 ac_status=$?
3208 grep -v '^ *+' conftest.er1 >conftest.err
3209 rm -f conftest.er1
3210 cat conftest.err >&5
3211 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3212 (exit $ac_status); } && {
3213 test -z "$ac_c_werror_flag" ||
3214 test ! -s conftest.err
3215 } && test -s conftest.$ac_objext; then
3216 ac_compiler_gnu=yes
3217 else
3218 echo "$as_me: failed program was:" >&5
3219 sed 's/^/| /' conftest.$ac_ext >&5
3220
3221 ac_compiler_gnu=no
3222 fi
3223
3224 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3225 ac_cv_c_compiler_gnu=$ac_compiler_gnu
3226
3227 fi
3228 { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
3229 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }
3230 GCC=`test $ac_compiler_gnu = yes && echo yes`
3231 ac_test_CFLAGS=${CFLAGS+set}
3232 ac_save_CFLAGS=$CFLAGS
3233 { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
3234 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }
3235 if test "${ac_cv_prog_cc_g+set}" = set; then
3236 echo $ECHO_N "(cached) $ECHO_C" >&6
3237 else
3238 ac_save_c_werror_flag=$ac_c_werror_flag
3239 ac_c_werror_flag=yes
3240 ac_cv_prog_cc_g=no
3241 CFLAGS="-g"
3242 cat >conftest.$ac_ext <<_ACEOF
3243 /* confdefs.h. */
3244 _ACEOF
3245 cat confdefs.h >>conftest.$ac_ext
3246 cat >>conftest.$ac_ext <<_ACEOF
3247 /* end confdefs.h. */
3248
3249 int
3250 main ()
3251 {
3252
3253 ;
3254 return 0;
3255 }
3256 _ACEOF
3257 rm -f conftest.$ac_objext
3258 if { (ac_try="$ac_compile"
3259 case "(($ac_try" in
3260 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3261 *) ac_try_echo=$ac_try;;
3262 esac
3263 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3264 (eval "$ac_compile") 2>conftest.er1
3265 ac_status=$?
3266 grep -v '^ *+' conftest.er1 >conftest.err
3267 rm -f conftest.er1
3268 cat conftest.err >&5
3269 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3270 (exit $ac_status); } && {
3271 test -z "$ac_c_werror_flag" ||
3272 test ! -s conftest.err
3273 } && test -s conftest.$ac_objext; then
3274 ac_cv_prog_cc_g=yes
3275 else
3276 echo "$as_me: failed program was:" >&5
3277 sed 's/^/| /' conftest.$ac_ext >&5
3278
3279 CFLAGS=""
3280 cat >conftest.$ac_ext <<_ACEOF
3281 /* confdefs.h. */
3282 _ACEOF
3283 cat confdefs.h >>conftest.$ac_ext
3284 cat >>conftest.$ac_ext <<_ACEOF
3285 /* end confdefs.h. */
3286
3287 int
3288 main ()
3289 {
3290
3291 ;
3292 return 0;
3293 }
3294 _ACEOF
3295 rm -f conftest.$ac_objext
3296 if { (ac_try="$ac_compile"
3297 case "(($ac_try" in
3298 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3299 *) ac_try_echo=$ac_try;;
3300 esac
3301 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3302 (eval "$ac_compile") 2>conftest.er1
3303 ac_status=$?
3304 grep -v '^ *+' conftest.er1 >conftest.err
3305 rm -f conftest.er1
3306 cat conftest.err >&5
3307 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3308 (exit $ac_status); } && {
3309 test -z "$ac_c_werror_flag" ||
3310 test ! -s conftest.err
3311 } && test -s conftest.$ac_objext; then
3312 :
3313 else
3314 echo "$as_me: failed program was:" >&5
3315 sed 's/^/| /' conftest.$ac_ext >&5
3316
3317 ac_c_werror_flag=$ac_save_c_werror_flag
3318 CFLAGS="-g"
3319 cat >conftest.$ac_ext <<_ACEOF
3320 /* confdefs.h. */
3321 _ACEOF
3322 cat confdefs.h >>conftest.$ac_ext
3323 cat >>conftest.$ac_ext <<_ACEOF
3324 /* end confdefs.h. */
3325
3326 int
3327 main ()
3328 {
3329
3330 ;
3331 return 0;
3332 }
3333 _ACEOF
3334 rm -f conftest.$ac_objext
3335 if { (ac_try="$ac_compile"
3336 case "(($ac_try" in
3337 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3338 *) ac_try_echo=$ac_try;;
3339 esac
3340 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3341 (eval "$ac_compile") 2>conftest.er1
3342 ac_status=$?
3343 grep -v '^ *+' conftest.er1 >conftest.err
3344 rm -f conftest.er1
3345 cat conftest.err >&5
3346 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3347 (exit $ac_status); } && {
3348 test -z "$ac_c_werror_flag" ||
3349 test ! -s conftest.err
3350 } && test -s conftest.$ac_objext; then
3351 ac_cv_prog_cc_g=yes
3352 else
3353 echo "$as_me: failed program was:" >&5
3354 sed 's/^/| /' conftest.$ac_ext >&5
3355
3356
3357 fi
3358
3359 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3360 fi
3361
3362 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3363 fi
3364
3365 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3366 ac_c_werror_flag=$ac_save_c_werror_flag
3367 fi
3368 { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
3369 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }
3370 if test "$ac_test_CFLAGS" = set; then
3371 CFLAGS=$ac_save_CFLAGS
3372 elif test $ac_cv_prog_cc_g = yes; then
3373 if test "$GCC" = yes; then
3374 CFLAGS="-g -O2"
3375 else
3376 CFLAGS="-g"
3377 fi
3378 else
3379 if test "$GCC" = yes; then
3380 CFLAGS="-O2"
3381 else
3382 CFLAGS=
3383 fi
3384 fi
3385 { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
3386 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
3387 if test "${ac_cv_prog_cc_c89+set}" = set; then
3388 echo $ECHO_N "(cached) $ECHO_C" >&6
3389 else
3390 ac_cv_prog_cc_c89=no
3391 ac_save_CC=$CC
3392 cat >conftest.$ac_ext <<_ACEOF
3393 /* confdefs.h. */
3394 _ACEOF
3395 cat confdefs.h >>conftest.$ac_ext
3396 cat >>conftest.$ac_ext <<_ACEOF
3397 /* end confdefs.h. */
3398 #include <stdarg.h>
3399 #include <stdio.h>
3400 #include <sys/types.h>
3401 #include <sys/stat.h>
3402 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
3403 struct buf { int x; };
3404 FILE * (*rcsopen) (struct buf *, struct stat *, int);
3405 static char *e (p, i)
3406 char **p;
3407 int i;
3408 {
3409 return p[i];
3410 }
3411 static char *f (char * (*g) (char **, int), char **p, ...)
3412 {
3413 char *s;
3414 va_list v;
3415 va_start (v,p);
3416 s = g (p, va_arg (v,int));
3417 va_end (v);
3418 return s;
3419 }
3420
3421 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
3422 function prototypes and stuff, but not '\xHH' hex character constants.
3423 These don't provoke an error unfortunately, instead are silently treated
3424 as 'x'. The following induces an error, until -std is added to get
3425 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
3426 array size at least. It's necessary to write '\x00'==0 to get something
3427 that's true only with -std. */
3428 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
3429
3430 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
3431 inside strings and character constants. */
3432 #define FOO(x) 'x'
3433 int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
3434
3435 int test (int i, double x);
3436 struct s1 {int (*f) (int a);};
3437 struct s2 {int (*f) (double a);};
3438 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
3439 int argc;
3440 char **argv;
3441 int
3442 main ()
3443 {
3444 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
3445 ;
3446 return 0;
3447 }
3448 _ACEOF
3449 for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
3450 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
3451 do
3452 CC="$ac_save_CC $ac_arg"
3453 rm -f conftest.$ac_objext
3454 if { (ac_try="$ac_compile"
3455 case "(($ac_try" in
3456 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3457 *) ac_try_echo=$ac_try;;
3458 esac
3459 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
3460 (eval "$ac_compile") 2>conftest.er1
3461 ac_status=$?
3462 grep -v '^ *+' conftest.er1 >conftest.err
3463 rm -f conftest.er1
3464 cat conftest.err >&5
3465 echo "$as_me:$LINENO: \$? = $ac_status" >&5
3466 (exit $ac_status); } && {
3467 test -z "$ac_c_werror_flag" ||
3468 test ! -s conftest.err
3469 } && test -s conftest.$ac_objext; then
3470 ac_cv_prog_cc_c89=$ac_arg
3471 else
3472 echo "$as_me: failed program was:" >&5
3473 sed 's/^/| /' conftest.$ac_ext >&5
3474
3475
3476 fi
3477
3478 rm -f core conftest.err conftest.$ac_objext
3479 test "x$ac_cv_prog_cc_c89" != "xno" && break
3480 done
3481 rm -f conftest.$ac_ext
3482 CC=$ac_save_CC
3483
3484 fi
3485 # AC_CACHE_VAL
3486 case "x$ac_cv_prog_cc_c89" in
3487 x)
3488 { echo "$as_me:$LINENO: result: none needed" >&5
3489 echo "${ECHO_T}none needed" >&6; } ;;
3490 xno)
3491 { echo "$as_me:$LINENO: result: unsupported" >&5
3492 echo "${ECHO_T}unsupported" >&6; } ;;
3493 *)
3494 CC="$CC $ac_cv_prog_cc_c89"
3495 { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
3496 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
3497 esac
3498
3499
3500 ac_ext=c
3501 ac_cpp='$CPP $CPPFLAGS'
3502 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3503 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3504 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3505 DEPDIR="${am__leading_dot}deps"
3506
3507 ac_config_commands="$ac_config_commands depfiles"
3508
3509
3510 am_make=${MAKE-make}
3511 cat > confinc << 'END'
3512 am__doit:
3513 @echo done
3514 .PHONY: am__doit
3515 END
3516 # If we don't find an include directive, just comment out the code.
3517 { echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5
3518 echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; }
3519 am__include="#"
3520 am__quote=
3521 _am_result=none
3522 # First try GNU make style include.
3523 echo "include confinc" > confmf
3524 # We grep out `Entering directory' and `Leaving directory'
3525 # messages which can occur if `w' ends up in MAKEFLAGS.
3526 # In particular we don't look at `^make:' because GNU make might
3527 # be invoked under some other name (usually "gmake"), in which
3528 # case it prints its new name instead of `make'.
3529 if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
3530 am__include=include
3531 am__quote=
3532 _am_result=GNU
3533 fi
3534 # Now try BSD make style include.
3535 if test "$am__include" = "#"; then
3536 echo '.include "confinc"' > confmf
3537 if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
3538 am__include=.include
3539 am__quote="\""
3540 _am_result=BSD
3541 fi
3542 fi
3543
3544
3545 { echo "$as_me:$LINENO: result: $_am_result" >&5
3546 echo "${ECHO_T}$_am_result" >&6; }
3547 rm -f confinc confmf
3548
3549 # Check whether --enable-dependency-tracking was given.
3550 if test "${enable_dependency_tracking+set}" = set; then
3551 enableval=$enable_dependency_tracking;
3552 fi
3553
3554 if test "x$enable_dependency_tracking" != xno; then
3555 am_depcomp="$ac_aux_dir/depcomp"
3556 AMDEPBACKSLASH='\'
3557 fi
3558 if test "x$enable_dependency_tracking" != xno; then
3559 AMDEP_TRUE=
3560 AMDEP_FALSE='#'
3561 else
3562 AMDEP_TRUE='#'
3563 AMDEP_FALSE=
3564 fi
3565
3566
3567
3568 depcc="$CC" am_compiler_list=
3569
3570 { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
3571 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; }
3572 if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then
3573 echo $ECHO_N "(cached) $ECHO_C" >&6
3574 else
3575 if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
3576 # We make a subdir and do the tests there. Otherwise we can end up
3577 # making bogus files that we don't know about and never remove. For
3578 # instance it was reported that on HP-UX the gcc test will end up
3579 # making a dummy file named `D' -- because `-MD' means `put the output
3580 # in D'.
3581 mkdir conftest.dir
3582 # Copy depcomp to subdir because otherwise we won't find it if we're
3583 # using a relative directory.
3584 cp "$am_depcomp" conftest.dir
3585 cd conftest.dir
3586 # We will build objects and dependencies in a subdirectory because
3587 # it helps to detect inapplicable dependency modes. For instance
3588 # both Tru64's cc and ICC support -MD to output dependencies as a
3589 # side effect of compilation, but ICC will put the dependencies in
3590 # the current directory while Tru64 will put them in the object
3591 # directory.
3592 mkdir sub
3593
3594 am_cv_CC_dependencies_compiler_type=none
3595 if test "$am_compiler_list" = ""; then
3596 am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
3597 fi
3598 for depmode in $am_compiler_list; do
3599 # Setup a source with many dependencies, because some compilers
3600 # like to wrap large dependency lists on column 80 (with \), and
3601 # we should not choose a depcomp mode which is confused by this.
3602 #
3603 # We need to recreate these files for each test, as the compiler may
3604 # overwrite some of them when testing with obscure command lines.
3605 # This happens at least with the AIX C compiler.
3606 : > sub/conftest.c
3607 for i in 1 2 3 4 5 6; do
3608 echo '#include "conftst'$i'.h"' >> sub/conftest.c
3609 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
3610 # Solaris 8's {/usr,}/bin/sh.
3611 touch sub/conftst$i.h
3612 done
3613 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
3614
3615 case $depmode in
3616 nosideeffect)
3617 # after this tag, mechanisms are not by side-effect, so they'll
3618 # only be used when explicitly requested
3619 if test "x$enable_dependency_tracking" = xyes; then
3620 continue
3621 else
3622 break
3623 fi
3624 ;;
3625 none) break ;;
3626 esac
3627 # We check with `-c' and `-o' for the sake of the "dashmstdout"
3628 # mode. It turns out that the SunPro C++ compiler does not properly
3629 # handle `-M -o', and we need to detect this.
3630 if depmode=$depmode \
3631 source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
3632 depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
3633 $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
3634 >/dev/null 2>conftest.err &&
3635 grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
3636 grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
3637 grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
3638 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
3639 # icc doesn't choke on unknown options, it will just issue warnings
3640 # or remarks (even with -Werror). So we grep stderr for any message
3641 # that says an option was ignored or not supported.
3642 # When given -MP, icc 7.0 and 7.1 complain thusly:
3643 # icc: Command line warning: ignoring option '-M'; no argument required
3644 # The diagnosis changed in icc 8.0:
3645 # icc: Command line remark: option '-MP' not supported
3646 if (grep 'ignoring option' conftest.err ||
3647 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
3648 am_cv_CC_dependencies_compiler_type=$depmode
3649 break
3650 fi
3651 fi
3652 done
3653
3654 cd ..
3655 rm -rf conftest.dir
3656 else
3657 am_cv_CC_dependencies_compiler_type=none
3658 fi
3659
3660 fi
3661 { echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5
3662 echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; }
3663 CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
3664
3665 if
3666 test "x$enable_dependency_tracking" != xno \
3667 && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
3668 am__fastdepCC_TRUE=
3669 am__fastdepCC_FALSE='#'
3670 else
3671 am__fastdepCC_TRUE='#'
3672 am__fastdepCC_FALSE=
3673 fi
3674
3675
3676 # Find a good install program. We prefer a C program (faster),
3677 # so one script is as good as another. But avoid the broken or
3678 # incompatible versions:
3679 # SysV /etc/install, /usr/sbin/install
3680 # SunOS /usr/etc/install
3681 # IRIX /sbin/install
3682 # AIX /bin/install
3683 # AmigaOS /C/install, which installs bootblocks on floppy discs
3684 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
3685 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
3686 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
3687 # OS/2's system install, which has a completely different semantic
3688 # ./install, which can be erroneously created by make from ./install.sh.
3689 { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
3690 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }
3691 if test -z "$INSTALL"; then
3692 if test "${ac_cv_path_install+set}" = set; then
3693 echo $ECHO_N "(cached) $ECHO_C" >&6
3694 else
3695 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3696 for as_dir in $PATH
3697 do
3698 IFS=$as_save_IFS
3699 test -z "$as_dir" && as_dir=.
3700 # Account for people who put trailing slashes in PATH elements.
3701 case $as_dir/ in
3702 ./ | .// | /cC/* | \
3703 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
3704 ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
3705 /usr/ucb/* ) ;;
3706 *)
3707 # OSF1 and SCO ODT 3.0 have their own names for install.
3708 # Don't use installbsd from OSF since it installs stuff as root
3709 # by default.
3710 for ac_prog in ginstall scoinst install; do
3711 for ac_exec_ext in '' $ac_executable_extensions; do
3712 if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
3713 if test $ac_prog = install &&
3714 grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
3715 # AIX install. It has an incompatible calling convention.
3716 :
3717 elif test $ac_prog = install &&
3718 grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
3719 # program-specific install script used by HP pwplus--don't use.
3720 :
3721 else
3722 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
3723 break 3
3724 fi
3725 fi
3726 done
3727 done
3728 ;;
3729 esac
3730 done
3731 IFS=$as_save_IFS
3732
3733
3734 fi
3735 if test "${ac_cv_path_install+set}" = set; then
3736 INSTALL=$ac_cv_path_install
3737 else
3738 # As a last resort, use the slow shell script. Don't cache a
3739 # value for INSTALL within a source directory, because that will
3740 # break other packages using the cache if that directory is
3741 # removed, or if the value is a relative name.
3742 INSTALL=$ac_install_sh
3743 fi
3744 fi
3745 { echo "$as_me:$LINENO: result: $INSTALL" >&5
3746 echo "${ECHO_T}$INSTALL" >&6; }
3747
3748 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
3749 # It thinks the first close brace ends the variable substitution.
3750 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
3751
3752 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
3753
3754 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
3755
3756
3757 # Turn off shared libraries during beta-testing, since they
3758 # make the build process take too long.
3759 case `pwd` in
3760 *\ * | *\ *)
3761 { echo "$as_me:$LINENO: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
3762 echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
3763 esac
3764
3765
3766
3767 macro_version='2.2.4'
3768 macro_revision='1.2976'
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782 ltmain="$ac_aux_dir/ltmain.sh"
3783
3784 # Make sure we can run config.sub.
3785 $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
3786 { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
3787 echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
3788 { (exit 1); exit 1; }; }
3789
3790 { echo "$as_me:$LINENO: checking build system type" >&5
3791 echo $ECHO_N "checking build system type... $ECHO_C" >&6; }
3792 if test "${ac_cv_build+set}" = set; then
3793 echo $ECHO_N "(cached) $ECHO_C" >&6
3794 else
3795 ac_build_alias=$build_alias
3796 test "x$ac_build_alias" = x &&
3797 ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
3798 test "x$ac_build_alias" = x &&
3799 { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
3800 echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
3801 { (exit 1); exit 1; }; }
3802 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
3803 { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
3804 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
3805 { (exit 1); exit 1; }; }
3806
3807 fi
3808 { echo "$as_me:$LINENO: result: $ac_cv_build" >&5
3809 echo "${ECHO_T}$ac_cv_build" >&6; }
3810 case $ac_cv_build in
3811 *-*-*) ;;
3812 *) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
3813 echo "$as_me: error: invalid value of canonical build" >&2;}
3814 { (exit 1); exit 1; }; };;
3815 esac
3816 build=$ac_cv_build
3817 ac_save_IFS=$IFS; IFS='-'
3818 set x $ac_cv_build
3819 shift
3820 build_cpu=$1
3821 build_vendor=$2
3822 shift; shift
3823 # Remember, the first character of IFS is used to create $*,
3824 # except with old shells:
3825 build_os=$*
3826 IFS=$ac_save_IFS
3827 case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
3828
3829
3830 { echo "$as_me:$LINENO: checking host system type" >&5
3831 echo $ECHO_N "checking host system type... $ECHO_C" >&6; }
3832 if test "${ac_cv_host+set}" = set; then
3833 echo $ECHO_N "(cached) $ECHO_C" >&6
3834 else
3835 if test "x$host_alias" = x; then
3836 ac_cv_host=$ac_cv_build
3837 else
3838 ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
3839 { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
3840 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
3841 { (exit 1); exit 1; }; }
3842 fi
3843
3844 fi
3845 { echo "$as_me:$LINENO: result: $ac_cv_host" >&5
3846 echo "${ECHO_T}$ac_cv_host" >&6; }
3847 case $ac_cv_host in
3848 *-*-*) ;;
3849 *) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
3850 echo "$as_me: error: invalid value of canonical host" >&2;}
3851 { (exit 1); exit 1; }; };;
3852 esac
3853 host=$ac_cv_host
3854 ac_save_IFS=$IFS; IFS='-'
3855 set x $ac_cv_host
3856 shift
3857 host_cpu=$1
3858 host_vendor=$2
3859 shift; shift
3860 # Remember, the first character of IFS is used to create $*,
3861 # except with old shells:
3862 host_os=$*
3863 IFS=$ac_save_IFS
3864 case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
3865
3866
3867 { echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
3868 echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6; }
3869 if test "${ac_cv_path_SED+set}" = set; then
3870 echo $ECHO_N "(cached) $ECHO_C" >&6
3871 else
3872 ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
3873 for ac_i in 1 2 3 4 5 6 7; do
3874 ac_script="$ac_script$as_nl$ac_script"
3875 done
3876 echo "$ac_script" | sed 99q >conftest.sed
3877 $as_unset ac_script || ac_script=
3878 # Extract the first word of "sed gsed" to use in msg output
3879 if test -z "$SED"; then
3880 set dummy sed gsed; ac_prog_name=$2
3881 if test "${ac_cv_path_SED+set}" = set; then
3882 echo $ECHO_N "(cached) $ECHO_C" >&6
3883 else
3884 ac_path_SED_found=false
3885 # Loop through the user's path and test for each of PROGNAME-LIST
3886 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3887 for as_dir in $PATH
3888 do
3889 IFS=$as_save_IFS
3890 test -z "$as_dir" && as_dir=.
3891 for ac_prog in sed gsed; do
3892 for ac_exec_ext in '' $ac_executable_extensions; do
3893 ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
3894 { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
3895 # Check for GNU ac_path_SED and select it if it is found.
3896 # Check for GNU $ac_path_SED
3897 case `"$ac_path_SED" --version 2>&1` in
3898 *GNU*)
3899 ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
3900 *)
3901 ac_count=0
3902 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
3903 while :
3904 do
3905 cat "conftest.in" "conftest.in" >"conftest.tmp"
3906 mv "conftest.tmp" "conftest.in"
3907 cp "conftest.in" "conftest.nl"
3908 echo '' >> "conftest.nl"
3909 "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
3910 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
3911 ac_count=`expr $ac_count + 1`
3912 if test $ac_count -gt ${ac_path_SED_max-0}; then
3913 # Best one so far, save it but keep looking for a better one
3914 ac_cv_path_SED="$ac_path_SED"
3915 ac_path_SED_max=$ac_count
3916 fi
3917 # 10*(2^10) chars as input seems more than enough
3918 test $ac_count -gt 10 && break
3919 done
3920 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
3921 esac
3922
3923
3924 $ac_path_SED_found && break 3
3925 done
3926 done
3927
3928 done
3929 IFS=$as_save_IFS
3930
3931
3932 fi
3933
3934 SED="$ac_cv_path_SED"
3935 if test -z "$SED"; then
3936 { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in \$PATH" >&5
3937 echo "$as_me: error: no acceptable $ac_prog_name could be found in \$PATH" >&2;}
3938 { (exit 1); exit 1; }; }
3939 fi
3940
3941 else
3942 ac_cv_path_SED=$SED
3943 fi
3944
3945 fi
3946 { echo "$as_me:$LINENO: result: $ac_cv_path_SED" >&5
3947 echo "${ECHO_T}$ac_cv_path_SED" >&6; }
3948 SED="$ac_cv_path_SED"
3949 rm -f conftest.sed
3950
3951 test -z "$SED" && SED=sed
3952 Xsed="$SED -e 1s/^X//"
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964 { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
3965 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }
3966 if test "${ac_cv_path_GREP+set}" = set; then
3967 echo $ECHO_N "(cached) $ECHO_C" >&6
3968 else
3969 # Extract the first word of "grep ggrep" to use in msg output
3970 if test -z "$GREP"; then
3971 set dummy grep ggrep; ac_prog_name=$2
3972 if test "${ac_cv_path_GREP+set}" = set; then
3973 echo $ECHO_N "(cached) $ECHO_C" >&6
3974 else
3975 ac_path_GREP_found=false
3976 # Loop through the user's path and test for each of PROGNAME-LIST
3977 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3978 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
3979 do
3980 IFS=$as_save_IFS
3981 test -z "$as_dir" && as_dir=.
3982 for ac_prog in grep ggrep; do
3983 for ac_exec_ext in '' $ac_executable_extensions; do
3984 ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
3985 { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
3986 # Check for GNU ac_path_GREP and select it if it is found.
3987 # Check for GNU $ac_path_GREP
3988 case `"$ac_path_GREP" --version 2>&1` in
3989 *GNU*)
3990 ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
3991 *)
3992 ac_count=0
3993 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
3994 while :
3995 do
3996 cat "conftest.in" "conftest.in" >"conftest.tmp"
3997 mv "conftest.tmp" "conftest.in"
3998 cp "conftest.in" "conftest.nl"
3999 echo 'GREP' >> "conftest.nl"
4000 "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
4001 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
4002 ac_count=`expr $ac_count + 1`
4003 if test $ac_count -gt ${ac_path_GREP_max-0}; then
4004 # Best one so far, save it but keep looking for a better one
4005 ac_cv_path_GREP="$ac_path_GREP"
4006 ac_path_GREP_max=$ac_count
4007 fi
4008 # 10*(2^10) chars as input seems more than enough
4009 test $ac_count -gt 10 && break
4010 done
4011 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
4012 esac
4013
4014
4015 $ac_path_GREP_found && break 3
4016 done
4017 done
4018
4019 done
4020 IFS=$as_save_IFS
4021
4022
4023 fi
4024
4025 GREP="$ac_cv_path_GREP"
4026 if test -z "$GREP"; then
4027 { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
4028 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
4029 { (exit 1); exit 1; }; }
4030 fi
4031
4032 else
4033 ac_cv_path_GREP=$GREP
4034 fi
4035
4036
4037 fi
4038 { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
4039 echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
4040 GREP="$ac_cv_path_GREP"
4041
4042
4043 { echo "$as_me:$LINENO: checking for egrep" >&5
4044 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
4045 if test "${ac_cv_path_EGREP+set}" = set; then
4046 echo $ECHO_N "(cached) $ECHO_C" >&6
4047 else
4048 if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
4049 then ac_cv_path_EGREP="$GREP -E"
4050 else
4051 # Extract the first word of "egrep" to use in msg output
4052 if test -z "$EGREP"; then
4053 set dummy egrep; ac_prog_name=$2
4054 if test "${ac_cv_path_EGREP+set}" = set; then
4055 echo $ECHO_N "(cached) $ECHO_C" >&6
4056 else
4057 ac_path_EGREP_found=false
4058 # Loop through the user's path and test for each of PROGNAME-LIST
4059 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4060 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
4061 do
4062 IFS=$as_save_IFS
4063 test -z "$as_dir" && as_dir=.
4064 for ac_prog in egrep; do
4065 for ac_exec_ext in '' $ac_executable_extensions; do
4066 ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
4067 { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
4068 # Check for GNU ac_path_EGREP and select it if it is found.
4069 # Check for GNU $ac_path_EGREP
4070 case `"$ac_path_EGREP" --version 2>&1` in
4071 *GNU*)
4072 ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
4073 *)
4074 ac_count=0
4075 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
4076 while :
4077 do
4078 cat "conftest.in" "conftest.in" >"conftest.tmp"
4079 mv "conftest.tmp" "conftest.in"
4080 cp "conftest.in" "conftest.nl"
4081 echo 'EGREP' >> "conftest.nl"
4082 "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
4083 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
4084 ac_count=`expr $ac_count + 1`
4085 if test $ac_count -gt ${ac_path_EGREP_max-0}; then
4086 # Best one so far, save it but keep looking for a better one
4087 ac_cv_path_EGREP="$ac_path_EGREP"
4088 ac_path_EGREP_max=$ac_count
4089 fi
4090 # 10*(2^10) chars as input seems more than enough
4091 test $ac_count -gt 10 && break
4092 done
4093 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
4094 esac
4095
4096
4097 $ac_path_EGREP_found && break 3
4098 done
4099 done
4100
4101 done
4102 IFS=$as_save_IFS
4103
4104
4105 fi
4106
4107 EGREP="$ac_cv_path_EGREP"
4108 if test -z "$EGREP"; then
4109 { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
4110 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
4111 { (exit 1); exit 1; }; }
4112 fi
4113
4114 else
4115 ac_cv_path_EGREP=$EGREP
4116 fi
4117
4118
4119 fi
4120 fi
4121 { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
4122 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
4123 EGREP="$ac_cv_path_EGREP"
4124
4125
4126 { echo "$as_me:$LINENO: checking for fgrep" >&5
4127 echo $ECHO_N "checking for fgrep... $ECHO_C" >&6; }
4128 if test "${ac_cv_path_FGREP+set}" = set; then
4129 echo $ECHO_N "(cached) $ECHO_C" >&6
4130 else
4131 if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
4132 then ac_cv_path_FGREP="$GREP -F"
4133 else
4134 # Extract the first word of "fgrep" to use in msg output
4135 if test -z "$FGREP"; then
4136 set dummy fgrep; ac_prog_name=$2
4137 if test "${ac_cv_path_FGREP+set}" = set; then
4138 echo $ECHO_N "(cached) $ECHO_C" >&6
4139 else
4140 ac_path_FGREP_found=false
4141 # Loop through the user's path and test for each of PROGNAME-LIST
4142 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4143 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
4144 do
4145 IFS=$as_save_IFS
4146 test -z "$as_dir" && as_dir=.
4147 for ac_prog in fgrep; do
4148 for ac_exec_ext in '' $ac_executable_extensions; do
4149 ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
4150 { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
4151 # Check for GNU ac_path_FGREP and select it if it is found.
4152 # Check for GNU $ac_path_FGREP
4153 case `"$ac_path_FGREP" --version 2>&1` in
4154 *GNU*)
4155 ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
4156 *)
4157 ac_count=0
4158 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
4159 while :
4160 do
4161 cat "conftest.in" "conftest.in" >"conftest.tmp"
4162 mv "conftest.tmp" "conftest.in"
4163 cp "conftest.in" "conftest.nl"
4164 echo 'FGREP' >> "conftest.nl"
4165 "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
4166 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
4167 ac_count=`expr $ac_count + 1`
4168 if test $ac_count -gt ${ac_path_FGREP_max-0}; then
4169 # Best one so far, save it but keep looking for a better one
4170 ac_cv_path_FGREP="$ac_path_FGREP"
4171 ac_path_FGREP_max=$ac_count
4172 fi
4173 # 10*(2^10) chars as input seems more than enough
4174 test $ac_count -gt 10 && break
4175 done
4176 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
4177 esac
4178
4179
4180 $ac_path_FGREP_found && break 3
4181 done
4182 done
4183
4184 done
4185 IFS=$as_save_IFS
4186
4187
4188 fi
4189
4190 FGREP="$ac_cv_path_FGREP"
4191 if test -z "$FGREP"; then
4192 { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
4193 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
4194 { (exit 1); exit 1; }; }
4195 fi
4196
4197 else
4198 ac_cv_path_FGREP=$FGREP
4199 fi
4200
4201
4202 fi
4203 fi
4204 { echo "$as_me:$LINENO: result: $ac_cv_path_FGREP" >&5
4205 echo "${ECHO_T}$ac_cv_path_FGREP" >&6; }
4206 FGREP="$ac_cv_path_FGREP"
4207
4208
4209 test -z "$GREP" && GREP=grep
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229 # Check whether --with-gnu-ld was given.
4230 if test "${with_gnu_ld+set}" = set; then
4231 withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
4232 else
4233 with_gnu_ld=no
4234 fi
4235
4236 ac_prog=ld
4237 if test "$GCC" = yes; then
4238 # Check if gcc -print-prog-name=ld gives a path.
4239 { echo "$as_me:$LINENO: checking for ld used by $CC" >&5
4240 echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6; }
4241 case $host in
4242 *-*-mingw*)
4243 # gcc leaves a trailing carriage return which upsets mingw
4244 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
4245 *)
4246 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
4247 esac
4248 case $ac_prog in
4249 # Accept absolute paths.
4250 [\\/]* | ?:[\\/]*)
4251 re_direlt='/[^/][^/]*/\.\./'
4252 # Canonicalize the pathname of ld
4253 ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
4254 while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
4255 ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
4256 done
4257 test -z "$LD" && LD="$ac_prog"
4258 ;;
4259 "")
4260 # If it fails, then pretend we aren't using GCC.
4261 ac_prog=ld
4262 ;;
4263 *)
4264 # If it is relative, then search for the first ld in PATH.
4265 with_gnu_ld=unknown
4266 ;;
4267 esac
4268 elif test "$with_gnu_ld" = yes; then
4269 { echo "$as_me:$LINENO: checking for GNU ld" >&5
4270 echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; }
4271 else
4272 { echo "$as_me:$LINENO: checking for non-GNU ld" >&5
4273 echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; }
4274 fi
4275 if test "${lt_cv_path_LD+set}" = set; then
4276 echo $ECHO_N "(cached) $ECHO_C" >&6
4277 else
4278 if test -z "$LD"; then
4279 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
4280 for ac_dir in $PATH; do
4281 IFS="$lt_save_ifs"
4282 test -z "$ac_dir" && ac_dir=.
4283 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
4284 lt_cv_path_LD="$ac_dir/$ac_prog"
4285 # Check to see if the program is GNU ld. I'd rather use --version,
4286 # but apparently some variants of GNU ld only accept -v.
4287 # Break only if it was the GNU/non-GNU ld that we prefer.
4288 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
4289 *GNU* | *'with BFD'*)
4290 test "$with_gnu_ld" != no && break
4291 ;;
4292 *)
4293 test "$with_gnu_ld" != yes && break
4294 ;;
4295 esac
4296 fi
4297 done
4298 IFS="$lt_save_ifs"
4299 else
4300 lt_cv_path_LD="$LD" # Let the user override the test with a path.
4301 fi
4302 fi
4303
4304 LD="$lt_cv_path_LD"
4305 if test -n "$LD"; then
4306 { echo "$as_me:$LINENO: result: $LD" >&5
4307 echo "${ECHO_T}$LD" >&6; }
4308 else
4309 { echo "$as_me:$LINENO: result: no" >&5
4310 echo "${ECHO_T}no" >&6; }
4311 fi
4312 test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
4313 echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
4314 { (exit 1); exit 1; }; }
4315 { echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
4316 echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; }
4317 if test "${lt_cv_prog_gnu_ld+set}" = set; then
4318 echo $ECHO_N "(cached) $ECHO_C" >&6
4319 else
4320 # I'd rather use --version here, but apparently some GNU lds only accept -v.
4321 case `$LD -v 2>&1 </dev/null` in
4322 *GNU* | *'with BFD'*)
4323 lt_cv_prog_gnu_ld=yes
4324 ;;
4325 *)
4326 lt_cv_prog_gnu_ld=no
4327 ;;
4328 esac
4329 fi
4330 { echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
4331 echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6; }
4332 with_gnu_ld=$lt_cv_prog_gnu_ld
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342 { echo "$as_me:$LINENO: checking for BSD- or MS-compatible name lister (nm)" >&5
4343 echo $ECHO_N "checking for BSD- or MS-compatible name lister (nm)... $ECHO_C" >&6; }
4344 if test "${lt_cv_path_NM+set}" = set; then
4345 echo $ECHO_N "(cached) $ECHO_C" >&6
4346 else
4347 if test -n "$NM"; then
4348 # Let the user override the test.
4349 lt_cv_path_NM="$NM"
4350 else
4351 lt_nm_to_check="${ac_tool_prefix}nm"
4352 if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
4353 lt_nm_to_check="$lt_nm_to_check nm"
4354 fi
4355 for lt_tmp_nm in $lt_nm_to_check; do
4356 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
4357 for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
4358 IFS="$lt_save_ifs"
4359 test -z "$ac_dir" && ac_dir=.
4360 tmp_nm="$ac_dir/$lt_tmp_nm"
4361 if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
4362 # Check to see if the nm accepts a BSD-compat flag.
4363 # Adding the `sed 1q' prevents false positives on HP-UX, which says:
4364 # nm: unknown option "B" ignored
4365 # Tru64's nm complains that /dev/null is an invalid object file
4366 case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
4367 */dev/null* | *'Invalid file or object type'*)
4368 lt_cv_path_NM="$tmp_nm -B"
4369 break
4370 ;;
4371 *)
4372 case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
4373 */dev/null*)
4374 lt_cv_path_NM="$tmp_nm -p"
4375 break
4376 ;;
4377 *)
4378 lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
4379 continue # so that we can try to find one that supports BSD flags
4380 ;;
4381 esac
4382 ;;
4383 esac
4384 fi
4385 done
4386 IFS="$lt_save_ifs"
4387 done
4388 : ${lt_cv_path_NM=no}
4389 fi
4390 fi
4391 { echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
4392 echo "${ECHO_T}$lt_cv_path_NM" >&6; }
4393 if test "$lt_cv_path_NM" != "no"; then
4394 NM="$lt_cv_path_NM"
4395 else
4396 # Didn't find any BSD compatible name lister, look for dumpbin.
4397 if test -n "$ac_tool_prefix"; then
4398 for ac_prog in "dumpbin -symbols" "link -dump -symbols"
4399 do
4400 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
4401 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
4402 { echo "$as_me:$LINENO: checking for $ac_word" >&5
4403 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
4404 if test "${ac_cv_prog_DUMPBIN+set}" = set; then
4405 echo $ECHO_N "(cached) $ECHO_C" >&6
4406 else
4407 if test -n "$DUMPBIN"; then
4408 ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
4409 else
4410 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4411 for as_dir in $PATH
4412 do
4413 IFS=$as_save_IFS
4414 test -z "$as_dir" && as_dir=.
4415 for ac_exec_ext in '' $ac_executable_extensions; do
4416 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
4417 ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
4418 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
4419 break 2
4420 fi
4421 done
4422 done
4423 IFS=$as_save_IFS
4424
4425 fi
4426 fi
4427 DUMPBIN=$ac_cv_prog_DUMPBIN
4428 if test -n "$DUMPBIN"; then
4429 { echo "$as_me:$LINENO: result: $DUMPBIN" >&5
4430 echo "${ECHO_T}$DUMPBIN" >&6; }
4431 else
4432 { echo "$as_me:$LINENO: result: no" >&5
4433 echo "${ECHO_T}no" >&6; }
4434 fi
4435
4436
4437 test -n "$DUMPBIN" && break
4438 done
4439 fi
4440 if test -z "$DUMPBIN"; then
4441 ac_ct_DUMPBIN=$DUMPBIN
4442 for ac_prog in "dumpbin -symbols" "link -dump -symbols"
4443 do
4444 # Extract the first word of "$ac_prog", so it can be a program name with args.
4445 set dummy $ac_prog; ac_word=$2
4446 { echo "$as_me:$LINENO: checking for $ac_word" >&5
4447 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
4448 if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then
4449 echo $ECHO_N "(cached) $ECHO_C" >&6
4450 else
4451 if test -n "$ac_ct_DUMPBIN"; then
4452 ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
4453 else
4454 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4455 for as_dir in $PATH
4456 do
4457 IFS=$as_save_IFS
4458 test -z "$as_dir" && as_dir=.
4459 for ac_exec_ext in '' $ac_executable_extensions; do
4460 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
4461 ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
4462 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
4463 break 2
4464 fi
4465 done
4466 done
4467 IFS=$as_save_IFS
4468
4469 fi
4470 fi
4471 ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
4472 if test -n "$ac_ct_DUMPBIN"; then
4473 { echo "$as_me:$LINENO: result: $ac_ct_DUMPBIN" >&5
4474 echo "${ECHO_T}$ac_ct_DUMPBIN" >&6; }
4475 else
4476 { echo "$as_me:$LINENO: result: no" >&5
4477 echo "${ECHO_T}no" >&6; }
4478 fi
4479
4480
4481 test -n "$ac_ct_DUMPBIN" && break
4482 done
4483
4484 if test "x$ac_ct_DUMPBIN" = x; then
4485 DUMPBIN=":"
4486 else
4487 case $cross_compiling:$ac_tool_warned in
4488 yes:)
4489 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
4490 whose name does not start with the host triplet. If you think this
4491 configuration is useful to you, please write to autoconf@gnu.org." >&5
4492 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
4493 whose name does not start with the host triplet. If you think this
4494 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
4495 ac_tool_warned=yes ;;
4496 esac
4497 DUMPBIN=$ac_ct_DUMPBIN
4498 fi
4499 fi
4500
4501
4502 if test "$DUMPBIN" != ":"; then
4503 NM="$DUMPBIN"
4504 fi
4505 fi
4506 test -z "$NM" && NM=nm
4507
4508
4509
4510
4511
4512
4513 { echo "$as_me:$LINENO: checking the name lister ($NM) interface" >&5
4514 echo $ECHO_N "checking the name lister ($NM) interface... $ECHO_C" >&6; }
4515 if test "${lt_cv_nm_interface+set}" = set; then
4516 echo $ECHO_N "(cached) $ECHO_C" >&6
4517 else
4518 lt_cv_nm_interface="BSD nm"
4519 echo "int some_variable = 0;" > conftest.$ac_ext
4520 (eval echo "\"\$as_me:4521: $ac_compile\"" >&5)
4521 (eval "$ac_compile" 2>conftest.err)
4522 cat conftest.err >&5
4523 (eval echo "\"\$as_me:4524: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
4524 (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
4525 cat conftest.err >&5
4526 (eval echo "\"\$as_me:4527: output\"" >&5)
4527 cat conftest.out >&5
4528 if $GREP 'External.*some_variable' conftest.out > /dev/null; then
4529 lt_cv_nm_interface="MS dumpbin"
4530 fi
4531 rm -r -f conftest*
4532 fi
4533 { echo "$as_me:$LINENO: result: $lt_cv_nm_interface" >&5
4534 echo "${ECHO_T}$lt_cv_nm_interface" >&6; }
4535
4536 { echo "$as_me:$LINENO: checking whether ln -s works" >&5
4537 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; }
4538 LN_S=$as_ln_s
4539 if test "$LN_S" = "ln -s"; then
4540 { echo "$as_me:$LINENO: result: yes" >&5
4541 echo "${ECHO_T}yes" >&6; }
4542 else
4543 { echo "$as_me:$LINENO: result: no, using $LN_S" >&5
4544 echo "${ECHO_T}no, using $LN_S" >&6; }
4545 fi
4546
4547 # find the maximum length of command line arguments
4548 { echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
4549 echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6; }
4550 if test "${lt_cv_sys_max_cmd_len+set}" = set; then
4551 echo $ECHO_N "(cached) $ECHO_C" >&6
4552 else
4553 i=0
4554 teststring="ABCD"
4555
4556 case $build_os in
4557 msdosdjgpp*)
4558 # On DJGPP, this test can blow up pretty badly due to problems in libc
4559 # (any single argument exceeding 2000 bytes causes a buffer overrun
4560 # during glob expansion). Even if it were fixed, the result of this
4561 # check would be larger than it should be.
4562 lt_cv_sys_max_cmd_len=12288; # 12K is about right
4563 ;;
4564
4565 gnu*)
4566 # Under GNU Hurd, this test is not required because there is
4567 # no limit to the length of command line arguments.
4568 # Libtool will interpret -1 as no limit whatsoever
4569 lt_cv_sys_max_cmd_len=-1;
4570 ;;
4571
4572 cygwin* | mingw*)
4573 # On Win9x/ME, this test blows up -- it succeeds, but takes
4574 # about 5 minutes as the teststring grows exponentially.
4575 # Worse, since 9x/ME are not pre-emptively multitasking,
4576 # you end up with a "frozen" computer, even though with patience
4577 # the test eventually succeeds (with a max line length of 256k).
4578 # Instead, let's just punt: use the minimum linelength reported by
4579 # all of the supported platforms: 8192 (on NT/2K/XP).
4580 lt_cv_sys_max_cmd_len=8192;
4581 ;;
4582
4583 amigaos*)
4584 # On AmigaOS with pdksh, this test takes hours, literally.
4585 # So we just punt and use a minimum line length of 8192.
4586 lt_cv_sys_max_cmd_len=8192;
4587 ;;
4588
4589 netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
4590 # This has been around since 386BSD, at least. Likely further.
4591 if test -x /sbin/sysctl; then
4592 lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
4593 elif test -x /usr/sbin/sysctl; then
4594 lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
4595 else
4596 lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
4597 fi
4598 # And add a safety zone
4599 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
4600 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
4601 ;;
4602
4603 interix*)
4604 # We know the value 262144 and hardcode it with a safety zone (like BSD)
4605 lt_cv_sys_max_cmd_len=196608
4606 ;;
4607
4608 osf*)
4609 # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
4610 # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
4611 # nice to cause kernel panics so lets avoid the loop below.
4612 # First set a reasonable default.
4613 lt_cv_sys_max_cmd_len=16384
4614 #
4615 if test -x /sbin/sysconfig; then
4616 case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
4617 *1*) lt_cv_sys_max_cmd_len=-1 ;;
4618 esac
4619 fi
4620 ;;
4621 sco3.2v5*)
4622 lt_cv_sys_max_cmd_len=102400
4623 ;;
4624 sysv5* | sco5v6* | sysv4.2uw2*)
4625 kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
4626 if test -n "$kargmax"; then
4627 lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
4628 else
4629 lt_cv_sys_max_cmd_len=32768
4630 fi
4631 ;;
4632 *)
4633 lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
4634 if test -n "$lt_cv_sys_max_cmd_len"; then
4635 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
4636 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
4637 else
4638 # Make teststring a little bigger before we do anything with it.
4639 # a 1K string should be a reasonable start.
4640 for i in 1 2 3 4 5 6 7 8 ; do
4641 teststring=$teststring$teststring
4642 done
4643 SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
4644 # If test is not a shell built-in, we'll probably end up computing a
4645 # maximum length that is only half of the actual maximum length, but
4646 # we can't tell.
4647 while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
4648 = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
4649 test $i != 17 # 1/2 MB should be enough
4650 do
4651 i=`expr $i + 1`
4652 teststring=$teststring$teststring
4653 done
4654 # Only check the string length outside the loop.
4655 lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
4656 teststring=
4657 # Add a significant safety factor because C++ compilers can tack on
4658 # massive amounts of additional arguments before passing them to the
4659 # linker. It appears as though 1/2 is a usable value.
4660 lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
4661 fi
4662 ;;
4663 esac
4664
4665 fi
4666
4667 if test -n $lt_cv_sys_max_cmd_len ; then
4668 { echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
4669 echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6; }
4670 else
4671 { echo "$as_me:$LINENO: result: none" >&5
4672 echo "${ECHO_T}none" >&6; }
4673 fi
4674 max_cmd_len=$lt_cv_sys_max_cmd_len
4675
4676
4677
4678
4679
4680
4681 : ${CP="cp -f"}
4682 : ${MV="mv -f"}
4683 : ${RM="rm -f"}
4684
4685 { echo "$as_me:$LINENO: checking whether the shell understands some XSI constructs" >&5
4686 echo $ECHO_N "checking whether the shell understands some XSI constructs... $ECHO_C" >&6; }
4687 # Try some XSI features
4688 xsi_shell=no
4689 ( _lt_dummy="a/b/c"
4690 test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
4691 = c,a/b,, \
4692 && eval 'test $(( 1 + 1 )) -eq 2 \
4693 && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
4694 && xsi_shell=yes
4695 { echo "$as_me:$LINENO: result: $xsi_shell" >&5
4696 echo "${ECHO_T}$xsi_shell" >&6; }
4697
4698
4699 { echo "$as_me:$LINENO: checking whether the shell understands \"+=\"" >&5
4700 echo $ECHO_N "checking whether the shell understands \"+=\"... $ECHO_C" >&6; }
4701 lt_shell_append=no
4702 ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
4703 >/dev/null 2>&1 \
4704 && lt_shell_append=yes
4705 { echo "$as_me:$LINENO: result: $lt_shell_append" >&5
4706 echo "${ECHO_T}$lt_shell_append" >&6; }
4707
4708
4709 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
4710 lt_unset=unset
4711 else
4712 lt_unset=false
4713 fi
4714
4715
4716
4717
4718
4719 # test EBCDIC or ASCII
4720 case `echo X|tr X '\101'` in
4721 A) # ASCII based system
4722 # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
4723 lt_SP2NL='tr \040 \012'
4724 lt_NL2SP='tr \015\012 \040\040'
4725 ;;
4726 *) # EBCDIC based system
4727 lt_SP2NL='tr \100 \n'
4728 lt_NL2SP='tr \r\n \100\100'
4729 ;;
4730 esac
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740 { echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
4741 echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6; }
4742 if test "${lt_cv_ld_reload_flag+set}" = set; then
4743 echo $ECHO_N "(cached) $ECHO_C" >&6
4744 else
4745 lt_cv_ld_reload_flag='-r'
4746 fi
4747 { echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
4748 echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6; }
4749 reload_flag=$lt_cv_ld_reload_flag
4750 case $reload_flag in
4751 "" | " "*) ;;
4752 *) reload_flag=" $reload_flag" ;;
4753 esac
4754 reload_cmds='$LD$reload_flag -o $output$reload_objs'
4755 case $host_os in
4756 darwin*)
4757 if test "$GCC" = yes; then
4758 reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
4759 else
4760 reload_cmds='$LD$reload_flag -o $output$reload_objs'
4761 fi
4762 ;;
4763 esac
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774 { echo "$as_me:$LINENO: checking how to recognize dependent libraries" >&5
4775 echo $ECHO_N "checking how to recognize dependent libraries... $ECHO_C" >&6; }
4776 if test "${lt_cv_deplibs_check_method+set}" = set; then
4777 echo $ECHO_N "(cached) $ECHO_C" >&6
4778 else
4779 lt_cv_file_magic_cmd='$MAGIC_CMD'
4780 lt_cv_file_magic_test_file=
4781 lt_cv_deplibs_check_method='unknown'
4782 # Need to set the preceding variable on all platforms that support
4783 # interlibrary dependencies.
4784 # 'none' -- dependencies not supported.
4785 # `unknown' -- same as none, but documents that we really don't know.
4786 # 'pass_all' -- all dependencies passed with no checks.
4787 # 'test_compile' -- check by making test program.
4788 # 'file_magic [[regex]]' -- check by looking for files in library path
4789 # which responds to the $file_magic_cmd with a given extended regex.
4790 # If you have `file' or equivalent on your system and you're not sure
4791 # whether `pass_all' will *always* work, you probably want this one.
4792
4793 case $host_os in
4794 aix[4-9]*)
4795 lt_cv_deplibs_check_method=pass_all
4796 ;;
4797
4798 beos*)
4799 lt_cv_deplibs_check_method=pass_all
4800 ;;
4801
4802 bsdi[45]*)
4803 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
4804 lt_cv_file_magic_cmd='/usr/bin/file -L'
4805 lt_cv_file_magic_test_file=/shlib/libc.so
4806 ;;
4807
4808 cygwin*)
4809 # func_win32_libid is a shell function defined in ltmain.sh
4810 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
4811 lt_cv_file_magic_cmd='func_win32_libid'
4812 ;;
4813
4814 mingw* | pw32*)
4815 # Base MSYS/MinGW do not provide the 'file' command needed by
4816 # func_win32_libid shell function, so use a weaker test based on 'objdump',
4817 # unless we find 'file', for example because we are cross-compiling.
4818 if ( file / ) >/dev/null 2>&1; then
4819 lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
4820 lt_cv_file_magic_cmd='func_win32_libid'
4821 else
4822 lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
4823 lt_cv_file_magic_cmd='$OBJDUMP -f'
4824 fi
4825 ;;
4826
4827 darwin* | rhapsody*)
4828 lt_cv_deplibs_check_method=pass_all
4829 ;;
4830
4831 freebsd* | dragonfly*)
4832 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
4833 case $host_cpu in
4834 i*86 )
4835 # Not sure whether the presence of OpenBSD here was a mistake.
4836 # Let's accept both of them until this is cleared up.
4837 lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
4838 lt_cv_file_magic_cmd=/usr/bin/file
4839 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
4840 ;;
4841 esac
4842 else
4843 lt_cv_deplibs_check_method=pass_all
4844 fi
4845 ;;
4846
4847 gnu*)
4848 lt_cv_deplibs_check_method=pass_all
4849 ;;
4850
4851 hpux10.20* | hpux11*)
4852 lt_cv_file_magic_cmd=/usr/bin/file
4853 case $host_cpu in
4854 ia64*)
4855 lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
4856 lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
4857 ;;
4858 hppa*64*)
4859 lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
4860 lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
4861 ;;
4862 *)
4863 lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
4864 lt_cv_file_magic_test_file=/usr/lib/libc.sl
4865 ;;
4866 esac
4867 ;;
4868
4869 interix[3-9]*)
4870 # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
4871 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
4872 ;;
4873
4874 irix5* | irix6* | nonstopux*)
4875 case $LD in
4876 *-32|*"-32 ") libmagic=32-bit;;
4877 *-n32|*"-n32 ") libmagic=N32;;
4878 *-64|*"-64 ") libmagic=64-bit;;
4879 *) libmagic=never-match;;
4880 esac
4881 lt_cv_deplibs_check_method=pass_all
4882 ;;
4883
4884 # This must be Linux ELF.
4885 linux* | k*bsd*-gnu)
4886 lt_cv_deplibs_check_method=pass_all
4887 ;;
4888
4889 netbsd*)
4890 if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
4891 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
4892 else
4893 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
4894 fi
4895 ;;
4896
4897 newos6*)
4898 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
4899 lt_cv_file_magic_cmd=/usr/bin/file
4900 lt_cv_file_magic_test_file=/usr/lib/libnls.so
4901 ;;
4902
4903 *nto* | *qnx*)
4904 lt_cv_deplibs_check_method=pass_all
4905 ;;
4906
4907 openbsd*)
4908 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
4909 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
4910 else
4911 lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
4912 fi
4913 ;;
4914
4915 osf3* | osf4* | osf5*)
4916 lt_cv_deplibs_check_method=pass_all
4917 ;;
4918
4919 rdos*)
4920 lt_cv_deplibs_check_method=pass_all
4921 ;;
4922
4923 solaris*)
4924 lt_cv_deplibs_check_method=pass_all
4925 ;;
4926
4927 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
4928 lt_cv_deplibs_check_method=pass_all
4929 ;;
4930
4931 sysv4 | sysv4.3*)
4932 case $host_vendor in
4933 motorola)
4934 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
4935 lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
4936 ;;
4937 ncr)
4938 lt_cv_deplibs_check_method=pass_all
4939 ;;
4940 sequent)
4941 lt_cv_file_magic_cmd='/bin/file'
4942 lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
4943 ;;
4944 sni)
4945 lt_cv_file_magic_cmd='/bin/file'
4946 lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
4947 lt_cv_file_magic_test_file=/lib/libc.so
4948 ;;
4949 siemens)
4950 lt_cv_deplibs_check_method=pass_all
4951 ;;
4952 pc)
4953 lt_cv_deplibs_check_method=pass_all
4954 ;;
4955 esac
4956 ;;
4957
4958 tpf*)
4959 lt_cv_deplibs_check_method=pass_all
4960 ;;
4961 esac
4962
4963 fi
4964 { echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
4965 echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6; }
4966 file_magic_cmd=$lt_cv_file_magic_cmd
4967 deplibs_check_method=$lt_cv_deplibs_check_method
4968 test -z "$deplibs_check_method" && deplibs_check_method=unknown
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981 if test -n "$ac_tool_prefix"; then
4982 # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
4983 set dummy ${ac_tool_prefix}ar; ac_word=$2
4984 { echo "$as_me:$LINENO: checking for $ac_word" >&5
4985 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
4986 if test "${ac_cv_prog_AR+set}" = set; then
4987 echo $ECHO_N "(cached) $ECHO_C" >&6
4988 else
4989 if test -n "$AR"; then
4990 ac_cv_prog_AR="$AR" # Let the user override the test.
4991 else
4992 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4993 for as_dir in $PATH
4994 do
4995 IFS=$as_save_IFS
4996 test -z "$as_dir" && as_dir=.
4997 for ac_exec_ext in '' $ac_executable_extensions; do
4998 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
4999 ac_cv_prog_AR="${ac_tool_prefix}ar"
5000 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5001 break 2
5002 fi
5003 done
5004 done
5005 IFS=$as_save_IFS
5006
5007 fi
5008 fi
5009 AR=$ac_cv_prog_AR
5010 if test -n "$AR"; then
5011 { echo "$as_me:$LINENO: result: $AR" >&5
5012 echo "${ECHO_T}$AR" >&6; }
5013 else
5014 { echo "$as_me:$LINENO: result: no" >&5
5015 echo "${ECHO_T}no" >&6; }
5016 fi
5017
5018
5019 fi
5020 if test -z "$ac_cv_prog_AR"; then
5021 ac_ct_AR=$AR
5022 # Extract the first word of "ar", so it can be a program name with args.
5023 set dummy ar; ac_word=$2
5024 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5025 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5026 if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
5027 echo $ECHO_N "(cached) $ECHO_C" >&6
5028 else
5029 if test -n "$ac_ct_AR"; then
5030 ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
5031 else
5032 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5033 for as_dir in $PATH
5034 do
5035 IFS=$as_save_IFS
5036 test -z "$as_dir" && as_dir=.
5037 for ac_exec_ext in '' $ac_executable_extensions; do
5038 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5039 ac_cv_prog_ac_ct_AR="ar"
5040 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5041 break 2
5042 fi
5043 done
5044 done
5045 IFS=$as_save_IFS
5046
5047 fi
5048 fi
5049 ac_ct_AR=$ac_cv_prog_ac_ct_AR
5050 if test -n "$ac_ct_AR"; then
5051 { echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
5052 echo "${ECHO_T}$ac_ct_AR" >&6; }
5053 else
5054 { echo "$as_me:$LINENO: result: no" >&5
5055 echo "${ECHO_T}no" >&6; }
5056 fi
5057
5058 if test "x$ac_ct_AR" = x; then
5059 AR="false"
5060 else
5061 case $cross_compiling:$ac_tool_warned in
5062 yes:)
5063 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
5064 whose name does not start with the host triplet. If you think this
5065 configuration is useful to you, please write to autoconf@gnu.org." >&5
5066 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
5067 whose name does not start with the host triplet. If you think this
5068 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
5069 ac_tool_warned=yes ;;
5070 esac
5071 AR=$ac_ct_AR
5072 fi
5073 else
5074 AR="$ac_cv_prog_AR"
5075 fi
5076
5077 test -z "$AR" && AR=ar
5078 test -z "$AR_FLAGS" && AR_FLAGS=cru
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090 if test -n "$ac_tool_prefix"; then
5091 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
5092 set dummy ${ac_tool_prefix}strip; ac_word=$2
5093 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5094 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5095 if test "${ac_cv_prog_STRIP+set}" = set; then
5096 echo $ECHO_N "(cached) $ECHO_C" >&6
5097 else
5098 if test -n "$STRIP"; then
5099 ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
5100 else
5101 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5102 for as_dir in $PATH
5103 do
5104 IFS=$as_save_IFS
5105 test -z "$as_dir" && as_dir=.
5106 for ac_exec_ext in '' $ac_executable_extensions; do
5107 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5108 ac_cv_prog_STRIP="${ac_tool_prefix}strip"
5109 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5110 break 2
5111 fi
5112 done
5113 done
5114 IFS=$as_save_IFS
5115
5116 fi
5117 fi
5118 STRIP=$ac_cv_prog_STRIP
5119 if test -n "$STRIP"; then
5120 { echo "$as_me:$LINENO: result: $STRIP" >&5
5121 echo "${ECHO_T}$STRIP" >&6; }
5122 else
5123 { echo "$as_me:$LINENO: result: no" >&5
5124 echo "${ECHO_T}no" >&6; }
5125 fi
5126
5127
5128 fi
5129 if test -z "$ac_cv_prog_STRIP"; then
5130 ac_ct_STRIP=$STRIP
5131 # Extract the first word of "strip", so it can be a program name with args.
5132 set dummy strip; ac_word=$2
5133 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5134 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5135 if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
5136 echo $ECHO_N "(cached) $ECHO_C" >&6
5137 else
5138 if test -n "$ac_ct_STRIP"; then
5139 ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
5140 else
5141 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5142 for as_dir in $PATH
5143 do
5144 IFS=$as_save_IFS
5145 test -z "$as_dir" && as_dir=.
5146 for ac_exec_ext in '' $ac_executable_extensions; do
5147 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5148 ac_cv_prog_ac_ct_STRIP="strip"
5149 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5150 break 2
5151 fi
5152 done
5153 done
5154 IFS=$as_save_IFS
5155
5156 fi
5157 fi
5158 ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
5159 if test -n "$ac_ct_STRIP"; then
5160 { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
5161 echo "${ECHO_T}$ac_ct_STRIP" >&6; }
5162 else
5163 { echo "$as_me:$LINENO: result: no" >&5
5164 echo "${ECHO_T}no" >&6; }
5165 fi
5166
5167 if test "x$ac_ct_STRIP" = x; then
5168 STRIP=":"
5169 else
5170 case $cross_compiling:$ac_tool_warned in
5171 yes:)
5172 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
5173 whose name does not start with the host triplet. If you think this
5174 configuration is useful to you, please write to autoconf@gnu.org." >&5
5175 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
5176 whose name does not start with the host triplet. If you think this
5177 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
5178 ac_tool_warned=yes ;;
5179 esac
5180 STRIP=$ac_ct_STRIP
5181 fi
5182 else
5183 STRIP="$ac_cv_prog_STRIP"
5184 fi
5185
5186 test -z "$STRIP" && STRIP=:
5187
5188
5189
5190
5191
5192
5193 if test -n "$ac_tool_prefix"; then
5194 # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
5195 set dummy ${ac_tool_prefix}ranlib; ac_word=$2
5196 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5197 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5198 if test "${ac_cv_prog_RANLIB+set}" = set; then
5199 echo $ECHO_N "(cached) $ECHO_C" >&6
5200 else
5201 if test -n "$RANLIB"; then
5202 ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
5203 else
5204 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5205 for as_dir in $PATH
5206 do
5207 IFS=$as_save_IFS
5208 test -z "$as_dir" && as_dir=.
5209 for ac_exec_ext in '' $ac_executable_extensions; do
5210 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5211 ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
5212 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5213 break 2
5214 fi
5215 done
5216 done
5217 IFS=$as_save_IFS
5218
5219 fi
5220 fi
5221 RANLIB=$ac_cv_prog_RANLIB
5222 if test -n "$RANLIB"; then
5223 { echo "$as_me:$LINENO: result: $RANLIB" >&5
5224 echo "${ECHO_T}$RANLIB" >&6; }
5225 else
5226 { echo "$as_me:$LINENO: result: no" >&5
5227 echo "${ECHO_T}no" >&6; }
5228 fi
5229
5230
5231 fi
5232 if test -z "$ac_cv_prog_RANLIB"; then
5233 ac_ct_RANLIB=$RANLIB
5234 # Extract the first word of "ranlib", so it can be a program name with args.
5235 set dummy ranlib; ac_word=$2
5236 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5237 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5238 if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
5239 echo $ECHO_N "(cached) $ECHO_C" >&6
5240 else
5241 if test -n "$ac_ct_RANLIB"; then
5242 ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
5243 else
5244 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5245 for as_dir in $PATH
5246 do
5247 IFS=$as_save_IFS
5248 test -z "$as_dir" && as_dir=.
5249 for ac_exec_ext in '' $ac_executable_extensions; do
5250 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5251 ac_cv_prog_ac_ct_RANLIB="ranlib"
5252 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5253 break 2
5254 fi
5255 done
5256 done
5257 IFS=$as_save_IFS
5258
5259 fi
5260 fi
5261 ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
5262 if test -n "$ac_ct_RANLIB"; then
5263 { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
5264 echo "${ECHO_T}$ac_ct_RANLIB" >&6; }
5265 else
5266 { echo "$as_me:$LINENO: result: no" >&5
5267 echo "${ECHO_T}no" >&6; }
5268 fi
5269
5270 if test "x$ac_ct_RANLIB" = x; then
5271 RANLIB=":"
5272 else
5273 case $cross_compiling:$ac_tool_warned in
5274 yes:)
5275 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
5276 whose name does not start with the host triplet. If you think this
5277 configuration is useful to you, please write to autoconf@gnu.org." >&5
5278 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
5279 whose name does not start with the host triplet. If you think this
5280 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
5281 ac_tool_warned=yes ;;
5282 esac
5283 RANLIB=$ac_ct_RANLIB
5284 fi
5285 else
5286 RANLIB="$ac_cv_prog_RANLIB"
5287 fi
5288
5289 test -z "$RANLIB" && RANLIB=:
5290
5291
5292
5293
5294
5295
5296 # Determine commands to create old-style static archives.
5297 old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
5298 old_postinstall_cmds='chmod 644 $oldlib'
5299 old_postuninstall_cmds=
5300
5301 if test -n "$RANLIB"; then
5302 case $host_os in
5303 openbsd*)
5304 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
5305 ;;
5306 *)
5307 old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
5308 ;;
5309 esac
5310 old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
5311 fi
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346 # If no C compiler was specified, use CC.
5347 LTCC=${LTCC-"$CC"}
5348
5349 # If no C compiler flags were specified, use CFLAGS.
5350 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
5351
5352 # Allow CC to be a program name with arguments.
5353 compiler=$CC
5354
5355
5356 # Check for command to grab the raw symbol name followed by C symbol from nm.
5357 { echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
5358 echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6; }
5359 if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
5360 echo $ECHO_N "(cached) $ECHO_C" >&6
5361 else
5362
5363 # These are sane defaults that work on at least a few old systems.
5364 # [They come from Ultrix. What could be older than Ultrix?!! ;)]
5365
5366 # Character class describing NM global symbol codes.
5367 symcode='[BCDEGRST]'
5368
5369 # Regexp to match symbols that can be accessed directly from C.
5370 sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
5371
5372 # Define system-specific variables.
5373 case $host_os in
5374 aix*)
5375 symcode='[BCDT]'
5376 ;;
5377 cygwin* | mingw* | pw32*)
5378 symcode='[ABCDGISTW]'
5379 ;;
5380 hpux*)
5381 if test "$host_cpu" = ia64; then
5382 symcode='[ABCDEGRST]'
5383 fi
5384 ;;
5385 irix* | nonstopux*)
5386 symcode='[BCDEGRST]'
5387 ;;
5388 osf*)
5389 symcode='[BCDEGQRST]'
5390 ;;
5391 solaris*)
5392 symcode='[BDRT]'
5393 ;;
5394 sco3.2v5*)
5395 symcode='[DT]'
5396 ;;
5397 sysv4.2uw2*)
5398 symcode='[DT]'
5399 ;;
5400 sysv5* | sco5v6* | unixware* | OpenUNIX*)
5401 symcode='[ABDT]'
5402 ;;
5403 sysv4)
5404 symcode='[DFNSTU]'
5405 ;;
5406 esac
5407
5408 # If we're using GNU nm, then use its standard symbol codes.
5409 case `$NM -V 2>&1` in
5410 *GNU* | *'with BFD'*)
5411 symcode='[ABCDGIRSTW]' ;;
5412 esac
5413
5414 # Transform an extracted symbol line into a proper C declaration.
5415 # Some systems (esp. on ia64) link data and code symbols differently,
5416 # so use this general approach.
5417 lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
5418
5419 # Transform an extracted symbol line into symbol name and symbol address
5420 lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'"
5421 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
5422
5423 # Handle CRLF in mingw tool chain
5424 opt_cr=
5425 case $build_os in
5426 mingw*)
5427 opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
5428 ;;
5429 esac
5430
5431 # Try without a prefix underscore, then with it.
5432 for ac_symprfx in "" "_"; do
5433
5434 # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
5435 symxfrm="\\1 $ac_symprfx\\2 \\2"
5436
5437 # Write the raw and C identifiers.
5438 if test "$lt_cv_nm_interface" = "MS dumpbin"; then
5439 # Fake it for dumpbin and say T for any non-static function
5440 # and D for any global variable.
5441 # Also find C++ and __fastcall symbols from MSVC++,
5442 # which start with @ or ?.
5443 lt_cv_sys_global_symbol_pipe="$AWK '"\
5444 " {last_section=section; section=\$ 3};"\
5445 " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
5446 " \$ 0!~/External *\|/{next};"\
5447 " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
5448 " {if(hide[section]) next};"\
5449 " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
5450 " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
5451 " s[1]~/^[@?]/{print s[1], s[1]; next};"\
5452 " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
5453 " ' prfx=^$ac_symprfx"
5454 else
5455 lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
5456 fi
5457
5458 # Check to see that the pipe works correctly.
5459 pipe_works=no
5460
5461 rm -r -f conftest*
5462 cat > conftest.$ac_ext <<_LT_EOF
5463 #ifdef __cplusplus
5464 extern "C" {
5465 #endif
5466 char nm_test_var;
5467 void nm_test_func(void);
5468 void nm_test_func(void){}
5469 #ifdef __cplusplus
5470 }
5471 #endif
5472 int main(){nm_test_var='a';nm_test_func();return(0);}
5473 _LT_EOF
5474
5475 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5476 (eval $ac_compile) 2>&5
5477 ac_status=$?
5478 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5479 (exit $ac_status); }; then
5480 # Now try to grab the symbols.
5481 nlist=conftest.nm
5482 if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
5483 (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
5484 ac_status=$?
5485 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5486 (exit $ac_status); } && test -s "$nlist"; then
5487 # Try sorting and uniquifying the output.
5488 if sort "$nlist" | uniq > "$nlist"T; then
5489 mv -f "$nlist"T "$nlist"
5490 else
5491 rm -f "$nlist"T
5492 fi
5493
5494 # Make sure that we snagged all the symbols we need.
5495 if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
5496 if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
5497 cat <<_LT_EOF > conftest.$ac_ext
5498 #ifdef __cplusplus
5499 extern "C" {
5500 #endif
5501
5502 _LT_EOF
5503 # Now generate the symbol file.
5504 eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
5505
5506 cat <<_LT_EOF >> conftest.$ac_ext
5507
5508 /* The mapping between symbol names and symbols. */
5509 const struct {
5510 const char *name;
5511 void *address;
5512 }
5513 lt__PROGRAM__LTX_preloaded_symbols[] =
5514 {
5515 { "@PROGRAM@", (void *) 0 },
5516 _LT_EOF
5517 $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
5518 cat <<\_LT_EOF >> conftest.$ac_ext
5519 {0, (void *) 0}
5520 };
5521
5522 /* This works around a problem in FreeBSD linker */
5523 #ifdef FREEBSD_WORKAROUND
5524 static const void *lt_preloaded_setup() {
5525 return lt__PROGRAM__LTX_preloaded_symbols;
5526 }
5527 #endif
5528
5529 #ifdef __cplusplus
5530 }
5531 #endif
5532 _LT_EOF
5533 # Now try linking the two files.
5534 mv conftest.$ac_objext conftstm.$ac_objext
5535 lt_save_LIBS="$LIBS"
5536 lt_save_CFLAGS="$CFLAGS"
5537 LIBS="conftstm.$ac_objext"
5538 CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
5539 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
5540 (eval $ac_link) 2>&5
5541 ac_status=$?
5542 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5543 (exit $ac_status); } && test -s conftest${ac_exeext}; then
5544 pipe_works=yes
5545 fi
5546 LIBS="$lt_save_LIBS"
5547 CFLAGS="$lt_save_CFLAGS"
5548 else
5549 echo "cannot find nm_test_func in $nlist" >&5
5550 fi
5551 else
5552 echo "cannot find nm_test_var in $nlist" >&5
5553 fi
5554 else
5555 echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
5556 fi
5557 else
5558 echo "$progname: failed program was:" >&5
5559 cat conftest.$ac_ext >&5
5560 fi
5561 rm -rf conftest* conftst*
5562
5563 # Do not use the global_symbol_pipe unless it works.
5564 if test "$pipe_works" = yes; then
5565 break
5566 else
5567 lt_cv_sys_global_symbol_pipe=
5568 fi
5569 done
5570
5571 fi
5572
5573 if test -z "$lt_cv_sys_global_symbol_pipe"; then
5574 lt_cv_sys_global_symbol_to_cdecl=
5575 fi
5576 if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
5577 { echo "$as_me:$LINENO: result: failed" >&5
5578 echo "${ECHO_T}failed" >&6; }
5579 else
5580 { echo "$as_me:$LINENO: result: ok" >&5
5581 echo "${ECHO_T}ok" >&6; }
5582 fi
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606 # Check whether --enable-libtool-lock was given.
5607 if test "${enable_libtool_lock+set}" = set; then
5608 enableval=$enable_libtool_lock;
5609 fi
5610
5611 test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
5612
5613 # Some flags need to be propagated to the compiler or linker for good
5614 # libtool support.
5615 case $host in
5616 ia64-*-hpux*)
5617 # Find out which ABI we are using.
5618 echo 'int i;' > conftest.$ac_ext
5619 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5620 (eval $ac_compile) 2>&5
5621 ac_status=$?
5622 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5623 (exit $ac_status); }; then
5624 case `/usr/bin/file conftest.$ac_objext` in
5625 *ELF-32*)
5626 HPUX_IA64_MODE="32"
5627 ;;
5628 *ELF-64*)
5629 HPUX_IA64_MODE="64"
5630 ;;
5631 esac
5632 fi
5633 rm -rf conftest*
5634 ;;
5635 *-*-irix6*)
5636 # Find out which ABI we are using.
5637 echo '#line 5638 "configure"' > conftest.$ac_ext
5638 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5639 (eval $ac_compile) 2>&5
5640 ac_status=$?
5641 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5642 (exit $ac_status); }; then
5643 if test "$lt_cv_prog_gnu_ld" = yes; then
5644 case `/usr/bin/file conftest.$ac_objext` in
5645 *32-bit*)
5646 LD="${LD-ld} -melf32bsmip"
5647 ;;
5648 *N32*)
5649 LD="${LD-ld} -melf32bmipn32"
5650 ;;
5651 *64-bit*)
5652 LD="${LD-ld} -melf64bmip"
5653 ;;
5654 esac
5655 else
5656 case `/usr/bin/file conftest.$ac_objext` in
5657 *32-bit*)
5658 LD="${LD-ld} -32"
5659 ;;
5660 *N32*)
5661 LD="${LD-ld} -n32"
5662 ;;
5663 *64-bit*)
5664 LD="${LD-ld} -64"
5665 ;;
5666 esac
5667 fi
5668 fi
5669 rm -rf conftest*
5670 ;;
5671
5672 x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
5673 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
5674 # Find out which ABI we are using.
5675 echo 'int i;' > conftest.$ac_ext
5676 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5677 (eval $ac_compile) 2>&5
5678 ac_status=$?
5679 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5680 (exit $ac_status); }; then
5681 case `/usr/bin/file conftest.o` in
5682 *32-bit*)
5683 case $host in
5684 x86_64-*kfreebsd*-gnu)
5685 LD="${LD-ld} -m elf_i386_fbsd"
5686 ;;
5687 x86_64-*linux*)
5688 LD="${LD-ld} -m elf_i386"
5689 ;;
5690 ppc64-*linux*|powerpc64-*linux*)
5691 LD="${LD-ld} -m elf32ppclinux"
5692 ;;
5693 s390x-*linux*)
5694 LD="${LD-ld} -m elf_s390"
5695 ;;
5696 sparc64-*linux*)
5697 LD="${LD-ld} -m elf32_sparc"
5698 ;;
5699 esac
5700 ;;
5701 *64-bit*)
5702 case $host in
5703 x86_64-*kfreebsd*-gnu)
5704 LD="${LD-ld} -m elf_x86_64_fbsd"
5705 ;;
5706 x86_64-*linux*)
5707 LD="${LD-ld} -m elf_x86_64"
5708 ;;
5709 ppc*-*linux*|powerpc*-*linux*)
5710 LD="${LD-ld} -m elf64ppc"
5711 ;;
5712 s390*-*linux*|s390*-*tpf*)
5713 LD="${LD-ld} -m elf64_s390"
5714 ;;
5715 sparc*-*linux*)
5716 LD="${LD-ld} -m elf64_sparc"
5717 ;;
5718 esac
5719 ;;
5720 esac
5721 fi
5722 rm -rf conftest*
5723 ;;
5724
5725 *-*-sco3.2v5*)
5726 # On SCO OpenServer 5, we need -belf to get full-featured binaries.
5727 SAVE_CFLAGS="$CFLAGS"
5728 CFLAGS="$CFLAGS -belf"
5729 { echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5
5730 echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6; }
5731 if test "${lt_cv_cc_needs_belf+set}" = set; then
5732 echo $ECHO_N "(cached) $ECHO_C" >&6
5733 else
5734 ac_ext=c
5735 ac_cpp='$CPP $CPPFLAGS'
5736 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5737 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5738 ac_compiler_gnu=$ac_cv_c_compiler_gnu
5739
5740 cat >conftest.$ac_ext <<_ACEOF
5741 /* confdefs.h. */
5742 _ACEOF
5743 cat confdefs.h >>conftest.$ac_ext
5744 cat >>conftest.$ac_ext <<_ACEOF
5745 /* end confdefs.h. */
5746
5747 int
5748 main ()
5749 {
5750
5751 ;
5752 return 0;
5753 }
5754 _ACEOF
5755 rm -f conftest.$ac_objext conftest$ac_exeext
5756 if { (ac_try="$ac_link"
5757 case "(($ac_try" in
5758 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
5759 *) ac_try_echo=$ac_try;;
5760 esac
5761 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
5762 (eval "$ac_link") 2>conftest.er1
5763 ac_status=$?
5764 grep -v '^ *+' conftest.er1 >conftest.err
5765 rm -f conftest.er1
5766 cat conftest.err >&5
5767 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5768 (exit $ac_status); } && {
5769 test -z "$ac_c_werror_flag" ||
5770 test ! -s conftest.err
5771 } && test -s conftest$ac_exeext &&
5772 $as_test_x conftest$ac_exeext; then
5773 lt_cv_cc_needs_belf=yes
5774 else
5775 echo "$as_me: failed program was:" >&5
5776 sed 's/^/| /' conftest.$ac_ext >&5
5777
5778 lt_cv_cc_needs_belf=no
5779 fi
5780
5781 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
5782 conftest$ac_exeext conftest.$ac_ext
5783 ac_ext=c
5784 ac_cpp='$CPP $CPPFLAGS'
5785 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
5786 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
5787 ac_compiler_gnu=$ac_cv_c_compiler_gnu
5788
5789 fi
5790 { echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5
5791 echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6; }
5792 if test x"$lt_cv_cc_needs_belf" != x"yes"; then
5793 # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
5794 CFLAGS="$SAVE_CFLAGS"
5795 fi
5796 ;;
5797 sparc*-*solaris*)
5798 # Find out which ABI we are using.
5799 echo 'int i;' > conftest.$ac_ext
5800 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
5801 (eval $ac_compile) 2>&5
5802 ac_status=$?
5803 echo "$as_me:$LINENO: \$? = $ac_status" >&5
5804 (exit $ac_status); }; then
5805 case `/usr/bin/file conftest.o` in
5806 *64-bit*)
5807 case $lt_cv_prog_gnu_ld in
5808 yes*) LD="${LD-ld} -m elf64_sparc" ;;
5809 *)
5810 if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
5811 LD="${LD-ld} -64"
5812 fi
5813 ;;
5814 esac
5815 ;;
5816 esac
5817 fi
5818 rm -rf conftest*
5819 ;;
5820 esac
5821
5822 need_locks="$enable_libtool_lock"
5823
5824
5825 case $host_os in
5826 rhapsody* | darwin*)
5827 if test -n "$ac_tool_prefix"; then
5828 # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
5829 set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
5830 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5831 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5832 if test "${ac_cv_prog_DSYMUTIL+set}" = set; then
5833 echo $ECHO_N "(cached) $ECHO_C" >&6
5834 else
5835 if test -n "$DSYMUTIL"; then
5836 ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
5837 else
5838 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5839 for as_dir in $PATH
5840 do
5841 IFS=$as_save_IFS
5842 test -z "$as_dir" && as_dir=.
5843 for ac_exec_ext in '' $ac_executable_extensions; do
5844 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5845 ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
5846 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5847 break 2
5848 fi
5849 done
5850 done
5851 IFS=$as_save_IFS
5852
5853 fi
5854 fi
5855 DSYMUTIL=$ac_cv_prog_DSYMUTIL
5856 if test -n "$DSYMUTIL"; then
5857 { echo "$as_me:$LINENO: result: $DSYMUTIL" >&5
5858 echo "${ECHO_T}$DSYMUTIL" >&6; }
5859 else
5860 { echo "$as_me:$LINENO: result: no" >&5
5861 echo "${ECHO_T}no" >&6; }
5862 fi
5863
5864
5865 fi
5866 if test -z "$ac_cv_prog_DSYMUTIL"; then
5867 ac_ct_DSYMUTIL=$DSYMUTIL
5868 # Extract the first word of "dsymutil", so it can be a program name with args.
5869 set dummy dsymutil; ac_word=$2
5870 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5871 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5872 if test "${ac_cv_prog_ac_ct_DSYMUTIL+set}" = set; then
5873 echo $ECHO_N "(cached) $ECHO_C" >&6
5874 else
5875 if test -n "$ac_ct_DSYMUTIL"; then
5876 ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
5877 else
5878 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5879 for as_dir in $PATH
5880 do
5881 IFS=$as_save_IFS
5882 test -z "$as_dir" && as_dir=.
5883 for ac_exec_ext in '' $ac_executable_extensions; do
5884 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5885 ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
5886 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5887 break 2
5888 fi
5889 done
5890 done
5891 IFS=$as_save_IFS
5892
5893 fi
5894 fi
5895 ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
5896 if test -n "$ac_ct_DSYMUTIL"; then
5897 { echo "$as_me:$LINENO: result: $ac_ct_DSYMUTIL" >&5
5898 echo "${ECHO_T}$ac_ct_DSYMUTIL" >&6; }
5899 else
5900 { echo "$as_me:$LINENO: result: no" >&5
5901 echo "${ECHO_T}no" >&6; }
5902 fi
5903
5904 if test "x$ac_ct_DSYMUTIL" = x; then
5905 DSYMUTIL=":"
5906 else
5907 case $cross_compiling:$ac_tool_warned in
5908 yes:)
5909 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
5910 whose name does not start with the host triplet. If you think this
5911 configuration is useful to you, please write to autoconf@gnu.org." >&5
5912 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
5913 whose name does not start with the host triplet. If you think this
5914 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
5915 ac_tool_warned=yes ;;
5916 esac
5917 DSYMUTIL=$ac_ct_DSYMUTIL
5918 fi
5919 else
5920 DSYMUTIL="$ac_cv_prog_DSYMUTIL"
5921 fi
5922
5923 if test -n "$ac_tool_prefix"; then
5924 # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
5925 set dummy ${ac_tool_prefix}nmedit; ac_word=$2
5926 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5927 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5928 if test "${ac_cv_prog_NMEDIT+set}" = set; then
5929 echo $ECHO_N "(cached) $ECHO_C" >&6
5930 else
5931 if test -n "$NMEDIT"; then
5932 ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
5933 else
5934 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5935 for as_dir in $PATH
5936 do
5937 IFS=$as_save_IFS
5938 test -z "$as_dir" && as_dir=.
5939 for ac_exec_ext in '' $ac_executable_extensions; do
5940 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5941 ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
5942 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5943 break 2
5944 fi
5945 done
5946 done
5947 IFS=$as_save_IFS
5948
5949 fi
5950 fi
5951 NMEDIT=$ac_cv_prog_NMEDIT
5952 if test -n "$NMEDIT"; then
5953 { echo "$as_me:$LINENO: result: $NMEDIT" >&5
5954 echo "${ECHO_T}$NMEDIT" >&6; }
5955 else
5956 { echo "$as_me:$LINENO: result: no" >&5
5957 echo "${ECHO_T}no" >&6; }
5958 fi
5959
5960
5961 fi
5962 if test -z "$ac_cv_prog_NMEDIT"; then
5963 ac_ct_NMEDIT=$NMEDIT
5964 # Extract the first word of "nmedit", so it can be a program name with args.
5965 set dummy nmedit; ac_word=$2
5966 { echo "$as_me:$LINENO: checking for $ac_word" >&5
5967 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
5968 if test "${ac_cv_prog_ac_ct_NMEDIT+set}" = set; then
5969 echo $ECHO_N "(cached) $ECHO_C" >&6
5970 else
5971 if test -n "$ac_ct_NMEDIT"; then
5972 ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
5973 else
5974 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5975 for as_dir in $PATH
5976 do
5977 IFS=$as_save_IFS
5978 test -z "$as_dir" && as_dir=.
5979 for ac_exec_ext in '' $ac_executable_extensions; do
5980 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
5981 ac_cv_prog_ac_ct_NMEDIT="nmedit"
5982 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
5983 break 2
5984 fi
5985 done
5986 done
5987 IFS=$as_save_IFS
5988
5989 fi
5990 fi
5991 ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
5992 if test -n "$ac_ct_NMEDIT"; then
5993 { echo "$as_me:$LINENO: result: $ac_ct_NMEDIT" >&5
5994 echo "${ECHO_T}$ac_ct_NMEDIT" >&6; }
5995 else
5996 { echo "$as_me:$LINENO: result: no" >&5
5997 echo "${ECHO_T}no" >&6; }
5998 fi
5999
6000 if test "x$ac_ct_NMEDIT" = x; then
6001 NMEDIT=":"
6002 else
6003 case $cross_compiling:$ac_tool_warned in
6004 yes:)
6005 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
6006 whose name does not start with the host triplet. If you think this
6007 configuration is useful to you, please write to autoconf@gnu.org." >&5
6008 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
6009 whose name does not start with the host triplet. If you think this
6010 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
6011 ac_tool_warned=yes ;;
6012 esac
6013 NMEDIT=$ac_ct_NMEDIT
6014 fi
6015 else
6016 NMEDIT="$ac_cv_prog_NMEDIT"
6017 fi
6018
6019 if test -n "$ac_tool_prefix"; then
6020 # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
6021 set dummy ${ac_tool_prefix}lipo; ac_word=$2
6022 { echo "$as_me:$LINENO: checking for $ac_word" >&5
6023 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
6024 if test "${ac_cv_prog_LIPO+set}" = set; then
6025 echo $ECHO_N "(cached) $ECHO_C" >&6
6026 else
6027 if test -n "$LIPO"; then
6028 ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
6029 else
6030 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6031 for as_dir in $PATH
6032 do
6033 IFS=$as_save_IFS
6034 test -z "$as_dir" && as_dir=.
6035 for ac_exec_ext in '' $ac_executable_extensions; do
6036 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
6037 ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
6038 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
6039 break 2
6040 fi
6041 done
6042 done
6043 IFS=$as_save_IFS
6044
6045 fi
6046 fi
6047 LIPO=$ac_cv_prog_LIPO
6048 if test -n "$LIPO"; then
6049 { echo "$as_me:$LINENO: result: $LIPO" >&5
6050 echo "${ECHO_T}$LIPO" >&6; }
6051 else
6052 { echo "$as_me:$LINENO: result: no" >&5
6053 echo "${ECHO_T}no" >&6; }
6054 fi
6055
6056
6057 fi
6058 if test -z "$ac_cv_prog_LIPO"; then
6059 ac_ct_LIPO=$LIPO
6060 # Extract the first word of "lipo", so it can be a program name with args.
6061 set dummy lipo; ac_word=$2
6062 { echo "$as_me:$LINENO: checking for $ac_word" >&5
6063 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
6064 if test "${ac_cv_prog_ac_ct_LIPO+set}" = set; then
6065 echo $ECHO_N "(cached) $ECHO_C" >&6
6066 else
6067 if test -n "$ac_ct_LIPO"; then
6068 ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
6069 else
6070 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6071 for as_dir in $PATH
6072 do
6073 IFS=$as_save_IFS
6074 test -z "$as_dir" && as_dir=.
6075 for ac_exec_ext in '' $ac_executable_extensions; do
6076 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
6077 ac_cv_prog_ac_ct_LIPO="lipo"
6078 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
6079 break 2
6080 fi
6081 done
6082 done
6083 IFS=$as_save_IFS
6084
6085 fi
6086 fi
6087 ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
6088 if test -n "$ac_ct_LIPO"; then
6089 { echo "$as_me:$LINENO: result: $ac_ct_LIPO" >&5
6090 echo "${ECHO_T}$ac_ct_LIPO" >&6; }
6091 else
6092 { echo "$as_me:$LINENO: result: no" >&5
6093 echo "${ECHO_T}no" >&6; }
6094 fi
6095
6096 if test "x$ac_ct_LIPO" = x; then
6097 LIPO=":"
6098 else
6099 case $cross_compiling:$ac_tool_warned in
6100 yes:)
6101 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
6102 whose name does not start with the host triplet. If you think this
6103 configuration is useful to you, please write to autoconf@gnu.org." >&5
6104 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
6105 whose name does not start with the host triplet. If you think this
6106 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
6107 ac_tool_warned=yes ;;
6108 esac
6109 LIPO=$ac_ct_LIPO
6110 fi
6111 else
6112 LIPO="$ac_cv_prog_LIPO"
6113 fi
6114
6115 if test -n "$ac_tool_prefix"; then
6116 # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
6117 set dummy ${ac_tool_prefix}otool; ac_word=$2
6118 { echo "$as_me:$LINENO: checking for $ac_word" >&5
6119 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
6120 if test "${ac_cv_prog_OTOOL+set}" = set; then
6121 echo $ECHO_N "(cached) $ECHO_C" >&6
6122 else
6123 if test -n "$OTOOL"; then
6124 ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
6125 else
6126 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6127 for as_dir in $PATH
6128 do
6129 IFS=$as_save_IFS
6130 test -z "$as_dir" && as_dir=.
6131 for ac_exec_ext in '' $ac_executable_extensions; do
6132 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
6133 ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
6134 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
6135 break 2
6136 fi
6137 done
6138 done
6139 IFS=$as_save_IFS
6140
6141 fi
6142 fi
6143 OTOOL=$ac_cv_prog_OTOOL
6144 if test -n "$OTOOL"; then
6145 { echo "$as_me:$LINENO: result: $OTOOL" >&5
6146 echo "${ECHO_T}$OTOOL" >&6; }
6147 else
6148 { echo "$as_me:$LINENO: result: no" >&5
6149 echo "${ECHO_T}no" >&6; }
6150 fi
6151
6152
6153 fi
6154 if test -z "$ac_cv_prog_OTOOL"; then
6155 ac_ct_OTOOL=$OTOOL
6156 # Extract the first word of "otool", so it can be a program name with args.
6157 set dummy otool; ac_word=$2
6158 { echo "$as_me:$LINENO: checking for $ac_word" >&5
6159 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
6160 if test "${ac_cv_prog_ac_ct_OTOOL+set}" = set; then
6161 echo $ECHO_N "(cached) $ECHO_C" >&6
6162 else
6163 if test -n "$ac_ct_OTOOL"; then
6164 ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
6165 else
6166 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6167 for as_dir in $PATH
6168 do
6169 IFS=$as_save_IFS
6170 test -z "$as_dir" && as_dir=.
6171 for ac_exec_ext in '' $ac_executable_extensions; do
6172 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
6173 ac_cv_prog_ac_ct_OTOOL="otool"
6174 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
6175 break 2
6176 fi
6177 done
6178 done
6179 IFS=$as_save_IFS
6180
6181 fi
6182 fi
6183 ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
6184 if test -n "$ac_ct_OTOOL"; then
6185 { echo "$as_me:$LINENO: result: $ac_ct_OTOOL" >&5
6186 echo "${ECHO_T}$ac_ct_OTOOL" >&6; }
6187 else
6188 { echo "$as_me:$LINENO: result: no" >&5
6189 echo "${ECHO_T}no" >&6; }
6190 fi
6191
6192 if test "x$ac_ct_OTOOL" = x; then
6193 OTOOL=":"
6194 else
6195 case $cross_compiling:$ac_tool_warned in
6196 yes:)
6197 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
6198 whose name does not start with the host triplet. If you think this
6199 configuration is useful to you, please write to autoconf@gnu.org." >&5
6200 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
6201 whose name does not start with the host triplet. If you think this
6202 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
6203 ac_tool_warned=yes ;;
6204 esac
6205 OTOOL=$ac_ct_OTOOL
6206 fi
6207 else
6208 OTOOL="$ac_cv_prog_OTOOL"
6209 fi
6210
6211 if test -n "$ac_tool_prefix"; then
6212 # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
6213 set dummy ${ac_tool_prefix}otool64; ac_word=$2
6214 { echo "$as_me:$LINENO: checking for $ac_word" >&5
6215 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
6216 if test "${ac_cv_prog_OTOOL64+set}" = set; then
6217 echo $ECHO_N "(cached) $ECHO_C" >&6
6218 else
6219 if test -n "$OTOOL64"; then
6220 ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
6221 else
6222 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6223 for as_dir in $PATH
6224 do
6225 IFS=$as_save_IFS
6226 test -z "$as_dir" && as_dir=.
6227 for ac_exec_ext in '' $ac_executable_extensions; do
6228 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
6229 ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
6230 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
6231 break 2
6232 fi
6233 done
6234 done
6235 IFS=$as_save_IFS
6236
6237 fi
6238 fi
6239 OTOOL64=$ac_cv_prog_OTOOL64
6240 if test -n "$OTOOL64"; then
6241 { echo "$as_me:$LINENO: result: $OTOOL64" >&5
6242 echo "${ECHO_T}$OTOOL64" >&6; }
6243 else
6244 { echo "$as_me:$LINENO: result: no" >&5
6245 echo "${ECHO_T}no" >&6; }
6246 fi
6247
6248
6249 fi
6250 if test -z "$ac_cv_prog_OTOOL64"; then
6251 ac_ct_OTOOL64=$OTOOL64
6252 # Extract the first word of "otool64", so it can be a program name with args.
6253 set dummy otool64; ac_word=$2
6254 { echo "$as_me:$LINENO: checking for $ac_word" >&5
6255 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
6256 if test "${ac_cv_prog_ac_ct_OTOOL64+set}" = set; then
6257 echo $ECHO_N "(cached) $ECHO_C" >&6
6258 else
6259 if test -n "$ac_ct_OTOOL64"; then
6260 ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
6261 else
6262 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
6263 for as_dir in $PATH
6264 do
6265 IFS=$as_save_IFS
6266 test -z "$as_dir" && as_dir=.
6267 for ac_exec_ext in '' $ac_executable_extensions; do
6268 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
6269 ac_cv_prog_ac_ct_OTOOL64="otool64"
6270 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
6271 break 2
6272 fi
6273 done
6274 done
6275 IFS=$as_save_IFS
6276
6277 fi
6278 fi
6279 ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
6280 if test -n "$ac_ct_OTOOL64"; then
6281 { echo "$as_me:$LINENO: result: $ac_ct_OTOOL64" >&5
6282 echo "${ECHO_T}$ac_ct_OTOOL64" >&6; }
6283 else
6284 { echo "$as_me:$LINENO: result: no" >&5
6285 echo "${ECHO_T}no" >&6; }
6286 fi
6287
6288 if test "x$ac_ct_OTOOL64" = x; then
6289 OTOOL64=":"
6290 else
6291 case $cross_compiling:$ac_tool_warned in
6292 yes:)
6293 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
6294 whose name does not start with the host triplet. If you think this
6295 configuration is useful to you, please write to autoconf@gnu.org." >&5
6296 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
6297 whose name does not start with the host triplet. If you think this
6298 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
6299 ac_tool_warned=yes ;;
6300 esac
6301 OTOOL64=$ac_ct_OTOOL64
6302 fi
6303 else
6304 OTOOL64="$ac_cv_prog_OTOOL64"
6305 fi
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333 { echo "$as_me:$LINENO: checking for -single_module linker flag" >&5
6334 echo $ECHO_N "checking for -single_module linker flag... $ECHO_C" >&6; }
6335 if test "${lt_cv_apple_cc_single_mod+set}" = set; then
6336 echo $ECHO_N "(cached) $ECHO_C" >&6
6337 else
6338 lt_cv_apple_cc_single_mod=no
6339 if test -z "${LT_MULTI_MODULE}"; then
6340 # By default we will add the -single_module flag. You can override
6341 # by either setting the environment variable LT_MULTI_MODULE
6342 # non-empty at configure time, or by adding -multi_module to the
6343 # link flags.
6344 rm -rf libconftest.dylib*
6345 echo "int foo(void){return 1;}" > conftest.c
6346 echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
6347 -dynamiclib -Wl,-single_module conftest.c" >&5
6348 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
6349 -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
6350 _lt_result=$?
6351 if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
6352 lt_cv_apple_cc_single_mod=yes
6353 else
6354 cat conftest.err >&5
6355 fi
6356 rm -rf libconftest.dylib*
6357 rm -f conftest.*
6358 fi
6359 fi
6360 { echo "$as_me:$LINENO: result: $lt_cv_apple_cc_single_mod" >&5
6361 echo "${ECHO_T}$lt_cv_apple_cc_single_mod" >&6; }
6362 { echo "$as_me:$LINENO: checking for -exported_symbols_list linker flag" >&5
6363 echo $ECHO_N "checking for -exported_symbols_list linker flag... $ECHO_C" >&6; }
6364 if test "${lt_cv_ld_exported_symbols_list+set}" = set; then
6365 echo $ECHO_N "(cached) $ECHO_C" >&6
6366 else
6367 lt_cv_ld_exported_symbols_list=no
6368 save_LDFLAGS=$LDFLAGS
6369 echo "_main" > conftest.sym
6370 LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
6371 cat >conftest.$ac_ext <<_ACEOF
6372 /* confdefs.h. */
6373 _ACEOF
6374 cat confdefs.h >>conftest.$ac_ext
6375 cat >>conftest.$ac_ext <<_ACEOF
6376 /* end confdefs.h. */
6377
6378 int
6379 main ()
6380 {
6381
6382 ;
6383 return 0;
6384 }
6385 _ACEOF
6386 rm -f conftest.$ac_objext conftest$ac_exeext
6387 if { (ac_try="$ac_link"
6388 case "(($ac_try" in
6389 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6390 *) ac_try_echo=$ac_try;;
6391 esac
6392 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6393 (eval "$ac_link") 2>conftest.er1
6394 ac_status=$?
6395 grep -v '^ *+' conftest.er1 >conftest.err
6396 rm -f conftest.er1
6397 cat conftest.err >&5
6398 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6399 (exit $ac_status); } && {
6400 test -z "$ac_c_werror_flag" ||
6401 test ! -s conftest.err
6402 } && test -s conftest$ac_exeext &&
6403 $as_test_x conftest$ac_exeext; then
6404 lt_cv_ld_exported_symbols_list=yes
6405 else
6406 echo "$as_me: failed program was:" >&5
6407 sed 's/^/| /' conftest.$ac_ext >&5
6408
6409 lt_cv_ld_exported_symbols_list=no
6410 fi
6411
6412 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
6413 conftest$ac_exeext conftest.$ac_ext
6414 LDFLAGS="$save_LDFLAGS"
6415
6416 fi
6417 { echo "$as_me:$LINENO: result: $lt_cv_ld_exported_symbols_list" >&5
6418 echo "${ECHO_T}$lt_cv_ld_exported_symbols_list" >&6; }
6419 case $host_os in
6420 rhapsody* | darwin1.[012])
6421 _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
6422 darwin1.*)
6423 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
6424 darwin*) # darwin 5.x on
6425 # if running on 10.5 or later, the deployment target defaults
6426 # to the OS version, if on x86, and 10.4, the deployment
6427 # target defaults to 10.4. Don't you love it?
6428 case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
6429 10.0,*86*-darwin8*|10.0,*-darwin[91]*)
6430 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
6431 10.[012]*)
6432 _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
6433 10.*)
6434 _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
6435 esac
6436 ;;
6437 esac
6438 if test "$lt_cv_apple_cc_single_mod" = "yes"; then
6439 _lt_dar_single_mod='$single_module'
6440 fi
6441 if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
6442 _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
6443 else
6444 _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
6445 fi
6446 if test "$DSYMUTIL" != ":"; then
6447 _lt_dsymutil='~$DSYMUTIL $lib || :'
6448 else
6449 _lt_dsymutil=
6450 fi
6451 ;;
6452 esac
6453
6454 ac_ext=c
6455 ac_cpp='$CPP $CPPFLAGS'
6456 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
6457 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
6458 ac_compiler_gnu=$ac_cv_c_compiler_gnu
6459 { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
6460 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; }
6461 # On Suns, sometimes $CPP names a directory.
6462 if test -n "$CPP" && test -d "$CPP"; then
6463 CPP=
6464 fi
6465 if test -z "$CPP"; then
6466 if test "${ac_cv_prog_CPP+set}" = set; then
6467 echo $ECHO_N "(cached) $ECHO_C" >&6
6468 else
6469 # Double quotes because CPP needs to be expanded
6470 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
6471 do
6472 ac_preproc_ok=false
6473 for ac_c_preproc_warn_flag in '' yes
6474 do
6475 # Use a header file that comes with gcc, so configuring glibc
6476 # with a fresh cross-compiler works.
6477 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
6478 # <limits.h> exists even on freestanding compilers.
6479 # On the NeXT, cc -E runs the code through the compiler's parser,
6480 # not just through cpp. "Syntax error" is here to catch this case.
6481 cat >conftest.$ac_ext <<_ACEOF
6482 /* confdefs.h. */
6483 _ACEOF
6484 cat confdefs.h >>conftest.$ac_ext
6485 cat >>conftest.$ac_ext <<_ACEOF
6486 /* end confdefs.h. */
6487 #ifdef __STDC__
6488 # include <limits.h>
6489 #else
6490 # include <assert.h>
6491 #endif
6492 Syntax error
6493 _ACEOF
6494 if { (ac_try="$ac_cpp conftest.$ac_ext"
6495 case "(($ac_try" in
6496 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6497 *) ac_try_echo=$ac_try;;
6498 esac
6499 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6500 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
6501 ac_status=$?
6502 grep -v '^ *+' conftest.er1 >conftest.err
6503 rm -f conftest.er1
6504 cat conftest.err >&5
6505 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6506 (exit $ac_status); } >/dev/null && {
6507 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
6508 test ! -s conftest.err
6509 }; then
6510 :
6511 else
6512 echo "$as_me: failed program was:" >&5
6513 sed 's/^/| /' conftest.$ac_ext >&5
6514
6515 # Broken: fails on valid input.
6516 continue
6517 fi
6518
6519 rm -f conftest.err conftest.$ac_ext
6520
6521 # OK, works on sane cases. Now check whether nonexistent headers
6522 # can be detected and how.
6523 cat >conftest.$ac_ext <<_ACEOF
6524 /* confdefs.h. */
6525 _ACEOF
6526 cat confdefs.h >>conftest.$ac_ext
6527 cat >>conftest.$ac_ext <<_ACEOF
6528 /* end confdefs.h. */
6529 #include <ac_nonexistent.h>
6530 _ACEOF
6531 if { (ac_try="$ac_cpp conftest.$ac_ext"
6532 case "(($ac_try" in
6533 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6534 *) ac_try_echo=$ac_try;;
6535 esac
6536 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6537 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
6538 ac_status=$?
6539 grep -v '^ *+' conftest.er1 >conftest.err
6540 rm -f conftest.er1
6541 cat conftest.err >&5
6542 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6543 (exit $ac_status); } >/dev/null && {
6544 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
6545 test ! -s conftest.err
6546 }; then
6547 # Broken: success on invalid input.
6548 continue
6549 else
6550 echo "$as_me: failed program was:" >&5
6551 sed 's/^/| /' conftest.$ac_ext >&5
6552
6553 # Passes both tests.
6554 ac_preproc_ok=:
6555 break
6556 fi
6557
6558 rm -f conftest.err conftest.$ac_ext
6559
6560 done
6561 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
6562 rm -f conftest.err conftest.$ac_ext
6563 if $ac_preproc_ok; then
6564 break
6565 fi
6566
6567 done
6568 ac_cv_prog_CPP=$CPP
6569
6570 fi
6571 CPP=$ac_cv_prog_CPP
6572 else
6573 ac_cv_prog_CPP=$CPP
6574 fi
6575 { echo "$as_me:$LINENO: result: $CPP" >&5
6576 echo "${ECHO_T}$CPP" >&6; }
6577 ac_preproc_ok=false
6578 for ac_c_preproc_warn_flag in '' yes
6579 do
6580 # Use a header file that comes with gcc, so configuring glibc
6581 # with a fresh cross-compiler works.
6582 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
6583 # <limits.h> exists even on freestanding compilers.
6584 # On the NeXT, cc -E runs the code through the compiler's parser,
6585 # not just through cpp. "Syntax error" is here to catch this case.
6586 cat >conftest.$ac_ext <<_ACEOF
6587 /* confdefs.h. */
6588 _ACEOF
6589 cat confdefs.h >>conftest.$ac_ext
6590 cat >>conftest.$ac_ext <<_ACEOF
6591 /* end confdefs.h. */
6592 #ifdef __STDC__
6593 # include <limits.h>
6594 #else
6595 # include <assert.h>
6596 #endif
6597 Syntax error
6598 _ACEOF
6599 if { (ac_try="$ac_cpp conftest.$ac_ext"
6600 case "(($ac_try" in
6601 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6602 *) ac_try_echo=$ac_try;;
6603 esac
6604 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6605 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
6606 ac_status=$?
6607 grep -v '^ *+' conftest.er1 >conftest.err
6608 rm -f conftest.er1
6609 cat conftest.err >&5
6610 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6611 (exit $ac_status); } >/dev/null && {
6612 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
6613 test ! -s conftest.err
6614 }; then
6615 :
6616 else
6617 echo "$as_me: failed program was:" >&5
6618 sed 's/^/| /' conftest.$ac_ext >&5
6619
6620 # Broken: fails on valid input.
6621 continue
6622 fi
6623
6624 rm -f conftest.err conftest.$ac_ext
6625
6626 # OK, works on sane cases. Now check whether nonexistent headers
6627 # can be detected and how.
6628 cat >conftest.$ac_ext <<_ACEOF
6629 /* confdefs.h. */
6630 _ACEOF
6631 cat confdefs.h >>conftest.$ac_ext
6632 cat >>conftest.$ac_ext <<_ACEOF
6633 /* end confdefs.h. */
6634 #include <ac_nonexistent.h>
6635 _ACEOF
6636 if { (ac_try="$ac_cpp conftest.$ac_ext"
6637 case "(($ac_try" in
6638 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6639 *) ac_try_echo=$ac_try;;
6640 esac
6641 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6642 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
6643 ac_status=$?
6644 grep -v '^ *+' conftest.er1 >conftest.err
6645 rm -f conftest.er1
6646 cat conftest.err >&5
6647 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6648 (exit $ac_status); } >/dev/null && {
6649 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
6650 test ! -s conftest.err
6651 }; then
6652 # Broken: success on invalid input.
6653 continue
6654 else
6655 echo "$as_me: failed program was:" >&5
6656 sed 's/^/| /' conftest.$ac_ext >&5
6657
6658 # Passes both tests.
6659 ac_preproc_ok=:
6660 break
6661 fi
6662
6663 rm -f conftest.err conftest.$ac_ext
6664
6665 done
6666 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
6667 rm -f conftest.err conftest.$ac_ext
6668 if $ac_preproc_ok; then
6669 :
6670 else
6671 { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
6672 See \`config.log' for more details." >&5
6673 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
6674 See \`config.log' for more details." >&2;}
6675 { (exit 1); exit 1; }; }
6676 fi
6677
6678 ac_ext=c
6679 ac_cpp='$CPP $CPPFLAGS'
6680 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
6681 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
6682 ac_compiler_gnu=$ac_cv_c_compiler_gnu
6683
6684
6685 { echo "$as_me:$LINENO: checking for ANSI C header files" >&5
6686 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
6687 if test "${ac_cv_header_stdc+set}" = set; then
6688 echo $ECHO_N "(cached) $ECHO_C" >&6
6689 else
6690 cat >conftest.$ac_ext <<_ACEOF
6691 /* confdefs.h. */
6692 _ACEOF
6693 cat confdefs.h >>conftest.$ac_ext
6694 cat >>conftest.$ac_ext <<_ACEOF
6695 /* end confdefs.h. */
6696 #include <stdlib.h>
6697 #include <stdarg.h>
6698 #include <string.h>
6699 #include <float.h>
6700
6701 int
6702 main ()
6703 {
6704
6705 ;
6706 return 0;
6707 }
6708 _ACEOF
6709 rm -f conftest.$ac_objext
6710 if { (ac_try="$ac_compile"
6711 case "(($ac_try" in
6712 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6713 *) ac_try_echo=$ac_try;;
6714 esac
6715 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6716 (eval "$ac_compile") 2>conftest.er1
6717 ac_status=$?
6718 grep -v '^ *+' conftest.er1 >conftest.err
6719 rm -f conftest.er1
6720 cat conftest.err >&5
6721 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6722 (exit $ac_status); } && {
6723 test -z "$ac_c_werror_flag" ||
6724 test ! -s conftest.err
6725 } && test -s conftest.$ac_objext; then
6726 ac_cv_header_stdc=yes
6727 else
6728 echo "$as_me: failed program was:" >&5
6729 sed 's/^/| /' conftest.$ac_ext >&5
6730
6731 ac_cv_header_stdc=no
6732 fi
6733
6734 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6735
6736 if test $ac_cv_header_stdc = yes; then
6737 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
6738 cat >conftest.$ac_ext <<_ACEOF
6739 /* confdefs.h. */
6740 _ACEOF
6741 cat confdefs.h >>conftest.$ac_ext
6742 cat >>conftest.$ac_ext <<_ACEOF
6743 /* end confdefs.h. */
6744 #include <string.h>
6745
6746 _ACEOF
6747 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
6748 $EGREP "memchr" >/dev/null 2>&1; then
6749 :
6750 else
6751 ac_cv_header_stdc=no
6752 fi
6753 rm -f -r conftest*
6754
6755 fi
6756
6757 if test $ac_cv_header_stdc = yes; then
6758 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
6759 cat >conftest.$ac_ext <<_ACEOF
6760 /* confdefs.h. */
6761 _ACEOF
6762 cat confdefs.h >>conftest.$ac_ext
6763 cat >>conftest.$ac_ext <<_ACEOF
6764 /* end confdefs.h. */
6765 #include <stdlib.h>
6766
6767 _ACEOF
6768 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
6769 $EGREP "free" >/dev/null 2>&1; then
6770 :
6771 else
6772 ac_cv_header_stdc=no
6773 fi
6774 rm -f -r conftest*
6775
6776 fi
6777
6778 if test $ac_cv_header_stdc = yes; then
6779 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
6780 if test "$cross_compiling" = yes; then
6781 :
6782 else
6783 cat >conftest.$ac_ext <<_ACEOF
6784 /* confdefs.h. */
6785 _ACEOF
6786 cat confdefs.h >>conftest.$ac_ext
6787 cat >>conftest.$ac_ext <<_ACEOF
6788 /* end confdefs.h. */
6789 #include <ctype.h>
6790 #include <stdlib.h>
6791 #if ((' ' & 0x0FF) == 0x020)
6792 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
6793 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
6794 #else
6795 # define ISLOWER(c) \
6796 (('a' <= (c) && (c) <= 'i') \
6797 || ('j' <= (c) && (c) <= 'r') \
6798 || ('s' <= (c) && (c) <= 'z'))
6799 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
6800 #endif
6801
6802 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
6803 int
6804 main ()
6805 {
6806 int i;
6807 for (i = 0; i < 256; i++)
6808 if (XOR (islower (i), ISLOWER (i))
6809 || toupper (i) != TOUPPER (i))
6810 return 2;
6811 return 0;
6812 }
6813 _ACEOF
6814 rm -f conftest$ac_exeext
6815 if { (ac_try="$ac_link"
6816 case "(($ac_try" in
6817 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6818 *) ac_try_echo=$ac_try;;
6819 esac
6820 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6821 (eval "$ac_link") 2>&5
6822 ac_status=$?
6823 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6824 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
6825 { (case "(($ac_try" in
6826 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6827 *) ac_try_echo=$ac_try;;
6828 esac
6829 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6830 (eval "$ac_try") 2>&5
6831 ac_status=$?
6832 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6833 (exit $ac_status); }; }; then
6834 :
6835 else
6836 echo "$as_me: program exited with status $ac_status" >&5
6837 echo "$as_me: failed program was:" >&5
6838 sed 's/^/| /' conftest.$ac_ext >&5
6839
6840 ( exit $ac_status )
6841 ac_cv_header_stdc=no
6842 fi
6843 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
6844 fi
6845
6846
6847 fi
6848 fi
6849 { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
6850 echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
6851 if test $ac_cv_header_stdc = yes; then
6852
6853 cat >>confdefs.h <<\_ACEOF
6854 #define STDC_HEADERS 1
6855 _ACEOF
6856
6857 fi
6858
6859 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
6870 inttypes.h stdint.h unistd.h
6871 do
6872 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
6873 { echo "$as_me:$LINENO: checking for $ac_header" >&5
6874 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
6875 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
6876 echo $ECHO_N "(cached) $ECHO_C" >&6
6877 else
6878 cat >conftest.$ac_ext <<_ACEOF
6879 /* confdefs.h. */
6880 _ACEOF
6881 cat confdefs.h >>conftest.$ac_ext
6882 cat >>conftest.$ac_ext <<_ACEOF
6883 /* end confdefs.h. */
6884 $ac_includes_default
6885
6886 #include <$ac_header>
6887 _ACEOF
6888 rm -f conftest.$ac_objext
6889 if { (ac_try="$ac_compile"
6890 case "(($ac_try" in
6891 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6892 *) ac_try_echo=$ac_try;;
6893 esac
6894 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6895 (eval "$ac_compile") 2>conftest.er1
6896 ac_status=$?
6897 grep -v '^ *+' conftest.er1 >conftest.err
6898 rm -f conftest.er1
6899 cat conftest.err >&5
6900 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6901 (exit $ac_status); } && {
6902 test -z "$ac_c_werror_flag" ||
6903 test ! -s conftest.err
6904 } && test -s conftest.$ac_objext; then
6905 eval "$as_ac_Header=yes"
6906 else
6907 echo "$as_me: failed program was:" >&5
6908 sed 's/^/| /' conftest.$ac_ext >&5
6909
6910 eval "$as_ac_Header=no"
6911 fi
6912
6913 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6914 fi
6915 ac_res=`eval echo '${'$as_ac_Header'}'`
6916 { echo "$as_me:$LINENO: result: $ac_res" >&5
6917 echo "${ECHO_T}$ac_res" >&6; }
6918 if test `eval echo '${'$as_ac_Header'}'` = yes; then
6919 cat >>confdefs.h <<_ACEOF
6920 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
6921 _ACEOF
6922
6923 fi
6924
6925 done
6926
6927
6928
6929 for ac_header in dlfcn.h
6930 do
6931 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
6932 { echo "$as_me:$LINENO: checking for $ac_header" >&5
6933 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
6934 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
6935 echo $ECHO_N "(cached) $ECHO_C" >&6
6936 else
6937 cat >conftest.$ac_ext <<_ACEOF
6938 /* confdefs.h. */
6939 _ACEOF
6940 cat confdefs.h >>conftest.$ac_ext
6941 cat >>conftest.$ac_ext <<_ACEOF
6942 /* end confdefs.h. */
6943 $ac_includes_default
6944
6945 #include <$ac_header>
6946 _ACEOF
6947 rm -f conftest.$ac_objext
6948 if { (ac_try="$ac_compile"
6949 case "(($ac_try" in
6950 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
6951 *) ac_try_echo=$ac_try;;
6952 esac
6953 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
6954 (eval "$ac_compile") 2>conftest.er1
6955 ac_status=$?
6956 grep -v '^ *+' conftest.er1 >conftest.err
6957 rm -f conftest.er1
6958 cat conftest.err >&5
6959 echo "$as_me:$LINENO: \$? = $ac_status" >&5
6960 (exit $ac_status); } && {
6961 test -z "$ac_c_werror_flag" ||
6962 test ! -s conftest.err
6963 } && test -s conftest.$ac_objext; then
6964 eval "$as_ac_Header=yes"
6965 else
6966 echo "$as_me: failed program was:" >&5
6967 sed 's/^/| /' conftest.$ac_ext >&5
6968
6969 eval "$as_ac_Header=no"
6970 fi
6971
6972 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
6973 fi
6974 ac_res=`eval echo '${'$as_ac_Header'}'`
6975 { echo "$as_me:$LINENO: result: $ac_res" >&5
6976 echo "${ECHO_T}$ac_res" >&6; }
6977 if test `eval echo '${'$as_ac_Header'}'` = yes; then
6978 cat >>confdefs.h <<_ACEOF
6979 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
6980 _ACEOF
6981
6982 fi
6983
6984 done
6985
6986
6987
6988 # Set options
6989
6990
6991
6992 enable_dlopen=no
6993
6994
6995 enable_win32_dll=no
6996
6997
6998 # Check whether --enable-shared was given.
6999 if test "${enable_shared+set}" = set; then
7000 enableval=$enable_shared; p=${PACKAGE-default}
7001 case $enableval in
7002 yes) enable_shared=yes ;;
7003 no) enable_shared=no ;;
7004 *)
7005 enable_shared=no
7006 # Look at the argument we got. We use all the common list separators.
7007 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7008 for pkg in $enableval; do
7009 IFS="$lt_save_ifs"
7010 if test "X$pkg" = "X$p"; then
7011 enable_shared=yes
7012 fi
7013 done
7014 IFS="$lt_save_ifs"
7015 ;;
7016 esac
7017 else
7018 enable_shared=yes
7019 fi
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029 # Check whether --enable-static was given.
7030 if test "${enable_static+set}" = set; then
7031 enableval=$enable_static; p=${PACKAGE-default}
7032 case $enableval in
7033 yes) enable_static=yes ;;
7034 no) enable_static=no ;;
7035 *)
7036 enable_static=no
7037 # Look at the argument we got. We use all the common list separators.
7038 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7039 for pkg in $enableval; do
7040 IFS="$lt_save_ifs"
7041 if test "X$pkg" = "X$p"; then
7042 enable_static=yes
7043 fi
7044 done
7045 IFS="$lt_save_ifs"
7046 ;;
7047 esac
7048 else
7049 enable_static=yes
7050 fi
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061 # Check whether --with-pic was given.
7062 if test "${with_pic+set}" = set; then
7063 withval=$with_pic; pic_mode="$withval"
7064 else
7065 pic_mode=default
7066 fi
7067
7068
7069 test -z "$pic_mode" && pic_mode=default
7070
7071
7072
7073
7074
7075
7076
7077 # Check whether --enable-fast-install was given.
7078 if test "${enable_fast_install+set}" = set; then
7079 enableval=$enable_fast_install; p=${PACKAGE-default}
7080 case $enableval in
7081 yes) enable_fast_install=yes ;;
7082 no) enable_fast_install=no ;;
7083 *)
7084 enable_fast_install=no
7085 # Look at the argument we got. We use all the common list separators.
7086 lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
7087 for pkg in $enableval; do
7088 IFS="$lt_save_ifs"
7089 if test "X$pkg" = "X$p"; then
7090 enable_fast_install=yes
7091 fi
7092 done
7093 IFS="$lt_save_ifs"
7094 ;;
7095 esac
7096 else
7097 enable_fast_install=yes
7098 fi
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110 # This can be used to rebuild libtool when needed
7111 LIBTOOL_DEPS="$ltmain"
7112
7113 # Always use our own libtool.
7114 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140 test -z "$LN_S" && LN_S="ln -s"
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155 if test -n "${ZSH_VERSION+set}" ; then
7156 setopt NO_GLOB_SUBST
7157 fi
7158
7159 { echo "$as_me:$LINENO: checking for objdir" >&5
7160 echo $ECHO_N "checking for objdir... $ECHO_C" >&6; }
7161 if test "${lt_cv_objdir+set}" = set; then
7162 echo $ECHO_N "(cached) $ECHO_C" >&6
7163 else
7164 rm -f .libs 2>/dev/null
7165 mkdir .libs 2>/dev/null
7166 if test -d .libs; then
7167 lt_cv_objdir=.libs
7168 else
7169 # MS-DOS does not allow filenames that begin with a dot.
7170 lt_cv_objdir=_libs
7171 fi
7172 rmdir .libs 2>/dev/null
7173 fi
7174 { echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
7175 echo "${ECHO_T}$lt_cv_objdir" >&6; }
7176 objdir=$lt_cv_objdir
7177
7178
7179
7180
7181
7182 cat >>confdefs.h <<_ACEOF
7183 #define LT_OBJDIR "$lt_cv_objdir/"
7184 _ACEOF
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202 case $host_os in
7203 aix3*)
7204 # AIX sometimes has problems with the GCC collect2 program. For some
7205 # reason, if we set the COLLECT_NAMES environment variable, the problems
7206 # vanish in a puff of smoke.
7207 if test "X${COLLECT_NAMES+set}" != Xset; then
7208 COLLECT_NAMES=
7209 export COLLECT_NAMES
7210 fi
7211 ;;
7212 esac
7213
7214 # Sed substitution that helps us do robust quoting. It backslashifies
7215 # metacharacters that are still active within double-quoted strings.
7216 sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
7217
7218 # Same as above, but do not quote variable references.
7219 double_quote_subst='s/\(["`\\]\)/\\\1/g'
7220
7221 # Sed substitution to delay expansion of an escaped shell variable in a
7222 # double_quote_subst'ed string.
7223 delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
7224
7225 # Sed substitution to delay expansion of an escaped single quote.
7226 delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
7227
7228 # Sed substitution to avoid accidental globbing in evaled expressions
7229 no_glob_subst='s/\*/\\\*/g'
7230
7231 # Global variables:
7232 ofile=libtool
7233 can_build_shared=yes
7234
7235 # All known linkers require a `.a' archive for static linking (except MSVC,
7236 # which needs '.lib').
7237 libext=a
7238
7239 with_gnu_ld="$lt_cv_prog_gnu_ld"
7240
7241 old_CC="$CC"
7242 old_CFLAGS="$CFLAGS"
7243
7244 # Set sane defaults for various variables
7245 test -z "$CC" && CC=cc
7246 test -z "$LTCC" && LTCC=$CC
7247 test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
7248 test -z "$LD" && LD=ld
7249 test -z "$ac_objext" && ac_objext=o
7250
7251 for cc_temp in $compiler""; do
7252 case $cc_temp in
7253 compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
7254 distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
7255 \-*) ;;
7256 *) break;;
7257 esac
7258 done
7259 cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
7260
7261
7262 # Only perform the check for file, if the check method requires it
7263 test -z "$MAGIC_CMD" && MAGIC_CMD=file
7264 case $deplibs_check_method in
7265 file_magic*)
7266 if test "$file_magic_cmd" = '$MAGIC_CMD'; then
7267 { echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
7268 echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6; }
7269 if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
7270 echo $ECHO_N "(cached) $ECHO_C" >&6
7271 else
7272 case $MAGIC_CMD in
7273 [\\/*] | ?:[\\/]*)
7274 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
7275 ;;
7276 *)
7277 lt_save_MAGIC_CMD="$MAGIC_CMD"
7278 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
7279 ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
7280 for ac_dir in $ac_dummy; do
7281 IFS="$lt_save_ifs"
7282 test -z "$ac_dir" && ac_dir=.
7283 if test -f $ac_dir/${ac_tool_prefix}file; then
7284 lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
7285 if test -n "$file_magic_test_file"; then
7286 case $deplibs_check_method in
7287 "file_magic "*)
7288 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
7289 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
7290 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
7291 $EGREP "$file_magic_regex" > /dev/null; then
7292 :
7293 else
7294 cat <<_LT_EOF 1>&2
7295
7296 *** Warning: the command libtool uses to detect shared libraries,
7297 *** $file_magic_cmd, produces output that libtool cannot recognize.
7298 *** The result is that libtool may fail to recognize shared libraries
7299 *** as such. This will affect the creation of libtool libraries that
7300 *** depend on shared libraries, but programs linked with such libtool
7301 *** libraries will work regardless of this problem. Nevertheless, you
7302 *** may want to report the problem to your system manager and/or to
7303 *** bug-libtool@gnu.org
7304
7305 _LT_EOF
7306 fi ;;
7307 esac
7308 fi
7309 break
7310 fi
7311 done
7312 IFS="$lt_save_ifs"
7313 MAGIC_CMD="$lt_save_MAGIC_CMD"
7314 ;;
7315 esac
7316 fi
7317
7318 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
7319 if test -n "$MAGIC_CMD"; then
7320 { echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
7321 echo "${ECHO_T}$MAGIC_CMD" >&6; }
7322 else
7323 { echo "$as_me:$LINENO: result: no" >&5
7324 echo "${ECHO_T}no" >&6; }
7325 fi
7326
7327
7328
7329
7330
7331 if test -z "$lt_cv_path_MAGIC_CMD"; then
7332 if test -n "$ac_tool_prefix"; then
7333 { echo "$as_me:$LINENO: checking for file" >&5
7334 echo $ECHO_N "checking for file... $ECHO_C" >&6; }
7335 if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
7336 echo $ECHO_N "(cached) $ECHO_C" >&6
7337 else
7338 case $MAGIC_CMD in
7339 [\\/*] | ?:[\\/]*)
7340 lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
7341 ;;
7342 *)
7343 lt_save_MAGIC_CMD="$MAGIC_CMD"
7344 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
7345 ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
7346 for ac_dir in $ac_dummy; do
7347 IFS="$lt_save_ifs"
7348 test -z "$ac_dir" && ac_dir=.
7349 if test -f $ac_dir/file; then
7350 lt_cv_path_MAGIC_CMD="$ac_dir/file"
7351 if test -n "$file_magic_test_file"; then
7352 case $deplibs_check_method in
7353 "file_magic "*)
7354 file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
7355 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
7356 if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
7357 $EGREP "$file_magic_regex" > /dev/null; then
7358 :
7359 else
7360 cat <<_LT_EOF 1>&2
7361
7362 *** Warning: the command libtool uses to detect shared libraries,
7363 *** $file_magic_cmd, produces output that libtool cannot recognize.
7364 *** The result is that libtool may fail to recognize shared libraries
7365 *** as such. This will affect the creation of libtool libraries that
7366 *** depend on shared libraries, but programs linked with such libtool
7367 *** libraries will work regardless of this problem. Nevertheless, you
7368 *** may want to report the problem to your system manager and/or to
7369 *** bug-libtool@gnu.org
7370
7371 _LT_EOF
7372 fi ;;
7373 esac
7374 fi
7375 break
7376 fi
7377 done
7378 IFS="$lt_save_ifs"
7379 MAGIC_CMD="$lt_save_MAGIC_CMD"
7380 ;;
7381 esac
7382 fi
7383
7384 MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
7385 if test -n "$MAGIC_CMD"; then
7386 { echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
7387 echo "${ECHO_T}$MAGIC_CMD" >&6; }
7388 else
7389 { echo "$as_me:$LINENO: result: no" >&5
7390 echo "${ECHO_T}no" >&6; }
7391 fi
7392
7393
7394 else
7395 MAGIC_CMD=:
7396 fi
7397 fi
7398
7399 fi
7400 ;;
7401 esac
7402
7403 # Use C for the default configuration in the libtool script
7404
7405 lt_save_CC="$CC"
7406 ac_ext=c
7407 ac_cpp='$CPP $CPPFLAGS'
7408 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
7409 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
7410 ac_compiler_gnu=$ac_cv_c_compiler_gnu
7411
7412
7413 # Source file extension for C test sources.
7414 ac_ext=c
7415
7416 # Object file extension for compiled C test sources.
7417 objext=o
7418 objext=$objext
7419
7420 # Code to be used in simple compile tests
7421 lt_simple_compile_test_code="int some_variable = 0;"
7422
7423 # Code to be used in simple link tests
7424 lt_simple_link_test_code='int main(){return(0);}'
7425
7426
7427
7428
7429
7430
7431
7432 # If no C compiler was specified, use CC.
7433 LTCC=${LTCC-"$CC"}
7434
7435 # If no C compiler flags were specified, use CFLAGS.
7436 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
7437
7438 # Allow CC to be a program name with arguments.
7439 compiler=$CC
7440
7441 # Save the default compiler, since it gets overwritten when the other
7442 # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
7443 compiler_DEFAULT=$CC
7444
7445 # save warnings/boilerplate of simple test code
7446 ac_outfile=conftest.$ac_objext
7447 echo "$lt_simple_compile_test_code" >conftest.$ac_ext
7448 eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
7449 _lt_compiler_boilerplate=`cat conftest.err`
7450 $RM -r conftest*
7451
7452 ac_outfile=conftest.$ac_objext
7453 echo "$lt_simple_link_test_code" >conftest.$ac_ext
7454 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
7455 _lt_linker_boilerplate=`cat conftest.err`
7456 $RM -r conftest*
7457
7458
7459 if test -n "$compiler"; then
7460
7461 lt_prog_compiler_no_builtin_flag=
7462
7463 if test "$GCC" = yes; then
7464 lt_prog_compiler_no_builtin_flag=' -fno-builtin'
7465
7466 { echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
7467 echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6; }
7468 if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
7469 echo $ECHO_N "(cached) $ECHO_C" >&6
7470 else
7471 lt_cv_prog_compiler_rtti_exceptions=no
7472 ac_outfile=conftest.$ac_objext
7473 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7474 lt_compiler_flag="-fno-rtti -fno-exceptions"
7475 # Insert the option either (1) after the last *FLAGS variable, or
7476 # (2) before a word containing "conftest.", or (3) at the end.
7477 # Note that $ac_compile itself does not contain backslashes and begins
7478 # with a dollar sign (not a hyphen), so the echo should work correctly.
7479 # The option is referenced via a variable to avoid confusing sed.
7480 lt_compile=`echo "$ac_compile" | $SED \
7481 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7482 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7483 -e 's:$: $lt_compiler_flag:'`
7484 (eval echo "\"\$as_me:7485: $lt_compile\"" >&5)
7485 (eval "$lt_compile" 2>conftest.err)
7486 ac_status=$?
7487 cat conftest.err >&5
7488 echo "$as_me:7489: \$? = $ac_status" >&5
7489 if (exit $ac_status) && test -s "$ac_outfile"; then
7490 # The compiler can only warn and ignore the option if not recognized
7491 # So say no if there are warnings other than the usual output.
7492 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
7493 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
7494 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
7495 lt_cv_prog_compiler_rtti_exceptions=yes
7496 fi
7497 fi
7498 $RM -r conftest*
7499
7500 fi
7501 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
7502 echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6; }
7503
7504 if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
7505 lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
7506 else
7507 :
7508 fi
7509
7510 fi
7511
7512
7513
7514
7515
7516
7517 lt_prog_compiler_wl=
7518 lt_prog_compiler_pic=
7519 lt_prog_compiler_static=
7520
7521 { echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
7522 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; }
7523
7524 if test "$GCC" = yes; then
7525 lt_prog_compiler_wl='-Wl,'
7526 lt_prog_compiler_static='-static'
7527
7528 case $host_os in
7529 aix*)
7530 # All AIX code is PIC.
7531 if test "$host_cpu" = ia64; then
7532 # AIX 5 now supports IA64 processor
7533 lt_prog_compiler_static='-Bstatic'
7534 fi
7535 ;;
7536
7537 amigaos*)
7538 case $host_cpu in
7539 powerpc)
7540 # see comment about AmigaOS4 .so support
7541 lt_prog_compiler_pic='-fPIC'
7542 ;;
7543 m68k)
7544 # FIXME: we need at least 68020 code to build shared libraries, but
7545 # adding the `-m68020' flag to GCC prevents building anything better,
7546 # like `-m68040'.
7547 lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
7548 ;;
7549 esac
7550 ;;
7551
7552 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
7553 # PIC is the default for these OSes.
7554 ;;
7555
7556 mingw* | cygwin* | pw32* | os2*)
7557 # This hack is so that the source file can tell whether it is being
7558 # built for inclusion in a dll (and should export symbols for example).
7559 # Although the cygwin gcc ignores -fPIC, still need this for old-style
7560 # (--disable-auto-import) libraries
7561 lt_prog_compiler_pic='-DDLL_EXPORT'
7562 ;;
7563
7564 darwin* | rhapsody*)
7565 # PIC is the default on this platform
7566 # Common symbols not allowed in MH_DYLIB files
7567 lt_prog_compiler_pic='-fno-common'
7568 ;;
7569
7570 hpux*)
7571 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
7572 # not for PA HP-UX.
7573 case $host_cpu in
7574 hppa*64*|ia64*)
7575 # +Z the default
7576 ;;
7577 *)
7578 lt_prog_compiler_pic='-fPIC'
7579 ;;
7580 esac
7581 ;;
7582
7583 interix[3-9]*)
7584 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
7585 # Instead, we relocate shared libraries at runtime.
7586 ;;
7587
7588 msdosdjgpp*)
7589 # Just because we use GCC doesn't mean we suddenly get shared libraries
7590 # on systems that don't support them.
7591 lt_prog_compiler_can_build_shared=no
7592 enable_shared=no
7593 ;;
7594
7595 *nto* | *qnx*)
7596 # QNX uses GNU C++, but need to define -shared option too, otherwise
7597 # it will coredump.
7598 lt_prog_compiler_pic='-fPIC -shared'
7599 ;;
7600
7601 sysv4*MP*)
7602 if test -d /usr/nec; then
7603 lt_prog_compiler_pic=-Kconform_pic
7604 fi
7605 ;;
7606
7607 *)
7608 lt_prog_compiler_pic='-fPIC'
7609 ;;
7610 esac
7611 else
7612 # PORTME Check for flag to pass linker flags through the system compiler.
7613 case $host_os in
7614 aix*)
7615 lt_prog_compiler_wl='-Wl,'
7616 if test "$host_cpu" = ia64; then
7617 # AIX 5 now supports IA64 processor
7618 lt_prog_compiler_static='-Bstatic'
7619 else
7620 lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
7621 fi
7622 ;;
7623
7624 mingw* | cygwin* | pw32* | os2*)
7625 # This hack is so that the source file can tell whether it is being
7626 # built for inclusion in a dll (and should export symbols for example).
7627 lt_prog_compiler_pic='-DDLL_EXPORT'
7628 ;;
7629
7630 hpux9* | hpux10* | hpux11*)
7631 lt_prog_compiler_wl='-Wl,'
7632 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
7633 # not for PA HP-UX.
7634 case $host_cpu in
7635 hppa*64*|ia64*)
7636 # +Z the default
7637 ;;
7638 *)
7639 lt_prog_compiler_pic='+Z'
7640 ;;
7641 esac
7642 # Is there a better lt_prog_compiler_static that works with the bundled CC?
7643 lt_prog_compiler_static='${wl}-a ${wl}archive'
7644 ;;
7645
7646 irix5* | irix6* | nonstopux*)
7647 lt_prog_compiler_wl='-Wl,'
7648 # PIC (with -KPIC) is the default.
7649 lt_prog_compiler_static='-non_shared'
7650 ;;
7651
7652 linux* | k*bsd*-gnu)
7653 case $cc_basename in
7654 icc* | ecc* | ifort*)
7655 lt_prog_compiler_wl='-Wl,'
7656 lt_prog_compiler_pic='-KPIC'
7657 lt_prog_compiler_static='-static'
7658 ;;
7659 pgcc* | pgf77* | pgf90* | pgf95*)
7660 # Portland Group compilers (*not* the Pentium gcc compiler,
7661 # which looks to be a dead project)
7662 lt_prog_compiler_wl='-Wl,'
7663 lt_prog_compiler_pic='-fpic'
7664 lt_prog_compiler_static='-Bstatic'
7665 ;;
7666 ccc*)
7667 lt_prog_compiler_wl='-Wl,'
7668 # All Alpha code is PIC.
7669 lt_prog_compiler_static='-non_shared'
7670 ;;
7671 xl*)
7672 # IBM XL C 8.0/Fortran 10.1 on PPC
7673 lt_prog_compiler_wl='-Wl,'
7674 lt_prog_compiler_pic='-qpic'
7675 lt_prog_compiler_static='-qstaticlink'
7676 ;;
7677 *)
7678 case `$CC -V 2>&1 | sed 5q` in
7679 *Sun\ C*)
7680 # Sun C 5.9
7681 lt_prog_compiler_pic='-KPIC'
7682 lt_prog_compiler_static='-Bstatic'
7683 lt_prog_compiler_wl='-Wl,'
7684 ;;
7685 *Sun\ F*)
7686 # Sun Fortran 8.3 passes all unrecognized flags to the linker
7687 lt_prog_compiler_pic='-KPIC'
7688 lt_prog_compiler_static='-Bstatic'
7689 lt_prog_compiler_wl=''
7690 ;;
7691 esac
7692 ;;
7693 esac
7694 ;;
7695
7696 newsos6)
7697 lt_prog_compiler_pic='-KPIC'
7698 lt_prog_compiler_static='-Bstatic'
7699 ;;
7700
7701 *nto* | *qnx*)
7702 # QNX uses GNU C++, but need to define -shared option too, otherwise
7703 # it will coredump.
7704 lt_prog_compiler_pic='-fPIC -shared'
7705 ;;
7706
7707 osf3* | osf4* | osf5*)
7708 lt_prog_compiler_wl='-Wl,'
7709 # All OSF/1 code is PIC.
7710 lt_prog_compiler_static='-non_shared'
7711 ;;
7712
7713 rdos*)
7714 lt_prog_compiler_static='-non_shared'
7715 ;;
7716
7717 solaris*)
7718 lt_prog_compiler_pic='-KPIC'
7719 lt_prog_compiler_static='-Bstatic'
7720 case $cc_basename in
7721 f77* | f90* | f95*)
7722 lt_prog_compiler_wl='-Qoption ld ';;
7723 *)
7724 lt_prog_compiler_wl='-Wl,';;
7725 esac
7726 ;;
7727
7728 sunos4*)
7729 lt_prog_compiler_wl='-Qoption ld '
7730 lt_prog_compiler_pic='-PIC'
7731 lt_prog_compiler_static='-Bstatic'
7732 ;;
7733
7734 sysv4 | sysv4.2uw2* | sysv4.3*)
7735 lt_prog_compiler_wl='-Wl,'
7736 lt_prog_compiler_pic='-KPIC'
7737 lt_prog_compiler_static='-Bstatic'
7738 ;;
7739
7740 sysv4*MP*)
7741 if test -d /usr/nec ;then
7742 lt_prog_compiler_pic='-Kconform_pic'
7743 lt_prog_compiler_static='-Bstatic'
7744 fi
7745 ;;
7746
7747 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
7748 lt_prog_compiler_wl='-Wl,'
7749 lt_prog_compiler_pic='-KPIC'
7750 lt_prog_compiler_static='-Bstatic'
7751 ;;
7752
7753 unicos*)
7754 lt_prog_compiler_wl='-Wl,'
7755 lt_prog_compiler_can_build_shared=no
7756 ;;
7757
7758 uts4*)
7759 lt_prog_compiler_pic='-pic'
7760 lt_prog_compiler_static='-Bstatic'
7761 ;;
7762
7763 *)
7764 lt_prog_compiler_can_build_shared=no
7765 ;;
7766 esac
7767 fi
7768
7769 case $host_os in
7770 # For platforms which do not support PIC, -DPIC is meaningless:
7771 *djgpp*)
7772 lt_prog_compiler_pic=
7773 ;;
7774 *)
7775 lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
7776 ;;
7777 esac
7778 { echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
7779 echo "${ECHO_T}$lt_prog_compiler_pic" >&6; }
7780
7781
7782
7783
7784
7785
7786 #
7787 # Check to make sure the PIC flag actually works.
7788 #
7789 if test -n "$lt_prog_compiler_pic"; then
7790 { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
7791 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6; }
7792 if test "${lt_cv_prog_compiler_pic_works+set}" = set; then
7793 echo $ECHO_N "(cached) $ECHO_C" >&6
7794 else
7795 lt_cv_prog_compiler_pic_works=no
7796 ac_outfile=conftest.$ac_objext
7797 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7798 lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
7799 # Insert the option either (1) after the last *FLAGS variable, or
7800 # (2) before a word containing "conftest.", or (3) at the end.
7801 # Note that $ac_compile itself does not contain backslashes and begins
7802 # with a dollar sign (not a hyphen), so the echo should work correctly.
7803 # The option is referenced via a variable to avoid confusing sed.
7804 lt_compile=`echo "$ac_compile" | $SED \
7805 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7806 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7807 -e 's:$: $lt_compiler_flag:'`
7808 (eval echo "\"\$as_me:7809: $lt_compile\"" >&5)
7809 (eval "$lt_compile" 2>conftest.err)
7810 ac_status=$?
7811 cat conftest.err >&5
7812 echo "$as_me:7813: \$? = $ac_status" >&5
7813 if (exit $ac_status) && test -s "$ac_outfile"; then
7814 # The compiler can only warn and ignore the option if not recognized
7815 # So say no if there are warnings other than the usual output.
7816 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
7817 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
7818 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
7819 lt_cv_prog_compiler_pic_works=yes
7820 fi
7821 fi
7822 $RM -r conftest*
7823
7824 fi
7825 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works" >&5
7826 echo "${ECHO_T}$lt_cv_prog_compiler_pic_works" >&6; }
7827
7828 if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
7829 case $lt_prog_compiler_pic in
7830 "" | " "*) ;;
7831 *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
7832 esac
7833 else
7834 lt_prog_compiler_pic=
7835 lt_prog_compiler_can_build_shared=no
7836 fi
7837
7838 fi
7839
7840
7841
7842
7843
7844
7845 #
7846 # Check to make sure the static flag actually works.
7847 #
7848 wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
7849 { echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
7850 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
7851 if test "${lt_cv_prog_compiler_static_works+set}" = set; then
7852 echo $ECHO_N "(cached) $ECHO_C" >&6
7853 else
7854 lt_cv_prog_compiler_static_works=no
7855 save_LDFLAGS="$LDFLAGS"
7856 LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
7857 echo "$lt_simple_link_test_code" > conftest.$ac_ext
7858 if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
7859 # The linker can only warn and ignore the option if not recognized
7860 # So say no if there are warnings
7861 if test -s conftest.err; then
7862 # Append any errors to the config.log.
7863 cat conftest.err 1>&5
7864 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
7865 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
7866 if diff conftest.exp conftest.er2 >/dev/null; then
7867 lt_cv_prog_compiler_static_works=yes
7868 fi
7869 else
7870 lt_cv_prog_compiler_static_works=yes
7871 fi
7872 fi
7873 $RM -r conftest*
7874 LDFLAGS="$save_LDFLAGS"
7875
7876 fi
7877 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works" >&5
7878 echo "${ECHO_T}$lt_cv_prog_compiler_static_works" >&6; }
7879
7880 if test x"$lt_cv_prog_compiler_static_works" = xyes; then
7881 :
7882 else
7883 lt_prog_compiler_static=
7884 fi
7885
7886
7887
7888
7889
7890
7891
7892 { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
7893 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; }
7894 if test "${lt_cv_prog_compiler_c_o+set}" = set; then
7895 echo $ECHO_N "(cached) $ECHO_C" >&6
7896 else
7897 lt_cv_prog_compiler_c_o=no
7898 $RM -r conftest 2>/dev/null
7899 mkdir conftest
7900 cd conftest
7901 mkdir out
7902 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7903
7904 lt_compiler_flag="-o out/conftest2.$ac_objext"
7905 # Insert the option either (1) after the last *FLAGS variable, or
7906 # (2) before a word containing "conftest.", or (3) at the end.
7907 # Note that $ac_compile itself does not contain backslashes and begins
7908 # with a dollar sign (not a hyphen), so the echo should work correctly.
7909 lt_compile=`echo "$ac_compile" | $SED \
7910 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7911 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7912 -e 's:$: $lt_compiler_flag:'`
7913 (eval echo "\"\$as_me:7914: $lt_compile\"" >&5)
7914 (eval "$lt_compile" 2>out/conftest.err)
7915 ac_status=$?
7916 cat out/conftest.err >&5
7917 echo "$as_me:7918: \$? = $ac_status" >&5
7918 if (exit $ac_status) && test -s out/conftest2.$ac_objext
7919 then
7920 # The compiler can only warn and ignore the option if not recognized
7921 # So say no if there are warnings
7922 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
7923 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
7924 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
7925 lt_cv_prog_compiler_c_o=yes
7926 fi
7927 fi
7928 chmod u+w . 2>&5
7929 $RM -r conftest*
7930 # SGI C++ compiler will create directory out/ii_files/ for
7931 # template instantiation
7932 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
7933 $RM out/* && rmdir out
7934 cd ..
7935 $RM -r conftest
7936 $RM -r conftest*
7937
7938 fi
7939 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
7940 echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6; }
7941
7942
7943
7944
7945
7946
7947 { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
7948 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; }
7949 if test "${lt_cv_prog_compiler_c_o+set}" = set; then
7950 echo $ECHO_N "(cached) $ECHO_C" >&6
7951 else
7952 lt_cv_prog_compiler_c_o=no
7953 $RM -r conftest 2>/dev/null
7954 mkdir conftest
7955 cd conftest
7956 mkdir out
7957 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
7958
7959 lt_compiler_flag="-o out/conftest2.$ac_objext"
7960 # Insert the option either (1) after the last *FLAGS variable, or
7961 # (2) before a word containing "conftest.", or (3) at the end.
7962 # Note that $ac_compile itself does not contain backslashes and begins
7963 # with a dollar sign (not a hyphen), so the echo should work correctly.
7964 lt_compile=`echo "$ac_compile" | $SED \
7965 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
7966 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
7967 -e 's:$: $lt_compiler_flag:'`
7968 (eval echo "\"\$as_me:7969: $lt_compile\"" >&5)
7969 (eval "$lt_compile" 2>out/conftest.err)
7970 ac_status=$?
7971 cat out/conftest.err >&5
7972 echo "$as_me:7973: \$? = $ac_status" >&5
7973 if (exit $ac_status) && test -s out/conftest2.$ac_objext
7974 then
7975 # The compiler can only warn and ignore the option if not recognized
7976 # So say no if there are warnings
7977 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
7978 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
7979 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
7980 lt_cv_prog_compiler_c_o=yes
7981 fi
7982 fi
7983 chmod u+w . 2>&5
7984 $RM -r conftest*
7985 # SGI C++ compiler will create directory out/ii_files/ for
7986 # template instantiation
7987 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
7988 $RM out/* && rmdir out
7989 cd ..
7990 $RM -r conftest
7991 $RM -r conftest*
7992
7993 fi
7994 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
7995 echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6; }
7996
7997
7998
7999
8000 hard_links="nottested"
8001 if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
8002 # do not overwrite the value of need_locks provided by the user
8003 { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
8004 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; }
8005 hard_links=yes
8006 $RM -r conftest*
8007 ln conftest.a conftest.b 2>/dev/null && hard_links=no
8008 touch conftest.a
8009 ln conftest.a conftest.b 2>&5 || hard_links=no
8010 ln conftest.a conftest.b 2>/dev/null && hard_links=no
8011 { echo "$as_me:$LINENO: result: $hard_links" >&5
8012 echo "${ECHO_T}$hard_links" >&6; }
8013 if test "$hard_links" = no; then
8014 { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
8015 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
8016 need_locks=warn
8017 fi
8018 else
8019 need_locks=no
8020 fi
8021
8022
8023
8024
8025
8026
8027 { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
8028 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
8029
8030 runpath_var=
8031 allow_undefined_flag=
8032 always_export_symbols=no
8033 archive_cmds=
8034 archive_expsym_cmds=
8035 compiler_needs_object=no
8036 enable_shared_with_static_runtimes=no
8037 export_dynamic_flag_spec=
8038 export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
8039 hardcode_automatic=no
8040 hardcode_direct=no
8041 hardcode_direct_absolute=no
8042 hardcode_libdir_flag_spec=
8043 hardcode_libdir_flag_spec_ld=
8044 hardcode_libdir_separator=
8045 hardcode_minus_L=no
8046 hardcode_shlibpath_var=unsupported
8047 inherit_rpath=no
8048 link_all_deplibs=unknown
8049 module_cmds=
8050 module_expsym_cmds=
8051 old_archive_from_new_cmds=
8052 old_archive_from_expsyms_cmds=
8053 thread_safe_flag_spec=
8054 whole_archive_flag_spec=
8055 # include_expsyms should be a list of space-separated symbols to be *always*
8056 # included in the symbol list
8057 include_expsyms=
8058 # exclude_expsyms can be an extended regexp of symbols to exclude
8059 # it will be wrapped by ` (' and `)$', so one must not match beginning or
8060 # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
8061 # as well as any symbol that contains `d'.
8062 exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
8063 # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
8064 # platforms (ab)use it in PIC code, but their linkers get confused if
8065 # the symbol is explicitly referenced. Since portable code cannot
8066 # rely on this symbol name, it's probably fine to never include it in
8067 # preloaded symbol tables.
8068 # Exclude shared library initialization/finalization symbols.
8069 extract_expsyms_cmds=
8070
8071 case $host_os in
8072 cygwin* | mingw* | pw32*)
8073 # FIXME: the MSVC++ port hasn't been tested in a loooong time
8074 # When not using gcc, we currently assume that we are using
8075 # Microsoft Visual C++.
8076 if test "$GCC" != yes; then
8077 with_gnu_ld=no
8078 fi
8079 ;;
8080 interix*)
8081 # we just hope/assume this is gcc and not c89 (= MSVC++)
8082 with_gnu_ld=yes
8083 ;;
8084 openbsd*)
8085 with_gnu_ld=no
8086 ;;
8087 esac
8088
8089 ld_shlibs=yes
8090 if test "$with_gnu_ld" = yes; then
8091 # If archive_cmds runs LD, not CC, wlarc should be empty
8092 wlarc='${wl}'
8093
8094 # Set some defaults for GNU ld with shared library support. These
8095 # are reset later if shared libraries are not supported. Putting them
8096 # here allows them to be overridden if necessary.
8097 runpath_var=LD_RUN_PATH
8098 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8099 export_dynamic_flag_spec='${wl}--export-dynamic'
8100 # ancient GNU ld didn't support --whole-archive et. al.
8101 if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
8102 whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
8103 else
8104 whole_archive_flag_spec=
8105 fi
8106 supports_anon_versioning=no
8107 case `$LD -v 2>&1` in
8108 *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
8109 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
8110 *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
8111 *\ 2.11.*) ;; # other 2.11 versions
8112 *) supports_anon_versioning=yes ;;
8113 esac
8114
8115 # See if GNU ld supports shared libraries.
8116 case $host_os in
8117 aix[3-9]*)
8118 # On AIX/PPC, the GNU linker is very broken
8119 if test "$host_cpu" != ia64; then
8120 ld_shlibs=no
8121 cat <<_LT_EOF 1>&2
8122
8123 *** Warning: the GNU linker, at least up to release 2.9.1, is reported
8124 *** to be unable to reliably create shared libraries on AIX.
8125 *** Therefore, libtool is disabling shared libraries support. If you
8126 *** really care for shared libraries, you may want to modify your PATH
8127 *** so that a non-GNU linker is found, and then restart.
8128
8129 _LT_EOF
8130 fi
8131 ;;
8132
8133 amigaos*)
8134 case $host_cpu in
8135 powerpc)
8136 # see comment about AmigaOS4 .so support
8137 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8138 archive_expsym_cmds=''
8139 ;;
8140 m68k)
8141 archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
8142 hardcode_libdir_flag_spec='-L$libdir'
8143 hardcode_minus_L=yes
8144 ;;
8145 esac
8146 ;;
8147
8148 beos*)
8149 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
8150 allow_undefined_flag=unsupported
8151 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
8152 # support --undefined. This deserves some investigation. FIXME
8153 archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8154 else
8155 ld_shlibs=no
8156 fi
8157 ;;
8158
8159 cygwin* | mingw* | pw32*)
8160 # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
8161 # as there is no search path for DLLs.
8162 hardcode_libdir_flag_spec='-L$libdir'
8163 allow_undefined_flag=unsupported
8164 always_export_symbols=no
8165 enable_shared_with_static_runtimes=yes
8166 export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
8167
8168 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
8169 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
8170 # If the export-symbols file already is a .def file (1st line
8171 # is EXPORTS), use it as is; otherwise, prepend...
8172 archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
8173 cp $export_symbols $output_objdir/$soname.def;
8174 else
8175 echo EXPORTS > $output_objdir/$soname.def;
8176 cat $export_symbols >> $output_objdir/$soname.def;
8177 fi~
8178 $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
8179 else
8180 ld_shlibs=no
8181 fi
8182 ;;
8183
8184 interix[3-9]*)
8185 hardcode_direct=no
8186 hardcode_shlibpath_var=no
8187 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
8188 export_dynamic_flag_spec='${wl}-E'
8189 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
8190 # Instead, shared libraries are loaded at an image base (0x10000000 by
8191 # default) and relocated if they conflict, which is a slow very memory
8192 # consuming and fragmenting process. To avoid this, we pick a random,
8193 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
8194 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
8195 archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
8196 archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
8197 ;;
8198
8199 gnu* | linux* | tpf* | k*bsd*-gnu)
8200 tmp_diet=no
8201 if test "$host_os" = linux-dietlibc; then
8202 case $cc_basename in
8203 diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
8204 esac
8205 fi
8206 if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
8207 && test "$tmp_diet" = no
8208 then
8209 tmp_addflag=
8210 tmp_sharedflag='-shared'
8211 case $cc_basename,$host_cpu in
8212 pgcc*) # Portland Group C compiler
8213 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
8214 tmp_addflag=' $pic_flag'
8215 ;;
8216 pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
8217 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
8218 tmp_addflag=' $pic_flag -Mnomain' ;;
8219 ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
8220 tmp_addflag=' -i_dynamic' ;;
8221 efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
8222 tmp_addflag=' -i_dynamic -nofor_main' ;;
8223 ifc* | ifort*) # Intel Fortran compiler
8224 tmp_addflag=' -nofor_main' ;;
8225 xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
8226 tmp_sharedflag='-qmkshrobj'
8227 tmp_addflag= ;;
8228 esac
8229 case `$CC -V 2>&1 | sed 5q` in
8230 *Sun\ C*) # Sun C 5.9
8231 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
8232 compiler_needs_object=yes
8233 tmp_sharedflag='-G' ;;
8234 *Sun\ F*) # Sun Fortran 8.3
8235 tmp_sharedflag='-G' ;;
8236 esac
8237 archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8238
8239 if test "x$supports_anon_versioning" = xyes; then
8240 archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
8241 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
8242 echo "local: *; };" >> $output_objdir/$libname.ver~
8243 $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
8244 fi
8245
8246 case $cc_basename in
8247 xlf*)
8248 # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
8249 whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
8250 hardcode_libdir_flag_spec=
8251 hardcode_libdir_flag_spec_ld='-rpath $libdir'
8252 archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
8253 if test "x$supports_anon_versioning" = xyes; then
8254 archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
8255 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
8256 echo "local: *; };" >> $output_objdir/$libname.ver~
8257 $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
8258 fi
8259 ;;
8260 esac
8261 else
8262 ld_shlibs=no
8263 fi
8264 ;;
8265
8266 netbsd*)
8267 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
8268 archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
8269 wlarc=
8270 else
8271 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8272 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
8273 fi
8274 ;;
8275
8276 solaris*)
8277 if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
8278 ld_shlibs=no
8279 cat <<_LT_EOF 1>&2
8280
8281 *** Warning: The releases 2.8.* of the GNU linker cannot reliably
8282 *** create shared libraries on Solaris systems. Therefore, libtool
8283 *** is disabling shared libraries support. We urge you to upgrade GNU
8284 *** binutils to release 2.9.1 or newer. Another option is to modify
8285 *** your PATH or compiler configuration so that the native linker is
8286 *** used, and then restart.
8287
8288 _LT_EOF
8289 elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
8290 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8291 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
8292 else
8293 ld_shlibs=no
8294 fi
8295 ;;
8296
8297 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
8298 case `$LD -v 2>&1` in
8299 *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
8300 ld_shlibs=no
8301 cat <<_LT_EOF 1>&2
8302
8303 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
8304 *** reliably create shared libraries on SCO systems. Therefore, libtool
8305 *** is disabling shared libraries support. We urge you to upgrade GNU
8306 *** binutils to release 2.16.91.0.3 or newer. Another option is to modify
8307 *** your PATH or compiler configuration so that the native linker is
8308 *** used, and then restart.
8309
8310 _LT_EOF
8311 ;;
8312 *)
8313 # For security reasons, it is highly recommended that you always
8314 # use absolute paths for naming shared libraries, and exclude the
8315 # DT_RUNPATH tag from executables and libraries. But doing so
8316 # requires that you compile everything twice, which is a pain.
8317 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
8318 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8319 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8320 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
8321 else
8322 ld_shlibs=no
8323 fi
8324 ;;
8325 esac
8326 ;;
8327
8328 sunos4*)
8329 archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
8330 wlarc=
8331 hardcode_direct=yes
8332 hardcode_shlibpath_var=no
8333 ;;
8334
8335 *)
8336 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
8337 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8338 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
8339 else
8340 ld_shlibs=no
8341 fi
8342 ;;
8343 esac
8344
8345 if test "$ld_shlibs" = no; then
8346 runpath_var=
8347 hardcode_libdir_flag_spec=
8348 export_dynamic_flag_spec=
8349 whole_archive_flag_spec=
8350 fi
8351 else
8352 # PORTME fill in a description of your system's linker (not GNU ld)
8353 case $host_os in
8354 aix3*)
8355 allow_undefined_flag=unsupported
8356 always_export_symbols=yes
8357 archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
8358 # Note: this linker hardcodes the directories in LIBPATH if there
8359 # are no directories specified by -L.
8360 hardcode_minus_L=yes
8361 if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
8362 # Neither direct hardcoding nor static linking is supported with a
8363 # broken collect2.
8364 hardcode_direct=unsupported
8365 fi
8366 ;;
8367
8368 aix[4-9]*)
8369 if test "$host_cpu" = ia64; then
8370 # On IA64, the linker does run time linking by default, so we don't
8371 # have to do anything special.
8372 aix_use_runtimelinking=no
8373 exp_sym_flag='-Bexport'
8374 no_entry_flag=""
8375 else
8376 # If we're using GNU nm, then we don't want the "-C" option.
8377 # -C means demangle to AIX nm, but means don't demangle with GNU nm
8378 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
8379 export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
8380 else
8381 export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
8382 fi
8383 aix_use_runtimelinking=no
8384
8385 # Test if we are trying to use run time linking or normal
8386 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
8387 # need to do runtime linking.
8388 case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
8389 for ld_flag in $LDFLAGS; do
8390 if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
8391 aix_use_runtimelinking=yes
8392 break
8393 fi
8394 done
8395 ;;
8396 esac
8397
8398 exp_sym_flag='-bexport'
8399 no_entry_flag='-bnoentry'
8400 fi
8401
8402 # When large executables or shared objects are built, AIX ld can
8403 # have problems creating the table of contents. If linking a library
8404 # or program results in "error TOC overflow" add -mminimal-toc to
8405 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
8406 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
8407
8408 archive_cmds=''
8409 hardcode_direct=yes
8410 hardcode_direct_absolute=yes
8411 hardcode_libdir_separator=':'
8412 link_all_deplibs=yes
8413 file_list_spec='${wl}-f,'
8414
8415 if test "$GCC" = yes; then
8416 case $host_os in aix4.[012]|aix4.[012].*)
8417 # We only want to do this on AIX 4.2 and lower, the check
8418 # below for broken collect2 doesn't work under 4.3+
8419 collect2name=`${CC} -print-prog-name=collect2`
8420 if test -f "$collect2name" &&
8421 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
8422 then
8423 # We have reworked collect2
8424 :
8425 else
8426 # We have old collect2
8427 hardcode_direct=unsupported
8428 # It fails to find uninstalled libraries when the uninstalled
8429 # path is not listed in the libpath. Setting hardcode_minus_L
8430 # to unsupported forces relinking
8431 hardcode_minus_L=yes
8432 hardcode_libdir_flag_spec='-L$libdir'
8433 hardcode_libdir_separator=
8434 fi
8435 ;;
8436 esac
8437 shared_flag='-shared'
8438 if test "$aix_use_runtimelinking" = yes; then
8439 shared_flag="$shared_flag "'${wl}-G'
8440 fi
8441 else
8442 # not using gcc
8443 if test "$host_cpu" = ia64; then
8444 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
8445 # chokes on -Wl,-G. The following line is correct:
8446 shared_flag='-G'
8447 else
8448 if test "$aix_use_runtimelinking" = yes; then
8449 shared_flag='${wl}-G'
8450 else
8451 shared_flag='${wl}-bM:SRE'
8452 fi
8453 fi
8454 fi
8455
8456 # It seems that -bexpall does not export symbols beginning with
8457 # underscore (_), so it is better to generate a list of symbols to export.
8458 always_export_symbols=yes
8459 if test "$aix_use_runtimelinking" = yes; then
8460 # Warning - without using the other runtime loading flags (-brtl),
8461 # -berok will link without error, but may produce a broken library.
8462 allow_undefined_flag='-berok'
8463 # Determine the default libpath from the value encoded in an
8464 # empty executable.
8465 cat >conftest.$ac_ext <<_ACEOF
8466 /* confdefs.h. */
8467 _ACEOF
8468 cat confdefs.h >>conftest.$ac_ext
8469 cat >>conftest.$ac_ext <<_ACEOF
8470 /* end confdefs.h. */
8471
8472 int
8473 main ()
8474 {
8475
8476 ;
8477 return 0;
8478 }
8479 _ACEOF
8480 rm -f conftest.$ac_objext conftest$ac_exeext
8481 if { (ac_try="$ac_link"
8482 case "(($ac_try" in
8483 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
8484 *) ac_try_echo=$ac_try;;
8485 esac
8486 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
8487 (eval "$ac_link") 2>conftest.er1
8488 ac_status=$?
8489 grep -v '^ *+' conftest.er1 >conftest.err
8490 rm -f conftest.er1
8491 cat conftest.err >&5
8492 echo "$as_me:$LINENO: \$? = $ac_status" >&5
8493 (exit $ac_status); } && {
8494 test -z "$ac_c_werror_flag" ||
8495 test ! -s conftest.err
8496 } && test -s conftest$ac_exeext &&
8497 $as_test_x conftest$ac_exeext; then
8498
8499 lt_aix_libpath_sed='
8500 /Import File Strings/,/^$/ {
8501 /^0/ {
8502 s/^0 *\(.*\)$/\1/
8503 p
8504 }
8505 }'
8506 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8507 # Check for a 64-bit object if we didn't find anything.
8508 if test -z "$aix_libpath"; then
8509 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8510 fi
8511 else
8512 echo "$as_me: failed program was:" >&5
8513 sed 's/^/| /' conftest.$ac_ext >&5
8514
8515
8516 fi
8517
8518 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
8519 conftest$ac_exeext conftest.$ac_ext
8520 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
8521
8522 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
8523 archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
8524 else
8525 if test "$host_cpu" = ia64; then
8526 hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
8527 allow_undefined_flag="-z nodefs"
8528 archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
8529 else
8530 # Determine the default libpath from the value encoded in an
8531 # empty executable.
8532 cat >conftest.$ac_ext <<_ACEOF
8533 /* confdefs.h. */
8534 _ACEOF
8535 cat confdefs.h >>conftest.$ac_ext
8536 cat >>conftest.$ac_ext <<_ACEOF
8537 /* end confdefs.h. */
8538
8539 int
8540 main ()
8541 {
8542
8543 ;
8544 return 0;
8545 }
8546 _ACEOF
8547 rm -f conftest.$ac_objext conftest$ac_exeext
8548 if { (ac_try="$ac_link"
8549 case "(($ac_try" in
8550 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
8551 *) ac_try_echo=$ac_try;;
8552 esac
8553 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
8554 (eval "$ac_link") 2>conftest.er1
8555 ac_status=$?
8556 grep -v '^ *+' conftest.er1 >conftest.err
8557 rm -f conftest.er1
8558 cat conftest.err >&5
8559 echo "$as_me:$LINENO: \$? = $ac_status" >&5
8560 (exit $ac_status); } && {
8561 test -z "$ac_c_werror_flag" ||
8562 test ! -s conftest.err
8563 } && test -s conftest$ac_exeext &&
8564 $as_test_x conftest$ac_exeext; then
8565
8566 lt_aix_libpath_sed='
8567 /Import File Strings/,/^$/ {
8568 /^0/ {
8569 s/^0 *\(.*\)$/\1/
8570 p
8571 }
8572 }'
8573 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8574 # Check for a 64-bit object if we didn't find anything.
8575 if test -z "$aix_libpath"; then
8576 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
8577 fi
8578 else
8579 echo "$as_me: failed program was:" >&5
8580 sed 's/^/| /' conftest.$ac_ext >&5
8581
8582
8583 fi
8584
8585 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
8586 conftest$ac_exeext conftest.$ac_ext
8587 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
8588
8589 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
8590 # Warning - without using the other run time loading flags,
8591 # -berok will link without error, but may produce a broken library.
8592 no_undefined_flag=' ${wl}-bernotok'
8593 allow_undefined_flag=' ${wl}-berok'
8594 # Exported symbols can be pulled into shared objects from archives
8595 whole_archive_flag_spec='$convenience'
8596 archive_cmds_need_lc=yes
8597 # This is similar to how AIX traditionally builds its shared libraries.
8598 archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
8599 fi
8600 fi
8601 ;;
8602
8603 amigaos*)
8604 case $host_cpu in
8605 powerpc)
8606 # see comment about AmigaOS4 .so support
8607 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
8608 archive_expsym_cmds=''
8609 ;;
8610 m68k)
8611 archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
8612 hardcode_libdir_flag_spec='-L$libdir'
8613 hardcode_minus_L=yes
8614 ;;
8615 esac
8616 ;;
8617
8618 bsdi[45]*)
8619 export_dynamic_flag_spec=-rdynamic
8620 ;;
8621
8622 cygwin* | mingw* | pw32*)
8623 # When not using gcc, we currently assume that we are using
8624 # Microsoft Visual C++.
8625 # hardcode_libdir_flag_spec is actually meaningless, as there is
8626 # no search path for DLLs.
8627 hardcode_libdir_flag_spec=' '
8628 allow_undefined_flag=unsupported
8629 # Tell ltmain to make .lib files, not .a files.
8630 libext=lib
8631 # Tell ltmain to make .dll files, not .so files.
8632 shrext_cmds=".dll"
8633 # FIXME: Setting linknames here is a bad hack.
8634 archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
8635 # The linker will automatically build a .lib file if we build a DLL.
8636 old_archive_from_new_cmds='true'
8637 # FIXME: Should let the user specify the lib program.
8638 old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
8639 fix_srcfile_path='`cygpath -w "$srcfile"`'
8640 enable_shared_with_static_runtimes=yes
8641 ;;
8642
8643 darwin* | rhapsody*)
8644
8645
8646 archive_cmds_need_lc=no
8647 hardcode_direct=no
8648 hardcode_automatic=yes
8649 hardcode_shlibpath_var=unsupported
8650 whole_archive_flag_spec=''
8651 link_all_deplibs=yes
8652 allow_undefined_flag="$_lt_dar_allow_undefined"
8653 if test "$GCC" = "yes"; then
8654 output_verbose_link_cmd=echo
8655 archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
8656 module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
8657 archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
8658 module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
8659
8660 else
8661 ld_shlibs=no
8662 fi
8663
8664 ;;
8665
8666 dgux*)
8667 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8668 hardcode_libdir_flag_spec='-L$libdir'
8669 hardcode_shlibpath_var=no
8670 ;;
8671
8672 freebsd1*)
8673 ld_shlibs=no
8674 ;;
8675
8676 # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
8677 # support. Future versions do this automatically, but an explicit c++rt0.o
8678 # does not break anything, and helps significantly (at the cost of a little
8679 # extra space).
8680 freebsd2.2*)
8681 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
8682 hardcode_libdir_flag_spec='-R$libdir'
8683 hardcode_direct=yes
8684 hardcode_shlibpath_var=no
8685 ;;
8686
8687 # Unfortunately, older versions of FreeBSD 2 do not have this feature.
8688 freebsd2*)
8689 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
8690 hardcode_direct=yes
8691 hardcode_minus_L=yes
8692 hardcode_shlibpath_var=no
8693 ;;
8694
8695 # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
8696 freebsd* | dragonfly*)
8697 archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
8698 hardcode_libdir_flag_spec='-R$libdir'
8699 hardcode_direct=yes
8700 hardcode_shlibpath_var=no
8701 ;;
8702
8703 hpux9*)
8704 if test "$GCC" = yes; then
8705 archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
8706 else
8707 archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
8708 fi
8709 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8710 hardcode_libdir_separator=:
8711 hardcode_direct=yes
8712
8713 # hardcode_minus_L: Not really in the search PATH,
8714 # but as the default location of the library.
8715 hardcode_minus_L=yes
8716 export_dynamic_flag_spec='${wl}-E'
8717 ;;
8718
8719 hpux10*)
8720 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
8721 archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8722 else
8723 archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
8724 fi
8725 if test "$with_gnu_ld" = no; then
8726 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8727 hardcode_libdir_flag_spec_ld='+b $libdir'
8728 hardcode_libdir_separator=:
8729 hardcode_direct=yes
8730 hardcode_direct_absolute=yes
8731 export_dynamic_flag_spec='${wl}-E'
8732 # hardcode_minus_L: Not really in the search PATH,
8733 # but as the default location of the library.
8734 hardcode_minus_L=yes
8735 fi
8736 ;;
8737
8738 hpux11*)
8739 if test "$GCC" = yes -a "$with_gnu_ld" = no; then
8740 case $host_cpu in
8741 hppa*64*)
8742 archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8743 ;;
8744 ia64*)
8745 archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
8746 ;;
8747 *)
8748 archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8749 ;;
8750 esac
8751 else
8752 case $host_cpu in
8753 hppa*64*)
8754 archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8755 ;;
8756 ia64*)
8757 archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
8758 ;;
8759 *)
8760 archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
8761 ;;
8762 esac
8763 fi
8764 if test "$with_gnu_ld" = no; then
8765 hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
8766 hardcode_libdir_separator=:
8767
8768 case $host_cpu in
8769 hppa*64*|ia64*)
8770 hardcode_direct=no
8771 hardcode_shlibpath_var=no
8772 ;;
8773 *)
8774 hardcode_direct=yes
8775 hardcode_direct_absolute=yes
8776 export_dynamic_flag_spec='${wl}-E'
8777
8778 # hardcode_minus_L: Not really in the search PATH,
8779 # but as the default location of the library.
8780 hardcode_minus_L=yes
8781 ;;
8782 esac
8783 fi
8784 ;;
8785
8786 irix5* | irix6* | nonstopux*)
8787 if test "$GCC" = yes; then
8788 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
8789 # Try to use the -exported_symbol ld option, if it does not
8790 # work, assume that -exports_file does not work either and
8791 # implicitly export all symbols.
8792 save_LDFLAGS="$LDFLAGS"
8793 LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
8794 cat >conftest.$ac_ext <<_ACEOF
8795 int foo(void) {}
8796 _ACEOF
8797 rm -f conftest.$ac_objext conftest$ac_exeext
8798 if { (ac_try="$ac_link"
8799 case "(($ac_try" in
8800 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
8801 *) ac_try_echo=$ac_try;;
8802 esac
8803 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
8804 (eval "$ac_link") 2>conftest.er1
8805 ac_status=$?
8806 grep -v '^ *+' conftest.er1 >conftest.err
8807 rm -f conftest.er1
8808 cat conftest.err >&5
8809 echo "$as_me:$LINENO: \$? = $ac_status" >&5
8810 (exit $ac_status); } && {
8811 test -z "$ac_c_werror_flag" ||
8812 test ! -s conftest.err
8813 } && test -s conftest$ac_exeext &&
8814 $as_test_x conftest$ac_exeext; then
8815 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
8816
8817 else
8818 echo "$as_me: failed program was:" >&5
8819 sed 's/^/| /' conftest.$ac_ext >&5
8820
8821
8822 fi
8823
8824 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
8825 conftest$ac_exeext conftest.$ac_ext
8826 LDFLAGS="$save_LDFLAGS"
8827 else
8828 archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
8829 archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
8830 fi
8831 archive_cmds_need_lc='no'
8832 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8833 hardcode_libdir_separator=:
8834 inherit_rpath=yes
8835 link_all_deplibs=yes
8836 ;;
8837
8838 netbsd*)
8839 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
8840 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
8841 else
8842 archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
8843 fi
8844 hardcode_libdir_flag_spec='-R$libdir'
8845 hardcode_direct=yes
8846 hardcode_shlibpath_var=no
8847 ;;
8848
8849 newsos6)
8850 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8851 hardcode_direct=yes
8852 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8853 hardcode_libdir_separator=:
8854 hardcode_shlibpath_var=no
8855 ;;
8856
8857 *nto* | *qnx*)
8858 ;;
8859
8860 openbsd*)
8861 if test -f /usr/libexec/ld.so; then
8862 hardcode_direct=yes
8863 hardcode_shlibpath_var=no
8864 hardcode_direct_absolute=yes
8865 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
8866 archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
8867 archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
8868 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
8869 export_dynamic_flag_spec='${wl}-E'
8870 else
8871 case $host_os in
8872 openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
8873 archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
8874 hardcode_libdir_flag_spec='-R$libdir'
8875 ;;
8876 *)
8877 archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
8878 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
8879 ;;
8880 esac
8881 fi
8882 else
8883 ld_shlibs=no
8884 fi
8885 ;;
8886
8887 os2*)
8888 hardcode_libdir_flag_spec='-L$libdir'
8889 hardcode_minus_L=yes
8890 allow_undefined_flag=unsupported
8891 archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
8892 old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
8893 ;;
8894
8895 osf3*)
8896 if test "$GCC" = yes; then
8897 allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
8898 archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
8899 else
8900 allow_undefined_flag=' -expect_unresolved \*'
8901 archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
8902 fi
8903 archive_cmds_need_lc='no'
8904 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8905 hardcode_libdir_separator=:
8906 ;;
8907
8908 osf4* | osf5*) # as osf3* with the addition of -msym flag
8909 if test "$GCC" = yes; then
8910 allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
8911 archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
8912 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
8913 else
8914 allow_undefined_flag=' -expect_unresolved \*'
8915 archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
8916 archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
8917 $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
8918
8919 # Both c and cxx compiler support -rpath directly
8920 hardcode_libdir_flag_spec='-rpath $libdir'
8921 fi
8922 archive_cmds_need_lc='no'
8923 hardcode_libdir_separator=:
8924 ;;
8925
8926 solaris*)
8927 no_undefined_flag=' -z defs'
8928 if test "$GCC" = yes; then
8929 wlarc='${wl}'
8930 archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
8931 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8932 $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
8933 else
8934 case `$CC -V 2>&1` in
8935 *"Compilers 5.0"*)
8936 wlarc=''
8937 archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
8938 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8939 $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
8940 ;;
8941 *)
8942 wlarc='${wl}'
8943 archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
8944 archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
8945 $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
8946 ;;
8947 esac
8948 fi
8949 hardcode_libdir_flag_spec='-R$libdir'
8950 hardcode_shlibpath_var=no
8951 case $host_os in
8952 solaris2.[0-5] | solaris2.[0-5].*) ;;
8953 *)
8954 # The compiler driver will combine and reorder linker options,
8955 # but understands `-z linker_flag'. GCC discards it without `$wl',
8956 # but is careful enough not to reorder.
8957 # Supported since Solaris 2.6 (maybe 2.5.1?)
8958 if test "$GCC" = yes; then
8959 whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
8960 else
8961 whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
8962 fi
8963 ;;
8964 esac
8965 link_all_deplibs=yes
8966 ;;
8967
8968 sunos4*)
8969 if test "x$host_vendor" = xsequent; then
8970 # Use $CC to link under sequent, because it throws in some extra .o
8971 # files that make .init and .fini sections work.
8972 archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
8973 else
8974 archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
8975 fi
8976 hardcode_libdir_flag_spec='-L$libdir'
8977 hardcode_direct=yes
8978 hardcode_minus_L=yes
8979 hardcode_shlibpath_var=no
8980 ;;
8981
8982 sysv4)
8983 case $host_vendor in
8984 sni)
8985 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8986 hardcode_direct=yes # is this really true???
8987 ;;
8988 siemens)
8989 ## LD is ld it makes a PLAMLIB
8990 ## CC just makes a GrossModule.
8991 archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
8992 reload_cmds='$CC -r -o $output$reload_objs'
8993 hardcode_direct=no
8994 ;;
8995 motorola)
8996 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
8997 hardcode_direct=no #Motorola manual says yes, but my tests say they lie
8998 ;;
8999 esac
9000 runpath_var='LD_RUN_PATH'
9001 hardcode_shlibpath_var=no
9002 ;;
9003
9004 sysv4.3*)
9005 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
9006 hardcode_shlibpath_var=no
9007 export_dynamic_flag_spec='-Bexport'
9008 ;;
9009
9010 sysv4*MP*)
9011 if test -d /usr/nec; then
9012 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
9013 hardcode_shlibpath_var=no
9014 runpath_var=LD_RUN_PATH
9015 hardcode_runpath_var=yes
9016 ld_shlibs=yes
9017 fi
9018 ;;
9019
9020 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
9021 no_undefined_flag='${wl}-z,text'
9022 archive_cmds_need_lc=no
9023 hardcode_shlibpath_var=no
9024 runpath_var='LD_RUN_PATH'
9025
9026 if test "$GCC" = yes; then
9027 archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
9028 archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
9029 else
9030 archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
9031 archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
9032 fi
9033 ;;
9034
9035 sysv5* | sco3.2v5* | sco5v6*)
9036 # Note: We can NOT use -z defs as we might desire, because we do not
9037 # link with -lc, and that would cause any symbols used from libc to
9038 # always be unresolved, which means just about no library would
9039 # ever link correctly. If we're not using GNU ld we use -z text
9040 # though, which does catch some bad symbols but isn't as heavy-handed
9041 # as -z defs.
9042 no_undefined_flag='${wl}-z,text'
9043 allow_undefined_flag='${wl}-z,nodefs'
9044 archive_cmds_need_lc=no
9045 hardcode_shlibpath_var=no
9046 hardcode_libdir_flag_spec='${wl}-R,$libdir'
9047 hardcode_libdir_separator=':'
9048 link_all_deplibs=yes
9049 export_dynamic_flag_spec='${wl}-Bexport'
9050 runpath_var='LD_RUN_PATH'
9051
9052 if test "$GCC" = yes; then
9053 archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
9054 archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
9055 else
9056 archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
9057 archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
9058 fi
9059 ;;
9060
9061 uts4*)
9062 archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
9063 hardcode_libdir_flag_spec='-L$libdir'
9064 hardcode_shlibpath_var=no
9065 ;;
9066
9067 *)
9068 ld_shlibs=no
9069 ;;
9070 esac
9071
9072 if test x$host_vendor = xsni; then
9073 case $host in
9074 sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
9075 export_dynamic_flag_spec='${wl}-Blargedynsym'
9076 ;;
9077 esac
9078 fi
9079 fi
9080
9081 { echo "$as_me:$LINENO: result: $ld_shlibs" >&5
9082 echo "${ECHO_T}$ld_shlibs" >&6; }
9083 test "$ld_shlibs" = no && can_build_shared=no
9084
9085 with_gnu_ld=$with_gnu_ld
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101 #
9102 # Do we need to explicitly link libc?
9103 #
9104 case "x$archive_cmds_need_lc" in
9105 x|xyes)
9106 # Assume -lc should be added
9107 archive_cmds_need_lc=yes
9108
9109 if test "$enable_shared" = yes && test "$GCC" = yes; then
9110 case $archive_cmds in
9111 *'~'*)
9112 # FIXME: we may have to deal with multi-command sequences.
9113 ;;
9114 '$CC '*)
9115 # Test whether the compiler implicitly links with -lc since on some
9116 # systems, -lgcc has to come before -lc. If gcc already passes -lc
9117 # to ld, don't add -lc before -lgcc.
9118 { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
9119 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; }
9120 $RM -r conftest*
9121 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
9122
9123 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
9124 (eval $ac_compile) 2>&5
9125 ac_status=$?
9126 echo "$as_me:$LINENO: \$? = $ac_status" >&5
9127 (exit $ac_status); } 2>conftest.err; then
9128 soname=conftest
9129 lib=conftest
9130 libobjs=conftest.$ac_objext
9131 deplibs=
9132 wl=$lt_prog_compiler_wl
9133 pic_flag=$lt_prog_compiler_pic
9134 compiler_flags=-v
9135 linker_flags=-v
9136 verstring=
9137 output_objdir=.
9138 libname=conftest
9139 lt_save_allow_undefined_flag=$allow_undefined_flag
9140 allow_undefined_flag=
9141 if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
9142 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
9143 ac_status=$?
9144 echo "$as_me:$LINENO: \$? = $ac_status" >&5
9145 (exit $ac_status); }
9146 then
9147 archive_cmds_need_lc=no
9148 else
9149 archive_cmds_need_lc=yes
9150 fi
9151 allow_undefined_flag=$lt_save_allow_undefined_flag
9152 else
9153 cat conftest.err 1>&5
9154 fi
9155 $RM -r conftest*
9156 { echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
9157 echo "${ECHO_T}$archive_cmds_need_lc" >&6; }
9158 ;;
9159 esac
9160 fi
9161 ;;
9162 esac
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320 { echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
9321 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; }
9322
9323 if test "$GCC" = yes; then
9324 case $host_os in
9325 darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
9326 *) lt_awk_arg="/^libraries:/" ;;
9327 esac
9328 lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
9329 if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
9330 # if the path contains ";" then we assume it to be the separator
9331 # otherwise default to the standard path separator (i.e. ":") - it is
9332 # assumed that no part of a normal pathname contains ";" but that should
9333 # okay in the real world where ";" in dirpaths is itself problematic.
9334 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
9335 else
9336 lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
9337 fi
9338 # Ok, now we have the path, separated by spaces, we can step through it
9339 # and add multilib dir if necessary.
9340 lt_tmp_lt_search_path_spec=
9341 lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
9342 for lt_sys_path in $lt_search_path_spec; do
9343 if test -d "$lt_sys_path/$lt_multi_os_dir"; then
9344 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
9345 else
9346 test -d "$lt_sys_path" && \
9347 lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
9348 fi
9349 done
9350 lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
9351 BEGIN {RS=" "; FS="/|\n";} {
9352 lt_foo="";
9353 lt_count=0;
9354 for (lt_i = NF; lt_i > 0; lt_i--) {
9355 if ($lt_i != "" && $lt_i != ".") {
9356 if ($lt_i == "..") {
9357 lt_count++;
9358 } else {
9359 if (lt_count == 0) {
9360 lt_foo="/" $lt_i lt_foo;
9361 } else {
9362 lt_count--;
9363 }
9364 }
9365 }
9366 }
9367 if (lt_foo != "") { lt_freq[lt_foo]++; }
9368 if (lt_freq[lt_foo] == 1) { print lt_foo; }
9369 }'`
9370 sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
9371 else
9372 sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
9373 fi
9374 library_names_spec=
9375 libname_spec='lib$name'
9376 soname_spec=
9377 shrext_cmds=".so"
9378 postinstall_cmds=
9379 postuninstall_cmds=
9380 finish_cmds=
9381 finish_eval=
9382 shlibpath_var=
9383 shlibpath_overrides_runpath=unknown
9384 version_type=none
9385 dynamic_linker="$host_os ld.so"
9386 sys_lib_dlsearch_path_spec="/lib /usr/lib"
9387 need_lib_prefix=unknown
9388 hardcode_into_libs=no
9389
9390 # when you set need_version to no, make sure it does not cause -set_version
9391 # flags to be left without arguments
9392 need_version=unknown
9393
9394 case $host_os in
9395 aix3*)
9396 version_type=linux
9397 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
9398 shlibpath_var=LIBPATH
9399
9400 # AIX 3 has no versioning support, so we append a major version to the name.
9401 soname_spec='${libname}${release}${shared_ext}$major'
9402 ;;
9403
9404 aix[4-9]*)
9405 version_type=linux
9406 need_lib_prefix=no
9407 need_version=no
9408 hardcode_into_libs=yes
9409 if test "$host_cpu" = ia64; then
9410 # AIX 5 supports IA64
9411 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
9412 shlibpath_var=LD_LIBRARY_PATH
9413 else
9414 # With GCC up to 2.95.x, collect2 would create an import file
9415 # for dependence libraries. The import file would start with
9416 # the line `#! .'. This would cause the generated library to
9417 # depend on `.', always an invalid library. This was fixed in
9418 # development snapshots of GCC prior to 3.0.
9419 case $host_os in
9420 aix4 | aix4.[01] | aix4.[01].*)
9421 if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
9422 echo ' yes '
9423 echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
9424 :
9425 else
9426 can_build_shared=no
9427 fi
9428 ;;
9429 esac
9430 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
9431 # soname into executable. Probably we can add versioning support to
9432 # collect2, so additional links can be useful in future.
9433 if test "$aix_use_runtimelinking" = yes; then
9434 # If using run time linking (on AIX 4.2 or later) use lib<name>.so
9435 # instead of lib<name>.a to let people know that these are not
9436 # typical AIX shared libraries.
9437 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9438 else
9439 # We preserve .a as extension for shared libraries through AIX4.2
9440 # and later when we are not doing run time linking.
9441 library_names_spec='${libname}${release}.a $libname.a'
9442 soname_spec='${libname}${release}${shared_ext}$major'
9443 fi
9444 shlibpath_var=LIBPATH
9445 fi
9446 ;;
9447
9448 amigaos*)
9449 case $host_cpu in
9450 powerpc)
9451 # Since July 2007 AmigaOS4 officially supports .so libraries.
9452 # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
9453 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9454 ;;
9455 m68k)
9456 library_names_spec='$libname.ixlibrary $libname.a'
9457 # Create ${libname}_ixlibrary.a entries in /sys/libs.
9458 finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
9459 ;;
9460 esac
9461 ;;
9462
9463 beos*)
9464 library_names_spec='${libname}${shared_ext}'
9465 dynamic_linker="$host_os ld.so"
9466 shlibpath_var=LIBRARY_PATH
9467 ;;
9468
9469 bsdi[45]*)
9470 version_type=linux
9471 need_version=no
9472 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9473 soname_spec='${libname}${release}${shared_ext}$major'
9474 finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
9475 shlibpath_var=LD_LIBRARY_PATH
9476 sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
9477 sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
9478 # the default ld.so.conf also contains /usr/contrib/lib and
9479 # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
9480 # libtool to hard-code these into programs
9481 ;;
9482
9483 cygwin* | mingw* | pw32*)
9484 version_type=windows
9485 shrext_cmds=".dll"
9486 need_version=no
9487 need_lib_prefix=no
9488
9489 case $GCC,$host_os in
9490 yes,cygwin* | yes,mingw* | yes,pw32*)
9491 library_names_spec='$libname.dll.a'
9492 # DLL is installed to $(libdir)/../bin by postinstall_cmds
9493 postinstall_cmds='base_file=`basename \${file}`~
9494 dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
9495 dldir=$destdir/`dirname \$dlpath`~
9496 test -d \$dldir || mkdir -p \$dldir~
9497 $install_prog $dir/$dlname \$dldir/$dlname~
9498 chmod a+x \$dldir/$dlname~
9499 if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
9500 eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
9501 fi'
9502 postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
9503 dlpath=$dir/\$dldll~
9504 $RM \$dlpath'
9505 shlibpath_overrides_runpath=yes
9506
9507 case $host_os in
9508 cygwin*)
9509 # Cygwin DLLs use 'cyg' prefix rather than 'lib'
9510 soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
9511 sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
9512 ;;
9513 mingw*)
9514 # MinGW DLLs use traditional 'lib' prefix
9515 soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
9516 sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
9517 if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
9518 # It is most probably a Windows format PATH printed by
9519 # mingw gcc, but we are running on Cygwin. Gcc prints its search
9520 # path with ; separators, and with drive letters. We can handle the
9521 # drive letters (cygwin fileutils understands them), so leave them,
9522 # especially as we might pass files found there to a mingw objdump,
9523 # which wouldn't understand a cygwinified path. Ahh.
9524 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
9525 else
9526 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
9527 fi
9528 ;;
9529 pw32*)
9530 # pw32 DLLs use 'pw' prefix rather than 'lib'
9531 library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
9532 ;;
9533 esac
9534 ;;
9535
9536 *)
9537 library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
9538 ;;
9539 esac
9540 dynamic_linker='Win32 ld.exe'
9541 # FIXME: first we should search . and the directory the executable is in
9542 shlibpath_var=PATH
9543 ;;
9544
9545 darwin* | rhapsody*)
9546 dynamic_linker="$host_os dyld"
9547 version_type=darwin
9548 need_lib_prefix=no
9549 need_version=no
9550 library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext ${libname}${release}${versuffix}$shared_ext'
9551 soname_spec='${libname}${release}${major}$shared_ext'
9552 shlibpath_overrides_runpath=yes
9553 shlibpath_var=DYLD_LIBRARY_PATH
9554 shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
9555
9556 sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
9557 sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
9558 ;;
9559
9560 dgux*)
9561 version_type=linux
9562 need_lib_prefix=no
9563 need_version=no
9564 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
9565 soname_spec='${libname}${release}${shared_ext}$major'
9566 shlibpath_var=LD_LIBRARY_PATH
9567 ;;
9568
9569 freebsd1*)
9570 dynamic_linker=no
9571 ;;
9572
9573 freebsd* | dragonfly*)
9574 # DragonFly does not have aout. When/if they implement a new
9575 # versioning mechanism, adjust this.
9576 if test -x /usr/bin/objformat; then
9577 objformat=`/usr/bin/objformat`
9578 else
9579 case $host_os in
9580 freebsd[123]*) objformat=aout ;;
9581 *) objformat=elf ;;
9582 esac
9583 fi
9584 version_type=freebsd-$objformat
9585 case $version_type in
9586 freebsd-elf*)
9587 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
9588 need_version=no
9589 need_lib_prefix=no
9590 ;;
9591 freebsd-*)
9592 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
9593 need_version=yes
9594 ;;
9595 esac
9596 shlibpath_var=LD_LIBRARY_PATH
9597 case $host_os in
9598 freebsd2*)
9599 shlibpath_overrides_runpath=yes
9600 ;;
9601 freebsd3.[01]* | freebsdelf3.[01]*)
9602 shlibpath_overrides_runpath=yes
9603 hardcode_into_libs=yes
9604 ;;
9605 freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
9606 freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
9607 shlibpath_overrides_runpath=no
9608 hardcode_into_libs=yes
9609 ;;
9610 *) # from 4.6 on, and DragonFly
9611 shlibpath_overrides_runpath=yes
9612 hardcode_into_libs=yes
9613 ;;
9614 esac
9615 ;;
9616
9617 gnu*)
9618 version_type=linux
9619 need_lib_prefix=no
9620 need_version=no
9621 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
9622 soname_spec='${libname}${release}${shared_ext}$major'
9623 shlibpath_var=LD_LIBRARY_PATH
9624 hardcode_into_libs=yes
9625 ;;
9626
9627 hpux9* | hpux10* | hpux11*)
9628 # Give a soname corresponding to the major version so that dld.sl refuses to
9629 # link against other versions.
9630 version_type=sunos
9631 need_lib_prefix=no
9632 need_version=no
9633 case $host_cpu in
9634 ia64*)
9635 shrext_cmds='.so'
9636 hardcode_into_libs=yes
9637 dynamic_linker="$host_os dld.so"
9638 shlibpath_var=LD_LIBRARY_PATH
9639 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
9640 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9641 soname_spec='${libname}${release}${shared_ext}$major'
9642 if test "X$HPUX_IA64_MODE" = X32; then
9643 sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
9644 else
9645 sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
9646 fi
9647 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
9648 ;;
9649 hppa*64*)
9650 shrext_cmds='.sl'
9651 hardcode_into_libs=yes
9652 dynamic_linker="$host_os dld.sl"
9653 shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
9654 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
9655 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9656 soname_spec='${libname}${release}${shared_ext}$major'
9657 sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
9658 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
9659 ;;
9660 *)
9661 shrext_cmds='.sl'
9662 dynamic_linker="$host_os dld.sl"
9663 shlibpath_var=SHLIB_PATH
9664 shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
9665 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9666 soname_spec='${libname}${release}${shared_ext}$major'
9667 ;;
9668 esac
9669 # HP-UX runs *really* slowly unless shared libraries are mode 555.
9670 postinstall_cmds='chmod 555 $lib'
9671 ;;
9672
9673 interix[3-9]*)
9674 version_type=linux
9675 need_lib_prefix=no
9676 need_version=no
9677 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
9678 soname_spec='${libname}${release}${shared_ext}$major'
9679 dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
9680 shlibpath_var=LD_LIBRARY_PATH
9681 shlibpath_overrides_runpath=no
9682 hardcode_into_libs=yes
9683 ;;
9684
9685 irix5* | irix6* | nonstopux*)
9686 case $host_os in
9687 nonstopux*) version_type=nonstopux ;;
9688 *)
9689 if test "$lt_cv_prog_gnu_ld" = yes; then
9690 version_type=linux
9691 else
9692 version_type=irix
9693 fi ;;
9694 esac
9695 need_lib_prefix=no
9696 need_version=no
9697 soname_spec='${libname}${release}${shared_ext}$major'
9698 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
9699 case $host_os in
9700 irix5* | nonstopux*)
9701 libsuff= shlibsuff=
9702 ;;
9703 *)
9704 case $LD in # libtool.m4 will add one of these switches to LD
9705 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
9706 libsuff= shlibsuff= libmagic=32-bit;;
9707 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
9708 libsuff=32 shlibsuff=N32 libmagic=N32;;
9709 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
9710 libsuff=64 shlibsuff=64 libmagic=64-bit;;
9711 *) libsuff= shlibsuff= libmagic=never-match;;
9712 esac
9713 ;;
9714 esac
9715 shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
9716 shlibpath_overrides_runpath=no
9717 sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
9718 sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
9719 hardcode_into_libs=yes
9720 ;;
9721
9722 # No shared lib support for Linux oldld, aout, or coff.
9723 linux*oldld* | linux*aout* | linux*coff*)
9724 dynamic_linker=no
9725 ;;
9726
9727 # This must be Linux ELF.
9728 linux* | k*bsd*-gnu)
9729 version_type=linux
9730 need_lib_prefix=no
9731 need_version=no
9732 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9733 soname_spec='${libname}${release}${shared_ext}$major'
9734 finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
9735 shlibpath_var=LD_LIBRARY_PATH
9736 shlibpath_overrides_runpath=no
9737 # Some binutils ld are patched to set DT_RUNPATH
9738 save_LDFLAGS=$LDFLAGS
9739 save_libdir=$libdir
9740 eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
9741 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
9742 cat >conftest.$ac_ext <<_ACEOF
9743 /* confdefs.h. */
9744 _ACEOF
9745 cat confdefs.h >>conftest.$ac_ext
9746 cat >>conftest.$ac_ext <<_ACEOF
9747 /* end confdefs.h. */
9748
9749 int
9750 main ()
9751 {
9752
9753 ;
9754 return 0;
9755 }
9756 _ACEOF
9757 rm -f conftest.$ac_objext conftest$ac_exeext
9758 if { (ac_try="$ac_link"
9759 case "(($ac_try" in
9760 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
9761 *) ac_try_echo=$ac_try;;
9762 esac
9763 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
9764 (eval "$ac_link") 2>conftest.er1
9765 ac_status=$?
9766 grep -v '^ *+' conftest.er1 >conftest.err
9767 rm -f conftest.er1
9768 cat conftest.err >&5
9769 echo "$as_me:$LINENO: \$? = $ac_status" >&5
9770 (exit $ac_status); } && {
9771 test -z "$ac_c_werror_flag" ||
9772 test ! -s conftest.err
9773 } && test -s conftest$ac_exeext &&
9774 $as_test_x conftest$ac_exeext; then
9775 if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then
9776 shlibpath_overrides_runpath=yes
9777 fi
9778
9779 else
9780 echo "$as_me: failed program was:" >&5
9781 sed 's/^/| /' conftest.$ac_ext >&5
9782
9783
9784 fi
9785
9786 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
9787 conftest$ac_exeext conftest.$ac_ext
9788 LDFLAGS=$save_LDFLAGS
9789 libdir=$save_libdir
9790
9791 # This implies no fast_install, which is unacceptable.
9792 # Some rework will be needed to allow for fast_install
9793 # before this can be enabled.
9794 hardcode_into_libs=yes
9795
9796 # Append ld.so.conf contents to the search path
9797 if test -f /etc/ld.so.conf; then
9798 lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
9799 sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
9800 fi
9801
9802 # We used to test for /lib/ld.so.1 and disable shared libraries on
9803 # powerpc, because MkLinux only supported shared libraries with the
9804 # GNU dynamic linker. Since this was broken with cross compilers,
9805 # most powerpc-linux boxes support dynamic linking these days and
9806 # people can always --disable-shared, the test was removed, and we
9807 # assume the GNU/Linux dynamic linker is in use.
9808 dynamic_linker='GNU/Linux ld.so'
9809 ;;
9810
9811 netbsd*)
9812 version_type=sunos
9813 need_lib_prefix=no
9814 need_version=no
9815 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
9816 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9817 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
9818 dynamic_linker='NetBSD (a.out) ld.so'
9819 else
9820 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
9821 soname_spec='${libname}${release}${shared_ext}$major'
9822 dynamic_linker='NetBSD ld.elf_so'
9823 fi
9824 shlibpath_var=LD_LIBRARY_PATH
9825 shlibpath_overrides_runpath=yes
9826 hardcode_into_libs=yes
9827 ;;
9828
9829 newsos6)
9830 version_type=linux
9831 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9832 shlibpath_var=LD_LIBRARY_PATH
9833 shlibpath_overrides_runpath=yes
9834 ;;
9835
9836 *nto* | *qnx*)
9837 version_type=qnx
9838 need_lib_prefix=no
9839 need_version=no
9840 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9841 soname_spec='${libname}${release}${shared_ext}$major'
9842 shlibpath_var=LD_LIBRARY_PATH
9843 shlibpath_overrides_runpath=no
9844 hardcode_into_libs=yes
9845 dynamic_linker='ldqnx.so'
9846 ;;
9847
9848 openbsd*)
9849 version_type=sunos
9850 sys_lib_dlsearch_path_spec="/usr/lib"
9851 need_lib_prefix=no
9852 # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
9853 case $host_os in
9854 openbsd3.3 | openbsd3.3.*) need_version=yes ;;
9855 *) need_version=no ;;
9856 esac
9857 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9858 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
9859 shlibpath_var=LD_LIBRARY_PATH
9860 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
9861 case $host_os in
9862 openbsd2.[89] | openbsd2.[89].*)
9863 shlibpath_overrides_runpath=no
9864 ;;
9865 *)
9866 shlibpath_overrides_runpath=yes
9867 ;;
9868 esac
9869 else
9870 shlibpath_overrides_runpath=yes
9871 fi
9872 ;;
9873
9874 os2*)
9875 libname_spec='$name'
9876 shrext_cmds=".dll"
9877 need_lib_prefix=no
9878 library_names_spec='$libname${shared_ext} $libname.a'
9879 dynamic_linker='OS/2 ld.exe'
9880 shlibpath_var=LIBPATH
9881 ;;
9882
9883 osf3* | osf4* | osf5*)
9884 version_type=osf
9885 need_lib_prefix=no
9886 need_version=no
9887 soname_spec='${libname}${release}${shared_ext}$major'
9888 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9889 shlibpath_var=LD_LIBRARY_PATH
9890 sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
9891 sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
9892 ;;
9893
9894 rdos*)
9895 dynamic_linker=no
9896 ;;
9897
9898 solaris*)
9899 version_type=linux
9900 need_lib_prefix=no
9901 need_version=no
9902 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9903 soname_spec='${libname}${release}${shared_ext}$major'
9904 shlibpath_var=LD_LIBRARY_PATH
9905 shlibpath_overrides_runpath=yes
9906 hardcode_into_libs=yes
9907 # ldd complains unless libraries are executable
9908 postinstall_cmds='chmod +x $lib'
9909 ;;
9910
9911 sunos4*)
9912 version_type=sunos
9913 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
9914 finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
9915 shlibpath_var=LD_LIBRARY_PATH
9916 shlibpath_overrides_runpath=yes
9917 if test "$with_gnu_ld" = yes; then
9918 need_lib_prefix=no
9919 fi
9920 need_version=yes
9921 ;;
9922
9923 sysv4 | sysv4.3*)
9924 version_type=linux
9925 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9926 soname_spec='${libname}${release}${shared_ext}$major'
9927 shlibpath_var=LD_LIBRARY_PATH
9928 case $host_vendor in
9929 sni)
9930 shlibpath_overrides_runpath=no
9931 need_lib_prefix=no
9932 runpath_var=LD_RUN_PATH
9933 ;;
9934 siemens)
9935 need_lib_prefix=no
9936 ;;
9937 motorola)
9938 need_lib_prefix=no
9939 need_version=no
9940 shlibpath_overrides_runpath=no
9941 sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
9942 ;;
9943 esac
9944 ;;
9945
9946 sysv4*MP*)
9947 if test -d /usr/nec ;then
9948 version_type=linux
9949 library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
9950 soname_spec='$libname${shared_ext}.$major'
9951 shlibpath_var=LD_LIBRARY_PATH
9952 fi
9953 ;;
9954
9955 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
9956 version_type=freebsd-elf
9957 need_lib_prefix=no
9958 need_version=no
9959 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
9960 soname_spec='${libname}${release}${shared_ext}$major'
9961 shlibpath_var=LD_LIBRARY_PATH
9962 shlibpath_overrides_runpath=yes
9963 hardcode_into_libs=yes
9964 if test "$with_gnu_ld" = yes; then
9965 sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
9966 else
9967 sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
9968 case $host_os in
9969 sco3.2v5*)
9970 sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
9971 ;;
9972 esac
9973 fi
9974 sys_lib_dlsearch_path_spec='/usr/lib'
9975 ;;
9976
9977 tpf*)
9978 # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
9979 version_type=linux
9980 need_lib_prefix=no
9981 need_version=no
9982 library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9983 shlibpath_var=LD_LIBRARY_PATH
9984 shlibpath_overrides_runpath=no
9985 hardcode_into_libs=yes
9986 ;;
9987
9988 uts4*)
9989 version_type=linux
9990 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
9991 soname_spec='${libname}${release}${shared_ext}$major'
9992 shlibpath_var=LD_LIBRARY_PATH
9993 ;;
9994
9995 *)
9996 dynamic_linker=no
9997 ;;
9998 esac
9999 { echo "$as_me:$LINENO: result: $dynamic_linker" >&5
10000 echo "${ECHO_T}$dynamic_linker" >&6; }
10001 test "$dynamic_linker" = no && can_build_shared=no
10002
10003 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
10004 if test "$GCC" = yes; then
10005 variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
10006 fi
10007
10008 if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
10009 sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
10010 fi
10011 if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
10012 sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
10013 fi
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101 { echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
10102 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; }
10103 hardcode_action=
10104 if test -n "$hardcode_libdir_flag_spec" ||
10105 test -n "$runpath_var" ||
10106 test "X$hardcode_automatic" = "Xyes" ; then
10107
10108 # We can hardcode non-existent directories.
10109 if test "$hardcode_direct" != no &&
10110 # If the only mechanism to avoid hardcoding is shlibpath_var, we
10111 # have to relink, otherwise we might link with an installed library
10112 # when we should be linking with a yet-to-be-installed one
10113 ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
10114 test "$hardcode_minus_L" != no; then
10115 # Linking always hardcodes the temporary library directory.
10116 hardcode_action=relink
10117 else
10118 # We can link without hardcoding, and we can hardcode nonexisting dirs.
10119 hardcode_action=immediate
10120 fi
10121 else
10122 # We cannot hardcode anything, or else we can only hardcode existing
10123 # directories.
10124 hardcode_action=unsupported
10125 fi
10126 { echo "$as_me:$LINENO: result: $hardcode_action" >&5
10127 echo "${ECHO_T}$hardcode_action" >&6; }
10128
10129 if test "$hardcode_action" = relink ||
10130 test "$inherit_rpath" = yes; then
10131 # Fast installation is not supported
10132 enable_fast_install=no
10133 elif test "$shlibpath_overrides_runpath" = yes ||
10134 test "$enable_shared" = no; then
10135 # Fast installation is not necessary
10136 enable_fast_install=needless
10137 fi
10138
10139
10140
10141
10142
10143
10144 if test "x$enable_dlopen" != xyes; then
10145 enable_dlopen=unknown
10146 enable_dlopen_self=unknown
10147 enable_dlopen_self_static=unknown
10148 else
10149 lt_cv_dlopen=no
10150 lt_cv_dlopen_libs=
10151
10152 case $host_os in
10153 beos*)
10154 lt_cv_dlopen="load_add_on"
10155 lt_cv_dlopen_libs=
10156 lt_cv_dlopen_self=yes
10157 ;;
10158
10159 mingw* | pw32*)
10160 lt_cv_dlopen="LoadLibrary"
10161 lt_cv_dlopen_libs=
10162 ;;
10163
10164 cygwin*)
10165 lt_cv_dlopen="dlopen"
10166 lt_cv_dlopen_libs=
10167 ;;
10168
10169 darwin*)
10170 # if libdl is installed we need to link against it
10171 { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
10172 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; }
10173 if test "${ac_cv_lib_dl_dlopen+set}" = set; then
10174 echo $ECHO_N "(cached) $ECHO_C" >&6
10175 else
10176 ac_check_lib_save_LIBS=$LIBS
10177 LIBS="-ldl $LIBS"
10178 cat >conftest.$ac_ext <<_ACEOF
10179 /* confdefs.h. */
10180 _ACEOF
10181 cat confdefs.h >>conftest.$ac_ext
10182 cat >>conftest.$ac_ext <<_ACEOF
10183 /* end confdefs.h. */
10184
10185 /* Override any GCC internal prototype to avoid an error.
10186 Use char because int might match the return type of a GCC
10187 builtin and then its argument prototype would still apply. */
10188 #ifdef __cplusplus
10189 extern "C"
10190 #endif
10191 char dlopen ();
10192 int
10193 main ()
10194 {
10195 return dlopen ();
10196 ;
10197 return 0;
10198 }
10199 _ACEOF
10200 rm -f conftest.$ac_objext conftest$ac_exeext
10201 if { (ac_try="$ac_link"
10202 case "(($ac_try" in
10203 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10204 *) ac_try_echo=$ac_try;;
10205 esac
10206 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
10207 (eval "$ac_link") 2>conftest.er1
10208 ac_status=$?
10209 grep -v '^ *+' conftest.er1 >conftest.err
10210 rm -f conftest.er1
10211 cat conftest.err >&5
10212 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10213 (exit $ac_status); } && {
10214 test -z "$ac_c_werror_flag" ||
10215 test ! -s conftest.err
10216 } && test -s conftest$ac_exeext &&
10217 $as_test_x conftest$ac_exeext; then
10218 ac_cv_lib_dl_dlopen=yes
10219 else
10220 echo "$as_me: failed program was:" >&5
10221 sed 's/^/| /' conftest.$ac_ext >&5
10222
10223 ac_cv_lib_dl_dlopen=no
10224 fi
10225
10226 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
10227 conftest$ac_exeext conftest.$ac_ext
10228 LIBS=$ac_check_lib_save_LIBS
10229 fi
10230 { echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
10231 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; }
10232 if test $ac_cv_lib_dl_dlopen = yes; then
10233 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
10234 else
10235
10236 lt_cv_dlopen="dyld"
10237 lt_cv_dlopen_libs=
10238 lt_cv_dlopen_self=yes
10239
10240 fi
10241
10242 ;;
10243
10244 *)
10245 { echo "$as_me:$LINENO: checking for shl_load" >&5
10246 echo $ECHO_N "checking for shl_load... $ECHO_C" >&6; }
10247 if test "${ac_cv_func_shl_load+set}" = set; then
10248 echo $ECHO_N "(cached) $ECHO_C" >&6
10249 else
10250 cat >conftest.$ac_ext <<_ACEOF
10251 /* confdefs.h. */
10252 _ACEOF
10253 cat confdefs.h >>conftest.$ac_ext
10254 cat >>conftest.$ac_ext <<_ACEOF
10255 /* end confdefs.h. */
10256 /* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
10257 For example, HP-UX 11i <limits.h> declares gettimeofday. */
10258 #define shl_load innocuous_shl_load
10259
10260 /* System header to define __stub macros and hopefully few prototypes,
10261 which can conflict with char shl_load (); below.
10262 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
10263 <limits.h> exists even on freestanding compilers. */
10264
10265 #ifdef __STDC__
10266 # include <limits.h>
10267 #else
10268 # include <assert.h>
10269 #endif
10270
10271 #undef shl_load
10272
10273 /* Override any GCC internal prototype to avoid an error.
10274 Use char because int might match the return type of a GCC
10275 builtin and then its argument prototype would still apply. */
10276 #ifdef __cplusplus
10277 extern "C"
10278 #endif
10279 char shl_load ();
10280 /* The GNU C library defines this for functions which it implements
10281 to always fail with ENOSYS. Some functions are actually named
10282 something starting with __ and the normal name is an alias. */
10283 #if defined __stub_shl_load || defined __stub___shl_load
10284 choke me
10285 #endif
10286
10287 int
10288 main ()
10289 {
10290 return shl_load ();
10291 ;
10292 return 0;
10293 }
10294 _ACEOF
10295 rm -f conftest.$ac_objext conftest$ac_exeext
10296 if { (ac_try="$ac_link"
10297 case "(($ac_try" in
10298 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10299 *) ac_try_echo=$ac_try;;
10300 esac
10301 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
10302 (eval "$ac_link") 2>conftest.er1
10303 ac_status=$?
10304 grep -v '^ *+' conftest.er1 >conftest.err
10305 rm -f conftest.er1
10306 cat conftest.err >&5
10307 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10308 (exit $ac_status); } && {
10309 test -z "$ac_c_werror_flag" ||
10310 test ! -s conftest.err
10311 } && test -s conftest$ac_exeext &&
10312 $as_test_x conftest$ac_exeext; then
10313 ac_cv_func_shl_load=yes
10314 else
10315 echo "$as_me: failed program was:" >&5
10316 sed 's/^/| /' conftest.$ac_ext >&5
10317
10318 ac_cv_func_shl_load=no
10319 fi
10320
10321 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
10322 conftest$ac_exeext conftest.$ac_ext
10323 fi
10324 { echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
10325 echo "${ECHO_T}$ac_cv_func_shl_load" >&6; }
10326 if test $ac_cv_func_shl_load = yes; then
10327 lt_cv_dlopen="shl_load"
10328 else
10329 { echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
10330 echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6; }
10331 if test "${ac_cv_lib_dld_shl_load+set}" = set; then
10332 echo $ECHO_N "(cached) $ECHO_C" >&6
10333 else
10334 ac_check_lib_save_LIBS=$LIBS
10335 LIBS="-ldld $LIBS"
10336 cat >conftest.$ac_ext <<_ACEOF
10337 /* confdefs.h. */
10338 _ACEOF
10339 cat confdefs.h >>conftest.$ac_ext
10340 cat >>conftest.$ac_ext <<_ACEOF
10341 /* end confdefs.h. */
10342
10343 /* Override any GCC internal prototype to avoid an error.
10344 Use char because int might match the return type of a GCC
10345 builtin and then its argument prototype would still apply. */
10346 #ifdef __cplusplus
10347 extern "C"
10348 #endif
10349 char shl_load ();
10350 int
10351 main ()
10352 {
10353 return shl_load ();
10354 ;
10355 return 0;
10356 }
10357 _ACEOF
10358 rm -f conftest.$ac_objext conftest$ac_exeext
10359 if { (ac_try="$ac_link"
10360 case "(($ac_try" in
10361 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10362 *) ac_try_echo=$ac_try;;
10363 esac
10364 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
10365 (eval "$ac_link") 2>conftest.er1
10366 ac_status=$?
10367 grep -v '^ *+' conftest.er1 >conftest.err
10368 rm -f conftest.er1
10369 cat conftest.err >&5
10370 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10371 (exit $ac_status); } && {
10372 test -z "$ac_c_werror_flag" ||
10373 test ! -s conftest.err
10374 } && test -s conftest$ac_exeext &&
10375 $as_test_x conftest$ac_exeext; then
10376 ac_cv_lib_dld_shl_load=yes
10377 else
10378 echo "$as_me: failed program was:" >&5
10379 sed 's/^/| /' conftest.$ac_ext >&5
10380
10381 ac_cv_lib_dld_shl_load=no
10382 fi
10383
10384 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
10385 conftest$ac_exeext conftest.$ac_ext
10386 LIBS=$ac_check_lib_save_LIBS
10387 fi
10388 { echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
10389 echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6; }
10390 if test $ac_cv_lib_dld_shl_load = yes; then
10391 lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
10392 else
10393 { echo "$as_me:$LINENO: checking for dlopen" >&5
10394 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6; }
10395 if test "${ac_cv_func_dlopen+set}" = set; then
10396 echo $ECHO_N "(cached) $ECHO_C" >&6
10397 else
10398 cat >conftest.$ac_ext <<_ACEOF
10399 /* confdefs.h. */
10400 _ACEOF
10401 cat confdefs.h >>conftest.$ac_ext
10402 cat >>conftest.$ac_ext <<_ACEOF
10403 /* end confdefs.h. */
10404 /* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
10405 For example, HP-UX 11i <limits.h> declares gettimeofday. */
10406 #define dlopen innocuous_dlopen
10407
10408 /* System header to define __stub macros and hopefully few prototypes,
10409 which can conflict with char dlopen (); below.
10410 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
10411 <limits.h> exists even on freestanding compilers. */
10412
10413 #ifdef __STDC__
10414 # include <limits.h>
10415 #else
10416 # include <assert.h>
10417 #endif
10418
10419 #undef dlopen
10420
10421 /* Override any GCC internal prototype to avoid an error.
10422 Use char because int might match the return type of a GCC
10423 builtin and then its argument prototype would still apply. */
10424 #ifdef __cplusplus
10425 extern "C"
10426 #endif
10427 char dlopen ();
10428 /* The GNU C library defines this for functions which it implements
10429 to always fail with ENOSYS. Some functions are actually named
10430 something starting with __ and the normal name is an alias. */
10431 #if defined __stub_dlopen || defined __stub___dlopen
10432 choke me
10433 #endif
10434
10435 int
10436 main ()
10437 {
10438 return dlopen ();
10439 ;
10440 return 0;
10441 }
10442 _ACEOF
10443 rm -f conftest.$ac_objext conftest$ac_exeext
10444 if { (ac_try="$ac_link"
10445 case "(($ac_try" in
10446 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10447 *) ac_try_echo=$ac_try;;
10448 esac
10449 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
10450 (eval "$ac_link") 2>conftest.er1
10451 ac_status=$?
10452 grep -v '^ *+' conftest.er1 >conftest.err
10453 rm -f conftest.er1
10454 cat conftest.err >&5
10455 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10456 (exit $ac_status); } && {
10457 test -z "$ac_c_werror_flag" ||
10458 test ! -s conftest.err
10459 } && test -s conftest$ac_exeext &&
10460 $as_test_x conftest$ac_exeext; then
10461 ac_cv_func_dlopen=yes
10462 else
10463 echo "$as_me: failed program was:" >&5
10464 sed 's/^/| /' conftest.$ac_ext >&5
10465
10466 ac_cv_func_dlopen=no
10467 fi
10468
10469 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
10470 conftest$ac_exeext conftest.$ac_ext
10471 fi
10472 { echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
10473 echo "${ECHO_T}$ac_cv_func_dlopen" >&6; }
10474 if test $ac_cv_func_dlopen = yes; then
10475 lt_cv_dlopen="dlopen"
10476 else
10477 { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
10478 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; }
10479 if test "${ac_cv_lib_dl_dlopen+set}" = set; then
10480 echo $ECHO_N "(cached) $ECHO_C" >&6
10481 else
10482 ac_check_lib_save_LIBS=$LIBS
10483 LIBS="-ldl $LIBS"
10484 cat >conftest.$ac_ext <<_ACEOF
10485 /* confdefs.h. */
10486 _ACEOF
10487 cat confdefs.h >>conftest.$ac_ext
10488 cat >>conftest.$ac_ext <<_ACEOF
10489 /* end confdefs.h. */
10490
10491 /* Override any GCC internal prototype to avoid an error.
10492 Use char because int might match the return type of a GCC
10493 builtin and then its argument prototype would still apply. */
10494 #ifdef __cplusplus
10495 extern "C"
10496 #endif
10497 char dlopen ();
10498 int
10499 main ()
10500 {
10501 return dlopen ();
10502 ;
10503 return 0;
10504 }
10505 _ACEOF
10506 rm -f conftest.$ac_objext conftest$ac_exeext
10507 if { (ac_try="$ac_link"
10508 case "(($ac_try" in
10509 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10510 *) ac_try_echo=$ac_try;;
10511 esac
10512 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
10513 (eval "$ac_link") 2>conftest.er1
10514 ac_status=$?
10515 grep -v '^ *+' conftest.er1 >conftest.err
10516 rm -f conftest.er1
10517 cat conftest.err >&5
10518 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10519 (exit $ac_status); } && {
10520 test -z "$ac_c_werror_flag" ||
10521 test ! -s conftest.err
10522 } && test -s conftest$ac_exeext &&
10523 $as_test_x conftest$ac_exeext; then
10524 ac_cv_lib_dl_dlopen=yes
10525 else
10526 echo "$as_me: failed program was:" >&5
10527 sed 's/^/| /' conftest.$ac_ext >&5
10528
10529 ac_cv_lib_dl_dlopen=no
10530 fi
10531
10532 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
10533 conftest$ac_exeext conftest.$ac_ext
10534 LIBS=$ac_check_lib_save_LIBS
10535 fi
10536 { echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
10537 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; }
10538 if test $ac_cv_lib_dl_dlopen = yes; then
10539 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
10540 else
10541 { echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
10542 echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6; }
10543 if test "${ac_cv_lib_svld_dlopen+set}" = set; then
10544 echo $ECHO_N "(cached) $ECHO_C" >&6
10545 else
10546 ac_check_lib_save_LIBS=$LIBS
10547 LIBS="-lsvld $LIBS"
10548 cat >conftest.$ac_ext <<_ACEOF
10549 /* confdefs.h. */
10550 _ACEOF
10551 cat confdefs.h >>conftest.$ac_ext
10552 cat >>conftest.$ac_ext <<_ACEOF
10553 /* end confdefs.h. */
10554
10555 /* Override any GCC internal prototype to avoid an error.
10556 Use char because int might match the return type of a GCC
10557 builtin and then its argument prototype would still apply. */
10558 #ifdef __cplusplus
10559 extern "C"
10560 #endif
10561 char dlopen ();
10562 int
10563 main ()
10564 {
10565 return dlopen ();
10566 ;
10567 return 0;
10568 }
10569 _ACEOF
10570 rm -f conftest.$ac_objext conftest$ac_exeext
10571 if { (ac_try="$ac_link"
10572 case "(($ac_try" in
10573 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10574 *) ac_try_echo=$ac_try;;
10575 esac
10576 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
10577 (eval "$ac_link") 2>conftest.er1
10578 ac_status=$?
10579 grep -v '^ *+' conftest.er1 >conftest.err
10580 rm -f conftest.er1
10581 cat conftest.err >&5
10582 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10583 (exit $ac_status); } && {
10584 test -z "$ac_c_werror_flag" ||
10585 test ! -s conftest.err
10586 } && test -s conftest$ac_exeext &&
10587 $as_test_x conftest$ac_exeext; then
10588 ac_cv_lib_svld_dlopen=yes
10589 else
10590 echo "$as_me: failed program was:" >&5
10591 sed 's/^/| /' conftest.$ac_ext >&5
10592
10593 ac_cv_lib_svld_dlopen=no
10594 fi
10595
10596 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
10597 conftest$ac_exeext conftest.$ac_ext
10598 LIBS=$ac_check_lib_save_LIBS
10599 fi
10600 { echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
10601 echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6; }
10602 if test $ac_cv_lib_svld_dlopen = yes; then
10603 lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
10604 else
10605 { echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
10606 echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6; }
10607 if test "${ac_cv_lib_dld_dld_link+set}" = set; then
10608 echo $ECHO_N "(cached) $ECHO_C" >&6
10609 else
10610 ac_check_lib_save_LIBS=$LIBS
10611 LIBS="-ldld $LIBS"
10612 cat >conftest.$ac_ext <<_ACEOF
10613 /* confdefs.h. */
10614 _ACEOF
10615 cat confdefs.h >>conftest.$ac_ext
10616 cat >>conftest.$ac_ext <<_ACEOF
10617 /* end confdefs.h. */
10618
10619 /* Override any GCC internal prototype to avoid an error.
10620 Use char because int might match the return type of a GCC
10621 builtin and then its argument prototype would still apply. */
10622 #ifdef __cplusplus
10623 extern "C"
10624 #endif
10625 char dld_link ();
10626 int
10627 main ()
10628 {
10629 return dld_link ();
10630 ;
10631 return 0;
10632 }
10633 _ACEOF
10634 rm -f conftest.$ac_objext conftest$ac_exeext
10635 if { (ac_try="$ac_link"
10636 case "(($ac_try" in
10637 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
10638 *) ac_try_echo=$ac_try;;
10639 esac
10640 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
10641 (eval "$ac_link") 2>conftest.er1
10642 ac_status=$?
10643 grep -v '^ *+' conftest.er1 >conftest.err
10644 rm -f conftest.er1
10645 cat conftest.err >&5
10646 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10647 (exit $ac_status); } && {
10648 test -z "$ac_c_werror_flag" ||
10649 test ! -s conftest.err
10650 } && test -s conftest$ac_exeext &&
10651 $as_test_x conftest$ac_exeext; then
10652 ac_cv_lib_dld_dld_link=yes
10653 else
10654 echo "$as_me: failed program was:" >&5
10655 sed 's/^/| /' conftest.$ac_ext >&5
10656
10657 ac_cv_lib_dld_dld_link=no
10658 fi
10659
10660 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
10661 conftest$ac_exeext conftest.$ac_ext
10662 LIBS=$ac_check_lib_save_LIBS
10663 fi
10664 { echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
10665 echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6; }
10666 if test $ac_cv_lib_dld_dld_link = yes; then
10667 lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
10668 fi
10669
10670
10671 fi
10672
10673
10674 fi
10675
10676
10677 fi
10678
10679
10680 fi
10681
10682
10683 fi
10684
10685 ;;
10686 esac
10687
10688 if test "x$lt_cv_dlopen" != xno; then
10689 enable_dlopen=yes
10690 else
10691 enable_dlopen=no
10692 fi
10693
10694 case $lt_cv_dlopen in
10695 dlopen)
10696 save_CPPFLAGS="$CPPFLAGS"
10697 test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
10698
10699 save_LDFLAGS="$LDFLAGS"
10700 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
10701
10702 save_LIBS="$LIBS"
10703 LIBS="$lt_cv_dlopen_libs $LIBS"
10704
10705 { echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
10706 echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6; }
10707 if test "${lt_cv_dlopen_self+set}" = set; then
10708 echo $ECHO_N "(cached) $ECHO_C" >&6
10709 else
10710 if test "$cross_compiling" = yes; then :
10711 lt_cv_dlopen_self=cross
10712 else
10713 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
10714 lt_status=$lt_dlunknown
10715 cat > conftest.$ac_ext <<_LT_EOF
10716 #line 10717 "configure"
10717 #include "confdefs.h"
10718
10719 #if HAVE_DLFCN_H
10720 #include <dlfcn.h>
10721 #endif
10722
10723 #include <stdio.h>
10724
10725 #ifdef RTLD_GLOBAL
10726 # define LT_DLGLOBAL RTLD_GLOBAL
10727 #else
10728 # ifdef DL_GLOBAL
10729 # define LT_DLGLOBAL DL_GLOBAL
10730 # else
10731 # define LT_DLGLOBAL 0
10732 # endif
10733 #endif
10734
10735 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
10736 find out it does not work in some platform. */
10737 #ifndef LT_DLLAZY_OR_NOW
10738 # ifdef RTLD_LAZY
10739 # define LT_DLLAZY_OR_NOW RTLD_LAZY
10740 # else
10741 # ifdef DL_LAZY
10742 # define LT_DLLAZY_OR_NOW DL_LAZY
10743 # else
10744 # ifdef RTLD_NOW
10745 # define LT_DLLAZY_OR_NOW RTLD_NOW
10746 # else
10747 # ifdef DL_NOW
10748 # define LT_DLLAZY_OR_NOW DL_NOW
10749 # else
10750 # define LT_DLLAZY_OR_NOW 0
10751 # endif
10752 # endif
10753 # endif
10754 # endif
10755 #endif
10756
10757 #ifdef __cplusplus
10758 extern "C" void exit (int);
10759 #endif
10760
10761 void fnord() { int i=42;}
10762 int main ()
10763 {
10764 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
10765 int status = $lt_dlunknown;
10766
10767 if (self)
10768 {
10769 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
10770 else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
10771 /* dlclose (self); */
10772 }
10773 else
10774 puts (dlerror ());
10775
10776 exit (status);
10777 }
10778 _LT_EOF
10779 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
10780 (eval $ac_link) 2>&5
10781 ac_status=$?
10782 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10783 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
10784 (./conftest; exit; ) >&5 2>/dev/null
10785 lt_status=$?
10786 case x$lt_status in
10787 x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
10788 x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
10789 x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
10790 esac
10791 else :
10792 # compilation failed
10793 lt_cv_dlopen_self=no
10794 fi
10795 fi
10796 rm -fr conftest*
10797
10798
10799 fi
10800 { echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
10801 echo "${ECHO_T}$lt_cv_dlopen_self" >&6; }
10802
10803 if test "x$lt_cv_dlopen_self" = xyes; then
10804 wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
10805 { echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
10806 echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6; }
10807 if test "${lt_cv_dlopen_self_static+set}" = set; then
10808 echo $ECHO_N "(cached) $ECHO_C" >&6
10809 else
10810 if test "$cross_compiling" = yes; then :
10811 lt_cv_dlopen_self_static=cross
10812 else
10813 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
10814 lt_status=$lt_dlunknown
10815 cat > conftest.$ac_ext <<_LT_EOF
10816 #line 10817 "configure"
10817 #include "confdefs.h"
10818
10819 #if HAVE_DLFCN_H
10820 #include <dlfcn.h>
10821 #endif
10822
10823 #include <stdio.h>
10824
10825 #ifdef RTLD_GLOBAL
10826 # define LT_DLGLOBAL RTLD_GLOBAL
10827 #else
10828 # ifdef DL_GLOBAL
10829 # define LT_DLGLOBAL DL_GLOBAL
10830 # else
10831 # define LT_DLGLOBAL 0
10832 # endif
10833 #endif
10834
10835 /* We may have to define LT_DLLAZY_OR_NOW in the command line if we
10836 find out it does not work in some platform. */
10837 #ifndef LT_DLLAZY_OR_NOW
10838 # ifdef RTLD_LAZY
10839 # define LT_DLLAZY_OR_NOW RTLD_LAZY
10840 # else
10841 # ifdef DL_LAZY
10842 # define LT_DLLAZY_OR_NOW DL_LAZY
10843 # else
10844 # ifdef RTLD_NOW
10845 # define LT_DLLAZY_OR_NOW RTLD_NOW
10846 # else
10847 # ifdef DL_NOW
10848 # define LT_DLLAZY_OR_NOW DL_NOW
10849 # else
10850 # define LT_DLLAZY_OR_NOW 0
10851 # endif
10852 # endif
10853 # endif
10854 # endif
10855 #endif
10856
10857 #ifdef __cplusplus
10858 extern "C" void exit (int);
10859 #endif
10860
10861 void fnord() { int i=42;}
10862 int main ()
10863 {
10864 void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
10865 int status = $lt_dlunknown;
10866
10867 if (self)
10868 {
10869 if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
10870 else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
10871 /* dlclose (self); */
10872 }
10873 else
10874 puts (dlerror ());
10875
10876 exit (status);
10877 }
10878 _LT_EOF
10879 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
10880 (eval $ac_link) 2>&5
10881 ac_status=$?
10882 echo "$as_me:$LINENO: \$? = $ac_status" >&5
10883 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
10884 (./conftest; exit; ) >&5 2>/dev/null
10885 lt_status=$?
10886 case x$lt_status in
10887 x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
10888 x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
10889 x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
10890 esac
10891 else :
10892 # compilation failed
10893 lt_cv_dlopen_self_static=no
10894 fi
10895 fi
10896 rm -fr conftest*
10897
10898
10899 fi
10900 { echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
10901 echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6; }
10902 fi
10903
10904 CPPFLAGS="$save_CPPFLAGS"
10905 LDFLAGS="$save_LDFLAGS"
10906 LIBS="$save_LIBS"
10907 ;;
10908 esac
10909
10910 case $lt_cv_dlopen_self in
10911 yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
10912 *) enable_dlopen_self=unknown ;;
10913 esac
10914
10915 case $lt_cv_dlopen_self_static in
10916 yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
10917 *) enable_dlopen_self_static=unknown ;;
10918 esac
10919 fi
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937 striplib=
10938 old_striplib=
10939 { echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
10940 echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6; }
10941 if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
10942 test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
10943 test -z "$striplib" && striplib="$STRIP --strip-unneeded"
10944 { echo "$as_me:$LINENO: result: yes" >&5
10945 echo "${ECHO_T}yes" >&6; }
10946 else
10947 # FIXME - insert some real tests, host_os isn't really good enough
10948 case $host_os in
10949 darwin*)
10950 if test -n "$STRIP" ; then
10951 striplib="$STRIP -x"
10952 old_striplib="$STRIP -S"
10953 { echo "$as_me:$LINENO: result: yes" >&5
10954 echo "${ECHO_T}yes" >&6; }
10955 else
10956 { echo "$as_me:$LINENO: result: no" >&5
10957 echo "${ECHO_T}no" >&6; }
10958 fi
10959 ;;
10960 *)
10961 { echo "$as_me:$LINENO: result: no" >&5
10962 echo "${ECHO_T}no" >&6; }
10963 ;;
10964 esac
10965 fi
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978 # Report which library types will actually be built
10979 { echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
10980 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6; }
10981 { echo "$as_me:$LINENO: result: $can_build_shared" >&5
10982 echo "${ECHO_T}$can_build_shared" >&6; }
10983
10984 { echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
10985 echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6; }
10986 test "$can_build_shared" = "no" && enable_shared=no
10987
10988 # On AIX, shared libraries and static libraries use the same namespace, and
10989 # are all built from PIC.
10990 case $host_os in
10991 aix3*)
10992 test "$enable_shared" = yes && enable_static=no
10993 if test -n "$RANLIB"; then
10994 archive_cmds="$archive_cmds~\$RANLIB \$lib"
10995 postinstall_cmds='$RANLIB $lib'
10996 fi
10997 ;;
10998
10999 aix[4-9]*)
11000 if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
11001 test "$enable_shared" = yes && enable_static=no
11002 fi
11003 ;;
11004 esac
11005 { echo "$as_me:$LINENO: result: $enable_shared" >&5
11006 echo "${ECHO_T}$enable_shared" >&6; }
11007
11008 { echo "$as_me:$LINENO: checking whether to build static libraries" >&5
11009 echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6; }
11010 # Make sure either enable_shared or enable_static is yes.
11011 test "$enable_shared" = yes || enable_static=yes
11012 { echo "$as_me:$LINENO: result: $enable_static" >&5
11013 echo "${ECHO_T}$enable_static" >&6; }
11014
11015
11016
11017
11018 fi
11019 ac_ext=c
11020 ac_cpp='$CPP $CPPFLAGS'
11021 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
11022 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
11023 ac_compiler_gnu=$ac_cv_c_compiler_gnu
11024
11025 CC="$lt_save_CC"
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039 ac_config_commands="$ac_config_commands libtool"
11040
11041
11042
11043
11044 # Only expand once:
11045
11046
11047
11048
11049 # We are now threading
11050 # See http://autoconf-archive.cryp.to/acx_pthread.html
11051 #License
11052 #
11053 #Copyright © 2008 Steven G. Johnson <stevenj@alum.mit.edu>
11054 #
11055 #This program is free software: you can redistribute it and/or modify
11056 #it under the terms of the GNU General Public License as published by
11057 #the Free Software Foundation, either version 3 of the License, or (at
11058 #your option) any later version.
11059
11060
11061 # ===========================================================================
11062 # http://autoconf-archive.cryp.to/ac_python_devel.html
11063 # ===========================================================================
11064 #
11065 # SYNOPSIS
11066 #
11067 # AC_PYTHON_DEVEL([version])
11068 #
11069 # DESCRIPTION
11070 #
11071 # Note: Defines as a precious variable "PYTHON_VERSION". Don't override it
11072 # in your configure.ac.
11073 #
11074 # This macro checks for Python and tries to get the include path to
11075 # 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS)
11076 # output variables. It also exports $(PYTHON_EXTRA_LIBS) and
11077 # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
11078 #
11079 # You can search for some particular version of Python by passing a
11080 # parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please
11081 # note that you *have* to pass also an operator along with the version to
11082 # match, and pay special attention to the single quotes surrounding the
11083 # version number. Don't use "PYTHON_VERSION" for this: that environment
11084 # variable is declared as precious and thus reserved for the end-user.
11085 #
11086 # This macro should work for all versions of Python >= 2.1.0. As an end
11087 # user, you can disable the check for the python version by setting the
11088 # PYTHON_NOVERSIONCHECK environment variable to something else than the
11089 # empty string.
11090 #
11091 # If you need to use this macro for an older Python version, please
11092 # contact the authors. We're always open for feedback.
11093 #
11094 # LICENSE
11095 #
11096 # Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de>
11097 # Copyright (c) 2009 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
11098 # Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net>
11099 # Copyright (c) 2009 Andrew Collier <colliera@ukzn.ac.za>
11100 # Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org>
11101 # Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org>
11102 #
11103 # This program is free software: you can redistribute it and/or modify it
11104 # under the terms of the GNU General Public License as published by the
11105 # Free Software Foundation, either version 3 of the License, or (at your
11106 # option) any later version.
11107 #
11108 # This program is distributed in the hope that it will be useful, but
11109 # WITHOUT ANY WARRANTY; without even the implied warranty of
11110 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
11111 # Public License for more details.
11112 #
11113 # You should have received a copy of the GNU General Public License along
11114 # with this program. If not, see <http://www.gnu.org/licenses/>.
11115 #
11116 # As a special exception, the respective Autoconf Macro's copyright owner
11117 # gives unlimited permission to copy, distribute and modify the configure
11118 # scripts that are the output of Autoconf when processing the Macro. You
11119 # need not follow the terms of the GNU General Public License when using
11120 # or distributing such scripts, even though portions of the text of the
11121 # Macro appear in them. The GNU General Public License (GPL) does govern
11122 # all other use of the material that constitutes the Autoconf Macro.
11123 #
11124 # This special exception to the GPL applies to versions of the Autoconf
11125 # Macro released by the Autoconf Archive. When you make and distribute a
11126 # modified version of the Autoconf Macro, you may extend this special
11127 # exception to the GPL to apply to your modified version as well.
11128
11129
11130 # ===========================================================================
11131 # http://autoconf-archive.cryp.to/ac_python_module.html
11132 # ===========================================================================
11133 #
11134 # SYNOPSIS
11135 #
11136 # AC_PYTHON_MODULE(modname[, fatal])
11137 #
11138 # DESCRIPTION
11139 #
11140 # Checks for Python module.
11141 #
11142 # If fatal is non-empty then absence of a module will trigger an error.
11143 #
11144 # LICENSE
11145 #
11146 # Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
11147 #
11148 # Copying and distribution of this file, with or without modification, are
11149 # permitted in any medium without royalty provided the copyright notice
11150 # and this notice are preserved.
11151
11152
11153 # ===========================================================================
11154 # http://autoconf-archive.cryp.to/az_python.html
11155 # ===========================================================================
11156 #
11157 # SYNOPSIS
11158 #
11159 # AZ_PYTHON_DEFAULT
11160 # AZ_PYTHON_ENABLE
11161 # AZ_PYTHON_WITH
11162 # AZ_PYTHON_PATH
11163 # AZ_PYTHON_VERSION_ENSURE( [2.2] )
11164 # AZ_PYTHON_CSPEC
11165 # AZ_PYTHON_LSPEC
11166 #
11167 # DESCRIPTION
11168 #
11169 # This file provides autoconf support for those applications that want to
11170 # embed python. It supports all pythons >= 2.2 which is the first official
11171 # release containing distutils. Version 2.2 of python was released
11172 # December 21, 2001. Since it actually executes the python, cross platform
11173 # configuration will probably not work. Also, most of the platforms
11174 # supported are consistent until you look into MacOSX. The python included
11175 # with it is installed as a framework which is a very different
11176 # environment to set up the normal tools such as gcc and libtool to deal
11177 # with. Therefore, once we establish which python that we are going to
11178 # use, we use its distutils to actually compile and link our modules or
11179 # applications.
11180 #
11181 # At this time, it does NOT support linking with Python statically. It
11182 # does support dynamic linking.
11183 #
11184 # This set of macros help define $PYTHON, $PYTHON_USE, $PYTHON_CSPEC and
11185 # $PYTHON_LSPEC. $PYTHON defines the full executable path for the Python
11186 # being linked to and is used within these macros to determine if that has
11187 # been specified or found. These macros do execute this python version so
11188 # it must be present on the system at configure time.
11189 #
11190 # $PYTHON_USE is an automake variable that defines whether Python support
11191 # should be included or not in your application. $PYTHON_CSPEC is a
11192 # variable that supplies additional CFLAGS for the compilation of the
11193 # application/shared library. $PYTHON_LSPEC is a variable that supplies
11194 # additional LDFLAGS for linking the application/shared library.
11195 #
11196 # The following is an example of how to set up for python usage within
11197 # your application in your configure.in:
11198 #
11199 # AZ_PYTHON_DEFAULT( )
11200 # AZ_PYTHON_ENABLE( ) # Optional
11201 # AZ_PYTHON_WITH( ) # Optional
11202 # AZ_PYTHON_PATH( ) # or AZ_PYTHON_INSIST( )
11203 # # if $PYTHON is not defined, then the following do nothing.
11204 # AZ_PYTHON_VERSION_ENSURE( [2.2] )
11205 # AZ_PYTHON_CSPEC
11206 # AZ_PYTHON_LSPEC
11207 #
11208 # The AZ_PYTHON_DEFAULT sets the $PYTHON_USE to false. Thereby, excluding
11209 # it if it was optional.
11210 #
11211 # The AZ_PYTHON_ENABLE looks for the optional configure parameters of
11212 # --enable-python/--disable-python and establishes the $PYTHON and
11213 # $PYTHON_USE variables accordingly.
11214 #
11215 # The AZ_PYTHON_WITH looks for the optional configure parameters of
11216 # --with-python/--without-python and establishes the $PYTHON and
11217 # $PYTHON_USE variables accordingly.
11218 #
11219 # The AZ_PYTHON_PATH looks for python assuming that none has been
11220 # previously found or defined and issues an error if it does not find it.
11221 # If it does find it, it establishes the $PYTHON and $PYTHON_USE variables
11222 # accordingly. AZ_PYTHON_INSIST could be used here instead if you want to
11223 # insist that Python support be included using the --enable-python or
11224 # --with-python checks previously done.
11225 #
11226 # The AZ_PYTHON_VERSION_ENSURE issues an error if the Python previously
11227 # found is not of version 2.2 or greater.
11228 #
11229 # Once that these macros have be run, we can use PYTHON_USE within the
11230 # makefile.am file to conditionally add the Python support such as:
11231 #
11232 # Makefile.am example showing optional inclusion of directories:
11233 #
11234 # if PYTHON_USE
11235 # plugins = plugins
11236 # src = src
11237 # else
11238 # plugins =
11239 # src =
11240 # endif
11241 #
11242 # SUBDIRS = . $(plugins) $(src)
11243 #
11244 # Makefile.am example showing optional shared library build:
11245 #
11246 # if PYTHON_USE
11247 # lib_LTLIBRARIES = libElemList.la
11248 # libElemList_la_SOURCES = libElemList.c
11249 # libElemList_la_CFLAGS = @PYTHON_CSPEC@
11250 # libElemList_la_LDFLAGS = @PYTHON_LSPEC@
11251 # endif
11252 #
11253 # Makefile.am example showing optional program build:
11254 #
11255 # if PYTHON_USE
11256 # bin_PROGRAMS = runFunc
11257 # runFunc_SOURCES = runFunc.c
11258 # runFunc_CFLAGS = @PYTHON_CSPEC@
11259 # runFunc_LDFLAGS = @PYTHON_LSPEC@
11260 # endif
11261 #
11262 # The above compiles the modules only if PYTHON_USE was specified as true.
11263 # Also, the else portion of the if was optional.
11264 #
11265 # LICENSE
11266 #
11267 # Copyright (c) 2008 Robert White <kranki@mac.com>
11268 # Copyright (c) 2008 Dustin J. Mitchell <dustin@cs.uchicago.edu>
11269 #
11270 # Copying and distribution of this file, with or without modification, are
11271 # permitted in any medium without royalty provided the copyright notice
11272 # and this notice are preserved.
11273
11274 # AZ_PYTHON_DEFAULT( )
11275 # -----------------
11276 # Sets the default to not include Python support.
11277
11278
11279
11280
11281
11282 # AZ_PYTHON_ENABLE( [path] )
11283 # -----------------------------------------------------------------
11284 # Handles the various --enable-python commands.
11285 # Input:
11286 # $1 is the optional search path for the python executable if needed
11287 # Ouput:
11288 # PYTHON_USE (AM_CONDITIONAL) is true if python executable found
11289 # and --enable-python was requested; otherwise false.
11290 # $PYTHON contains the full executable path to python if PYTHON_ENABLE_USE
11291 # is true.
11292 #
11293 # Example:
11294 # AZ_PYTHON_ENABLE( )
11295 # or
11296 # AZ_PYTHON_ENABLE( "/usr/bin" )
11297
11298
11299
11300
11301
11302 # AZ_PYTHON_CSPEC( )
11303 # -----------------
11304 # Set up the c compiler options to compile Python
11305 # embedded programs/libraries in $PYTHON_CSPEC if
11306 # $PYTHON has been defined.
11307
11308
11309
11310
11311
11312 # AZ_PYTHON_INSIST( )
11313 # -----------------
11314 # Look for Python and set the output variable 'PYTHON'
11315 # to 'python' if found, empty otherwise.
11316
11317
11318
11319
11320
11321 # AZ_PYTHON_LSPEC( )
11322 # -----------------
11323 # Set up the linker options to link Python embedded
11324 # programs/libraries in $PYTHON_LSPEC if $PYTHON
11325 # has been defined.
11326
11327
11328
11329
11330
11331 # AZ_PYTHON_PATH( )
11332 # -----------------
11333 # Look for Python and set the output variable 'PYTHON'
11334 # to 'python' if found, empty otherwise.
11335
11336
11337
11338
11339
11340 # AZ_PYTHON_PREFIX( )
11341 # -------------------
11342 # Use the values of $prefix and $exec_prefix for the corresponding
11343 # values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.
11344
11345
11346
11347
11348
11349 # AZ_PYTHON_RUN( PYTHON_PROGRAM )
11350 # -----------------
11351 # Run a Python Test Program saving its output
11352 # in az_python_output and its condition code
11353 # in az_python_cc.
11354
11355
11356
11357
11358
11359 # AZ_PYTHON_VERSION_CHECK( VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE] )
11360 # -----------------------------------------------------------------------------
11361 # Run ACTION-IF-TRUE if the Python interpreter has version >= VERSION.
11362 # Run ACTION-IF-FALSE otherwise.
11363 # This test uses sys.hexversion instead of the string equivalant (first
11364 # word of sys.version), in order to cope with versions such as 2.2c1.
11365 # hexversion has been introduced in Python 1.5.2; it's probably not
11366 # worth to support older versions (1.5.1 was released on October 31, 1998).
11367
11368
11369
11370
11371
11372 # AZ_PYTHON_VERSION_ENSURE( VERSION )
11373 # -----------------
11374 # Insure that the Python Interpreter Version
11375 # is greater than or equal to the VERSION
11376 # parameter.
11377
11378
11379
11380
11381
11382 # AZ_PYTHON_WITH( [path] )
11383 # -----------------------------------------------------------------
11384 # Handles the various --with-python commands.
11385 # Input:
11386 # $1 is the optional search path for the python executable if needed
11387 # Ouput:
11388 # PYTHON_USE (AM_CONDITIONAL) is true if python executable found
11389 # and --with-python was requested; otherwise false.
11390 # $PYTHON contains the full executable path to python if PYTHON_USE
11391 # is true.
11392 #
11393 # Example:
11394 # AZ_PYTHON_WITH( )
11395 # or
11396 # AZ_PYTHON_WITH("/usr/bin")
11397
11398
11399
11400
11401
11402
11403 ac_ext=c
11404 ac_cpp='$CPP $CPPFLAGS'
11405 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
11406 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
11407 ac_compiler_gnu=$ac_cv_c_compiler_gnu
11408
11409 acx_pthread_ok=no
11410
11411 # We used to check for pthread.h first, but this fails if pthread.h
11412 # requires special compiler flags (e.g. on True64 or Sequent).
11413 # It gets checked for in the link test anyway.
11414
11415 # First of all, check if the user has set any of the PTHREAD_LIBS,
11416 # etcetera environment variables, and if threads linking works using
11417 # them:
11418 if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
11419 save_CFLAGS="$CFLAGS"
11420 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
11421 v save_LIBS="$LIBS"
11422 LIBS="$PTHREAD_LIBS $LIBS"
11423 { echo "$as_me:$LINENO: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
11424 echo $ECHO_N "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... $ECHO_C" >&6; }
11425 cat >conftest.$ac_ext <<_ACEOF
11426 /* confdefs.h. */
11427 _ACEOF
11428 cat confdefs.h >>conftest.$ac_ext
11429 cat >>conftest.$ac_ext <<_ACEOF
11430 /* end confdefs.h. */
11431
11432 /* Override any GCC internal prototype to avoid an error.
11433 Use char because int might match the return type of a GCC
11434 builtin and then its argument prototype would still apply. */
11435 #ifdef __cplusplus
11436 extern "C"
11437 #endif
11438 char pthread_join ();
11439 int
11440 main ()
11441 {
11442 return pthread_join ();
11443 ;
11444 return 0;
11445 }
11446 _ACEOF
11447 rm -f conftest.$ac_objext conftest$ac_exeext
11448 if { (ac_try="$ac_link"
11449 case "(($ac_try" in
11450 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
11451 *) ac_try_echo=$ac_try;;
11452 esac
11453 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
11454 (eval "$ac_link") 2>conftest.er1
11455 ac_status=$?
11456 grep -v '^ *+' conftest.er1 >conftest.err
11457 rm -f conftest.er1
11458 cat conftest.err >&5
11459 echo "$as_me:$LINENO: \$? = $ac_status" >&5
11460 (exit $ac_status); } && {
11461 test -z "$ac_c_werror_flag" ||
11462 test ! -s conftest.err
11463 } && test -s conftest$ac_exeext &&
11464 $as_test_x conftest$ac_exeext; then
11465 acx_pthread_ok=yes
11466 else
11467 echo "$as_me: failed program was:" >&5
11468 sed 's/^/| /' conftest.$ac_ext >&5
11469
11470
11471 fi
11472
11473 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
11474 conftest$ac_exeext conftest.$ac_ext
11475 { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
11476 echo "${ECHO_T}$acx_pthread_ok" >&6; }
11477 if test x"$acx_pthread_ok" = xno; then
11478 PTHREAD_LIBS=""
11479 PTHREAD_CFLAGS=""
11480 fi
11481 LIBS="$save_LIBS"
11482 CFLAGS="$save_CFLAGS"
11483 fi
11484
11485 # We must check for the threads library under a number of different
11486 # names; the ordering is very important because some systems
11487 # (e.g. DEC) have both -lpthread and -lpthreads, where one of the
11488 # libraries is broken (non-POSIX).
11489
11490 # Create a list of thread flags to try. Items starting with a "-" are
11491 # C compiler flags, and other items are library names, except for "none"
11492 # which indicates that we try without any flags at all, and "pthread-config"
11493 # which is a program returning the flags for the Pth emulation library.
11494
11495 acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
11496
11497 # The ordering *is* (sometimes) important. Some notes on the
11498 # individual items follow:
11499
11500 # pthreads: AIX (must check this before -lpthread)
11501 # none: in case threads are in libc; should be tried before -Kthread and
11502 # other compiler flags to prevent continual compiler warnings
11503 # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
11504 # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
11505 # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
11506 # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
11507 # -pthreads: Solaris/gcc
11508 # -mthreads: Mingw32/gcc, Lynx/gcc
11509 # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
11510 # doesn't hurt to check since this sometimes defines pthreads too;
11511 # also defines -D_REENTRANT)
11512 # ... -mt is also the pthreads flag for HP/aCC
11513 # pthread: Linux, etcetera
11514 # --thread-safe: KAI C++
11515 # pthread-config: use pthread-config program (for GNU Pth library)
11516
11517 case "${host_cpu}-${host_os}" in
11518 *solaris*)
11519
11520 # On Solaris (at least, for some versions), libc contains stubbed
11521 # (non-functional) versions of the pthreads routines, so link-based
11522 # tests will erroneously succeed. (We need to link with -pthreads/-mt/
11523 # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
11524 # a function called by this macro, so we could check for that, but
11525 # who knows whether they'll stub that too in a future libc.) So,
11526 # we'll just look for -pthreads and -lpthread first:
11527
11528 acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
11529 ;;
11530 esac
11531
11532 if test x"$acx_pthread_ok" = xno; then
11533 for flag in $acx_pthread_flags; do
11534
11535 case $flag in
11536 none)
11537 { echo "$as_me:$LINENO: checking whether pthreads work without any flags" >&5
11538 echo $ECHO_N "checking whether pthreads work without any flags... $ECHO_C" >&6; }
11539 ;;
11540
11541 -*)
11542 { echo "$as_me:$LINENO: checking whether pthreads work with $flag" >&5
11543 echo $ECHO_N "checking whether pthreads work with $flag... $ECHO_C" >&6; }
11544 PTHREAD_CFLAGS="$flag"
11545 ;;
11546
11547 pthread-config)
11548 # Extract the first word of "pthread-config", so it can be a program name with args.
11549 set dummy pthread-config; ac_word=$2
11550 { echo "$as_me:$LINENO: checking for $ac_word" >&5
11551 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
11552 if test "${ac_cv_prog_acx_pthread_config+set}" = set; then
11553 echo $ECHO_N "(cached) $ECHO_C" >&6
11554 else
11555 if test -n "$acx_pthread_config"; then
11556 ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test.
11557 else
11558 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11559 for as_dir in $PATH
11560 do
11561 IFS=$as_save_IFS
11562 test -z "$as_dir" && as_dir=.
11563 for ac_exec_ext in '' $ac_executable_extensions; do
11564 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
11565 ac_cv_prog_acx_pthread_config="yes"
11566 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
11567 break 2
11568 fi
11569 done
11570 done
11571 IFS=$as_save_IFS
11572
11573 test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
11574 fi
11575 fi
11576 acx_pthread_config=$ac_cv_prog_acx_pthread_config
11577 if test -n "$acx_pthread_config"; then
11578 { echo "$as_me:$LINENO: result: $acx_pthread_config" >&5
11579 echo "${ECHO_T}$acx_pthread_config" >&6; }
11580 else
11581 { echo "$as_me:$LINENO: result: no" >&5
11582 echo "${ECHO_T}no" >&6; }
11583 fi
11584
11585
11586 if test x"$acx_pthread_config" = xno; then continue; fi
11587 PTHREAD_CFLAGS="`pthread-config --cflags`"
11588 PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
11589 ;;
11590
11591 *)
11592 { echo "$as_me:$LINENO: checking for the pthreads library -l$flag" >&5
11593 echo $ECHO_N "checking for the pthreads library -l$flag... $ECHO_C" >&6; }
11594 PTHREAD_LIBS="-l$flag"
11595 ;;
11596 esac
11597
11598 save_LIBS="$LIBS"
11599 save_CFLAGS="$CFLAGS"
11600 LIBS="$PTHREAD_LIBS $LIBS"
11601 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
11602
11603 # Check for various functions. We must include pthread.h,
11604 # since some functions may be macros. (On the Sequent, we
11605 # need a special flag -Kthread to make this header compile.)
11606 # We check for pthread_join because it is in -lpthread on IRIX
11607 # while pthread_create is in libc. We check for pthread_attr_init
11608 # due to DEC craziness with -lpthreads. We check for
11609 # pthread_cleanup_push because it is one of the few pthread
11610 # functions on Solaris that doesn't have a non-functional libc stub.
11611 # We try pthread_create on general principles.
11612 cat >conftest.$ac_ext <<_ACEOF
11613 /* confdefs.h. */
11614 _ACEOF
11615 cat confdefs.h >>conftest.$ac_ext
11616 cat >>conftest.$ac_ext <<_ACEOF
11617 /* end confdefs.h. */
11618 #include <pthread.h>
11619 int
11620 main ()
11621 {
11622 pthread_t th; pthread_join(th, 0);
11623 pthread_attr_init(0); pthread_cleanup_push(0, 0);
11624 pthread_create(0,0,0,0); pthread_cleanup_pop(0);
11625 ;
11626 return 0;
11627 }
11628 _ACEOF
11629 rm -f conftest.$ac_objext conftest$ac_exeext
11630 if { (ac_try="$ac_link"
11631 case "(($ac_try" in
11632 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
11633 *) ac_try_echo=$ac_try;;
11634 esac
11635 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
11636 (eval "$ac_link") 2>conftest.er1
11637 ac_status=$?
11638 grep -v '^ *+' conftest.er1 >conftest.err
11639 rm -f conftest.er1
11640 cat conftest.err >&5
11641 echo "$as_me:$LINENO: \$? = $ac_status" >&5
11642 (exit $ac_status); } && {
11643 test -z "$ac_c_werror_flag" ||
11644 test ! -s conftest.err
11645 } && test -s conftest$ac_exeext &&
11646 $as_test_x conftest$ac_exeext; then
11647 acx_pthread_ok=yes
11648 else
11649 echo "$as_me: failed program was:" >&5
11650 sed 's/^/| /' conftest.$ac_ext >&5
11651
11652
11653 fi
11654
11655 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
11656 conftest$ac_exeext conftest.$ac_ext
11657
11658 LIBS="$save_LIBS"
11659 CFLAGS="$save_CFLAGS"
11660
11661 { echo "$as_me:$LINENO: result: $acx_pthread_ok" >&5
11662 echo "${ECHO_T}$acx_pthread_ok" >&6; }
11663 if test "x$acx_pthread_ok" = xyes; then
11664 break;
11665 fi
11666
11667 PTHREAD_LIBS=""
11668 PTHREAD_CFLAGS=""
11669 done
11670 fi
11671
11672 # Various other checks:
11673 if test "x$acx_pthread_ok" = xyes; then
11674 save_LIBS="$LIBS"
11675 LIBS="$PTHREAD_LIBS $LIBS"
11676 save_CFLAGS="$CFLAGS"
11677 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
11678
11679 # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
11680 { echo "$as_me:$LINENO: checking for joinable pthread attribute" >&5
11681 echo $ECHO_N "checking for joinable pthread attribute... $ECHO_C" >&6; }
11682 attr_name=unknown
11683 for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
11684 cat >conftest.$ac_ext <<_ACEOF
11685 /* confdefs.h. */
11686 _ACEOF
11687 cat confdefs.h >>conftest.$ac_ext
11688 cat >>conftest.$ac_ext <<_ACEOF
11689 /* end confdefs.h. */
11690 #include <pthread.h>
11691 int
11692 main ()
11693 {
11694 int attr=$attr; return attr;
11695 ;
11696 return 0;
11697 }
11698 _ACEOF
11699 rm -f conftest.$ac_objext conftest$ac_exeext
11700 if { (ac_try="$ac_link"
11701 case "(($ac_try" in
11702 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
11703 *) ac_try_echo=$ac_try;;
11704 esac
11705 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
11706 (eval "$ac_link") 2>conftest.er1
11707 ac_status=$?
11708 grep -v '^ *+' conftest.er1 >conftest.err
11709 rm -f conftest.er1
11710 cat conftest.err >&5
11711 echo "$as_me:$LINENO: \$? = $ac_status" >&5
11712 (exit $ac_status); } && {
11713 test -z "$ac_c_werror_flag" ||
11714 test ! -s conftest.err
11715 } && test -s conftest$ac_exeext &&
11716 $as_test_x conftest$ac_exeext; then
11717 attr_name=$attr; break
11718 else
11719 echo "$as_me: failed program was:" >&5
11720 sed 's/^/| /' conftest.$ac_ext >&5
11721
11722
11723 fi
11724
11725 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
11726 conftest$ac_exeext conftest.$ac_ext
11727 done
11728 { echo "$as_me:$LINENO: result: $attr_name" >&5
11729 echo "${ECHO_T}$attr_name" >&6; }
11730 if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
11731
11732 cat >>confdefs.h <<_ACEOF
11733 #define PTHREAD_CREATE_JOINABLE $attr_name
11734 _ACEOF
11735
11736 fi
11737
11738 { echo "$as_me:$LINENO: checking if more special flags are required for pthreads" >&5
11739 echo $ECHO_N "checking if more special flags are required for pthreads... $ECHO_C" >&6; }
11740 flag=no
11741 case "${host_cpu}-${host_os}" in
11742 *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
11743 *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
11744 esac
11745 { echo "$as_me:$LINENO: result: ${flag}" >&5
11746 echo "${ECHO_T}${flag}" >&6; }
11747 if test "x$flag" != xno; then
11748 PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
11749 fi
11750
11751 LIBS="$save_LIBS"
11752 CFLAGS="$save_CFLAGS"
11753
11754 # More AIX lossage: must compile with xlc_r or cc_r
11755 if test x"$GCC" != xyes; then
11756 for ac_prog in xlc_r cc_r
11757 do
11758 # Extract the first word of "$ac_prog", so it can be a program name with args.
11759 set dummy $ac_prog; ac_word=$2
11760 { echo "$as_me:$LINENO: checking for $ac_word" >&5
11761 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
11762 if test "${ac_cv_prog_PTHREAD_CC+set}" = set; then
11763 echo $ECHO_N "(cached) $ECHO_C" >&6
11764 else
11765 if test -n "$PTHREAD_CC"; then
11766 ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test.
11767 else
11768 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
11769 for as_dir in $PATH
11770 do
11771 IFS=$as_save_IFS
11772 test -z "$as_dir" && as_dir=.
11773 for ac_exec_ext in '' $ac_executable_extensions; do
11774 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
11775 ac_cv_prog_PTHREAD_CC="$ac_prog"
11776 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
11777 break 2
11778 fi
11779 done
11780 done
11781 IFS=$as_save_IFS
11782
11783 fi
11784 fi
11785 PTHREAD_CC=$ac_cv_prog_PTHREAD_CC
11786 if test -n "$PTHREAD_CC"; then
11787 { echo "$as_me:$LINENO: result: $PTHREAD_CC" >&5
11788 echo "${ECHO_T}$PTHREAD_CC" >&6; }
11789 else
11790 { echo "$as_me:$LINENO: result: no" >&5
11791 echo "${ECHO_T}no" >&6; }
11792 fi
11793
11794
11795 test -n "$PTHREAD_CC" && break
11796 done
11797 test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
11798
11799 else
11800 PTHREAD_CC=$CC
11801 fi
11802 else
11803 PTHREAD_CC="$CC"
11804 fi
11805
11806
11807
11808
11809
11810 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
11811 if test x"$acx_pthread_ok" = xyes; then
11812
11813 cat >>confdefs.h <<\_ACEOF
11814 #define HAVE_PTHREAD 1
11815 _ACEOF
11816
11817 :
11818 else
11819 acx_pthread_ok=no
11820
11821 fi
11822 ac_ext=c
11823 ac_cpp='$CPP $CPPFLAGS'
11824 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
11825 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
11826 ac_compiler_gnu=$ac_cv_c_compiler_gnu
11827
11828
11829
11830
11831 # AC_PROG_RANLIB not needed if you are using AC_PROG_LIBTOOL
11832 # AC_PROG_RANLIB
11833 ac_config_files="$ac_config_files Makefile lib/Makefile tools/Makefile lzma443/Makefile win32/Makefile tests/Makefile doc/Makefile pyaff/Makefile man/Makefile lib/version.h"
11834
11835 ac_config_files="$ac_config_files debian/changelog"
11836
11837 ac_config_files="$ac_config_files debian/shlibs.local.ex"
11838
11839 ac_config_files="$ac_config_files afflib.spec"
11840
11841 ac_config_headers="$ac_config_headers affconfig.h"
11842
11843
11844 # Bring additional directories where things might be found into our
11845 # search path. I don't know why autoconf doesn't do this by default
11846 for spfx in /usr/local /opt/local /sw ${prefix} ; do
11847 echo checking ${spfx}/include
11848 if test -d ${spfx}/include; then
11849 CPPFLAGS="-I${spfx}/include $CPPFLAGS"
11850 LDFLAGS="-L${spfx}/lib $LDFLAGS"
11851 fi
11852 done
11853
11854
11855
11856 cat >>confdefs.h <<\_ACEOF
11857 #define IN_AFFLIB 1
11858 _ACEOF
11859
11860
11861 # Special features that I use
11862 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
11863 # for constant arguments. Useless!
11864 { echo "$as_me:$LINENO: checking for working alloca.h" >&5
11865 echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6; }
11866 if test "${ac_cv_working_alloca_h+set}" = set; then
11867 echo $ECHO_N "(cached) $ECHO_C" >&6
11868 else
11869 cat >conftest.$ac_ext <<_ACEOF
11870 /* confdefs.h. */
11871 _ACEOF
11872 cat confdefs.h >>conftest.$ac_ext
11873 cat >>conftest.$ac_ext <<_ACEOF
11874 /* end confdefs.h. */
11875 #include <alloca.h>
11876 int
11877 main ()
11878 {
11879 char *p = (char *) alloca (2 * sizeof (int));
11880 if (p) return 0;
11881 ;
11882 return 0;
11883 }
11884 _ACEOF
11885 rm -f conftest.$ac_objext conftest$ac_exeext
11886 if { (ac_try="$ac_link"
11887 case "(($ac_try" in
11888 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
11889 *) ac_try_echo=$ac_try;;
11890 esac
11891 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
11892 (eval "$ac_link") 2>conftest.er1
11893 ac_status=$?
11894 grep -v '^ *+' conftest.er1 >conftest.err
11895 rm -f conftest.er1
11896 cat conftest.err >&5
11897 echo "$as_me:$LINENO: \$? = $ac_status" >&5
11898 (exit $ac_status); } && {
11899 test -z "$ac_c_werror_flag" ||
11900 test ! -s conftest.err
11901 } && test -s conftest$ac_exeext &&
11902 $as_test_x conftest$ac_exeext; then
11903 ac_cv_working_alloca_h=yes
11904 else
11905 echo "$as_me: failed program was:" >&5
11906 sed 's/^/| /' conftest.$ac_ext >&5
11907
11908 ac_cv_working_alloca_h=no
11909 fi
11910
11911 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
11912 conftest$ac_exeext conftest.$ac_ext
11913 fi
11914 { echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5
11915 echo "${ECHO_T}$ac_cv_working_alloca_h" >&6; }
11916 if test $ac_cv_working_alloca_h = yes; then
11917
11918 cat >>confdefs.h <<\_ACEOF
11919 #define HAVE_ALLOCA_H 1
11920 _ACEOF
11921
11922 fi
11923
11924 { echo "$as_me:$LINENO: checking for alloca" >&5
11925 echo $ECHO_N "checking for alloca... $ECHO_C" >&6; }
11926 if test "${ac_cv_func_alloca_works+set}" = set; then
11927 echo $ECHO_N "(cached) $ECHO_C" >&6
11928 else
11929 cat >conftest.$ac_ext <<_ACEOF
11930 /* confdefs.h. */
11931 _ACEOF
11932 cat confdefs.h >>conftest.$ac_ext
11933 cat >>conftest.$ac_ext <<_ACEOF
11934 /* end confdefs.h. */
11935 #ifdef __GNUC__
11936 # define alloca __builtin_alloca
11937 #else
11938 # ifdef _MSC_VER
11939 # include <malloc.h>
11940 # define alloca _alloca
11941 # else
11942 # ifdef HAVE_ALLOCA_H
11943 # include <alloca.h>
11944 # else
11945 # ifdef _AIX
11946 #pragma alloca
11947 # else
11948 # ifndef alloca /* predefined by HP cc +Olibcalls */
11949 char *alloca ();
11950 # endif
11951 # endif
11952 # endif
11953 # endif
11954 #endif
11955
11956 int
11957 main ()
11958 {
11959 char *p = (char *) alloca (1);
11960 if (p) return 0;
11961 ;
11962 return 0;
11963 }
11964 _ACEOF
11965 rm -f conftest.$ac_objext conftest$ac_exeext
11966 if { (ac_try="$ac_link"
11967 case "(($ac_try" in
11968 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
11969 *) ac_try_echo=$ac_try;;
11970 esac
11971 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
11972 (eval "$ac_link") 2>conftest.er1
11973 ac_status=$?
11974 grep -v '^ *+' conftest.er1 >conftest.err
11975 rm -f conftest.er1
11976 cat conftest.err >&5
11977 echo "$as_me:$LINENO: \$? = $ac_status" >&5
11978 (exit $ac_status); } && {
11979 test -z "$ac_c_werror_flag" ||
11980 test ! -s conftest.err
11981 } && test -s conftest$ac_exeext &&
11982 $as_test_x conftest$ac_exeext; then
11983 ac_cv_func_alloca_works=yes
11984 else
11985 echo "$as_me: failed program was:" >&5
11986 sed 's/^/| /' conftest.$ac_ext >&5
11987
11988 ac_cv_func_alloca_works=no
11989 fi
11990
11991 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
11992 conftest$ac_exeext conftest.$ac_ext
11993 fi
11994 { echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5
11995 echo "${ECHO_T}$ac_cv_func_alloca_works" >&6; }
11996
11997 if test $ac_cv_func_alloca_works = yes; then
11998
11999 cat >>confdefs.h <<\_ACEOF
12000 #define HAVE_ALLOCA 1
12001 _ACEOF
12002
12003 else
12004 # The SVR3 libPW and SVR4 libucb both contain incompatible functions
12005 # that cause trouble. Some versions do not even contain alloca or
12006 # contain a buggy version. If you still want to use their alloca,
12007 # use ar to extract alloca.o from them instead of compiling alloca.c.
12008
12009 ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
12010
12011 cat >>confdefs.h <<\_ACEOF
12012 #define C_ALLOCA 1
12013 _ACEOF
12014
12015
12016 { echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5
12017 echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6; }
12018 if test "${ac_cv_os_cray+set}" = set; then
12019 echo $ECHO_N "(cached) $ECHO_C" >&6
12020 else
12021 cat >conftest.$ac_ext <<_ACEOF
12022 /* confdefs.h. */
12023 _ACEOF
12024 cat confdefs.h >>conftest.$ac_ext
12025 cat >>conftest.$ac_ext <<_ACEOF
12026 /* end confdefs.h. */
12027 #if defined CRAY && ! defined CRAY2
12028 webecray
12029 #else
12030 wenotbecray
12031 #endif
12032
12033 _ACEOF
12034 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
12035 $EGREP "webecray" >/dev/null 2>&1; then
12036 ac_cv_os_cray=yes
12037 else
12038 ac_cv_os_cray=no
12039 fi
12040 rm -f -r conftest*
12041
12042 fi
12043 { echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5
12044 echo "${ECHO_T}$ac_cv_os_cray" >&6; }
12045 if test $ac_cv_os_cray = yes; then
12046 for ac_func in _getb67 GETB67 getb67; do
12047 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
12048 { echo "$as_me:$LINENO: checking for $ac_func" >&5
12049 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
12050 if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
12051 echo $ECHO_N "(cached) $ECHO_C" >&6
12052 else
12053 cat >conftest.$ac_ext <<_ACEOF
12054 /* confdefs.h. */
12055 _ACEOF
12056 cat confdefs.h >>conftest.$ac_ext
12057 cat >>conftest.$ac_ext <<_ACEOF
12058 /* end confdefs.h. */
12059 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
12060 For example, HP-UX 11i <limits.h> declares gettimeofday. */
12061 #define $ac_func innocuous_$ac_func
12062
12063 /* System header to define __stub macros and hopefully few prototypes,
12064 which can conflict with char $ac_func (); below.
12065 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
12066 <limits.h> exists even on freestanding compilers. */
12067
12068 #ifdef __STDC__
12069 # include <limits.h>
12070 #else
12071 # include <assert.h>
12072 #endif
12073
12074 #undef $ac_func
12075
12076 /* Override any GCC internal prototype to avoid an error.
12077 Use char because int might match the return type of a GCC
12078 builtin and then its argument prototype would still apply. */
12079 #ifdef __cplusplus
12080 extern "C"
12081 #endif
12082 char $ac_func ();
12083 /* The GNU C library defines this for functions which it implements
12084 to always fail with ENOSYS. Some functions are actually named
12085 something starting with __ and the normal name is an alias. */
12086 #if defined __stub_$ac_func || defined __stub___$ac_func
12087 choke me
12088 #endif
12089
12090 int
12091 main ()
12092 {
12093 return $ac_func ();
12094 ;
12095 return 0;
12096 }
12097 _ACEOF
12098 rm -f conftest.$ac_objext conftest$ac_exeext
12099 if { (ac_try="$ac_link"
12100 case "(($ac_try" in
12101 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12102 *) ac_try_echo=$ac_try;;
12103 esac
12104 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12105 (eval "$ac_link") 2>conftest.er1
12106 ac_status=$?
12107 grep -v '^ *+' conftest.er1 >conftest.err
12108 rm -f conftest.er1
12109 cat conftest.err >&5
12110 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12111 (exit $ac_status); } && {
12112 test -z "$ac_c_werror_flag" ||
12113 test ! -s conftest.err
12114 } && test -s conftest$ac_exeext &&
12115 $as_test_x conftest$ac_exeext; then
12116 eval "$as_ac_var=yes"
12117 else
12118 echo "$as_me: failed program was:" >&5
12119 sed 's/^/| /' conftest.$ac_ext >&5
12120
12121 eval "$as_ac_var=no"
12122 fi
12123
12124 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
12125 conftest$ac_exeext conftest.$ac_ext
12126 fi
12127 ac_res=`eval echo '${'$as_ac_var'}'`
12128 { echo "$as_me:$LINENO: result: $ac_res" >&5
12129 echo "${ECHO_T}$ac_res" >&6; }
12130 if test `eval echo '${'$as_ac_var'}'` = yes; then
12131
12132 cat >>confdefs.h <<_ACEOF
12133 #define CRAY_STACKSEG_END $ac_func
12134 _ACEOF
12135
12136 break
12137 fi
12138
12139 done
12140 fi
12141
12142 { echo "$as_me:$LINENO: checking stack direction for C alloca" >&5
12143 echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6; }
12144 if test "${ac_cv_c_stack_direction+set}" = set; then
12145 echo $ECHO_N "(cached) $ECHO_C" >&6
12146 else
12147 if test "$cross_compiling" = yes; then
12148 ac_cv_c_stack_direction=0
12149 else
12150 cat >conftest.$ac_ext <<_ACEOF
12151 /* confdefs.h. */
12152 _ACEOF
12153 cat confdefs.h >>conftest.$ac_ext
12154 cat >>conftest.$ac_ext <<_ACEOF
12155 /* end confdefs.h. */
12156 $ac_includes_default
12157 int
12158 find_stack_direction ()
12159 {
12160 static char *addr = 0;
12161 auto char dummy;
12162 if (addr == 0)
12163 {
12164 addr = &dummy;
12165 return find_stack_direction ();
12166 }
12167 else
12168 return (&dummy > addr) ? 1 : -1;
12169 }
12170
12171 int
12172 main ()
12173 {
12174 return find_stack_direction () < 0;
12175 }
12176 _ACEOF
12177 rm -f conftest$ac_exeext
12178 if { (ac_try="$ac_link"
12179 case "(($ac_try" in
12180 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12181 *) ac_try_echo=$ac_try;;
12182 esac
12183 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12184 (eval "$ac_link") 2>&5
12185 ac_status=$?
12186 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12187 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
12188 { (case "(($ac_try" in
12189 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12190 *) ac_try_echo=$ac_try;;
12191 esac
12192 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12193 (eval "$ac_try") 2>&5
12194 ac_status=$?
12195 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12196 (exit $ac_status); }; }; then
12197 ac_cv_c_stack_direction=1
12198 else
12199 echo "$as_me: program exited with status $ac_status" >&5
12200 echo "$as_me: failed program was:" >&5
12201 sed 's/^/| /' conftest.$ac_ext >&5
12202
12203 ( exit $ac_status )
12204 ac_cv_c_stack_direction=-1
12205 fi
12206 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
12207 fi
12208
12209
12210 fi
12211 { echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5
12212 echo "${ECHO_T}$ac_cv_c_stack_direction" >&6; }
12213
12214 cat >>confdefs.h <<_ACEOF
12215 #define STACK_DIRECTION $ac_cv_c_stack_direction
12216 _ACEOF
12217
12218
12219 fi
12220
12221 { echo "$as_me:$LINENO: checking for _LARGEFILE_SOURCE value needed for large files" >&5
12222 echo $ECHO_N "checking for _LARGEFILE_SOURCE value needed for large files... $ECHO_C" >&6; }
12223 if test "${ac_cv_sys_largefile_source+set}" = set; then
12224 echo $ECHO_N "(cached) $ECHO_C" >&6
12225 else
12226 while :; do
12227 cat >conftest.$ac_ext <<_ACEOF
12228 /* confdefs.h. */
12229 _ACEOF
12230 cat confdefs.h >>conftest.$ac_ext
12231 cat >>conftest.$ac_ext <<_ACEOF
12232 /* end confdefs.h. */
12233 #include <stdio.h>
12234 int
12235 main ()
12236 {
12237 return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
12238 ;
12239 return 0;
12240 }
12241 _ACEOF
12242 rm -f conftest.$ac_objext conftest$ac_exeext
12243 if { (ac_try="$ac_link"
12244 case "(($ac_try" in
12245 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12246 *) ac_try_echo=$ac_try;;
12247 esac
12248 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12249 (eval "$ac_link") 2>conftest.er1
12250 ac_status=$?
12251 grep -v '^ *+' conftest.er1 >conftest.err
12252 rm -f conftest.er1
12253 cat conftest.err >&5
12254 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12255 (exit $ac_status); } && {
12256 test -z "$ac_c_werror_flag" ||
12257 test ! -s conftest.err
12258 } && test -s conftest$ac_exeext &&
12259 $as_test_x conftest$ac_exeext; then
12260 ac_cv_sys_largefile_source=no; break
12261 else
12262 echo "$as_me: failed program was:" >&5
12263 sed 's/^/| /' conftest.$ac_ext >&5
12264
12265
12266 fi
12267
12268 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
12269 conftest$ac_exeext conftest.$ac_ext
12270 cat >conftest.$ac_ext <<_ACEOF
12271 /* confdefs.h. */
12272 _ACEOF
12273 cat confdefs.h >>conftest.$ac_ext
12274 cat >>conftest.$ac_ext <<_ACEOF
12275 /* end confdefs.h. */
12276 #define _LARGEFILE_SOURCE 1
12277 #include <stdio.h>
12278 int
12279 main ()
12280 {
12281 return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
12282 ;
12283 return 0;
12284 }
12285 _ACEOF
12286 rm -f conftest.$ac_objext conftest$ac_exeext
12287 if { (ac_try="$ac_link"
12288 case "(($ac_try" in
12289 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12290 *) ac_try_echo=$ac_try;;
12291 esac
12292 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12293 (eval "$ac_link") 2>conftest.er1
12294 ac_status=$?
12295 grep -v '^ *+' conftest.er1 >conftest.err
12296 rm -f conftest.er1
12297 cat conftest.err >&5
12298 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12299 (exit $ac_status); } && {
12300 test -z "$ac_c_werror_flag" ||
12301 test ! -s conftest.err
12302 } && test -s conftest$ac_exeext &&
12303 $as_test_x conftest$ac_exeext; then
12304 ac_cv_sys_largefile_source=1; break
12305 else
12306 echo "$as_me: failed program was:" >&5
12307 sed 's/^/| /' conftest.$ac_ext >&5
12308
12309
12310 fi
12311
12312 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
12313 conftest$ac_exeext conftest.$ac_ext
12314 ac_cv_sys_largefile_source=unknown
12315 break
12316 done
12317 fi
12318 { echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_source" >&5
12319 echo "${ECHO_T}$ac_cv_sys_largefile_source" >&6; }
12320 case $ac_cv_sys_largefile_source in #(
12321 no | unknown) ;;
12322 *)
12323 cat >>confdefs.h <<_ACEOF
12324 #define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source
12325 _ACEOF
12326 ;;
12327 esac
12328 rm -f -r conftest*
12329
12330 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
12331 # in glibc 2.1.3, but that breaks too many other things.
12332 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
12333 if test $ac_cv_sys_largefile_source != unknown; then
12334
12335 cat >>confdefs.h <<\_ACEOF
12336 #define HAVE_FSEEKO 1
12337 _ACEOF
12338
12339 fi
12340
12341
12342
12343
12344
12345
12346 ac_header_dirent=no
12347 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
12348 as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
12349 { echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5
12350 echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; }
12351 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
12352 echo $ECHO_N "(cached) $ECHO_C" >&6
12353 else
12354 cat >conftest.$ac_ext <<_ACEOF
12355 /* confdefs.h. */
12356 _ACEOF
12357 cat confdefs.h >>conftest.$ac_ext
12358 cat >>conftest.$ac_ext <<_ACEOF
12359 /* end confdefs.h. */
12360 #include <sys/types.h>
12361 #include <$ac_hdr>
12362
12363 int
12364 main ()
12365 {
12366 if ((DIR *) 0)
12367 return 0;
12368 ;
12369 return 0;
12370 }
12371 _ACEOF
12372 rm -f conftest.$ac_objext
12373 if { (ac_try="$ac_compile"
12374 case "(($ac_try" in
12375 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12376 *) ac_try_echo=$ac_try;;
12377 esac
12378 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12379 (eval "$ac_compile") 2>conftest.er1
12380 ac_status=$?
12381 grep -v '^ *+' conftest.er1 >conftest.err
12382 rm -f conftest.er1
12383 cat conftest.err >&5
12384 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12385 (exit $ac_status); } && {
12386 test -z "$ac_c_werror_flag" ||
12387 test ! -s conftest.err
12388 } && test -s conftest.$ac_objext; then
12389 eval "$as_ac_Header=yes"
12390 else
12391 echo "$as_me: failed program was:" >&5
12392 sed 's/^/| /' conftest.$ac_ext >&5
12393
12394 eval "$as_ac_Header=no"
12395 fi
12396
12397 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12398 fi
12399 ac_res=`eval echo '${'$as_ac_Header'}'`
12400 { echo "$as_me:$LINENO: result: $ac_res" >&5
12401 echo "${ECHO_T}$ac_res" >&6; }
12402 if test `eval echo '${'$as_ac_Header'}'` = yes; then
12403 cat >>confdefs.h <<_ACEOF
12404 #define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
12405 _ACEOF
12406
12407 ac_header_dirent=$ac_hdr; break
12408 fi
12409
12410 done
12411 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
12412 if test $ac_header_dirent = dirent.h; then
12413 { echo "$as_me:$LINENO: checking for library containing opendir" >&5
12414 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; }
12415 if test "${ac_cv_search_opendir+set}" = set; then
12416 echo $ECHO_N "(cached) $ECHO_C" >&6
12417 else
12418 ac_func_search_save_LIBS=$LIBS
12419 cat >conftest.$ac_ext <<_ACEOF
12420 /* confdefs.h. */
12421 _ACEOF
12422 cat confdefs.h >>conftest.$ac_ext
12423 cat >>conftest.$ac_ext <<_ACEOF
12424 /* end confdefs.h. */
12425
12426 /* Override any GCC internal prototype to avoid an error.
12427 Use char because int might match the return type of a GCC
12428 builtin and then its argument prototype would still apply. */
12429 #ifdef __cplusplus
12430 extern "C"
12431 #endif
12432 char opendir ();
12433 int
12434 main ()
12435 {
12436 return opendir ();
12437 ;
12438 return 0;
12439 }
12440 _ACEOF
12441 for ac_lib in '' dir; do
12442 if test -z "$ac_lib"; then
12443 ac_res="none required"
12444 else
12445 ac_res=-l$ac_lib
12446 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
12447 fi
12448 rm -f conftest.$ac_objext conftest$ac_exeext
12449 if { (ac_try="$ac_link"
12450 case "(($ac_try" in
12451 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12452 *) ac_try_echo=$ac_try;;
12453 esac
12454 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12455 (eval "$ac_link") 2>conftest.er1
12456 ac_status=$?
12457 grep -v '^ *+' conftest.er1 >conftest.err
12458 rm -f conftest.er1
12459 cat conftest.err >&5
12460 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12461 (exit $ac_status); } && {
12462 test -z "$ac_c_werror_flag" ||
12463 test ! -s conftest.err
12464 } && test -s conftest$ac_exeext &&
12465 $as_test_x conftest$ac_exeext; then
12466 ac_cv_search_opendir=$ac_res
12467 else
12468 echo "$as_me: failed program was:" >&5
12469 sed 's/^/| /' conftest.$ac_ext >&5
12470
12471
12472 fi
12473
12474 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
12475 conftest$ac_exeext
12476 if test "${ac_cv_search_opendir+set}" = set; then
12477 break
12478 fi
12479 done
12480 if test "${ac_cv_search_opendir+set}" = set; then
12481 :
12482 else
12483 ac_cv_search_opendir=no
12484 fi
12485 rm conftest.$ac_ext
12486 LIBS=$ac_func_search_save_LIBS
12487 fi
12488 { echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
12489 echo "${ECHO_T}$ac_cv_search_opendir" >&6; }
12490 ac_res=$ac_cv_search_opendir
12491 if test "$ac_res" != no; then
12492 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
12493
12494 fi
12495
12496 else
12497 { echo "$as_me:$LINENO: checking for library containing opendir" >&5
12498 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; }
12499 if test "${ac_cv_search_opendir+set}" = set; then
12500 echo $ECHO_N "(cached) $ECHO_C" >&6
12501 else
12502 ac_func_search_save_LIBS=$LIBS
12503 cat >conftest.$ac_ext <<_ACEOF
12504 /* confdefs.h. */
12505 _ACEOF
12506 cat confdefs.h >>conftest.$ac_ext
12507 cat >>conftest.$ac_ext <<_ACEOF
12508 /* end confdefs.h. */
12509
12510 /* Override any GCC internal prototype to avoid an error.
12511 Use char because int might match the return type of a GCC
12512 builtin and then its argument prototype would still apply. */
12513 #ifdef __cplusplus
12514 extern "C"
12515 #endif
12516 char opendir ();
12517 int
12518 main ()
12519 {
12520 return opendir ();
12521 ;
12522 return 0;
12523 }
12524 _ACEOF
12525 for ac_lib in '' x; do
12526 if test -z "$ac_lib"; then
12527 ac_res="none required"
12528 else
12529 ac_res=-l$ac_lib
12530 LIBS="-l$ac_lib $ac_func_search_save_LIBS"
12531 fi
12532 rm -f conftest.$ac_objext conftest$ac_exeext
12533 if { (ac_try="$ac_link"
12534 case "(($ac_try" in
12535 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12536 *) ac_try_echo=$ac_try;;
12537 esac
12538 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12539 (eval "$ac_link") 2>conftest.er1
12540 ac_status=$?
12541 grep -v '^ *+' conftest.er1 >conftest.err
12542 rm -f conftest.er1
12543 cat conftest.err >&5
12544 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12545 (exit $ac_status); } && {
12546 test -z "$ac_c_werror_flag" ||
12547 test ! -s conftest.err
12548 } && test -s conftest$ac_exeext &&
12549 $as_test_x conftest$ac_exeext; then
12550 ac_cv_search_opendir=$ac_res
12551 else
12552 echo "$as_me: failed program was:" >&5
12553 sed 's/^/| /' conftest.$ac_ext >&5
12554
12555
12556 fi
12557
12558 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
12559 conftest$ac_exeext
12560 if test "${ac_cv_search_opendir+set}" = set; then
12561 break
12562 fi
12563 done
12564 if test "${ac_cv_search_opendir+set}" = set; then
12565 :
12566 else
12567 ac_cv_search_opendir=no
12568 fi
12569 rm conftest.$ac_ext
12570 LIBS=$ac_func_search_save_LIBS
12571 fi
12572 { echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5
12573 echo "${ECHO_T}$ac_cv_search_opendir" >&6; }
12574 ac_res=$ac_cv_search_opendir
12575 if test "$ac_res" != no; then
12576 test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
12577
12578 fi
12579
12580 fi
12581
12582 { echo "$as_me:$LINENO: checking for ANSI C header files" >&5
12583 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
12584 if test "${ac_cv_header_stdc+set}" = set; then
12585 echo $ECHO_N "(cached) $ECHO_C" >&6
12586 else
12587 cat >conftest.$ac_ext <<_ACEOF
12588 /* confdefs.h. */
12589 _ACEOF
12590 cat confdefs.h >>conftest.$ac_ext
12591 cat >>conftest.$ac_ext <<_ACEOF
12592 /* end confdefs.h. */
12593 #include <stdlib.h>
12594 #include <stdarg.h>
12595 #include <string.h>
12596 #include <float.h>
12597
12598 int
12599 main ()
12600 {
12601
12602 ;
12603 return 0;
12604 }
12605 _ACEOF
12606 rm -f conftest.$ac_objext
12607 if { (ac_try="$ac_compile"
12608 case "(($ac_try" in
12609 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12610 *) ac_try_echo=$ac_try;;
12611 esac
12612 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12613 (eval "$ac_compile") 2>conftest.er1
12614 ac_status=$?
12615 grep -v '^ *+' conftest.er1 >conftest.err
12616 rm -f conftest.er1
12617 cat conftest.err >&5
12618 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12619 (exit $ac_status); } && {
12620 test -z "$ac_c_werror_flag" ||
12621 test ! -s conftest.err
12622 } && test -s conftest.$ac_objext; then
12623 ac_cv_header_stdc=yes
12624 else
12625 echo "$as_me: failed program was:" >&5
12626 sed 's/^/| /' conftest.$ac_ext >&5
12627
12628 ac_cv_header_stdc=no
12629 fi
12630
12631 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12632
12633 if test $ac_cv_header_stdc = yes; then
12634 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
12635 cat >conftest.$ac_ext <<_ACEOF
12636 /* confdefs.h. */
12637 _ACEOF
12638 cat confdefs.h >>conftest.$ac_ext
12639 cat >>conftest.$ac_ext <<_ACEOF
12640 /* end confdefs.h. */
12641 #include <string.h>
12642
12643 _ACEOF
12644 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
12645 $EGREP "memchr" >/dev/null 2>&1; then
12646 :
12647 else
12648 ac_cv_header_stdc=no
12649 fi
12650 rm -f -r conftest*
12651
12652 fi
12653
12654 if test $ac_cv_header_stdc = yes; then
12655 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
12656 cat >conftest.$ac_ext <<_ACEOF
12657 /* confdefs.h. */
12658 _ACEOF
12659 cat confdefs.h >>conftest.$ac_ext
12660 cat >>conftest.$ac_ext <<_ACEOF
12661 /* end confdefs.h. */
12662 #include <stdlib.h>
12663
12664 _ACEOF
12665 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
12666 $EGREP "free" >/dev/null 2>&1; then
12667 :
12668 else
12669 ac_cv_header_stdc=no
12670 fi
12671 rm -f -r conftest*
12672
12673 fi
12674
12675 if test $ac_cv_header_stdc = yes; then
12676 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
12677 if test "$cross_compiling" = yes; then
12678 :
12679 else
12680 cat >conftest.$ac_ext <<_ACEOF
12681 /* confdefs.h. */
12682 _ACEOF
12683 cat confdefs.h >>conftest.$ac_ext
12684 cat >>conftest.$ac_ext <<_ACEOF
12685 /* end confdefs.h. */
12686 #include <ctype.h>
12687 #include <stdlib.h>
12688 #if ((' ' & 0x0FF) == 0x020)
12689 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
12690 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
12691 #else
12692 # define ISLOWER(c) \
12693 (('a' <= (c) && (c) <= 'i') \
12694 || ('j' <= (c) && (c) <= 'r') \
12695 || ('s' <= (c) && (c) <= 'z'))
12696 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
12697 #endif
12698
12699 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
12700 int
12701 main ()
12702 {
12703 int i;
12704 for (i = 0; i < 256; i++)
12705 if (XOR (islower (i), ISLOWER (i))
12706 || toupper (i) != TOUPPER (i))
12707 return 2;
12708 return 0;
12709 }
12710 _ACEOF
12711 rm -f conftest$ac_exeext
12712 if { (ac_try="$ac_link"
12713 case "(($ac_try" in
12714 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12715 *) ac_try_echo=$ac_try;;
12716 esac
12717 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12718 (eval "$ac_link") 2>&5
12719 ac_status=$?
12720 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12721 (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
12722 { (case "(($ac_try" in
12723 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12724 *) ac_try_echo=$ac_try;;
12725 esac
12726 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12727 (eval "$ac_try") 2>&5
12728 ac_status=$?
12729 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12730 (exit $ac_status); }; }; then
12731 :
12732 else
12733 echo "$as_me: program exited with status $ac_status" >&5
12734 echo "$as_me: failed program was:" >&5
12735 sed 's/^/| /' conftest.$ac_ext >&5
12736
12737 ( exit $ac_status )
12738 ac_cv_header_stdc=no
12739 fi
12740 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
12741 fi
12742
12743
12744 fi
12745 fi
12746 { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
12747 echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
12748 if test $ac_cv_header_stdc = yes; then
12749
12750 cat >>confdefs.h <<\_ACEOF
12751 #define STDC_HEADERS 1
12752 _ACEOF
12753
12754 fi
12755
12756 # Check whether --enable-largefile was given.
12757 if test "${enable_largefile+set}" = set; then
12758 enableval=$enable_largefile;
12759 fi
12760
12761 if test "$enable_largefile" != no; then
12762
12763 { echo "$as_me:$LINENO: checking for special C compiler options needed for large files" >&5
12764 echo $ECHO_N "checking for special C compiler options needed for large files... $ECHO_C" >&6; }
12765 if test "${ac_cv_sys_largefile_CC+set}" = set; then
12766 echo $ECHO_N "(cached) $ECHO_C" >&6
12767 else
12768 ac_cv_sys_largefile_CC=no
12769 if test "$GCC" != yes; then
12770 ac_save_CC=$CC
12771 while :; do
12772 # IRIX 6.2 and later do not support large files by default,
12773 # so use the C compiler's -n32 option if that helps.
12774 cat >conftest.$ac_ext <<_ACEOF
12775 /* confdefs.h. */
12776 _ACEOF
12777 cat confdefs.h >>conftest.$ac_ext
12778 cat >>conftest.$ac_ext <<_ACEOF
12779 /* end confdefs.h. */
12780 #include <sys/types.h>
12781 /* Check that off_t can represent 2**63 - 1 correctly.
12782 We can't simply define LARGE_OFF_T to be 9223372036854775807,
12783 since some C++ compilers masquerading as C compilers
12784 incorrectly reject 9223372036854775807. */
12785 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
12786 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
12787 && LARGE_OFF_T % 2147483647 == 1)
12788 ? 1 : -1];
12789 int
12790 main ()
12791 {
12792
12793 ;
12794 return 0;
12795 }
12796 _ACEOF
12797 rm -f conftest.$ac_objext
12798 if { (ac_try="$ac_compile"
12799 case "(($ac_try" in
12800 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12801 *) ac_try_echo=$ac_try;;
12802 esac
12803 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12804 (eval "$ac_compile") 2>conftest.er1
12805 ac_status=$?
12806 grep -v '^ *+' conftest.er1 >conftest.err
12807 rm -f conftest.er1
12808 cat conftest.err >&5
12809 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12810 (exit $ac_status); } && {
12811 test -z "$ac_c_werror_flag" ||
12812 test ! -s conftest.err
12813 } && test -s conftest.$ac_objext; then
12814 break
12815 else
12816 echo "$as_me: failed program was:" >&5
12817 sed 's/^/| /' conftest.$ac_ext >&5
12818
12819
12820 fi
12821
12822 rm -f core conftest.err conftest.$ac_objext
12823 CC="$CC -n32"
12824 rm -f conftest.$ac_objext
12825 if { (ac_try="$ac_compile"
12826 case "(($ac_try" in
12827 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12828 *) ac_try_echo=$ac_try;;
12829 esac
12830 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12831 (eval "$ac_compile") 2>conftest.er1
12832 ac_status=$?
12833 grep -v '^ *+' conftest.er1 >conftest.err
12834 rm -f conftest.er1
12835 cat conftest.err >&5
12836 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12837 (exit $ac_status); } && {
12838 test -z "$ac_c_werror_flag" ||
12839 test ! -s conftest.err
12840 } && test -s conftest.$ac_objext; then
12841 ac_cv_sys_largefile_CC=' -n32'; break
12842 else
12843 echo "$as_me: failed program was:" >&5
12844 sed 's/^/| /' conftest.$ac_ext >&5
12845
12846
12847 fi
12848
12849 rm -f core conftest.err conftest.$ac_objext
12850 break
12851 done
12852 CC=$ac_save_CC
12853 rm -f conftest.$ac_ext
12854 fi
12855 fi
12856 { echo "$as_me:$LINENO: result: $ac_cv_sys_largefile_CC" >&5
12857 echo "${ECHO_T}$ac_cv_sys_largefile_CC" >&6; }
12858 if test "$ac_cv_sys_largefile_CC" != no; then
12859 CC=$CC$ac_cv_sys_largefile_CC
12860 fi
12861
12862 { echo "$as_me:$LINENO: checking for _FILE_OFFSET_BITS value needed for large files" >&5
12863 echo $ECHO_N "checking for _FILE_OFFSET_BITS value needed for large files... $ECHO_C" >&6; }
12864 if test "${ac_cv_sys_file_offset_bits+set}" = set; then
12865 echo $ECHO_N "(cached) $ECHO_C" >&6
12866 else
12867 while :; do
12868 cat >conftest.$ac_ext <<_ACEOF
12869 /* confdefs.h. */
12870 _ACEOF
12871 cat confdefs.h >>conftest.$ac_ext
12872 cat >>conftest.$ac_ext <<_ACEOF
12873 /* end confdefs.h. */
12874 #include <sys/types.h>
12875 /* Check that off_t can represent 2**63 - 1 correctly.
12876 We can't simply define LARGE_OFF_T to be 9223372036854775807,
12877 since some C++ compilers masquerading as C compilers
12878 incorrectly reject 9223372036854775807. */
12879 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
12880 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
12881 && LARGE_OFF_T % 2147483647 == 1)
12882 ? 1 : -1];
12883 int
12884 main ()
12885 {
12886
12887 ;
12888 return 0;
12889 }
12890 _ACEOF
12891 rm -f conftest.$ac_objext
12892 if { (ac_try="$ac_compile"
12893 case "(($ac_try" in
12894 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12895 *) ac_try_echo=$ac_try;;
12896 esac
12897 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12898 (eval "$ac_compile") 2>conftest.er1
12899 ac_status=$?
12900 grep -v '^ *+' conftest.er1 >conftest.err
12901 rm -f conftest.er1
12902 cat conftest.err >&5
12903 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12904 (exit $ac_status); } && {
12905 test -z "$ac_c_werror_flag" ||
12906 test ! -s conftest.err
12907 } && test -s conftest.$ac_objext; then
12908 ac_cv_sys_file_offset_bits=no; break
12909 else
12910 echo "$as_me: failed program was:" >&5
12911 sed 's/^/| /' conftest.$ac_ext >&5
12912
12913
12914 fi
12915
12916 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12917 cat >conftest.$ac_ext <<_ACEOF
12918 /* confdefs.h. */
12919 _ACEOF
12920 cat confdefs.h >>conftest.$ac_ext
12921 cat >>conftest.$ac_ext <<_ACEOF
12922 /* end confdefs.h. */
12923 #define _FILE_OFFSET_BITS 64
12924 #include <sys/types.h>
12925 /* Check that off_t can represent 2**63 - 1 correctly.
12926 We can't simply define LARGE_OFF_T to be 9223372036854775807,
12927 since some C++ compilers masquerading as C compilers
12928 incorrectly reject 9223372036854775807. */
12929 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
12930 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
12931 && LARGE_OFF_T % 2147483647 == 1)
12932 ? 1 : -1];
12933 int
12934 main ()
12935 {
12936
12937 ;
12938 return 0;
12939 }
12940 _ACEOF
12941 rm -f conftest.$ac_objext
12942 if { (ac_try="$ac_compile"
12943 case "(($ac_try" in
12944 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
12945 *) ac_try_echo=$ac_try;;
12946 esac
12947 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
12948 (eval "$ac_compile") 2>conftest.er1
12949 ac_status=$?
12950 grep -v '^ *+' conftest.er1 >conftest.err
12951 rm -f conftest.er1
12952 cat conftest.err >&5
12953 echo "$as_me:$LINENO: \$? = $ac_status" >&5
12954 (exit $ac_status); } && {
12955 test -z "$ac_c_werror_flag" ||
12956 test ! -s conftest.err
12957 } && test -s conftest.$ac_objext; then
12958 ac_cv_sys_file_offset_bits=64; break
12959 else
12960 echo "$as_me: failed program was:" >&5
12961 sed 's/^/| /' conftest.$ac_ext >&5
12962
12963
12964 fi
12965
12966 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12967 ac_cv_sys_file_offset_bits=unknown
12968 break
12969 done
12970 fi
12971 { echo "$as_me:$LINENO: result: $ac_cv_sys_file_offset_bits" >&5
12972 echo "${ECHO_T}$ac_cv_sys_file_offset_bits" >&6; }
12973 case $ac_cv_sys_file_offset_bits in #(
12974 no | unknown) ;;
12975 *)
12976 cat >>confdefs.h <<_ACEOF
12977 #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits
12978 _ACEOF
12979 ;;
12980 esac
12981 rm -f -r conftest*
12982 if test $ac_cv_sys_file_offset_bits = unknown; then
12983 { echo "$as_me:$LINENO: checking for _LARGE_FILES value needed for large files" >&5
12984 echo $ECHO_N "checking for _LARGE_FILES value needed for large files... $ECHO_C" >&6; }
12985 if test "${ac_cv_sys_large_files+set}" = set; then
12986 echo $ECHO_N "(cached) $ECHO_C" >&6
12987 else
12988 while :; do
12989 cat >conftest.$ac_ext <<_ACEOF
12990 /* confdefs.h. */
12991 _ACEOF
12992 cat confdefs.h >>conftest.$ac_ext
12993 cat >>conftest.$ac_ext <<_ACEOF
12994 /* end confdefs.h. */
12995 #include <sys/types.h>
12996 /* Check that off_t can represent 2**63 - 1 correctly.
12997 We can't simply define LARGE_OFF_T to be 9223372036854775807,
12998 since some C++ compilers masquerading as C compilers
12999 incorrectly reject 9223372036854775807. */
13000 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
13001 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
13002 && LARGE_OFF_T % 2147483647 == 1)
13003 ? 1 : -1];
13004 int
13005 main ()
13006 {
13007
13008 ;
13009 return 0;
13010 }
13011 _ACEOF
13012 rm -f conftest.$ac_objext
13013 if { (ac_try="$ac_compile"
13014 case "(($ac_try" in
13015 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13016 *) ac_try_echo=$ac_try;;
13017 esac
13018 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13019 (eval "$ac_compile") 2>conftest.er1
13020 ac_status=$?
13021 grep -v '^ *+' conftest.er1 >conftest.err
13022 rm -f conftest.er1
13023 cat conftest.err >&5
13024 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13025 (exit $ac_status); } && {
13026 test -z "$ac_c_werror_flag" ||
13027 test ! -s conftest.err
13028 } && test -s conftest.$ac_objext; then
13029 ac_cv_sys_large_files=no; break
13030 else
13031 echo "$as_me: failed program was:" >&5
13032 sed 's/^/| /' conftest.$ac_ext >&5
13033
13034
13035 fi
13036
13037 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13038 cat >conftest.$ac_ext <<_ACEOF
13039 /* confdefs.h. */
13040 _ACEOF
13041 cat confdefs.h >>conftest.$ac_ext
13042 cat >>conftest.$ac_ext <<_ACEOF
13043 /* end confdefs.h. */
13044 #define _LARGE_FILES 1
13045 #include <sys/types.h>
13046 /* Check that off_t can represent 2**63 - 1 correctly.
13047 We can't simply define LARGE_OFF_T to be 9223372036854775807,
13048 since some C++ compilers masquerading as C compilers
13049 incorrectly reject 9223372036854775807. */
13050 #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
13051 int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
13052 && LARGE_OFF_T % 2147483647 == 1)
13053 ? 1 : -1];
13054 int
13055 main ()
13056 {
13057
13058 ;
13059 return 0;
13060 }
13061 _ACEOF
13062 rm -f conftest.$ac_objext
13063 if { (ac_try="$ac_compile"
13064 case "(($ac_try" in
13065 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13066 *) ac_try_echo=$ac_try;;
13067 esac
13068 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13069 (eval "$ac_compile") 2>conftest.er1
13070 ac_status=$?
13071 grep -v '^ *+' conftest.er1 >conftest.err
13072 rm -f conftest.er1
13073 cat conftest.err >&5
13074 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13075 (exit $ac_status); } && {
13076 test -z "$ac_c_werror_flag" ||
13077 test ! -s conftest.err
13078 } && test -s conftest.$ac_objext; then
13079 ac_cv_sys_large_files=1; break
13080 else
13081 echo "$as_me: failed program was:" >&5
13082 sed 's/^/| /' conftest.$ac_ext >&5
13083
13084
13085 fi
13086
13087 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13088 ac_cv_sys_large_files=unknown
13089 break
13090 done
13091 fi
13092 { echo "$as_me:$LINENO: result: $ac_cv_sys_large_files" >&5
13093 echo "${ECHO_T}$ac_cv_sys_large_files" >&6; }
13094 case $ac_cv_sys_large_files in #(
13095 no | unknown) ;;
13096 *)
13097 cat >>confdefs.h <<_ACEOF
13098 #define _LARGE_FILES $ac_cv_sys_large_files
13099 _ACEOF
13100 ;;
13101 esac
13102 rm -f -r conftest*
13103 fi
13104 fi
13105
13106
13107
13108 # Checks for typedefs, structures, and compiler characteristics.
13109 { echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5
13110 echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; }
13111 if test "${ac_cv_header_stdbool_h+set}" = set; then
13112 echo $ECHO_N "(cached) $ECHO_C" >&6
13113 else
13114 cat >conftest.$ac_ext <<_ACEOF
13115 /* confdefs.h. */
13116 _ACEOF
13117 cat confdefs.h >>conftest.$ac_ext
13118 cat >>conftest.$ac_ext <<_ACEOF
13119 /* end confdefs.h. */
13120
13121 #include <stdbool.h>
13122 #ifndef bool
13123 "error: bool is not defined"
13124 #endif
13125 #ifndef false
13126 "error: false is not defined"
13127 #endif
13128 #if false
13129 "error: false is not 0"
13130 #endif
13131 #ifndef true
13132 "error: true is not defined"
13133 #endif
13134 #if true != 1
13135 "error: true is not 1"
13136 #endif
13137 #ifndef __bool_true_false_are_defined
13138 "error: __bool_true_false_are_defined is not defined"
13139 #endif
13140
13141 struct s { _Bool s: 1; _Bool t; } s;
13142
13143 char a[true == 1 ? 1 : -1];
13144 char b[false == 0 ? 1 : -1];
13145 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
13146 char d[(bool) 0.5 == true ? 1 : -1];
13147 bool e = &s;
13148 char f[(_Bool) 0.0 == false ? 1 : -1];
13149 char g[true];
13150 char h[sizeof (_Bool)];
13151 char i[sizeof s.t];
13152 enum { j = false, k = true, l = false * true, m = true * 256 };
13153 _Bool n[m];
13154 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
13155 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
13156 # if defined __xlc__ || defined __GNUC__
13157 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
13158 reported by James Lemley on 2005-10-05; see
13159 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
13160 This test is not quite right, since xlc is allowed to
13161 reject this program, as the initializer for xlcbug is
13162 not one of the forms that C requires support for.
13163 However, doing the test right would require a runtime
13164 test, and that would make cross-compilation harder.
13165 Let us hope that IBM fixes the xlc bug, and also adds
13166 support for this kind of constant expression. In the
13167 meantime, this test will reject xlc, which is OK, since
13168 our stdbool.h substitute should suffice. We also test
13169 this with GCC, where it should work, to detect more
13170 quickly whether someone messes up the test in the
13171 future. */
13172 char digs[] = "0123456789";
13173 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
13174 # endif
13175 /* Catch a bug in an HP-UX C compiler. See
13176 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
13177 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
13178 */
13179 _Bool q = true;
13180 _Bool *pq = &q;
13181
13182 int
13183 main ()
13184 {
13185
13186 *pq |= q;
13187 *pq |= ! q;
13188 /* Refer to every declared value, to avoid compiler optimizations. */
13189 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
13190 + !m + !n + !o + !p + !q + !pq);
13191
13192 ;
13193 return 0;
13194 }
13195 _ACEOF
13196 rm -f conftest.$ac_objext
13197 if { (ac_try="$ac_compile"
13198 case "(($ac_try" in
13199 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13200 *) ac_try_echo=$ac_try;;
13201 esac
13202 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13203 (eval "$ac_compile") 2>conftest.er1
13204 ac_status=$?
13205 grep -v '^ *+' conftest.er1 >conftest.err
13206 rm -f conftest.er1
13207 cat conftest.err >&5
13208 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13209 (exit $ac_status); } && {
13210 test -z "$ac_c_werror_flag" ||
13211 test ! -s conftest.err
13212 } && test -s conftest.$ac_objext; then
13213 ac_cv_header_stdbool_h=yes
13214 else
13215 echo "$as_me: failed program was:" >&5
13216 sed 's/^/| /' conftest.$ac_ext >&5
13217
13218 ac_cv_header_stdbool_h=no
13219 fi
13220
13221 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13222 fi
13223 { echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5
13224 echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; }
13225 { echo "$as_me:$LINENO: checking for _Bool" >&5
13226 echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; }
13227 if test "${ac_cv_type__Bool+set}" = set; then
13228 echo $ECHO_N "(cached) $ECHO_C" >&6
13229 else
13230 cat >conftest.$ac_ext <<_ACEOF
13231 /* confdefs.h. */
13232 _ACEOF
13233 cat confdefs.h >>conftest.$ac_ext
13234 cat >>conftest.$ac_ext <<_ACEOF
13235 /* end confdefs.h. */
13236 $ac_includes_default
13237 typedef _Bool ac__type_new_;
13238 int
13239 main ()
13240 {
13241 if ((ac__type_new_ *) 0)
13242 return 0;
13243 if (sizeof (ac__type_new_))
13244 return 0;
13245 ;
13246 return 0;
13247 }
13248 _ACEOF
13249 rm -f conftest.$ac_objext
13250 if { (ac_try="$ac_compile"
13251 case "(($ac_try" in
13252 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13253 *) ac_try_echo=$ac_try;;
13254 esac
13255 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13256 (eval "$ac_compile") 2>conftest.er1
13257 ac_status=$?
13258 grep -v '^ *+' conftest.er1 >conftest.err
13259 rm -f conftest.er1
13260 cat conftest.err >&5
13261 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13262 (exit $ac_status); } && {
13263 test -z "$ac_c_werror_flag" ||
13264 test ! -s conftest.err
13265 } && test -s conftest.$ac_objext; then
13266 ac_cv_type__Bool=yes
13267 else
13268 echo "$as_me: failed program was:" >&5
13269 sed 's/^/| /' conftest.$ac_ext >&5
13270
13271 ac_cv_type__Bool=no
13272 fi
13273
13274 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13275 fi
13276 { echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5
13277 echo "${ECHO_T}$ac_cv_type__Bool" >&6; }
13278 if test $ac_cv_type__Bool = yes; then
13279
13280 cat >>confdefs.h <<_ACEOF
13281 #define HAVE__BOOL 1
13282 _ACEOF
13283
13284
13285 fi
13286
13287 if test $ac_cv_header_stdbool_h = yes; then
13288
13289 cat >>confdefs.h <<\_ACEOF
13290 #define HAVE_STDBOOL_H 1
13291 _ACEOF
13292
13293 fi
13294
13295 { echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
13296 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; }
13297 if test "${ac_cv_c_const+set}" = set; then
13298 echo $ECHO_N "(cached) $ECHO_C" >&6
13299 else
13300 cat >conftest.$ac_ext <<_ACEOF
13301 /* confdefs.h. */
13302 _ACEOF
13303 cat confdefs.h >>conftest.$ac_ext
13304 cat >>conftest.$ac_ext <<_ACEOF
13305 /* end confdefs.h. */
13306
13307 int
13308 main ()
13309 {
13310 /* FIXME: Include the comments suggested by Paul. */
13311 #ifndef __cplusplus
13312 /* Ultrix mips cc rejects this. */
13313 typedef int charset[2];
13314 const charset cs;
13315 /* SunOS 4.1.1 cc rejects this. */
13316 char const *const *pcpcc;
13317 char **ppc;
13318 /* NEC SVR4.0.2 mips cc rejects this. */
13319 struct point {int x, y;};
13320 static struct point const zero = {0,0};
13321 /* AIX XL C 1.02.0.0 rejects this.
13322 It does not let you subtract one const X* pointer from another in
13323 an arm of an if-expression whose if-part is not a constant
13324 expression */
13325 const char *g = "string";
13326 pcpcc = &g + (g ? g-g : 0);
13327 /* HPUX 7.0 cc rejects these. */
13328 ++pcpcc;
13329 ppc = (char**) pcpcc;
13330 pcpcc = (char const *const *) ppc;
13331 { /* SCO 3.2v4 cc rejects this. */
13332 char *t;
13333 char const *s = 0 ? (char *) 0 : (char const *) 0;
13334
13335 *t++ = 0;
13336 if (s) return 0;
13337 }
13338 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
13339 int x[] = {25, 17};
13340 const int *foo = &x[0];
13341 ++foo;
13342 }
13343 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
13344 typedef const int *iptr;
13345 iptr p = 0;
13346 ++p;
13347 }
13348 { /* AIX XL C 1.02.0.0 rejects this saying
13349 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
13350 struct s { int j; const int *ap[3]; };
13351 struct s *b; b->j = 5;
13352 }
13353 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
13354 const int foo = 10;
13355 if (!foo) return 0;
13356 }
13357 return !cs[0] && !zero.x;
13358 #endif
13359
13360 ;
13361 return 0;
13362 }
13363 _ACEOF
13364 rm -f conftest.$ac_objext
13365 if { (ac_try="$ac_compile"
13366 case "(($ac_try" in
13367 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13368 *) ac_try_echo=$ac_try;;
13369 esac
13370 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13371 (eval "$ac_compile") 2>conftest.er1
13372 ac_status=$?
13373 grep -v '^ *+' conftest.er1 >conftest.err
13374 rm -f conftest.er1
13375 cat conftest.err >&5
13376 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13377 (exit $ac_status); } && {
13378 test -z "$ac_c_werror_flag" ||
13379 test ! -s conftest.err
13380 } && test -s conftest.$ac_objext; then
13381 ac_cv_c_const=yes
13382 else
13383 echo "$as_me: failed program was:" >&5
13384 sed 's/^/| /' conftest.$ac_ext >&5
13385
13386 ac_cv_c_const=no
13387 fi
13388
13389 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13390 fi
13391 { echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5
13392 echo "${ECHO_T}$ac_cv_c_const" >&6; }
13393 if test $ac_cv_c_const = no; then
13394
13395 cat >>confdefs.h <<\_ACEOF
13396 #define const
13397 _ACEOF
13398
13399 fi
13400
13401 { echo "$as_me:$LINENO: checking for inline" >&5
13402 echo $ECHO_N "checking for inline... $ECHO_C" >&6; }
13403 if test "${ac_cv_c_inline+set}" = set; then
13404 echo $ECHO_N "(cached) $ECHO_C" >&6
13405 else
13406 ac_cv_c_inline=no
13407 for ac_kw in inline __inline__ __inline; do
13408 cat >conftest.$ac_ext <<_ACEOF
13409 /* confdefs.h. */
13410 _ACEOF
13411 cat confdefs.h >>conftest.$ac_ext
13412 cat >>conftest.$ac_ext <<_ACEOF
13413 /* end confdefs.h. */
13414 #ifndef __cplusplus
13415 typedef int foo_t;
13416 static $ac_kw foo_t static_foo () {return 0; }
13417 $ac_kw foo_t foo () {return 0; }
13418 #endif
13419
13420 _ACEOF
13421 rm -f conftest.$ac_objext
13422 if { (ac_try="$ac_compile"
13423 case "(($ac_try" in
13424 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13425 *) ac_try_echo=$ac_try;;
13426 esac
13427 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13428 (eval "$ac_compile") 2>conftest.er1
13429 ac_status=$?
13430 grep -v '^ *+' conftest.er1 >conftest.err
13431 rm -f conftest.er1
13432 cat conftest.err >&5
13433 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13434 (exit $ac_status); } && {
13435 test -z "$ac_c_werror_flag" ||
13436 test ! -s conftest.err
13437 } && test -s conftest.$ac_objext; then
13438 ac_cv_c_inline=$ac_kw
13439 else
13440 echo "$as_me: failed program was:" >&5
13441 sed 's/^/| /' conftest.$ac_ext >&5
13442
13443
13444 fi
13445
13446 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13447 test "$ac_cv_c_inline" != no && break
13448 done
13449
13450 fi
13451 { echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
13452 echo "${ECHO_T}$ac_cv_c_inline" >&6; }
13453
13454
13455 case $ac_cv_c_inline in
13456 inline | yes) ;;
13457 *)
13458 case $ac_cv_c_inline in
13459 no) ac_val=;;
13460 *) ac_val=$ac_cv_c_inline;;
13461 esac
13462 cat >>confdefs.h <<_ACEOF
13463 #ifndef __cplusplus
13464 #define inline $ac_val
13465 #endif
13466 _ACEOF
13467 ;;
13468 esac
13469
13470 { echo "$as_me:$LINENO: checking for mode_t" >&5
13471 echo $ECHO_N "checking for mode_t... $ECHO_C" >&6; }
13472 if test "${ac_cv_type_mode_t+set}" = set; then
13473 echo $ECHO_N "(cached) $ECHO_C" >&6
13474 else
13475 cat >conftest.$ac_ext <<_ACEOF
13476 /* confdefs.h. */
13477 _ACEOF
13478 cat confdefs.h >>conftest.$ac_ext
13479 cat >>conftest.$ac_ext <<_ACEOF
13480 /* end confdefs.h. */
13481 $ac_includes_default
13482 typedef mode_t ac__type_new_;
13483 int
13484 main ()
13485 {
13486 if ((ac__type_new_ *) 0)
13487 return 0;
13488 if (sizeof (ac__type_new_))
13489 return 0;
13490 ;
13491 return 0;
13492 }
13493 _ACEOF
13494 rm -f conftest.$ac_objext
13495 if { (ac_try="$ac_compile"
13496 case "(($ac_try" in
13497 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13498 *) ac_try_echo=$ac_try;;
13499 esac
13500 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13501 (eval "$ac_compile") 2>conftest.er1
13502 ac_status=$?
13503 grep -v '^ *+' conftest.er1 >conftest.err
13504 rm -f conftest.er1
13505 cat conftest.err >&5
13506 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13507 (exit $ac_status); } && {
13508 test -z "$ac_c_werror_flag" ||
13509 test ! -s conftest.err
13510 } && test -s conftest.$ac_objext; then
13511 ac_cv_type_mode_t=yes
13512 else
13513 echo "$as_me: failed program was:" >&5
13514 sed 's/^/| /' conftest.$ac_ext >&5
13515
13516 ac_cv_type_mode_t=no
13517 fi
13518
13519 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13520 fi
13521 { echo "$as_me:$LINENO: result: $ac_cv_type_mode_t" >&5
13522 echo "${ECHO_T}$ac_cv_type_mode_t" >&6; }
13523 if test $ac_cv_type_mode_t = yes; then
13524 :
13525 else
13526
13527 cat >>confdefs.h <<_ACEOF
13528 #define mode_t int
13529 _ACEOF
13530
13531 fi
13532
13533 { echo "$as_me:$LINENO: checking for off_t" >&5
13534 echo $ECHO_N "checking for off_t... $ECHO_C" >&6; }
13535 if test "${ac_cv_type_off_t+set}" = set; then
13536 echo $ECHO_N "(cached) $ECHO_C" >&6
13537 else
13538 cat >conftest.$ac_ext <<_ACEOF
13539 /* confdefs.h. */
13540 _ACEOF
13541 cat confdefs.h >>conftest.$ac_ext
13542 cat >>conftest.$ac_ext <<_ACEOF
13543 /* end confdefs.h. */
13544 $ac_includes_default
13545 typedef off_t ac__type_new_;
13546 int
13547 main ()
13548 {
13549 if ((ac__type_new_ *) 0)
13550 return 0;
13551 if (sizeof (ac__type_new_))
13552 return 0;
13553 ;
13554 return 0;
13555 }
13556 _ACEOF
13557 rm -f conftest.$ac_objext
13558 if { (ac_try="$ac_compile"
13559 case "(($ac_try" in
13560 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13561 *) ac_try_echo=$ac_try;;
13562 esac
13563 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13564 (eval "$ac_compile") 2>conftest.er1
13565 ac_status=$?
13566 grep -v '^ *+' conftest.er1 >conftest.err
13567 rm -f conftest.er1
13568 cat conftest.err >&5
13569 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13570 (exit $ac_status); } && {
13571 test -z "$ac_c_werror_flag" ||
13572 test ! -s conftest.err
13573 } && test -s conftest.$ac_objext; then
13574 ac_cv_type_off_t=yes
13575 else
13576 echo "$as_me: failed program was:" >&5
13577 sed 's/^/| /' conftest.$ac_ext >&5
13578
13579 ac_cv_type_off_t=no
13580 fi
13581
13582 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13583 fi
13584 { echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5
13585 echo "${ECHO_T}$ac_cv_type_off_t" >&6; }
13586 if test $ac_cv_type_off_t = yes; then
13587 :
13588 else
13589
13590 cat >>confdefs.h <<_ACEOF
13591 #define off_t long int
13592 _ACEOF
13593
13594 fi
13595
13596 { echo "$as_me:$LINENO: checking for size_t" >&5
13597 echo $ECHO_N "checking for size_t... $ECHO_C" >&6; }
13598 if test "${ac_cv_type_size_t+set}" = set; then
13599 echo $ECHO_N "(cached) $ECHO_C" >&6
13600 else
13601 cat >conftest.$ac_ext <<_ACEOF
13602 /* confdefs.h. */
13603 _ACEOF
13604 cat confdefs.h >>conftest.$ac_ext
13605 cat >>conftest.$ac_ext <<_ACEOF
13606 /* end confdefs.h. */
13607 $ac_includes_default
13608 typedef size_t ac__type_new_;
13609 int
13610 main ()
13611 {
13612 if ((ac__type_new_ *) 0)
13613 return 0;
13614 if (sizeof (ac__type_new_))
13615 return 0;
13616 ;
13617 return 0;
13618 }
13619 _ACEOF
13620 rm -f conftest.$ac_objext
13621 if { (ac_try="$ac_compile"
13622 case "(($ac_try" in
13623 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13624 *) ac_try_echo=$ac_try;;
13625 esac
13626 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13627 (eval "$ac_compile") 2>conftest.er1
13628 ac_status=$?
13629 grep -v '^ *+' conftest.er1 >conftest.err
13630 rm -f conftest.er1
13631 cat conftest.err >&5
13632 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13633 (exit $ac_status); } && {
13634 test -z "$ac_c_werror_flag" ||
13635 test ! -s conftest.err
13636 } && test -s conftest.$ac_objext; then
13637 ac_cv_type_size_t=yes
13638 else
13639 echo "$as_me: failed program was:" >&5
13640 sed 's/^/| /' conftest.$ac_ext >&5
13641
13642 ac_cv_type_size_t=no
13643 fi
13644
13645 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13646 fi
13647 { echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5
13648 echo "${ECHO_T}$ac_cv_type_size_t" >&6; }
13649 if test $ac_cv_type_size_t = yes; then
13650 :
13651 else
13652
13653 cat >>confdefs.h <<_ACEOF
13654 #define size_t unsigned int
13655 _ACEOF
13656
13657 fi
13658
13659 { echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5
13660 echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6; }
13661 if test "${ac_cv_struct_tm+set}" = set; then
13662 echo $ECHO_N "(cached) $ECHO_C" >&6
13663 else
13664 cat >conftest.$ac_ext <<_ACEOF
13665 /* confdefs.h. */
13666 _ACEOF
13667 cat confdefs.h >>conftest.$ac_ext
13668 cat >>conftest.$ac_ext <<_ACEOF
13669 /* end confdefs.h. */
13670 #include <sys/types.h>
13671 #include <time.h>
13672
13673 int
13674 main ()
13675 {
13676 struct tm tm;
13677 int *p = &tm.tm_sec;
13678 return !p;
13679 ;
13680 return 0;
13681 }
13682 _ACEOF
13683 rm -f conftest.$ac_objext
13684 if { (ac_try="$ac_compile"
13685 case "(($ac_try" in
13686 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13687 *) ac_try_echo=$ac_try;;
13688 esac
13689 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13690 (eval "$ac_compile") 2>conftest.er1
13691 ac_status=$?
13692 grep -v '^ *+' conftest.er1 >conftest.err
13693 rm -f conftest.er1
13694 cat conftest.err >&5
13695 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13696 (exit $ac_status); } && {
13697 test -z "$ac_c_werror_flag" ||
13698 test ! -s conftest.err
13699 } && test -s conftest.$ac_objext; then
13700 ac_cv_struct_tm=time.h
13701 else
13702 echo "$as_me: failed program was:" >&5
13703 sed 's/^/| /' conftest.$ac_ext >&5
13704
13705 ac_cv_struct_tm=sys/time.h
13706 fi
13707
13708 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13709 fi
13710 { echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5
13711 echo "${ECHO_T}$ac_cv_struct_tm" >&6; }
13712 if test $ac_cv_struct_tm = sys/time.h; then
13713
13714 cat >>confdefs.h <<\_ACEOF
13715 #define TM_IN_SYS_TIME 1
13716 _ACEOF
13717
13718 fi
13719
13720 { echo "$as_me:$LINENO: checking for struct stat.st_blocks" >&5
13721 echo $ECHO_N "checking for struct stat.st_blocks... $ECHO_C" >&6; }
13722 if test "${ac_cv_member_struct_stat_st_blocks+set}" = set; then
13723 echo $ECHO_N "(cached) $ECHO_C" >&6
13724 else
13725 cat >conftest.$ac_ext <<_ACEOF
13726 /* confdefs.h. */
13727 _ACEOF
13728 cat confdefs.h >>conftest.$ac_ext
13729 cat >>conftest.$ac_ext <<_ACEOF
13730 /* end confdefs.h. */
13731 $ac_includes_default
13732 int
13733 main ()
13734 {
13735 static struct stat ac_aggr;
13736 if (ac_aggr.st_blocks)
13737 return 0;
13738 ;
13739 return 0;
13740 }
13741 _ACEOF
13742 rm -f conftest.$ac_objext
13743 if { (ac_try="$ac_compile"
13744 case "(($ac_try" in
13745 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13746 *) ac_try_echo=$ac_try;;
13747 esac
13748 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13749 (eval "$ac_compile") 2>conftest.er1
13750 ac_status=$?
13751 grep -v '^ *+' conftest.er1 >conftest.err
13752 rm -f conftest.er1
13753 cat conftest.err >&5
13754 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13755 (exit $ac_status); } && {
13756 test -z "$ac_c_werror_flag" ||
13757 test ! -s conftest.err
13758 } && test -s conftest.$ac_objext; then
13759 ac_cv_member_struct_stat_st_blocks=yes
13760 else
13761 echo "$as_me: failed program was:" >&5
13762 sed 's/^/| /' conftest.$ac_ext >&5
13763
13764 cat >conftest.$ac_ext <<_ACEOF
13765 /* confdefs.h. */
13766 _ACEOF
13767 cat confdefs.h >>conftest.$ac_ext
13768 cat >>conftest.$ac_ext <<_ACEOF
13769 /* end confdefs.h. */
13770 $ac_includes_default
13771 int
13772 main ()
13773 {
13774 static struct stat ac_aggr;
13775 if (sizeof ac_aggr.st_blocks)
13776 return 0;
13777 ;
13778 return 0;
13779 }
13780 _ACEOF
13781 rm -f conftest.$ac_objext
13782 if { (ac_try="$ac_compile"
13783 case "(($ac_try" in
13784 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13785 *) ac_try_echo=$ac_try;;
13786 esac
13787 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13788 (eval "$ac_compile") 2>conftest.er1
13789 ac_status=$?
13790 grep -v '^ *+' conftest.er1 >conftest.err
13791 rm -f conftest.er1
13792 cat conftest.err >&5
13793 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13794 (exit $ac_status); } && {
13795 test -z "$ac_c_werror_flag" ||
13796 test ! -s conftest.err
13797 } && test -s conftest.$ac_objext; then
13798 ac_cv_member_struct_stat_st_blocks=yes
13799 else
13800 echo "$as_me: failed program was:" >&5
13801 sed 's/^/| /' conftest.$ac_ext >&5
13802
13803 ac_cv_member_struct_stat_st_blocks=no
13804 fi
13805
13806 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13807 fi
13808
13809 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13810 fi
13811 { echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_blocks" >&5
13812 echo "${ECHO_T}$ac_cv_member_struct_stat_st_blocks" >&6; }
13813 if test $ac_cv_member_struct_stat_st_blocks = yes; then
13814
13815 cat >>confdefs.h <<_ACEOF
13816 #define HAVE_STRUCT_STAT_ST_BLOCKS 1
13817 _ACEOF
13818
13819
13820 cat >>confdefs.h <<\_ACEOF
13821 #define HAVE_ST_BLOCKS 1
13822 _ACEOF
13823
13824 else
13825 case " $LIBOBJS " in
13826 *" fileblocks.$ac_objext "* ) ;;
13827 *) LIBOBJS="$LIBOBJS fileblocks.$ac_objext"
13828 ;;
13829 esac
13830
13831 fi
13832
13833
13834 { echo "$as_me:$LINENO: checking for struct stat.st_rdev" >&5
13835 echo $ECHO_N "checking for struct stat.st_rdev... $ECHO_C" >&6; }
13836 if test "${ac_cv_member_struct_stat_st_rdev+set}" = set; then
13837 echo $ECHO_N "(cached) $ECHO_C" >&6
13838 else
13839 cat >conftest.$ac_ext <<_ACEOF
13840 /* confdefs.h. */
13841 _ACEOF
13842 cat confdefs.h >>conftest.$ac_ext
13843 cat >>conftest.$ac_ext <<_ACEOF
13844 /* end confdefs.h. */
13845 $ac_includes_default
13846 int
13847 main ()
13848 {
13849 static struct stat ac_aggr;
13850 if (ac_aggr.st_rdev)
13851 return 0;
13852 ;
13853 return 0;
13854 }
13855 _ACEOF
13856 rm -f conftest.$ac_objext
13857 if { (ac_try="$ac_compile"
13858 case "(($ac_try" in
13859 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13860 *) ac_try_echo=$ac_try;;
13861 esac
13862 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13863 (eval "$ac_compile") 2>conftest.er1
13864 ac_status=$?
13865 grep -v '^ *+' conftest.er1 >conftest.err
13866 rm -f conftest.er1
13867 cat conftest.err >&5
13868 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13869 (exit $ac_status); } && {
13870 test -z "$ac_c_werror_flag" ||
13871 test ! -s conftest.err
13872 } && test -s conftest.$ac_objext; then
13873 ac_cv_member_struct_stat_st_rdev=yes
13874 else
13875 echo "$as_me: failed program was:" >&5
13876 sed 's/^/| /' conftest.$ac_ext >&5
13877
13878 cat >conftest.$ac_ext <<_ACEOF
13879 /* confdefs.h. */
13880 _ACEOF
13881 cat confdefs.h >>conftest.$ac_ext
13882 cat >>conftest.$ac_ext <<_ACEOF
13883 /* end confdefs.h. */
13884 $ac_includes_default
13885 int
13886 main ()
13887 {
13888 static struct stat ac_aggr;
13889 if (sizeof ac_aggr.st_rdev)
13890 return 0;
13891 ;
13892 return 0;
13893 }
13894 _ACEOF
13895 rm -f conftest.$ac_objext
13896 if { (ac_try="$ac_compile"
13897 case "(($ac_try" in
13898 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
13899 *) ac_try_echo=$ac_try;;
13900 esac
13901 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
13902 (eval "$ac_compile") 2>conftest.er1
13903 ac_status=$?
13904 grep -v '^ *+' conftest.er1 >conftest.err
13905 rm -f conftest.er1
13906 cat conftest.err >&5
13907 echo "$as_me:$LINENO: \$? = $ac_status" >&5
13908 (exit $ac_status); } && {
13909 test -z "$ac_c_werror_flag" ||
13910 test ! -s conftest.err
13911 } && test -s conftest.$ac_objext; then
13912 ac_cv_member_struct_stat_st_rdev=yes
13913 else
13914 echo "$as_me: failed program was:" >&5
13915 sed 's/^/| /' conftest.$ac_ext >&5
13916
13917 ac_cv_member_struct_stat_st_rdev=no
13918 fi
13919
13920 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13921 fi
13922
13923 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13924 fi
13925 { echo "$as_me:$LINENO: result: $ac_cv_member_struct_stat_st_rdev" >&5
13926 echo "${ECHO_T}$ac_cv_member_struct_stat_st_rdev" >&6; }
13927 if test $ac_cv_member_struct_stat_st_rdev = yes; then
13928
13929 cat >>confdefs.h <<_ACEOF
13930 #define HAVE_STRUCT_STAT_ST_RDEV 1
13931 _ACEOF
13932
13933
13934 cat >>confdefs.h <<\_ACEOF
13935 #define HAVE_ST_RDEV 1
13936 _ACEOF
13937
13938 fi
13939
13940
13941
13942
13943 # Specific headers that I plan to use
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979 for ac_header in arpa/inet.h assert.h ctype.h dmalloc.h err.h errno.h fcntl.h getopt.h inttypes.h linux/fs.h malloc.h ncurses/term.h netinet/in.h signal.h stdio.h stdlib.h string.h sys/cdefs.h sys/disk.h sys/file.h sys/ioctl.h sys/ioctl.h sys/param.h sys/param.h sys/socket.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/vfs.h sysexits.h term.h time.h unistd.h zlib.h
13980 do
13981 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
13982 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
13983 { echo "$as_me:$LINENO: checking for $ac_header" >&5
13984 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
13985 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
13986 echo $ECHO_N "(cached) $ECHO_C" >&6
13987 fi
13988 ac_res=`eval echo '${'$as_ac_Header'}'`
13989 { echo "$as_me:$LINENO: result: $ac_res" >&5
13990 echo "${ECHO_T}$ac_res" >&6; }
13991 else
13992 # Is the header compilable?
13993 { echo "$as_me:$LINENO: checking $ac_header usability" >&5
13994 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
13995 cat >conftest.$ac_ext <<_ACEOF
13996 /* confdefs.h. */
13997 _ACEOF
13998 cat confdefs.h >>conftest.$ac_ext
13999 cat >>conftest.$ac_ext <<_ACEOF
14000 /* end confdefs.h. */
14001 $ac_includes_default
14002 #include <$ac_header>
14003 _ACEOF
14004 rm -f conftest.$ac_objext
14005 if { (ac_try="$ac_compile"
14006 case "(($ac_try" in
14007 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14008 *) ac_try_echo=$ac_try;;
14009 esac
14010 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14011 (eval "$ac_compile") 2>conftest.er1
14012 ac_status=$?
14013 grep -v '^ *+' conftest.er1 >conftest.err
14014 rm -f conftest.er1
14015 cat conftest.err >&5
14016 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14017 (exit $ac_status); } && {
14018 test -z "$ac_c_werror_flag" ||
14019 test ! -s conftest.err
14020 } && test -s conftest.$ac_objext; then
14021 ac_header_compiler=yes
14022 else
14023 echo "$as_me: failed program was:" >&5
14024 sed 's/^/| /' conftest.$ac_ext >&5
14025
14026 ac_header_compiler=no
14027 fi
14028
14029 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14030 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
14031 echo "${ECHO_T}$ac_header_compiler" >&6; }
14032
14033 # Is the header present?
14034 { echo "$as_me:$LINENO: checking $ac_header presence" >&5
14035 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
14036 cat >conftest.$ac_ext <<_ACEOF
14037 /* confdefs.h. */
14038 _ACEOF
14039 cat confdefs.h >>conftest.$ac_ext
14040 cat >>conftest.$ac_ext <<_ACEOF
14041 /* end confdefs.h. */
14042 #include <$ac_header>
14043 _ACEOF
14044 if { (ac_try="$ac_cpp conftest.$ac_ext"
14045 case "(($ac_try" in
14046 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14047 *) ac_try_echo=$ac_try;;
14048 esac
14049 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14050 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
14051 ac_status=$?
14052 grep -v '^ *+' conftest.er1 >conftest.err
14053 rm -f conftest.er1
14054 cat conftest.err >&5
14055 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14056 (exit $ac_status); } >/dev/null && {
14057 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
14058 test ! -s conftest.err
14059 }; then
14060 ac_header_preproc=yes
14061 else
14062 echo "$as_me: failed program was:" >&5
14063 sed 's/^/| /' conftest.$ac_ext >&5
14064
14065 ac_header_preproc=no
14066 fi
14067
14068 rm -f conftest.err conftest.$ac_ext
14069 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
14070 echo "${ECHO_T}$ac_header_preproc" >&6; }
14071
14072 # So? What about this header?
14073 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
14074 yes:no: )
14075 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
14076 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
14077 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
14078 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
14079 ac_header_preproc=yes
14080 ;;
14081 no:yes:* )
14082 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
14083 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
14084 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
14085 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
14086 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
14087 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
14088 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
14089 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
14090 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
14091 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
14092 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
14093 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
14094 ( cat <<\_ASBOX
14095 ## ------------------------------ ##
14096 ## Report this to bugs@afflib.org ##
14097 ## ------------------------------ ##
14098 _ASBOX
14099 ) | sed "s/^/$as_me: WARNING: /" >&2
14100 ;;
14101 esac
14102 { echo "$as_me:$LINENO: checking for $ac_header" >&5
14103 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
14104 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
14105 echo $ECHO_N "(cached) $ECHO_C" >&6
14106 else
14107 eval "$as_ac_Header=\$ac_header_preproc"
14108 fi
14109 ac_res=`eval echo '${'$as_ac_Header'}'`
14110 { echo "$as_me:$LINENO: result: $ac_res" >&5
14111 echo "${ECHO_T}$ac_res" >&6; }
14112
14113 fi
14114 if test `eval echo '${'$as_ac_Header'}'` = yes; then
14115 cat >>confdefs.h <<_ACEOF
14116 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
14117 _ACEOF
14118
14119 fi
14120
14121 done
14122
14123
14124 { echo "$as_me:$LINENO: checking for struct sockaddr_in.sin_len" >&5
14125 echo $ECHO_N "checking for struct sockaddr_in.sin_len... $ECHO_C" >&6; }
14126 if test "${ac_cv_member_struct_sockaddr_in_sin_len+set}" = set; then
14127 echo $ECHO_N "(cached) $ECHO_C" >&6
14128 else
14129 cat >conftest.$ac_ext <<_ACEOF
14130 /* confdefs.h. */
14131 _ACEOF
14132 cat confdefs.h >>conftest.$ac_ext
14133 cat >>conftest.$ac_ext <<_ACEOF
14134 /* end confdefs.h. */
14135
14136 #include <sys/types.h>
14137 #include <sys/socket.h>
14138 #include <netinet/in.h>
14139
14140
14141 int
14142 main ()
14143 {
14144 static struct sockaddr_in ac_aggr;
14145 if (ac_aggr.sin_len)
14146 return 0;
14147 ;
14148 return 0;
14149 }
14150 _ACEOF
14151 rm -f conftest.$ac_objext
14152 if { (ac_try="$ac_compile"
14153 case "(($ac_try" in
14154 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14155 *) ac_try_echo=$ac_try;;
14156 esac
14157 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14158 (eval "$ac_compile") 2>conftest.er1
14159 ac_status=$?
14160 grep -v '^ *+' conftest.er1 >conftest.err
14161 rm -f conftest.er1
14162 cat conftest.err >&5
14163 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14164 (exit $ac_status); } && {
14165 test -z "$ac_c_werror_flag" ||
14166 test ! -s conftest.err
14167 } && test -s conftest.$ac_objext; then
14168 ac_cv_member_struct_sockaddr_in_sin_len=yes
14169 else
14170 echo "$as_me: failed program was:" >&5
14171 sed 's/^/| /' conftest.$ac_ext >&5
14172
14173 cat >conftest.$ac_ext <<_ACEOF
14174 /* confdefs.h. */
14175 _ACEOF
14176 cat confdefs.h >>conftest.$ac_ext
14177 cat >>conftest.$ac_ext <<_ACEOF
14178 /* end confdefs.h. */
14179
14180 #include <sys/types.h>
14181 #include <sys/socket.h>
14182 #include <netinet/in.h>
14183
14184
14185 int
14186 main ()
14187 {
14188 static struct sockaddr_in ac_aggr;
14189 if (sizeof ac_aggr.sin_len)
14190 return 0;
14191 ;
14192 return 0;
14193 }
14194 _ACEOF
14195 rm -f conftest.$ac_objext
14196 if { (ac_try="$ac_compile"
14197 case "(($ac_try" in
14198 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14199 *) ac_try_echo=$ac_try;;
14200 esac
14201 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14202 (eval "$ac_compile") 2>conftest.er1
14203 ac_status=$?
14204 grep -v '^ *+' conftest.er1 >conftest.err
14205 rm -f conftest.er1
14206 cat conftest.err >&5
14207 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14208 (exit $ac_status); } && {
14209 test -z "$ac_c_werror_flag" ||
14210 test ! -s conftest.err
14211 } && test -s conftest.$ac_objext; then
14212 ac_cv_member_struct_sockaddr_in_sin_len=yes
14213 else
14214 echo "$as_me: failed program was:" >&5
14215 sed 's/^/| /' conftest.$ac_ext >&5
14216
14217 ac_cv_member_struct_sockaddr_in_sin_len=no
14218 fi
14219
14220 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14221 fi
14222
14223 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14224 fi
14225 { echo "$as_me:$LINENO: result: $ac_cv_member_struct_sockaddr_in_sin_len" >&5
14226 echo "${ECHO_T}$ac_cv_member_struct_sockaddr_in_sin_len" >&6; }
14227 if test $ac_cv_member_struct_sockaddr_in_sin_len = yes; then
14228
14229 cat >>confdefs.h <<\_ACEOF
14230 #define HAVE_SOCKADDR_SIN_LEN 1
14231 _ACEOF
14232
14233 fi
14234
14235
14236
14237 # Specific functions that we want to know about
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268 for ac_func in getprogname strlcpy strlcat err_set_exit srandom srandomdev flock fstatfs valloc isdigit isalnum isalphanum isatty popen ftruncate memset mkdir putenv regcomp srandomdev strcasecmp strchr strdup strerror strrchr err errx warn warnx utimes
14269 do
14270 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
14271 { echo "$as_me:$LINENO: checking for $ac_func" >&5
14272 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
14273 if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
14274 echo $ECHO_N "(cached) $ECHO_C" >&6
14275 else
14276 cat >conftest.$ac_ext <<_ACEOF
14277 /* confdefs.h. */
14278 _ACEOF
14279 cat confdefs.h >>conftest.$ac_ext
14280 cat >>conftest.$ac_ext <<_ACEOF
14281 /* end confdefs.h. */
14282 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
14283 For example, HP-UX 11i <limits.h> declares gettimeofday. */
14284 #define $ac_func innocuous_$ac_func
14285
14286 /* System header to define __stub macros and hopefully few prototypes,
14287 which can conflict with char $ac_func (); below.
14288 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
14289 <limits.h> exists even on freestanding compilers. */
14290
14291 #ifdef __STDC__
14292 # include <limits.h>
14293 #else
14294 # include <assert.h>
14295 #endif
14296
14297 #undef $ac_func
14298
14299 /* Override any GCC internal prototype to avoid an error.
14300 Use char because int might match the return type of a GCC
14301 builtin and then its argument prototype would still apply. */
14302 #ifdef __cplusplus
14303 extern "C"
14304 #endif
14305 char $ac_func ();
14306 /* The GNU C library defines this for functions which it implements
14307 to always fail with ENOSYS. Some functions are actually named
14308 something starting with __ and the normal name is an alias. */
14309 #if defined __stub_$ac_func || defined __stub___$ac_func
14310 choke me
14311 #endif
14312
14313 int
14314 main ()
14315 {
14316 return $ac_func ();
14317 ;
14318 return 0;
14319 }
14320 _ACEOF
14321 rm -f conftest.$ac_objext conftest$ac_exeext
14322 if { (ac_try="$ac_link"
14323 case "(($ac_try" in
14324 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14325 *) ac_try_echo=$ac_try;;
14326 esac
14327 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14328 (eval "$ac_link") 2>conftest.er1
14329 ac_status=$?
14330 grep -v '^ *+' conftest.er1 >conftest.err
14331 rm -f conftest.er1
14332 cat conftest.err >&5
14333 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14334 (exit $ac_status); } && {
14335 test -z "$ac_c_werror_flag" ||
14336 test ! -s conftest.err
14337 } && test -s conftest$ac_exeext &&
14338 $as_test_x conftest$ac_exeext; then
14339 eval "$as_ac_var=yes"
14340 else
14341 echo "$as_me: failed program was:" >&5
14342 sed 's/^/| /' conftest.$ac_ext >&5
14343
14344 eval "$as_ac_var=no"
14345 fi
14346
14347 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
14348 conftest$ac_exeext conftest.$ac_ext
14349 fi
14350 ac_res=`eval echo '${'$as_ac_var'}'`
14351 { echo "$as_me:$LINENO: result: $ac_res" >&5
14352 echo "${ECHO_T}$ac_res" >&6; }
14353 if test `eval echo '${'$as_ac_var'}'` = yes; then
14354 cat >>confdefs.h <<_ACEOF
14355 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
14356 _ACEOF
14357
14358 fi
14359 done
14360
14361
14362 # Special features that can be enabled or disabled
14363
14364 # Check whether --with-noopt was given.
14365 if test "${with_noopt+set}" = set; then
14366 withval=$with_noopt;
14367 fi
14368
14369
14370 # C++ headers
14371 ac_ext=cpp
14372 ac_cpp='$CXXCPP $CPPFLAGS'
14373 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
14374 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
14375 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
14376 if test -z "$CXX"; then
14377 if test -n "$CCC"; then
14378 CXX=$CCC
14379 else
14380 if test -n "$ac_tool_prefix"; then
14381 for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
14382 do
14383 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
14384 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
14385 { echo "$as_me:$LINENO: checking for $ac_word" >&5
14386 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
14387 if test "${ac_cv_prog_CXX+set}" = set; then
14388 echo $ECHO_N "(cached) $ECHO_C" >&6
14389 else
14390 if test -n "$CXX"; then
14391 ac_cv_prog_CXX="$CXX" # Let the user override the test.
14392 else
14393 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14394 for as_dir in $PATH
14395 do
14396 IFS=$as_save_IFS
14397 test -z "$as_dir" && as_dir=.
14398 for ac_exec_ext in '' $ac_executable_extensions; do
14399 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
14400 ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
14401 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
14402 break 2
14403 fi
14404 done
14405 done
14406 IFS=$as_save_IFS
14407
14408 fi
14409 fi
14410 CXX=$ac_cv_prog_CXX
14411 if test -n "$CXX"; then
14412 { echo "$as_me:$LINENO: result: $CXX" >&5
14413 echo "${ECHO_T}$CXX" >&6; }
14414 else
14415 { echo "$as_me:$LINENO: result: no" >&5
14416 echo "${ECHO_T}no" >&6; }
14417 fi
14418
14419
14420 test -n "$CXX" && break
14421 done
14422 fi
14423 if test -z "$CXX"; then
14424 ac_ct_CXX=$CXX
14425 for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
14426 do
14427 # Extract the first word of "$ac_prog", so it can be a program name with args.
14428 set dummy $ac_prog; ac_word=$2
14429 { echo "$as_me:$LINENO: checking for $ac_word" >&5
14430 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
14431 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
14432 echo $ECHO_N "(cached) $ECHO_C" >&6
14433 else
14434 if test -n "$ac_ct_CXX"; then
14435 ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
14436 else
14437 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14438 for as_dir in $PATH
14439 do
14440 IFS=$as_save_IFS
14441 test -z "$as_dir" && as_dir=.
14442 for ac_exec_ext in '' $ac_executable_extensions; do
14443 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
14444 ac_cv_prog_ac_ct_CXX="$ac_prog"
14445 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
14446 break 2
14447 fi
14448 done
14449 done
14450 IFS=$as_save_IFS
14451
14452 fi
14453 fi
14454 ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
14455 if test -n "$ac_ct_CXX"; then
14456 { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
14457 echo "${ECHO_T}$ac_ct_CXX" >&6; }
14458 else
14459 { echo "$as_me:$LINENO: result: no" >&5
14460 echo "${ECHO_T}no" >&6; }
14461 fi
14462
14463
14464 test -n "$ac_ct_CXX" && break
14465 done
14466
14467 if test "x$ac_ct_CXX" = x; then
14468 CXX="g++"
14469 else
14470 case $cross_compiling:$ac_tool_warned in
14471 yes:)
14472 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
14473 whose name does not start with the host triplet. If you think this
14474 configuration is useful to you, please write to autoconf@gnu.org." >&5
14475 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
14476 whose name does not start with the host triplet. If you think this
14477 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
14478 ac_tool_warned=yes ;;
14479 esac
14480 CXX=$ac_ct_CXX
14481 fi
14482 fi
14483
14484 fi
14485 fi
14486 # Provide some information about the compiler.
14487 echo "$as_me:$LINENO: checking for C++ compiler version" >&5
14488 ac_compiler=`set X $ac_compile; echo $2`
14489 { (ac_try="$ac_compiler --version >&5"
14490 case "(($ac_try" in
14491 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14492 *) ac_try_echo=$ac_try;;
14493 esac
14494 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14495 (eval "$ac_compiler --version >&5") 2>&5
14496 ac_status=$?
14497 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14498 (exit $ac_status); }
14499 { (ac_try="$ac_compiler -v >&5"
14500 case "(($ac_try" in
14501 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14502 *) ac_try_echo=$ac_try;;
14503 esac
14504 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14505 (eval "$ac_compiler -v >&5") 2>&5
14506 ac_status=$?
14507 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14508 (exit $ac_status); }
14509 { (ac_try="$ac_compiler -V >&5"
14510 case "(($ac_try" in
14511 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14512 *) ac_try_echo=$ac_try;;
14513 esac
14514 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14515 (eval "$ac_compiler -V >&5") 2>&5
14516 ac_status=$?
14517 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14518 (exit $ac_status); }
14519
14520 { echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
14521 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; }
14522 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
14523 echo $ECHO_N "(cached) $ECHO_C" >&6
14524 else
14525 cat >conftest.$ac_ext <<_ACEOF
14526 /* confdefs.h. */
14527 _ACEOF
14528 cat confdefs.h >>conftest.$ac_ext
14529 cat >>conftest.$ac_ext <<_ACEOF
14530 /* end confdefs.h. */
14531
14532 int
14533 main ()
14534 {
14535 #ifndef __GNUC__
14536 choke me
14537 #endif
14538
14539 ;
14540 return 0;
14541 }
14542 _ACEOF
14543 rm -f conftest.$ac_objext
14544 if { (ac_try="$ac_compile"
14545 case "(($ac_try" in
14546 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14547 *) ac_try_echo=$ac_try;;
14548 esac
14549 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14550 (eval "$ac_compile") 2>conftest.er1
14551 ac_status=$?
14552 grep -v '^ *+' conftest.er1 >conftest.err
14553 rm -f conftest.er1
14554 cat conftest.err >&5
14555 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14556 (exit $ac_status); } && {
14557 test -z "$ac_cxx_werror_flag" ||
14558 test ! -s conftest.err
14559 } && test -s conftest.$ac_objext; then
14560 ac_compiler_gnu=yes
14561 else
14562 echo "$as_me: failed program was:" >&5
14563 sed 's/^/| /' conftest.$ac_ext >&5
14564
14565 ac_compiler_gnu=no
14566 fi
14567
14568 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14569 ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
14570
14571 fi
14572 { echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
14573 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
14574 GXX=`test $ac_compiler_gnu = yes && echo yes`
14575 ac_test_CXXFLAGS=${CXXFLAGS+set}
14576 ac_save_CXXFLAGS=$CXXFLAGS
14577 { echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
14578 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
14579 if test "${ac_cv_prog_cxx_g+set}" = set; then
14580 echo $ECHO_N "(cached) $ECHO_C" >&6
14581 else
14582 ac_save_cxx_werror_flag=$ac_cxx_werror_flag
14583 ac_cxx_werror_flag=yes
14584 ac_cv_prog_cxx_g=no
14585 CXXFLAGS="-g"
14586 cat >conftest.$ac_ext <<_ACEOF
14587 /* confdefs.h. */
14588 _ACEOF
14589 cat confdefs.h >>conftest.$ac_ext
14590 cat >>conftest.$ac_ext <<_ACEOF
14591 /* end confdefs.h. */
14592
14593 int
14594 main ()
14595 {
14596
14597 ;
14598 return 0;
14599 }
14600 _ACEOF
14601 rm -f conftest.$ac_objext
14602 if { (ac_try="$ac_compile"
14603 case "(($ac_try" in
14604 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14605 *) ac_try_echo=$ac_try;;
14606 esac
14607 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14608 (eval "$ac_compile") 2>conftest.er1
14609 ac_status=$?
14610 grep -v '^ *+' conftest.er1 >conftest.err
14611 rm -f conftest.er1
14612 cat conftest.err >&5
14613 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14614 (exit $ac_status); } && {
14615 test -z "$ac_cxx_werror_flag" ||
14616 test ! -s conftest.err
14617 } && test -s conftest.$ac_objext; then
14618 ac_cv_prog_cxx_g=yes
14619 else
14620 echo "$as_me: failed program was:" >&5
14621 sed 's/^/| /' conftest.$ac_ext >&5
14622
14623 CXXFLAGS=""
14624 cat >conftest.$ac_ext <<_ACEOF
14625 /* confdefs.h. */
14626 _ACEOF
14627 cat confdefs.h >>conftest.$ac_ext
14628 cat >>conftest.$ac_ext <<_ACEOF
14629 /* end confdefs.h. */
14630
14631 int
14632 main ()
14633 {
14634
14635 ;
14636 return 0;
14637 }
14638 _ACEOF
14639 rm -f conftest.$ac_objext
14640 if { (ac_try="$ac_compile"
14641 case "(($ac_try" in
14642 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14643 *) ac_try_echo=$ac_try;;
14644 esac
14645 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14646 (eval "$ac_compile") 2>conftest.er1
14647 ac_status=$?
14648 grep -v '^ *+' conftest.er1 >conftest.err
14649 rm -f conftest.er1
14650 cat conftest.err >&5
14651 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14652 (exit $ac_status); } && {
14653 test -z "$ac_cxx_werror_flag" ||
14654 test ! -s conftest.err
14655 } && test -s conftest.$ac_objext; then
14656 :
14657 else
14658 echo "$as_me: failed program was:" >&5
14659 sed 's/^/| /' conftest.$ac_ext >&5
14660
14661 ac_cxx_werror_flag=$ac_save_cxx_werror_flag
14662 CXXFLAGS="-g"
14663 cat >conftest.$ac_ext <<_ACEOF
14664 /* confdefs.h. */
14665 _ACEOF
14666 cat confdefs.h >>conftest.$ac_ext
14667 cat >>conftest.$ac_ext <<_ACEOF
14668 /* end confdefs.h. */
14669
14670 int
14671 main ()
14672 {
14673
14674 ;
14675 return 0;
14676 }
14677 _ACEOF
14678 rm -f conftest.$ac_objext
14679 if { (ac_try="$ac_compile"
14680 case "(($ac_try" in
14681 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14682 *) ac_try_echo=$ac_try;;
14683 esac
14684 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14685 (eval "$ac_compile") 2>conftest.er1
14686 ac_status=$?
14687 grep -v '^ *+' conftest.er1 >conftest.err
14688 rm -f conftest.er1
14689 cat conftest.err >&5
14690 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14691 (exit $ac_status); } && {
14692 test -z "$ac_cxx_werror_flag" ||
14693 test ! -s conftest.err
14694 } && test -s conftest.$ac_objext; then
14695 ac_cv_prog_cxx_g=yes
14696 else
14697 echo "$as_me: failed program was:" >&5
14698 sed 's/^/| /' conftest.$ac_ext >&5
14699
14700
14701 fi
14702
14703 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14704 fi
14705
14706 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14707 fi
14708
14709 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14710 ac_cxx_werror_flag=$ac_save_cxx_werror_flag
14711 fi
14712 { echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
14713 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
14714 if test "$ac_test_CXXFLAGS" = set; then
14715 CXXFLAGS=$ac_save_CXXFLAGS
14716 elif test $ac_cv_prog_cxx_g = yes; then
14717 if test "$GXX" = yes; then
14718 CXXFLAGS="-g -O2"
14719 else
14720 CXXFLAGS="-g"
14721 fi
14722 else
14723 if test "$GXX" = yes; then
14724 CXXFLAGS="-O2"
14725 else
14726 CXXFLAGS=
14727 fi
14728 fi
14729 ac_ext=c
14730 ac_cpp='$CPP $CPPFLAGS'
14731 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
14732 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
14733 ac_compiler_gnu=$ac_cv_c_compiler_gnu
14734
14735 depcc="$CXX" am_compiler_list=
14736
14737 { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
14738 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; }
14739 if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
14740 echo $ECHO_N "(cached) $ECHO_C" >&6
14741 else
14742 if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
14743 # We make a subdir and do the tests there. Otherwise we can end up
14744 # making bogus files that we don't know about and never remove. For
14745 # instance it was reported that on HP-UX the gcc test will end up
14746 # making a dummy file named `D' -- because `-MD' means `put the output
14747 # in D'.
14748 mkdir conftest.dir
14749 # Copy depcomp to subdir because otherwise we won't find it if we're
14750 # using a relative directory.
14751 cp "$am_depcomp" conftest.dir
14752 cd conftest.dir
14753 # We will build objects and dependencies in a subdirectory because
14754 # it helps to detect inapplicable dependency modes. For instance
14755 # both Tru64's cc and ICC support -MD to output dependencies as a
14756 # side effect of compilation, but ICC will put the dependencies in
14757 # the current directory while Tru64 will put them in the object
14758 # directory.
14759 mkdir sub
14760
14761 am_cv_CXX_dependencies_compiler_type=none
14762 if test "$am_compiler_list" = ""; then
14763 am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
14764 fi
14765 for depmode in $am_compiler_list; do
14766 # Setup a source with many dependencies, because some compilers
14767 # like to wrap large dependency lists on column 80 (with \), and
14768 # we should not choose a depcomp mode which is confused by this.
14769 #
14770 # We need to recreate these files for each test, as the compiler may
14771 # overwrite some of them when testing with obscure command lines.
14772 # This happens at least with the AIX C compiler.
14773 : > sub/conftest.c
14774 for i in 1 2 3 4 5 6; do
14775 echo '#include "conftst'$i'.h"' >> sub/conftest.c
14776 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
14777 # Solaris 8's {/usr,}/bin/sh.
14778 touch sub/conftst$i.h
14779 done
14780 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
14781
14782 case $depmode in
14783 nosideeffect)
14784 # after this tag, mechanisms are not by side-effect, so they'll
14785 # only be used when explicitly requested
14786 if test "x$enable_dependency_tracking" = xyes; then
14787 continue
14788 else
14789 break
14790 fi
14791 ;;
14792 none) break ;;
14793 esac
14794 # We check with `-c' and `-o' for the sake of the "dashmstdout"
14795 # mode. It turns out that the SunPro C++ compiler does not properly
14796 # handle `-M -o', and we need to detect this.
14797 if depmode=$depmode \
14798 source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
14799 depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
14800 $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
14801 >/dev/null 2>conftest.err &&
14802 grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
14803 grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
14804 grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
14805 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
14806 # icc doesn't choke on unknown options, it will just issue warnings
14807 # or remarks (even with -Werror). So we grep stderr for any message
14808 # that says an option was ignored or not supported.
14809 # When given -MP, icc 7.0 and 7.1 complain thusly:
14810 # icc: Command line warning: ignoring option '-M'; no argument required
14811 # The diagnosis changed in icc 8.0:
14812 # icc: Command line remark: option '-MP' not supported
14813 if (grep 'ignoring option' conftest.err ||
14814 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
14815 am_cv_CXX_dependencies_compiler_type=$depmode
14816 break
14817 fi
14818 fi
14819 done
14820
14821 cd ..
14822 rm -rf conftest.dir
14823 else
14824 am_cv_CXX_dependencies_compiler_type=none
14825 fi
14826
14827 fi
14828 { echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
14829 echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; }
14830 CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
14831
14832 if
14833 test "x$enable_dependency_tracking" != xno \
14834 && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
14835 am__fastdepCXX_TRUE=
14836 am__fastdepCXX_FALSE='#'
14837 else
14838 am__fastdepCXX_TRUE='#'
14839 am__fastdepCXX_FALSE=
14840 fi
14841
14842
14843
14844 ac_ext=cpp
14845 ac_cpp='$CXXCPP $CPPFLAGS'
14846 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
14847 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
14848 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
14849 if test -z "$CXX"; then
14850 if test -n "$CCC"; then
14851 CXX=$CCC
14852 else
14853 if test -n "$ac_tool_prefix"; then
14854 for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
14855 do
14856 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
14857 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
14858 { echo "$as_me:$LINENO: checking for $ac_word" >&5
14859 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
14860 if test "${ac_cv_prog_CXX+set}" = set; then
14861 echo $ECHO_N "(cached) $ECHO_C" >&6
14862 else
14863 if test -n "$CXX"; then
14864 ac_cv_prog_CXX="$CXX" # Let the user override the test.
14865 else
14866 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14867 for as_dir in $PATH
14868 do
14869 IFS=$as_save_IFS
14870 test -z "$as_dir" && as_dir=.
14871 for ac_exec_ext in '' $ac_executable_extensions; do
14872 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
14873 ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
14874 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
14875 break 2
14876 fi
14877 done
14878 done
14879 IFS=$as_save_IFS
14880
14881 fi
14882 fi
14883 CXX=$ac_cv_prog_CXX
14884 if test -n "$CXX"; then
14885 { echo "$as_me:$LINENO: result: $CXX" >&5
14886 echo "${ECHO_T}$CXX" >&6; }
14887 else
14888 { echo "$as_me:$LINENO: result: no" >&5
14889 echo "${ECHO_T}no" >&6; }
14890 fi
14891
14892
14893 test -n "$CXX" && break
14894 done
14895 fi
14896 if test -z "$CXX"; then
14897 ac_ct_CXX=$CXX
14898 for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
14899 do
14900 # Extract the first word of "$ac_prog", so it can be a program name with args.
14901 set dummy $ac_prog; ac_word=$2
14902 { echo "$as_me:$LINENO: checking for $ac_word" >&5
14903 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
14904 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
14905 echo $ECHO_N "(cached) $ECHO_C" >&6
14906 else
14907 if test -n "$ac_ct_CXX"; then
14908 ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
14909 else
14910 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
14911 for as_dir in $PATH
14912 do
14913 IFS=$as_save_IFS
14914 test -z "$as_dir" && as_dir=.
14915 for ac_exec_ext in '' $ac_executable_extensions; do
14916 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
14917 ac_cv_prog_ac_ct_CXX="$ac_prog"
14918 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
14919 break 2
14920 fi
14921 done
14922 done
14923 IFS=$as_save_IFS
14924
14925 fi
14926 fi
14927 ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
14928 if test -n "$ac_ct_CXX"; then
14929 { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
14930 echo "${ECHO_T}$ac_ct_CXX" >&6; }
14931 else
14932 { echo "$as_me:$LINENO: result: no" >&5
14933 echo "${ECHO_T}no" >&6; }
14934 fi
14935
14936
14937 test -n "$ac_ct_CXX" && break
14938 done
14939
14940 if test "x$ac_ct_CXX" = x; then
14941 CXX="g++"
14942 else
14943 case $cross_compiling:$ac_tool_warned in
14944 yes:)
14945 { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
14946 whose name does not start with the host triplet. If you think this
14947 configuration is useful to you, please write to autoconf@gnu.org." >&5
14948 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
14949 whose name does not start with the host triplet. If you think this
14950 configuration is useful to you, please write to autoconf@gnu.org." >&2;}
14951 ac_tool_warned=yes ;;
14952 esac
14953 CXX=$ac_ct_CXX
14954 fi
14955 fi
14956
14957 fi
14958 fi
14959 # Provide some information about the compiler.
14960 echo "$as_me:$LINENO: checking for C++ compiler version" >&5
14961 ac_compiler=`set X $ac_compile; echo $2`
14962 { (ac_try="$ac_compiler --version >&5"
14963 case "(($ac_try" in
14964 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14965 *) ac_try_echo=$ac_try;;
14966 esac
14967 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14968 (eval "$ac_compiler --version >&5") 2>&5
14969 ac_status=$?
14970 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14971 (exit $ac_status); }
14972 { (ac_try="$ac_compiler -v >&5"
14973 case "(($ac_try" in
14974 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14975 *) ac_try_echo=$ac_try;;
14976 esac
14977 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14978 (eval "$ac_compiler -v >&5") 2>&5
14979 ac_status=$?
14980 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14981 (exit $ac_status); }
14982 { (ac_try="$ac_compiler -V >&5"
14983 case "(($ac_try" in
14984 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
14985 *) ac_try_echo=$ac_try;;
14986 esac
14987 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
14988 (eval "$ac_compiler -V >&5") 2>&5
14989 ac_status=$?
14990 echo "$as_me:$LINENO: \$? = $ac_status" >&5
14991 (exit $ac_status); }
14992
14993 { echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
14994 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; }
14995 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
14996 echo $ECHO_N "(cached) $ECHO_C" >&6
14997 else
14998 cat >conftest.$ac_ext <<_ACEOF
14999 /* confdefs.h. */
15000 _ACEOF
15001 cat confdefs.h >>conftest.$ac_ext
15002 cat >>conftest.$ac_ext <<_ACEOF
15003 /* end confdefs.h. */
15004
15005 int
15006 main ()
15007 {
15008 #ifndef __GNUC__
15009 choke me
15010 #endif
15011
15012 ;
15013 return 0;
15014 }
15015 _ACEOF
15016 rm -f conftest.$ac_objext
15017 if { (ac_try="$ac_compile"
15018 case "(($ac_try" in
15019 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15020 *) ac_try_echo=$ac_try;;
15021 esac
15022 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15023 (eval "$ac_compile") 2>conftest.er1
15024 ac_status=$?
15025 grep -v '^ *+' conftest.er1 >conftest.err
15026 rm -f conftest.er1
15027 cat conftest.err >&5
15028 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15029 (exit $ac_status); } && {
15030 test -z "$ac_cxx_werror_flag" ||
15031 test ! -s conftest.err
15032 } && test -s conftest.$ac_objext; then
15033 ac_compiler_gnu=yes
15034 else
15035 echo "$as_me: failed program was:" >&5
15036 sed 's/^/| /' conftest.$ac_ext >&5
15037
15038 ac_compiler_gnu=no
15039 fi
15040
15041 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15042 ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
15043
15044 fi
15045 { echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
15046 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
15047 GXX=`test $ac_compiler_gnu = yes && echo yes`
15048 ac_test_CXXFLAGS=${CXXFLAGS+set}
15049 ac_save_CXXFLAGS=$CXXFLAGS
15050 { echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
15051 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
15052 if test "${ac_cv_prog_cxx_g+set}" = set; then
15053 echo $ECHO_N "(cached) $ECHO_C" >&6
15054 else
15055 ac_save_cxx_werror_flag=$ac_cxx_werror_flag
15056 ac_cxx_werror_flag=yes
15057 ac_cv_prog_cxx_g=no
15058 CXXFLAGS="-g"
15059 cat >conftest.$ac_ext <<_ACEOF
15060 /* confdefs.h. */
15061 _ACEOF
15062 cat confdefs.h >>conftest.$ac_ext
15063 cat >>conftest.$ac_ext <<_ACEOF
15064 /* end confdefs.h. */
15065
15066 int
15067 main ()
15068 {
15069
15070 ;
15071 return 0;
15072 }
15073 _ACEOF
15074 rm -f conftest.$ac_objext
15075 if { (ac_try="$ac_compile"
15076 case "(($ac_try" in
15077 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15078 *) ac_try_echo=$ac_try;;
15079 esac
15080 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15081 (eval "$ac_compile") 2>conftest.er1
15082 ac_status=$?
15083 grep -v '^ *+' conftest.er1 >conftest.err
15084 rm -f conftest.er1
15085 cat conftest.err >&5
15086 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15087 (exit $ac_status); } && {
15088 test -z "$ac_cxx_werror_flag" ||
15089 test ! -s conftest.err
15090 } && test -s conftest.$ac_objext; then
15091 ac_cv_prog_cxx_g=yes
15092 else
15093 echo "$as_me: failed program was:" >&5
15094 sed 's/^/| /' conftest.$ac_ext >&5
15095
15096 CXXFLAGS=""
15097 cat >conftest.$ac_ext <<_ACEOF
15098 /* confdefs.h. */
15099 _ACEOF
15100 cat confdefs.h >>conftest.$ac_ext
15101 cat >>conftest.$ac_ext <<_ACEOF
15102 /* end confdefs.h. */
15103
15104 int
15105 main ()
15106 {
15107
15108 ;
15109 return 0;
15110 }
15111 _ACEOF
15112 rm -f conftest.$ac_objext
15113 if { (ac_try="$ac_compile"
15114 case "(($ac_try" in
15115 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15116 *) ac_try_echo=$ac_try;;
15117 esac
15118 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15119 (eval "$ac_compile") 2>conftest.er1
15120 ac_status=$?
15121 grep -v '^ *+' conftest.er1 >conftest.err
15122 rm -f conftest.er1
15123 cat conftest.err >&5
15124 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15125 (exit $ac_status); } && {
15126 test -z "$ac_cxx_werror_flag" ||
15127 test ! -s conftest.err
15128 } && test -s conftest.$ac_objext; then
15129 :
15130 else
15131 echo "$as_me: failed program was:" >&5
15132 sed 's/^/| /' conftest.$ac_ext >&5
15133
15134 ac_cxx_werror_flag=$ac_save_cxx_werror_flag
15135 CXXFLAGS="-g"
15136 cat >conftest.$ac_ext <<_ACEOF
15137 /* confdefs.h. */
15138 _ACEOF
15139 cat confdefs.h >>conftest.$ac_ext
15140 cat >>conftest.$ac_ext <<_ACEOF
15141 /* end confdefs.h. */
15142
15143 int
15144 main ()
15145 {
15146
15147 ;
15148 return 0;
15149 }
15150 _ACEOF
15151 rm -f conftest.$ac_objext
15152 if { (ac_try="$ac_compile"
15153 case "(($ac_try" in
15154 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15155 *) ac_try_echo=$ac_try;;
15156 esac
15157 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15158 (eval "$ac_compile") 2>conftest.er1
15159 ac_status=$?
15160 grep -v '^ *+' conftest.er1 >conftest.err
15161 rm -f conftest.er1
15162 cat conftest.err >&5
15163 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15164 (exit $ac_status); } && {
15165 test -z "$ac_cxx_werror_flag" ||
15166 test ! -s conftest.err
15167 } && test -s conftest.$ac_objext; then
15168 ac_cv_prog_cxx_g=yes
15169 else
15170 echo "$as_me: failed program was:" >&5
15171 sed 's/^/| /' conftest.$ac_ext >&5
15172
15173
15174 fi
15175
15176 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15177 fi
15178
15179 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15180 fi
15181
15182 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
15183 ac_cxx_werror_flag=$ac_save_cxx_werror_flag
15184 fi
15185 { echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
15186 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
15187 if test "$ac_test_CXXFLAGS" = set; then
15188 CXXFLAGS=$ac_save_CXXFLAGS
15189 elif test $ac_cv_prog_cxx_g = yes; then
15190 if test "$GXX" = yes; then
15191 CXXFLAGS="-g -O2"
15192 else
15193 CXXFLAGS="-g"
15194 fi
15195 else
15196 if test "$GXX" = yes; then
15197 CXXFLAGS="-O2"
15198 else
15199 CXXFLAGS=
15200 fi
15201 fi
15202 ac_ext=c
15203 ac_cpp='$CPP $CPPFLAGS'
15204 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15205 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15206 ac_compiler_gnu=$ac_cv_c_compiler_gnu
15207
15208 depcc="$CXX" am_compiler_list=
15209
15210 { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5
15211 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; }
15212 if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then
15213 echo $ECHO_N "(cached) $ECHO_C" >&6
15214 else
15215 if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
15216 # We make a subdir and do the tests there. Otherwise we can end up
15217 # making bogus files that we don't know about and never remove. For
15218 # instance it was reported that on HP-UX the gcc test will end up
15219 # making a dummy file named `D' -- because `-MD' means `put the output
15220 # in D'.
15221 mkdir conftest.dir
15222 # Copy depcomp to subdir because otherwise we won't find it if we're
15223 # using a relative directory.
15224 cp "$am_depcomp" conftest.dir
15225 cd conftest.dir
15226 # We will build objects and dependencies in a subdirectory because
15227 # it helps to detect inapplicable dependency modes. For instance
15228 # both Tru64's cc and ICC support -MD to output dependencies as a
15229 # side effect of compilation, but ICC will put the dependencies in
15230 # the current directory while Tru64 will put them in the object
15231 # directory.
15232 mkdir sub
15233
15234 am_cv_CXX_dependencies_compiler_type=none
15235 if test "$am_compiler_list" = ""; then
15236 am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
15237 fi
15238 for depmode in $am_compiler_list; do
15239 # Setup a source with many dependencies, because some compilers
15240 # like to wrap large dependency lists on column 80 (with \), and
15241 # we should not choose a depcomp mode which is confused by this.
15242 #
15243 # We need to recreate these files for each test, as the compiler may
15244 # overwrite some of them when testing with obscure command lines.
15245 # This happens at least with the AIX C compiler.
15246 : > sub/conftest.c
15247 for i in 1 2 3 4 5 6; do
15248 echo '#include "conftst'$i'.h"' >> sub/conftest.c
15249 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
15250 # Solaris 8's {/usr,}/bin/sh.
15251 touch sub/conftst$i.h
15252 done
15253 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
15254
15255 case $depmode in
15256 nosideeffect)
15257 # after this tag, mechanisms are not by side-effect, so they'll
15258 # only be used when explicitly requested
15259 if test "x$enable_dependency_tracking" = xyes; then
15260 continue
15261 else
15262 break
15263 fi
15264 ;;
15265 none) break ;;
15266 esac
15267 # We check with `-c' and `-o' for the sake of the "dashmstdout"
15268 # mode. It turns out that the SunPro C++ compiler does not properly
15269 # handle `-M -o', and we need to detect this.
15270 if depmode=$depmode \
15271 source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
15272 depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
15273 $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
15274 >/dev/null 2>conftest.err &&
15275 grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
15276 grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
15277 grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
15278 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
15279 # icc doesn't choke on unknown options, it will just issue warnings
15280 # or remarks (even with -Werror). So we grep stderr for any message
15281 # that says an option was ignored or not supported.
15282 # When given -MP, icc 7.0 and 7.1 complain thusly:
15283 # icc: Command line warning: ignoring option '-M'; no argument required
15284 # The diagnosis changed in icc 8.0:
15285 # icc: Command line remark: option '-MP' not supported
15286 if (grep 'ignoring option' conftest.err ||
15287 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
15288 am_cv_CXX_dependencies_compiler_type=$depmode
15289 break
15290 fi
15291 fi
15292 done
15293
15294 cd ..
15295 rm -rf conftest.dir
15296 else
15297 am_cv_CXX_dependencies_compiler_type=none
15298 fi
15299
15300 fi
15301 { echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5
15302 echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; }
15303 CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
15304
15305 if
15306 test "x$enable_dependency_tracking" != xno \
15307 && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
15308 am__fastdepCXX_TRUE=
15309 am__fastdepCXX_FALSE='#'
15310 else
15311 am__fastdepCXX_TRUE='#'
15312 am__fastdepCXX_FALSE=
15313 fi
15314
15315
15316 if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
15317 ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
15318 (test "X$CXX" != "Xg++"))) ; then
15319 ac_ext=cpp
15320 ac_cpp='$CXXCPP $CPPFLAGS'
15321 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15322 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15323 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
15324 { echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5
15325 echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6; }
15326 if test -z "$CXXCPP"; then
15327 if test "${ac_cv_prog_CXXCPP+set}" = set; then
15328 echo $ECHO_N "(cached) $ECHO_C" >&6
15329 else
15330 # Double quotes because CXXCPP needs to be expanded
15331 for CXXCPP in "$CXX -E" "/lib/cpp"
15332 do
15333 ac_preproc_ok=false
15334 for ac_cxx_preproc_warn_flag in '' yes
15335 do
15336 # Use a header file that comes with gcc, so configuring glibc
15337 # with a fresh cross-compiler works.
15338 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
15339 # <limits.h> exists even on freestanding compilers.
15340 # On the NeXT, cc -E runs the code through the compiler's parser,
15341 # not just through cpp. "Syntax error" is here to catch this case.
15342 cat >conftest.$ac_ext <<_ACEOF
15343 /* confdefs.h. */
15344 _ACEOF
15345 cat confdefs.h >>conftest.$ac_ext
15346 cat >>conftest.$ac_ext <<_ACEOF
15347 /* end confdefs.h. */
15348 #ifdef __STDC__
15349 # include <limits.h>
15350 #else
15351 # include <assert.h>
15352 #endif
15353 Syntax error
15354 _ACEOF
15355 if { (ac_try="$ac_cpp conftest.$ac_ext"
15356 case "(($ac_try" in
15357 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15358 *) ac_try_echo=$ac_try;;
15359 esac
15360 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15361 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
15362 ac_status=$?
15363 grep -v '^ *+' conftest.er1 >conftest.err
15364 rm -f conftest.er1
15365 cat conftest.err >&5
15366 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15367 (exit $ac_status); } >/dev/null && {
15368 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
15369 test ! -s conftest.err
15370 }; then
15371 :
15372 else
15373 echo "$as_me: failed program was:" >&5
15374 sed 's/^/| /' conftest.$ac_ext >&5
15375
15376 # Broken: fails on valid input.
15377 continue
15378 fi
15379
15380 rm -f conftest.err conftest.$ac_ext
15381
15382 # OK, works on sane cases. Now check whether nonexistent headers
15383 # can be detected and how.
15384 cat >conftest.$ac_ext <<_ACEOF
15385 /* confdefs.h. */
15386 _ACEOF
15387 cat confdefs.h >>conftest.$ac_ext
15388 cat >>conftest.$ac_ext <<_ACEOF
15389 /* end confdefs.h. */
15390 #include <ac_nonexistent.h>
15391 _ACEOF
15392 if { (ac_try="$ac_cpp conftest.$ac_ext"
15393 case "(($ac_try" in
15394 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15395 *) ac_try_echo=$ac_try;;
15396 esac
15397 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15398 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
15399 ac_status=$?
15400 grep -v '^ *+' conftest.er1 >conftest.err
15401 rm -f conftest.er1
15402 cat conftest.err >&5
15403 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15404 (exit $ac_status); } >/dev/null && {
15405 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
15406 test ! -s conftest.err
15407 }; then
15408 # Broken: success on invalid input.
15409 continue
15410 else
15411 echo "$as_me: failed program was:" >&5
15412 sed 's/^/| /' conftest.$ac_ext >&5
15413
15414 # Passes both tests.
15415 ac_preproc_ok=:
15416 break
15417 fi
15418
15419 rm -f conftest.err conftest.$ac_ext
15420
15421 done
15422 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
15423 rm -f conftest.err conftest.$ac_ext
15424 if $ac_preproc_ok; then
15425 break
15426 fi
15427
15428 done
15429 ac_cv_prog_CXXCPP=$CXXCPP
15430
15431 fi
15432 CXXCPP=$ac_cv_prog_CXXCPP
15433 else
15434 ac_cv_prog_CXXCPP=$CXXCPP
15435 fi
15436 { echo "$as_me:$LINENO: result: $CXXCPP" >&5
15437 echo "${ECHO_T}$CXXCPP" >&6; }
15438 ac_preproc_ok=false
15439 for ac_cxx_preproc_warn_flag in '' yes
15440 do
15441 # Use a header file that comes with gcc, so configuring glibc
15442 # with a fresh cross-compiler works.
15443 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
15444 # <limits.h> exists even on freestanding compilers.
15445 # On the NeXT, cc -E runs the code through the compiler's parser,
15446 # not just through cpp. "Syntax error" is here to catch this case.
15447 cat >conftest.$ac_ext <<_ACEOF
15448 /* confdefs.h. */
15449 _ACEOF
15450 cat confdefs.h >>conftest.$ac_ext
15451 cat >>conftest.$ac_ext <<_ACEOF
15452 /* end confdefs.h. */
15453 #ifdef __STDC__
15454 # include <limits.h>
15455 #else
15456 # include <assert.h>
15457 #endif
15458 Syntax error
15459 _ACEOF
15460 if { (ac_try="$ac_cpp conftest.$ac_ext"
15461 case "(($ac_try" in
15462 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15463 *) ac_try_echo=$ac_try;;
15464 esac
15465 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15466 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
15467 ac_status=$?
15468 grep -v '^ *+' conftest.er1 >conftest.err
15469 rm -f conftest.er1
15470 cat conftest.err >&5
15471 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15472 (exit $ac_status); } >/dev/null && {
15473 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
15474 test ! -s conftest.err
15475 }; then
15476 :
15477 else
15478 echo "$as_me: failed program was:" >&5
15479 sed 's/^/| /' conftest.$ac_ext >&5
15480
15481 # Broken: fails on valid input.
15482 continue
15483 fi
15484
15485 rm -f conftest.err conftest.$ac_ext
15486
15487 # OK, works on sane cases. Now check whether nonexistent headers
15488 # can be detected and how.
15489 cat >conftest.$ac_ext <<_ACEOF
15490 /* confdefs.h. */
15491 _ACEOF
15492 cat confdefs.h >>conftest.$ac_ext
15493 cat >>conftest.$ac_ext <<_ACEOF
15494 /* end confdefs.h. */
15495 #include <ac_nonexistent.h>
15496 _ACEOF
15497 if { (ac_try="$ac_cpp conftest.$ac_ext"
15498 case "(($ac_try" in
15499 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15500 *) ac_try_echo=$ac_try;;
15501 esac
15502 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15503 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
15504 ac_status=$?
15505 grep -v '^ *+' conftest.er1 >conftest.err
15506 rm -f conftest.er1
15507 cat conftest.err >&5
15508 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15509 (exit $ac_status); } >/dev/null && {
15510 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
15511 test ! -s conftest.err
15512 }; then
15513 # Broken: success on invalid input.
15514 continue
15515 else
15516 echo "$as_me: failed program was:" >&5
15517 sed 's/^/| /' conftest.$ac_ext >&5
15518
15519 # Passes both tests.
15520 ac_preproc_ok=:
15521 break
15522 fi
15523
15524 rm -f conftest.err conftest.$ac_ext
15525
15526 done
15527 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
15528 rm -f conftest.err conftest.$ac_ext
15529 if $ac_preproc_ok; then
15530 :
15531 else
15532 _lt_caught_CXX_error=yes
15533 fi
15534
15535 ac_ext=c
15536 ac_cpp='$CPP $CPPFLAGS'
15537 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15538 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15539 ac_compiler_gnu=$ac_cv_c_compiler_gnu
15540
15541 else
15542 _lt_caught_CXX_error=yes
15543 fi
15544
15545
15546
15547
15548 ac_ext=cpp
15549 ac_cpp='$CXXCPP $CPPFLAGS'
15550 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
15551 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
15552 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
15553
15554 archive_cmds_need_lc_CXX=no
15555 allow_undefined_flag_CXX=
15556 always_export_symbols_CXX=no
15557 archive_expsym_cmds_CXX=
15558 compiler_needs_object_CXX=no
15559 export_dynamic_flag_spec_CXX=
15560 hardcode_direct_CXX=no
15561 hardcode_direct_absolute_CXX=no
15562 hardcode_libdir_flag_spec_CXX=
15563 hardcode_libdir_flag_spec_ld_CXX=
15564 hardcode_libdir_separator_CXX=
15565 hardcode_minus_L_CXX=no
15566 hardcode_shlibpath_var_CXX=unsupported
15567 hardcode_automatic_CXX=no
15568 inherit_rpath_CXX=no
15569 module_cmds_CXX=
15570 module_expsym_cmds_CXX=
15571 link_all_deplibs_CXX=unknown
15572 old_archive_cmds_CXX=$old_archive_cmds
15573 no_undefined_flag_CXX=
15574 whole_archive_flag_spec_CXX=
15575 enable_shared_with_static_runtimes_CXX=no
15576
15577 # Source file extension for C++ test sources.
15578 ac_ext=cpp
15579
15580 # Object file extension for compiled C++ test sources.
15581 objext=o
15582 objext_CXX=$objext
15583
15584 # No sense in running all these tests if we already determined that
15585 # the CXX compiler isn't working. Some variables (like enable_shared)
15586 # are currently assumed to apply to all compilers on this platform,
15587 # and will be corrupted by setting them based on a non-working compiler.
15588 if test "$_lt_caught_CXX_error" != yes; then
15589 # Code to be used in simple compile tests
15590 lt_simple_compile_test_code="int some_variable = 0;"
15591
15592 # Code to be used in simple link tests
15593 lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
15594
15595 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
15596
15597
15598
15599
15600
15601
15602 # If no C compiler was specified, use CC.
15603 LTCC=${LTCC-"$CC"}
15604
15605 # If no C compiler flags were specified, use CFLAGS.
15606 LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
15607
15608 # Allow CC to be a program name with arguments.
15609 compiler=$CC
15610
15611
15612 # save warnings/boilerplate of simple test code
15613 ac_outfile=conftest.$ac_objext
15614 echo "$lt_simple_compile_test_code" >conftest.$ac_ext
15615 eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
15616 _lt_compiler_boilerplate=`cat conftest.err`
15617 $RM -r conftest*
15618
15619 ac_outfile=conftest.$ac_objext
15620 echo "$lt_simple_link_test_code" >conftest.$ac_ext
15621 eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
15622 _lt_linker_boilerplate=`cat conftest.err`
15623 $RM -r conftest*
15624
15625
15626 # Allow CC to be a program name with arguments.
15627 lt_save_CC=$CC
15628 lt_save_LD=$LD
15629 lt_save_GCC=$GCC
15630 GCC=$GXX
15631 lt_save_with_gnu_ld=$with_gnu_ld
15632 lt_save_path_LD=$lt_cv_path_LD
15633 if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
15634 lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
15635 else
15636 $as_unset lt_cv_prog_gnu_ld
15637 fi
15638 if test -n "${lt_cv_path_LDCXX+set}"; then
15639 lt_cv_path_LD=$lt_cv_path_LDCXX
15640 else
15641 $as_unset lt_cv_path_LD
15642 fi
15643 test -z "${LDCXX+set}" || LD=$LDCXX
15644 CC=${CXX-"c++"}
15645 compiler=$CC
15646 compiler_CXX=$CC
15647 for cc_temp in $compiler""; do
15648 case $cc_temp in
15649 compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
15650 distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
15651 \-*) ;;
15652 *) break;;
15653 esac
15654 done
15655 cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
15656
15657
15658 if test -n "$compiler"; then
15659 # We don't want -fno-exception when compiling C++ code, so set the
15660 # no_builtin_flag separately
15661 if test "$GXX" = yes; then
15662 lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
15663 else
15664 lt_prog_compiler_no_builtin_flag_CXX=
15665 fi
15666
15667 if test "$GXX" = yes; then
15668 # Set up default GNU C++ configuration
15669
15670
15671
15672 # Check whether --with-gnu-ld was given.
15673 if test "${with_gnu_ld+set}" = set; then
15674 withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
15675 else
15676 with_gnu_ld=no
15677 fi
15678
15679 ac_prog=ld
15680 if test "$GCC" = yes; then
15681 # Check if gcc -print-prog-name=ld gives a path.
15682 { echo "$as_me:$LINENO: checking for ld used by $CC" >&5
15683 echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6; }
15684 case $host in
15685 *-*-mingw*)
15686 # gcc leaves a trailing carriage return which upsets mingw
15687 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
15688 *)
15689 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
15690 esac
15691 case $ac_prog in
15692 # Accept absolute paths.
15693 [\\/]* | ?:[\\/]*)
15694 re_direlt='/[^/][^/]*/\.\./'
15695 # Canonicalize the pathname of ld
15696 ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
15697 while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
15698 ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
15699 done
15700 test -z "$LD" && LD="$ac_prog"
15701 ;;
15702 "")
15703 # If it fails, then pretend we aren't using GCC.
15704 ac_prog=ld
15705 ;;
15706 *)
15707 # If it is relative, then search for the first ld in PATH.
15708 with_gnu_ld=unknown
15709 ;;
15710 esac
15711 elif test "$with_gnu_ld" = yes; then
15712 { echo "$as_me:$LINENO: checking for GNU ld" >&5
15713 echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; }
15714 else
15715 { echo "$as_me:$LINENO: checking for non-GNU ld" >&5
15716 echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; }
15717 fi
15718 if test "${lt_cv_path_LD+set}" = set; then
15719 echo $ECHO_N "(cached) $ECHO_C" >&6
15720 else
15721 if test -z "$LD"; then
15722 lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
15723 for ac_dir in $PATH; do
15724 IFS="$lt_save_ifs"
15725 test -z "$ac_dir" && ac_dir=.
15726 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
15727 lt_cv_path_LD="$ac_dir/$ac_prog"
15728 # Check to see if the program is GNU ld. I'd rather use --version,
15729 # but apparently some variants of GNU ld only accept -v.
15730 # Break only if it was the GNU/non-GNU ld that we prefer.
15731 case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
15732 *GNU* | *'with BFD'*)
15733 test "$with_gnu_ld" != no && break
15734 ;;
15735 *)
15736 test "$with_gnu_ld" != yes && break
15737 ;;
15738 esac
15739 fi
15740 done
15741 IFS="$lt_save_ifs"
15742 else
15743 lt_cv_path_LD="$LD" # Let the user override the test with a path.
15744 fi
15745 fi
15746
15747 LD="$lt_cv_path_LD"
15748 if test -n "$LD"; then
15749 { echo "$as_me:$LINENO: result: $LD" >&5
15750 echo "${ECHO_T}$LD" >&6; }
15751 else
15752 { echo "$as_me:$LINENO: result: no" >&5
15753 echo "${ECHO_T}no" >&6; }
15754 fi
15755 test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
15756 echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
15757 { (exit 1); exit 1; }; }
15758 { echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
15759 echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; }
15760 if test "${lt_cv_prog_gnu_ld+set}" = set; then
15761 echo $ECHO_N "(cached) $ECHO_C" >&6
15762 else
15763 # I'd rather use --version here, but apparently some GNU lds only accept -v.
15764 case `$LD -v 2>&1 </dev/null` in
15765 *GNU* | *'with BFD'*)
15766 lt_cv_prog_gnu_ld=yes
15767 ;;
15768 *)
15769 lt_cv_prog_gnu_ld=no
15770 ;;
15771 esac
15772 fi
15773 { echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
15774 echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6; }
15775 with_gnu_ld=$lt_cv_prog_gnu_ld
15776
15777
15778
15779
15780
15781
15782
15783 # Check if GNU C++ uses GNU ld as the underlying linker, since the
15784 # archiving commands below assume that GNU ld is being used.
15785 if test "$with_gnu_ld" = yes; then
15786 archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
15787 archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
15788
15789 hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
15790 export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
15791
15792 # If archive_cmds runs LD, not CC, wlarc should be empty
15793 # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
15794 # investigate it a little bit more. (MM)
15795 wlarc='${wl}'
15796
15797 # ancient GNU ld didn't support --whole-archive et. al.
15798 if eval "`$CC -print-prog-name=ld` --help 2>&1" |
15799 $GREP 'no-whole-archive' > /dev/null; then
15800 whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
15801 else
15802 whole_archive_flag_spec_CXX=
15803 fi
15804 else
15805 with_gnu_ld=no
15806 wlarc=
15807
15808 # A generic and very simple default shared library creation
15809 # command for GNU C++ for the case where it uses the native
15810 # linker, instead of GNU ld. If possible, this setting should
15811 # overridden to take advantage of the native linker features on
15812 # the platform it is being used on.
15813 archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
15814 fi
15815
15816 # Commands to make compiler produce verbose output that lists
15817 # what "hidden" libraries, object files and flags are used when
15818 # linking a shared library.
15819 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
15820
15821 else
15822 GXX=no
15823 with_gnu_ld=no
15824 wlarc=
15825 fi
15826
15827 # PORTME: fill in a description of your system's C++ link characteristics
15828 { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
15829 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
15830 ld_shlibs_CXX=yes
15831 case $host_os in
15832 aix3*)
15833 # FIXME: insert proper C++ library support
15834 ld_shlibs_CXX=no
15835 ;;
15836 aix[4-9]*)
15837 if test "$host_cpu" = ia64; then
15838 # On IA64, the linker does run time linking by default, so we don't
15839 # have to do anything special.
15840 aix_use_runtimelinking=no
15841 exp_sym_flag='-Bexport'
15842 no_entry_flag=""
15843 else
15844 aix_use_runtimelinking=no
15845
15846 # Test if we are trying to use run time linking or normal
15847 # AIX style linking. If -brtl is somewhere in LDFLAGS, we
15848 # need to do runtime linking.
15849 case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
15850 for ld_flag in $LDFLAGS; do
15851 case $ld_flag in
15852 *-brtl*)
15853 aix_use_runtimelinking=yes
15854 break
15855 ;;
15856 esac
15857 done
15858 ;;
15859 esac
15860
15861 exp_sym_flag='-bexport'
15862 no_entry_flag='-bnoentry'
15863 fi
15864
15865 # When large executables or shared objects are built, AIX ld can
15866 # have problems creating the table of contents. If linking a library
15867 # or program results in "error TOC overflow" add -mminimal-toc to
15868 # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
15869 # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
15870
15871 archive_cmds_CXX=''
15872 hardcode_direct_CXX=yes
15873 hardcode_direct_absolute_CXX=yes
15874 hardcode_libdir_separator_CXX=':'
15875 link_all_deplibs_CXX=yes
15876 file_list_spec_CXX='${wl}-f,'
15877
15878 if test "$GXX" = yes; then
15879 case $host_os in aix4.[012]|aix4.[012].*)
15880 # We only want to do this on AIX 4.2 and lower, the check
15881 # below for broken collect2 doesn't work under 4.3+
15882 collect2name=`${CC} -print-prog-name=collect2`
15883 if test -f "$collect2name" &&
15884 strings "$collect2name" | $GREP resolve_lib_name >/dev/null
15885 then
15886 # We have reworked collect2
15887 :
15888 else
15889 # We have old collect2
15890 hardcode_direct_CXX=unsupported
15891 # It fails to find uninstalled libraries when the uninstalled
15892 # path is not listed in the libpath. Setting hardcode_minus_L
15893 # to unsupported forces relinking
15894 hardcode_minus_L_CXX=yes
15895 hardcode_libdir_flag_spec_CXX='-L$libdir'
15896 hardcode_libdir_separator_CXX=
15897 fi
15898 esac
15899 shared_flag='-shared'
15900 if test "$aix_use_runtimelinking" = yes; then
15901 shared_flag="$shared_flag "'${wl}-G'
15902 fi
15903 else
15904 # not using gcc
15905 if test "$host_cpu" = ia64; then
15906 # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
15907 # chokes on -Wl,-G. The following line is correct:
15908 shared_flag='-G'
15909 else
15910 if test "$aix_use_runtimelinking" = yes; then
15911 shared_flag='${wl}-G'
15912 else
15913 shared_flag='${wl}-bM:SRE'
15914 fi
15915 fi
15916 fi
15917
15918 # It seems that -bexpall does not export symbols beginning with
15919 # underscore (_), so it is better to generate a list of symbols to
15920 # export.
15921 always_export_symbols_CXX=yes
15922 if test "$aix_use_runtimelinking" = yes; then
15923 # Warning - without using the other runtime loading flags (-brtl),
15924 # -berok will link without error, but may produce a broken library.
15925 allow_undefined_flag_CXX='-berok'
15926 # Determine the default libpath from the value encoded in an empty
15927 # executable.
15928 cat >conftest.$ac_ext <<_ACEOF
15929 /* confdefs.h. */
15930 _ACEOF
15931 cat confdefs.h >>conftest.$ac_ext
15932 cat >>conftest.$ac_ext <<_ACEOF
15933 /* end confdefs.h. */
15934
15935 int
15936 main ()
15937 {
15938
15939 ;
15940 return 0;
15941 }
15942 _ACEOF
15943 rm -f conftest.$ac_objext conftest$ac_exeext
15944 if { (ac_try="$ac_link"
15945 case "(($ac_try" in
15946 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
15947 *) ac_try_echo=$ac_try;;
15948 esac
15949 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
15950 (eval "$ac_link") 2>conftest.er1
15951 ac_status=$?
15952 grep -v '^ *+' conftest.er1 >conftest.err
15953 rm -f conftest.er1
15954 cat conftest.err >&5
15955 echo "$as_me:$LINENO: \$? = $ac_status" >&5
15956 (exit $ac_status); } && {
15957 test -z "$ac_cxx_werror_flag" ||
15958 test ! -s conftest.err
15959 } && test -s conftest$ac_exeext &&
15960 $as_test_x conftest$ac_exeext; then
15961
15962 lt_aix_libpath_sed='
15963 /Import File Strings/,/^$/ {
15964 /^0/ {
15965 s/^0 *\(.*\)$/\1/
15966 p
15967 }
15968 }'
15969 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
15970 # Check for a 64-bit object if we didn't find anything.
15971 if test -z "$aix_libpath"; then
15972 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
15973 fi
15974 else
15975 echo "$as_me: failed program was:" >&5
15976 sed 's/^/| /' conftest.$ac_ext >&5
15977
15978
15979 fi
15980
15981 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
15982 conftest$ac_exeext conftest.$ac_ext
15983 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
15984
15985 hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
15986
15987 archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
15988 else
15989 if test "$host_cpu" = ia64; then
15990 hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
15991 allow_undefined_flag_CXX="-z nodefs"
15992 archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
15993 else
15994 # Determine the default libpath from the value encoded in an
15995 # empty executable.
15996 cat >conftest.$ac_ext <<_ACEOF
15997 /* confdefs.h. */
15998 _ACEOF
15999 cat confdefs.h >>conftest.$ac_ext
16000 cat >>conftest.$ac_ext <<_ACEOF
16001 /* end confdefs.h. */
16002
16003 int
16004 main ()
16005 {
16006
16007 ;
16008 return 0;
16009 }
16010 _ACEOF
16011 rm -f conftest.$ac_objext conftest$ac_exeext
16012 if { (ac_try="$ac_link"
16013 case "(($ac_try" in
16014 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
16015 *) ac_try_echo=$ac_try;;
16016 esac
16017 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
16018 (eval "$ac_link") 2>conftest.er1
16019 ac_status=$?
16020 grep -v '^ *+' conftest.er1 >conftest.err
16021 rm -f conftest.er1
16022 cat conftest.err >&5
16023 echo "$as_me:$LINENO: \$? = $ac_status" >&5
16024 (exit $ac_status); } && {
16025 test -z "$ac_cxx_werror_flag" ||
16026 test ! -s conftest.err
16027 } && test -s conftest$ac_exeext &&
16028 $as_test_x conftest$ac_exeext; then
16029
16030 lt_aix_libpath_sed='
16031 /Import File Strings/,/^$/ {
16032 /^0/ {
16033 s/^0 *\(.*\)$/\1/
16034 p
16035 }
16036 }'
16037 aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
16038 # Check for a 64-bit object if we didn't find anything.
16039 if test -z "$aix_libpath"; then
16040 aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
16041 fi
16042 else
16043 echo "$as_me: failed program was:" >&5
16044 sed 's/^/| /' conftest.$ac_ext >&5
16045
16046
16047 fi
16048
16049 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
16050 conftest$ac_exeext conftest.$ac_ext
16051 if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
16052
16053 hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
16054 # Warning - without using the other run time loading flags,
16055 # -berok will link without error, but may produce a broken library.
16056 no_undefined_flag_CXX=' ${wl}-bernotok'
16057 allow_undefined_flag_CXX=' ${wl}-berok'
16058 # Exported symbols can be pulled into shared objects from archives
16059 whole_archive_flag_spec_CXX='$convenience'
16060 archive_cmds_need_lc_CXX=yes
16061 # This is similar to how AIX traditionally builds its shared
16062 # libraries.
16063 archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
16064 fi
16065 fi
16066 ;;
16067
16068 beos*)
16069 if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
16070 allow_undefined_flag_CXX=unsupported
16071 # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
16072 # support --undefined. This deserves some investigation. FIXME
16073 archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
16074 else
16075 ld_shlibs_CXX=no
16076 fi
16077 ;;
16078
16079 chorus*)
16080 case $cc_basename in
16081 *)
16082 # FIXME: insert proper C++ library support
16083 ld_shlibs_CXX=no
16084 ;;
16085 esac
16086 ;;
16087
16088 cygwin* | mingw* | pw32*)
16089 # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
16090 # as there is no search path for DLLs.
16091 hardcode_libdir_flag_spec_CXX='-L$libdir'
16092 allow_undefined_flag_CXX=unsupported
16093 always_export_symbols_CXX=no
16094 enable_shared_with_static_runtimes_CXX=yes
16095
16096 if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
16097 archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
16098 # If the export-symbols file already is a .def file (1st line
16099 # is EXPORTS), use it as is; otherwise, prepend...
16100 archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
16101 cp $export_symbols $output_objdir/$soname.def;
16102 else
16103 echo EXPORTS > $output_objdir/$soname.def;
16104 cat $export_symbols >> $output_objdir/$soname.def;
16105 fi~
16106 $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
16107 else
16108 ld_shlibs_CXX=no
16109 fi
16110 ;;
16111 darwin* | rhapsody*)
16112
16113
16114 archive_cmds_need_lc_CXX=no
16115 hardcode_direct_CXX=no
16116 hardcode_automatic_CXX=yes
16117 hardcode_shlibpath_var_CXX=unsupported
16118 whole_archive_flag_spec_CXX=''
16119 link_all_deplibs_CXX=yes
16120 allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
16121 if test "$GCC" = "yes"; then
16122 output_verbose_link_cmd=echo
16123 archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
16124 module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
16125 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
16126 module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
16127 if test "$lt_cv_apple_cc_single_mod" != "yes"; then
16128 archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
16129 archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
16130 fi
16131
16132 else
16133 ld_shlibs_CXX=no
16134 fi
16135
16136 ;;
16137
16138 dgux*)
16139 case $cc_basename in
16140 ec++*)
16141 # FIXME: insert proper C++ library support
16142 ld_shlibs_CXX=no
16143 ;;
16144 ghcx*)
16145 # Green Hills C++ Compiler
16146 # FIXME: insert proper C++ library support
16147 ld_shlibs_CXX=no
16148 ;;
16149 *)
16150 # FIXME: insert proper C++ library support
16151 ld_shlibs_CXX=no
16152 ;;
16153 esac
16154 ;;
16155
16156 freebsd[12]*)
16157 # C++ shared libraries reported to be fairly broken before
16158 # switch to ELF
16159 ld_shlibs_CXX=no
16160 ;;
16161
16162 freebsd-elf*)
16163 archive_cmds_need_lc_CXX=no
16164 ;;
16165
16166 freebsd* | dragonfly*)
16167 # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
16168 # conventions
16169 ld_shlibs_CXX=yes
16170 ;;
16171
16172 gnu*)
16173 ;;
16174
16175 hpux9*)
16176 hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
16177 hardcode_libdir_separator_CXX=:
16178 export_dynamic_flag_spec_CXX='${wl}-E'
16179 hardcode_direct_CXX=yes
16180 hardcode_minus_L_CXX=yes # Not in the search PATH,
16181 # but as the default
16182 # location of the library.
16183
16184 case $cc_basename in
16185 CC*)
16186 # FIXME: insert proper C++ library support
16187 ld_shlibs_CXX=no
16188 ;;
16189 aCC*)
16190 archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
16191 # Commands to make compiler produce verbose output that lists
16192 # what "hidden" libraries, object files and flags are used when
16193 # linking a shared library.
16194 #
16195 # There doesn't appear to be a way to prevent this compiler from
16196 # explicitly linking system object files so we need to strip them
16197 # from the output so that they don't get included in the library
16198 # dependencies.
16199 output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
16200 ;;
16201 *)
16202 if test "$GXX" = yes; then
16203 archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
16204 else
16205 # FIXME: insert proper C++ library support
16206 ld_shlibs_CXX=no
16207 fi
16208 ;;
16209 esac
16210 ;;
16211
16212 hpux10*|hpux11*)
16213 if test $with_gnu_ld = no; then
16214 hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
16215 hardcode_libdir_separator_CXX=:
16216
16217 case $host_cpu in
16218 hppa*64*|ia64*)
16219 ;;
16220 *)
16221 export_dynamic_flag_spec_CXX='${wl}-E'
16222 ;;
16223 esac
16224 fi
16225 case $host_cpu in
16226 hppa*64*|ia64*)
16227 hardcode_direct_CXX=no
16228 hardcode_shlibpath_var_CXX=no
16229 ;;
16230 *)
16231 hardcode_direct_CXX=yes
16232 hardcode_direct_absolute_CXX=yes
16233 hardcode_minus_L_CXX=yes # Not in the search PATH,
16234 # but as the default
16235 # location of the library.
16236 ;;
16237 esac
16238
16239 case $cc_basename in
16240 CC*)
16241 # FIXME: insert proper C++ library support
16242 ld_shlibs_CXX=no
16243 ;;
16244 aCC*)
16245 case $host_cpu in
16246 hppa*64*)
16247 archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
16248 ;;
16249 ia64*)
16250 archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
16251 ;;
16252 *)
16253 archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
16254 ;;
16255 esac
16256 # Commands to make compiler produce verbose output that lists
16257 # what "hidden" libraries, object files and flags are used when
16258 # linking a shared library.
16259 #
16260 # There doesn't appear to be a way to prevent this compiler from
16261 # explicitly linking system object files so we need to strip them
16262 # from the output so that they don't get included in the library
16263 # dependencies.
16264 output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
16265 ;;
16266 *)
16267 if test "$GXX" = yes; then
16268 if test $with_gnu_ld = no; then
16269 case $host_cpu in
16270 hppa*64*)
16271 archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
16272 ;;
16273 ia64*)
16274 archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
16275 ;;
16276 *)
16277 archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
16278 ;;
16279 esac
16280 fi
16281 else
16282 # FIXME: insert proper C++ library support
16283 ld_shlibs_CXX=no
16284 fi
16285 ;;
16286 esac
16287 ;;
16288
16289 interix[3-9]*)
16290 hardcode_direct_CXX=no
16291 hardcode_shlibpath_var_CXX=no
16292 hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
16293 export_dynamic_flag_spec_CXX='${wl}-E'
16294 # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
16295 # Instead, shared libraries are loaded at an image base (0x10000000 by
16296 # default) and relocated if they conflict, which is a slow very memory
16297 # consuming and fragmenting process. To avoid this, we pick a random,
16298 # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
16299 # time. Moving up from 0x10000000 also allows more sbrk(2) space.
16300 archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
16301 archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
16302 ;;
16303 irix5* | irix6*)
16304 case $cc_basename in
16305 CC*)
16306 # SGI C++
16307 archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
16308
16309 # Archives containing C++ object files must be created using
16310 # "CC -ar", where "CC" is the IRIX C++ compiler. This is
16311 # necessary to make sure instantiated templates are included
16312 # in the archive.
16313 old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
16314 ;;
16315 *)
16316 if test "$GXX" = yes; then
16317 if test "$with_gnu_ld" = no; then
16318 archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
16319 else
16320 archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
16321 fi
16322 fi
16323 link_all_deplibs_CXX=yes
16324 ;;
16325 esac
16326 hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
16327 hardcode_libdir_separator_CXX=:
16328 inherit_rpath_CXX=yes
16329 ;;
16330
16331 linux* | k*bsd*-gnu)
16332 case $cc_basename in
16333 KCC*)
16334 # Kuck and Associates, Inc. (KAI) C++ Compiler
16335
16336 # KCC will only create a shared library if the output file
16337 # ends with ".so" (or ".sl" for HP-UX), so rename the library
16338 # to its proper name (with version) after linking.
16339 archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
16340 archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
16341 # Commands to make compiler produce verbose output that lists
16342 # what "hidden" libraries, object files and flags are used when
16343 # linking a shared library.
16344 #
16345 # There doesn't appear to be a way to prevent this compiler from
16346 # explicitly linking system object files so we need to strip them
16347 # from the output so that they don't get included in the library
16348 # dependencies.
16349 output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
16350
16351 hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
16352 export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
16353
16354 # Archives containing C++ object files must be created using
16355 # "CC -Bstatic", where "CC" is the KAI C++ compiler.
16356 old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
16357 ;;
16358 icpc* | ecpc* )
16359 # Intel C++
16360 with_gnu_ld=yes
16361 # version 8.0 and above of icpc choke on multiply defined symbols
16362 # if we add $predep_objects and $postdep_objects, however 7.1 and
16363 # earlier do not add the objects themselves.
16364 case `$CC -V 2>&1` in
16365 *"Version 7."*)
16366 archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
16367 archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
16368 ;;
16369 *) # Version 8.0 or newer
16370 tmp_idyn=
16371 case $host_cpu in
16372 ia64*) tmp_idyn=' -i_dynamic';;
16373 esac
16374 archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
16375 archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
16376 ;;
16377 esac
16378 archive_cmds_need_lc_CXX=no
16379 hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
16380 export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
16381 whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
16382 ;;
16383 pgCC* | pgcpp*)
16384 # Portland Group C++ compiler
16385 case `$CC -V` in
16386 *pgCC\ [1-5]* | *pgcpp\ [1-5]*)
16387 prelink_cmds_CXX='tpldir=Template.dir~
16388 rm -rf $tpldir~
16389 $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
16390 compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
16391 old_archive_cmds_CXX='tpldir=Template.dir~
16392 rm -rf $tpldir~
16393 $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
16394 $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
16395 $RANLIB $oldlib'
16396 archive_cmds_CXX='tpldir=Template.dir~
16397 rm -rf $tpldir~
16398 $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
16399 $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
16400 archive_expsym_cmds_CXX='tpldir=Template.dir~
16401 rm -rf $tpldir~
16402 $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
16403 $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
16404 ;;
16405 *) # Version 6 will use weak symbols
16406 archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
16407 archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
16408 ;;
16409 esac
16410
16411 hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
16412 export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
16413 whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
16414 ;;
16415 cxx*)
16416 # Compaq C++
16417 archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
16418 archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
16419
16420 runpath_var=LD_RUN_PATH
16421 hardcode_libdir_flag_spec_CXX='-rpath $libdir'
16422 hardcode_libdir_separator_CXX=:
16423
16424 # Commands to make compiler produce verbose output that lists
16425 # what "hidden" libraries, object files and flags are used when
16426 # linking a shared library.
16427 #
16428 # There doesn't appear to be a way to prevent this compiler from
16429 # explicitly linking system object files so we need to strip them
16430 # from the output so that they don't get included in the library
16431 # dependencies.
16432 output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
16433 ;;
16434 xl*)
16435 # IBM XL 8.0 on PPC, with GNU ld
16436 hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
16437 export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
16438 archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
16439 if test "x$supports_anon_versioning" = xyes; then
16440 archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
16441 cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
16442 echo "local: *; };" >> $output_objdir/$libname.ver~
16443 $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
16444 fi
16445 ;;
16446 *)
16447 case `$CC -V 2>&1 | sed 5q` in
16448 *Sun\ C*)
16449 # Sun C++ 5.9
16450 no_undefined_flag_CXX=' -zdefs'
16451 archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
16452 archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
16453 hardcode_libdir_flag_spec_CXX='-R$libdir'
16454 whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
16455 compiler_needs_object_CXX=yes
16456
16457 # Not sure whether something based on
16458 # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
16459 # would be better.
16460 output_verbose_link_cmd='echo'
16461
16462 # Archives containing C++ object files must be created using
16463 # "CC -xar", where "CC" is the Sun C++ compiler. This is
16464 # necessary to make sure instantiated templates are included
16465 # in the archive.
16466 old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
16467 ;;
16468 esac
16469 ;;
16470 esac
16471 ;;
16472
16473 lynxos*)
16474 # FIXME: insert proper C++ library support
16475 ld_shlibs_CXX=no
16476 ;;
16477
16478 m88k*)
16479 # FIXME: insert proper C++ library support
16480 ld_shlibs_CXX=no
16481 ;;
16482
16483 mvs*)
16484 case $cc_basename in
16485 cxx*)
16486 # FIXME: insert proper C++ library support
16487 ld_shlibs_CXX=no
16488 ;;
16489 *)
16490 # FIXME: insert proper C++ library support
16491 ld_shlibs_CXX=no
16492 ;;
16493 esac
16494 ;;
16495
16496 netbsd*)
16497 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
16498 archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
16499 wlarc=
16500 hardcode_libdir_flag_spec_CXX='-R$libdir'
16501 hardcode_direct_CXX=yes
16502 hardcode_shlibpath_var_CXX=no
16503 fi
16504 # Workaround some broken pre-1.5 toolchains
16505 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
16506 ;;
16507
16508 *nto* | *qnx*)
16509 ld_shlibs_CXX=yes
16510 ;;
16511
16512 openbsd2*)
16513 # C++ shared libraries are fairly broken
16514 ld_shlibs_CXX=no
16515 ;;
16516
16517 openbsd*)
16518 if test -f /usr/libexec/ld.so; then
16519 hardcode_direct_CXX=yes
16520 hardcode_shlibpath_var_CXX=no
16521 hardcode_direct_absolute_CXX=yes
16522 archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
16523 hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
16524 if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
16525 archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
16526 export_dynamic_flag_spec_CXX='${wl}-E'
16527 whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
16528 fi
16529 output_verbose_link_cmd=echo
16530 else
16531 ld_shlibs_CXX=no
16532 fi
16533 ;;
16534
16535 osf3* | osf4* | osf5*)
16536 case $cc_basename in
16537 KCC*)
16538 # Kuck and Associates, Inc. (KAI) C++ Compiler
16539
16540 # KCC will only create a shared library if the output file
16541 # ends with ".so" (or ".sl" for HP-UX), so rename the library
16542 # to its proper name (with version) after linking.
16543 archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
16544
16545 hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
16546 hardcode_libdir_separator_CXX=:
16547
16548 # Archives containing C++ object files must be created using
16549 # the KAI C++ compiler.
16550 case $host in
16551 osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
16552 *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
16553 esac
16554 ;;
16555 RCC*)
16556 # Rational C++ 2.4.1
16557 # FIXME: insert proper C++ library support
16558 ld_shlibs_CXX=no
16559 ;;
16560 cxx*)
16561 case $host in
16562 osf3*)
16563 allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
16564 archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
16565 hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
16566 ;;
16567 *)
16568 allow_undefined_flag_CXX=' -expect_unresolved \*'
16569 archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
16570 archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
16571 echo "-hidden">> $lib.exp~
16572 $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
16573 $RM $lib.exp'
16574 hardcode_libdir_flag_spec_CXX='-rpath $libdir'
16575 ;;
16576 esac
16577
16578 hardcode_libdir_separator_CXX=:
16579
16580 # Commands to make compiler produce verbose output that lists
16581 # what "hidden" libraries, object files and flags are used when
16582 # linking a shared library.
16583 #
16584 # There doesn't appear to be a way to prevent this compiler from
16585 # explicitly linking system object files so we need to strip them
16586 # from the output so that they don't get included in the library
16587 # dependencies.
16588 output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
16589 ;;
16590 *)
16591 if test "$GXX" = yes && test "$with_gnu_ld" = no; then
16592 allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
16593 case $host in
16594 osf3*)
16595 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
16596 ;;
16597 *)
16598 archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
16599 ;;
16600 esac
16601
16602 hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
16603 hardcode_libdir_separator_CXX=:
16604
16605 # Commands to make compiler produce verbose output that lists
16606 # what "hidden" libraries, object files and flags are used when
16607 # linking a shared library.
16608 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
16609
16610 else
16611 # FIXME: insert proper C++ library support
16612 ld_shlibs_CXX=no
16613 fi
16614 ;;
16615 esac
16616 ;;
16617
16618 psos*)
16619 # FIXME: insert proper C++ library support
16620 ld_shlibs_CXX=no
16621 ;;
16622
16623 sunos4*)
16624 case $cc_basename in
16625 CC*)
16626 # Sun C++ 4.x
16627 # FIXME: insert proper C++ library support
16628 ld_shlibs_CXX=no
16629 ;;
16630 lcc*)
16631 # Lucid
16632 # FIXME: insert proper C++ library support
16633 ld_shlibs_CXX=no
16634 ;;
16635 *)
16636 # FIXME: insert proper C++ library support
16637 ld_shlibs_CXX=no
16638 ;;
16639 esac
16640 ;;
16641
16642 solaris*)
16643 case $cc_basename in
16644 CC*)
16645 # Sun C++ 4.2, 5.x and Centerline C++
16646 archive_cmds_need_lc_CXX=yes
16647 no_undefined_flag_CXX=' -zdefs'
16648 archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
16649 archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
16650 $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
16651
16652 hardcode_libdir_flag_spec_CXX='-R$libdir'
16653 hardcode_shlibpath_var_CXX=no
16654 case $host_os in
16655 solaris2.[0-5] | solaris2.[0-5].*) ;;
16656 *)
16657 # The compiler driver will combine and reorder linker options,
16658 # but understands `-z linker_flag'.
16659 # Supported since Solaris 2.6 (maybe 2.5.1?)
16660 whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
16661 ;;
16662 esac
16663 link_all_deplibs_CXX=yes
16664
16665 output_verbose_link_cmd='echo'
16666
16667 # Archives containing C++ object files must be created using
16668 # "CC -xar", where "CC" is the Sun C++ compiler. This is
16669 # necessary to make sure instantiated templates are included
16670 # in the archive.
16671 old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
16672 ;;
16673 gcx*)
16674 # Green Hills C++ Compiler
16675 archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
16676
16677 # The C++ compiler must be used to create the archive.
16678 old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
16679 ;;
16680 *)
16681 # GNU C++ compiler with Solaris linker
16682 if test "$GXX" = yes && test "$with_gnu_ld" = no; then
16683 no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
16684 if $CC --version | $GREP -v '^2\.7' > /dev/null; then
16685 archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
16686 archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
16687 $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
16688
16689 # Commands to make compiler produce verbose output that lists
16690 # what "hidden" libraries, object files and flags are used when
16691 # linking a shared library.
16692 output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
16693 else
16694 # g++ 2.7 appears to require `-G' NOT `-shared' on this
16695 # platform.
16696 archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
16697 archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
16698 $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
16699
16700 # Commands to make compiler produce verbose output that lists
16701 # what "hidden" libraries, object files and flags are used when
16702 # linking a shared library.
16703 output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
16704 fi
16705
16706 hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
16707 case $host_os in
16708 solaris2.[0-5] | solaris2.[0-5].*) ;;
16709 *)
16710 whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
16711 ;;
16712 esac
16713 fi
16714 ;;
16715 esac
16716 ;;
16717
16718 sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
16719 no_undefined_flag_CXX='${wl}-z,text'
16720 archive_cmds_need_lc_CXX=no
16721 hardcode_shlibpath_var_CXX=no
16722 runpath_var='LD_RUN_PATH'
16723
16724 case $cc_basename in
16725 CC*)
16726 archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
16727 archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
16728 ;;
16729 *)
16730 archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
16731 archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
16732 ;;
16733 esac
16734 ;;
16735
16736 sysv5* | sco3.2v5* | sco5v6*)
16737 # Note: We can NOT use -z defs as we might desire, because we do not
16738 # link with -lc, and that would cause any symbols used from libc to
16739 # always be unresolved, which means just about no library would
16740 # ever link correctly. If we're not using GNU ld we use -z text
16741 # though, which does catch some bad symbols but isn't as heavy-handed
16742 # as -z defs.
16743 no_undefined_flag_CXX='${wl}-z,text'
16744 allow_undefined_flag_CXX='${wl}-z,nodefs'
16745 archive_cmds_need_lc_CXX=no
16746 hardcode_shlibpath_var_CXX=no
16747 hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
16748 hardcode_libdir_separator_CXX=':'
16749 link_all_deplibs_CXX=yes
16750 export_dynamic_flag_spec_CXX='${wl}-Bexport'
16751 runpath_var='LD_RUN_PATH'
16752
16753 case $cc_basename in
16754 CC*)
16755 archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
16756 archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
16757 ;;
16758 *)
16759 archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
16760 archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
16761 ;;
16762 esac
16763 ;;
16764
16765 tandem*)
16766 case $cc_basename in
16767 NCC*)
16768 # NonStop-UX NCC 3.20
16769 # FIXME: insert proper C++ library support
16770 ld_shlibs_CXX=no
16771 ;;
16772 *)
16773 # FIXME: insert proper C++ library support
16774 ld_shlibs_CXX=no
16775 ;;
16776 esac
16777 ;;
16778
16779 vxworks*)
16780 # FIXME: insert proper C++ library support
16781 ld_shlibs_CXX=no
16782 ;;
16783
16784 *)
16785 # FIXME: insert proper C++ library support
16786 ld_shlibs_CXX=no
16787 ;;
16788 esac
16789
16790 { echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
16791 echo "${ECHO_T}$ld_shlibs_CXX" >&6; }
16792 test "$ld_shlibs_CXX" = no && can_build_shared=no
16793
16794 GCC_CXX="$GXX"
16795 LD_CXX="$LD"
16796
16797 ## CAVEAT EMPTOR:
16798 ## There is no encapsulation within the following macros, do not change
16799 ## the running order or otherwise move them around unless you know exactly
16800 ## what you are doing...
16801 # Dependencies to place before and after the object being linked:
16802 predep_objects_CXX=
16803 postdep_objects_CXX=
16804 predeps_CXX=
16805 postdeps_CXX=
16806 compiler_lib_search_path_CXX=
16807
16808 cat > conftest.$ac_ext <<_LT_EOF
16809 class Foo
16810 {
16811 public:
16812 Foo (void) { a = 0; }
16813 private:
16814 int a;
16815 };
16816 _LT_EOF
16817
16818 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
16819 (eval $ac_compile) 2>&5
16820 ac_status=$?
16821 echo "$as_me:$LINENO: \$? = $ac_status" >&5
16822 (exit $ac_status); }; then
16823 # Parse the compiler output and extract the necessary
16824 # objects, libraries and library flags.
16825
16826 # Sentinel used to keep track of whether or not we are before
16827 # the conftest object file.
16828 pre_test_object_deps_done=no
16829
16830 for p in `eval "$output_verbose_link_cmd"`; do
16831 case $p in
16832
16833 -L* | -R* | -l*)
16834 # Some compilers place space between "-{L,R}" and the path.
16835 # Remove the space.
16836 if test $p = "-L" ||
16837 test $p = "-R"; then
16838 prev=$p
16839 continue
16840 else
16841 prev=
16842 fi
16843
16844 if test "$pre_test_object_deps_done" = no; then
16845 case $p in
16846 -L* | -R*)
16847 # Internal compiler library paths should come after those
16848 # provided the user. The postdeps already come after the
16849 # user supplied libs so there is no need to process them.
16850 if test -z "$compiler_lib_search_path_CXX"; then
16851 compiler_lib_search_path_CXX="${prev}${p}"
16852 else
16853 compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
16854 fi
16855 ;;
16856 # The "-l" case would never come before the object being
16857 # linked, so don't bother handling this case.
16858 esac
16859 else
16860 if test -z "$postdeps_CXX"; then
16861 postdeps_CXX="${prev}${p}"
16862 else
16863 postdeps_CXX="${postdeps_CXX} ${prev}${p}"
16864 fi
16865 fi
16866 ;;
16867
16868 *.$objext)
16869 # This assumes that the test object file only shows up
16870 # once in the compiler output.
16871 if test "$p" = "conftest.$objext"; then
16872 pre_test_object_deps_done=yes
16873 continue
16874 fi
16875
16876 if test "$pre_test_object_deps_done" = no; then
16877 if test -z "$predep_objects_CXX"; then
16878 predep_objects_CXX="$p"
16879 else
16880 predep_objects_CXX="$predep_objects_CXX $p"
16881 fi
16882 else
16883 if test -z "$postdep_objects_CXX"; then
16884 postdep_objects_CXX="$p"
16885 else
16886 postdep_objects_CXX="$postdep_objects_CXX $p"
16887 fi
16888 fi
16889 ;;
16890
16891 *) ;; # Ignore the rest.
16892
16893 esac
16894 done
16895
16896 # Clean up.
16897 rm -f a.out a.exe
16898 else
16899 echo "libtool.m4: error: problem compiling CXX test program"
16900 fi
16901
16902 $RM -f confest.$objext
16903
16904 # PORTME: override above test on systems where it is broken
16905 case $host_os in
16906 interix[3-9]*)
16907 # Interix 3.5 installs completely hosed .la files for C++, so rather than
16908 # hack all around it, let's just trust "g++" to DTRT.
16909 predep_objects_CXX=
16910 postdep_objects_CXX=
16911 postdeps_CXX=
16912 ;;
16913
16914 linux*)
16915 case `$CC -V 2>&1 | sed 5q` in
16916 *Sun\ C*)
16917 # Sun C++ 5.9
16918
16919 # The more standards-conforming stlport4 library is
16920 # incompatible with the Cstd library. Avoid specifying
16921 # it if it's in CXXFLAGS. Ignore libCrun as
16922 # -library=stlport4 depends on it.
16923 case " $CXX $CXXFLAGS " in
16924 *" -library=stlport4 "*)
16925 solaris_use_stlport4=yes
16926 ;;
16927 esac
16928
16929 if test "$solaris_use_stlport4" != yes; then
16930 postdeps_CXX='-library=Cstd -library=Crun'
16931 fi
16932 ;;
16933 esac
16934 ;;
16935
16936 solaris*)
16937 case $cc_basename in
16938 CC*)
16939 # The more standards-conforming stlport4 library is
16940 # incompatible with the Cstd library. Avoid specifying
16941 # it if it's in CXXFLAGS. Ignore libCrun as
16942 # -library=stlport4 depends on it.
16943 case " $CXX $CXXFLAGS " in
16944 *" -library=stlport4 "*)
16945 solaris_use_stlport4=yes
16946 ;;
16947 esac
16948
16949 # Adding this requires a known-good setup of shared libraries for
16950 # Sun compiler versions before 5.6, else PIC objects from an old
16951 # archive will be linked into the output, leading to subtle bugs.
16952 if test "$solaris_use_stlport4" != yes; then
16953 postdeps_CXX='-library=Cstd -library=Crun'
16954 fi
16955 ;;
16956 esac
16957 ;;
16958 esac
16959
16960
16961 case " $postdeps_CXX " in
16962 *" -lc "*) archive_cmds_need_lc_CXX=no ;;
16963 esac
16964 compiler_lib_search_dirs_CXX=
16965 if test -n "${compiler_lib_search_path_CXX}"; then
16966 compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
16967 fi
16968
16969
16970
16971
16972
16973
16974
16975
16976
16977
16978
16979
16980
16981
16982
16983
16984
16985
16986
16987
16988
16989
16990
16991
16992
16993
16994
16995
16996
16997
16998
16999 lt_prog_compiler_wl_CXX=
17000 lt_prog_compiler_pic_CXX=
17001 lt_prog_compiler_static_CXX=
17002
17003 { echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
17004 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; }
17005
17006 # C++ specific cases for pic, static, wl, etc.
17007 if test "$GXX" = yes; then
17008 lt_prog_compiler_wl_CXX='-Wl,'
17009 lt_prog_compiler_static_CXX='-static'
17010
17011 case $host_os in
17012 aix*)
17013 # All AIX code is PIC.
17014 if test "$host_cpu" = ia64; then
17015 # AIX 5 now supports IA64 processor
17016 lt_prog_compiler_static_CXX='-Bstatic'
17017 fi
17018 ;;
17019
17020 amigaos*)
17021 case $host_cpu in
17022 powerpc)
17023 # see comment about AmigaOS4 .so support
17024 lt_prog_compiler_pic_CXX='-fPIC'
17025 ;;
17026 m68k)
17027 # FIXME: we need at least 68020 code to build shared libraries, but
17028 # adding the `-m68020' flag to GCC prevents building anything better,
17029 # like `-m68040'.
17030 lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
17031 ;;
17032 esac
17033 ;;
17034
17035 beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
17036 # PIC is the default for these OSes.
17037 ;;
17038 mingw* | cygwin* | os2* | pw32*)
17039 # This hack is so that the source file can tell whether it is being
17040 # built for inclusion in a dll (and should export symbols for example).
17041 # Although the cygwin gcc ignores -fPIC, still need this for old-style
17042 # (--disable-auto-import) libraries
17043 lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
17044 ;;
17045 darwin* | rhapsody*)
17046 # PIC is the default on this platform
17047 # Common symbols not allowed in MH_DYLIB files
17048 lt_prog_compiler_pic_CXX='-fno-common'
17049 ;;
17050 *djgpp*)
17051 # DJGPP does not support shared libraries at all
17052 lt_prog_compiler_pic_CXX=
17053 ;;
17054 interix[3-9]*)
17055 # Interix 3.x gcc -fpic/-fPIC options generate broken code.
17056 # Instead, we relocate shared libraries at runtime.
17057 ;;
17058 sysv4*MP*)
17059 if test -d /usr/nec; then
17060 lt_prog_compiler_pic_CXX=-Kconform_pic
17061 fi
17062 ;;
17063 hpux*)
17064 # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
17065 # not for PA HP-UX.
17066 case $host_cpu in
17067 hppa*64*|ia64*)
17068 ;;
17069 *)
17070 lt_prog_compiler_pic_CXX='-fPIC'
17071 ;;
17072 esac
17073 ;;
17074 *qnx* | *nto*)
17075 # QNX uses GNU C++, but need to define -shared option too, otherwise
17076 # it will coredump.
17077 lt_prog_compiler_pic_CXX='-fPIC -shared'
17078 ;;
17079 *)
17080 lt_prog_compiler_pic_CXX='-fPIC'
17081 ;;
17082 esac
17083 else
17084 case $host_os in
17085 aix[4-9]*)
17086 # All AIX code is PIC.
17087 if test "$host_cpu" = ia64; then
17088 # AIX 5 now supports IA64 processor
17089 lt_prog_compiler_static_CXX='-Bstatic'
17090 else
17091 lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
17092 fi
17093 ;;
17094 chorus*)
17095 case $cc_basename in
17096 cxch68*)
17097 # Green Hills C++ Compiler
17098 # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
17099 ;;
17100 esac
17101 ;;
17102 dgux*)
17103 case $cc_basename in
17104 ec++*)
17105 lt_prog_compiler_pic_CXX='-KPIC'
17106 ;;
17107 ghcx*)
17108 # Green Hills C++ Compiler
17109 lt_prog_compiler_pic_CXX='-pic'
17110 ;;
17111 *)
17112 ;;
17113 esac
17114 ;;
17115 freebsd* | dragonfly*)
17116 # FreeBSD uses GNU C++
17117 ;;
17118 hpux9* | hpux10* | hpux11*)
17119 case $cc_basename in
17120 CC*)
17121 lt_prog_compiler_wl_CXX='-Wl,'
17122 lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
17123 if test "$host_cpu" != ia64; then
17124 lt_prog_compiler_pic_CXX='+Z'
17125 fi
17126 ;;
17127 aCC*)
17128 lt_prog_compiler_wl_CXX='-Wl,'
17129 lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
17130 case $host_cpu in
17131 hppa*64*|ia64*)
17132 # +Z the default
17133 ;;
17134 *)
17135 lt_prog_compiler_pic_CXX='+Z'
17136 ;;
17137 esac
17138 ;;
17139 *)
17140 ;;
17141 esac
17142 ;;
17143 interix*)
17144 # This is c89, which is MS Visual C++ (no shared libs)
17145 # Anyone wants to do a port?
17146 ;;
17147 irix5* | irix6* | nonstopux*)
17148 case $cc_basename in
17149 CC*)
17150 lt_prog_compiler_wl_CXX='-Wl,'
17151 lt_prog_compiler_static_CXX='-non_shared'
17152 # CC pic flag -KPIC is the default.
17153 ;;
17154 *)
17155 ;;
17156 esac
17157 ;;
17158 linux* | k*bsd*-gnu)
17159 case $cc_basename in
17160 KCC*)
17161 # KAI C++ Compiler
17162 lt_prog_compiler_wl_CXX='--backend -Wl,'
17163 lt_prog_compiler_pic_CXX='-fPIC'
17164 ;;
17165 icpc* | ecpc* )
17166 # Intel C++
17167 lt_prog_compiler_wl_CXX='-Wl,'
17168 lt_prog_compiler_pic_CXX='-KPIC'
17169 lt_prog_compiler_static_CXX='-static'
17170 ;;
17171 pgCC* | pgcpp*)
17172 # Portland Group C++ compiler
17173 lt_prog_compiler_wl_CXX='-Wl,'
17174 lt_prog_compiler_pic_CXX='-fpic'
17175 lt_prog_compiler_static_CXX='-Bstatic'
17176 ;;
17177 cxx*)
17178 # Compaq C++
17179 # Make sure the PIC flag is empty. It appears that all Alpha
17180 # Linux and Compaq Tru64 Unix objects are PIC.
17181 lt_prog_compiler_pic_CXX=
17182 lt_prog_compiler_static_CXX='-non_shared'
17183 ;;
17184 xlc* | xlC*)
17185 # IBM XL 8.0 on PPC
17186 lt_prog_compiler_wl_CXX='-Wl,'
17187 lt_prog_compiler_pic_CXX='-qpic'
17188 lt_prog_compiler_static_CXX='-qstaticlink'
17189 ;;
17190 *)
17191 case `$CC -V 2>&1 | sed 5q` in
17192 *Sun\ C*)
17193 # Sun C++ 5.9
17194 lt_prog_compiler_pic_CXX='-KPIC'
17195 lt_prog_compiler_static_CXX='-Bstatic'
17196 lt_prog_compiler_wl_CXX='-Qoption ld '
17197 ;;
17198 esac
17199 ;;
17200 esac
17201 ;;
17202 lynxos*)
17203 ;;
17204 m88k*)
17205 ;;
17206 mvs*)
17207 case $cc_basename in
17208 cxx*)
17209 lt_prog_compiler_pic_CXX='-W c,exportall'
17210 ;;
17211 *)
17212 ;;
17213 esac
17214 ;;
17215 netbsd*)
17216 ;;
17217 *qnx* | *nto*)
17218 # QNX uses GNU C++, but need to define -shared option too, otherwise
17219 # it will coredump.
17220 lt_prog_compiler_pic_CXX='-fPIC -shared'
17221 ;;
17222 osf3* | osf4* | osf5*)
17223 case $cc_basename in
17224 KCC*)
17225 lt_prog_compiler_wl_CXX='--backend -Wl,'
17226 ;;
17227 RCC*)
17228 # Rational C++ 2.4.1
17229 lt_prog_compiler_pic_CXX='-pic'
17230 ;;
17231 cxx*)
17232 # Digital/Compaq C++
17233 lt_prog_compiler_wl_CXX='-Wl,'
17234 # Make sure the PIC flag is empty. It appears that all Alpha
17235 # Linux and Compaq Tru64 Unix objects are PIC.
17236 lt_prog_compiler_pic_CXX=
17237 lt_prog_compiler_static_CXX='-non_shared'
17238 ;;
17239 *)
17240 ;;
17241 esac
17242 ;;
17243 psos*)
17244 ;;
17245 solaris*)
17246 case $cc_basename in
17247 CC*)
17248 # Sun C++ 4.2, 5.x and Centerline C++
17249 lt_prog_compiler_pic_CXX='-KPIC'
17250 lt_prog_compiler_static_CXX='-Bstatic'
17251 lt_prog_compiler_wl_CXX='-Qoption ld '
17252 ;;
17253 gcx*)
17254 # Green Hills C++ Compiler
17255 lt_prog_compiler_pic_CXX='-PIC'
17256 ;;
17257 *)
17258 ;;
17259 esac
17260 ;;
17261 sunos4*)
17262 case $cc_basename in
17263 CC*)
17264 # Sun C++ 4.x
17265 lt_prog_compiler_pic_CXX='-pic'
17266 lt_prog_compiler_static_CXX='-Bstatic'
17267 ;;
17268 lcc*)
17269 # Lucid
17270 lt_prog_compiler_pic_CXX='-pic'
17271 ;;
17272 *)
17273 ;;
17274 esac
17275 ;;
17276 sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
17277 case $cc_basename in
17278 CC*)
17279 lt_prog_compiler_wl_CXX='-Wl,'
17280 lt_prog_compiler_pic_CXX='-KPIC'
17281 lt_prog_compiler_static_CXX='-Bstatic'
17282 ;;
17283 esac
17284 ;;
17285 tandem*)
17286 case $cc_basename in
17287 NCC*)
17288 # NonStop-UX NCC 3.20
17289 lt_prog_compiler_pic_CXX='-KPIC'
17290 ;;
17291 *)
17292 ;;
17293 esac
17294 ;;
17295 vxworks*)
17296 ;;
17297 *)
17298 lt_prog_compiler_can_build_shared_CXX=no
17299 ;;
17300 esac
17301 fi
17302
17303 case $host_os in
17304 # For platforms which do not support PIC, -DPIC is meaningless:
17305 *djgpp*)
17306 lt_prog_compiler_pic_CXX=
17307 ;;
17308 *)
17309 lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
17310 ;;
17311 esac
17312 { echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5
17313 echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6; }
17314
17315
17316
17317 #
17318 # Check to make sure the PIC flag actually works.
17319 #
17320 if test -n "$lt_prog_compiler_pic_CXX"; then
17321 { echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
17322 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6; }
17323 if test "${lt_cv_prog_compiler_pic_works_CXX+set}" = set; then
17324 echo $ECHO_N "(cached) $ECHO_C" >&6
17325 else
17326 lt_cv_prog_compiler_pic_works_CXX=no
17327 ac_outfile=conftest.$ac_objext
17328 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
17329 lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
17330 # Insert the option either (1) after the last *FLAGS variable, or
17331 # (2) before a word containing "conftest.", or (3) at the end.
17332 # Note that $ac_compile itself does not contain backslashes and begins
17333 # with a dollar sign (not a hyphen), so the echo should work correctly.
17334 # The option is referenced via a variable to avoid confusing sed.
17335 lt_compile=`echo "$ac_compile" | $SED \
17336 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
17337 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
17338 -e 's:$: $lt_compiler_flag:'`
17339 (eval echo "\"\$as_me:17340: $lt_compile\"" >&5)
17340 (eval "$lt_compile" 2>conftest.err)
17341 ac_status=$?
17342 cat conftest.err >&5
17343 echo "$as_me:17344: \$? = $ac_status" >&5
17344 if (exit $ac_status) && test -s "$ac_outfile"; then
17345 # The compiler can only warn and ignore the option if not recognized
17346 # So say no if there are warnings other than the usual output.
17347 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
17348 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
17349 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
17350 lt_cv_prog_compiler_pic_works_CXX=yes
17351 fi
17352 fi
17353 $RM -r conftest*
17354
17355 fi
17356 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
17357 echo "${ECHO_T}$lt_cv_prog_compiler_pic_works_CXX" >&6; }
17358
17359 if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
17360 case $lt_prog_compiler_pic_CXX in
17361 "" | " "*) ;;
17362 *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
17363 esac
17364 else
17365 lt_prog_compiler_pic_CXX=
17366 lt_prog_compiler_can_build_shared_CXX=no
17367 fi
17368
17369 fi
17370
17371
17372
17373 #
17374 # Check to make sure the static flag actually works.
17375 #
17376 wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
17377 { echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
17378 echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6; }
17379 if test "${lt_cv_prog_compiler_static_works_CXX+set}" = set; then
17380 echo $ECHO_N "(cached) $ECHO_C" >&6
17381 else
17382 lt_cv_prog_compiler_static_works_CXX=no
17383 save_LDFLAGS="$LDFLAGS"
17384 LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
17385 echo "$lt_simple_link_test_code" > conftest.$ac_ext
17386 if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
17387 # The linker can only warn and ignore the option if not recognized
17388 # So say no if there are warnings
17389 if test -s conftest.err; then
17390 # Append any errors to the config.log.
17391 cat conftest.err 1>&5
17392 $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
17393 $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
17394 if diff conftest.exp conftest.er2 >/dev/null; then
17395 lt_cv_prog_compiler_static_works_CXX=yes
17396 fi
17397 else
17398 lt_cv_prog_compiler_static_works_CXX=yes
17399 fi
17400 fi
17401 $RM -r conftest*
17402 LDFLAGS="$save_LDFLAGS"
17403
17404 fi
17405 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_static_works_CXX" >&5
17406 echo "${ECHO_T}$lt_cv_prog_compiler_static_works_CXX" >&6; }
17407
17408 if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
17409 :
17410 else
17411 lt_prog_compiler_static_CXX=
17412 fi
17413
17414
17415
17416
17417 { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
17418 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; }
17419 if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
17420 echo $ECHO_N "(cached) $ECHO_C" >&6
17421 else
17422 lt_cv_prog_compiler_c_o_CXX=no
17423 $RM -r conftest 2>/dev/null
17424 mkdir conftest
17425 cd conftest
17426 mkdir out
17427 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
17428
17429 lt_compiler_flag="-o out/conftest2.$ac_objext"
17430 # Insert the option either (1) after the last *FLAGS variable, or
17431 # (2) before a word containing "conftest.", or (3) at the end.
17432 # Note that $ac_compile itself does not contain backslashes and begins
17433 # with a dollar sign (not a hyphen), so the echo should work correctly.
17434 lt_compile=`echo "$ac_compile" | $SED \
17435 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
17436 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
17437 -e 's:$: $lt_compiler_flag:'`
17438 (eval echo "\"\$as_me:17439: $lt_compile\"" >&5)
17439 (eval "$lt_compile" 2>out/conftest.err)
17440 ac_status=$?
17441 cat out/conftest.err >&5
17442 echo "$as_me:17443: \$? = $ac_status" >&5
17443 if (exit $ac_status) && test -s out/conftest2.$ac_objext
17444 then
17445 # The compiler can only warn and ignore the option if not recognized
17446 # So say no if there are warnings
17447 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
17448 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
17449 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
17450 lt_cv_prog_compiler_c_o_CXX=yes
17451 fi
17452 fi
17453 chmod u+w . 2>&5
17454 $RM -r conftest*
17455 # SGI C++ compiler will create directory out/ii_files/ for
17456 # template instantiation
17457 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
17458 $RM out/* && rmdir out
17459 cd ..
17460 $RM -r conftest
17461 $RM -r conftest*
17462
17463 fi
17464 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
17465 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6; }
17466
17467
17468
17469 { echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
17470 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; }
17471 if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then
17472 echo $ECHO_N "(cached) $ECHO_C" >&6
17473 else
17474 lt_cv_prog_compiler_c_o_CXX=no
17475 $RM -r conftest 2>/dev/null
17476 mkdir conftest
17477 cd conftest
17478 mkdir out
17479 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
17480
17481 lt_compiler_flag="-o out/conftest2.$ac_objext"
17482 # Insert the option either (1) after the last *FLAGS variable, or
17483 # (2) before a word containing "conftest.", or (3) at the end.
17484 # Note that $ac_compile itself does not contain backslashes and begins
17485 # with a dollar sign (not a hyphen), so the echo should work correctly.
17486 lt_compile=`echo "$ac_compile" | $SED \
17487 -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
17488 -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
17489 -e 's:$: $lt_compiler_flag:'`
17490 (eval echo "\"\$as_me:17491: $lt_compile\"" >&5)
17491 (eval "$lt_compile" 2>out/conftest.err)
17492 ac_status=$?
17493 cat out/conftest.err >&5
17494 echo "$as_me:17495: \$? = $ac_status" >&5
17495 if (exit $ac_status) && test -s out/conftest2.$ac_objext
17496 then
17497 # The compiler can only warn and ignore the option if not recognized
17498 # So say no if there are warnings
17499 $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
17500 $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
17501 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
17502 lt_cv_prog_compiler_c_o_CXX=yes
17503 fi
17504 fi
17505 chmod u+w . 2>&5
17506 $RM -r conftest*
17507 # SGI C++ compiler will create directory out/ii_files/ for
17508 # template instantiation
17509 test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
17510 $RM out/* && rmdir out
17511 cd ..
17512 $RM -r conftest
17513 $RM -r conftest*
17514
17515 fi
17516 { echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5
17517 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6; }
17518
17519
17520
17521
17522 hard_links="nottested"
17523 if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
17524 # do not overwrite the value of need_locks provided by the user
17525 { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
17526 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; }
17527 hard_links=yes
17528 $RM -r conftest*
17529 ln conftest.a conftest.b 2>/dev/null && hard_links=no
17530 touch conftest.a
17531 ln conftest.a conftest.b 2>&5 || hard_links=no
17532 ln conftest.a conftest.b 2>/dev/null && hard_links=no
17533 { echo "$as_me:$LINENO: result: $hard_links" >&5
17534 echo "${ECHO_T}$hard_links" >&6; }
17535 if test "$hard_links" = no; then
17536 { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
17537 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
17538 need_locks=warn
17539 fi
17540 else
17541 need_locks=no
17542 fi
17543
17544
17545
17546 { echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
17547 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; }
17548
17549 export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
17550 case $host_os in
17551 aix[4-9]*)
17552 # If we're using GNU nm, then we don't want the "-C" option.
17553 # -C means demangle to AIX nm, but means don't demangle with GNU nm
17554 if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
17555 export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
17556 else
17557 export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
17558 fi
17559 ;;
17560 pw32*)
17561 export_symbols_cmds_CXX="$ltdll_cmds"
17562 ;;
17563 cygwin* | mingw*)
17564 export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
17565 ;;
17566 *)
17567 export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
17568 ;;
17569 esac
17570 exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
17571
17572 { echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5
17573 echo "${ECHO_T}$ld_shlibs_CXX" >&6; }
17574 test "$ld_shlibs_CXX" = no && can_build_shared=no
17575
17576 with_gnu_ld_CXX=$with_gnu_ld
17577
17578
17579
17580
17581
17582
17583 #
17584 # Do we need to explicitly link libc?
17585 #
17586 case "x$archive_cmds_need_lc_CXX" in
17587 x|xyes)
17588 # Assume -lc should be added
17589 archive_cmds_need_lc_CXX=yes
17590
17591 if test "$enable_shared" = yes && test "$GCC" = yes; then
17592 case $archive_cmds_CXX in
17593 *'~'*)
17594 # FIXME: we may have to deal with multi-command sequences.
17595 ;;
17596 '$CC '*)
17597 # Test whether the compiler implicitly links with -lc since on some
17598 # systems, -lgcc has to come before -lc. If gcc already passes -lc
17599 # to ld, don't add -lc before -lgcc.
17600 { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
17601 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; }
17602 $RM -r conftest*
17603 echo "$lt_simple_compile_test_code" > conftest.$ac_ext
17604
17605 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
17606 (eval $ac_compile) 2>&5
17607 ac_status=$?
17608 echo "$as_me:$LINENO: \$? = $ac_status" >&5
17609 (exit $ac_status); } 2>conftest.err; then
17610 soname=conftest
17611 lib=conftest
17612 libobjs=conftest.$ac_objext
17613 deplibs=
17614 wl=$lt_prog_compiler_wl_CXX
17615 pic_flag=$lt_prog_compiler_pic_CXX
17616 compiler_flags=-v
17617 linker_flags=-v
17618 verstring=
17619 output_objdir=.
17620 libname=conftest
17621 lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
17622 allow_undefined_flag_CXX=
17623 if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
17624 (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
17625 ac_status=$?
17626 echo "$as_me:$LINENO: \$? = $ac_status" >&5
17627 (exit $ac_status); }
17628 then
17629 archive_cmds_need_lc_CXX=no
17630 else
17631 archive_cmds_need_lc_CXX=yes
17632 fi
17633 allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
17634 else
17635 cat conftest.err 1>&5
17636 fi
17637 $RM -r conftest*
17638 { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5
17639 echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6; }
17640 ;;
17641 esac
17642 fi
17643 ;;
17644 esac
17645
17646
17647
17648
17649
17650
17651
17652
17653
17654
17655
17656
17657
17658
17659
17660
17661
17662
17663
17664
17665
17666
17667
17668
17669
17670
17671
17672
17673
17674
17675
17676
17677
17678
17679
17680
17681
17682
17683
17684
17685
17686
17687
17688
17689
17690
17691
17692
17693
17694
17695
17696
17697
17698
17699
17700
17701
17702
17703
17704
17705
17706
17707
17708
17709 { echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
17710 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; }
17711
17712 library_names_spec=
17713 libname_spec='lib$name'
17714 soname_spec=
17715 shrext_cmds=".so"
17716 postinstall_cmds=
17717 postuninstall_cmds=
17718 finish_cmds=
17719 finish_eval=
17720 shlibpath_var=
17721 shlibpath_overrides_runpath=unknown
17722 version_type=none
17723 dynamic_linker="$host_os ld.so"
17724 sys_lib_dlsearch_path_spec="/lib /usr/lib"
17725 need_lib_prefix=unknown
17726 hardcode_into_libs=no
17727
17728 # when you set need_version to no, make sure it does not cause -set_version
17729 # flags to be left without arguments
17730 need_version=unknown
17731
17732 case $host_os in
17733 aix3*)
17734 version_type=linux
17735 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
17736 shlibpath_var=LIBPATH
17737
17738 # AIX 3 has no versioning support, so we append a major version to the name.
17739 soname_spec='${libname}${release}${shared_ext}$major'
17740 ;;
17741
17742 aix[4-9]*)
17743 version_type=linux
17744 need_lib_prefix=no
17745 need_version=no
17746 hardcode_into_libs=yes
17747 if test "$host_cpu" = ia64; then
17748 # AIX 5 supports IA64
17749 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
17750 shlibpath_var=LD_LIBRARY_PATH
17751 else
17752 # With GCC up to 2.95.x, collect2 would create an import file
17753 # for dependence libraries. The import file would start with
17754 # the line `#! .'. This would cause the generated library to
17755 # depend on `.', always an invalid library. This was fixed in
17756 # development snapshots of GCC prior to 3.0.
17757 case $host_os in
17758 aix4 | aix4.[01] | aix4.[01].*)
17759 if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
17760 echo ' yes '
17761 echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
17762 :
17763 else
17764 can_build_shared=no
17765 fi
17766 ;;
17767 esac
17768 # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
17769 # soname into executable. Probably we can add versioning support to
17770 # collect2, so additional links can be useful in future.
17771 if test "$aix_use_runtimelinking" = yes; then
17772 # If using run time linking (on AIX 4.2 or later) use lib<name>.so
17773 # instead of lib<name>.a to let people know that these are not
17774 # typical AIX shared libraries.
17775 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
17776 else
17777 # We preserve .a as extension for shared libraries through AIX4.2
17778 # and later when we are not doing run time linking.
17779 library_names_spec='${libname}${release}.a $libname.a'
17780 soname_spec='${libname}${release}${shared_ext}$major'
17781 fi
17782 shlibpath_var=LIBPATH
17783 fi
17784 ;;
17785
17786 amigaos*)
17787 case $host_cpu in
17788 powerpc)
17789 # Since July 2007 AmigaOS4 officially supports .so libraries.
17790 # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
17791 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
17792 ;;
17793 m68k)
17794 library_names_spec='$libname.ixlibrary $libname.a'
17795 # Create ${libname}_ixlibrary.a entries in /sys/libs.
17796 finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
17797 ;;
17798 esac
17799 ;;
17800
17801 beos*)
17802 library_names_spec='${libname}${shared_ext}'
17803 dynamic_linker="$host_os ld.so"
17804 shlibpath_var=LIBRARY_PATH
17805 ;;
17806
17807 bsdi[45]*)
17808 version_type=linux
17809 need_version=no
17810 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
17811 soname_spec='${libname}${release}${shared_ext}$major'
17812 finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
17813 shlibpath_var=LD_LIBRARY_PATH
17814 sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
17815 sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
17816 # the default ld.so.conf also contains /usr/contrib/lib and
17817 # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
17818 # libtool to hard-code these into programs
17819 ;;
17820
17821 cygwin* | mingw* | pw32*)
17822 version_type=windows
17823 shrext_cmds=".dll"
17824 need_version=no
17825 need_lib_prefix=no
17826
17827 case $GCC,$host_os in
17828 yes,cygwin* | yes,mingw* | yes,pw32*)
17829 library_names_spec='$libname.dll.a'
17830 # DLL is installed to $(libdir)/../bin by postinstall_cmds
17831 postinstall_cmds='base_file=`basename \${file}`~
17832 dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
17833 dldir=$destdir/`dirname \$dlpath`~
17834 test -d \$dldir || mkdir -p \$dldir~
17835 $install_prog $dir/$dlname \$dldir/$dlname~
17836 chmod a+x \$dldir/$dlname~
17837 if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
17838 eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
17839 fi'
17840 postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
17841 dlpath=$dir/\$dldll~
17842 $RM \$dlpath'
17843 shlibpath_overrides_runpath=yes
17844
17845 case $host_os in
17846 cygwin*)
17847 # Cygwin DLLs use 'cyg' prefix rather than 'lib'
17848 soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
17849 sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
17850 ;;
17851 mingw*)
17852 # MinGW DLLs use traditional 'lib' prefix
17853 soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
17854 sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
17855 if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
17856 # It is most probably a Windows format PATH printed by
17857 # mingw gcc, but we are running on Cygwin. Gcc prints its search
17858 # path with ; separators, and with drive letters. We can handle the
17859 # drive letters (cygwin fileutils understands them), so leave them,
17860 # especially as we might pass files found there to a mingw objdump,
17861 # which wouldn't understand a cygwinified path. Ahh.
17862 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
17863 else
17864 sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
17865 fi
17866 ;;
17867 pw32*)
17868 # pw32 DLLs use 'pw' prefix rather than 'lib'
17869 library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
17870 ;;
17871 esac
17872 ;;
17873
17874 *)
17875 library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
17876 ;;
17877 esac
17878 dynamic_linker='Win32 ld.exe'
17879 # FIXME: first we should search . and the directory the executable is in
17880 shlibpath_var=PATH
17881 ;;
17882
17883 darwin* | rhapsody*)
17884 dynamic_linker="$host_os dyld"
17885 version_type=darwin
17886 need_lib_prefix=no
17887 need_version=no
17888 library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext ${libname}${release}${versuffix}$shared_ext'
17889 soname_spec='${libname}${release}${major}$shared_ext'
17890 shlibpath_overrides_runpath=yes
17891 shlibpath_var=DYLD_LIBRARY_PATH
17892 shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
17893
17894 sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
17895 ;;
17896
17897 dgux*)
17898 version_type=linux
17899 need_lib_prefix=no
17900 need_version=no
17901 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
17902 soname_spec='${libname}${release}${shared_ext}$major'
17903 shlibpath_var=LD_LIBRARY_PATH
17904 ;;
17905
17906 freebsd1*)
17907 dynamic_linker=no
17908 ;;
17909
17910 freebsd* | dragonfly*)
17911 # DragonFly does not have aout. When/if they implement a new
17912 # versioning mechanism, adjust this.
17913 if test -x /usr/bin/objformat; then
17914 objformat=`/usr/bin/objformat`
17915 else
17916 case $host_os in
17917 freebsd[123]*) objformat=aout ;;
17918 *) objformat=elf ;;
17919 esac
17920 fi
17921 version_type=freebsd-$objformat
17922 case $version_type in
17923 freebsd-elf*)
17924 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
17925 need_version=no
17926 need_lib_prefix=no
17927 ;;
17928 freebsd-*)
17929 library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
17930 need_version=yes
17931 ;;
17932 esac
17933 shlibpath_var=LD_LIBRARY_PATH
17934 case $host_os in
17935 freebsd2*)
17936 shlibpath_overrides_runpath=yes
17937 ;;
17938 freebsd3.[01]* | freebsdelf3.[01]*)
17939 shlibpath_overrides_runpath=yes
17940 hardcode_into_libs=yes
17941 ;;
17942 freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
17943 freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
17944 shlibpath_overrides_runpath=no
17945 hardcode_into_libs=yes
17946 ;;
17947 *) # from 4.6 on, and DragonFly
17948 shlibpath_overrides_runpath=yes
17949 hardcode_into_libs=yes
17950 ;;
17951 esac
17952 ;;
17953
17954 gnu*)
17955 version_type=linux
17956 need_lib_prefix=no
17957 need_version=no
17958 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
17959 soname_spec='${libname}${release}${shared_ext}$major'
17960 shlibpath_var=LD_LIBRARY_PATH
17961 hardcode_into_libs=yes
17962 ;;
17963
17964 hpux9* | hpux10* | hpux11*)
17965 # Give a soname corresponding to the major version so that dld.sl refuses to
17966 # link against other versions.
17967 version_type=sunos
17968 need_lib_prefix=no
17969 need_version=no
17970 case $host_cpu in
17971 ia64*)
17972 shrext_cmds='.so'
17973 hardcode_into_libs=yes
17974 dynamic_linker="$host_os dld.so"
17975 shlibpath_var=LD_LIBRARY_PATH
17976 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
17977 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
17978 soname_spec='${libname}${release}${shared_ext}$major'
17979 if test "X$HPUX_IA64_MODE" = X32; then
17980 sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
17981 else
17982 sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
17983 fi
17984 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
17985 ;;
17986 hppa*64*)
17987 shrext_cmds='.sl'
17988 hardcode_into_libs=yes
17989 dynamic_linker="$host_os dld.sl"
17990 shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
17991 shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
17992 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
17993 soname_spec='${libname}${release}${shared_ext}$major'
17994 sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
17995 sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
17996 ;;
17997 *)
17998 shrext_cmds='.sl'
17999 dynamic_linker="$host_os dld.sl"
18000 shlibpath_var=SHLIB_PATH
18001 shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
18002 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18003 soname_spec='${libname}${release}${shared_ext}$major'
18004 ;;
18005 esac
18006 # HP-UX runs *really* slowly unless shared libraries are mode 555.
18007 postinstall_cmds='chmod 555 $lib'
18008 ;;
18009
18010 interix[3-9]*)
18011 version_type=linux
18012 need_lib_prefix=no
18013 need_version=no
18014 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
18015 soname_spec='${libname}${release}${shared_ext}$major'
18016 dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
18017 shlibpath_var=LD_LIBRARY_PATH
18018 shlibpath_overrides_runpath=no
18019 hardcode_into_libs=yes
18020 ;;
18021
18022 irix5* | irix6* | nonstopux*)
18023 case $host_os in
18024 nonstopux*) version_type=nonstopux ;;
18025 *)
18026 if test "$lt_cv_prog_gnu_ld" = yes; then
18027 version_type=linux
18028 else
18029 version_type=irix
18030 fi ;;
18031 esac
18032 need_lib_prefix=no
18033 need_version=no
18034 soname_spec='${libname}${release}${shared_ext}$major'
18035 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
18036 case $host_os in
18037 irix5* | nonstopux*)
18038 libsuff= shlibsuff=
18039 ;;
18040 *)
18041 case $LD in # libtool.m4 will add one of these switches to LD
18042 *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
18043 libsuff= shlibsuff= libmagic=32-bit;;
18044 *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
18045 libsuff=32 shlibsuff=N32 libmagic=N32;;
18046 *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
18047 libsuff=64 shlibsuff=64 libmagic=64-bit;;
18048 *) libsuff= shlibsuff= libmagic=never-match;;
18049 esac
18050 ;;
18051 esac
18052 shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
18053 shlibpath_overrides_runpath=no
18054 sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
18055 sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
18056 hardcode_into_libs=yes
18057 ;;
18058
18059 # No shared lib support for Linux oldld, aout, or coff.
18060 linux*oldld* | linux*aout* | linux*coff*)
18061 dynamic_linker=no
18062 ;;
18063
18064 # This must be Linux ELF.
18065 linux* | k*bsd*-gnu)
18066 version_type=linux
18067 need_lib_prefix=no
18068 need_version=no
18069 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18070 soname_spec='${libname}${release}${shared_ext}$major'
18071 finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
18072 shlibpath_var=LD_LIBRARY_PATH
18073 shlibpath_overrides_runpath=no
18074 # Some binutils ld are patched to set DT_RUNPATH
18075 save_LDFLAGS=$LDFLAGS
18076 save_libdir=$libdir
18077 eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
18078 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
18079 cat >conftest.$ac_ext <<_ACEOF
18080 /* confdefs.h. */
18081 _ACEOF
18082 cat confdefs.h >>conftest.$ac_ext
18083 cat >>conftest.$ac_ext <<_ACEOF
18084 /* end confdefs.h. */
18085
18086 int
18087 main ()
18088 {
18089
18090 ;
18091 return 0;
18092 }
18093 _ACEOF
18094 rm -f conftest.$ac_objext conftest$ac_exeext
18095 if { (ac_try="$ac_link"
18096 case "(($ac_try" in
18097 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18098 *) ac_try_echo=$ac_try;;
18099 esac
18100 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18101 (eval "$ac_link") 2>conftest.er1
18102 ac_status=$?
18103 grep -v '^ *+' conftest.er1 >conftest.err
18104 rm -f conftest.er1
18105 cat conftest.err >&5
18106 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18107 (exit $ac_status); } && {
18108 test -z "$ac_cxx_werror_flag" ||
18109 test ! -s conftest.err
18110 } && test -s conftest$ac_exeext &&
18111 $as_test_x conftest$ac_exeext; then
18112 if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then
18113 shlibpath_overrides_runpath=yes
18114 fi
18115
18116 else
18117 echo "$as_me: failed program was:" >&5
18118 sed 's/^/| /' conftest.$ac_ext >&5
18119
18120
18121 fi
18122
18123 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
18124 conftest$ac_exeext conftest.$ac_ext
18125 LDFLAGS=$save_LDFLAGS
18126 libdir=$save_libdir
18127
18128 # This implies no fast_install, which is unacceptable.
18129 # Some rework will be needed to allow for fast_install
18130 # before this can be enabled.
18131 hardcode_into_libs=yes
18132
18133 # Append ld.so.conf contents to the search path
18134 if test -f /etc/ld.so.conf; then
18135 lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
18136 sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
18137 fi
18138
18139 # We used to test for /lib/ld.so.1 and disable shared libraries on
18140 # powerpc, because MkLinux only supported shared libraries with the
18141 # GNU dynamic linker. Since this was broken with cross compilers,
18142 # most powerpc-linux boxes support dynamic linking these days and
18143 # people can always --disable-shared, the test was removed, and we
18144 # assume the GNU/Linux dynamic linker is in use.
18145 dynamic_linker='GNU/Linux ld.so'
18146 ;;
18147
18148 netbsd*)
18149 version_type=sunos
18150 need_lib_prefix=no
18151 need_version=no
18152 if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
18153 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
18154 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
18155 dynamic_linker='NetBSD (a.out) ld.so'
18156 else
18157 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
18158 soname_spec='${libname}${release}${shared_ext}$major'
18159 dynamic_linker='NetBSD ld.elf_so'
18160 fi
18161 shlibpath_var=LD_LIBRARY_PATH
18162 shlibpath_overrides_runpath=yes
18163 hardcode_into_libs=yes
18164 ;;
18165
18166 newsos6)
18167 version_type=linux
18168 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18169 shlibpath_var=LD_LIBRARY_PATH
18170 shlibpath_overrides_runpath=yes
18171 ;;
18172
18173 *nto* | *qnx*)
18174 version_type=qnx
18175 need_lib_prefix=no
18176 need_version=no
18177 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18178 soname_spec='${libname}${release}${shared_ext}$major'
18179 shlibpath_var=LD_LIBRARY_PATH
18180 shlibpath_overrides_runpath=no
18181 hardcode_into_libs=yes
18182 dynamic_linker='ldqnx.so'
18183 ;;
18184
18185 openbsd*)
18186 version_type=sunos
18187 sys_lib_dlsearch_path_spec="/usr/lib"
18188 need_lib_prefix=no
18189 # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
18190 case $host_os in
18191 openbsd3.3 | openbsd3.3.*) need_version=yes ;;
18192 *) need_version=no ;;
18193 esac
18194 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
18195 finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
18196 shlibpath_var=LD_LIBRARY_PATH
18197 if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
18198 case $host_os in
18199 openbsd2.[89] | openbsd2.[89].*)
18200 shlibpath_overrides_runpath=no
18201 ;;
18202 *)
18203 shlibpath_overrides_runpath=yes
18204 ;;
18205 esac
18206 else
18207 shlibpath_overrides_runpath=yes
18208 fi
18209 ;;
18210
18211 os2*)
18212 libname_spec='$name'
18213 shrext_cmds=".dll"
18214 need_lib_prefix=no
18215 library_names_spec='$libname${shared_ext} $libname.a'
18216 dynamic_linker='OS/2 ld.exe'
18217 shlibpath_var=LIBPATH
18218 ;;
18219
18220 osf3* | osf4* | osf5*)
18221 version_type=osf
18222 need_lib_prefix=no
18223 need_version=no
18224 soname_spec='${libname}${release}${shared_ext}$major'
18225 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18226 shlibpath_var=LD_LIBRARY_PATH
18227 sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
18228 sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
18229 ;;
18230
18231 rdos*)
18232 dynamic_linker=no
18233 ;;
18234
18235 solaris*)
18236 version_type=linux
18237 need_lib_prefix=no
18238 need_version=no
18239 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18240 soname_spec='${libname}${release}${shared_ext}$major'
18241 shlibpath_var=LD_LIBRARY_PATH
18242 shlibpath_overrides_runpath=yes
18243 hardcode_into_libs=yes
18244 # ldd complains unless libraries are executable
18245 postinstall_cmds='chmod +x $lib'
18246 ;;
18247
18248 sunos4*)
18249 version_type=sunos
18250 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
18251 finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
18252 shlibpath_var=LD_LIBRARY_PATH
18253 shlibpath_overrides_runpath=yes
18254 if test "$with_gnu_ld" = yes; then
18255 need_lib_prefix=no
18256 fi
18257 need_version=yes
18258 ;;
18259
18260 sysv4 | sysv4.3*)
18261 version_type=linux
18262 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18263 soname_spec='${libname}${release}${shared_ext}$major'
18264 shlibpath_var=LD_LIBRARY_PATH
18265 case $host_vendor in
18266 sni)
18267 shlibpath_overrides_runpath=no
18268 need_lib_prefix=no
18269 runpath_var=LD_RUN_PATH
18270 ;;
18271 siemens)
18272 need_lib_prefix=no
18273 ;;
18274 motorola)
18275 need_lib_prefix=no
18276 need_version=no
18277 shlibpath_overrides_runpath=no
18278 sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
18279 ;;
18280 esac
18281 ;;
18282
18283 sysv4*MP*)
18284 if test -d /usr/nec ;then
18285 version_type=linux
18286 library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
18287 soname_spec='$libname${shared_ext}.$major'
18288 shlibpath_var=LD_LIBRARY_PATH
18289 fi
18290 ;;
18291
18292 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
18293 version_type=freebsd-elf
18294 need_lib_prefix=no
18295 need_version=no
18296 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
18297 soname_spec='${libname}${release}${shared_ext}$major'
18298 shlibpath_var=LD_LIBRARY_PATH
18299 shlibpath_overrides_runpath=yes
18300 hardcode_into_libs=yes
18301 if test "$with_gnu_ld" = yes; then
18302 sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
18303 else
18304 sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
18305 case $host_os in
18306 sco3.2v5*)
18307 sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
18308 ;;
18309 esac
18310 fi
18311 sys_lib_dlsearch_path_spec='/usr/lib'
18312 ;;
18313
18314 tpf*)
18315 # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
18316 version_type=linux
18317 need_lib_prefix=no
18318 need_version=no
18319 library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18320 shlibpath_var=LD_LIBRARY_PATH
18321 shlibpath_overrides_runpath=no
18322 hardcode_into_libs=yes
18323 ;;
18324
18325 uts4*)
18326 version_type=linux
18327 library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
18328 soname_spec='${libname}${release}${shared_ext}$major'
18329 shlibpath_var=LD_LIBRARY_PATH
18330 ;;
18331
18332 *)
18333 dynamic_linker=no
18334 ;;
18335 esac
18336 { echo "$as_me:$LINENO: result: $dynamic_linker" >&5
18337 echo "${ECHO_T}$dynamic_linker" >&6; }
18338 test "$dynamic_linker" = no && can_build_shared=no
18339
18340 variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
18341 if test "$GCC" = yes; then
18342 variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
18343 fi
18344
18345 if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
18346 sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
18347 fi
18348 if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
18349 sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
18350 fi
18351
18352
18353
18354
18355
18356
18357
18358
18359
18360
18361
18362
18363
18364
18365
18366
18367
18368
18369
18370
18371
18372
18373
18374
18375
18376
18377
18378
18379
18380
18381
18382
18383
18384
18385
18386
18387 { echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
18388 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; }
18389 hardcode_action_CXX=
18390 if test -n "$hardcode_libdir_flag_spec_CXX" ||
18391 test -n "$runpath_var_CXX" ||
18392 test "X$hardcode_automatic_CXX" = "Xyes" ; then
18393
18394 # We can hardcode non-existent directories.
18395 if test "$hardcode_direct_CXX" != no &&
18396 # If the only mechanism to avoid hardcoding is shlibpath_var, we
18397 # have to relink, otherwise we might link with an installed library
18398 # when we should be linking with a yet-to-be-installed one
18399 ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
18400 test "$hardcode_minus_L_CXX" != no; then
18401 # Linking always hardcodes the temporary library directory.
18402 hardcode_action_CXX=relink
18403 else
18404 # We can link without hardcoding, and we can hardcode nonexisting dirs.
18405 hardcode_action_CXX=immediate
18406 fi
18407 else
18408 # We cannot hardcode anything, or else we can only hardcode existing
18409 # directories.
18410 hardcode_action_CXX=unsupported
18411 fi
18412 { echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5
18413 echo "${ECHO_T}$hardcode_action_CXX" >&6; }
18414
18415 if test "$hardcode_action_CXX" = relink ||
18416 test "$inherit_rpath_CXX" = yes; then
18417 # Fast installation is not supported
18418 enable_fast_install=no
18419 elif test "$shlibpath_overrides_runpath" = yes ||
18420 test "$enable_shared" = no; then
18421 # Fast installation is not necessary
18422 enable_fast_install=needless
18423 fi
18424
18425
18426
18427
18428
18429
18430
18431 fi # test -n "$compiler"
18432
18433 CC=$lt_save_CC
18434 LDCXX=$LD
18435 LD=$lt_save_LD
18436 GCC=$lt_save_GCC
18437 with_gnu_ld=$lt_save_with_gnu_ld
18438 lt_cv_path_LDCXX=$lt_cv_path_LD
18439 lt_cv_path_LD=$lt_save_path_LD
18440 lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
18441 lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
18442 fi # test "$_lt_caught_CXX_error" != yes
18443
18444 ac_ext=c
18445 ac_cpp='$CPP $CPPFLAGS'
18446 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
18447 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
18448 ac_compiler_gnu=$ac_cv_c_compiler_gnu
18449
18450
18451 ac_ext=cpp
18452 ac_cpp='$CXXCPP $CPPFLAGS'
18453 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
18454 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
18455 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
18456
18457
18458
18459 for ac_header in cstring
18460 do
18461 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
18462 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
18463 { echo "$as_me:$LINENO: checking for $ac_header" >&5
18464 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
18465 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
18466 echo $ECHO_N "(cached) $ECHO_C" >&6
18467 fi
18468 ac_res=`eval echo '${'$as_ac_Header'}'`
18469 { echo "$as_me:$LINENO: result: $ac_res" >&5
18470 echo "${ECHO_T}$ac_res" >&6; }
18471 else
18472 # Is the header compilable?
18473 { echo "$as_me:$LINENO: checking $ac_header usability" >&5
18474 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
18475 cat >conftest.$ac_ext <<_ACEOF
18476 /* confdefs.h. */
18477 _ACEOF
18478 cat confdefs.h >>conftest.$ac_ext
18479 cat >>conftest.$ac_ext <<_ACEOF
18480 /* end confdefs.h. */
18481 $ac_includes_default
18482 #include <$ac_header>
18483 _ACEOF
18484 rm -f conftest.$ac_objext
18485 if { (ac_try="$ac_compile"
18486 case "(($ac_try" in
18487 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18488 *) ac_try_echo=$ac_try;;
18489 esac
18490 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18491 (eval "$ac_compile") 2>conftest.er1
18492 ac_status=$?
18493 grep -v '^ *+' conftest.er1 >conftest.err
18494 rm -f conftest.er1
18495 cat conftest.err >&5
18496 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18497 (exit $ac_status); } && {
18498 test -z "$ac_cxx_werror_flag" ||
18499 test ! -s conftest.err
18500 } && test -s conftest.$ac_objext; then
18501 ac_header_compiler=yes
18502 else
18503 echo "$as_me: failed program was:" >&5
18504 sed 's/^/| /' conftest.$ac_ext >&5
18505
18506 ac_header_compiler=no
18507 fi
18508
18509 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
18510 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
18511 echo "${ECHO_T}$ac_header_compiler" >&6; }
18512
18513 # Is the header present?
18514 { echo "$as_me:$LINENO: checking $ac_header presence" >&5
18515 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
18516 cat >conftest.$ac_ext <<_ACEOF
18517 /* confdefs.h. */
18518 _ACEOF
18519 cat confdefs.h >>conftest.$ac_ext
18520 cat >>conftest.$ac_ext <<_ACEOF
18521 /* end confdefs.h. */
18522 #include <$ac_header>
18523 _ACEOF
18524 if { (ac_try="$ac_cpp conftest.$ac_ext"
18525 case "(($ac_try" in
18526 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18527 *) ac_try_echo=$ac_try;;
18528 esac
18529 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18530 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
18531 ac_status=$?
18532 grep -v '^ *+' conftest.er1 >conftest.err
18533 rm -f conftest.er1
18534 cat conftest.err >&5
18535 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18536 (exit $ac_status); } >/dev/null && {
18537 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
18538 test ! -s conftest.err
18539 }; then
18540 ac_header_preproc=yes
18541 else
18542 echo "$as_me: failed program was:" >&5
18543 sed 's/^/| /' conftest.$ac_ext >&5
18544
18545 ac_header_preproc=no
18546 fi
18547
18548 rm -f conftest.err conftest.$ac_ext
18549 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
18550 echo "${ECHO_T}$ac_header_preproc" >&6; }
18551
18552 # So? What about this header?
18553 case $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in
18554 yes:no: )
18555 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
18556 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
18557 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
18558 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
18559 ac_header_preproc=yes
18560 ;;
18561 no:yes:* )
18562 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
18563 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
18564 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
18565 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
18566 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
18567 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
18568 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
18569 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
18570 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
18571 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
18572 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
18573 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
18574 ( cat <<\_ASBOX
18575 ## ------------------------------ ##
18576 ## Report this to bugs@afflib.org ##
18577 ## ------------------------------ ##
18578 _ASBOX
18579 ) | sed "s/^/$as_me: WARNING: /" >&2
18580 ;;
18581 esac
18582 { echo "$as_me:$LINENO: checking for $ac_header" >&5
18583 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
18584 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
18585 echo $ECHO_N "(cached) $ECHO_C" >&6
18586 else
18587 eval "$as_ac_Header=\$ac_header_preproc"
18588 fi
18589 ac_res=`eval echo '${'$as_ac_Header'}'`
18590 { echo "$as_me:$LINENO: result: $ac_res" >&5
18591 echo "${ECHO_T}$ac_res" >&6; }
18592
18593 fi
18594 if test `eval echo '${'$as_ac_Header'}'` = yes; then
18595 cat >>confdefs.h <<_ACEOF
18596 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
18597 _ACEOF
18598
18599 fi
18600
18601 done
18602
18603 ac_ext=c
18604 ac_cpp='$CPP $CPPFLAGS'
18605 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
18606 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
18607 ac_compiler_gnu=$ac_cv_c_compiler_gnu
18608
18609
18610
18611
18612 ################################################################
18613 ## LIBEWF support
18614
18615
18616
18617
18618
18619
18620
18621 # Check whether --enable-libewf was given.
18622 if test "${enable_libewf+set}" = set; then
18623 enableval=$enable_libewf; enable_libewf=$enableval
18624 else
18625 enable_libewf=yes
18626 fi
18627
18628
18629 if test "${enable_libewf}" = "yes" ; then
18630
18631 for ac_header in libewf.h
18632 do
18633 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
18634 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
18635 { echo "$as_me:$LINENO: checking for $ac_header" >&5
18636 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
18637 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
18638 echo $ECHO_N "(cached) $ECHO_C" >&6
18639 fi
18640 ac_res=`eval echo '${'$as_ac_Header'}'`
18641 { echo "$as_me:$LINENO: result: $ac_res" >&5
18642 echo "${ECHO_T}$ac_res" >&6; }
18643 else
18644 # Is the header compilable?
18645 { echo "$as_me:$LINENO: checking $ac_header usability" >&5
18646 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
18647 cat >conftest.$ac_ext <<_ACEOF
18648 /* confdefs.h. */
18649 _ACEOF
18650 cat confdefs.h >>conftest.$ac_ext
18651 cat >>conftest.$ac_ext <<_ACEOF
18652 /* end confdefs.h. */
18653 $ac_includes_default
18654 #include <$ac_header>
18655 _ACEOF
18656 rm -f conftest.$ac_objext
18657 if { (ac_try="$ac_compile"
18658 case "(($ac_try" in
18659 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18660 *) ac_try_echo=$ac_try;;
18661 esac
18662 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18663 (eval "$ac_compile") 2>conftest.er1
18664 ac_status=$?
18665 grep -v '^ *+' conftest.er1 >conftest.err
18666 rm -f conftest.er1
18667 cat conftest.err >&5
18668 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18669 (exit $ac_status); } && {
18670 test -z "$ac_c_werror_flag" ||
18671 test ! -s conftest.err
18672 } && test -s conftest.$ac_objext; then
18673 ac_header_compiler=yes
18674 else
18675 echo "$as_me: failed program was:" >&5
18676 sed 's/^/| /' conftest.$ac_ext >&5
18677
18678 ac_header_compiler=no
18679 fi
18680
18681 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
18682 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
18683 echo "${ECHO_T}$ac_header_compiler" >&6; }
18684
18685 # Is the header present?
18686 { echo "$as_me:$LINENO: checking $ac_header presence" >&5
18687 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
18688 cat >conftest.$ac_ext <<_ACEOF
18689 /* confdefs.h. */
18690 _ACEOF
18691 cat confdefs.h >>conftest.$ac_ext
18692 cat >>conftest.$ac_ext <<_ACEOF
18693 /* end confdefs.h. */
18694 #include <$ac_header>
18695 _ACEOF
18696 if { (ac_try="$ac_cpp conftest.$ac_ext"
18697 case "(($ac_try" in
18698 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18699 *) ac_try_echo=$ac_try;;
18700 esac
18701 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18702 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
18703 ac_status=$?
18704 grep -v '^ *+' conftest.er1 >conftest.err
18705 rm -f conftest.er1
18706 cat conftest.err >&5
18707 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18708 (exit $ac_status); } >/dev/null && {
18709 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
18710 test ! -s conftest.err
18711 }; then
18712 ac_header_preproc=yes
18713 else
18714 echo "$as_me: failed program was:" >&5
18715 sed 's/^/| /' conftest.$ac_ext >&5
18716
18717 ac_header_preproc=no
18718 fi
18719
18720 rm -f conftest.err conftest.$ac_ext
18721 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
18722 echo "${ECHO_T}$ac_header_preproc" >&6; }
18723
18724 # So? What about this header?
18725 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
18726 yes:no: )
18727 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
18728 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
18729 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
18730 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
18731 ac_header_preproc=yes
18732 ;;
18733 no:yes:* )
18734 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
18735 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
18736 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
18737 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
18738 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
18739 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
18740 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
18741 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
18742 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
18743 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
18744 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
18745 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
18746 ( cat <<\_ASBOX
18747 ## ------------------------------ ##
18748 ## Report this to bugs@afflib.org ##
18749 ## ------------------------------ ##
18750 _ASBOX
18751 ) | sed "s/^/$as_me: WARNING: /" >&2
18752 ;;
18753 esac
18754 { echo "$as_me:$LINENO: checking for $ac_header" >&5
18755 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
18756 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
18757 echo $ECHO_N "(cached) $ECHO_C" >&6
18758 else
18759 eval "$as_ac_Header=\$ac_header_preproc"
18760 fi
18761 ac_res=`eval echo '${'$as_ac_Header'}'`
18762 { echo "$as_me:$LINENO: result: $ac_res" >&5
18763 echo "${ECHO_T}$ac_res" >&6; }
18764
18765 fi
18766 if test `eval echo '${'$as_ac_Header'}'` = yes; then
18767 cat >>confdefs.h <<_ACEOF
18768 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
18769 _ACEOF
18770
18771 else
18772 enable_libewf=no
18773 fi
18774
18775 done
18776
18777 fi
18778
18779 if test "${enable_libewf}" = "yes" ; then
18780 { echo "$as_me:$LINENO: On linux, libewf has a dependency which forces linking with -luuid" >&5
18781 echo "$as_me: On linux, libewf has a dependency which forces linking with -luuid" >&6;}
18782 { echo "$as_me:$LINENO: so if we are running on linux and that version of libewf is installed," >&5
18783 echo "$as_me: so if we are running on linux and that version of libewf is installed," >&6;}
18784 { echo "$as_me:$LINENO: make sure the libuuid is installed" >&5
18785 echo "$as_me: make sure the libuuid is installed" >&6;}
18786
18787 if test -r /usr/lib/libewf.la ; then
18788 if grep luuid /usr/lib/libewf.la ; then
18789 { echo "$as_me:$LINENO: Installed libewf requires libuuid." >&5
18790 echo "$as_me: Installed libewf requires libuuid." >&6;}
18791
18792 { echo "$as_me:$LINENO: checking for uuid_generate_random in -luuid" >&5
18793 echo $ECHO_N "checking for uuid_generate_random in -luuid... $ECHO_C" >&6; }
18794 if test "${ac_cv_lib_uuid_uuid_generate_random+set}" = set; then
18795 echo $ECHO_N "(cached) $ECHO_C" >&6
18796 else
18797 ac_check_lib_save_LIBS=$LIBS
18798 LIBS="-luuid $LIBS"
18799 cat >conftest.$ac_ext <<_ACEOF
18800 /* confdefs.h. */
18801 _ACEOF
18802 cat confdefs.h >>conftest.$ac_ext
18803 cat >>conftest.$ac_ext <<_ACEOF
18804 /* end confdefs.h. */
18805
18806 /* Override any GCC internal prototype to avoid an error.
18807 Use char because int might match the return type of a GCC
18808 builtin and then its argument prototype would still apply. */
18809 #ifdef __cplusplus
18810 extern "C"
18811 #endif
18812 char uuid_generate_random ();
18813 int
18814 main ()
18815 {
18816 return uuid_generate_random ();
18817 ;
18818 return 0;
18819 }
18820 _ACEOF
18821 rm -f conftest.$ac_objext conftest$ac_exeext
18822 if { (ac_try="$ac_link"
18823 case "(($ac_try" in
18824 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18825 *) ac_try_echo=$ac_try;;
18826 esac
18827 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18828 (eval "$ac_link") 2>conftest.er1
18829 ac_status=$?
18830 grep -v '^ *+' conftest.er1 >conftest.err
18831 rm -f conftest.er1
18832 cat conftest.err >&5
18833 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18834 (exit $ac_status); } && {
18835 test -z "$ac_c_werror_flag" ||
18836 test ! -s conftest.err
18837 } && test -s conftest$ac_exeext &&
18838 $as_test_x conftest$ac_exeext; then
18839 ac_cv_lib_uuid_uuid_generate_random=yes
18840 else
18841 echo "$as_me: failed program was:" >&5
18842 sed 's/^/| /' conftest.$ac_ext >&5
18843
18844 ac_cv_lib_uuid_uuid_generate_random=no
18845 fi
18846
18847 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
18848 conftest$ac_exeext conftest.$ac_ext
18849 LIBS=$ac_check_lib_save_LIBS
18850 fi
18851 { echo "$as_me:$LINENO: result: $ac_cv_lib_uuid_uuid_generate_random" >&5
18852 echo "${ECHO_T}$ac_cv_lib_uuid_uuid_generate_random" >&6; }
18853 if test $ac_cv_lib_uuid_uuid_generate_random = yes; then
18854 cat >>confdefs.h <<_ACEOF
18855 #define HAVE_LIBUUID 1
18856 _ACEOF
18857
18858 LIBS="-luuid $LIBS"
18859
18860 else
18861 enable_libewf=no
18862 fi
18863
18864 fi
18865 fi
18866 fi
18867
18868 if test "${enable_libewf}" = "yes" ; then
18869
18870 { echo "$as_me:$LINENO: checking for libewf_get_version in -lewf" >&5
18871 echo $ECHO_N "checking for libewf_get_version in -lewf... $ECHO_C" >&6; }
18872 if test "${ac_cv_lib_ewf_libewf_get_version+set}" = set; then
18873 echo $ECHO_N "(cached) $ECHO_C" >&6
18874 else
18875 ac_check_lib_save_LIBS=$LIBS
18876 LIBS="-lewf $LIBS"
18877 cat >conftest.$ac_ext <<_ACEOF
18878 /* confdefs.h. */
18879 _ACEOF
18880 cat confdefs.h >>conftest.$ac_ext
18881 cat >>conftest.$ac_ext <<_ACEOF
18882 /* end confdefs.h. */
18883
18884 /* Override any GCC internal prototype to avoid an error.
18885 Use char because int might match the return type of a GCC
18886 builtin and then its argument prototype would still apply. */
18887 #ifdef __cplusplus
18888 extern "C"
18889 #endif
18890 char libewf_get_version ();
18891 int
18892 main ()
18893 {
18894 return libewf_get_version ();
18895 ;
18896 return 0;
18897 }
18898 _ACEOF
18899 rm -f conftest.$ac_objext conftest$ac_exeext
18900 if { (ac_try="$ac_link"
18901 case "(($ac_try" in
18902 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18903 *) ac_try_echo=$ac_try;;
18904 esac
18905 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
18906 (eval "$ac_link") 2>conftest.er1
18907 ac_status=$?
18908 grep -v '^ *+' conftest.er1 >conftest.err
18909 rm -f conftest.er1
18910 cat conftest.err >&5
18911 echo "$as_me:$LINENO: \$? = $ac_status" >&5
18912 (exit $ac_status); } && {
18913 test -z "$ac_c_werror_flag" ||
18914 test ! -s conftest.err
18915 } && test -s conftest$ac_exeext &&
18916 $as_test_x conftest$ac_exeext; then
18917 ac_cv_lib_ewf_libewf_get_version=yes
18918 else
18919 echo "$as_me: failed program was:" >&5
18920 sed 's/^/| /' conftest.$ac_ext >&5
18921
18922 ac_cv_lib_ewf_libewf_get_version=no
18923 fi
18924
18925 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
18926 conftest$ac_exeext conftest.$ac_ext
18927 LIBS=$ac_check_lib_save_LIBS
18928 fi
18929 { echo "$as_me:$LINENO: result: $ac_cv_lib_ewf_libewf_get_version" >&5
18930 echo "${ECHO_T}$ac_cv_lib_ewf_libewf_get_version" >&6; }
18931 if test $ac_cv_lib_ewf_libewf_get_version = yes; then
18932 cat >>confdefs.h <<_ACEOF
18933 #define HAVE_LIBEWF 1
18934 _ACEOF
18935
18936 LIBS="-lewf $LIBS"
18937
18938 else
18939 enable_libewf=no
18940 fi
18941
18942 fi
18943
18944 if test "${enable_libewf}" = "yes" ; then
18945 { echo "$as_me:$LINENO: checking for libewf_get_media_size" >&5
18946 echo $ECHO_N "checking for libewf_get_media_size... $ECHO_C" >&6; }
18947 if test "${ac_cv_func_libewf_get_media_size+set}" = set; then
18948 echo $ECHO_N "(cached) $ECHO_C" >&6
18949 else
18950 cat >conftest.$ac_ext <<_ACEOF
18951 /* confdefs.h. */
18952 _ACEOF
18953 cat confdefs.h >>conftest.$ac_ext
18954 cat >>conftest.$ac_ext <<_ACEOF
18955 /* end confdefs.h. */
18956 /* Define libewf_get_media_size to an innocuous variant, in case <limits.h> declares libewf_get_media_size.
18957 For example, HP-UX 11i <limits.h> declares gettimeofday. */
18958 #define libewf_get_media_size innocuous_libewf_get_media_size
18959
18960 /* System header to define __stub macros and hopefully few prototypes,
18961 which can conflict with char libewf_get_media_size (); below.
18962 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
18963 <limits.h> exists even on freestanding compilers. */
18964
18965 #ifdef __STDC__
18966 # include <limits.h>
18967 #else
18968 # include <assert.h>
18969 #endif
18970
18971 #undef libewf_get_media_size
18972
18973 /* Override any GCC internal prototype to avoid an error.
18974 Use char because int might match the return type of a GCC
18975 builtin and then its argument prototype would still apply. */
18976 #ifdef __cplusplus
18977 extern "C"
18978 #endif
18979 char libewf_get_media_size ();
18980 /* The GNU C library defines this for functions which it implements
18981 to always fail with ENOSYS. Some functions are actually named
18982 something starting with __ and the normal name is an alias. */
18983 #if defined __stub_libewf_get_media_size || defined __stub___libewf_get_media_size
18984 choke me
18985 #endif
18986
18987 int
18988 main ()
18989 {
18990 return libewf_get_media_size ();
18991 ;
18992 return 0;
18993 }
18994 _ACEOF
18995 rm -f conftest.$ac_objext conftest$ac_exeext
18996 if { (ac_try="$ac_link"
18997 case "(($ac_try" in
18998 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
18999 *) ac_try_echo=$ac_try;;
19000 esac
19001 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19002 (eval "$ac_link") 2>conftest.er1
19003 ac_status=$?
19004 grep -v '^ *+' conftest.er1 >conftest.err
19005 rm -f conftest.er1
19006 cat conftest.err >&5
19007 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19008 (exit $ac_status); } && {
19009 test -z "$ac_c_werror_flag" ||
19010 test ! -s conftest.err
19011 } && test -s conftest$ac_exeext &&
19012 $as_test_x conftest$ac_exeext; then
19013 ac_cv_func_libewf_get_media_size=yes
19014 else
19015 echo "$as_me: failed program was:" >&5
19016 sed 's/^/| /' conftest.$ac_ext >&5
19017
19018 ac_cv_func_libewf_get_media_size=no
19019 fi
19020
19021 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19022 conftest$ac_exeext conftest.$ac_ext
19023 fi
19024 { echo "$as_me:$LINENO: result: $ac_cv_func_libewf_get_media_size" >&5
19025 echo "${ECHO_T}$ac_cv_func_libewf_get_media_size" >&6; }
19026 if test $ac_cv_func_libewf_get_media_size = yes; then
19027
19028 cat >>confdefs.h <<\_ACEOF
19029 #define HAVE_LIBEWF_GET_MEDIA_SIZE 1
19030 _ACEOF
19031
19032 ac_ext=c
19033 ac_cpp='$CPP $CPPFLAGS'
19034 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
19035 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
19036 ac_compiler_gnu=$ac_cv_c_compiler_gnu
19037
19038 { echo "$as_me:$LINENO: checking if libewf_get_media_size takes size as an argument." >&5
19039 echo $ECHO_N "checking if libewf_get_media_size takes size as an argument.... $ECHO_C" >&6; }
19040 cat >conftest.$ac_ext <<_ACEOF
19041 /* confdefs.h. */
19042 _ACEOF
19043 cat confdefs.h >>conftest.$ac_ext
19044 cat >>conftest.$ac_ext <<_ACEOF
19045 /* end confdefs.h. */
19046 #include <libewf.h>
19047 int
19048 main ()
19049 {
19050 libewf_get_media_size(NULL,NULL);
19051 ;
19052 return 0;
19053 }
19054 _ACEOF
19055 rm -f conftest.$ac_objext conftest$ac_exeext
19056 if { (ac_try="$ac_link"
19057 case "(($ac_try" in
19058 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19059 *) ac_try_echo=$ac_try;;
19060 esac
19061 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19062 (eval "$ac_link") 2>conftest.er1
19063 ac_status=$?
19064 grep -v '^ *+' conftest.er1 >conftest.err
19065 rm -f conftest.er1
19066 cat conftest.err >&5
19067 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19068 (exit $ac_status); } && {
19069 test -z "$ac_c_werror_flag" ||
19070 test ! -s conftest.err
19071 } && test -s conftest$ac_exeext &&
19072 $as_test_x conftest$ac_exeext; then
19073 { echo "$as_me:$LINENO: result: yes" >&5
19074 echo "${ECHO_T}yes" >&6; }
19075
19076 cat >>confdefs.h <<\_ACEOF
19077 #define HAVE_LIBEWF_GET_MEDIA_SIZE_ARGUMENT_VALUE 1
19078 _ACEOF
19079
19080 else
19081 echo "$as_me: failed program was:" >&5
19082 sed 's/^/| /' conftest.$ac_ext >&5
19083
19084 { echo "$as_me:$LINENO: result: no" >&5
19085 echo "${ECHO_T}no" >&6; }
19086 fi
19087
19088 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19089 conftest$ac_exeext conftest.$ac_ext
19090 ac_ext=c
19091 ac_cpp='$CPP $CPPFLAGS'
19092 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
19093 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
19094 ac_compiler_gnu=$ac_cv_c_compiler_gnu
19095
19096 fi
19097
19098
19099 { echo "$as_me:$LINENO: checking for libewf_get_chunk_size" >&5
19100 echo $ECHO_N "checking for libewf_get_chunk_size... $ECHO_C" >&6; }
19101 if test "${ac_cv_func_libewf_get_chunk_size+set}" = set; then
19102 echo $ECHO_N "(cached) $ECHO_C" >&6
19103 else
19104 cat >conftest.$ac_ext <<_ACEOF
19105 /* confdefs.h. */
19106 _ACEOF
19107 cat confdefs.h >>conftest.$ac_ext
19108 cat >>conftest.$ac_ext <<_ACEOF
19109 /* end confdefs.h. */
19110 /* Define libewf_get_chunk_size to an innocuous variant, in case <limits.h> declares libewf_get_chunk_size.
19111 For example, HP-UX 11i <limits.h> declares gettimeofday. */
19112 #define libewf_get_chunk_size innocuous_libewf_get_chunk_size
19113
19114 /* System header to define __stub macros and hopefully few prototypes,
19115 which can conflict with char libewf_get_chunk_size (); below.
19116 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
19117 <limits.h> exists even on freestanding compilers. */
19118
19119 #ifdef __STDC__
19120 # include <limits.h>
19121 #else
19122 # include <assert.h>
19123 #endif
19124
19125 #undef libewf_get_chunk_size
19126
19127 /* Override any GCC internal prototype to avoid an error.
19128 Use char because int might match the return type of a GCC
19129 builtin and then its argument prototype would still apply. */
19130 #ifdef __cplusplus
19131 extern "C"
19132 #endif
19133 char libewf_get_chunk_size ();
19134 /* The GNU C library defines this for functions which it implements
19135 to always fail with ENOSYS. Some functions are actually named
19136 something starting with __ and the normal name is an alias. */
19137 #if defined __stub_libewf_get_chunk_size || defined __stub___libewf_get_chunk_size
19138 choke me
19139 #endif
19140
19141 int
19142 main ()
19143 {
19144 return libewf_get_chunk_size ();
19145 ;
19146 return 0;
19147 }
19148 _ACEOF
19149 rm -f conftest.$ac_objext conftest$ac_exeext
19150 if { (ac_try="$ac_link"
19151 case "(($ac_try" in
19152 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19153 *) ac_try_echo=$ac_try;;
19154 esac
19155 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19156 (eval "$ac_link") 2>conftest.er1
19157 ac_status=$?
19158 grep -v '^ *+' conftest.er1 >conftest.err
19159 rm -f conftest.er1
19160 cat conftest.err >&5
19161 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19162 (exit $ac_status); } && {
19163 test -z "$ac_c_werror_flag" ||
19164 test ! -s conftest.err
19165 } && test -s conftest$ac_exeext &&
19166 $as_test_x conftest$ac_exeext; then
19167 ac_cv_func_libewf_get_chunk_size=yes
19168 else
19169 echo "$as_me: failed program was:" >&5
19170 sed 's/^/| /' conftest.$ac_ext >&5
19171
19172 ac_cv_func_libewf_get_chunk_size=no
19173 fi
19174
19175 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19176 conftest$ac_exeext conftest.$ac_ext
19177 fi
19178 { echo "$as_me:$LINENO: result: $ac_cv_func_libewf_get_chunk_size" >&5
19179 echo "${ECHO_T}$ac_cv_func_libewf_get_chunk_size" >&6; }
19180 if test $ac_cv_func_libewf_get_chunk_size = yes; then
19181
19182 cat >>confdefs.h <<\_ACEOF
19183 #define HAVE_LIBEWF_GET_CHUNK_SIZE 1
19184 _ACEOF
19185
19186 ac_ext=c
19187 ac_cpp='$CPP $CPPFLAGS'
19188 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
19189 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
19190 ac_compiler_gnu=$ac_cv_c_compiler_gnu
19191
19192 { echo "$as_me:$LINENO: checking if libewf_get_chunk_size takes size as an argument." >&5
19193 echo $ECHO_N "checking if libewf_get_chunk_size takes size as an argument.... $ECHO_C" >&6; }
19194 cat >conftest.$ac_ext <<_ACEOF
19195 /* confdefs.h. */
19196 _ACEOF
19197 cat confdefs.h >>conftest.$ac_ext
19198 cat >>conftest.$ac_ext <<_ACEOF
19199 /* end confdefs.h. */
19200 #include <libewf.h>
19201 int
19202 main ()
19203 {
19204 libewf_get_chunk_size(NULL,NULL);
19205 ;
19206 return 0;
19207 }
19208 _ACEOF
19209 rm -f conftest.$ac_objext conftest$ac_exeext
19210 if { (ac_try="$ac_link"
19211 case "(($ac_try" in
19212 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19213 *) ac_try_echo=$ac_try;;
19214 esac
19215 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19216 (eval "$ac_link") 2>conftest.er1
19217 ac_status=$?
19218 grep -v '^ *+' conftest.er1 >conftest.err
19219 rm -f conftest.er1
19220 cat conftest.err >&5
19221 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19222 (exit $ac_status); } && {
19223 test -z "$ac_c_werror_flag" ||
19224 test ! -s conftest.err
19225 } && test -s conftest$ac_exeext &&
19226 $as_test_x conftest$ac_exeext; then
19227 { echo "$as_me:$LINENO: result: yes" >&5
19228 echo "${ECHO_T}yes" >&6; }
19229
19230 cat >>confdefs.h <<\_ACEOF
19231 #define HAVE_LIBEWF_GET_CHUNK_SIZE_ARGUMENT_VALUE 1
19232 _ACEOF
19233
19234 else
19235 echo "$as_me: failed program was:" >&5
19236 sed 's/^/| /' conftest.$ac_ext >&5
19237
19238 { echo "$as_me:$LINENO: result: no" >&5
19239 echo "${ECHO_T}no" >&6; }
19240 fi
19241
19242 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19243 conftest$ac_exeext conftest.$ac_ext
19244 ac_ext=c
19245 ac_cpp='$CPP $CPPFLAGS'
19246 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
19247 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
19248 ac_compiler_gnu=$ac_cv_c_compiler_gnu
19249
19250 fi
19251
19252
19253 { echo "$as_me:$LINENO: checking for libewf_get_bytes_per_sector" >&5
19254 echo $ECHO_N "checking for libewf_get_bytes_per_sector... $ECHO_C" >&6; }
19255 if test "${ac_cv_func_libewf_get_bytes_per_sector+set}" = set; then
19256 echo $ECHO_N "(cached) $ECHO_C" >&6
19257 else
19258 cat >conftest.$ac_ext <<_ACEOF
19259 /* confdefs.h. */
19260 _ACEOF
19261 cat confdefs.h >>conftest.$ac_ext
19262 cat >>conftest.$ac_ext <<_ACEOF
19263 /* end confdefs.h. */
19264 /* Define libewf_get_bytes_per_sector to an innocuous variant, in case <limits.h> declares libewf_get_bytes_per_sector.
19265 For example, HP-UX 11i <limits.h> declares gettimeofday. */
19266 #define libewf_get_bytes_per_sector innocuous_libewf_get_bytes_per_sector
19267
19268 /* System header to define __stub macros and hopefully few prototypes,
19269 which can conflict with char libewf_get_bytes_per_sector (); below.
19270 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
19271 <limits.h> exists even on freestanding compilers. */
19272
19273 #ifdef __STDC__
19274 # include <limits.h>
19275 #else
19276 # include <assert.h>
19277 #endif
19278
19279 #undef libewf_get_bytes_per_sector
19280
19281 /* Override any GCC internal prototype to avoid an error.
19282 Use char because int might match the return type of a GCC
19283 builtin and then its argument prototype would still apply. */
19284 #ifdef __cplusplus
19285 extern "C"
19286 #endif
19287 char libewf_get_bytes_per_sector ();
19288 /* The GNU C library defines this for functions which it implements
19289 to always fail with ENOSYS. Some functions are actually named
19290 something starting with __ and the normal name is an alias. */
19291 #if defined __stub_libewf_get_bytes_per_sector || defined __stub___libewf_get_bytes_per_sector
19292 choke me
19293 #endif
19294
19295 int
19296 main ()
19297 {
19298 return libewf_get_bytes_per_sector ();
19299 ;
19300 return 0;
19301 }
19302 _ACEOF
19303 rm -f conftest.$ac_objext conftest$ac_exeext
19304 if { (ac_try="$ac_link"
19305 case "(($ac_try" in
19306 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19307 *) ac_try_echo=$ac_try;;
19308 esac
19309 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19310 (eval "$ac_link") 2>conftest.er1
19311 ac_status=$?
19312 grep -v '^ *+' conftest.er1 >conftest.err
19313 rm -f conftest.er1
19314 cat conftest.err >&5
19315 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19316 (exit $ac_status); } && {
19317 test -z "$ac_c_werror_flag" ||
19318 test ! -s conftest.err
19319 } && test -s conftest$ac_exeext &&
19320 $as_test_x conftest$ac_exeext; then
19321 ac_cv_func_libewf_get_bytes_per_sector=yes
19322 else
19323 echo "$as_me: failed program was:" >&5
19324 sed 's/^/| /' conftest.$ac_ext >&5
19325
19326 ac_cv_func_libewf_get_bytes_per_sector=no
19327 fi
19328
19329 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19330 conftest$ac_exeext conftest.$ac_ext
19331 fi
19332 { echo "$as_me:$LINENO: result: $ac_cv_func_libewf_get_bytes_per_sector" >&5
19333 echo "${ECHO_T}$ac_cv_func_libewf_get_bytes_per_sector" >&6; }
19334 if test $ac_cv_func_libewf_get_bytes_per_sector = yes; then
19335
19336 cat >>confdefs.h <<\_ACEOF
19337 #define HAVE_LIBEWF_GET_BYTES_PER_SECTOR 1
19338 _ACEOF
19339
19340 ac_ext=c
19341 ac_cpp='$CPP $CPPFLAGS'
19342 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
19343 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
19344 ac_compiler_gnu=$ac_cv_c_compiler_gnu
19345
19346 { echo "$as_me:$LINENO: checking if libewf_get_bytes_per_sector takes size as an argument." >&5
19347 echo $ECHO_N "checking if libewf_get_bytes_per_sector takes size as an argument.... $ECHO_C" >&6; }
19348 cat >conftest.$ac_ext <<_ACEOF
19349 /* confdefs.h. */
19350 _ACEOF
19351 cat confdefs.h >>conftest.$ac_ext
19352 cat >>conftest.$ac_ext <<_ACEOF
19353 /* end confdefs.h. */
19354 #include <libewf.h>
19355 int
19356 main ()
19357 {
19358 libewf_get_bytes_per_sector(NULL,NULL);
19359 ;
19360 return 0;
19361 }
19362 _ACEOF
19363 rm -f conftest.$ac_objext conftest$ac_exeext
19364 if { (ac_try="$ac_link"
19365 case "(($ac_try" in
19366 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19367 *) ac_try_echo=$ac_try;;
19368 esac
19369 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19370 (eval "$ac_link") 2>conftest.er1
19371 ac_status=$?
19372 grep -v '^ *+' conftest.er1 >conftest.err
19373 rm -f conftest.er1
19374 cat conftest.err >&5
19375 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19376 (exit $ac_status); } && {
19377 test -z "$ac_c_werror_flag" ||
19378 test ! -s conftest.err
19379 } && test -s conftest$ac_exeext &&
19380 $as_test_x conftest$ac_exeext; then
19381 { echo "$as_me:$LINENO: result: yes" >&5
19382 echo "${ECHO_T}yes" >&6; }
19383
19384 cat >>confdefs.h <<\_ACEOF
19385 #define HAVE_LIBEWF_GET_BYTES_PER_SECTOR_ARGUMENT_VALUE 1
19386 _ACEOF
19387
19388 else
19389 echo "$as_me: failed program was:" >&5
19390 sed 's/^/| /' conftest.$ac_ext >&5
19391
19392 { echo "$as_me:$LINENO: result: no" >&5
19393 echo "${ECHO_T}no" >&6; }
19394 fi
19395
19396 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19397 conftest$ac_exeext conftest.$ac_ext
19398 ac_ext=c
19399 ac_cpp='$CPP $CPPFLAGS'
19400 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
19401 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
19402 ac_compiler_gnu=$ac_cv_c_compiler_gnu
19403
19404 fi
19405
19406
19407
19408 cat >>confdefs.h <<\_ACEOF
19409 #define USE_LIBEWF 1
19410 _ACEOF
19411
19412 fi
19413
19414
19415 ################################################################
19416 # For AFF tools
19417
19418
19419
19420
19421
19422
19423
19424
19425
19426 for ac_func in tputs tgoto tgetstr tgetnum gotorc beep endwin setupterm printw
19427 do
19428 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
19429 { echo "$as_me:$LINENO: checking for $ac_func" >&5
19430 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
19431 if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
19432 echo $ECHO_N "(cached) $ECHO_C" >&6
19433 else
19434 cat >conftest.$ac_ext <<_ACEOF
19435 /* confdefs.h. */
19436 _ACEOF
19437 cat confdefs.h >>conftest.$ac_ext
19438 cat >>conftest.$ac_ext <<_ACEOF
19439 /* end confdefs.h. */
19440 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
19441 For example, HP-UX 11i <limits.h> declares gettimeofday. */
19442 #define $ac_func innocuous_$ac_func
19443
19444 /* System header to define __stub macros and hopefully few prototypes,
19445 which can conflict with char $ac_func (); below.
19446 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
19447 <limits.h> exists even on freestanding compilers. */
19448
19449 #ifdef __STDC__
19450 # include <limits.h>
19451 #else
19452 # include <assert.h>
19453 #endif
19454
19455 #undef $ac_func
19456
19457 /* Override any GCC internal prototype to avoid an error.
19458 Use char because int might match the return type of a GCC
19459 builtin and then its argument prototype would still apply. */
19460 #ifdef __cplusplus
19461 extern "C"
19462 #endif
19463 char $ac_func ();
19464 /* The GNU C library defines this for functions which it implements
19465 to always fail with ENOSYS. Some functions are actually named
19466 something starting with __ and the normal name is an alias. */
19467 #if defined __stub_$ac_func || defined __stub___$ac_func
19468 choke me
19469 #endif
19470
19471 int
19472 main ()
19473 {
19474 return $ac_func ();
19475 ;
19476 return 0;
19477 }
19478 _ACEOF
19479 rm -f conftest.$ac_objext conftest$ac_exeext
19480 if { (ac_try="$ac_link"
19481 case "(($ac_try" in
19482 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19483 *) ac_try_echo=$ac_try;;
19484 esac
19485 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19486 (eval "$ac_link") 2>conftest.er1
19487 ac_status=$?
19488 grep -v '^ *+' conftest.er1 >conftest.err
19489 rm -f conftest.er1
19490 cat conftest.err >&5
19491 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19492 (exit $ac_status); } && {
19493 test -z "$ac_c_werror_flag" ||
19494 test ! -s conftest.err
19495 } && test -s conftest$ac_exeext &&
19496 $as_test_x conftest$ac_exeext; then
19497 eval "$as_ac_var=yes"
19498 else
19499 echo "$as_me: failed program was:" >&5
19500 sed 's/^/| /' conftest.$ac_ext >&5
19501
19502 eval "$as_ac_var=no"
19503 fi
19504
19505 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19506 conftest$ac_exeext conftest.$ac_ext
19507 fi
19508 ac_res=`eval echo '${'$as_ac_var'}'`
19509 { echo "$as_me:$LINENO: result: $ac_res" >&5
19510 echo "${ECHO_T}$ac_res" >&6; }
19511 if test `eval echo '${'$as_ac_var'}'` = yes; then
19512 cat >>confdefs.h <<_ACEOF
19513 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
19514 _ACEOF
19515
19516 fi
19517 done
19518
19519
19520 for ac_header in readline/readline.h
19521 do
19522 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
19523 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
19524 { echo "$as_me:$LINENO: checking for $ac_header" >&5
19525 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
19526 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
19527 echo $ECHO_N "(cached) $ECHO_C" >&6
19528 fi
19529 ac_res=`eval echo '${'$as_ac_Header'}'`
19530 { echo "$as_me:$LINENO: result: $ac_res" >&5
19531 echo "${ECHO_T}$ac_res" >&6; }
19532 else
19533 # Is the header compilable?
19534 { echo "$as_me:$LINENO: checking $ac_header usability" >&5
19535 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
19536 cat >conftest.$ac_ext <<_ACEOF
19537 /* confdefs.h. */
19538 _ACEOF
19539 cat confdefs.h >>conftest.$ac_ext
19540 cat >>conftest.$ac_ext <<_ACEOF
19541 /* end confdefs.h. */
19542 $ac_includes_default
19543 #include <$ac_header>
19544 _ACEOF
19545 rm -f conftest.$ac_objext
19546 if { (ac_try="$ac_compile"
19547 case "(($ac_try" in
19548 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19549 *) ac_try_echo=$ac_try;;
19550 esac
19551 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19552 (eval "$ac_compile") 2>conftest.er1
19553 ac_status=$?
19554 grep -v '^ *+' conftest.er1 >conftest.err
19555 rm -f conftest.er1
19556 cat conftest.err >&5
19557 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19558 (exit $ac_status); } && {
19559 test -z "$ac_c_werror_flag" ||
19560 test ! -s conftest.err
19561 } && test -s conftest.$ac_objext; then
19562 ac_header_compiler=yes
19563 else
19564 echo "$as_me: failed program was:" >&5
19565 sed 's/^/| /' conftest.$ac_ext >&5
19566
19567 ac_header_compiler=no
19568 fi
19569
19570 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
19571 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
19572 echo "${ECHO_T}$ac_header_compiler" >&6; }
19573
19574 # Is the header present?
19575 { echo "$as_me:$LINENO: checking $ac_header presence" >&5
19576 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
19577 cat >conftest.$ac_ext <<_ACEOF
19578 /* confdefs.h. */
19579 _ACEOF
19580 cat confdefs.h >>conftest.$ac_ext
19581 cat >>conftest.$ac_ext <<_ACEOF
19582 /* end confdefs.h. */
19583 #include <$ac_header>
19584 _ACEOF
19585 if { (ac_try="$ac_cpp conftest.$ac_ext"
19586 case "(($ac_try" in
19587 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19588 *) ac_try_echo=$ac_try;;
19589 esac
19590 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19591 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
19592 ac_status=$?
19593 grep -v '^ *+' conftest.er1 >conftest.err
19594 rm -f conftest.er1
19595 cat conftest.err >&5
19596 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19597 (exit $ac_status); } >/dev/null && {
19598 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
19599 test ! -s conftest.err
19600 }; then
19601 ac_header_preproc=yes
19602 else
19603 echo "$as_me: failed program was:" >&5
19604 sed 's/^/| /' conftest.$ac_ext >&5
19605
19606 ac_header_preproc=no
19607 fi
19608
19609 rm -f conftest.err conftest.$ac_ext
19610 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
19611 echo "${ECHO_T}$ac_header_preproc" >&6; }
19612
19613 # So? What about this header?
19614 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
19615 yes:no: )
19616 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
19617 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
19618 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
19619 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
19620 ac_header_preproc=yes
19621 ;;
19622 no:yes:* )
19623 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
19624 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
19625 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
19626 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
19627 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
19628 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
19629 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
19630 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
19631 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
19632 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
19633 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
19634 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
19635 ( cat <<\_ASBOX
19636 ## ------------------------------ ##
19637 ## Report this to bugs@afflib.org ##
19638 ## ------------------------------ ##
19639 _ASBOX
19640 ) | sed "s/^/$as_me: WARNING: /" >&2
19641 ;;
19642 esac
19643 { echo "$as_me:$LINENO: checking for $ac_header" >&5
19644 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
19645 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
19646 echo $ECHO_N "(cached) $ECHO_C" >&6
19647 else
19648 eval "$as_ac_Header=\$ac_header_preproc"
19649 fi
19650 ac_res=`eval echo '${'$as_ac_Header'}'`
19651 { echo "$as_me:$LINENO: result: $ac_res" >&5
19652 echo "${ECHO_T}$ac_res" >&6; }
19653
19654 fi
19655 if test `eval echo '${'$as_ac_Header'}'` = yes; then
19656 cat >>confdefs.h <<_ACEOF
19657 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
19658 _ACEOF
19659
19660 fi
19661
19662 done
19663
19664
19665
19666 for ac_header in curses.h termcap.h
19667 do
19668 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
19669 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
19670 { echo "$as_me:$LINENO: checking for $ac_header" >&5
19671 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
19672 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
19673 echo $ECHO_N "(cached) $ECHO_C" >&6
19674 fi
19675 ac_res=`eval echo '${'$as_ac_Header'}'`
19676 { echo "$as_me:$LINENO: result: $ac_res" >&5
19677 echo "${ECHO_T}$ac_res" >&6; }
19678 else
19679 # Is the header compilable?
19680 { echo "$as_me:$LINENO: checking $ac_header usability" >&5
19681 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
19682 cat >conftest.$ac_ext <<_ACEOF
19683 /* confdefs.h. */
19684 _ACEOF
19685 cat confdefs.h >>conftest.$ac_ext
19686 cat >>conftest.$ac_ext <<_ACEOF
19687 /* end confdefs.h. */
19688 $ac_includes_default
19689 #include <$ac_header>
19690 _ACEOF
19691 rm -f conftest.$ac_objext
19692 if { (ac_try="$ac_compile"
19693 case "(($ac_try" in
19694 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19695 *) ac_try_echo=$ac_try;;
19696 esac
19697 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19698 (eval "$ac_compile") 2>conftest.er1
19699 ac_status=$?
19700 grep -v '^ *+' conftest.er1 >conftest.err
19701 rm -f conftest.er1
19702 cat conftest.err >&5
19703 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19704 (exit $ac_status); } && {
19705 test -z "$ac_c_werror_flag" ||
19706 test ! -s conftest.err
19707 } && test -s conftest.$ac_objext; then
19708 ac_header_compiler=yes
19709 else
19710 echo "$as_me: failed program was:" >&5
19711 sed 's/^/| /' conftest.$ac_ext >&5
19712
19713 ac_header_compiler=no
19714 fi
19715
19716 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
19717 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
19718 echo "${ECHO_T}$ac_header_compiler" >&6; }
19719
19720 # Is the header present?
19721 { echo "$as_me:$LINENO: checking $ac_header presence" >&5
19722 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
19723 cat >conftest.$ac_ext <<_ACEOF
19724 /* confdefs.h. */
19725 _ACEOF
19726 cat confdefs.h >>conftest.$ac_ext
19727 cat >>conftest.$ac_ext <<_ACEOF
19728 /* end confdefs.h. */
19729 #include <$ac_header>
19730 _ACEOF
19731 if { (ac_try="$ac_cpp conftest.$ac_ext"
19732 case "(($ac_try" in
19733 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19734 *) ac_try_echo=$ac_try;;
19735 esac
19736 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19737 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
19738 ac_status=$?
19739 grep -v '^ *+' conftest.er1 >conftest.err
19740 rm -f conftest.er1
19741 cat conftest.err >&5
19742 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19743 (exit $ac_status); } >/dev/null && {
19744 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
19745 test ! -s conftest.err
19746 }; then
19747 ac_header_preproc=yes
19748 else
19749 echo "$as_me: failed program was:" >&5
19750 sed 's/^/| /' conftest.$ac_ext >&5
19751
19752 ac_header_preproc=no
19753 fi
19754
19755 rm -f conftest.err conftest.$ac_ext
19756 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
19757 echo "${ECHO_T}$ac_header_preproc" >&6; }
19758
19759 # So? What about this header?
19760 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
19761 yes:no: )
19762 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
19763 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
19764 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
19765 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
19766 ac_header_preproc=yes
19767 ;;
19768 no:yes:* )
19769 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
19770 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
19771 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
19772 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
19773 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
19774 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
19775 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
19776 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
19777 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
19778 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
19779 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
19780 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
19781 ( cat <<\_ASBOX
19782 ## ------------------------------ ##
19783 ## Report this to bugs@afflib.org ##
19784 ## ------------------------------ ##
19785 _ASBOX
19786 ) | sed "s/^/$as_me: WARNING: /" >&2
19787 ;;
19788 esac
19789 { echo "$as_me:$LINENO: checking for $ac_header" >&5
19790 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
19791 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
19792 echo $ECHO_N "(cached) $ECHO_C" >&6
19793 else
19794 eval "$as_ac_Header=\$ac_header_preproc"
19795 fi
19796 ac_res=`eval echo '${'$as_ac_Header'}'`
19797 { echo "$as_me:$LINENO: result: $ac_res" >&5
19798 echo "${ECHO_T}$ac_res" >&6; }
19799
19800 fi
19801 if test `eval echo '${'$as_ac_Header'}'` = yes; then
19802 cat >>confdefs.h <<_ACEOF
19803 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
19804 _ACEOF
19805
19806 fi
19807
19808 done
19809
19810
19811 { echo "$as_me:$LINENO: checking for readline in -lreadline" >&5
19812 echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6; }
19813 if test "${ac_cv_lib_readline_readline+set}" = set; then
19814 echo $ECHO_N "(cached) $ECHO_C" >&6
19815 else
19816 ac_check_lib_save_LIBS=$LIBS
19817 LIBS="-lreadline $LIBS"
19818 cat >conftest.$ac_ext <<_ACEOF
19819 /* confdefs.h. */
19820 _ACEOF
19821 cat confdefs.h >>conftest.$ac_ext
19822 cat >>conftest.$ac_ext <<_ACEOF
19823 /* end confdefs.h. */
19824
19825 /* Override any GCC internal prototype to avoid an error.
19826 Use char because int might match the return type of a GCC
19827 builtin and then its argument prototype would still apply. */
19828 #ifdef __cplusplus
19829 extern "C"
19830 #endif
19831 char readline ();
19832 int
19833 main ()
19834 {
19835 return readline ();
19836 ;
19837 return 0;
19838 }
19839 _ACEOF
19840 rm -f conftest.$ac_objext conftest$ac_exeext
19841 if { (ac_try="$ac_link"
19842 case "(($ac_try" in
19843 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19844 *) ac_try_echo=$ac_try;;
19845 esac
19846 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19847 (eval "$ac_link") 2>conftest.er1
19848 ac_status=$?
19849 grep -v '^ *+' conftest.er1 >conftest.err
19850 rm -f conftest.er1
19851 cat conftest.err >&5
19852 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19853 (exit $ac_status); } && {
19854 test -z "$ac_c_werror_flag" ||
19855 test ! -s conftest.err
19856 } && test -s conftest$ac_exeext &&
19857 $as_test_x conftest$ac_exeext; then
19858 ac_cv_lib_readline_readline=yes
19859 else
19860 echo "$as_me: failed program was:" >&5
19861 sed 's/^/| /' conftest.$ac_ext >&5
19862
19863 ac_cv_lib_readline_readline=no
19864 fi
19865
19866 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19867 conftest$ac_exeext conftest.$ac_ext
19868 LIBS=$ac_check_lib_save_LIBS
19869 fi
19870 { echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5
19871 echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6; }
19872 if test $ac_cv_lib_readline_readline = yes; then
19873 cat >>confdefs.h <<_ACEOF
19874 #define HAVE_LIBREADLINE 1
19875 _ACEOF
19876
19877 LIBS="-lreadline $LIBS"
19878
19879 else
19880 { echo "$as_me:$LINENO: result: readline not installed" >&5
19881 echo "${ECHO_T}readline not installed" >&6; }
19882 fi
19883
19884
19885 { echo "$as_me:$LINENO: checking for initscr in -lncurses" >&5
19886 echo $ECHO_N "checking for initscr in -lncurses... $ECHO_C" >&6; }
19887 if test "${ac_cv_lib_ncurses_initscr+set}" = set; then
19888 echo $ECHO_N "(cached) $ECHO_C" >&6
19889 else
19890 ac_check_lib_save_LIBS=$LIBS
19891 LIBS="-lncurses $LIBS"
19892 cat >conftest.$ac_ext <<_ACEOF
19893 /* confdefs.h. */
19894 _ACEOF
19895 cat confdefs.h >>conftest.$ac_ext
19896 cat >>conftest.$ac_ext <<_ACEOF
19897 /* end confdefs.h. */
19898
19899 /* Override any GCC internal prototype to avoid an error.
19900 Use char because int might match the return type of a GCC
19901 builtin and then its argument prototype would still apply. */
19902 #ifdef __cplusplus
19903 extern "C"
19904 #endif
19905 char initscr ();
19906 int
19907 main ()
19908 {
19909 return initscr ();
19910 ;
19911 return 0;
19912 }
19913 _ACEOF
19914 rm -f conftest.$ac_objext conftest$ac_exeext
19915 if { (ac_try="$ac_link"
19916 case "(($ac_try" in
19917 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19918 *) ac_try_echo=$ac_try;;
19919 esac
19920 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19921 (eval "$ac_link") 2>conftest.er1
19922 ac_status=$?
19923 grep -v '^ *+' conftest.er1 >conftest.err
19924 rm -f conftest.er1
19925 cat conftest.err >&5
19926 echo "$as_me:$LINENO: \$? = $ac_status" >&5
19927 (exit $ac_status); } && {
19928 test -z "$ac_c_werror_flag" ||
19929 test ! -s conftest.err
19930 } && test -s conftest$ac_exeext &&
19931 $as_test_x conftest$ac_exeext; then
19932 ac_cv_lib_ncurses_initscr=yes
19933 else
19934 echo "$as_me: failed program was:" >&5
19935 sed 's/^/| /' conftest.$ac_ext >&5
19936
19937 ac_cv_lib_ncurses_initscr=no
19938 fi
19939
19940 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
19941 conftest$ac_exeext conftest.$ac_ext
19942 LIBS=$ac_check_lib_save_LIBS
19943 fi
19944 { echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_initscr" >&5
19945 echo "${ECHO_T}$ac_cv_lib_ncurses_initscr" >&6; }
19946 if test $ac_cv_lib_ncurses_initscr = yes; then
19947 cat >>confdefs.h <<_ACEOF
19948 #define HAVE_LIBNCURSES 1
19949 _ACEOF
19950
19951 LIBS="-lncurses $LIBS"
19952
19953 else
19954 { echo "$as_me:$LINENO: result: ncurses not installed" >&5
19955 echo "${ECHO_T}ncurses not installed" >&6; }
19956 fi
19957
19958
19959 { echo "$as_me:$LINENO: checking for uncompress in -lz" >&5
19960 echo $ECHO_N "checking for uncompress in -lz... $ECHO_C" >&6; }
19961 if test "${ac_cv_lib_z_uncompress+set}" = set; then
19962 echo $ECHO_N "(cached) $ECHO_C" >&6
19963 else
19964 ac_check_lib_save_LIBS=$LIBS
19965 LIBS="-lz $LIBS"
19966 cat >conftest.$ac_ext <<_ACEOF
19967 /* confdefs.h. */
19968 _ACEOF
19969 cat confdefs.h >>conftest.$ac_ext
19970 cat >>conftest.$ac_ext <<_ACEOF
19971 /* end confdefs.h. */
19972
19973 /* Override any GCC internal prototype to avoid an error.
19974 Use char because int might match the return type of a GCC
19975 builtin and then its argument prototype would still apply. */
19976 #ifdef __cplusplus
19977 extern "C"
19978 #endif
19979 char uncompress ();
19980 int
19981 main ()
19982 {
19983 return uncompress ();
19984 ;
19985 return 0;
19986 }
19987 _ACEOF
19988 rm -f conftest.$ac_objext conftest$ac_exeext
19989 if { (ac_try="$ac_link"
19990 case "(($ac_try" in
19991 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
19992 *) ac_try_echo=$ac_try;;
19993 esac
19994 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
19995 (eval "$ac_link") 2>conftest.er1
19996 ac_status=$?
19997 grep -v '^ *+' conftest.er1 >conftest.err
19998 rm -f conftest.er1
19999 cat conftest.err >&5
20000 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20001 (exit $ac_status); } && {
20002 test -z "$ac_c_werror_flag" ||
20003 test ! -s conftest.err
20004 } && test -s conftest$ac_exeext &&
20005 $as_test_x conftest$ac_exeext; then
20006 ac_cv_lib_z_uncompress=yes
20007 else
20008 echo "$as_me: failed program was:" >&5
20009 sed 's/^/| /' conftest.$ac_ext >&5
20010
20011 ac_cv_lib_z_uncompress=no
20012 fi
20013
20014 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
20015 conftest$ac_exeext conftest.$ac_ext
20016 LIBS=$ac_check_lib_save_LIBS
20017 fi
20018 { echo "$as_me:$LINENO: result: $ac_cv_lib_z_uncompress" >&5
20019 echo "${ECHO_T}$ac_cv_lib_z_uncompress" >&6; }
20020 if test $ac_cv_lib_z_uncompress = yes; then
20021 cat >>confdefs.h <<_ACEOF
20022 #define HAVE_LIBZ 1
20023 _ACEOF
20024
20025 LIBS="-lz $LIBS"
20026
20027 else
20028 { { echo "$as_me:$LINENO: error: zlib not installed; cannot continue. Try adding zlib-dev or zlib1g-dev." >&5
20029 echo "$as_me: error: zlib not installed; cannot continue. Try adding zlib-dev or zlib1g-dev." >&2;}
20030 { (exit 1); exit 1; }; }
20031 fi
20032
20033
20034 { echo "$as_me:$LINENO: checking for aio_error64 in -lrt" >&5
20035 echo $ECHO_N "checking for aio_error64 in -lrt... $ECHO_C" >&6; }
20036 if test "${ac_cv_lib_rt_aio_error64+set}" = set; then
20037 echo $ECHO_N "(cached) $ECHO_C" >&6
20038 else
20039 ac_check_lib_save_LIBS=$LIBS
20040 LIBS="-lrt $LIBS"
20041 cat >conftest.$ac_ext <<_ACEOF
20042 /* confdefs.h. */
20043 _ACEOF
20044 cat confdefs.h >>conftest.$ac_ext
20045 cat >>conftest.$ac_ext <<_ACEOF
20046 /* end confdefs.h. */
20047
20048 /* Override any GCC internal prototype to avoid an error.
20049 Use char because int might match the return type of a GCC
20050 builtin and then its argument prototype would still apply. */
20051 #ifdef __cplusplus
20052 extern "C"
20053 #endif
20054 char aio_error64 ();
20055 int
20056 main ()
20057 {
20058 return aio_error64 ();
20059 ;
20060 return 0;
20061 }
20062 _ACEOF
20063 rm -f conftest.$ac_objext conftest$ac_exeext
20064 if { (ac_try="$ac_link"
20065 case "(($ac_try" in
20066 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
20067 *) ac_try_echo=$ac_try;;
20068 esac
20069 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
20070 (eval "$ac_link") 2>conftest.er1
20071 ac_status=$?
20072 grep -v '^ *+' conftest.er1 >conftest.err
20073 rm -f conftest.er1
20074 cat conftest.err >&5
20075 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20076 (exit $ac_status); } && {
20077 test -z "$ac_c_werror_flag" ||
20078 test ! -s conftest.err
20079 } && test -s conftest$ac_exeext &&
20080 $as_test_x conftest$ac_exeext; then
20081 ac_cv_lib_rt_aio_error64=yes
20082 else
20083 echo "$as_me: failed program was:" >&5
20084 sed 's/^/| /' conftest.$ac_ext >&5
20085
20086 ac_cv_lib_rt_aio_error64=no
20087 fi
20088
20089 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
20090 conftest$ac_exeext conftest.$ac_ext
20091 LIBS=$ac_check_lib_save_LIBS
20092 fi
20093 { echo "$as_me:$LINENO: result: $ac_cv_lib_rt_aio_error64" >&5
20094 echo "${ECHO_T}$ac_cv_lib_rt_aio_error64" >&6; }
20095 if test $ac_cv_lib_rt_aio_error64 = yes; then
20096 cat >>confdefs.h <<_ACEOF
20097 #define HAVE_LIBRT 1
20098 _ACEOF
20099
20100 LIBS="-lrt $LIBS"
20101
20102 fi
20103
20104
20105 ################################################################
20106 ## Expat
20107 ## Required for S3 and Digital Signatures
20108 ##
20109
20110 # Check whether --with-expat was given.
20111 if test "${with_expat+set}" = set; then
20112 withval=$with_expat; LDFLAGS="-L${with_expat} $LDFLAGS" ;
20113 CPPFLAGS="-I${with_expat}/lib $CPPFLAGS"
20114 fi
20115
20116
20117 have_expat=yes
20118 if test "${ac_cv_header_expat_h+set}" = set; then
20119 { echo "$as_me:$LINENO: checking for expat.h" >&5
20120 echo $ECHO_N "checking for expat.h... $ECHO_C" >&6; }
20121 if test "${ac_cv_header_expat_h+set}" = set; then
20122 echo $ECHO_N "(cached) $ECHO_C" >&6
20123 fi
20124 { echo "$as_me:$LINENO: result: $ac_cv_header_expat_h" >&5
20125 echo "${ECHO_T}$ac_cv_header_expat_h" >&6; }
20126 else
20127 # Is the header compilable?
20128 { echo "$as_me:$LINENO: checking expat.h usability" >&5
20129 echo $ECHO_N "checking expat.h usability... $ECHO_C" >&6; }
20130 cat >conftest.$ac_ext <<_ACEOF
20131 /* confdefs.h. */
20132 _ACEOF
20133 cat confdefs.h >>conftest.$ac_ext
20134 cat >>conftest.$ac_ext <<_ACEOF
20135 /* end confdefs.h. */
20136 $ac_includes_default
20137 #include <expat.h>
20138 _ACEOF
20139 rm -f conftest.$ac_objext
20140 if { (ac_try="$ac_compile"
20141 case "(($ac_try" in
20142 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
20143 *) ac_try_echo=$ac_try;;
20144 esac
20145 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
20146 (eval "$ac_compile") 2>conftest.er1
20147 ac_status=$?
20148 grep -v '^ *+' conftest.er1 >conftest.err
20149 rm -f conftest.er1
20150 cat conftest.err >&5
20151 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20152 (exit $ac_status); } && {
20153 test -z "$ac_c_werror_flag" ||
20154 test ! -s conftest.err
20155 } && test -s conftest.$ac_objext; then
20156 ac_header_compiler=yes
20157 else
20158 echo "$as_me: failed program was:" >&5
20159 sed 's/^/| /' conftest.$ac_ext >&5
20160
20161 ac_header_compiler=no
20162 fi
20163
20164 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
20165 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
20166 echo "${ECHO_T}$ac_header_compiler" >&6; }
20167
20168 # Is the header present?
20169 { echo "$as_me:$LINENO: checking expat.h presence" >&5
20170 echo $ECHO_N "checking expat.h presence... $ECHO_C" >&6; }
20171 cat >conftest.$ac_ext <<_ACEOF
20172 /* confdefs.h. */
20173 _ACEOF
20174 cat confdefs.h >>conftest.$ac_ext
20175 cat >>conftest.$ac_ext <<_ACEOF
20176 /* end confdefs.h. */
20177 #include <expat.h>
20178 _ACEOF
20179 if { (ac_try="$ac_cpp conftest.$ac_ext"
20180 case "(($ac_try" in
20181 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
20182 *) ac_try_echo=$ac_try;;
20183 esac
20184 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
20185 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
20186 ac_status=$?
20187 grep -v '^ *+' conftest.er1 >conftest.err
20188 rm -f conftest.er1
20189 cat conftest.err >&5
20190 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20191 (exit $ac_status); } >/dev/null && {
20192 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
20193 test ! -s conftest.err
20194 }; then
20195 ac_header_preproc=yes
20196 else
20197 echo "$as_me: failed program was:" >&5
20198 sed 's/^/| /' conftest.$ac_ext >&5
20199
20200 ac_header_preproc=no
20201 fi
20202
20203 rm -f conftest.err conftest.$ac_ext
20204 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
20205 echo "${ECHO_T}$ac_header_preproc" >&6; }
20206
20207 # So? What about this header?
20208 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
20209 yes:no: )
20210 { echo "$as_me:$LINENO: WARNING: expat.h: accepted by the compiler, rejected by the preprocessor!" >&5
20211 echo "$as_me: WARNING: expat.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
20212 { echo "$as_me:$LINENO: WARNING: expat.h: proceeding with the compiler's result" >&5
20213 echo "$as_me: WARNING: expat.h: proceeding with the compiler's result" >&2;}
20214 ac_header_preproc=yes
20215 ;;
20216 no:yes:* )
20217 { echo "$as_me:$LINENO: WARNING: expat.h: present but cannot be compiled" >&5
20218 echo "$as_me: WARNING: expat.h: present but cannot be compiled" >&2;}
20219 { echo "$as_me:$LINENO: WARNING: expat.h: check for missing prerequisite headers?" >&5
20220 echo "$as_me: WARNING: expat.h: check for missing prerequisite headers?" >&2;}
20221 { echo "$as_me:$LINENO: WARNING: expat.h: see the Autoconf documentation" >&5
20222 echo "$as_me: WARNING: expat.h: see the Autoconf documentation" >&2;}
20223 { echo "$as_me:$LINENO: WARNING: expat.h: section \"Present But Cannot Be Compiled\"" >&5
20224 echo "$as_me: WARNING: expat.h: section \"Present But Cannot Be Compiled\"" >&2;}
20225 { echo "$as_me:$LINENO: WARNING: expat.h: proceeding with the preprocessor's result" >&5
20226 echo "$as_me: WARNING: expat.h: proceeding with the preprocessor's result" >&2;}
20227 { echo "$as_me:$LINENO: WARNING: expat.h: in the future, the compiler will take precedence" >&5
20228 echo "$as_me: WARNING: expat.h: in the future, the compiler will take precedence" >&2;}
20229 ( cat <<\_ASBOX
20230 ## ------------------------------ ##
20231 ## Report this to bugs@afflib.org ##
20232 ## ------------------------------ ##
20233 _ASBOX
20234 ) | sed "s/^/$as_me: WARNING: /" >&2
20235 ;;
20236 esac
20237 { echo "$as_me:$LINENO: checking for expat.h" >&5
20238 echo $ECHO_N "checking for expat.h... $ECHO_C" >&6; }
20239 if test "${ac_cv_header_expat_h+set}" = set; then
20240 echo $ECHO_N "(cached) $ECHO_C" >&6
20241 else
20242 ac_cv_header_expat_h=$ac_header_preproc
20243 fi
20244 { echo "$as_me:$LINENO: result: $ac_cv_header_expat_h" >&5
20245 echo "${ECHO_T}$ac_cv_header_expat_h" >&6; }
20246
20247 fi
20248
20249
20250
20251 { echo "$as_me:$LINENO: checking for XML_ParserCreate in -lexpat" >&5
20252 echo $ECHO_N "checking for XML_ParserCreate in -lexpat... $ECHO_C" >&6; }
20253 if test "${ac_cv_lib_expat_XML_ParserCreate+set}" = set; then
20254 echo $ECHO_N "(cached) $ECHO_C" >&6
20255 else
20256 ac_check_lib_save_LIBS=$LIBS
20257 LIBS="-lexpat $LIBS"
20258 cat >conftest.$ac_ext <<_ACEOF
20259 /* confdefs.h. */
20260 _ACEOF
20261 cat confdefs.h >>conftest.$ac_ext
20262 cat >>conftest.$ac_ext <<_ACEOF
20263 /* end confdefs.h. */
20264
20265 /* Override any GCC internal prototype to avoid an error.
20266 Use char because int might match the return type of a GCC
20267 builtin and then its argument prototype would still apply. */
20268 #ifdef __cplusplus
20269 extern "C"
20270 #endif
20271 char XML_ParserCreate ();
20272 int
20273 main ()
20274 {
20275 return XML_ParserCreate ();
20276 ;
20277 return 0;
20278 }
20279 _ACEOF
20280 rm -f conftest.$ac_objext conftest$ac_exeext
20281 if { (ac_try="$ac_link"
20282 case "(($ac_try" in
20283 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
20284 *) ac_try_echo=$ac_try;;
20285 esac
20286 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
20287 (eval "$ac_link") 2>conftest.er1
20288 ac_status=$?
20289 grep -v '^ *+' conftest.er1 >conftest.err
20290 rm -f conftest.er1
20291 cat conftest.err >&5
20292 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20293 (exit $ac_status); } && {
20294 test -z "$ac_c_werror_flag" ||
20295 test ! -s conftest.err
20296 } && test -s conftest$ac_exeext &&
20297 $as_test_x conftest$ac_exeext; then
20298 ac_cv_lib_expat_XML_ParserCreate=yes
20299 else
20300 echo "$as_me: failed program was:" >&5
20301 sed 's/^/| /' conftest.$ac_ext >&5
20302
20303 ac_cv_lib_expat_XML_ParserCreate=no
20304 fi
20305
20306 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
20307 conftest$ac_exeext conftest.$ac_ext
20308 LIBS=$ac_check_lib_save_LIBS
20309 fi
20310 { echo "$as_me:$LINENO: result: $ac_cv_lib_expat_XML_ParserCreate" >&5
20311 echo "${ECHO_T}$ac_cv_lib_expat_XML_ParserCreate" >&6; }
20312 if test $ac_cv_lib_expat_XML_ParserCreate = yes; then
20313 cat >>confdefs.h <<_ACEOF
20314 #define HAVE_LIBEXPAT 1
20315 _ACEOF
20316
20317 LIBS="-lexpat $LIBS"
20318
20319 else
20320 have_expat="no ";{ echo "$as_me:$LINENO: WARNING: expat not found; S3 and Digital Signatures not enabled" >&5
20321 echo "$as_me: WARNING: expat not found; S3 and Digital Signatures not enabled" >&2;}
20322 fi
20323
20324
20325
20326 ################################################################
20327 ## Amazon S3
20328 ## S3 requires curl and expat; otherwise we don't need them
20329 # Check whether --enable-s3 was given.
20330 if test "${enable_s3+set}" = set; then
20331 enableval=$enable_s3; enable_s3=$enableval
20332 else
20333 enable_s3=no
20334 fi
20335
20336
20337 if test "x${enable_s3}" = "xyes" ; then
20338 { echo "$as_me:$LINENO: S3 support requested. Looking for curl and expat..." >&5
20339 echo "$as_me: S3 support requested. Looking for curl and expat..." >&6;}
20340 # Extract the first word of "curl-config", so it can be a program name with args.
20341 set dummy curl-config; ac_word=$2
20342 { echo "$as_me:$LINENO: checking for $ac_word" >&5
20343 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
20344 if test "${ac_cv_path_CURL_CONFIG+set}" = set; then
20345 echo $ECHO_N "(cached) $ECHO_C" >&6
20346 else
20347 case $CURL_CONFIG in
20348 [\\/]* | ?:[\\/]*)
20349 ac_cv_path_CURL_CONFIG="$CURL_CONFIG" # Let the user override the test with a path.
20350 ;;
20351 *)
20352 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
20353 for as_dir in $PATH
20354 do
20355 IFS=$as_save_IFS
20356 test -z "$as_dir" && as_dir=.
20357 for ac_exec_ext in '' $ac_executable_extensions; do
20358 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
20359 ac_cv_path_CURL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
20360 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
20361 break 2
20362 fi
20363 done
20364 done
20365 IFS=$as_save_IFS
20366
20367 ;;
20368 esac
20369 fi
20370 CURL_CONFIG=$ac_cv_path_CURL_CONFIG
20371 if test -n "$CURL_CONFIG"; then
20372 { echo "$as_me:$LINENO: result: $CURL_CONFIG" >&5
20373 echo "${ECHO_T}$CURL_CONFIG" >&6; }
20374 else
20375 { echo "$as_me:$LINENO: result: no" >&5
20376 echo "${ECHO_T}no" >&6; }
20377 fi
20378
20379
20380
20381 # Check whether --with-curl was given.
20382 if test "${with_curl+set}" = set; then
20383 withval=$with_curl; CURL_CONFIG="${with_curl}/bin/curl-config"
20384 fi
20385
20386 if test -f "${CURL_CONFIG}"; then
20387 LDFLAGS="`${CURL_CONFIG} --libs` $LDFLAGS"
20388 CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
20389 else
20390 { echo "$as_me:$LINENO: WARNING: curl-config not found, guessing at libcurl build settings" >&5
20391 echo "$as_me: WARNING: curl-config not found, guessing at libcurl build settings" >&2;}
20392 fi
20393 if test "${ac_cv_header_curl_curl_h+set}" = set; then
20394 { echo "$as_me:$LINENO: checking for curl/curl.h" >&5
20395 echo $ECHO_N "checking for curl/curl.h... $ECHO_C" >&6; }
20396 if test "${ac_cv_header_curl_curl_h+set}" = set; then
20397 echo $ECHO_N "(cached) $ECHO_C" >&6
20398 fi
20399 { echo "$as_me:$LINENO: result: $ac_cv_header_curl_curl_h" >&5
20400 echo "${ECHO_T}$ac_cv_header_curl_curl_h" >&6; }
20401 else
20402 # Is the header compilable?
20403 { echo "$as_me:$LINENO: checking curl/curl.h usability" >&5
20404 echo $ECHO_N "checking curl/curl.h usability... $ECHO_C" >&6; }
20405 cat >conftest.$ac_ext <<_ACEOF
20406 /* confdefs.h. */
20407 _ACEOF
20408 cat confdefs.h >>conftest.$ac_ext
20409 cat >>conftest.$ac_ext <<_ACEOF
20410 /* end confdefs.h. */
20411 $ac_includes_default
20412 #include <curl/curl.h>
20413 _ACEOF
20414 rm -f conftest.$ac_objext
20415 if { (ac_try="$ac_compile"
20416 case "(($ac_try" in
20417 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
20418 *) ac_try_echo=$ac_try;;
20419 esac
20420 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
20421 (eval "$ac_compile") 2>conftest.er1
20422 ac_status=$?
20423 grep -v '^ *+' conftest.er1 >conftest.err
20424 rm -f conftest.er1
20425 cat conftest.err >&5
20426 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20427 (exit $ac_status); } && {
20428 test -z "$ac_c_werror_flag" ||
20429 test ! -s conftest.err
20430 } && test -s conftest.$ac_objext; then
20431 ac_header_compiler=yes
20432 else
20433 echo "$as_me: failed program was:" >&5
20434 sed 's/^/| /' conftest.$ac_ext >&5
20435
20436 ac_header_compiler=no
20437 fi
20438
20439 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
20440 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
20441 echo "${ECHO_T}$ac_header_compiler" >&6; }
20442
20443 # Is the header present?
20444 { echo "$as_me:$LINENO: checking curl/curl.h presence" >&5
20445 echo $ECHO_N "checking curl/curl.h presence... $ECHO_C" >&6; }
20446 cat >conftest.$ac_ext <<_ACEOF
20447 /* confdefs.h. */
20448 _ACEOF
20449 cat confdefs.h >>conftest.$ac_ext
20450 cat >>conftest.$ac_ext <<_ACEOF
20451 /* end confdefs.h. */
20452 #include <curl/curl.h>
20453 _ACEOF
20454 if { (ac_try="$ac_cpp conftest.$ac_ext"
20455 case "(($ac_try" in
20456 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
20457 *) ac_try_echo=$ac_try;;
20458 esac
20459 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
20460 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
20461 ac_status=$?
20462 grep -v '^ *+' conftest.er1 >conftest.err
20463 rm -f conftest.er1
20464 cat conftest.err >&5
20465 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20466 (exit $ac_status); } >/dev/null && {
20467 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
20468 test ! -s conftest.err
20469 }; then
20470 ac_header_preproc=yes
20471 else
20472 echo "$as_me: failed program was:" >&5
20473 sed 's/^/| /' conftest.$ac_ext >&5
20474
20475 ac_header_preproc=no
20476 fi
20477
20478 rm -f conftest.err conftest.$ac_ext
20479 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
20480 echo "${ECHO_T}$ac_header_preproc" >&6; }
20481
20482 # So? What about this header?
20483 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
20484 yes:no: )
20485 { echo "$as_me:$LINENO: WARNING: curl/curl.h: accepted by the compiler, rejected by the preprocessor!" >&5
20486 echo "$as_me: WARNING: curl/curl.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
20487 { echo "$as_me:$LINENO: WARNING: curl/curl.h: proceeding with the compiler's result" >&5
20488 echo "$as_me: WARNING: curl/curl.h: proceeding with the compiler's result" >&2;}
20489 ac_header_preproc=yes
20490 ;;
20491 no:yes:* )
20492 { echo "$as_me:$LINENO: WARNING: curl/curl.h: present but cannot be compiled" >&5
20493 echo "$as_me: WARNING: curl/curl.h: present but cannot be compiled" >&2;}
20494 { echo "$as_me:$LINENO: WARNING: curl/curl.h: check for missing prerequisite headers?" >&5
20495 echo "$as_me: WARNING: curl/curl.h: check for missing prerequisite headers?" >&2;}
20496 { echo "$as_me:$LINENO: WARNING: curl/curl.h: see the Autoconf documentation" >&5
20497 echo "$as_me: WARNING: curl/curl.h: see the Autoconf documentation" >&2;}
20498 { echo "$as_me:$LINENO: WARNING: curl/curl.h: section \"Present But Cannot Be Compiled\"" >&5
20499 echo "$as_me: WARNING: curl/curl.h: section \"Present But Cannot Be Compiled\"" >&2;}
20500 { echo "$as_me:$LINENO: WARNING: curl/curl.h: proceeding with the preprocessor's result" >&5
20501 echo "$as_me: WARNING: curl/curl.h: proceeding with the preprocessor's result" >&2;}
20502 { echo "$as_me:$LINENO: WARNING: curl/curl.h: in the future, the compiler will take precedence" >&5
20503 echo "$as_me: WARNING: curl/curl.h: in the future, the compiler will take precedence" >&2;}
20504 ( cat <<\_ASBOX
20505 ## ------------------------------ ##
20506 ## Report this to bugs@afflib.org ##
20507 ## ------------------------------ ##
20508 _ASBOX
20509 ) | sed "s/^/$as_me: WARNING: /" >&2
20510 ;;
20511 esac
20512 { echo "$as_me:$LINENO: checking for curl/curl.h" >&5
20513 echo $ECHO_N "checking for curl/curl.h... $ECHO_C" >&6; }
20514 if test "${ac_cv_header_curl_curl_h+set}" = set; then
20515 echo $ECHO_N "(cached) $ECHO_C" >&6
20516 else
20517 ac_cv_header_curl_curl_h=$ac_header_preproc
20518 fi
20519 { echo "$as_me:$LINENO: result: $ac_cv_header_curl_curl_h" >&5
20520 echo "${ECHO_T}$ac_cv_header_curl_curl_h" >&6; }
20521
20522 fi
20523 if test $ac_cv_header_curl_curl_h = yes; then
20524 :
20525 else
20526 { echo "$as_me:$LINENO: WARNING: curl/curl.h not found; Disabling S3 Support." >&5
20527 echo "$as_me: WARNING: curl/curl.h not found; Disabling S3 Support." >&2;}
20528 enable_s3=no
20529 fi
20530
20531
20532
20533 { echo "$as_me:$LINENO: checking for curl_global_init in -lcurl" >&5
20534 echo $ECHO_N "checking for curl_global_init in -lcurl... $ECHO_C" >&6; }
20535 if test "${ac_cv_lib_curl_curl_global_init+set}" = set; then
20536 echo $ECHO_N "(cached) $ECHO_C" >&6
20537 else
20538 ac_check_lib_save_LIBS=$LIBS
20539 LIBS="-lcurl $LIBS"
20540 cat >conftest.$ac_ext <<_ACEOF
20541 /* confdefs.h. */
20542 _ACEOF
20543 cat confdefs.h >>conftest.$ac_ext
20544 cat >>conftest.$ac_ext <<_ACEOF
20545 /* end confdefs.h. */
20546
20547 /* Override any GCC internal prototype to avoid an error.
20548 Use char because int might match the return type of a GCC
20549 builtin and then its argument prototype would still apply. */
20550 #ifdef __cplusplus
20551 extern "C"
20552 #endif
20553 char curl_global_init ();
20554 int
20555 main ()
20556 {
20557 return curl_global_init ();
20558 ;
20559 return 0;
20560 }
20561 _ACEOF
20562 rm -f conftest.$ac_objext conftest$ac_exeext
20563 if { (ac_try="$ac_link"
20564 case "(($ac_try" in
20565 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
20566 *) ac_try_echo=$ac_try;;
20567 esac
20568 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
20569 (eval "$ac_link") 2>conftest.er1
20570 ac_status=$?
20571 grep -v '^ *+' conftest.er1 >conftest.err
20572 rm -f conftest.er1
20573 cat conftest.err >&5
20574 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20575 (exit $ac_status); } && {
20576 test -z "$ac_c_werror_flag" ||
20577 test ! -s conftest.err
20578 } && test -s conftest$ac_exeext &&
20579 $as_test_x conftest$ac_exeext; then
20580 ac_cv_lib_curl_curl_global_init=yes
20581 else
20582 echo "$as_me: failed program was:" >&5
20583 sed 's/^/| /' conftest.$ac_ext >&5
20584
20585 ac_cv_lib_curl_curl_global_init=no
20586 fi
20587
20588 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
20589 conftest$ac_exeext conftest.$ac_ext
20590 LIBS=$ac_check_lib_save_LIBS
20591 fi
20592 { echo "$as_me:$LINENO: result: $ac_cv_lib_curl_curl_global_init" >&5
20593 echo "${ECHO_T}$ac_cv_lib_curl_curl_global_init" >&6; }
20594 if test $ac_cv_lib_curl_curl_global_init = yes; then
20595 cat >>confdefs.h <<_ACEOF
20596 #define HAVE_LIBCURL 1
20597 _ACEOF
20598
20599 LIBS="-lcurl $LIBS"
20600
20601 else
20602 { echo "$as_me:$LINENO: WARNING: Curl library corrupt; Disabling S3 Support." >&5
20603 echo "$as_me: WARNING: Curl library corrupt; Disabling S3 Support." >&2;}
20604 enable_s3=no
20605 fi
20606
20607 fi
20608
20609 S3_BIN=
20610 if test "x${enable_s3}" = "xyes" ; then
20611
20612 cat >>confdefs.h <<\_ACEOF
20613 #define USE_S3 1
20614 _ACEOF
20615
20616 S3_BIN='s3$(EXEEXT)'
20617 fi
20618
20619 if test "x${enable_s3}" = "xyes"; then
20620 MAYBE_S3_TRUE=
20621 MAYBE_S3_FALSE='#'
20622 else
20623 MAYBE_S3_TRUE='#'
20624 MAYBE_S3_FALSE=
20625 fi
20626 # used by automake
20627
20628 ################################################################
20629 ### QEMU
20630 ################################################################
20631
20632 # Check whether --enable-qemu was given.
20633 if test "${enable_qemu+set}" = set; then
20634 enableval=$enable_qemu;
20635 fi
20636
20637
20638 echo "disable_qemu: " ${disable_qemu}
20639 echo "enable_qemu: " ${enable_qemu}
20640
20641 if test "x${enable_qemu}" = "xno" ; then
20642 enable_qemu="no"
20643
20644 cat >>confdefs.h <<\_ACEOF
20645 #define DISABLE_QEMU 1
20646 _ACEOF
20647
20648 else
20649
20650 cat >>confdefs.h <<\_ACEOF
20651 #define USE_QEMU 1
20652 _ACEOF
20653
20654 enable_qemu="yes"
20655 fi
20656 if test "x${enable_qemu}" = "xyes"; then
20657 MAYBE_QEMU_TRUE=
20658 MAYBE_QEMU_FALSE='#'
20659 else
20660 MAYBE_QEMU_TRUE='#'
20661 MAYBE_QEMU_FALSE=
20662 fi
20663 # used by automake
20664
20665
20666 ################################################################
20667 ### PyAFF
20668 ################################################################
20669 # python checks
20670 # (requires autoconf 1.5+ and the macros in acinclude.m4)
20671 # Check whether --enable-python was given.
20672 if test "${enable_python+set}" = set; then
20673 enableval=$enable_python; enable_python=$enableval
20674 else
20675 enable_python=no
20676 fi
20677
20678 if test "${enable_python}" = "yes" ; then
20679
20680
20681
20682
20683 if test -n "$PYTHON"; then
20684 # If the user set $PYTHON, use it and don't search something else.
20685 { echo "$as_me:$LINENO: checking whether $PYTHON version >= 2.5" >&5
20686 echo $ECHO_N "checking whether $PYTHON version >= 2.5... $ECHO_C" >&6; }
20687 prog="import sys, string
20688 # split strings by '.' and convert to numeric. Append some zeros
20689 # because we need at least 4 digits for the hex conversion.
20690 minver = map(int, string.split('2.5', '.')) + [0, 0, 0]
20691 minverhex = 0
20692 for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[i]
20693 sys.exit(sys.hexversion < minverhex)"
20694 if { echo "$as_me:$LINENO: $PYTHON -c "$prog"" >&5
20695 ($PYTHON -c "$prog") >&5 2>&5
20696 ac_status=$?
20697 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20698 (exit $ac_status); }; then
20699 { echo "$as_me:$LINENO: result: yes" >&5
20700 echo "${ECHO_T}yes" >&6; }
20701 else
20702 { { echo "$as_me:$LINENO: error: too old" >&5
20703 echo "$as_me: error: too old" >&2;}
20704 { (exit 1); exit 1; }; }
20705 fi
20706
20707 am_display_PYTHON=$PYTHON
20708 else
20709 # Otherwise, try each interpreter until we find one that satisfies
20710 # VERSION.
20711 { echo "$as_me:$LINENO: checking for a Python interpreter with version >= 2.5" >&5
20712 echo $ECHO_N "checking for a Python interpreter with version >= 2.5... $ECHO_C" >&6; }
20713 if test "${am_cv_pathless_PYTHON+set}" = set; then
20714 echo $ECHO_N "(cached) $ECHO_C" >&6
20715 else
20716
20717 for am_cv_pathless_PYTHON in python python2 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 none; do
20718 test "$am_cv_pathless_PYTHON" = none && break
20719 prog="import sys, string
20720 # split strings by '.' and convert to numeric. Append some zeros
20721 # because we need at least 4 digits for the hex conversion.
20722 minver = map(int, string.split('2.5', '.')) + [0, 0, 0]
20723 minverhex = 0
20724 for i in xrange(0, 4): minverhex = (minverhex << 8) + minver[i]
20725 sys.exit(sys.hexversion < minverhex)"
20726 if { echo "$as_me:$LINENO: $am_cv_pathless_PYTHON -c "$prog"" >&5
20727 ($am_cv_pathless_PYTHON -c "$prog") >&5 2>&5
20728 ac_status=$?
20729 echo "$as_me:$LINENO: \$? = $ac_status" >&5
20730 (exit $ac_status); }; then
20731 break
20732 fi
20733
20734 done
20735 fi
20736 { echo "$as_me:$LINENO: result: $am_cv_pathless_PYTHON" >&5
20737 echo "${ECHO_T}$am_cv_pathless_PYTHON" >&6; }
20738 # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
20739 if test "$am_cv_pathless_PYTHON" = none; then
20740 PYTHON=:
20741 else
20742 # Extract the first word of "$am_cv_pathless_PYTHON", so it can be a program name with args.
20743 set dummy $am_cv_pathless_PYTHON; ac_word=$2
20744 { echo "$as_me:$LINENO: checking for $ac_word" >&5
20745 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
20746 if test "${ac_cv_path_PYTHON+set}" = set; then
20747 echo $ECHO_N "(cached) $ECHO_C" >&6
20748 else
20749 case $PYTHON in
20750 [\\/]* | ?:[\\/]*)
20751 ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
20752 ;;
20753 *)
20754 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
20755 for as_dir in $PATH
20756 do
20757 IFS=$as_save_IFS
20758 test -z "$as_dir" && as_dir=.
20759 for ac_exec_ext in '' $ac_executable_extensions; do
20760 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
20761 ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
20762 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
20763 break 2
20764 fi
20765 done
20766 done
20767 IFS=$as_save_IFS
20768
20769 ;;
20770 esac
20771 fi
20772 PYTHON=$ac_cv_path_PYTHON
20773 if test -n "$PYTHON"; then
20774 { echo "$as_me:$LINENO: result: $PYTHON" >&5
20775 echo "${ECHO_T}$PYTHON" >&6; }
20776 else
20777 { echo "$as_me:$LINENO: result: no" >&5
20778 echo "${ECHO_T}no" >&6; }
20779 fi
20780
20781
20782 fi
20783 am_display_PYTHON=$am_cv_pathless_PYTHON
20784 fi
20785
20786
20787 if test "$PYTHON" = :; then
20788 { { echo "$as_me:$LINENO: error: no suitable Python interpreter found" >&5
20789 echo "$as_me: error: no suitable Python interpreter found" >&2;}
20790 { (exit 1); exit 1; }; }
20791 else
20792
20793
20794 { echo "$as_me:$LINENO: checking for $am_display_PYTHON version" >&5
20795 echo $ECHO_N "checking for $am_display_PYTHON version... $ECHO_C" >&6; }
20796 if test "${am_cv_python_version+set}" = set; then
20797 echo $ECHO_N "(cached) $ECHO_C" >&6
20798 else
20799 am_cv_python_version=`$PYTHON -c "import sys; print sys.version[:3]"`
20800 fi
20801 { echo "$as_me:$LINENO: result: $am_cv_python_version" >&5
20802 echo "${ECHO_T}$am_cv_python_version" >&6; }
20803 PYTHON_VERSION=$am_cv_python_version
20804
20805
20806
20807 PYTHON_PREFIX='${prefix}'
20808
20809 PYTHON_EXEC_PREFIX='${exec_prefix}'
20810
20811
20812
20813 { echo "$as_me:$LINENO: checking for $am_display_PYTHON platform" >&5
20814 echo $ECHO_N "checking for $am_display_PYTHON platform... $ECHO_C" >&6; }
20815 if test "${am_cv_python_platform+set}" = set; then
20816 echo $ECHO_N "(cached) $ECHO_C" >&6
20817 else
20818 am_cv_python_platform=`$PYTHON -c "import sys; print sys.platform"`
20819 fi
20820 { echo "$as_me:$LINENO: result: $am_cv_python_platform" >&5
20821 echo "${ECHO_T}$am_cv_python_platform" >&6; }
20822 PYTHON_PLATFORM=$am_cv_python_platform
20823
20824
20825
20826
20827 { echo "$as_me:$LINENO: checking for $am_display_PYTHON script directory" >&5
20828 echo $ECHO_N "checking for $am_display_PYTHON script directory... $ECHO_C" >&6; }
20829 if test "${am_cv_python_pythondir+set}" = set; then
20830 echo $ECHO_N "(cached) $ECHO_C" >&6
20831 else
20832 am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX')" 2>/dev/null ||
20833 echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`
20834 fi
20835 { echo "$as_me:$LINENO: result: $am_cv_python_pythondir" >&5
20836 echo "${ECHO_T}$am_cv_python_pythondir" >&6; }
20837 pythondir=$am_cv_python_pythondir
20838
20839
20840
20841 pkgpythondir=\${pythondir}/$PACKAGE
20842
20843
20844 { echo "$as_me:$LINENO: checking for $am_display_PYTHON extension module directory" >&5
20845 echo $ECHO_N "checking for $am_display_PYTHON extension module directory... $ECHO_C" >&6; }
20846 if test "${am_cv_python_pyexecdir+set}" = set; then
20847 echo $ECHO_N "(cached) $ECHO_C" >&6
20848 else
20849 am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX')" 2>/dev/null ||
20850 echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`
20851 fi
20852 { echo "$as_me:$LINENO: result: $am_cv_python_pyexecdir" >&5
20853 echo "${ECHO_T}$am_cv_python_pyexecdir" >&6; }
20854 pyexecdir=$am_cv_python_pyexecdir
20855
20856
20857
20858 pkgpyexecdir=\${pyexecdir}/$PACKAGE
20859
20860
20861
20862 fi
20863
20864
20865
20866 #
20867 # Allow the use of a (user set) custom python version
20868 #
20869
20870
20871 # Extract the first word of "python[$PYTHON_VERSION]", so it can be a program name with args.
20872 set dummy python$PYTHON_VERSION; ac_word=$2
20873 { echo "$as_me:$LINENO: checking for $ac_word" >&5
20874 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
20875 if test "${ac_cv_path_PYTHON+set}" = set; then
20876 echo $ECHO_N "(cached) $ECHO_C" >&6
20877 else
20878 case $PYTHON in
20879 [\\/]* | ?:[\\/]*)
20880 ac_cv_path_PYTHON="$PYTHON" # Let the user override the test with a path.
20881 ;;
20882 *)
20883 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
20884 for as_dir in $PATH
20885 do
20886 IFS=$as_save_IFS
20887 test -z "$as_dir" && as_dir=.
20888 for ac_exec_ext in '' $ac_executable_extensions; do
20889 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
20890 ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext"
20891 echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
20892 break 2
20893 fi
20894 done
20895 done
20896 IFS=$as_save_IFS
20897
20898 ;;
20899 esac
20900 fi
20901 PYTHON=$ac_cv_path_PYTHON
20902 if test -n "$PYTHON"; then
20903 { echo "$as_me:$LINENO: result: $PYTHON" >&5
20904 echo "${ECHO_T}$PYTHON" >&6; }
20905 else
20906 { echo "$as_me:$LINENO: result: no" >&5
20907 echo "${ECHO_T}no" >&6; }
20908 fi
20909
20910
20911 if test -z "$PYTHON"; then
20912 { { echo "$as_me:$LINENO: error: Cannot find python$PYTHON_VERSION in your system path" >&5
20913 echo "$as_me: error: Cannot find python$PYTHON_VERSION in your system path" >&2;}
20914 { (exit 1); exit 1; }; }
20915 PYTHON_VERSION=""
20916 fi
20917
20918 #
20919 # Check for a version of Python >= 2.1.0
20920 #
20921 { echo "$as_me:$LINENO: checking for a version of Python >= '2.1.0'" >&5
20922 echo $ECHO_N "checking for a version of Python >= '2.1.0'... $ECHO_C" >&6; }
20923 ac_supports_python_ver=`$PYTHON -c "import sys; \
20924 ver = sys.version.split ()[0]; \
20925 print (ver >= '2.1.0')"`
20926 if test "$ac_supports_python_ver" != "True"; then
20927 if test -z "$PYTHON_NOVERSIONCHECK"; then
20928 { echo "$as_me:$LINENO: result: no" >&5
20929 echo "${ECHO_T}no" >&6; }
20930 { { echo "$as_me:$LINENO: error:
20931 This version of the AC_PYTHON_DEVEL macro
20932 doesn't work properly with versions of Python before
20933 2.1.0. You may need to re-run configure, setting the
20934 variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
20935 PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
20936 Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
20937 to something else than an empty string.
20938
20939 See \`config.log' for more details." >&5
20940 echo "$as_me: error:
20941 This version of the AC_PYTHON_DEVEL macro
20942 doesn't work properly with versions of Python before
20943 2.1.0. You may need to re-run configure, setting the
20944 variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
20945 PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
20946 Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
20947 to something else than an empty string.
20948
20949 See \`config.log' for more details." >&2;}
20950 { (exit 1); exit 1; }; }
20951 else
20952 { echo "$as_me:$LINENO: result: skip at user request" >&5
20953 echo "${ECHO_T}skip at user request" >&6; }
20954 fi
20955 else
20956 { echo "$as_me:$LINENO: result: yes" >&5
20957 echo "${ECHO_T}yes" >&6; }
20958 fi
20959
20960 #
20961 # if the macro parameter ``version'' is set, honour it
20962 #
20963 if test -n ""; then
20964 { echo "$as_me:$LINENO: checking for a version of Python " >&5
20965 echo $ECHO_N "checking for a version of Python ... $ECHO_C" >&6; }
20966 ac_supports_python_ver=`$PYTHON -c "import sys; \
20967 ver = sys.version.split ()[0]; \
20968 print (ver )"`
20969 if test "$ac_supports_python_ver" = "True"; then
20970 { echo "$as_me:$LINENO: result: yes" >&5
20971 echo "${ECHO_T}yes" >&6; }
20972 else
20973 { echo "$as_me:$LINENO: result: no" >&5
20974 echo "${ECHO_T}no" >&6; }
20975 { { echo "$as_me:$LINENO: error: this package requires Python .
20976 If you have it installed, but it isn't the default Python
20977 interpreter in your system path, please pass the PYTHON_VERSION
20978 variable to configure. See \`\`configure --help'' for reference.
20979 " >&5
20980 echo "$as_me: error: this package requires Python .
20981 If you have it installed, but it isn't the default Python
20982 interpreter in your system path, please pass the PYTHON_VERSION
20983 variable to configure. See \`\`configure --help'' for reference.
20984 " >&2;}
20985 { (exit 1); exit 1; }; }
20986 PYTHON_VERSION=""
20987 fi
20988 fi
20989
20990 #
20991 # Check if you have distutils, else fail
20992 #
20993 { echo "$as_me:$LINENO: checking for the distutils Python package" >&5
20994 echo $ECHO_N "checking for the distutils Python package... $ECHO_C" >&6; }
20995 ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
20996 if test -z "$ac_distutils_result"; then
20997 { echo "$as_me:$LINENO: result: yes" >&5
20998 echo "${ECHO_T}yes" >&6; }
20999 else
21000 { echo "$as_me:$LINENO: result: no" >&5
21001 echo "${ECHO_T}no" >&6; }
21002 { { echo "$as_me:$LINENO: error: cannot import Python module \"distutils\".
21003 Please check your Python installation. The error was:
21004 $ac_distutils_result" >&5
21005 echo "$as_me: error: cannot import Python module \"distutils\".
21006 Please check your Python installation. The error was:
21007 $ac_distutils_result" >&2;}
21008 { (exit 1); exit 1; }; }
21009 PYTHON_VERSION=""
21010 fi
21011
21012 #
21013 # Check for Python include path
21014 #
21015 { echo "$as_me:$LINENO: checking for Python include path" >&5
21016 echo $ECHO_N "checking for Python include path... $ECHO_C" >&6; }
21017 if test -z "$PYTHON_CPPFLAGS"; then
21018 python_path=`$PYTHON -c "import distutils.sysconfig; \
21019 print (distutils.sysconfig.get_python_inc ());"`
21020 if test -n "${python_path}"; then
21021 python_path="-I$python_path"
21022 fi
21023 PYTHON_CPPFLAGS=$python_path
21024 fi
21025 { echo "$as_me:$LINENO: result: $PYTHON_CPPFLAGS" >&5
21026 echo "${ECHO_T}$PYTHON_CPPFLAGS" >&6; }
21027
21028
21029 #
21030 # Check for Python library path
21031 #
21032 { echo "$as_me:$LINENO: checking for Python library path" >&5
21033 echo $ECHO_N "checking for Python library path... $ECHO_C" >&6; }
21034 if test -z "$PYTHON_LDFLAGS"; then
21035 # (makes two attempts to ensure we've got a version number
21036 # from the interpreter)
21037 ac_python_version=`cat<<EOD | $PYTHON -
21038
21039 # join all versioning strings, on some systems
21040 # major/minor numbers could be in different list elements
21041 from distutils.sysconfig import *
21042 ret = ''
21043 for e in get_config_vars ('VERSION'):
21044 if (e != None):
21045 ret += e
21046 print (ret)
21047 EOD`
21048
21049 if test -z "$ac_python_version"; then
21050 if test -n "$PYTHON_VERSION"; then
21051 ac_python_version=$PYTHON_VERSION
21052 else
21053 ac_python_version=`$PYTHON -c "import sys; \
21054 print (sys.version[:3])"`
21055 fi
21056 fi
21057
21058 # Make the versioning information available to the compiler
21059
21060 cat >>confdefs.h <<_ACEOF
21061 #define HAVE_PYTHON "$ac_python_version"
21062 _ACEOF
21063
21064
21065 # First, the library directory:
21066 ac_python_libdir=`cat<<EOD | $PYTHON -
21067
21068 # There should be only one
21069 import distutils.sysconfig
21070 for e in distutils.sysconfig.get_config_vars ('LIBDIR'):
21071 if e != None:
21072 print (e)
21073 break
21074 EOD`
21075
21076 # Before checking for libpythonX.Y, we need to know
21077 # the extension the OS we're on uses for libraries
21078 # (we take the first one, if there's more than one fix me!):
21079 ac_python_soext=`$PYTHON -c \
21080 "import distutils.sysconfig; \
21081 print (distutils.sysconfig.get_config_vars('SO')[0])"`
21082
21083 # Now, for the library:
21084 ac_python_soname=`$PYTHON -c \
21085 "import distutils.sysconfig; \
21086 print (distutils.sysconfig.get_config_vars('LDLIBRARY')[0])"`
21087
21088 # Strip away extension from the end to canonicalize its name:
21089 ac_python_library=`echo "$ac_python_soname" | sed "s/${ac_python_soext}$//"`
21090
21091 # This small piece shamelessly adapted from PostgreSQL python macro;
21092 # credits goes to momjian, I think. I'd like to put the right name
21093 # in the credits, if someone can point me in the right direction... ?
21094 #
21095 if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
21096 -a x"$ac_python_library" != x"$ac_python_soname"
21097 then
21098 # use the official shared library
21099 ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
21100 PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
21101 else
21102 # old way: use libpython from python_configdir
21103 ac_python_libdir=`$PYTHON -c \
21104 "from distutils.sysconfig import get_python_lib as f; \
21105 import os; \
21106 print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
21107 PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
21108 fi
21109
21110 if test -z "PYTHON_LDFLAGS"; then
21111 { { echo "$as_me:$LINENO: error:
21112 Cannot determine location of your Python DSO. Please check it was installed with
21113 dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand.
21114 " >&5
21115 echo "$as_me: error:
21116 Cannot determine location of your Python DSO. Please check it was installed with
21117 dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand.
21118 " >&2;}
21119 { (exit 1); exit 1; }; }
21120 fi
21121 fi
21122 { echo "$as_me:$LINENO: result: $PYTHON_LDFLAGS" >&5
21123 echo "${ECHO_T}$PYTHON_LDFLAGS" >&6; }
21124
21125
21126 #
21127 # Check for site packages
21128 #
21129 { echo "$as_me:$LINENO: checking for Python site-packages path" >&5
21130 echo $ECHO_N "checking for Python site-packages path... $ECHO_C" >&6; }
21131 if test -z "$PYTHON_SITE_PKG"; then
21132 PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
21133 print (distutils.sysconfig.get_python_lib(0,0));"`
21134 fi
21135 { echo "$as_me:$LINENO: result: $PYTHON_SITE_PKG" >&5
21136 echo "${ECHO_T}$PYTHON_SITE_PKG" >&6; }
21137
21138
21139 #
21140 # libraries which must be linked in when embedding
21141 #
21142 { echo "$as_me:$LINENO: checking python extra libraries" >&5
21143 echo $ECHO_N "checking python extra libraries... $ECHO_C" >&6; }
21144 if test -z "$PYTHON_EXTRA_LIBS"; then
21145 PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
21146 conf = distutils.sysconfig.get_config_var; \
21147 print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"`
21148 fi
21149 { echo "$as_me:$LINENO: result: $PYTHON_EXTRA_LIBS" >&5
21150 echo "${ECHO_T}$PYTHON_EXTRA_LIBS" >&6; }
21151
21152
21153 #
21154 # linking flags needed when embedding
21155 #
21156 { echo "$as_me:$LINENO: checking python extra linking flags" >&5
21157 echo $ECHO_N "checking python extra linking flags... $ECHO_C" >&6; }
21158 if test -z "$PYTHON_EXTRA_LDFLAGS"; then
21159 PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
21160 conf = distutils.sysconfig.get_config_var; \
21161 print (conf('LINKFORSHARED'))"`
21162 fi
21163 { echo "$as_me:$LINENO: result: $PYTHON_EXTRA_LDFLAGS" >&5
21164 echo "${ECHO_T}$PYTHON_EXTRA_LDFLAGS" >&6; }
21165
21166
21167 #
21168 # final check to see if everything compiles alright
21169 #
21170 { echo "$as_me:$LINENO: checking consistency of all components of python development environment" >&5
21171 echo $ECHO_N "checking consistency of all components of python development environment... $ECHO_C" >&6; }
21172 # save current global flags
21173 ac_save_LIBS="$LIBS"
21174 ac_save_CPPFLAGS="$CPPFLAGS"
21175 LIBS="$LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS $PYTHON_EXTRA_LIBS"
21176 CPPFLAGS="$CPPFLAGS $PYTHON_CPPFLAGS"
21177 ac_ext=c
21178 ac_cpp='$CPP $CPPFLAGS'
21179 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
21180 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
21181 ac_compiler_gnu=$ac_cv_c_compiler_gnu
21182
21183 cat >conftest.$ac_ext <<_ACEOF
21184
21185 /* confdefs.h. */
21186 _ACEOF
21187 cat confdefs.h >>conftest.$ac_ext
21188 cat >>conftest.$ac_ext <<_ACEOF
21189 /* end confdefs.h. */
21190 #include <Python.h>
21191 int
21192 main ()
21193 {
21194 Py_Initialize();
21195 ;
21196 return 0;
21197 }
21198
21199 _ACEOF
21200 rm -f conftest.$ac_objext conftest$ac_exeext
21201 if { (ac_try="$ac_link"
21202 case "(($ac_try" in
21203 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21204 *) ac_try_echo=$ac_try;;
21205 esac
21206 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21207 (eval "$ac_link") 2>conftest.er1
21208 ac_status=$?
21209 grep -v '^ *+' conftest.er1 >conftest.err
21210 rm -f conftest.er1
21211 cat conftest.err >&5
21212 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21213 (exit $ac_status); } && {
21214 test -z "$ac_c_werror_flag" ||
21215 test ! -s conftest.err
21216 } && test -s conftest$ac_exeext &&
21217 $as_test_x conftest$ac_exeext; then
21218 pythonexists=yes
21219 else
21220 echo "$as_me: failed program was:" >&5
21221 sed 's/^/| /' conftest.$ac_ext >&5
21222
21223 pythonexists=no
21224 fi
21225
21226 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
21227 conftest$ac_exeext conftest.$ac_ext
21228 ac_ext=c
21229 ac_cpp='$CPP $CPPFLAGS'
21230 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
21231 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
21232 ac_compiler_gnu=$ac_cv_c_compiler_gnu
21233
21234 # turn back to default flags
21235 CPPFLAGS="$ac_save_CPPFLAGS"
21236 LIBS="$ac_save_LIBS"
21237
21238 { echo "$as_me:$LINENO: result: $pythonexists" >&5
21239 echo "${ECHO_T}$pythonexists" >&6; }
21240
21241 if test ! "x$pythonexists" = "xyes"; then
21242 { { echo "$as_me:$LINENO: error:
21243 Could not link test program to Python. Maybe the main Python library has been
21244 installed in some non-standard library path. If so, pass it to configure,
21245 via the LDFLAGS environment variable.
21246 Example: ./configure LDFLAGS=\"-L/usr/non-standard-path/python/lib\"
21247 ============================================================================
21248 ERROR!
21249 You probably have to install the development version of the Python package
21250 for your distribution. The exact name of this package varies among them.
21251 ============================================================================
21252
21253 See \`config.log' for more details." >&5
21254 echo "$as_me: error:
21255 Could not link test program to Python. Maybe the main Python library has been
21256 installed in some non-standard library path. If so, pass it to configure,
21257 via the LDFLAGS environment variable.
21258 Example: ./configure LDFLAGS=\"-L/usr/non-standard-path/python/lib\"
21259 ============================================================================
21260 ERROR!
21261 You probably have to install the development version of the Python package
21262 for your distribution. The exact name of this package varies among them.
21263 ============================================================================
21264
21265 See \`config.log' for more details." >&2;}
21266 { (exit 1); exit 1; }; }
21267 PYTHON_VERSION=""
21268 fi
21269
21270 #
21271 # all done!
21272 #
21273
21274
21275 cat >>confdefs.h <<\_ACEOF
21276 #define HAVE_PYTHON 1
21277 _ACEOF
21278
21279 fi
21280
21281 if test "$enable_python" = yes; then
21282 HAVE_PYTHON_TRUE=
21283 HAVE_PYTHON_FALSE='#'
21284 else
21285 HAVE_PYTHON_TRUE='#'
21286 HAVE_PYTHON_FALSE=
21287 fi
21288
21289
21290 ##
21291 ################################################################
21292 ################################################################
21293 ## Crypto (must follow S3)
21294 ###
21295
21296
21297
21298 { echo "$as_me:$LINENO: checking for ssl3_new in -lssl" >&5
21299 echo $ECHO_N "checking for ssl3_new in -lssl... $ECHO_C" >&6; }
21300 if test "${ac_cv_lib_ssl_ssl3_new+set}" = set; then
21301 echo $ECHO_N "(cached) $ECHO_C" >&6
21302 else
21303 ac_check_lib_save_LIBS=$LIBS
21304 LIBS="-lssl $LIBS"
21305 cat >conftest.$ac_ext <<_ACEOF
21306 /* confdefs.h. */
21307 _ACEOF
21308 cat confdefs.h >>conftest.$ac_ext
21309 cat >>conftest.$ac_ext <<_ACEOF
21310 /* end confdefs.h. */
21311
21312 /* Override any GCC internal prototype to avoid an error.
21313 Use char because int might match the return type of a GCC
21314 builtin and then its argument prototype would still apply. */
21315 #ifdef __cplusplus
21316 extern "C"
21317 #endif
21318 char ssl3_new ();
21319 int
21320 main ()
21321 {
21322 return ssl3_new ();
21323 ;
21324 return 0;
21325 }
21326 _ACEOF
21327 rm -f conftest.$ac_objext conftest$ac_exeext
21328 if { (ac_try="$ac_link"
21329 case "(($ac_try" in
21330 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21331 *) ac_try_echo=$ac_try;;
21332 esac
21333 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21334 (eval "$ac_link") 2>conftest.er1
21335 ac_status=$?
21336 grep -v '^ *+' conftest.er1 >conftest.err
21337 rm -f conftest.er1
21338 cat conftest.err >&5
21339 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21340 (exit $ac_status); } && {
21341 test -z "$ac_c_werror_flag" ||
21342 test ! -s conftest.err
21343 } && test -s conftest$ac_exeext &&
21344 $as_test_x conftest$ac_exeext; then
21345 ac_cv_lib_ssl_ssl3_new=yes
21346 else
21347 echo "$as_me: failed program was:" >&5
21348 sed 's/^/| /' conftest.$ac_ext >&5
21349
21350 ac_cv_lib_ssl_ssl3_new=no
21351 fi
21352
21353 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
21354 conftest$ac_exeext conftest.$ac_ext
21355 LIBS=$ac_check_lib_save_LIBS
21356 fi
21357 { echo "$as_me:$LINENO: result: $ac_cv_lib_ssl_ssl3_new" >&5
21358 echo "${ECHO_T}$ac_cv_lib_ssl_ssl3_new" >&6; }
21359 if test $ac_cv_lib_ssl_ssl3_new = yes; then
21360 cat >>confdefs.h <<_ACEOF
21361 #define HAVE_LIBSSL 1
21362 _ACEOF
21363
21364 LIBS="-lssl $LIBS"
21365
21366 else
21367 { { echo "$as_me:$LINENO: error: OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue." >&5
21368 echo "$as_me: error: OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue." >&2;}
21369 { (exit 1); exit 1; }; }
21370 fi
21371
21372
21373 { echo "$as_me:$LINENO: checking for MD5_Update in -lcrypto" >&5
21374 echo $ECHO_N "checking for MD5_Update in -lcrypto... $ECHO_C" >&6; }
21375 if test "${ac_cv_lib_crypto_MD5_Update+set}" = set; then
21376 echo $ECHO_N "(cached) $ECHO_C" >&6
21377 else
21378 ac_check_lib_save_LIBS=$LIBS
21379 LIBS="-lcrypto $LIBS"
21380 cat >conftest.$ac_ext <<_ACEOF
21381 /* confdefs.h. */
21382 _ACEOF
21383 cat confdefs.h >>conftest.$ac_ext
21384 cat >>conftest.$ac_ext <<_ACEOF
21385 /* end confdefs.h. */
21386
21387 /* Override any GCC internal prototype to avoid an error.
21388 Use char because int might match the return type of a GCC
21389 builtin and then its argument prototype would still apply. */
21390 #ifdef __cplusplus
21391 extern "C"
21392 #endif
21393 char MD5_Update ();
21394 int
21395 main ()
21396 {
21397 return MD5_Update ();
21398 ;
21399 return 0;
21400 }
21401 _ACEOF
21402 rm -f conftest.$ac_objext conftest$ac_exeext
21403 if { (ac_try="$ac_link"
21404 case "(($ac_try" in
21405 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21406 *) ac_try_echo=$ac_try;;
21407 esac
21408 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21409 (eval "$ac_link") 2>conftest.er1
21410 ac_status=$?
21411 grep -v '^ *+' conftest.er1 >conftest.err
21412 rm -f conftest.er1
21413 cat conftest.err >&5
21414 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21415 (exit $ac_status); } && {
21416 test -z "$ac_c_werror_flag" ||
21417 test ! -s conftest.err
21418 } && test -s conftest$ac_exeext &&
21419 $as_test_x conftest$ac_exeext; then
21420 ac_cv_lib_crypto_MD5_Update=yes
21421 else
21422 echo "$as_me: failed program was:" >&5
21423 sed 's/^/| /' conftest.$ac_ext >&5
21424
21425 ac_cv_lib_crypto_MD5_Update=no
21426 fi
21427
21428 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
21429 conftest$ac_exeext conftest.$ac_ext
21430 LIBS=$ac_check_lib_save_LIBS
21431 fi
21432 { echo "$as_me:$LINENO: result: $ac_cv_lib_crypto_MD5_Update" >&5
21433 echo "${ECHO_T}$ac_cv_lib_crypto_MD5_Update" >&6; }
21434 if test $ac_cv_lib_crypto_MD5_Update = yes; then
21435 cat >>confdefs.h <<_ACEOF
21436 #define HAVE_LIBCRYPTO 1
21437 _ACEOF
21438
21439 LIBS="-lcrypto $LIBS"
21440
21441 else
21442 { { echo "$as_me:$LINENO: error: OpenSSL developer library 'libcrypto' not installed; cannot continue." >&5
21443 echo "$as_me: error: OpenSSL developer library 'libcrypto' not installed; cannot continue." >&2;}
21444 { (exit 1); exit 1; }; }
21445 fi
21446
21447
21448
21449
21450
21451
21452
21453
21454
21455
21456
21457
21458 for ac_header in openssl/aes.h openssl/bio.h openssl/evp.h openssl/hmac.h openssl/md5.h openssl/rand.h openssl/rsa.h openssl/sha.h openssl/pem.h openssl/x509.h
21459 do
21460 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
21461 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
21462 { echo "$as_me:$LINENO: checking for $ac_header" >&5
21463 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
21464 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
21465 echo $ECHO_N "(cached) $ECHO_C" >&6
21466 fi
21467 ac_res=`eval echo '${'$as_ac_Header'}'`
21468 { echo "$as_me:$LINENO: result: $ac_res" >&5
21469 echo "${ECHO_T}$ac_res" >&6; }
21470 else
21471 # Is the header compilable?
21472 { echo "$as_me:$LINENO: checking $ac_header usability" >&5
21473 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
21474 cat >conftest.$ac_ext <<_ACEOF
21475 /* confdefs.h. */
21476 _ACEOF
21477 cat confdefs.h >>conftest.$ac_ext
21478 cat >>conftest.$ac_ext <<_ACEOF
21479 /* end confdefs.h. */
21480 $ac_includes_default
21481 #include <$ac_header>
21482 _ACEOF
21483 rm -f conftest.$ac_objext
21484 if { (ac_try="$ac_compile"
21485 case "(($ac_try" in
21486 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21487 *) ac_try_echo=$ac_try;;
21488 esac
21489 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21490 (eval "$ac_compile") 2>conftest.er1
21491 ac_status=$?
21492 grep -v '^ *+' conftest.er1 >conftest.err
21493 rm -f conftest.er1
21494 cat conftest.err >&5
21495 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21496 (exit $ac_status); } && {
21497 test -z "$ac_c_werror_flag" ||
21498 test ! -s conftest.err
21499 } && test -s conftest.$ac_objext; then
21500 ac_header_compiler=yes
21501 else
21502 echo "$as_me: failed program was:" >&5
21503 sed 's/^/| /' conftest.$ac_ext >&5
21504
21505 ac_header_compiler=no
21506 fi
21507
21508 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21509 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
21510 echo "${ECHO_T}$ac_header_compiler" >&6; }
21511
21512 # Is the header present?
21513 { echo "$as_me:$LINENO: checking $ac_header presence" >&5
21514 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
21515 cat >conftest.$ac_ext <<_ACEOF
21516 /* confdefs.h. */
21517 _ACEOF
21518 cat confdefs.h >>conftest.$ac_ext
21519 cat >>conftest.$ac_ext <<_ACEOF
21520 /* end confdefs.h. */
21521 #include <$ac_header>
21522 _ACEOF
21523 if { (ac_try="$ac_cpp conftest.$ac_ext"
21524 case "(($ac_try" in
21525 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21526 *) ac_try_echo=$ac_try;;
21527 esac
21528 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21529 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
21530 ac_status=$?
21531 grep -v '^ *+' conftest.er1 >conftest.err
21532 rm -f conftest.er1
21533 cat conftest.err >&5
21534 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21535 (exit $ac_status); } >/dev/null && {
21536 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
21537 test ! -s conftest.err
21538 }; then
21539 ac_header_preproc=yes
21540 else
21541 echo "$as_me: failed program was:" >&5
21542 sed 's/^/| /' conftest.$ac_ext >&5
21543
21544 ac_header_preproc=no
21545 fi
21546
21547 rm -f conftest.err conftest.$ac_ext
21548 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
21549 echo "${ECHO_T}$ac_header_preproc" >&6; }
21550
21551 # So? What about this header?
21552 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
21553 yes:no: )
21554 { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
21555 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
21556 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
21557 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
21558 ac_header_preproc=yes
21559 ;;
21560 no:yes:* )
21561 { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
21562 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
21563 { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
21564 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
21565 { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
21566 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
21567 { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
21568 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
21569 { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
21570 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
21571 { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
21572 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
21573 ( cat <<\_ASBOX
21574 ## ------------------------------ ##
21575 ## Report this to bugs@afflib.org ##
21576 ## ------------------------------ ##
21577 _ASBOX
21578 ) | sed "s/^/$as_me: WARNING: /" >&2
21579 ;;
21580 esac
21581 { echo "$as_me:$LINENO: checking for $ac_header" >&5
21582 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
21583 if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
21584 echo $ECHO_N "(cached) $ECHO_C" >&6
21585 else
21586 eval "$as_ac_Header=\$ac_header_preproc"
21587 fi
21588 ac_res=`eval echo '${'$as_ac_Header'}'`
21589 { echo "$as_me:$LINENO: result: $ac_res" >&5
21590 echo "${ECHO_T}$ac_res" >&6; }
21591
21592 fi
21593 if test `eval echo '${'$as_ac_Header'}'` = yes; then
21594 cat >>confdefs.h <<_ACEOF
21595 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
21596 _ACEOF
21597
21598 fi
21599
21600 done
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610 for ac_func in MD5 SHA1 AES_encrypt RAND_pseudo_bytes des_read_pw_string EVP_read_pw_string EVP_MD_size
21611 do
21612 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
21613 { echo "$as_me:$LINENO: checking for $ac_func" >&5
21614 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
21615 if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
21616 echo $ECHO_N "(cached) $ECHO_C" >&6
21617 else
21618 cat >conftest.$ac_ext <<_ACEOF
21619 /* confdefs.h. */
21620 _ACEOF
21621 cat confdefs.h >>conftest.$ac_ext
21622 cat >>conftest.$ac_ext <<_ACEOF
21623 /* end confdefs.h. */
21624 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
21625 For example, HP-UX 11i <limits.h> declares gettimeofday. */
21626 #define $ac_func innocuous_$ac_func
21627
21628 /* System header to define __stub macros and hopefully few prototypes,
21629 which can conflict with char $ac_func (); below.
21630 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
21631 <limits.h> exists even on freestanding compilers. */
21632
21633 #ifdef __STDC__
21634 # include <limits.h>
21635 #else
21636 # include <assert.h>
21637 #endif
21638
21639 #undef $ac_func
21640
21641 /* Override any GCC internal prototype to avoid an error.
21642 Use char because int might match the return type of a GCC
21643 builtin and then its argument prototype would still apply. */
21644 #ifdef __cplusplus
21645 extern "C"
21646 #endif
21647 char $ac_func ();
21648 /* The GNU C library defines this for functions which it implements
21649 to always fail with ENOSYS. Some functions are actually named
21650 something starting with __ and the normal name is an alias. */
21651 #if defined __stub_$ac_func || defined __stub___$ac_func
21652 choke me
21653 #endif
21654
21655 int
21656 main ()
21657 {
21658 return $ac_func ();
21659 ;
21660 return 0;
21661 }
21662 _ACEOF
21663 rm -f conftest.$ac_objext conftest$ac_exeext
21664 if { (ac_try="$ac_link"
21665 case "(($ac_try" in
21666 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21667 *) ac_try_echo=$ac_try;;
21668 esac
21669 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21670 (eval "$ac_link") 2>conftest.er1
21671 ac_status=$?
21672 grep -v '^ *+' conftest.er1 >conftest.err
21673 rm -f conftest.er1
21674 cat conftest.err >&5
21675 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21676 (exit $ac_status); } && {
21677 test -z "$ac_c_werror_flag" ||
21678 test ! -s conftest.err
21679 } && test -s conftest$ac_exeext &&
21680 $as_test_x conftest$ac_exeext; then
21681 eval "$as_ac_var=yes"
21682 else
21683 echo "$as_me: failed program was:" >&5
21684 sed 's/^/| /' conftest.$ac_ext >&5
21685
21686 eval "$as_ac_var=no"
21687 fi
21688
21689 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
21690 conftest$ac_exeext conftest.$ac_ext
21691 fi
21692 ac_res=`eval echo '${'$as_ac_var'}'`
21693 { echo "$as_me:$LINENO: result: $ac_res" >&5
21694 echo "${ECHO_T}$ac_res" >&6; }
21695 if test `eval echo '${'$as_ac_var'}'` = yes; then
21696 cat >>confdefs.h <<_ACEOF
21697 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
21698 _ACEOF
21699
21700 fi
21701 done
21702
21703
21704 { echo "$as_me:$LINENO: checking for MD5 in -lmd" >&5
21705 echo $ECHO_N "checking for MD5 in -lmd... $ECHO_C" >&6; }
21706 if test "${ac_cv_lib_md_MD5+set}" = set; then
21707 echo $ECHO_N "(cached) $ECHO_C" >&6
21708 else
21709 ac_check_lib_save_LIBS=$LIBS
21710 LIBS="-lmd $LIBS"
21711 cat >conftest.$ac_ext <<_ACEOF
21712 /* confdefs.h. */
21713 _ACEOF
21714 cat confdefs.h >>conftest.$ac_ext
21715 cat >>conftest.$ac_ext <<_ACEOF
21716 /* end confdefs.h. */
21717
21718 /* Override any GCC internal prototype to avoid an error.
21719 Use char because int might match the return type of a GCC
21720 builtin and then its argument prototype would still apply. */
21721 #ifdef __cplusplus
21722 extern "C"
21723 #endif
21724 char MD5 ();
21725 int
21726 main ()
21727 {
21728 return MD5 ();
21729 ;
21730 return 0;
21731 }
21732 _ACEOF
21733 rm -f conftest.$ac_objext conftest$ac_exeext
21734 if { (ac_try="$ac_link"
21735 case "(($ac_try" in
21736 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21737 *) ac_try_echo=$ac_try;;
21738 esac
21739 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21740 (eval "$ac_link") 2>conftest.er1
21741 ac_status=$?
21742 grep -v '^ *+' conftest.er1 >conftest.err
21743 rm -f conftest.er1
21744 cat conftest.err >&5
21745 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21746 (exit $ac_status); } && {
21747 test -z "$ac_c_werror_flag" ||
21748 test ! -s conftest.err
21749 } && test -s conftest$ac_exeext &&
21750 $as_test_x conftest$ac_exeext; then
21751 ac_cv_lib_md_MD5=yes
21752 else
21753 echo "$as_me: failed program was:" >&5
21754 sed 's/^/| /' conftest.$ac_ext >&5
21755
21756 ac_cv_lib_md_MD5=no
21757 fi
21758
21759 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
21760 conftest$ac_exeext conftest.$ac_ext
21761 LIBS=$ac_check_lib_save_LIBS
21762 fi
21763 { echo "$as_me:$LINENO: result: $ac_cv_lib_md_MD5" >&5
21764 echo "${ECHO_T}$ac_cv_lib_md_MD5" >&6; }
21765 if test $ac_cv_lib_md_MD5 = yes; then
21766 cat >>confdefs.h <<_ACEOF
21767 #define HAVE_LIBMD 1
21768 _ACEOF
21769
21770 LIBS="-lmd $LIBS"
21771
21772 fi
21773 # if libmd is available, get it
21774
21775
21776 for ac_func in PEM_read_bio_RSA_PUBKEY
21777 do
21778 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
21779 { echo "$as_me:$LINENO: checking for $ac_func" >&5
21780 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
21781 if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
21782 echo $ECHO_N "(cached) $ECHO_C" >&6
21783 else
21784 cat >conftest.$ac_ext <<_ACEOF
21785 /* confdefs.h. */
21786 _ACEOF
21787 cat confdefs.h >>conftest.$ac_ext
21788 cat >>conftest.$ac_ext <<_ACEOF
21789 /* end confdefs.h. */
21790 /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
21791 For example, HP-UX 11i <limits.h> declares gettimeofday. */
21792 #define $ac_func innocuous_$ac_func
21793
21794 /* System header to define __stub macros and hopefully few prototypes,
21795 which can conflict with char $ac_func (); below.
21796 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
21797 <limits.h> exists even on freestanding compilers. */
21798
21799 #ifdef __STDC__
21800 # include <limits.h>
21801 #else
21802 # include <assert.h>
21803 #endif
21804
21805 #undef $ac_func
21806
21807 /* Override any GCC internal prototype to avoid an error.
21808 Use char because int might match the return type of a GCC
21809 builtin and then its argument prototype would still apply. */
21810 #ifdef __cplusplus
21811 extern "C"
21812 #endif
21813 char $ac_func ();
21814 /* The GNU C library defines this for functions which it implements
21815 to always fail with ENOSYS. Some functions are actually named
21816 something starting with __ and the normal name is an alias. */
21817 #if defined __stub_$ac_func || defined __stub___$ac_func
21818 choke me
21819 #endif
21820
21821 int
21822 main ()
21823 {
21824 return $ac_func ();
21825 ;
21826 return 0;
21827 }
21828 _ACEOF
21829 rm -f conftest.$ac_objext conftest$ac_exeext
21830 if { (ac_try="$ac_link"
21831 case "(($ac_try" in
21832 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21833 *) ac_try_echo=$ac_try;;
21834 esac
21835 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21836 (eval "$ac_link") 2>conftest.er1
21837 ac_status=$?
21838 grep -v '^ *+' conftest.er1 >conftest.err
21839 rm -f conftest.er1
21840 cat conftest.err >&5
21841 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21842 (exit $ac_status); } && {
21843 test -z "$ac_c_werror_flag" ||
21844 test ! -s conftest.err
21845 } && test -s conftest$ac_exeext &&
21846 $as_test_x conftest$ac_exeext; then
21847 eval "$as_ac_var=yes"
21848 else
21849 echo "$as_me: failed program was:" >&5
21850 sed 's/^/| /' conftest.$ac_ext >&5
21851
21852 eval "$as_ac_var=no"
21853 fi
21854
21855 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
21856 conftest$ac_exeext conftest.$ac_ext
21857 fi
21858 ac_res=`eval echo '${'$as_ac_var'}'`
21859 { echo "$as_me:$LINENO: result: $ac_res" >&5
21860 echo "${ECHO_T}$ac_res" >&6; }
21861 if test `eval echo '${'$as_ac_var'}'` = yes; then
21862 cat >>confdefs.h <<_ACEOF
21863 #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
21864 _ACEOF
21865
21866 fi
21867 done
21868
21869
21870 ################################################################
21871 ## FUSE: Filesystem in Userspace
21872 # Check whether --enable-fuse was given.
21873 if test "${enable_fuse+set}" = set; then
21874 enableval=$enable_fuse; enable_fuse=$enableval
21875 else
21876 enable_fuse=yes
21877 fi
21878
21879 if test "x${enable_fuse}" = "xyes" ; then
21880 { echo "$as_me:$LINENO: FUSE requested" >&5
21881 echo "$as_me: FUSE requested" >&6;}
21882 CPPFLAGS="-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 $CPPFLAGS"
21883 if test `uname -s` = Darwin ; then
21884 { echo "$as_me:$LINENO: FUSE IS NOT SUPPORTED ON MACOS" >&5
21885 echo "$as_me: FUSE IS NOT SUPPORTED ON MACOS" >&6;}
21886 enable_fuse=no
21887 fi
21888 if test "${ac_cv_header_fuse_h+set}" = set; then
21889 { echo "$as_me:$LINENO: checking for fuse.h" >&5
21890 echo $ECHO_N "checking for fuse.h... $ECHO_C" >&6; }
21891 if test "${ac_cv_header_fuse_h+set}" = set; then
21892 echo $ECHO_N "(cached) $ECHO_C" >&6
21893 fi
21894 { echo "$as_me:$LINENO: result: $ac_cv_header_fuse_h" >&5
21895 echo "${ECHO_T}$ac_cv_header_fuse_h" >&6; }
21896 else
21897 # Is the header compilable?
21898 { echo "$as_me:$LINENO: checking fuse.h usability" >&5
21899 echo $ECHO_N "checking fuse.h usability... $ECHO_C" >&6; }
21900 cat >conftest.$ac_ext <<_ACEOF
21901 /* confdefs.h. */
21902 _ACEOF
21903 cat confdefs.h >>conftest.$ac_ext
21904 cat >>conftest.$ac_ext <<_ACEOF
21905 /* end confdefs.h. */
21906 $ac_includes_default
21907 #include <fuse.h>
21908 _ACEOF
21909 rm -f conftest.$ac_objext
21910 if { (ac_try="$ac_compile"
21911 case "(($ac_try" in
21912 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21913 *) ac_try_echo=$ac_try;;
21914 esac
21915 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21916 (eval "$ac_compile") 2>conftest.er1
21917 ac_status=$?
21918 grep -v '^ *+' conftest.er1 >conftest.err
21919 rm -f conftest.er1
21920 cat conftest.err >&5
21921 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21922 (exit $ac_status); } && {
21923 test -z "$ac_c_werror_flag" ||
21924 test ! -s conftest.err
21925 } && test -s conftest.$ac_objext; then
21926 ac_header_compiler=yes
21927 else
21928 echo "$as_me: failed program was:" >&5
21929 sed 's/^/| /' conftest.$ac_ext >&5
21930
21931 ac_header_compiler=no
21932 fi
21933
21934 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21935 { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
21936 echo "${ECHO_T}$ac_header_compiler" >&6; }
21937
21938 # Is the header present?
21939 { echo "$as_me:$LINENO: checking fuse.h presence" >&5
21940 echo $ECHO_N "checking fuse.h presence... $ECHO_C" >&6; }
21941 cat >conftest.$ac_ext <<_ACEOF
21942 /* confdefs.h. */
21943 _ACEOF
21944 cat confdefs.h >>conftest.$ac_ext
21945 cat >>conftest.$ac_ext <<_ACEOF
21946 /* end confdefs.h. */
21947 #include <fuse.h>
21948 _ACEOF
21949 if { (ac_try="$ac_cpp conftest.$ac_ext"
21950 case "(($ac_try" in
21951 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21952 *) ac_try_echo=$ac_try;;
21953 esac
21954 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21955 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
21956 ac_status=$?
21957 grep -v '^ *+' conftest.er1 >conftest.err
21958 rm -f conftest.er1
21959 cat conftest.err >&5
21960 echo "$as_me:$LINENO: \$? = $ac_status" >&5
21961 (exit $ac_status); } >/dev/null && {
21962 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
21963 test ! -s conftest.err
21964 }; then
21965 ac_header_preproc=yes
21966 else
21967 echo "$as_me: failed program was:" >&5
21968 sed 's/^/| /' conftest.$ac_ext >&5
21969
21970 ac_header_preproc=no
21971 fi
21972
21973 rm -f conftest.err conftest.$ac_ext
21974 { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
21975 echo "${ECHO_T}$ac_header_preproc" >&6; }
21976
21977 # So? What about this header?
21978 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
21979 yes:no: )
21980 { echo "$as_me:$LINENO: WARNING: fuse.h: accepted by the compiler, rejected by the preprocessor!" >&5
21981 echo "$as_me: WARNING: fuse.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
21982 { echo "$as_me:$LINENO: WARNING: fuse.h: proceeding with the compiler's result" >&5
21983 echo "$as_me: WARNING: fuse.h: proceeding with the compiler's result" >&2;}
21984 ac_header_preproc=yes
21985 ;;
21986 no:yes:* )
21987 { echo "$as_me:$LINENO: WARNING: fuse.h: present but cannot be compiled" >&5
21988 echo "$as_me: WARNING: fuse.h: present but cannot be compiled" >&2;}
21989 { echo "$as_me:$LINENO: WARNING: fuse.h: check for missing prerequisite headers?" >&5
21990 echo "$as_me: WARNING: fuse.h: check for missing prerequisite headers?" >&2;}
21991 { echo "$as_me:$LINENO: WARNING: fuse.h: see the Autoconf documentation" >&5
21992 echo "$as_me: WARNING: fuse.h: see the Autoconf documentation" >&2;}
21993 { echo "$as_me:$LINENO: WARNING: fuse.h: section \"Present But Cannot Be Compiled\"" >&5
21994 echo "$as_me: WARNING: fuse.h: section \"Present But Cannot Be Compiled\"" >&2;}
21995 { echo "$as_me:$LINENO: WARNING: fuse.h: proceeding with the preprocessor's result" >&5
21996 echo "$as_me: WARNING: fuse.h: proceeding with the preprocessor's result" >&2;}
21997 { echo "$as_me:$LINENO: WARNING: fuse.h: in the future, the compiler will take precedence" >&5
21998 echo "$as_me: WARNING: fuse.h: in the future, the compiler will take precedence" >&2;}
21999 ( cat <<\_ASBOX
22000 ## ------------------------------ ##
22001 ## Report this to bugs@afflib.org ##
22002 ## ------------------------------ ##
22003 _ASBOX
22004 ) | sed "s/^/$as_me: WARNING: /" >&2
22005 ;;
22006 esac
22007 { echo "$as_me:$LINENO: checking for fuse.h" >&5
22008 echo $ECHO_N "checking for fuse.h... $ECHO_C" >&6; }
22009 if test "${ac_cv_header_fuse_h+set}" = set; then
22010 echo $ECHO_N "(cached) $ECHO_C" >&6
22011 else
22012 ac_cv_header_fuse_h=$ac_header_preproc
22013 fi
22014 { echo "$as_me:$LINENO: result: $ac_cv_header_fuse_h" >&5
22015 echo "${ECHO_T}$ac_cv_header_fuse_h" >&6; }
22016
22017 fi
22018 if test $ac_cv_header_fuse_h = yes; then
22019 :
22020 else
22021 { echo "$as_me:$LINENO: fuse.h not found; Disabling FUSE support." >&5
22022 echo "$as_me: fuse.h not found; Disabling FUSE support." >&6;}
22023 enable_fuse=no
22024 fi
22025
22026
22027
22028
22029 fi
22030 AFFUSE_BIN=
22031 if test "${enable_fuse}" = "yes"; then
22032
22033 cat >>confdefs.h <<\_ACEOF
22034 #define USE_FUSE 1
22035 _ACEOF
22036
22037 AFFUSE_BIN='affuse$(EXEEXT)'
22038 FUSE_LIBS=-lfuse
22039 fi
22040
22041 if test "x$CC" != xcc; then
22042 { echo "$as_me:$LINENO: checking whether $CC and cc understand -c and -o together" >&5
22043 echo $ECHO_N "checking whether $CC and cc understand -c and -o together... $ECHO_C" >&6; }
22044 else
22045 { echo "$as_me:$LINENO: checking whether cc understands -c and -o together" >&5
22046 echo $ECHO_N "checking whether cc understands -c and -o together... $ECHO_C" >&6; }
22047 fi
22048 set dummy $CC; ac_cc=`echo $2 |
22049 sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
22050 if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then
22051 echo $ECHO_N "(cached) $ECHO_C" >&6
22052 else
22053 cat >conftest.$ac_ext <<_ACEOF
22054 /* confdefs.h. */
22055 _ACEOF
22056 cat confdefs.h >>conftest.$ac_ext
22057 cat >>conftest.$ac_ext <<_ACEOF
22058 /* end confdefs.h. */
22059
22060 int
22061 main ()
22062 {
22063
22064 ;
22065 return 0;
22066 }
22067 _ACEOF
22068 # Make sure it works both with $CC and with simple cc.
22069 # We do the test twice because some compilers refuse to overwrite an
22070 # existing .o file with -o, though they will create one.
22071 ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
22072 rm -f conftest2.*
22073 if { (case "(($ac_try" in
22074 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
22075 *) ac_try_echo=$ac_try;;
22076 esac
22077 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
22078 (eval "$ac_try") 2>&5
22079 ac_status=$?
22080 echo "$as_me:$LINENO: \$? = $ac_status" >&5
22081 (exit $ac_status); } &&
22082 test -f conftest2.$ac_objext && { (case "(($ac_try" in
22083 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
22084 *) ac_try_echo=$ac_try;;
22085 esac
22086 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
22087 (eval "$ac_try") 2>&5
22088 ac_status=$?
22089 echo "$as_me:$LINENO: \$? = $ac_status" >&5
22090 (exit $ac_status); };
22091 then
22092 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
22093 if test "x$CC" != xcc; then
22094 # Test first that cc exists at all.
22095 if { ac_try='cc -c conftest.$ac_ext >&5'
22096 { (case "(($ac_try" in
22097 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
22098 *) ac_try_echo=$ac_try;;
22099 esac
22100 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
22101 (eval "$ac_try") 2>&5
22102 ac_status=$?
22103 echo "$as_me:$LINENO: \$? = $ac_status" >&5
22104 (exit $ac_status); }; }; then
22105 ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
22106 rm -f conftest2.*
22107 if { (case "(($ac_try" in
22108 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
22109 *) ac_try_echo=$ac_try;;
22110 esac
22111 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
22112 (eval "$ac_try") 2>&5
22113 ac_status=$?
22114 echo "$as_me:$LINENO: \$? = $ac_status" >&5
22115 (exit $ac_status); } &&
22116 test -f conftest2.$ac_objext && { (case "(($ac_try" in
22117 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
22118 *) ac_try_echo=$ac_try;;
22119 esac
22120 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
22121 (eval "$ac_try") 2>&5
22122 ac_status=$?
22123 echo "$as_me:$LINENO: \$? = $ac_status" >&5
22124 (exit $ac_status); };
22125 then
22126 # cc works too.
22127 :
22128 else
22129 # cc exists but doesn't like -o.
22130 eval ac_cv_prog_cc_${ac_cc}_c_o=no
22131 fi
22132 fi
22133 fi
22134 else
22135 eval ac_cv_prog_cc_${ac_cc}_c_o=no
22136 fi
22137 rm -f -r core conftest*
22138
22139 fi
22140 if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
22141 { echo "$as_me:$LINENO: result: yes" >&5
22142 echo "${ECHO_T}yes" >&6; }
22143 else
22144 { echo "$as_me:$LINENO: result: no" >&5
22145 echo "${ECHO_T}no" >&6; }
22146
22147 cat >>confdefs.h <<\_ACEOF
22148 #define NO_MINUS_C_MINUS_O 1
22149 _ACEOF
22150
22151 fi
22152
22153 # FIXME: we rely on the cache variable name because
22154 # there is no other way.
22155 set dummy $CC
22156 ac_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
22157 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
22158 # Losing compiler, so override with the script.
22159 # FIXME: It is wrong to rewrite CC.
22160 # But if we don't then we get into trouble of one sort or another.
22161 # A longer-term fix would be to have automake use am__CC in this case,
22162 # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
22163 CC="$am_aux_dir/compile $CC"
22164 fi
22165
22166
22167 ############## drop optimization flags if requeted ################
22168
22169 if test x"${AFF_NOOPT}" != "x" ; then
22170 with_noopt="yes";
22171 fi
22172
22173 if test "${with_noopt}" = "yes" ; then
22174 CFLAGS=`echo "$CFLAGS" | sed s/-O[0-9]//` # note the double quoting!
22175 CXXFLAGS=`echo "$CXXFLAGS" | sed s/-O[0-9]//`
22176 fi
22177
22178 # I am a glutten for punishment and this is security-critical software
22179 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -Wall"
22180 CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2 -Wall"
22181
22182
22183 ################ drop threading if requested ################
22184 # Check whether --enable-threading was given.
22185 if test "${enable_threading+set}" = set; then
22186 enableval=$enable_threading;
22187 fi
22188
22189 if test "x$disable_threading" != xno; then
22190 PTHREAD_CFLAGS=""
22191 PTHREAD_CXXFLAGS=""
22192 PTHREAD_LDFLAGS=""
22193
22194 cat >>confdefs.h <<\_ACEOF
22195 #define DISABLE_PTHREAD 1
22196 _ACEOF
22197
22198 fi
22199 if test "x$enable_threading" != xno; then
22200 THREADING_TRUE=
22201 THREADING_FALSE='#'
22202 else
22203 THREADING_TRUE='#'
22204 THREADING_FALSE=
22205 fi
22206
22207
22208 ###### Tell user what flags we have #######
22209 # see http://pre.plt-scheme.org/plt/src/mzscheme/configure.ac
22210 #
22211 { echo "$as_me:$LINENO: " >&5
22212 echo "$as_me: " >&6;}
22213 { echo "$as_me:$LINENO: *****************************************" >&5
22214 echo "$as_me: *****************************************" >&6;}
22215 { echo "$as_me:$LINENO: AFFLIB ${PACKAGE_VERSION} configuration" >&5
22216 echo "$as_me: AFFLIB ${PACKAGE_VERSION} configuration" >&6;}
22217 { echo "$as_me:$LINENO: Amazon S3 Support: ${enable_s3}" >&5
22218 echo "$as_me: Amazon S3 Support: ${enable_s3}" >&6;}
22219 { echo "$as_me:$LINENO: LZMA Compression: yes" >&5
22220 echo "$as_me: LZMA Compression: yes" >&6;}
22221 { echo "$as_me:$LINENO: LIBEWF: ${enable_libewf} (requires uuid-dev on Linux)" >&5
22222 echo "$as_me: LIBEWF: ${enable_libewf} (requires uuid-dev on Linux)" >&6;}
22223 { echo "$as_me:$LINENO: PYTHON Bindings: ${enable_python}" >&5
22224 echo "$as_me: PYTHON Bindings: ${enable_python}" >&6;}
22225 { echo "$as_me:$LINENO: QEMU Image Drivers: ${enable_qemu}" >&5
22226 echo "$as_me: QEMU Image Drivers: ${enable_qemu}" >&6;}
22227 { echo "$as_me:$LINENO: FUSE: ${enable_fuse}" >&5
22228 echo "$as_me: FUSE: ${enable_fuse}" >&6;}
22229 { echo "$as_me:$LINENO: LIBEXPAT: ${have_expat} (needed for AFF signatures)" >&5
22230 echo "$as_me: LIBEXPAT: ${have_expat} (needed for AFF signatures)" >&6;}
22231 { echo "$as_me:$LINENO: " >&5
22232 echo "$as_me: " >&6;}
22233 { echo "$as_me:$LINENO: CFLAGS: ${CFLAGS}" >&5
22234 echo "$as_me: CFLAGS: ${CFLAGS}" >&6;}
22235 { echo "$as_me:$LINENO: CPPFLAGS: ${CPPFLAGS}" >&5
22236 echo "$as_me: CPPFLAGS: ${CPPFLAGS}" >&6;}
22237 { echo "$as_me:$LINENO: CXXFLAGS: ${CXXFLAGS}" >&5
22238 echo "$as_me: CXXFLAGS: ${CXXFLAGS}" >&6;}
22239 { echo "$as_me:$LINENO: LIBS: ${LIBS}" >&5
22240 echo "$as_me: LIBS: ${LIBS}" >&6;}
22241 { echo "$as_me:$LINENO: LDFLAGS: ${LDFLAGS}" >&5
22242 echo "$as_me: LDFLAGS: ${LDFLAGS}" >&6;}
22243 { echo "$as_me:$LINENO: *****************************************" >&5
22244 echo "$as_me: *****************************************" >&6;}
22245 { echo "$as_me:$LINENO: " >&5
22246 echo "$as_me: " >&6;}
22247 ac_config_files="$ac_config_files afflib.pc"
22248
22249 cat >confcache <<\_ACEOF
22250 # This file is a shell script that caches the results of configure
22251 # tests run on this system so they can be shared between configure
22252 # scripts and configure runs, see configure's option --config-cache.
22253 # It is not useful on other systems. If it contains results you don't
22254 # want to keep, you may remove or edit it.
22255 #
22256 # config.status only pays attention to the cache file if you give it
22257 # the --recheck option to rerun configure.
22258 #
22259 # `ac_cv_env_foo' variables (set or unset) will be overridden when
22260 # loading this file, other *unset* `ac_cv_foo' will be assigned the
22261 # following values.
22262
22263 _ACEOF
22264
22265 # The following way of writing the cache mishandles newlines in values,
22266 # but we know of no workaround that is simple, portable, and efficient.
22267 # So, we kill variables containing newlines.
22268 # Ultrix sh set writes to stderr and can't be redirected directly,
22269 # and sets the high bit in the cache file unless we assign to the vars.
22270 (
22271 for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
22272 eval ac_val=\$$ac_var
22273 case $ac_val in #(
22274 *${as_nl}*)
22275 case $ac_var in #(
22276 *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
22277 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
22278 esac
22279 case $ac_var in #(
22280 _ | IFS | as_nl) ;; #(
22281 *) $as_unset $ac_var ;;
22282 esac ;;
22283 esac
22284 done
22285
22286 (set) 2>&1 |
22287 case $as_nl`(ac_space=' '; set) 2>&1` in #(
22288 *${as_nl}ac_space=\ *)
22289 # `set' does not quote correctly, so add quotes (double-quote
22290 # substitution turns \\\\ into \\, and sed turns \\ into \).
22291 sed -n \
22292 "s/'/'\\\\''/g;
22293 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
22294 ;; #(
22295 *)
22296 # `set' quotes correctly as required by POSIX, so do not add quotes.
22297 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
22298 ;;
22299 esac |
22300 sort
22301 ) |
22302 sed '
22303 /^ac_cv_env_/b end
22304 t clear
22305 :clear
22306 s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
22307 t end
22308 s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
22309 :end' >>confcache
22310 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
22311 if test -w "$cache_file"; then
22312 test "x$cache_file" != "x/dev/null" &&
22313 { echo "$as_me:$LINENO: updating cache $cache_file" >&5
22314 echo "$as_me: updating cache $cache_file" >&6;}
22315 cat confcache >$cache_file
22316 else
22317 { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
22318 echo "$as_me: not updating unwritable cache $cache_file" >&6;}
22319 fi
22320 fi
22321 rm -f confcache
22322
22323 test "x$prefix" = xNONE && prefix=$ac_default_prefix
22324 # Let make expand exec_prefix.
22325 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
22326
22327 DEFS=-DHAVE_CONFIG_H
22328
22329 ac_libobjs=
22330 ac_ltlibobjs=
22331 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
22332 # 1. Remove the extension, and $U if already installed.
22333 ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
22334 ac_i=`echo "$ac_i" | sed "$ac_script"`
22335 # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
22336 # will be set to the directory where LIBOBJS objects are built.
22337 ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
22338 ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
22339 done
22340 LIBOBJS=$ac_libobjs
22341
22342 LTLIBOBJS=$ac_ltlibobjs
22343
22344
22345 if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
22346 { { echo "$as_me:$LINENO: error: conditional \"MAINTAINER_MODE\" was never defined.
22347 Usually this means the macro was only invoked conditionally." >&5
22348 echo "$as_me: error: conditional \"MAINTAINER_MODE\" was never defined.
22349 Usually this means the macro was only invoked conditionally." >&2;}
22350 { (exit 1); exit 1; }; }
22351 fi
22352 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
22353 { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
22354 Usually this means the macro was only invoked conditionally." >&5
22355 echo "$as_me: error: conditional \"AMDEP\" was never defined.
22356 Usually this means the macro was only invoked conditionally." >&2;}
22357 { (exit 1); exit 1; }; }
22358 fi
22359 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
22360 { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined.
22361 Usually this means the macro was only invoked conditionally." >&5
22362 echo "$as_me: error: conditional \"am__fastdepCC\" was never defined.
22363 Usually this means the macro was only invoked conditionally." >&2;}
22364 { (exit 1); exit 1; }; }
22365 fi
22366 if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
22367 { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
22368 Usually this means the macro was only invoked conditionally." >&5
22369 echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
22370 Usually this means the macro was only invoked conditionally." >&2;}
22371 { (exit 1); exit 1; }; }
22372 fi
22373 if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
22374 { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined.
22375 Usually this means the macro was only invoked conditionally." >&5
22376 echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined.
22377 Usually this means the macro was only invoked conditionally." >&2;}
22378 { (exit 1); exit 1; }; }
22379 fi
22380 if test -z "${MAYBE_S3_TRUE}" && test -z "${MAYBE_S3_FALSE}"; then
22381 { { echo "$as_me:$LINENO: error: conditional \"MAYBE_S3\" was never defined.
22382 Usually this means the macro was only invoked conditionally." >&5
22383 echo "$as_me: error: conditional \"MAYBE_S3\" was never defined.
22384 Usually this means the macro was only invoked conditionally." >&2;}
22385 { (exit 1); exit 1; }; }
22386 fi
22387 if test -z "${MAYBE_QEMU_TRUE}" && test -z "${MAYBE_QEMU_FALSE}"; then
22388 { { echo "$as_me:$LINENO: error: conditional \"MAYBE_QEMU\" was never defined.
22389 Usually this means the macro was only invoked conditionally." >&5
22390 echo "$as_me: error: conditional \"MAYBE_QEMU\" was never defined.
22391 Usually this means the macro was only invoked conditionally." >&2;}
22392 { (exit 1); exit 1; }; }
22393 fi
22394 if test -z "${HAVE_PYTHON_TRUE}" && test -z "${HAVE_PYTHON_FALSE}"; then
22395 { { echo "$as_me:$LINENO: error: conditional \"HAVE_PYTHON\" was never defined.
22396 Usually this means the macro was only invoked conditionally." >&5
22397 echo "$as_me: error: conditional \"HAVE_PYTHON\" was never defined.
22398 Usually this means the macro was only invoked conditionally." >&2;}
22399 { (exit 1); exit 1; }; }
22400 fi
22401 if test -z "${THREADING_TRUE}" && test -z "${THREADING_FALSE}"; then
22402 { { echo "$as_me:$LINENO: error: conditional \"THREADING\" was never defined.
22403 Usually this means the macro was only invoked conditionally." >&5
22404 echo "$as_me: error: conditional \"THREADING\" was never defined.
22405 Usually this means the macro was only invoked conditionally." >&2;}
22406 { (exit 1); exit 1; }; }
22407 fi
22408
22409 : ${CONFIG_STATUS=./config.status}
22410 ac_clean_files_save=$ac_clean_files
22411 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
22412 { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
22413 echo "$as_me: creating $CONFIG_STATUS" >&6;}
22414 cat >$CONFIG_STATUS <<_ACEOF
22415 #! $SHELL
22416 # Generated by $as_me.
22417 # Run this file to recreate the current configuration.
22418 # Compiler output produced by configure, useful for debugging
22419 # configure, is in config.log if it exists.
22420
22421 debug=false
22422 ac_cs_recheck=false
22423 ac_cs_silent=false
22424 SHELL=\${CONFIG_SHELL-$SHELL}
22425 _ACEOF
22426
22427 cat >>$CONFIG_STATUS <<\_ACEOF
22428 ## --------------------- ##
22429 ## M4sh Initialization. ##
22430 ## --------------------- ##
22431
22432 # Be more Bourne compatible
22433 DUALCASE=1; export DUALCASE # for MKS sh
22434 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
22435 emulate sh
22436 NULLCMD=:
22437 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
22438 # is contrary to our usage. Disable this feature.
22439 alias -g '${1+"$@"}'='"$@"'
22440 setopt NO_GLOB_SUBST
22441 else
22442 case `(set -o) 2>/dev/null` in
22443 *posix*) set -o posix ;;
22444 esac
22445
22446 fi
22447
22448
22449
22450
22451 # PATH needs CR
22452 # Avoid depending upon Character Ranges.
22453 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
22454 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
22455 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
22456 as_cr_digits='0123456789'
22457 as_cr_alnum=$as_cr_Letters$as_cr_digits
22458
22459 # The user is always right.
22460 if test "${PATH_SEPARATOR+set}" != set; then
22461 echo "#! /bin/sh" >conf$$.sh
22462 echo "exit 0" >>conf$$.sh
22463 chmod +x conf$$.sh
22464 if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
22465 PATH_SEPARATOR=';'
22466 else
22467 PATH_SEPARATOR=:
22468 fi
22469 rm -f conf$$.sh
22470 fi
22471
22472 # Support unset when possible.
22473 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
22474 as_unset=unset
22475 else
22476 as_unset=false
22477 fi
22478
22479
22480 # IFS
22481 # We need space, tab and new line, in precisely that order. Quoting is
22482 # there to prevent editors from complaining about space-tab.
22483 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
22484 # splitting by setting IFS to empty value.)
22485 as_nl='
22486 '
22487 IFS=" "" $as_nl"
22488
22489 # Find who we are. Look in the path if we contain no directory separator.
22490 case $0 in
22491 *[\\/]* ) as_myself=$0 ;;
22492 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
22493 for as_dir in $PATH
22494 do
22495 IFS=$as_save_IFS
22496 test -z "$as_dir" && as_dir=.
22497 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
22498 done
22499 IFS=$as_save_IFS
22500
22501 ;;
22502 esac
22503 # We did not find ourselves, most probably we were run as `sh COMMAND'
22504 # in which case we are not to be found in the path.
22505 if test "x$as_myself" = x; then
22506 as_myself=$0
22507 fi
22508 if test ! -f "$as_myself"; then
22509 echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
22510 { (exit 1); exit 1; }
22511 fi
22512
22513 # Work around bugs in pre-3.0 UWIN ksh.
22514 for as_var in ENV MAIL MAILPATH
22515 do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
22516 done
22517 PS1='$ '
22518 PS2='> '
22519 PS4='+ '
22520
22521 # NLS nuisances.
22522 for as_var in \
22523 LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
22524 LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
22525 LC_TELEPHONE LC_TIME
22526 do
22527 if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
22528 eval $as_var=C; export $as_var
22529 else
22530 ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
22531 fi
22532 done
22533
22534 # Required to use basename.
22535 if expr a : '\(a\)' >/dev/null 2>&1 &&
22536 test "X`expr 00001 : '.*\(...\)'`" = X001; then
22537 as_expr=expr
22538 else
22539 as_expr=false
22540 fi
22541
22542 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
22543 as_basename=basename
22544 else
22545 as_basename=false
22546 fi
22547
22548
22549 # Name of the executable.
22550 as_me=`$as_basename -- "$0" ||
22551 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
22552 X"$0" : 'X\(//\)$' \| \
22553 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
22554 echo X/"$0" |
22555 sed '/^.*\/\([^/][^/]*\)\/*$/{
22556 s//\1/
22557 q
22558 }
22559 /^X\/\(\/\/\)$/{
22560 s//\1/
22561 q
22562 }
22563 /^X\/\(\/\).*/{
22564 s//\1/
22565 q
22566 }
22567 s/.*/./; q'`
22568
22569 # CDPATH.
22570 $as_unset CDPATH
22571
22572
22573
22574 as_lineno_1=$LINENO
22575 as_lineno_2=$LINENO
22576 test "x$as_lineno_1" != "x$as_lineno_2" &&
22577 test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
22578
22579 # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
22580 # uniformly replaced by the line number. The first 'sed' inserts a
22581 # line-number line after each line using $LINENO; the second 'sed'
22582 # does the real work. The second script uses 'N' to pair each
22583 # line-number line with the line containing $LINENO, and appends
22584 # trailing '-' during substitution so that $LINENO is not a special
22585 # case at line end.
22586 # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
22587 # scripts with optimization help from Paolo Bonzini. Blame Lee
22588 # E. McMahon (1931-1989) for sed's syntax. :-)
22589 sed -n '
22590 p
22591 /[$]LINENO/=
22592 ' <$as_myself |
22593 sed '
22594 s/[$]LINENO.*/&-/
22595 t lineno
22596 b
22597 :lineno
22598 N
22599 :loop
22600 s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
22601 t loop
22602 s/-\n.*//
22603 ' >$as_me.lineno &&
22604 chmod +x "$as_me.lineno" ||
22605 { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
22606 { (exit 1); exit 1; }; }
22607
22608 # Don't try to exec as it changes $[0], causing all sort of problems
22609 # (the dirname of $[0] is not the place where we might find the
22610 # original and so on. Autoconf is especially sensitive to this).
22611 . "./$as_me.lineno"
22612 # Exit status is that of the last command.
22613 exit
22614 }
22615
22616
22617 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
22618 as_dirname=dirname
22619 else
22620 as_dirname=false
22621 fi
22622
22623 ECHO_C= ECHO_N= ECHO_T=
22624 case `echo -n x` in
22625 -n*)
22626 case `echo 'x\c'` in
22627 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
22628 *) ECHO_C='\c';;
22629 esac;;
22630 *)
22631 ECHO_N='-n';;
22632 esac
22633
22634 if expr a : '\(a\)' >/dev/null 2>&1 &&
22635 test "X`expr 00001 : '.*\(...\)'`" = X001; then
22636 as_expr=expr
22637 else
22638 as_expr=false
22639 fi
22640
22641 rm -f conf$$ conf$$.exe conf$$.file
22642 if test -d conf$$.dir; then
22643 rm -f conf$$.dir/conf$$.file
22644 else
22645 rm -f conf$$.dir
22646 mkdir conf$$.dir
22647 fi
22648 echo >conf$$.file
22649 if ln -s conf$$.file conf$$ 2>/dev/null; then
22650 as_ln_s='ln -s'
22651 # ... but there are two gotchas:
22652 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
22653 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
22654 # In both cases, we have to default to `cp -p'.
22655 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
22656 as_ln_s='cp -p'
22657 elif ln conf$$.file conf$$ 2>/dev/null; then
22658 as_ln_s=ln
22659 else
22660 as_ln_s='cp -p'
22661 fi
22662 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
22663 rmdir conf$$.dir 2>/dev/null
22664
22665 if mkdir -p . 2>/dev/null; then
22666 as_mkdir_p=:
22667 else
22668 test -d ./-p && rmdir ./-p
22669 as_mkdir_p=false
22670 fi
22671
22672 if test -x / >/dev/null 2>&1; then
22673 as_test_x='test -x'
22674 else
22675 if ls -dL / >/dev/null 2>&1; then
22676 as_ls_L_option=L
22677 else
22678 as_ls_L_option=
22679 fi
22680 as_test_x='
22681 eval sh -c '\''
22682 if test -d "$1"; then
22683 test -d "$1/.";
22684 else
22685 case $1 in
22686 -*)set "./$1";;
22687 esac;
22688 case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in
22689 ???[sx]*):;;*)false;;esac;fi
22690 '\'' sh
22691 '
22692 fi
22693 as_executable_p=$as_test_x
22694
22695 # Sed expression to map a string onto a valid CPP name.
22696 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
22697
22698 # Sed expression to map a string onto a valid variable name.
22699 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
22700
22701
22702 exec 6>&1
22703
22704 # Save the log message, to keep $[0] and so on meaningful, and to
22705 # report actual input values of CONFIG_FILES etc. instead of their
22706 # values after options handling.
22707 ac_log="
22708 This file was extended by AFFLIB $as_me 3.5.10, which was
22709 generated by GNU Autoconf 2.61. Invocation command line was
22710
22711 CONFIG_FILES = $CONFIG_FILES
22712 CONFIG_HEADERS = $CONFIG_HEADERS
22713 CONFIG_LINKS = $CONFIG_LINKS
22714 CONFIG_COMMANDS = $CONFIG_COMMANDS
22715 $ $0 $@
22716
22717 on `(hostname || uname -n) 2>/dev/null | sed 1q`
22718 "
22719
22720 _ACEOF
22721
22722 cat >>$CONFIG_STATUS <<_ACEOF
22723 # Files that config.status was made for.
22724 config_files="$ac_config_files"
22725 config_headers="$ac_config_headers"
22726 config_commands="$ac_config_commands"
22727
22728 _ACEOF
22729
22730 cat >>$CONFIG_STATUS <<\_ACEOF
22731 ac_cs_usage="\
22732 \`$as_me' instantiates files from templates according to the
22733 current configuration.
22734
22735 Usage: $0 [OPTIONS] [FILE]...
22736
22737 -h, --help print this help, then exit
22738 -V, --version print version number and configuration settings, then exit
22739 -q, --quiet do not print progress messages
22740 -d, --debug don't remove temporary files
22741 --recheck update $as_me by reconfiguring in the same conditions
22742 --file=FILE[:TEMPLATE]
22743 instantiate the configuration file FILE
22744 --header=FILE[:TEMPLATE]
22745 instantiate the configuration header FILE
22746
22747 Configuration files:
22748 $config_files
22749
22750 Configuration headers:
22751 $config_headers
22752
22753 Configuration commands:
22754 $config_commands
22755
22756 Report bugs to <bug-autoconf@gnu.org>."
22757
22758 _ACEOF
22759 cat >>$CONFIG_STATUS <<_ACEOF
22760 ac_cs_version="\\
22761 AFFLIB config.status 3.5.10
22762 configured by $0, generated by GNU Autoconf 2.61,
22763 with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
22764
22765 Copyright (C) 2006 Free Software Foundation, Inc.
22766 This config.status script is free software; the Free Software Foundation
22767 gives unlimited permission to copy, distribute and modify it."
22768
22769 ac_pwd='$ac_pwd'
22770 srcdir='$srcdir'
22771 INSTALL='$INSTALL'
22772 MKDIR_P='$MKDIR_P'
22773 _ACEOF
22774
22775 cat >>$CONFIG_STATUS <<\_ACEOF
22776 # If no file are specified by the user, then we need to provide default
22777 # value. By we need to know if files were specified by the user.
22778 ac_need_defaults=:
22779 while test $# != 0
22780 do
22781 case $1 in
22782 --*=*)
22783 ac_option=`expr "X$1" : 'X\([^=]*\)='`
22784 ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
22785 ac_shift=:
22786 ;;
22787 *)
22788 ac_option=$1
22789 ac_optarg=$2
22790 ac_shift=shift
22791 ;;
22792 esac
22793
22794 case $ac_option in
22795 # Handling of the options.
22796 -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
22797 ac_cs_recheck=: ;;
22798 --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
22799 echo "$ac_cs_version"; exit ;;
22800 --debug | --debu | --deb | --de | --d | -d )
22801 debug=: ;;
22802 --file | --fil | --fi | --f )
22803 $ac_shift
22804 CONFIG_FILES="$CONFIG_FILES $ac_optarg"
22805 ac_need_defaults=false;;
22806 --header | --heade | --head | --hea )
22807 $ac_shift
22808 CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
22809 ac_need_defaults=false;;
22810 --he | --h)
22811 # Conflict between --help and --header
22812 { echo "$as_me: error: ambiguous option: $1
22813 Try \`$0 --help' for more information." >&2
22814 { (exit 1); exit 1; }; };;
22815 --help | --hel | -h )
22816 echo "$ac_cs_usage"; exit ;;
22817 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
22818 | -silent | --silent | --silen | --sile | --sil | --si | --s)
22819 ac_cs_silent=: ;;
22820
22821 # This is an error.
22822 -*) { echo "$as_me: error: unrecognized option: $1
22823 Try \`$0 --help' for more information." >&2
22824 { (exit 1); exit 1; }; } ;;
22825
22826 *) ac_config_targets="$ac_config_targets $1"
22827 ac_need_defaults=false ;;
22828
22829 esac
22830 shift
22831 done
22832
22833 ac_configure_extra_args=
22834
22835 if $ac_cs_silent; then
22836 exec 6>/dev/null
22837 ac_configure_extra_args="$ac_configure_extra_args --silent"
22838 fi
22839
22840 _ACEOF
22841 cat >>$CONFIG_STATUS <<_ACEOF
22842 if \$ac_cs_recheck; then
22843 echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
22844 CONFIG_SHELL=$SHELL
22845 export CONFIG_SHELL
22846 exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
22847 fi
22848
22849 _ACEOF
22850 cat >>$CONFIG_STATUS <<\_ACEOF
22851 exec 5>>config.log
22852 {
22853 echo
22854 sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
22855 ## Running $as_me. ##
22856 _ASBOX
22857 echo "$ac_log"
22858 } >&5
22859
22860 _ACEOF
22861 cat >>$CONFIG_STATUS <<_ACEOF
22862 #
22863 # INIT-COMMANDS
22864 #
22865 AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
22866
22867
22868 # The HP-UX ksh and POSIX shell print the target directory to stdout
22869 # if CDPATH is set.
22870 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
22871
22872 sed_quote_subst='$sed_quote_subst'
22873 double_quote_subst='$double_quote_subst'
22874 delay_variable_subst='$delay_variable_subst'
22875 macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`'
22876 macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`'
22877 enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`'
22878 enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`'
22879 pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`'
22880 enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`'
22881 host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`'
22882 host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`'
22883 host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`'
22884 build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`'
22885 build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`'
22886 build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`'
22887 SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`'
22888 Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`'
22889 GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`'
22890 EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`'
22891 FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`'
22892 LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`'
22893 NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`'
22894 LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`'
22895 max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`'
22896 ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`'
22897 exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`'
22898 lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`'
22899 lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`'
22900 lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`'
22901 reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`'
22902 reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22903 deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`'
22904 file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`'
22905 AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`'
22906 AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`'
22907 STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`'
22908 RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`'
22909 old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22910 old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22911 old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22912 CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`'
22913 CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`'
22914 compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`'
22915 GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`'
22916 lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`'
22917 lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`'
22918 lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`'
22919 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
22920 objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`'
22921 SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`'
22922 ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`'
22923 MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`'
22924 lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`'
22925 lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`'
22926 lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`'
22927 lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`'
22928 lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`'
22929 need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`'
22930 DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`'
22931 NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`'
22932 LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`'
22933 OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`'
22934 OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`'
22935 libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`'
22936 shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22937 extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22938 archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`'
22939 enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`'
22940 export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
22941 whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
22942 compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`'
22943 old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22944 old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22945 archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22946 archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22947 module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22948 module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22949 with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`'
22950 allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
22951 no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
22952 hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
22953 hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`'
22954 hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`'
22955 hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`'
22956 hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`'
22957 hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`'
22958 hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
22959 hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`'
22960 inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`'
22961 link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`'
22962 fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`'
22963 always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`'
22964 export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22965 exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
22966 include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
22967 prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22968 file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`'
22969 variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`'
22970 need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
22971 need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`'
22972 version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`'
22973 runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`'
22974 shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
22975 shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`'
22976 libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`'
22977 library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`'
22978 soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`'
22979 postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22980 postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22981 finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`'
22982 finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`'
22983 hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`'
22984 sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
22985 sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
22986 hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`'
22987 enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`'
22988 enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`'
22989 enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`'
22990 old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`'
22991 striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`'
22992 compiler_lib_search_dirs='`$ECHO "X$compiler_lib_search_dirs" | $Xsed -e "$delay_single_quote_subst"`'
22993 predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`'
22994 postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`'
22995 predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`'
22996 postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`'
22997 compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`'
22998 LD_CXX='`$ECHO "X$LD_CXX" | $Xsed -e "$delay_single_quote_subst"`'
22999 old_archive_cmds_CXX='`$ECHO "X$old_archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23000 compiler_CXX='`$ECHO "X$compiler_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23001 GCC_CXX='`$ECHO "X$GCC_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23002 lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "X$lt_prog_compiler_no_builtin_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23003 lt_prog_compiler_wl_CXX='`$ECHO "X$lt_prog_compiler_wl_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23004 lt_prog_compiler_pic_CXX='`$ECHO "X$lt_prog_compiler_pic_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23005 lt_prog_compiler_static_CXX='`$ECHO "X$lt_prog_compiler_static_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23006 lt_cv_prog_compiler_c_o_CXX='`$ECHO "X$lt_cv_prog_compiler_c_o_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23007 archive_cmds_need_lc_CXX='`$ECHO "X$archive_cmds_need_lc_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23008 enable_shared_with_static_runtimes_CXX='`$ECHO "X$enable_shared_with_static_runtimes_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23009 export_dynamic_flag_spec_CXX='`$ECHO "X$export_dynamic_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23010 whole_archive_flag_spec_CXX='`$ECHO "X$whole_archive_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23011 compiler_needs_object_CXX='`$ECHO "X$compiler_needs_object_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23012 old_archive_from_new_cmds_CXX='`$ECHO "X$old_archive_from_new_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23013 old_archive_from_expsyms_cmds_CXX='`$ECHO "X$old_archive_from_expsyms_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23014 archive_cmds_CXX='`$ECHO "X$archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23015 archive_expsym_cmds_CXX='`$ECHO "X$archive_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23016 module_cmds_CXX='`$ECHO "X$module_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23017 module_expsym_cmds_CXX='`$ECHO "X$module_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23018 with_gnu_ld_CXX='`$ECHO "X$with_gnu_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23019 allow_undefined_flag_CXX='`$ECHO "X$allow_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23020 no_undefined_flag_CXX='`$ECHO "X$no_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23021 hardcode_libdir_flag_spec_CXX='`$ECHO "X$hardcode_libdir_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23022 hardcode_libdir_flag_spec_ld_CXX='`$ECHO "X$hardcode_libdir_flag_spec_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23023 hardcode_libdir_separator_CXX='`$ECHO "X$hardcode_libdir_separator_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23024 hardcode_direct_CXX='`$ECHO "X$hardcode_direct_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23025 hardcode_direct_absolute_CXX='`$ECHO "X$hardcode_direct_absolute_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23026 hardcode_minus_L_CXX='`$ECHO "X$hardcode_minus_L_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23027 hardcode_shlibpath_var_CXX='`$ECHO "X$hardcode_shlibpath_var_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23028 hardcode_automatic_CXX='`$ECHO "X$hardcode_automatic_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23029 inherit_rpath_CXX='`$ECHO "X$inherit_rpath_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23030 link_all_deplibs_CXX='`$ECHO "X$link_all_deplibs_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23031 fix_srcfile_path_CXX='`$ECHO "X$fix_srcfile_path_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23032 always_export_symbols_CXX='`$ECHO "X$always_export_symbols_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23033 export_symbols_cmds_CXX='`$ECHO "X$export_symbols_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23034 exclude_expsyms_CXX='`$ECHO "X$exclude_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23035 include_expsyms_CXX='`$ECHO "X$include_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23036 prelink_cmds_CXX='`$ECHO "X$prelink_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23037 file_list_spec_CXX='`$ECHO "X$file_list_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23038 hardcode_action_CXX='`$ECHO "X$hardcode_action_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23039 compiler_lib_search_dirs_CXX='`$ECHO "X$compiler_lib_search_dirs_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23040 predep_objects_CXX='`$ECHO "X$predep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23041 postdep_objects_CXX='`$ECHO "X$postdep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23042 predeps_CXX='`$ECHO "X$predeps_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23043 postdeps_CXX='`$ECHO "X$postdeps_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23044 compiler_lib_search_path_CXX='`$ECHO "X$compiler_lib_search_path_CXX" | $Xsed -e "$delay_single_quote_subst"`'
23045
23046 LTCC='$LTCC'
23047 LTCFLAGS='$LTCFLAGS'
23048 compiler='$compiler_DEFAULT'
23049
23050 # Quote evaled strings.
23051 for var in SED \
23052 GREP \
23053 EGREP \
23054 FGREP \
23055 LD \
23056 NM \
23057 LN_S \
23058 lt_SP2NL \
23059 lt_NL2SP \
23060 reload_flag \
23061 deplibs_check_method \
23062 file_magic_cmd \
23063 AR \
23064 AR_FLAGS \
23065 STRIP \
23066 RANLIB \
23067 CC \
23068 CFLAGS \
23069 compiler \
23070 lt_cv_sys_global_symbol_pipe \
23071 lt_cv_sys_global_symbol_to_cdecl \
23072 lt_cv_sys_global_symbol_to_c_name_address \
23073 lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
23074 SHELL \
23075 ECHO \
23076 lt_prog_compiler_no_builtin_flag \
23077 lt_prog_compiler_wl \
23078 lt_prog_compiler_pic \
23079 lt_prog_compiler_static \
23080 lt_cv_prog_compiler_c_o \
23081 need_locks \
23082 DSYMUTIL \
23083 NMEDIT \
23084 LIPO \
23085 OTOOL \
23086 OTOOL64 \
23087 shrext_cmds \
23088 export_dynamic_flag_spec \
23089 whole_archive_flag_spec \
23090 compiler_needs_object \
23091 with_gnu_ld \
23092 allow_undefined_flag \
23093 no_undefined_flag \
23094 hardcode_libdir_flag_spec \
23095 hardcode_libdir_flag_spec_ld \
23096 hardcode_libdir_separator \
23097 fix_srcfile_path \
23098 exclude_expsyms \
23099 include_expsyms \
23100 file_list_spec \
23101 variables_saved_for_relink \
23102 libname_spec \
23103 library_names_spec \
23104 soname_spec \
23105 finish_eval \
23106 old_striplib \
23107 striplib \
23108 compiler_lib_search_dirs \
23109 predep_objects \
23110 postdep_objects \
23111 predeps \
23112 postdeps \
23113 compiler_lib_search_path \
23114 LD_CXX \
23115 compiler_CXX \
23116 lt_prog_compiler_no_builtin_flag_CXX \
23117 lt_prog_compiler_wl_CXX \
23118 lt_prog_compiler_pic_CXX \
23119 lt_prog_compiler_static_CXX \
23120 lt_cv_prog_compiler_c_o_CXX \
23121 export_dynamic_flag_spec_CXX \
23122 whole_archive_flag_spec_CXX \
23123 compiler_needs_object_CXX \
23124 with_gnu_ld_CXX \
23125 allow_undefined_flag_CXX \
23126 no_undefined_flag_CXX \
23127 hardcode_libdir_flag_spec_CXX \
23128 hardcode_libdir_flag_spec_ld_CXX \
23129 hardcode_libdir_separator_CXX \
23130 fix_srcfile_path_CXX \
23131 exclude_expsyms_CXX \
23132 include_expsyms_CXX \
23133 file_list_spec_CXX \
23134 compiler_lib_search_dirs_CXX \
23135 predep_objects_CXX \
23136 postdep_objects_CXX \
23137 predeps_CXX \
23138 postdeps_CXX \
23139 compiler_lib_search_path_CXX; do
23140 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
23141 *[\\\\\\\`\\"\\\$]*)
23142 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
23143 ;;
23144 *)
23145 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
23146 ;;
23147 esac
23148 done
23149
23150 # Double-quote double-evaled strings.
23151 for var in reload_cmds \
23152 old_postinstall_cmds \
23153 old_postuninstall_cmds \
23154 old_archive_cmds \
23155 extract_expsyms_cmds \
23156 old_archive_from_new_cmds \
23157 old_archive_from_expsyms_cmds \
23158 archive_cmds \
23159 archive_expsym_cmds \
23160 module_cmds \
23161 module_expsym_cmds \
23162 export_symbols_cmds \
23163 prelink_cmds \
23164 postinstall_cmds \
23165 postuninstall_cmds \
23166 finish_cmds \
23167 sys_lib_search_path_spec \
23168 sys_lib_dlsearch_path_spec \
23169 old_archive_cmds_CXX \
23170 old_archive_from_new_cmds_CXX \
23171 old_archive_from_expsyms_cmds_CXX \
23172 archive_cmds_CXX \
23173 archive_expsym_cmds_CXX \
23174 module_cmds_CXX \
23175 module_expsym_cmds_CXX \
23176 export_symbols_cmds_CXX \
23177 prelink_cmds_CXX; do
23178 case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
23179 *[\\\\\\\`\\"\\\$]*)
23180 eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
23181 ;;
23182 *)
23183 eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
23184 ;;
23185 esac
23186 done
23187
23188 # Fix-up fallback echo if it was mangled by the above quoting rules.
23189 case \$lt_ECHO in
23190 *'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\`
23191 ;;
23192 esac
23193
23194 ac_aux_dir='$ac_aux_dir'
23195 xsi_shell='$xsi_shell'
23196 lt_shell_append='$lt_shell_append'
23197
23198 # See if we are running on zsh, and set the options which allow our
23199 # commands through without removal of \ escapes INIT.
23200 if test -n "\${ZSH_VERSION+set}" ; then
23201 setopt NO_GLOB_SUBST
23202 fi
23203
23204
23205 PACKAGE='$PACKAGE'
23206 VERSION='$VERSION'
23207 TIMESTAMP='$TIMESTAMP'
23208 RM='$RM'
23209 ofile='$ofile'
23210
23211
23212
23213
23214
23215
23216 _ACEOF
23217
23218 cat >>$CONFIG_STATUS <<\_ACEOF
23219
23220 # Handling of arguments.
23221 for ac_config_target in $ac_config_targets
23222 do
23223 case $ac_config_target in
23224 "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
23225 "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
23226 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
23227 "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
23228 "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
23229 "lzma443/Makefile") CONFIG_FILES="$CONFIG_FILES lzma443/Makefile" ;;
23230 "win32/Makefile") CONFIG_FILES="$CONFIG_FILES win32/Makefile" ;;
23231 "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
23232 "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
23233 "pyaff/Makefile") CONFIG_FILES="$CONFIG_FILES pyaff/Makefile" ;;
23234 "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
23235 "lib/version.h") CONFIG_FILES="$CONFIG_FILES lib/version.h" ;;
23236 "debian/changelog") CONFIG_FILES="$CONFIG_FILES debian/changelog" ;;
23237 "debian/shlibs.local.ex") CONFIG_FILES="$CONFIG_FILES debian/shlibs.local.ex" ;;
23238 "afflib.spec") CONFIG_FILES="$CONFIG_FILES afflib.spec" ;;
23239 "affconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS affconfig.h" ;;
23240 "afflib.pc") CONFIG_FILES="$CONFIG_FILES afflib.pc" ;;
23241
23242 *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
23243 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
23244 { (exit 1); exit 1; }; };;
23245 esac
23246 done
23247
23248
23249 # If the user did not use the arguments to specify the items to instantiate,
23250 # then the envvar interface is used. Set only those that are not.
23251 # We use the long form for the default assignment because of an extremely
23252 # bizarre bug on SunOS 4.1.3.
23253 if $ac_need_defaults; then
23254 test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
23255 test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
23256 test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
23257 fi
23258
23259 # Have a temporary directory for convenience. Make it in the build tree
23260 # simply because there is no reason against having it here, and in addition,
23261 # creating and moving files from /tmp can sometimes cause problems.
23262 # Hook for its removal unless debugging.
23263 # Note that there is a small window in which the directory will not be cleaned:
23264 # after its creation but before its name has been assigned to `$tmp'.
23265 $debug ||
23266 {
23267 tmp=
23268 trap 'exit_status=$?
23269 { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
23270 ' 0
23271 trap '{ (exit 1); exit 1; }' 1 2 13 15
23272 }
23273 # Create a (secure) tmp directory for tmp files.
23274
23275 {
23276 tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
23277 test -n "$tmp" && test -d "$tmp"
23278 } ||
23279 {
23280 tmp=./conf$$-$RANDOM
23281 (umask 077 && mkdir "$tmp")
23282 } ||
23283 {
23284 echo "$me: cannot create a temporary directory in ." >&2
23285 { (exit 1); exit 1; }
23286 }
23287
23288 #
23289 # Set up the sed scripts for CONFIG_FILES section.
23290 #
23291
23292 # No need to generate the scripts if there are no CONFIG_FILES.
23293 # This happens for instance when ./config.status config.h
23294 if test -n "$CONFIG_FILES"; then
23295
23296 _ACEOF
23297
23298
23299
23300 ac_delim='%!_!# '
23301 for ac_last_try in false false false false false :; do
23302 cat >conf$$subs.sed <<_ACEOF
23303 SHELL!$SHELL$ac_delim
23304 PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim
23305 PACKAGE_NAME!$PACKAGE_NAME$ac_delim
23306 PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim
23307 PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim
23308 PACKAGE_STRING!$PACKAGE_STRING$ac_delim
23309 PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim
23310 exec_prefix!$exec_prefix$ac_delim
23311 prefix!$prefix$ac_delim
23312 program_transform_name!$program_transform_name$ac_delim
23313 bindir!$bindir$ac_delim
23314 sbindir!$sbindir$ac_delim
23315 libexecdir!$libexecdir$ac_delim
23316 datarootdir!$datarootdir$ac_delim
23317 datadir!$datadir$ac_delim
23318 sysconfdir!$sysconfdir$ac_delim
23319 sharedstatedir!$sharedstatedir$ac_delim
23320 localstatedir!$localstatedir$ac_delim
23321 includedir!$includedir$ac_delim
23322 oldincludedir!$oldincludedir$ac_delim
23323 docdir!$docdir$ac_delim
23324 infodir!$infodir$ac_delim
23325 htmldir!$htmldir$ac_delim
23326 dvidir!$dvidir$ac_delim
23327 pdfdir!$pdfdir$ac_delim
23328 psdir!$psdir$ac_delim
23329 libdir!$libdir$ac_delim
23330 localedir!$localedir$ac_delim
23331 mandir!$mandir$ac_delim
23332 DEFS!$DEFS$ac_delim
23333 ECHO_C!$ECHO_C$ac_delim
23334 ECHO_N!$ECHO_N$ac_delim
23335 ECHO_T!$ECHO_T$ac_delim
23336 LIBS!$LIBS$ac_delim
23337 build_alias!$build_alias$ac_delim
23338 host_alias!$host_alias$ac_delim
23339 target_alias!$target_alias$ac_delim
23340 INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim
23341 INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim
23342 INSTALL_DATA!$INSTALL_DATA$ac_delim
23343 am__isrc!$am__isrc$ac_delim
23344 CYGPATH_W!$CYGPATH_W$ac_delim
23345 PACKAGE!$PACKAGE$ac_delim
23346 VERSION!$VERSION$ac_delim
23347 ACLOCAL!$ACLOCAL$ac_delim
23348 AUTOCONF!$AUTOCONF$ac_delim
23349 AUTOMAKE!$AUTOMAKE$ac_delim
23350 AUTOHEADER!$AUTOHEADER$ac_delim
23351 MAKEINFO!$MAKEINFO$ac_delim
23352 install_sh!$install_sh$ac_delim
23353 STRIP!$STRIP$ac_delim
23354 INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim
23355 mkdir_p!$mkdir_p$ac_delim
23356 AWK!$AWK$ac_delim
23357 SET_MAKE!$SET_MAKE$ac_delim
23358 am__leading_dot!$am__leading_dot$ac_delim
23359 AMTAR!$AMTAR$ac_delim
23360 am__tar!$am__tar$ac_delim
23361 am__untar!$am__untar$ac_delim
23362 MAINTAINER_MODE_TRUE!$MAINTAINER_MODE_TRUE$ac_delim
23363 MAINTAINER_MODE_FALSE!$MAINTAINER_MODE_FALSE$ac_delim
23364 MAINT!$MAINT$ac_delim
23365 ac_prefix_program!$ac_prefix_program$ac_delim
23366 CC!$CC$ac_delim
23367 CFLAGS!$CFLAGS$ac_delim
23368 LDFLAGS!$LDFLAGS$ac_delim
23369 CPPFLAGS!$CPPFLAGS$ac_delim
23370 ac_ct_CC!$ac_ct_CC$ac_delim
23371 EXEEXT!$EXEEXT$ac_delim
23372 OBJEXT!$OBJEXT$ac_delim
23373 DEPDIR!$DEPDIR$ac_delim
23374 am__include!$am__include$ac_delim
23375 am__quote!$am__quote$ac_delim
23376 AMDEP_TRUE!$AMDEP_TRUE$ac_delim
23377 AMDEP_FALSE!$AMDEP_FALSE$ac_delim
23378 AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim
23379 CCDEPMODE!$CCDEPMODE$ac_delim
23380 am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim
23381 am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim
23382 LIBTOOL!$LIBTOOL$ac_delim
23383 build!$build$ac_delim
23384 build_cpu!$build_cpu$ac_delim
23385 build_vendor!$build_vendor$ac_delim
23386 build_os!$build_os$ac_delim
23387 host!$host$ac_delim
23388 host_cpu!$host_cpu$ac_delim
23389 host_vendor!$host_vendor$ac_delim
23390 host_os!$host_os$ac_delim
23391 SED!$SED$ac_delim
23392 GREP!$GREP$ac_delim
23393 EGREP!$EGREP$ac_delim
23394 FGREP!$FGREP$ac_delim
23395 LD!$LD$ac_delim
23396 DUMPBIN!$DUMPBIN$ac_delim
23397 ac_ct_DUMPBIN!$ac_ct_DUMPBIN$ac_delim
23398 NM!$NM$ac_delim
23399 LN_S!$LN_S$ac_delim
23400 _ACEOF
23401
23402 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
23403 break
23404 elif $ac_last_try; then
23405 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
23406 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
23407 { (exit 1); exit 1; }; }
23408 else
23409 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
23410 fi
23411 done
23412
23413 ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
23414 if test -n "$ac_eof"; then
23415 ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
23416 ac_eof=`expr $ac_eof + 1`
23417 fi
23418
23419 cat >>$CONFIG_STATUS <<_ACEOF
23420 cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof
23421 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
23422 _ACEOF
23423 sed '
23424 s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
23425 s/^/s,@/; s/!/@,|#_!!_#|/
23426 :n
23427 t n
23428 s/'"$ac_delim"'$/,g/; t
23429 s/$/\\/; p
23430 N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
23431 ' >>$CONFIG_STATUS <conf$$subs.sed
23432 rm -f conf$$subs.sed
23433 cat >>$CONFIG_STATUS <<_ACEOF
23434 CEOF$ac_eof
23435 _ACEOF
23436
23437
23438 ac_delim='%!_!# '
23439 for ac_last_try in false false false false false :; do
23440 cat >conf$$subs.sed <<_ACEOF
23441 AR!$AR$ac_delim
23442 RANLIB!$RANLIB$ac_delim
23443 lt_ECHO!$lt_ECHO$ac_delim
23444 DSYMUTIL!$DSYMUTIL$ac_delim
23445 NMEDIT!$NMEDIT$ac_delim
23446 LIPO!$LIPO$ac_delim
23447 OTOOL!$OTOOL$ac_delim
23448 OTOOL64!$OTOOL64$ac_delim
23449 CPP!$CPP$ac_delim
23450 acx_pthread_config!$acx_pthread_config$ac_delim
23451 PTHREAD_CC!$PTHREAD_CC$ac_delim
23452 PTHREAD_LIBS!$PTHREAD_LIBS$ac_delim
23453 PTHREAD_CFLAGS!$PTHREAD_CFLAGS$ac_delim
23454 ALLOCA!$ALLOCA$ac_delim
23455 LIBOBJS!$LIBOBJS$ac_delim
23456 CXX!$CXX$ac_delim
23457 CXXFLAGS!$CXXFLAGS$ac_delim
23458 ac_ct_CXX!$ac_ct_CXX$ac_delim
23459 CXXDEPMODE!$CXXDEPMODE$ac_delim
23460 am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim
23461 am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim
23462 CXXCPP!$CXXCPP$ac_delim
23463 CURL_CONFIG!$CURL_CONFIG$ac_delim
23464 S3_BIN!$S3_BIN$ac_delim
23465 MAYBE_S3_TRUE!$MAYBE_S3_TRUE$ac_delim
23466 MAYBE_S3_FALSE!$MAYBE_S3_FALSE$ac_delim
23467 MAYBE_QEMU_TRUE!$MAYBE_QEMU_TRUE$ac_delim
23468 MAYBE_QEMU_FALSE!$MAYBE_QEMU_FALSE$ac_delim
23469 PYTHON!$PYTHON$ac_delim
23470 PYTHON_VERSION!$PYTHON_VERSION$ac_delim
23471 PYTHON_PREFIX!$PYTHON_PREFIX$ac_delim
23472 PYTHON_EXEC_PREFIX!$PYTHON_EXEC_PREFIX$ac_delim
23473 PYTHON_PLATFORM!$PYTHON_PLATFORM$ac_delim
23474 pythondir!$pythondir$ac_delim
23475 pkgpythondir!$pkgpythondir$ac_delim
23476 pyexecdir!$pyexecdir$ac_delim
23477 pkgpyexecdir!$pkgpyexecdir$ac_delim
23478 PYTHON_CPPFLAGS!$PYTHON_CPPFLAGS$ac_delim
23479 PYTHON_LDFLAGS!$PYTHON_LDFLAGS$ac_delim
23480 PYTHON_SITE_PKG!$PYTHON_SITE_PKG$ac_delim
23481 PYTHON_EXTRA_LIBS!$PYTHON_EXTRA_LIBS$ac_delim
23482 PYTHON_EXTRA_LDFLAGS!$PYTHON_EXTRA_LDFLAGS$ac_delim
23483 HAVE_PYTHON_TRUE!$HAVE_PYTHON_TRUE$ac_delim
23484 HAVE_PYTHON_FALSE!$HAVE_PYTHON_FALSE$ac_delim
23485 FUSE_LIBS!$FUSE_LIBS$ac_delim
23486 FUSE_CFLAGS!$FUSE_CFLAGS$ac_delim
23487 AFFUSE_BIN!$AFFUSE_BIN$ac_delim
23488 THREADING_TRUE!$THREADING_TRUE$ac_delim
23489 THREADING_FALSE!$THREADING_FALSE$ac_delim
23490 LTLIBOBJS!$LTLIBOBJS$ac_delim
23491 _ACEOF
23492
23493 if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 50; then
23494 break
23495 elif $ac_last_try; then
23496 { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
23497 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
23498 { (exit 1); exit 1; }; }
23499 else
23500 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
23501 fi
23502 done
23503
23504 ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
23505 if test -n "$ac_eof"; then
23506 ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
23507 ac_eof=`expr $ac_eof + 1`
23508 fi
23509
23510 cat >>$CONFIG_STATUS <<_ACEOF
23511 cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof
23512 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
23513 _ACEOF
23514 sed '
23515 s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
23516 s/^/s,@/; s/!/@,|#_!!_#|/
23517 :n
23518 t n
23519 s/'"$ac_delim"'$/,g/; t
23520 s/$/\\/; p
23521 N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
23522 ' >>$CONFIG_STATUS <conf$$subs.sed
23523 rm -f conf$$subs.sed
23524 cat >>$CONFIG_STATUS <<_ACEOF
23525 :end
23526 s/|#_!!_#|//g
23527 CEOF$ac_eof
23528 _ACEOF
23529
23530
23531 # VPATH may cause trouble with some makes, so we remove $(srcdir),
23532 # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
23533 # trailing colons and then remove the whole line if VPATH becomes empty
23534 # (actually we leave an empty line to preserve line numbers).
23535 if test "x$srcdir" = x.; then
23536 ac_vpsub='/^[ ]*VPATH[ ]*=/{
23537 s/:*\$(srcdir):*/:/
23538 s/:*\${srcdir}:*/:/
23539 s/:*@srcdir@:*/:/
23540 s/^\([^=]*=[ ]*\):*/\1/
23541 s/:*$//
23542 s/^[^=]*=[ ]*$//
23543 }'
23544 fi
23545
23546 cat >>$CONFIG_STATUS <<\_ACEOF
23547 fi # test -n "$CONFIG_FILES"
23548
23549
23550 for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS
23551 do
23552 case $ac_tag in
23553 :[FHLC]) ac_mode=$ac_tag; continue;;
23554 esac
23555 case $ac_mode$ac_tag in
23556 :[FHL]*:*);;
23557 :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
23558 echo "$as_me: error: Invalid tag $ac_tag." >&2;}
23559 { (exit 1); exit 1; }; };;
23560 :[FH]-) ac_tag=-:-;;
23561 :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
23562 esac
23563 ac_save_IFS=$IFS
23564 IFS=:
23565 set x $ac_tag
23566 IFS=$ac_save_IFS
23567 shift
23568 ac_file=$1
23569 shift
23570
23571 case $ac_mode in
23572 :L) ac_source=$1;;
23573 :[FH])
23574 ac_file_inputs=
23575 for ac_f
23576 do
23577 case $ac_f in
23578 -) ac_f="$tmp/stdin";;
23579 *) # Look for the file first in the build tree, then in the source tree
23580 # (if the path is not absolute). The absolute path cannot be DOS-style,
23581 # because $ac_f cannot contain `:'.
23582 test -f "$ac_f" ||
23583 case $ac_f in
23584 [\\/$]*) false;;
23585 *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
23586 esac ||
23587 { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
23588 echo "$as_me: error: cannot find input file: $ac_f" >&2;}
23589 { (exit 1); exit 1; }; };;
23590 esac
23591 ac_file_inputs="$ac_file_inputs $ac_f"
23592 done
23593
23594 # Let's still pretend it is `configure' which instantiates (i.e., don't
23595 # use $as_me), people would be surprised to read:
23596 # /* config.h. Generated by config.status. */
23597 configure_input="Generated from "`IFS=:
23598 echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
23599 if test x"$ac_file" != x-; then
23600 configure_input="$ac_file. $configure_input"
23601 { echo "$as_me:$LINENO: creating $ac_file" >&5
23602 echo "$as_me: creating $ac_file" >&6;}
23603 fi
23604
23605 case $ac_tag in
23606 *:-:* | *:-) cat >"$tmp/stdin";;
23607 esac
23608 ;;
23609 esac
23610
23611 ac_dir=`$as_dirname -- "$ac_file" ||
23612 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
23613 X"$ac_file" : 'X\(//\)[^/]' \| \
23614 X"$ac_file" : 'X\(//\)$' \| \
23615 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
23616 echo X"$ac_file" |
23617 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
23618 s//\1/
23619 q
23620 }
23621 /^X\(\/\/\)[^/].*/{
23622 s//\1/
23623 q
23624 }
23625 /^X\(\/\/\)$/{
23626 s//\1/
23627 q
23628 }
23629 /^X\(\/\).*/{
23630 s//\1/
23631 q
23632 }
23633 s/.*/./; q'`
23634 { as_dir="$ac_dir"
23635 case $as_dir in #(
23636 -*) as_dir=./$as_dir;;
23637 esac
23638 test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
23639 as_dirs=
23640 while :; do
23641 case $as_dir in #(
23642 *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
23643 *) as_qdir=$as_dir;;
23644 esac
23645 as_dirs="'$as_qdir' $as_dirs"
23646 as_dir=`$as_dirname -- "$as_dir" ||
23647 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
23648 X"$as_dir" : 'X\(//\)[^/]' \| \
23649 X"$as_dir" : 'X\(//\)$' \| \
23650 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
23651 echo X"$as_dir" |
23652 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
23653 s//\1/
23654 q
23655 }
23656 /^X\(\/\/\)[^/].*/{
23657 s//\1/
23658 q
23659 }
23660 /^X\(\/\/\)$/{
23661 s//\1/
23662 q
23663 }
23664 /^X\(\/\).*/{
23665 s//\1/
23666 q
23667 }
23668 s/.*/./; q'`
23669 test -d "$as_dir" && break
23670 done
23671 test -z "$as_dirs" || eval "mkdir $as_dirs"
23672 } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
23673 echo "$as_me: error: cannot create directory $as_dir" >&2;}
23674 { (exit 1); exit 1; }; }; }
23675 ac_builddir=.
23676
23677 case "$ac_dir" in
23678 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
23679 *)
23680 ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
23681 # A ".." for each directory in $ac_dir_suffix.
23682 ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
23683 case $ac_top_builddir_sub in
23684 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
23685 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
23686 esac ;;
23687 esac
23688 ac_abs_top_builddir=$ac_pwd
23689 ac_abs_builddir=$ac_pwd$ac_dir_suffix
23690 # for backward compatibility:
23691 ac_top_builddir=$ac_top_build_prefix
23692
23693 case $srcdir in
23694 .) # We are building in place.
23695 ac_srcdir=.
23696 ac_top_srcdir=$ac_top_builddir_sub
23697 ac_abs_top_srcdir=$ac_pwd ;;
23698 [\\/]* | ?:[\\/]* ) # Absolute name.
23699 ac_srcdir=$srcdir$ac_dir_suffix;
23700 ac_top_srcdir=$srcdir
23701 ac_abs_top_srcdir=$srcdir ;;
23702 *) # Relative name.
23703 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
23704 ac_top_srcdir=$ac_top_build_prefix$srcdir
23705 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
23706 esac
23707 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
23708
23709
23710 case $ac_mode in
23711 :F)
23712 #
23713 # CONFIG_FILE
23714 #
23715
23716 case $INSTALL in
23717 [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
23718 *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
23719 esac
23720 ac_MKDIR_P=$MKDIR_P
23721 case $MKDIR_P in
23722 [\\/$]* | ?:[\\/]* ) ;;
23723 */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
23724 esac
23725 _ACEOF
23726
23727 cat >>$CONFIG_STATUS <<\_ACEOF
23728 # If the template does not know about datarootdir, expand it.
23729 # FIXME: This hack should be removed a few years after 2.60.
23730 ac_datarootdir_hack=; ac_datarootdir_seen=
23731
23732 case `sed -n '/datarootdir/ {
23733 p
23734 q
23735 }
23736 /@datadir@/p
23737 /@docdir@/p
23738 /@infodir@/p
23739 /@localedir@/p
23740 /@mandir@/p
23741 ' $ac_file_inputs` in
23742 *datarootdir*) ac_datarootdir_seen=yes;;
23743 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
23744 { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
23745 echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
23746 _ACEOF
23747 cat >>$CONFIG_STATUS <<_ACEOF
23748 ac_datarootdir_hack='
23749 s&@datadir@&$datadir&g
23750 s&@docdir@&$docdir&g
23751 s&@infodir@&$infodir&g
23752 s&@localedir@&$localedir&g
23753 s&@mandir@&$mandir&g
23754 s&\\\${datarootdir}&$datarootdir&g' ;;
23755 esac
23756 _ACEOF
23757
23758 # Neutralize VPATH when `$srcdir' = `.'.
23759 # Shell code in configure.ac might set extrasub.
23760 # FIXME: do we really want to maintain this feature?
23761 cat >>$CONFIG_STATUS <<_ACEOF
23762 sed "$ac_vpsub
23763 $extrasub
23764 _ACEOF
23765 cat >>$CONFIG_STATUS <<\_ACEOF
23766 :t
23767 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
23768 s&@configure_input@&$configure_input&;t t
23769 s&@top_builddir@&$ac_top_builddir_sub&;t t
23770 s&@srcdir@&$ac_srcdir&;t t
23771 s&@abs_srcdir@&$ac_abs_srcdir&;t t
23772 s&@top_srcdir@&$ac_top_srcdir&;t t
23773 s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
23774 s&@builddir@&$ac_builddir&;t t
23775 s&@abs_builddir@&$ac_abs_builddir&;t t
23776 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
23777 s&@INSTALL@&$ac_INSTALL&;t t
23778 s&@MKDIR_P@&$ac_MKDIR_P&;t t
23779 $ac_datarootdir_hack
23780 " $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out
23781
23782 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
23783 { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
23784 { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
23785 { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
23786 which seems to be undefined. Please make sure it is defined." >&5
23787 echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
23788 which seems to be undefined. Please make sure it is defined." >&2;}
23789
23790 rm -f "$tmp/stdin"
23791 case $ac_file in
23792 -) cat "$tmp/out"; rm -f "$tmp/out";;
23793 *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
23794 esac
23795 ;;
23796 :H)
23797 #
23798 # CONFIG_HEADER
23799 #
23800 _ACEOF
23801
23802 # Transform confdefs.h into a sed script `conftest.defines', that
23803 # substitutes the proper values into config.h.in to produce config.h.
23804 rm -f conftest.defines conftest.tail
23805 # First, append a space to every undef/define line, to ease matching.
23806 echo 's/$/ /' >conftest.defines
23807 # Then, protect against being on the right side of a sed subst, or in
23808 # an unquoted here document, in config.status. If some macros were
23809 # called several times there might be several #defines for the same
23810 # symbol, which is useless. But do not sort them, since the last
23811 # AC_DEFINE must be honored.
23812 ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
23813 # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
23814 # NAME is the cpp macro being defined, VALUE is the value it is being given.
23815 # PARAMS is the parameter list in the macro definition--in most cases, it's
23816 # just an empty string.
23817 ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*'
23818 ac_dB='\\)[ (].*,\\1define\\2'
23819 ac_dC=' '
23820 ac_dD=' ,'
23821
23822 uniq confdefs.h |
23823 sed -n '
23824 t rset
23825 :rset
23826 s/^[ ]*#[ ]*define[ ][ ]*//
23827 t ok
23828 d
23829 :ok
23830 s/[\\&,]/\\&/g
23831 s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
23832 s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
23833 ' >>conftest.defines
23834
23835 # Remove the space that was appended to ease matching.
23836 # Then replace #undef with comments. This is necessary, for
23837 # example, in the case of _POSIX_SOURCE, which is predefined and required
23838 # on some systems where configure will not decide to define it.
23839 # (The regexp can be short, since the line contains either #define or #undef.)
23840 echo 's/ $//
23841 s,^[ #]*u.*,/* & */,' >>conftest.defines
23842
23843 # Break up conftest.defines:
23844 ac_max_sed_lines=50
23845
23846 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1"
23847 # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2"
23848 # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1"
23849 # et cetera.
23850 ac_in='$ac_file_inputs'
23851 ac_out='"$tmp/out1"'
23852 ac_nxt='"$tmp/out2"'
23853
23854 while :
23855 do
23856 # Write a here document:
23857 cat >>$CONFIG_STATUS <<_ACEOF
23858 # First, check the format of the line:
23859 cat >"\$tmp/defines.sed" <<\\CEOF
23860 /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def
23861 /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def
23862 b
23863 :def
23864 _ACEOF
23865 sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
23866 echo 'CEOF
23867 sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
23868 ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
23869 sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
23870 grep . conftest.tail >/dev/null || break
23871 rm -f conftest.defines
23872 mv conftest.tail conftest.defines
23873 done
23874 rm -f conftest.defines conftest.tail
23875
23876 echo "ac_result=$ac_in" >>$CONFIG_STATUS
23877 cat >>$CONFIG_STATUS <<\_ACEOF
23878 if test x"$ac_file" != x-; then
23879 echo "/* $configure_input */" >"$tmp/config.h"
23880 cat "$ac_result" >>"$tmp/config.h"
23881 if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
23882 { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
23883 echo "$as_me: $ac_file is unchanged" >&6;}
23884 else
23885 rm -f $ac_file
23886 mv "$tmp/config.h" $ac_file
23887 fi
23888 else
23889 echo "/* $configure_input */"
23890 cat "$ac_result"
23891 fi
23892 rm -f "$tmp/out12"
23893 # Compute $ac_file's index in $config_headers.
23894 _am_stamp_count=1
23895 for _am_header in $config_headers :; do
23896 case $_am_header in
23897 $ac_file | $ac_file:* )
23898 break ;;
23899 * )
23900 _am_stamp_count=`expr $_am_stamp_count + 1` ;;
23901 esac
23902 done
23903 echo "timestamp for $ac_file" >`$as_dirname -- $ac_file ||
23904 $as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
23905 X$ac_file : 'X\(//\)[^/]' \| \
23906 X$ac_file : 'X\(//\)$' \| \
23907 X$ac_file : 'X\(/\)' \| . 2>/dev/null ||
23908 echo X$ac_file |
23909 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
23910 s//\1/
23911 q
23912 }
23913 /^X\(\/\/\)[^/].*/{
23914 s//\1/
23915 q
23916 }
23917 /^X\(\/\/\)$/{
23918 s//\1/
23919 q
23920 }
23921 /^X\(\/\).*/{
23922 s//\1/
23923 q
23924 }
23925 s/.*/./; q'`/stamp-h$_am_stamp_count
23926 ;;
23927
23928 :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5
23929 echo "$as_me: executing $ac_file commands" >&6;}
23930 ;;
23931 esac
23932
23933
23934 case $ac_file$ac_mode in
23935 "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
23936 # Strip MF so we end up with the name of the file.
23937 mf=`echo "$mf" | sed -e 's/:.*$//'`
23938 # Check whether this is an Automake generated Makefile or not.
23939 # We used to match only the files named `Makefile.in', but
23940 # some people rename them; so instead we look at the file content.
23941 # Grep'ing the first line is not enough: some people post-process
23942 # each Makefile.in and add a new line on top of each file to say so.
23943 # Grep'ing the whole file is not good either: AIX grep has a line
23944 # limit of 2048, but all sed's we know have understand at least 4000.
23945 if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then
23946 dirpart=`$as_dirname -- "$mf" ||
23947 $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
23948 X"$mf" : 'X\(//\)[^/]' \| \
23949 X"$mf" : 'X\(//\)$' \| \
23950 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
23951 echo X"$mf" |
23952 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
23953 s//\1/
23954 q
23955 }
23956 /^X\(\/\/\)[^/].*/{
23957 s//\1/
23958 q
23959 }
23960 /^X\(\/\/\)$/{
23961 s//\1/
23962 q
23963 }
23964 /^X\(\/\).*/{
23965 s//\1/
23966 q
23967 }
23968 s/.*/./; q'`
23969 else
23970 continue
23971 fi
23972 # Extract the definition of DEPDIR, am__include, and am__quote
23973 # from the Makefile without running `make'.
23974 DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
23975 test -z "$DEPDIR" && continue
23976 am__include=`sed -n 's/^am__include = //p' < "$mf"`
23977 test -z "am__include" && continue
23978 am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
23979 # When using ansi2knr, U may be empty or an underscore; expand it
23980 U=`sed -n 's/^U = //p' < "$mf"`
23981 # Find all dependency output files, they are included files with
23982 # $(DEPDIR) in their names. We invoke sed twice because it is the
23983 # simplest approach to changing $(DEPDIR) to its actual value in the
23984 # expansion.
23985 for file in `sed -n "
23986 s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
23987 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
23988 # Make sure the directory exists.
23989 test -f "$dirpart/$file" && continue
23990 fdir=`$as_dirname -- "$file" ||
23991 $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
23992 X"$file" : 'X\(//\)[^/]' \| \
23993 X"$file" : 'X\(//\)$' \| \
23994 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
23995 echo X"$file" |
23996 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
23997 s//\1/
23998 q
23999 }
24000 /^X\(\/\/\)[^/].*/{
24001 s//\1/
24002 q
24003 }
24004 /^X\(\/\/\)$/{
24005 s//\1/
24006 q
24007 }
24008 /^X\(\/\).*/{
24009 s//\1/
24010 q
24011 }
24012 s/.*/./; q'`
24013 { as_dir=$dirpart/$fdir
24014 case $as_dir in #(
24015 -*) as_dir=./$as_dir;;
24016 esac
24017 test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
24018 as_dirs=
24019 while :; do
24020 case $as_dir in #(
24021 *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
24022 *) as_qdir=$as_dir;;
24023 esac
24024 as_dirs="'$as_qdir' $as_dirs"
24025 as_dir=`$as_dirname -- "$as_dir" ||
24026 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
24027 X"$as_dir" : 'X\(//\)[^/]' \| \
24028 X"$as_dir" : 'X\(//\)$' \| \
24029 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
24030 echo X"$as_dir" |
24031 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
24032 s//\1/
24033 q
24034 }
24035 /^X\(\/\/\)[^/].*/{
24036 s//\1/
24037 q
24038 }
24039 /^X\(\/\/\)$/{
24040 s//\1/
24041 q
24042 }
24043 /^X\(\/\).*/{
24044 s//\1/
24045 q
24046 }
24047 s/.*/./; q'`
24048 test -d "$as_dir" && break
24049 done
24050 test -z "$as_dirs" || eval "mkdir $as_dirs"
24051 } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
24052 echo "$as_me: error: cannot create directory $as_dir" >&2;}
24053 { (exit 1); exit 1; }; }; }
24054 # echo "creating $dirpart/$file"
24055 echo '# dummy' > "$dirpart/$file"
24056 done
24057 done
24058 ;;
24059 "libtool":C)
24060
24061 # See if we are running on zsh, and set the options which allow our
24062 # commands through without removal of \ escapes.
24063 if test -n "${ZSH_VERSION+set}" ; then
24064 setopt NO_GLOB_SUBST
24065 fi
24066
24067 cfgfile="${ofile}T"
24068 trap "$RM -f \"$cfgfile\"; exit 1" 1 2 15
24069 $RM -f "$cfgfile"
24070
24071 cat <<_LT_EOF >> "$cfgfile"
24072 #! $SHELL
24073
24074 # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
24075 # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
24076 # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
24077 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
24078 #
24079 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
24080 # 2006, 2007, 2008 Free Software Foundation, Inc.
24081 # Written by Gordon Matzigkeit, 1996
24082 #
24083 # This file is part of GNU Libtool.
24084 #
24085 # GNU Libtool is free software; you can redistribute it and/or
24086 # modify it under the terms of the GNU General Public License as
24087 # published by the Free Software Foundation; either version 2 of
24088 # the License, or (at your option) any later version.
24089 #
24090 # As a special exception to the GNU General Public License,
24091 # if you distribute this file as part of a program or library that
24092 # is built using GNU Libtool, you may include this file under the
24093 # same distribution terms that you use for the rest of that program.
24094 #
24095 # GNU Libtool is distributed in the hope that it will be useful,
24096 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24097 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24098 # GNU General Public License for more details.
24099 #
24100 # You should have received a copy of the GNU General Public License
24101 # along with GNU Libtool; see the file COPYING. If not, a copy
24102 # can be downloaded from http://www.gnu.org/licenses/gpl.html, or
24103 # obtained by writing to the Free Software Foundation, Inc.,
24104 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24105
24106
24107 # The names of the tagged configurations supported by this script.
24108 available_tags="CXX "
24109
24110 # ### BEGIN LIBTOOL CONFIG
24111
24112 # Which release of libtool.m4 was used?
24113 macro_version=$macro_version
24114 macro_revision=$macro_revision
24115
24116 # Whether or not to build shared libraries.
24117 build_libtool_libs=$enable_shared
24118
24119 # Whether or not to build static libraries.
24120 build_old_libs=$enable_static
24121
24122 # What type of objects to build.
24123 pic_mode=$pic_mode
24124
24125 # Whether or not to optimize for fast installation.
24126 fast_install=$enable_fast_install
24127
24128 # The host system.
24129 host_alias=$host_alias
24130 host=$host
24131 host_os=$host_os
24132
24133 # The build system.
24134 build_alias=$build_alias
24135 build=$build
24136 build_os=$build_os
24137
24138 # A sed program that does not truncate output.
24139 SED=$lt_SED
24140
24141 # Sed that helps us avoid accidentally triggering echo(1) options like -n.
24142 Xsed="\$SED -e 1s/^X//"
24143
24144 # A grep program that handles long lines.
24145 GREP=$lt_GREP
24146
24147 # An ERE matcher.
24148 EGREP=$lt_EGREP
24149
24150 # A literal string matcher.
24151 FGREP=$lt_FGREP
24152
24153 # A BSD- or MS-compatible name lister.
24154 NM=$lt_NM
24155
24156 # Whether we need soft or hard links.
24157 LN_S=$lt_LN_S
24158
24159 # What is the maximum length of a command?
24160 max_cmd_len=$max_cmd_len
24161
24162 # Object file suffix (normally "o").
24163 objext=$ac_objext
24164
24165 # Executable file suffix (normally "").
24166 exeext=$exeext
24167
24168 # whether the shell understands "unset".
24169 lt_unset=$lt_unset
24170
24171 # turn spaces into newlines.
24172 SP2NL=$lt_lt_SP2NL
24173
24174 # turn newlines into spaces.
24175 NL2SP=$lt_lt_NL2SP
24176
24177 # How to create reloadable object files.
24178 reload_flag=$lt_reload_flag
24179 reload_cmds=$lt_reload_cmds
24180
24181 # Method to check whether dependent libraries are shared objects.
24182 deplibs_check_method=$lt_deplibs_check_method
24183
24184 # Command to use when deplibs_check_method == "file_magic".
24185 file_magic_cmd=$lt_file_magic_cmd
24186
24187 # The archiver.
24188 AR=$lt_AR
24189 AR_FLAGS=$lt_AR_FLAGS
24190
24191 # A symbol stripping program.
24192 STRIP=$lt_STRIP
24193
24194 # Commands used to install an old-style archive.
24195 RANLIB=$lt_RANLIB
24196 old_postinstall_cmds=$lt_old_postinstall_cmds
24197 old_postuninstall_cmds=$lt_old_postuninstall_cmds
24198
24199 # A C compiler.
24200 LTCC=$lt_CC
24201
24202 # LTCC compiler flags.
24203 LTCFLAGS=$lt_CFLAGS
24204
24205 # Take the output of nm and produce a listing of raw symbols and C names.
24206 global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
24207
24208 # Transform the output of nm in a proper C declaration.
24209 global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
24210
24211 # Transform the output of nm in a C name address pair.
24212 global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
24213
24214 # Transform the output of nm in a C name address pair when lib prefix is needed.
24215 global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
24216
24217 # The name of the directory that contains temporary libtool files.
24218 objdir=$objdir
24219
24220 # Shell to use when invoking shell scripts.
24221 SHELL=$lt_SHELL
24222
24223 # An echo program that does not interpret backslashes.
24224 ECHO=$lt_ECHO
24225
24226 # Used to examine libraries when file_magic_cmd begins with "file".
24227 MAGIC_CMD=$MAGIC_CMD
24228
24229 # Must we lock files when doing compilation?
24230 need_locks=$lt_need_locks
24231
24232 # Tool to manipulate archived DWARF debug symbol files on Mac OS X.
24233 DSYMUTIL=$lt_DSYMUTIL
24234
24235 # Tool to change global to local symbols on Mac OS X.
24236 NMEDIT=$lt_NMEDIT
24237
24238 # Tool to manipulate fat objects and archives on Mac OS X.
24239 LIPO=$lt_LIPO
24240
24241 # ldd/readelf like tool for Mach-O binaries on Mac OS X.
24242 OTOOL=$lt_OTOOL
24243
24244 # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
24245 OTOOL64=$lt_OTOOL64
24246
24247 # Old archive suffix (normally "a").
24248 libext=$libext
24249
24250 # Shared library suffix (normally ".so").
24251 shrext_cmds=$lt_shrext_cmds
24252
24253 # The commands to extract the exported symbol list from a shared archive.
24254 extract_expsyms_cmds=$lt_extract_expsyms_cmds
24255
24256 # Variables whose values should be saved in libtool wrapper scripts and
24257 # restored at link time.
24258 variables_saved_for_relink=$lt_variables_saved_for_relink
24259
24260 # Do we need the "lib" prefix for modules?
24261 need_lib_prefix=$need_lib_prefix
24262
24263 # Do we need a version for libraries?
24264 need_version=$need_version
24265
24266 # Library versioning type.
24267 version_type=$version_type
24268
24269 # Shared library runtime path variable.
24270 runpath_var=$runpath_var
24271
24272 # Shared library path variable.
24273 shlibpath_var=$shlibpath_var
24274
24275 # Is shlibpath searched before the hard-coded library search path?
24276 shlibpath_overrides_runpath=$shlibpath_overrides_runpath
24277
24278 # Format of library name prefix.
24279 libname_spec=$lt_libname_spec
24280
24281 # List of archive names. First name is the real one, the rest are links.
24282 # The last name is the one that the linker finds with -lNAME
24283 library_names_spec=$lt_library_names_spec
24284
24285 # The coded name of the library, if different from the real name.
24286 soname_spec=$lt_soname_spec
24287
24288 # Command to use after installation of a shared archive.
24289 postinstall_cmds=$lt_postinstall_cmds
24290
24291 # Command to use after uninstallation of a shared archive.
24292 postuninstall_cmds=$lt_postuninstall_cmds
24293
24294 # Commands used to finish a libtool library installation in a directory.
24295 finish_cmds=$lt_finish_cmds
24296
24297 # As "finish_cmds", except a single script fragment to be evaled but
24298 # not shown.
24299 finish_eval=$lt_finish_eval
24300
24301 # Whether we should hardcode library paths into libraries.
24302 hardcode_into_libs=$hardcode_into_libs
24303
24304 # Compile-time system search path for libraries.
24305 sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
24306
24307 # Run-time system search path for libraries.
24308 sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
24309
24310 # Whether dlopen is supported.
24311 dlopen_support=$enable_dlopen
24312
24313 # Whether dlopen of programs is supported.
24314 dlopen_self=$enable_dlopen_self
24315
24316 # Whether dlopen of statically linked programs is supported.
24317 dlopen_self_static=$enable_dlopen_self_static
24318
24319 # Commands to strip libraries.
24320 old_striplib=$lt_old_striplib
24321 striplib=$lt_striplib
24322
24323
24324 # The linker used to build libraries.
24325 LD=$lt_LD
24326
24327 # Commands used to build an old-style archive.
24328 old_archive_cmds=$lt_old_archive_cmds
24329
24330 # A language specific compiler.
24331 CC=$lt_compiler
24332
24333 # Is the compiler the GNU compiler?
24334 with_gcc=$GCC
24335
24336 # Compiler flag to turn off builtin functions.
24337 no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
24338
24339 # How to pass a linker flag through the compiler.
24340 wl=$lt_lt_prog_compiler_wl
24341
24342 # Additional compiler flags for building library objects.
24343 pic_flag=$lt_lt_prog_compiler_pic
24344
24345 # Compiler flag to prevent dynamic linking.
24346 link_static_flag=$lt_lt_prog_compiler_static
24347
24348 # Does compiler simultaneously support -c and -o options?
24349 compiler_c_o=$lt_lt_cv_prog_compiler_c_o
24350
24351 # Whether or not to add -lc for building shared libraries.
24352 build_libtool_need_lc=$archive_cmds_need_lc
24353
24354 # Whether or not to disallow shared libs when runtime libs are static.
24355 allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
24356
24357 # Compiler flag to allow reflexive dlopens.
24358 export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
24359
24360 # Compiler flag to generate shared objects directly from archives.
24361 whole_archive_flag_spec=$lt_whole_archive_flag_spec
24362
24363 # Whether the compiler copes with passing no objects directly.
24364 compiler_needs_object=$lt_compiler_needs_object
24365
24366 # Create an old-style archive from a shared archive.
24367 old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
24368
24369 # Create a temporary old-style archive to link instead of a shared archive.
24370 old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
24371
24372 # Commands used to build a shared archive.
24373 archive_cmds=$lt_archive_cmds
24374 archive_expsym_cmds=$lt_archive_expsym_cmds
24375
24376 # Commands used to build a loadable module if different from building
24377 # a shared archive.
24378 module_cmds=$lt_module_cmds
24379 module_expsym_cmds=$lt_module_expsym_cmds
24380
24381 # Whether we are building with GNU ld or not.
24382 with_gnu_ld=$lt_with_gnu_ld
24383
24384 # Flag that allows shared libraries with undefined symbols to be built.
24385 allow_undefined_flag=$lt_allow_undefined_flag
24386
24387 # Flag that enforces no undefined symbols.
24388 no_undefined_flag=$lt_no_undefined_flag
24389
24390 # Flag to hardcode \$libdir into a binary during linking.
24391 # This must work even if \$libdir does not exist
24392 hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
24393
24394 # If ld is used when linking, flag to hardcode \$libdir into a binary
24395 # during linking. This must work even if \$libdir does not exist.
24396 hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
24397
24398 # Whether we need a single "-rpath" flag with a separated argument.
24399 hardcode_libdir_separator=$lt_hardcode_libdir_separator
24400
24401 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
24402 # DIR into the resulting binary.
24403 hardcode_direct=$hardcode_direct
24404
24405 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
24406 # DIR into the resulting binary and the resulting library dependency is
24407 # "absolute",i.e impossible to change by setting \${shlibpath_var} if the
24408 # library is relocated.
24409 hardcode_direct_absolute=$hardcode_direct_absolute
24410
24411 # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
24412 # into the resulting binary.
24413 hardcode_minus_L=$hardcode_minus_L
24414
24415 # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
24416 # into the resulting binary.
24417 hardcode_shlibpath_var=$hardcode_shlibpath_var
24418
24419 # Set to "yes" if building a shared library automatically hardcodes DIR
24420 # into the library and all subsequent libraries and executables linked
24421 # against it.
24422 hardcode_automatic=$hardcode_automatic
24423
24424 # Set to yes if linker adds runtime paths of dependent libraries
24425 # to runtime path list.
24426 inherit_rpath=$inherit_rpath
24427
24428 # Whether libtool must link a program against all its dependency libraries.
24429 link_all_deplibs=$link_all_deplibs
24430
24431 # Fix the shell variable \$srcfile for the compiler.
24432 fix_srcfile_path=$lt_fix_srcfile_path
24433
24434 # Set to "yes" if exported symbols are required.
24435 always_export_symbols=$always_export_symbols
24436
24437 # The commands to list exported symbols.
24438 export_symbols_cmds=$lt_export_symbols_cmds
24439
24440 # Symbols that should not be listed in the preloaded symbols.
24441 exclude_expsyms=$lt_exclude_expsyms
24442
24443 # Symbols that must always be exported.
24444 include_expsyms=$lt_include_expsyms
24445
24446 # Commands necessary for linking programs (against libraries) with templates.
24447 prelink_cmds=$lt_prelink_cmds
24448
24449 # Specify filename containing input files.
24450 file_list_spec=$lt_file_list_spec
24451
24452 # How to hardcode a shared library path into an executable.
24453 hardcode_action=$hardcode_action
24454
24455 # The directories searched by this compiler when creating a shared library.
24456 compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
24457
24458 # Dependencies to place before and after the objects being linked to
24459 # create a shared library.
24460 predep_objects=$lt_predep_objects
24461 postdep_objects=$lt_postdep_objects
24462 predeps=$lt_predeps
24463 postdeps=$lt_postdeps
24464
24465 # The library search path used internally by the compiler when linking
24466 # a shared library.
24467 compiler_lib_search_path=$lt_compiler_lib_search_path
24468
24469 # ### END LIBTOOL CONFIG
24470
24471 _LT_EOF
24472
24473 case $host_os in
24474 aix3*)
24475 cat <<\_LT_EOF >> "$cfgfile"
24476 # AIX sometimes has problems with the GCC collect2 program. For some
24477 # reason, if we set the COLLECT_NAMES environment variable, the problems
24478 # vanish in a puff of smoke.
24479 if test "X${COLLECT_NAMES+set}" != Xset; then
24480 COLLECT_NAMES=
24481 export COLLECT_NAMES
24482 fi
24483 _LT_EOF
24484 ;;
24485 esac
24486
24487
24488 ltmain="$ac_aux_dir/ltmain.sh"
24489
24490
24491 # We use sed instead of cat because bash on DJGPP gets confused if
24492 # if finds mixed CR/LF and LF-only lines. Since sed operates in
24493 # text mode, it properly converts lines to CR/LF. This bash problem
24494 # is reportedly fixed, but why not run on old versions too?
24495 sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
24496 || (rm -f "$cfgfile"; exit 1)
24497
24498 case $xsi_shell in
24499 yes)
24500 cat << \_LT_EOF >> "$cfgfile"
24501
24502 # func_dirname file append nondir_replacement
24503 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
24504 # otherwise set result to NONDIR_REPLACEMENT.
24505 func_dirname ()
24506 {
24507 case ${1} in
24508 */*) func_dirname_result="${1%/*}${2}" ;;
24509 * ) func_dirname_result="${3}" ;;
24510 esac
24511 }
24512
24513 # func_basename file
24514 func_basename ()
24515 {
24516 func_basename_result="${1##*/}"
24517 }
24518
24519 # func_dirname_and_basename file append nondir_replacement
24520 # perform func_basename and func_dirname in a single function
24521 # call:
24522 # dirname: Compute the dirname of FILE. If nonempty,
24523 # add APPEND to the result, otherwise set result
24524 # to NONDIR_REPLACEMENT.
24525 # value returned in "$func_dirname_result"
24526 # basename: Compute filename of FILE.
24527 # value retuned in "$func_basename_result"
24528 # Implementation must be kept synchronized with func_dirname
24529 # and func_basename. For efficiency, we do not delegate to
24530 # those functions but instead duplicate the functionality here.
24531 func_dirname_and_basename ()
24532 {
24533 case ${1} in
24534 */*) func_dirname_result="${1%/*}${2}" ;;
24535 * ) func_dirname_result="${3}" ;;
24536 esac
24537 func_basename_result="${1##*/}"
24538 }
24539
24540 # func_stripname prefix suffix name
24541 # strip PREFIX and SUFFIX off of NAME.
24542 # PREFIX and SUFFIX must not contain globbing or regex special
24543 # characters, hashes, percent signs, but SUFFIX may contain a leading
24544 # dot (in which case that matches only a dot).
24545 func_stripname ()
24546 {
24547 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
24548 # positional parameters, so assign one to ordinary parameter first.
24549 func_stripname_result=${3}
24550 func_stripname_result=${func_stripname_result#"${1}"}
24551 func_stripname_result=${func_stripname_result%"${2}"}
24552 }
24553
24554 # func_opt_split
24555 func_opt_split ()
24556 {
24557 func_opt_split_opt=${1%%=*}
24558 func_opt_split_arg=${1#*=}
24559 }
24560
24561 # func_lo2o object
24562 func_lo2o ()
24563 {
24564 case ${1} in
24565 *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
24566 *) func_lo2o_result=${1} ;;
24567 esac
24568 }
24569
24570 # func_xform libobj-or-source
24571 func_xform ()
24572 {
24573 func_xform_result=${1%.*}.lo
24574 }
24575
24576 # func_arith arithmetic-term...
24577 func_arith ()
24578 {
24579 func_arith_result=$(( $* ))
24580 }
24581
24582 # func_len string
24583 # STRING may not start with a hyphen.
24584 func_len ()
24585 {
24586 func_len_result=${#1}
24587 }
24588
24589 _LT_EOF
24590 ;;
24591 *) # Bourne compatible functions.
24592 cat << \_LT_EOF >> "$cfgfile"
24593
24594 # func_dirname file append nondir_replacement
24595 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
24596 # otherwise set result to NONDIR_REPLACEMENT.
24597 func_dirname ()
24598 {
24599 # Extract subdirectory from the argument.
24600 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
24601 if test "X$func_dirname_result" = "X${1}"; then
24602 func_dirname_result="${3}"
24603 else
24604 func_dirname_result="$func_dirname_result${2}"
24605 fi
24606 }
24607
24608 # func_basename file
24609 func_basename ()
24610 {
24611 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
24612 }
24613
24614
24615 # func_stripname prefix suffix name
24616 # strip PREFIX and SUFFIX off of NAME.
24617 # PREFIX and SUFFIX must not contain globbing or regex special
24618 # characters, hashes, percent signs, but SUFFIX may contain a leading
24619 # dot (in which case that matches only a dot).
24620 # func_strip_suffix prefix name
24621 func_stripname ()
24622 {
24623 case ${2} in
24624 .*) func_stripname_result=`$ECHO "X${3}" \
24625 | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
24626 *) func_stripname_result=`$ECHO "X${3}" \
24627 | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
24628 esac
24629 }
24630
24631 # sed scripts:
24632 my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
24633 my_sed_long_arg='1s/^-[^=]*=//'
24634
24635 # func_opt_split
24636 func_opt_split ()
24637 {
24638 func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
24639 func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
24640 }
24641
24642 # func_lo2o object
24643 func_lo2o ()
24644 {
24645 func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
24646 }
24647
24648 # func_xform libobj-or-source
24649 func_xform ()
24650 {
24651 func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'`
24652 }
24653
24654 # func_arith arithmetic-term...
24655 func_arith ()
24656 {
24657 func_arith_result=`expr "$@"`
24658 }
24659
24660 # func_len string
24661 # STRING may not start with a hyphen.
24662 func_len ()
24663 {
24664 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
24665 }
24666
24667 _LT_EOF
24668 esac
24669
24670 case $lt_shell_append in
24671 yes)
24672 cat << \_LT_EOF >> "$cfgfile"
24673
24674 # func_append var value
24675 # Append VALUE to the end of shell variable VAR.
24676 func_append ()
24677 {
24678 eval "$1+=\$2"
24679 }
24680 _LT_EOF
24681 ;;
24682 *)
24683 cat << \_LT_EOF >> "$cfgfile"
24684
24685 # func_append var value
24686 # Append VALUE to the end of shell variable VAR.
24687 func_append ()
24688 {
24689 eval "$1=\$$1\$2"
24690 }
24691
24692 _LT_EOF
24693 ;;
24694 esac
24695
24696
24697 sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
24698 || (rm -f "$cfgfile"; exit 1)
24699
24700 mv -f "$cfgfile" "$ofile" ||
24701 (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
24702 chmod +x "$ofile"
24703
24704
24705 cat <<_LT_EOF >> "$ofile"
24706
24707 # ### BEGIN LIBTOOL TAG CONFIG: CXX
24708
24709 # The linker used to build libraries.
24710 LD=$lt_LD_CXX
24711
24712 # Commands used to build an old-style archive.
24713 old_archive_cmds=$lt_old_archive_cmds_CXX
24714
24715 # A language specific compiler.
24716 CC=$lt_compiler_CXX
24717
24718 # Is the compiler the GNU compiler?
24719 with_gcc=$GCC_CXX
24720
24721 # Compiler flag to turn off builtin functions.
24722 no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
24723
24724 # How to pass a linker flag through the compiler.
24725 wl=$lt_lt_prog_compiler_wl_CXX
24726
24727 # Additional compiler flags for building library objects.
24728 pic_flag=$lt_lt_prog_compiler_pic_CXX
24729
24730 # Compiler flag to prevent dynamic linking.
24731 link_static_flag=$lt_lt_prog_compiler_static_CXX
24732
24733 # Does compiler simultaneously support -c and -o options?
24734 compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
24735
24736 # Whether or not to add -lc for building shared libraries.
24737 build_libtool_need_lc=$archive_cmds_need_lc_CXX
24738
24739 # Whether or not to disallow shared libs when runtime libs are static.
24740 allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
24741
24742 # Compiler flag to allow reflexive dlopens.
24743 export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
24744
24745 # Compiler flag to generate shared objects directly from archives.
24746 whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
24747
24748 # Whether the compiler copes with passing no objects directly.
24749 compiler_needs_object=$lt_compiler_needs_object_CXX
24750
24751 # Create an old-style archive from a shared archive.
24752 old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
24753
24754 # Create a temporary old-style archive to link instead of a shared archive.
24755 old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
24756
24757 # Commands used to build a shared archive.
24758 archive_cmds=$lt_archive_cmds_CXX
24759 archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
24760
24761 # Commands used to build a loadable module if different from building
24762 # a shared archive.
24763 module_cmds=$lt_module_cmds_CXX
24764 module_expsym_cmds=$lt_module_expsym_cmds_CXX
24765
24766 # Whether we are building with GNU ld or not.
24767 with_gnu_ld=$lt_with_gnu_ld_CXX
24768
24769 # Flag that allows shared libraries with undefined symbols to be built.
24770 allow_undefined_flag=$lt_allow_undefined_flag_CXX
24771
24772 # Flag that enforces no undefined symbols.
24773 no_undefined_flag=$lt_no_undefined_flag_CXX
24774
24775 # Flag to hardcode \$libdir into a binary during linking.
24776 # This must work even if \$libdir does not exist
24777 hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
24778
24779 # If ld is used when linking, flag to hardcode \$libdir into a binary
24780 # during linking. This must work even if \$libdir does not exist.
24781 hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
24782
24783 # Whether we need a single "-rpath" flag with a separated argument.
24784 hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
24785
24786 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
24787 # DIR into the resulting binary.
24788 hardcode_direct=$hardcode_direct_CXX
24789
24790 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
24791 # DIR into the resulting binary and the resulting library dependency is
24792 # "absolute",i.e impossible to change by setting \${shlibpath_var} if the
24793 # library is relocated.
24794 hardcode_direct_absolute=$hardcode_direct_absolute_CXX
24795
24796 # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
24797 # into the resulting binary.
24798 hardcode_minus_L=$hardcode_minus_L_CXX
24799
24800 # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
24801 # into the resulting binary.
24802 hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
24803
24804 # Set to "yes" if building a shared library automatically hardcodes DIR
24805 # into the library and all subsequent libraries and executables linked
24806 # against it.
24807 hardcode_automatic=$hardcode_automatic_CXX
24808
24809 # Set to yes if linker adds runtime paths of dependent libraries
24810 # to runtime path list.
24811 inherit_rpath=$inherit_rpath_CXX
24812
24813 # Whether libtool must link a program against all its dependency libraries.
24814 link_all_deplibs=$link_all_deplibs_CXX
24815
24816 # Fix the shell variable \$srcfile for the compiler.
24817 fix_srcfile_path=$lt_fix_srcfile_path_CXX
24818
24819 # Set to "yes" if exported symbols are required.
24820 always_export_symbols=$always_export_symbols_CXX
24821
24822 # The commands to list exported symbols.
24823 export_symbols_cmds=$lt_export_symbols_cmds_CXX
24824
24825 # Symbols that should not be listed in the preloaded symbols.
24826 exclude_expsyms=$lt_exclude_expsyms_CXX
24827
24828 # Symbols that must always be exported.
24829 include_expsyms=$lt_include_expsyms_CXX
24830
24831 # Commands necessary for linking programs (against libraries) with templates.
24832 prelink_cmds=$lt_prelink_cmds_CXX
24833
24834 # Specify filename containing input files.
24835 file_list_spec=$lt_file_list_spec_CXX
24836
24837 # How to hardcode a shared library path into an executable.
24838 hardcode_action=$hardcode_action_CXX
24839
24840 # The directories searched by this compiler when creating a shared library.
24841 compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
24842
24843 # Dependencies to place before and after the objects being linked to
24844 # create a shared library.
24845 predep_objects=$lt_predep_objects_CXX
24846 postdep_objects=$lt_postdep_objects_CXX
24847 predeps=$lt_predeps_CXX
24848 postdeps=$lt_postdeps_CXX
24849
24850 # The library search path used internally by the compiler when linking
24851 # a shared library.
24852 compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
24853
24854 # ### END LIBTOOL TAG CONFIG: CXX
24855 _LT_EOF
24856
24857 ;;
24858
24859 esac
24860 done # for ac_tag
24861
24862
24863 { (exit 0); exit 0; }
24864 _ACEOF
24865 chmod +x $CONFIG_STATUS
24866 ac_clean_files=$ac_clean_files_save
24867
24868
24869 # configure is writing to config.log, and then calls config.status.
24870 # config.status does its own redirection, appending to config.log.
24871 # Unfortunately, on DOS this fails, as config.log is still kept open
24872 # by configure, so config.status won't be able to write to it; its
24873 # output is simply discarded. So we exec the FD to /dev/null,
24874 # effectively closing config.log, so it can be properly (re)opened and
24875 # appended to by config.status. When coming back to configure, we
24876 # need to make the FD available again.
24877 if test "$no_create" != yes; then
24878 ac_cs_success=:
24879 ac_config_status_args=
24880 test "$silent" = yes &&
24881 ac_config_status_args="$ac_config_status_args --quiet"
24882 exec 5>/dev/null
24883 $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
24884 exec 5>>config.log
24885 # Use ||, not &&, to avoid exiting from the if with $? = 1, which
24886 # would make configure fail if this is the last instruction.
24887 $ac_cs_success || { (exit 1); exit 1; }
24888 fi
24889
24890
24891
0 -*- Autoconf -*-
1 # Process this file with autoconf to produce a configure script.
2 # Order is largely irrevellant, although it must start with AC_INIT and end with AC_OUTPUT
3 # See http://autotoolset.sourceforge.net/tutorial.html
4 # and http://www.openismus.com/documents/linux/automake/automake.shtml
5
6
7 AC_INIT([AFFLIB],[3.5.10],[bugs@afflib.org])
8 AM_INIT_AUTOMAKE
9 AM_MAINTAINER_MODE
10
11
12 # Where we get installed
13 AC_PREFIX_PROGRAM
14
15 # Programs that we will be using
16 AC_PROG_CC
17 AC_PROG_INSTALL
18
19 # Turn off shared libraries during beta-testing, since they
20 # make the build process take too long.
21 AC_PROG_LIBTOOL
22 AC_CONFIG_MACRO_DIR([m4])
23
24 # We are now threading
25 m4_include([acx_pthread.m4])
26 m4_include([acinclude.m4])
27 ACX_PTHREAD()
28
29
30 # AC_PROG_RANLIB not needed if you are using AC_PROG_LIBTOOL
31 # AC_PROG_RANLIB
32 AC_CONFIG_FILES([Makefile lib/Makefile tools/Makefile lzma443/Makefile win32/Makefile
33 tests/Makefile doc/Makefile pyaff/Makefile man/Makefile lib/version.h])
34 dnl Have configure make distribution specific files
35 AC_CONFIG_FILES([debian/changelog])
36 AC_CONFIG_FILES([debian/shlibs.local.ex])
37 AC_CONFIG_FILES([afflib.spec])
38 dnl Have configure write its configuration
39 AM_CONFIG_HEADER([affconfig.h])
40
41 # Bring additional directories where things might be found into our
42 # search path. I don't know why autoconf doesn't do this by default
43 for spfx in /usr/local /opt/local /sw ${prefix} ; do
44 echo checking ${spfx}/include
45 if test -d ${spfx}/include; then
46 CPPFLAGS="-I${spfx}/include $CPPFLAGS"
47 LDFLAGS="-L${spfx}/lib $LDFLAGS"
48 fi
49 done
50
51
52 AC_DEFINE([IN_AFFLIB],1,[Defined if we are inside AFFLIB])
53
54 # Special features that I use
55 AC_FUNC_ALLOCA
56 AC_FUNC_FSEEKO
57 AC_HEADER_DIRENT
58 AC_HEADER_STDC
59 AC_SYS_LARGEFILE
60
61
62 # Checks for typedefs, structures, and compiler characteristics.
63 AC_HEADER_STDBOOL
64 AC_C_CONST
65 AC_C_INLINE
66 AC_TYPE_MODE_T
67 AC_TYPE_OFF_T
68 AC_TYPE_SIZE_T
69 AC_STRUCT_TM
70 AC_STRUCT_ST_BLOCKS
71 AC_STRUCT_ST_RDEV
72
73
74 # Specific headers that I plan to use
75 AC_CHECK_HEADERS([arpa/inet.h assert.h ctype.h dmalloc.h err.h errno.h fcntl.h getopt.h inttypes.h linux/fs.h malloc.h ncurses/term.h netinet/in.h signal.h stdio.h stdlib.h string.h sys/cdefs.h sys/disk.h sys/file.h sys/ioctl.h sys/ioctl.h sys/param.h sys/param.h sys/socket.h sys/signal.h sys/stat.h sys/time.h sys/types.h sys/vfs.h sysexits.h term.h time.h unistd.h zlib.h])
76
77 AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
78 [ AC_DEFINE(HAVE_SOCKADDR_SIN_LEN, 1, [Do we have sockaddr.sin_len?]) ],
79 [],
80 [
81 #include <sys/types.h>
82 #include <sys/socket.h>
83 #include <netinet/in.h>
84 ])
85
86
87 # Specific functions that we want to know about
88 AC_CHECK_FUNCS([getprogname strlcpy strlcat err_set_exit srandom srandomdev flock fstatfs valloc isdigit isalnum isalphanum isatty popen ftruncate memset mkdir putenv regcomp srandomdev strcasecmp strchr strdup strerror strrchr err errx warn warnx utimes])
89
90 # Special features that can be enabled or disabled
91 AC_ARG_WITH([noopt], AC_HELP_STRING([--with-noopt],[Drop -O C flags]))
92
93 # C++ headers
94 AC_PROG_CXX
95 AC_LANG_PUSH([C++])
96 AC_CHECK_HEADERS([cstring])
97 AC_LANG_POP([C++])
98
99
100
101 ################################################################
102 ## LIBEWF support
103 dnl Function to test if a libewf_get_media_size takes value as an argument
104 AC_DEFUN([AFF_CHECK_LIBEWF_GET_MEDIA_SIZE],
105 [AC_CHECK_FUNC(
106 [libewf_get_media_size],
107 [AC_DEFINE(
108 [HAVE_LIBEWF_GET_MEDIA_SIZE],
109 [1],
110 [Define to 1 if you have the libewf_get_media_size function.])
111 AC_LANG_PUSH(C)
112 AC_MSG_CHECKING(
113 [if libewf_get_media_size takes size as an argument.])
114 AC_LINK_IFELSE(
115 [AC_LANG_PROGRAM(
116 [[#include <libewf.h>]],
117 [[libewf_get_media_size(NULL,NULL); ]] )],
118 [AC_MSG_RESULT(
119 [yes])
120 AC_DEFINE(
121 [HAVE_LIBEWF_GET_MEDIA_SIZE_ARGUMENT_VALUE],
122 [1],
123 [Define to 1 if libewf_get_media_size takes value as an argument.])],
124 [AC_MSG_RESULT(
125 [no])] )
126 AC_LANG_POP(C) ])
127 ])
128
129 dnl Function to test if a libewf_get_chunk_size takes value as an argument
130 AC_DEFUN([AFF_CHECK_LIBEWF_GET_CHUNK_SIZE],
131 [AC_CHECK_FUNC(
132 [libewf_get_chunk_size],
133 [AC_DEFINE(
134 [HAVE_LIBEWF_GET_CHUNK_SIZE],
135 [1],
136 [Define to 1 if you have the libewf_get_chunk_size function.])
137 AC_LANG_PUSH(C)
138 AC_MSG_CHECKING(
139 [if libewf_get_chunk_size takes size as an argument.])
140 AC_LINK_IFELSE(
141 [AC_LANG_PROGRAM(
142 [[#include <libewf.h>]],
143 [[libewf_get_chunk_size(NULL,NULL); ]] )],
144 [AC_MSG_RESULT(
145 [yes])
146 AC_DEFINE(
147 [HAVE_LIBEWF_GET_CHUNK_SIZE_ARGUMENT_VALUE],
148 [1],
149 [Define to 1 if libewf_get_chunk_size takes value as an argument.])],
150 [AC_MSG_RESULT(
151 [no])] )
152 AC_LANG_POP(C) ])
153 ])
154
155 dnl Function to test if a libewf_get_bytes_per_sector takes value as an argument
156 AC_DEFUN([AFF_CHECK_LIBEWF_GET_BYTES_PER_SECTOR],
157 [AC_CHECK_FUNC(
158 [libewf_get_bytes_per_sector],
159 [AC_DEFINE(
160 [HAVE_LIBEWF_GET_BYTES_PER_SECTOR],
161 [1],
162 [Define to 1 if you have the libewf_get_bytes_per_sector function.])
163 AC_LANG_PUSH(C)
164 AC_MSG_CHECKING(
165 [if libewf_get_bytes_per_sector takes size as an argument.])
166 AC_LINK_IFELSE(
167 [AC_LANG_PROGRAM(
168 [[#include <libewf.h>]],
169 [[libewf_get_bytes_per_sector(NULL,NULL); ]] )],
170 [AC_MSG_RESULT(
171 [yes])
172 AC_DEFINE(
173 [HAVE_LIBEWF_GET_BYTES_PER_SECTOR_ARGUMENT_VALUE],
174 [1],
175 [Define to 1 if libewf_get_bytes_per_sector takes value as an argument.])],
176 [AC_MSG_RESULT(
177 [no])] )
178 AC_LANG_POP(C) ])
179 ])
180
181
182 AC_ARG_ENABLE([libewf],
183 AC_HELP_STRING([--enable-libewf=yes], [Use libewf for reading EnCase files(default yes)]),
184 [enable_libewf=$enableval], [enable_libewf=yes])
185
186 if test "${enable_libewf}" = "yes" ; then
187 AC_CHECK_HEADERS([libewf.h],,[enable_libewf=no])
188 fi
189
190 if test "${enable_libewf}" = "yes" ; then
191 AC_MSG_NOTICE([On linux, libewf has a dependency which forces linking with -luuid])
192 AC_MSG_NOTICE([so if we are running on linux and that version of libewf is installed,])
193 AC_MSG_NOTICE([make sure the libuuid is installed])
194
195 if test -r /usr/lib/libewf.la ; then
196 if grep luuid /usr/lib/libewf.la ; then
197 AC_MSG_NOTICE([Installed libewf requires libuuid.])
198 AC_CHECK_LIB([uuid],[uuid_generate_random],,[enable_libewf=no])
199 fi
200 fi
201 fi
202
203 if test "${enable_libewf}" = "yes" ; then
204 AC_CHECK_LIB([ewf],[libewf_get_version],,[enable_libewf=no])
205 fi
206
207 if test "${enable_libewf}" = "yes" ; then
208 AFF_CHECK_LIBEWF_GET_MEDIA_SIZE
209 AFF_CHECK_LIBEWF_GET_CHUNK_SIZE
210 AFF_CHECK_LIBEWF_GET_BYTES_PER_SECTOR
211 AC_DEFINE([USE_LIBEWF],1,[Use libewf to read EnCase files])
212 fi
213
214
215 ################################################################
216 # For AFF tools
217 AC_CHECK_FUNCS(tputs tgoto tgetstr tgetnum gotorc beep endwin setupterm printw)
218 AC_CHECK_HEADERS([readline/readline.h])
219 AC_CHECK_HEADERS([curses.h termcap.h])
220 AC_CHECK_LIB([readline],[readline],, AC_MSG_RESULT([readline not installed]))
221 AC_CHECK_LIB([ncurses],[initscr],, AC_MSG_RESULT([ncurses not installed]))
222 AC_CHECK_LIB([z],[uncompress],, AC_MSG_ERROR([zlib not installed; cannot continue. Try adding zlib-dev or zlib1g-dev.]))
223 AC_CHECK_LIB([rt],[aio_error64])
224
225 ################################################################
226 ## Expat
227 ## Required for S3 and Digital Signatures
228 ##
229 AC_ARG_WITH(expat,
230 AS_HELP_STRING([--with-expat=PATH], [where libexpat is compiled (if it isn't installed); required for S3 and Digital Signatures]),
231 [LDFLAGS="-L${with_expat} $LDFLAGS" ;
232 CPPFLAGS="-I${with_expat}/lib $CPPFLAGS"])
233
234 have_expat=yes
235 AC_CHECK_HEADER([expat.h])
236 AC_CHECK_LIB([expat],[XML_ParserCreate],,[have_expat="no ";AC_MSG_WARN([expat not found; S3 and Digital Signatures not enabled])])
237
238
239 ################################################################
240 ## Amazon S3
241 ## S3 requires curl and expat; otherwise we don't need them
242 AC_ARG_ENABLE(s3,
243 AC_HELP_STRING([--enable-s3=yes],
244 [Support for Amazon's S3 service. Requires CURL and Expat.]),
245 [enable_s3=$enableval], [enable_s3=no])
246
247 if test "x${enable_s3}" = "xyes" ; then
248 AC_MSG_NOTICE([S3 support requested. Looking for curl and expat...])
249 AC_PATH_PROG(CURL_CONFIG,curl-config)
250 AC_ARG_WITH(curl,
251 AC_HELP_STRING([--with-curl=PATH], [where libcurl is installed; required for S3]),
252 [CURL_CONFIG="${with_curl}/bin/curl-config"])
253 if test -f "${CURL_CONFIG}"; then
254 LDFLAGS="`${CURL_CONFIG} --libs` $LDFLAGS"
255 CPPFLAGS="`${CURL_CONFIG} --cflags` $CPPFLAGS"
256 else
257 AC_MSG_WARN([curl-config not found, guessing at libcurl build settings])
258 fi
259 AC_CHECK_HEADER([curl/curl.h],,
260 AC_MSG_WARN([curl/curl.h not found; Disabling S3 Support.])
261 enable_s3=no)
262 AC_CHECK_LIB([curl],[curl_global_init],,
263 AC_MSG_WARN([Curl library corrupt; Disabling S3 Support.])
264 enable_s3=no)
265 fi
266
267 S3_BIN=
268 if test "x${enable_s3}" = "xyes" ; then
269 AC_DEFINE([USE_S3],1,[Enable support for Amazon S3])
270 S3_BIN='s3$(EXEEXT)'
271 fi
272 AC_SUBST(S3_BIN)
273 AM_CONDITIONAL([MAYBE_S3],[test "x${enable_s3}" = "xyes"]) # used by automake
274
275 ################################################################
276 ### QEMU
277 ################################################################
278
279 AC_ARG_ENABLE([qemu])
280
281 echo "disable_qemu: " ${disable_qemu}
282 echo "enable_qemu: " ${enable_qemu}
283
284 if test "x${enable_qemu}" = "xno" ; then
285 enable_qemu="no"
286 AC_DEFINE([DISABLE_QEMU],1,[User has disabled QEMU support])
287 else
288 AC_DEFINE([USE_QEMU],1,[Use QEMU image drivers])
289 enable_qemu="yes"
290 fi
291 AM_CONDITIONAL([MAYBE_QEMU],[test "x${enable_qemu}" = "xyes"]) # used by automake
292
293
294 ################################################################
295 ### PyAFF
296 ################################################################
297 # python checks
298 # (requires autoconf 1.5+ and the macros in acinclude.m4)
299 AC_ARG_ENABLE([python],
300 AC_HELP_STRING([--enable-python=no], [Build python bindings (pyaff)]),
301 [enable_python=$enableval], [enable_python=no])
302 if test "${enable_python}" = "yes" ; then
303 AM_PATH_PYTHON([2.5])
304 AC_PYTHON_DEVEL()
305 AC_DEFINE([HAVE_PYTHON],1,[Build Python bindings])
306 fi
307
308 AM_CONDITIONAL(HAVE_PYTHON, test "$enable_python" = yes)
309
310 ##
311 ################################################################
312 ################################################################
313 ## Crypto (must follow S3)
314 ###
315
316
317 AC_CHECK_LIB([ssl],[ssl3_new],,
318 AC_MSG_ERROR([OpenSSL developer library 'libssl-dev' or 'openssl-devel' not installed; cannot continue.]))
319 AC_CHECK_LIB([crypto],[MD5_Update],,
320 AC_MSG_ERROR([OpenSSL developer library 'libcrypto' not installed; cannot continue.]))
321
322 AC_CHECK_HEADERS([openssl/aes.h openssl/bio.h openssl/evp.h openssl/hmac.h openssl/md5.h openssl/rand.h openssl/rsa.h openssl/sha.h openssl/pem.h openssl/x509.h])
323
324 AC_CHECK_FUNCS([MD5 SHA1 AES_encrypt RAND_pseudo_bytes des_read_pw_string EVP_read_pw_string EVP_MD_size])
325 AC_CHECK_LIB([md],[MD5]) # if libmd is available, get it
326
327 AC_CHECK_FUNCS([PEM_read_bio_RSA_PUBKEY])
328
329 ################################################################
330 ## FUSE: Filesystem in Userspace
331 AC_ARG_ENABLE(fuse,
332 AC_HELP_STRING([--enable-fuse=yes],
333 [Support for FUSE, Filesystem in Userspace. (default yes)]),
334 [enable_fuse=$enableval], [enable_fuse=yes])
335 if test "x${enable_fuse}" = "xyes" ; then
336 AC_MSG_NOTICE([FUSE requested])
337 CPPFLAGS="-D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26 $CPPFLAGS"
338 if test `uname -s` = Darwin ; then
339 AC_MSG_NOTICE([FUSE IS NOT SUPPORTED ON MACOS])
340 enable_fuse=no
341 fi
342 AC_CHECK_HEADER([fuse.h],,
343 AC_MSG_NOTICE([fuse.h not found; Disabling FUSE support.])
344 enable_fuse=no)
345 AC_SUBST(FUSE_LIBS)
346 AC_SUBST(FUSE_CFLAGS)
347 fi
348 AFFUSE_BIN=
349 if test "${enable_fuse}" = "yes"; then
350 AC_DEFINE([USE_FUSE],1,[Use FUSE to mount AFF images])
351 AFFUSE_BIN='affuse$(EXEEXT)'
352 FUSE_LIBS=-lfuse
353 fi
354 AC_SUBST(AFFUSE_BIN)
355 AM_PROG_CC_C_O dnl for affuse
356
357 ############## drop optimization flags if requeted ################
358
359 if test x"${AFF_NOOPT}" != "x" ; then
360 with_noopt="yes";
361 fi
362
363 if test "${with_noopt}" = "yes" ; then
364 CFLAGS=`echo "$CFLAGS" | sed s/-O[[0-9]]//` # note the double quoting!
365 CXXFLAGS=`echo "$CXXFLAGS" | sed s/-O[[0-9]]//`
366 fi
367
368 # I am a glutten for punishment and this is security-critical software
369 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -Wall"
370 CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2 -Wall"
371
372
373 ################ drop threading if requested ################
374 AC_ARG_ENABLE(threading,
375 [ --disable-threading builds library without threading
376 --enable-threading use threading if available])
377 if test "x$disable_threading" != xno; then
378 PTHREAD_CFLAGS=""
379 PTHREAD_CXXFLAGS=""
380 PTHREAD_LDFLAGS=""
381 AC_DEFINE(DISABLE_PTHREAD,1,[User has disabled PTHREADING])
382 fi
383 AM_CONDITIONAL([THREADING], [test "x$enable_threading" != xno])
384
385 ###### Tell user what flags we have #######
386 # see http://pre.plt-scheme.org/plt/src/mzscheme/configure.ac
387 #
388 AC_MSG_NOTICE([])
389 AC_MSG_NOTICE([*****************************************])
390 AC_MSG_NOTICE([AFFLIB ${PACKAGE_VERSION} configuration])
391 AC_MSG_NOTICE([Amazon S3 Support: ${enable_s3}])
392 AC_MSG_NOTICE([LZMA Compression: yes])
393 AC_MSG_NOTICE([LIBEWF: ${enable_libewf} (requires uuid-dev on Linux)])
394 AC_MSG_NOTICE([PYTHON Bindings: ${enable_python}])
395 AC_MSG_NOTICE([QEMU Image Drivers: ${enable_qemu}])
396 AC_MSG_NOTICE([FUSE: ${enable_fuse}])
397 AC_MSG_NOTICE([LIBEXPAT: ${have_expat} (needed for AFF signatures)])
398 AC_MSG_NOTICE([])
399 AC_MSG_NOTICE([CFLAGS: ${CFLAGS}])
400 AC_MSG_NOTICE([CPPFLAGS: ${CPPFLAGS}])
401 AC_MSG_NOTICE([CXXFLAGS: ${CXXFLAGS}])
402 AC_MSG_NOTICE([LIBS: ${LIBS}])
403 AC_MSG_NOTICE([LDFLAGS: ${LDFLAGS}])
404 AC_MSG_NOTICE([*****************************************])
405 AC_MSG_NOTICE([])
406 AC_OUTPUT([afflib.pc])
407
408
0 #! /bin/sh
1 # depcomp - compile a program generating dependencies as side-effects
2
3 scriptversion=2005-07-09.11
4
5 # Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
21
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
26
27 # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
28
29 case $1 in
30 '')
31 echo "$0: No command. Try \`$0 --help' for more information." 1>&2
32 exit 1;
33 ;;
34 -h | --h*)
35 cat <<\EOF
36 Usage: depcomp [--help] [--version] PROGRAM [ARGS]
37
38 Run PROGRAMS ARGS to compile a file, generating dependencies
39 as side-effects.
40
41 Environment variables:
42 depmode Dependency tracking mode.
43 source Source file read by `PROGRAMS ARGS'.
44 object Object file output by `PROGRAMS ARGS'.
45 DEPDIR directory where to store dependencies.
46 depfile Dependency file to output.
47 tmpdepfile Temporary file to use when outputing dependencies.
48 libtool Whether libtool is used (yes/no).
49
50 Report bugs to <bug-automake@gnu.org>.
51 EOF
52 exit $?
53 ;;
54 -v | --v*)
55 echo "depcomp $scriptversion"
56 exit $?
57 ;;
58 esac
59
60 if test -z "$depmode" || test -z "$source" || test -z "$object"; then
61 echo "depcomp: Variables source, object and depmode must be set" 1>&2
62 exit 1
63 fi
64
65 # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
66 depfile=${depfile-`echo "$object" |
67 sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
68 tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
69
70 rm -f "$tmpdepfile"
71
72 # Some modes work just like other modes, but use different flags. We
73 # parameterize here, but still list the modes in the big case below,
74 # to make depend.m4 easier to write. Note that we *cannot* use a case
75 # here, because this file can only contain one case statement.
76 if test "$depmode" = hp; then
77 # HP compiler uses -M and no extra arg.
78 gccflag=-M
79 depmode=gcc
80 fi
81
82 if test "$depmode" = dashXmstdout; then
83 # This is just like dashmstdout with a different argument.
84 dashmflag=-xM
85 depmode=dashmstdout
86 fi
87
88 case "$depmode" in
89 gcc3)
90 ## gcc 3 implements dependency tracking that does exactly what
91 ## we want. Yay! Note: for some reason libtool 1.4 doesn't like
92 ## it if -MD -MP comes after the -MF stuff. Hmm.
93 "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
94 stat=$?
95 if test $stat -eq 0; then :
96 else
97 rm -f "$tmpdepfile"
98 exit $stat
99 fi
100 mv "$tmpdepfile" "$depfile"
101 ;;
102
103 gcc)
104 ## There are various ways to get dependency output from gcc. Here's
105 ## why we pick this rather obscure method:
106 ## - Don't want to use -MD because we'd like the dependencies to end
107 ## up in a subdir. Having to rename by hand is ugly.
108 ## (We might end up doing this anyway to support other compilers.)
109 ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
110 ## -MM, not -M (despite what the docs say).
111 ## - Using -M directly means running the compiler twice (even worse
112 ## than renaming).
113 if test -z "$gccflag"; then
114 gccflag=-MD,
115 fi
116 "$@" -Wp,"$gccflag$tmpdepfile"
117 stat=$?
118 if test $stat -eq 0; then :
119 else
120 rm -f "$tmpdepfile"
121 exit $stat
122 fi
123 rm -f "$depfile"
124 echo "$object : \\" > "$depfile"
125 alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
126 ## The second -e expression handles DOS-style file names with drive letters.
127 sed -e 's/^[^:]*: / /' \
128 -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
129 ## This next piece of magic avoids the `deleted header file' problem.
130 ## The problem is that when a header file which appears in a .P file
131 ## is deleted, the dependency causes make to die (because there is
132 ## typically no way to rebuild the header). We avoid this by adding
133 ## dummy dependencies for each header file. Too bad gcc doesn't do
134 ## this for us directly.
135 tr ' ' '
136 ' < "$tmpdepfile" |
137 ## Some versions of gcc put a space before the `:'. On the theory
138 ## that the space means something, we add a space to the output as
139 ## well.
140 ## Some versions of the HPUX 10.20 sed can't process this invocation
141 ## correctly. Breaking it into two sed invocations is a workaround.
142 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
143 rm -f "$tmpdepfile"
144 ;;
145
146 hp)
147 # This case exists only to let depend.m4 do its work. It works by
148 # looking at the text of this script. This case will never be run,
149 # since it is checked for above.
150 exit 1
151 ;;
152
153 sgi)
154 if test "$libtool" = yes; then
155 "$@" "-Wp,-MDupdate,$tmpdepfile"
156 else
157 "$@" -MDupdate "$tmpdepfile"
158 fi
159 stat=$?
160 if test $stat -eq 0; then :
161 else
162 rm -f "$tmpdepfile"
163 exit $stat
164 fi
165 rm -f "$depfile"
166
167 if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
168 echo "$object : \\" > "$depfile"
169
170 # Clip off the initial element (the dependent). Don't try to be
171 # clever and replace this with sed code, as IRIX sed won't handle
172 # lines with more than a fixed number of characters (4096 in
173 # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
174 # the IRIX cc adds comments like `#:fec' to the end of the
175 # dependency line.
176 tr ' ' '
177 ' < "$tmpdepfile" \
178 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
179 tr '
180 ' ' ' >> $depfile
181 echo >> $depfile
182
183 # The second pass generates a dummy entry for each header file.
184 tr ' ' '
185 ' < "$tmpdepfile" \
186 | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
187 >> $depfile
188 else
189 # The sourcefile does not contain any dependencies, so just
190 # store a dummy comment line, to avoid errors with the Makefile
191 # "include basename.Plo" scheme.
192 echo "#dummy" > "$depfile"
193 fi
194 rm -f "$tmpdepfile"
195 ;;
196
197 aix)
198 # The C for AIX Compiler uses -M and outputs the dependencies
199 # in a .u file. In older versions, this file always lives in the
200 # current directory. Also, the AIX compiler puts `$object:' at the
201 # start of each line; $object doesn't have directory information.
202 # Version 6 uses the directory in both cases.
203 stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
204 tmpdepfile="$stripped.u"
205 if test "$libtool" = yes; then
206 "$@" -Wc,-M
207 else
208 "$@" -M
209 fi
210 stat=$?
211
212 if test -f "$tmpdepfile"; then :
213 else
214 stripped=`echo "$stripped" | sed 's,^.*/,,'`
215 tmpdepfile="$stripped.u"
216 fi
217
218 if test $stat -eq 0; then :
219 else
220 rm -f "$tmpdepfile"
221 exit $stat
222 fi
223
224 if test -f "$tmpdepfile"; then
225 outname="$stripped.o"
226 # Each line is of the form `foo.o: dependent.h'.
227 # Do two passes, one to just change these to
228 # `$object: dependent.h' and one to simply `dependent.h:'.
229 sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
230 sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
231 else
232 # The sourcefile does not contain any dependencies, so just
233 # store a dummy comment line, to avoid errors with the Makefile
234 # "include basename.Plo" scheme.
235 echo "#dummy" > "$depfile"
236 fi
237 rm -f "$tmpdepfile"
238 ;;
239
240 icc)
241 # Intel's C compiler understands `-MD -MF file'. However on
242 # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
243 # ICC 7.0 will fill foo.d with something like
244 # foo.o: sub/foo.c
245 # foo.o: sub/foo.h
246 # which is wrong. We want:
247 # sub/foo.o: sub/foo.c
248 # sub/foo.o: sub/foo.h
249 # sub/foo.c:
250 # sub/foo.h:
251 # ICC 7.1 will output
252 # foo.o: sub/foo.c sub/foo.h
253 # and will wrap long lines using \ :
254 # foo.o: sub/foo.c ... \
255 # sub/foo.h ... \
256 # ...
257
258 "$@" -MD -MF "$tmpdepfile"
259 stat=$?
260 if test $stat -eq 0; then :
261 else
262 rm -f "$tmpdepfile"
263 exit $stat
264 fi
265 rm -f "$depfile"
266 # Each line is of the form `foo.o: dependent.h',
267 # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
268 # Do two passes, one to just change these to
269 # `$object: dependent.h' and one to simply `dependent.h:'.
270 sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
271 # Some versions of the HPUX 10.20 sed can't process this invocation
272 # correctly. Breaking it into two sed invocations is a workaround.
273 sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
274 sed -e 's/$/ :/' >> "$depfile"
275 rm -f "$tmpdepfile"
276 ;;
277
278 tru64)
279 # The Tru64 compiler uses -MD to generate dependencies as a side
280 # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
281 # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
282 # dependencies in `foo.d' instead, so we check for that too.
283 # Subdirectories are respected.
284 dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
285 test "x$dir" = "x$object" && dir=
286 base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
287
288 if test "$libtool" = yes; then
289 # With Tru64 cc, shared objects can also be used to make a
290 # static library. This mecanism is used in libtool 1.4 series to
291 # handle both shared and static libraries in a single compilation.
292 # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
293 #
294 # With libtool 1.5 this exception was removed, and libtool now
295 # generates 2 separate objects for the 2 libraries. These two
296 # compilations output dependencies in in $dir.libs/$base.o.d and
297 # in $dir$base.o.d. We have to check for both files, because
298 # one of the two compilations can be disabled. We should prefer
299 # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
300 # automatically cleaned when .libs/ is deleted, while ignoring
301 # the former would cause a distcleancheck panic.
302 tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
303 tmpdepfile2=$dir$base.o.d # libtool 1.5
304 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
305 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
306 "$@" -Wc,-MD
307 else
308 tmpdepfile1=$dir$base.o.d
309 tmpdepfile2=$dir$base.d
310 tmpdepfile3=$dir$base.d
311 tmpdepfile4=$dir$base.d
312 "$@" -MD
313 fi
314
315 stat=$?
316 if test $stat -eq 0; then :
317 else
318 rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
319 exit $stat
320 fi
321
322 for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
323 do
324 test -f "$tmpdepfile" && break
325 done
326 if test -f "$tmpdepfile"; then
327 sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
328 # That's a tab and a space in the [].
329 sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
330 else
331 echo "#dummy" > "$depfile"
332 fi
333 rm -f "$tmpdepfile"
334 ;;
335
336 #nosideeffect)
337 # This comment above is used by automake to tell side-effect
338 # dependency tracking mechanisms from slower ones.
339
340 dashmstdout)
341 # Important note: in order to support this mode, a compiler *must*
342 # always write the preprocessed file to stdout, regardless of -o.
343 "$@" || exit $?
344
345 # Remove the call to Libtool.
346 if test "$libtool" = yes; then
347 while test $1 != '--mode=compile'; do
348 shift
349 done
350 shift
351 fi
352
353 # Remove `-o $object'.
354 IFS=" "
355 for arg
356 do
357 case $arg in
358 -o)
359 shift
360 ;;
361 $object)
362 shift
363 ;;
364 *)
365 set fnord "$@" "$arg"
366 shift # fnord
367 shift # $arg
368 ;;
369 esac
370 done
371
372 test -z "$dashmflag" && dashmflag=-M
373 # Require at least two characters before searching for `:'
374 # in the target name. This is to cope with DOS-style filenames:
375 # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
376 "$@" $dashmflag |
377 sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
378 rm -f "$depfile"
379 cat < "$tmpdepfile" > "$depfile"
380 tr ' ' '
381 ' < "$tmpdepfile" | \
382 ## Some versions of the HPUX 10.20 sed can't process this invocation
383 ## correctly. Breaking it into two sed invocations is a workaround.
384 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
385 rm -f "$tmpdepfile"
386 ;;
387
388 dashXmstdout)
389 # This case only exists to satisfy depend.m4. It is never actually
390 # run, as this mode is specially recognized in the preamble.
391 exit 1
392 ;;
393
394 makedepend)
395 "$@" || exit $?
396 # Remove any Libtool call
397 if test "$libtool" = yes; then
398 while test $1 != '--mode=compile'; do
399 shift
400 done
401 shift
402 fi
403 # X makedepend
404 shift
405 cleared=no
406 for arg in "$@"; do
407 case $cleared in
408 no)
409 set ""; shift
410 cleared=yes ;;
411 esac
412 case "$arg" in
413 -D*|-I*)
414 set fnord "$@" "$arg"; shift ;;
415 # Strip any option that makedepend may not understand. Remove
416 # the object too, otherwise makedepend will parse it as a source file.
417 -*|$object)
418 ;;
419 *)
420 set fnord "$@" "$arg"; shift ;;
421 esac
422 done
423 obj_suffix="`echo $object | sed 's/^.*\././'`"
424 touch "$tmpdepfile"
425 ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
426 rm -f "$depfile"
427 cat < "$tmpdepfile" > "$depfile"
428 sed '1,2d' "$tmpdepfile" | tr ' ' '
429 ' | \
430 ## Some versions of the HPUX 10.20 sed can't process this invocation
431 ## correctly. Breaking it into two sed invocations is a workaround.
432 sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
433 rm -f "$tmpdepfile" "$tmpdepfile".bak
434 ;;
435
436 cpp)
437 # Important note: in order to support this mode, a compiler *must*
438 # always write the preprocessed file to stdout.
439 "$@" || exit $?
440
441 # Remove the call to Libtool.
442 if test "$libtool" = yes; then
443 while test $1 != '--mode=compile'; do
444 shift
445 done
446 shift
447 fi
448
449 # Remove `-o $object'.
450 IFS=" "
451 for arg
452 do
453 case $arg in
454 -o)
455 shift
456 ;;
457 $object)
458 shift
459 ;;
460 *)
461 set fnord "$@" "$arg"
462 shift # fnord
463 shift # $arg
464 ;;
465 esac
466 done
467
468 "$@" -E |
469 sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
470 -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
471 sed '$ s: \\$::' > "$tmpdepfile"
472 rm -f "$depfile"
473 echo "$object : \\" > "$depfile"
474 cat < "$tmpdepfile" >> "$depfile"
475 sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
476 rm -f "$tmpdepfile"
477 ;;
478
479 msvisualcpp)
480 # Important note: in order to support this mode, a compiler *must*
481 # always write the preprocessed file to stdout, regardless of -o,
482 # because we must use -o when running libtool.
483 "$@" || exit $?
484 IFS=" "
485 for arg
486 do
487 case "$arg" in
488 "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
489 set fnord "$@"
490 shift
491 shift
492 ;;
493 *)
494 set fnord "$@" "$arg"
495 shift
496 shift
497 ;;
498 esac
499 done
500 "$@" -E |
501 sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
502 rm -f "$depfile"
503 echo "$object : \\" > "$depfile"
504 . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
505 echo " " >> "$depfile"
506 . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
507 rm -f "$tmpdepfile"
508 ;;
509
510 none)
511 exec "$@"
512 ;;
513
514 *)
515 echo "Unknown depmode $depmode" 1>&2
516 exit 1
517 ;;
518 esac
519
520 exit 0
521
522 # Local Variables:
523 # mode: shell-script
524 # sh-indentation: 2
525 # eval: (add-hook 'write-file-hooks 'time-stamp)
526 # time-stamp-start: "scriptversion="
527 # time-stamp-format: "%:y-%02m-%02d.%02H"
528 # time-stamp-end: "$"
529 # End:
0 Q: Why a new file format? What's wrong with block-by-block?
1
2 A: Raw image files take up a lot of space. In many cases this space
3 can be dramatically reduced by using compression.
4 Unfortunately, if you just use "gzip" or "bzip2" for compression,
5 you need to uncompress the entire file in order to use it with a
6 forensics program. That's because there is no easy way to "seek"
7 within a compressed file.
8
9 The proprietary EnCase file format supports seeking within a
10 compressed file, but the specification for this file format is not
11 publicly available. Also, EnCase does not allow the storage of
12 arbitrary name/value pairs.
13
14
15 Q: Why not put meta information into log files?
16
17 A: In many cases it is advantageous to store meta information (such as
18 case numbers, acquisition times, the name of the investigator,
19 etc.) directly in the image file. For example, storing this
20 information in a single file with the image makes it very unlikely
21 that they will become separated, and perhaps the wrong log file
22 being used with an image.
23
24 Q: Will AFF support hashes other than MD5 and SHA-1?
25
26 A: Yes. The MD5 hash is stored in a segment named "md5". The SHA-1
27 hash is stored in a segment named "sha1". As support for other hash
28 functions are added to the OpenSSL library, the "aconvert" and
29 "aimage" programs will be updated to automatically calculate and
30 store the other hashes in the AFF files.
31
32
33 Q: Are the images directly mountable so that they can be used with
34 today's forensic tools, or must they be uncompressed for host-based tools to
35 work with them?
36
37 A: If you have source code for a scanner, you can modify it to use
38 af_open() and af_read() instead of fopen() and fread(). You can
39 then read the AFF files directly. If you don't have source code,
40 but have a scanner that can read from standard input, you can
41 use the "afcat" program to copy the contents of an AFF file to
42 standard output.
43
44 Eventually, we plan to have a version of samba that is modified to
45 transparently mount and serve an AFF file. This will allow
46 off-the-shelf Windows executables to be used with AFF archives.
47
48
49 Q: How long do you think it will be before EnCase,
50 ProDiscover, FTK, and the open source tools are able
51 to process files in this format?
52
53 A: I'm currently modifying some of the Open Source tools to handle
54 AFF and hope to have an announcement regarding this relatively
55 soon. It's actually quite easy to modify an Open Source tool to work
56 with AFF: you simply replace the fopen() call with af_open(), fseek()
57 with af_seek(), and fclose() with af_close().
58
59 I've had no contact with the authors of EnCase, ProDiscover, and
60 FTK. I imagine that if AFF becomes popular they will modify their
61 tools to handle the format. But even if they don't, we plan to
62 support those tools through the use of a samba loopback
63 filesystem.
64
65
66 Q: Will it be possible to mount an AFF image as a "virtual file
67 system" the way you can with EnCase.
68
69 A: Yes, it is quite possible to create a device driver that would
70 perform the necessary transformation. That is how the AFFLIB
71 af_read() and af_seek() function calls are implemented.
72
73
74
75 Q: Wouldn't it be more efficient to have an index segment, rather than
76 having to read through all of the individual AF Headers for each
77 segment?
78
79 A: We thought so as well! However, our initial experiments indicated
80 that the overhead for doing a seek for every 16MB segment and
81 reading a few bytes was quite minimal. The advantage of not having
82 to maintain the index is significant. However, if the overhead
83 becomes substantial, we can easily add an index segment type. The
84 design of AFF allows for an index segment to be added to an
85 existing AFF file without changing the contents of the segments
86 that contain forensic information.
87
88
89 Q: Its very important for us to have a format which can be written
90 into a pipe because that makes acquisition over the network much
91 easier.
92
93 A: The "aimage" acquisition program currently under development allows
94 for acquisition either from an ATA/USB/Firewire device or over a
95 network. It allows for discontinuous segments of the disk to be
96 acquired at different times and for data to be inserted into a
97 single AFF file.
0 EXTRA_DIST = FAQ.txt crypto_api.txt crypto_design.txt crypto_doc.txt filetypes.txt\
1 threading.txt \
2 annotations.txt \
3 announce_1.0.txt \
4 announce_1.7.txt \
5 announce_1.8.txt \
6 announce_2.2.txt \
7 announce_3.0.txt \
8 announce_3.3.txt
0 # Makefile.in generated by automake 1.10 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 pkgdatadir = $(datadir)/@PACKAGE@
17 pkglibdir = $(libdir)/@PACKAGE@
18 pkgincludedir = $(includedir)/@PACKAGE@
19 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
20 install_sh_DATA = $(install_sh) -c -m 644
21 install_sh_PROGRAM = $(install_sh) -c
22 install_sh_SCRIPT = $(install_sh) -c
23 INSTALL_HEADER = $(INSTALL_DATA)
24 transform = $(program_transform_name)
25 NORMAL_INSTALL = :
26 PRE_INSTALL = :
27 POST_INSTALL = :
28 NORMAL_UNINSTALL = :
29 PRE_UNINSTALL = :
30 POST_UNINSTALL = :
31 build_triplet = @build@
32 host_triplet = @host@
33 subdir = doc
34 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
35 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
36 am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
37 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
38 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
39 $(ACLOCAL_M4)
40 mkinstalldirs = $(install_sh) -d
41 CONFIG_HEADER = $(top_builddir)/affconfig.h
42 CONFIG_CLEAN_FILES =
43 SOURCES =
44 DIST_SOURCES =
45 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
46 ACLOCAL = @ACLOCAL@
47 AFFUSE_BIN = @AFFUSE_BIN@
48 ALLOCA = @ALLOCA@
49 AMTAR = @AMTAR@
50 AR = @AR@
51 AUTOCONF = @AUTOCONF@
52 AUTOHEADER = @AUTOHEADER@
53 AUTOMAKE = @AUTOMAKE@
54 AWK = @AWK@
55 CC = @CC@
56 CCDEPMODE = @CCDEPMODE@
57 CFLAGS = @CFLAGS@
58 CPP = @CPP@
59 CPPFLAGS = @CPPFLAGS@
60 CURL_CONFIG = @CURL_CONFIG@
61 CXX = @CXX@
62 CXXCPP = @CXXCPP@
63 CXXDEPMODE = @CXXDEPMODE@
64 CXXFLAGS = @CXXFLAGS@
65 CYGPATH_W = @CYGPATH_W@
66 DEFS = @DEFS@
67 DEPDIR = @DEPDIR@
68 DSYMUTIL = @DSYMUTIL@
69 DUMPBIN = @DUMPBIN@
70 ECHO_C = @ECHO_C@
71 ECHO_N = @ECHO_N@
72 ECHO_T = @ECHO_T@
73 EGREP = @EGREP@
74 EXEEXT = @EXEEXT@
75 FGREP = @FGREP@
76 FUSE_CFLAGS = @FUSE_CFLAGS@
77 FUSE_LIBS = @FUSE_LIBS@
78 GREP = @GREP@
79 INSTALL = @INSTALL@
80 INSTALL_DATA = @INSTALL_DATA@
81 INSTALL_PROGRAM = @INSTALL_PROGRAM@
82 INSTALL_SCRIPT = @INSTALL_SCRIPT@
83 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
84 LD = @LD@
85 LDFLAGS = @LDFLAGS@
86 LIBOBJS = @LIBOBJS@
87 LIBS = @LIBS@
88 LIBTOOL = @LIBTOOL@
89 LIPO = @LIPO@
90 LN_S = @LN_S@
91 LTLIBOBJS = @LTLIBOBJS@
92 MAINT = @MAINT@
93 MAKEINFO = @MAKEINFO@
94 MKDIR_P = @MKDIR_P@
95 NM = @NM@
96 NMEDIT = @NMEDIT@
97 OBJEXT = @OBJEXT@
98 OTOOL = @OTOOL@
99 OTOOL64 = @OTOOL64@
100 PACKAGE = @PACKAGE@
101 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
102 PACKAGE_NAME = @PACKAGE_NAME@
103 PACKAGE_STRING = @PACKAGE_STRING@
104 PACKAGE_TARNAME = @PACKAGE_TARNAME@
105 PACKAGE_VERSION = @PACKAGE_VERSION@
106 PATH_SEPARATOR = @PATH_SEPARATOR@
107 PTHREAD_CC = @PTHREAD_CC@
108 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
109 PTHREAD_LIBS = @PTHREAD_LIBS@
110 PYTHON = @PYTHON@
111 PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
112 PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
113 PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
114 PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
115 PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
116 PYTHON_PLATFORM = @PYTHON_PLATFORM@
117 PYTHON_PREFIX = @PYTHON_PREFIX@
118 PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
119 PYTHON_VERSION = @PYTHON_VERSION@
120 RANLIB = @RANLIB@
121 S3_BIN = @S3_BIN@
122 SED = @SED@
123 SET_MAKE = @SET_MAKE@
124 SHELL = @SHELL@
125 STRIP = @STRIP@
126 VERSION = @VERSION@
127 abs_builddir = @abs_builddir@
128 abs_srcdir = @abs_srcdir@
129 abs_top_builddir = @abs_top_builddir@
130 abs_top_srcdir = @abs_top_srcdir@
131 ac_ct_CC = @ac_ct_CC@
132 ac_ct_CXX = @ac_ct_CXX@
133 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
134 ac_prefix_program = @ac_prefix_program@
135 acx_pthread_config = @acx_pthread_config@
136 am__include = @am__include@
137 am__leading_dot = @am__leading_dot@
138 am__quote = @am__quote@
139 am__tar = @am__tar@
140 am__untar = @am__untar@
141 bindir = @bindir@
142 build = @build@
143 build_alias = @build_alias@
144 build_cpu = @build_cpu@
145 build_os = @build_os@
146 build_vendor = @build_vendor@
147 builddir = @builddir@
148 datadir = @datadir@
149 datarootdir = @datarootdir@
150 docdir = @docdir@
151 dvidir = @dvidir@
152 exec_prefix = @exec_prefix@
153 host = @host@
154 host_alias = @host_alias@
155 host_cpu = @host_cpu@
156 host_os = @host_os@
157 host_vendor = @host_vendor@
158 htmldir = @htmldir@
159 includedir = @includedir@
160 infodir = @infodir@
161 install_sh = @install_sh@
162 libdir = @libdir@
163 libexecdir = @libexecdir@
164 localedir = @localedir@
165 localstatedir = @localstatedir@
166 lt_ECHO = @lt_ECHO@
167 mandir = @mandir@
168 mkdir_p = @mkdir_p@
169 oldincludedir = @oldincludedir@
170 pdfdir = @pdfdir@
171 pkgpyexecdir = @pkgpyexecdir@
172 pkgpythondir = @pkgpythondir@
173 prefix = @prefix@
174 program_transform_name = @program_transform_name@
175 psdir = @psdir@
176 pyexecdir = @pyexecdir@
177 pythondir = @pythondir@
178 sbindir = @sbindir@
179 sharedstatedir = @sharedstatedir@
180 srcdir = @srcdir@
181 sysconfdir = @sysconfdir@
182 target_alias = @target_alias@
183 top_builddir = @top_builddir@
184 top_srcdir = @top_srcdir@
185 EXTRA_DIST = FAQ.txt crypto_api.txt crypto_design.txt crypto_doc.txt filetypes.txt\
186 threading.txt \
187 annotations.txt \
188 announce_1.0.txt \
189 announce_1.7.txt \
190 announce_1.8.txt \
191 announce_2.2.txt \
192 announce_3.0.txt \
193 announce_3.3.txt
194
195 all: all-am
196
197 .SUFFIXES:
198 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
199 @for dep in $?; do \
200 case '$(am__configure_deps)' in \
201 *$$dep*) \
202 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
203 && exit 0; \
204 exit 1;; \
205 esac; \
206 done; \
207 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
208 cd $(top_srcdir) && \
209 $(AUTOMAKE) --gnu doc/Makefile
210 .PRECIOUS: Makefile
211 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
212 @case '$?' in \
213 *config.status*) \
214 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
215 *) \
216 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
217 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
218 esac;
219
220 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
221 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
222
223 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
224 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
225 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
226 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
227
228 mostlyclean-libtool:
229 -rm -f *.lo
230
231 clean-libtool:
232 -rm -rf .libs _libs
233 tags: TAGS
234 TAGS:
235
236 ctags: CTAGS
237 CTAGS:
238
239
240 distdir: $(DISTFILES)
241 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
242 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
243 list='$(DISTFILES)'; \
244 dist_files=`for file in $$list; do echo $$file; done | \
245 sed -e "s|^$$srcdirstrip/||;t" \
246 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
247 case $$dist_files in \
248 */*) $(MKDIR_P) `echo "$$dist_files" | \
249 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
250 sort -u` ;; \
251 esac; \
252 for file in $$dist_files; do \
253 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
254 if test -d $$d/$$file; then \
255 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
256 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
257 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
258 fi; \
259 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
260 else \
261 test -f $(distdir)/$$file \
262 || cp -p $$d/$$file $(distdir)/$$file \
263 || exit 1; \
264 fi; \
265 done
266 check-am: all-am
267 check: check-am
268 all-am: Makefile
269 installdirs:
270 install: install-am
271 install-exec: install-exec-am
272 install-data: install-data-am
273 uninstall: uninstall-am
274
275 install-am: all-am
276 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
277
278 installcheck: installcheck-am
279 install-strip:
280 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
281 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
282 `test -z '$(STRIP)' || \
283 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
284 mostlyclean-generic:
285
286 clean-generic:
287
288 distclean-generic:
289 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
290
291 maintainer-clean-generic:
292 @echo "This command is intended for maintainers to use"
293 @echo "it deletes files that may require special tools to rebuild."
294 clean: clean-am
295
296 clean-am: clean-generic clean-libtool mostlyclean-am
297
298 distclean: distclean-am
299 -rm -f Makefile
300 distclean-am: clean-am distclean-generic
301
302 dvi: dvi-am
303
304 dvi-am:
305
306 html: html-am
307
308 info: info-am
309
310 info-am:
311
312 install-data-am:
313
314 install-dvi: install-dvi-am
315
316 install-exec-am:
317
318 install-html: install-html-am
319
320 install-info: install-info-am
321
322 install-man:
323
324 install-pdf: install-pdf-am
325
326 install-ps: install-ps-am
327
328 installcheck-am:
329
330 maintainer-clean: maintainer-clean-am
331 -rm -f Makefile
332 maintainer-clean-am: distclean-am maintainer-clean-generic
333
334 mostlyclean: mostlyclean-am
335
336 mostlyclean-am: mostlyclean-generic mostlyclean-libtool
337
338 pdf: pdf-am
339
340 pdf-am:
341
342 ps: ps-am
343
344 ps-am:
345
346 uninstall-am:
347
348 .MAKE: install-am install-strip
349
350 .PHONY: all all-am check check-am clean clean-generic clean-libtool \
351 distclean distclean-generic distclean-libtool distdir dvi \
352 dvi-am html html-am info info-am install install-am \
353 install-data install-data-am install-dvi install-dvi-am \
354 install-exec install-exec-am install-html install-html-am \
355 install-info install-info-am install-man install-pdf \
356 install-pdf-am install-ps install-ps-am install-strip \
357 installcheck installcheck-am installdirs maintainer-clean \
358 maintainer-clean-generic mostlyclean mostlyclean-generic \
359 mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
360
361 # Tell versions [3.59,3.63) of GNU make to not export all variables.
362 # Otherwise a system limit (for SysV at least) may be exceeded.
363 .NOEXPORT:
0 AFF sector annotations.
1
2 Why? Becuase there are many cases where we want to annotate on a sector-by-sector basis:
3 * Bad blocks
4 * Blank sectors
5 * Accessed sectors.
6
7 Functionality we want:
8 * Set annotation
9 * Query
10 * Find sectors with an annotation?
11
12 Model: A 1TB disk has 2 billion sectors and 62,500 AFF pages (wow;
13 what happens to AFF performance when all of that is stored in a
14 sequential, unsorted list?)
15
16 If we store these annotations as a byte array, that's 2GB for the 1TB disk. Not acceptable.
17 Storing it as bits is 256MB; still pretty harsh.
18
19 Store the annotations per page and you have 4096 bytes with a 1-bit annotation.
20 - That's okay for a bad block list.
21 for a byte annotation per sector, there are 32K 512-byte sectors on a page.
22
23 Another option: Store as a sequence of [start block, run length, annotation]
24 - Good for sparse, bad for filled.
25 - So you would need a way to turn the sparse into non-sparse
26
0 The Advanced Forensic Format
1 Library and Tools
2
3 Simson L. Garfinkel
4 and
5 Basis Technology, Inc.
6 (C) 2005-2007
7
8
9
10 INTRODUCTION
11
12 The Advanced Forensic Format --- AFF(tm) --- is an extensible open
13 format for the storage of disk images and related forensic
14 information.
15
16 Features of AFF include:
17
18 * Open format, free from any patent or license restriction.
19 Can be used with both open-source and proprietary forensic tools.
20
21 * Extensible. Any amount of metadata can be encoded in AFF files in the
22 format of name/value pairs.
23
24 * Efficient. AFF supports both compression and seeking within
25 compressed files.
26
27 * Open Source C/C++ Implementation. A freely redistributable C/C++
28 implementation including the AFF Library and basic conversion tools
29 is available for download. AFFLIB(tm) is being distributed under the BSD
30 license, allowing it to be incorporated in free and proprietary
31 programs without the need to pay license fees.
32
33 * Byte-order independent. AFFLib has been tested on both Intel and
34 PowerPC-based systems. Images created on one platform can be read on
35 another.
36
37 * Automatic calculation and storage of MD5 and SHA-1 hash codes,
38 allowing AFF files to be automatically validated after they are
39 copied to check for accidentally corruption.
40
41 * Explicit identification of sectors that could not be read from the
42 original disk.
43
44 * Planned support for digital signatures and direct authoring of AFF
45 files using dd_recover.
46
47 AFF is distributed as a subroutine library. The library implements a
48 FILE-like abstraction that supports the full range of POSIX-like file
49 routines, including af_open(), af_read(), af_seek(), af_close(). The
50 af_open() routine checks to see if a file is an AFF file and, if not,
51 can automatically fall-back into raw mode. Thus, most existing
52 forensic tools can be trivially modified to work with AFF-formatted
53 files.
54
55
56 The AFF library can be downloaded from:
57
58 http://www.simson.net/afflib/
59
60
61 ================================================================
62 HOW AFF WORKS
63
64 AFF is a segmented archive file specification. Each AFF file consists
65 of an AFF File Header followed by one or more AFF Segments.
66
67
68 AFF SEGMENTS:
69
70 AFF Segments are used to store all information inside the AFF
71 File. This includes the image itself and image metadata.
72
73 Segments can be between 32 bytes and 2^32-1 bytes long. When used to
74 store the contents of a disk image, the image is broken up into a
75 number of equal-sized Image Segments. These Image Segments are then optionally
76 compressed and stored sequentially in the AFF file.
77
78 Each AFF Segment has a header, a name, a 32-bit argument, an optional data
79 payload, and finally a tail. The header and tail make it possible to
80 seek rapidly through the AFF file, skipping much of the image data.
81
82 The segment size of the image file is determined when the file is
83 converted from a RAW file to an AFF file. Once a file is converted, it
84 can be opened using the af_open() function call and read using
85 af_read() and af_seek(). The AFF library automatically handles the
86 locating, reading, and optional decompressing of each segment as needed.
87
88 Other segments can be used to hold information such as the time that
89 the disk was imaged, a case number, the forensic examiner, and the MD5
90 or SHA-1 of the original unconverted image file. Utility programs are
91 included in the AFF Library to display this information and validate
92 the contents of an AFF file against the stored hashes.
93
94
95 AFF uses OpenSSL for computing hash functions and ZLIB for compressing
96 image segments.
97
98 ================================================================
99 AFF UTILITY PROGRAMS
100
101 The AFF Library comes with the following utility programs:
102
103 afcat - copies from the contents of an AFFILE to stdout.
104 afcompare - compares two AFF files or an AFF file and a raw file
105 afconvert - converts AFF->raw, raw->AFF, or AFF->AFF (or even raw->raw, if you want)
106 optionally recompressed files.
107 affix - Reports errors with AFF files and optioanlly fixes them.
108 afinfo - prints info about an AFF file from an examination of the segments
109 afstats - prints statistics about one or more AFF files
110 aftest - regression testing for AFF library
111 afxml - outputs an AFF file's metadata as XML
112
113 aimage - Image a hard drive into AFF or raw format
114
115
116 ================================================================
117 AFF DETAILS
118
119 AFF SEGMENT NAMES:
120
121 The following AFF Segment Names have been defined in the initial
122 release:
123
124 segsize - The size of each image segment, stored as a 32-bit value.
125
126 imagesize - The total number of bytes in the file, stored as a 64-bit
127 value.
128
129 md5 - The MD5 of the uncompressed image file, stored as
130 128-bit value.
131
132 sha1 - The SHA-1 of the uncompressed image file, stored as a
133 160-bit value.
134
135 badflag - A 512-bit value that is stored in the file to denote a bad
136 sector. This value typically consists of the string
137 "BAD SECTOR\000" followed by a timestamp and a block of
138 random data.
139
140
141 badsector - The total number of bad sectors in the image, stored as a
142 32-bit number.
143
144 seg0 - The contents of the first segment in the image file.
145 A flag of '1' stored in the segment argument indicates
146 that the segment was compressed with zlib.
147
148 seg1 - The contents of the second segment in the image file
149
150 segNNN - The contents of the NNNth segment of the image file.
151
152 a.manufacturer - The manufacturer of the disk drive, stored as a UTF-8
153 string.
154
155 a.model - The model number of the disk drive, stored as a UTF-8
156 string
157
158 a.property - Any arbitrary "property" of the disk drive, stored as a
159 UTF-8 string.
160
161 xxx - This segment should be ignored. (Space may be left for
162 future use.)
163
164 "" - Segments with 0-length name are to be ignored and can
165 be garbage collected.
166
167
168 THE AFF SEGMENT FORMAT:
169
170 Each AFF Segment contains the following information:
171
172 - The Segment Header
173 - The Segment Data Payload
174 - The Segment Footer
175
176 The Segment Header consists of the following
177 - A 4-byte Segment Header Flag ("AFF\000")
178 - The Length of the segment name (as an unsigned 4-byte value)
179 - The Length of the segment data payload
180 - The "argument", a 32-bit unsigned value
181 - The data segment name (stored as a Unicode UTF-8 string)
182
183 The Segment Footer consists of:
184 - The 4-byte Segment Footer Flag ("ATT\000")
185 - The length of the entire segment, as a 32-bit unsigned value
186
187 Because the segment length can be determined by reading both the
188 Header or the Footer, the AFF library can seek forwards or backwards
189 in the AFF file, similar to the way that a tape drive seeks forwards
190 and backwards through a tape drive.
191
192 All 4-byte binary values are stored in network byte order to provide
193 for byte order independence. These values are automatically written
194 with the htonl() macro and read with the ntohl() macro by the AFF
195 Library.
196
197
198 AFF OPTIMIZATIONS:
199
200 Although the AFF file format is quite simple, the library and
201 conversion routines implement a variety of optimizations to speed
202 conversion and reading. Among these optimizations are:
203
204 * Image segments are only compressed in the AFF file if compression
205 would decrease the amount of data required by 5%. Otherwise no
206 compression is performed. As a result, images containing
207 uncompressable data are not compressed. This saves CPU time.
208
209 * When an image is converted, space is left at the beginning of the
210 AFF file for the image hash and other metadata. As a result, this
211 information can be rapidly read when a new AFF image is opened.
212
213 * AFF's af_read() routine caches the current image segment being read,
214 allowing for rapid seeking within the segment. And because all image
215 segments represent the same number of bytes in the original image
216 file, the library routine can rapidly locate the image segment that
217 corresponds to any byte offset within the original raw image, load
218 that image segment into memory, and return the sectors that are
219 requested.
220
221
222 LICENSE
223
224 The AFF Library is distributed with a modified BSD license that allows
225 the use of AFF in any program, free or commercial, provided that the
226 copyright statement is included in both the source and binary file,
227 and in any advertisements for products based on the Garfinkel/Basis
228 AFF implementation.
229
230 ================================================================
231 ACKNOWLEDGEMENTS
232
233 Brian Carrier provided useful feedback on the initial AFF design.
234
235 Jean-Francois Beckers has provided many suggestions for functionality
236 and has found many bugs in his extensive testing.
237
238 ================================================================
239 BUILDING AFF
240
241 export AFF_NOOPT=1 to disable compiler optimizations
242 ================================================================
243 AFF DIRECTORIES (AFD)
244
245 Many file systems limit the maximum file size to 2^32-1 or
246 4,294,967,295 bytes. Unfortunately, even compressed images can easily
247 exceed this size.
248
249 An AFF Directory (.affd) is a directory of AFF files that the AFF
250 Library knits together to give the appearance of a single AFF
251 file. No rules are imposed on the names of these files or the order of
252 the segments that they contain. If a segment with the same name exists
253 in more than one AFF file it is undefined which file's segment will be
254 returned if that segment is read.
255
256 The AFFDIR is actually implemented using the AFF VNODE abstraction
257 (which allows arbitrary file system interfaces) and a special driver
258 that recursively opens multiple AFF sub-files. The current system
259 opens all of the files in the directory and keeps them all open.
260
261
262 The "aimage" analyzes the disk being imaged and the file system and
263 determines if the image can be stored in an AFF file or in an
264 AFFDIR. If it creates a dir, it automatically creates new AFF files
265 when the files being imaged exceeds 500MB.
266
267 ==================================
268 PyAFF - Python bindings for AFFLIB
269 ==================================
270
271 These bindings currently support a read-only file-like interface to AFFLIB and
272 basic metadata accessor functions. The binding is not currently complete.
273
274 --------
275 BUILDING
276 --------
277
278 ./configure --enable-python
279
280 -----
281 USAGE
282 -----
283
284 Basic usage example:
285
286 #/usr/bin/python
287 import pyaff
288
289 fd = pyaff("diskimage.aff")
290 data = fd.read(1000)
291 fd.seek(0, SEEK_SET)
292
293 print fd.get_seg_names()
294 print fd.get_seg("afflib_version")
295
296
297
298 ================
299 Note: AFF and AFFLIB are trademarks of Simson L. Garfinkel and Basis
300 Technology, Inc.
301
302
303 # Local Variables:
304 # mode: auto-fill
305 # mode: flyspell
306 # End:
0 ANNOUNCING AFFLIB 1.7
1
2 I'm happy to announce the release of AFFLIB 1.7. You can download it
3 from the standard location at http://www.afflib.org/
4
5 Version 1.7 represents a major advance over previous versions.
6 Upgrading is recommended for all users.
7
8 Key improvements in Version 1.7 include:
9
10 * Dramatically smaller image size in almost all cases.
11
12 * Significantly improved performance
13
14 * Improved tools!
15
16
17 DRAMATICALLY SMALLER IMAGES
18 ---------------------------
19
20 AFFLIB has always supported pluggable compression algorithms, but previous
21 versions featured just a single compression algorithm --- zlib (the
22 same algorithm used in gzip).
23
24 Version 1.7 introduces two new compressors:
25
26 LZMA - This is the compressor developed by Igor Pavlov and
27 popularized by the 7-Zip compression system. LZMA uses
28 a very large dictionary to achive compression that is
29 30-70% better, on average, than zlib.
30
31 NULL - This compressor checks to see if a page is 16MB of NULLs. If it is,
32 this fact is simply noted. The result is considerable savings on many
33 drives, since many drives have large regions that are all NULLs.
34
35
36 The result of these two compression algorithms together is
37 significant. My library of images from 1000 disks purchased on the
38 secondary market now takes roughly 1/2 the space that it prevously
39 did. And it is faster to work with these highly-compressed images than
40 with raw images or impages compressed with zlib, since decompression
41 is I/O bound, not CPU-bound.
42
43
44
45 SIGNIFICANTLY IMPROVED PERFORMANCE
46 ----------------------------------
47
48 Forensic programs like The Sleuth Kit will run significantly faster
49 with Version 1.7 than with previous versions. Instead of a single page
50 cache, Version 1.7 can cache multiple pages. The number of pages
51 cached is determined by the environment variable AFFLIB_CACHE_PAGES;
52 the default value is 2 which gives good performance with TSK --- one
53 page for the inode table, one page for the data.
54
55 Remember, each page is typically 16MB, so you can quickly overwhelm
56 your memory if you set the value too large. Don't page the cache out
57 to the hard drive --- it's faster to throw away the pages, re-read the
58 originally compressed page and decompress it, than it is to write out
59 the uncompressed page and read it back.
60
61 One of the problems with using compressed images is that you can't
62 memory-map the file directly into the memory space of a 64-bit
63 processor. (You can't do it with a 32-bit processor, of course, if the
64 image is larger than 1GB or so.) Setting AFFLIB_CACHE_PAGES to a large
65 value gives you even better performance than memory-mapping a raw
66 file.
67
68
69
70 IMPROVED TOOLS
71 --------------
72
73 The AFFLIB Tools have been expanded and refined. The toolset now
74 consists of 10 programs to assist in working with libraries of AFF
75 images.
76
77 Current tools include:
78
79 afcat - Outputs the contents of an AFF file stdout.
80
81 afcompare - Compares two AFF files, or an AFF file and a non-AFF file.
82 Can also report on the success of "preening"
83
84 afconvert - Converts a non-AFF file to an AFF file.
85
86 afcopy - Makes a verified copy of an AFF file to another location.
87 Accepts multiple destinations and minimizes reads (ie:
88 reads each segment once and then does the copies.) Future
89 version might do writes simultaneously if they are to
90 different devices.
91
92 -p option causes files to be recompressed with LZMA when
93 they are copied. This can be done without invalidating
94 digital signatures.
95
96 affix - If an AFF file ends with an incomplete segment, this
97 program removes it.
98
99 afinfo - Reports information about an AFF file.
100
101 afsegment - Allows an individual segment to be read or
102 written. Typically used to allow shell-script access to metadata.
103
104 afstats - Prints statistics from a single AFF file or multiple
105 files. Prints reports.
106
107 afxml - Outputs the AFF medata in XML, for all of you XML fans.
108
109
110 and, of course:
111
112 aimage - The advanced disk imager. Now images to LZMA (but it's slow...)
113
114
115
116 WHAT'S NEXT?
117 ------------
118
119 And here is what's on the agenda for the next major release of AFF:
120
121 + Support for Amazon's S3.
122 + Labeling of "bad" and redacted sectors in the metadata (rather than
123 relying on high-entropy tokens in the data.)
124 + Support for NSRL bloom filters.
125
0 ANNOUNCING AFFLIB 1.8
1
2 I'm happy to announce the release of AFFLIB 1.8. You can download it
3 from the standard location at http://www.afflib.org/
4
5 Version 1.8 introduces support for Amazon's Simple Storage Service
6 (S3). Using S3 you can store an unlimited amount of information on S3
7 and then process it using Amazon's Elastic Computing Cloud (EC2).
8 This makes it possible for researchers to work with extremely large
9 forensic data sets in an efficient and cost-effective manner.
10
11 Amazon's S3 system allows you to store data for just 15 cents per
12 gigabyte per month. That's great; for $150 per month I can store a
13 terrabyte. It's true that I can buy a terrabyte hard drive for $700
14 (or two 500 gigabyte hard drives for $300). The key difference between
15 Amazon's storage and my storage is that Amazon's is backed-up,
16 replicated, and available at high-speed from multiple locations around
17 the world.
18
19 The problem with S3 is that it costs 20 cents per gigabyte to transfer
20 data in-or-out of Amazon. That's more than storing it! This turns out
21 to be not so much of a problem, though, because Amazon also rents CPUs
22 for 10 cents per hour on EC2 and there is no bandwidth charge to move
23 data between EC2 and S3.
24
25 As a result, my typical workload looks like this:
26
27 * Image disks to S3.
28 * Bring up a few dozen computers on EC2 to analyze the disks.
29 * Wipe the disks or store them for long-term.
30
31
32
33 USING S3 FOR COMPUTER FORENSICS
34 ==================
35
36 All objects in Amazon S3 must fit in the same global namespace. The
37 namespace consists of a "bucket name" which must be unique, and an
38 "object name" which is pretty much anything you want. ("foo" is okay
39 here.) These get turns into URLs of the form
40 http://s3.amazonws.com/bucket/object-name using the REST API. (There
41 is also a CORBA API, but you don't want to use that because it
42 requires that every object be repeatedly encoded into Base64 and
43 decoded from Base64.)
44
45 Buckets come on a first-come, first-serve basis. You can't
46 have "foo" because it's already been taken, but you could have a
47 bucket with the base64 coding of the MD5 of your social security
48 number, if you wanted to do that. It's even reasonably secure, because
49 bucket names are private --- nobody can list your bucket names.
50 It's possible to infer that your bucket name exists by doing an
51 exhaustive search, which is a problem for dictionary words but not for
52 base64 encodings of MD5 hashes.
53
54 You can only have 100 buckets per account, so don't go crazy with
55 them.
56
57 Access control in based on buckets. You can make your bucket readable
58 by up to 100 Amazon AWS IDs and read-write for another 100 IDs. If you
59 need more than that, deploy a server on EC2 and implement your own
60 access control policy using a database of your choosing.
61
62 The easiest way to use S3 is to some something like MonkeyDrive, which
63 makes an S3 bucket look like a remote file system. Unfortunately, this won't
64 work for computer forensics for two reasons:
65
66 1. S3 likes to read and write entire objects at once.
67 2. S3 has a maximum object size of 5GB, which MonkeyDrive lowers
68 to 2GB due to a bug in Amazon's load balancers.
69
70 The AFFLIB S3 implementation gets around this by storing each AFF
71 segment inside its own object. Recall that AFF breaks a single disk
72 image into data "pages" and metadata, where each data page is
73 16MB. Because these pages are then compressed with zlib or LZMA, they
74 can be quite small. That's good when you are paying 15 cents per
75 gigabyte per month for storage.
76
77 USING S3 with AFFLIB
78
79 Using AFFLIB with S3 is really easy. AFF files stored on S3 are given
80 URLs where the service is "s3" and the hostname is actually the name
81 of the bucket in which the AFF file is stored. For example, if you
82 have an AFF file called myfile.aff stored in a bucket called
83 subjectfiles, the filename would be:
84
85 s3://subjectfiles/myfile.aff
86
87 (Behind the scenes the S3 implementation is mapping this to a whole
88 bunch of objects. For example, the segment "page1" maps to
89 http://s3.amazonaws.com/subjectfiles/myfile.aff/page1 . But that level
90 of detail shouldn't matter to most users of this system.)
91
92 To actually use S3 and EC2 you need to sign up for an Amazon Web
93 Service's account, which you can do with a credit-card. There are no
94 start-up fees.
95
96 1. Sign up for Amazon AWS and add S3 as a service.
97 2. Set the following environment variables:
98
99 setenv AWS_ACCESS_KEY_ID "<your access key> id"
100 setenv AWS_SECRET_ACCESS_KEY "<your secret access key>
101
102 3. You'll need a bucket to store your files in. There's a new AFF
103 utility called "s3" that controls the Amazon S3 system. Go ahead and
104 make a bucket:
105
106 s3 mkdir <mybucketname>
107
108 for example, we could make a bucket called subjectfiles:
109
110 s3 mkdir subjectfiles
111
112 4. You can now use the afcopy program to copy an AFF file to this
113 bucket:
114
115 afcopy myfile.aff s3://subjectfiles/myfile.aff
116
117
118 5. You can set the environment variable S3_DEFAULT_BUCKET If you don't
119 want to type "subjectfiles" all the time:
120
121 setenv S3_DEFAULT_BUCKET subjectfiles
122
123 Then you can use the URL:
124
125 s3:///myfile.aff
126
127
0 ANNOUNCING AFFLIB 2.2
1
2 I'm happy to announce the release of AFFLIB 2.2. You can download it
3 from the standard location at http://www.afflib.org/
4
5 Version 2.2 brings several important new features to AFFLIB:
6
7 * AIMAGE now computes SHA256 when an entire image is acquired,
8 in addition to also calculating MD5 and SHA1.
9
10 * Support for AFFLIB running under Windows has been greatly
11 expanded. Now AFFLIB compiles on both Cygwin and Microsoft VC++
12 (version 2005). Extensive documentation is included in the Win32
13 directory for both downloading and installing the (free) Microsoft
14 build tools, and for compiling AFFLIB.
15
0 ANNOUNCING AFFLIB 3.0
1
2 I'm happy to announce the release of AFFLIB 3.0. You can download it
3 from the standard location at http://www.afflib.org/
4
5 Version 3.0 is a significant upgrade to AFFLIB which introduces the
6 following features:
7
8 * STRONG ENCRYPTION FOR AFF FILES.
9 * STRONG DIGITAL SIGNATURES WITH X.509 CERTIFICATES
10 * SIGNED BILL-OF-MATERIALS AND CHAIN OF CUSTODY
11 * SIGNED ISO FILES
12 * PARITY PAGES ALLOW RECONSTRUCTION OF DAMAGED DISK IMAGES
13
14 * STRONG ENCRYPTION FOR AFF FILES.
15
16 With Version 3.0 we are introducing the ability to encrypt AFF
17 evidence files with the AES-256 algorithm, the strongest encryption
18 algorithm available today.
19
20 Each AFF 3.0 file can be encrypted with a unique AES-256 key. This key is
21 can then itself be encrypted using a passphrase provided by the
22 user, or using an X.509 public key. Because of this two-step
23 process, the passphraseor public key can be changed in just a few
24 seconds without having to decrypt and re-encrypt the entire disk
25 image.
26
27 Whereas some other forensic programs provide the ability to put a
28 "password" on an evidence file, those passwords can be disregarded
29 by non-conformant programs. (For example, GetData claims that it's
30 MountImage Pro program can "open EnCase password protected image
31 files without the password.) AFF 3.0 uses true encryption: if you
32 do not know the correct decryption key, the only way to access the
33 evidence is to brute-force the encryption passphrase (if there is
34 one). THERE IS NO BACK DOOR.
35
36
37 * STRONG DIGITAL SIGNATURES WITH X.509 CERTIFICATES
38
39 Version 3.0 introduces strong digital signatures (SHA-256) signed
40 with X.509 certificates.
41
42 Digital signatures represents a significant improvement for evidence
43 integrity over today's standard practice of recording the MD5 or
44 SHA-1 of an imaged disk in an investigator's notebook.
45
46 AFF Digital Signatures, signatures are written for the entire disk
47 image, all of the disk's metadata, and every 16-megabyte AFF "page."
48
49 Because digital signatures are written after each "page" is
50 acquired, the integrity of these pages can be established in court
51 even if the entire disk cannot be images (for example, because the
52 device is fault, or because there is insufficient time).
53
54 AFF Digital Signatures complement existing integrity
55 measures. Because the signature is stored in its own metadata
56 segment, the signature does not change the content of the acquired
57 disk image.
58
59 Signatures can be written with either self-signed certificates or
60 with X.509 certificates that are issued as part of an organization's
61 PKI. Using X.509 certificates means that AFF can support RSA or DSA
62 algorithms with 1024, 2048 or larger keys.
63
64
65 * SIGNED BILL-OF-MATERIALS AND CHAIN OF CUSTODY
66
67 Version 3.0 introduces a special XML structure that contains a list
68 of every AFF segment in the file, a signature for each segment, a
69 set of "notes," and a public key. This structure is called an "AFF
70 Bill Of Materials" (AFFBOM).
71
72 When an AFF image is created with AIMAGE, the AFFBOM is created and
73 signed with the private key belonging to the person who did the
74 acquisiton. Thereafter, each time a signed AFF file is copied, a new
75 AFFBOM can be created which includes a new AFFBOM which covers all
76 of the original segments and all of the previous AFFBOMs. In this
77 manner the sequence of signed bill-of-materials becomes a custody
78 chain, showing who has copied the image and verifying that no
79 evidentuary segments have been added, deleted, or modified.
80
81
82 * SIGNED ISO FILES
83
84 AFF's "AFM" format allows a disk image to be stored in an uncompressed
85 raw file (eg "file.iso") and the associated metadata to be stored in a
86 ".afm" file. The AFM format can also handle raw data stored as a
87 series of "split" raw files (eg "file.001", "file.002", "file.003"
88 etc.)
89
90 Beacuse AFF tools operating on named segments that are independent
91 of the underlying storage container, the AFM format allows any
92 ISO-file to be signed using the "afsign" command. When filename.iso
93 is signed, the afsign create a new file called filename.afm which
94 contains the signatures, the signed bill of materials, and other
95 metadata.
96
97 Although it is also possible sign ISO files using existing tools
98 such as PGP with detached signatures, afsign has several advantages:
99
100 - afsign will sign every 16-megabytes chunk of the ISO file. In this
101 way, if the file is corrupted, you will be able to pinpoint what
102 data is invalid and what data is still good.
103
104 - Unlike PGP, afsign allows you to add arbitrary metadata and
105 maintain chain-of-custody information.
106
107 - You can sign with X.509 certificates
108
109
110 * PARITY PAGES ALLOW RECONSTRUCTION OF DAMAGED DISK IMAGES
111
112 Because every 16-megabyte chunk of an AFF or AFM file is signed,
113 it is easy to detect when a page has been modified or accidently
114 corrupted. The BoM allows missing pages to be detected.
115
116 Similar to RAID5 on hard drives, an AFF parity page makes possible
117 to reconstruct damaged or missing AFF data segments. Once repaired
118 or reconstructed, the signature (which is stored in a differnet
119 location) can be used to determine if the reconstruction is correct.
120
121 Partiy Pages are automatically created when an image is signed with
122 afsign. The rewritten aimage that will be part of AFFLIB 3.1 will
123 create parity pages as the drive is imaged.
124
125 ================================================================
126 AVAILABILITY
127
128 AFFLIB 3.0.0 is available now.
129
130
131 ================================================================
132 NEW AND MODIFIED TOOLS IN AFF 3.0:
133
134 The following tools have been aded for AFF 3.0:
135
136 * afsign - signs an AFF file.
137
138 * afverify - verifies the signature and chain-of-custody segments of
139 an AFF file.
140
141 * afcrypto - manipulates the cryptographic properties of an AFF file.
142 - Can change the passphrase
143
144 The following tools have been modified:
145
146 * afcopy - If you provide a signing key, a signed bill-of-materials
147 will be added to extend the chain-of-custody.
148
149
150 Other changes in AFF3.0:
151
152 * A few bugs have been fixed which caused difficulties in testing. (No
153 users reported problems with them.)
154
155 ================================================================
156 COMING IN AFFLIB 3.1:
157
158 I've pushed out Version 3.0 so that people can start to experiment
159 with it now. Meanwhile, I'm now working on the following features
160 which, I'm hoping, will make it into Version 3.1:
161
162 * Public key encryption (so agents in the field can encrypt to a
163 public key, and the images can only be decrypted in the lab.)
164
165 * Dramatically improved performance when opening AFF files with signed
166 bill-of-materials. (The BOM will be used as a table-of-contents so
167 that large AFF files do not need to be scanned from end-to-end.)
168
169 * A rewrite of aimage:
170
171 - The ability to image raw and AFF files at the same time will be
172 removed (since AFF can now write raw files directly).
173
174 - page-at-a-time imaging, resulting in more compact AFF files (less
175 wasted space) and easier implementation of novel data recovery
176 algorithms.
177
178 - Calculation of parity pages while the image is written, rather
179 than afterwards.
180
0 ANNOUNCING AFFLIB 3.3
1
2 I'm happy to announce the release of AFFLIB 3.3. You can download it
3 from the standard location at http://www.afflib.org/
4
5 Version 3.0 is a significant upgrade to AFFLIB which introduces the
6 following features:
7
8 * SUPPORT FOR VMWARE, PARALLELS, APPLE DMG DISK IMAGES
9
10 * SIGNIFICANTLY IMPROVED PERFORMANCE
11
12 ================================================================
13 SUPPORT FOR VMWARE DISK IMAGES
14
15 AFFLIB 3.3 incorporates the disk image subsystem from the open-source
16 QEMU processor virtualization project. Although most of QEMU is
17 distributed under the GPL license, the disk subsystem is distributed
18 under a less restrictive license that allows any use.
19
20 As a result, forensic programs linked with AFFLIB can now
21 transparently access disk images stored in any of the following
22 formats; currently the format is specified with the indicated extension.
23
24 So far we have only tested with VMWare .vmdk images:
25
26 * VMWare VMDK (.vmdk) (tested)
27
28 We also have the ability to add additional file types, including:
29 * Bochs Virtual HD Image
30 * cloop
31 * cow
32 * DMG
33 * qcow
34 * qcow2
35 * VFAT
36 * Parallels
37 * Connectix Virtual PC
38
39 Support for these will be enabled if requested.
40 ================================================================
41 SIGNIFICANTLY IMPROVED PERFORMANCE
42
43 Now that the feature set for AFFLIB is largely complete, we are
44 beginning to pay attention to performance issues. In particular, we
45 found a significant problem in versions 3.0 through 3.2 that would
46 significantly degrade performance of disk images larger than 1GB. This
47 has now been addressed.
48
49 ================================================================
50
51
52
0
1 IMPLEMENTATION
2 ==============
3
4 AFFLIB encryption will continue to use the cryptographic primitives
5 provided by the OpenSSL library.
6
7 The AFFILE Structure will be modified to include these additional fields:
8 AES_KEY ekey - The OpenSSL AES256 encryption key
9 AES_KEY dkey - The OpenSSL AES256 decryption key
10
11
12 Reading:
13
14 Getting pages is currently implemented with a chain of functions:
15
16 af_get_page() - gets the page and decompresses it if necessary.
17 af_get_page_raw() - gets raw pages (without compression)
18 af_get_seg() - gets the actual segment
19
20
21 Proposed modification:
22
23 If af_get_seg(s1) fails AND if a symmetric encryption key has been
24 set, the function will then look for s1/aes. If this is found the
25 segment will be decrypted and returned.
26
27 Writing:
28
29
30 Currently pages are written with these functions:
31
32 af_update_page(af,pagenum,data,datalen)
33 af_update_seg()
34
35 Procedure for writing encrypted pages:
36
37 - Modify af_update_page() to call a new function,
38 af_update_page_raw(), which does the encryption.
39
40
41 Other work that needs to be done:
42
43 - Make sure that pages are only written with this function. In
44 particular, check out afconvert, aimage, and atest
45
46
47 ================================================================
48 Performance Notes:
49
50 When reading encrypted AFF files, specify read buffers that are at
51 least 16 bytes larger than you expect. This gives the internal
52 routines space to do the decryption in place. Otherwise additional
53 memory needs to be allocated and data needs to be copied.
54
55
56 ================================================================
0 Design for the encryption system:
1
2 Encryption on AFF will be implemented by AFF Base Encryption
3 Services. On top of the Base Encryption may be layered either
4 Passphrase Encryption or Public Key Encryption.
5
6 AFF Base Encryption:
7 ---------------------
8 Currently we'll be doing this with AES-256, but the system can be
9 evolved to accommodate other encryption schemes as needed.
10
11 Today AFF data pages are stored in segments named page%d --- page0, page1, etc.
12 The flag indicates if compression is used or not.
13
14 Encrypted pages will be stored in segments named page%d/aes --- ie,
15 page0/aes, page1/aes, etc.
16
17 Restrictions:
18
19 * A single "affkey" is used to encrypt every page.
20 * The AES-256 key cannot be changed.
21
22 Encryption will be done with AES256 in CBC mode.
23 The IV is the name of the sector, padded with NULs.
24
25 AES256 requires that all buffers be padded to the AES block size,
26 which is 16 bytes. For performance we don't want to add padding if
27 the page is already a multiple of the bock size, so here is the
28 algorithm:
29
30 * If len%16==0, do not pad
31 * If len%16!=0, let
32 extra = len%16
33 pad = 16-extra
34 Append pad NUL bytes
35 Encrypt
36 Append extra NUL bytes.
37 Write
38
39 Now, when segment is read:
40 extra = len%16
41 pad = 16-extra
42
43 * extra==0, it wasn't padded
44 * Otherwise
45 Remove extra NUL bytes
46 Decrypt
47 Remove pad NUL bytes
48
49 In this way, the length does not need to be explicitly coded.
50
51 On decryption, the key can be "validated" by attempting to decrypt
52 page0/aes and seeing if page0_md5 matches (because that's the MD5
53 for the unencrypted, uncompressed page.) A new API call will be
54 created for this purpose.
55
56 If a key is set, then pages that are written are automatically encrypted first.
57
58 If both an encrypted page and an unencrypted page are present in the
59 file, the unencrypted page is returned (because the software never
60 looks for the encrypted page.)
61
62 If an unencrypted page is updated and encryption is turned on, the
63 encrypted page is first written, then the unencrypted page is deleted.
64
65 It is an error to change the affkey encryption key once it has been set.
66
67
68
69 Advantages:
70 * Simple to implement & test.
71 * It's real encryption, not a "password" like E01 format uses.
72 * Works transparently with S3 implementation.
73 * Allows an unencrypted file to be encrypted in-place.
74 * We can push this down into a lower layer to provide for encryption
75 of all metadata, although that won't be done in the initial
76 implementation.
77
78 Disadvantages:
79 * Only encrypts the page data, not the metadata, in the initial implementation.
80 * Only way to change the key is to copy to a new AFF file.
81 * Encryption key is cached in memory in the AF structure.
82
83
84 Proposed API:
85 af_set_aes_key(af,key,keysize) - sets the key; use alg=0 to turn off encryption.
86 - key is unsigned char.
87 - keysize is in bits.
88 af_validate_key(af) - returns 0 if the key that was set can be used
89 to validate a page
90 af_validate_key_page(af,pagenum) - Specifically checks to see if pagenum
91 can be validated with the key that was set.
92 returns 0 - validates, -1 = does't validate; -2 = page doesn't
93 exist; -3 = page md5 doesn't exist.
94
95
96 AFF Passphrase Encryption
97 --------------------------
98 This approach builds upon the Base Encryption, but allows the user to
99 store a passphrase. Instead of using SHA256 to generate the encryption
100 key directly, the encryption key is a random 256 bit string. This
101 string is then encrypted with the passphrase and stored in the AFF
102 file.
103
104 The scheme could easily support multiple passphrases on each file,
105 although that may not be useful.
106
107 The encrypted encryption key is stored in a new segment: affkey-aes256
108
109 The contents of affkey_aes256 a 68 byte structure:
110 bytes 0-3 - Version number. This is version 1. Stored in network byte order.
111 bytes 4-67 - The affkey, encrypted with AES in codebook mode
112 using SHA-256 of the passphrase as the encryption key.
113 bytes 68-131 - the SHA-256 of the affkey (so you know when you got it).
114
115 With this scheme the passphrase can be changed without requiring the
116 entire disk image to be re-encrypted---just rewrite affkey-aes256
117 with a new password.
118
119 Advantages:
120 * Easy to change the key
121 * The passphrase is not cached in memory.
122
123 Disadvantages:
124 * If you can encrypt, you can decrypt (it's a passphrase).
125
126
127 Proposed API:
128 af_use_passphrase(af,char *phrase)
129 - Tries to use an existing passphrase from an AES-encrypted AFFILE
130 - errors if there is no AES-encrypted data to decrypt of if passphrase is wrong.
131
132 af_establish_passphrase(af,char *phrase)
133 - If no encryption has been used yet, makes a random key and
134 stores it encrypted with the passphrase.
135 - fails if encryption has been used
136
137 af_establish_passphrase_key(af,char *passphrase,char *key,int keylen)
138 - Verifies that the key is good (by decrypting existing encrypted data)
139
140 af_change_passphrase(af,char *oldphrase,char *newphrase)
141 - Validates that oldphrase is correct, then changes it to new phrase.
142
143
144 Signing AFF files with X.509 certificates
145 --------------------------
146 This approach is similar to AFF Passphrase Encryption, except that the
147 instead of encrypting the affkey with a passphrase, we encrypt it a
148 an X.509 certificate and its matching private key.
149
150 The easiest way to get a private key and a corresponding X.509
151 certificate is to make a self-signed certificate using the openssl command:
152
153 It can also use self-signed certificates:
154 openssl req -x509 -newkey rsa:1024 -keyout sign.key -out sign.key -nodes
155
156 This command will ask you a bunch of questions; the results are stored
157 in the file sign.crt. When you create a signed AFF file the
158 certificate will be stored in the file, so be careful what you
159 say. Alternatively, you can create an RSA private/public key pair,
160 create a certificate request (CSR), send the CSR to a certificate
161 authority, and use the certificate that the authority sends you back.
162
163 Note that this puts both the key and the self-signed certificate in
164 the same file. That's fine for our purposes.
165
166 You can view the contents the certificate with this openssl command:
167
168 openssl x509 -text -in sign.key
169
170 Each segment is signed with the X509 private key by the AFF library
171 when the segment is written. Two signature modes are support:
172
173 Mode 0 : RAW SEGMENT SIGNATURE.
174 The signature is computed by calculating
175 the SHA256 hash of the segment name, a NULL byte, the segment argument (a 32-bit
176 number) in network byte order, and the segment data.
177
178 Mode 1 : DATA PAGE SIGNATURE
179 The signature is computed by calculating
180 the SHA256 hash of the segment name, five NULL bytes, and the
181 page data.
182
183 Mode 1 is used for signing user data acquired from the hard drive; it
184 intentionally signs uncompressed data. Mode 0 is used for signing all
185 other data, including metadata returned from the drive, examiner
186 notes, and so on.
187
188 The signatures are written into segments themselves, with the segment
189 name being "name/sha256" where "name" is the original segment
190 name. The argument of the segment is the signature mode.
191
192 Notice that AFF signatures are independent of the underlying storage
193 system. The signatures can be stored in one file and the data in
194 another file (as in an AFM file), or in multiple AFF files (as in an
195 AFD directory). They can even be stored in a network-based object
196 storage system (like S3).
197
198 If not private key exists and a data segment is written AFFLIB will
199 automatically compute the MD5 of the uncompressed data page and write
200 it to the file. This isn't done if a private key exist.
201
202 Right now the primary limitation is that the signature does not
203 indicate which private key was used to create it. This isn't so much a
204 problem, though, because we only support a single signing key. It is
205 an issue for chain of custody blocks
206
207 AFF Chain of Custody Block.
208
209 When an AFF file is created or copied, an AFF Chain of Custody Block
210 can be added. This block can be thought of as a signed table of
211 contents, although it isn't strictly a TOC because the CCB doesn't
212 indicate the position of each signed segment within the file.
213
214 The AFF Chain of Custody Block is an XML block. Right now the block is
215 just written into a segment and that signment is signed using the
216 standard segment signing appraoch. Eventually the segment may be
217 signed using XML signatures.
218
219 XML elements:
220
221 <custody_chain>
222 <date type="ISO 8601" value="19980708T13:33:11"/> - Date that this is being written
223 <signingcert>mycert</signingcert> - base64 encoding of X.509 certificate
224 <notes>
225 </notes>
226 <segments> - segments that are present in AFF file at time it was received
227 <segment_hash segname='myname1' mode='0' alg='sha256'>signature in base64 coding</segment_signature>
228 ...
229 </segments>
230 </custody_chain>
231
232 Right now this is signed with a base-64 signature following the
233 chain. Eventually we may move to XML signatures.
234
235 ================================================================
236
237 Encrypting AFF files with X.509 certificates
238 -------------------------------------------
239
240 The public key is specified when the file is created. After the file
241 is created, it can only be accessed using the corresponding private
242 key. This includes all access--both reading and writing.
243
244 For encrypting the private key is stored in the
245 environment variable AFFLIB_ENCRYPTING_PUBLIC_KEY or in a filename
246 referenced by the variable AFFLIB_ENCRYPTING_PUBLIC_KEYFILE
247
248 For decrypting the private key is stored in the
249 environment variable AFFLIB_DECRYPTING_PRIVATE_KEY or in a filename
250 referenced by the variable AFFLIB_DECRYPTING_PRIVATE_KEYFILE
251
252 Public key encryption is implemented by taking the affkey and storing
253 it in a segment called "affkey-rsannn" where nnn runs from 0 to whatever.
254 Padding is with PKCS1.
255
256 Advantages:
257 * Easy to implement with existing cryptographic tools.
258 * Can encrypt to multiple keys
259
260 ================================================================
261
262 AFF Public Key Signatures:
263 --------------------------
264 This approach uses a private key to sign each segment when it is written.
265 In this case, a private key is used for signing and the public key is
266 used for verifying signatures. The public key will be stored in the
267 image itself; its fingerprint can be recorded elsewhere.
268
269 Once again, filenames are specified in environment variables:
270
271 AFFLIB_SIGNING_PRIVATE_KEY
272 AFFLIB_SIGNING_PUBLIC_KEY
273
274
275 ================================================================
276
277
278 ================================================================
0 AFF Encryption
1 =============
2
3 Release 2.4 of AFFLIB implements AFF pass-phrase encryption.
4
5 Encryption is based on a 256-bit randomly-generated AES key (called
6 the AFF key). This key is itself encrypted with an AFF passphrase and
7 stored in its own segment. This strategy allows an AFF image
8 encryption passphrase to be changed without re-encrypting the entire
9 disk image.
10
11 AFF PASSPHRASE ENCRYPTION
12 =========================
13
14 The AFF passphrase may be specified either as part of the filename or,
15 in some cases, as an optional argument for some of the AFF commands.
16 AFF uses RFC 1630 URI syntax to specify encryption
17 passphrases. Specifically, RFC 1630 allows the file myfile.aff to be
18 specified as a URI:
19
20 afinfo file:///myfile.aff
21
22 The passphrase 'mypassphrase' can be added to this URL:
23
24 afinfo file://:mypassphrase@/myfile.aff
25
26 If you wish to refer to myfile.aff in the root directory, use this
27 syntax:
28
29 afinfo file:////myfile.aff
30
31 Because windows interperts the forward and back slashes in the same
32 manner, this will refer to the file c:\myfile.aff
33
34 afinfo file:///c:/myfile.aff
35
36 You can also save the passphrase in an environment variable called AFFPASSPHRASE:
37
38 setenv AFFLIB_PASSPHRASE "mypassphrase" (csh)
39 export AFFLIB_PASSPHRASE="mypassphrase" (bash)
40 set AFFLIB_PASSPHRASE="mypassphrase" (windows)
41 afinfo myfile.aff
42
43 You can store the passphrase in a file and specify that file with the AFFLIB_PASSPHRASE_FILE variable.
44 setenv AFFLIB_PASSPHRASE_FILE "/tmp/myfile"
45 echo "mypassphrase" > /tmp/myfile
46 afinfo myfile.aff
47
48
49 A passphrase can also be read from a file descriptor by putting the file descriptor number in
50 the environment variable AFFLIB_PASSPHRASE_FD:
51 setenv AFFLIB_PASSPHRASE_FD "5"
52 echo "mypassphrase" > /tmp/myfile
53 afinfo myfile.aff 5</etc/myfile
54
55
56 MAC USERS NOTE: SHA-256 IS REQUIRED
57
58 If you are compiling on a Macintosh, you must download the most recent
59 developer tools from developer.apple.com in order to obtain the
60 SHA-256 libraries. Otherwise you cannot compile the cryptographic code.
61
62
63 HOW AFF USES THE PASSPHRASE FOR ENCRYPTION
64
65 AFF encryption works segment-by-segment. Segments are encrypted with
66 the AFFKEY, a randomly generated 256-bit AES key. After the AFFKEY is
67 set, all segments that are written are first encrypted with the AES256
68 cipher operating in CBC mode. (The segment name is used as the
69 initialization vector.) When a segment is read, AFF will return either
70 the unencrypted segment or, if there is an encrypted segment, it will
71 decrypt that segment and return it. (The internal design of AFF
72 prevents there from being both an encrypted and unencrypted segment by
73 the same name in the same file.)
74
75 The first time an AFF file is written with a passphrase the AFF
76 library creates a random key, encrypts that key with the SHA-256 of
77 the passphrase, and stores the resulting encrypted key in a special
78 segment. Thus, the AFF passphrase can be changed by simply reading
79 this segment, decrypting it with the old phrase and re-encrypting it with
80 the new phrase. The afcrypto command does this automatically.
81
82 If a passphrase is set both in the file:// URL and in the environment
83 variable, the URL passphrase takes precedence.
84
85
86 EXAMPLES
87
88 To encrypt the AFF file disk.aff, you might use this command:
89
90 afcopy disk.aff file://:mypassphrase@/disk-encrypted.aff
91
92 To image directly to an encrypted AFF file, you might use aimage like
93 this:
94
95 aimage /dev/hda file://:mypassphrase@/disk-encrypted.aff
96
97
98 If you want to see the encrypted segments, use this command:
99
100 afinfo -a disk-encrypted.aff
101
102 If you want to see the decrypted segments, use this command:
103
104 afinfo -a file://:mypassphrase@/disk-encrypted.aff
105
106 You can mount an encrypted image with affuse:
107
108 mkdir /mnt/aff
109 affuse file://:mypassphrase@/disk-encrypted.aff /mnt/aff
110
111 You can change the passphrase on a file using the afcrypto command:
112
113 afcrypto -c disk-encrypted.aff
114 Enter old passphrase: mypassphrase
115 Enter new passphrase: newpassphrase
116
117 change passphrase
118 passphrase successfully changed.
119
120
121
122 AFF PUBLIC KEY SIGNING AND ENCRYPTION
123 =====================================
124 AFF can use public key cryptography for both signing acqired images
125 and encrypting the images so that they can only be read by the
126 intended recepient.
127
128 To use public key encryption you will need to make a pair of
129 keys---one key for signing, the other key for encrypting. These keys
130 can both be made with the "makekeys.bat" script that is located in the
131 tools directory.
132
133 There are two ways to sign AFF file:
134
135 * You can sign the file when it is acquired with the aimage
136 program by specifying your signing key on the command line:
137
138 * You can sign the file after-the-fact using the "afcrypto"
139 command:
140
141 Signatures can be verified using the afcrypto command; the afcrypto
142 command will print the fingerprint of the key used to sign the file,
143 will print any segments that do not verify, and will print any
144 segments that are NOT SIGNED.
145
146 We imagine that most users will wish to have digitally signed AFF
147 files.
148
149 AFF can also use public key cryptography to encrypt the contents of an
150 AFF file. In this case a public key is used to encrypt a file that is
151 created with either the aimage or afcopy commands. Once a file is
152 encrypted it can only be accessed with a corresponding private
153 key. The primary purpose of public key cryptography here is to prevent
154 images that are acquired in the field from being readable by anyone
155 other than a particular analysis laboratory. This might be useful when
156 images are acquired in or transported through a potentially hostile
157 area.
158
159
160 ================================================================
161 Please let me know what you think!
162
163 Simson Garfinkel
164 August 27, 2007
0 AFF:
1 Setting maxsize with AFF files will have no effect, because AFF
2 files are by definition not split. If you want a split AFF file,
3 you must use AFD files (AFD is a directory with a .afd extension
4 that holds multiple AFF files).
5
6 AFM:
7 The size of AFM split files is stored in af->maxsize (also ap->sr->maxsize).
8
9 This value is determined by multiplying the AF_PAGESIZE (which defaults to
10 AFF_DEFAULT_PAGESIZ, currently 1024*1024*16) by AF_PAGES_PER_RAW_IMAGE_FILE.
11
12 By default, AF_PAGES_PER_RAW_IMAGE_FILE is not set. This means that, by default,
13 AFM files are not split but consist of a single raw file and a single AFM file
14 (which holds the metadata for the raw file).
15
16 You can set AF_PAGES_PER_RAW image like this:
17
18 int64_t pages_per_file = 128;
19 af_update_segq (af, AF_PAGES_PER_RAW_IMAGE_FILE, pages_per_file);
20
21 AFM files that are created by aimage do have this value set,
22 however: it is set to 2^31.
23
24
25
0 Plans for making AFFLIB multi-threaded:
1
2 Low hanging fruit:
3 * Compress in background
4 * Calculate hashes in background
5
6 Easy implementation strategy:
7 * mutext for:
8 - the entire cache
9 - each page of the cache
10 - the TOC (should this be re-implemented as a C++ vector?)
11
12 Both compressing and hashing needs access to the page cache in another thread:
13 - Needs to lock the page cache so no other process will write to it.
14 - Or needs to make a copy of it.
15 - Then needs to write it out.
16
17
18 Test program:
19 - Can we write a method that computes hash in another thread?
0 #!/bin/sh
1 # install - install a program, script, or datafile
2
3 scriptversion=2005-05-14.22
4
5 # This originates from X11R5 (mit/util/scripts/install.sh), which was
6 # later released in X11R6 (xc/config/util/install.sh) with the
7 # following copyright and license.
8 #
9 # Copyright (C) 1994 X Consortium
10 #
11 # Permission is hereby granted, free of charge, to any person obtaining a copy
12 # of this software and associated documentation files (the "Software"), to
13 # deal in the Software without restriction, including without limitation the
14 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15 # sell copies of the Software, and to permit persons to whom the Software is
16 # furnished to do so, subject to the following conditions:
17 #
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
20 #
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
26 # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #
28 # Except as contained in this notice, the name of the X Consortium shall not
29 # be used in advertising or otherwise to promote the sale, use or other deal-
30 # ings in this Software without prior written authorization from the X Consor-
31 # tium.
32 #
33 #
34 # FSF changes to this file are in the public domain.
35 #
36 # Calling this script install-sh is preferred over install.sh, to prevent
37 # `make' implicit rules from creating a file called install from it
38 # when there is no Makefile.
39 #
40 # This script is compatible with the BSD install script, but was written
41 # from scratch. It can only install one file at a time, a restriction
42 # shared with many OS's install programs.
43
44 # set DOITPROG to echo to test this script
45
46 # Don't use :- since 4.3BSD and earlier shells don't like it.
47 doit="${DOITPROG-}"
48
49 # put in absolute paths if you don't have them in your path; or use env. vars.
50
51 mvprog="${MVPROG-mv}"
52 cpprog="${CPPROG-cp}"
53 chmodprog="${CHMODPROG-chmod}"
54 chownprog="${CHOWNPROG-chown}"
55 chgrpprog="${CHGRPPROG-chgrp}"
56 stripprog="${STRIPPROG-strip}"
57 rmprog="${RMPROG-rm}"
58 mkdirprog="${MKDIRPROG-mkdir}"
59
60 chmodcmd="$chmodprog 0755"
61 chowncmd=
62 chgrpcmd=
63 stripcmd=
64 rmcmd="$rmprog -f"
65 mvcmd="$mvprog"
66 src=
67 dst=
68 dir_arg=
69 dstarg=
70 no_target_directory=
71
72 usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
73 or: $0 [OPTION]... SRCFILES... DIRECTORY
74 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
75 or: $0 [OPTION]... -d DIRECTORIES...
76
77 In the 1st form, copy SRCFILE to DSTFILE.
78 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
79 In the 4th, create DIRECTORIES.
80
81 Options:
82 -c (ignored)
83 -d create directories instead of installing files.
84 -g GROUP $chgrpprog installed files to GROUP.
85 -m MODE $chmodprog installed files to MODE.
86 -o USER $chownprog installed files to USER.
87 -s $stripprog installed files.
88 -t DIRECTORY install into DIRECTORY.
89 -T report an error if DSTFILE is a directory.
90 --help display this help and exit.
91 --version display version info and exit.
92
93 Environment variables override the default commands:
94 CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
95 "
96
97 while test -n "$1"; do
98 case $1 in
99 -c) shift
100 continue;;
101
102 -d) dir_arg=true
103 shift
104 continue;;
105
106 -g) chgrpcmd="$chgrpprog $2"
107 shift
108 shift
109 continue;;
110
111 --help) echo "$usage"; exit $?;;
112
113 -m) chmodcmd="$chmodprog $2"
114 shift
115 shift
116 continue;;
117
118 -o) chowncmd="$chownprog $2"
119 shift
120 shift
121 continue;;
122
123 -s) stripcmd=$stripprog
124 shift
125 continue;;
126
127 -t) dstarg=$2
128 shift
129 shift
130 continue;;
131
132 -T) no_target_directory=true
133 shift
134 continue;;
135
136 --version) echo "$0 $scriptversion"; exit $?;;
137
138 *) # When -d is used, all remaining arguments are directories to create.
139 # When -t is used, the destination is already specified.
140 test -n "$dir_arg$dstarg" && break
141 # Otherwise, the last argument is the destination. Remove it from $@.
142 for arg
143 do
144 if test -n "$dstarg"; then
145 # $@ is not empty: it contains at least $arg.
146 set fnord "$@" "$dstarg"
147 shift # fnord
148 fi
149 shift # arg
150 dstarg=$arg
151 done
152 break;;
153 esac
154 done
155
156 if test -z "$1"; then
157 if test -z "$dir_arg"; then
158 echo "$0: no input file specified." >&2
159 exit 1
160 fi
161 # It's OK to call `install-sh -d' without argument.
162 # This can happen when creating conditional directories.
163 exit 0
164 fi
165
166 for src
167 do
168 # Protect names starting with `-'.
169 case $src in
170 -*) src=./$src ;;
171 esac
172
173 if test -n "$dir_arg"; then
174 dst=$src
175 src=
176
177 if test -d "$dst"; then
178 mkdircmd=:
179 chmodcmd=
180 else
181 mkdircmd=$mkdirprog
182 fi
183 else
184 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
185 # might cause directories to be created, which would be especially bad
186 # if $src (and thus $dsttmp) contains '*'.
187 if test ! -f "$src" && test ! -d "$src"; then
188 echo "$0: $src does not exist." >&2
189 exit 1
190 fi
191
192 if test -z "$dstarg"; then
193 echo "$0: no destination specified." >&2
194 exit 1
195 fi
196
197 dst=$dstarg
198 # Protect names starting with `-'.
199 case $dst in
200 -*) dst=./$dst ;;
201 esac
202
203 # If destination is a directory, append the input filename; won't work
204 # if double slashes aren't ignored.
205 if test -d "$dst"; then
206 if test -n "$no_target_directory"; then
207 echo "$0: $dstarg: Is a directory" >&2
208 exit 1
209 fi
210 dst=$dst/`basename "$src"`
211 fi
212 fi
213
214 # This sed command emulates the dirname command.
215 dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
216
217 # Make sure that the destination directory exists.
218
219 # Skip lots of stat calls in the usual case.
220 if test ! -d "$dstdir"; then
221 defaultIFS='
222 '
223 IFS="${IFS-$defaultIFS}"
224
225 oIFS=$IFS
226 # Some sh's can't handle IFS=/ for some reason.
227 IFS='%'
228 set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
229 shift
230 IFS=$oIFS
231
232 pathcomp=
233
234 while test $# -ne 0 ; do
235 pathcomp=$pathcomp$1
236 shift
237 if test ! -d "$pathcomp"; then
238 $mkdirprog "$pathcomp"
239 # mkdir can fail with a `File exist' error in case several
240 # install-sh are creating the directory concurrently. This
241 # is OK.
242 test -d "$pathcomp" || exit
243 fi
244 pathcomp=$pathcomp/
245 done
246 fi
247
248 if test -n "$dir_arg"; then
249 $doit $mkdircmd "$dst" \
250 && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
251 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
252 && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
253 && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
254
255 else
256 dstfile=`basename "$dst"`
257
258 # Make a couple of temp file names in the proper directory.
259 dsttmp=$dstdir/_inst.$$_
260 rmtmp=$dstdir/_rm.$$_
261
262 # Trap to clean up those temp files at exit.
263 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
264 trap '(exit $?); exit' 1 2 13 15
265
266 # Copy the file name to the temp name.
267 $doit $cpprog "$src" "$dsttmp" &&
268
269 # and set any options; do chmod last to preserve setuid bits.
270 #
271 # If any of these fail, we abort the whole thing. If we want to
272 # ignore errors from any of these, just make sure not to ignore
273 # errors from the above "$doit $cpprog $src $dsttmp" command.
274 #
275 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
276 && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
277 && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
278 && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
279
280 # Now rename the file to the real destination.
281 { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
282 || {
283 # The rename failed, perhaps because mv can't rename something else
284 # to itself, or perhaps because mv is so ancient that it does not
285 # support -f.
286
287 # Now remove or move aside any old file at destination location.
288 # We try this two ways since rm can't unlink itself on some
289 # systems and the destination file might be busy for other
290 # reasons. In this case, the final cleanup might fail but the new
291 # file should still install successfully.
292 {
293 if test -f "$dstdir/$dstfile"; then
294 $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
295 || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
296 || {
297 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
298 (exit 1); exit 1
299 }
300 else
301 :
302 fi
303 } &&
304
305 # Now rename the file to the real destination.
306 $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
307 }
308 }
309 fi || { (exit 1); exit 1; }
310 done
311
312 # The final little trick to "correctly" pass the exit status to the exit trap.
313 {
314 (exit 0); exit 0
315 }
316
317 # Local variables:
318 # eval: (add-hook 'write-file-hooks 'time-stamp)
319 # time-stamp-start: "scriptversion="
320 # time-stamp-format: "%:y-%02m-%02d.%02H"
321 # time-stamp-end: "$"
322 # End:
0 bin_PROGRAMS = aftest
1 aftest_SOURCES = aftest.cpp
2 aftest_LDADD = libafflib.la
3
4 TESTS = aftest
5
6 aftest_LDFLAGS = $(PTHREAD_CFLAGS) -static # easier debugging
7
8 AFFLIB_SOURCES = aff_db.cpp aff_db.h aff_toc.cpp \
9 afflib.cpp afflib.h afflib_i.h threaded_hash.h afflib_os.cpp \
10 afflib_pages.cpp afflib_stream.cpp afflib_util.cpp \
11 crypto.cpp \
12 base64.cpp base64.h lzma_glue.cpp s3_glue.h \
13 vnode_aff.cpp vnode_aff.h \
14 vnode_afd.cpp vnode_afd.h \
15 vnode_afm.cpp vnode_afm.h \
16 vnode_ewf.cpp vnode_ewf.h \
17 vnode_raw.cpp vnode_raw.h \
18 vnode_split_raw.cpp vnode_split_raw.h \
19 aftimer.h \
20 utils.cpp utils.h display.cpp
21
22 libafflib_la_SOURCES = $(AFFLIB_SOURCES)
23
24 QEMU_SOURCES = \
25 vnode_qemu.cpp \
26 vnode_qemu.h \
27 qemu/aes.h \
28 qemu/aff-block-vmdk.h \
29 qemu/block-bochs.c \
30 qemu/block-cloop.c \
31 qemu/block-cow.c \
32 qemu/block-dmg.c \
33 qemu/block-parallels.c \
34 qemu/block-qcow.c \
35 qemu/block-qcow2.c \
36 qemu/block-raw-posix.c \
37 qemu/block-vmdk.c \
38 qemu/block-vpc.c \
39 qemu/block-vvfat.c \
40 qemu/block.c \
41 qemu/block.h \
42 qemu/block_int.h \
43 qemu/bswap.h \
44 qemu/config-host.h \
45 qemu/console.h \
46 qemu/exec-all.h \
47 qemu/osdep.h \
48 qemu/qemu-common.h \
49 qemu/qemu-timer.h \
50 qemu/qemu_glue.c
51
52 if MAYBE_QEMU
53 libafflib_la_SOURCES += $(QEMU_SOURCES)
54 libafflib_la_CFLAGS = -DQEMU_IMG
55 aftest_CFLAGS = -DQEMU_IMG
56 endif
57
58 if MAYBE_S3
59 bin_PROGRAMS += s3
60 libafflib_la_SOURCES += vnode_s3.cpp vnode_s3.h s3_glue.cpp
61 s3_SOURCES = s3.cpp
62 s3_LDADD = libafflib.la
63 s3_LDFLAGS = $(PTHREAD_CFLAGS)
64 endif
65
66
67 install-exec-hook:
68 @if [ -r $(DESTDIR)/etc/ld.so.conf ] ; then \
69 echo "*************************************************" ;\
70 echo "*** Checking shared library config for $(libdir) " ;\
71 if grep ^$(libdir) $(DESTDIR)/etc/ld.so.conf >/dev/null ; \
72 then echo $(libdir) already installed ; \
73 else echo installing $(libdir) in $(DESTDIR)/etc/ld.so.conf ; \
74 echo $(libdir) >> $(DESTDIR)/etc/ld.so.conf ; \
75 PATH=$(PATH):/sbin; \
76 ldconfig; \
77 fi ; \
78 echo "*************************************************" ;\
79 fi
80
81 EXTRA_DIST =
82
83 INCLUDES = \
84 -I@top_srcdir@/lzma443/C \
85 -I@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone
86
87 LZMA_SOURCES = \
88 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp \
89 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp \
90 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c \
91 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c \
92 @top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c \
93 @top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp \
94 @top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp \
95 @top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp \
96 @top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp \
97 @top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp \
98 @top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp \
99 @top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp \
100 @top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp \
101 @top_srcdir@/lzma443/C/Common/Alloc.cpp \
102 @top_srcdir@/lzma443/C/Common/CommandLineParser.cpp \
103 @top_srcdir@/lzma443/C/Common/CRC.cpp \
104 @top_srcdir@/lzma443/C/Common/String.cpp \
105 @top_srcdir@/lzma443/C/Common/StringConvert.cpp \
106 @top_srcdir@/lzma443/C/Common/StringToInt.cpp \
107 @top_srcdir@/lzma443/C/Common/Vector.cpp
108
109
110 # specify lib_ to force tools to be dynamically linked against the installed library.
111 # specify noinst_LTLIBRARIES to have the tools be statically linked
112 # Unfortunately, when we specify lib_, things don't build. I can't figure it out.
113 lib_LTLIBRARIES = libafflib.la
114 libafflib_la_SOURCES += $(LZMA_SOURCES)
0 # Makefile.in generated by automake 1.10 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16
17 VPATH = @srcdir@
18 pkgdatadir = $(datadir)/@PACKAGE@
19 pkglibdir = $(libdir)/@PACKAGE@
20 pkgincludedir = $(includedir)/@PACKAGE@
21 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
22 install_sh_DATA = $(install_sh) -c -m 644
23 install_sh_PROGRAM = $(install_sh) -c
24 install_sh_SCRIPT = $(install_sh) -c
25 INSTALL_HEADER = $(INSTALL_DATA)
26 transform = $(program_transform_name)
27 NORMAL_INSTALL = :
28 PRE_INSTALL = :
29 POST_INSTALL = :
30 NORMAL_UNINSTALL = :
31 PRE_UNINSTALL = :
32 POST_UNINSTALL = :
33 build_triplet = @build@
34 host_triplet = @host@
35 bin_PROGRAMS = aftest$(EXEEXT) $(am__EXEEXT_1)
36 TESTS = aftest$(EXEEXT)
37 @MAYBE_QEMU_TRUE@am__append_1 = $(QEMU_SOURCES)
38 @MAYBE_S3_TRUE@am__append_2 = s3
39 @MAYBE_S3_TRUE@am__append_3 = vnode_s3.cpp vnode_s3.h s3_glue.cpp
40 subdir = lib
41 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
42 $(srcdir)/version.h.in
43 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
44 am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
45 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
46 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
47 $(ACLOCAL_M4)
48 mkinstalldirs = $(install_sh) -d
49 CONFIG_HEADER = $(top_builddir)/affconfig.h
50 CONFIG_CLEAN_FILES = version.h
51 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
52 am__vpath_adj = case $$p in \
53 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
54 *) f=$$p;; \
55 esac;
56 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
57 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"
58 libLTLIBRARIES_INSTALL = $(INSTALL)
59 LTLIBRARIES = $(lib_LTLIBRARIES)
60 libafflib_la_LIBADD =
61 am__libafflib_la_SOURCES_DIST = aff_db.cpp aff_db.h aff_toc.cpp \
62 afflib.cpp afflib.h afflib_i.h threaded_hash.h afflib_os.cpp \
63 afflib_pages.cpp afflib_stream.cpp afflib_util.cpp crypto.cpp \
64 base64.cpp base64.h lzma_glue.cpp s3_glue.h vnode_aff.cpp \
65 vnode_aff.h vnode_afd.cpp vnode_afd.h vnode_afm.cpp \
66 vnode_afm.h vnode_ewf.cpp vnode_ewf.h vnode_raw.cpp \
67 vnode_raw.h vnode_split_raw.cpp vnode_split_raw.h aftimer.h \
68 utils.cpp utils.h display.cpp vnode_qemu.cpp vnode_qemu.h \
69 qemu/aes.h qemu/aff-block-vmdk.h qemu/block-bochs.c \
70 qemu/block-cloop.c qemu/block-cow.c qemu/block-dmg.c \
71 qemu/block-parallels.c qemu/block-qcow.c qemu/block-qcow2.c \
72 qemu/block-raw-posix.c qemu/block-vmdk.c qemu/block-vpc.c \
73 qemu/block-vvfat.c qemu/block.c qemu/block.h qemu/block_int.h \
74 qemu/bswap.h qemu/config-host.h qemu/console.h qemu/exec-all.h \
75 qemu/osdep.h qemu/qemu-common.h qemu/qemu-timer.h \
76 qemu/qemu_glue.c vnode_s3.cpp vnode_s3.h s3_glue.cpp \
77 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp \
78 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp \
79 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c \
80 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c \
81 @top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c \
82 @top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp \
83 @top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp \
84 @top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp \
85 @top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp \
86 @top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp \
87 @top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp \
88 @top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp \
89 @top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp \
90 @top_srcdir@/lzma443/C/Common/Alloc.cpp \
91 @top_srcdir@/lzma443/C/Common/CommandLineParser.cpp \
92 @top_srcdir@/lzma443/C/Common/CRC.cpp \
93 @top_srcdir@/lzma443/C/Common/String.cpp \
94 @top_srcdir@/lzma443/C/Common/StringConvert.cpp \
95 @top_srcdir@/lzma443/C/Common/StringToInt.cpp \
96 @top_srcdir@/lzma443/C/Common/Vector.cpp
97 am__objects_1 = aff_db.lo aff_toc.lo afflib.lo afflib_os.lo \
98 afflib_pages.lo afflib_stream.lo afflib_util.lo crypto.lo \
99 base64.lo lzma_glue.lo vnode_aff.lo vnode_afd.lo vnode_afm.lo \
100 vnode_ewf.lo vnode_raw.lo vnode_split_raw.lo utils.lo \
101 display.lo
102 am__objects_2 = vnode_qemu.lo libafflib_la-block-bochs.lo \
103 libafflib_la-block-cloop.lo libafflib_la-block-cow.lo \
104 libafflib_la-block-dmg.lo libafflib_la-block-parallels.lo \
105 libafflib_la-block-qcow.lo libafflib_la-block-qcow2.lo \
106 libafflib_la-block-raw-posix.lo libafflib_la-block-vmdk.lo \
107 libafflib_la-block-vpc.lo libafflib_la-block-vvfat.lo \
108 libafflib_la-block.lo libafflib_la-qemu_glue.lo
109 @MAYBE_QEMU_TRUE@am__objects_3 = $(am__objects_2)
110 @MAYBE_S3_TRUE@am__objects_4 = vnode_s3.lo s3_glue.lo
111 am__objects_5 = LzmaBench.lo LzmaRam.lo libafflib_la-LzmaRamDecode.lo \
112 libafflib_la-LzmaDecode.lo libafflib_la-BranchX86.lo \
113 LZMADecoder.lo LZMAEncoder.lo LZInWindow.lo LZOutWindow.lo \
114 RangeCoderBit.lo InBuffer.lo OutBuffer.lo StreamUtils.lo \
115 Alloc.lo CommandLineParser.lo CRC.lo String.lo \
116 StringConvert.lo StringToInt.lo Vector.lo
117 am_libafflib_la_OBJECTS = $(am__objects_1) $(am__objects_3) \
118 $(am__objects_4) $(am__objects_5)
119 libafflib_la_OBJECTS = $(am_libafflib_la_OBJECTS)
120 @MAYBE_S3_TRUE@am__EXEEXT_1 = s3$(EXEEXT)
121 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
122 PROGRAMS = $(bin_PROGRAMS)
123 am_aftest_OBJECTS = aftest.$(OBJEXT)
124 aftest_OBJECTS = $(am_aftest_OBJECTS)
125 aftest_DEPENDENCIES = libafflib.la
126 aftest_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
127 --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
128 $(aftest_LDFLAGS) $(LDFLAGS) -o $@
129 am__s3_SOURCES_DIST = s3.cpp
130 @MAYBE_S3_TRUE@am_s3_OBJECTS = s3.$(OBJEXT)
131 s3_OBJECTS = $(am_s3_OBJECTS)
132 @MAYBE_S3_TRUE@s3_DEPENDENCIES = libafflib.la
133 s3_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
134 --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(s3_LDFLAGS) \
135 $(LDFLAGS) -o $@
136 DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
137 depcomp = $(SHELL) $(top_srcdir)/depcomp
138 am__depfiles_maybe = depfiles
139 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
140 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
141 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
142 --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
143 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
144 CCLD = $(CC)
145 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
146 --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
147 $(LDFLAGS) -o $@
148 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
149 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
150 LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
151 --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
152 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
153 CXXLD = $(CXX)
154 CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
155 --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
156 $(LDFLAGS) -o $@
157 SOURCES = $(libafflib_la_SOURCES) $(aftest_SOURCES) $(s3_SOURCES)
158 DIST_SOURCES = $(am__libafflib_la_SOURCES_DIST) $(aftest_SOURCES) \
159 $(am__s3_SOURCES_DIST)
160 ETAGS = etags
161 CTAGS = ctags
162 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
163 ACLOCAL = @ACLOCAL@
164 AFFUSE_BIN = @AFFUSE_BIN@
165 ALLOCA = @ALLOCA@
166 AMTAR = @AMTAR@
167 AR = @AR@
168 AUTOCONF = @AUTOCONF@
169 AUTOHEADER = @AUTOHEADER@
170 AUTOMAKE = @AUTOMAKE@
171 AWK = @AWK@
172 CC = @CC@
173 CCDEPMODE = @CCDEPMODE@
174 CFLAGS = @CFLAGS@
175 CPP = @CPP@
176 CPPFLAGS = @CPPFLAGS@
177 CURL_CONFIG = @CURL_CONFIG@
178 CXX = @CXX@
179 CXXCPP = @CXXCPP@
180 CXXDEPMODE = @CXXDEPMODE@
181 CXXFLAGS = @CXXFLAGS@
182 CYGPATH_W = @CYGPATH_W@
183 DEFS = @DEFS@
184 DEPDIR = @DEPDIR@
185 DSYMUTIL = @DSYMUTIL@
186 DUMPBIN = @DUMPBIN@
187 ECHO_C = @ECHO_C@
188 ECHO_N = @ECHO_N@
189 ECHO_T = @ECHO_T@
190 EGREP = @EGREP@
191 EXEEXT = @EXEEXT@
192 FGREP = @FGREP@
193 FUSE_CFLAGS = @FUSE_CFLAGS@
194 FUSE_LIBS = @FUSE_LIBS@
195 GREP = @GREP@
196 INSTALL = @INSTALL@
197 INSTALL_DATA = @INSTALL_DATA@
198 INSTALL_PROGRAM = @INSTALL_PROGRAM@
199 INSTALL_SCRIPT = @INSTALL_SCRIPT@
200 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
201 LD = @LD@
202 LDFLAGS = @LDFLAGS@
203 LIBOBJS = @LIBOBJS@
204 LIBS = @LIBS@
205 LIBTOOL = @LIBTOOL@
206 LIPO = @LIPO@
207 LN_S = @LN_S@
208 LTLIBOBJS = @LTLIBOBJS@
209 MAINT = @MAINT@
210 MAKEINFO = @MAKEINFO@
211 MKDIR_P = @MKDIR_P@
212 NM = @NM@
213 NMEDIT = @NMEDIT@
214 OBJEXT = @OBJEXT@
215 OTOOL = @OTOOL@
216 OTOOL64 = @OTOOL64@
217 PACKAGE = @PACKAGE@
218 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
219 PACKAGE_NAME = @PACKAGE_NAME@
220 PACKAGE_STRING = @PACKAGE_STRING@
221 PACKAGE_TARNAME = @PACKAGE_TARNAME@
222 PACKAGE_VERSION = @PACKAGE_VERSION@
223 PATH_SEPARATOR = @PATH_SEPARATOR@
224 PTHREAD_CC = @PTHREAD_CC@
225 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
226 PTHREAD_LIBS = @PTHREAD_LIBS@
227 PYTHON = @PYTHON@
228 PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
229 PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
230 PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
231 PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
232 PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
233 PYTHON_PLATFORM = @PYTHON_PLATFORM@
234 PYTHON_PREFIX = @PYTHON_PREFIX@
235 PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
236 PYTHON_VERSION = @PYTHON_VERSION@
237 RANLIB = @RANLIB@
238 S3_BIN = @S3_BIN@
239 SED = @SED@
240 SET_MAKE = @SET_MAKE@
241 SHELL = @SHELL@
242 STRIP = @STRIP@
243 VERSION = @VERSION@
244 abs_builddir = @abs_builddir@
245 abs_srcdir = @abs_srcdir@
246 abs_top_builddir = @abs_top_builddir@
247 abs_top_srcdir = @abs_top_srcdir@
248 ac_ct_CC = @ac_ct_CC@
249 ac_ct_CXX = @ac_ct_CXX@
250 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
251 ac_prefix_program = @ac_prefix_program@
252 acx_pthread_config = @acx_pthread_config@
253 am__include = @am__include@
254 am__leading_dot = @am__leading_dot@
255 am__quote = @am__quote@
256 am__tar = @am__tar@
257 am__untar = @am__untar@
258 bindir = @bindir@
259 build = @build@
260 build_alias = @build_alias@
261 build_cpu = @build_cpu@
262 build_os = @build_os@
263 build_vendor = @build_vendor@
264 builddir = @builddir@
265 datadir = @datadir@
266 datarootdir = @datarootdir@
267 docdir = @docdir@
268 dvidir = @dvidir@
269 exec_prefix = @exec_prefix@
270 host = @host@
271 host_alias = @host_alias@
272 host_cpu = @host_cpu@
273 host_os = @host_os@
274 host_vendor = @host_vendor@
275 htmldir = @htmldir@
276 includedir = @includedir@
277 infodir = @infodir@
278 install_sh = @install_sh@
279 libdir = @libdir@
280 libexecdir = @libexecdir@
281 localedir = @localedir@
282 localstatedir = @localstatedir@
283 lt_ECHO = @lt_ECHO@
284 mandir = @mandir@
285 mkdir_p = @mkdir_p@
286 oldincludedir = @oldincludedir@
287 pdfdir = @pdfdir@
288 pkgpyexecdir = @pkgpyexecdir@
289 pkgpythondir = @pkgpythondir@
290 prefix = @prefix@
291 program_transform_name = @program_transform_name@
292 psdir = @psdir@
293 pyexecdir = @pyexecdir@
294 pythondir = @pythondir@
295 sbindir = @sbindir@
296 sharedstatedir = @sharedstatedir@
297 srcdir = @srcdir@
298 sysconfdir = @sysconfdir@
299 target_alias = @target_alias@
300 top_builddir = @top_builddir@
301 top_srcdir = @top_srcdir@
302 aftest_SOURCES = aftest.cpp
303 aftest_LDADD = libafflib.la
304 aftest_LDFLAGS = $(PTHREAD_CFLAGS) -static # easier debugging
305 AFFLIB_SOURCES = aff_db.cpp aff_db.h aff_toc.cpp \
306 afflib.cpp afflib.h afflib_i.h threaded_hash.h afflib_os.cpp \
307 afflib_pages.cpp afflib_stream.cpp afflib_util.cpp \
308 crypto.cpp \
309 base64.cpp base64.h lzma_glue.cpp s3_glue.h \
310 vnode_aff.cpp vnode_aff.h \
311 vnode_afd.cpp vnode_afd.h \
312 vnode_afm.cpp vnode_afm.h \
313 vnode_ewf.cpp vnode_ewf.h \
314 vnode_raw.cpp vnode_raw.h \
315 vnode_split_raw.cpp vnode_split_raw.h \
316 aftimer.h \
317 utils.cpp utils.h display.cpp
318
319 libafflib_la_SOURCES = $(AFFLIB_SOURCES) $(am__append_1) \
320 $(am__append_3) $(LZMA_SOURCES)
321 QEMU_SOURCES = \
322 vnode_qemu.cpp \
323 vnode_qemu.h \
324 qemu/aes.h \
325 qemu/aff-block-vmdk.h \
326 qemu/block-bochs.c \
327 qemu/block-cloop.c \
328 qemu/block-cow.c \
329 qemu/block-dmg.c \
330 qemu/block-parallels.c \
331 qemu/block-qcow.c \
332 qemu/block-qcow2.c \
333 qemu/block-raw-posix.c \
334 qemu/block-vmdk.c \
335 qemu/block-vpc.c \
336 qemu/block-vvfat.c \
337 qemu/block.c \
338 qemu/block.h \
339 qemu/block_int.h \
340 qemu/bswap.h \
341 qemu/config-host.h \
342 qemu/console.h \
343 qemu/exec-all.h \
344 qemu/osdep.h \
345 qemu/qemu-common.h \
346 qemu/qemu-timer.h \
347 qemu/qemu_glue.c
348
349 @MAYBE_QEMU_TRUE@libafflib_la_CFLAGS = -DQEMU_IMG
350 @MAYBE_QEMU_TRUE@aftest_CFLAGS = -DQEMU_IMG
351 @MAYBE_S3_TRUE@s3_SOURCES = s3.cpp
352 @MAYBE_S3_TRUE@s3_LDADD = libafflib.la
353 @MAYBE_S3_TRUE@s3_LDFLAGS = $(PTHREAD_CFLAGS)
354 EXTRA_DIST =
355 INCLUDES = \
356 -I@top_srcdir@/lzma443/C \
357 -I@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone
358
359 LZMA_SOURCES = \
360 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp \
361 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp \
362 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c \
363 @top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c \
364 @top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c \
365 @top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp \
366 @top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp \
367 @top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp \
368 @top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp \
369 @top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp \
370 @top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp \
371 @top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp \
372 @top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp \
373 @top_srcdir@/lzma443/C/Common/Alloc.cpp \
374 @top_srcdir@/lzma443/C/Common/CommandLineParser.cpp \
375 @top_srcdir@/lzma443/C/Common/CRC.cpp \
376 @top_srcdir@/lzma443/C/Common/String.cpp \
377 @top_srcdir@/lzma443/C/Common/StringConvert.cpp \
378 @top_srcdir@/lzma443/C/Common/StringToInt.cpp \
379 @top_srcdir@/lzma443/C/Common/Vector.cpp
380
381
382 # specify lib_ to force tools to be dynamically linked against the installed library.
383 # specify noinst_LTLIBRARIES to have the tools be statically linked
384 # Unfortunately, when we specify lib_, things don't build. I can't figure it out.
385 lib_LTLIBRARIES = libafflib.la
386 all: all-am
387
388 .SUFFIXES:
389 .SUFFIXES: .c .cpp .lo .o .obj
390 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
391 @for dep in $?; do \
392 case '$(am__configure_deps)' in \
393 *$$dep*) \
394 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
395 && exit 0; \
396 exit 1;; \
397 esac; \
398 done; \
399 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \
400 cd $(top_srcdir) && \
401 $(AUTOMAKE) --gnu lib/Makefile
402 .PRECIOUS: Makefile
403 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
404 @case '$?' in \
405 *config.status*) \
406 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
407 *) \
408 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
409 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
410 esac;
411
412 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
413 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
414
415 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
416 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
417 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
418 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
419 version.h: $(top_builddir)/config.status $(srcdir)/version.h.in
420 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
421 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
422 @$(NORMAL_INSTALL)
423 test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
424 @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
425 if test -f $$p; then \
426 f=$(am__strip_dir) \
427 echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
428 $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
429 else :; fi; \
430 done
431
432 uninstall-libLTLIBRARIES:
433 @$(NORMAL_UNINSTALL)
434 @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
435 p=$(am__strip_dir) \
436 echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
437 $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
438 done
439
440 clean-libLTLIBRARIES:
441 -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
442 @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
443 dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
444 test "$$dir" != "$$p" || dir=.; \
445 echo "rm -f \"$${dir}/so_locations\""; \
446 rm -f "$${dir}/so_locations"; \
447 done
448 libafflib.la: $(libafflib_la_OBJECTS) $(libafflib_la_DEPENDENCIES)
449 $(CXXLINK) -rpath $(libdir) $(libafflib_la_OBJECTS) $(libafflib_la_LIBADD) $(LIBS)
450 install-binPROGRAMS: $(bin_PROGRAMS)
451 @$(NORMAL_INSTALL)
452 test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
453 @list='$(bin_PROGRAMS)'; for p in $$list; do \
454 p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
455 if test -f $$p \
456 || test -f $$p1 \
457 ; then \
458 f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
459 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
460 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
461 else :; fi; \
462 done
463
464 uninstall-binPROGRAMS:
465 @$(NORMAL_UNINSTALL)
466 @list='$(bin_PROGRAMS)'; for p in $$list; do \
467 f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
468 echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
469 rm -f "$(DESTDIR)$(bindir)/$$f"; \
470 done
471
472 clean-binPROGRAMS:
473 @list='$(bin_PROGRAMS)'; for p in $$list; do \
474 f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
475 echo " rm -f $$p $$f"; \
476 rm -f $$p $$f ; \
477 done
478 aftest$(EXEEXT): $(aftest_OBJECTS) $(aftest_DEPENDENCIES)
479 @rm -f aftest$(EXEEXT)
480 $(aftest_LINK) $(aftest_OBJECTS) $(aftest_LDADD) $(LIBS)
481 s3$(EXEEXT): $(s3_OBJECTS) $(s3_DEPENDENCIES)
482 @rm -f s3$(EXEEXT)
483 $(s3_LINK) $(s3_OBJECTS) $(s3_LDADD) $(LIBS)
484
485 mostlyclean-compile:
486 -rm -f *.$(OBJEXT)
487
488 distclean-compile:
489 -rm -f *.tab.c
490
491 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Alloc.Plo@am__quote@
492 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CRC.Plo@am__quote@
493 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CommandLineParser.Plo@am__quote@
494 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InBuffer.Plo@am__quote@
495 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LZInWindow.Plo@am__quote@
496 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LZMADecoder.Plo@am__quote@
497 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LZMAEncoder.Plo@am__quote@
498 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LZOutWindow.Plo@am__quote@
499 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LzmaBench.Plo@am__quote@
500 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LzmaRam.Plo@am__quote@
501 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OutBuffer.Plo@am__quote@
502 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RangeCoderBit.Plo@am__quote@
503 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StreamUtils.Plo@am__quote@
504 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/String.Plo@am__quote@
505 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StringConvert.Plo@am__quote@
506 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StringToInt.Plo@am__quote@
507 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Vector.Plo@am__quote@
508 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aff_db.Plo@am__quote@
509 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aff_toc.Plo@am__quote@
510 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afflib.Plo@am__quote@
511 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afflib_os.Plo@am__quote@
512 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afflib_pages.Plo@am__quote@
513 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afflib_stream.Plo@am__quote@
514 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afflib_util.Plo@am__quote@
515 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aftest.Po@am__quote@
516 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Plo@am__quote@
517 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypto.Plo@am__quote@
518 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/display.Plo@am__quote@
519 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-BranchX86.Plo@am__quote@
520 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-LzmaDecode.Plo@am__quote@
521 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-LzmaRamDecode.Plo@am__quote@
522 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-bochs.Plo@am__quote@
523 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-cloop.Plo@am__quote@
524 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-cow.Plo@am__quote@
525 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-dmg.Plo@am__quote@
526 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-parallels.Plo@am__quote@
527 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-qcow.Plo@am__quote@
528 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-qcow2.Plo@am__quote@
529 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-raw-posix.Plo@am__quote@
530 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-vmdk.Plo@am__quote@
531 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-vpc.Plo@am__quote@
532 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block-vvfat.Plo@am__quote@
533 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-block.Plo@am__quote@
534 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libafflib_la-qemu_glue.Plo@am__quote@
535 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lzma_glue.Plo@am__quote@
536 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s3.Po@am__quote@
537 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/s3_glue.Plo@am__quote@
538 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Plo@am__quote@
539 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnode_afd.Plo@am__quote@
540 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnode_aff.Plo@am__quote@
541 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnode_afm.Plo@am__quote@
542 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnode_ewf.Plo@am__quote@
543 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnode_qemu.Plo@am__quote@
544 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnode_raw.Plo@am__quote@
545 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnode_s3.Plo@am__quote@
546 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnode_split_raw.Plo@am__quote@
547
548 .c.o:
549 @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
550 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
551 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
552 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
553 @am__fastdepCC_FALSE@ $(COMPILE) -c $<
554
555 .c.obj:
556 @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
557 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
558 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
559 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
560 @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
561
562 .c.lo:
563 @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
564 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
565 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
566 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
567 @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
568
569 libafflib_la-block-bochs.lo: qemu/block-bochs.c
570 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-bochs.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-bochs.Tpo -c -o libafflib_la-block-bochs.lo `test -f 'qemu/block-bochs.c' || echo '$(srcdir)/'`qemu/block-bochs.c
571 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-bochs.Tpo $(DEPDIR)/libafflib_la-block-bochs.Plo
572 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-bochs.c' object='libafflib_la-block-bochs.lo' libtool=yes @AMDEPBACKSLASH@
573 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
574 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-bochs.lo `test -f 'qemu/block-bochs.c' || echo '$(srcdir)/'`qemu/block-bochs.c
575
576 libafflib_la-block-cloop.lo: qemu/block-cloop.c
577 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-cloop.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-cloop.Tpo -c -o libafflib_la-block-cloop.lo `test -f 'qemu/block-cloop.c' || echo '$(srcdir)/'`qemu/block-cloop.c
578 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-cloop.Tpo $(DEPDIR)/libafflib_la-block-cloop.Plo
579 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-cloop.c' object='libafflib_la-block-cloop.lo' libtool=yes @AMDEPBACKSLASH@
580 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
581 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-cloop.lo `test -f 'qemu/block-cloop.c' || echo '$(srcdir)/'`qemu/block-cloop.c
582
583 libafflib_la-block-cow.lo: qemu/block-cow.c
584 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-cow.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-cow.Tpo -c -o libafflib_la-block-cow.lo `test -f 'qemu/block-cow.c' || echo '$(srcdir)/'`qemu/block-cow.c
585 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-cow.Tpo $(DEPDIR)/libafflib_la-block-cow.Plo
586 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-cow.c' object='libafflib_la-block-cow.lo' libtool=yes @AMDEPBACKSLASH@
587 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
588 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-cow.lo `test -f 'qemu/block-cow.c' || echo '$(srcdir)/'`qemu/block-cow.c
589
590 libafflib_la-block-dmg.lo: qemu/block-dmg.c
591 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-dmg.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-dmg.Tpo -c -o libafflib_la-block-dmg.lo `test -f 'qemu/block-dmg.c' || echo '$(srcdir)/'`qemu/block-dmg.c
592 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-dmg.Tpo $(DEPDIR)/libafflib_la-block-dmg.Plo
593 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-dmg.c' object='libafflib_la-block-dmg.lo' libtool=yes @AMDEPBACKSLASH@
594 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
595 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-dmg.lo `test -f 'qemu/block-dmg.c' || echo '$(srcdir)/'`qemu/block-dmg.c
596
597 libafflib_la-block-parallels.lo: qemu/block-parallels.c
598 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-parallels.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-parallels.Tpo -c -o libafflib_la-block-parallels.lo `test -f 'qemu/block-parallels.c' || echo '$(srcdir)/'`qemu/block-parallels.c
599 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-parallels.Tpo $(DEPDIR)/libafflib_la-block-parallels.Plo
600 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-parallels.c' object='libafflib_la-block-parallels.lo' libtool=yes @AMDEPBACKSLASH@
601 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
602 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-parallels.lo `test -f 'qemu/block-parallels.c' || echo '$(srcdir)/'`qemu/block-parallels.c
603
604 libafflib_la-block-qcow.lo: qemu/block-qcow.c
605 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-qcow.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-qcow.Tpo -c -o libafflib_la-block-qcow.lo `test -f 'qemu/block-qcow.c' || echo '$(srcdir)/'`qemu/block-qcow.c
606 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-qcow.Tpo $(DEPDIR)/libafflib_la-block-qcow.Plo
607 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-qcow.c' object='libafflib_la-block-qcow.lo' libtool=yes @AMDEPBACKSLASH@
608 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
609 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-qcow.lo `test -f 'qemu/block-qcow.c' || echo '$(srcdir)/'`qemu/block-qcow.c
610
611 libafflib_la-block-qcow2.lo: qemu/block-qcow2.c
612 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-qcow2.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-qcow2.Tpo -c -o libafflib_la-block-qcow2.lo `test -f 'qemu/block-qcow2.c' || echo '$(srcdir)/'`qemu/block-qcow2.c
613 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-qcow2.Tpo $(DEPDIR)/libafflib_la-block-qcow2.Plo
614 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-qcow2.c' object='libafflib_la-block-qcow2.lo' libtool=yes @AMDEPBACKSLASH@
615 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
616 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-qcow2.lo `test -f 'qemu/block-qcow2.c' || echo '$(srcdir)/'`qemu/block-qcow2.c
617
618 libafflib_la-block-raw-posix.lo: qemu/block-raw-posix.c
619 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-raw-posix.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-raw-posix.Tpo -c -o libafflib_la-block-raw-posix.lo `test -f 'qemu/block-raw-posix.c' || echo '$(srcdir)/'`qemu/block-raw-posix.c
620 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-raw-posix.Tpo $(DEPDIR)/libafflib_la-block-raw-posix.Plo
621 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-raw-posix.c' object='libafflib_la-block-raw-posix.lo' libtool=yes @AMDEPBACKSLASH@
622 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
623 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-raw-posix.lo `test -f 'qemu/block-raw-posix.c' || echo '$(srcdir)/'`qemu/block-raw-posix.c
624
625 libafflib_la-block-vmdk.lo: qemu/block-vmdk.c
626 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-vmdk.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-vmdk.Tpo -c -o libafflib_la-block-vmdk.lo `test -f 'qemu/block-vmdk.c' || echo '$(srcdir)/'`qemu/block-vmdk.c
627 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-vmdk.Tpo $(DEPDIR)/libafflib_la-block-vmdk.Plo
628 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-vmdk.c' object='libafflib_la-block-vmdk.lo' libtool=yes @AMDEPBACKSLASH@
629 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
630 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-vmdk.lo `test -f 'qemu/block-vmdk.c' || echo '$(srcdir)/'`qemu/block-vmdk.c
631
632 libafflib_la-block-vpc.lo: qemu/block-vpc.c
633 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-vpc.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-vpc.Tpo -c -o libafflib_la-block-vpc.lo `test -f 'qemu/block-vpc.c' || echo '$(srcdir)/'`qemu/block-vpc.c
634 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-vpc.Tpo $(DEPDIR)/libafflib_la-block-vpc.Plo
635 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-vpc.c' object='libafflib_la-block-vpc.lo' libtool=yes @AMDEPBACKSLASH@
636 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
637 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-vpc.lo `test -f 'qemu/block-vpc.c' || echo '$(srcdir)/'`qemu/block-vpc.c
638
639 libafflib_la-block-vvfat.lo: qemu/block-vvfat.c
640 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block-vvfat.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block-vvfat.Tpo -c -o libafflib_la-block-vvfat.lo `test -f 'qemu/block-vvfat.c' || echo '$(srcdir)/'`qemu/block-vvfat.c
641 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block-vvfat.Tpo $(DEPDIR)/libafflib_la-block-vvfat.Plo
642 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block-vvfat.c' object='libafflib_la-block-vvfat.lo' libtool=yes @AMDEPBACKSLASH@
643 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
644 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block-vvfat.lo `test -f 'qemu/block-vvfat.c' || echo '$(srcdir)/'`qemu/block-vvfat.c
645
646 libafflib_la-block.lo: qemu/block.c
647 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-block.lo -MD -MP -MF $(DEPDIR)/libafflib_la-block.Tpo -c -o libafflib_la-block.lo `test -f 'qemu/block.c' || echo '$(srcdir)/'`qemu/block.c
648 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-block.Tpo $(DEPDIR)/libafflib_la-block.Plo
649 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/block.c' object='libafflib_la-block.lo' libtool=yes @AMDEPBACKSLASH@
650 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
651 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-block.lo `test -f 'qemu/block.c' || echo '$(srcdir)/'`qemu/block.c
652
653 libafflib_la-qemu_glue.lo: qemu/qemu_glue.c
654 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-qemu_glue.lo -MD -MP -MF $(DEPDIR)/libafflib_la-qemu_glue.Tpo -c -o libafflib_la-qemu_glue.lo `test -f 'qemu/qemu_glue.c' || echo '$(srcdir)/'`qemu/qemu_glue.c
655 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-qemu_glue.Tpo $(DEPDIR)/libafflib_la-qemu_glue.Plo
656 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='qemu/qemu_glue.c' object='libafflib_la-qemu_glue.lo' libtool=yes @AMDEPBACKSLASH@
657 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
658 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-qemu_glue.lo `test -f 'qemu/qemu_glue.c' || echo '$(srcdir)/'`qemu/qemu_glue.c
659
660 libafflib_la-LzmaRamDecode.lo: @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c
661 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-LzmaRamDecode.lo -MD -MP -MF $(DEPDIR)/libafflib_la-LzmaRamDecode.Tpo -c -o libafflib_la-LzmaRamDecode.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c
662 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-LzmaRamDecode.Tpo $(DEPDIR)/libafflib_la-LzmaRamDecode.Plo
663 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c' object='libafflib_la-LzmaRamDecode.lo' libtool=yes @AMDEPBACKSLASH@
664 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
665 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-LzmaRamDecode.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c
666
667 libafflib_la-LzmaDecode.lo: @top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c
668 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-LzmaDecode.lo -MD -MP -MF $(DEPDIR)/libafflib_la-LzmaDecode.Tpo -c -o libafflib_la-LzmaDecode.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c
669 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-LzmaDecode.Tpo $(DEPDIR)/libafflib_la-LzmaDecode.Plo
670 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c' object='libafflib_la-LzmaDecode.lo' libtool=yes @AMDEPBACKSLASH@
671 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
672 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-LzmaDecode.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA_C/LzmaDecode.c
673
674 libafflib_la-BranchX86.lo: @top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c
675 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -MT libafflib_la-BranchX86.lo -MD -MP -MF $(DEPDIR)/libafflib_la-BranchX86.Tpo -c -o libafflib_la-BranchX86.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c
676 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libafflib_la-BranchX86.Tpo $(DEPDIR)/libafflib_la-BranchX86.Plo
677 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c' object='libafflib_la-BranchX86.lo' libtool=yes @AMDEPBACKSLASH@
678 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
679 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libafflib_la_CFLAGS) $(CFLAGS) -c -o libafflib_la-BranchX86.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/Branch/BranchX86.c
680
681 .cpp.o:
682 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
683 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
684 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
685 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
686 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
687
688 .cpp.obj:
689 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
690 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
691 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
692 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
693 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
694
695 .cpp.lo:
696 @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
697 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
698 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
699 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
700 @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
701
702 LzmaBench.lo: @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp
703 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT LzmaBench.lo -MD -MP -MF $(DEPDIR)/LzmaBench.Tpo -c -o LzmaBench.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp
704 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/LzmaBench.Tpo $(DEPDIR)/LzmaBench.Plo
705 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp' object='LzmaBench.lo' libtool=yes @AMDEPBACKSLASH@
706 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
707 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o LzmaBench.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaBench.cpp
708
709 LzmaRam.lo: @top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp
710 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT LzmaRam.lo -MD -MP -MF $(DEPDIR)/LzmaRam.Tpo -c -o LzmaRam.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp
711 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/LzmaRam.Tpo $(DEPDIR)/LzmaRam.Plo
712 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp' object='LzmaRam.lo' libtool=yes @AMDEPBACKSLASH@
713 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
714 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o LzmaRam.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA_Alone/LzmaRam.cpp
715
716 LZMADecoder.lo: @top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp
717 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT LZMADecoder.lo -MD -MP -MF $(DEPDIR)/LZMADecoder.Tpo -c -o LZMADecoder.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp
718 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/LZMADecoder.Tpo $(DEPDIR)/LZMADecoder.Plo
719 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp' object='LZMADecoder.lo' libtool=yes @AMDEPBACKSLASH@
720 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
721 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o LZMADecoder.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMADecoder.cpp
722
723 LZMAEncoder.lo: @top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp
724 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT LZMAEncoder.lo -MD -MP -MF $(DEPDIR)/LZMAEncoder.Tpo -c -o LZMAEncoder.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp
725 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/LZMAEncoder.Tpo $(DEPDIR)/LZMAEncoder.Plo
726 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp' object='LZMAEncoder.lo' libtool=yes @AMDEPBACKSLASH@
727 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
728 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o LZMAEncoder.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZMA/LZMAEncoder.cpp
729
730 LZInWindow.lo: @top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp
731 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT LZInWindow.lo -MD -MP -MF $(DEPDIR)/LZInWindow.Tpo -c -o LZInWindow.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp
732 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/LZInWindow.Tpo $(DEPDIR)/LZInWindow.Plo
733 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp' object='LZInWindow.lo' libtool=yes @AMDEPBACKSLASH@
734 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
735 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o LZInWindow.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZInWindow.cpp
736
737 LZOutWindow.lo: @top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp
738 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT LZOutWindow.lo -MD -MP -MF $(DEPDIR)/LZOutWindow.Tpo -c -o LZOutWindow.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp
739 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/LZOutWindow.Tpo $(DEPDIR)/LZOutWindow.Plo
740 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp' object='LZOutWindow.lo' libtool=yes @AMDEPBACKSLASH@
741 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
742 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o LZOutWindow.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/LZ/LZOutWindow.cpp
743
744 RangeCoderBit.lo: @top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp
745 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT RangeCoderBit.lo -MD -MP -MF $(DEPDIR)/RangeCoderBit.Tpo -c -o RangeCoderBit.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp
746 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/RangeCoderBit.Tpo $(DEPDIR)/RangeCoderBit.Plo
747 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp' object='RangeCoderBit.lo' libtool=yes @AMDEPBACKSLASH@
748 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
749 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o RangeCoderBit.lo `test -f '@top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp
750
751 InBuffer.lo: @top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp
752 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT InBuffer.lo -MD -MP -MF $(DEPDIR)/InBuffer.Tpo -c -o InBuffer.lo `test -f '@top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp
753 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/InBuffer.Tpo $(DEPDIR)/InBuffer.Plo
754 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp' object='InBuffer.lo' libtool=yes @AMDEPBACKSLASH@
755 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
756 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o InBuffer.lo `test -f '@top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Common/InBuffer.cpp
757
758 OutBuffer.lo: @top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp
759 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT OutBuffer.lo -MD -MP -MF $(DEPDIR)/OutBuffer.Tpo -c -o OutBuffer.lo `test -f '@top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp
760 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/OutBuffer.Tpo $(DEPDIR)/OutBuffer.Plo
761 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp' object='OutBuffer.lo' libtool=yes @AMDEPBACKSLASH@
762 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
763 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o OutBuffer.lo `test -f '@top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Common/OutBuffer.cpp
764
765 StreamUtils.lo: @top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp
766 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT StreamUtils.lo -MD -MP -MF $(DEPDIR)/StreamUtils.Tpo -c -o StreamUtils.lo `test -f '@top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp
767 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/StreamUtils.Tpo $(DEPDIR)/StreamUtils.Plo
768 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp' object='StreamUtils.lo' libtool=yes @AMDEPBACKSLASH@
769 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
770 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o StreamUtils.lo `test -f '@top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/7zip/Common/StreamUtils.cpp
771
772 Alloc.lo: @top_srcdir@/lzma443/C/Common/Alloc.cpp
773 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Alloc.lo -MD -MP -MF $(DEPDIR)/Alloc.Tpo -c -o Alloc.lo `test -f '@top_srcdir@/lzma443/C/Common/Alloc.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/Alloc.cpp
774 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/Alloc.Tpo $(DEPDIR)/Alloc.Plo
775 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/Common/Alloc.cpp' object='Alloc.lo' libtool=yes @AMDEPBACKSLASH@
776 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
777 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Alloc.lo `test -f '@top_srcdir@/lzma443/C/Common/Alloc.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/Alloc.cpp
778
779 CommandLineParser.lo: @top_srcdir@/lzma443/C/Common/CommandLineParser.cpp
780 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CommandLineParser.lo -MD -MP -MF $(DEPDIR)/CommandLineParser.Tpo -c -o CommandLineParser.lo `test -f '@top_srcdir@/lzma443/C/Common/CommandLineParser.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/CommandLineParser.cpp
781 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/CommandLineParser.Tpo $(DEPDIR)/CommandLineParser.Plo
782 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/Common/CommandLineParser.cpp' object='CommandLineParser.lo' libtool=yes @AMDEPBACKSLASH@
783 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
784 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CommandLineParser.lo `test -f '@top_srcdir@/lzma443/C/Common/CommandLineParser.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/CommandLineParser.cpp
785
786 CRC.lo: @top_srcdir@/lzma443/C/Common/CRC.cpp
787 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CRC.lo -MD -MP -MF $(DEPDIR)/CRC.Tpo -c -o CRC.lo `test -f '@top_srcdir@/lzma443/C/Common/CRC.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/CRC.cpp
788 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/CRC.Tpo $(DEPDIR)/CRC.Plo
789 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/Common/CRC.cpp' object='CRC.lo' libtool=yes @AMDEPBACKSLASH@
790 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
791 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CRC.lo `test -f '@top_srcdir@/lzma443/C/Common/CRC.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/CRC.cpp
792
793 String.lo: @top_srcdir@/lzma443/C/Common/String.cpp
794 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT String.lo -MD -MP -MF $(DEPDIR)/String.Tpo -c -o String.lo `test -f '@top_srcdir@/lzma443/C/Common/String.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/String.cpp
795 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/String.Tpo $(DEPDIR)/String.Plo
796 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/Common/String.cpp' object='String.lo' libtool=yes @AMDEPBACKSLASH@
797 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
798 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o String.lo `test -f '@top_srcdir@/lzma443/C/Common/String.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/String.cpp
799
800 StringConvert.lo: @top_srcdir@/lzma443/C/Common/StringConvert.cpp
801 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT StringConvert.lo -MD -MP -MF $(DEPDIR)/StringConvert.Tpo -c -o StringConvert.lo `test -f '@top_srcdir@/lzma443/C/Common/StringConvert.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/StringConvert.cpp
802 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/StringConvert.Tpo $(DEPDIR)/StringConvert.Plo
803 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/Common/StringConvert.cpp' object='StringConvert.lo' libtool=yes @AMDEPBACKSLASH@
804 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
805 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o StringConvert.lo `test -f '@top_srcdir@/lzma443/C/Common/StringConvert.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/StringConvert.cpp
806
807 StringToInt.lo: @top_srcdir@/lzma443/C/Common/StringToInt.cpp
808 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT StringToInt.lo -MD -MP -MF $(DEPDIR)/StringToInt.Tpo -c -o StringToInt.lo `test -f '@top_srcdir@/lzma443/C/Common/StringToInt.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/StringToInt.cpp
809 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/StringToInt.Tpo $(DEPDIR)/StringToInt.Plo
810 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/Common/StringToInt.cpp' object='StringToInt.lo' libtool=yes @AMDEPBACKSLASH@
811 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
812 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o StringToInt.lo `test -f '@top_srcdir@/lzma443/C/Common/StringToInt.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/StringToInt.cpp
813
814 Vector.lo: @top_srcdir@/lzma443/C/Common/Vector.cpp
815 @am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT Vector.lo -MD -MP -MF $(DEPDIR)/Vector.Tpo -c -o Vector.lo `test -f '@top_srcdir@/lzma443/C/Common/Vector.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/Vector.cpp
816 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/Vector.Tpo $(DEPDIR)/Vector.Plo
817 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='@top_srcdir@/lzma443/C/Common/Vector.cpp' object='Vector.lo' libtool=yes @AMDEPBACKSLASH@
818 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
819 @am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o Vector.lo `test -f '@top_srcdir@/lzma443/C/Common/Vector.cpp' || echo '$(srcdir)/'`@top_srcdir@/lzma443/C/Common/Vector.cpp
820
821 mostlyclean-libtool:
822 -rm -f *.lo
823
824 clean-libtool:
825 -rm -rf .libs _libs
826
827 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
828 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
829 unique=`for i in $$list; do \
830 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
831 done | \
832 $(AWK) ' { files[$$0] = 1; } \
833 END { for (i in files) print i; }'`; \
834 mkid -fID $$unique
835 tags: TAGS
836
837 TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
838 $(TAGS_FILES) $(LISP)
839 tags=; \
840 here=`pwd`; \
841 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
842 unique=`for i in $$list; do \
843 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
844 done | \
845 $(AWK) ' { files[$$0] = 1; } \
846 END { for (i in files) print i; }'`; \
847 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
848 test -n "$$unique" || unique=$$empty_fix; \
849 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
850 $$tags $$unique; \
851 fi
852 ctags: CTAGS
853 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
854 $(TAGS_FILES) $(LISP)
855 tags=; \
856 here=`pwd`; \
857 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
858 unique=`for i in $$list; do \
859 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
860 done | \
861 $(AWK) ' { files[$$0] = 1; } \
862 END { for (i in files) print i; }'`; \
863 test -z "$(CTAGS_ARGS)$$tags$$unique" \
864 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
865 $$tags $$unique
866
867 GTAGS:
868 here=`$(am__cd) $(top_builddir) && pwd` \
869 && cd $(top_srcdir) \
870 && gtags -i $(GTAGS_ARGS) $$here
871
872 distclean-tags:
873 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
874
875 check-TESTS: $(TESTS)
876 @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
877 srcdir=$(srcdir); export srcdir; \
878 list=' $(TESTS) '; \
879 if test -n "$$list"; then \
880 for tst in $$list; do \
881 if test -f ./$$tst; then dir=./; \
882 elif test -f $$tst; then dir=; \
883 else dir="$(srcdir)/"; fi; \
884 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
885 all=`expr $$all + 1`; \
886 case " $(XFAIL_TESTS) " in \
887 *$$ws$$tst$$ws*) \
888 xpass=`expr $$xpass + 1`; \
889 failed=`expr $$failed + 1`; \
890 echo "XPASS: $$tst"; \
891 ;; \
892 *) \
893 echo "PASS: $$tst"; \
894 ;; \
895 esac; \
896 elif test $$? -ne 77; then \
897 all=`expr $$all + 1`; \
898 case " $(XFAIL_TESTS) " in \
899 *$$ws$$tst$$ws*) \
900 xfail=`expr $$xfail + 1`; \
901 echo "XFAIL: $$tst"; \
902 ;; \
903 *) \
904 failed=`expr $$failed + 1`; \
905 echo "FAIL: $$tst"; \
906 ;; \
907 esac; \
908 else \
909 skip=`expr $$skip + 1`; \
910 echo "SKIP: $$tst"; \
911 fi; \
912 done; \
913 if test "$$failed" -eq 0; then \
914 if test "$$xfail" -eq 0; then \
915 banner="All $$all tests passed"; \
916 else \
917 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
918 fi; \
919 else \
920 if test "$$xpass" -eq 0; then \
921 banner="$$failed of $$all tests failed"; \
922 else \
923 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
924 fi; \
925 fi; \
926 dashes="$$banner"; \
927 skipped=""; \
928 if test "$$skip" -ne 0; then \
929 skipped="($$skip tests were not run)"; \
930 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
931 dashes="$$skipped"; \
932 fi; \
933 report=""; \
934 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
935 report="Please report to $(PACKAGE_BUGREPORT)"; \
936 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
937 dashes="$$report"; \
938 fi; \
939 dashes=`echo "$$dashes" | sed s/./=/g`; \
940 echo "$$dashes"; \
941 echo "$$banner"; \
942 test -z "$$skipped" || echo "$$skipped"; \
943 test -z "$$report" || echo "$$report"; \
944 echo "$$dashes"; \
945 test "$$failed" -eq 0; \
946 else :; fi
947
948 distdir: $(DISTFILES)
949 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
950 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
951 list='$(DISTFILES)'; \
952 dist_files=`for file in $$list; do echo $$file; done | \
953 sed -e "s|^$$srcdirstrip/||;t" \
954 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
955 case $$dist_files in \
956 */*) $(MKDIR_P) `echo "$$dist_files" | \
957 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
958 sort -u` ;; \
959 esac; \
960 for file in $$dist_files; do \
961 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
962 if test -d $$d/$$file; then \
963 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
964 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
965 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
966 fi; \
967 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
968 else \
969 test -f $(distdir)/$$file \
970 || cp -p $$d/$$file $(distdir)/$$file \
971 || exit 1; \
972 fi; \
973 done
974 check-am: all-am
975 $(MAKE) $(AM_MAKEFLAGS) check-TESTS
976 check: check-am
977 all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
978 install-binPROGRAMS: install-libLTLIBRARIES
979
980 installdirs:
981 for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)"; do \
982 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
983 done
984 install: install-am
985 install-exec: install-exec-am
986 install-data: install-data-am
987 uninstall: uninstall-am
988
989 install-am: all-am
990 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
991
992 installcheck: installcheck-am
993 install-strip:
994 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
995 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
996 `test -z '$(STRIP)' || \
997 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
998 mostlyclean-generic:
999
1000 clean-generic:
1001
1002 distclean-generic:
1003 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
1004
1005 maintainer-clean-generic:
1006 @echo "This command is intended for maintainers to use"
1007 @echo "it deletes files that may require special tools to rebuild."
1008 clean: clean-am
1009
1010 clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
1011 clean-libtool mostlyclean-am
1012
1013 distclean: distclean-am
1014 -rm -rf ./$(DEPDIR)
1015 -rm -f Makefile
1016 distclean-am: clean-am distclean-compile distclean-generic \
1017 distclean-tags
1018
1019 dvi: dvi-am
1020
1021 dvi-am:
1022
1023 html: html-am
1024
1025 info: info-am
1026
1027 info-am:
1028
1029 install-data-am:
1030
1031 install-dvi: install-dvi-am
1032
1033 install-exec-am: install-binPROGRAMS install-libLTLIBRARIES
1034 @$(NORMAL_INSTALL)
1035 $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
1036
1037 install-html: install-html-am
1038
1039 install-info: install-info-am
1040
1041 install-man:
1042
1043 install-pdf: install-pdf-am
1044
1045 install-ps: install-ps-am
1046
1047 installcheck-am:
1048
1049 maintainer-clean: maintainer-clean-am
1050 -rm -rf ./$(DEPDIR)
1051 -rm -f Makefile
1052 maintainer-clean-am: distclean-am maintainer-clean-generic
1053
1054 mostlyclean: mostlyclean-am
1055
1056 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
1057 mostlyclean-libtool
1058
1059 pdf: pdf-am
1060
1061 pdf-am:
1062
1063 ps: ps-am
1064
1065 ps-am:
1066
1067 uninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES
1068
1069 .MAKE: install-am install-exec-am install-strip
1070
1071 .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
1072 clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
1073 clean-libtool ctags distclean distclean-compile \
1074 distclean-generic distclean-libtool distclean-tags distdir dvi \
1075 dvi-am html html-am info info-am install install-am \
1076 install-binPROGRAMS install-data install-data-am install-dvi \
1077 install-dvi-am install-exec install-exec-am install-exec-hook \
1078 install-html install-html-am install-info install-info-am \
1079 install-libLTLIBRARIES install-man install-pdf install-pdf-am \
1080 install-ps install-ps-am install-strip installcheck \
1081 installcheck-am installdirs maintainer-clean \
1082 maintainer-clean-generic mostlyclean mostlyclean-compile \
1083 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
1084 tags uninstall uninstall-am uninstall-binPROGRAMS \
1085 uninstall-libLTLIBRARIES
1086
1087
1088 install-exec-hook:
1089 @if [ -r $(DESTDIR)/etc/ld.so.conf ] ; then \
1090 echo "*************************************************" ;\
1091 echo "*** Checking shared library config for $(libdir) " ;\
1092 if grep ^$(libdir) $(DESTDIR)/etc/ld.so.conf >/dev/null ; \
1093 then echo $(libdir) already installed ; \
1094 else echo installing $(libdir) in $(DESTDIR)/etc/ld.so.conf ; \
1095 echo $(libdir) >> $(DESTDIR)/etc/ld.so.conf ; \
1096 PATH=$(PATH):/sbin; \
1097 ldconfig; \
1098 fi ; \
1099 echo "*************************************************" ;\
1100 fi
1101 # Tell versions [3.59,3.63) of GNU make to not export all variables.
1102 # Otherwise a system limit (for SysV at least) may be exceeded.
1103 .NOEXPORT:
0 /*
1 * afflib_db.cpp:
2 *
3 * Functions for the manipulation of the AFF database.
4 */
5
6
7 #include "affconfig.h"
8 #include "afflib.h"
9 #include "afflib_i.h"
10 #include "aff_db.h"
11
12
13 /****************************************************************
14 *** Low-level functions
15 ****************************************************************/
16
17 /****************************************************************
18 *** Probe Functions
19 ****************************************************************/
20
21 int af_probe_next_seg(AFFILE *af,
22 char *segname,
23 size_t segname_len,
24 unsigned long *arg_, // optional arg
25 size_t *datasize_, // optional get datasize
26 size_t *segsize_, // optional get size of entire segment
27 int do_rewind) // optional rewind af->aseg, otherwise leave at start of segment data
28 {
29 if(!af->aseg)(*af->error_reporter)("af_probe_next_segment only works with aff files");
30
31 struct af_segment_head segh;
32 memset(&segh,0,sizeof(segh));
33
34 uint64_t start = ftello(af->aseg);
35 #ifdef __BORLANDC__
36 fseeko(af->aseg, start, SEEK_SET) ; // Windows is dumb :-(
37 #endif
38
39 if(fread(&segh,sizeof(segh),1,af->aseg)!=1){
40 return AF_ERROR_EOF;
41 }
42 if(strcmp(segh.magic,AF_SEGHEAD)!=0){
43 snprintf(af->error_str,sizeof(af->error_str),"afflib: segh is corrupt at %" PRIu64,start);
44 return AF_ERROR_SEGH;
45 }
46
47 unsigned long name_len = ntohl(segh.name_len);
48 unsigned long datasize = ntohl(segh.data_len);
49 if(name_len>AF_MAX_NAME_LEN){
50 snprintf(af->error_str,sizeof(af->error_str),"afflib: name_len=%lu (an outrageous value)",name_len);
51 return AF_ERROR_NAME;
52 }
53
54 if(name_len+1 > segname_len){
55 fseeko(af->aseg,start,SEEK_SET); // rewind to start
56 return -2;
57 }
58
59 if(fread(segname,1,name_len,af->aseg)!=name_len){
60 fseeko(af->aseg,start,SEEK_SET); // rewind
61 return -1;
62 }
63 segname[name_len] = 0;
64
65 if(do_rewind) fseeko(af->aseg,start,SEEK_SET); // rewind
66
67 unsigned long segsize = sizeof(struct af_segment_head)
68 + sizeof(struct af_segment_tail)
69 + name_len + datasize;
70
71 if(arg_) *arg_ = ntohl(segh.flag);
72 if(datasize_) *datasize_ = datasize;
73 if(segsize_) *segsize_ = segsize;
74
75 #ifdef DEBUG
76 fprintf(stderr,"af_probe_next_seg(segname=%s datasize=%d segsize=%d) do_rewind=%d\n",
77 segname,datasize,segsize,do_rewind);
78 #endif
79 return 0;
80 }
81
82 /* af_backspace:
83 * moves back one segment in the aff file.
84 * Returns 0 if success, -1 if we can't back up further.
85 */
86 int af_backspace(AFFILE *af)
87 {
88 struct af_segment_tail segt;
89
90 uint64_t start = ftello(af->aseg);
91
92 if(start==sizeof(AF_HEADER) || start<sizeof(segt)) return -1; // can't backspace further
93
94 uint64_t pos_tail = start - sizeof(segt); // backspace to read the tail
95 fseeko(af->aseg,pos_tail,SEEK_SET);
96 if(fread(&segt,sizeof(segt),1,af->aseg)!=1){
97 fseeko(af->aseg,start,SEEK_SET); // put it back
98 return -1; // can't read segt?
99 }
100 /* Verify that this is a segment tail. if it isn't, put the file pointer back and return */
101 if(memcmp(segt.magic,AF_SEGTAIL,sizeof(AF_SEGTAIL))!=0){
102 fseeko(af->aseg,start,SEEK_SET);
103 return -1;
104 }
105
106 /* Now I know how long the segment was. Compute where it started */
107 uint64_t seg_start = start - ntohl(segt.segment_len);
108 fseeko(af->aseg,seg_start,SEEK_SET);
109 return 0;
110 }
111
112
113
114 /* find the given segment and return 0 if found.
115 * Leave the file pointer positioned at the start of the segment.
116 * Return -1 if segment is not found, and leave pointer at the end
117 */
118 int aff_find_seg(AFFILE *af,const char *segname,
119 unsigned long *arg,
120 size_t *datasize,
121 size_t *segsize)
122 {
123 char next_segment_name[AF_MAX_NAME_LEN];
124 size_t next_segsize = 0;
125 size_t next_datasize = 0;
126 unsigned long next_arg;
127
128 /* Try to use the TOC to find the segment in question */
129 struct aff_toc_mem *adm = aff_toc(af,segname);
130 if(adm){
131 if(datasize==0 && segsize==0 && arg==0){
132 /* User was just probing to see if it was present. And it is! */
133 return 0;
134 }
135 fseeko(af->aseg,adm->offset,SEEK_SET);
136 }
137 else {
138 af_rewind_seg(af);
139 }
140 while(af_probe_next_seg(af,next_segment_name,sizeof(next_segment_name),
141 &next_arg,&next_datasize,&next_segsize,1)==0){
142 if(strcmp(next_segment_name,segname)==0){ // found the segment!
143 if(datasize) *datasize = next_datasize;
144 if(segsize) *segsize = next_segsize;
145 if(arg) *arg = next_arg;
146 return 0; // return the info
147 }
148 fseeko(af->aseg,next_segsize,SEEK_CUR); // skip the segment
149 }
150 return -1; // couldn't find segment
151 }
152
153 int af_get_segq(AFFILE *af,const char *name,int64_t *aff_quad)
154 {
155 unsigned char buf[8];
156 size_t bufsize = sizeof(buf);
157
158 if(af_get_seg(af,name,0,(unsigned char *)&buf,&bufsize)){
159 return -1; // couldn't get it...
160 }
161 if(bufsize!=sizeof(struct aff_quad)){ // make sure size is good.
162 return -1;
163 }
164
165 *aff_quad = af_decode_q(buf);
166 return 0;
167 }
168
169
170 /* af_update_segq:
171 * Update the named aff_quad-byte value.
172 */
173
174
175 int af_update_segq(AFFILE *af, const char *name, int64_t value)
176 {
177 struct aff_quad q;
178 q.low = htonl((unsigned long)(value & 0xffffffff));
179 q.high = htonl((unsigned long)(value >> 32));
180 return af_update_seg(af,name,AF_SEG_QUADWORD,(const u_char *)&q,8);
181 }
182
183
0 int aff_find_seg(AFFILE *af,const char *segname, unsigned long *arg,size_t *datasize, size_t *segsize);
0 /*
1 * afflib_dir.cpp:
2 *
3 * Functions for the manipulation of the AFF directories
4 */
5
6 #include "affconfig.h"
7 #include "afflib.h"
8 #include "afflib_i.h"
9
10 int aff_toc_free(AFFILE *af)
11 {
12 if(af->toc){
13 for(int i=0;i<af->toc_count;i++){
14 if(af->toc[i].name) free(af->toc[i].name);
15 }
16 free(af->toc);
17 af->toc = 0;
18 af->toc_count = 0;
19 }
20 return 0;
21 }
22
23
24 void aff_toc_print(AFFILE *af)
25 {
26 printf("AF DIRECTORY:\n");
27 for(int i=0;i<af->toc_count;i++){
28 if(af->toc[i].name){
29 printf("%-32s @%"I64u" len: %"I64u" \n",af->toc[i].name, af->toc[i].offset,af->toc[i].segment_len);
30 }
31 }
32 }
33
34 #if 0
35 static int toc_sort(const void *a_,const void *b_)
36 {
37 const aff_toc_mem *a = (const aff_toc_mem *)a_;
38 const aff_toc_mem *b = (const aff_toc_mem *)b_;
39 if(a->offset < b->offset) return -1;
40 if(a->offset > b->offset) return 1;
41 return 0;
42 }
43 #endif
44
45 static int aff_toc_append(AFFILE *af,const char *segname,uint64_t offset,uint64_t datalen)
46 {
47 af->toc = (aff_toc_mem *)realloc(af->toc,sizeof(*af->toc)*(af->toc_count+1));
48 if(af->toc==0){
49 (*af->error_reporter)("realloc() failed in aff_toc_append. toc_count=%d\n",af->toc_count);
50 return -1;
51 }
52 af->toc[af->toc_count].offset = offset;
53 af->toc[af->toc_count].name = strdup(segname); // make a copy of the string
54 af->toc[af->toc_count].segment_len = aff_segment_overhead(segname)+datalen;
55 af->toc_count++;
56 return 0;
57 }
58
59 /* Find an empty slot in the TOC in which to put the TOC.
60 * Otherwise add it to the end.
61 */
62 void aff_toc_update(AFFILE *af,const char *segname,uint64_t offset,uint64_t datalen)
63 {
64 for(int i=0;i<af->toc_count;i++){
65 if(af->toc[i].name==0 || strcmp(af->toc[i].name,segname)==0){
66 if(af->toc[i].name==0){ // if name was empty, copy it over
67 af->toc[i].name = strdup(segname);
68 }
69 af->toc[i].offset = offset;
70 af->toc[i].segment_len = aff_segment_overhead(segname)+datalen;
71 return;
72 }
73 }
74 aff_toc_append(af,segname,offset,datalen); /* Need to append it to the directory */
75 }
76
77 /*
78 * aff_toc_build:
79 * Build the directory by reading the existing file.
80 * Notice that we know that we can simply append.
81 */
82 int aff_toc_build(AFFILE *af) // build the dir if we couldn't find it
83 {
84 aff_toc_free(af); // clear the old one
85 af_rewind_seg(af); // start at the beginning
86
87 // note: was malloc(0), but that causes problems under Borland
88 af->toc = (aff_toc_mem *)malloc(sizeof(aff_toc_mem));
89 while(1){
90 char segname[AF_MAX_NAME_LEN];
91 size_t segname_len=sizeof(segname);
92 off_t pos = ftello(af->aseg);
93 size_t datalen=0;
94
95 int r = af_get_next_seg(af,segname,segname_len,0,0,&datalen);
96 switch(r){
97 case AF_ERROR_NO_ERROR:
98 if(aff_toc_append(af,segname,pos,datalen)){
99 return -1; // malloc error?
100 }
101 break;
102 case AF_ERROR_EOF:
103 return 0; // end of file; no errors
104 default: /* unknown error */
105 fseeko(af->aseg,pos,SEEK_SET); // go back
106 return r; // send up the error code
107 }
108 }
109 return AF_ERROR_NO_ERROR;
110 }
111
112 /*
113 * return the named entry in the directory
114 */
115
116 struct aff_toc_mem *aff_toc(AFFILE *af,const char *segname)
117 {
118 for(int i=0;i<af->toc_count;i++){
119 if(af->toc[i].name && strcmp(af->toc[i].name,segname)==0) return &af->toc[i];
120 }
121 return 0;
122 }
123
124 /* Delete something from the directory, but don't bother reallocating.*/
125 int aff_toc_del(AFFILE *af,const char *segname)
126 {
127 for(int i=0;i<af->toc_count;i++){
128 if(af->toc[i].name && strcmp(af->toc[i].name,segname)==0){
129 free(af->toc[i].name);
130 af->toc[i].name=0;
131 return 0; // should only be in TOC once
132 }
133 }
134 return -1;
135 }
136
0 /*
1 * Copyright (c) 2005, 2006, 2007
2 * Simson L. Garfinkel and Basis Technology, Inc.
3 * All rights reserved.
4 *
5 * This code is derrived from software contributed by
6 * Simson L. Garfinkel
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Simson L. Garfinkel
19 * and Basis Technology Corp.
20 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
21 * contributors to this program may be used to endorse or promote
22 * products derived from this software without specific prior written
23 * permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
26 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
27 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
30 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
33 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40 #include "affconfig.h"
41 #include "afflib.h"
42 #include "afflib_i.h"
43
44 #ifdef HAVE_OPENSSL_PEM_H
45 #include <openssl/pem.h>
46 #include <openssl/bio.h>
47 #endif
48
49 #include "vnode_raw.h"
50 #include "vnode_split_raw.h"
51 #include "vnode_afm.h"
52 #include "vnode_aff.h"
53 #include "vnode_afd.h"
54 #include "vnode_ewf.h"
55
56 #ifdef USE_QEMU
57 #include "vnode_qemu.h"
58 #endif
59
60 #ifdef USE_S3
61 #include "vnode_s3.h"
62 #endif
63
64 #ifdef HAVE_FCNTL_H
65 #include <fcntl.h>
66 #endif
67
68 #include <assert.h>
69 #include <errno.h>
70
71
72 // vnode implementations.
73 // order matters
74 struct af_vnode *af_vnode_array[] = {
75 #ifdef USE_S3
76 &vnode_s3, // must be first for s3:// interpertation
77 #endif
78 &vnode_afd,
79 &vnode_afm, // must be before aff
80 &vnode_aff,
81 #ifdef USE_LIBEWF
82 &vnode_ewf, // libewf
83 #endif
84 #ifdef USE_QEMU
85 &vnode_vmdk,
86 &vnode_dmg,
87 #endif
88 #ifdef USE_SPARSEIMAGE
89 &vnode_sparseimage,
90 #endif
91 &vnode_split_raw, // must be before raw
92 &vnode_raw, // greedy; must be last
93 0};
94
95
96
97 /****************************************************************
98 *** Support functions that don't use the "af"
99 ****************************************************************/
100
101 static int aff_initialized = 0;
102 int af_cache_debug = 0;
103 FILE *af_trace = 0;
104
105 void af_initialize()
106 {
107 if(aff_initialized) return;
108
109 /* make sure things were compiled properly */
110 assert(sizeof(struct af_head)==8);
111 assert(sizeof(struct af_segment_head)==16);
112 assert(sizeof(struct af_segment_tail)==8);
113 assert(sizeof(struct affkey)==AFFKEY_SIZE);
114
115 /* Make sure OpenSSL is working */
116 OpenSSL_add_all_algorithms();
117
118 const char *val = getenv(AFFLIB_CACHE_DEBUG);
119 if(val) af_cache_debug = atoi(val);
120
121 val = getenv(AFFLIB_TRACEFILE);
122 if(val){
123 af_trace = fopen(val,"wa");
124 fprintf(af_trace,"============================\n");
125 fprintf(af_trace,"AFFLIB trace started\n");
126 setvbuf(af_trace,0,_IOLBF,0);
127 }
128 aff_initialized = 1;
129 }
130
131
132 /****************************************************************
133 *** Other functions that don't use the af
134 ****************************************************************/
135
136
137 const char *af_version(void)
138 {
139 return PACKAGE_VERSION;
140 }
141
142
143 /* Return 1 if a file is probably an AFF file
144 * 0 if it is not.
145 * -1 if failure.
146 */
147
148 int af_identify_file_type(const char *filename,int exists)
149 {
150 for(int i = 0; af_vnode_array[i]; i++){
151 if( (*af_vnode_array[i]->identify)(filename,exists)==1 ){
152 return (af_vnode_array[i]->type);
153 }
154 }
155 return exists ? AF_IDENTIFY_NOEXIST : AF_IDENTIFY_ERR;
156 }
157
158 const char *af_identify_file_name(const char *filename,int exists)
159 {
160 for(int i = 0; af_vnode_array[i]; i++){
161 if( (*af_vnode_array[i]->identify)(filename,exists)==1 ){
162 return (af_vnode_array[i]->name);
163 }
164 }
165 return 0;
166 }
167
168 char af_error_str[64]; // in case af_perror is called
169 void af_perror(const char *str)
170 {
171 #ifdef HAVE_GETPROGNAME
172 fprintf(stderr,"%s: %s: %s\n",getprogname(),str,af_error_str);
173 #else
174 fprintf(stderr,"%s: %s\n",str,af_error_str);
175 #endif
176 }
177
178
179 /* Return the 'extension' of str.
180 * af_str("filename.aff") = ".aff"
181 */
182 const char *af_ext(const char *str)
183 {
184 int len = strlen(str);
185 if(len==0) return str; // no extension
186 for(int i=len-1;i>0;i--){
187 if(str[i]=='.') return &str[i+1];
188 }
189 return str;
190 }
191
192 int af_ext_is(const char *filename,const char *ext)
193 {
194 return strcasecmp(af_ext(filename),ext)==0;
195 }
196
197 static int ends_with(const char *buf,const char *with)
198 {
199 if(buf && with){
200 size_t buflen = strlen(buf);
201 size_t withlen = strlen(with);
202 if(buflen>withlen && strcmp(buf+buflen-withlen,with)==0) return 1;
203 }
204 return 0;
205 }
206
207 /****************************************************************
208 *** GET FUNCTIONS
209 ****************************************************************/
210
211 /****************************************************************
212 *** Probe the next segment:
213 *** Return its name and argument, but don't advance the pointer....
214 *** Returns 0 on success, -1 on end of file or other error.
215 ****************************************************************/
216
217 /****************************************************************
218 *** AFF creation functions
219 ****************************************************************/
220
221 static void af_deallocate(AFFILE *af)
222 {
223 /* Clear out the cache */
224 if(af->pbcache){
225 for(int i=0;i<af->num_pbufs;i++){
226 struct aff_pagebuf *p = &af->pbcache[i];
227 if(p->pagebuf){
228 memset(p->pagebuf,0,af->image_pagesize); // clean object reuse
229 free(p->pagebuf);
230 }
231 }
232 free(af->pbcache);
233 }
234 #ifdef HAVE_PTHREAD
235 AF_UNLOCK(af);
236 pthread_rwlock_destroy(&af->rwlock);
237 #endif
238 if(af->protocol) free(af->protocol);
239 if(af->fname) free(af->fname);
240 if(af->username) free(af->username);
241 if(af->password) free(af->password);
242 if(af->hostname) free(af->hostname);
243 if(af->badflag) free(af->badflag);
244 if(af->toc) free(af->toc);
245 if(af->crypto) af_crypto_deallocate(af);
246 if(af->vni_cache) free(af->vni_cache);
247 memset(af,0,sizeof(*af)); // clean object reuse
248 free(af);
249 }
250
251 static void af_sanitize_password(AFFILE *af)
252 {
253 for(char *cc = af->password;*cc;cc++){
254 *cc = 'X';
255 }
256 free(af->password);
257 af->password = 0;
258 }
259
260
261 /* af_open_with is the real open routine.
262 * It opens a particular file with a particular vnode implementation.
263 */
264 AFFILE *af_open_with(const char *url,int flags,int mode, struct af_vnode *v)
265 {
266 /* Alloate the space for the AFFILE structure */
267 AFFILE *af = (AFFILE *)calloc(sizeof(AFFILE),1);
268 af_crypto_allocate(af);
269 #ifdef HAVE_PTHREAD
270 pthread_rwlock_init(&af->rwlock);
271 AF_WRLOCK(af);
272 #endif
273 af->v = v;
274 af->version = 2;
275 af->openflags = flags | O_BINARY; // make sure that we ask for binray
276 af->openmode = mode;
277 af->image_sectorsize = 512; // default size
278 af->error_reporter = warnx;
279 af->badflag = (unsigned char *)malloc(af->image_sectorsize);
280
281 /* Decode URL */
282 af_parse_url(url,&af->protocol,&af->hostname,&af->username,&af->password,
283 &af->port,&af->fname);
284
285 /* A null passphrase is the same as no passphrase*/
286 if(af->password && af->password[0]==0){
287 free(af->password);
288 af->password=0;
289 }
290 /* If no password was set and the AFFLIB_PASSPHRASE environment variable is set, use that */
291 if(af->password==0 && getenv(AFFLIB_PASSPHRASE)){
292 af->password = strdup(getenv(AFFLIB_PASSPHRASE));
293 }
294 /* If no password is set and its in a file, get it there */
295 if(af->password==0 && getenv(AFFLIB_PASSPHRASE_FILE)){
296 int fd = open(AFFLIB_PASSPHRASE_FILE,O_RDONLY,0);
297 if(fd>0){
298 struct stat sb;
299 if(fstat(fd,&sb)==0){
300 af->password = (char *)malloc(sb.st_size);
301 int r = read(fd,af->password,sb.st_size);
302 if(r!=sb.st_size){
303 free(af->password);
304 af->password=0; // couldn't read it
305 }
306 close(fd);
307 }
308 }
309 }
310 /* If no password is set and its in a file, get it there */
311 if(af->password==0 && getenv(AFFLIB_PASSPHRASE_FD)){
312 int fd = atoi(AFFLIB_PASSPHRASE_FD);
313 af->password = (char *)malloc(1);
314 int buflen = 0;
315 int rlen = 0;
316 char mybuf[1024];
317
318 while((rlen=read(fd,mybuf,sizeof(mybuf)))>0){
319 af->password = (char *)realloc(af->password,buflen+rlen+1);
320 memcpy(af->password+buflen,mybuf,rlen);
321 buflen += rlen;
322 af->password[buflen] = '\000';
323 }
324 }
325
326 /* TK: If no password was set and the AFFLIB_ASK_PASS is set, ask for a passphrase */
327
328 /* Note things for hard files */
329 af->exists = (access(af->fname,R_OK) == 0); // does the file exist?
330
331 /* Right now just set up the cache by hand */
332 const char *cache_pages = getenv(AFFLIB_CACHE_PAGES);
333 if(cache_pages) af->num_pbufs = atoi(cache_pages);
334 if(af->num_pbufs<1) af->num_pbufs = AFFLIB_CACHE_PAGES_DEFAULT; // default valuen
335
336 af->pbcache = (struct aff_pagebuf *)calloc(af->num_pbufs,sizeof(struct aff_pagebuf));
337 if(af->pbcache==0){ // if can't allocate the full amount
338 af->num_pbufs = 2; // try a significantly smaller cache
339 af->pbcache = (struct aff_pagebuf *)calloc(af->num_pbufs,sizeof(struct aff_pagebuf));
340 }
341
342 if(flags & AF_HALF_OPEN) return af; // for low-level tools
343
344 /* Try opening it! */
345 if((*af->v->open)(af)){
346 strlcpy(af_error_str,af->error_str,sizeof(af_error_str)); // make a copy of the error string
347 af_deallocate(af);
348 return 0;
349 }
350
351 /* If there is no AFFKEY and the file is read-only, don't use a password */
352 if(af->password && (af_get_seg(af,AF_AFFKEY,0,0,0)!=0) && ((af->openflags & O_ACCMODE)==O_RDONLY)){
353 af_sanitize_password(af);
354 }
355
356 /* Set up the encryption if requested and if this support metadata */
357 if(AF_SEALING_VNODE(af)){
358 bool can_decrypt = false;
359 if(af->password){
360 struct af_vnode_info vni;
361 memset(&vni,0,sizeof(vni));
362 if((*af->v->vstat)(af,&vni)==0 && vni.supports_metadata){
363 int r = 0;
364 if(af_get_seg(af,AF_AFFKEY,0,0,0)!=0){ // it does not have a password
365 r = af_establish_aes_passphrase(af,af->password);
366 }
367 if(r==0){
368 r = af_use_aes_passphrase(af,af->password);
369 if(r==0) {
370 can_decrypt = true;
371 } else {
372 (*af->error_reporter)("af_open: invalid passphrase: '%s'",af->password);
373 }
374 }
375 af_sanitize_password(af);
376 }
377 }
378
379 /* Try public key... */
380 if(can_decrypt==false){
381 const char *kf = getenv(AFFLIB_DECRYPTING_PRIVATE_KEYFILE);
382 if(kf){
383 af_set_unseal_keyfile(af,kf);
384 }
385 }
386 }
387
388 af_read_sizes(af); // set up the metadata
389 if(af_trace) fprintf(af_trace,"af_open_with(%s,%o,%o,%s)\n",url,flags,mode,v->name);
390 return af;
391 }
392
393
394
395 AFFILE *af_open(const char *filename,int flags,int mode)
396 {
397 if(!aff_initialized) af_initialize();
398 if(flags & O_WRONLY){
399 errno = EINVAL;
400 return 0; // this flag not supported
401 }
402 int exists = (flags & O_CREAT) ? 0 : 1; // file must exist if O_CREAT not specified
403
404
405 /* Figure out it's format, then hand off to the correct subsystem. */
406 for(int i = 0; af_vnode_array[i]; i++){
407 /* Check to see if the implementation identifies the file */
408 if( (*af_vnode_array[i]->identify)(filename,exists)==1 ){
409 AFFILE *af = af_open_with(filename,flags,mode,af_vnode_array[i]);
410 return af;
411 }
412 }
413 errno = EINVAL;
414 if(exists) errno = ENOENT;
415 return 0; // can't figure it out; must be an invalid extension
416 }
417
418 /** Set an option and return the previous value */
419 int af_set_option(AFFILE *af,int option,int value)
420 {
421 int prev = 0;
422 switch(option){
423 case AF_OPTION_AUTO_ENCRYPT:
424 prev = af->crypto->auto_encrypt;
425 af->crypto->auto_encrypt = value;
426 return prev;
427 case AF_OPTION_AUTO_DECRYPT:
428 prev = af->crypto->auto_decrypt;
429 af->crypto->auto_decrypt = value;
430 return prev;
431 }
432 return -1;
433 }
434
435 /* Open a regular file as an affile.
436 * Can only be a raw file...
437 */
438 AFFILE *af_freopen(FILE *file)
439 {
440 if(!aff_initialized) af_initialize();
441
442 AFFILE *af = (AFFILE *)calloc(sizeof(AFFILE),1);
443 af->v = &vnode_raw;
444 af->image_sectorsize = 512; // default
445 raw_freopen(af,file);
446 return af;
447 }
448
449 #ifdef UNIX
450 /* Open a regular file as an affile */
451 AFFILE *af_popen(const char *command,const char *type)
452 {
453 if(!aff_initialized) af_initialize();
454 AFFILE *af = (AFFILE *)calloc(sizeof(AFFILE),1);
455 af->v = &vnode_raw;
456 raw_popen(af,command,type);
457 af->image_sectorsize = 512; // default
458 af->openflags = O_RDONLY;
459 af->fname = strdup(command);
460 return af;
461 }
462 #endif
463
464
465 /* Close the image and unallocate fields */
466 int af_close(AFFILE *af)
467 {
468 int ret = 0;
469
470 AF_WRLOCK(af);
471 af_cache_flush(af); // flush the cache (if writing)
472
473 if(af->image_size != af->image_size_in_file){
474 af_update_segq(af,AF_IMAGESIZE,(int64_t)af->image_size);
475 af->image_size_in_file = af->image_size;
476 }
477 if(getenv(AFFLIB_CACHE_STATS)){
478 fputc('\n',stderr);
479 af_stats(af,stderr);
480 }
481
482 (*af->v->close)(af);
483 af_deallocate(af);
484 return ret;
485 }
486
487
488 /* Seek in the virtual file */
489 uint64_t af_seek(AFFILE *af,int64_t pos,int whence)
490 {
491 AF_WRLOCK(af);
492 if(af_trace) fprintf(af_trace,"af_seek(%p,%"I64d",%d)\n",af,pos,whence);
493 uint64_t new_pos=0;
494 switch(whence){
495 case SEEK_SET:
496 new_pos = pos;
497 break;
498 case SEEK_CUR:
499 if(pos<0 && ((uint64_t)(-pos)) > af->pos) new_pos=0;
500 else new_pos = af->pos + pos;
501 break;
502 case SEEK_END:
503 if((uint64_t)pos > af->image_size) new_pos=0;
504 else new_pos = af->image_size - pos;
505 break;
506 }
507
508 /* Note if the direction has changed */
509 int direction = (new_pos > af->pos) ? 1 : ((new_pos < af->pos) ? -1 : 0);
510 if(af->last_direction != direction) af->direction_changes++;
511 if(af->direction_changes > 5 && af->random_access==0){
512 af->random_access=1;
513 }
514 af->last_direction = direction;
515 /*****************************************************************/
516
517 /* Finally update the direction */
518 af->pos = new_pos; // set the new position
519 AF_UNLOCK(af);
520 return af->pos;
521 }
522
523 /* Returns the name and offset of the last segment */
524 int af_last_seg(AFFILE *af,char *last_segname,int last_segname_len,int64_t *pos)
525 {
526 AF_WRLOCK(af);
527 /* Find the name of the last segment */
528 fseeko(af->aseg,0,SEEK_END);
529 af_backspace(af); // back up one segment
530 *pos = ftello(af->aseg); // remember where it is
531 last_segname[0] = 0;
532 int ret = af_probe_next_seg(af,last_segname,last_segname_len,0,0,0,0);
533 AF_UNLOCK(af);
534 return ret;
535 }
536
537
538 uint64_t af_tell(AFFILE *af)
539 {
540 AF_READLOCK(af);
541 uint64_t ret = af->pos;
542 AF_UNLOCK(af);
543 return ret;
544 }
545
546 /* Return if we are at the end of the file */
547 int af_eof(AFFILE *af)
548 {
549 AF_READLOCK(af);
550 af_vnode_info vni;
551
552 if(af_vstat(af,&vni)) return -1; // this is bad; we need vstat...
553 if(vni.use_eof) return vni.at_eof; // if implementation wants to use it, use it
554 if(af->pos<0){ // pos shouldn't be <0
555 errno = EINVAL;
556 return -1; // this is bad
557 }
558 int ret = ((int64_t)af->pos >= vni.imagesize);
559 AF_UNLOCK(af);
560 return ret;
561 }
562
563 void af_set_callback(AFFILE *af,void (*wcb)(struct affcallback_info *))
564 {
565 AF_WRLOCK(af);
566 af->w_callback = wcb;
567 AF_UNLOCK(af);
568 }
569
570
571 void af_enable_compression(AFFILE *af,int type,int level)
572 {
573 AF_WRLOCK(af);
574 af->compression_type = type;
575 af->compression_level = level;
576 AF_UNLOCK(af);
577 }
578
579 int af_compression_type(AFFILE *af)
580 {
581 AF_READLOCK(af);
582 int ret = af->compression_type;
583 AF_UNLOCK(af);
584 return ret;
585 }
586
587
588 /* Doesn't need locking because it won't change */
589 const char *af_filename(AFFILE *af)
590 {
591 return af->fname;
592 }
593
594 /* Doesn't need locking because it won't change */
595 int af_identify(AFFILE *af)
596 {
597 return af->v->type;
598 }
599
600 /* af_get_imagesize:
601 * Return the byte # of last mapped byte in image, or size of device;
602 * No locking is needed because individual elements of the af structure are not accessed.
603 */
604 int64_t af_get_imagesize(AFFILE *af)
605 {
606 int64_t ret = -1;
607 struct af_vnode_info vni;
608 memset(&vni,0,sizeof(vni));
609 if(af_vstat(af,&vni)==0){
610 /* If vni.imagesize is 0 and if there are encrypted segments and if there
611 * is no imagesize segment but there is an encrypted one, then we can't read this encrypted file...
612 */
613 if(vni.imagesize<=0 && vni.segment_count_encrypted>0){
614 if(af_get_seg(af,AF_IMAGESIZE,0,0,0)!=0){
615 errno = EPERM;
616 goto done;
617 }
618 }
619 ret = vni.imagesize;
620 }
621 done:;
622 return ret;
623 }
624
625 /*
626 * af_make_badflag:
627 * Create a randomized bag flag and
628 * leave an empty segment of how many badsectors there are
629 * in the image...
630 */
631 int af_make_badflag(AFFILE *af)
632 {
633 #ifdef HAVE_OPENSSL_RAND_H
634 /* Use a good random number generator if we have it */
635 RAND_pseudo_bytes(af->badflag,af->image_sectorsize);
636 strcpy((char *)af->badflag,"BAD SECTOR");
637 #else
638 /* Otherwise use a bad one */
639 for(int i=0;i<af->image_sectorsize;i++){
640 af->badflag[i] = rand() & 0xff;
641 }
642 #endif
643
644 AF_WRLOCK(af);
645 af->badflag_set = 1;
646 if(af_update_seg(af,AF_BADFLAG,0,af->badflag,af->image_sectorsize)){
647 AF_UNLOCK(af);
648 return -1;
649 }
650 if(af_update_segq(af,AF_BADSECTORS,0)){
651 AF_UNLOCK(af);
652 return -1;
653 }
654 AF_UNLOCK(af);
655 return 0;
656 }
657
658
659 /*
660 * make the IMAGE_GID segment if it doesn't exist
661 * Returns -1 if an error, 0 if the GID exists, and 1 if one is made.
662 */
663 int af_make_gid(AFFILE *af)
664 {
665 int ret = 0;
666 AF_WRLOCK(af);
667 if(af_get_seg(af,AF_IMAGE_GID,0,0,0)!=0){
668 unsigned char bit128[16];
669 RAND_pseudo_bytes(bit128,sizeof(bit128));
670 int r = af_update_seg(af,AF_IMAGE_GID,0,bit128,sizeof(bit128));
671 if(r<0) ret = -1;
672 else ret = 1;
673 }
674 AF_UNLOCK(af);
675 return ret;
676 }
677
678
679
680 /*TK: Here for locking */
681
682 /* Decrypt data and perform unblocking if necessary.
683 * This could eliminate a memory copy by doing the decryption for everything
684 * but the last block in place, and just doing a copy for the last block.
685 */
686 void af_aes_decrypt(AFFILE *af,const char *segname,unsigned char *data,size_t *datalen)
687 {
688 #ifdef HAVE_AES_ENCRYPT
689 if(datalen==0) return; // can't decrypt; no clue how long it is
690
691 /* An encrypted segment was retrieved; decrypt and trunc the length as necessary */
692 unsigned int extra = (*datalen) % AES_BLOCK_SIZE;
693 unsigned int pad = (AES_BLOCK_SIZE - extra) % AES_BLOCK_SIZE;
694
695 if(data==0){ // just wants to find out new length
696 if(extra>0){
697 *datalen -= AES_BLOCK_SIZE;
698 }
699 return;
700 }
701
702 if(extra!=0 && *datalen < AES_BLOCK_SIZE){
703 *datalen = 0; // something is wrong
704 return;
705 }
706
707 if(data==0){ // just report the new size
708 if(extra!=0) *datalen -= AES_BLOCK_SIZE; // a block was added
709 return;
710 }
711
712 *datalen -= extra; // *datalen is now a multiple of AES_BLOCK_SIZE
713 /* Create an IV */
714 unsigned char iv[AES_BLOCK_SIZE];
715 memset(iv,0,sizeof(iv));
716 strlcpy((char *)iv,segname,sizeof(iv));
717
718 /* Decrypt! */
719 AF_READLOCK(af);
720 AES_cbc_encrypt(data,data,*datalen,&af->crypto->dkey,iv,AES_DECRYPT);
721 AF_UNLOCK(af);
722 *datalen -= pad; // remove the padding
723 #endif
724 }
725
726
727 int af_get_seg(AFFILE *af,const char *segname,unsigned long *arg,unsigned char *data,size_t *datalen)
728 {
729 AF_READLOCK(af);
730 if(af->v->get_seg==0){
731 errno = ENOTSUP;
732 return -1; // not supported by this file system
733 }
734 #ifdef HAVE_AES_ENCRYPT
735 /* If we have encryption and it is turned on, check for encrypted segment first */
736 if(AF_SEALING_VNODE(af) && af->crypto->auto_decrypt){
737 size_t datalen_orig = datalen ? *datalen : 0;
738 char aesname[AF_MAX_NAME_LEN];
739 strlcpy(aesname,segname,sizeof(aesname));
740 strlcat(aesname,AF_AES256_SUFFIX,sizeof(aesname));
741 int r = (*af->v->get_seg)(af,aesname,arg,data,datalen);
742 if(r==0){
743 af_aes_decrypt(af,segname,data,datalen);
744 return 0;
745 }
746 if(r==AF_ERROR_DATASMALL && datalen && (*datalen % AES_BLOCK_SIZE != 0)){
747 /* Not enough space was provided to decrypt, probably because this was blocked out */
748 size_t bigger_data_len = datalen_orig + AES_BLOCK_SIZE;
749 unsigned char *bigger_data = (unsigned char *)malloc(bigger_data_len);
750 if(!bigger_data) return -1; // Malloc failed
751 r = (*af->v->get_seg)(af,aesname,arg,bigger_data,&bigger_data_len);
752 if(r!=0){
753 free(bigger_data);
754 return -1; // something deeper is wrong
755 }
756 af_aes_decrypt(af,segname,bigger_data,&bigger_data_len);
757 if(bigger_data_len > datalen_orig){
758 free(bigger_data);
759 return -1; // it's still too big
760 }
761 memcpy(data,bigger_data,bigger_data_len);
762 *datalen = bigger_data_len;
763 free(bigger_data);
764 return 0; // finally it fits
765 }
766 }
767 #endif
768 /* Try for the unencrypted segment */
769 int ret = (*af->v->get_seg)(af,segname,arg,data,datalen);
770 AF_UNLOCK(af);
771 return ret;
772 }
773
774 int af_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
775 unsigned char *data,size_t *datalen)
776 {
777 size_t datalen_orig = datalen ? *datalen : 0;
778 AF_READLOCK(af);
779 if(af->v->get_next_seg==0){
780 errno = ENOTSUP;
781 AF_UNLOCK(af);
782 return -1;
783 }
784 int r = (*af->v->get_next_seg)(af,segname,segname_len,arg,data,datalen);
785 #ifdef HAVE_AES_ENCRYPT
786 if(AF_SEALING_VNODE(af)
787 && ends_with(segname,AF_AES256_SUFFIX)
788 && af->crypto->auto_decrypt){
789 segname[strlen(segname)-strlen(AF_AES256_SUFFIX)] = 0;
790 /* An encrypted segment was retrieved.
791 * If it fit, decrypt and return.
792 * If it doesn't fit, try to get it again (which will use our adaptive blocksize)
793 *
794 * Normaly it will fit becuase the caller doesn't know how long the 'next' segment is,
795 * so the caller normally leaves enough space.
796 */
797 if(r==0){
798 af_aes_decrypt(af,segname,data,datalen);
799 AF_UNLOCK(af);
800 return 0;
801 }
802 if(r==AF_ERROR_DATASMALL && datalen && (*datalen % AES_BLOCK_SIZE !=0)){
803 *datalen = datalen_orig;
804 AF_UNLOCK(af);
805 return af_get_seg(af,segname,arg,data,datalen);
806 }
807 AF_UNLOCK(af);
808 return r; // not sure why we got this error
809 }
810 #endif
811 AF_UNLOCK(af);
812 return r;
813 }
814
815 int af_rewind_seg(AFFILE *af)
816 {
817 if(af_trace) fprintf(af_trace,"af_rewind_seg(%p)\n",af);
818 AF_READLOCK(af);
819 if(af->v->rewind_seg==0){
820 errno = ENOTSUP;
821 AF_UNLOCK(af);
822 return -1;
823 }
824 int ret = (*af->v->rewind_seg)(af);
825 AF_UNLOCK(af);
826 return ret;
827 }
828
829 /** Main routine for writing segments
830 */
831
832 int af_update_segf(AFFILE *af, const char *segname,
833 unsigned long arg,const u_char *data,unsigned int datalen,u_int flag)
834 {
835 if(af_trace) fprintf(af_trace,"af_update_segf(%p,segname=%s,arg=%lu,datalen=%d)\n",af,segname,arg,datalen);
836 AF_WRLOCK(af);
837 if(af->v->update_seg==0){
838 errno = ENOTSUP;
839 AF_UNLOCK(af);
840 return -1; // not supported by this file system
841 }
842
843 af_invalidate_vni_cache(af);
844
845 /* See if we need to encrypt. New memory might need to be allocated.
846 * This isn't a big deal, because encryption requires copying memory
847 * in any event; it's either an in-place copy or a copy to another location.
848 */
849 #ifdef HAVE_AES_ENCRYPT
850 const char *oldname = 0;
851 unsigned char *newdata = 0;
852 if(AF_SEALING(af)
853 && ((flag & AF_SIGFLAG_NOSEAL)==0)){
854 /* Create an IV */
855 unsigned char iv[AES_BLOCK_SIZE];
856 memset(iv,0,sizeof(iv));
857 strlcpy((char *)iv,segname,sizeof(iv));
858
859 /* Figure out the real segment name */
860 char aesname[AF_MAX_NAME_LEN];
861 strlcpy(aesname,segname,sizeof(aesname));
862 strlcat(aesname,AF_AES256_SUFFIX,sizeof(aesname));
863 oldname = segname;
864 segname = aesname;
865
866 /* Figure out if we need to padd out for encryption. Allocate space and
867 */
868 unsigned int extra = (datalen) % AES_BLOCK_SIZE;
869 unsigned int pad = (AES_BLOCK_SIZE - extra) % AES_BLOCK_SIZE;
870 newdata = (unsigned char *)malloc(datalen+pad+extra);
871 memset(newdata+datalen,pad+extra,pad); // PKCS7 uses 01 for one pad byte, 02 02 for two, etc.
872 /* Encrypt */
873 AES_cbc_encrypt((const unsigned char *)data,
874 newdata,
875 datalen+pad,&af->crypto->ekey,iv,AES_ENCRYPT);
876 data = newdata; // we will write this out
877 datalen += pad + extra;
878 }
879 #endif
880 int r = (*af->v->update_seg)(af,segname,arg,data,datalen);
881 if(r==0) af->bytes_written += datalen;
882 #ifdef HAVE_AES_ENCRYPT
883 /* if we encrypted, make sure the unencrypted segment is deleted */
884 if(r==0 && oldname) (*af->v->del_seg)(af,oldname);
885 if(newdata){
886 free(newdata); // free any allocated data
887 newdata = 0;
888 }
889 #endif
890 /* Sign the segment if:
891 * - there is a signing private key
892 * - the data structure and flag not set
893 * - This is not a signature segment
894 */
895 #ifdef USE_AFFSIGS
896 const u_char *signdata = data; // remember the original data location
897 if(AF_SEALING(af)
898 && (r==0)
899 && af->crypto->sign_privkey
900 && ((flag & AF_SIGFLAG_NOSIG)==0)
901 && !ends_with(segname,AF_SIG256_SUFFIX)){
902 // return code doesn't matter; it's either signed or not.
903 af_sign_seg3(af,segname,arg,signdata,datalen,AF_SIGNATURE_MODE0);
904 }
905 #endif
906 AF_UNLOCK(af);
907 return r;
908 }
909
910 /* Requires no locking because locking is done in af_update_segf */
911 int af_update_seg(AFFILE *af, const char *segname,
912 unsigned long arg,const u_char *data,unsigned int datalen)
913 {
914 return af_update_segf(af,segname,arg,data,datalen,0);
915 }
916
917 #ifdef HAVE_OPENSSL_BIO_H
918 /* Requires no locking */
919 int af_update_seg_frombio(AFFILE *af,const char *segname,unsigned long arg,BIO *bio)
920 {
921 /* Get the buffer to write out */
922 u_char *buf=0;
923 size_t buflen = BIO_get_mem_data(bio,&buf);
924 return af_update_seg(af,segname,0,buf,buflen);
925 }
926 #endif
927
928 int af_del_seg(AFFILE *af,const char *segname)
929 {
930 AF_WRLOCK(af);
931 if(af->v->del_seg==0){
932 errno = ENOTSUP;
933 AF_UNLOCK(af);
934 return -1; // not supported
935 }
936 #ifdef HAVE_AES_ENCRYPT
937 if(AF_SEALING(af)){
938 /* Delete the encrypted segment if it exists */
939 char aesname[AF_MAX_NAME_LEN];
940 strlcpy(aesname,segname,sizeof(aesname));
941 strlcat(aesname,AF_AES256_SUFFIX,sizeof(aesname));
942 (*af->v->del_seg)(af,aesname);
943 }
944 #endif
945 /* Delete the unencrypted segment */
946 int ret = (*af->v->del_seg)(af,segname);
947 AF_UNLOCK(af);
948 return ret;
949 }
950
951 void af_invalidate_vni_cache(AFFILE *af)
952 {
953 if(af->vni_cache){
954 free(af->vni_cache);
955 af->vni_cache = 0;
956 }
957 }
958
959 int af_vstat(AFFILE *af,struct af_vnode_info *vni)
960 {
961 AF_READLOCK(af);
962 if(af->v->vstat==0){
963 errno = ENOTSUP;
964 AF_UNLOCK(af);
965 return -1; // not supported
966 }
967 int ret = 0;
968 if(af->vni_cache==0){ // no cached copy?
969 af->vni_cache = (struct af_vnode_info *)calloc(1,sizeof(struct af_vnode_info)); // allocate a space
970 ret = (*af->v->vstat)(af,af->vni_cache);
971 }
972 if(ret==0) memcpy(vni,af->vni_cache,sizeof(*vni));
973 AF_UNLOCK(af);
974 return ret;
975 }
976
977 /* Requires no locking */
978 int af_has_pages(AFFILE *af)
979 {
980 struct af_vnode_info vni;
981 if(af_vstat(af,&vni)) return -1; // can't figure it out
982 return vni.has_pages; // will return 0 or 1
983 }
984
985
986 void af_stats(AFFILE *af,FILE *f)
987 {
988 AF_READLOCK(af);
989 fprintf(f,"AFSTATS for %s\n",af_filename(af));
990 fprintf(f,"Pages read: %"I64u"\n",af->pages_read);
991 fprintf(f,"Pages written: %"I64u"\n",af->pages_written);
992 fprintf(f,"Pages compressed: %"I64u"\n",af->pages_compressed);
993 fprintf(f,"Pages decompressed: %"I64u"\n",af->pages_decompressed);
994 fprintf(f,"Cache hits: %"I64u"\n",af->cache_hits);
995 fprintf(f,"Cache misses: %"I64u"\n",af->cache_misses);
996 fprintf(f,"Bytes copied: %"I64u"\n",af->bytes_memcpy);
997 AF_UNLOCK(af);
998 }
999
1000
1001 int af_set_acquisition_date(AFFILE *af,time_t t)
1002 {
1003 char timebuf[64];
1004 strftime(timebuf,sizeof(timebuf),"%Y-%m-%d %H:%M:%S\n",localtime(&t));
1005 return af_update_seg(af,AF_ACQUISITION_DATE,0,(const u_char *)timebuf,strlen(timebuf));
1006 }
0 #ifndef _AFFLIB_H_
1 #define _AFFLIB_H_
2
3 /*
4 * afflib.h:
5 *
6 * This file describes the public AFFLIB interface.
7 * The interface to reading AFF files, Raw files, and EnCase file (if libewf is compiled in).
8 */
9
10 /* Figure out what kind of OS we are running on */
11
12 /* These are both needed; no need to bother with affconfig.h #defines */
13 #include <stdio.h>
14 #include <sys/types.h>
15
16 #ifdef HAVE_SYS_CDEFS_H
17 #include <sys/cdefs.h>
18 #endif
19
20 #ifdef linux
21 /* Horrible lossage stuff for largefile support under Linux */
22 #define _LARGEFILE_SOURCE 1
23 #define _FILE_OFFSET_BITS 64
24 #endif
25
26 #ifdef HAVE_INTTYPES_H
27 #ifndef __STDC_FORMAT_MACROS
28 #define __STDC_FORMAT_MACROS
29 #endif
30 #include <inttypes.h>
31 #endif
32
33 /* WIN32 is defined by the NMAKE makefile for Visual C++ under Windows */
34 #ifdef WIN32
35 #include <io.h> // gets isatty
36 typedef unsigned int uint;
37 typedef unsigned int u_int;
38 typedef unsigned long ulong;
39 typedef unsigned long u_long;
40 typedef unsigned _int64 uint64; /* 64-bit types Types */
41 typedef _int64 int64;
42 typedef unsigned char u_char;
43 #ifndef _UINT64_T_DECLARED
44 typedef unsigned _int64 uint64_t; /* 64-bit types Types */
45 #define _UINT64_T_DECLARED
46
47 #ifndef PRId64
48 #define PRId64 "I64d"
49 #endif
50 #ifndef PRIi64
51 #define PRIi64 "I64i"
52 #endif
53 #ifndef PRIu64
54 #define PRIu64 "I64u"
55 #endif
56 #endif
57
58 #ifndef _INT64_T_DECLARED
59 typedef _int64 int64_t;
60 #define _INT64_T_DECLARED
61 #endif
62 int64 ftello(FILE *stream); /* Functions that Microsoft forgot */
63 int fseeko(FILE *stream,int64 offset,int whence);
64 #endif
65
66 #define I64d PRIi64
67 #define I64u PRIu64
68
69 /* If our types still aren't defined, give some kind of error
70 */
71 #define USE_LZMA
72 struct affcallback_info;
73 struct aff_pagebuf {
74 int64_t pagenum; // -1 means no page loaded
75 unsigned char *pagebuf; // where the data is; size is image_pagesize
76 size_t pagebuf_bytes; // number of bytes in the pagebuf that are valid.
77 unsigned int pagenum_valid:1; // buffer contains data
78 unsigned int pagebuf_valid:1; // buffer contains data
79 unsigned int pagebuf_dirty:1; // data was modified
80 int last; // when the page was last visited
81 };
82
83 struct af_vnode_info {
84 int64_t imagesize; // size of this image
85 int pagesize; // what is the natural page size?
86 u_int supports_compression:1; // supports writing compressed segments
87 u_int has_pages:1; // does system support page segments?
88 u_int supports_metadata:1; // does it support metadata?
89 u_int is_raw:1; // file is raw
90 u_int use_eof:1; // should we use the EOF flag?
91 u_int at_eof:1; // are we at the EOF?
92 u_int changable_pagesize:1; // pagesize can be changed at any time
93 u_int changable_sectorsize:1; // sectorsize can be changed at any time
94 u_int cannot_decrypt:1; // encrypted pages cannot be decrypted becuase passphrase is invalid
95 u_int segment_count_total;
96 u_int page_count_total;
97 u_int segment_count_signed;
98 u_int segment_count_encrypted;
99 u_int page_count_encrypted;
100 }; //
101
102
103 /* All of this stuff should be hidden inside a single private structure... */
104 typedef struct _AFFILE AFFILE;
105
106 /* The information that is provided in the aff callback */
107 struct affcallback_info {
108 int info_version; // version number for this segment
109 AFFILE *af; // v1: the AFFILE responsibile for the callback
110 int phase; // v1: 1 = before compress; 2 = after compressing;
111 // 3 = before writing; 4 = after writing
112 int64_t pagenum; // v1: page number being written
113 int bytes_to_write; // v1: >0 if we are going to write bytes
114 int bytes_written; // v1: >0 if bytes were written
115 int compressed; // v1: >0 if bytes were/will be compressed
116 int compression_alg; // v1: compression algorithm
117 int compression_level; // v1: compression level
118 };
119
120 /* Utility Functions */
121
122 #ifdef __cplusplus
123 extern "C" {
124 #endif
125 #ifdef __never_defined__
126 }
127 #endif
128
129 /****************************************************************
130 ***
131 *** Intended user AFF interface
132 ***
133 ****************************************************************/
134
135 const char *af_version(void); // returns AFF Version Number
136
137 /* af_file stream functions */
138 AFFILE *af_open(const char *filename,int flags,int mode);
139 AFFILE *af_freopen(FILE *file); // reopen a raw file as an AFFILE
140 AFFILE *af_popen(const char *command,const char *type); // no need to use pclose(); af_close() is fine
141 int af_close(AFFILE *af);
142 void af_set_error_reporter(AFFILE *af,void (*reporter)(const char *fmt,...));
143 void af_stats(AFFILE *af,FILE *f); // print stats to f
144 void af_set_cachesize(AFFILE *af,int max); // how much memory can the cache use?
145 int af_vstat(AFFILE *af,struct af_vnode_info *vni); // does the stat
146 void af_perror(const char *fname); // print the error string to stderr
147 void af_err(int code,const char *fname,...); // like err(), but will also print AFF-specific errors
148
149
150
151 /* Generic set/get option routines; this replaces individual options in previous implementations.
152 * af==0 to set global options. Return the previous value.
153 */
154 int af_set_option(AFFILE *af,int option,int value);
155
156 #define AF_OPTION_AUTO_ENCRYPT 1 // 1 = auto-encrypt
157 #define AF_OPTION_AUTO_DECRYPT 2 // 1 = auto-decrypt
158 // The following are not implemented yet
159 #define AF_OPTION_PIECEWISE_MD5 3 // 1 = automatically write pagen_md5 segments
160 #define AF_OPTION_PIECEWISE_SHA1 4 // 1 = automatically write pagen_md5 segments
161 #define AF_OPTION_PIECEWISE_SHA256 5 // 1 = automatically write pagen_md5 segments
162 #define AF_OPTION_DISABLE_RDLOCK 6 // 1 = do not read lock, but report that it should have locked.
163
164
165 /* Special AFOPEN flags for af_open_with */
166 #define AF_OPEN_PRIMITIVE (1<<31) // only open primtive, not compound files
167 #define AF_BADBLOCK_FILL (1<<30) // fill unallocated (sparse) with BADBLOCK flag
168 #define AF_HALF_OPEN (1<<29) // return af before calling af->v->open;
169
170 /* navigating within the data segments as if they were a single file */
171 ssize_t af_read(AFFILE *af,unsigned char *buf,ssize_t count);
172 uint64_t af_seek(AFFILE *af,int64_t pos,int whence); // returns new position
173 uint64_t af_tell(AFFILE *af);
174 int af_eof(AFFILE *af); // is the virtual file at the end?
175
176 /* Additional routines for writing */
177 void af_set_callback(AFFILE *af, void (*cb)(struct affcallback_info *acbi));
178 void af_enable_compression(AFFILE *af,int type,int level); // set/gunset compression for writing
179 int af_compression_type(AFFILE *af);
180 int af_write(AFFILE *af,unsigned char *buf,size_t count);
181 const unsigned char *af_badflag(AFFILE *af); // return the pattern used to identify bad sectors
182 int af_is_badsector(AFFILE *af,const unsigned char *buf); // 0 if not, 1 if it is, -1 if error
183
184
185 /* Misc. Functions */
186 const char *af_ext(const char *filename); // return the extension of str including the dot
187 int af_ext_is(const char *filename,const char *ext);
188 const char *af_filename(AFFILE *af); // returns the filename of an open stream.
189 int af_identify(AFFILE *af); // returns type of AFFILE pointer
190
191 /* Accessor Functions */
192 int64_t af_get_imagesize(AFFILE *af); // byte # of last mapped byte in image, or size of device;
193 // returns -1 if error
194 int af_set_acquisition_date(AFFILE *af,time_t t); // sets AF_ACQUISITION_DATE
195
196 #define af_imagesize(af) af_get_imagesize(af) // backwards compatiability
197 int af_get_segq(AFFILE *af,const char *name,int64_t *quad);/* Get/set 8-byte values */
198 int af_update_segq(AFFILE *af,const char *name,int64_t quad);
199
200
201 /****************************************************************
202 * Functions for manipulating the AFFILE as if it were a name/value database.
203 ****************************************************************/
204
205 /* get functions:
206 * get the named segment.
207 * If arg!=0, set *arg to be the segment's flag.
208 * if data==0, don't return it.
209 * if datalen && *datalen==0, return the size of the data segment.
210 *** Returns 0 on success,
211 *** -1 on end of file. (AF_ERROR_EOF)
212 *** -2 if *data is not large enough to hold the segment (AF_ERROR_DATASMALL)
213 *** -3 file is corrupt or other internal error. (AF_ERROR_CORRUPT)
214 */
215
216 int af_get_seg(AFFILE *af,const char *name,unsigned long *arg,
217 unsigned char *data,size_t *datalen);
218 int af_get_next_seg(AFFILE *af,char *segname,size_t segname_len,
219 unsigned long *arg, unsigned char *data, size_t *datalen);
220
221 int af_rewind_seg(AFFILE *af); // rewind seg pointer to beginning
222
223 /*
224 * af_update_seg() should be your primary routine for writing new values.
225 */
226
227 /* Writing arbitrary name/value pairs */
228 int af_update_seg(AFFILE *af,const char *segname,unsigned long arg,
229 const unsigned char *value,unsigned int vallen);
230 #ifdef HAVE_OPENSSL_BIO_H
231 /* Write a memory bio to a segment */
232 #include <openssl/bio.h>
233 int af_update_seg_frombio(AFFILE *af,const char *segname,unsigned long arg,BIO *bio);
234 #endif
235
236
237 /* Delete functions */
238
239 int af_del_seg(AFFILE *af,const char *name); // complete delete of first name
240 // returns 0 if success, -1 if seg not found
241
242 /* Segname parse functions.
243 * af_segname_page_number:
244 * - Returns page number if segment name is a page #, and -1 if it is not
245 * af_segname_hash_page_number:
246 * - Returns page number if segment name is a page hash, sets hash function
247 * to be the function used.
248 */
249 int64_t af_segname_page_number(const char *name); // return -1 if it is not a page number
250 int64_t af_segname_hash_page_number(const char *name,char *hash,int hashlen); // return -1 if it is not a hash page #
251
252 int af_display_as_quad(const char *segname); // afflib recommends displaying this segment as an 8-byte quad
253 int af_display_as_hex(const char *segname); // afflib recommends displaying this segment as a hex-string
254
255 /****************************************************************/
256
257 /* Crypto */
258 /* AFF Base Encryption */
259 int af_SHA256(const unsigned char *buf,size_t buflen,unsigned char md[32]); // return 0 if success, -1 if no cipher
260 int af_set_aes_key(AFFILE *af,const unsigned char *userKey,const int bits);
261 int af_cannot_decrypt(AFFILE *af); // encrypted pages are present which cannot be decrypted
262 int af_has_encrypted_segments(AFFILE *af);
263 int af_is_encrypted_segment(const char *segname);
264
265 /* AFF Passphrase Encryption */
266 int af_establish_aes_passphrase(AFFILE *af,const char *passphrase);
267 int af_change_aes_passphrase(AFFILE *af,const char *oldphrase,const char *newphrase);
268 int af_use_aes_passphrase(AFFILE *af,const char *passphrase);
269 int af_save_aes_key_with_passphrase(AFFILE *af,const char *passphrase, const u_char affkey[32]);
270 int af_get_aes_key_from_passphrase(AFFILE *af,const char *passphrase, unsigned char affkey[32]);
271
272
273 /* PKI Signing */
274 int af_set_sign_files(AFFILE *af,const char *keyfile,const char *certfile);
275 int af_sign_seg3(AFFILE *af,const char *segname, unsigned long arg,
276 const unsigned char *data,unsigned int datalen,unsigned long signmode);
277 int af_sign_seg(AFFILE *af,const char *segname);
278 int af_sign_all_unsigned_segments(AFFILE *af); //
279 int af_sig_verify_seg(AFFILE *af,const char *segname); // see below for return codes
280
281 int af_is_signature_segment(const char *segname);
282
283 /* PKI sealing */
284 int af_set_seal_certificates(AFFILE *af,const char *certfiles[],int numcertfiles);
285 int af_seal_affkey_using_certificates(AFFILE *af,const char *certfiles[],int numcertfiles, unsigned char affkey[32]);//
286 int af_set_unseal_keybuffer(AFFILE *af,const char *key); // take key from a buffer
287 int af_set_unseal_keyfile(AFFILE *af,const char *keyfile); // take key from a file
288 int af_get_affkey_using_keyfile(AFFILE *af, const char *private_keyfile,u_char affkey[32]);
289
290
291
292 #ifdef HAVE_OPENSSL_EVP_H
293 #include <openssl/evp.h>
294 int af_sig_verify_seg2(AFFILE *af,const char *segname,EVP_PKEY *pubkey,u_char *sigbuf,
295 size_t sigbuf_len,int sigmode);
296 int af_hash_verify_seg2(AFFILE *af,const char *segname,u_char *sigbuf_,size_t sigbuf_len_,int sigmode);
297 #define AF_HASH_VERIFIES 0
298
299 #endif
300 #define AF_SIGNATURE_MODE0 0x0000 // signature is for segname, arg, data in segment
301 #define AF_SIGNATURE_MODE1 0x0001 // signature is for segname, 0 arg, uncompressed data in segment
302 #define AF_SIGNATURE_DELETE 0xFFFF // signature is invalid; delete segment
303
304 /* Metadata access */
305
306 /* Compression amounts */
307
308 #define AF_COMPRESSION_MIN 1
309 #define AF_COMPRESSION_DEFAULT -1
310 #define AF_COMPRESSION_MAX 9
311 #define AF_COMPRESSION_MIN 1
312
313
314 /****************************************************************
315 *** AF segment names that you might be interested in...
316 ****************************************************************/
317
318 #define AF_IGNORE "" // ignore segments with 0-length name
319 #define AF_DIRECTORY "dir" // the directory
320 #define AF_RAW_IMAGE_FILE_EXTENSION "raw_image_file_extension"
321 #define AF_PAGES_PER_RAW_IMAGE_FILE "pages_per_raw_image_file"
322
323 #define AF_PAGESIZE "pagesize" // page data size, in bytes, stored in arg
324 #define AF_IMAGESIZE "imagesize" // last logical byte in image, stored as a 64-bit number
325 #define AF_BADSECTORS "badsectors" // number of bad sectors
326 #define AF_SECTORSIZE "sectorsize" // in bytes, stored in arg
327 #define AF_DEVICE_SECTORS "devicesectors"// stored as a 64-bit number
328 #define AF_BADFLAG "badflag" // data used to mark a bad sector
329 #define AF_PAGE "page%"I64d // segment flag indicates compression (replaces seg%d)
330 #define AF_PAGE_MD5 AF_PAGE"_md5" // md5 hash of page
331 #define AF_PAGE_SHA1 AF_PAGE"_sha1" // sha1 hash of page
332 #define AF_PAGE_SHA256 AF_PAGE"_sha256"// sha256 hash of page
333 #define AF_PARITY0 "parity0" // parity page of all bytes
334 #define AF_BATCH_NAME "batch_name"
335 #define AF_BATCH_ITEM_NAME "batch_item_name"
336
337 #define AF_BLANKSECTORS "blanksectors" // all NULs; 8-bytes
338 #define AF_AFF_FILE_TYPE "aff_file_type" // contents should be "AFF", "AFM" or "AFD"
339
340 #define AF_AFFKEY "affkey_aes256" // segment for AES256 session key encrypted with sha of the passphrase
341 #define AF_AFFKEY_EVP "affkey_evp%d" // segment for encrypted affkey
342 #define AF_AES256_SUFFIX "/aes256" // suffix for encrypted segments
343 #define AF_SIG256_SUFFIX "/sha256" // suffix for signature segments
344 #define AF_SIGN256_CERT "cert-sha256" // segment name for image creator's public key
345 #define AF_PARITY0_SIG "parity0/sha256" // signature for parity segment
346
347 /* Chain of custody segments */
348 #define AF_BOM_SEG "affbom%d"
349
350 /* Deprecated terminology; pages were originally called data segments */
351 #define AF_SEG_D "seg%"I64d // segment flag indicates compression (deprecated)
352 #define AF_SEGSIZE_D "segsize" // segment data size (deprecated)
353
354 /* Bill of Materials */
355 #define AF_XML_AFFBOM "affbom"
356 #define AF_XML_DATE "date"
357 #define AF_XML_SIGNING_CER "signingcert"
358 #define AF_XML_SEGMENT_HASH "segmenthash"
359
360
361 /* AFF Flags */
362 /* Flags for 8-byte segments */
363 #define AF_SEG_QUADWORD 0x0002
364
365 /* Flags for selecting compression algorithm to try */
366 #define AF_COMPRESSION_ALG_NONE 0 // don't compress
367 #define AF_COMPRESSION_ALG_ZLIB 1 // try to compress with zlib
368 #define AF_COMPRESSION_ALG_LZMA 2 // try to compress with LZMA
369
370 /* Arg Flags for data pages; this is stored in 'flag' of data segment */
371 #define AF_PAGE_COMPRESSED 0x0001
372 #define AF_PAGE_COMP_MAX 0x0002 // compressed at maximum; nice to know
373 #define AF_PAGE_COMP_ALG_MASK 0x00F0 // up to 16 compression algorithms may be used
374 #define AF_PAGE_COMP_ALG_ZLIB 0x0000
375 #define AF_PAGE_COMP_ALG_BZIP 0x0010 // not implemented; why bother?
376 #define AF_PAGE_COMP_ALG_LZMA 0x0020 // high compression but pretty slow
377 #define AF_PAGE_COMP_ALG_ZERO 0x0030 // Data segment is a 4-byte value of # of NULLs.
378
379 #define AF_MD5 "md5" // stores image md5
380 #define AF_SHA1 "sha1" // stores image sha1
381 #define AF_SHA256 "sha256" // stores image sha256
382
383 #define AF_CREATOR "creator" // progname of the program that created the AFF file
384
385 /* segment names: imaging */
386 #define AF_CASE_NUM "case_num" // case number
387 #define AF_IMAGE_GID "image_gid" // 128-bit unique number
388 #define AF_ACQUISITION_ISO_COUNTRY "acquisition_iso_country" // ISO country code
389 #define AF_ACQUISITION_COMMAND_LINE "acquisition_commandline" // actual command line used to create the image
390 #define AF_ACQUISITION_DATE "acquisition_date" // YYYY-MM-DD HH:MM:SS TZT
391 #define AF_ACQUISITION_NOTES "acquisition_notes" // notes made while imaging
392 #define AF_ACQUISITION_DEVICE "acquisition_device" // device used to do the imaging
393 #define AF_ACQUISITION_SECONDS "acquisition_seconds" // stored in arg
394 #define AF_ACQUISITION_TECHNICIAN "acquisition_tecnician"
395 #define AF_ACQUISITION_MACADDR "acquisition_macaddr"
396 #define AF_ACQUISITION_DMESG "acquisition_dmesg"
397
398
399 // mac addresses are store in ASCII as a list of lines that end with \n,
400 // for example, "00:03:93:14:c5:04\n"
401 // It is all the mac addresses that were on the acquisition system
402
403 // DMESG is the output from the "dmesg" command at the time of acquisition
404
405
406 /* segment names: device hardware */
407
408 #define AF_AFFLIB_VERSION "afflib_version" // version of AFFLIB that made this file
409 #define AF_DEVICE_MANUFACTURER "device_manufacturer"
410 #define AF_DEVICE_MODEL "device_model" // string for ident from drive
411 #define AF_DEVICE_SN "device_sn" // string of drive capabilities
412 #define AF_DEVICE_FIRMWARE "device_firmware" // string of drive capabilities
413 #define AF_DEVICE_SOURCE "device_source" // string
414 #define AF_CYLINDERS "cylinders" // quad with # cylinders
415 #define AF_HEADS "heads" // quad with # heads
416 #define AF_SECTORS_PER_TRACK "sectors_per_track"// quad with # sectors/track
417 #define AF_LBA_SIZE "lbasize"
418 #define AF_HPA_PRESENT "hpa_present" // flag = 1 or 0
419 #define AF_DCO_PRESENT "dco_present" // flag = 1 or 0
420 #define AF_LOCATION_IN_COMPUTER "location_in_computer" // text, where it was found
421 #define AF_DEVICE_CAPABILITIES "device_capabilities" // string; human-readable
422
423 #define AF_MAX_NAME_LEN 64 // segment names should not be larger than this
424
425 /* AFF error codes */
426 #define AF_ERROR_NO_ERROR 0
427 #define AF_ERROR_EOF -1
428 #define AF_ERROR_DATASMALL -2
429 #define AF_ERROR_TAIL -3 // no tail, or error reading tail
430 #define AF_ERROR_SEGH -4 // no head, or error reading head
431 #define AF_ERROR_NAME -5 // segment name invalid
432 #define AF_ERROR_INVALID_ARG -6 // argument invalid
433 #define AF_ERROR_NO_AES -7 // AES support is not compiled in
434 #define AF_ERROR_AES_TOO_SMALL -8 // and AES-encrypted segment was too small
435 #define AF_ERROR_KEY_SET -9 // a key was already set
436 #define AF_ERROR_AFFKEY_EXISTS -10 // a key already exists in file an attempt was made to establish
437 #define AF_ERROR_AFFKEY_NOT_EXIST -11 // a key does not exist and an attempt was made to use it.
438 #define AF_ERROR_AFFKEY_WRONG_VERSION -12
439 #define AF_ERROR_WRONG_PASSPHRASE -13
440 #define AF_ERROR_RNG_FAIL -13
441 #define AF_ERROR_HASH_FAIL -14
442 #define AF_ERROR_NO_SHA256 -15
443
444 #define AF_SIG_GOOD 0
445 #define AF_ERROR_SIG_BAD -15
446 #define AF_ERROR_SIG_NO_CERT -16
447 #define AF_ERROR_SIG_CANNOT_READ_PUBLIC_KEY -17
448 #define AF_ERROR_SIG_DATAREAD_ERROR -18
449 #define AF_ERROR_SIG_MALLOC -19
450 #define AF_ERROR_SIG_READ_ERROR -20
451 #define AF_ERROR_SIG_SIG_SEG -21 // can't verify the signature on a signature segment
452 #define AF_ERROR_SIG_NOT_COMPILED -22 // afflib compiled without signature support
453
454
455 /* AFF environment variables */
456 #define AFFLIB_CACHE_STATS "AFFLIB_CACHE_STATS" // make non-zero to dump stats to STDERR at end
457 #define AFFLIB_CACHE_DEBUG "AFFLIB_CACHE_DEBUG" // make "1" to dump a trace of cache events to stderr
458 #define AFFLIB_CACHE_PAGES "AFFLIB_CACHE_PAGES" // Size of the page cache
459 #define AFFLIB_CACHE_PAGES_DEFAULT 32 // default number of cache pages
460 #define AFFLIB_BIGTMP "AFFLIB_BIGTMP" // default directory to put very big files for test programs
461 #define AFFLIB_TRACEFILE "AFFLIB_TRACEFILE" // If set, send a record of all activity to the location
462 /* passphrases for single-key cryptography */
463 #define AFFLIB_PASSPHRASE "AFFLIB_PASSPHRASE"
464 #define AFFLIB_PASSPHRASE_FILE "AFFLIB_PASSPHRASE_FILE"
465 #define AFFLIB_PASSPHRASE_FD "AFFLIB_PASSPHRASE_FD"
466
467 /* passphrases for signing keys */
468 #define AFFLIB_PEM_SIGNING_PASSPHRASE "AFFLIB_PEM_SIGNING_PASSPHRASE"
469
470 /* passphrases for sealing keys */
471
472 #define AFFLIB_DECRYPTING_PRIVATE_KEYFILE "AFFLIB_DECRYPTING_PRIVATE_KEYFILE"
473
474 extern FILE *af_trace; // fd to trace to
475
476 /****************************************************************
477 *** Not AFF functions at all, but placed here for convenience.
478 ****************************************************************/
479 const char *af_hexbuf(char *dst,int dst_len,const unsigned char *bin,int bytes,int format_flag);
480
481 /* af_hexbuf formats: */
482 #define AF_HEXBUF_NO_SPACES 0
483 #define AF_HEXBUF_SPACE2 0x0001 // space every 2 characters
484 #define AF_HEXBUF_SPACE4 0x0002 // space every 4 characters
485 #define AF_HEXBUF_UPPERCASE 0x1000 // uppercase
486 #define AF_HEXBUF_LINEBREAK 0x2000 // break every 80 cols
487
488
489 /****************************************************************
490 *** Internal implementation details below.
491 ****************************************************************/
492
493
494 #ifdef __never_defined__
495 {
496 #endif
497 #ifdef __cplusplus
498 }
499 #endif
500 #endif
501
502
0 /*
1 * afflib_i.h:
2 * The "master include file" of the AFF Library.
3 * Includes many fucntions that are not designed
4 * to be used by application programmers.
5 */
6
7 /*
8 * Copyright (c) 2005-2008
9 * Simson L. Garfinkel and Basis Technology, Inc.
10 * All rights reserved.
11 *
12 * This code is derrived from software contributed by
13 * Simson L. Garfinkel
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. All advertising materials mentioning features or use of this software
24 * must display the following acknowledgement:
25 * This product includes software developed by Simson L. Garfinkel
26 * and Basis Technology Corp.
27 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
28 * contributors to this program may be used to endorse or promote
29 * products derived from this software without specific prior written
30 * permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
33 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
34 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
37 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
38 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
40 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
43 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * SUCH DAMAGE.
45 */
46
47 #ifndef AFFLIB_I_H
48 #define AFFLIB_I_H
49
50 /* Should we disable threading? */
51 #ifdef DISABLE_PTHREAD
52 #undef HAVE_PTHREAD
53 #endif
54
55 /* Standard includes */
56 #ifdef HAVE_STRING_H
57 #include <string.h>
58 #endif
59
60 #ifdef HAVE_STDLIB_H
61 #include <stdlib.h>
62 #endif
63
64 #ifdef HAVE_ZLIB_H
65 #include <zlib.h>
66 #endif
67
68 #ifdef HAVE_SYS_STAT_H
69 #include <sys/stat.h>
70 #endif
71
72 #ifdef HAVE_FCNTL_H
73 #include <fcntl.h>
74 #endif
75
76 #ifdef HAVE_ASSERT_H
77 #include <assert.h>
78 #endif
79
80 #ifdef HAVE_ERRNO_H
81 #include <errno.h>
82 #endif
83
84 #ifdef HAVE_DIRENT_H
85 #include <dirent.h>
86 #endif
87
88 #ifdef HAVE_ERR_H
89 #include <err.h>
90 #endif
91
92 #ifdef HAVE_ALLOCA_H
93 #include <alloca.h>
94 #endif
95
96 #ifdef HAVE_LIBSSL
97 #include <openssl/aes.h>
98 #include <openssl/rsa.h> // a standard part of OpenSSL
99 #include <openssl/rand.h>
100 #include <openssl/md5.h>
101 #include <openssl/sha.h>
102 #endif
103
104 #ifdef HAVE_PTHREAD
105 #include <pthread.h>
106 #define AF_READLOCK(af) pthread_rwlock_rdlock(&af->rwlock);
107 #define AF_WRLOCK(af) pthread_rwlock_wrlock(&af->rwlock);
108 #define AF_UNLOCK(af) pthread_rwlock_unlock(&af->rwlock);
109 #else
110 /* No threads */
111 #define AF_READLOCK(af) {}
112 #define AF_WRLOCK(af) {}
113 #define AF_UNLOCK(af) {}
114 #endif
115
116 #ifdef WIN32
117 #pragma warning(disable: 4996) /* Don't warn on Windows about using POSIX open() instead of _open() */
118 #include <malloc.h>
119 #include <windows.h>
120 #include <winsock.h> // htonl()
121 #include <direct.h>
122 #define snprintf _snprintf
123 #define strcasecmp _stricmp
124 #define mkdir(path,mode) _mkdir(path)
125 #define ENOTSUP 65536 /* made up number */
126 #define random() rand()
127 #define access _access
128 #define strdup _strdup
129 typedef int mode_t;
130 typedef unsigned int uint32_t ;
131
132 #ifndef S_ISDIR
133 #define S_ISDIR(m)(((m) & 0170000) == 0040000)
134 #endif
135
136 #define ftruncate(fd,size) _chsize_s(fd,size)
137 #define MAXPATHLEN 1024
138 #endif
139
140 #ifdef HAVE_SYS_PARAM_H
141 #include <sys/param.h>
142 #endif
143
144 #ifdef HAVE_ARPA_INET_H
145 #include <arpa/inet.h>
146 #endif
147
148 #ifdef HAVE_UNISTD_H
149 #include <unistd.h>
150 #endif
151
152 /* Pick an appropriate POINTER_FMT; isn't there an ANSI standard for this? */
153 #ifdef __APPLE__
154 #define POINTER_FMT "%p"
155 #endif
156
157 #ifdef linux
158 #define POINTER_FMT "%p"
159 #endif
160
161 #ifndef POINTER_FMT
162 #define POINTER_FMT "%x" // guess
163 #endif
164
165 /* Handle systems that are missing some #defines */
166
167 #ifndef O_BINARY
168 #define O_BINARY 0 // for Windows compatability
169 #endif
170
171 #ifndef ENOTSUP
172 #define ENOTSUP EOPNOTSUPP
173 #endif
174
175 #ifndef O_ACCMODE
176 #define O_ACCMODE 0x0003
177 #endif
178
179 /* If these functions do not exist, we need to create our own */
180
181 #ifndef HAVE_ERR
182 void err(int eval, const char *fmt, ...);
183 #endif
184
185 #ifndef HAVE_ERRX
186 void errx(int eval, const char *fmt, ...);
187 #endif
188
189 #ifndef HAVE_WARN
190 void warn(const char *fmt, ...);
191 #endif
192
193 #ifndef HAVE_WARNX
194 void warnx(const char *fmt, ...);
195 #endif
196
197 /* access function */
198 #ifndef F_OK
199 #define F_OK 0 /* test for existence of file */
200 #endif
201
202 #ifndef X_OK
203 #define X_OK 0x01 /* test for execute or search permission */
204 #endif
205
206 #ifndef W_OK
207 #define W_OK 0x02 /* test for write permission */
208 #endif
209
210 #ifndef R_OK
211 #define R_OK 0x04 /* test for read permission */
212 #endif
213
214
215 #ifdef WIN32
216 /****************************************************************
217 *** Windows emulation of opendir()/readdir()
218 *** From php
219 ****************************************************************/
220
221 /* struct dirent - same as Unix */
222
223 struct dirent {
224 long d_ino; /* inode (always 1 in WIN32) */
225 off_t d_off; /* offset to this dirent */
226 int d_reclen; /* length of d_name; was unsigned short */
227 char d_name[_MAX_FNAME + 1]; /* filename (null terminated) */
228 };
229
230
231 /* typedef DIR - not the same as Unix */
232 typedef struct {
233 long handle; /* _findfirst/_findnext handle */
234 short offset; /* offset into directory */
235 short finished; /* 1 if there are not more files */
236 struct _finddata_t fileinfo; /* from _findfirst/_findnext */
237 char *dir; /* the dir we are reading */
238 struct dirent dent; /* the dirent to return */
239 } DIR;
240
241 /* Function prototypes */
242
243
244 #ifdef __cplusplus
245 extern "C" {
246 #endif
247
248 DIR *opendir(const char *);
249 struct dirent *readdir(DIR *);
250 int readdir_r(DIR *, struct dirent *, struct dirent **);
251 int closedir(DIR *);
252 int rewinddir(DIR *);
253
254
255 #ifdef __cplusplus
256 }
257 #endif
258 #endif
259
260
261 /****************************************************************
262 *** AFFLIB internal stuff follows.
263 ****************************************************************/
264
265 #ifdef __cplusplus
266 extern "C" {
267 #endif
268 #ifdef NEVER_DEFINED
269 }
270 #endif
271
272 #if defined(HAVE_LIBEXPAT)
273 #define USE_AFFSIGS
274 #endif
275
276 struct _AFFILE {
277 int version; // 2
278 void *tag; // available to callers; unused by AFFLIB
279
280 struct af_vnode *v; // which function table to use.
281 struct _AFFILE *parent; // for AFF file inside an AFD
282
283 /* For all files */
284 int openflags; // how it was opened
285 int openmode; // how we were asked to open it; more
286 int exists; // did file exist before open was called?
287
288 /* From URLs */
289 char *fname; // Filename of file; be sure to free when done
290 char *protocol; // could be "file" or "s3"
291 char *username; // optionally specified in URL
292 char *password; // from URL; erase after use.
293 char *hostname; // from URL
294 int port; // from URL
295
296 /* Extended Logging */
297 char error_str[64]; // what went wrong
298
299 /* Implement a stream abstraction */
300 uint64_t image_size; // last mappable byte of disk image
301 uint64_t image_size_in_file; // see if it was changed...
302 u_long image_pagesize; // the size of image data segments in this file
303 u_long image_sectorsize;
304 uint64_t pos; // location in stream; should be signed because of comparisons
305
306 /* Page buffer cache */
307 struct aff_pagebuf *pb; // the current page buffer
308 struct aff_pagebuf *pbcache; // array of pagebufs
309 int num_pbufs; // number of pagebufs; default is 1
310 int afftime; // for updating last
311 int64_t cur_page; // used by vnode_raw and vnode_ewf to fake pages
312 // must be able to go negative
313
314 int debug; // for debugging, of course
315 unsigned int badflag_set:1; // is badflag set?
316 unsigned char *badflag; // bad sector flag
317
318
319 /****************************************************************/
320 /* Right now the instance variables for each implementation are here,
321 * which is ugly but easier for development...
322 */
323
324 /* For AFF Segment Files; this could be moved into private storage... */
325 FILE *aseg;
326 struct aff_toc_mem *toc; // table of contents
327 int toc_count; // number of directory elements
328
329 /****************************************************************/
330
331 unsigned int write_md5:1; // automatically write the MD5 for each page
332 unsigned int write_sha1:1;
333 unsigned int write_sha256:1;
334
335
336 /* These are for optimizing updates; really this should go away and we should just
337 * exmaine the TOC to find a hole, but currently we don't do that.
338 */
339 unsigned int direction_changes; // how many times have we changed directions?
340 int last_direction; // should be 1 or -1
341 unsigned int random_access:1; // are we in random access mode?
342
343 /* additional support for writing. */
344 unsigned int compression_type; // preferred compression type
345 int compression_level; // 0 is no compression
346
347
348 /* w_callback:
349 * A callback that is called before and after each segment is written.
350 * Called with the arguments (i,0,0) at the beginning of the write operation.
351 * Called with the arguments (i,j,k) at the end of the write operation.
352 * i = segment number
353 * j = segment length
354 * If segment is being written with compresison, k = compressed length.
355 * If segment is written w/o compression, k = 0
356 */
357 void (*w_callback)(struct affcallback_info *acbi);
358 // called at start and end of compression.
359
360 uint64_t maxsize; // maximum file size of a multi-segment files,
361 // or 0 if this is not a multi-segment file
362
363 /* Performance Counters */
364 uint64_t bytes_memcpy; // total number of bytes memcpy'ed
365 uint64_t pages_written; // total number of pages written
366 uint64_t pages_compressed; // total number of pages compressed
367 uint64_t pages_decompressed;
368 uint64_t pages_read; // total number of pages read
369 uint64_t bytes_written;
370 uint64_t cache_hits;
371 uint64_t cache_misses; // total number of pages flushed from cache
372
373 void *vnodeprivate; // private storage for the vnode
374 void (*error_reporter)(const char *fmt, ...);
375 struct af_crypto *crypto;
376 #ifdef HAVE_PTHREAD
377 pthread_rwlock_t rwlock; // automatically created and destroyed if pthread exists
378 #endif
379 struct af_vnode_info *vni_cache; // vstat cache
380 };
381
382
383
384 /* af_crypto:
385 * copy of AES encrypt and decrypt keys.
386 */
387 void af_crypto_allocate(AFFILE *af);
388 void af_crypto_deallocate(AFFILE *af);
389
390 struct af_crypto {
391 u_int sealing_key_set:1; // encryption key has been set
392 u_int auto_encrypt:1; // encrypt segments when we write
393 u_int auto_decrypt:1; // automatically decrypto when we read
394 #ifdef AES_BLOCK_SIZE
395 AES_KEY ekey; // encrypt key
396 AES_KEY dkey; // decrypt key
397 #endif
398 #ifdef HAVE_OPENSSL_EVP_H
399 EVP_PKEY *sign_privkey; // signing private key (to write signatures)
400 EVP_PKEY *sign_pubkey; // signing public key (to verify signatures)
401 X509 *sign_cert; // signing certificate (for verifying signatures)
402 /* Sealing is kept locally and immediately turned into a dkey & ekey */
403 #endif
404 };
405
406
407 /* The AFF STREAM VNODE */
408 struct af_vnode {
409 int type; // numeric vnode type
410 int flag; // file system flag type
411 const char *name;
412 int (*identify)(const char *fname,int exists); // returns 1 if file system is identified by implementation;
413 int (*open)(AFFILE *af);
414 int (*close)(AFFILE *af);
415 int (*vstat)(AFFILE *af,struct af_vnode_info *); // returns info about the vnode image file
416 int (*get_seg)(AFFILE *af,const char *name,unsigned long *arg, u_char *data,size_t *datalen);
417 int (*get_next_seg)(AFFILE *af,char *segname,size_t segname_len,
418 unsigned long *arg, u_char *data, size_t *datalen);
419 int (*rewind_seg)(AFFILE *af);
420 int (*update_seg)(AFFILE *af,const char *name,unsigned long arg,
421 const u_char *value,u_int vallen);
422 int (*del_seg)(AFFILE *af,const char *name);
423 int (*read)(AFFILE *af,u_char *buf,uint64_t offset,size_t count);
424 int (*write)(AFFILE *af,u_char *buf,uint64_t offset,size_t count);
425 };
426
427 /* VNODE Flags */
428 #define AF_VNODE_TYPE_PRIMITIVE 0x01 // single-file implementation
429 #define AF_VNODE_TYPE_COMPOUND 0x02 // multi-file implementation
430 #define AF_VNODE_TYPE_RELIABLE 0x04 // writes are reliable; no need to verify them.
431 #define AF_VNODE_MAXSIZE_MULTIPLE 0x08 // maxsize must be multiple of pagesize (for AFM and splitraw)
432 #define AF_VNODE_NO_SIGNING 0x10 // vnode does not support signing (like raw)
433 #define AF_VNODE_NO_SEALING 0x20 // vnode does not support sealing (like raw and afd)
434
435 #define AF_SEALING_VNODE(af) (!(af->v->flag & AF_VNODE_NO_SEALING))
436 #define AF_SIGNING_VNODE(af) (!(af->v->flag & AF_VNODE_NO_SIGNING))
437 #define AF_SEALING(af) AF_SEALING_VNODE(af) && af->crypto && af->crypto->sealing_key_set
438
439
440 /* The header for an AFF file. All binary numbers are stored in network byte order. */
441 #define AF_HEADER "AFF10\r\n\000"
442 struct af_head {
443 char header[8]; // "AFF10\r\n\000"
444 /* segments follow */
445 };
446
447
448 /* The header of each segment */
449 #define AF_SEGHEAD "AFF\000"
450 struct af_segment_head {
451 char magic[4]; // "AFF\000"
452 unsigned long name_len:32; // length of segment name
453 unsigned long data_len:32; // length of segment data, if any
454 unsigned long flag:32; // argument for name;
455 /* name follows, then data */
456 };
457
458 /* The tail of each segment */
459 #define AF_SEGTAIL "ATT\000"
460 struct af_segment_tail {
461 char magic[4]; // "ATT\000"
462 unsigned long segment_len:32; // includes head, tail, name & length
463 };
464
465
466 /* How 64-bit values are stored in a segment */
467 #pragma pack(1)
468 struct aff_quad {
469 unsigned long low:32;
470 unsigned long high:32;
471 };
472 #pragma pack()
473
474
475 /* As it is kept in memory */
476 struct aff_toc_mem {
477 char *name; // name of this directory entry
478 uint64_t offset; // offset from beginning of file.
479 uint64_t segment_len; // includes head, tail, name & length
480 };
481
482 /* How encryption keys are stored */
483 struct affkey {
484 u_char version[4];
485 u_char affkey_aes256[32]; // AFF key encrypted with SHA-256 of passphrase
486 // encrypted as two codebooks in a row; no need for CBC
487 u_char zeros_aes256[16]; // all zeros encrypted with SHA-256 of passphrase
488 };
489 #define AFFKEY_SIZE 4+32+16
490
491
492 void af_initialize(); // initialize the AFFLIB
493 // automatically called by af_open()
494
495 /* Internal identification routines */
496 int af_identify_file_type(const char *filename,int exists); // returns type of a file; if exists=1, file must exist
497 const char *af_identify_file_name(const char *filename,int exists); // returns name of a file type;
498
499 /* AFF implementation types returned by af_identify_type() and af_identify_name()*/
500
501 #define AF_IDENTIFY_RAW 0 // file is a raw file
502 #define AF_IDENTIFY_AFF 1 // file is an AFF file
503 #define AF_IDENTIFY_AFD 2 // file is a directory of AFF files
504 #define AF_IDENTIFY_EVF 3 // file is an EnCase file
505 #define AF_IDENTIFY_EVD 4 // file is a .E01 file when there are more files following
506 #define AF_IDENTIFY_SPLIT_RAW 5 // file is a split raw file
507 #define AF_IDENTIFY_AFM 6 // file is raw file with metadata
508 #define AF_IDENTIFY_EWF 7 // libewf
509 #define AF_IDENTIFY_S3 8 // is an s3:/// file
510 #define AF_IDENTIFY_VMDK 9 // QEMU support for VMDK format
511 #define AF_IDENTIFY_DMG 10 // QEMU support for Apple DMG format
512 #define AF_IDENTIFY_SPARSEIMAGE 11 // QEMU support for Apple SPARSEIMAGE format
513
514
515 #define AF_IDENTIFY_ERR -1 // error encountered on identify
516 #define AF_IDENTIFY_NOEXIST -2 // file does not exist
517
518
519 AFFILE *af_open_with(const char *filename,int flags,int mode, struct af_vnode *v);
520 extern struct af_vnode *af_vnode_array[]; // array of filesystems; last is a "0"
521
522 int af_last_seg(AFFILE *af,char *last_segname,int last_segname_len,int64_t *pos);
523 int af_make_badflag(AFFILE *af); // creates a badflag and puts it
524 int af_make_gid(AFFILE *af); // created an AF_IMAGE_GID if it doesn't exist
525 extern char af_error_str[64];
526
527
528 #define AFF_DEFAULT_PAGESIZE (1024*1024*16)
529
530
531 /* afflib_os.cpp:
532 * Operating-system specific code.
533 */
534
535 /* af_figure_media:
536 * Returns information about the media in a structure.
537 * Returns 0 if successful, -1 if error.
538 */
539
540 struct af_figure_media_buf {
541 int version;
542 int sector_size;
543 uint64_t total_sectors;
544 uint64_t max_read_blocks; // was previously 4-bytes; must be 8!
545 };
546 int af_figure_media(int fd,struct af_figure_media_buf *);
547
548 /****************************************************************
549 *** Lowest-level routines for manipulating the AFF File...
550 ****************************************************************/
551
552 /* Navigating within the AFFILE */
553 /* probe the next segment.
554 * Returns: 0 if success
555 * -1 if error
556 * -2 if segname_len was not large enough to hold segname
557 * - segname - the name of the next segment.
558 * - segsize - number of bytes the entire segment is.
559 *
560 * doesn't change af->aseg pointer if do_rewind is true, otherwise leaves stream
561 * positioned ready to read the data
562 */
563
564 int af_probe_next_seg(AFFILE *af,char *segname,size_t segname_len,
565 unsigned long *arg,size_t *datasize, size_t *segsize,int do_rewind);
566 int af_backspace(AFFILE *af); // back up one segment
567
568
569
570 /* find the given segment and return 0 if found, filling in the fields.
571 * Leave the file pointer positioned at the start of the segment.
572 * Return -1 if segment is not found, and leave pointer at the end
573 */
574 int af_get_seg(AFFILE *af,const char *name,unsigned long *arg,
575 u_char *data,size_t *datalen);
576
577 /****************************************************************
578 *** Reading functions
579 ****************************************************************/
580
581
582 /* Support for data pages. This is what the stream system is built upon.
583 * Note: pagename to string translation happens inside afflib.cpp, not inside
584 * the vnode driver.
585 */
586 void af_read_sizes(AFFILE *af); // sets up values if we can get them.
587 int af_set_pagesize(AFFILE *af,u_long pagesize); // sets the pagesize; fails with -1 if imagesize >=0
588 int af_set_sectorsize(AFFILE *AF,int sectorsize); // fails with -1 if imagesize>=0
589 int af_get_sectorsize(AFFILE *AF); // returns sector size
590 int af_has_pages(AFFILE *af); // does the underlying system support pages?
591 int af_page_size(AFFILE *af); // returns page size, or -1
592 int af_get_page_raw(AFFILE *af,int64_t pagenum,unsigned long *arg,u_char *data,size_t *bytes);
593 int af_get_page(AFFILE *af,int64_t pagenum,u_char *data,size_t *bytes);
594 #define AF_SIGFLAG_NOSIG 0x0001 // do not write signatures with af_update_segf()
595 #define AF_SIGFLAG_NOSEAL 0x0002 // do not encrypt an af_update_segf()
596
597 /****************************************************************
598 *** Writing functions
599 ****************************************************************/
600
601 extern int af_cache_debug; // sets level of verbosity */
602 int af_set_maxsize(AFFILE *af,int64_t size); // sets maximum AFF file size
603 int af_update_page(AFFILE *af,int64_t pagenum,u_char *data,int datalen);
604 int af_update_segf(AFFILE *af,const char *name,
605 unsigned long arg,const u_char *value,u_int vallen,u_int sigflag);
606
607 void af_invalidate_vni_cache(AFFILE *af);
608 void af_cache_writethrough(AFFILE *af,int64_t pagenum,
609 const u_char *buf,int bufflen);
610 int af_cache_flush(AFFILE *af); // write buffers to disk
611 struct aff_pagebuf *af_cache_alloc(AFFILE *af,int64_t pagenum);
612
613
614 /****************************************************************
615 ***/
616
617 /* afflib_util.cpp
618 */
619 uint64_t af_decode_q(u_char buf[8]); // return buf[8] into an unsigned quad
620 const char *af_commas(char buf[64],int64_t val);
621 int af_hasmeta(const char *buf); // return 1 if buf has shell metacharacters
622 int af_is_filestream(const char *filename); // return 1 if file:// or filename
623 void af_parse_url(const char *url,char **protocol,char **hostname,
624 char **username,char **password,int *port,char **path);
625
626 #ifndef HAVE_STRLCPY
627 size_t strlcpy(char *dest,const char *src,size_t dest_size);
628 #endif
629
630 #ifndef HAVE_STRLCAT
631 size_t strlcat(char *dest,const char *src,size_t dest_size);
632 #endif
633
634
635 /****************************************************************
636 *** Table of Contents
637 ****************************************************************/
638
639 /* Needs a rewrite for efficiency */
640
641 /* afflib_toc.cpp:
642 * Table of contents management routines
643 * Remember: all of these routines may fail, because the whole TOC may not
644 * fit in memory...
645 *
646 * This is all experimental right now.
647 */
648
649 int aff_segment_overhead(const char *segname);
650 int aff_toc_free(AFFILE *af);
651 void aff_toc_print(AFFILE *af);
652 //int aff_toc_append(AFFILE *af,const char *segname,int64_t offset);
653 int aff_toc_build(AFFILE *af); // build by scanning the AFFILE
654 struct aff_toc_mem *aff_toc(AFFILE *af,const char *segname);
655 int aff_toc_del(AFFILE *af,const char *segname);
656 void aff_toc_update(AFFILE *af,const char *segname,uint64_t offset,uint64_t datalen);
657
658 /* lzma_glue.cpp:
659 * For the LZMA compression engine
660 */
661 int lzma_compress(u_char *dest,size_t *destLen, const u_char *data,size_t datalen,int level);
662 int lzma_uncompress(u_char *buf,size_t *buflen, const u_char *cbuf,size_t cbuf_size);
663
664 #ifdef NEVER_DEFINED
665 {
666 #endif
667 #ifdef __cplusplus
668 }
669 #endif
670 #endif
671
672
0 /*
1 * afflib_os.cpp:
2 *
3 * The OS-specific features of AFFLIB
4 */
5
6 #include "affconfig.h"
7 #include "afflib.h"
8 #include "afflib_i.h"
9
10 #ifdef HAVE_SYS_PARAM_H
11 #include <sys/param.h>
12 #endif
13
14 #if defined(__FreeBSD_version) && __FreeBSD_version<500000
15 #undef HAVE_SYS_DISK_H
16 #endif
17
18 #if defined(HAVE_SYS_DISK_H)
19 #include <sys/disk.h>
20 #endif
21
22
23 #ifdef HAVE_LINUX_FS_H
24 #include <linux/fs.h>
25 #endif
26
27 #ifdef HAVE_SYS_IOCTL_H
28 #include <sys/ioctl.h> // needed for Linux
29 #endif
30
31 /****************************************************************
32 *** Extra code for Windows...
33 ****************************************************************/
34
35 #ifdef WIN32
36 #pragma warning(disable: 4996)
37 int64 ftello(FILE *stream)
38 {
39 fpos_t pos;
40 if(fgetpos(stream,&pos) != 0){
41 return -1;
42 }
43 return pos;
44 }
45
46 int fseeko(FILE *stream,int64 offset,int whence)
47 {
48
49
50 switch(whence){
51 case SEEK_SET:
52 break; // jump down to fsetpos()
53 case SEEK_CUR:
54 offset += ftello(stream);
55 break;
56 case SEEK_END:
57 fseek(stream,0L,SEEK_END); // go to the end; hope this works for big files
58 offset = ftello(stream) - offset;
59 break;
60 default:
61 return -1;
62 }
63 return fsetpos(stream,&offset);
64
65 }
66 #endif
67
68
69
70
71 /****************************************************************/
72
73
74 /* af_figure_media():
75 *
76 * This is a function that returns, for the file handle of an open
77 * device, the sector_size, total_sectors, and maximum number of
78 * blocks that can be read at a time (or 0 if there is no max). There
79 * is a generic implementation at the bottom, and operating-specific
80 * versions above.
81 */
82
83 #ifdef linux
84 typedef unsigned long long int u64; // required for slackware
85 #endif
86
87 int af_figure_media(int fd,struct af_figure_media_buf *afb)
88 {
89 memset(afb,0,sizeof(*afb));
90 afb->version = 1;
91
92 #ifdef __APPLE__
93 #define MEDIA_FIGURED
94 if(ioctl(fd,DKIOCGETBLOCKSIZE,&afb->sector_size)){
95 afb->sector_size = 512; // assume 512
96 }
97 if(ioctl(fd,DKIOCGETBLOCKCOUNT,&afb->total_sectors)){
98 afb->total_sectors=0; // seeking not allowed on stdin
99 }
100 if(ioctl(fd,DKIOCGETMAXBLOCKCOUNTREAD,&afb->max_read_blocks)){
101 afb->max_read_blocks = 0; // read all you want
102 }
103 #endif
104 #if defined(__FreeBSD__) && defined(DIOCGSECTORSIZE)
105 #define MEDIA_FIGURED
106 if(ioctl(fd,DIOCGSECTORSIZE,&afb->sector_size)){
107 afb->sector_size = 512; // can't figure it out; go with the default
108 }
109 off_t inbytes=0;
110 if(ioctl(fd,DIOCGMEDIASIZE,&inbytes)){
111 afb->total_sectors = 0;
112 }
113 if(inbytes % afb->sector_size != 0){
114 fprintf(stderr,"ioctl(DIOCGSECTORSIZE) returns %d bytes\n", afb->sector_size);
115 fprintf(stderr,"ioctl(DIOCGMEDIASIZE) returns %d bytes\n", inbytes);
116 fprintf(stderr,"which is not an even number of sectors.\n");
117 return -1;
118 }
119 afb->total_sectors = inbytes / afb->sector_size;
120 afb->max_read_blocks = 0;
121 #endif
122 #ifdef linux
123 #define MEDIA_FIGURED
124 /* With Linux, we figure out how many bytes there are and get sector size
125 * from a #define
126 */
127
128 afb->sector_size = BLOCK_SIZE;
129 #ifdef BLKGETSIZE64
130 uint64_t total_bytes=0;
131 if(ioctl(fd,BLKGETSIZE64,&total_bytes)){
132 total_bytes = 0;
133 }
134 #else
135 int total_bytes=0;
136 if(ioctl(fd,BLKGETSIZE,&total_bytes)){
137 total_bytes = 0;
138 }
139 #endif
140
141
142 afb->total_sectors = total_bytes / afb->sector_size;
143 afb->max_read_blocks = 0;
144 #endif
145 #ifndef MEDIA_FIGURED
146
147 /* Unknown OS type. Try our best-effort guess,
148 */
149 #ifdef BLOCK_SIZE
150 afb->sector_size = BLOCK_SIZE; // it's a good guess
151 #else
152 afb->sector_size = 512; // it's a good guess
153 #endif
154
155 /* Try seeking to the end of fd and ask where we are! */
156
157 off_t start_pos = lseek(fd,0,SEEK_CUR); // find where we are
158 off_t end_of_file = lseek(fd,0,SEEK_END);
159
160 if(end_of_file==-1){
161 end_of_file = 0; // can't figure it.
162 }
163 lseek(fd,start_pos,SEEK_SET); // go back to the starting position
164
165 afb->total_sectors = end_of_file / afb->sector_size;
166 afb->max_read_blocks = 0;
167 #endif
168 return 0;
169 }
170
171
172
0 /*
1 * The AFFLIB page abstraction.
2 */
3
4 /*
5 * Copyright (c) 2005, 2006
6 * Simson L. Garfinkel and Basis Technology, Inc.
7 * All rights reserved.
8 *
9 * This code is derrived from software contributed by
10 * Simson L. Garfinkel
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
20 * 3. All advertising materials mentioning features or use of this software
21 * must display the following acknowledgement:
22 * This product includes software developed by Simson L. Garfinkel
23 * and Basis Technology Corp.
24 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
25 * contributors to this program may be used to endorse or promote
26 * products derived from this software without specific prior written
27 * permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
30 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
31 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
34 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
37 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
38 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
39 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
40 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * SUCH DAMAGE.
42 */
43
44 #include "affconfig.h"
45 #include "afflib.h"
46 #include "afflib_i.h"
47
48
49 /* af_read_sizes:
50 * Get the page sizes if they are set in the file.
51 */
52 void af_read_sizes(AFFILE *af)
53 {
54 af_get_seg(af,AF_SECTORSIZE,&af->image_sectorsize,0,0);
55 if(af->image_sectorsize==0) af->image_sectorsize = 512; // reasonable default
56
57 if(af_get_seg(af,AF_PAGESIZE,&af->image_pagesize,0,0)){
58 af_get_seg(af,AF_SEGSIZE_D,&af->image_pagesize,0,0); // try old name
59 }
60
61 /* Read the badflag if it is present */
62 size_t sectorsize = af->image_sectorsize;
63 if(af->badflag==0) af->badflag = (unsigned char *)malloc(sectorsize);
64 if(af_get_seg(af,AF_BADFLAG,0,af->badflag,(size_t *)&sectorsize)==0){
65 af->badflag_set = 1;
66 }
67
68 /* Read the image file segment if it is present.
69 * If it isn't, scan through the disk image to figure out the size of the disk image.
70 */
71
72 if(af_get_segq(af,AF_IMAGESIZE,(int64_t *)&af->image_size)){
73
74 /* Calculate the imagesize by scanning all of the pages that are in
75 * the disk image and finding the highest page number.
76 * Then read that page to find the last allocated byte.
77 */
78 char segname[AF_MAX_NAME_LEN];
79 size_t datalen = 0;
80 af_rewind_seg(af); // start at the beginning
81 int64_t highest_page_number = 0;
82 while(af_get_next_seg(af,segname,sizeof(segname),0,0,&datalen)==0){
83 if(segname[0]==0) continue; // ignore sector
84 int64_t pagenum = af_segname_page_number(segname);
85 if(pagenum > highest_page_number) highest_page_number = pagenum;
86 }
87 size_t highest_page_len = 0;
88 if(af_get_page(af,highest_page_number,0,&highest_page_len)==0){
89 af->image_size = af->image_pagesize * highest_page_number + highest_page_len;
90 }
91 }
92 af->image_size_in_file = af->image_size;
93 }
94
95
96 int af_page_size(AFFILE *af)
97 {
98 return af->image_pagesize;
99 }
100
101 /* af_set_sectorsize:
102 * Sets the sectorsize.
103 * Fails with -1 if imagesize >=0 unless these changes permitted
104 */
105 int af_set_sectorsize(AFFILE *af,int sectorsize)
106 {
107 struct af_vnode_info vni;
108 af_vstat(af,&vni);
109 if(vni.changable_pagesize==0 && af->image_size>0){
110 errno = EINVAL;
111 return -1;
112 }
113 af->image_sectorsize =sectorsize;
114 if(af->badflag==0) af->badflag = (unsigned char *)malloc(sectorsize);
115 else af->badflag = (unsigned char *)realloc(af->badflag,sectorsize);
116 af->badflag_set = 0;
117
118 if(af_update_seg(af,AF_SECTORSIZE,sectorsize,0,0)){
119 if(errno != ENOTSUP) return -1;
120 }
121 return 0;
122 }
123
124 int af_get_sectorsize(AFFILE *af) // returns sector size
125 {
126 return af->image_sectorsize;
127 }
128
129 /*
130 * af_set_pagesize:
131 * Sets the pagesize. Fails with -1 if it can't be changed.
132 */
133 int af_set_pagesize(AFFILE *af,u_long pagesize)
134 {
135 /* Allow the pagesize to be changed if it hasn't been set yet
136 * and if this format doesn't support metadata updating (which is the raw formats)
137 */
138 struct af_vnode_info vni;
139
140 af_vstat(af,&vni);
141
142 if(vni.changable_pagesize==0 && af->image_size>0){
143 if(pagesize==af->image_pagesize) return 0; // it's already set to this, so let it pass
144 errno = EINVAL;
145 return -1;
146 }
147 if(pagesize % af->image_sectorsize != 0){
148 (*af->error_reporter)("Cannot set pagesize to %d (sectorsize=%d)\n",
149 pagesize,af->image_sectorsize);
150 errno = EINVAL;
151 return -1;
152 }
153
154 af->image_pagesize = pagesize;
155 if(af_update_seg(af,AF_PAGESIZE,pagesize,0,0)){
156 if(errno != ENOTSUP) return -1; // error updating (don't report ENOTSUP);
157 }
158 return 0;
159 }
160
161
162 /****************************************************************
163 *** page-level interface
164 ****************************************************************/
165
166 int af_get_page_raw(AFFILE *af,int64_t pagenum,unsigned long *arg,
167 unsigned char *data,size_t *bytes)
168 {
169 char segname[AF_MAX_NAME_LEN];
170
171 memset(segname,0,sizeof(segname));
172 sprintf(segname,AF_PAGE,pagenum);
173 int r = af_get_seg(af,segname,arg,data,bytes);
174 if(r!=0){
175 /* Couldn't read with AF_PAGE; try AF_SEG_D.
176 * This is legacy for the old AFF files. Perhaps we should delete it.
177 */
178 sprintf(segname,AF_SEG_D,pagenum);
179 r = af_get_seg(af,segname,arg,data,bytes);
180 }
181 /* Update the counters */
182 if(r==0 && bytes && *bytes>0) af->pages_read++; // note that we read a page
183 return r;
184 }
185
186 /* af_get_page:
187 * Get a page from its named segment.
188 * If the page is compressed, uncompress it.
189 * data points to a segmenet of at least *bytes;
190 * *bytes is then modified to indicate the actual amount of bytes read.
191 * Return 0 if success, -1 if fail.
192 */
193
194 int af_get_page(AFFILE *af,int64_t pagenum,unsigned char *data,size_t *bytes)
195 {
196 unsigned long arg=0;
197 size_t page_len=0;
198
199 if (af_trace){
200 fprintf(af_trace,"af_get_page(%p,pagenum=%"I64d",buf=%p,bytes=%zu)\n",af,pagenum,data,*bytes);
201 }
202
203 /* Find out the size of the segment and if it is compressed or not.
204 * If we can't find it with new nomenclature, try the old one...
205 */
206 int r = af_get_page_raw(af,pagenum,&arg,0,&page_len);
207 if(r){
208 /* Segment doesn't exist.
209 * If we have been provided with a buffer,
210 * fill buffer with the 'bad segment' flag and return.
211 */
212 if (data && (af->openmode&AF_BADBLOCK_FILL)) {
213 for(size_t i = 0;i <= af->image_pagesize - af->image_sectorsize;
214 i+= af->image_sectorsize){
215 memcpy(data+i,af->badflag,af->image_sectorsize);
216 af->bytes_memcpy += af->image_sectorsize;
217 }
218 }
219 return r; // segment doesn't exist
220 }
221
222 /* If no data buffer was provided, just return */
223 if(data==0) return 0;
224
225 /* If the segment isn't compressed, just get it*/
226 unsigned long pageflag = 0;
227 if((arg & AF_PAGE_COMPRESSED)==0){
228 int ret = af_get_page_raw(af,pagenum,&pageflag,data,bytes);
229 if(*bytes > page_len) *bytes = page_len; // we only read this much
230 if(ret!=0) return ret; // some error happened?
231 }
232 else {
233 /* Allocate memory to hold the compressed segment */
234 unsigned char *compressed_data = (unsigned char *)malloc(page_len);
235 size_t compressed_data_len = page_len;
236 if(compressed_data==0){
237 return -2; // memory error
238 }
239
240 /* Get the data */
241 if(af_get_page_raw(af,pagenum,&pageflag,compressed_data,&compressed_data_len)){
242 free(compressed_data);
243 return -3; // read error
244 }
245
246 /* Now uncompress directly into the buffer provided by the caller. */
247 int res = -1; // 0 is success
248
249 switch((pageflag & AF_PAGE_COMP_ALG_MASK)){
250 case AF_PAGE_COMP_ALG_ZERO:
251 if(compressed_data_len != 4){
252 (*af->error_reporter)("ALG_ZERO compressed data is %d bytes, expected 4.",compressed_data_len);
253 break;
254 }
255 memset(data,0,af->image_pagesize);
256 *bytes = ntohl(*(long *)compressed_data);
257 res = 0; // not very hard to decompress with the ZERO compressor.
258 break;
259
260 case AF_PAGE_COMP_ALG_ZLIB:
261 res = uncompress(data,(uLongf *)bytes,compressed_data,compressed_data_len);
262 switch(res){
263 case Z_OK:
264 break;
265 case Z_ERRNO:
266 (*af->error_reporter)("Z_ERRNOR decompressing segment %"I64d,pagenum);
267 case Z_STREAM_ERROR:
268 (*af->error_reporter)("Z_STREAM_ERROR decompressing segment %"I64d,pagenum);
269 case Z_DATA_ERROR:
270 (*af->error_reporter)("Z_DATA_ERROR decompressing segment %"I64d,pagenum);
271 case Z_MEM_ERROR:
272 (*af->error_reporter)("Z_MEM_ERROR decompressing segment %"I64d,pagenum);
273 case Z_BUF_ERROR:
274 (*af->error_reporter)("Z_BUF_ERROR decompressing segment %"I64d,pagenum);
275 case Z_VERSION_ERROR:
276 (*af->error_reporter)("Z_VERSION_ERROR decompressing segment %"I64d,pagenum);
277 default:
278 (*af->error_reporter)("uncompress returned an invalid value in get_segment");
279 }
280 break;
281
282 #ifdef USE_LZMA
283 case AF_PAGE_COMP_ALG_LZMA:
284 res = lzma_uncompress(data,bytes,compressed_data,compressed_data_len);
285 if (af_trace) fprintf(af_trace," LZMA decompressed page %"I64d". %zd bytes => %zd bytes\n",
286 pagenum,compressed_data_len,*bytes);
287 switch(res){
288 case 0:break; // OK
289 case 1:(*af->error_reporter)("LZMA header error decompressing segment %"I64d"\n",pagenum);
290 break;
291 case 2:(*af->error_reporter)("LZMA memory error decompressing segment %"I64d"\n",pagenum);
292 break;
293 }
294 break;
295 #endif
296
297 default:
298 (*af->error_reporter)("Unknown compression algorithm 0x%d",
299 pageflag & AF_PAGE_COMP_ALG_MASK);
300 break;
301 }
302
303 free(compressed_data); // don't need this one anymore
304 af->pages_decompressed++;
305 if(res!=Z_OK) return -1;
306 }
307
308 /* If the page size is larger than the sector_size,
309 * make sure that the rest of the sector is zeroed, and that the
310 * rest after that has the 'bad block' notation.
311 */
312 if(af->image_pagesize > af->image_sectorsize){
313 const int SECTOR_SIZE = af->image_sectorsize; // for ease of typing
314 size_t bytes_left_in_sector = (SECTOR_SIZE - (*bytes % SECTOR_SIZE)) % SECTOR_SIZE;
315 for(size_t i=0;i<bytes_left_in_sector;i++){
316 data[*bytes + i] = 0;
317 }
318 size_t end_of_data = *bytes + bytes_left_in_sector;
319
320 /* Now fill to the end of the page... */
321 for(size_t i = end_of_data; i <= af->image_pagesize-SECTOR_SIZE; i+=SECTOR_SIZE){
322 memcpy(data+i,af->badflag,SECTOR_SIZE);
323 af->bytes_memcpy += SECTOR_SIZE;
324 }
325 }
326 return 0;
327 }
328
329
330 static bool is_buffer_zero(unsigned char *buf,int buflen)
331 {
332 for(int i=0;i<buflen;i++){
333 if(buf[i]) return false;
334 }
335 return true;
336 }
337
338 /* Write a actual data segment to the disk and sign if necessary. */
339 int af_update_page(AFFILE *af,int64_t pagenum,unsigned char *data,int datalen)
340 {
341 char segname_buf[32];
342 snprintf(segname_buf,sizeof(segname_buf),AF_PAGE,pagenum); // determine segment name
343
344 #ifdef USE_AFFSIGS
345 /* Write out the signature if we have a private key */
346 if(af->crypto && af->crypto->sign_privkey){
347 af_sign_seg3(af,segname_buf,0,data,datalen,AF_SIGNATURE_MODE1);
348 }
349 #endif
350
351 #ifdef HAVE_MD5
352 /* Write out MD5 if requested */
353 if(af->write_md5){
354 unsigned char md5_buf[16];
355 char md5name_buf[32];
356 MD5(data,datalen,md5_buf);
357 snprintf(md5name_buf,sizeof(md5name_buf),AF_PAGE_MD5,pagenum);
358 af_update_segf(af,md5name_buf,0,md5_buf,sizeof(md5_buf),AF_SIGFLAG_NOSIG); // ignore failure
359 }
360 #endif
361 #ifdef HAVE_SHA1
362 /* Write out SHA1 if requested */
363 if(af->write_sha1){
364 unsigned char sha1_buf[20];
365 char sha1name_buf[32];
366 SHA1(data,datalen,sha1_buf);
367 snprintf(sha1name_buf,sizeof(sha1name_buf),AF_PAGE_SHA1,pagenum);
368 af_update_segf(af,sha1name_buf,0,sha1_buf,sizeof(sha1_buf),AF_SIGFLAG_NOSIG); // ignore failure
369 }
370 #endif
371 /* Write out SHA256 if requested and if SHA256 is available */
372 if(af->write_sha256){
373 unsigned char sha256_buf[32];
374 if(af_SHA256(data,datalen,sha256_buf)==0){
375 char sha256name_buf[32];
376 snprintf(sha256name_buf,sizeof(sha256name_buf),AF_PAGE_SHA256,pagenum);
377 af_update_segf(af,sha256name_buf,0,sha256_buf,sizeof(sha256_buf),AF_SIGFLAG_NOSIG); // ignore failure
378 }
379 }
380
381 /* Check for bypass */
382 if(af->v->write){
383 int r = (*af->v->write)(af,data,af->image_pagesize * pagenum,datalen);
384 if(r!=datalen) return -1;
385 return 0;
386 }
387
388 struct affcallback_info acbi;
389 int ret = 0;
390 uint64_t starting_pages_written = af->pages_written;
391
392 /* Setup the callback structure */
393 memset(&acbi,0,sizeof(acbi));
394 acbi.info_version = 1;
395 acbi.af = af->parent ? af->parent : af;
396 acbi.pagenum = pagenum;
397 acbi.bytes_to_write = datalen;
398
399 size_t destLen = af->image_pagesize; // it could be this big.
400
401 /* Compress and write the data, if we are allowed to compress */
402 if(af->compression_type != AF_COMPRESSION_ALG_NONE){
403 unsigned char *cdata = (unsigned char *)malloc(destLen); // compressed data
404 unsigned long *ldata = (unsigned long *)cdata; // allows me to reference as a buffer of unsigned longs
405 if(cdata!=0){ // If data could be allocated
406 int cres = -1; // compression results
407 unsigned int flag = 0; // flag for data segment
408 int dont_compress = 0;
409
410 /* Try zero compression first; it's the best algorithm we have */
411 if(is_buffer_zero(data,datalen)){
412 acbi.compression_alg = AF_PAGE_COMP_ALG_ZERO;
413 acbi.compression_level = AF_COMPRESSION_MAX;
414
415 if(af->w_callback) { acbi.phase = 1; (*af->w_callback)(&acbi); }
416
417 *ldata = htonl(datalen); // store the data length
418 destLen = 4; // 4 bytes
419 flag = AF_PAGE_COMPRESSED | AF_PAGE_COMP_ALG_ZERO | AF_PAGE_COMP_MAX;
420 cres = 0;
421
422 acbi.compressed = 1; // it was compressed
423 if(af->w_callback) {acbi.phase = 2;(*af->w_callback)(&acbi);}
424 }
425
426 #ifdef USE_LZMA
427 if(cres!=0 && af->compression_type==AF_COMPRESSION_ALG_LZMA){ // try to compress with LZMA
428 acbi.compression_alg = AF_PAGE_COMP_ALG_LZMA;
429 acbi.compression_level = 7; // right now, this is the level we use
430 if(af->w_callback) { acbi.phase = 1; (*af->w_callback)(&acbi); }
431
432 cres = lzma_compress(cdata,&destLen,data,datalen,9);
433 #if 0
434 switch(cres){
435 case 0:break; // OKAY
436 case 1: (*af->error_reporter)("LZMA: Unspecified Error\n");break;
437 case 2: (*af->error_reporter)("LZMA: Memory Allocating Error\n");break;
438 case 3: (*af->error_reporter)("LZMA: Output buffer OVERFLOW\n"); break;
439 default: (*af->error_reporter)("LZMA: Unknown error %d\n",cres);break;
440 }
441 #endif
442 if(cres==0){
443 flag = AF_PAGE_COMPRESSED | AF_PAGE_COMP_ALG_LZMA;
444 acbi.compressed = 1;
445 if(af->w_callback) {acbi.phase = 2;(*af->w_callback)(&acbi);}
446 }
447 else {
448 /* Don't bother reporting LZMA errors; we just won't compress */
449 dont_compress = 1;
450 if(af->w_callback) {acbi.phase = 2;(*af->w_callback)(&acbi);}
451 }
452 }
453 #endif
454
455 if(cres!=0
456 && af->compression_type==AF_COMPRESSION_ALG_ZLIB
457 && dont_compress==0){ // try to compress with zlib
458 acbi.compression_alg = AF_PAGE_COMP_ALG_ZLIB; // only one that we support
459 acbi.compression_level = af->compression_level;
460 if(af->w_callback) { acbi.phase = 1; (*af->w_callback)(&acbi); }
461
462 cres = compress2((Bytef *)cdata, (uLongf *)&destLen,
463 (Bytef *)data,datalen, af->compression_level);
464
465 if(cres==0){
466 flag = AF_PAGE_COMPRESSED | AF_PAGE_COMP_ALG_ZLIB;
467 if(af->compression_level == AF_COMPRESSION_MAX){
468 flag |= AF_PAGE_COMP_MAX; // useful to know it can't be better
469 }
470 }
471 acbi.compressed = 1; // it was compressed (or not compressed)
472 if(af->w_callback) {acbi.phase = 2;(*af->w_callback)(&acbi);}
473 }
474
475 if(cres==0 && destLen < af->image_pagesize){
476 /* Prepare to write out the compressed segment with compression */
477 if(af->w_callback) {acbi.phase = 3;(*af->w_callback)(&acbi);}
478 ret = af_update_segf(af,segname_buf,flag,cdata,destLen,AF_SIGFLAG_NOSIG);
479 acbi.bytes_written = destLen;
480 if(af->w_callback) {acbi.phase = 4;(*af->w_callback)(&acbi);}
481 if(ret==0){
482 af->pages_written++;
483 af->pages_compressed++;
484 }
485 }
486 free(cdata);
487 cdata = 0;
488 }
489 }
490
491 /* If a compressed segment was not written, write it uncompressed */
492 if(af->pages_written == starting_pages_written){
493 if(af->w_callback) {acbi.phase = 3;(*af->w_callback)(&acbi);}
494 ret = af_update_segf(af,segname_buf,0,data,datalen,AF_SIGFLAG_NOSIG);
495 acbi.bytes_written = datalen;
496 if(af->w_callback) {acbi.phase = 4;(*af->w_callback)(&acbi);}
497 if(ret==0){
498 acbi.bytes_written = datalen; // because that is how much we wrote
499 af->pages_written++;
500 }
501 }
502 return ret;
503 }
504
505 /****************************************************************
506 *** Cache interface
507 ****************************************************************/
508
509 /* The page cache is a read/write cache.
510 *
511 * Pages that are read are cached after they are decompressed.
512 * When new pages are fetched, we check the cache first to see if they are there;
513 * if so, they are satsfied by the cache.
514 *
515 * Modifications are written to the cache, then dumped to the disk.
516 *
517 * The cache is managed by two functions:
518 * af_cache_flush(af) - (prevously af_purge)
519 * - Makes sure that all dirty buffers are written.
520 * - Sets af->pb=NULL (no current page)
521 * - (returns 0 if success, -1 if failure.)
522 *
523 * af_cache_writethrough(af,page,buf,buflen)
524 * - used for write bypass
525 *
526 * af_cache_load(af,page) -
527 * - If page is already in the cache, return it.
528 * - If cache is filled, randomly discard a page
529 * - if page is on the disk, load the page.
530 * - Sets af->bp to be the page that was loaded.
531 *
532 */
533
534 static int cachetime = 0;
535
536
537 int af_cache_flush(AFFILE *af)
538 {
539 if(af_trace) fprintf(af_trace,"af_cache_flush()\n");
540 int ret = 0;
541 for(int i=0;i<af->num_pbufs;i++){
542 struct aff_pagebuf *p = &af->pbcache[i];
543 if(p->pagebuf_valid && p->pagebuf_dirty){
544 if(af_update_page(af,p->pagenum,p->pagebuf,p->pagebuf_bytes)){
545 ret = -1; // got an error; keep going, though
546 }
547 p->pagebuf_dirty = 0;
548 if(af_trace) fprintf(af_trace,"af_cache_flush: slot %d page %"PRIu64" flushed.\n",i,p->pagenum);
549 }
550 }
551 return ret; // now return the error that I might have gotten
552 }
553
554 /* If the page being written is in the cache, update it.
555 * Question: would it make sense to copy the data anyway? I don't think so, because
556 * the main use of writethrough is when imaging, and in that event you probably don't
557 * want the extra memcpy.
558 */
559 void af_cache_writethrough(AFFILE *af,int64_t pagenum,const unsigned char *buf,int bufflen)
560 {
561 for(int i=0;i<af->num_pbufs;i++){
562 struct aff_pagebuf *p = &af->pbcache[i];
563 if(p->pagenum_valid && p->pagenum == pagenum){
564 if(p->pagebuf_dirty){
565 (*af->error_reporter)("af_cache_writethrough: overwriting page %"I64u".\n",pagenum);
566 exit(-1); // this shouldn't happen
567 }
568 memcpy(p->pagebuf,buf,bufflen);
569 memset(p->pagebuf+bufflen,0,af->image_pagesize-bufflen); // zero fill the rest
570 af->bytes_memcpy += bufflen;
571 p->pagebuf_valid = 1; // we have a copy of it now.
572 p->pagebuf_dirty = 0; // but it isn't dirty
573 p->last = cachetime++;
574 }
575 }
576 }
577
578 #ifdef HAVE_MALLOC_H
579 #include <malloc.h>
580 #endif
581
582 #ifndef HAVE_VALLOC
583 #define valloc malloc
584 #endif
585
586 struct aff_pagebuf *af_cache_alloc(AFFILE *af,int64_t pagenum)
587 {
588 if(af_trace) fprintf(af_trace,"af_cache_alloc(%p,%"I64d")\n",af,pagenum);
589 af_cache_flush(af); // make sure nothing in cache is dirty
590 /* See if this page is already in the cache */
591 for(int i=0;i<af->num_pbufs;i++){
592 struct aff_pagebuf *p = &af->pbcache[i];
593 if(p->pagenum_valid && p->pagenum==pagenum){
594 af->cache_hits++;
595 if(af_trace) fprintf(af_trace," page %"I64d" satisfied fromcache\n",pagenum);
596 p->last = cachetime++;
597 return p;
598 }
599 }
600
601 af->cache_misses++;
602 int slot = -1;
603 /* See if there is an empty slot in the cache */
604 for(int i=0;i<af->num_pbufs;i++){
605 struct aff_pagebuf *p = &af->pbcache[i];
606 if(p->pagenum_valid==0){
607 slot = i;
608 if(af_trace) fprintf(af_trace," slot %d given to page %"I64d"\n",slot,pagenum);
609 break;
610 }
611 }
612 if(slot==-1){
613 /* Find the oldest cache entry */
614 int oldest_i = 0;
615 int oldest_t = af->pbcache[0].last;
616 for(int i=1;i<af->num_pbufs;i++){
617 if(af->pbcache[i].last < oldest_t){
618 oldest_t = af->pbcache[i].last;
619 oldest_i = i;
620 }
621 }
622 slot = oldest_i;
623 if(af_trace) fprintf(af_trace," slot %d assigned to page %"I64d"\n",slot,pagenum);
624 }
625 /* take over this slot */
626 struct aff_pagebuf *p = &af->pbcache[slot];
627 if(p->pagebuf==0){
628 p->pagebuf = (unsigned char *)valloc(af->image_pagesize); // allocate to a page boundary
629 if(p->pagebuf==0){
630 /* Malloc failed; See if we can just use the first slot */
631 slot = 0;
632 if(af->pbcache[0].pagebuf==0) return 0; // ugh. Cannot malloc?
633
634 /* First slot is available. Just use it. */
635 p = &af->pbcache[0];
636 }
637 }
638 memset(p->pagebuf,0,af->image_pagesize); // clean object reuse
639 p->pagenum = pagenum;
640 p->pagenum_valid = 1;
641 p->pagebuf_valid = 0;
642 p->pagebuf_dirty = 0;
643 p->last = cachetime++;
644 if(af_trace){
645 fprintf(af_trace," current pages in cache: ");
646 for(int i=0;i<af->num_pbufs;i++){
647 fprintf(af_trace," %"I64d,af->pbcache[i].pagenum);
648 }
649 fprintf(af_trace,"\n");
650 }
651 return p;
652 }
653
654
655
656
0 /*
1 * The AFFLIB data stream interface.
2 * Supports the page->segment name translation, and the actual file pointer.
3 */
4
5 /*
6 * Copyright (c) 2005, 2006
7 * Simson L. Garfinkel and Basis Technology, Inc.
8 * All rights reserved.
9 *
10 * This code is derrived from software contributed by
11 * Simson L. Garfinkel
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by Simson L. Garfinkel
24 * and Basis Technology Corp.
25 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
26 * contributors to this program may be used to endorse or promote
27 * products derived from this software without specific prior written
28 * permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
31 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
32 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
35 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
38 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
40 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
41 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 */
44
45
46 #include "affconfig.h"
47 #include "afflib.h"
48 #include "afflib_i.h"
49
50
51 /****************************************************************
52 *** Internal Functions.
53 ****************************************************************/
54
55 /*
56 * af_set_maxsize
57 * Sets the maxsize.
58 Fails with -1 if imagesize >= 0 unless this is a raw or split_raw file
59 */
60 int af_set_maxsize(AFFILE *af,int64_t maxsize)
61 {
62 AF_WRLOCK(af);
63 if(af->image_size>0){
64 (*af->error_reporter)("Cannot set maxsize as imagesize is already set (%"I64d")",af->image_size);
65 AF_UNLOCK(af);
66 return -1; // now allowed to set if imagesize is bigger than 0
67 }
68 if((af->image_pagesize!=0)
69 && (af->v->type & AF_VNODE_MAXSIZE_MULTIPLE)
70 && (maxsize % af->image_pagesize != 0)){
71 (*af->error_reporter)("Cannot set maxsize to %"I64d" --- not multiple of pagesize=%d\n",
72 maxsize,af->image_pagesize);
73 AF_UNLOCK(af);
74 return -1;
75 }
76 af->maxsize = maxsize;
77 AF_UNLOCK(af);
78 return 0;
79 }
80
81 const unsigned char *af_badflag(AFFILE *af)
82 {
83 return af->badflag;
84 }
85
86
87 /****************************************************************
88 *** Stream-level interface
89 ****************************************************************/
90
91
92 /* Throw out the current segment */
93 int af_purge(AFFILE *af)
94 {
95 AF_WRLOCK(af);
96 if (af_trace) fprintf(af_trace,"af_purge(%p)\n",af);
97 int ret = af_cache_flush(af); // flush the cache
98 af->pb = 0; // no longer have a current page
99 AF_UNLOCK(af);
100 return ret;
101 }
102
103 ssize_t af_read(AFFILE *af,unsigned char *buf,ssize_t count)
104 {
105 int total = 0;
106
107 AF_WRLOCK(af); // wrlock because cache may change
108 if (af_trace) fprintf(af_trace,"af_read(%p,%p,%zd) (pos=%"I64d")\n",af,buf,count,af->pos);
109 if (af->v->read){ // check for bypass
110 int r = (af->v->read)(af, buf, af->pos, count);
111 if(r>0) af->pos += r;
112 AF_UNLOCK(af);
113 return r;
114 }
115
116 /* performance improvement: use af->image_size if it is set */
117 uint64_t offset = af->pos; /* where to start */
118
119 if(af->image_size<0) {total=-1;goto done;} // error
120 if(af->image_size==0) {goto done;} // no data in file
121 if(af->pos > af->image_size) {goto done;} // seeked beyond end of file
122 if(af->pos+count > af->image_size) count = af->image_size - af->pos; // only this much left in file
123
124
125 /* Make sure we have a pagebuf if none was defined */
126 if(af->image_pagesize==0){ // page size not defined
127 errno = EFAULT;
128 total=-1;
129 goto done;
130 }
131
132 while(count>0){
133 /* If the correct segment is not loaded, purge the segment */
134 int64_t new_page = offset / af->image_pagesize;
135
136 if(af->pb==0 || new_page != af->pb->pagenum){
137 af_cache_flush(af);
138 af->pb = 0;
139 }
140
141 /* If no segment is loaded in cache, load the current segment */
142 if(af->pb==0){
143 int64_t pagenum = offset / af->image_pagesize;
144 af->pb = af_cache_alloc(af,pagenum);
145 if(af->pb->pagebuf_valid==0){
146 /* page buffer isn't valid; need to get it */
147 af->pb->pagebuf_bytes = af->image_pagesize; // we can hold this much
148 if(af_get_page(af,af->pb->pagenum,af->pb->pagebuf, &af->pb->pagebuf_bytes)){
149 /* Page doesn't exist; fill with NULs */
150 memset(af->pb->pagebuf,0,af->pb->pagebuf_bytes);
151 /* TK: Should fill with BADBLOCK here if desired */
152 /* previously had BREAK here */
153 }
154 af->pb->pagebuf_valid = 1; // contents of the page buffer are valid
155 }
156 }
157 // Compute how many bytes can be copied...
158 // where we were reading from
159 u_int page_offset = (u_int)(offset - af->pb->pagenum * af->image_pagesize);
160
161 if(page_offset > af->pb->pagebuf_bytes){
162 /* Page is short. */
163 /* Question - should we advance af->pos to the next page? */
164 break;
165 }
166
167 u_int page_left = af->pb->pagebuf_bytes - page_offset; // number we can get out
168 u_int bytes_to_read = count;
169
170 if(bytes_to_read > page_left) bytes_to_read = page_left;
171 if(bytes_to_read > af->image_size - offset) bytes_to_read = (u_int)(af->image_size - offset);
172
173 assert(bytes_to_read >= 0); //
174 if(bytes_to_read==0) break; // that's all we could get
175
176 /* Copy out the bytes for the user */
177 memcpy(buf,af->pb->pagebuf+page_offset,bytes_to_read); // copy out
178 af->bytes_memcpy += bytes_to_read;
179 buf += bytes_to_read;
180 offset += bytes_to_read;
181 count -= bytes_to_read;
182 total += bytes_to_read;
183 af->pos += bytes_to_read;
184 }
185 /* We have copied all of the user's requested data, so return */
186 done:
187 AF_UNLOCK(af);
188 return total;
189 }
190
191
192 /*
193 * Handle writing to the file...
194 * af_write() --- returns the number of bytes written
195 *
196 */
197
198 int af_write(AFFILE *af,unsigned char *buf,size_t count)
199 {
200 AF_WRLOCK(af);
201 if (af_trace){
202 fprintf(af_trace,"af_write(af=%p,buf=%p,count=%zd) pos=%"I64d"\n", af,buf,count,af->pos);
203 }
204 /* Invalidate caches */
205 af_invalidate_vni_cache(af);
206
207 /* vnode write bypass:
208 * If a write function is defined, use it and avoid the page and cache business.
209 */
210 if (af->v->write){
211 int r = (af->v->write)(af, buf, af->pos, count);
212 if(r>0){
213 af->pos += r;
214 af->bytes_written += r;
215 }
216 if(af->pos >= af->image_size) af->image_size = af->pos;
217 AF_UNLOCK(af);
218 return r;
219 }
220
221 /* If no pagesize has been set, go with the default pagesize */
222 if(af->image_pagesize==0){
223 if(af_set_pagesize(af,AFF_DEFAULT_PAGESIZE)){
224 AF_UNLOCK(af);
225 return -1;
226 }
227 }
228
229 int64_t offset = af->pos; // where to start
230
231 /* If the correct segment is not loaded, purge the current segment */
232 int64_t write_page = offset / af->image_pagesize;
233 if(af->pb && af->pb->pagenum!=write_page){
234 af_cache_flush(af);
235 af->pb = 0;
236 }
237
238 int write_page_offset = (int)(offset % af->image_pagesize);
239
240 /* Page Write Bypass:
241 * If no data has been written into the current page buffer,
242 * and if the position of the stream is byte-aligned on the page buffer,
243 * and if an entire page is being written,
244 * just write it out and update the pointers, then return.
245 */
246 if(af->pb==0 && af->image_pagesize==(unsigned)count && write_page_offset == 0){
247 // copy into cache if we have this page anywhere in our cache
248 af_cache_writethrough(af,write_page,buf,count);
249 int ret = af_update_page(af,write_page,buf,count);
250 if(ret==0){ // no error
251 af->pos += count;
252 if(af->pos > af->image_size) af->image_size = af->pos;
253 AF_UNLOCK(af);
254 return count;
255 }
256 AF_UNLOCK(af);
257 return -1; // error
258 }
259
260
261 /* Can't use high-speed optimization; write through the cache */
262 int total = 0;
263 while(count>0){
264 /* If no page is loaded, or the wrong page is loaded, load the correct page */
265 int64_t pagenum = offset / af->image_pagesize; // will be the segment we want
266 if(af->pb==0 || af->pb->pagenum != pagenum){
267 af->pb = af_cache_alloc(af,pagenum);
268 af->pb->pagebuf_bytes = af->image_pagesize;
269 assert(af->pb->pagenum == pagenum);
270
271 /* Now try to load the page.
272 * If we can't load it, then we are creating a new page.
273 */
274 if(af_get_page(af,af->pb->pagenum,af->pb->pagebuf, &af->pb->pagebuf_bytes)){
275 /* Creating a new page; note that we have no bytes in this page */
276 af->pb->pagebuf_bytes = 0;
277 }
278 }
279 // where writing to
280 u_int seg_offset = (u_int)(offset - af->pb->pagenum * af->image_pagesize);
281
282 // number we can write into
283 u_int seg_left = af->image_pagesize - seg_offset;
284 u_int bytes_to_write = count;
285
286 if(bytes_to_write > seg_left) bytes_to_write = seg_left;
287
288 assert(bytes_to_write >= 0); //
289 if(bytes_to_write==0) break; // that's all we could get
290
291 /* Copy out the bytes for the user */
292 memcpy(af->pb->pagebuf+seg_offset,buf,bytes_to_write); // copy into the page cache
293 af->bytes_memcpy += bytes_to_write;
294
295 if(af->pb->pagebuf_bytes < seg_offset+bytes_to_write){
296 af->pb->pagebuf_bytes = seg_offset+bytes_to_write; // it has been extended.
297 }
298
299 buf += bytes_to_write;
300 offset += bytes_to_write;
301 count -= bytes_to_write;
302 total += bytes_to_write;
303 af->pos += bytes_to_write;
304 af->pb->pagebuf_valid = 1;
305 af->pb->pagebuf_dirty = 1;
306
307 /* If we wrote out all of the bytes that were left in the segment,
308 * then we are at the end of the segment, write it back...
309 */
310 if(seg_left == bytes_to_write){
311 if(af_cache_flush(af)){
312 AF_UNLOCK(af);
313 return -1;
314 }
315 }
316
317 /* If we have written more than the image size, update the image size */
318 if((u_int64_t)offset > af->image_size) af->image_size = offset;
319 }
320 /* We have copied all of the user's requested data, so return */
321 AF_UNLOCK(af);
322 return total;
323 }
324
325 /* No lock needed? */
326 int af_is_badsector(AFFILE *af,const unsigned char *buf)
327 {
328 if(af->badflag_set==0) return 0;
329 if(af->badflag==0) return 0;
330 return memcmp(af->badflag,buf,af->image_sectorsize)==0;
331 }
0 /*
1 * utility functions used by AFFLIB.
2 * These functions do not actually read or write data into the AFF File.
3 */
4
5 /*
6 * Copyright (c) 2005
7 * Simson L. Garfinkel and Basis Technology, Inc.
8 * All rights reserved.
9 *
10 * This code is derrived from software contributed by
11 * Simson L. Garfinkel
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed by Simson L. Garfinkel
24 * and Basis Technology Corp.
25 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
26 * contributors to this program may be used to endorse or promote
27 * products derived from this software without specific prior written
28 * permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
31 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
32 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
33 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
35 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
37 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
38 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
39 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
40 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
41 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 */
44
45 #include "affconfig.h"
46 #include "afflib.h"
47 #include "afflib_i.h"
48
49 #ifndef HAVE_ERR
50 #include <stdarg.h>
51 void err(int eval,const char *fmt,...)
52 {
53 va_list ap;
54 va_start(ap,fmt);
55 vfprintf(stderr,fmt,ap);
56 va_end(ap);
57 fprintf(stderr,": %s\n",strerror(errno));
58 exit(eval);
59 }
60 #endif
61
62 void af_err(int eval,const char *fmt,...)
63 {
64 va_list ap;
65 va_start(ap,fmt);
66 vfprintf(stderr,fmt,ap);
67 va_end(ap);
68 if(af_error_str[0]) fprintf(stderr,": %s",af_error_str);
69 if(errno) fprintf(stderr,": %s",strerror(errno));
70 fputc('\n',stderr);
71 exit(eval);
72 }
73
74
75 #ifndef HAVE_ERRX
76 #include <stdarg.h>
77 void errx(int eval,const char *fmt,...)
78 {
79 va_list ap;
80 va_start(ap,fmt);
81 vfprintf(stderr,fmt,ap);
82 fprintf(stderr,"%s\n",strerror(errno));
83 va_end(ap);
84 exit(eval);
85 }
86 #endif
87
88 #ifndef HAVE_WARN
89 #include <stdarg.h>
90 void warn(const char *fmt, ...)
91 {
92 va_list args;
93 va_start(args,fmt);
94 vfprintf(stderr,fmt, args);
95 fprintf(stderr,": %s",strerror(errno));
96 }
97 #endif
98
99 #ifndef HAVE_WARNX
100 #include <stdarg.h>
101 void warnx(const char *fmt,...)
102 {
103 va_list ap;
104 va_start(ap,fmt);
105 vfprintf(stderr,fmt,ap);
106 va_end(ap);
107 }
108 #endif
109
110
111
112
113 /*
114 * af_hexbuf:
115 * Turn a binay string into a hex string, optionally with spaces.
116 */
117
118 const char *af_hexbuf(char *dst,int dst_len,const unsigned char *bin,int bytes,int flag)
119 {
120 int charcount = 0;
121 const char *start = dst; // remember where the start of the string is
122 const char *fmt = (flag & AF_HEXBUF_UPPERCASE) ? "%02X" : "%02x";
123
124 *dst = 0; // begin with null termination
125 while(bytes>0 && dst_len > 3){
126 sprintf(dst,fmt,*bin); // convert the next byte
127 dst += 2;
128 bin += 1;
129 dst_len -= 2;
130 bytes--;
131 charcount++; // how many characters
132
133 bool add_spaces = false;
134 if(flag & AF_HEXBUF_SPACE2) add_spaces = true;
135 if((flag & AF_HEXBUF_SPACE4) && charcount%2==0){
136 *dst++ = ' ';
137 *dst = '\000';
138 dst_len -= 1;
139 }
140 }
141 return start; // return the start
142 }
143
144
145 /* Add commas
146 */
147 const char *af_commas(char buf[64],int64_t val)
148 {
149 char tmp[64];
150 char t2[64];
151 int negative = 0;
152
153 buf[0] = 0;
154 if(val==0){
155 strcpy(buf,"0");
156 }
157 if(val<0){
158 negative = 1;
159 val = -val;
160 }
161
162 while(val>0){
163 int digits = val % 1000; // get the residue
164 val = val / 1000; // and shift what's over
165
166 if(val>0){ // we will still have more to do
167 sprintf(tmp,",%03d",digits); // so pad it with zeros and a comma
168 }
169 else {
170 sprintf(tmp,"%d",digits); // otherwise just get the value
171 }
172 strcpy(t2,buf); // copy out the buffer
173 strcpy(buf,tmp); // copy in what we just did
174 strcat(buf,t2); // and put back what was there
175 }
176 if(negative){
177 strcpy(t2,buf);
178 strcpy(buf,"-");
179 strcat(buf,t2);
180 }
181 return buf;
182 }
183
184 uint64_t af_decode_q(unsigned char buf[8])
185 {
186 struct aff_quad *q = (struct aff_quad *)buf; // point q to buf.
187
188 assert(sizeof(*q)==8); // be sure!
189 return (((uint64_t)ntohl(q->high)) << 32) + ((uint64_t)ntohl(q->low));
190 }
191
192 /* parse the segment number.
193 * The extra %c picks up characters that might be after the number,
194 * so that page5_hash doesn't match for page5.
195 */
196 int64_t af_segname_page_number(const char *name)
197 {
198 int64_t pagenum;
199 char ch;
200 if(sscanf(name,AF_PAGE"%c",&pagenum,&ch)==1){
201 return pagenum; // new-style page number
202 }
203 if(sscanf(name,AF_SEG_D"%c",&pagenum,&ch)==1){
204 return pagenum; // old-style page number
205 }
206 return -1;
207 }
208
209 int64_t af_segname_hash_page_number(const char *name,char *hash,int hashlen)
210 {
211 char copy[AF_MAX_NAME_LEN];
212 const char *cc = strchr((char *)name,'_');
213 if(!cc) return -1; // not possibly correct
214 strlcpy(copy,name,sizeof(copy));
215 char *dd = strchr(copy,'_');
216 if(!dd) return -1; // really weird; shouldn't happen
217 *dd++ = '\000'; // terminate at _
218 if(strcmp(dd,"md5")!=0) return -1; // not a valid hash
219 int64_t page = af_segname_page_number(copy);
220 if(page<0) return -1; // wasn't what we wanted
221 strlcpy(hash,dd,hashlen);
222 return page;
223 }
224
225 int af_hasmeta(const char *infile)
226 {
227 /* return 1 if the string has shell metacharacters */
228 for(const char *cc = infile;*cc;cc++){
229 switch(*cc){
230 case '?': return 1;
231 case '*': return 1;
232 case '&': return 1;
233 case '`': return 1;
234 case '(': return 1;
235 case ')': return 1;
236 }
237 }
238 return 0;
239 }
240
241 /* It is a filestream if the filename begins file:// or has no "://" in it */
242 int af_is_filestream(const char *filename)
243 {
244 if(strncmp(filename,"file://",7)==0) return 1;
245 if(strstr(filename,"://")==0) return 1;
246 return 0;
247 }
248
249
250
251
252
253
254 #ifndef HAVE_STRLCPY
255 size_t strlcpy(char *dest,const char *src,size_t dest_size)
256 {
257 strncpy(dest,src,dest_size);
258 dest[dest_size-1] = '\000';
259 return strlen(dest);
260 }
261 #endif
262
263 #ifndef HAVE_STRLCAT
264 size_t strlcat(char *dest,const char *src,size_t dest_size)
265 {
266 int dest_len = strlen(dest);
267 int src_len = strlen(src);
268 int room = dest_size - (dest_len +src_len+1);
269 if(room>0){
270 /* There is room; just copy over what we have and return */
271 strcat(dest,src);
272 return strlen(dest);
273 }
274 /* Not room; figure out how many bytes we can copy... */
275 int left = dest_size - (dest_len+1);
276 strncpy(dest+dest_len,src,left);
277 dest[dest_len-1] = '\000';
278 return strlen(dest);
279 }
280 #endif
281
282 /* Parse a URL. Allocate the parts if requested. Default protocol is "file", of course*/
283 void af_parse_url(const char *url,char **protocol,char **hostname,char **username,char **password,
284 int *port,char **path)
285 {
286 const char *p1 = strstr(url,"://");
287 if(!p1){
288 if(protocol) *protocol = strdup("file");
289 if(path) *path = strdup(url);
290 return;
291 }
292 if(protocol){
293 int len = p1-url;
294 *protocol = (char *)malloc(len+1);
295 strncpy(*protocol,url,len);
296 }
297 url = p1+3; // move past ://
298
299 const char *at = strchr(url,'@');
300 if(at){ // we may have a username and/or password
301 char *scratch = (char *)malloc(at-url+1);
302 strncpy(scratch,url,at-url);
303 scratch[at-url]='\000';
304 char *colon = strchr(scratch,':');
305 if(colon){
306 *colon = '\000';
307 }
308 if(username) *username = strdup(scratch);
309 if(colon){
310 if(password) *password = strdup(colon+1);
311 }
312 free(scratch);
313 url = at+1;
314 }
315
316 /* Process hostname if it exists */
317 const char *slash = strchr(url,'/');
318 if(slash){
319 char *scratch = (char *)malloc(slash-url+1);
320 strncpy(scratch,url,slash-url);
321 scratch[slash-url]='\000';
322 char *colon = strchr(scratch,':');
323 if(colon){
324 *colon = '\000';
325 }
326 if(hostname) *hostname = strdup(scratch);
327 if(colon){
328 if(port) *port = atoi(colon+1);
329 }
330 free(scratch);
331 url = slash+1;
332 }
333 if(path) *path = strdup(url); // remember file name
334 }
0 /*
1 * atest.cpp:
2 * test suite for the AFF Library.
3 */
4
5 #include "affconfig.h"
6 #include "afflib.h"
7 #include "afflib_i.h"
8 #include "base64.h"
9 #include "aftimer.h"
10 #include "threaded_hash.h"
11
12 #ifdef HAVE_GETOPT_H
13 #include <getopt.h>
14 #endif
15
16 #include "LzmaRam.h"
17 extern "C" {
18 #include "LzmaRamDecode.h"
19 }
20
21 int MAX_FMTS = 10000; // how many formats we should write
22
23 const char *fmt = "%8d Another format string.\n"; // must be constant size
24 const char *progname = 0;
25
26 const char *opt_protocol = "file:///";
27 const char *opt_ext = "aff";
28 int opt_compression_level = AF_COMPRESSION_DEFAULT;// default compression level
29 int opt_compression_type = AF_COMPRESSION_ALG_ZLIB; //
30 const char *tempdir = "/tmp/";
31
32
33 /* Create the segment that we need */
34
35 #ifndef MIN
36 #define MIN(x,y) ((x)<(y)?(x):(y))
37 #endif
38
39
40 const char *filename(char *buf,int buflen,const char *base)
41 {
42 snprintf(buf,buflen,"%s%s%s.%s",opt_protocol,tempdir,base,opt_ext);
43 return buf;
44 }
45
46 AFFILE *open_testfile(const char *base,int wipe)
47 {
48 int flags = O_CREAT|O_RDWR;
49 char fn[1024];
50
51 filename(fn,sizeof(fn),base);
52 printf("%s = %s\n",base,fn);
53 if(wipe){
54 unlink(fn); // make sure it is gone
55 flags |= O_TRUNC;
56 }
57 AFFILE *af = af_open(fn,flags,0666);
58 if(!af) err(1,"af_open");
59 if(wipe){
60 af_enable_compression(af,opt_compression_type,opt_compression_level);
61 af_set_pagesize(af,1024);
62 af_set_maxsize(af,(int64_t)65536); // force splitting of raw and afd files
63 }
64 return af;
65 }
66
67 int sequential_test()
68 {
69 char buf[1024];
70 const char *fmt = "this is line %d\n";
71
72 printf("Sequential test...\n");
73
74 AFFILE *af = open_testfile("test_sequential",1);
75 for(int i=0;i<MAX_FMTS;i++){
76 if(i%250==0) printf("\rwriting %d/%d...",i,MAX_FMTS);
77 sprintf(buf,fmt,i);
78 if(af_write(af,(unsigned char *)buf,strlen(buf))!=(int)strlen(buf)){
79 err(1,"Attempt to write buffer %d failed\n",i);
80 }
81 }
82 /* Test for a random bug that was reported */
83 af_update_seg(af,"test",0,(const u_char *)"foo",3);
84 af_update_seg(af,"test",0,(const u_char *)"bar",3);
85 af_del_seg(af,"test");
86 af_del_seg(af,"test");
87 af_close(af);
88
89 printf("\nSequential file written.\n");
90 printf("\n");
91 printf("Now verifying the string...\n");
92 af = open_testfile("test_sequential",0);
93 if(!af) err(1,"af_open");
94 for(int i=0;i<MAX_FMTS;i++){
95 char rbuf[1024];
96 sprintf(buf,fmt,i);
97 int len = strlen(buf);
98 if(af_read(af,(unsigned char *)rbuf,len)!=len){
99 err(1,"Attempt to read entry %d failed\n",i);
100 }
101 rbuf[len] = 0; // terminate the string
102 if(strcmp(buf,rbuf)!=0){
103 err(1,"Attempt to verify entry %d failed.\nExpected: (len=%zd) '%s'\nGot: (len=%zd) '%s'\n",
104 i,strlen(buf),buf,strlen(rbuf),rbuf);
105 }
106 }
107 af_close(af);
108
109 printf("===========================\n\n");
110 return 0;
111 }
112
113 int reverse_test()
114 {
115 char wbuf[1024];
116 char rbuf[1024];
117
118 printf("Reverse write test...\n");
119 for(int pass=1;pass<=2;pass++){
120
121 AFFILE *af = open_testfile("test_reverse",pass==1);
122 for(int i=MAX_FMTS-1;i>=0;i--){
123 sprintf(wbuf,fmt,i);
124 af_seek(af,strlen(wbuf)*i,SEEK_SET);
125 if(pass==1){
126 if(af_write(af,(unsigned char *)wbuf,strlen(wbuf))!=(int)strlen(wbuf)){
127 err(1,"Attempt to write buffer %d failed\n",i);
128 }
129 }
130 if(pass==2){
131 memset(rbuf,0,sizeof(rbuf));
132 if(af_read(af,(unsigned char *)rbuf,strlen(wbuf))!=(int)strlen(wbuf)){
133 err(1,"Attempt to read buffer %d failed\n",i);
134 }
135 if(strcmp(rbuf,wbuf)!=0){
136 errx(1,"Data doesn't verify.\nWrote: '%s'\nRead: '%s'\n",wbuf,rbuf);
137 }
138 }
139 }
140 af_close(af);
141 }
142
143 printf("\nReverse test passes.\n");
144 printf("======================\n\n");
145 return 0;
146 }
147
148
149 int random_write_test()
150 {
151 char buf[1024];
152 char *tally = (char *)calloc(MAX_FMTS,1);
153 int i;
154
155 memset(tally,0,sizeof(tally));
156
157 /* Create the AFF file */
158 sprintf(buf,fmt,0); // figure out how big fmt string is
159 int fmt_size = strlen(buf);
160
161 printf("Random write test...\n");
162 printf("Creating test file with %d byte records.\n", fmt_size);
163
164 AFFILE *af = open_testfile("test_random",1);
165
166 if(af_write(af,(unsigned char *)buf,fmt_size)!=fmt_size){
167 err(1,"af_write");
168 }
169 for(i=0;i<MAX_FMTS;i++){
170 /* Find a random spot that's available */
171 int pos = rand() % MAX_FMTS;
172 while(tally[pos]==1){ // if this one is used, find next
173 pos = (pos + 1) % MAX_FMTS;
174 }
175 tally[pos] = 1;
176 sprintf(buf,fmt,pos);
177 assert((int)strlen(buf)==fmt_size); // make sure
178 af_seek(af,fmt_size*pos,SEEK_SET);
179 int wrote = af_write(af,(unsigned char *)buf,fmt_size);
180 if(wrote !=fmt_size){
181 fprintf(stderr,"Attempt to write buffer #%d \n",pos);
182 fprintf(stderr,"wrote %d bytes instead of %d bytes\n",wrote,fmt_size);
183 exit(1);
184 }
185 if(i%250==0) printf("\r%d ...",i);
186 fflush(stdout);
187 }
188 af_close(af);
189
190 /* Now verify what was written */
191 printf("Verifying write test...\n");
192 af = open_testfile("test_random",0);
193
194 for(i=0;i<MAX_FMTS;i++){
195 char should[256]; // what we should get
196 sprintf(should,fmt,i);
197 int got = af_read(af,(unsigned char *)buf,fmt_size);
198 if(got != fmt_size){
199 fprintf(stderr,"Attempt to read %d bytes; got %d\n",fmt_size,got);
200 exit(1);
201 }
202 if(i%250==24) printf("\r%d .. %d okay",i-24,i);
203 }
204 af_close(af);
205 printf("\n");
206 printf("\nRandom write test passes.\n");
207 printf("======================\n");
208 return 0;
209 }
210
211 int random_read_test(int total_bytes,int data_page_size)
212 {
213 printf("\n\n\nrandom read test. filesize=%d, page_size=%d\n",
214 total_bytes,data_page_size);
215
216 /* Create a regular file and an AFF file */
217
218 printf("Creating random_contents.img and random_contents.%s, "
219 "both with %d bytes of user data...\n",
220 opt_ext,total_bytes);
221
222 int fd = open("test_random_contents.img",
223 O_CREAT|O_RDWR|O_TRUNC|O_BINARY,0666);
224 if(fd<0) err(1,"fopen");
225
226 AFFILE *af = open_testfile("test_random_contents",1);
227
228 /* Just write it out as one big write */
229
230 unsigned char *buf = (unsigned char *)malloc(total_bytes);
231 unsigned char *buf2 = (unsigned char *)malloc(total_bytes);
232
233 /* First half is random */
234 #ifdef HAVE_RAND_PSEUDO_BYTES
235 RAND_pseudo_bytes(buf,total_bytes/2);
236 #else
237 for(int i=0;i<total_bytes/2;i++){
238 buf[i] = random();
239 }
240 #endif
241
242 /* Second half is a bit more predictable */
243 for(int i=total_bytes/2;i<total_bytes;i++){
244 buf[i] = ((i % 256) + (i / 256)) % 256;
245 }
246
247 if(write(fd,buf,total_bytes)!=total_bytes) err(1,"fwrite");
248 if(af_write(af,buf,total_bytes)!=(int)total_bytes) err(1,"af_write");
249
250 /* Now try lots of seeks and reads */
251 for(int i=0;i<MAX_FMTS;i++){
252 unsigned int loc = rand() % total_bytes;
253 unsigned int len = rand() % total_bytes;
254 memset(buf,0,total_bytes);
255 memset(buf2,0,total_bytes);
256
257 if(i%250==0) printf("\r#%d reading %u bytes at %u ...",i,loc,len);
258 fflush(stdout);
259
260 unsigned long l1 = (unsigned long)lseek(fd,loc,SEEK_SET);
261 unsigned long l2 = (unsigned long)af_seek(af,loc,SEEK_SET);
262
263
264 if(l1!=l2){
265 err(1,"l1 (%lu) != l2 (%lu)",l1,l2);
266 }
267
268 int r1 = read(fd,buf,len);
269 int r2 = af_read(af,buf2,len);
270
271 if(r1!=r2){
272 err(1,"r1 (%d) != r2 (%d)",r1,r2);
273 }
274 }
275 af_close(af);
276 close(fd);
277 printf("\nRandom read test passes\n");
278 return 0;
279 }
280
281 void large_file_test()
282 {
283 int pagesize = 1024*1024; // megabyte sized segments
284 int64_t num_segments = 5000;
285 int64_t i;
286 char fn[1024];
287
288 printf("Large file test... Creating a %"I64d"MB file...\n",pagesize*num_segments/(1024*1024));
289 filename(fn,sizeof(fn),"large_file");
290 AFFILE *af = af_open(fn,O_CREAT|O_RDWR|O_TRUNC,0666);
291
292 unsigned char *buf = (unsigned char *)malloc(pagesize);
293
294 memset(buf,'E', pagesize);
295 af_enable_compression(af,opt_compression_type,opt_compression_level);
296 af_set_pagesize(af,pagesize);
297 af_set_maxsize(af,(int64_t)pagesize * 600);
298
299 for(i=0;i<num_segments;i++){
300 sprintf((char *)buf,"%"I64d" page is put here",i);
301 if(i%25==0) printf("\rWriting page %"I64d"\r",i);
302 if(af_write(af,buf,pagesize)!=pagesize){
303 err(1,"Can't write page %"I64d,i);
304 }
305 }
306 printf("\n\n");
307 /* Now let's just read some test locations */
308 for(i=0;i<num_segments;i+=num_segments/25){ // check a few places
309 int r;
310 af_seek(af,pagesize*i,SEEK_SET);
311 r = af_read(af,buf,1024); // just read a bit
312 if(r!=1024){
313 err(1,"Tried to read 1024 bytes; got %d\n",r);
314 }
315 if(atoi((char *)buf)!=i){
316 err(1,"at page %"I64d", expected %"I64d", got %s\n",i,i,buf);
317 }
318 printf("Page %"I64d" validates\n",i);
319 }
320
321 af_close(af);
322 if(unlink("large_file.aff")){
323 err(1,"Can't delete large_file.aff");
324 }
325 printf("Large file test passes\n");
326 }
327
328 void maxsize_test()
329 {
330 printf("Maxsize test. This test is designed to test creation of files\n");
331 printf("Larger than 4GB. Currently it's disabled, though.\n");
332 #if 0
333 char segname[16];
334 char buf[1024];
335 char fn[1024];
336 int numpages = 1000;
337
338 AFFILE *af = af_open(filename(fn,sizeof(fn),"maxsize"),O_CREAT|O_RDWR|O_TRUNC,0666);
339 memset(buf,0,sizeof(buf));
340 for(int64_t i=0;i<numpages;i++){
341 sprintf(buf,"This is page %"I64d". ****************************************************\n",i);
342 sprintf(segname,AF_PAGE,i);
343 af_update_seg(af,segname,0,buf,sizeof(buf));
344 }
345 af_close(af);
346 printf("\nMaxsize test passes.\n");
347 #endif
348 printf("\n====================\n");
349 }
350
351 void sparse_test()
352 {
353 printf("Sparse test...\n");
354
355 char buf[1024];
356 char fn[1024];
357
358 uint64_t mult = (uint64_t)3 * (uint64_t)1000000000; // 3GB in
359
360 AFFILE *af = af_open(filename(fn,sizeof(fn),"sparse"),O_CREAT|O_RDWR|O_TRUNC,0666);
361 af_enable_compression(af,opt_compression_type,opt_compression_level);
362 af_set_maxsize(af,(int64_t)1024*1024*256);
363 af_set_pagesize(af,1024*1024*16);
364
365 for(u_int i=0;i<10;i++){
366 u_int64_t pos = mult*i;
367 memset(buf,0,sizeof(buf));
368 snprintf(buf,sizeof(buf),"This is at location=%"I64u"\n",pos);
369 af_seek(af,pos,SEEK_SET);
370 af_write(af,(unsigned char *)buf,sizeof(buf));
371 }
372
373 /* Now verify */
374 for(u_int i=0;i<10;i++){
375 u_int64_t pos = mult*i;
376 u_int64_t q;
377 af_seek(af,pos,SEEK_SET);
378 af_read(af,(unsigned char *)buf,sizeof(buf));
379 char *cc = strchr(buf,'=');
380 if(!cc){
381 printf("Garbage read at location %"I64u"\n.",pos);
382 exit(1);
383 }
384 if(sscanf(cc+1,"%"I64u,&q)!=1){
385 printf("Could not decode value at location %"I64u"(%s)\n",pos,cc+1);
386 exit(1);
387 }
388 if(pos!=q){
389 printf("Wrong value at location %"I64u"; read %"I64u" in error.\n", pos,q);
390 exit(1);
391 }
392 }
393
394 /* Now seek to somewhere that no data has been written and see if we get 0s. */
395 memset(buf,'g',sizeof(buf));
396 af_seek(af,mult/2,SEEK_SET);
397 ssize_t r = af_read(af,(unsigned char *)buf,sizeof(buf));
398 if(r!=sizeof(buf)){
399 err(1,"Tried to read %zd bytes at mult/2; got %zd bytes\n",sizeof(buf),r);
400 }
401 for(u_int i=0;i<sizeof(buf);i++){
402 if(buf[i]!=0) err(1,"data error; buf[%d]=%d\n",i,buf[i]);
403 }
404
405 /* Now try to read the last page in the file */
406 unsigned char big_buf[65536];
407 af_seek(af,9*mult,SEEK_SET);
408 r = af_read(af,big_buf,sizeof(big_buf));
409 if(r!=sizeof(buf)){
410 errx(1,"Tried to read %zd bytes at the end of the file; got %zd bytes (should get %zd)",
411 sizeof(big_buf),r,sizeof(buf));
412 }
413
414
415 /* Now see if we can read past the end of the file */
416 af_seek(af,11*mult,SEEK_SET);
417 r = af_read(af,(unsigned char *)buf,sizeof(buf));
418 if(r!=0) errx(1,"Tried to read past end of file; got %zd bytes (should get 0)",r);
419
420 af_close(af);
421 printf("\nSprase test passes.\n");
422 printf("=====================\n\n");
423 }
424
425 void figure(const char *fn)
426 {
427 struct af_figure_media_buf afb;
428
429 int fd = open(fn,O_RDONLY);
430 if(fd<0) err(1,"%s",fn);
431 if(af_figure_media(fd,&afb)){
432 err(1,"af_figure_media");
433 }
434 printf("sector size: %d\n",afb.sector_size);
435 printf("total sectors: %"PRId64"\n",afb.total_sectors);
436 printf("max read blocks: %"PRId64"\n",afb.max_read_blocks);
437 exit(0);
438 }
439
440
441 void compress(const char *fname)
442 {
443 int fd = open(fname,O_RDONLY,0666);
444 if(fd<0) err(1,"%s",fname);
445
446 struct stat st;
447 if(fstat(fd,&st)) err(1,"stat");
448
449 /* Allocate memory */
450 char *buf = (char *)malloc(st.st_size);
451 if(buf==0) errx(1,"malloc");
452
453 if(read(fd,buf,st.st_size)!=st.st_size) err(1,"read");
454 //size_t outSize = (int)((double)st.st_size * 1.05);
455 //char *outBuffer = (char *)malloc(outSize);
456 //size_t outSizeProcessed = 0;
457 }
458
459 void lzma_test()
460 {
461 #if defined(__FreeBSD__) && !defined(__APPLE__)
462 _malloc_options = "XARV";
463 #endif
464 //char *fn = "/usr/share/dict/web2";
465 const char *fn = "/etc/motd";
466
467 printf("starting up\n");
468 FILE *f = fopen(fn,"r");
469 if(!f) err(1,"%s",fn);
470
471 struct stat st;
472 if(fstat(fileno(f),&st)) err(1,"stat");
473
474 /* Allocate memory */
475 size_t buflen = st.st_size;
476 printf("size=%qd\n",(long long)buflen);
477 unsigned char *buf = (unsigned char *)malloc(buflen);
478 if(buf==0) errx(1,"malloc");
479 if(fread(buf,1,st.st_size,f)!=(unsigned long long)st.st_size) err(1,"read");
480
481 /* Allocate memory for the compressed buffer */
482 size_t cbufsize = (int)(buflen*1.05);
483 size_t cbuf_actual=0;
484 unsigned char *cbuf = (unsigned char *)malloc(cbufsize);
485
486 #ifdef USE_LZMA
487 lzma_compress(cbuf,&cbufsize,buf,st.st_size,9);
488 #endif
489 printf("cbuf_actual=%d\n",(int)cbuf_actual);
490
491 /* Now try to decompress */
492 size_t outbuf_size = buflen*2;
493 unsigned char *outbuf = (unsigned char *)malloc(outbuf_size);
494
495 #ifdef USE_LZMA
496 lzma_uncompress(outbuf,&outbuf_size,cbuf,cbufsize);
497 #endif
498 printf("cbuf[0]=%d\n",cbuf[0]);
499
500 if(memcmp(buf,outbuf,outbuf_size)==0){
501 printf("Decompression works!\n");
502 }
503 }
504
505
506 void make_test_seg(u_char buf[1024],int num)
507 {
508 memset(buf,0,sizeof(buf));
509 sprintf((char *)buf,"This test %d. This is just a test. Stop thinking.\n",num);
510 }
511
512 int aestest()
513 {
514 unsigned char keyblock[32];
515
516 /* Make a key; doesn't need to be a good key; make it 256 bits */
517 for(int i=0;i<32;i++){
518 keyblock[i] = i;
519 }
520
521 AFFILE *af = af_open("crypto.aff",O_CREAT|O_RDWR|O_TRUNC,0666);
522 if(!af) err(1,"af_open");
523 if(af_set_aes_key(af,keyblock,256)) err(1,"af_set_aes_key");
524 af_set_pagesize(af,65536);
525
526 /* Now, let's write some data of various sizes */
527
528 u_char test[1024],buf[1024],rbuf[1024];
529 size_t buflen = sizeof(buf);
530 make_test_seg(test,0);
531 for(u_int len=0;len<=strlen((const char *)test);len++){
532 if(af_update_seg(af,"page0",0,test,len)) err(1,"af_update_seg len=%d",len);
533
534 /* Now try to read the segment */
535 memset(buf,0,sizeof(buf));
536 buflen = sizeof(buf);
537 if(af_get_seg(af,"page0",0,(unsigned char *)buf,&buflen)){
538 err(1,"Could not read encrypted segment with length %d.\n",len);
539 }
540 if(buflen!=len){
541 printf("size of returned segment = %zd ",buflen);
542 printf("(should be %d) \n",len);
543 exit(0);
544 }
545 if(memcmp(buf,test,len)!=0){
546 printf("does not match\n");
547 printf(" wanted: %s\n",test);
548 printf(" got: %s\n",buf);
549 exit(0);
550 }
551 }
552 if(af_close(af)) err(1,"af_close");
553
554 /* Now re-open the file, do not set the encryption key, and see if we can read it */
555 int r;
556 memset(buf,0,sizeof(buf));
557 af = af_open("crypto.aff",O_RDONLY,0666);
558 buflen = sizeof(buf);
559 r = af_get_seg(af,"page0",0,(unsigned char *)buf,&buflen);
560 if(r!=-1) {
561 errx(1,"Error; attempt to read segment 'encrypted' succeded. It should have failed.");
562 }
563
564 /* Try to read 'encrypted/aes' */
565 r = af_get_seg(af,"encrypted/aes",0,(unsigned char *)buf,&buflen);
566 if(memcmp(buf,test,buflen)==0){
567 errx(1,"Error: segment encrypted/aes wasn't actually encrypted.");
568 }
569 af_close(af);
570
571 /* Now set the correct encryption key and see if we can read it */
572 af = af_open("crypto.aff",O_RDONLY,0666);
573 if(af_set_aes_key(af,keyblock,256)) err(1,"af_set_aes_key");
574 buflen = sizeof(buf);
575 memset(buf,0,sizeof(buf));
576 r = af_get_seg(af,"page0",0,(unsigned char *)buf,&buflen);
577 if(buflen != strlen((const char *)test)){
578 errx(1,"Error: Could not read encrypted segment after re-opening file");
579 }
580 if(memcmp(buf,test,buflen)!=0) errx(1,"Error: Re-read of file produces wrong data.");
581 printf("encrypted data read and decrypted: '%s'\n",buf);
582 /* Try to read a segment that doesn't eixst */
583 buflen = 0;
584 if(af_get_seg(af,"encrypted2",0,0,&buflen)==0){
585 errx(1,"Error: Attempt to get size of non-existant segment 'encrypted2' got %zd\n",buflen);
586 }
587 af_close(af);
588
589
590 /* Now set the wrong encryption key and see if we can read it */
591 memset(buf,0,sizeof(buf));
592 af = af_open("crypto.aff",O_RDONLY,0666);
593 keyblock[3] = 42;
594 if(af_set_aes_key(af,keyblock,256)) err(1,"af_set_aes_key");
595 buflen = sizeof(buf);
596 r = af_get_seg(af,"page0",0,(unsigned char *)buf,&buflen);
597 if(memcmp(buf,test,buflen)==0) errx(1,"Error: Setting wrong key still produces correct data.");
598 af_close(af);
599
600 printf("Basic crypto checks. Now check passphrase....\n");
601
602 /* Write the data with a passphrase and try to read it back */
603 af = af_open("crypto_pass.aff",O_CREAT|O_RDWR|O_TRUNC,0666);
604 if(!af) err(1,"af_open 3");
605 af_set_pagesize(af,65536);
606 if(af_establish_aes_passphrase(af,"yummy")) err(1,"af_establish_aes_passphrase");
607 if(af_use_aes_passphrase(af,"yummy")) err(1,"af_use_aes_passphrase");
608 if(af_update_seg(af,"page0",0,(const u_char *)test,strlen((const char *)test))) err(1,"af_update_seg failed at 3");
609 if(af_close(af)) err(1,"af_close at 3");
610
611
612 /* Now try to read it back */
613 memset(rbuf,0,sizeof(rbuf));
614 size_t rbuflen = sizeof(rbuf);
615 af = af_open("crypto_pass.aff",O_RDONLY,0666);
616 if(!af) err(1,"af_open 4");
617 if(af_get_seg(af,"page0",0,(unsigned char *)buf,&buflen)==0){
618 errx(1,"af_get_seg should have failed and didn't");
619 }
620 if(af_use_aes_passphrase(af,"yummy")) err(1,"af_set_passphrase 2");
621 rbuflen=sizeof(rbuf);
622 if(af_get_seg(af,"page0",0,(unsigned char *)rbuf,&rbuflen)){
623 errx(1,"af_get_seg failed");
624 }
625 if(rbuflen!=strlen((const char *)test)) errx(1,"Reading encrypted data returned wrong size");
626 if(memcmp(rbuf,test,rbuflen)!=0) errx(1,"Error: wrong data");
627 printf("encrypted data read with passphrase 'yummy': %s\n",rbuf);
628 af_close(af);
629
630 /* Try to change the passphrase */
631 af = af_open("crypto_pass.aff",O_RDWR,0666);
632 if(!af) err(1,"af_open 5");
633 if(af_change_aes_passphrase(af,"yummy","dummy")) err(1,"could not change passphrase");
634 af_close(af);
635
636 /* Try to read with new passphrase */
637 af = af_open("crypto_pass.aff",O_RDONLY,0666);
638 if(!af) err(1,"af_open 5");
639 memset(rbuf,0,sizeof(rbuf));
640 rbuflen = sizeof(rbuf);
641 if(af_use_aes_passphrase(af,"dummy")) err(1,"af_set_passphrase 2");
642 rbuflen=sizeof(rbuf);
643 if(af_get_seg(af,"page0",0,(unsigned char *)rbuf,&rbuflen)){
644 errx(1,"af_get_seg failed");
645 }
646 if(rbuflen!=strlen((const char *)test)) errx(1,"Reading encrypted with new passphrase data returned wrong size");
647 if(memcmp(rbuf,test,rbuflen)!=0) errx(1,"Error: wrong data");
648 printf("encrypted data read with new passphrase 'dummy': %s\n",rbuf);
649 af_close(af);
650 exit(0);
651
652
653 /* Now try to read with the wrong passphrase */
654 af = af_open("crypto.aff",O_RDONLY,0666);
655 if(af_use_aes_passphrase(af,"yummy2")) err(1,"af_set_passphrase 3");
656 buflen=sizeof(buf);
657 memset(buf,0,sizeof(buf));
658 if(af_get_seg(af,"page0",0,(unsigned char *)buf,&buflen)){
659 printf("Couldn't get data with wrong passphrase (that's good)\n");
660 }
661 printf("data read with wrong passphrase: %s\n",buf);
662 if(buflen>0 && memcmp(buf,test,buflen)==0){
663 errx(1,"Error: data fetched with wrong passphrase was not scrambled.");
664 }
665 af_close(af);
666 exit(0);
667 }
668
669 void readfile_test(const char *fname)
670 {
671 unsigned char buf[1024];
672 memset(buf,0,sizeof(buf));
673 AFFILE *af = af_open(fname,O_RDONLY,0666);
674 if(!af){
675 af_perror(fname);
676 err(1,"af_open(%s)",fname);
677 }
678 printf("using '%s'\n",af->v->name);
679 printf("af_get_imagesize()=%"PRId64" errno=%d\n",af_get_imagesize(af),errno);
680
681 int r = af_read(af,buf,sizeof(buf));
682 printf("af_read(af,buf,1024)=%d errno=%d\n",r,errno);
683 fwrite(buf,1,512,stdout);
684 af_close(af);
685 exit(0);
686 }
687
688 void zap(const char *fn)
689 {
690 unsigned char buf[1024*1024];
691 AFFILE *af = af_open(fn,O_RDWR,0666);
692 if(!af) err(1,"af_open(%s)",fn);
693 memset(buf,0,sizeof(buf));
694 if(af_write(af,buf,sizeof(buf))!=sizeof(buf)){
695 err(1,"af_write()");
696 }
697 af_close(af);
698 }
699
700 void bugs_test()
701 {
702 const char *buf = "This is a test\n";
703 int len = strlen(buf);
704
705 AFFILE *af = af_open("bugs.aff",O_RDWR|O_CREAT|O_TRUNC,0666);
706 if(!af) err(1,"bugs.aff");
707 int r = af_write(af,(unsigned char *)buf,strlen(buf));
708 if(r!=len) err(1,"r=%d len=%d\n",r,len);
709 af_close(af);
710 }
711
712
713 void rsatest();
714 void xmltest(const char *fn);
715
716 void time_test()
717 {
718 int size = 1024*1024*256;
719 unsigned char *buf1 = (u_char *)calloc(size,1);
720 int threaded=0;
721
722 printf("sha1 is 3b4417fc421cee30a9ad0fd9319220a8dae32da2\n");
723 for(int count=0;count<2;count++){
724 buf1[0]= count;
725 for(threaded=0;threaded<2;threaded++){
726 aftimer t;
727 threaded_hash h_md5(EVP_get_digestbyname("md5"),threaded);
728 threaded_hash h_sha1(EVP_get_digestbyname("sha1"),threaded);
729 threaded_hash h_sha2(EVP_get_digestbyname("sha1"),threaded);
730 threaded_hash h_sha3(EVP_get_digestbyname("sha1"),threaded);
731 threaded_hash h_sha256(EVP_get_digestbyname("sha256"),threaded);
732
733 printf("Threaded: %d size: %d\n",threaded,size);
734 t.start();
735 h_sha1.update(buf1,size);
736 h_sha2.update(buf1,size);
737 h_sha3.update(buf1,size);
738 h_md5.update(buf1,size);
739 h_sha256.update(buf1,size);
740
741 unsigned char md[32];
742 char b[64];
743
744 h_md5.final(md,sizeof(md)); printf("md5: %s\n",af_hexbuf(b,sizeof(b),md,16,0));
745 h_sha1.final(md,sizeof(md)); printf("sha1: %s\n",af_hexbuf(b,sizeof(b),md,20,0));
746 h_sha2.final(md,sizeof(md)); printf("sha2: %s\n",af_hexbuf(b,sizeof(b),md,20,0));
747 h_sha3.final(md,sizeof(md)); printf("sha3: %s\n",af_hexbuf(b,sizeof(b),md,20,0));
748 h_sha256.final(md,sizeof(md)); printf("sha256: %s\n",af_hexbuf(b,sizeof(b),md,32,0));
749 t.stop();
750 printf("time: %g\n",t.elapsed_seconds());
751 printf("==============================\n");
752 }
753 }
754 exit(0);
755 }
756
757
758 #include <openssl/pem.h>
759 #include <openssl/bio.h>
760
761 void rsatest()
762 {
763 const EVP_MD *sha256 = EVP_get_digestbyname("sha256");
764
765 if(!sha256){
766 fprintf(stderr,"SHA256 not available\n");
767 return;
768 }
769
770 printf("Now try signing with X.509 certificates and EVP\n");
771
772 char ptext[16];
773 memset(ptext,0,sizeof(ptext));
774 strcpy(ptext,"Simson");
775
776 unsigned char sig[1024];
777 unsigned int siglen = sizeof(sig);
778
779 BIO *bp = BIO_new_file("signing_key.pem","r");
780
781 EVP_MD_CTX md;
782 EVP_PKEY *pkey = PEM_read_bio_PrivateKey(bp,0,0,0);
783
784 EVP_SignInit(&md,sha256);
785 EVP_SignUpdate(&md,ptext,sizeof(ptext));
786 EVP_SignFinal(&md,sig,&siglen,pkey);
787
788 /* let's try to verify it */
789 bp = BIO_new_file("signing_cert.pem","r");
790 X509 *x = 0;
791 PEM_read_bio_X509(bp,&x,0,0);
792 EVP_PKEY *pubkey = X509_get_pubkey(x);
793
794 printf("pubkey=%p\n",pubkey);
795
796 EVP_VerifyInit(&md,sha256);
797 EVP_VerifyUpdate(&md,ptext,sizeof(ptext));
798 int r = EVP_VerifyFinal(&md,sig,siglen,pubkey);
799 printf("r=%d\n",r);
800
801 printf("do it again...\n");
802 EVP_VerifyInit(&md,sha256);
803 EVP_VerifyUpdate(&md,ptext,sizeof(ptext));
804 r = EVP_VerifyFinal(&md,sig,siglen,pubkey);
805 printf("r=%d\n",r);
806
807 printf("make a tiny change...\n");
808 ptext[0]='f';
809 EVP_VerifyInit(&md,sha256);
810 EVP_VerifyUpdate(&md,ptext,sizeof(ptext));
811 r = EVP_VerifyFinal(&md,sig,siglen,pubkey);
812 printf("r=%d\n",r);
813 }
814
815 void xmlseg(BIO *bp,AFFILE *af,const char *segname)
816 {
817 BIO_printf(bp," <segment>\n");
818 BIO_printf(bp," <name>%s</name>\n",segname);
819 /* Get the signature and base64 it (if we can) */
820 u_char sigbuf[1024];
821 size_t sigbuf_len = sizeof(sigbuf);
822 char segname_sig[1024];
823 strlcpy(segname_sig,segname,sizeof(segname_sig));
824 strlcat(segname_sig,AF_SIG256_SUFFIX,sizeof(segname_sig));
825 if(af_get_seg(af,segname_sig,0,sigbuf,&sigbuf_len)==0){
826 char sigbuf48[2048];
827 int sigbuf48_len = b64_ntop(sigbuf,sigbuf_len,sigbuf48,sizeof(sigbuf48));
828 sigbuf48[sigbuf48_len] = 0; // null terminate
829 BIO_printf(bp," <sig>%s</sig>\n",sigbuf48);
830 }
831 BIO_printf(bp," </segment>\n");
832 }
833
834 void xmltest(const char *fn)
835 {
836 BIO *bp = BIO_new(BIO_s_mem());
837 AFFILE *af = af_open(fn,O_RDONLY,0);
838 if(!af) err(1,"%s",fn);
839 char segname[AF_MAX_NAME_LEN];
840 while(af_get_next_seg(af,segname,sizeof(segname),0,0,0)==0){
841 xmlseg(bp,af,segname);
842 }
843 char *buf=0;
844 size_t len = BIO_get_mem_data(bp,&buf);
845 fwrite(buf,1,len,stdout);
846 }
847
848
849 void image_test()
850 {
851 char fn[1024];
852 printf("Imaging test...\n");
853 filename(fn,sizeof(fn),"test_image");
854 unlink(fn); // make sure it is gone
855 AFFILE *af = af_open(fn,O_CREAT|O_RDWR|O_TRUNC,0666);
856 if(!af) err(1,"af_open");
857 }
858
859 void usage()
860 {
861 printf("usage: %s [options]\n",progname);
862 printf(" -e ext = use ext for extension (default is %s)\n",opt_ext);
863 printf(" -p protocol = use protocol for protocol (default is %s)\n",opt_protocol);
864 printf(" -a = do all tests (except -L)\n");
865 printf(" -b = do the bugs test (tests things that were reported and fixed)\n");
866 printf(" -1 = do sequential test\n");
867 printf(" -2 = do reverse test\n");
868 printf(" -3 = do random write test\n");
869 printf(" -4 = do random read test\n");
870 printf(" -5 = do maxsize multi-file test\n");
871 printf(" -6 = sparse file test\n");
872 printf(" -B = run large file test (needs 5GB of disk)\n");
873 printf(" -L = use LZMA compression\n");
874 printf(" -r = perform RSA tests\n");
875 printf(" -d<dir> = use <dir> as the working dir for files (default is %s)\n",tempdir);
876 printf(" -D<filename> = write debugging trace to <filename>\n");
877 printf(" -f<dev> = run af_figure_media on dev and print the results\n");
878 printf(" -c filename = compress filename and output to stdout\n");
879 printf(" -T = just test the LZMA compression\n");
880 printf(" -q = quite; just report errors\n");
881 printf(" -R filename = just try to read the first 1024 bytes of a file and print what happens...\n");
882 printf(" -t = run some timing tests\n");
883 printf(" -n nn = sets MAX_FMTS (default %d)\n",MAX_FMTS);
884 printf(" -i image write speed test (lots of small pages)\n");
885 printf(" -v = verbose\n");
886 #ifdef HAVE_AES_ENCRYPT
887 printf(" -C = just test AES encryption\n");
888 #endif
889 printf(" -x fn = xml test\n");
890 printf(" -z fn = open up fn for writing and zap it.\n");
891 }
892
893 int main(int argc,char **argv)
894 {
895 progname = argv[0];
896 int do_bugs = 0;
897 int do_sequential = 0;
898 int do_reverse = 0;
899 int do_random_write_test = 0;
900 int do_random_read_test = 0;
901 int do_large_file = 0;
902 int do_maxsize_test = 0;
903 int random_repeat = 1;
904 int do_sparse_test = 0;
905 int do_all=0;
906 int do_image_test =1;
907 int ch;
908
909 const char *bigdir = getenv(AFFLIB_BIGTMP); // use by default
910
911 if(bigdir) tempdir = bigdir;
912
913 setvbuf(stdout,0,_IONBF,0);
914 //putenv(AFFLIB_CACHE_STATS"=1");
915
916 if(argc==1){
917 printf("running all tests with -a option (exception bigfile test)\n");
918 do_all = 1;
919 }
920
921 while ((ch = getopt(argc, argv, "b123456aBLd:h?f:e:c:TCp:rx:R:z:tn:D:")) != -1) {
922 switch(ch){
923 case 'D': af_trace = fopen(optarg,"w");break;
924 case 'R': readfile_test(optarg); break;
925 case 'b':
926 do_bugs = 1;
927 break;
928 case '1':
929 do_sequential = 1;
930 break;
931 case '2':
932 do_reverse = 1;
933 break;
934 case '3':
935 do_random_write_test = 1;
936 break;
937 case '4':
938 do_random_read_test = 1;
939 break;
940 case '5':
941 do_maxsize_test = 1;
942 break;
943 case '6': do_sparse_test = 1; break;
944 case 'l':
945 random_repeat = atoi(optarg);
946 break;
947 case 'B':
948 do_large_file = 1;
949 break;
950 case 'n': MAX_FMTS = atoi(optarg); break;
951 case 't': time_test(); break;
952 case 'L': opt_compression_type = AF_COMPRESSION_ALG_LZMA; break;
953 case 'T': lzma_test(); break;
954 case 'r': rsatest(); break;
955 case 'a':
956 do_all = 1;
957 break;
958 case 'z':
959 zap(optarg);break;
960 case 'd': tempdir = optarg; break;
961 case 'f': figure(optarg); break;
962 case 'e': opt_ext = optarg; break;
963 case 'c': compress(optarg); break;
964
965 case 'p': opt_protocol = optarg; break;
966 case 'x': xmltest(optarg);break;
967 case 'C': aestest(); break;
968 case 'i': do_image_test=1;break;
969 case 'h':
970 case '?':
971 default:
972 usage();
973 }
974 }
975
976 if(do_bugs || do_all) bugs_test();
977 if(do_sequential || do_all) sequential_test();
978 if(do_reverse || do_all ) reverse_test();
979 if(do_maxsize_test || do_all) maxsize_test();
980 if(do_sparse_test || do_all) sparse_test();
981 if(do_image_test || do_all) image_test();
982
983 for(int i=0;i<random_repeat;i++){
984 if(do_random_read_test || do_all) random_read_test(256*1024,rand() % 65536);
985 if(do_random_write_test || do_all) random_write_test();
986 }
987
988 if(do_large_file) large_file_test();
989
990 /* Now erase the files ... */
991 unlink("test_random.aff");
992 unlink("test_reverse.aff");
993 unlink("test_random_contents.aff");
994 unlink("test_sequential.aff");
995 unlink("bugs.aff");
996 unlink("test_random_contents.img");
997 unlink("sparse.aff");
998 return 0;
999 }
1000
1001
0 #ifndef __TIMER_H__
1 #define __TIMER_H__
2
3
4 #ifdef __cplusplus
5 #ifndef WIN32
6 #include <inttypes.h>
7 #include <sys/time.h>
8 #endif
9 #include <sys/types.h>
10 #include <stdio.h>
11
12
13 class aftimer {
14 bool used; // was this timer used?
15 struct timeval t0;
16 bool running;
17 long total_sec;
18 long total_usec;
19 double lap_time_; // time from when we last did a "stop"
20 char buf[64]; // internal time buffer
21 public:
22 aftimer();
23 time_t tstart();
24 void start();
25 void stop();
26 double elapsed_seconds(); //
27 double lap_time();
28 static char *hms(char *b,long t); // turn a number of seconds into hms
29 const char *timer_text(char *buf); // return the time spent reading, as text
30 const char *timer_text(); // uses internal buffer
31 double eta(double fraction_done); // calculate ETA in seconds, given fraction
32 const char *eta_text(char *buf,double fraction_done);
33 const char *eta_text(double fraction_done);
34 };
35
36 inline aftimer::aftimer()
37 {
38 running = false;
39 total_sec = 0;
40 total_usec = 0;
41 lap_time_ = 0;
42 }
43
44
45 inline time_t aftimer::tstart()
46 {
47 return t0.tv_sec;
48 }
49
50 inline void aftimer::start()
51 {
52 gettimeofday(&t0,NULL);
53 running = 1;
54 }
55
56 inline void aftimer::stop(){
57 if(running){
58 struct timeval t;
59 gettimeofday(&t,NULL);
60 total_sec += t.tv_sec - t0.tv_sec;
61 total_usec += t.tv_usec - t0.tv_usec;
62 lap_time_ = (double)(t.tv_sec - t0.tv_sec) + (double)(t.tv_usec - t0.tv_usec)/1000000.0;
63 running = false;
64 }
65 }
66
67 inline double aftimer::lap_time()
68 {
69 return lap_time_;
70 }
71
72 inline double aftimer::elapsed_seconds()
73 {
74 double ret = (double)total_sec + (double)total_usec/1000000.0;
75 if(running){
76 struct timeval t;
77 gettimeofday(&t,NULL);
78 ret += t.tv_sec - t0.tv_sec;
79 ret += (t.tv_usec - t0.tv_usec) / 1000000.0;
80 }
81 return ret;
82 }
83
84 inline char *aftimer::hms(char *buf,long t)
85 {
86 int h = t / 3600;
87 int m = (t / 60) % 60;
88 int s = t % 60;
89 sprintf(buf,"%02d:%02d:%02d",h,m,s);
90 return buf;
91 }
92
93 inline const char *aftimer::timer_text(char *buf)
94 {
95 return hms(buf,(int)elapsed_seconds());
96 }
97
98 inline const char *aftimer::timer_text()
99 {
100 return timer_text(buf);
101 }
102
103 inline double aftimer::eta(double fraction_done)
104 {
105 double t = elapsed_seconds();
106 if(t==0) return -1; // can't figure it out
107 if(fraction_done==0) return -1; // can't figure it out
108 return (t * 1.0/fraction_done - t);
109 }
110
111 inline const char *aftimer::eta_text(char *buf,double fraction_done)
112 {
113 double e = eta(fraction_done);
114 if(e<0) return "n/a"; // can't figure it out
115 return hms(buf,(long)e);
116 }
117
118 inline const char *aftimer::eta_text(double fraction_done)
119 {
120 return eta_text(buf,fraction_done);
121 }
122
123 #endif
124
125 #endif
0 /*
1 * Copyright (c) 1996-1999 by Internet Software Consortium.
2 *
3 * Permission to use, copy, modify, and distribute this software for any
4 * purpose with or without fee is hereby granted, provided that the above
5 * copyright notice and this permission notice appear in all copies.
6 *
7 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
8 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
9 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
10 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
11 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
12 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
13 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
14 * SOFTWARE.
15 */
16
17 /*
18 * Portions Copyright (c) 1995 by International Business Machines, Inc.
19 *
20 * International Business Machines, Inc. (hereinafter called IBM) grants
21 * permission under its copyrights to use, copy, modify, and distribute this
22 * Software with or without fee, provided that the above copyright notice and
23 * all paragraphs of this notice appear in all copies, and that the name of IBM
24 * not be used in connection with the marketing of any product incorporating
25 * the Software or modifications thereof, without specific, written prior
26 * permission.
27 *
28 * To the extent it has a right to do so, IBM grants an immunity from suit
29 * under its patents, if any, for the use, sale or manufacture of products to
30 * the extent that such products are used for performing Domain Name System
31 * dynamic updates in TCP/IP networks by means of the Software. No immunity is
32 * granted for any product per se or for any other function of any product.
33 *
34 * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
35 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
36 * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
37 * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
38 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
39 * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
40 */
41
42 #include <stdio.h>
43 #include <stdlib.h>
44
45 #ifdef HAVE_SYS_TYPES_H
46 #include <sys/types.h>
47 #else
48 typedef unsigned char u_char;
49 #endif
50
51 #include <ctype.h>
52 #include <string.h>
53
54 #include "base64.h"
55
56 #define Assert(Cond) if (!(Cond)) abort()
57
58 static const char Base64[] =
59 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
60 static const char Pad64 = '=';
61
62 /* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
63 The following encoding technique is taken from RFC 1521 by Borenstein
64 and Freed. It is reproduced here in a slightly edited form for
65 convenience.
66
67 A 65-character subset of US-ASCII is used, enabling 6 bits to be
68 represented per printable character. (The extra 65th character, "=",
69 is used to signify a special processing function.)
70
71 The encoding process represents 24-bit groups of input bits as output
72 strings of 4 encoded characters. Proceeding from left to right, a
73 24-bit input group is formed by concatenating 3 8-bit input groups.
74 These 24 bits are then treated as 4 concatenated 6-bit groups, each
75 of which is translated into a single digit in the base64 alphabet.
76
77 Each 6-bit group is used as an index into an array of 64 printable
78 characters. The character referenced by the index is placed in the
79 output string.
80
81 Table 1: The Base64 Alphabet
82
83 Value Encoding Value Encoding Value Encoding Value Encoding
84 0 A 17 R 34 i 51 z
85 1 B 18 S 35 j 52 0
86 2 C 19 T 36 k 53 1
87 3 D 20 U 37 l 54 2
88 4 E 21 V 38 m 55 3
89 5 F 22 W 39 n 56 4
90 6 G 23 X 40 o 57 5
91 7 H 24 Y 41 p 58 6
92 8 I 25 Z 42 q 59 7
93 9 J 26 a 43 r 60 8
94 10 K 27 b 44 s 61 9
95 11 L 28 c 45 t 62 +
96 12 M 29 d 46 u 63 /
97 13 N 30 e 47 v
98 14 O 31 f 48 w (pad) =
99 15 P 32 g 49 x
100 16 Q 33 h 50 y
101
102 Special processing is performed if fewer than 24 bits are available
103 at the end of the data being encoded. A full encoding quantum is
104 always completed at the end of a quantity. When fewer than 24 input
105 bits are available in an input group, zero bits are added (on the
106 right) to form an integral number of 6-bit groups. Padding at the
107 end of the data is performed using the '=' character.
108
109 Since all base64 input is an integral number of octets, only the
110 -------------------------------------------------
111 following cases can arise:
112
113 (1) the final quantum of encoding input is an integral
114 multiple of 24 bits; here, the final unit of encoded
115 output will be an integral multiple of 4 characters
116 with no "=" padding,
117 (2) the final quantum of encoding input is exactly 8 bits;
118 here, the final unit of encoded output will be two
119 characters followed by two "=" padding characters, or
120 (3) the final quantum of encoding input is exactly 16 bits;
121 here, the final unit of encoded output will be three
122 characters followed by one "=" padding character.
123 */
124
125 extern "C"
126 int
127 b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) {
128 size_t datalength = 0;
129 u_char input[3];
130 u_char output[4];
131 size_t i;
132
133 while (2 < srclength) {
134 input[0] = *src++;
135 input[1] = *src++;
136 input[2] = *src++;
137 srclength -= 3;
138
139 output[0] = input[0] >> 2;
140 output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
141 output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
142 output[3] = input[2] & 0x3f;
143 Assert(output[0] < 64);
144 Assert(output[1] < 64);
145 Assert(output[2] < 64);
146 Assert(output[3] < 64);
147
148 if (datalength + 4 > targsize)
149 return (-1);
150 target[datalength++] = Base64[output[0]];
151 target[datalength++] = Base64[output[1]];
152 target[datalength++] = Base64[output[2]];
153 target[datalength++] = Base64[output[3]];
154 }
155
156 /* Now we worry about padding. */
157 if (0 != srclength) {
158 /* Get what's left. */
159 input[0] = input[1] = input[2] = '\0';
160 for (i = 0; i < srclength; i++)
161 input[i] = *src++;
162
163 output[0] = input[0] >> 2;
164 output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
165 output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
166 Assert(output[0] < 64);
167 Assert(output[1] < 64);
168 Assert(output[2] < 64);
169
170 if (datalength + 4 > targsize)
171 return (-1);
172 target[datalength++] = Base64[output[0]];
173 target[datalength++] = Base64[output[1]];
174 if (srclength == 1)
175 target[datalength++] = Pad64;
176 else
177 target[datalength++] = Base64[output[2]];
178 target[datalength++] = Pad64;
179 }
180 if (datalength >= targsize)
181 return (-1);
182 target[datalength] = '\0'; /* Returned value doesn't count \0. */
183 return (datalength);
184 }
185
186 /* skips all whitespace anywhere.
187 converts characters, four at a time, starting at (or after)
188 src from base - 64 numbers into three 8 bit bytes in the target area.
189 it returns the number of data bytes stored at the target, or -1 on error.
190 */
191
192 extern "C"
193 int
194 b64_pton_slg(char const *src, int srclen, u_char *target, size_t targsize)
195 {
196 int tarindex, state, ch;
197 const char *pos;
198
199 state = 0;
200 tarindex = 0;
201
202 while ((ch = *src++) != '\0' && srclen>0){
203 srclen--;
204 if (isspace(ch)) /* Skip whitespace anywhere. */
205 continue;
206
207 if (ch == Pad64)
208 break;
209
210 pos = strchr(Base64, ch);
211 if (pos == 0){ /* A non-base64 character. */
212 puts("B64 Fail at 1");
213 return (-1);
214 }
215
216 switch (state) {
217 case 0:
218 if (target) {
219 if ((size_t)tarindex >= targsize){
220 puts("B64 fail at 2");
221 return (-1);
222 }
223 target[tarindex] = (pos - Base64) << 2;
224 }
225 state = 1;
226 break;
227 case 1:
228 if (target) {
229 if ((size_t)tarindex + 1 >= targsize){
230 puts("B64 fail at 3");
231 return (-1);
232 }
233 target[tarindex] |= (pos - Base64) >> 4;
234 target[tarindex+1] = ((pos - Base64) & 0x0f)
235 << 4 ;
236 }
237 tarindex++;
238 state = 2;
239 break;
240 case 2:
241 if (target) {
242 if ((size_t)tarindex + 1 >= targsize){
243 puts("B64 fail at 4");
244 return (-1);
245 }
246 target[tarindex] |= (pos - Base64) >> 2;
247 target[tarindex+1] = ((pos - Base64) & 0x03)
248 << 6;
249 }
250 tarindex++;
251 state = 3;
252 break;
253 case 3:
254 if (target) {
255 if ((size_t)tarindex >= targsize){
256 puts("B64 fail at 5");
257 return (-1);
258 }
259 target[tarindex] |= (pos - Base64);
260 }
261 tarindex++;
262 state = 0;
263 break;
264 default:
265 abort();
266 }
267 }
268
269 /*
270 * We are done decoding Base-64 chars. Let's see if we ended
271 * on a byte boundary, and/or with erroneous trailing characters.
272 */
273
274 if (ch == Pad64) { /* We got a pad char. */
275 ch = *src++; /* Skip it, get next. */
276 srclen--;
277
278 switch (state) {
279 case 0: /* Invalid = in first position */
280 case 1: /* Invalid = in second position */
281 puts("B64 fail at 6");
282 /* return (-1);*/
283 return tarindex; /* slg is nicer */
284
285 case 2: /* Valid, means one byte of info */
286 /* Skip any number of spaces. */
287 for ((void)NULL; ch != '\0' && srclen>0 ; ch = *src++,srclen--){
288 if (!isspace(ch)){
289 break;
290 }
291 }
292 /* Make sure there is another trailing = sign. */
293 if (ch != Pad64){
294 puts("B64 fail at 7");
295 return (-1);
296 }
297 ch = *src++; /* Skip the = */
298 srclen--;
299 /* Fall through to "single trailing =" case. */
300 /* FALLTHROUGH */
301
302 case 3: /* Valid, means two bytes of info */
303 /*
304 * We know this char is an =. Is there anything but
305 * whitespace after it?
306 */
307 for ((void)NULL; ch != '\0' && srclen>0; ch = *src++,srclen--)
308 if (!isspace(ch)){
309 puts("B64 fail at 8");
310 return (-1);
311 }
312
313 /*
314 * Now make sure for cases 2 and 3 that the "extra"
315 * bits that slopped past the last full byte were
316 * zeros. If we don't check them, they become a
317 * subliminal channel.
318 */
319 if (target && target[tarindex] != 0){
320 puts("B64 fail at 9");
321 return (-1);
322 }
323 }
324 } else {
325 /*
326 * We ended by seeing the end of the string. Make sure we
327 * have no partial bytes lying around.
328 */
329 if (state != 0){
330 puts("B64 fail at 10");
331 return (-1);
332 }
333 }
334
335 return (tarindex);
336 }
0 /*
1 * Base64 conversion.
2 *
3 * From RFC1521 and draft-ietf-dnssec-secext-03.txt.
4 *
5 * Implementation (C) 1996-1999 by Internet Software Consortium.
6 */
7
8
9
10 #ifndef BASE64_H
11 #define BASE64_H
12
13 #include <sys/types.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 #ifdef NEVER_DEFINED
19 }
20 #endif
21 /* Convert from printable base64 to binary.
22 * Returns number of bytes converted
23 */
24 int b64_pton_slg(const char *str,int srclen,unsigned char *target,size_t targsize);
25
26 /* Convert from binary to printable base 64.
27 * returns size of printable thing.
28 */
29 int b64_ntop(const unsigned char *str,size_t srclength,char *target,size_t targsize);
30
31 #ifdef NEVER_DEFINED
32 {
33 #endif
34 #ifdef __cplusplus
35 }
36 #endif
37
38 #endif
0 /*
1 * Copyright (c) 2005, 2006, 2007
2 * Simson L. Garfinkel and Basis Technology, Inc.
3 * All rights reserved.
4 *
5 * This code is derrived from software contributed by
6 * Simson L. Garfinkel
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Simson L. Garfinkel
19 * and Basis Technology Corp.
20 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
21 * contributors to this program may be used to endorse or promote
22 * products derived from this software without specific prior written
23 * permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
26 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
27 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
30 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
33 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
35 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
36 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39
40 #include "affconfig.h"
41 #include "afflib.h"
42 #include "afflib_i.h"
43 #include "utils.h"
44
45 #ifdef HAVE_OPENSSL_PEM_H
46 #include <openssl/pem.h>
47 #include <openssl/bio.h>
48 #endif
49
50 #include <vector>
51 #include <set>
52 #include <string>
53
54 #ifdef HAVE_CSTRING
55 #include <cstring>
56 #endif
57
58
59 using namespace std;
60
61
62
63 /****************************************************************
64 *** LOW LEVEL ROUTINES
65 ****************************************************************/
66
67 /**
68 * Returns TRUE if the segment named 'buf' has the suffixi indicating
69 * that it is an encrypted segment.
70 */
71 int af_is_encrypted_segment(const char *segname){
72 if(strcmp(segname,AF_AFFKEY)==0) return 1;
73 if(aff::ends_with(segname,AF_AES256_SUFFIX)) return 1;
74 if(strncmp(segname,AF_AFFKEY_EVP,strlen(AF_AFFKEY_EVP)-1)==0) return 1;
75 return 0;
76 }
77
78 /**
79 * Returns TRUE if the segment named 'buf' has the suffix indicating
80 * that it is a signature segment.
81 *
82 * @param segname - segment to check
83 */
84 int af_is_signature_segment(const char *segname){
85 int num = 0;
86 char cc;
87 if(aff::ends_with(segname,AF_SIG256_SUFFIX)) return 1;
88 if(sscanf(segname,"affbom%d%c",&num,&cc)==1) return 1; // it's a bom segment
89 return 0;
90 }
91
92
93 /****************************************************************
94 *** AES ENCRYPTION LAYER
95 ****************************************************************/
96
97 static const char *aff_cannot_sign = "AFFLIB: OpenSSL does not have SHA256! "\
98 "AFF segments cannot be signed. "\
99 "See http://www.afflib.org/requirements.php for additional information.";
100
101 void af_crypto_allocate(AFFILE *af)
102 {
103 af->crypto = (struct af_crypto *)calloc(sizeof(struct af_crypto),1); // give space
104 }
105
106
107 /** compute SHA256.
108 * Return 0 if success, -1 if error.
109 */
110 int af_SHA256(const unsigned char *data,size_t datalen,unsigned char md[32])
111 {
112 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
113 if(!sha256) return -1;
114
115 unsigned int sha256_buflen = 32;
116 EVP_MD_CTX ctx;
117 EVP_DigestInit(&ctx,sha256);
118 EVP_DigestUpdate(&ctx,data,datalen);
119 if(EVP_DigestFinal(&ctx,md,&sha256_buflen)!=1) return -1; // EVP_DigestFinal returns 1 for success
120 return 0;
121 }
122
123 void af_crypto_deallocate(AFFILE *af)
124 {
125 #ifdef AES_BLOCK_SIZE
126 memset(&af->crypto->ekey,0,sizeof(af->crypto->ekey));
127 memset(&af->crypto->dkey,0,sizeof(af->crypto->dkey));
128 #endif
129 #ifdef HAVE_PEM_READ_BIO_RSA_PUBKEY
130 if(af->crypto->sign_privkey){
131 EVP_PKEY_free(af->crypto->sign_privkey);
132 af->crypto->sign_privkey = 0;
133 }
134 if(af->crypto->sign_pubkey){
135 EVP_PKEY_free(af->crypto->sign_pubkey);
136 af->crypto->sign_pubkey = 0;
137 }
138 if(af->crypto->sign_cert){
139 X509_free(af->crypto->sign_cert);
140 af->crypto->sign_cert = 0;
141 }
142 #endif
143 free(af->crypto);
144 af->crypto = 0;
145 }
146
147
148 int af_set_aes_key(AFFILE *af,const unsigned char *userKey,const int bits)
149 {
150 #ifdef HAVE_AES_ENCRYPT
151 if(af->crypto->sealing_key_set){
152 if(userKey==0){ // key was set and it is being cleared
153 af->crypto->sealing_key_set = 0;
154 return 0;
155 }
156 return AF_ERROR_KEY_SET; // key is already set
157 }
158 int r;
159 r = AES_set_encrypt_key(userKey,bits,&af->crypto->ekey);
160 if(r) return r;
161
162 r = AES_set_decrypt_key(userKey,bits,&af->crypto->dkey);
163 if(r) return r;
164
165 af->crypto->sealing_key_set = 1;
166 af->crypto->auto_decrypt = 1; // default
167 af_invalidate_vni_cache(af); // invalidate the cache, because now we can read encrypted values
168 return 0;
169 #else
170 return AF_ERROR_NO_AES;
171 #endif
172 }
173
174
175
176 /**
177 * Take an unencrypted AFFKEY, encrypt it with the SHA256 of the passphrase,
178 * and save it in the appropriate segment.
179 */
180
181 int af_save_aes_key_with_passphrase(AFFILE *af,const char *passphrase, const u_char affkey[32])
182 {
183 #if defined(HAVE_AES_ENCRYPT)
184 if(af->crypto->sealing_key_set) return AF_ERROR_KEY_SET; // already enabled
185
186 /* Make an encrypted copy of the AFFkey */
187 unsigned char passphrase_hash[32];
188 af_SHA256((const unsigned char *)passphrase, strlen(passphrase), passphrase_hash);
189
190 struct affkey affkey_seg;
191 assert(sizeof(affkey_seg)==AFFKEY_SIZE);
192 memset((unsigned char *)&affkey_seg,0,sizeof(affkey_seg));
193
194 uint32_t version_number = htonl(1); // version 1
195 memcpy(affkey_seg.version,(u_char *)&version_number,4);
196 memcpy(affkey_seg.affkey_aes256,affkey,32);
197
198 /* Use the hash to encrypt the key and all zeros */
199 AES_KEY ekey;
200 AES_set_encrypt_key(passphrase_hash,256,&ekey);
201 AES_encrypt(affkey_seg.affkey_aes256,
202 affkey_seg.affkey_aes256,&ekey);
203 AES_encrypt(affkey_seg.affkey_aes256+AES_BLOCK_SIZE,
204 affkey_seg.affkey_aes256+AES_BLOCK_SIZE,&ekey);
205 AES_encrypt(affkey_seg.zeros_aes256,affkey_seg.zeros_aes256,&ekey);
206
207 /* Write this to a segment */
208 if(af_update_seg(af,AF_AFFKEY,0,(const u_char *)&affkey_seg,sizeof(affkey_seg))) return -1;
209 memset((unsigned char *)&affkey_seg,0,sizeof(affkey_seg)); // erase the temp data
210 return 0;
211 #endif
212 #if !defined(HAVE_AES_ENCRYPT)
213 return AF_ERROR_NO_AES;
214 #endif
215 }
216
217 /** MacOS 10.5 with GCC 4.0.1 packed affkey at 52 bytes.
218 ** Linux GCC 4.1.2 packed affkey at 56 bytes. It should be 52 bytes
219 ** --- 4 bytes for the version number, 32 bytes for the affkey, 16 bytes for encryption of zeros.
220 ** original code specified the version as unsigned long version:32, for which the
221 ** compiler allocated 64 bits...
222 ** So this code needs to be willing to accept a 52-byte or 56-byte affkey.
223 **/
224 /* Legacy - this version of the structure was improperly used in AFFLIB prior to
225 * 3.1.6. Unfortunately, the structure didn't pack properly, resulting in some images
226 * in which the affkey structure was too large.
227 */
228 struct affkey_legacy {
229 unsigned long version:32;
230 u_char affkey_aes256[32]; // AFF key encrypted with SHA-256 of passphrase
231 // encrypted as two codebooks in a row; no need for CBC
232 u_char zeros_aes256[16]; // all zeros encrypted with SHA-256 of passphrase
233 };
234
235 int af_get_aes_key_from_passphrase(AFFILE *af,const char *passphrase,
236 unsigned char affkey[32])
237 {
238 #if defined(HAVE_AES_ENCRYPT)
239 if(af->crypto->sealing_key_set) return AF_ERROR_KEY_SET; // already enabled
240
241 /* Get the segment with the key in it. It should be AFFKEY_SIZE
242 * but there are a few images out there with the wrong key size due
243 * to a compiler packing bug. Automatically handle those.
244 */
245 struct affkey affkey_seg; // in-memory copy
246 u_char kbuf[1024];
247 size_t klen=sizeof(kbuf);
248 uint32_t version;
249 int kversion=0;
250
251 /* Try to get the segment */
252 if(af_get_seg(af,AF_AFFKEY,0,kbuf,&klen)) return AF_ERROR_AFFKEY_NOT_EXIST;
253
254 if(sizeof(affkey_seg)==klen){
255 // On-disk structure is correct; copy it over
256 memcpy(&affkey_seg,kbuf,klen);
257 memcpy((char *)&version,affkey_seg.version,4);
258 kversion = ntohl(version);
259 } else {
260 // Try to figure it out manually
261 memcpy((char *)&version,kbuf,4);
262 kversion = ntohl(version);
263 memcpy(affkey_seg.affkey_aes256,kbuf+4,sizeof(affkey_seg.affkey_aes256));
264 memcpy(affkey_seg.zeros_aes256,kbuf+36,sizeof(affkey_seg.zeros_aes256));
265 }
266
267 /* make sure version is correct */
268 if(kversion != 1){
269 errno = EINVAL;
270 return AF_ERROR_AFFKEY_WRONG_VERSION;
271 }
272
273 /* hash the passphrase */
274 unsigned char passphrase_hash[32];
275 if(af_SHA256((const unsigned char *)passphrase,strlen(passphrase), passphrase_hash)){
276 return AF_ERROR_NO_SHA256;
277 }
278
279 /* Try to decrypt the key */
280
281 AES_KEY dkey;
282 AES_set_decrypt_key(passphrase_hash,256,&dkey);
283 AES_decrypt(affkey_seg.affkey_aes256,
284 affkey_seg.affkey_aes256,&dkey);
285 AES_decrypt(affkey_seg.affkey_aes256+AES_BLOCK_SIZE,
286 affkey_seg.affkey_aes256+AES_BLOCK_SIZE,&dkey);
287 AES_decrypt(affkey_seg.zeros_aes256,affkey_seg.zeros_aes256,&dkey);
288
289 /* See if its zero? */
290 for(u_int i=0;i<sizeof(affkey_seg.zeros_aes256);i++){
291 if(affkey_seg.zeros_aes256[i]) return AF_ERROR_WRONG_PASSPHRASE;
292 }
293
294
295 memcpy(affkey,affkey_seg.affkey_aes256,32); /* copy out the result */
296 memset((unsigned char *)&affkey_seg,0,sizeof(affkey_seg)); // erase the temp data
297 return 0;
298 #endif
299 #if !defined(HAVE_AES_ENCRYPT)
300 return AF_ERROR_NO_AES;
301 #endif
302 }
303
304 /**
305 * make a random affkey and encrypt it with passphrase.
306 */
307 int af_establish_aes_passphrase(AFFILE *af,const char *passphrase)
308 {
309 #ifdef HAVE_AES_ENCRYPT
310 if(af->crypto->sealing_key_set) return AF_ERROR_KEY_SET; // already enabled
311
312 /* Can only establish a passphrase if the encryption segment doesn't exist */
313 if(af_get_seg(af,AF_AFFKEY,0,0,0)==0) return AF_ERROR_AFFKEY_EXISTS;
314
315 /* Check to make sure it wasn't public key encrypted */
316 char segname[AF_MAX_NAME_LEN];
317 snprintf(segname,sizeof(segname),AF_AFFKEY_EVP,0);
318 if(af_get_seg(af,segname,0,0,0)==0) return AF_ERROR_AFFKEY_EXISTS;
319
320 /* Okay; make a random key and encrypt it with the passphrase */
321 unsigned char affkey[32];
322 int r = RAND_bytes(affkey,sizeof(affkey)); // makes a random key; with REAL random bytes
323 if(r!=1) r = RAND_pseudo_bytes(affkey,sizeof(affkey)); // true random not supported
324 if(r!=1) return AF_ERROR_RNG_FAIL; // pretty bad...
325
326 /* I have the key, now save it */
327 r = af_save_aes_key_with_passphrase(af,passphrase,affkey);
328 memset(affkey,0,sizeof(affkey)); /* Erase the encryption key in memory */
329 return r;
330 #else
331 return AF_ERROR_NO_AES;
332 #endif
333 }
334
335
336 /** Like the one above, this public interface actually wipes the key after it is created.
337 * @param passphrase - Passphrae, use NULL to erase the encryption key.
338 * This can only be done if the file is opened read-only.
339 */
340 int af_use_aes_passphrase(AFFILE *af,const char *passphrase)
341 {
342 if(passphrase==0 && !(af->openflags & O_RDWR)){
343 af->crypto->sealing_key_set = 0;
344 return 0;
345 }
346
347 if(af->crypto->sealing_key_set) return AF_ERROR_KEY_SET; // already enabled
348
349 unsigned char affkey[32];
350 int r = af_get_aes_key_from_passphrase(af,passphrase,affkey);
351 if(r) return r; // wrong keyphrase
352 r = af_set_aes_key(af,affkey,256); /* Set the encryption key */
353 memset(affkey,0,sizeof(affkey)); /* Erase the encryption key in memory */
354 return r;
355 }
356
357
358 /* gets the key with the old phrase and then changes it to the new one */
359 int af_change_aes_passphrase(AFFILE *af,const char *oldphrase,const char *newphrase)
360 {
361 if(af->crypto->sealing_key_set) return AF_ERROR_KEY_SET; // already enabled
362
363 unsigned char affkey[32];
364 int r = af_get_aes_key_from_passphrase(af,oldphrase,affkey);
365
366 if(r) return r;
367 r = af_save_aes_key_with_passphrase(af,newphrase,affkey);
368 memset(affkey,0,sizeof(affkey)); // erase the temp data
369 return r;
370 }
371
372
373 int af_has_encrypted_segments(AFFILE *af)
374 {
375 struct af_vnode_info vni;
376 af_vstat(af,&vni);
377 return vni.segment_count_encrypted>0;
378 }
379
380 /**
381 * Returns true if there are segments that cannot be decrypted
382 * (other than key segments)
383 */
384 int af_cannot_decrypt(AFFILE *af){
385 if(af_has_encrypted_segments(af)==0) return 0; // no encrypted segments to decrypt
386 /* Now start at the beginning and see if any segments are read which are encrypted.
387 * If they are encrypted, then we don't have the encryption key.
388 */
389 if(af_rewind_seg(af)) return -1;
390 char segname[AF_MAX_NAME_LEN];
391 memset(segname,0,sizeof(segname));
392 while(af_get_next_seg(af,segname,sizeof(segname),0,0,0)==0){
393 if(aff::ends_with(segname,AF_AES256_SUFFIX)) return 1; // we shouldn't see these.
394 }
395 return 0;
396 }
397
398 /****************************************************************
399 ***
400 *** Signature Routines
401 ***
402 ****************************************************************/
403
404 /** See if the public key and private key match by dial a trial encryption and decryption.
405 *
406 * @param pubkey
407 * @param privkey
408 * @returns 0 if successful, -1 if failure.
409 */
410 static int check_keys(EVP_PKEY *privkey,EVP_PKEY *pubkey)
411 {
412 char ptext[16]; /* plaintext of a 128-bit message */
413 unsigned char sig[1024]; /* signature; bigger than needed */
414 unsigned int siglen = sizeof(sig); /* length of signature */
415
416 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
417 if(!sha256) return -1; // no SHA256.
418
419 EVP_MD_CTX md; /* EVP message digest */
420
421
422 /* make the plaintext message */
423 memset(ptext,0,sizeof(ptext));
424 strcpy(ptext,"Test Message");
425 EVP_SignInit(&md,sha256);
426 EVP_SignUpdate(&md,ptext,sizeof(ptext));
427 EVP_SignFinal(&md,sig,&siglen,privkey);
428
429 /* Verify the message */
430 EVP_VerifyInit(&md,sha256);
431 EVP_VerifyUpdate(&md,ptext,sizeof(ptext));
432 if(EVP_VerifyFinal(&md,sig,siglen,pubkey)!=1){
433 return -3;
434 }
435 return 0;
436 }
437
438
439 /**
440 * af_set_sign_files:
441 *
442 * Load the private key & certificate, make sure they are matched, and
443 * write to the AFF. This requirest not just AES256, but EVP_SHA256
444 * because we use the openSSL signature functions.
445 *
446 * @param af - The open AFFILE
447 * @param keyfile - The filename of the key file to read
448 * @param certfile - The filename of the certificate file to read
449 */
450
451
452 int af_set_sign_files(AFFILE *af,const char *keyfile,const char *certfile)
453 {
454 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
455 if(!sha256){
456 (*af->error_reporter)(aff_cannot_sign);
457 return AF_ERROR_NO_SHA256; //
458 }
459
460 BIO *bp = BIO_new_file(keyfile,"r");
461 if(!bp) return -1;
462 af->crypto->sign_privkey = PEM_read_bio_PrivateKey(bp,0,0,NULL);
463 BIO_free(bp);
464 if(!af->crypto->sign_privkey) return -2; // can't decode keyfile
465
466 bp = BIO_new_file(certfile,"r");
467 if(!bp) return -1;
468 PEM_read_bio_X509(bp,&af->crypto->sign_cert,0,0);
469 if(af->crypto->sign_cert==0){
470 EVP_PKEY_free(af->crypto->sign_privkey);
471 af->crypto->sign_privkey = 0;
472 return -3;
473 }
474 af->crypto->sign_pubkey = X509_get_pubkey(af->crypto->sign_cert);
475 BIO_free(bp);
476
477 if(check_keys(af->crypto->sign_privkey,af->crypto->sign_pubkey)){
478 /* private key doesn't match certificate */
479 EVP_PKEY_free(af->crypto->sign_privkey); af->crypto->sign_privkey = 0;
480 EVP_PKEY_free(af->crypto->sign_pubkey); af->crypto->sign_pubkey = 0;
481 return -4;
482 }
483
484 /* Looks good; save the cert in a segment */
485 BIO *xbp = BIO_new(BIO_s_mem()); // where we are writing
486 PEM_write_bio_X509(xbp,af->crypto->sign_cert);
487 af_update_seg_frombio(af,AF_SIGN256_CERT,0,xbp);
488 BIO_free(xbp);
489 return 0;
490 }
491
492 /* Sign the segment with the signing key. Signatures are calculated
493 * by taking the SHA256 of the following concatenated together:
494 * segment name
495 * segment arg (in network byte order)
496 * segment data
497 */
498 int af_sign_seg3(AFFILE *af,const char *segname,
499 unsigned long arg,const unsigned char *data,unsigned int datalen,
500 unsigned long signmode)
501 {
502 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
503 if(!sha256){
504 (*af->error_reporter)(aff_cannot_sign);
505 return AF_ERROR_NO_SHA256; //
506 }
507
508
509 if(af->crypto->sign_privkey==0) return -1; // can't sign; no signing key
510
511 if(strlen(segname)+strlen(AF_SIG256_SUFFIX)+1 > AF_MAX_NAME_LEN) return -1; // too long
512
513 char signed_segname[AF_MAX_NAME_LEN];
514 strlcpy(signed_segname,segname,AF_MAX_NAME_LEN);
515 strlcat(signed_segname,AF_SIG256_SUFFIX,AF_MAX_NAME_LEN);
516
517 if(signmode==AF_SIGNATURE_DELETE){
518 af_del_seg(af,signed_segname);
519 return 0;
520 }
521
522 unsigned long arg_net = htonl(arg);
523 unsigned char sig[1024]; /* signature; bigger than needed */
524 unsigned int siglen = sizeof(sig); /* length of signature */
525
526 EVP_MD_CTX md; /* EVP message digest */
527 EVP_SignInit(&md,sha256);
528 EVP_SignUpdate(&md,(const unsigned char *)segname,strlen(segname)+1);
529 EVP_SignUpdate(&md,(const unsigned char *)&arg_net,sizeof(arg_net));
530 EVP_SignUpdate(&md,data,datalen);
531 EVP_SignFinal(&md,sig,&siglen,af->crypto->sign_privkey);
532 return (*af->v->update_seg)(af,signed_segname,signmode,sig,siglen);
533 }
534
535
536 int af_sign_seg(AFFILE *af,const char *segname)
537 {
538 size_t datalen = 0;
539
540 /* Now get the data to verify */
541 if(af_get_seg(af,segname,0,0,&datalen)){
542 return AF_ERROR_SIG_DATAREAD_ERROR; // can't read the segment length
543 }
544
545 /* Now read the segment */
546 unsigned char *data=(unsigned char *)malloc(datalen);
547 if(data==0) return AF_ERROR_SIG_MALLOC;
548
549 unsigned long arg=0;
550 if(af_get_seg(af,segname,&arg,data,&datalen)){
551 free(data);
552 return AF_ERROR_SIG_DATAREAD_ERROR; // can't read the segment length
553 }
554
555 /* Note: it woudl be wrong to detect pages and sign them in mode1, because we don't really
556 * have access to the uncompressed data...
557 */
558 int r = af_sign_seg3(af,segname,arg,data,datalen,AF_SIGNATURE_MODE0);
559 free(data);
560 return r;
561 }
562
563
564 /** Returns number of segments that were signed.
565 * Returns -1 if there is an error.
566 */
567 int af_sign_all_unsigned_segments(AFFILE *af)
568 {
569 vector<string> segs;
570 set<string>sigs;
571 char name[AF_MAX_NAME_LEN];
572 int count=0;
573
574 /* Get a list of all the segments and all the signatures */
575 if(af_rewind_seg(af)) return -1;
576 while(af_get_next_seg(af,name,sizeof(name),0,0,0)==0){
577 if(name[0]==0) continue; // don't sign the empty segments
578 if(aff::ends_with(name,AF_SIG256_SUFFIX)==0){
579 segs.push_back(name);
580 }
581 else{
582 sigs.insert(name);
583 }
584 }
585 /* Sign the ones that are unsigned. */
586 for(vector<string>::const_iterator s = segs.begin();
587 s != segs.end();
588 s++){
589 /* Compute name of the signature */
590 string signame = *s + AF_SIG256_SUFFIX;
591 if(sigs.find(signame) == sigs.end()){
592 if(af_sign_seg(af,s->c_str())){
593 (*af->error_reporter)("AFFLIB: Could not sign segment '%s'",s->c_str());
594 return -1;
595 }
596 count++;
597 }
598 }
599 return count;
600 }
601
602 /* Verify a segment against a particular signature and public key */
603 int af_hash_verify_seg2(AFFILE *af,const char *segname,u_char *sigbuf_,size_t sigbuf_len_,int sigmode)
604 {
605 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
606 if(!sha256){
607 (*af->error_reporter)(aff_cannot_sign);
608 return AF_ERROR_NO_SHA256; //
609 }
610
611 /* Now get the data to verify */
612 size_t seglen = 0;
613 unsigned char *segbuf = 0;
614 unsigned long arg=0;
615
616 /* Do we need to get the page */
617 if(sigmode==AF_SIGNATURE_MODE1){
618 int64_t pagenumber = af_segname_page_number(segname);
619 if(pagenumber>=0){
620 seglen = af_page_size(af);
621 segbuf = (unsigned char *)malloc(seglen);
622 if(segbuf==0) return AF_ERROR_SIG_MALLOC;
623 if(af_get_page(af,pagenumber,segbuf,&seglen)){
624 free(segbuf);
625 return -1;
626 }
627 }
628 }
629 if(segbuf==0){ // get the raw segment
630 if(af_get_seg(af,segname,0,0,&seglen)){
631 return AF_ERROR_SIG_DATAREAD_ERROR; // can't read the segment length
632 }
633
634 /* Now read the segment */
635 segbuf=(unsigned char *)malloc(seglen);
636 if(segbuf==0) return AF_ERROR_SIG_MALLOC;
637
638 if(af_get_seg(af,segname,&arg,segbuf,&seglen)){
639 free(segbuf);
640 return AF_ERROR_SIG_DATAREAD_ERROR; // can't read the segment length
641 }
642 }
643
644 /* Verify the signature*/
645 u_char sigbuf[1024];
646 u_int sigbuf_len = sizeof(sigbuf);
647 u_long arg_net = htonl(arg);
648 EVP_MD_CTX md; /* EVP message digest */
649 EVP_DigestInit(&md,sha256);
650 EVP_DigestUpdate(&md,(const unsigned char *)segname,strlen(segname)+1);
651 EVP_DigestUpdate(&md,(const unsigned char *)&arg_net,sizeof(arg_net));
652 EVP_DigestUpdate(&md,segbuf,seglen);
653 EVP_DigestFinal(&md,sigbuf,&sigbuf_len);
654 int r = memcmp(sigbuf,sigbuf_,sigbuf_len);
655 if(sigbuf_len != sigbuf_len_) r = -1; // doesn't match
656 free(segbuf);
657
658 if(r==0) return 0; // verifies
659 return AF_ERROR_SIG_BAD; // doesn't verify
660 }
661
662 /* Verify a segment against a particular signature and public key */
663 int af_sig_verify_seg2(AFFILE *af,const char *segname,EVP_PKEY *pubkey,u_char *sigbuf,size_t sigbuf_len,int sigmode)
664 {
665 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
666 if(!sha256){
667 (*af->error_reporter)(aff_cannot_sign);
668 return AF_ERROR_NO_SHA256; //
669 }
670
671
672 /* Now get the data to verify */
673 size_t seglen = 0;
674 unsigned char *segbuf = 0;
675 unsigned long arg=0;
676
677 /* Do we need to get the page */
678 if(sigmode==AF_SIGNATURE_MODE1){
679 int64_t pagenumber = af_segname_page_number(segname);
680 if(pagenumber>=0){
681 seglen = af_page_size(af);
682 segbuf = (unsigned char *)malloc(seglen);
683 if(segbuf==0) return AF_ERROR_SIG_MALLOC;
684 if(af_get_page(af,pagenumber,segbuf,&seglen)){
685 free(segbuf);
686 return -1;
687 }
688 }
689 }
690 if(segbuf==0){ // get the raw segment
691 if(af_get_seg(af,segname,0,0,&seglen)){
692 return AF_ERROR_SIG_DATAREAD_ERROR; // can't read the segment length
693 }
694
695 /* Now read the segment */
696 segbuf=(unsigned char *)malloc(seglen);
697 if(segbuf==0) return AF_ERROR_SIG_MALLOC;
698
699 if(af_get_seg(af,segname,&arg,segbuf,&seglen)){
700 free(segbuf);
701 return AF_ERROR_SIG_DATAREAD_ERROR; // can't read the segment length
702 }
703 }
704
705 /* Verify the signature*/
706 unsigned long arg_net = htonl(arg);
707 EVP_MD_CTX md; /* EVP message digest */
708 EVP_VerifyInit(&md,sha256);
709 EVP_VerifyUpdate(&md,(const unsigned char *)segname,strlen(segname)+1);
710 EVP_VerifyUpdate(&md,(const unsigned char *)&arg_net,sizeof(arg_net));
711 EVP_VerifyUpdate(&md,segbuf,seglen);
712 int r = EVP_VerifyFinal(&md,sigbuf,sigbuf_len,af->crypto->sign_pubkey);
713 free(segbuf);
714
715 if(r==1) return 0; // verifies
716 return AF_ERROR_SIG_BAD; // doesn't verify
717 }
718
719
720
721 int af_sig_verify_seg(AFFILE *af,const char *segname)
722 {
723 #ifdef USE_AFFSIGS
724 if(aff::ends_with(segname,AF_SIG256_SUFFIX)){
725 return AF_ERROR_SIG_SIG_SEG; // don't verify the signature segments
726 }
727
728 /* Need the public key if I don't have it */
729 if(af->crypto->sign_pubkey==0){
730 unsigned char certbuf[65536];
731 size_t certbuf_len = sizeof(certbuf);
732 if(af_get_seg(af,AF_SIGN256_CERT,0,certbuf,&certbuf_len)!=0){
733 return AF_ERROR_SIG_NO_CERT;
734 }
735 af->crypto->sign_cert = 0;
736 BIO *cert_bio = BIO_new_mem_buf(certbuf,certbuf_len);
737 PEM_read_bio_X509(cert_bio,&af->crypto->sign_cert,0,0);
738 BIO_free(cert_bio);
739 af->crypto->sign_pubkey = X509_get_pubkey(af->crypto->sign_cert);
740 }
741
742 /* Figure out the signature segment name */
743 char sigseg[AF_MAX_NAME_LEN + 1 + sizeof(AF_SIG256_SUFFIX)];
744 strlcpy(sigseg,segname,sizeof(sigseg));
745 strlcat(sigseg,AF_SIG256_SUFFIX,sizeof(sigseg));
746
747 /* Get the signature (it says how we need to handle the data) */
748 unsigned char sigbuf[2048]; // big enough to hold any conceivable signature
749 size_t sigbuf_len=sizeof(sigbuf);
750 unsigned long sigmode=0;
751 if(af_get_seg(af,sigseg,&sigmode,sigbuf,&sigbuf_len)){
752 return AF_ERROR_SIG_READ_ERROR;
753 }
754
755 return af_sig_verify_seg2(af,segname,af->crypto->sign_pubkey,sigbuf,sigbuf_len,sigmode);
756 #else
757 return AF_ERROR_SIG_NOT_COMPILED; // sig support not compiled in
758 #endif
759 }
760
761 /****************************************************************
762 *** PUBLIC KEY ENCRYPION ROUTINES
763 ****************************************************************/
764
765 /**
766 * af_set_seal_certfiles
767 *
768 * Specifies the certific file(s) to use for creating a new affkey.
769 * If an affkey is already on the disk, this returns with an error.
770 *
771 * @param af - The open AFFILE
772 * @param certfile - The filename of the certificate file to read
773 */
774
775 int af_set_seal_certificates(AFFILE *af,const char *certfiles[],int numcertfiles)
776 {
777 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
778 if(!sha256){
779 (*af->error_reporter)(aff_cannot_sign);
780 return AF_ERROR_NO_SHA256; //
781 }
782
783 char evp0[AF_MAX_NAME_LEN];
784 snprintf(evp0,sizeof(evp0),AF_AFFKEY_EVP,0);
785
786 /* If an affkey has not been created, create one if there is a public key(s)...
787 * todo: this should probably see if there is ANY evp segment.
788 */
789 if(af_get_seg(af,evp0,0,0,0)==0) return -1;
790 if(af_get_seg(af,AF_AFFKEY,0,0,0)==0) return -1;
791 if(certfiles==0 || numcertfiles==0) return -1;
792
793 /* First make the affkey */
794 unsigned char affkey[32];
795 int r = RAND_bytes(affkey,sizeof(affkey));
796 if(r!=1) r = RAND_pseudo_bytes(affkey,sizeof(affkey)); // true random not supported
797 if(r!=1) return AF_ERROR_RNG_FAIL; // pretty bad...
798
799 af_seal_affkey_using_certificates(af, certfiles, numcertfiles, affkey);
800 return 0;
801 }
802
803 /**
804 * af_seal_affkey_using_certificates
805 *
806 * Encrypt the provided affkey.
807 *
808 *
809 */
810
811 int af_seal_affkey_using_certificates(AFFILE *af,const char *certfiles[],int numcertfiles, unsigned char affkey[32])
812 {
813 /* Repeat for each public key.. */
814 int r;
815 for(int i=0;i<numcertfiles;i++){
816
817 EVP_PKEY *seal_pubkey=0; // encrypting public key (for encrypting the affkey)
818 X509 *seal_cert=0; // encrypting certificate that was used...
819
820 BIO *bp = BIO_new_file(certfiles[i],"r");
821 if(!bp) return -1;
822 PEM_read_bio_X509(bp,&seal_cert,0,0);
823 BIO_free(bp);
824 if(seal_cert==0){
825 return -2;
826 }
827 seal_pubkey = X509_get_pubkey(seal_cert);
828
829 /* Create the next encrypted key. First make a copy of it... */
830 unsigned char affkey_copy[32];
831 memcpy(affkey_copy,affkey,32);
832
833 EVP_CIPHER_CTX cipher_ctx;
834
835 /* IV */
836 unsigned char iv[EVP_MAX_IV_LENGTH];
837 RAND_pseudo_bytes(iv, EVP_MAX_IV_LENGTH); /* make a random iv */
838
839 /* EK */
840 unsigned char *ek=0;
841 unsigned char *ek_array[1];
842
843 int ek_size = EVP_PKEY_size(seal_pubkey);
844 ek = (unsigned char *)malloc(ek_size);
845 ek_array[0] = ek;
846
847 /* Destination for encrypted AFF key */
848 unsigned char encrypted_affkey[1024];
849 int encrypted_bytes = 0;
850 memset(encrypted_affkey,0,sizeof(encrypted_affkey));
851
852 r = EVP_SealInit(&cipher_ctx,EVP_aes_256_cbc(),ek_array,&ek_size,&iv[0],&seal_pubkey,1);
853 if(r!=1) return -10; // bad
854
855 r = EVP_SealUpdate(&cipher_ctx,encrypted_affkey,&encrypted_bytes,affkey_copy,sizeof(affkey_copy));
856 if(r!=1) return -11; // bad
857
858 int total_encrypted_bytes = encrypted_bytes;
859 r = EVP_SealFinal(&cipher_ctx,encrypted_affkey+total_encrypted_bytes,&encrypted_bytes);
860 if(r!=1) return -12;
861
862 total_encrypted_bytes += encrypted_bytes;
863
864 /* Now we need to combine the IV, encrypted key, and the encrypted aff key onto a single structure
865 * and write it out
866 */
867 const int int1 = sizeof(int)*1;
868 const int int2 = sizeof(int)*2;
869 const int int3 = sizeof(int)*3;
870 const int buflen = int3+EVP_MAX_IV_LENGTH+ek_size+total_encrypted_bytes;
871 unsigned char *buf = (unsigned char *)malloc(buflen);
872 *(u_int *)(buf) = htonl(1); // version 1.0
873 *(u_int *)(buf+int1) = htonl(ek_size);
874 *(u_int *)(buf+int2) = htonl(total_encrypted_bytes);
875 memcpy(buf+int3,iv,EVP_MAX_IV_LENGTH);
876 memcpy(buf+int3+EVP_MAX_IV_LENGTH,ek,ek_size);
877 memcpy(buf+int3+EVP_MAX_IV_LENGTH+ek_size,encrypted_affkey,total_encrypted_bytes);
878
879 /* Write this into the seg */
880 char segname[AF_MAX_NAME_LEN];
881 snprintf(segname,sizeof(segname),AF_AFFKEY_EVP,i);
882 if(af_update_segf(af,segname,0,buf,buflen,AF_SIGFLAG_NOSEAL)){
883 return -1; // update seg failed?
884 }
885 EVP_PKEY_free(seal_pubkey);
886 seal_pubkey = 0;
887 memset(affkey_copy,0,sizeof(affkey_copy)); // overwrite
888 memset(buf,0,buflen); // overwrite
889 free(buf);
890 }
891 /* Start using this key */
892 if(af_set_aes_key(af,affkey,256)) return -100; // hm. That's weird.
893 return 0; // good to go
894 }
895
896
897
898 /**
899 * Given a private key in a file:
900 * 1 - Scan all of the encrypted AFFKEYs to see if any can be decrypted.
901 * 2 - When the one is found that can be decrypted, put the AFFKEY in a buffer
902 * 3 - Return that buffer.
903 *
904 * @param af The open AFFILE
905 * @param private_keyfile - The filename of the key file to read
906 * @param affkey - The decrypted AFFkey (output)
907 *
908 * Load the private and/or public key files.
909 * Try to decrypt the affkey with the private key.p
910 *
911 */
912
913 int af_get_affkey_using_keyfile(AFFILE *af, const char *private_keyfile,u_char affkey[32])
914 {
915 if(!private_keyfile) return -1;
916 BIO *bp = BIO_new_file(private_keyfile,"r");
917 if(!bp) return -2;
918 EVP_PKEY *seal_privkey = PEM_read_bio_PrivateKey(bp,0,0,0);
919 BIO_free(bp);
920 if(!seal_privkey) return -3;
921
922 int i = 0;
923 int ret = -1; // return code; set to 0 when successful
924 while(i<1000 && ret!=0){ // hopefully there aren't more than 1000 keys...
925 char segname[AF_MAX_NAME_LEN];
926
927 sprintf(segname,AF_AFFKEY_EVP,i++);
928 size_t buflen=0;
929 if(af_get_seg(af,segname,0,0,&buflen)){
930 return -1; // guess none of the keys work
931 }
932 unsigned char *buf = (unsigned char *)malloc(buflen);
933 if(buf==0) return -1; // malloc failed
934 if(af_get_seg(af,segname,0,buf,&buflen)){
935 free(buf);
936 return -1; // could not get the segment
937 }
938
939 /* Try to get and decrypt the segment */
940 unsigned char *decrypted = 0; //
941 if (*(u_int *)buf == htonl(1)){ // check to see if the encrypted EVP is rev 1
942 /* Handle rev 1 */
943 const u_int int1 = sizeof(int)*1; // offset #1
944 const u_int int2 = sizeof(int)*2; // offset #2
945 const u_int int3 = sizeof(int)*3; // offset #3
946 int ek_size = ntohl(*(u_int *)(buf+int1));
947 int total_encrypted_bytes = ntohl(*(u_int *)(buf+int2));
948 if(int3+EVP_MAX_IV_LENGTH+ek_size+total_encrypted_bytes != buflen){
949 goto next;
950 }
951 unsigned char *iv = buf+int3;
952 unsigned char *ek = buf+int3+EVP_MAX_IV_LENGTH;
953 unsigned char *encrypted_affkey = buf+int3+EVP_MAX_IV_LENGTH+ek_size;
954
955 /* Now let's see if we can decode it*/
956 EVP_CIPHER_CTX cipher_ctx;
957 int r = EVP_OpenInit(&cipher_ctx,EVP_aes_256_cbc(),ek,ek_size,iv,seal_privkey);
958 if(r==1){
959 /* allocate a buffer for the decrypted data */
960 decrypted = (unsigned char *)malloc(total_encrypted_bytes);
961 if(!decrypted) return -1; // shouldn't fail
962
963 int decrypted_len;
964 r = EVP_OpenUpdate(&cipher_ctx,decrypted,&decrypted_len,encrypted_affkey,total_encrypted_bytes);
965 if(r==1){
966 /* OpenSSL requires that we call EVP_OpenFinal to finish the decryption */
967 unsigned char *decrypted2 = decrypted+decrypted_len; // where the decryption continues
968 int decrypted2_len = 0;
969 r = EVP_OpenFinal(&cipher_ctx,decrypted2,&decrypted2_len);
970 if(r==1){
971 memcpy(affkey,decrypted,32);
972 ret = 0; // successful return
973 }
974 }
975 memset(decrypted,0,total_encrypted_bytes); // overwrite our temp buffer
976 free(decrypted);
977 }
978 }
979 next:;
980 free(buf);
981 }
982 return ret; // return the code
983 }
984
985
986 /**
987 *
988 * Given a private key in a file:
989 * 1 - Scan all of the encrypted AFFKEYs to see if any can be decrypted.
990 * 2 - When the one is found that can be decrypted, put the AFFKEY in a buffer
991 * 3 - Set that buffer to be the active AFFKEY so that the AFF file can be read and written.
992 *
993 * @param af - The open AFFILE
994 * @param private_keyfile - The filename of the key file to read
995 * @param certfile - The filename of the certificate file to read
996 */
997
998 int af_set_unseal_keyfile(AFFILE *af,const char *private_keyfile)
999 {
1000 u_char affkey[32]; // place to put the decrypted affkey
1001 if(af_get_affkey_using_keyfile(af,private_keyfile,affkey)){
1002 return -1; // couldn't get the affkey
1003 }
1004 /* It decrypted. Looks like we got an AFF key */
1005 return af_set_aes_key(af,affkey,256);
1006 }
0 /*
1 * A list of the segments that should be displayed as a quadword.
2 */
3
4 #include "affconfig.h"
5 #include "afflib.h"
6 #include "afflib_i.h"
7
8 static const char *quads[] = {
9 AF_IMAGESIZE,
10 AF_BADSECTORS,
11 AF_BLANKSECTORS,
12 AF_DEVICE_SECTORS,
13 0
14 };
15
16
17 int af_display_as_quad(const char *segname)
18 {
19 for(int i=0;quads[i];i++){
20 if(strcmp(segname,quads[i])==0) return true;
21 }
22 return false;
23 }
24
25 int af_display_as_hex(const char *segname)
26 {
27 if(strcmp(segname,AF_MD5)==0) return 1;
28 if(strcmp(segname,AF_SHA1)==0) return 1;
29 if(strcmp(segname,AF_SHA256)==0) return 1;
30 if(strcmp(segname,AF_IMAGE_GID)==0) return 1;
31 return 0;
32 }
33
0 #include "affconfig.h"
1 #include "afflib.h"
2 #include "afflib_i.h"
3
4 #include "../../../Common/MyWindows.h"
5 #include "../../../Common/MyInitGuid.h"
6 #include "../../Common/FileStreams.h"
7 #include "../../Common/StreamUtils.h"
8 #include "../LZMA/LZMADecoder.h"
9 #include "../LZMA/LZMAEncoder.h"
10 #include "LzmaBench.h"
11
12 #include "LzmaRam.h"
13 extern "C" {
14 #include "LzmaRamDecode.h"
15 }
16
17
18 class CInMemoryStream: public ISequentialInStream, public CMyUnknownImp {
19 public:
20 const unsigned char *buf;
21 size_t buflen;
22 size_t ptr;
23 virtual ~CInMemoryStream(){}
24 CInMemoryStream(const unsigned char *buf_,size_t len){
25 buf = buf_;
26 buflen = len;
27 ptr = 0;
28 }
29
30 MY_UNKNOWN_IMP1(IInStream)
31 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize){
32 if(ptr+size > buflen) size = buflen - ptr; // max that can be read
33 memcpy(data,buf+ptr,size);
34 ptr += size;
35 if(processedSize) *processedSize = size;
36 return S_OK;
37 }
38 };
39
40
41 class COutMemoryStream: public ISequentialOutStream, public CMyUnknownImp {
42 public:
43 unsigned char *buf;
44 size_t buflen;
45 size_t ptr;
46 size_t *notify;
47 virtual ~COutMemoryStream(){}
48 COutMemoryStream(unsigned char *buf_,size_t len,size_t *notify_){
49 buf = buf_;
50 buflen = len;
51 ptr = 0;
52 notify = notify_;
53 }
54
55 MY_UNKNOWN_IMP1(IOutStream) STDMETHOD(Write)(const void *data, UInt32 size,
56 UInt32 *processedSize){
57 if(ptr+size > buflen) return E_FAIL;
58 memcpy(buf+ptr,data,size);
59 ptr += size;
60 if(processedSize) *processedSize = size;
61 if(notify) *notify = ptr;
62 return S_OK;
63 }
64 };
65
66 /*
67 * Attempt to compress. Return -1 if fail.
68 * (Fails if compression results in expansion.
69 */
70
71 int lzma_compress(unsigned char *dest,size_t *destLen,const unsigned char *data,size_t datalen,int level)
72 {
73 PROPID propIDs[] = {
74 NCoderPropID::kDictionarySize,
75 NCoderPropID::kPosStateBits,
76 NCoderPropID::kLitContextBits,
77 NCoderPropID::kLitPosBits,
78 NCoderPropID::kAlgorithm,
79 NCoderPropID::kNumFastBytes,
80 NCoderPropID::kMatchFinder,
81 NCoderPropID::kEndMarker
82 };
83 const int nprops = sizeof(propIDs) / sizeof(propIDs[0]);
84 PROPVARIANT p[nprops];
85
86 p[0].vt = VT_UI4; p[0].ulVal = UInt32(1 << 24);
87 p[1].vt = VT_UI4; p[1].ulVal = UInt32(2); // posBits
88 p[2].vt = VT_UI4; p[2].ulVal = UInt32(3); // literal context bits
89 p[3].vt = VT_UI4; p[3].ulVal = UInt32(0); // literal pos bits
90 p[4].vt = VT_UI4; p[4].ulVal = UInt32(2); // compression mode
91 p[5].vt = VT_UI4; p[5].ulVal = UInt32(128); // fast_bytes
92
93 // old code generates warnings now
94 //p[6].vt = VT_BSTR; p[6].bstrVal = L"bt4"; // it's okay; we won't change it
95
96 // new code
97 const void *temp = L"bt4";
98 p[6].vt = VT_BSTR; p[6].bstrVal = (OLECHAR *)temp; // it's okay; we won't change it
99
100 p[7].vt = VT_BOOL; p[7].boolVal = VARIANT_FALSE;
101
102 NCompress::NLZMA::CEncoder *encoder = new NCompress::NLZMA::CEncoder;
103
104 if (encoder->SetCoderProperties(propIDs, p, nprops) != S_OK){
105 return -1; /* Couldn't set encoder properties */
106 }
107
108 /* Open and configure the output stream */
109 UInt64 fileSize = datalen;
110 COutMemoryStream *outStream = new COutMemoryStream(dest,*destLen,destLen);
111 outStream->AddRef();
112
113 encoder->WriteCoderProperties(outStream);
114
115 for (int i = 0; i < 8; i++) {
116 Byte b = Byte(fileSize >> (8 * i));
117 if (outStream->Write(&b, sizeof(b), 0) != S_OK){
118 outStream->Release();
119 return -1; /* Write error while encoding */
120 }
121 }
122
123 CInMemoryStream *inStream = new CInMemoryStream(data,datalen);
124 inStream->AddRef();
125 HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
126 inStream->Release();
127 outStream->Release();
128 delete(encoder);
129
130 return result;
131 }
132
133
134 int lzma_uncompress(unsigned char *buf,size_t *buflen, const unsigned char *cbuf,size_t cbuf_size)
135 {
136 CInMemoryStream *inStream = new CInMemoryStream(cbuf,cbuf_size);
137 inStream->AddRef();
138
139 const UInt32 kPropertiesSize = 5;
140 Byte properties[kPropertiesSize];
141 UInt32 processedSize;
142 UInt64 fileSize = 0;
143 NCompress::NLZMA::CDecoder decoderSpec;
144
145 if (inStream->Read(properties, kPropertiesSize, &processedSize) != S_OK){
146 inStream->Release();
147 return -1;
148 }
149 if (processedSize != kPropertiesSize) return -1;
150 if (decoderSpec.SetDecoderProperties2(properties, kPropertiesSize) != S_OK){
151 inStream->Release();
152 return -1;
153 }
154
155 for (int i = 0; i < 8; i++) {
156 Byte b;
157 if (inStream->Read(&b, sizeof(b), &processedSize) != S_OK) return -1;
158 if (processedSize != 1){
159 inStream->Release();
160 return -1;
161 }
162 fileSize |= ((UInt64)b) << (8 * i);
163 }
164
165 COutMemoryStream *outStream = new COutMemoryStream(buf,*buflen,buflen);
166 outStream->AddRef();
167 int r = decoderSpec.Code(inStream, outStream, 0, &fileSize, 0);
168 inStream->Release();
169 outStream->Release();
170 return r;
171 }
172
0 #include <openssl/aes.h>
0 /* Simson Garfinkel's fake header to make block-vmdk.c compile */
1 #include "affconfig.h"
2 #include "afflib.h"
3 #include "afflib_i.h"
4
0 /*
1 * Block driver for the various disk image formats used by Bochs
2 * Currently only for "growing" type in read-only mode
3 *
4 * Copyright (c) 2005 Alex Beregszaszi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 #include "qemu-common.h"
25 #include "block_int.h"
26
27 /**************************************************************/
28
29 #define HEADER_MAGIC "Bochs Virtual HD Image"
30 #define HEADER_VERSION 0x00020000
31 #define HEADER_V1 0x00010000
32 #define HEADER_SIZE 512
33
34 #define REDOLOG_TYPE "Redolog"
35 #define GROWING_TYPE "Growing"
36
37 // not allocated: 0xffffffff
38
39 // always little-endian
40 struct bochs_header_v1 {
41 char magic[32]; // "Bochs Virtual HD Image"
42 char type[16]; // "Redolog"
43 char subtype[16]; // "Undoable" / "Volatile" / "Growing"
44 uint32_t version;
45 uint32_t header; // size of header
46
47 union {
48 struct {
49 uint32_t catalog; // num of entries
50 uint32_t bitmap; // bitmap size
51 uint32_t extent; // extent size
52 uint64_t disk; // disk size
53 char padding[HEADER_SIZE - 64 - 8 - 20];
54 } redolog;
55 char padding[HEADER_SIZE - 64 - 8];
56 } extra;
57 };
58
59 // always little-endian
60 struct bochs_header {
61 char magic[32]; // "Bochs Virtual HD Image"
62 char type[16]; // "Redolog"
63 char subtype[16]; // "Undoable" / "Volatile" / "Growing"
64 uint32_t version;
65 uint32_t header; // size of header
66
67 union {
68 struct {
69 uint32_t catalog; // num of entries
70 uint32_t bitmap; // bitmap size
71 uint32_t extent; // extent size
72 uint32_t reserved; // for ???
73 uint64_t disk; // disk size
74 char padding[HEADER_SIZE - 64 - 8 - 24];
75 } redolog;
76 char padding[HEADER_SIZE - 64 - 8];
77 } extra;
78 };
79
80 typedef struct BDRVBochsState {
81 int fd;
82
83 uint32_t *catalog_bitmap;
84 int catalog_size;
85
86 int data_offset;
87
88 int bitmap_blocks;
89 int extent_blocks;
90 int extent_size;
91 } BDRVBochsState;
92
93 static int bochs_probe(const uint8_t *buf, int buf_size, const char *filename)
94 {
95 const struct bochs_header *bochs = (const void *)buf;
96
97 if (buf_size < HEADER_SIZE)
98 return 0;
99
100 if (!strcmp(bochs->magic, HEADER_MAGIC) &&
101 !strcmp(bochs->type, REDOLOG_TYPE) &&
102 !strcmp(bochs->subtype, GROWING_TYPE) &&
103 ((le32_to_cpu(bochs->version) == HEADER_VERSION) ||
104 (le32_to_cpu(bochs->version) == HEADER_V1)))
105 return 100;
106
107 return 0;
108 }
109
110 static int bochs_open(BlockDriverState *bs, const char *filename, int flags)
111 {
112 BDRVBochsState *s = bs->opaque;
113 int fd, i;
114 struct bochs_header bochs;
115 struct bochs_header_v1 header_v1;
116
117 fd = open(filename, O_RDWR | O_BINARY);
118 if (fd < 0) {
119 fd = open(filename, O_RDONLY | O_BINARY);
120 if (fd < 0)
121 return -1;
122 }
123
124 bs->read_only = 1; // no write support yet
125
126 s->fd = fd;
127
128 if (read(fd, &bochs, sizeof(bochs)) != sizeof(bochs)) {
129 goto fail;
130 }
131
132 if (strcmp(bochs.magic, HEADER_MAGIC) ||
133 strcmp(bochs.type, REDOLOG_TYPE) ||
134 strcmp(bochs.subtype, GROWING_TYPE) ||
135 ((le32_to_cpu(bochs.version) != HEADER_VERSION) &&
136 (le32_to_cpu(bochs.version) != HEADER_V1))) {
137 goto fail;
138 }
139
140 if (le32_to_cpu(bochs.version) == HEADER_V1) {
141 memcpy(&header_v1, &bochs, sizeof(bochs));
142 bs->total_sectors = le64_to_cpu(header_v1.extra.redolog.disk) / 512;
143 } else {
144 bs->total_sectors = le64_to_cpu(bochs.extra.redolog.disk) / 512;
145 }
146
147 lseek(s->fd, le32_to_cpu(bochs.header), SEEK_SET);
148
149 s->catalog_size = le32_to_cpu(bochs.extra.redolog.catalog);
150 s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
151 if (!s->catalog_bitmap)
152 goto fail;
153 if (read(s->fd, s->catalog_bitmap, s->catalog_size * 4) !=
154 s->catalog_size * 4)
155 goto fail;
156 for (i = 0; i < s->catalog_size; i++)
157 le32_to_cpus(&s->catalog_bitmap[i]);
158
159 s->data_offset = le32_to_cpu(bochs.header) + (s->catalog_size * 4);
160
161 s->bitmap_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.bitmap) - 1) / 512;
162 s->extent_blocks = 1 + (le32_to_cpu(bochs.extra.redolog.extent) - 1) / 512;
163
164 s->extent_size = le32_to_cpu(bochs.extra.redolog.extent);
165
166 return 0;
167 fail:
168 close(fd);
169 return -1;
170 }
171
172 static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
173 {
174 BDRVBochsState *s = bs->opaque;
175 int64_t offset = sector_num * 512;
176 int64_t extent_index, extent_offset, bitmap_offset, block_offset;
177 char bitmap_entry;
178
179 // seek to sector
180 extent_index = offset / s->extent_size;
181 extent_offset = (offset % s->extent_size) / 512;
182
183 if (s->catalog_bitmap[extent_index] == 0xffffffff)
184 {
185 // fprintf(stderr, "page not allocated [%x - %x:%x]\n",
186 // sector_num, extent_index, extent_offset);
187 return -1; // not allocated
188 }
189
190 bitmap_offset = s->data_offset + (512 * s->catalog_bitmap[extent_index] *
191 (s->extent_blocks + s->bitmap_blocks));
192 block_offset = bitmap_offset + (512 * (s->bitmap_blocks + extent_offset));
193
194 // fprintf(stderr, "sect: %x [ext i: %x o: %x] -> %x bitmap: %x block: %x\n",
195 // sector_num, extent_index, extent_offset,
196 // le32_to_cpu(s->catalog_bitmap[extent_index]),
197 // bitmap_offset, block_offset);
198
199 // read in bitmap for current extent
200 lseek(s->fd, bitmap_offset + (extent_offset / 8), SEEK_SET);
201
202 if(read(s->fd, &bitmap_entry, 1)!=1) return -1;
203
204 if (!((bitmap_entry >> (extent_offset % 8)) & 1))
205 {
206 // fprintf(stderr, "sector (%x) in bitmap not allocated\n",
207 // sector_num);
208 return -1; // not allocated
209 }
210
211 lseek(s->fd, block_offset, SEEK_SET);
212
213 return 0;
214 }
215
216 static int bochs_read(BlockDriverState *bs, int64_t sector_num,
217 uint8_t *buf, int nb_sectors)
218 {
219 BDRVBochsState *s = bs->opaque;
220 int ret;
221
222 while (nb_sectors > 0) {
223 if (!seek_to_sector(bs, sector_num))
224 {
225 ret = read(s->fd, buf, 512);
226 if (ret != 512)
227 return -1;
228 }
229 else
230 memset(buf, 0, 512);
231 nb_sectors--;
232 sector_num++;
233 buf += 512;
234 }
235 return 0;
236 }
237
238 static void bochs_close(BlockDriverState *bs)
239 {
240 BDRVBochsState *s = bs->opaque;
241 qemu_free(s->catalog_bitmap);
242 close(s->fd);
243 }
244
245 BlockDriver bdrv_bochs = {
246 "bochs",
247 sizeof(BDRVBochsState),
248 bochs_probe,
249 bochs_open,
250 bochs_read,
251 NULL,
252 bochs_close,
253 };
0 /*
1 * QEMU Block driver for CLOOP images
2 *
3 * Copyright (c) 2004 Johannes E. Schindelin
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #include "qemu-common.h"
24 #include "block_int.h"
25 #include <zlib.h>
26
27 typedef struct BDRVCloopState {
28 int fd;
29 uint32_t block_size;
30 uint32_t n_blocks;
31 uint64_t* offsets;
32 uint32_t sectors_per_block;
33 uint32_t current_block;
34 uint8_t *compressed_block;
35 uint8_t *uncompressed_block;
36 z_stream zstream;
37 } BDRVCloopState;
38
39 static int cloop_probe(const uint8_t *buf, int buf_size, const char *filename)
40 {
41 const char* magic_version_2_0="#!/bin/sh\n"
42 "#V2.0 Format\n"
43 "modprobe cloop file=$0 && mount -r -t iso9660 /dev/cloop $1\n";
44 int length=strlen(magic_version_2_0);
45 if(length>buf_size)
46 length=buf_size;
47 if(!memcmp(magic_version_2_0,buf,length))
48 return 2;
49 return 0;
50 }
51
52 static int cloop_open(BlockDriverState *bs, const char *filename, int flags)
53 {
54 BDRVCloopState *s = bs->opaque;
55 uint32_t offsets_size,max_compressed_block_size=1,i;
56
57 s->fd = open(filename, O_RDONLY | O_BINARY);
58 if (s->fd < 0)
59 return -errno;
60 bs->read_only = 1;
61
62 /* read header */
63 if(lseek(s->fd,128,SEEK_SET)<0) {
64 cloop_close:
65 close(s->fd);
66 return -1;
67 }
68 if(read(s->fd,&s->block_size,4)<4)
69 goto cloop_close;
70 s->block_size=be32_to_cpu(s->block_size);
71 if(read(s->fd,&s->n_blocks,4)<4)
72 goto cloop_close;
73 s->n_blocks=be32_to_cpu(s->n_blocks);
74
75 /* read offsets */
76 offsets_size=s->n_blocks*sizeof(uint64_t);
77 if(!(s->offsets=(uint64_t*)malloc(offsets_size)))
78 goto cloop_close;
79 if(read(s->fd,s->offsets,offsets_size)<offsets_size)
80 goto cloop_close;
81 for(i=0;i<s->n_blocks;i++) {
82 s->offsets[i]=be64_to_cpu(s->offsets[i]);
83 if(i>0) {
84 uint32_t size=s->offsets[i]-s->offsets[i-1];
85 if(size>max_compressed_block_size)
86 max_compressed_block_size=size;
87 }
88 }
89
90 /* initialize zlib engine */
91 if(!(s->compressed_block = malloc(max_compressed_block_size+1)))
92 goto cloop_close;
93 if(!(s->uncompressed_block = malloc(s->block_size)))
94 goto cloop_close;
95 if(inflateInit(&s->zstream) != Z_OK)
96 goto cloop_close;
97 s->current_block=s->n_blocks;
98
99 s->sectors_per_block = s->block_size/512;
100 bs->total_sectors = s->n_blocks*s->sectors_per_block;
101 return 0;
102 }
103
104 static inline int cloop_read_block(BDRVCloopState *s,int block_num)
105 {
106 if(s->current_block != block_num) {
107 int ret;
108 uint32_t bytes = s->offsets[block_num+1]-s->offsets[block_num];
109
110 lseek(s->fd, s->offsets[block_num], SEEK_SET);
111 ret = read(s->fd, s->compressed_block, bytes);
112 if (ret != bytes)
113 return -1;
114
115 s->zstream.next_in = s->compressed_block;
116 s->zstream.avail_in = bytes;
117 s->zstream.next_out = s->uncompressed_block;
118 s->zstream.avail_out = s->block_size;
119 ret = inflateReset(&s->zstream);
120 if(ret != Z_OK)
121 return -1;
122 ret = inflate(&s->zstream, Z_FINISH);
123 if(ret != Z_STREAM_END || s->zstream.total_out != s->block_size)
124 return -1;
125
126 s->current_block = block_num;
127 }
128 return 0;
129 }
130
131 static int cloop_read(BlockDriverState *bs, int64_t sector_num,
132 uint8_t *buf, int nb_sectors)
133 {
134 BDRVCloopState *s = bs->opaque;
135 int i;
136
137 for(i=0;i<nb_sectors;i++) {
138 uint32_t sector_offset_in_block=((sector_num+i)%s->sectors_per_block),
139 block_num=(sector_num+i)/s->sectors_per_block;
140 if(cloop_read_block(s, block_num) != 0)
141 return -1;
142 memcpy(buf+i*512,s->uncompressed_block+sector_offset_in_block*512,512);
143 }
144 return 0;
145 }
146
147 static void cloop_close(BlockDriverState *bs)
148 {
149 BDRVCloopState *s = bs->opaque;
150 close(s->fd);
151 if(s->n_blocks>0)
152 free(s->offsets);
153 free(s->compressed_block);
154 free(s->uncompressed_block);
155 inflateEnd(&s->zstream);
156 }
157
158 BlockDriver bdrv_cloop = {
159 "cloop",
160 sizeof(BDRVCloopState),
161 cloop_probe,
162 cloop_open,
163 cloop_read,
164 NULL,
165 cloop_close,
166 };
167
168
0 /*
1 * Block driver for the COW format
2 *
3 * Copyright (c) 2004 Fabrice Bellard
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #ifndef _WIN32
24 #include "qemu-common.h"
25 #include "block_int.h"
26 #include <sys/mman.h>
27
28 /**************************************************************/
29 /* COW block driver using file system holes */
30
31 /* user mode linux compatible COW file */
32 #define COW_MAGIC 0x4f4f4f4d /* MOOO */
33 #define COW_VERSION 2
34
35 struct cow_header_v2 {
36 uint32_t magic;
37 uint32_t version;
38 char backing_file[1024];
39 int32_t mtime;
40 uint64_t size;
41 uint32_t sectorsize;
42 };
43
44 typedef struct BDRVCowState {
45 int fd;
46 uint8_t *cow_bitmap; /* if non NULL, COW mappings are used first */
47 uint8_t *cow_bitmap_addr; /* mmap address of cow_bitmap */
48 int cow_bitmap_size;
49 int64_t cow_sectors_offset;
50 } BDRVCowState;
51
52 static int cow_probe(const uint8_t *buf, int buf_size, const char *filename)
53 {
54 const struct cow_header_v2 *cow_header = (const void *)buf;
55
56 if (buf_size >= sizeof(struct cow_header_v2) &&
57 be32_to_cpu(cow_header->magic) == COW_MAGIC &&
58 be32_to_cpu(cow_header->version) == COW_VERSION)
59 return 100;
60 else
61 return 0;
62 }
63
64 static int cow_open(BlockDriverState *bs, const char *filename, int flags)
65 {
66 BDRVCowState *s = bs->opaque;
67 int fd;
68 struct cow_header_v2 cow_header;
69 int64_t size;
70
71 fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
72 if (fd < 0) {
73 fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
74 if (fd < 0)
75 return -1;
76 }
77 s->fd = fd;
78 /* see if it is a cow image */
79 if (read(fd, &cow_header, sizeof(cow_header)) != sizeof(cow_header)) {
80 goto fail;
81 }
82
83 if (be32_to_cpu(cow_header.magic) != COW_MAGIC ||
84 be32_to_cpu(cow_header.version) != COW_VERSION) {
85 goto fail;
86 }
87
88 /* cow image found */
89 size = be64_to_cpu(cow_header.size);
90 bs->total_sectors = size / 512;
91
92 pstrcpy(bs->backing_file, sizeof(bs->backing_file),
93 cow_header.backing_file);
94
95 /* mmap the bitmap */
96 s->cow_bitmap_size = ((bs->total_sectors + 7) >> 3) + sizeof(cow_header);
97 s->cow_bitmap_addr = mmap(get_mmap_addr(s->cow_bitmap_size),
98 s->cow_bitmap_size,
99 PROT_READ | PROT_WRITE,
100 MAP_SHARED, s->fd, 0);
101 if (s->cow_bitmap_addr == MAP_FAILED)
102 goto fail;
103 s->cow_bitmap = s->cow_bitmap_addr + sizeof(cow_header);
104 s->cow_sectors_offset = (s->cow_bitmap_size + 511) & ~511;
105 return 0;
106 fail:
107 close(fd);
108 return -1;
109 }
110
111 static inline void cow_set_bit(uint8_t *bitmap, int64_t bitnum)
112 {
113 bitmap[bitnum / 8] |= (1 << (bitnum%8));
114 }
115
116 static inline int is_bit_set(const uint8_t *bitmap, int64_t bitnum)
117 {
118 return !!(bitmap[bitnum / 8] & (1 << (bitnum%8)));
119 }
120
121
122 /* Return true if first block has been changed (ie. current version is
123 * in COW file). Set the number of continuous blocks for which that
124 * is true. */
125 static inline int is_changed(uint8_t *bitmap,
126 int64_t sector_num, int nb_sectors,
127 int *num_same)
128 {
129 int changed;
130
131 if (!bitmap || nb_sectors == 0) {
132 *num_same = nb_sectors;
133 return 0;
134 }
135
136 changed = is_bit_set(bitmap, sector_num);
137 for (*num_same = 1; *num_same < nb_sectors; (*num_same)++) {
138 if (is_bit_set(bitmap, sector_num + *num_same) != changed)
139 break;
140 }
141
142 return changed;
143 }
144
145 static int cow_is_allocated(BlockDriverState *bs, int64_t sector_num,
146 int nb_sectors, int *pnum)
147 {
148 BDRVCowState *s = bs->opaque;
149 return is_changed(s->cow_bitmap, sector_num, nb_sectors, pnum);
150 }
151
152 static int cow_read(BlockDriverState *bs, int64_t sector_num,
153 uint8_t *buf, int nb_sectors)
154 {
155 BDRVCowState *s = bs->opaque;
156 int ret, n;
157
158 while (nb_sectors > 0) {
159 if (is_changed(s->cow_bitmap, sector_num, nb_sectors, &n)) {
160 lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
161 ret = read(s->fd, buf, n * 512);
162 if (ret != n * 512)
163 return -1;
164 } else {
165 if (bs->backing_hd) {
166 /* read from the base image */
167 ret = bdrv_read(bs->backing_hd, sector_num, buf, n);
168 if (ret < 0)
169 return -1;
170 } else {
171 memset(buf, 0, n * 512);
172 }
173 }
174 nb_sectors -= n;
175 sector_num += n;
176 buf += n * 512;
177 }
178 return 0;
179 }
180
181 static int cow_write(BlockDriverState *bs, int64_t sector_num,
182 const uint8_t *buf, int nb_sectors)
183 {
184 BDRVCowState *s = bs->opaque;
185 int ret, i;
186
187 lseek(s->fd, s->cow_sectors_offset + sector_num * 512, SEEK_SET);
188 ret = write(s->fd, buf, nb_sectors * 512);
189 if (ret != nb_sectors * 512)
190 return -1;
191 for (i = 0; i < nb_sectors; i++)
192 cow_set_bit(s->cow_bitmap, sector_num + i);
193 return 0;
194 }
195
196 static void cow_close(BlockDriverState *bs)
197 {
198 BDRVCowState *s = bs->opaque;
199 munmap(s->cow_bitmap_addr, s->cow_bitmap_size);
200 close(s->fd);
201 }
202
203 static int cow_create(const char *filename, int64_t image_sectors,
204 const char *image_filename, int flags)
205 {
206 int fd, cow_fd;
207 struct cow_header_v2 cow_header;
208 struct stat st;
209
210 if (flags)
211 return -ENOTSUP;
212
213 cow_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
214 0644);
215 if (cow_fd < 0)
216 return -1;
217 memset(&cow_header, 0, sizeof(cow_header));
218 cow_header.magic = cpu_to_be32(COW_MAGIC);
219 cow_header.version = cpu_to_be32(COW_VERSION);
220 if (image_filename) {
221 /* Note: if no file, we put a dummy mtime */
222 cow_header.mtime = cpu_to_be32(0);
223
224 fd = open(image_filename, O_RDONLY | O_BINARY);
225 if (fd < 0) {
226 close(cow_fd);
227 goto mtime_fail;
228 }
229 if (fstat(fd, &st) != 0) {
230 close(fd);
231 goto mtime_fail;
232 }
233 close(fd);
234 cow_header.mtime = cpu_to_be32(st.st_mtime);
235 mtime_fail:
236 pstrcpy(cow_header.backing_file, sizeof(cow_header.backing_file),
237 image_filename);
238 }
239 cow_header.sectorsize = cpu_to_be32(512);
240 cow_header.size = cpu_to_be64(image_sectors * 512);
241 if(write(cow_fd, &cow_header, sizeof(cow_header))!=sizeof(cow_header)) return -1;
242 /* resize to include at least all the bitmap */
243 if(ftruncate(cow_fd, sizeof(cow_header) + ((image_sectors + 7) >> 3))<0) return -1;
244 close(cow_fd);
245 return 0;
246 }
247
248 static void cow_flush(BlockDriverState *bs)
249 {
250 BDRVCowState *s = bs->opaque;
251 fsync(s->fd);
252 }
253
254 BlockDriver bdrv_cow = {
255 "cow",
256 sizeof(BDRVCowState),
257 cow_probe,
258 cow_open,
259 cow_read,
260 cow_write,
261 cow_close,
262 cow_create,
263 cow_flush,
264 cow_is_allocated,
265 };
266 #endif
0 /*
1 * QEMU Block driver for DMG images
2 *
3 * Copyright (c) 2004 Johannes E. Schindelin
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #include "qemu-common.h"
24 #include "block_int.h"
25 #include "bswap.h"
26 #include <zlib.h>
27
28 typedef struct BDRVDMGState {
29 int fd;
30
31 /* each chunk contains a certain number of sectors,
32 * offsets[i] is the offset in the .dmg file,
33 * lengths[i] is the length of the compressed chunk,
34 * sectors[i] is the sector beginning at offsets[i],
35 * sectorcounts[i] is the number of sectors in that chunk,
36 * the sectors array is ordered
37 * 0<=i<n_chunks */
38
39 uint32_t n_chunks;
40 uint32_t* types;
41 uint64_t* offsets;
42 uint64_t* lengths;
43 uint64_t* sectors;
44 uint64_t* sectorcounts;
45 uint32_t current_chunk;
46 uint8_t *compressed_chunk;
47 uint8_t *uncompressed_chunk;
48 z_stream zstream;
49 } BDRVDMGState;
50
51 static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
52 {
53 int len=strlen(filename);
54 if(len>4 && !strcmp(filename+len-4,".dmg"))
55 return 2;
56 return 0;
57 }
58
59 static off_t read_off(int fd)
60 {
61 uint64_t buffer;
62 if(read(fd,&buffer,8)<8)
63 return 0;
64 return be64_to_cpu(buffer);
65 }
66
67 static off_t read_uint32(int fd)
68 {
69 uint32_t buffer;
70 if(read(fd,&buffer,4)<4)
71 return 0;
72 return be32_to_cpu(buffer);
73 }
74
75 static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
76 {
77 BDRVDMGState *s = bs->opaque;
78 off_t info_begin,info_end,last_in_offset,last_out_offset;
79 uint32_t count;
80 uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i;
81
82 s->fd = open(filename, O_RDONLY | O_BINARY);
83 if (s->fd < 0)
84 return -errno;
85 bs->read_only = 1;
86 s->n_chunks = 0;
87 s->offsets = s->lengths = s->sectors = s->sectorcounts = 0;
88
89 /* read offset of info blocks */
90 if(lseek(s->fd,-0x1d8,SEEK_END)<0) {
91 dmg_close:
92 close(s->fd);
93 /* open raw instead */
94 bs->drv=&bdrv_raw;
95 return bs->drv->bdrv_open(bs, filename, flags);
96 }
97 info_begin=read_off(s->fd);
98 if(info_begin==0)
99 goto dmg_close;
100 if(lseek(s->fd,info_begin,SEEK_SET)<0)
101 goto dmg_close;
102 if(read_uint32(s->fd)!=0x100)
103 goto dmg_close;
104 if((count = read_uint32(s->fd))==0)
105 goto dmg_close;
106 info_end = info_begin+count;
107 if(lseek(s->fd,0xf8,SEEK_CUR)<0)
108 goto dmg_close;
109
110 /* read offsets */
111 last_in_offset = last_out_offset = 0;
112 while(lseek(s->fd,0,SEEK_CUR)<info_end) {
113 uint32_t type;
114
115 count = read_uint32(s->fd);
116 if(count==0)
117 goto dmg_close;
118 type = read_uint32(s->fd);
119 if(type!=0x6d697368 || count<244)
120 lseek(s->fd,count-4,SEEK_CUR);
121 else {
122 int new_size, chunk_count;
123 if(lseek(s->fd,200,SEEK_CUR)<0)
124 goto dmg_close;
125 chunk_count = (count-204)/40;
126 new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
127 s->types = realloc(s->types, new_size/2);
128 s->offsets = realloc(s->offsets, new_size);
129 s->lengths = realloc(s->lengths, new_size);
130 s->sectors = realloc(s->sectors, new_size);
131 s->sectorcounts = realloc(s->sectorcounts, new_size);
132
133 for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) {
134 s->types[i] = read_uint32(s->fd);
135 if(s->types[i]!=0x80000005 && s->types[i]!=1 && s->types[i]!=2) {
136 if(s->types[i]==0xffffffff) {
137 last_in_offset = s->offsets[i-1]+s->lengths[i-1];
138 last_out_offset = s->sectors[i-1]+s->sectorcounts[i-1];
139 }
140 chunk_count--;
141 i--;
142 if(lseek(s->fd,36,SEEK_CUR)<0)
143 goto dmg_close;
144 continue;
145 }
146 read_uint32(s->fd);
147 s->sectors[i] = last_out_offset+read_off(s->fd);
148 s->sectorcounts[i] = read_off(s->fd);
149 s->offsets[i] = last_in_offset+read_off(s->fd);
150 s->lengths[i] = read_off(s->fd);
151 if(s->lengths[i]>max_compressed_size)
152 max_compressed_size = s->lengths[i];
153 if(s->sectorcounts[i]>max_sectors_per_chunk)
154 max_sectors_per_chunk = s->sectorcounts[i];
155 }
156 s->n_chunks+=chunk_count;
157 }
158 }
159
160 /* initialize zlib engine */
161 if(!(s->compressed_chunk = malloc(max_compressed_size+1)))
162 goto dmg_close;
163 if(!(s->uncompressed_chunk = malloc(512*max_sectors_per_chunk)))
164 goto dmg_close;
165 if(inflateInit(&s->zstream) != Z_OK)
166 goto dmg_close;
167
168 s->current_chunk = s->n_chunks;
169
170 return 0;
171 }
172
173 static inline int is_sector_in_chunk(BDRVDMGState* s,
174 uint32_t chunk_num,int sector_num)
175 {
176 if(chunk_num>=s->n_chunks || s->sectors[chunk_num]>sector_num ||
177 s->sectors[chunk_num]+s->sectorcounts[chunk_num]<=sector_num)
178 return 0;
179 else
180 return -1;
181 }
182
183 static inline uint32_t search_chunk(BDRVDMGState* s,int sector_num)
184 {
185 /* binary search */
186 uint32_t chunk1=0,chunk2=s->n_chunks,chunk3;
187 while(chunk1!=chunk2) {
188 chunk3 = (chunk1+chunk2)/2;
189 if(s->sectors[chunk3]>sector_num)
190 chunk2 = chunk3;
191 else if(s->sectors[chunk3]+s->sectorcounts[chunk3]>sector_num)
192 return chunk3;
193 else
194 chunk1 = chunk3;
195 }
196 return s->n_chunks; /* error */
197 }
198
199 static inline int dmg_read_chunk(BDRVDMGState *s,int sector_num)
200 {
201 if(!is_sector_in_chunk(s,s->current_chunk,sector_num)) {
202 int ret;
203 uint32_t chunk = search_chunk(s,sector_num);
204
205 if(chunk>=s->n_chunks)
206 return -1;
207
208 s->current_chunk = s->n_chunks;
209 switch(s->types[chunk]) {
210 case 0x80000005: { /* zlib compressed */
211 int i;
212
213 ret = lseek(s->fd, s->offsets[chunk], SEEK_SET);
214 if(ret<0)
215 return -1;
216
217 /* we need to buffer, because only the chunk as whole can be
218 * inflated. */
219 i=0;
220 do {
221 ret = read(s->fd, s->compressed_chunk+i, s->lengths[chunk]-i);
222 if(ret<0 && errno==EINTR)
223 ret=0;
224 i+=ret;
225 } while(ret>=0 && ret+i<s->lengths[chunk]);
226
227 if (ret != s->lengths[chunk])
228 return -1;
229
230 s->zstream.next_in = s->compressed_chunk;
231 s->zstream.avail_in = s->lengths[chunk];
232 s->zstream.next_out = s->uncompressed_chunk;
233 s->zstream.avail_out = 512*s->sectorcounts[chunk];
234 ret = inflateReset(&s->zstream);
235 if(ret != Z_OK)
236 return -1;
237 ret = inflate(&s->zstream, Z_FINISH);
238 if(ret != Z_STREAM_END || s->zstream.total_out != 512*s->sectorcounts[chunk])
239 return -1;
240 break; }
241 case 1: /* copy */
242 ret = read(s->fd, s->uncompressed_chunk, s->lengths[chunk]);
243 if (ret != s->lengths[chunk])
244 return -1;
245 break;
246 case 2: /* zero */
247 memset(s->uncompressed_chunk, 0, 512*s->sectorcounts[chunk]);
248 break;
249 }
250 s->current_chunk = chunk;
251 }
252 return 0;
253 }
254
255 static int dmg_read(BlockDriverState *bs, int64_t sector_num,
256 uint8_t *buf, int nb_sectors)
257 {
258 BDRVDMGState *s = bs->opaque;
259 int i;
260
261 for(i=0;i<nb_sectors;i++) {
262 uint32_t sector_offset_in_chunk;
263 if(dmg_read_chunk(s, sector_num+i) != 0)
264 return -1;
265 sector_offset_in_chunk = sector_num+i-s->sectors[s->current_chunk];
266 memcpy(buf+i*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);
267 }
268 return 0;
269 }
270
271 static void dmg_close(BlockDriverState *bs)
272 {
273 BDRVDMGState *s = bs->opaque;
274 close(s->fd);
275 if(s->n_chunks>0) {
276 free(s->types);
277 free(s->offsets);
278 free(s->lengths);
279 free(s->sectors);
280 free(s->sectorcounts);
281 }
282 free(s->compressed_chunk);
283 free(s->uncompressed_chunk);
284 inflateEnd(&s->zstream);
285 }
286
287 BlockDriver bdrv_dmg = {
288 "dmg",
289 sizeof(BDRVDMGState),
290 dmg_probe,
291 dmg_open,
292 dmg_read,
293 NULL,
294 dmg_close,
295 };
296
0 /*
1 * Block driver for Parallels disk image format
2 *
3 * Copyright (c) 2007 Alex Beregszaszi
4 *
5 * This code is based on comparing different disk images created by Parallels.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25 #include "qemu-common.h"
26 #include "block_int.h"
27
28 /**************************************************************/
29
30 #define HEADER_MAGIC "WithoutFreeSpace"
31 #define HEADER_VERSION 2
32 #define HEADER_SIZE 64
33
34 // always little-endian
35 struct parallels_header {
36 char magic[16]; // "WithoutFreeSpace"
37 uint32_t version;
38 uint32_t heads;
39 uint32_t cylinders;
40 uint32_t tracks;
41 uint32_t catalog_entries;
42 uint32_t nb_sectors;
43 char padding[24];
44 } __attribute__((packed));
45
46 typedef struct BDRVParallelsState {
47 int fd;
48
49 uint32_t *catalog_bitmap;
50 int catalog_size;
51
52 int tracks;
53 } BDRVParallelsState;
54
55 static int parallels_probe(const uint8_t *buf, int buf_size, const char *filename)
56 {
57 const struct parallels_header *ph = (const void *)buf;
58
59 if (buf_size < HEADER_SIZE)
60 return 0;
61
62 if (!memcmp(ph->magic, HEADER_MAGIC, 16) &&
63 (le32_to_cpu(ph->version) == HEADER_VERSION))
64 return 100;
65
66 return 0;
67 }
68
69 static int parallels_open(BlockDriverState *bs, const char *filename, int flags)
70 {
71 BDRVParallelsState *s = bs->opaque;
72 int fd, i;
73 struct parallels_header ph;
74
75 fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
76 if (fd < 0) {
77 fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
78 if (fd < 0)
79 return -1;
80 }
81
82 bs->read_only = 1; // no write support yet
83
84 s->fd = fd;
85
86 if (read(fd, &ph, sizeof(ph)) != sizeof(ph))
87 goto fail;
88
89 if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
90 (le32_to_cpu(ph.version) != HEADER_VERSION)) {
91 goto fail;
92 }
93
94 bs->total_sectors = le32_to_cpu(ph.nb_sectors);
95
96 if (lseek(s->fd, 64, SEEK_SET) != 64)
97 goto fail;
98
99 s->tracks = le32_to_cpu(ph.tracks);
100
101 s->catalog_size = le32_to_cpu(ph.catalog_entries);
102 s->catalog_bitmap = qemu_malloc(s->catalog_size * 4);
103 if (!s->catalog_bitmap)
104 goto fail;
105 if (read(s->fd, s->catalog_bitmap, s->catalog_size * 4) !=
106 s->catalog_size * 4)
107 goto fail;
108 for (i = 0; i < s->catalog_size; i++)
109 le32_to_cpus(&s->catalog_bitmap[i]);
110
111 return 0;
112 fail:
113 if (s->catalog_bitmap)
114 qemu_free(s->catalog_bitmap);
115 close(fd);
116 return -1;
117 }
118
119 static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
120 {
121 BDRVParallelsState *s = bs->opaque;
122 uint32_t index, offset, position;
123
124 index = sector_num / s->tracks;
125 offset = sector_num % s->tracks;
126
127 // not allocated
128 if ((index > s->catalog_size) || (s->catalog_bitmap[index] == 0))
129 return -1;
130
131 position = (s->catalog_bitmap[index] + offset) * 512;
132
133 // fprintf(stderr, "sector: %llx index=%x offset=%x pointer=%x position=%x\n",
134 // sector_num, index, offset, s->catalog_bitmap[index], position);
135
136 if (lseek(s->fd, position, SEEK_SET) != position)
137 return -1;
138
139 return 0;
140 }
141
142 static int parallels_read(BlockDriverState *bs, int64_t sector_num,
143 uint8_t *buf, int nb_sectors)
144 {
145 BDRVParallelsState *s = bs->opaque;
146
147 while (nb_sectors > 0) {
148 if (!seek_to_sector(bs, sector_num)) {
149 if (read(s->fd, buf, 512) != 512)
150 return -1;
151 } else
152 memset(buf, 0, 512);
153 nb_sectors--;
154 sector_num++;
155 buf += 512;
156 }
157 return 0;
158 }
159
160 static void parallels_close(BlockDriverState *bs)
161 {
162 BDRVParallelsState *s = bs->opaque;
163 qemu_free(s->catalog_bitmap);
164 close(s->fd);
165 }
166
167 BlockDriver bdrv_parallels = {
168 "parallels",
169 sizeof(BDRVParallelsState),
170 parallels_probe,
171 parallels_open,
172 parallels_read,
173 NULL,
174 parallels_close,
175 };
0 /*
1 * Block driver for the QCOW format
2 *
3 * Copyright (c) 2004-2006 Fabrice Bellard
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #include "qemu-common.h"
24 #include "block_int.h"
25 #include <zlib.h>
26 #include "aes.h"
27
28 /**************************************************************/
29 /* QEMU COW block driver with compression and encryption support */
30
31 #define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
32 #define QCOW_VERSION 1
33
34 #define QCOW_CRYPT_NONE 0
35 #define QCOW_CRYPT_AES 1
36
37 #define QCOW_OFLAG_COMPRESSED (1LL << 63)
38
39 typedef struct QCowHeader {
40 uint32_t magic;
41 uint32_t version;
42 uint64_t backing_file_offset;
43 uint32_t backing_file_size;
44 uint32_t mtime;
45 uint64_t size; /* in bytes */
46 uint8_t cluster_bits;
47 uint8_t l2_bits;
48 uint32_t crypt_method;
49 uint64_t l1_table_offset;
50 } QCowHeader;
51
52 #define L2_CACHE_SIZE 16
53
54 typedef struct BDRVQcowState {
55 BlockDriverState *hd;
56 int cluster_bits;
57 int cluster_size;
58 int cluster_sectors;
59 int l2_bits;
60 int l2_size;
61 int l1_size;
62 uint64_t cluster_offset_mask;
63 uint64_t l1_table_offset;
64 uint64_t *l1_table;
65 uint64_t *l2_cache;
66 uint64_t l2_cache_offsets[L2_CACHE_SIZE];
67 uint32_t l2_cache_counts[L2_CACHE_SIZE];
68 uint8_t *cluster_cache;
69 uint8_t *cluster_data;
70 uint64_t cluster_cache_offset;
71 uint32_t crypt_method; /* current crypt method, 0 if no key yet */
72 uint32_t crypt_method_header;
73 AES_KEY aes_encrypt_key;
74 AES_KEY aes_decrypt_key;
75 } BDRVQcowState;
76
77 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset);
78
79 static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
80 {
81 const QCowHeader *cow_header = (const void *)buf;
82
83 if (buf_size >= sizeof(QCowHeader) &&
84 be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
85 be32_to_cpu(cow_header->version) == QCOW_VERSION)
86 return 100;
87 else
88 return 0;
89 }
90
91 static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
92 {
93 BDRVQcowState *s = bs->opaque;
94 int len, i, shift, ret;
95 QCowHeader header;
96
97 ret = bdrv_file_open(&s->hd, filename, flags);
98 if (ret < 0)
99 return ret;
100 if (bdrv_pread(s->hd, 0, &header, sizeof(header)) != sizeof(header))
101 goto fail;
102 be32_to_cpus(&header.magic);
103 be32_to_cpus(&header.version);
104 be64_to_cpus(&header.backing_file_offset);
105 be32_to_cpus(&header.backing_file_size);
106 be32_to_cpus(&header.mtime);
107 be64_to_cpus(&header.size);
108 be32_to_cpus(&header.crypt_method);
109 be64_to_cpus(&header.l1_table_offset);
110
111 if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION)
112 goto fail;
113 if (header.size <= 1 || header.cluster_bits < 9)
114 goto fail;
115 if (header.crypt_method > QCOW_CRYPT_AES)
116 goto fail;
117 s->crypt_method_header = header.crypt_method;
118 if (s->crypt_method_header)
119 bs->encrypted = 1;
120 s->cluster_bits = header.cluster_bits;
121 s->cluster_size = 1 << s->cluster_bits;
122 s->cluster_sectors = 1 << (s->cluster_bits - 9);
123 s->l2_bits = header.l2_bits;
124 s->l2_size = 1 << s->l2_bits;
125 bs->total_sectors = header.size / 512;
126 s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1;
127
128 /* read the level 1 table */
129 shift = s->cluster_bits + s->l2_bits;
130 s->l1_size = (header.size + (1LL << shift) - 1) >> shift;
131
132 s->l1_table_offset = header.l1_table_offset;
133 s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
134 if (!s->l1_table)
135 goto fail;
136 if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) !=
137 s->l1_size * sizeof(uint64_t))
138 goto fail;
139 for(i = 0;i < s->l1_size; i++) {
140 be64_to_cpus(&s->l1_table[i]);
141 }
142 /* alloc L2 cache */
143 s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
144 if (!s->l2_cache)
145 goto fail;
146 s->cluster_cache = qemu_malloc(s->cluster_size);
147 if (!s->cluster_cache)
148 goto fail;
149 s->cluster_data = qemu_malloc(s->cluster_size);
150 if (!s->cluster_data)
151 goto fail;
152 s->cluster_cache_offset = -1;
153
154 /* read the backing file name */
155 if (header.backing_file_offset != 0) {
156 len = header.backing_file_size;
157 if (len > 1023)
158 len = 1023;
159 if (bdrv_pread(s->hd, header.backing_file_offset, bs->backing_file, len) != len)
160 goto fail;
161 bs->backing_file[len] = '\0';
162 }
163 return 0;
164
165 fail:
166 qemu_free(s->l1_table);
167 qemu_free(s->l2_cache);
168 qemu_free(s->cluster_cache);
169 qemu_free(s->cluster_data);
170 bdrv_delete(s->hd);
171 return -1;
172 }
173
174 static int qcow_set_key(BlockDriverState *bs, const char *key)
175 {
176 BDRVQcowState *s = bs->opaque;
177 uint8_t keybuf[16];
178 int len, i;
179
180 memset(keybuf, 0, 16);
181 len = strlen(key);
182 if (len > 16)
183 len = 16;
184 /* XXX: we could compress the chars to 7 bits to increase
185 entropy */
186 for(i = 0;i < len;i++) {
187 keybuf[i] = key[i];
188 }
189 s->crypt_method = s->crypt_method_header;
190
191 if (AES_set_encrypt_key(keybuf, 128, &s->aes_encrypt_key) != 0)
192 return -1;
193 if (AES_set_decrypt_key(keybuf, 128, &s->aes_decrypt_key) != 0)
194 return -1;
195 #if 0
196 /* test */
197 {
198 uint8_t in[16];
199 uint8_t out[16];
200 uint8_t tmp[16];
201 for(i=0;i<16;i++)
202 in[i] = i;
203 AES_encrypt(in, tmp, &s->aes_encrypt_key);
204 AES_decrypt(tmp, out, &s->aes_decrypt_key);
205 for(i = 0; i < 16; i++)
206 printf(" %02x", tmp[i]);
207 printf("\n");
208 for(i = 0; i < 16; i++)
209 printf(" %02x", out[i]);
210 printf("\n");
211 }
212 #endif
213 return 0;
214 }
215
216 /* The crypt function is compatible with the linux cryptoloop
217 algorithm for < 4 GB images. NOTE: out_buf == in_buf is
218 supported */
219 static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
220 uint8_t *out_buf, const uint8_t *in_buf,
221 int nb_sectors, int enc,
222 const AES_KEY *key)
223 {
224 union {
225 uint64_t ll[2];
226 uint8_t b[16];
227 } ivec;
228 int i;
229
230 for(i = 0; i < nb_sectors; i++) {
231 ivec.ll[0] = cpu_to_le64(sector_num);
232 ivec.ll[1] = 0;
233 AES_cbc_encrypt(in_buf, out_buf, 512, key,
234 ivec.b, enc);
235 sector_num++;
236 in_buf += 512;
237 out_buf += 512;
238 }
239 }
240
241 /* 'allocate' is:
242 *
243 * 0 to not allocate.
244 *
245 * 1 to allocate a normal cluster (for sector indexes 'n_start' to
246 * 'n_end')
247 *
248 * 2 to allocate a compressed cluster of size
249 * 'compressed_size'. 'compressed_size' must be > 0 and <
250 * cluster_size
251 *
252 * return 0 if not allocated.
253 */
254 static uint64_t get_cluster_offset(BlockDriverState *bs,
255 uint64_t offset, int allocate,
256 int compressed_size,
257 int n_start, int n_end)
258 {
259 BDRVQcowState *s = bs->opaque;
260 int min_index, i, j, l1_index, l2_index;
261 uint64_t l2_offset, *l2_table, cluster_offset, tmp;
262 uint32_t min_count;
263 int new_l2_table;
264
265 l1_index = offset >> (s->l2_bits + s->cluster_bits);
266 l2_offset = s->l1_table[l1_index];
267 new_l2_table = 0;
268 if (!l2_offset) {
269 if (!allocate)
270 return 0;
271 /* allocate a new l2 entry */
272 l2_offset = bdrv_getlength(s->hd);
273 /* round to cluster size */
274 l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
275 /* update the L1 entry */
276 s->l1_table[l1_index] = l2_offset;
277 tmp = cpu_to_be64(l2_offset);
278 if (bdrv_pwrite(s->hd, s->l1_table_offset + l1_index * sizeof(tmp),
279 &tmp, sizeof(tmp)) != sizeof(tmp))
280 return 0;
281 new_l2_table = 1;
282 }
283 for(i = 0; i < L2_CACHE_SIZE; i++) {
284 if (l2_offset == s->l2_cache_offsets[i]) {
285 /* increment the hit count */
286 if (++s->l2_cache_counts[i] == 0xffffffff) {
287 for(j = 0; j < L2_CACHE_SIZE; j++) {
288 s->l2_cache_counts[j] >>= 1;
289 }
290 }
291 l2_table = s->l2_cache + (i << s->l2_bits);
292 goto found;
293 }
294 }
295 /* not found: load a new entry in the least used one */
296 min_index = 0;
297 min_count = 0xffffffff;
298 for(i = 0; i < L2_CACHE_SIZE; i++) {
299 if (s->l2_cache_counts[i] < min_count) {
300 min_count = s->l2_cache_counts[i];
301 min_index = i;
302 }
303 }
304 l2_table = s->l2_cache + (min_index << s->l2_bits);
305 if (new_l2_table) {
306 memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
307 if (bdrv_pwrite(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
308 s->l2_size * sizeof(uint64_t))
309 return 0;
310 } else {
311 if (bdrv_pread(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
312 s->l2_size * sizeof(uint64_t))
313 return 0;
314 }
315 s->l2_cache_offsets[min_index] = l2_offset;
316 s->l2_cache_counts[min_index] = 1;
317 found:
318 l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
319 cluster_offset = be64_to_cpu(l2_table[l2_index]);
320 if (!cluster_offset ||
321 ((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
322 if (!allocate)
323 return 0;
324 /* allocate a new cluster */
325 if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
326 (n_end - n_start) < s->cluster_sectors) {
327 /* if the cluster is already compressed, we must
328 decompress it in the case it is not completely
329 overwritten */
330 if (decompress_cluster(s, cluster_offset) < 0)
331 return 0;
332 cluster_offset = bdrv_getlength(s->hd);
333 cluster_offset = (cluster_offset + s->cluster_size - 1) &
334 ~(s->cluster_size - 1);
335 /* write the cluster content */
336 if (bdrv_pwrite(s->hd, cluster_offset, s->cluster_cache, s->cluster_size) !=
337 s->cluster_size)
338 return -1;
339 } else {
340 cluster_offset = bdrv_getlength(s->hd);
341 if (allocate == 1) {
342 /* round to cluster size */
343 cluster_offset = (cluster_offset + s->cluster_size - 1) &
344 ~(s->cluster_size - 1);
345 bdrv_truncate(s->hd, cluster_offset + s->cluster_size);
346 /* if encrypted, we must initialize the cluster
347 content which won't be written */
348 if (s->crypt_method &&
349 (n_end - n_start) < s->cluster_sectors) {
350 uint64_t start_sect;
351 start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
352 memset(s->cluster_data + 512, 0x00, 512);
353 for(i = 0; i < s->cluster_sectors; i++) {
354 if (i < n_start || i >= n_end) {
355 encrypt_sectors(s, start_sect + i,
356 s->cluster_data,
357 s->cluster_data + 512, 1, 1,
358 &s->aes_encrypt_key);
359 if (bdrv_pwrite(s->hd, cluster_offset + i * 512,
360 s->cluster_data, 512) != 512)
361 return -1;
362 }
363 }
364 }
365 } else {
366 cluster_offset |= QCOW_OFLAG_COMPRESSED |
367 (uint64_t)compressed_size << (63 - s->cluster_bits);
368 }
369 }
370 /* update L2 table */
371 tmp = cpu_to_be64(cluster_offset);
372 l2_table[l2_index] = tmp;
373 if (bdrv_pwrite(s->hd,
374 l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))
375 return 0;
376 }
377 return cluster_offset;
378 }
379
380 static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num,
381 int nb_sectors, int *pnum)
382 {
383 BDRVQcowState *s = bs->opaque;
384 int index_in_cluster, n;
385 uint64_t cluster_offset;
386
387 cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
388 index_in_cluster = sector_num & (s->cluster_sectors - 1);
389 n = s->cluster_sectors - index_in_cluster;
390 if (n > nb_sectors)
391 n = nb_sectors;
392 *pnum = n;
393 return (cluster_offset != 0);
394 }
395
396 static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
397 const uint8_t *buf, int buf_size)
398 {
399 z_stream strm1, *strm = &strm1;
400 int ret, out_len;
401
402 memset(strm, 0, sizeof(*strm));
403
404 strm->next_in = (uint8_t *)buf;
405 strm->avail_in = buf_size;
406 strm->next_out = out_buf;
407 strm->avail_out = out_buf_size;
408
409 ret = inflateInit2(strm, -12);
410 if (ret != Z_OK)
411 return -1;
412 ret = inflate(strm, Z_FINISH);
413 out_len = strm->next_out - out_buf;
414 if ((ret != Z_STREAM_END && ret != Z_BUF_ERROR) ||
415 out_len != out_buf_size) {
416 inflateEnd(strm);
417 return -1;
418 }
419 inflateEnd(strm);
420 return 0;
421 }
422
423 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
424 {
425 int ret, csize;
426 uint64_t coffset;
427
428 coffset = cluster_offset & s->cluster_offset_mask;
429 if (s->cluster_cache_offset != coffset) {
430 csize = cluster_offset >> (63 - s->cluster_bits);
431 csize &= (s->cluster_size - 1);
432 ret = bdrv_pread(s->hd, coffset, s->cluster_data, csize);
433 if (ret != csize)
434 return -1;
435 if (decompress_buffer(s->cluster_cache, s->cluster_size,
436 s->cluster_data, csize) < 0) {
437 return -1;
438 }
439 s->cluster_cache_offset = coffset;
440 }
441 return 0;
442 }
443
444 #if 0
445
446 static int qcow_read(BlockDriverState *bs, int64_t sector_num,
447 uint8_t *buf, int nb_sectors)
448 {
449 BDRVQcowState *s = bs->opaque;
450 int ret, index_in_cluster, n;
451 uint64_t cluster_offset;
452
453 while (nb_sectors > 0) {
454 cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
455 index_in_cluster = sector_num & (s->cluster_sectors - 1);
456 n = s->cluster_sectors - index_in_cluster;
457 if (n > nb_sectors)
458 n = nb_sectors;
459 if (!cluster_offset) {
460 if (bs->backing_hd) {
461 /* read from the base image */
462 ret = bdrv_read(bs->backing_hd, sector_num, buf, n);
463 if (ret < 0)
464 return -1;
465 } else {
466 memset(buf, 0, 512 * n);
467 }
468 } else if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
469 if (decompress_cluster(s, cluster_offset) < 0)
470 return -1;
471 memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
472 } else {
473 ret = bdrv_pread(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512);
474 if (ret != n * 512)
475 return -1;
476 if (s->crypt_method) {
477 encrypt_sectors(s, sector_num, buf, buf, n, 0,
478 &s->aes_decrypt_key);
479 }
480 }
481 nb_sectors -= n;
482 sector_num += n;
483 buf += n * 512;
484 }
485 return 0;
486 }
487 #endif
488
489 static int qcow_write(BlockDriverState *bs, int64_t sector_num,
490 const uint8_t *buf, int nb_sectors)
491 {
492 BDRVQcowState *s = bs->opaque;
493 int ret, index_in_cluster, n;
494 uint64_t cluster_offset;
495
496 while (nb_sectors > 0) {
497 index_in_cluster = sector_num & (s->cluster_sectors - 1);
498 n = s->cluster_sectors - index_in_cluster;
499 if (n > nb_sectors)
500 n = nb_sectors;
501 cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
502 index_in_cluster,
503 index_in_cluster + n);
504 if (!cluster_offset)
505 return -1;
506 if (s->crypt_method) {
507 encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1,
508 &s->aes_encrypt_key);
509 ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512,
510 s->cluster_data, n * 512);
511 } else {
512 ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512);
513 }
514 if (ret != n * 512)
515 return -1;
516 nb_sectors -= n;
517 sector_num += n;
518 buf += n * 512;
519 }
520 s->cluster_cache_offset = -1; /* disable compressed cache */
521 return 0;
522 }
523
524 typedef struct QCowAIOCB {
525 BlockDriverAIOCB common;
526 int64_t sector_num;
527 uint8_t *buf;
528 int nb_sectors;
529 int n;
530 uint64_t cluster_offset;
531 uint8_t *cluster_data;
532 BlockDriverAIOCB *hd_aiocb;
533 } QCowAIOCB;
534
535 static void qcow_aio_read_cb(void *opaque, int ret)
536 {
537 QCowAIOCB *acb = opaque;
538 BlockDriverState *bs = acb->common.bs;
539 BDRVQcowState *s = bs->opaque;
540 int index_in_cluster;
541
542 acb->hd_aiocb = NULL;
543 if (ret < 0) {
544 fail:
545 acb->common.cb(acb->common.opaque, ret);
546 qemu_aio_release(acb);
547 return;
548 }
549
550 redo:
551 /* post process the read buffer */
552 if (!acb->cluster_offset) {
553 /* nothing to do */
554 } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) {
555 /* nothing to do */
556 } else {
557 if (s->crypt_method) {
558 encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf,
559 acb->n, 0,
560 &s->aes_decrypt_key);
561 }
562 }
563
564 acb->nb_sectors -= acb->n;
565 acb->sector_num += acb->n;
566 acb->buf += acb->n * 512;
567
568 if (acb->nb_sectors == 0) {
569 /* request completed */
570 acb->common.cb(acb->common.opaque, 0);
571 qemu_aio_release(acb);
572 return;
573 }
574
575 /* prepare next AIO request */
576 acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9,
577 0, 0, 0, 0);
578 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
579 acb->n = s->cluster_sectors - index_in_cluster;
580 if (acb->n > acb->nb_sectors)
581 acb->n = acb->nb_sectors;
582
583 if (!acb->cluster_offset) {
584 if (bs->backing_hd) {
585 /* read from the base image */
586 acb->hd_aiocb = bdrv_aio_read(bs->backing_hd,
587 acb->sector_num, acb->buf, acb->n, qcow_aio_read_cb, acb);
588 if (acb->hd_aiocb == NULL)
589 goto fail;
590 } else {
591 /* Note: in this case, no need to wait */
592 memset(acb->buf, 0, 512 * acb->n);
593 goto redo;
594 }
595 } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) {
596 /* add AIO support for compressed blocks ? */
597 if (decompress_cluster(s, acb->cluster_offset) < 0)
598 goto fail;
599 memcpy(acb->buf,
600 s->cluster_cache + index_in_cluster * 512, 512 * acb->n);
601 goto redo;
602 } else {
603 if ((acb->cluster_offset & 511) != 0) {
604 ret = -EIO;
605 goto fail;
606 }
607 acb->hd_aiocb = bdrv_aio_read(s->hd,
608 (acb->cluster_offset >> 9) + index_in_cluster,
609 acb->buf, acb->n, qcow_aio_read_cb, acb);
610 if (acb->hd_aiocb == NULL)
611 goto fail;
612 }
613 }
614
615 static BlockDriverAIOCB *qcow_aio_read(BlockDriverState *bs,
616 int64_t sector_num, uint8_t *buf, int nb_sectors,
617 BlockDriverCompletionFunc *cb, void *opaque)
618 {
619 QCowAIOCB *acb;
620
621 acb = qemu_aio_get(bs, cb, opaque);
622 if (!acb)
623 return NULL;
624 acb->hd_aiocb = NULL;
625 acb->sector_num = sector_num;
626 acb->buf = buf;
627 acb->nb_sectors = nb_sectors;
628 acb->n = 0;
629 acb->cluster_offset = 0;
630
631 qcow_aio_read_cb(acb, 0);
632 return &acb->common;
633 }
634
635 static void qcow_aio_write_cb(void *opaque, int ret)
636 {
637 QCowAIOCB *acb = opaque;
638 BlockDriverState *bs = acb->common.bs;
639 BDRVQcowState *s = bs->opaque;
640 int index_in_cluster;
641 uint64_t cluster_offset;
642 const uint8_t *src_buf;
643
644 acb->hd_aiocb = NULL;
645
646 if (ret < 0) {
647 fail:
648 acb->common.cb(acb->common.opaque, ret);
649 qemu_aio_release(acb);
650 return;
651 }
652
653 acb->nb_sectors -= acb->n;
654 acb->sector_num += acb->n;
655 acb->buf += acb->n * 512;
656
657 if (acb->nb_sectors == 0) {
658 /* request completed */
659 acb->common.cb(acb->common.opaque, 0);
660 qemu_aio_release(acb);
661 return;
662 }
663
664 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
665 acb->n = s->cluster_sectors - index_in_cluster;
666 if (acb->n > acb->nb_sectors)
667 acb->n = acb->nb_sectors;
668 cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, 1, 0,
669 index_in_cluster,
670 index_in_cluster + acb->n);
671 if (!cluster_offset || (cluster_offset & 511) != 0) {
672 ret = -EIO;
673 goto fail;
674 }
675 if (s->crypt_method) {
676 if (!acb->cluster_data) {
677 acb->cluster_data = qemu_mallocz(s->cluster_size);
678 if (!acb->cluster_data) {
679 ret = -ENOMEM;
680 goto fail;
681 }
682 }
683 encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
684 acb->n, 1, &s->aes_encrypt_key);
685 src_buf = acb->cluster_data;
686 } else {
687 src_buf = acb->buf;
688 }
689 acb->hd_aiocb = bdrv_aio_write(s->hd,
690 (cluster_offset >> 9) + index_in_cluster,
691 src_buf, acb->n,
692 qcow_aio_write_cb, acb);
693 if (acb->hd_aiocb == NULL)
694 goto fail;
695 }
696
697 static BlockDriverAIOCB *qcow_aio_write(BlockDriverState *bs,
698 int64_t sector_num, const uint8_t *buf, int nb_sectors,
699 BlockDriverCompletionFunc *cb, void *opaque)
700 {
701 BDRVQcowState *s = bs->opaque;
702 QCowAIOCB *acb;
703
704 s->cluster_cache_offset = -1; /* disable compressed cache */
705
706 acb = qemu_aio_get(bs, cb, opaque);
707 if (!acb)
708 return NULL;
709 acb->hd_aiocb = NULL;
710 acb->sector_num = sector_num;
711 acb->buf = (uint8_t *)buf;
712 acb->nb_sectors = nb_sectors;
713 acb->n = 0;
714
715 qcow_aio_write_cb(acb, 0);
716 return &acb->common;
717 }
718
719 static void qcow_aio_cancel(BlockDriverAIOCB *blockacb)
720 {
721 QCowAIOCB *acb = (QCowAIOCB *)blockacb;
722 if (acb->hd_aiocb)
723 bdrv_aio_cancel(acb->hd_aiocb);
724 qemu_aio_release(acb);
725 }
726
727 static void qcow_close(BlockDriverState *bs)
728 {
729 BDRVQcowState *s = bs->opaque;
730 qemu_free(s->l1_table);
731 qemu_free(s->l2_cache);
732 qemu_free(s->cluster_cache);
733 qemu_free(s->cluster_data);
734 bdrv_delete(s->hd);
735 }
736
737 static int qcow_create(const char *filename, int64_t total_size,
738 const char *backing_file, int flags)
739 {
740 int fd, header_size, backing_filename_len, l1_size, i, shift;
741 QCowHeader header;
742 uint64_t tmp;
743
744 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
745 if (fd < 0)
746 return -1;
747 memset(&header, 0, sizeof(header));
748 header.magic = cpu_to_be32(QCOW_MAGIC);
749 header.version = cpu_to_be32(QCOW_VERSION);
750 header.size = cpu_to_be64(total_size * 512);
751 header_size = sizeof(header);
752 backing_filename_len = 0;
753 if (backing_file) {
754 header.backing_file_offset = cpu_to_be64(header_size);
755 backing_filename_len = strlen(backing_file);
756 header.backing_file_size = cpu_to_be32(backing_filename_len);
757 header_size += backing_filename_len;
758 header.mtime = cpu_to_be32(0);
759 header.cluster_bits = 9; /* 512 byte cluster to avoid copying
760 unmodifyed sectors */
761 header.l2_bits = 12; /* 32 KB L2 tables */
762 } else {
763 header.cluster_bits = 12; /* 4 KB clusters */
764 header.l2_bits = 9; /* 4 KB L2 tables */
765 }
766 header_size = (header_size + 7) & ~7;
767 shift = header.cluster_bits + header.l2_bits;
768 l1_size = ((total_size * 512) + (1LL << shift) - 1) >> shift;
769
770 header.l1_table_offset = cpu_to_be64(header_size);
771 if (flags & BLOCK_FLAG_ENCRYPT) {
772 header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
773 } else {
774 header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
775 }
776
777 /* write all the data */
778 if(write(fd, &header, sizeof(header))!=sizeof(header)) return -1;
779 if (backing_file) {
780 if(write(fd, backing_file, backing_filename_len)!=backing_filename_len) return -1;
781 }
782 lseek(fd, header_size, SEEK_SET);
783 tmp = 0;
784 for(i = 0;i < l1_size; i++) {
785 if(write(fd, &tmp, sizeof(tmp))!=sizeof(tmp)) return -1;
786 }
787 close(fd);
788 return 0;
789 }
790
791 static int qcow_make_empty(BlockDriverState *bs)
792 {
793 BDRVQcowState *s = bs->opaque;
794 uint32_t l1_length = s->l1_size * sizeof(uint64_t);
795 int ret;
796
797 memset(s->l1_table, 0, l1_length);
798 if (bdrv_pwrite(s->hd, s->l1_table_offset, s->l1_table, l1_length) < 0)
799 return -1;
800 ret = bdrv_truncate(s->hd, s->l1_table_offset + l1_length);
801 if (ret < 0)
802 return ret;
803
804 memset(s->l2_cache, 0, s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
805 memset(s->l2_cache_offsets, 0, L2_CACHE_SIZE * sizeof(uint64_t));
806 memset(s->l2_cache_counts, 0, L2_CACHE_SIZE * sizeof(uint32_t));
807
808 return 0;
809 }
810
811 /* XXX: put compressed sectors first, then all the cluster aligned
812 tables to avoid losing bytes in alignment */
813 static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
814 const uint8_t *buf, int nb_sectors)
815 {
816 BDRVQcowState *s = bs->opaque;
817 z_stream strm;
818 int ret, out_len;
819 uint8_t *out_buf;
820 uint64_t cluster_offset;
821
822 if (nb_sectors != s->cluster_sectors)
823 return -EINVAL;
824
825 out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
826 if (!out_buf)
827 return -1;
828
829 /* best compression, small window, no zlib header */
830 memset(&strm, 0, sizeof(strm));
831 ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION,
832 Z_DEFLATED, -12,
833 9, Z_DEFAULT_STRATEGY);
834 if (ret != 0) {
835 qemu_free(out_buf);
836 return -1;
837 }
838
839 strm.avail_in = s->cluster_size;
840 strm.next_in = (uint8_t *)buf;
841 strm.avail_out = s->cluster_size;
842 strm.next_out = out_buf;
843
844 ret = deflate(&strm, Z_FINISH);
845 if (ret != Z_STREAM_END && ret != Z_OK) {
846 qemu_free(out_buf);
847 deflateEnd(&strm);
848 return -1;
849 }
850 out_len = strm.next_out - out_buf;
851
852 deflateEnd(&strm);
853
854 if (ret != Z_STREAM_END || out_len >= s->cluster_size) {
855 /* could not compress: write normal cluster */
856 qcow_write(bs, sector_num, buf, s->cluster_sectors);
857 } else {
858 cluster_offset = get_cluster_offset(bs, sector_num << 9, 2,
859 out_len, 0, 0);
860 cluster_offset &= s->cluster_offset_mask;
861 if (bdrv_pwrite(s->hd, cluster_offset, out_buf, out_len) != out_len) {
862 qemu_free(out_buf);
863 return -1;
864 }
865 }
866
867 qemu_free(out_buf);
868 return 0;
869 }
870
871 static void qcow_flush(BlockDriverState *bs)
872 {
873 BDRVQcowState *s = bs->opaque;
874 bdrv_flush(s->hd);
875 }
876
877 static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
878 {
879 BDRVQcowState *s = bs->opaque;
880 bdi->cluster_size = s->cluster_size;
881 return 0;
882 }
883
884 BlockDriver bdrv_qcow = {
885 "qcow",
886 sizeof(BDRVQcowState),
887 qcow_probe,
888 qcow_open,
889 NULL,
890 NULL,
891 qcow_close,
892 qcow_create,
893 qcow_flush,
894 qcow_is_allocated,
895 qcow_set_key,
896 qcow_make_empty,
897
898 .bdrv_aio_read = qcow_aio_read,
899 .bdrv_aio_write = qcow_aio_write,
900 .bdrv_aio_cancel = qcow_aio_cancel,
901 .aiocb_size = sizeof(QCowAIOCB),
902 .bdrv_write_compressed = qcow_write_compressed,
903 .bdrv_get_info = qcow_get_info,
904 };
0 /*
1 * Block driver for the QCOW version 2 format
2 *
3 * Copyright (c) 2004-2006 Fabrice Bellard
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #include "qemu-common.h"
24 #include "block_int.h"
25 #include <zlib.h>
26 #include "aes.h"
27 #include <assert.h>
28
29 /*
30 Differences with QCOW:
31
32 - Support for multiple incremental snapshots.
33 - Memory management by reference counts.
34 - Clusters which have a reference count of one have the bit
35 QCOW_OFLAG_COPIED to optimize write performance.
36 - Size of compressed clusters is stored in sectors to reduce bit usage
37 in the cluster offsets.
38 - Support for storing additional data (such as the VM state) in the
39 snapshots.
40 - If a backing store is used, the cluster size is not constrained
41 (could be backported to QCOW).
42 - L2 tables have always a size of one cluster.
43 */
44
45 //#define DEBUG_ALLOC
46 //#define DEBUG_ALLOC2
47
48 #define QCOW_MAGIC (('Q' << 24) | ('F' << 16) | ('I' << 8) | 0xfb)
49 #define QCOW_VERSION 2
50
51 #define QCOW_CRYPT_NONE 0
52 #define QCOW_CRYPT_AES 1
53
54 /* indicate that the refcount of the referenced cluster is exactly one. */
55 #define QCOW_OFLAG_COPIED (1LL << 63)
56 /* indicate that the cluster is compressed (they never have the copied flag) */
57 #define QCOW_OFLAG_COMPRESSED (1LL << 62)
58
59 #define REFCOUNT_SHIFT 1 /* refcount size is 2 bytes */
60
61 #ifndef offsetof
62 #define offsetof(type, field) ((size_t) &((type *)0)->field)
63 #endif
64
65 typedef struct QCowHeader {
66 uint32_t magic;
67 uint32_t version;
68 uint64_t backing_file_offset;
69 uint32_t backing_file_size;
70 uint32_t cluster_bits;
71 uint64_t size; /* in bytes */
72 uint32_t crypt_method;
73 uint32_t l1_size; /* XXX: save number of clusters instead ? */
74 uint64_t l1_table_offset;
75 uint64_t refcount_table_offset;
76 uint32_t refcount_table_clusters;
77 uint32_t nb_snapshots;
78 uint64_t snapshots_offset;
79 } QCowHeader;
80
81 typedef struct __attribute__((packed)) QCowSnapshotHeader {
82 /* header is 8 byte aligned */
83 uint64_t l1_table_offset;
84
85 uint32_t l1_size;
86 uint16_t id_str_size;
87 uint16_t name_size;
88
89 uint32_t date_sec;
90 uint32_t date_nsec;
91
92 uint64_t vm_clock_nsec;
93
94 uint32_t vm_state_size;
95 uint32_t extra_data_size; /* for extension */
96 /* extra data follows */
97 /* id_str follows */
98 /* name follows */
99 } QCowSnapshotHeader;
100
101 #define L2_CACHE_SIZE 16
102
103 typedef struct QCowSnapshot {
104 uint64_t l1_table_offset;
105 uint32_t l1_size;
106 char *id_str;
107 char *name;
108 uint32_t vm_state_size;
109 uint32_t date_sec;
110 uint32_t date_nsec;
111 uint64_t vm_clock_nsec;
112 } QCowSnapshot;
113
114 typedef struct BDRVQcowState {
115 BlockDriverState *hd;
116 int cluster_bits;
117 int cluster_size;
118 int cluster_sectors;
119 int l2_bits;
120 int l2_size;
121 int l1_size;
122 int l1_vm_state_index;
123 int csize_shift;
124 int csize_mask;
125 uint64_t cluster_offset_mask;
126 uint64_t l1_table_offset;
127 uint64_t *l1_table;
128 uint64_t *l2_cache;
129 uint64_t l2_cache_offsets[L2_CACHE_SIZE];
130 uint32_t l2_cache_counts[L2_CACHE_SIZE];
131 uint8_t *cluster_cache;
132 uint8_t *cluster_data;
133 uint64_t cluster_cache_offset;
134
135 uint64_t *refcount_table;
136 uint64_t refcount_table_offset;
137 uint32_t refcount_table_size;
138 uint64_t refcount_block_cache_offset;
139 uint16_t *refcount_block_cache;
140 int64_t free_cluster_index;
141 int64_t free_byte_offset;
142
143 uint32_t crypt_method; /* current crypt method, 0 if no key yet */
144 uint32_t crypt_method_header;
145 AES_KEY aes_encrypt_key;
146 AES_KEY aes_decrypt_key;
147 uint64_t snapshots_offset;
148 int snapshots_size;
149 int nb_snapshots;
150 QCowSnapshot *snapshots;
151 } BDRVQcowState;
152
153 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset);
154 static int qcow_read(BlockDriverState *bs, int64_t sector_num,
155 uint8_t *buf, int nb_sectors);
156 static int qcow_read_snapshots(BlockDriverState *bs);
157 static void qcow_free_snapshots(BlockDriverState *bs);
158 static int refcount_init(BlockDriverState *bs);
159 static void refcount_close(BlockDriverState *bs);
160 static int get_refcount(BlockDriverState *bs, int64_t cluster_index);
161 static int update_cluster_refcount(BlockDriverState *bs,
162 int64_t cluster_index,
163 int addend);
164 static void update_refcount(BlockDriverState *bs,
165 int64_t offset, int64_t length,
166 int addend);
167 static int64_t alloc_clusters(BlockDriverState *bs, int64_t size);
168 static int64_t alloc_bytes(BlockDriverState *bs, int size);
169 static void free_clusters(BlockDriverState *bs,
170 int64_t offset, int64_t size);
171 #ifdef DEBUG_ALLOC
172 static void check_refcounts(BlockDriverState *bs);
173 #endif
174
175 static int qcow_probe(const uint8_t *buf, int buf_size, const char *filename)
176 {
177 const QCowHeader *cow_header = (const void *)buf;
178
179 if (buf_size >= sizeof(QCowHeader) &&
180 be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
181 be32_to_cpu(cow_header->version) == QCOW_VERSION)
182 return 100;
183 else
184 return 0;
185 }
186
187 static int qcow_open(BlockDriverState *bs, const char *filename, int flags)
188 {
189 BDRVQcowState *s = bs->opaque;
190 int len, i, shift, ret;
191 QCowHeader header;
192
193 ret = bdrv_file_open(&s->hd, filename, flags);
194 if (ret < 0)
195 return ret;
196 if (bdrv_pread(s->hd, 0, &header, sizeof(header)) != sizeof(header))
197 goto fail;
198 be32_to_cpus(&header.magic);
199 be32_to_cpus(&header.version);
200 be64_to_cpus(&header.backing_file_offset);
201 be32_to_cpus(&header.backing_file_size);
202 be64_to_cpus(&header.size);
203 be32_to_cpus(&header.cluster_bits);
204 be32_to_cpus(&header.crypt_method);
205 be64_to_cpus(&header.l1_table_offset);
206 be32_to_cpus(&header.l1_size);
207 be64_to_cpus(&header.refcount_table_offset);
208 be32_to_cpus(&header.refcount_table_clusters);
209 be64_to_cpus(&header.snapshots_offset);
210 be32_to_cpus(&header.nb_snapshots);
211
212 if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION)
213 goto fail;
214 if (header.size <= 1 ||
215 header.cluster_bits < 9 ||
216 header.cluster_bits > 16)
217 goto fail;
218 if (header.crypt_method > QCOW_CRYPT_AES)
219 goto fail;
220 s->crypt_method_header = header.crypt_method;
221 if (s->crypt_method_header)
222 bs->encrypted = 1;
223 s->cluster_bits = header.cluster_bits;
224 s->cluster_size = 1 << s->cluster_bits;
225 s->cluster_sectors = 1 << (s->cluster_bits - 9);
226 s->l2_bits = s->cluster_bits - 3; /* L2 is always one cluster */
227 s->l2_size = 1 << s->l2_bits;
228 bs->total_sectors = header.size / 512;
229 s->csize_shift = (62 - (s->cluster_bits - 8));
230 s->csize_mask = (1 << (s->cluster_bits - 8)) - 1;
231 s->cluster_offset_mask = (1LL << s->csize_shift) - 1;
232 s->refcount_table_offset = header.refcount_table_offset;
233 s->refcount_table_size =
234 header.refcount_table_clusters << (s->cluster_bits - 3);
235
236 s->snapshots_offset = header.snapshots_offset;
237 s->nb_snapshots = header.nb_snapshots;
238
239 /* read the level 1 table */
240 s->l1_size = header.l1_size;
241 shift = s->cluster_bits + s->l2_bits;
242 s->l1_vm_state_index = (header.size + (1LL << shift) - 1) >> shift;
243 /* the L1 table must contain at least enough entries to put
244 header.size bytes */
245 if (s->l1_size < s->l1_vm_state_index)
246 goto fail;
247 s->l1_table_offset = header.l1_table_offset;
248 s->l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
249 if (!s->l1_table)
250 goto fail;
251 if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)) !=
252 s->l1_size * sizeof(uint64_t))
253 goto fail;
254 for(i = 0;i < s->l1_size; i++) {
255 be64_to_cpus(&s->l1_table[i]);
256 }
257 /* alloc L2 cache */
258 s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
259 if (!s->l2_cache)
260 goto fail;
261 s->cluster_cache = qemu_malloc(s->cluster_size);
262 if (!s->cluster_cache)
263 goto fail;
264 /* one more sector for decompressed data alignment */
265 s->cluster_data = qemu_malloc(s->cluster_size + 512);
266 if (!s->cluster_data)
267 goto fail;
268 s->cluster_cache_offset = -1;
269
270 if (refcount_init(bs) < 0)
271 goto fail;
272
273 /* read the backing file name */
274 if (header.backing_file_offset != 0) {
275 len = header.backing_file_size;
276 if (len > 1023)
277 len = 1023;
278 if (bdrv_pread(s->hd, header.backing_file_offset, bs->backing_file, len) != len)
279 goto fail;
280 bs->backing_file[len] = '\0';
281 }
282 if (qcow_read_snapshots(bs) < 0)
283 goto fail;
284
285 #ifdef DEBUG_ALLOC
286 check_refcounts(bs);
287 #endif
288 return 0;
289
290 fail:
291 qcow_free_snapshots(bs);
292 refcount_close(bs);
293 qemu_free(s->l1_table);
294 qemu_free(s->l2_cache);
295 qemu_free(s->cluster_cache);
296 qemu_free(s->cluster_data);
297 bdrv_delete(s->hd);
298 return -1;
299 }
300
301 static int qcow_set_key(BlockDriverState *bs, const char *key)
302 {
303 BDRVQcowState *s = bs->opaque;
304 uint8_t keybuf[16];
305 int len, i;
306
307 memset(keybuf, 0, 16);
308 len = strlen(key);
309 if (len > 16)
310 len = 16;
311 /* XXX: we could compress the chars to 7 bits to increase
312 entropy */
313 for(i = 0;i < len;i++) {
314 keybuf[i] = key[i];
315 }
316 s->crypt_method = s->crypt_method_header;
317
318 if (AES_set_encrypt_key(keybuf, 128, &s->aes_encrypt_key) != 0)
319 return -1;
320 if (AES_set_decrypt_key(keybuf, 128, &s->aes_decrypt_key) != 0)
321 return -1;
322 #if 0
323 /* test */
324 {
325 uint8_t in[16];
326 uint8_t out[16];
327 uint8_t tmp[16];
328 for(i=0;i<16;i++)
329 in[i] = i;
330 AES_encrypt(in, tmp, &s->aes_encrypt_key);
331 AES_decrypt(tmp, out, &s->aes_decrypt_key);
332 for(i = 0; i < 16; i++)
333 printf(" %02x", tmp[i]);
334 printf("\n");
335 for(i = 0; i < 16; i++)
336 printf(" %02x", out[i]);
337 printf("\n");
338 }
339 #endif
340 return 0;
341 }
342
343 /* The crypt function is compatible with the linux cryptoloop
344 algorithm for < 4 GB images. NOTE: out_buf == in_buf is
345 supported */
346 static void encrypt_sectors(BDRVQcowState *s, int64_t sector_num,
347 uint8_t *out_buf, const uint8_t *in_buf,
348 int nb_sectors, int enc,
349 const AES_KEY *key)
350 {
351 union {
352 uint64_t ll[2];
353 uint8_t b[16];
354 } ivec;
355 int i;
356
357 for(i = 0; i < nb_sectors; i++) {
358 ivec.ll[0] = cpu_to_le64(sector_num);
359 ivec.ll[1] = 0;
360 AES_cbc_encrypt(in_buf, out_buf, 512, key,
361 ivec.b, enc);
362 sector_num++;
363 in_buf += 512;
364 out_buf += 512;
365 }
366 }
367
368 static int copy_sectors(BlockDriverState *bs, uint64_t start_sect,
369 uint64_t cluster_offset, int n_start, int n_end)
370 {
371 BDRVQcowState *s = bs->opaque;
372 int n, ret;
373
374 n = n_end - n_start;
375 if (n <= 0)
376 return 0;
377 ret = qcow_read(bs, start_sect + n_start, s->cluster_data, n);
378 if (ret < 0)
379 return ret;
380 if (s->crypt_method) {
381 encrypt_sectors(s, start_sect + n_start,
382 s->cluster_data,
383 s->cluster_data, n, 1,
384 &s->aes_encrypt_key);
385 }
386 ret = bdrv_write(s->hd, (cluster_offset >> 9) + n_start,
387 s->cluster_data, n);
388 if (ret < 0)
389 return ret;
390 return 0;
391 }
392
393 static void l2_cache_reset(BlockDriverState *bs)
394 {
395 BDRVQcowState *s = bs->opaque;
396
397 memset(s->l2_cache, 0, s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
398 memset(s->l2_cache_offsets, 0, L2_CACHE_SIZE * sizeof(uint64_t));
399 memset(s->l2_cache_counts, 0, L2_CACHE_SIZE * sizeof(uint32_t));
400 }
401
402 static inline int l2_cache_new_entry(BlockDriverState *bs)
403 {
404 BDRVQcowState *s = bs->opaque;
405 uint32_t min_count;
406 int min_index, i;
407
408 /* find a new entry in the least used one */
409 min_index = 0;
410 min_count = 0xffffffff;
411 for(i = 0; i < L2_CACHE_SIZE; i++) {
412 if (s->l2_cache_counts[i] < min_count) {
413 min_count = s->l2_cache_counts[i];
414 min_index = i;
415 }
416 }
417 return min_index;
418 }
419
420 static int64_t align_offset(int64_t offset, int n)
421 {
422 offset = (offset + n - 1) & ~(n - 1);
423 return offset;
424 }
425
426 static int grow_l1_table(BlockDriverState *bs, int min_size)
427 {
428 BDRVQcowState *s = bs->opaque;
429 int new_l1_size, new_l1_size2, ret, i;
430 uint64_t *new_l1_table;
431 uint64_t new_l1_table_offset;
432 uint64_t data64;
433 uint32_t data32;
434
435 new_l1_size = s->l1_size;
436 if (min_size <= new_l1_size)
437 return 0;
438 while (min_size > new_l1_size) {
439 new_l1_size = (new_l1_size * 3 + 1) / 2;
440 }
441 #ifdef DEBUG_ALLOC2
442 printf("grow l1_table from %d to %d\n", s->l1_size, new_l1_size);
443 #endif
444
445 new_l1_size2 = sizeof(uint64_t) * new_l1_size;
446 new_l1_table = qemu_mallocz(new_l1_size2);
447 if (!new_l1_table)
448 return -ENOMEM;
449 memcpy(new_l1_table, s->l1_table, s->l1_size * sizeof(uint64_t));
450
451 /* write new table (align to cluster) */
452 new_l1_table_offset = alloc_clusters(bs, new_l1_size2);
453
454 for(i = 0; i < s->l1_size; i++)
455 new_l1_table[i] = cpu_to_be64(new_l1_table[i]);
456 ret = bdrv_pwrite(s->hd, new_l1_table_offset, new_l1_table, new_l1_size2);
457 if (ret != new_l1_size2)
458 goto fail;
459 for(i = 0; i < s->l1_size; i++)
460 new_l1_table[i] = be64_to_cpu(new_l1_table[i]);
461
462 /* set new table */
463 data64 = cpu_to_be64(new_l1_table_offset);
464 if (bdrv_pwrite(s->hd, offsetof(QCowHeader, l1_table_offset),
465 &data64, sizeof(data64)) != sizeof(data64))
466 goto fail;
467 data32 = cpu_to_be32(new_l1_size);
468 if (bdrv_pwrite(s->hd, offsetof(QCowHeader, l1_size),
469 &data32, sizeof(data32)) != sizeof(data32))
470 goto fail;
471 qemu_free(s->l1_table);
472 free_clusters(bs, s->l1_table_offset, s->l1_size * sizeof(uint64_t));
473 s->l1_table_offset = new_l1_table_offset;
474 s->l1_table = new_l1_table;
475 s->l1_size = new_l1_size;
476 return 0;
477 fail:
478 qemu_free(s->l1_table);
479 return -EIO;
480 }
481
482 /* 'allocate' is:
483 *
484 * 0 not to allocate.
485 *
486 * 1 to allocate a normal cluster (for sector indexes 'n_start' to
487 * 'n_end')
488 *
489 * 2 to allocate a compressed cluster of size
490 * 'compressed_size'. 'compressed_size' must be > 0 and <
491 * cluster_size
492 *
493 * return 0 if not allocated.
494 */
495 static uint64_t get_cluster_offset(BlockDriverState *bs,
496 uint64_t offset, int allocate,
497 int compressed_size,
498 int n_start, int n_end)
499 {
500 BDRVQcowState *s = bs->opaque;
501 int min_index, i, j, l1_index, l2_index, ret;
502 uint64_t l2_offset, *l2_table, cluster_offset, tmp, old_l2_offset;
503
504 l1_index = offset >> (s->l2_bits + s->cluster_bits);
505 if (l1_index >= s->l1_size) {
506 /* outside l1 table is allowed: we grow the table if needed */
507 if (!allocate)
508 return 0;
509 if (grow_l1_table(bs, l1_index + 1) < 0)
510 return 0;
511 }
512 l2_offset = s->l1_table[l1_index];
513 if (!l2_offset) {
514 if (!allocate)
515 return 0;
516 l2_allocate:
517 old_l2_offset = l2_offset;
518 /* allocate a new l2 entry */
519 l2_offset = alloc_clusters(bs, s->l2_size * sizeof(uint64_t));
520 /* update the L1 entry */
521 s->l1_table[l1_index] = l2_offset | QCOW_OFLAG_COPIED;
522 tmp = cpu_to_be64(l2_offset | QCOW_OFLAG_COPIED);
523 if (bdrv_pwrite(s->hd, s->l1_table_offset + l1_index * sizeof(tmp),
524 &tmp, sizeof(tmp)) != sizeof(tmp))
525 return 0;
526 min_index = l2_cache_new_entry(bs);
527 l2_table = s->l2_cache + (min_index << s->l2_bits);
528
529 if (old_l2_offset == 0) {
530 memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
531 } else {
532 if (bdrv_pread(s->hd, old_l2_offset,
533 l2_table, s->l2_size * sizeof(uint64_t)) !=
534 s->l2_size * sizeof(uint64_t))
535 return 0;
536 }
537 if (bdrv_pwrite(s->hd, l2_offset,
538 l2_table, s->l2_size * sizeof(uint64_t)) !=
539 s->l2_size * sizeof(uint64_t))
540 return 0;
541 } else {
542 if (!(l2_offset & QCOW_OFLAG_COPIED)) {
543 if (allocate) {
544 free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t));
545 goto l2_allocate;
546 }
547 } else {
548 l2_offset &= ~QCOW_OFLAG_COPIED;
549 }
550 for(i = 0; i < L2_CACHE_SIZE; i++) {
551 if (l2_offset == s->l2_cache_offsets[i]) {
552 /* increment the hit count */
553 if (++s->l2_cache_counts[i] == 0xffffffff) {
554 for(j = 0; j < L2_CACHE_SIZE; j++) {
555 s->l2_cache_counts[j] >>= 1;
556 }
557 }
558 l2_table = s->l2_cache + (i << s->l2_bits);
559 goto found;
560 }
561 }
562 /* not found: load a new entry in the least used one */
563 min_index = l2_cache_new_entry(bs);
564 l2_table = s->l2_cache + (min_index << s->l2_bits);
565 if (bdrv_pread(s->hd, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)) !=
566 s->l2_size * sizeof(uint64_t))
567 return 0;
568 }
569 s->l2_cache_offsets[min_index] = l2_offset;
570 s->l2_cache_counts[min_index] = 1;
571 found:
572 l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
573 cluster_offset = be64_to_cpu(l2_table[l2_index]);
574 if (!cluster_offset) {
575 if (!allocate)
576 return cluster_offset;
577 } else if (!(cluster_offset & QCOW_OFLAG_COPIED)) {
578 if (!allocate)
579 return cluster_offset;
580 /* free the cluster */
581 if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
582 int nb_csectors;
583 nb_csectors = ((cluster_offset >> s->csize_shift) &
584 s->csize_mask) + 1;
585 free_clusters(bs, (cluster_offset & s->cluster_offset_mask) & ~511,
586 nb_csectors * 512);
587 } else {
588 free_clusters(bs, cluster_offset, s->cluster_size);
589 }
590 } else {
591 cluster_offset &= ~QCOW_OFLAG_COPIED;
592 return cluster_offset;
593 }
594 if (allocate == 1) {
595 /* allocate a new cluster */
596 cluster_offset = alloc_clusters(bs, s->cluster_size);
597
598 /* we must initialize the cluster content which won't be
599 written */
600 if ((n_end - n_start) < s->cluster_sectors) {
601 uint64_t start_sect;
602
603 start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
604 ret = copy_sectors(bs, start_sect,
605 cluster_offset, 0, n_start);
606 if (ret < 0)
607 return 0;
608 ret = copy_sectors(bs, start_sect,
609 cluster_offset, n_end, s->cluster_sectors);
610 if (ret < 0)
611 return 0;
612 }
613 tmp = cpu_to_be64(cluster_offset | QCOW_OFLAG_COPIED);
614 } else {
615 int nb_csectors;
616 cluster_offset = alloc_bytes(bs, compressed_size);
617 nb_csectors = ((cluster_offset + compressed_size - 1) >> 9) -
618 (cluster_offset >> 9);
619 cluster_offset |= QCOW_OFLAG_COMPRESSED |
620 ((uint64_t)nb_csectors << s->csize_shift);
621 /* compressed clusters never have the copied flag */
622 tmp = cpu_to_be64(cluster_offset);
623 }
624 /* update L2 table */
625 l2_table[l2_index] = tmp;
626 if (bdrv_pwrite(s->hd,
627 l2_offset + l2_index * sizeof(tmp), &tmp, sizeof(tmp)) != sizeof(tmp))
628 return 0;
629 return cluster_offset;
630 }
631
632 static int qcow_is_allocated(BlockDriverState *bs, int64_t sector_num,
633 int nb_sectors, int *pnum)
634 {
635 BDRVQcowState *s = bs->opaque;
636 int index_in_cluster, n;
637 uint64_t cluster_offset;
638
639 cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
640 index_in_cluster = sector_num & (s->cluster_sectors - 1);
641 n = s->cluster_sectors - index_in_cluster;
642 if (n > nb_sectors)
643 n = nb_sectors;
644 *pnum = n;
645 return (cluster_offset != 0);
646 }
647
648 static int decompress_buffer(uint8_t *out_buf, int out_buf_size,
649 const uint8_t *buf, int buf_size)
650 {
651 z_stream strm1, *strm = &strm1;
652 int ret, out_len;
653
654 memset(strm, 0, sizeof(*strm));
655
656 strm->next_in = (uint8_t *)buf;
657 strm->avail_in = buf_size;
658 strm->next_out = out_buf;
659 strm->avail_out = out_buf_size;
660
661 ret = inflateInit2(strm, -12);
662 if (ret != Z_OK)
663 return -1;
664 ret = inflate(strm, Z_FINISH);
665 out_len = strm->next_out - out_buf;
666 if ((ret != Z_STREAM_END && ret != Z_BUF_ERROR) ||
667 out_len != out_buf_size) {
668 inflateEnd(strm);
669 return -1;
670 }
671 inflateEnd(strm);
672 return 0;
673 }
674
675 static int decompress_cluster(BDRVQcowState *s, uint64_t cluster_offset)
676 {
677 int ret, csize, nb_csectors, sector_offset;
678 uint64_t coffset;
679
680 coffset = cluster_offset & s->cluster_offset_mask;
681 if (s->cluster_cache_offset != coffset) {
682 nb_csectors = ((cluster_offset >> s->csize_shift) & s->csize_mask) + 1;
683 sector_offset = coffset & 511;
684 csize = nb_csectors * 512 - sector_offset;
685 ret = bdrv_read(s->hd, coffset >> 9, s->cluster_data, nb_csectors);
686 if (ret < 0) {
687 return -1;
688 }
689 if (decompress_buffer(s->cluster_cache, s->cluster_size,
690 s->cluster_data + sector_offset, csize) < 0) {
691 return -1;
692 }
693 s->cluster_cache_offset = coffset;
694 }
695 return 0;
696 }
697
698 /* handle reading after the end of the backing file */
699 static int backing_read1(BlockDriverState *bs,
700 int64_t sector_num, uint8_t *buf, int nb_sectors)
701 {
702 int n1;
703 if ((sector_num + nb_sectors) <= bs->total_sectors)
704 return nb_sectors;
705 if (sector_num >= bs->total_sectors)
706 n1 = 0;
707 else
708 n1 = bs->total_sectors - sector_num;
709 memset(buf + n1 * 512, 0, 512 * (nb_sectors - n1));
710 return n1;
711 }
712
713 static int qcow_read(BlockDriverState *bs, int64_t sector_num,
714 uint8_t *buf, int nb_sectors)
715 {
716 BDRVQcowState *s = bs->opaque;
717 int ret, index_in_cluster, n, n1;
718 uint64_t cluster_offset;
719
720 while (nb_sectors > 0) {
721 cluster_offset = get_cluster_offset(bs, sector_num << 9, 0, 0, 0, 0);
722 index_in_cluster = sector_num & (s->cluster_sectors - 1);
723 n = s->cluster_sectors - index_in_cluster;
724 if (n > nb_sectors)
725 n = nb_sectors;
726 if (!cluster_offset) {
727 if (bs->backing_hd) {
728 /* read from the base image */
729 n1 = backing_read1(bs->backing_hd, sector_num, buf, n);
730 if (n1 > 0) {
731 ret = bdrv_read(bs->backing_hd, sector_num, buf, n1);
732 if (ret < 0)
733 return -1;
734 }
735 } else {
736 memset(buf, 0, 512 * n);
737 }
738 } else if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
739 if (decompress_cluster(s, cluster_offset) < 0)
740 return -1;
741 memcpy(buf, s->cluster_cache + index_in_cluster * 512, 512 * n);
742 } else {
743 ret = bdrv_pread(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512);
744 if (ret != n * 512)
745 return -1;
746 if (s->crypt_method) {
747 encrypt_sectors(s, sector_num, buf, buf, n, 0,
748 &s->aes_decrypt_key);
749 }
750 }
751 nb_sectors -= n;
752 sector_num += n;
753 buf += n * 512;
754 }
755 return 0;
756 }
757
758 static int qcow_write(BlockDriverState *bs, int64_t sector_num,
759 const uint8_t *buf, int nb_sectors)
760 {
761 BDRVQcowState *s = bs->opaque;
762 int ret, index_in_cluster, n;
763 uint64_t cluster_offset;
764
765 while (nb_sectors > 0) {
766 index_in_cluster = sector_num & (s->cluster_sectors - 1);
767 n = s->cluster_sectors - index_in_cluster;
768 if (n > nb_sectors)
769 n = nb_sectors;
770 cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0,
771 index_in_cluster,
772 index_in_cluster + n);
773 if (!cluster_offset)
774 return -1;
775 if (s->crypt_method) {
776 encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1,
777 &s->aes_encrypt_key);
778 ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512,
779 s->cluster_data, n * 512);
780 } else {
781 ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512);
782 }
783 if (ret != n * 512)
784 return -1;
785 nb_sectors -= n;
786 sector_num += n;
787 buf += n * 512;
788 }
789 s->cluster_cache_offset = -1; /* disable compressed cache */
790 return 0;
791 }
792
793 typedef struct QCowAIOCB {
794 BlockDriverAIOCB common;
795 int64_t sector_num;
796 uint8_t *buf;
797 int nb_sectors;
798 int n;
799 uint64_t cluster_offset;
800 uint8_t *cluster_data;
801 BlockDriverAIOCB *hd_aiocb;
802 } QCowAIOCB;
803
804 static void qcow_aio_read_cb(void *opaque, int ret)
805 {
806 QCowAIOCB *acb = opaque;
807 BlockDriverState *bs = acb->common.bs;
808 BDRVQcowState *s = bs->opaque;
809 int index_in_cluster, n1;
810
811 acb->hd_aiocb = NULL;
812 if (ret < 0) {
813 fail:
814 acb->common.cb(acb->common.opaque, ret);
815 qemu_aio_release(acb);
816 return;
817 }
818
819 redo:
820 /* post process the read buffer */
821 if (!acb->cluster_offset) {
822 /* nothing to do */
823 } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) {
824 /* nothing to do */
825 } else {
826 if (s->crypt_method) {
827 encrypt_sectors(s, acb->sector_num, acb->buf, acb->buf,
828 acb->n, 0,
829 &s->aes_decrypt_key);
830 }
831 }
832
833 acb->nb_sectors -= acb->n;
834 acb->sector_num += acb->n;
835 acb->buf += acb->n * 512;
836
837 if (acb->nb_sectors == 0) {
838 /* request completed */
839 acb->common.cb(acb->common.opaque, 0);
840 qemu_aio_release(acb);
841 return;
842 }
843
844 /* prepare next AIO request */
845 acb->cluster_offset = get_cluster_offset(bs, acb->sector_num << 9,
846 0, 0, 0, 0);
847 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
848 acb->n = s->cluster_sectors - index_in_cluster;
849 if (acb->n > acb->nb_sectors)
850 acb->n = acb->nb_sectors;
851
852 if (!acb->cluster_offset) {
853 if (bs->backing_hd) {
854 /* read from the base image */
855 n1 = backing_read1(bs->backing_hd, acb->sector_num,
856 acb->buf, acb->n);
857 if (n1 > 0) {
858 acb->hd_aiocb = bdrv_aio_read(bs->backing_hd, acb->sector_num,
859 acb->buf, acb->n, qcow_aio_read_cb, acb);
860 if (acb->hd_aiocb == NULL)
861 goto fail;
862 } else {
863 goto redo;
864 }
865 } else {
866 /* Note: in this case, no need to wait */
867 memset(acb->buf, 0, 512 * acb->n);
868 goto redo;
869 }
870 } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) {
871 /* add AIO support for compressed blocks ? */
872 if (decompress_cluster(s, acb->cluster_offset) < 0)
873 goto fail;
874 memcpy(acb->buf,
875 s->cluster_cache + index_in_cluster * 512, 512 * acb->n);
876 goto redo;
877 } else {
878 if ((acb->cluster_offset & 511) != 0) {
879 ret = -EIO;
880 goto fail;
881 }
882 acb->hd_aiocb = bdrv_aio_read(s->hd,
883 (acb->cluster_offset >> 9) + index_in_cluster,
884 acb->buf, acb->n, qcow_aio_read_cb, acb);
885 if (acb->hd_aiocb == NULL)
886 goto fail;
887 }
888 }
889
890 static QCowAIOCB *qcow_aio_setup(BlockDriverState *bs,
891 int64_t sector_num, uint8_t *buf, int nb_sectors,
892 BlockDriverCompletionFunc *cb, void *opaque)
893 {
894 QCowAIOCB *acb;
895
896 acb = qemu_aio_get(bs, cb, opaque);
897 if (!acb)
898 return NULL;
899 acb->hd_aiocb = NULL;
900 acb->sector_num = sector_num;
901 acb->buf = buf;
902 acb->nb_sectors = nb_sectors;
903 acb->n = 0;
904 acb->cluster_offset = 0;
905 return acb;
906 }
907
908 static BlockDriverAIOCB *qcow_aio_read(BlockDriverState *bs,
909 int64_t sector_num, uint8_t *buf, int nb_sectors,
910 BlockDriverCompletionFunc *cb, void *opaque)
911 {
912 QCowAIOCB *acb;
913
914 acb = qcow_aio_setup(bs, sector_num, buf, nb_sectors, cb, opaque);
915 if (!acb)
916 return NULL;
917
918 qcow_aio_read_cb(acb, 0);
919 return &acb->common;
920 }
921
922 static void qcow_aio_write_cb(void *opaque, int ret)
923 {
924 QCowAIOCB *acb = opaque;
925 BlockDriverState *bs = acb->common.bs;
926 BDRVQcowState *s = bs->opaque;
927 int index_in_cluster;
928 uint64_t cluster_offset;
929 const uint8_t *src_buf;
930
931 acb->hd_aiocb = NULL;
932
933 if (ret < 0) {
934 fail:
935 acb->common.cb(acb->common.opaque, ret);
936 qemu_aio_release(acb);
937 return;
938 }
939
940 acb->nb_sectors -= acb->n;
941 acb->sector_num += acb->n;
942 acb->buf += acb->n * 512;
943
944 if (acb->nb_sectors == 0) {
945 /* request completed */
946 acb->common.cb(acb->common.opaque, 0);
947 qemu_aio_release(acb);
948 return;
949 }
950
951 index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
952 acb->n = s->cluster_sectors - index_in_cluster;
953 if (acb->n > acb->nb_sectors)
954 acb->n = acb->nb_sectors;
955 cluster_offset = get_cluster_offset(bs, acb->sector_num << 9, 1, 0,
956 index_in_cluster,
957 index_in_cluster + acb->n);
958 if (!cluster_offset || (cluster_offset & 511) != 0) {
959 ret = -EIO;
960 goto fail;
961 }
962 if (s->crypt_method) {
963 if (!acb->cluster_data) {
964 acb->cluster_data = qemu_mallocz(s->cluster_size);
965 if (!acb->cluster_data) {
966 ret = -ENOMEM;
967 goto fail;
968 }
969 }
970 encrypt_sectors(s, acb->sector_num, acb->cluster_data, acb->buf,
971 acb->n, 1, &s->aes_encrypt_key);
972 src_buf = acb->cluster_data;
973 } else {
974 src_buf = acb->buf;
975 }
976 acb->hd_aiocb = bdrv_aio_write(s->hd,
977 (cluster_offset >> 9) + index_in_cluster,
978 src_buf, acb->n,
979 qcow_aio_write_cb, acb);
980 if (acb->hd_aiocb == NULL)
981 goto fail;
982 }
983
984 static BlockDriverAIOCB *qcow_aio_write(BlockDriverState *bs,
985 int64_t sector_num, const uint8_t *buf, int nb_sectors,
986 BlockDriverCompletionFunc *cb, void *opaque)
987 {
988 BDRVQcowState *s = bs->opaque;
989 QCowAIOCB *acb;
990
991 s->cluster_cache_offset = -1; /* disable compressed cache */
992
993 acb = qcow_aio_setup(bs, sector_num, (uint8_t*)buf, nb_sectors, cb, opaque);
994 if (!acb)
995 return NULL;
996
997 qcow_aio_write_cb(acb, 0);
998 return &acb->common;
999 }
1000
1001 static void qcow_aio_cancel(BlockDriverAIOCB *blockacb)
1002 {
1003 QCowAIOCB *acb = (QCowAIOCB *)blockacb;
1004 if (acb->hd_aiocb)
1005 bdrv_aio_cancel(acb->hd_aiocb);
1006 qemu_aio_release(acb);
1007 }
1008
1009 static void qcow_close(BlockDriverState *bs)
1010 {
1011 BDRVQcowState *s = bs->opaque;
1012 qemu_free(s->l1_table);
1013 qemu_free(s->l2_cache);
1014 qemu_free(s->cluster_cache);
1015 qemu_free(s->cluster_data);
1016 refcount_close(bs);
1017 bdrv_delete(s->hd);
1018 }
1019
1020 /* XXX: use std qcow open function ? */
1021 typedef struct QCowCreateState {
1022 int cluster_size;
1023 int cluster_bits;
1024 uint16_t *refcount_block;
1025 uint64_t *refcount_table;
1026 int64_t l1_table_offset;
1027 int64_t refcount_table_offset;
1028 int64_t refcount_block_offset;
1029 } QCowCreateState;
1030
1031 static void create_refcount_update(QCowCreateState *s,
1032 int64_t offset, int64_t size)
1033 {
1034 int refcount;
1035 int64_t start, last, cluster_offset;
1036 uint16_t *p;
1037
1038 start = offset & ~(s->cluster_size - 1);
1039 last = (offset + size - 1) & ~(s->cluster_size - 1);
1040 for(cluster_offset = start; cluster_offset <= last;
1041 cluster_offset += s->cluster_size) {
1042 p = &s->refcount_block[cluster_offset >> s->cluster_bits];
1043 refcount = be16_to_cpu(*p);
1044 refcount++;
1045 *p = cpu_to_be16(refcount);
1046 }
1047 }
1048
1049 static int qcow_create(const char *filename, int64_t total_size,
1050 const char *backing_file, int flags)
1051 {
1052 int fd, header_size, backing_filename_len, l1_size, i, shift, l2_bits;
1053 QCowHeader header;
1054 uint64_t tmp, offset;
1055 QCowCreateState s1, *s = &s1;
1056
1057 memset(s, 0, sizeof(*s));
1058
1059 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
1060 if (fd < 0)
1061 return -1;
1062 memset(&header, 0, sizeof(header));
1063 header.magic = cpu_to_be32(QCOW_MAGIC);
1064 header.version = cpu_to_be32(QCOW_VERSION);
1065 header.size = cpu_to_be64(total_size * 512);
1066 header_size = sizeof(header);
1067 backing_filename_len = 0;
1068 if (backing_file) {
1069 header.backing_file_offset = cpu_to_be64(header_size);
1070 backing_filename_len = strlen(backing_file);
1071 header.backing_file_size = cpu_to_be32(backing_filename_len);
1072 header_size += backing_filename_len;
1073 }
1074 s->cluster_bits = 12; /* 4 KB clusters */
1075 s->cluster_size = 1 << s->cluster_bits;
1076 header.cluster_bits = cpu_to_be32(s->cluster_bits);
1077 header_size = (header_size + 7) & ~7;
1078 if (flags & BLOCK_FLAG_ENCRYPT) {
1079 header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
1080 } else {
1081 header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
1082 }
1083 l2_bits = s->cluster_bits - 3;
1084 shift = s->cluster_bits + l2_bits;
1085 l1_size = (((total_size * 512) + (1LL << shift) - 1) >> shift);
1086 offset = align_offset(header_size, s->cluster_size);
1087 s->l1_table_offset = offset;
1088 header.l1_table_offset = cpu_to_be64(s->l1_table_offset);
1089 header.l1_size = cpu_to_be32(l1_size);
1090 offset += align_offset(l1_size * sizeof(uint64_t), s->cluster_size);
1091
1092 s->refcount_table = qemu_mallocz(s->cluster_size);
1093 if (!s->refcount_table)
1094 goto fail;
1095 s->refcount_block = qemu_mallocz(s->cluster_size);
1096 if (!s->refcount_block)
1097 goto fail;
1098
1099 s->refcount_table_offset = offset;
1100 header.refcount_table_offset = cpu_to_be64(offset);
1101 header.refcount_table_clusters = cpu_to_be32(1);
1102 offset += s->cluster_size;
1103
1104 s->refcount_table[0] = cpu_to_be64(offset);
1105 s->refcount_block_offset = offset;
1106 offset += s->cluster_size;
1107
1108 /* update refcounts */
1109 create_refcount_update(s, 0, header_size);
1110 create_refcount_update(s, s->l1_table_offset, l1_size * sizeof(uint64_t));
1111 create_refcount_update(s, s->refcount_table_offset, s->cluster_size);
1112 create_refcount_update(s, s->refcount_block_offset, s->cluster_size);
1113
1114 /* write all the data */
1115 if(write(fd, &header, sizeof(header))!=sizeof(header)) return -1;
1116 if (backing_file) {
1117 if(write(fd, backing_file, backing_filename_len)!=backing_filename_len) return -1;
1118 }
1119 lseek(fd, s->l1_table_offset, SEEK_SET);
1120 tmp = 0;
1121 for(i = 0;i < l1_size; i++) {
1122 if(write(fd, &tmp, sizeof(tmp))!=sizeof(tmp)) return -1;
1123 }
1124 lseek(fd, s->refcount_table_offset, SEEK_SET);
1125 if(write(fd, s->refcount_table, s->cluster_size)!=s->cluster_size) return -1;
1126
1127 lseek(fd, s->refcount_block_offset, SEEK_SET);
1128 if(write(fd, s->refcount_block, s->cluster_size)!=s->cluster_size) return -1;
1129
1130 qemu_free(s->refcount_table);
1131 qemu_free(s->refcount_block);
1132 close(fd);
1133 return 0;
1134 fail:
1135 qemu_free(s->refcount_table);
1136 qemu_free(s->refcount_block);
1137 close(fd);
1138 return -ENOMEM;
1139 }
1140
1141 static int qcow_make_empty(BlockDriverState *bs)
1142 {
1143 #if 0
1144 /* XXX: not correct */
1145 BDRVQcowState *s = bs->opaque;
1146 uint32_t l1_length = s->l1_size * sizeof(uint64_t);
1147 int ret;
1148
1149 memset(s->l1_table, 0, l1_length);
1150 if (bdrv_pwrite(s->hd, s->l1_table_offset, s->l1_table, l1_length) < 0)
1151 return -1;
1152 ret = bdrv_truncate(s->hd, s->l1_table_offset + l1_length);
1153 if (ret < 0)
1154 return ret;
1155
1156 l2_cache_reset(bs);
1157 #endif
1158 return 0;
1159 }
1160
1161 /* XXX: put compressed sectors first, then all the cluster aligned
1162 tables to avoid losing bytes in alignment */
1163 static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,
1164 const uint8_t *buf, int nb_sectors)
1165 {
1166 BDRVQcowState *s = bs->opaque;
1167 z_stream strm;
1168 int ret, out_len;
1169 uint8_t *out_buf;
1170 uint64_t cluster_offset;
1171
1172 if (nb_sectors == 0) {
1173 /* align end of file to a sector boundary to ease reading with
1174 sector based I/Os */
1175 cluster_offset = bdrv_getlength(s->hd);
1176 cluster_offset = (cluster_offset + 511) & ~511;
1177 bdrv_truncate(s->hd, cluster_offset);
1178 return 0;
1179 }
1180
1181 if (nb_sectors != s->cluster_sectors)
1182 return -EINVAL;
1183
1184 out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);
1185 if (!out_buf)
1186 return -ENOMEM;
1187
1188 /* best compression, small window, no zlib header */
1189 memset(&strm, 0, sizeof(strm));
1190 ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION,
1191 Z_DEFLATED, -12,
1192 9, Z_DEFAULT_STRATEGY);
1193 if (ret != 0) {
1194 qemu_free(out_buf);
1195 return -1;
1196 }
1197
1198 strm.avail_in = s->cluster_size;
1199 strm.next_in = (uint8_t *)buf;
1200 strm.avail_out = s->cluster_size;
1201 strm.next_out = out_buf;
1202
1203 ret = deflate(&strm, Z_FINISH);
1204 if (ret != Z_STREAM_END && ret != Z_OK) {
1205 qemu_free(out_buf);
1206 deflateEnd(&strm);
1207 return -1;
1208 }
1209 out_len = strm.next_out - out_buf;
1210
1211 deflateEnd(&strm);
1212
1213 if (ret != Z_STREAM_END || out_len >= s->cluster_size) {
1214 /* could not compress: write normal cluster */
1215 qcow_write(bs, sector_num, buf, s->cluster_sectors);
1216 } else {
1217 cluster_offset = get_cluster_offset(bs, sector_num << 9, 2,
1218 out_len, 0, 0);
1219 cluster_offset &= s->cluster_offset_mask;
1220 if (bdrv_pwrite(s->hd, cluster_offset, out_buf, out_len) != out_len) {
1221 qemu_free(out_buf);
1222 return -1;
1223 }
1224 }
1225
1226 qemu_free(out_buf);
1227 return 0;
1228 }
1229
1230 static void qcow_flush(BlockDriverState *bs)
1231 {
1232 BDRVQcowState *s = bs->opaque;
1233 bdrv_flush(s->hd);
1234 }
1235
1236 static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
1237 {
1238 BDRVQcowState *s = bs->opaque;
1239 bdi->cluster_size = s->cluster_size;
1240 bdi->vm_state_offset = (int64_t)s->l1_vm_state_index <<
1241 (s->cluster_bits + s->l2_bits);
1242 return 0;
1243 }
1244
1245 /*********************************************************/
1246 /* snapshot support */
1247
1248 /* update the refcounts of snapshots and the copied flag */
1249 static int update_snapshot_refcount(BlockDriverState *bs,
1250 int64_t l1_table_offset,
1251 int l1_size,
1252 int addend)
1253 {
1254 BDRVQcowState *s = bs->opaque;
1255 uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2, l1_allocated;
1256 int64_t old_offset, old_l2_offset;
1257 int l2_size, i, j, l1_modified, l2_modified, nb_csectors, refcount;
1258
1259 l2_cache_reset(bs);
1260
1261 l2_table = NULL;
1262 l1_table = NULL;
1263 l1_size2 = l1_size * sizeof(uint64_t);
1264 l1_allocated = 0;
1265 if (l1_table_offset != s->l1_table_offset) {
1266 l1_table = qemu_malloc(l1_size2);
1267 if (!l1_table)
1268 goto fail;
1269 l1_allocated = 1;
1270 if (bdrv_pread(s->hd, l1_table_offset,
1271 l1_table, l1_size2) != l1_size2)
1272 goto fail;
1273 for(i = 0;i < l1_size; i++)
1274 be64_to_cpus(&l1_table[i]);
1275 } else {
1276 assert(l1_size == s->l1_size);
1277 l1_table = s->l1_table;
1278 l1_allocated = 0;
1279 }
1280
1281 l2_size = s->l2_size * sizeof(uint64_t);
1282 l2_table = qemu_malloc(l2_size);
1283 if (!l2_table)
1284 goto fail;
1285 l1_modified = 0;
1286 for(i = 0; i < l1_size; i++) {
1287 l2_offset = l1_table[i];
1288 if (l2_offset) {
1289 old_l2_offset = l2_offset;
1290 l2_offset &= ~QCOW_OFLAG_COPIED;
1291 l2_modified = 0;
1292 if (bdrv_pread(s->hd, l2_offset, l2_table, l2_size) != l2_size)
1293 goto fail;
1294 for(j = 0; j < s->l2_size; j++) {
1295 offset = be64_to_cpu(l2_table[j]);
1296 if (offset != 0) {
1297 old_offset = offset;
1298 offset &= ~QCOW_OFLAG_COPIED;
1299 if (offset & QCOW_OFLAG_COMPRESSED) {
1300 nb_csectors = ((offset >> s->csize_shift) &
1301 s->csize_mask) + 1;
1302 if (addend != 0)
1303 update_refcount(bs, (offset & s->cluster_offset_mask) & ~511,
1304 nb_csectors * 512, addend);
1305 /* compressed clusters are never modified */
1306 refcount = 2;
1307 } else {
1308 if (addend != 0) {
1309 refcount = update_cluster_refcount(bs, offset >> s->cluster_bits, addend);
1310 } else {
1311 refcount = get_refcount(bs, offset >> s->cluster_bits);
1312 }
1313 }
1314
1315 if (refcount == 1) {
1316 offset |= QCOW_OFLAG_COPIED;
1317 }
1318 if (offset != old_offset) {
1319 l2_table[j] = cpu_to_be64(offset);
1320 l2_modified = 1;
1321 }
1322 }
1323 }
1324 if (l2_modified) {
1325 if (bdrv_pwrite(s->hd,
1326 l2_offset, l2_table, l2_size) != l2_size)
1327 goto fail;
1328 }
1329
1330 if (addend != 0) {
1331 refcount = update_cluster_refcount(bs, l2_offset >> s->cluster_bits, addend);
1332 } else {
1333 refcount = get_refcount(bs, l2_offset >> s->cluster_bits);
1334 }
1335 if (refcount == 1) {
1336 l2_offset |= QCOW_OFLAG_COPIED;
1337 }
1338 if (l2_offset != old_l2_offset) {
1339 l1_table[i] = l2_offset;
1340 l1_modified = 1;
1341 }
1342 }
1343 }
1344 if (l1_modified) {
1345 for(i = 0; i < l1_size; i++)
1346 cpu_to_be64s(&l1_table[i]);
1347 if (bdrv_pwrite(s->hd, l1_table_offset, l1_table,
1348 l1_size2) != l1_size2)
1349 goto fail;
1350 for(i = 0; i < l1_size; i++)
1351 be64_to_cpus(&l1_table[i]);
1352 }
1353 if (l1_allocated)
1354 qemu_free(l1_table);
1355 qemu_free(l2_table);
1356 return 0;
1357 fail:
1358 if (l1_allocated)
1359 qemu_free(l1_table);
1360 qemu_free(l2_table);
1361 return -EIO;
1362 }
1363
1364 static void qcow_free_snapshots(BlockDriverState *bs)
1365 {
1366 BDRVQcowState *s = bs->opaque;
1367 int i;
1368
1369 for(i = 0; i < s->nb_snapshots; i++) {
1370 qemu_free(s->snapshots[i].name);
1371 qemu_free(s->snapshots[i].id_str);
1372 }
1373 qemu_free(s->snapshots);
1374 s->snapshots = NULL;
1375 s->nb_snapshots = 0;
1376 }
1377
1378 static int qcow_read_snapshots(BlockDriverState *bs)
1379 {
1380 BDRVQcowState *s = bs->opaque;
1381 QCowSnapshotHeader h;
1382 QCowSnapshot *sn;
1383 int i, id_str_size, name_size;
1384 int64_t offset;
1385 uint32_t extra_data_size;
1386
1387 offset = s->snapshots_offset;
1388 s->snapshots = qemu_mallocz(s->nb_snapshots * sizeof(QCowSnapshot));
1389 if (!s->snapshots)
1390 goto fail;
1391 for(i = 0; i < s->nb_snapshots; i++) {
1392 offset = align_offset(offset, 8);
1393 if (bdrv_pread(s->hd, offset, &h, sizeof(h)) != sizeof(h))
1394 goto fail;
1395 offset += sizeof(h);
1396 sn = s->snapshots + i;
1397 sn->l1_table_offset = be64_to_cpu(h.l1_table_offset);
1398 sn->l1_size = be32_to_cpu(h.l1_size);
1399 sn->vm_state_size = be32_to_cpu(h.vm_state_size);
1400 sn->date_sec = be32_to_cpu(h.date_sec);
1401 sn->date_nsec = be32_to_cpu(h.date_nsec);
1402 sn->vm_clock_nsec = be64_to_cpu(h.vm_clock_nsec);
1403 extra_data_size = be32_to_cpu(h.extra_data_size);
1404
1405 id_str_size = be16_to_cpu(h.id_str_size);
1406 name_size = be16_to_cpu(h.name_size);
1407
1408 offset += extra_data_size;
1409
1410 sn->id_str = qemu_malloc(id_str_size + 1);
1411 if (!sn->id_str)
1412 goto fail;
1413 if (bdrv_pread(s->hd, offset, sn->id_str, id_str_size) != id_str_size)
1414 goto fail;
1415 offset += id_str_size;
1416 sn->id_str[id_str_size] = '\0';
1417
1418 sn->name = qemu_malloc(name_size + 1);
1419 if (!sn->name)
1420 goto fail;
1421 if (bdrv_pread(s->hd, offset, sn->name, name_size) != name_size)
1422 goto fail;
1423 offset += name_size;
1424 sn->name[name_size] = '\0';
1425 }
1426 s->snapshots_size = offset - s->snapshots_offset;
1427 return 0;
1428 fail:
1429 qcow_free_snapshots(bs);
1430 return -1;
1431 }
1432
1433 /* add at the end of the file a new list of snapshots */
1434 static int qcow_write_snapshots(BlockDriverState *bs)
1435 {
1436 BDRVQcowState *s = bs->opaque;
1437 QCowSnapshot *sn;
1438 QCowSnapshotHeader h;
1439 int i, name_size, id_str_size, snapshots_size;
1440 uint64_t data64;
1441 uint32_t data32;
1442 int64_t offset, snapshots_offset;
1443
1444 /* compute the size of the snapshots */
1445 offset = 0;
1446 for(i = 0; i < s->nb_snapshots; i++) {
1447 sn = s->snapshots + i;
1448 offset = align_offset(offset, 8);
1449 offset += sizeof(h);
1450 offset += strlen(sn->id_str);
1451 offset += strlen(sn->name);
1452 }
1453 snapshots_size = offset;
1454
1455 snapshots_offset = alloc_clusters(bs, snapshots_size);
1456 offset = snapshots_offset;
1457
1458 for(i = 0; i < s->nb_snapshots; i++) {
1459 sn = s->snapshots + i;
1460 memset(&h, 0, sizeof(h));
1461 h.l1_table_offset = cpu_to_be64(sn->l1_table_offset);
1462 h.l1_size = cpu_to_be32(sn->l1_size);
1463 h.vm_state_size = cpu_to_be32(sn->vm_state_size);
1464 h.date_sec = cpu_to_be32(sn->date_sec);
1465 h.date_nsec = cpu_to_be32(sn->date_nsec);
1466 h.vm_clock_nsec = cpu_to_be64(sn->vm_clock_nsec);
1467
1468 id_str_size = strlen(sn->id_str);
1469 name_size = strlen(sn->name);
1470 h.id_str_size = cpu_to_be16(id_str_size);
1471 h.name_size = cpu_to_be16(name_size);
1472 offset = align_offset(offset, 8);
1473 if (bdrv_pwrite(s->hd, offset, &h, sizeof(h)) != sizeof(h))
1474 goto fail;
1475 offset += sizeof(h);
1476 if (bdrv_pwrite(s->hd, offset, sn->id_str, id_str_size) != id_str_size)
1477 goto fail;
1478 offset += id_str_size;
1479 if (bdrv_pwrite(s->hd, offset, sn->name, name_size) != name_size)
1480 goto fail;
1481 offset += name_size;
1482 }
1483
1484 /* update the various header fields */
1485 data64 = cpu_to_be64(snapshots_offset);
1486 if (bdrv_pwrite(s->hd, offsetof(QCowHeader, snapshots_offset),
1487 &data64, sizeof(data64)) != sizeof(data64))
1488 goto fail;
1489 data32 = cpu_to_be32(s->nb_snapshots);
1490 if (bdrv_pwrite(s->hd, offsetof(QCowHeader, nb_snapshots),
1491 &data32, sizeof(data32)) != sizeof(data32))
1492 goto fail;
1493
1494 /* free the old snapshot table */
1495 free_clusters(bs, s->snapshots_offset, s->snapshots_size);
1496 s->snapshots_offset = snapshots_offset;
1497 s->snapshots_size = snapshots_size;
1498 return 0;
1499 fail:
1500 return -1;
1501 }
1502
1503 static void find_new_snapshot_id(BlockDriverState *bs,
1504 char *id_str, int id_str_size)
1505 {
1506 BDRVQcowState *s = bs->opaque;
1507 QCowSnapshot *sn;
1508 int i, id, id_max = 0;
1509
1510 for(i = 0; i < s->nb_snapshots; i++) {
1511 sn = s->snapshots + i;
1512 id = strtoul(sn->id_str, NULL, 10);
1513 if (id > id_max)
1514 id_max = id;
1515 }
1516 snprintf(id_str, id_str_size, "%d", id_max + 1);
1517 }
1518
1519 static int find_snapshot_by_id(BlockDriverState *bs, const char *id_str)
1520 {
1521 BDRVQcowState *s = bs->opaque;
1522 int i;
1523
1524 for(i = 0; i < s->nb_snapshots; i++) {
1525 if (!strcmp(s->snapshots[i].id_str, id_str))
1526 return i;
1527 }
1528 return -1;
1529 }
1530
1531 static int find_snapshot_by_id_or_name(BlockDriverState *bs, const char *name)
1532 {
1533 BDRVQcowState *s = bs->opaque;
1534 int i, ret;
1535
1536 ret = find_snapshot_by_id(bs, name);
1537 if (ret >= 0)
1538 return ret;
1539 for(i = 0; i < s->nb_snapshots; i++) {
1540 if (!strcmp(s->snapshots[i].name, name))
1541 return i;
1542 }
1543 return -1;
1544 }
1545
1546 /* if no id is provided, a new one is constructed */
1547 static int qcow_snapshot_create(BlockDriverState *bs,
1548 QEMUSnapshotInfo *sn_info)
1549 {
1550 BDRVQcowState *s = bs->opaque;
1551 QCowSnapshot *snapshots1, sn1, *sn = &sn1;
1552 int i, ret;
1553 uint64_t *l1_table = NULL;
1554
1555 memset(sn, 0, sizeof(*sn));
1556
1557 if (sn_info->id_str[0] == '\0') {
1558 /* compute a new id */
1559 find_new_snapshot_id(bs, sn_info->id_str, sizeof(sn_info->id_str));
1560 }
1561
1562 /* check that the ID is unique */
1563 if (find_snapshot_by_id(bs, sn_info->id_str) >= 0)
1564 return -ENOENT;
1565
1566 sn->id_str = qemu_strdup(sn_info->id_str);
1567 if (!sn->id_str)
1568 goto fail;
1569 sn->name = qemu_strdup(sn_info->name);
1570 if (!sn->name)
1571 goto fail;
1572 sn->vm_state_size = sn_info->vm_state_size;
1573 sn->date_sec = sn_info->date_sec;
1574 sn->date_nsec = sn_info->date_nsec;
1575 sn->vm_clock_nsec = sn_info->vm_clock_nsec;
1576
1577 ret = update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1);
1578 if (ret < 0)
1579 goto fail;
1580
1581 /* create the L1 table of the snapshot */
1582 sn->l1_table_offset = alloc_clusters(bs, s->l1_size * sizeof(uint64_t));
1583 sn->l1_size = s->l1_size;
1584
1585 l1_table = qemu_malloc(s->l1_size * sizeof(uint64_t));
1586 if (!l1_table)
1587 goto fail;
1588 for(i = 0; i < s->l1_size; i++) {
1589 l1_table[i] = cpu_to_be64(s->l1_table[i]);
1590 }
1591 if (bdrv_pwrite(s->hd, sn->l1_table_offset,
1592 l1_table, s->l1_size * sizeof(uint64_t)) !=
1593 (s->l1_size * sizeof(uint64_t)))
1594 goto fail;
1595 qemu_free(l1_table);
1596 l1_table = NULL;
1597
1598 snapshots1 = qemu_malloc((s->nb_snapshots + 1) * sizeof(QCowSnapshot));
1599 if (!snapshots1)
1600 goto fail;
1601 memcpy(snapshots1, s->snapshots, s->nb_snapshots * sizeof(QCowSnapshot));
1602 s->snapshots = snapshots1;
1603 s->snapshots[s->nb_snapshots++] = *sn;
1604
1605 if (qcow_write_snapshots(bs) < 0)
1606 goto fail;
1607 #ifdef DEBUG_ALLOC
1608 check_refcounts(bs);
1609 #endif
1610 return 0;
1611 fail:
1612 qemu_free(sn->name);
1613 qemu_free(l1_table);
1614 return -1;
1615 }
1616
1617 /* copy the snapshot 'snapshot_name' into the current disk image */
1618 static int qcow_snapshot_goto(BlockDriverState *bs,
1619 const char *snapshot_id)
1620 {
1621 BDRVQcowState *s = bs->opaque;
1622 QCowSnapshot *sn;
1623 int i, snapshot_index, l1_size2;
1624
1625 snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
1626 if (snapshot_index < 0)
1627 return -ENOENT;
1628 sn = &s->snapshots[snapshot_index];
1629
1630 if (update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, -1) < 0)
1631 goto fail;
1632
1633 if (grow_l1_table(bs, sn->l1_size) < 0)
1634 goto fail;
1635
1636 s->l1_size = sn->l1_size;
1637 l1_size2 = s->l1_size * sizeof(uint64_t);
1638 /* copy the snapshot l1 table to the current l1 table */
1639 if (bdrv_pread(s->hd, sn->l1_table_offset,
1640 s->l1_table, l1_size2) != l1_size2)
1641 goto fail;
1642 if (bdrv_pwrite(s->hd, s->l1_table_offset,
1643 s->l1_table, l1_size2) != l1_size2)
1644 goto fail;
1645 for(i = 0;i < s->l1_size; i++) {
1646 be64_to_cpus(&s->l1_table[i]);
1647 }
1648
1649 if (update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 1) < 0)
1650 goto fail;
1651
1652 #ifdef DEBUG_ALLOC
1653 check_refcounts(bs);
1654 #endif
1655 return 0;
1656 fail:
1657 return -EIO;
1658 }
1659
1660 static int qcow_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
1661 {
1662 BDRVQcowState *s = bs->opaque;
1663 QCowSnapshot *sn;
1664 int snapshot_index, ret;
1665
1666 snapshot_index = find_snapshot_by_id_or_name(bs, snapshot_id);
1667 if (snapshot_index < 0)
1668 return -ENOENT;
1669 sn = &s->snapshots[snapshot_index];
1670
1671 ret = update_snapshot_refcount(bs, sn->l1_table_offset, sn->l1_size, -1);
1672 if (ret < 0)
1673 return ret;
1674 /* must update the copied flag on the current cluster offsets */
1675 ret = update_snapshot_refcount(bs, s->l1_table_offset, s->l1_size, 0);
1676 if (ret < 0)
1677 return ret;
1678 free_clusters(bs, sn->l1_table_offset, sn->l1_size * sizeof(uint64_t));
1679
1680 qemu_free(sn->id_str);
1681 qemu_free(sn->name);
1682 memmove(sn, sn + 1, (s->nb_snapshots - snapshot_index - 1) * sizeof(*sn));
1683 s->nb_snapshots--;
1684 ret = qcow_write_snapshots(bs);
1685 if (ret < 0) {
1686 /* XXX: restore snapshot if error ? */
1687 return ret;
1688 }
1689 #ifdef DEBUG_ALLOC
1690 check_refcounts(bs);
1691 #endif
1692 return 0;
1693 }
1694
1695 static int qcow_snapshot_list(BlockDriverState *bs,
1696 QEMUSnapshotInfo **psn_tab)
1697 {
1698 BDRVQcowState *s = bs->opaque;
1699 QEMUSnapshotInfo *sn_tab, *sn_info;
1700 QCowSnapshot *sn;
1701 int i;
1702
1703 sn_tab = qemu_mallocz(s->nb_snapshots * sizeof(QEMUSnapshotInfo));
1704 if (!sn_tab)
1705 goto fail;
1706 for(i = 0; i < s->nb_snapshots; i++) {
1707 sn_info = sn_tab + i;
1708 sn = s->snapshots + i;
1709 pstrcpy(sn_info->id_str, sizeof(sn_info->id_str),
1710 sn->id_str);
1711 pstrcpy(sn_info->name, sizeof(sn_info->name),
1712 sn->name);
1713 sn_info->vm_state_size = sn->vm_state_size;
1714 sn_info->date_sec = sn->date_sec;
1715 sn_info->date_nsec = sn->date_nsec;
1716 sn_info->vm_clock_nsec = sn->vm_clock_nsec;
1717 }
1718 *psn_tab = sn_tab;
1719 return s->nb_snapshots;
1720 fail:
1721 qemu_free(sn_tab);
1722 *psn_tab = NULL;
1723 return -ENOMEM;
1724 }
1725
1726 /*********************************************************/
1727 /* refcount handling */
1728
1729 static int refcount_init(BlockDriverState *bs)
1730 {
1731 BDRVQcowState *s = bs->opaque;
1732 int ret, refcount_table_size2, i;
1733
1734 s->refcount_block_cache = qemu_malloc(s->cluster_size);
1735 if (!s->refcount_block_cache)
1736 goto fail;
1737 refcount_table_size2 = s->refcount_table_size * sizeof(uint64_t);
1738 s->refcount_table = qemu_malloc(refcount_table_size2);
1739 if (!s->refcount_table)
1740 goto fail;
1741 if (s->refcount_table_size > 0) {
1742 ret = bdrv_pread(s->hd, s->refcount_table_offset,
1743 s->refcount_table, refcount_table_size2);
1744 if (ret != refcount_table_size2)
1745 goto fail;
1746 for(i = 0; i < s->refcount_table_size; i++)
1747 be64_to_cpus(&s->refcount_table[i]);
1748 }
1749 return 0;
1750 fail:
1751 return -ENOMEM;
1752 }
1753
1754 static void refcount_close(BlockDriverState *bs)
1755 {
1756 BDRVQcowState *s = bs->opaque;
1757 qemu_free(s->refcount_block_cache);
1758 qemu_free(s->refcount_table);
1759 }
1760
1761
1762 static int load_refcount_block(BlockDriverState *bs,
1763 int64_t refcount_block_offset)
1764 {
1765 BDRVQcowState *s = bs->opaque;
1766 int ret;
1767 ret = bdrv_pread(s->hd, refcount_block_offset, s->refcount_block_cache,
1768 s->cluster_size);
1769 if (ret != s->cluster_size)
1770 return -EIO;
1771 s->refcount_block_cache_offset = refcount_block_offset;
1772 return 0;
1773 }
1774
1775 static int get_refcount(BlockDriverState *bs, int64_t cluster_index)
1776 {
1777 BDRVQcowState *s = bs->opaque;
1778 int refcount_table_index, block_index;
1779 int64_t refcount_block_offset;
1780
1781 refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
1782 if (refcount_table_index >= s->refcount_table_size)
1783 return 0;
1784 refcount_block_offset = s->refcount_table[refcount_table_index];
1785 if (!refcount_block_offset)
1786 return 0;
1787 if (refcount_block_offset != s->refcount_block_cache_offset) {
1788 /* better than nothing: return allocated if read error */
1789 if (load_refcount_block(bs, refcount_block_offset) < 0)
1790 return 1;
1791 }
1792 block_index = cluster_index &
1793 ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
1794 return be16_to_cpu(s->refcount_block_cache[block_index]);
1795 }
1796
1797 /* return < 0 if error */
1798 static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size)
1799 {
1800 BDRVQcowState *s = bs->opaque;
1801 int i, nb_clusters;
1802
1803 nb_clusters = (size + s->cluster_size - 1) >> s->cluster_bits;
1804 for(;;) {
1805 if (get_refcount(bs, s->free_cluster_index) == 0) {
1806 s->free_cluster_index++;
1807 for(i = 1; i < nb_clusters; i++) {
1808 if (get_refcount(bs, s->free_cluster_index) != 0)
1809 goto not_found;
1810 s->free_cluster_index++;
1811 }
1812 #ifdef DEBUG_ALLOC2
1813 printf("alloc_clusters: size=%lld -> %lld\n",
1814 size,
1815 (s->free_cluster_index - nb_clusters) << s->cluster_bits);
1816 #endif
1817 return (s->free_cluster_index - nb_clusters) << s->cluster_bits;
1818 } else {
1819 not_found:
1820 s->free_cluster_index++;
1821 }
1822 }
1823 }
1824
1825 static int64_t alloc_clusters(BlockDriverState *bs, int64_t size)
1826 {
1827 int64_t offset;
1828
1829 offset = alloc_clusters_noref(bs, size);
1830 update_refcount(bs, offset, size, 1);
1831 return offset;
1832 }
1833
1834 /* only used to allocate compressed sectors. We try to allocate
1835 contiguous sectors. size must be <= cluster_size */
1836 static int64_t alloc_bytes(BlockDriverState *bs, int size)
1837 {
1838 BDRVQcowState *s = bs->opaque;
1839 int64_t offset, cluster_offset;
1840 int free_in_cluster;
1841
1842 assert(size > 0 && size <= s->cluster_size);
1843 if (s->free_byte_offset == 0) {
1844 s->free_byte_offset = alloc_clusters(bs, s->cluster_size);
1845 }
1846 redo:
1847 free_in_cluster = s->cluster_size -
1848 (s->free_byte_offset & (s->cluster_size - 1));
1849 if (size <= free_in_cluster) {
1850 /* enough space in current cluster */
1851 offset = s->free_byte_offset;
1852 s->free_byte_offset += size;
1853 free_in_cluster -= size;
1854 if (free_in_cluster == 0)
1855 s->free_byte_offset = 0;
1856 if ((offset & (s->cluster_size - 1)) != 0)
1857 update_cluster_refcount(bs, offset >> s->cluster_bits, 1);
1858 } else {
1859 offset = alloc_clusters(bs, s->cluster_size);
1860 cluster_offset = s->free_byte_offset & ~(s->cluster_size - 1);
1861 if ((cluster_offset + s->cluster_size) == offset) {
1862 /* we are lucky: contiguous data */
1863 offset = s->free_byte_offset;
1864 update_cluster_refcount(bs, offset >> s->cluster_bits, 1);
1865 s->free_byte_offset += size;
1866 } else {
1867 s->free_byte_offset = offset;
1868 goto redo;
1869 }
1870 }
1871 return offset;
1872 }
1873
1874 static void free_clusters(BlockDriverState *bs,
1875 int64_t offset, int64_t size)
1876 {
1877 update_refcount(bs, offset, size, -1);
1878 }
1879
1880 static int grow_refcount_table(BlockDriverState *bs, int min_size)
1881 {
1882 BDRVQcowState *s = bs->opaque;
1883 int new_table_size, new_table_size2, refcount_table_clusters, i, ret;
1884 uint64_t *new_table;
1885 int64_t table_offset;
1886 uint64_t data64;
1887 uint32_t data32;
1888 int old_table_size;
1889 int64_t old_table_offset;
1890
1891 if (min_size <= s->refcount_table_size)
1892 return 0;
1893 /* compute new table size */
1894 refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3);
1895 for(;;) {
1896 if (refcount_table_clusters == 0) {
1897 refcount_table_clusters = 1;
1898 } else {
1899 refcount_table_clusters = (refcount_table_clusters * 3 + 1) / 2;
1900 }
1901 new_table_size = refcount_table_clusters << (s->cluster_bits - 3);
1902 if (min_size <= new_table_size)
1903 break;
1904 }
1905 #ifdef DEBUG_ALLOC2
1906 printf("grow_refcount_table from %d to %d\n",
1907 s->refcount_table_size,
1908 new_table_size);
1909 #endif
1910 new_table_size2 = new_table_size * sizeof(uint64_t);
1911 new_table = qemu_mallocz(new_table_size2);
1912 if (!new_table)
1913 return -ENOMEM;
1914 memcpy(new_table, s->refcount_table,
1915 s->refcount_table_size * sizeof(uint64_t));
1916 for(i = 0; i < s->refcount_table_size; i++)
1917 cpu_to_be64s(&new_table[i]);
1918 /* Note: we cannot update the refcount now to avoid recursion */
1919 table_offset = alloc_clusters_noref(bs, new_table_size2);
1920 ret = bdrv_pwrite(s->hd, table_offset, new_table, new_table_size2);
1921 if (ret != new_table_size2)
1922 goto fail;
1923 for(i = 0; i < s->refcount_table_size; i++)
1924 be64_to_cpus(&new_table[i]);
1925
1926 data64 = cpu_to_be64(table_offset);
1927 if (bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset),
1928 &data64, sizeof(data64)) != sizeof(data64))
1929 goto fail;
1930 data32 = cpu_to_be32(refcount_table_clusters);
1931 if (bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_clusters),
1932 &data32, sizeof(data32)) != sizeof(data32))
1933 goto fail;
1934 qemu_free(s->refcount_table);
1935 old_table_offset = s->refcount_table_offset;
1936 old_table_size = s->refcount_table_size;
1937 s->refcount_table = new_table;
1938 s->refcount_table_size = new_table_size;
1939 s->refcount_table_offset = table_offset;
1940
1941 update_refcount(bs, table_offset, new_table_size2, 1);
1942 free_clusters(bs, old_table_offset, old_table_size * sizeof(uint64_t));
1943 return 0;
1944 fail:
1945 free_clusters(bs, table_offset, new_table_size2);
1946 qemu_free(new_table);
1947 return -EIO;
1948 }
1949
1950 /* addend must be 1 or -1 */
1951 /* XXX: cache several refcount block clusters ? */
1952 static int update_cluster_refcount(BlockDriverState *bs,
1953 int64_t cluster_index,
1954 int addend)
1955 {
1956 BDRVQcowState *s = bs->opaque;
1957 int64_t offset, refcount_block_offset;
1958 int ret, refcount_table_index, block_index, refcount;
1959 uint64_t data64;
1960
1961 refcount_table_index = cluster_index >> (s->cluster_bits - REFCOUNT_SHIFT);
1962 if (refcount_table_index >= s->refcount_table_size) {
1963 if (addend < 0)
1964 return -EINVAL;
1965 ret = grow_refcount_table(bs, refcount_table_index + 1);
1966 if (ret < 0)
1967 return ret;
1968 }
1969 refcount_block_offset = s->refcount_table[refcount_table_index];
1970 if (!refcount_block_offset) {
1971 if (addend < 0)
1972 return -EINVAL;
1973 /* create a new refcount block */
1974 /* Note: we cannot update the refcount now to avoid recursion */
1975 offset = alloc_clusters_noref(bs, s->cluster_size);
1976 memset(s->refcount_block_cache, 0, s->cluster_size);
1977 ret = bdrv_pwrite(s->hd, offset, s->refcount_block_cache, s->cluster_size);
1978 if (ret != s->cluster_size)
1979 return -EINVAL;
1980 s->refcount_table[refcount_table_index] = offset;
1981 data64 = cpu_to_be64(offset);
1982 ret = bdrv_pwrite(s->hd, s->refcount_table_offset +
1983 refcount_table_index * sizeof(uint64_t),
1984 &data64, sizeof(data64));
1985 if (ret != sizeof(data64))
1986 return -EINVAL;
1987
1988 refcount_block_offset = offset;
1989 s->refcount_block_cache_offset = offset;
1990 update_refcount(bs, offset, s->cluster_size, 1);
1991 } else {
1992 if (refcount_block_offset != s->refcount_block_cache_offset) {
1993 if (load_refcount_block(bs, refcount_block_offset) < 0)
1994 return -EIO;
1995 }
1996 }
1997 /* we can update the count and save it */
1998 block_index = cluster_index &
1999 ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
2000 refcount = be16_to_cpu(s->refcount_block_cache[block_index]);
2001 refcount += addend;
2002 if (refcount < 0 || refcount > 0xffff)
2003 return -EINVAL;
2004 if (refcount == 0 && cluster_index < s->free_cluster_index) {
2005 s->free_cluster_index = cluster_index;
2006 }
2007 s->refcount_block_cache[block_index] = cpu_to_be16(refcount);
2008 if (bdrv_pwrite(s->hd,
2009 refcount_block_offset + (block_index << REFCOUNT_SHIFT),
2010 &s->refcount_block_cache[block_index], 2) != 2)
2011 return -EIO;
2012 return refcount;
2013 }
2014
2015 static void update_refcount(BlockDriverState *bs,
2016 int64_t offset, int64_t length,
2017 int addend)
2018 {
2019 BDRVQcowState *s = bs->opaque;
2020 int64_t start, last, cluster_offset;
2021
2022 #ifdef DEBUG_ALLOC2
2023 printf("update_refcount: offset=%lld size=%lld addend=%d\n",
2024 offset, length, addend);
2025 #endif
2026 if (length <= 0)
2027 return;
2028 start = offset & ~(s->cluster_size - 1);
2029 last = (offset + length - 1) & ~(s->cluster_size - 1);
2030 for(cluster_offset = start; cluster_offset <= last;
2031 cluster_offset += s->cluster_size) {
2032 update_cluster_refcount(bs, cluster_offset >> s->cluster_bits, addend);
2033 }
2034 }
2035
2036 #ifdef DEBUG_ALLOC
2037 static void inc_refcounts(BlockDriverState *bs,
2038 uint16_t *refcount_table,
2039 int refcount_table_size,
2040 int64_t offset, int64_t size)
2041 {
2042 BDRVQcowState *s = bs->opaque;
2043 int64_t start, last, cluster_offset;
2044 int k;
2045
2046 if (size <= 0)
2047 return;
2048
2049 start = offset & ~(s->cluster_size - 1);
2050 last = (offset + size - 1) & ~(s->cluster_size - 1);
2051 for(cluster_offset = start; cluster_offset <= last;
2052 cluster_offset += s->cluster_size) {
2053 k = cluster_offset >> s->cluster_bits;
2054 if (k < 0 || k >= refcount_table_size) {
2055 printf("ERROR: invalid cluster offset=0x%llx\n", cluster_offset);
2056 } else {
2057 if (++refcount_table[k] == 0) {
2058 printf("ERROR: overflow cluster offset=0x%llx\n", cluster_offset);
2059 }
2060 }
2061 }
2062 }
2063
2064 static int check_refcounts_l1(BlockDriverState *bs,
2065 uint16_t *refcount_table,
2066 int refcount_table_size,
2067 int64_t l1_table_offset, int l1_size,
2068 int check_copied)
2069 {
2070 BDRVQcowState *s = bs->opaque;
2071 uint64_t *l1_table, *l2_table, l2_offset, offset, l1_size2;
2072 int l2_size, i, j, nb_csectors, refcount;
2073
2074 l2_table = NULL;
2075 l1_size2 = l1_size * sizeof(uint64_t);
2076
2077 inc_refcounts(bs, refcount_table, refcount_table_size,
2078 l1_table_offset, l1_size2);
2079
2080 l1_table = qemu_malloc(l1_size2);
2081 if (!l1_table)
2082 goto fail;
2083 if (bdrv_pread(s->hd, l1_table_offset,
2084 l1_table, l1_size2) != l1_size2)
2085 goto fail;
2086 for(i = 0;i < l1_size; i++)
2087 be64_to_cpus(&l1_table[i]);
2088
2089 l2_size = s->l2_size * sizeof(uint64_t);
2090 l2_table = qemu_malloc(l2_size);
2091 if (!l2_table)
2092 goto fail;
2093 for(i = 0; i < l1_size; i++) {
2094 l2_offset = l1_table[i];
2095 if (l2_offset) {
2096 if (check_copied) {
2097 refcount = get_refcount(bs, (l2_offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits);
2098 if ((refcount == 1) != ((l2_offset & QCOW_OFLAG_COPIED) != 0)) {
2099 printf("ERROR OFLAG_COPIED: l2_offset=%llx refcount=%d\n",
2100 l2_offset, refcount);
2101 }
2102 }
2103 l2_offset &= ~QCOW_OFLAG_COPIED;
2104 if (bdrv_pread(s->hd, l2_offset, l2_table, l2_size) != l2_size)
2105 goto fail;
2106 for(j = 0; j < s->l2_size; j++) {
2107 offset = be64_to_cpu(l2_table[j]);
2108 if (offset != 0) {
2109 if (offset & QCOW_OFLAG_COMPRESSED) {
2110 if (offset & QCOW_OFLAG_COPIED) {
2111 printf("ERROR: cluster %lld: copied flag must never be set for compressed clusters\n",
2112 offset >> s->cluster_bits);
2113 offset &= ~QCOW_OFLAG_COPIED;
2114 }
2115 nb_csectors = ((offset >> s->csize_shift) &
2116 s->csize_mask) + 1;
2117 offset &= s->cluster_offset_mask;
2118 inc_refcounts(bs, refcount_table,
2119 refcount_table_size,
2120 offset & ~511, nb_csectors * 512);
2121 } else {
2122 if (check_copied) {
2123 refcount = get_refcount(bs, (offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits);
2124 if ((refcount == 1) != ((offset & QCOW_OFLAG_COPIED) != 0)) {
2125 printf("ERROR OFLAG_COPIED: offset=%llx refcount=%d\n",
2126 offset, refcount);
2127 }
2128 }
2129 offset &= ~QCOW_OFLAG_COPIED;
2130 inc_refcounts(bs, refcount_table,
2131 refcount_table_size,
2132 offset, s->cluster_size);
2133 }
2134 }
2135 }
2136 inc_refcounts(bs, refcount_table,
2137 refcount_table_size,
2138 l2_offset,
2139 s->cluster_size);
2140 }
2141 }
2142 qemu_free(l1_table);
2143 qemu_free(l2_table);
2144 return 0;
2145 fail:
2146 printf("ERROR: I/O error in check_refcounts_l1\n");
2147 qemu_free(l1_table);
2148 qemu_free(l2_table);
2149 return -EIO;
2150 }
2151
2152 static void check_refcounts(BlockDriverState *bs)
2153 {
2154 BDRVQcowState *s = bs->opaque;
2155 int64_t size;
2156 int nb_clusters, refcount1, refcount2, i;
2157 QCowSnapshot *sn;
2158 uint16_t *refcount_table;
2159
2160 size = bdrv_getlength(s->hd);
2161 nb_clusters = (size + s->cluster_size - 1) >> s->cluster_bits;
2162 refcount_table = qemu_mallocz(nb_clusters * sizeof(uint16_t));
2163
2164 /* header */
2165 inc_refcounts(bs, refcount_table, nb_clusters,
2166 0, s->cluster_size);
2167
2168 check_refcounts_l1(bs, refcount_table, nb_clusters,
2169 s->l1_table_offset, s->l1_size, 1);
2170
2171 /* snapshots */
2172 for(i = 0; i < s->nb_snapshots; i++) {
2173 sn = s->snapshots + i;
2174 check_refcounts_l1(bs, refcount_table, nb_clusters,
2175 sn->l1_table_offset, sn->l1_size, 0);
2176 }
2177 inc_refcounts(bs, refcount_table, nb_clusters,
2178 s->snapshots_offset, s->snapshots_size);
2179
2180 /* refcount data */
2181 inc_refcounts(bs, refcount_table, nb_clusters,
2182 s->refcount_table_offset,
2183 s->refcount_table_size * sizeof(uint64_t));
2184 for(i = 0; i < s->refcount_table_size; i++) {
2185 int64_t offset;
2186 offset = s->refcount_table[i];
2187 if (offset != 0) {
2188 inc_refcounts(bs, refcount_table, nb_clusters,
2189 offset, s->cluster_size);
2190 }
2191 }
2192
2193 /* compare ref counts */
2194 for(i = 0; i < nb_clusters; i++) {
2195 refcount1 = get_refcount(bs, i);
2196 refcount2 = refcount_table[i];
2197 if (refcount1 != refcount2)
2198 printf("ERROR cluster %d refcount=%d reference=%d\n",
2199 i, refcount1, refcount2);
2200 }
2201
2202 qemu_free(refcount_table);
2203 }
2204
2205 #if 0
2206 static void dump_refcounts(BlockDriverState *bs)
2207 {
2208 BDRVQcowState *s = bs->opaque;
2209 int64_t nb_clusters, k, k1, size;
2210 int refcount;
2211
2212 size = bdrv_getlength(s->hd);
2213 nb_clusters = (size + s->cluster_size - 1) >> s->cluster_bits;
2214 for(k = 0; k < nb_clusters;) {
2215 k1 = k;
2216 refcount = get_refcount(bs, k);
2217 k++;
2218 while (k < nb_clusters && get_refcount(bs, k) == refcount)
2219 k++;
2220 printf("%lld: refcount=%d nb=%lld\n", k, refcount, k - k1);
2221 }
2222 }
2223 #endif
2224 #endif
2225
2226 BlockDriver bdrv_qcow2 = {
2227 "qcow2",
2228 sizeof(BDRVQcowState),
2229 qcow_probe,
2230 qcow_open,
2231 NULL,
2232 NULL,
2233 qcow_close,
2234 qcow_create,
2235 qcow_flush,
2236 qcow_is_allocated,
2237 qcow_set_key,
2238 qcow_make_empty,
2239
2240 .bdrv_aio_read = qcow_aio_read,
2241 .bdrv_aio_write = qcow_aio_write,
2242 .bdrv_aio_cancel = qcow_aio_cancel,
2243 .aiocb_size = sizeof(QCowAIOCB),
2244 .bdrv_write_compressed = qcow_write_compressed,
2245
2246 .bdrv_snapshot_create = qcow_snapshot_create,
2247 .bdrv_snapshot_goto = qcow_snapshot_goto,
2248 .bdrv_snapshot_delete = qcow_snapshot_delete,
2249 .bdrv_snapshot_list = qcow_snapshot_list,
2250 .bdrv_get_info = qcow_get_info,
2251 };
0 /*
1 * Block driver for RAW files (posix)
2 *
3 * Copyright (c) 2006 Fabrice Bellard
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #include <signal.h>
24
25 #include "qemu-common.h"
26 #ifndef QEMU_IMG
27 #include "qemu-timer.h"
28 #include "exec-all.h"
29 #endif
30 #include "block_int.h"
31 #include <assert.h>
32 #include <aio.h>
33
34 #ifdef CONFIG_COCOA
35 #include <paths.h>
36 #include <sys/param.h>
37 #include <IOKit/IOKitLib.h>
38 #include <IOKit/IOBSD.h>
39 #include <IOKit/storage/IOMediaBSDClient.h>
40 #include <IOKit/storage/IOMedia.h>
41 #include <IOKit/storage/IOCDMedia.h>
42 //#include <IOKit/storage/IOCDTypes.h>
43 #include <CoreFoundation/CoreFoundation.h>
44 #endif
45
46 #ifdef __sun__
47 #define _POSIX_PTHREAD_SEMANTICS 1
48 #include <signal.h>
49 #include <sys/dkio.h>
50 #endif
51 #ifdef __linux__
52 #include <sys/ioctl.h>
53 #include <linux/cdrom.h>
54 #include <linux/fd.h>
55 #endif
56 #ifdef __FreeBSD__
57 #include <sys/disk.h>
58 #endif
59
60 //#define DEBUG_FLOPPY
61
62 //#define DEBUG_BLOCK
63 #if defined(DEBUG_BLOCK) && !defined(QEMU_IMG)
64 #define DEBUG_BLOCK_PRINT(formatCstr, args...) do { if (loglevel != 0) \
65 { fprintf(logfile, formatCstr, ##args); fflush(logfile); } } while (0)
66 #else
67 #define DEBUG_BLOCK_PRINT(formatCstr, args...)
68 #endif
69
70 #define FTYPE_FILE 0
71 #define FTYPE_CD 1
72 #define FTYPE_FD 2
73
74 /* if the FD is not accessed during that time (in ms), we try to
75 reopen it to see if the disk has been changed */
76 #define FD_OPEN_TIMEOUT 1000
77
78 typedef struct BDRVRawState {
79 int fd;
80 int type;
81 unsigned int lseek_err_cnt;
82 #if defined(__linux__)
83 /* linux floppy specific */
84 int fd_open_flags;
85 int64_t fd_open_time;
86 int64_t fd_error_time;
87 int fd_got_error;
88 int fd_media_changed;
89 #endif
90 } BDRVRawState;
91
92 static int fd_open(BlockDriverState *bs);
93
94 static int raw_open(BlockDriverState *bs, const char *filename, int flags)
95 {
96 BDRVRawState *s = bs->opaque;
97 int fd, open_flags, ret;
98
99 s->lseek_err_cnt = 0;
100
101 open_flags = O_BINARY;
102 if ((flags & BDRV_O_ACCESS) == O_RDWR) {
103 open_flags |= O_RDWR;
104 } else {
105 open_flags |= O_RDONLY;
106 bs->read_only = 1;
107 }
108 if (flags & BDRV_O_CREAT)
109 open_flags |= O_CREAT | O_TRUNC;
110 #ifdef O_DIRECT
111 if (flags & BDRV_O_DIRECT)
112 open_flags |= O_DIRECT;
113 #endif
114
115 s->type = FTYPE_FILE;
116
117 fd = open(filename, open_flags, 0644);
118 if (fd < 0) {
119 ret = -errno;
120 if (ret == -EROFS)
121 ret = -EACCES;
122 return ret;
123 }
124 s->fd = fd;
125 return 0;
126 }
127
128 /* XXX: use host sector size if necessary with:
129 #ifdef DIOCGSECTORSIZE
130 {
131 unsigned int sectorsize = 512;
132 if (!ioctl(fd, DIOCGSECTORSIZE, &sectorsize) &&
133 sectorsize > bufsize)
134 bufsize = sectorsize;
135 }
136 #endif
137 #ifdef CONFIG_COCOA
138 u_int32_t blockSize = 512;
139 if ( !ioctl( fd, DKIOCGETBLOCKSIZE, &blockSize ) && blockSize > bufsize) {
140 bufsize = blockSize;
141 }
142 #endif
143 */
144
145 static int raw_pread(BlockDriverState *bs, int64_t offset,
146 uint8_t *buf, int count)
147 {
148 BDRVRawState *s = bs->opaque;
149 int ret;
150
151 ret = fd_open(bs);
152 if (ret < 0)
153 return ret;
154
155 if (offset >= 0 && lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
156 ++(s->lseek_err_cnt);
157 if(s->lseek_err_cnt <= 10) {
158 DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
159 "] lseek failed : %d = %s\n",
160 s->fd, bs->filename, offset, buf, count,
161 bs->total_sectors, errno, strerror(errno));
162 }
163 return -1;
164 }
165 s->lseek_err_cnt=0;
166
167 ret = read(s->fd, buf, count);
168 if (ret == count)
169 goto label__raw_read__success;
170
171 DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
172 "] read failed %d : %d = %s\n",
173 s->fd, bs->filename, offset, buf, count,
174 bs->total_sectors, ret, errno, strerror(errno));
175
176 /* Try harder for CDrom. */
177 if (bs->type == BDRV_TYPE_CDROM) {
178 lseek(s->fd, offset, SEEK_SET);
179 ret = read(s->fd, buf, count);
180 if (ret == count)
181 goto label__raw_read__success;
182 lseek(s->fd, offset, SEEK_SET);
183 ret = read(s->fd, buf, count);
184 if (ret == count)
185 goto label__raw_read__success;
186
187 DEBUG_BLOCK_PRINT("raw_pread(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
188 "] retry read failed %d : %d = %s\n",
189 s->fd, bs->filename, offset, buf, count,
190 bs->total_sectors, ret, errno, strerror(errno));
191 }
192
193 label__raw_read__success:
194
195 return ret;
196 }
197
198 static int raw_pwrite(BlockDriverState *bs, int64_t offset,
199 const uint8_t *buf, int count)
200 {
201 BDRVRawState *s = bs->opaque;
202 int ret;
203
204 ret = fd_open(bs);
205 if (ret < 0)
206 return ret;
207
208 if (offset >= 0 && lseek(s->fd, offset, SEEK_SET) == (off_t)-1) {
209 ++(s->lseek_err_cnt);
210 if(s->lseek_err_cnt) {
211 DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%"
212 PRId64 "] lseek failed : %d = %s\n",
213 s->fd, bs->filename, offset, buf, count,
214 bs->total_sectors, errno, strerror(errno));
215 }
216 return -1;
217 }
218 s->lseek_err_cnt = 0;
219
220 ret = write(s->fd, buf, count);
221 if (ret == count)
222 goto label__raw_write__success;
223
224 DEBUG_BLOCK_PRINT("raw_pwrite(%d:%s, %" PRId64 ", %p, %d) [%" PRId64
225 "] write failed %d : %d = %s\n",
226 s->fd, bs->filename, offset, buf, count,
227 bs->total_sectors, ret, errno, strerror(errno));
228
229 label__raw_write__success:
230
231 return ret;
232 }
233
234 /***********************************************************/
235 /* Unix AIO using POSIX AIO */
236
237 typedef struct RawAIOCB {
238 BlockDriverAIOCB common;
239 struct aiocb aiocb;
240 struct RawAIOCB *next;
241 } RawAIOCB;
242
243 static int aio_sig_num = SIGUSR2;
244 static RawAIOCB *first_aio; /* AIO issued */
245 static int aio_initialized = 0;
246
247 static void aio_signal_handler(int signum)
248 {
249 #ifndef QEMU_IMG
250 CPUState *env = cpu_single_env;
251 if (env) {
252 /* stop the currently executing cpu because a timer occured */
253 cpu_interrupt(env, CPU_INTERRUPT_EXIT);
254 #ifdef USE_KQEMU
255 if (env->kqemu_enabled) {
256 kqemu_cpu_interrupt(env);
257 }
258 #endif
259 }
260 #endif
261 }
262
263 void qemu_aio_init(void)
264 {
265 struct sigaction act;
266
267 aio_initialized = 1;
268
269 sigfillset(&act.sa_mask);
270 act.sa_flags = 0; /* do not restart syscalls to interrupt select() */
271 act.sa_handler = aio_signal_handler;
272 sigaction(aio_sig_num, &act, NULL);
273
274 //#if defined(__GLIBC__) && defined(__linux__)
275 // {
276 // /* XXX: aio thread exit seems to hang on RedHat 9 and this init
277 // seems to fix the problem. */
278 // struct aioinit ai;
279 // memset(&ai, 0, sizeof(ai));
280 // ai.aio_threads = 1;
281 // ai.aio_num = 1;
282 // ai.aio_idle_time = 365 * 100000;
283 // aio_init(&ai);
284 // }
285 //#endif
286 }
287
288 void qemu_aio_poll(void)
289 {
290 RawAIOCB *acb, **pacb;
291 int ret;
292
293 for(;;) {
294 pacb = &first_aio;
295 for(;;) {
296 acb = *pacb;
297 if (!acb)
298 goto the_end;
299 ret = aio_error(&acb->aiocb);
300 if (ret == ECANCELED) {
301 /* remove the request */
302 *pacb = acb->next;
303 qemu_aio_release(acb);
304 } else if (ret != EINPROGRESS) {
305 /* end of aio */
306 if (ret == 0) {
307 ret = aio_return(&acb->aiocb);
308 if (ret == acb->aiocb.aio_nbytes)
309 ret = 0;
310 else
311 ret = -EINVAL;
312 } else {
313 ret = -ret;
314 }
315 /* remove the request */
316 *pacb = acb->next;
317 /* call the callback */
318 acb->common.cb(acb->common.opaque, ret);
319 qemu_aio_release(acb);
320 break;
321 } else {
322 pacb = &acb->next;
323 }
324 }
325 }
326 the_end: ;
327 }
328
329 /* Wait for all IO requests to complete. */
330 void qemu_aio_flush(void)
331 {
332 qemu_aio_wait_start();
333 qemu_aio_poll();
334 while (first_aio) {
335 qemu_aio_wait();
336 }
337 qemu_aio_wait_end();
338 }
339
340 /* wait until at least one AIO was handled */
341 static sigset_t wait_oset;
342
343 void qemu_aio_wait_start(void)
344 {
345 sigset_t set;
346
347 if (!aio_initialized)
348 qemu_aio_init();
349 sigemptyset(&set);
350 sigaddset(&set, aio_sig_num);
351 sigprocmask(SIG_BLOCK, &set, &wait_oset);
352 }
353
354 void qemu_aio_wait(void)
355 {
356 sigset_t set;
357 int nb_sigs;
358
359 #ifndef QEMU_IMG
360 if (qemu_bh_poll())
361 return;
362 #endif
363 sigemptyset(&set);
364 sigaddset(&set, aio_sig_num);
365 sigwait(&set, &nb_sigs);
366 qemu_aio_poll();
367 }
368
369 void qemu_aio_wait_end(void)
370 {
371 sigprocmask(SIG_SETMASK, &wait_oset, NULL);
372 }
373
374 static RawAIOCB *raw_aio_setup(BlockDriverState *bs,
375 int64_t sector_num, uint8_t *buf, int nb_sectors,
376 BlockDriverCompletionFunc *cb, void *opaque)
377 {
378 BDRVRawState *s = bs->opaque;
379 RawAIOCB *acb;
380
381 if (fd_open(bs) < 0)
382 return NULL;
383
384 acb = qemu_aio_get(bs, cb, opaque);
385 if (!acb)
386 return NULL;
387 acb->aiocb.aio_fildes = s->fd;
388 acb->aiocb.aio_sigevent.sigev_signo = aio_sig_num;
389 acb->aiocb.aio_sigevent.sigev_notify = SIGEV_SIGNAL;
390 acb->aiocb.aio_buf = buf;
391 if (nb_sectors < 0)
392 acb->aiocb.aio_nbytes = -nb_sectors;
393 else
394 acb->aiocb.aio_nbytes = nb_sectors * 512;
395 acb->aiocb.aio_offset = sector_num * 512;
396 acb->next = first_aio;
397 first_aio = acb;
398 return acb;
399 }
400
401 static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs,
402 int64_t sector_num, uint8_t *buf, int nb_sectors,
403 BlockDriverCompletionFunc *cb, void *opaque)
404 {
405 RawAIOCB *acb;
406
407 acb = raw_aio_setup(bs, sector_num, buf, nb_sectors, cb, opaque);
408 if (!acb)
409 return NULL;
410 if (aio_read(&acb->aiocb) < 0) {
411 qemu_aio_release(acb);
412 return NULL;
413 }
414 return &acb->common;
415 }
416
417 static BlockDriverAIOCB *raw_aio_write(BlockDriverState *bs,
418 int64_t sector_num, const uint8_t *buf, int nb_sectors,
419 BlockDriverCompletionFunc *cb, void *opaque)
420 {
421 RawAIOCB *acb;
422
423 acb = raw_aio_setup(bs, sector_num, (uint8_t*)buf, nb_sectors, cb, opaque);
424 if (!acb)
425 return NULL;
426 if (aio_write(&acb->aiocb) < 0) {
427 qemu_aio_release(acb);
428 return NULL;
429 }
430 return &acb->common;
431 }
432
433 static void raw_aio_cancel(BlockDriverAIOCB *blockacb)
434 {
435 int ret;
436 RawAIOCB *acb = (RawAIOCB *)blockacb;
437 RawAIOCB **pacb;
438
439 ret = aio_cancel(acb->aiocb.aio_fildes, &acb->aiocb);
440 if (ret == AIO_NOTCANCELED) {
441 /* fail safe: if the aio could not be canceled, we wait for
442 it */
443 while (aio_error(&acb->aiocb) == EINPROGRESS);
444 }
445
446 /* remove the callback from the queue */
447 pacb = &first_aio;
448 for(;;) {
449 if (*pacb == NULL) {
450 break;
451 } else if (*pacb == acb) {
452 *pacb = acb->next;
453 qemu_aio_release(acb);
454 break;
455 }
456 pacb = &acb->next;
457 }
458 }
459
460 static void raw_close(BlockDriverState *bs)
461 {
462 BDRVRawState *s = bs->opaque;
463 if (s->fd >= 0) {
464 close(s->fd);
465 s->fd = -1;
466 }
467 }
468
469 static int raw_truncate(BlockDriverState *bs, int64_t offset)
470 {
471 BDRVRawState *s = bs->opaque;
472 if (s->type != FTYPE_FILE)
473 return -ENOTSUP;
474 if (ftruncate(s->fd, offset) < 0)
475 return -errno;
476 return 0;
477 }
478
479 static int64_t raw_getlength(BlockDriverState *bs)
480 {
481 BDRVRawState *s = bs->opaque;
482 int fd = s->fd;
483 int64_t size;
484 #ifdef _BSD
485 struct stat sb;
486 #endif
487 #ifdef __sun__
488 struct dk_minfo minfo;
489 int rv;
490 #endif
491 int ret;
492
493 ret = fd_open(bs);
494 if (ret < 0)
495 return ret;
496
497 #ifdef _BSD
498 if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
499 #ifdef DIOCGMEDIASIZE
500 if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
501 #endif
502 #ifdef CONFIG_COCOA
503 size = LONG_LONG_MAX;
504 #else
505 size = lseek(fd, 0LL, SEEK_END);
506 #endif
507 } else
508 #endif
509 #ifdef __sun__
510 /*
511 * use the DKIOCGMEDIAINFO ioctl to read the size.
512 */
513 rv = ioctl ( fd, DKIOCGMEDIAINFO, &minfo );
514 if ( rv != -1 ) {
515 size = minfo.dki_lbsize * minfo.dki_capacity;
516 } else /* there are reports that lseek on some devices
517 fails, but irc discussion said that contingency
518 on contingency was overkill */
519 #endif
520 {
521 size = lseek(fd, 0, SEEK_END);
522 }
523 return size;
524 }
525
526 static int raw_create(const char *filename, int64_t total_size,
527 const char *backing_file, int flags)
528 {
529 int fd;
530
531 if (flags || backing_file)
532 return -ENOTSUP;
533
534 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
535 0644);
536 if (fd < 0)
537 return -EIO;
538 if(ftruncate(fd, total_size * 512)<0) return -1;
539 close(fd);
540 return 0;
541 }
542
543 static void raw_flush(BlockDriverState *bs)
544 {
545 BDRVRawState *s = bs->opaque;
546 fsync(s->fd);
547 }
548
549 BlockDriver bdrv_raw = {
550 "raw",
551 sizeof(BDRVRawState),
552 NULL, /* no probe for protocols */
553 raw_open,
554 NULL,
555 NULL,
556 raw_close,
557 raw_create,
558 raw_flush,
559
560 .bdrv_aio_read = raw_aio_read,
561 .bdrv_aio_write = raw_aio_write,
562 .bdrv_aio_cancel = raw_aio_cancel,
563 .aiocb_size = sizeof(RawAIOCB),
564 .protocol_name = "file",
565 .bdrv_pread = raw_pread,
566 .bdrv_pwrite = raw_pwrite,
567 .bdrv_truncate = raw_truncate,
568 .bdrv_getlength = raw_getlength,
569 };
570
571 /***********************************************/
572 /* host device */
573
574 #ifdef CONFIG_COCOA
575 static kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator );
576 static kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFIndex maxPathSize );
577
578 kern_return_t FindEjectableCDMedia( io_iterator_t *mediaIterator )
579 {
580 kern_return_t kernResult;
581 mach_port_t masterPort;
582 CFMutableDictionaryRef classesToMatch;
583
584 kernResult = IOMasterPort( MACH_PORT_NULL, &masterPort );
585 if ( KERN_SUCCESS != kernResult ) {
586 printf( "IOMasterPort returned %d\n", kernResult );
587 }
588
589 classesToMatch = IOServiceMatching( kIOCDMediaClass );
590 if ( classesToMatch == NULL ) {
591 printf( "IOServiceMatching returned a NULL dictionary.\n" );
592 } else {
593 CFDictionarySetValue( classesToMatch, CFSTR( kIOMediaEjectableKey ), kCFBooleanTrue );
594 }
595 kernResult = IOServiceGetMatchingServices( masterPort, classesToMatch, mediaIterator );
596 if ( KERN_SUCCESS != kernResult )
597 {
598 printf( "IOServiceGetMatchingServices returned %d\n", kernResult );
599 }
600
601 return kernResult;
602 }
603
604 kern_return_t GetBSDPath( io_iterator_t mediaIterator, char *bsdPath, CFIndex maxPathSize )
605 {
606 io_object_t nextMedia;
607 kern_return_t kernResult = KERN_FAILURE;
608 *bsdPath = '\0';
609 nextMedia = IOIteratorNext( mediaIterator );
610 if ( nextMedia )
611 {
612 CFTypeRef bsdPathAsCFString;
613 bsdPathAsCFString = IORegistryEntryCreateCFProperty( nextMedia, CFSTR( kIOBSDNameKey ), kCFAllocatorDefault, 0 );
614 if ( bsdPathAsCFString ) {
615 size_t devPathLength;
616 strcpy( bsdPath, _PATH_DEV );
617 strcat( bsdPath, "r" );
618 devPathLength = strlen( bsdPath );
619 if ( CFStringGetCString( bsdPathAsCFString, bsdPath + devPathLength, maxPathSize - devPathLength, kCFStringEncodingASCII ) ) {
620 kernResult = KERN_SUCCESS;
621 }
622 CFRelease( bsdPathAsCFString );
623 }
624 IOObjectRelease( nextMedia );
625 }
626
627 return kernResult;
628 }
629
630 #endif
631
632 static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
633 {
634 BDRVRawState *s = bs->opaque;
635 int fd, open_flags, ret;
636
637 #ifdef CONFIG_COCOA
638 if (strstart(filename, "/dev/cdrom", NULL)) {
639 kern_return_t kernResult;
640 io_iterator_t mediaIterator;
641 char bsdPath[ MAXPATHLEN ];
642 int fd;
643
644 kernResult = FindEjectableCDMedia( &mediaIterator );
645 kernResult = GetBSDPath( mediaIterator, bsdPath, sizeof( bsdPath ) );
646
647 if ( bsdPath[ 0 ] != '\0' ) {
648 strcat(bsdPath,"s0");
649 /* some CDs don't have a partition 0 */
650 fd = open(bsdPath, O_RDONLY | O_BINARY | O_LARGEFILE);
651 if (fd < 0) {
652 bsdPath[strlen(bsdPath)-1] = '1';
653 } else {
654 close(fd);
655 }
656 filename = bsdPath;
657 }
658
659 if ( mediaIterator )
660 IOObjectRelease( mediaIterator );
661 }
662 #endif
663 open_flags = O_BINARY;
664 if ((flags & BDRV_O_ACCESS) == O_RDWR) {
665 open_flags |= O_RDWR;
666 } else {
667 open_flags |= O_RDONLY;
668 bs->read_only = 1;
669 }
670 #ifdef O_DIRECT
671 if (flags & BDRV_O_DIRECT)
672 open_flags |= O_DIRECT;
673 #endif
674
675 s->type = FTYPE_FILE;
676 #if defined(__linux__)
677 if (strstart(filename, "/dev/cd", NULL)) {
678 /* open will not fail even if no CD is inserted */
679 open_flags |= O_NONBLOCK;
680 s->type = FTYPE_CD;
681 } else if (strstart(filename, "/dev/fd", NULL)) {
682 s->type = FTYPE_FD;
683 s->fd_open_flags = open_flags;
684 /* open will not fail even if no floppy is inserted */
685 open_flags |= O_NONBLOCK;
686 } else if (strstart(filename, "/dev/sg", NULL)) {
687 bs->sg = 1;
688 }
689 #endif
690 fd = open(filename, open_flags, 0644);
691 if (fd < 0) {
692 ret = -errno;
693 if (ret == -EROFS)
694 ret = -EACCES;
695 return ret;
696 }
697 s->fd = fd;
698 #if defined(__linux__)
699 /* close fd so that we can reopen it as needed */
700 if (s->type == FTYPE_FD) {
701 close(s->fd);
702 s->fd = -1;
703 s->fd_media_changed = 1;
704 }
705 #endif
706 return 0;
707 }
708
709 #if defined(__linux__) && !defined(QEMU_IMG)
710
711 /* Note: we do not have a reliable method to detect if the floppy is
712 present. The current method is to try to open the floppy at every
713 I/O and to keep it opened during a few hundreds of ms. */
714 static int fd_open(BlockDriverState *bs)
715 {
716 BDRVRawState *s = bs->opaque;
717 int last_media_present;
718
719 if (s->type != FTYPE_FD)
720 return 0;
721 last_media_present = (s->fd >= 0);
722 if (s->fd >= 0 &&
723 (qemu_get_clock(rt_clock) - s->fd_open_time) >= FD_OPEN_TIMEOUT) {
724 close(s->fd);
725 s->fd = -1;
726 #ifdef DEBUG_FLOPPY
727 printf("Floppy closed\n");
728 #endif
729 }
730 if (s->fd < 0) {
731 if (s->fd_got_error &&
732 (qemu_get_clock(rt_clock) - s->fd_error_time) < FD_OPEN_TIMEOUT) {
733 #ifdef DEBUG_FLOPPY
734 printf("No floppy (open delayed)\n");
735 #endif
736 return -EIO;
737 }
738 s->fd = open(bs->filename, s->fd_open_flags);
739 if (s->fd < 0) {
740 s->fd_error_time = qemu_get_clock(rt_clock);
741 s->fd_got_error = 1;
742 if (last_media_present)
743 s->fd_media_changed = 1;
744 #ifdef DEBUG_FLOPPY
745 printf("No floppy\n");
746 #endif
747 return -EIO;
748 }
749 #ifdef DEBUG_FLOPPY
750 printf("Floppy opened\n");
751 #endif
752 }
753 if (!last_media_present)
754 s->fd_media_changed = 1;
755 s->fd_open_time = qemu_get_clock(rt_clock);
756 s->fd_got_error = 0;
757 return 0;
758 }
759 #else
760 static int fd_open(BlockDriverState *bs)
761 {
762 return 0;
763 }
764 #endif
765
766 #if defined(__linux__)
767
768 static int raw_is_inserted(BlockDriverState *bs)
769 {
770 BDRVRawState *s = bs->opaque;
771 int ret;
772
773 switch(s->type) {
774 case FTYPE_CD:
775 ret = ioctl(s->fd, CDROM_DRIVE_STATUS, CDSL_CURRENT);
776 if (ret == CDS_DISC_OK)
777 return 1;
778 else
779 return 0;
780 break;
781 case FTYPE_FD:
782 ret = fd_open(bs);
783 return (ret >= 0);
784 default:
785 return 1;
786 }
787 }
788
789 /* currently only used by fdc.c, but a CD version would be good too */
790 static int raw_media_changed(BlockDriverState *bs)
791 {
792 BDRVRawState *s = bs->opaque;
793
794 switch(s->type) {
795 case FTYPE_FD:
796 {
797 int ret;
798 /* XXX: we do not have a true media changed indication. It
799 does not work if the floppy is changed without trying
800 to read it */
801 fd_open(bs);
802 ret = s->fd_media_changed;
803 s->fd_media_changed = 0;
804 #ifdef DEBUG_FLOPPY
805 printf("Floppy changed=%d\n", ret);
806 #endif
807 return ret;
808 }
809 default:
810 return -ENOTSUP;
811 }
812 }
813
814 static int raw_eject(BlockDriverState *bs, int eject_flag)
815 {
816 BDRVRawState *s = bs->opaque;
817
818 switch(s->type) {
819 case FTYPE_CD:
820 if (eject_flag) {
821 if (ioctl (s->fd, CDROMEJECT, NULL) < 0)
822 perror("CDROMEJECT");
823 } else {
824 if (ioctl (s->fd, CDROMCLOSETRAY, NULL) < 0)
825 perror("CDROMEJECT");
826 }
827 break;
828 case FTYPE_FD:
829 {
830 int fd;
831 if (s->fd >= 0) {
832 close(s->fd);
833 s->fd = -1;
834 }
835 fd = open(bs->filename, s->fd_open_flags | O_NONBLOCK);
836 if (fd >= 0) {
837 if (ioctl(fd, FDEJECT, 0) < 0)
838 perror("FDEJECT");
839 close(fd);
840 }
841 }
842 break;
843 default:
844 return -ENOTSUP;
845 }
846 return 0;
847 }
848
849 static int raw_set_locked(BlockDriverState *bs, int locked)
850 {
851 BDRVRawState *s = bs->opaque;
852
853 switch(s->type) {
854 case FTYPE_CD:
855 if (ioctl (s->fd, CDROM_LOCKDOOR, locked) < 0) {
856 /* Note: an error can happen if the distribution automatically
857 mounts the CD-ROM */
858 // perror("CDROM_LOCKDOOR");
859 }
860 break;
861 default:
862 return -ENOTSUP;
863 }
864 return 0;
865 }
866
867 static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
868 {
869 BDRVRawState *s = bs->opaque;
870
871 return ioctl(s->fd, req, buf);
872 }
873 #else
874
875 static int raw_is_inserted(BlockDriverState *bs)
876 {
877 return 1;
878 }
879
880 static int raw_media_changed(BlockDriverState *bs)
881 {
882 return -ENOTSUP;
883 }
884
885 static int raw_eject(BlockDriverState *bs, int eject_flag)
886 {
887 return -ENOTSUP;
888 }
889
890 static int raw_set_locked(BlockDriverState *bs, int locked)
891 {
892 return -ENOTSUP;
893 }
894
895 static int raw_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
896 {
897 return -ENOTSUP;
898 }
899 #endif /* !linux */
900
901 BlockDriver bdrv_host_device = {
902 "host_device",
903 sizeof(BDRVRawState),
904 NULL, /* no probe for protocols */
905 hdev_open,
906 NULL,
907 NULL,
908 raw_close,
909 NULL,
910 raw_flush,
911
912 .bdrv_aio_read = raw_aio_read,
913 .bdrv_aio_write = raw_aio_write,
914 .bdrv_aio_cancel = raw_aio_cancel,
915 .aiocb_size = sizeof(RawAIOCB),
916 .bdrv_pread = raw_pread,
917 .bdrv_pwrite = raw_pwrite,
918 .bdrv_getlength = raw_getlength,
919
920 /* removable device support */
921 .bdrv_is_inserted = raw_is_inserted,
922 .bdrv_media_changed = raw_media_changed,
923 .bdrv_eject = raw_eject,
924 .bdrv_set_locked = raw_set_locked,
925 /* generic scsi device */
926 .bdrv_ioctl = raw_ioctl,
927 };
0 /*
1 * Block driver for the VMDK format
2 *
3 * Copyright (c) 2004 Fabrice Bellard
4 * Copyright (c) 2005 Filip Navara
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25 #include "aff-block-vmdk.h" /* added for AFF */
26
27 #include "qemu-common.h"
28 #include "block_int.h"
29
30 #define VMDK3_MAGIC (('C' << 24) | ('O' << 16) | ('W' << 8) | 'D')
31 #define VMDK4_MAGIC (('K' << 24) | ('D' << 16) | ('M' << 8) | 'V')
32
33 typedef struct {
34 uint32_t version;
35 uint32_t flags;
36 uint32_t disk_sectors;
37 uint32_t granularity;
38 uint32_t l1dir_offset;
39 uint32_t l1dir_size;
40 uint32_t file_sectors;
41 uint32_t cylinders;
42 uint32_t heads;
43 uint32_t sectors_per_track;
44 } VMDK3Header;
45
46 typedef struct {
47 uint32_t version;
48 uint32_t flags;
49 int64_t capacity;
50 int64_t granularity;
51 int64_t desc_offset;
52 int64_t desc_size;
53 int32_t num_gtes_per_gte;
54 int64_t rgd_offset;
55 int64_t gd_offset;
56 int64_t grain_offset;
57 char filler[1];
58 char check_bytes[4];
59 } __attribute__((packed)) VMDK4Header;
60
61 #define L2_CACHE_SIZE 16
62
63 typedef struct BDRVVmdkState {
64 BlockDriverState *hd;
65 int64_t l1_table_offset;
66 int64_t l1_backup_table_offset;
67 uint32_t *l1_table;
68 uint32_t *l1_backup_table;
69 unsigned int l1_size;
70 uint32_t l1_entry_sectors;
71
72 unsigned int l2_size;
73 uint32_t *l2_cache;
74 uint32_t l2_cache_offsets[L2_CACHE_SIZE];
75 uint32_t l2_cache_counts[L2_CACHE_SIZE];
76
77 unsigned int cluster_sectors;
78 uint32_t parent_cid;
79 int is_parent;
80 } BDRVVmdkState;
81
82 typedef struct VmdkMetaData {
83 uint32_t offset;
84 unsigned int l1_index;
85 unsigned int l2_index;
86 unsigned int l2_offset;
87 int valid;
88 } VmdkMetaData;
89
90 typedef struct ActiveBDRVState{
91 BlockDriverState *hd; // active image handler
92 uint64_t cluster_offset; // current write offset
93 }ActiveBDRVState;
94
95 static ActiveBDRVState activeBDRV;
96
97
98 static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
99 {
100 uint32_t magic;
101
102 if (buf_size < 4)
103 return 0;
104 magic = be32_to_cpu(*(uint32_t *)buf);
105 if (magic == VMDK3_MAGIC ||
106 magic == VMDK4_MAGIC)
107 return 100;
108 else
109 return 0;
110 }
111
112 #define CHECK_CID 1
113
114 #define SECTOR_SIZE 512
115 #define DESC_SIZE 20*SECTOR_SIZE // 20 sectors of 512 bytes each
116 #define HEADER_SIZE 512 // first sector of 512 bytes
117
118 static uint32_t vmdk_read_cid(BlockDriverState *bs, int parent)
119 {
120 BDRVVmdkState *s = bs->opaque;
121 char desc[DESC_SIZE];
122 uint32_t cid;
123 char *p_name, *cid_str;
124 size_t cid_str_size;
125
126 /* the descriptor offset = 0x200 */
127 if (bdrv_pread(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)
128 return 0;
129
130 if (parent) {
131 cid_str = "parentCID";
132 cid_str_size = sizeof("parentCID");
133 } else {
134 cid_str = "CID";
135 cid_str_size = sizeof("CID");
136 }
137
138 if ((p_name = strstr(desc,cid_str)) != 0) {
139 p_name += cid_str_size;
140 sscanf(p_name,"%x",&cid);
141 }
142
143 return cid;
144 }
145
146 static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
147 {
148 BDRVVmdkState *s = bs->opaque;
149 char desc[DESC_SIZE], tmp_desc[DESC_SIZE];
150 char *p_name, *tmp_str;
151
152 /* the descriptor offset = 0x200 */
153 if (bdrv_pread(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)
154 return -1;
155
156 tmp_str = strstr(desc,"parentCID");
157 strcpy(tmp_desc, tmp_str);
158 if ((p_name = strstr(desc,"CID")) != 0) {
159 p_name += sizeof("CID");
160 sprintf(p_name,"%x\n",cid);
161 strcat(desc,tmp_desc);
162 }
163
164 if (bdrv_pwrite(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)
165 return -1;
166 return 0;
167 }
168
169 static int vmdk_is_cid_valid(BlockDriverState *bs)
170 {
171 #ifdef CHECK_CID
172 BDRVVmdkState *s = bs->opaque;
173 BlockDriverState *p_bs = s->hd->backing_hd;
174 uint32_t cur_pcid;
175
176 if (p_bs) {
177 cur_pcid = vmdk_read_cid(p_bs,0);
178 if (s->parent_cid != cur_pcid)
179 // CID not valid
180 return 0;
181 }
182 #endif
183 // CID valid
184 return 1;
185 }
186
187 static int vmdk_snapshot_create(const char *filename, const char *backing_file)
188 {
189 int snp_fd, p_fd;
190 uint32_t p_cid;
191 char *p_name, *gd_buf, *rgd_buf;
192 const char *real_filename, *temp_str;
193 VMDK4Header header;
194 uint32_t gde_entries, gd_size;
195 int64_t gd_offset, rgd_offset, capacity, gt_size;
196 char p_desc[DESC_SIZE], s_desc[DESC_SIZE], hdr[HEADER_SIZE];
197 char *desc_template =
198 "# Disk DescriptorFile\n"
199 "version=1\n"
200 "CID=%x\n"
201 "parentCID=%x\n"
202 "createType=\"monolithicSparse\"\n"
203 "parentFileNameHint=\"%s\"\n"
204 "\n"
205 "# Extent description\n"
206 "RW %lu SPARSE \"%s\"\n"
207 "\n"
208 "# The Disk Data Base \n"
209 "#DDB\n"
210 "\n";
211
212 snp_fd = open(filename, O_RDWR | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE, 0644);
213 if (snp_fd < 0)
214 return -1;
215 p_fd = open(backing_file, O_RDONLY | O_BINARY | O_LARGEFILE);
216 if (p_fd < 0) {
217 close(snp_fd);
218 return -1;
219 }
220
221 /* read the header */
222 if (lseek(p_fd, 0x0, SEEK_SET) == -1)
223 goto fail;
224 if (read(p_fd, hdr, HEADER_SIZE) != HEADER_SIZE)
225 goto fail;
226
227 /* write the header */
228 if (lseek(snp_fd, 0x0, SEEK_SET) == -1)
229 goto fail;
230 if (write(snp_fd, hdr, HEADER_SIZE) == -1)
231 goto fail;
232
233 memset(&header, 0, sizeof(header));
234 memcpy(&header,&hdr[4], sizeof(header)); // skip the VMDK4_MAGIC
235
236 if(ftruncate(snp_fd, header.grain_offset << 9)<0) return -1;
237 /* the descriptor offset = 0x200 */
238 if (lseek(p_fd, 0x200, SEEK_SET) == -1)
239 goto fail;
240 if (read(p_fd, p_desc, DESC_SIZE) != DESC_SIZE)
241 goto fail;
242
243 if ((p_name = strstr(p_desc,"CID")) != 0) {
244 p_name += sizeof("CID");
245 sscanf(p_name,"%x",&p_cid);
246 }
247
248 real_filename = filename;
249 if ((temp_str = strrchr(real_filename, '\\')) != NULL)
250 real_filename = temp_str + 1;
251 if ((temp_str = strrchr(real_filename, '/')) != NULL)
252 real_filename = temp_str + 1;
253 if ((temp_str = strrchr(real_filename, ':')) != NULL)
254 real_filename = temp_str + 1;
255
256 sprintf(s_desc, desc_template, p_cid, p_cid, backing_file
257 , (uint32_t)header.capacity, real_filename);
258
259 /* write the descriptor */
260 if (lseek(snp_fd, 0x200, SEEK_SET) == -1)
261 goto fail;
262 if (write(snp_fd, s_desc, strlen(s_desc)) == -1)
263 goto fail;
264
265 gd_offset = header.gd_offset * SECTOR_SIZE; // offset of GD table
266 rgd_offset = header.rgd_offset * SECTOR_SIZE; // offset of RGD table
267 capacity = header.capacity * SECTOR_SIZE; // Extent size
268 /*
269 * Each GDE span 32M disk, means:
270 * 512 GTE per GT, each GTE points to grain
271 */
272 gt_size = (int64_t)header.num_gtes_per_gte * header.granularity * SECTOR_SIZE;
273 if (!gt_size)
274 goto fail;
275 gde_entries = (uint32_t)(capacity / gt_size); // number of gde/rgde
276 gd_size = gde_entries * sizeof(uint32_t);
277
278 /* write RGD */
279 rgd_buf = qemu_malloc(gd_size);
280 if (!rgd_buf)
281 goto fail;
282 if (lseek(p_fd, rgd_offset, SEEK_SET) == -1)
283 goto fail_rgd;
284 if (read(p_fd, rgd_buf, gd_size) != gd_size)
285 goto fail_rgd;
286 if (lseek(snp_fd, rgd_offset, SEEK_SET) == -1)
287 goto fail_rgd;
288 if (write(snp_fd, rgd_buf, gd_size) == -1)
289 goto fail_rgd;
290 qemu_free(rgd_buf);
291
292 /* write GD */
293 gd_buf = qemu_malloc(gd_size);
294 if (!gd_buf)
295 goto fail_rgd;
296 if (lseek(p_fd, gd_offset, SEEK_SET) == -1)
297 goto fail_gd;
298 if (read(p_fd, gd_buf, gd_size) != gd_size)
299 goto fail_gd;
300 if (lseek(snp_fd, gd_offset, SEEK_SET) == -1)
301 goto fail_gd;
302 if (write(snp_fd, gd_buf, gd_size) == -1)
303 goto fail_gd;
304 qemu_free(gd_buf);
305
306 close(p_fd);
307 close(snp_fd);
308 return 0;
309
310 fail_gd:
311 qemu_free(gd_buf);
312 fail_rgd:
313 qemu_free(rgd_buf);
314 fail:
315 close(p_fd);
316 close(snp_fd);
317 return -1;
318 }
319
320 static void vmdk_parent_close(BlockDriverState *bs)
321 {
322 if (bs->backing_hd)
323 bdrv_close(bs->backing_hd);
324 }
325
326 int parent_open = 0;
327 static int vmdk_parent_open(BlockDriverState *bs, const char * filename)
328 {
329 BDRVVmdkState *s = bs->opaque;
330 char *p_name;
331 char desc[DESC_SIZE];
332 char parent_img_name[1024];
333
334 /* the descriptor offset = 0x200 */
335 if (bdrv_pread(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE)
336 return -1;
337
338 if ((p_name = strstr(desc,"parentFileNameHint")) != 0) {
339 char *end_name;
340 struct stat file_buf;
341
342 p_name += sizeof("parentFileNameHint") + 1;
343 if ((end_name = strchr(p_name,'\"')) == 0)
344 return -1;
345
346 strncpy(s->hd->backing_file, p_name, end_name - p_name);
347 if (stat(s->hd->backing_file, &file_buf) != 0) {
348 path_combine(parent_img_name, sizeof(parent_img_name),
349 filename, s->hd->backing_file);
350 } else {
351 strcpy(parent_img_name, s->hd->backing_file);
352 }
353
354 s->hd->backing_hd = bdrv_new("");
355 if (!s->hd->backing_hd) {
356 failure:
357 bdrv_close(s->hd);
358 return -1;
359 }
360 parent_open = 1;
361 if (bdrv_open(s->hd->backing_hd, parent_img_name, BDRV_O_RDONLY) < 0)
362 goto failure;
363 parent_open = 0;
364 }
365
366 return 0;
367 }
368
369 static int vmdk_open(BlockDriverState *bs, const char *filename, int flags)
370 {
371 BDRVVmdkState *s = bs->opaque;
372 uint32_t magic;
373 int l1_size, i, ret;
374
375 if (parent_open)
376 // Parent must be opened as RO.
377 flags = BDRV_O_RDONLY;
378 // SLG AFFLIB MOD START
379 //fprintf(stderr, "(VMDK) image open: flags=0x%x filename=%s\n", flags, bs->filename);
380 // SLG AFFLIB MOD END
381
382 ret = bdrv_file_open(&s->hd, filename, flags);
383 if (ret < 0)
384 return ret;
385 if (bdrv_pread(s->hd, 0, &magic, sizeof(magic)) != sizeof(magic))
386 goto fail;
387
388 magic = be32_to_cpu(magic);
389 if (magic == VMDK3_MAGIC) {
390 VMDK3Header header;
391
392 if (bdrv_pread(s->hd, sizeof(magic), &header, sizeof(header)) != sizeof(header))
393 goto fail;
394 s->cluster_sectors = le32_to_cpu(header.granularity);
395 s->l2_size = 1 << 9;
396 s->l1_size = 1 << 6;
397 bs->total_sectors = le32_to_cpu(header.disk_sectors);
398 s->l1_table_offset = le32_to_cpu(header.l1dir_offset) << 9;
399 s->l1_backup_table_offset = 0;
400 s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
401 } else if (magic == VMDK4_MAGIC) {
402 VMDK4Header header;
403
404 if (bdrv_pread(s->hd, sizeof(magic), &header, sizeof(header)) != sizeof(header))
405 goto fail;
406 bs->total_sectors = le64_to_cpu(header.capacity);
407 s->cluster_sectors = le64_to_cpu(header.granularity);
408 s->l2_size = le32_to_cpu(header.num_gtes_per_gte);
409 s->l1_entry_sectors = s->l2_size * s->cluster_sectors;
410 if (s->l1_entry_sectors <= 0)
411 goto fail;
412 s->l1_size = (bs->total_sectors + s->l1_entry_sectors - 1)
413 / s->l1_entry_sectors;
414 s->l1_table_offset = le64_to_cpu(header.rgd_offset) << 9;
415 s->l1_backup_table_offset = le64_to_cpu(header.gd_offset) << 9;
416
417 if (parent_open)
418 s->is_parent = 1;
419 else
420 s->is_parent = 0;
421
422 // try to open parent images, if exist
423 if (vmdk_parent_open(bs, filename) != 0)
424 goto fail;
425 // write the CID once after the image creation
426 s->parent_cid = vmdk_read_cid(bs,1);
427 } else {
428 goto fail;
429 }
430
431 /* read the L1 table */
432 l1_size = s->l1_size * sizeof(uint32_t);
433 s->l1_table = qemu_malloc(l1_size);
434 if (!s->l1_table)
435 goto fail;
436 if (bdrv_pread(s->hd, s->l1_table_offset, s->l1_table, l1_size) != l1_size)
437 goto fail;
438 for(i = 0; i < s->l1_size; i++) {
439 le32_to_cpus(&s->l1_table[i]);
440 }
441
442 if (s->l1_backup_table_offset) {
443 s->l1_backup_table = qemu_malloc(l1_size);
444 if (!s->l1_backup_table)
445 goto fail;
446 if (bdrv_pread(s->hd, s->l1_backup_table_offset, s->l1_backup_table, l1_size) != l1_size)
447 goto fail;
448 for(i = 0; i < s->l1_size; i++) {
449 le32_to_cpus(&s->l1_backup_table[i]);
450 }
451 }
452
453 s->l2_cache = qemu_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint32_t));
454 if (!s->l2_cache)
455 goto fail;
456 return 0;
457 fail:
458 qemu_free(s->l1_backup_table);
459 qemu_free(s->l1_table);
460 qemu_free(s->l2_cache);
461 bdrv_delete(s->hd);
462 return -1;
463 }
464
465 static uint64_t get_cluster_offset(BlockDriverState *bs, VmdkMetaData *m_data,
466 uint64_t offset, int allocate);
467
468 static int get_whole_cluster(BlockDriverState *bs, uint64_t cluster_offset,
469 uint64_t offset, int allocate)
470 {
471 uint64_t parent_cluster_offset;
472 BDRVVmdkState *s = bs->opaque;
473 uint8_t whole_grain[s->cluster_sectors*512]; // 128 sectors * 512 bytes each = grain size 64KB
474
475 // we will be here if it's first write on non-exist grain(cluster).
476 // try to read from parent image, if exist
477 if (s->hd->backing_hd) {
478 BDRVVmdkState *ps = s->hd->backing_hd->opaque;
479
480 if (!vmdk_is_cid_valid(bs))
481 return -1;
482
483 parent_cluster_offset = get_cluster_offset(s->hd->backing_hd, NULL, offset, allocate);
484
485 if (parent_cluster_offset) {
486 BDRVVmdkState *act_s = activeBDRV.hd->opaque;
487
488 if (bdrv_pread(ps->hd, parent_cluster_offset, whole_grain, ps->cluster_sectors*512) != ps->cluster_sectors*512)
489 return -1;
490
491 //Write grain only into the active image
492 if (bdrv_pwrite(act_s->hd, activeBDRV.cluster_offset << 9, whole_grain, sizeof(whole_grain)) != sizeof(whole_grain))
493 return -1;
494 }
495 }
496 return 0;
497 }
498
499 static int vmdk_L2update(BlockDriverState *bs, VmdkMetaData *m_data)
500 {
501 BDRVVmdkState *s = bs->opaque;
502
503 /* update L2 table */
504 if (bdrv_pwrite(s->hd, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
505 &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
506 return -1;
507 /* update backup L2 table */
508 if (s->l1_backup_table_offset != 0) {
509 m_data->l2_offset = s->l1_backup_table[m_data->l1_index];
510 if (bdrv_pwrite(s->hd, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)),
511 &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset))
512 return -1;
513 }
514
515 return 0;
516 }
517
518 static uint64_t get_cluster_offset(BlockDriverState *bs, VmdkMetaData *m_data,
519 uint64_t offset, int allocate)
520 {
521 BDRVVmdkState *s = bs->opaque;
522 unsigned int l1_index, l2_offset, l2_index;
523 int min_index, i, j;
524 uint32_t min_count, *l2_table, tmp = 0;
525 uint64_t cluster_offset;
526
527 if (m_data)
528 m_data->valid = 0;
529
530 l1_index = (offset >> 9) / s->l1_entry_sectors;
531 if (l1_index >= s->l1_size)
532 return 0;
533 l2_offset = s->l1_table[l1_index];
534 if (!l2_offset)
535 return 0;
536 for(i = 0; i < L2_CACHE_SIZE; i++) {
537 if (l2_offset == s->l2_cache_offsets[i]) {
538 /* increment the hit count */
539 if (++s->l2_cache_counts[i] == 0xffffffff) {
540 for(j = 0; j < L2_CACHE_SIZE; j++) {
541 s->l2_cache_counts[j] >>= 1;
542 }
543 }
544 l2_table = s->l2_cache + (i * s->l2_size);
545 goto found;
546 }
547 }
548 /* not found: load a new entry in the least used one */
549 min_index = 0;
550 min_count = 0xffffffff;
551 for(i = 0; i < L2_CACHE_SIZE; i++) {
552 if (s->l2_cache_counts[i] < min_count) {
553 min_count = s->l2_cache_counts[i];
554 min_index = i;
555 }
556 }
557 l2_table = s->l2_cache + (min_index * s->l2_size);
558 if (bdrv_pread(s->hd, (int64_t)l2_offset * 512, l2_table, s->l2_size * sizeof(uint32_t)) !=
559 s->l2_size * sizeof(uint32_t))
560 return 0;
561
562 s->l2_cache_offsets[min_index] = l2_offset;
563 s->l2_cache_counts[min_index] = 1;
564 found:
565 l2_index = ((offset >> 9) / s->cluster_sectors) % s->l2_size;
566 cluster_offset = le32_to_cpu(l2_table[l2_index]);
567
568 if (!cluster_offset) {
569 if (!allocate)
570 return 0;
571 // Avoid the L2 tables update for the images that have snapshots.
572 if (!s->is_parent) {
573 cluster_offset = bdrv_getlength(s->hd);
574 bdrv_truncate(s->hd, cluster_offset + (s->cluster_sectors << 9));
575
576 cluster_offset >>= 9;
577 tmp = cpu_to_le32(cluster_offset);
578 l2_table[l2_index] = tmp;
579 // Save the active image state
580 activeBDRV.cluster_offset = cluster_offset;
581 activeBDRV.hd = bs;
582 }
583 /* First of all we write grain itself, to avoid race condition
584 * that may to corrupt the image.
585 * This problem may occur because of insufficient space on host disk
586 * or inappropriate VM shutdown.
587 */
588 if (get_whole_cluster(bs, cluster_offset, offset, allocate) == -1)
589 return 0;
590
591 if (m_data) {
592 m_data->offset = tmp;
593 m_data->l1_index = l1_index;
594 m_data->l2_index = l2_index;
595 m_data->l2_offset = l2_offset;
596 m_data->valid = 1;
597 }
598 }
599 cluster_offset <<= 9;
600 return cluster_offset;
601 }
602
603 static int vmdk_is_allocated(BlockDriverState *bs, int64_t sector_num,
604 int nb_sectors, int *pnum)
605 {
606 BDRVVmdkState *s = bs->opaque;
607 int index_in_cluster, n;
608 uint64_t cluster_offset;
609
610 cluster_offset = get_cluster_offset(bs, NULL, sector_num << 9, 0);
611 index_in_cluster = sector_num % s->cluster_sectors;
612 n = s->cluster_sectors - index_in_cluster;
613 if (n > nb_sectors)
614 n = nb_sectors;
615 *pnum = n;
616 return (cluster_offset != 0);
617 }
618
619 static int vmdk_read(BlockDriverState *bs, int64_t sector_num,
620 uint8_t *buf, int nb_sectors)
621 {
622 BDRVVmdkState *s = bs->opaque;
623 int index_in_cluster, n, ret;
624 uint64_t cluster_offset;
625
626 while (nb_sectors > 0) {
627 cluster_offset = get_cluster_offset(bs, NULL, sector_num << 9, 0);
628 index_in_cluster = sector_num % s->cluster_sectors;
629 n = s->cluster_sectors - index_in_cluster;
630 if (n > nb_sectors)
631 n = nb_sectors;
632 if (!cluster_offset) {
633 // try to read from parent image, if exist
634 if (s->hd->backing_hd) {
635 if (!vmdk_is_cid_valid(bs))
636 return -1;
637 ret = bdrv_read(s->hd->backing_hd, sector_num, buf, n);
638 if (ret < 0)
639 return -1;
640 } else {
641 memset(buf, 0, 512 * n);
642 }
643 } else {
644 if(bdrv_pread(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512) != n * 512)
645 return -1;
646 }
647 nb_sectors -= n;
648 sector_num += n;
649 buf += n * 512;
650 }
651 return 0;
652 }
653
654 static int vmdk_write(BlockDriverState *bs, int64_t sector_num,
655 const uint8_t *buf, int nb_sectors)
656 {
657 BDRVVmdkState *s = bs->opaque;
658 VmdkMetaData m_data;
659 int index_in_cluster, n;
660 uint64_t cluster_offset;
661 static int cid_update = 0;
662
663 if (sector_num > bs->total_sectors) {
664 fprintf(stderr,
665 "(VMDK) Wrong offset: sector_num=0x%" PRIx64
666 " total_sectors=0x%" PRIx64 "\n",
667 sector_num, bs->total_sectors);
668 return -1;
669 }
670
671 while (nb_sectors > 0) {
672 index_in_cluster = sector_num & (s->cluster_sectors - 1);
673 n = s->cluster_sectors - index_in_cluster;
674 if (n > nb_sectors)
675 n = nb_sectors;
676 cluster_offset = get_cluster_offset(bs, &m_data, sector_num << 9, 1);
677 if (!cluster_offset)
678 return -1;
679
680 if (bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512) != n * 512)
681 return -1;
682 if (m_data.valid) {
683 /* update L2 tables */
684 if (vmdk_L2update(bs, &m_data) == -1)
685 return -1;
686 }
687 nb_sectors -= n;
688 sector_num += n;
689 buf += n * 512;
690
691 // update CID on the first write every time the virtual disk is opened
692 if (!cid_update) {
693 vmdk_write_cid(bs, time(NULL));
694 cid_update++;
695 }
696 }
697 return 0;
698 }
699
700 static int vmdk_create(const char *filename, int64_t total_size,
701 const char *backing_file, int flags)
702 {
703 int fd, i;
704 VMDK4Header header;
705 uint32_t tmp, magic, grains, gd_size, gt_size, gt_count;
706 char *desc_template =
707 "# Disk DescriptorFile\n"
708 "version=1\n"
709 "CID=%x\n"
710 "parentCID=ffffffff\n"
711 "createType=\"monolithicSparse\"\n"
712 "\n"
713 "# Extent description\n"
714 "RW %lu SPARSE \"%s\"\n"
715 "\n"
716 "# The Disk Data Base \n"
717 "#DDB\n"
718 "\n"
719 "ddb.virtualHWVersion = \"%d\"\n"
720 "ddb.geometry.cylinders = \"%lu\"\n"
721 "ddb.geometry.heads = \"16\"\n"
722 "ddb.geometry.sectors = \"63\"\n"
723 "ddb.adapterType = \"ide\"\n";
724 char desc[1024];
725 const char *real_filename, *temp_str;
726
727 /* XXX: add support for backing file */
728 if (backing_file) {
729 return vmdk_snapshot_create(filename, backing_file);
730 }
731
732 fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_LARGEFILE,
733 0644);
734 if (fd < 0)
735 return -1;
736 magic = cpu_to_be32(VMDK4_MAGIC);
737 memset(&header, 0, sizeof(header));
738 header.version = cpu_to_le32(1);
739 header.flags = cpu_to_le32(3); /* ?? */
740 header.capacity = cpu_to_le64(total_size);
741 header.granularity = cpu_to_le64(128);
742 header.num_gtes_per_gte = cpu_to_le32(512);
743
744 grains = (total_size + header.granularity - 1) / header.granularity;
745 gt_size = ((header.num_gtes_per_gte * sizeof(uint32_t)) + 511) >> 9;
746 gt_count = (grains + header.num_gtes_per_gte - 1) / header.num_gtes_per_gte;
747 gd_size = (gt_count * sizeof(uint32_t) + 511) >> 9;
748
749 header.desc_offset = 1;
750 header.desc_size = 20;
751 header.rgd_offset = header.desc_offset + header.desc_size;
752 header.gd_offset = header.rgd_offset + gd_size + (gt_size * gt_count);
753 header.grain_offset =
754 ((header.gd_offset + gd_size + (gt_size * gt_count) +
755 header.granularity - 1) / header.granularity) *
756 header.granularity;
757
758 header.desc_offset = cpu_to_le64(header.desc_offset);
759 header.desc_size = cpu_to_le64(header.desc_size);
760 header.rgd_offset = cpu_to_le64(header.rgd_offset);
761 header.gd_offset = cpu_to_le64(header.gd_offset);
762 header.grain_offset = cpu_to_le64(header.grain_offset);
763
764 header.check_bytes[0] = 0xa;
765 header.check_bytes[1] = 0x20;
766 header.check_bytes[2] = 0xd;
767 header.check_bytes[3] = 0xa;
768
769 /* write all the data */
770 if(write(fd, &magic, sizeof(magic))!=sizeof(magic)) return -1;
771 if(write(fd, &header, sizeof(header))!=sizeof(header)) return -1;
772
773 if(ftruncate(fd, header.grain_offset << 9)<0) return -1;
774
775 /* write grain directory */
776 lseek(fd, le64_to_cpu(header.rgd_offset) << 9, SEEK_SET);
777 for (i = 0, tmp = header.rgd_offset + gd_size;
778 i < gt_count; i++, tmp += gt_size)
779 if(write(fd, &tmp, sizeof(tmp))!=sizeof(tmp)) return -1;
780
781 /* write backup grain directory */
782 lseek(fd, le64_to_cpu(header.gd_offset) << 9, SEEK_SET);
783 for (i = 0, tmp = header.gd_offset + gd_size;
784 i < gt_count; i++, tmp += gt_size)
785 if(write(fd, &tmp, sizeof(tmp))!=sizeof(tmp)) return -1;
786
787 /* compose the descriptor */
788 real_filename = filename;
789 if ((temp_str = strrchr(real_filename, '\\')) != NULL)
790 real_filename = temp_str + 1;
791 if ((temp_str = strrchr(real_filename, '/')) != NULL)
792 real_filename = temp_str + 1;
793 if ((temp_str = strrchr(real_filename, ':')) != NULL)
794 real_filename = temp_str + 1;
795 sprintf(desc, desc_template, time(NULL), (unsigned long)total_size,
796 real_filename, (flags & BLOCK_FLAG_COMPAT6 ? 6 : 4), total_size / (63 * 16));
797
798 /* write the descriptor */
799 lseek(fd, le64_to_cpu(header.desc_offset) << 9, SEEK_SET);
800 if(write(fd, desc, strlen(desc))!=strlen(desc)) return -1;
801
802 close(fd);
803 return 0;
804 }
805
806 static void vmdk_close(BlockDriverState *bs)
807 {
808 BDRVVmdkState *s = bs->opaque;
809
810 qemu_free(s->l1_table);
811 qemu_free(s->l2_cache);
812 bdrv_delete(s->hd);
813 // try to close parent image, if exist
814 vmdk_parent_close(s->hd);
815 }
816
817 static void vmdk_flush(BlockDriverState *bs)
818 {
819 BDRVVmdkState *s = bs->opaque;
820 bdrv_flush(s->hd);
821 }
822
823 BlockDriver bdrv_vmdk = {
824 "vmdk",
825 sizeof(BDRVVmdkState),
826 vmdk_probe,
827 vmdk_open,
828 vmdk_read,
829 vmdk_write,
830 vmdk_close,
831 vmdk_create,
832 vmdk_flush,
833 vmdk_is_allocated,
834 };
0 /*
1 * Block driver for Conectix/Microsoft Virtual PC images
2 *
3 * Copyright (c) 2005 Alex Beregszaszi
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #include "qemu-common.h"
24 #include "block_int.h"
25
26 /**************************************************************/
27
28 #define HEADER_SIZE 512
29
30 //#define CACHE
31
32 // always big-endian
33 struct vpc_subheader {
34 char magic[8]; // "conectix" / "cxsparse"
35 union {
36 struct {
37 uint32_t unk1[2];
38 uint32_t unk2; // always zero?
39 uint32_t subheader_offset;
40 uint32_t unk3; // some size?
41 char creator[4]; // "vpc "
42 uint16_t major;
43 uint16_t minor;
44 char guest[4]; // "Wi2k"
45 uint32_t unk4[7];
46 uint8_t vnet_id[16]; // virtual network id, purpose unknown
47 // next 16 longs are used, but dunno the purpose
48 // next 6 longs unknown, following 7 long maybe a serial
49 char padding[HEADER_SIZE - 84];
50 } main;
51 struct {
52 uint32_t unk1[2]; // all bits set
53 uint32_t unk2; // always zero?
54 uint32_t pagetable_offset;
55 uint32_t unk3;
56 uint32_t pagetable_entries; // 32bit/entry
57 uint32_t pageentry_size; // 512*8*512
58 uint32_t nb_sectors;
59 char padding[HEADER_SIZE - 40];
60 } sparse;
61 char padding[HEADER_SIZE - 8];
62 } type;
63 };
64
65 typedef struct BDRVVPCState {
66 int fd;
67
68 int pagetable_entries;
69 uint32_t *pagetable;
70
71 uint32_t pageentry_size;
72 #ifdef CACHE
73 uint8_t *pageentry_u8;
74 uint32_t *pageentry_u32;
75 uint16_t *pageentry_u16;
76
77 uint64_t last_bitmap;
78 #endif
79 } BDRVVPCState;
80
81 static int vpc_probe(const uint8_t *buf, int buf_size, const char *filename)
82 {
83 if (buf_size >= 8 && !strncmp((char *)buf, "conectix", 8))
84 return 100;
85 return 0;
86 }
87
88 static int vpc_open(BlockDriverState *bs, const char *filename, int flags)
89 {
90 BDRVVPCState *s = bs->opaque;
91 int fd, i;
92 struct vpc_subheader header;
93
94 fd = open(filename, O_RDONLY | O_BINARY);
95 if (fd < 0)
96 return -1;
97
98 bs->read_only = 1; // no write support yet
99
100 s->fd = fd;
101
102 if (read(fd, &header, HEADER_SIZE) != HEADER_SIZE)
103 goto fail;
104
105 if (strncmp(header.magic, "conectix", 8))
106 goto fail;
107 lseek(s->fd, be32_to_cpu(header.type.main.subheader_offset), SEEK_SET);
108
109 if (read(fd, &header, HEADER_SIZE) != HEADER_SIZE)
110 goto fail;
111
112 if (strncmp(header.magic, "cxsparse", 8))
113 goto fail;
114
115 bs->total_sectors = ((uint64_t)be32_to_cpu(header.type.sparse.pagetable_entries) *
116 be32_to_cpu(header.type.sparse.pageentry_size)) / 512;
117
118 lseek(s->fd, be32_to_cpu(header.type.sparse.pagetable_offset), SEEK_SET);
119
120 s->pagetable_entries = be32_to_cpu(header.type.sparse.pagetable_entries);
121 s->pagetable = qemu_malloc(s->pagetable_entries * 4);
122 if (!s->pagetable)
123 goto fail;
124 if (read(s->fd, s->pagetable, s->pagetable_entries * 4) !=
125 s->pagetable_entries * 4)
126 goto fail;
127 for (i = 0; i < s->pagetable_entries; i++)
128 be32_to_cpus(&s->pagetable[i]);
129
130 s->pageentry_size = be32_to_cpu(header.type.sparse.pageentry_size);
131 #ifdef CACHE
132 s->pageentry_u8 = qemu_malloc(512);
133 if (!s->pageentry_u8)
134 goto fail;
135 s->pageentry_u32 = s->pageentry_u8;
136 s->pageentry_u16 = s->pageentry_u8;
137 s->last_pagetable = -1;
138 #endif
139
140 return 0;
141 fail:
142 close(fd);
143 return -1;
144 }
145
146 static inline int seek_to_sector(BlockDriverState *bs, int64_t sector_num)
147 {
148 BDRVVPCState *s = bs->opaque;
149 uint64_t offset = sector_num * 512;
150 uint64_t bitmap_offset, block_offset;
151 uint32_t pagetable_index, pageentry_index;
152
153 pagetable_index = offset / s->pageentry_size;
154 pageentry_index = (offset % s->pageentry_size) / 512;
155
156 if (pagetable_index > s->pagetable_entries || s->pagetable[pagetable_index] == 0xffffffff)
157 return -1; // not allocated
158
159 bitmap_offset = 512 * s->pagetable[pagetable_index];
160 block_offset = bitmap_offset + 512 + (512 * pageentry_index);
161
162 // printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n",
163 // sector_num, pagetable_index, pageentry_index,
164 // bitmap_offset, block_offset);
165
166 // disabled by reason
167 #if 0
168 #ifdef CACHE
169 if (bitmap_offset != s->last_bitmap)
170 {
171 lseek(s->fd, bitmap_offset, SEEK_SET);
172
173 s->last_bitmap = bitmap_offset;
174
175 // Scary! Bitmap is stored as big endian 32bit entries,
176 // while we used to look it up byte by byte
177 read(s->fd, s->pageentry_u8, 512);
178 for (i = 0; i < 128; i++)
179 be32_to_cpus(&s->pageentry_u32[i]);
180 }
181
182 if ((s->pageentry_u8[pageentry_index / 8] >> (pageentry_index % 8)) & 1)
183 return -1;
184 #else
185 lseek(s->fd, bitmap_offset + (pageentry_index / 8), SEEK_SET);
186
187 read(s->fd, &bitmap_entry, 1);
188
189 if ((bitmap_entry >> (pageentry_index % 8)) & 1)
190 return -1; // not allocated
191 #endif
192 #endif
193 lseek(s->fd, block_offset, SEEK_SET);
194
195 return 0;
196 }
197
198 static int vpc_read(BlockDriverState *bs, int64_t sector_num,
199 uint8_t *buf, int nb_sectors)
200 {
201 BDRVVPCState *s = bs->opaque;
202 int ret;
203
204 while (nb_sectors > 0) {
205 if (!seek_to_sector(bs, sector_num))
206 {
207 ret = read(s->fd, buf, 512);
208 if (ret != 512)
209 return -1;
210 }
211 else
212 memset(buf, 0, 512);
213 nb_sectors--;
214 sector_num++;
215 buf += 512;
216 }
217 return 0;
218 }
219
220 static void vpc_close(BlockDriverState *bs)
221 {
222 BDRVVPCState *s = bs->opaque;
223 qemu_free(s->pagetable);
224 #ifdef CACHE
225 qemu_free(s->pageentry_u8);
226 #endif
227 close(s->fd);
228 }
229
230 BlockDriver bdrv_vpc = {
231 "vpc",
232 sizeof(BDRVVPCState),
233 vpc_probe,
234 vpc_open,
235 vpc_read,
236 NULL,
237 vpc_close,
238 };
0 /* vim:set shiftwidth=4 ts=8: */
1 /*
2 * QEMU Block driver for virtual VFAT (shadows a local directory)
3 *
4 * Copyright (c) 2004,2005 Johannes E. Schindelin
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 #include <sys/stat.h>
25 #include <dirent.h>
26 #include <assert.h>
27 #include "qemu-common.h"
28 #include "block_int.h"
29
30 #ifndef S_IWGRP
31 #define S_IWGRP 0
32 #endif
33 #ifndef S_IWOTH
34 #define S_IWOTH 0
35 #endif
36
37 /* TODO: add ":bootsector=blabla.img:" */
38 /* LATER TODO: add automatic boot sector generation from
39 BOOTEASY.ASM and Ranish Partition Manager
40 Note that DOS assumes the system files to be the first files in the
41 file system (test if the boot sector still relies on that fact)! */
42 /* MAYBE TODO: write block-visofs.c */
43 /* TODO: call try_commit() only after a timeout */
44
45 /* #define DEBUG */
46
47 #ifdef DEBUG
48
49 #define DLOG(a) a
50
51 #undef stderr
52 #define stderr STDERR
53 FILE* stderr = NULL;
54
55 static void checkpoint();
56
57 #ifdef __MINGW32__
58 void nonono(const char* file, int line, const char* msg) {
59 fprintf(stderr, "Nonono! %s:%d %s\n", file, line, msg);
60 exit(-5);
61 }
62 #undef assert
63 #define assert(a) do {if (!(a)) nonono(__FILE__, __LINE__, #a);}while(0)
64 #endif
65
66 #else
67
68 #define DLOG(a)
69
70 #endif
71
72 /* dynamic array functions */
73 typedef struct array_t {
74 char* pointer;
75 unsigned int size,next,item_size;
76 } array_t;
77
78 static inline void array_init(array_t* array,unsigned int item_size)
79 {
80 array->pointer=0;
81 array->size=0;
82 array->next=0;
83 array->item_size=item_size;
84 }
85
86 static inline void array_free(array_t* array)
87 {
88 if(array->pointer)
89 free(array->pointer);
90 array->size=array->next=0;
91 }
92
93 /* does not automatically grow */
94 static inline void* array_get(array_t* array,unsigned int index) {
95 assert(index >= 0);
96 assert(index < array->next);
97 return array->pointer + index * array->item_size;
98 }
99
100 static inline int array_ensure_allocated(array_t* array, int index)
101 {
102 if((index + 1) * array->item_size > array->size) {
103 int new_size = (index + 32) * array->item_size;
104 array->pointer = realloc(array->pointer, new_size);
105 if (!array->pointer)
106 return -1;
107 array->size = new_size;
108 array->next = index + 1;
109 }
110
111 return 0;
112 }
113
114 static inline void* array_get_next(array_t* array) {
115 unsigned int next = array->next;
116 void* result;
117
118 if (array_ensure_allocated(array, next) < 0)
119 return NULL;
120
121 array->next = next + 1;
122 result = array_get(array, next);
123
124 return result;
125 }
126
127 static inline void* array_insert(array_t* array,unsigned int index,unsigned int count) {
128 if((array->next+count)*array->item_size>array->size) {
129 int increment=count*array->item_size;
130 array->pointer=realloc(array->pointer,array->size+increment);
131 if(!array->pointer)
132 return 0;
133 array->size+=increment;
134 }
135 memmove(array->pointer+(index+count)*array->item_size,
136 array->pointer+index*array->item_size,
137 (array->next-index)*array->item_size);
138 array->next+=count;
139 return array->pointer+index*array->item_size;
140 }
141
142 /* this performs a "roll", so that the element which was at index_from becomes
143 * index_to, but the order of all other elements is preserved. */
144 static inline int array_roll(array_t* array,int index_to,int index_from,int count)
145 {
146 char* buf;
147 char* from;
148 char* to;
149 int is;
150
151 if(!array ||
152 index_to<0 || index_to>=array->next ||
153 index_from<0 || index_from>=array->next)
154 return -1;
155
156 if(index_to==index_from)
157 return 0;
158
159 is=array->item_size;
160 from=array->pointer+index_from*is;
161 to=array->pointer+index_to*is;
162 buf=malloc(is*count);
163 memcpy(buf,from,is*count);
164
165 if(index_to<index_from)
166 memmove(to+is*count,to,from-to);
167 else
168 memmove(from,from+is*count,to-from);
169
170 memcpy(to,buf,is*count);
171
172 free(buf);
173
174 return 0;
175 }
176
177 static inline int array_remove_slice(array_t* array,int index, int count)
178 {
179 assert(index >=0);
180 assert(count > 0);
181 assert(index + count <= array->next);
182 if(array_roll(array,array->next-1,index,count))
183 return -1;
184 array->next -= count;
185 return 0;
186 }
187
188 static int array_remove(array_t* array,int index)
189 {
190 return array_remove_slice(array, index, 1);
191 }
192
193 /* return the index for a given member */
194 static int array_index(array_t* array, void* pointer)
195 {
196 size_t offset = (char*)pointer - array->pointer;
197 assert(offset >= 0);
198 assert((offset % array->item_size) == 0);
199 assert(offset/array->item_size < array->next);
200 return offset/array->item_size;
201 }
202
203 /* These structures are used to fake a disk and the VFAT filesystem.
204 * For this reason we need to use __attribute__((packed)). */
205
206 typedef struct bootsector_t {
207 uint8_t jump[3];
208 uint8_t name[8];
209 uint16_t sector_size;
210 uint8_t sectors_per_cluster;
211 uint16_t reserved_sectors;
212 uint8_t number_of_fats;
213 uint16_t root_entries;
214 uint16_t total_sectors16;
215 uint8_t media_type;
216 uint16_t sectors_per_fat;
217 uint16_t sectors_per_track;
218 uint16_t number_of_heads;
219 uint32_t hidden_sectors;
220 uint32_t total_sectors;
221 union {
222 struct {
223 uint8_t drive_number;
224 uint8_t current_head;
225 uint8_t signature;
226 uint32_t id;
227 uint8_t volume_label[11];
228 } __attribute__((packed)) fat16;
229 struct {
230 uint32_t sectors_per_fat;
231 uint16_t flags;
232 uint8_t major,minor;
233 uint32_t first_cluster_of_root_directory;
234 uint16_t info_sector;
235 uint16_t backup_boot_sector;
236 uint16_t ignored;
237 } __attribute__((packed)) fat32;
238 } u;
239 uint8_t fat_type[8];
240 uint8_t ignored[0x1c0];
241 uint8_t magic[2];
242 } __attribute__((packed)) bootsector_t;
243
244 typedef struct {
245 uint8_t head;
246 uint8_t sector;
247 uint8_t cylinder;
248 } mbr_chs_t;
249
250 typedef struct partition_t {
251 uint8_t attributes; /* 0x80 = bootable */
252 mbr_chs_t start_CHS;
253 uint8_t fs_type; /* 0x1 = FAT12, 0x6 = FAT16, 0xe = FAT16_LBA, 0xb = FAT32, 0xc = FAT32_LBA */
254 mbr_chs_t end_CHS;
255 uint32_t start_sector_long;
256 uint32_t length_sector_long;
257 } __attribute__((packed)) partition_t;
258
259 typedef struct mbr_t {
260 uint8_t ignored[0x1b8];
261 uint32_t nt_id;
262 uint8_t ignored2[2];
263 partition_t partition[4];
264 uint8_t magic[2];
265 } __attribute__((packed)) mbr_t;
266
267 typedef struct direntry_t {
268 uint8_t name[8];
269 uint8_t extension[3];
270 uint8_t attributes;
271 uint8_t reserved[2];
272 uint16_t ctime;
273 uint16_t cdate;
274 uint16_t adate;
275 uint16_t begin_hi;
276 uint16_t mtime;
277 uint16_t mdate;
278 uint16_t begin;
279 uint32_t size;
280 } __attribute__((packed)) direntry_t;
281
282 /* this structure are used to transparently access the files */
283
284 typedef struct mapping_t {
285 /* begin is the first cluster, end is the last+1 */
286 uint32_t begin,end;
287 /* as s->directory is growable, no pointer may be used here */
288 unsigned int dir_index;
289 /* the clusters of a file may be in any order; this points to the first */
290 int first_mapping_index;
291 union {
292 /* offset is
293 * - the offset in the file (in clusters) for a file, or
294 * - the next cluster of the directory for a directory, and
295 * - the address of the buffer for a faked entry
296 */
297 struct {
298 uint32_t offset;
299 } file;
300 struct {
301 int parent_mapping_index;
302 int first_dir_index;
303 } dir;
304 } info;
305 /* path contains the full path, i.e. it always starts with s->path */
306 char* path;
307
308 enum { MODE_UNDEFINED = 0, MODE_NORMAL = 1, MODE_MODIFIED = 2,
309 MODE_DIRECTORY = 4, MODE_FAKED = 8,
310 MODE_DELETED = 16, MODE_RENAMED = 32 } mode;
311 int read_only;
312 } mapping_t;
313
314 #ifdef DEBUG
315 static void print_direntry(const struct direntry_t*);
316 static void print_mapping(const struct mapping_t* mapping);
317 #endif
318
319 /* here begins the real VVFAT driver */
320
321 typedef struct BDRVVVFATState {
322 BlockDriverState* bs; /* pointer to parent */
323 unsigned int first_sectors_number; /* 1 for a single partition, 0x40 for a disk with partition table */
324 unsigned char first_sectors[0x40*0x200];
325
326 int fat_type; /* 16 or 32 */
327 array_t fat,directory,mapping;
328
329 unsigned int cluster_size;
330 unsigned int sectors_per_cluster;
331 unsigned int sectors_per_fat;
332 unsigned int sectors_of_root_directory;
333 uint32_t last_cluster_of_root_directory;
334 unsigned int faked_sectors; /* how many sectors are faked before file data */
335 uint32_t sector_count; /* total number of sectors of the partition */
336 uint32_t cluster_count; /* total number of clusters of this partition */
337 uint32_t max_fat_value;
338
339 int current_fd;
340 mapping_t* current_mapping;
341 unsigned char* cluster; /* points to current cluster */
342 unsigned char* cluster_buffer; /* points to a buffer to hold temp data */
343 unsigned int current_cluster;
344
345 /* write support */
346 BlockDriverState* write_target;
347 char* qcow_filename;
348 BlockDriverState* qcow;
349 void* fat2;
350 char* used_clusters;
351 array_t commits;
352 const char* path;
353 int downcase_short_names;
354 } BDRVVVFATState;
355
356 /* take the sector position spos and convert it to Cylinder/Head/Sector position
357 * if the position is outside the specified geometry, fill maximum value for CHS
358 * and return 1 to signal overflow.
359 */
360 static int sector2CHS(BlockDriverState* bs, mbr_chs_t * chs, int spos){
361 int head,sector;
362 sector = spos % (bs->secs); spos/= bs->secs;
363 head = spos % (bs->heads); spos/= bs->heads;
364 if(spos >= bs->cyls){
365 /* Overflow,
366 it happens if 32bit sector positions are used, while CHS is only 24bit.
367 Windows/Dos is said to take 1023/255/63 as nonrepresentable CHS */
368 chs->head = 0xFF;
369 chs->sector = 0xFF;
370 chs->cylinder = 0xFF;
371 return 1;
372 }
373 chs->head = (uint8_t)head;
374 chs->sector = (uint8_t)( (sector+1) | ((spos>>8)<<6) );
375 chs->cylinder = (uint8_t)spos;
376 return 0;
377 }
378
379 static void init_mbr(BDRVVVFATState* s)
380 {
381 /* TODO: if the files mbr.img and bootsect.img exist, use them */
382 mbr_t* real_mbr=(mbr_t*)s->first_sectors;
383 partition_t* partition=&(real_mbr->partition[0]);
384 int lba;
385
386 memset(s->first_sectors,0,512);
387
388 /* Win NT Disk Signature */
389 real_mbr->nt_id= cpu_to_le32(0xbe1afdfa);
390
391 partition->attributes=0x80; /* bootable */
392
393 /* LBA is used when partition is outside the CHS geometry */
394 lba = sector2CHS(s->bs, &partition->start_CHS, s->first_sectors_number-1);
395 lba|= sector2CHS(s->bs, &partition->end_CHS, s->sector_count);
396
397 /*LBA partitions are identified only by start/length_sector_long not by CHS*/
398 partition->start_sector_long =cpu_to_le32(s->first_sectors_number-1);
399 partition->length_sector_long=cpu_to_le32(s->sector_count - s->first_sectors_number+1);
400
401 /* FAT12/FAT16/FAT32 */
402 /* DOS uses different types when partition is LBA,
403 probably to prevent older versions from using CHS on them */
404 partition->fs_type= s->fat_type==12 ? 0x1:
405 s->fat_type==16 ? (lba?0xe:0x06):
406 /*fat_tyoe==32*/ (lba?0xc:0x0b);
407
408 real_mbr->magic[0]=0x55; real_mbr->magic[1]=0xaa;
409 }
410
411 /* direntry functions */
412
413 /* dest is assumed to hold 258 bytes, and pads with 0xffff up to next multiple of 26 */
414 static inline int short2long_name(char* dest,const char* src)
415 {
416 int i;
417 int len;
418 for(i=0;i<129 && src[i];i++) {
419 dest[2*i]=src[i];
420 dest[2*i+1]=0;
421 }
422 len=2*i;
423 dest[2*i]=dest[2*i+1]=0;
424 for(i=2*i+2;(i%26);i++)
425 dest[i]=0xff;
426 return len;
427 }
428
429 static inline direntry_t* create_long_filename(BDRVVVFATState* s,const char* filename)
430 {
431 char buffer[258];
432 int length=short2long_name(buffer,filename),
433 number_of_entries=(length+25)/26,i;
434 direntry_t* entry;
435
436 for(i=0;i<number_of_entries;i++) {
437 entry=array_get_next(&(s->directory));
438 entry->attributes=0xf;
439 entry->reserved[0]=0;
440 entry->begin=0;
441 entry->name[0]=(number_of_entries-i)|(i==0?0x40:0);
442 }
443 for(i=0;i<26*number_of_entries;i++) {
444 int offset=(i%26);
445 if(offset<10) offset=1+offset;
446 else if(offset<22) offset=14+offset-10;
447 else offset=28+offset-22;
448 entry=array_get(&(s->directory),s->directory.next-1-(i/26));
449 entry->name[offset]=buffer[i];
450 }
451 return array_get(&(s->directory),s->directory.next-number_of_entries);
452 }
453
454 static char is_free(const direntry_t* direntry)
455 {
456 /* return direntry->name[0]==0 ; */
457 return direntry->attributes == 0 || direntry->name[0]==0xe5;
458 }
459
460 static char is_volume_label(const direntry_t* direntry)
461 {
462 return direntry->attributes == 0x28;
463 }
464
465 static char is_long_name(const direntry_t* direntry)
466 {
467 return direntry->attributes == 0xf;
468 }
469
470 static char is_short_name(const direntry_t* direntry)
471 {
472 return !is_volume_label(direntry) && !is_long_name(direntry)
473 && !is_free(direntry);
474 }
475
476 static char is_directory(const direntry_t* direntry)
477 {
478 return direntry->attributes & 0x10 && direntry->name[0] != 0xe5;
479 }
480
481 static inline char is_dot(const direntry_t* direntry)
482 {
483 return is_short_name(direntry) && direntry->name[0] == '.';
484 }
485
486 static char is_file(const direntry_t* direntry)
487 {
488 return is_short_name(direntry) && !is_directory(direntry);
489 }
490
491 static inline uint32_t begin_of_direntry(const direntry_t* direntry)
492 {
493 return le16_to_cpu(direntry->begin)|(le16_to_cpu(direntry->begin_hi)<<16);
494 }
495
496 static inline uint32_t filesize_of_direntry(const direntry_t* direntry)
497 {
498 return le32_to_cpu(direntry->size);
499 }
500
501 static void set_begin_of_direntry(direntry_t* direntry, uint32_t begin)
502 {
503 direntry->begin = cpu_to_le16(begin & 0xffff);
504 direntry->begin_hi = cpu_to_le16((begin >> 16) & 0xffff);
505 }
506
507 /* fat functions */
508
509 static inline uint8_t fat_chksum(const direntry_t* entry)
510 {
511 uint8_t chksum=0;
512 int i;
513
514 for(i=0;i<11;i++)
515 chksum=(((chksum&0xfe)>>1)|((chksum&0x01)?0x80:0))
516 +(unsigned char)entry->name[i];
517
518 return chksum;
519 }
520
521 /* if return_time==0, this returns the fat_date, else the fat_time */
522 static uint16_t fat_datetime(time_t time,int return_time) {
523 struct tm* t;
524 #ifdef _WIN32
525 t=localtime(&time); /* this is not thread safe */
526 #else
527 struct tm t1;
528 t=&t1;
529 localtime_r(&time,t);
530 #endif
531 if(return_time)
532 return cpu_to_le16((t->tm_sec/2)|(t->tm_min<<5)|(t->tm_hour<<11));
533 return cpu_to_le16((t->tm_mday)|((t->tm_mon+1)<<5)|((t->tm_year-80)<<9));
534 }
535
536 static inline void fat_set(BDRVVVFATState* s,unsigned int cluster,uint32_t value)
537 {
538 if(s->fat_type==32) {
539 uint32_t* entry=array_get(&(s->fat),cluster);
540 *entry=cpu_to_le32(value);
541 } else if(s->fat_type==16) {
542 uint16_t* entry=array_get(&(s->fat),cluster);
543 *entry=cpu_to_le16(value&0xffff);
544 } else {
545 int offset = (cluster*3/2);
546 unsigned char* p = array_get(&(s->fat), offset);
547 switch (cluster&1) {
548 case 0:
549 p[0] = value&0xff;
550 p[1] = (p[1]&0xf0) | ((value>>8)&0xf);
551 break;
552 case 1:
553 p[0] = (p[0]&0xf) | ((value&0xf)<<4);
554 p[1] = (value>>4);
555 break;
556 }
557 }
558 }
559
560 static inline uint32_t fat_get(BDRVVVFATState* s,unsigned int cluster)
561 {
562 if(s->fat_type==32) {
563 uint32_t* entry=array_get(&(s->fat),cluster);
564 return le32_to_cpu(*entry);
565 } else if(s->fat_type==16) {
566 uint16_t* entry=array_get(&(s->fat),cluster);
567 return le16_to_cpu(*entry);
568 } else {
569 const uint8_t* x=(uint8_t*)(s->fat.pointer)+cluster*3/2;
570 return ((x[0]|(x[1]<<8))>>(cluster&1?4:0))&0x0fff;
571 }
572 }
573
574 static inline int fat_eof(BDRVVVFATState* s,uint32_t fat_entry)
575 {
576 if(fat_entry>s->max_fat_value-8)
577 return -1;
578 return 0;
579 }
580
581 static inline void init_fat(BDRVVVFATState* s)
582 {
583 if (s->fat_type == 12) {
584 array_init(&(s->fat),1);
585 array_ensure_allocated(&(s->fat),
586 s->sectors_per_fat * 0x200 * 3 / 2 - 1);
587 } else {
588 array_init(&(s->fat),(s->fat_type==32?4:2));
589 array_ensure_allocated(&(s->fat),
590 s->sectors_per_fat * 0x200 / s->fat.item_size - 1);
591 }
592 memset(s->fat.pointer,0,s->fat.size);
593
594 switch(s->fat_type) {
595 case 12: s->max_fat_value=0xfff; break;
596 case 16: s->max_fat_value=0xffff; break;
597 case 32: s->max_fat_value=0x0fffffff; break;
598 default: s->max_fat_value=0; /* error... */
599 }
600
601 }
602
603 /* TODO: in create_short_filename, 0xe5->0x05 is not yet handled! */
604 /* TODO: in parse_short_filename, 0x05->0xe5 is not yet handled! */
605 static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s,
606 unsigned int directory_start, const char* filename, int is_dot)
607 {
608 int i,j,long_index=s->directory.next;
609 direntry_t* entry=0;
610 direntry_t* entry_long=0;
611
612 if(is_dot) {
613 entry=array_get_next(&(s->directory));
614 memset(entry->name,0x20,11);
615 memcpy(entry->name,filename,strlen(filename));
616 return entry;
617 }
618
619 entry_long=create_long_filename(s,filename);
620
621 i = strlen(filename);
622 for(j = i - 1; j>0 && filename[j]!='.';j--);
623 if (j > 0)
624 i = (j > 8 ? 8 : j);
625 else if (i > 8)
626 i = 8;
627
628 entry=array_get_next(&(s->directory));
629 memset(entry->name,0x20,11);
630 strncpy((char*)entry->name,filename,i);
631
632 if(j > 0)
633 for (i = 0; i < 3 && filename[j+1+i]; i++)
634 entry->extension[i] = filename[j+1+i];
635
636 /* upcase & remove unwanted characters */
637 for(i=10;i>=0;i--) {
638 if(i==10 || i==7) for(;i>0 && entry->name[i]==' ';i--);
639 if(entry->name[i]<=' ' || entry->name[i]>0x7f
640 || strchr(".*?<>|\":/\\[];,+='",entry->name[i]))
641 entry->name[i]='_';
642 else if(entry->name[i]>='a' && entry->name[i]<='z')
643 entry->name[i]+='A'-'a';
644 }
645
646 /* mangle duplicates */
647 while(1) {
648 direntry_t* entry1=array_get(&(s->directory),directory_start);
649 int j;
650
651 for(;entry1<entry;entry1++)
652 if(!is_long_name(entry1) && !memcmp(entry1->name,entry->name,11))
653 break; /* found dupe */
654 if(entry1==entry) /* no dupe found */
655 break;
656
657 /* use all 8 characters of name */
658 if(entry->name[7]==' ') {
659 int j;
660 for(j=6;j>0 && entry->name[j]==' ';j--)
661 entry->name[j]='~';
662 }
663
664 /* increment number */
665 for(j=7;j>0 && entry->name[j]=='9';j--)
666 entry->name[j]='0';
667 if(j>0) {
668 if(entry->name[j]<'0' || entry->name[j]>'9')
669 entry->name[j]='0';
670 else
671 entry->name[j]++;
672 }
673 }
674
675 /* calculate checksum; propagate to long name */
676 if(entry_long) {
677 uint8_t chksum=fat_chksum(entry);
678
679 /* calculate anew, because realloc could have taken place */
680 entry_long=array_get(&(s->directory),long_index);
681 while(entry_long<entry && is_long_name(entry_long)) {
682 entry_long->reserved[1]=chksum;
683 entry_long++;
684 }
685 }
686
687 return entry;
688 }
689
690 /*
691 * Read a directory. (the index of the corresponding mapping must be passed).
692 */
693 static int read_directory(BDRVVVFATState* s, int mapping_index)
694 {
695 mapping_t* mapping = array_get(&(s->mapping), mapping_index);
696 direntry_t* direntry;
697 const char* dirname = mapping->path;
698 int first_cluster = mapping->begin;
699 int parent_index = mapping->info.dir.parent_mapping_index;
700 mapping_t* parent_mapping = (mapping_t*)
701 (parent_index >= 0 ? array_get(&(s->mapping), parent_index) : 0);
702 int first_cluster_of_parent = parent_mapping ? parent_mapping->begin : -1;
703
704 DIR* dir=opendir(dirname);
705 struct dirent* entry;
706 int i;
707
708 assert(mapping->mode & MODE_DIRECTORY);
709
710 if(!dir) {
711 mapping->end = mapping->begin;
712 return -1;
713 }
714
715 i = mapping->info.dir.first_dir_index =
716 first_cluster == 0 ? 0 : s->directory.next;
717
718 /* actually read the directory, and allocate the mappings */
719 while((entry=readdir(dir))) {
720 unsigned int length=strlen(dirname)+2+strlen(entry->d_name);
721 char* buffer;
722 direntry_t* direntry;
723 struct stat st;
724 int is_dot=!strcmp(entry->d_name,".");
725 int is_dotdot=!strcmp(entry->d_name,"..");
726
727 if(first_cluster == 0 && (is_dotdot || is_dot))
728 continue;
729
730 buffer=(char*)malloc(length);
731 assert(buffer);
732 snprintf(buffer,length,"%s/%s",dirname,entry->d_name);
733
734 if(stat(buffer,&st)<0) {
735 free(buffer);
736 continue;
737 }
738
739 /* create directory entry for this file */
740 direntry=create_short_and_long_name(s, i, entry->d_name,
741 is_dot || is_dotdot);
742 direntry->attributes=(S_ISDIR(st.st_mode)?0x10:0x20);
743 direntry->reserved[0]=direntry->reserved[1]=0;
744 direntry->ctime=fat_datetime(st.st_ctime,1);
745 direntry->cdate=fat_datetime(st.st_ctime,0);
746 direntry->adate=fat_datetime(st.st_atime,0);
747 direntry->begin_hi=0;
748 direntry->mtime=fat_datetime(st.st_mtime,1);
749 direntry->mdate=fat_datetime(st.st_mtime,0);
750 if(is_dotdot)
751 set_begin_of_direntry(direntry, first_cluster_of_parent);
752 else if(is_dot)
753 set_begin_of_direntry(direntry, first_cluster);
754 else
755 direntry->begin=0; /* do that later */
756 if (st.st_size > 0x7fffffff) {
757 fprintf(stderr, "File %s is larger than 2GB\n", buffer);
758 free(buffer);
759 return -2;
760 }
761 direntry->size=cpu_to_le32(S_ISDIR(st.st_mode)?0:st.st_size);
762
763 /* create mapping for this file */
764 if(!is_dot && !is_dotdot && (S_ISDIR(st.st_mode) || st.st_size)) {
765 s->current_mapping=(mapping_t*)array_get_next(&(s->mapping));
766 s->current_mapping->begin=0;
767 s->current_mapping->end=st.st_size;
768 /*
769 * we get the direntry of the most recent direntry, which
770 * contains the short name and all the relevant information.
771 */
772 s->current_mapping->dir_index=s->directory.next-1;
773 s->current_mapping->first_mapping_index = -1;
774 if (S_ISDIR(st.st_mode)) {
775 s->current_mapping->mode = MODE_DIRECTORY;
776 s->current_mapping->info.dir.parent_mapping_index =
777 mapping_index;
778 } else {
779 s->current_mapping->mode = MODE_UNDEFINED;
780 s->current_mapping->info.file.offset = 0;
781 }
782 s->current_mapping->path=buffer;
783 s->current_mapping->read_only =
784 (st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) == 0;
785 }
786 }
787 closedir(dir);
788
789 /* fill with zeroes up to the end of the cluster */
790 while(s->directory.next%(0x10*s->sectors_per_cluster)) {
791 direntry_t* direntry=array_get_next(&(s->directory));
792 memset(direntry,0,sizeof(direntry_t));
793 }
794
795 /* TODO: if there are more entries, bootsector has to be adjusted! */
796 #define ROOT_ENTRIES (0x02 * 0x10 * s->sectors_per_cluster)
797 if (mapping_index == 0 && s->directory.next < ROOT_ENTRIES) {
798 /* root directory */
799 int cur = s->directory.next;
800 array_ensure_allocated(&(s->directory), ROOT_ENTRIES - 1);
801 memset(array_get(&(s->directory), cur), 0,
802 (ROOT_ENTRIES - cur) * sizeof(direntry_t));
803 }
804
805 /* reget the mapping, since s->mapping was possibly realloc()ed */
806 mapping = (mapping_t*)array_get(&(s->mapping), mapping_index);
807 first_cluster += (s->directory.next - mapping->info.dir.first_dir_index)
808 * 0x20 / s->cluster_size;
809 mapping->end = first_cluster;
810
811 direntry = (direntry_t*)array_get(&(s->directory), mapping->dir_index);
812 set_begin_of_direntry(direntry, mapping->begin);
813
814 return 0;
815 }
816
817 static inline uint32_t sector2cluster(BDRVVVFATState* s,off_t sector_num)
818 {
819 return (sector_num-s->faked_sectors)/s->sectors_per_cluster;
820 }
821
822 static inline off_t cluster2sector(BDRVVVFATState* s, uint32_t cluster_num)
823 {
824 return s->faked_sectors + s->sectors_per_cluster * cluster_num;
825 }
826
827 static inline uint32_t sector_offset_in_cluster(BDRVVVFATState* s,off_t sector_num)
828 {
829 return (sector_num-s->first_sectors_number-2*s->sectors_per_fat)%s->sectors_per_cluster;
830 }
831
832 #ifdef DBG
833 static direntry_t* get_direntry_for_mapping(BDRVVVFATState* s,mapping_t* mapping)
834 {
835 if(mapping->mode==MODE_UNDEFINED)
836 return 0;
837 return (direntry_t*)(s->directory.pointer+sizeof(direntry_t)*mapping->dir_index);
838 }
839 #endif
840
841 static int init_directories(BDRVVVFATState* s,
842 const char* dirname)
843 {
844 bootsector_t* bootsector;
845 mapping_t* mapping;
846 unsigned int i;
847 unsigned int cluster;
848
849 memset(&(s->first_sectors[0]),0,0x40*0x200);
850
851 s->cluster_size=s->sectors_per_cluster*0x200;
852 s->cluster_buffer=malloc(s->cluster_size);
853 assert(s->cluster_buffer);
854
855 /*
856 * The formula: sc = spf+1+spf*spc*(512*8/fat_type),
857 * where sc is sector_count,
858 * spf is sectors_per_fat,
859 * spc is sectors_per_clusters, and
860 * fat_type = 12, 16 or 32.
861 */
862 i = 1+s->sectors_per_cluster*0x200*8/s->fat_type;
863 s->sectors_per_fat=(s->sector_count+i)/i; /* round up */
864
865 array_init(&(s->mapping),sizeof(mapping_t));
866 array_init(&(s->directory),sizeof(direntry_t));
867
868 /* add volume label */
869 {
870 direntry_t* entry=array_get_next(&(s->directory));
871 entry->attributes=0x28; /* archive | volume label */
872 snprintf((char*)entry->name,11,"QEMU VVFAT");
873 }
874
875 /* Now build FAT, and write back information into directory */
876 init_fat(s);
877
878 s->faked_sectors=s->first_sectors_number+s->sectors_per_fat*2;
879 s->cluster_count=sector2cluster(s, s->sector_count);
880
881 mapping = array_get_next(&(s->mapping));
882 mapping->begin = 0;
883 mapping->dir_index = 0;
884 mapping->info.dir.parent_mapping_index = -1;
885 mapping->first_mapping_index = -1;
886 mapping->path = strdup(dirname);
887 i = strlen(mapping->path);
888 if (i > 0 && mapping->path[i - 1] == '/')
889 mapping->path[i - 1] = '\0';
890 mapping->mode = MODE_DIRECTORY;
891 mapping->read_only = 0;
892 s->path = mapping->path;
893
894 for (i = 0, cluster = 0; i < s->mapping.next; i++) {
895 int j;
896 /* MS-DOS expects the FAT to be 0 for the root directory
897 * (except for the media byte). */
898 /* LATER TODO: still true for FAT32? */
899 int fix_fat = (i != 0);
900 mapping = array_get(&(s->mapping), i);
901
902 if (mapping->mode & MODE_DIRECTORY) {
903 mapping->begin = cluster;
904 if(read_directory(s, i)) {
905 fprintf(stderr, "Could not read directory %s\n",
906 mapping->path);
907 return -1;
908 }
909 mapping = array_get(&(s->mapping), i);
910 } else {
911 assert(mapping->mode == MODE_UNDEFINED);
912 mapping->mode=MODE_NORMAL;
913 mapping->begin = cluster;
914 if (mapping->end > 0) {
915 direntry_t* direntry = array_get(&(s->directory),
916 mapping->dir_index);
917
918 mapping->end = cluster + 1 + (mapping->end-1)/s->cluster_size;
919 set_begin_of_direntry(direntry, mapping->begin);
920 } else {
921 mapping->end = cluster + 1;
922 fix_fat = 0;
923 }
924 }
925
926 assert(mapping->begin < mapping->end);
927
928 /* fix fat for entry */
929 if (fix_fat) {
930 for(j = mapping->begin; j < mapping->end - 1; j++)
931 fat_set(s, j, j+1);
932 fat_set(s, mapping->end - 1, s->max_fat_value);
933 }
934
935 /* next free cluster */
936 cluster = mapping->end;
937
938 if(cluster > s->cluster_count) {
939 fprintf(stderr,"Directory does not fit in FAT%d\n",s->fat_type);
940 return -1;
941 }
942 }
943
944 mapping = array_get(&(s->mapping), 0);
945 s->sectors_of_root_directory = mapping->end * s->sectors_per_cluster;
946 s->last_cluster_of_root_directory = mapping->end;
947
948 /* the FAT signature */
949 fat_set(s,0,s->max_fat_value);
950 fat_set(s,1,s->max_fat_value);
951
952 s->current_mapping = NULL;
953
954 bootsector=(bootsector_t*)(s->first_sectors+(s->first_sectors_number-1)*0x200);
955 bootsector->jump[0]=0xeb;
956 bootsector->jump[1]=0x3e;
957 bootsector->jump[2]=0x90;
958 memcpy(bootsector->name,"QEMU ",8);
959 bootsector->sector_size=cpu_to_le16(0x200);
960 bootsector->sectors_per_cluster=s->sectors_per_cluster;
961 bootsector->reserved_sectors=cpu_to_le16(1);
962 bootsector->number_of_fats=0x2; /* number of FATs */
963 bootsector->root_entries=cpu_to_le16(s->sectors_of_root_directory*0x10);
964 bootsector->total_sectors16=s->sector_count>0xffff?0:cpu_to_le16(s->sector_count);
965 bootsector->media_type=(s->fat_type!=12?0xf8:s->sector_count==5760?0xf9:0xf8); /* media descriptor */
966 s->fat.pointer[0] = bootsector->media_type;
967 bootsector->sectors_per_fat=cpu_to_le16(s->sectors_per_fat);
968 bootsector->sectors_per_track=cpu_to_le16(s->bs->secs);
969 bootsector->number_of_heads=cpu_to_le16(s->bs->heads);
970 bootsector->hidden_sectors=cpu_to_le32(s->first_sectors_number==1?0:0x3f);
971 bootsector->total_sectors=cpu_to_le32(s->sector_count>0xffff?s->sector_count:0);
972
973 /* LATER TODO: if FAT32, this is wrong */
974 bootsector->u.fat16.drive_number=s->fat_type==12?0:0x80; /* assume this is hda (TODO) */
975 bootsector->u.fat16.current_head=0;
976 bootsector->u.fat16.signature=0x29;
977 bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);
978
979 memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11);
980 memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8);
981 bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;
982
983 return 0;
984 }
985
986 #ifdef DEBUG
987 static BDRVVVFATState *vvv = NULL;
988 #endif
989
990 static int enable_write_target(BDRVVVFATState *s);
991 static int is_consistent(BDRVVVFATState *s);
992
993 static int vvfat_open(BlockDriverState *bs, const char* dirname, int flags)
994 {
995 BDRVVVFATState *s = bs->opaque;
996 int floppy = 0;
997 int i;
998
999 #ifdef DEBUG
1000 vvv = s;
1001 #endif
1002
1003 DLOG(if (stderr == NULL) {
1004 stderr = fopen("vvfat.log", "a");
1005 setbuf(stderr, NULL);
1006 })
1007
1008 s->bs = bs;
1009
1010 s->fat_type=16;
1011 /* LATER TODO: if FAT32, adjust */
1012 s->sectors_per_cluster=0x10;
1013 /* 504MB disk*/
1014 bs->cyls=1024; bs->heads=16; bs->secs=63;
1015
1016 s->current_cluster=0xffffffff;
1017
1018 s->first_sectors_number=0x40;
1019 /* read only is the default for safety */
1020 bs->read_only = 1;
1021 s->qcow = s->write_target = NULL;
1022 s->qcow_filename = NULL;
1023 s->fat2 = NULL;
1024 s->downcase_short_names = 1;
1025
1026 if (!strstart(dirname, "fat:", NULL))
1027 return -1;
1028
1029 if (strstr(dirname, ":floppy:")) {
1030 floppy = 1;
1031 s->fat_type = 12;
1032 s->first_sectors_number = 1;
1033 s->sectors_per_cluster=2;
1034 bs->cyls = 80; bs->heads = 2; bs->secs = 36;
1035 }
1036
1037 s->sector_count=bs->cyls*bs->heads*bs->secs;
1038
1039 if (strstr(dirname, ":32:")) {
1040 fprintf(stderr, "Big fat greek warning: FAT32 has not been tested. You are welcome to do so!\n");
1041 s->fat_type = 32;
1042 } else if (strstr(dirname, ":16:")) {
1043 s->fat_type = 16;
1044 } else if (strstr(dirname, ":12:")) {
1045 s->fat_type = 12;
1046 s->sector_count=2880;
1047 }
1048
1049 if (strstr(dirname, ":rw:")) {
1050 if (enable_write_target(s))
1051 return -1;
1052 bs->read_only = 0;
1053 }
1054
1055 i = strrchr(dirname, ':') - dirname;
1056 assert(i >= 3);
1057 if (dirname[i-2] == ':' && isalpha(dirname[i-1]))
1058 /* workaround for DOS drive names */
1059 dirname += i-1;
1060 else
1061 dirname += i+1;
1062
1063 bs->total_sectors=bs->cyls*bs->heads*bs->secs;
1064
1065 if(init_directories(s, dirname))
1066 return -1;
1067
1068 s->sector_count = s->faked_sectors + s->sectors_per_cluster*s->cluster_count;
1069
1070 if(s->first_sectors_number==0x40)
1071 init_mbr(s);
1072
1073 /* for some reason or other, MS-DOS does not like to know about CHS... */
1074 if (floppy)
1075 bs->heads = bs->cyls = bs->secs = 0;
1076
1077 // assert(is_consistent(s));
1078 return 0;
1079 }
1080
1081 static inline void vvfat_close_current_file(BDRVVVFATState *s)
1082 {
1083 if(s->current_mapping) {
1084 s->current_mapping = NULL;
1085 if (s->current_fd) {
1086 close(s->current_fd);
1087 s->current_fd = 0;
1088 }
1089 }
1090 s->current_cluster = -1;
1091 }
1092
1093 /* mappings between index1 and index2-1 are supposed to be ordered
1094 * return value is the index of the last mapping for which end>cluster_num
1095 */
1096 static inline int find_mapping_for_cluster_aux(BDRVVVFATState* s,int cluster_num,int index1,int index2)
1097 {
1098 int index3=index1+1;
1099 while(1) {
1100 mapping_t* mapping;
1101 index3=(index1+index2)/2;
1102 mapping=array_get(&(s->mapping),index3);
1103 assert(mapping->begin < mapping->end);
1104 if(mapping->begin>=cluster_num) {
1105 assert(index2!=index3 || index2==0);
1106 if(index2==index3)
1107 return index1;
1108 index2=index3;
1109 } else {
1110 if(index1==index3)
1111 return mapping->end<=cluster_num ? index2 : index1;
1112 index1=index3;
1113 }
1114 assert(index1<=index2);
1115 DLOG(mapping=array_get(&(s->mapping),index1);
1116 assert(mapping->begin<=cluster_num);
1117 assert(index2 >= s->mapping.next ||
1118 ((mapping = array_get(&(s->mapping),index2)) &&
1119 mapping->end>cluster_num)));
1120 }
1121 }
1122
1123 static inline mapping_t* find_mapping_for_cluster(BDRVVVFATState* s,int cluster_num)
1124 {
1125 int index=find_mapping_for_cluster_aux(s,cluster_num,0,s->mapping.next);
1126 mapping_t* mapping;
1127 if(index>=s->mapping.next)
1128 return 0;
1129 mapping=array_get(&(s->mapping),index);
1130 if(mapping->begin>cluster_num)
1131 return 0;
1132 assert(mapping->begin<=cluster_num && mapping->end>cluster_num);
1133 return mapping;
1134 }
1135
1136 /*
1137 * This function simply compares path == mapping->path. Since the mappings
1138 * are sorted by cluster, this is expensive: O(n).
1139 */
1140 static inline mapping_t* find_mapping_for_path(BDRVVVFATState* s,
1141 const char* path)
1142 {
1143 int i;
1144
1145 for (i = 0; i < s->mapping.next; i++) {
1146 mapping_t* mapping = array_get(&(s->mapping), i);
1147 if (mapping->first_mapping_index < 0 &&
1148 !strcmp(path, mapping->path))
1149 return mapping;
1150 }
1151
1152 return NULL;
1153 }
1154
1155 static int open_file(BDRVVVFATState* s,mapping_t* mapping)
1156 {
1157 if(!mapping)
1158 return -1;
1159 if(!s->current_mapping ||
1160 strcmp(s->current_mapping->path,mapping->path)) {
1161 /* open file */
1162 int fd = open(mapping->path, O_RDONLY | O_BINARY | O_LARGEFILE);
1163 if(fd<0)
1164 return -1;
1165 vvfat_close_current_file(s);
1166 s->current_fd = fd;
1167 s->current_mapping = mapping;
1168 }
1169 return 0;
1170 }
1171
1172 static inline int read_cluster(BDRVVVFATState *s,int cluster_num)
1173 {
1174 if(s->current_cluster != cluster_num) {
1175 int result=0;
1176 off_t offset;
1177 assert(!s->current_mapping || s->current_fd || (s->current_mapping->mode & MODE_DIRECTORY));
1178 if(!s->current_mapping
1179 || s->current_mapping->begin>cluster_num
1180 || s->current_mapping->end<=cluster_num) {
1181 /* binary search of mappings for file */
1182 mapping_t* mapping=find_mapping_for_cluster(s,cluster_num);
1183
1184 assert(!mapping || (cluster_num>=mapping->begin && cluster_num<mapping->end));
1185
1186 if (mapping && mapping->mode & MODE_DIRECTORY) {
1187 vvfat_close_current_file(s);
1188 s->current_mapping = mapping;
1189 read_cluster_directory:
1190 offset = s->cluster_size*(cluster_num-s->current_mapping->begin);
1191 s->cluster = (unsigned char*)s->directory.pointer+offset
1192 + 0x20*s->current_mapping->info.dir.first_dir_index;
1193 assert(((s->cluster-(unsigned char*)s->directory.pointer)%s->cluster_size)==0);
1194 assert((char*)s->cluster+s->cluster_size <= s->directory.pointer+s->directory.next*s->directory.item_size);
1195 s->current_cluster = cluster_num;
1196 return 0;
1197 }
1198
1199 if(open_file(s,mapping))
1200 return -2;
1201 } else if (s->current_mapping->mode & MODE_DIRECTORY)
1202 goto read_cluster_directory;
1203
1204 assert(s->current_fd);
1205
1206 offset=s->cluster_size*(cluster_num-s->current_mapping->begin)+s->current_mapping->info.file.offset;
1207 if(lseek(s->current_fd, offset, SEEK_SET)!=offset)
1208 return -3;
1209 s->cluster=s->cluster_buffer;
1210 result=read(s->current_fd,s->cluster,s->cluster_size);
1211 if(result<0) {
1212 s->current_cluster = -1;
1213 return -1;
1214 }
1215 s->current_cluster = cluster_num;
1216 }
1217 return 0;
1218 }
1219
1220 #ifdef DEBUG
1221 static void hexdump(const void* address, uint32_t len)
1222 {
1223 const unsigned char* p = address;
1224 int i, j;
1225
1226 for (i = 0; i < len; i += 16) {
1227 for (j = 0; j < 16 && i + j < len; j++)
1228 fprintf(stderr, "%02x ", p[i + j]);
1229 for (; j < 16; j++)
1230 fprintf(stderr, " ");
1231 fprintf(stderr, " ");
1232 for (j = 0; j < 16 && i + j < len; j++)
1233 fprintf(stderr, "%c", (p[i + j] < ' ' || p[i + j] > 0x7f) ? '.' : p[i + j]);
1234 fprintf(stderr, "\n");
1235 }
1236 }
1237
1238 static void print_direntry(const direntry_t* direntry)
1239 {
1240 int j = 0;
1241 char buffer[1024];
1242
1243 fprintf(stderr, "direntry 0x%x: ", (int)direntry);
1244 if(!direntry)
1245 return;
1246 if(is_long_name(direntry)) {
1247 unsigned char* c=(unsigned char*)direntry;
1248 int i;
1249 for(i=1;i<11 && c[i] && c[i]!=0xff;i+=2)
1250 #define ADD_CHAR(c) {buffer[j] = (c); if (buffer[j] < ' ') buffer[j] = '°'; j++;}
1251 ADD_CHAR(c[i]);
1252 for(i=14;i<26 && c[i] && c[i]!=0xff;i+=2)
1253 ADD_CHAR(c[i]);
1254 for(i=28;i<32 && c[i] && c[i]!=0xff;i+=2)
1255 ADD_CHAR(c[i]);
1256 buffer[j] = 0;
1257 fprintf(stderr, "%s\n", buffer);
1258 } else {
1259 int i;
1260 for(i=0;i<11;i++)
1261 ADD_CHAR(direntry->name[i]);
1262 buffer[j] = 0;
1263 fprintf(stderr,"%s attributes=0x%02x begin=%d size=%d\n",
1264 buffer,
1265 direntry->attributes,
1266 begin_of_direntry(direntry),le32_to_cpu(direntry->size));
1267 }
1268 }
1269
1270 static void print_mapping(const mapping_t* mapping)
1271 {
1272 fprintf(stderr, "mapping (0x%x): begin, end = %d, %d, dir_index = %d, first_mapping_index = %d, name = %s, mode = 0x%x, " , (int)mapping, mapping->begin, mapping->end, mapping->dir_index, mapping->first_mapping_index, mapping->path, mapping->mode);
1273 if (mapping->mode & MODE_DIRECTORY)
1274 fprintf(stderr, "parent_mapping_index = %d, first_dir_index = %d\n", mapping->info.dir.parent_mapping_index, mapping->info.dir.first_dir_index);
1275 else
1276 fprintf(stderr, "offset = %d\n", mapping->info.file.offset);
1277 }
1278 #endif
1279
1280 static int vvfat_read(BlockDriverState *bs, int64_t sector_num,
1281 uint8_t *buf, int nb_sectors)
1282 {
1283 BDRVVVFATState *s = bs->opaque;
1284 int i;
1285
1286 for(i=0;i<nb_sectors;i++,sector_num++) {
1287 if (sector_num >= s->sector_count)
1288 return -1;
1289 if (s->qcow) {
1290 int n;
1291 if (s->qcow->drv->bdrv_is_allocated(s->qcow,
1292 sector_num, nb_sectors-i, &n)) {
1293 DLOG(fprintf(stderr, "sectors %d+%d allocated\n", (int)sector_num, n));
1294 if (s->qcow->drv->bdrv_read(s->qcow, sector_num, buf+i*0x200, n))
1295 return -1;
1296 i += n - 1;
1297 sector_num += n - 1;
1298 continue;
1299 }
1300 DLOG(fprintf(stderr, "sector %d not allocated\n", (int)sector_num));
1301 }
1302 if(sector_num<s->faked_sectors) {
1303 if(sector_num<s->first_sectors_number)
1304 memcpy(buf+i*0x200,&(s->first_sectors[sector_num*0x200]),0x200);
1305 else if(sector_num-s->first_sectors_number<s->sectors_per_fat)
1306 memcpy(buf+i*0x200,&(s->fat.pointer[(sector_num-s->first_sectors_number)*0x200]),0x200);
1307 else if(sector_num-s->first_sectors_number-s->sectors_per_fat<s->sectors_per_fat)
1308 memcpy(buf+i*0x200,&(s->fat.pointer[(sector_num-s->first_sectors_number-s->sectors_per_fat)*0x200]),0x200);
1309 } else {
1310 uint32_t sector=sector_num-s->faked_sectors,
1311 sector_offset_in_cluster=(sector%s->sectors_per_cluster),
1312 cluster_num=sector/s->sectors_per_cluster;
1313 if(read_cluster(s, cluster_num) != 0) {
1314 /* LATER TODO: strict: return -1; */
1315 memset(buf+i*0x200,0,0x200);
1316 continue;
1317 }
1318 memcpy(buf+i*0x200,s->cluster+sector_offset_in_cluster*0x200,0x200);
1319 }
1320 }
1321 return 0;
1322 }
1323
1324 /* LATER TODO: statify all functions */
1325
1326 /*
1327 * Idea of the write support (use snapshot):
1328 *
1329 * 1. check if all data is consistent, recording renames, modifications,
1330 * new files and directories (in s->commits).
1331 *
1332 * 2. if the data is not consistent, stop committing
1333 *
1334 * 3. handle renames, and create new files and directories (do not yet
1335 * write their contents)
1336 *
1337 * 4. walk the directories, fixing the mapping and direntries, and marking
1338 * the handled mappings as not deleted
1339 *
1340 * 5. commit the contents of the files
1341 *
1342 * 6. handle deleted files and directories
1343 *
1344 */
1345
1346 typedef struct commit_t {
1347 char* path;
1348 union {
1349 struct { uint32_t cluster; } rename;
1350 struct { int dir_index; uint32_t modified_offset; } writeout;
1351 struct { uint32_t first_cluster; } new_file;
1352 struct { uint32_t cluster; } mkdir;
1353 } param;
1354 /* DELETEs and RMDIRs are handled differently: see handle_deletes() */
1355 enum {
1356 ACTION_RENAME, ACTION_WRITEOUT, ACTION_NEW_FILE, ACTION_MKDIR
1357 } action;
1358 } commit_t;
1359
1360 static void clear_commits(BDRVVVFATState* s)
1361 {
1362 int i;
1363 DLOG(fprintf(stderr, "clear_commits (%d commits)\n", s->commits.next));
1364 for (i = 0; i < s->commits.next; i++) {
1365 commit_t* commit = array_get(&(s->commits), i);
1366 assert(commit->path || commit->action == ACTION_WRITEOUT);
1367 if (commit->action != ACTION_WRITEOUT) {
1368 assert(commit->path);
1369 free(commit->path);
1370 } else
1371 assert(commit->path == NULL);
1372 }
1373 s->commits.next = 0;
1374 }
1375
1376 static void schedule_rename(BDRVVVFATState* s,
1377 uint32_t cluster, char* new_path)
1378 {
1379 commit_t* commit = array_get_next(&(s->commits));
1380 commit->path = new_path;
1381 commit->param.rename.cluster = cluster;
1382 commit->action = ACTION_RENAME;
1383 }
1384
1385 static void schedule_writeout(BDRVVVFATState* s,
1386 int dir_index, uint32_t modified_offset)
1387 {
1388 commit_t* commit = array_get_next(&(s->commits));
1389 commit->path = NULL;
1390 commit->param.writeout.dir_index = dir_index;
1391 commit->param.writeout.modified_offset = modified_offset;
1392 commit->action = ACTION_WRITEOUT;
1393 }
1394
1395 static void schedule_new_file(BDRVVVFATState* s,
1396 char* path, uint32_t first_cluster)
1397 {
1398 commit_t* commit = array_get_next(&(s->commits));
1399 commit->path = path;
1400 commit->param.new_file.first_cluster = first_cluster;
1401 commit->action = ACTION_NEW_FILE;
1402 }
1403
1404 static void schedule_mkdir(BDRVVVFATState* s, uint32_t cluster, char* path)
1405 {
1406 commit_t* commit = array_get_next(&(s->commits));
1407 commit->path = path;
1408 commit->param.mkdir.cluster = cluster;
1409 commit->action = ACTION_MKDIR;
1410 }
1411
1412 typedef struct {
1413 unsigned char name[1024];
1414 int checksum, len;
1415 int sequence_number;
1416 } long_file_name;
1417
1418 static void lfn_init(long_file_name* lfn)
1419 {
1420 lfn->sequence_number = lfn->len = 0;
1421 lfn->checksum = 0x100;
1422 }
1423
1424 /* return 0 if parsed successfully, > 0 if no long name, < 0 if error */
1425 static int parse_long_name(long_file_name* lfn,
1426 const direntry_t* direntry)
1427 {
1428 int i, j, offset;
1429 const unsigned char* pointer = (const unsigned char*)direntry;
1430
1431 if (!is_long_name(direntry))
1432 return 1;
1433
1434 if (pointer[0] & 0x40) {
1435 lfn->sequence_number = pointer[0] & 0x3f;
1436 lfn->checksum = pointer[13];
1437 lfn->name[0] = 0;
1438 } else if ((pointer[0] & 0x3f) != --lfn->sequence_number)
1439 return -1;
1440 else if (pointer[13] != lfn->checksum)
1441 return -2;
1442 else if (pointer[12] || pointer[26] || pointer[27])
1443 return -3;
1444
1445 offset = 13 * (lfn->sequence_number - 1);
1446 for (i = 0, j = 1; i < 13; i++, j+=2) {
1447 if (j == 11)
1448 j = 14;
1449 else if (j == 26)
1450 j = 28;
1451
1452 if (pointer[j+1] == 0)
1453 lfn->name[offset + i] = pointer[j];
1454 else if (pointer[j+1] != 0xff || (pointer[0] & 0x40) == 0)
1455 return -4;
1456 else
1457 lfn->name[offset + i] = 0;
1458 }
1459
1460 if (pointer[0] & 0x40)
1461 lfn->len = offset + strlen((char*)lfn->name + offset);
1462
1463 return 0;
1464 }
1465
1466 /* returns 0 if successful, >0 if no short_name, and <0 on error */
1467 static int parse_short_name(BDRVVVFATState* s,
1468 long_file_name* lfn, direntry_t* direntry)
1469 {
1470 int i, j;
1471
1472 if (!is_short_name(direntry))
1473 return 1;
1474
1475 for (j = 7; j >= 0 && direntry->name[j] == ' '; j--);
1476 for (i = 0; i <= j; i++) {
1477 if (direntry->name[i] <= ' ' || direntry->name[i] > 0x7f)
1478 return -1;
1479 else if (s->downcase_short_names)
1480 lfn->name[i] = tolower(direntry->name[i]);
1481 else
1482 lfn->name[i] = direntry->name[i];
1483 }
1484
1485 for (j = 2; j >= 0 && direntry->extension[j] == ' '; j--);
1486 if (j >= 0) {
1487 lfn->name[i++] = '.';
1488 lfn->name[i + j + 1] = '\0';
1489 for (;j >= 0; j--) {
1490 if (direntry->extension[j] <= ' ' || direntry->extension[j] > 0x7f)
1491 return -2;
1492 else if (s->downcase_short_names)
1493 lfn->name[i + j] = tolower(direntry->extension[j]);
1494 else
1495 lfn->name[i + j] = direntry->extension[j];
1496 }
1497 } else
1498 lfn->name[i + j + 1] = '\0';
1499
1500 lfn->len = strlen((char*)lfn->name);
1501
1502 return 0;
1503 }
1504
1505 static inline uint32_t modified_fat_get(BDRVVVFATState* s,
1506 unsigned int cluster)
1507 {
1508 if (cluster < s->last_cluster_of_root_directory) {
1509 if (cluster + 1 == s->last_cluster_of_root_directory)
1510 return s->max_fat_value;
1511 else
1512 return cluster + 1;
1513 }
1514
1515 if (s->fat_type==32) {
1516 uint32_t* entry=((uint32_t*)s->fat2)+cluster;
1517 return le32_to_cpu(*entry);
1518 } else if (s->fat_type==16) {
1519 uint16_t* entry=((uint16_t*)s->fat2)+cluster;
1520 return le16_to_cpu(*entry);
1521 } else {
1522 const uint8_t* x=s->fat2+cluster*3/2;
1523 return ((x[0]|(x[1]<<8))>>(cluster&1?4:0))&0x0fff;
1524 }
1525 }
1526
1527 static inline int cluster_was_modified(BDRVVVFATState* s, uint32_t cluster_num)
1528 {
1529 int was_modified = 0;
1530 int i, dummy;
1531
1532 if (s->qcow == NULL)
1533 return 0;
1534
1535 for (i = 0; !was_modified && i < s->sectors_per_cluster; i++)
1536 was_modified = s->qcow->drv->bdrv_is_allocated(s->qcow,
1537 cluster2sector(s, cluster_num) + i, 1, &dummy);
1538
1539 return was_modified;
1540 }
1541
1542 static const char* get_basename(const char* path)
1543 {
1544 char* basename = strrchr(path, '/');
1545 if (basename == NULL)
1546 return path;
1547 else
1548 return basename + 1; /* strip '/' */
1549 }
1550
1551 /*
1552 * The array s->used_clusters holds the states of the clusters. If it is
1553 * part of a file, it has bit 2 set, in case of a directory, bit 1. If it
1554 * was modified, bit 3 is set.
1555 * If any cluster is allocated, but not part of a file or directory, this
1556 * driver refuses to commit.
1557 */
1558 typedef enum {
1559 USED_DIRECTORY = 1, USED_FILE = 2, USED_ANY = 3, USED_ALLOCATED = 4
1560 } used_t;
1561
1562 /*
1563 * get_cluster_count_for_direntry() not only determines how many clusters
1564 * are occupied by direntry, but also if it was renamed or modified.
1565 *
1566 * A file is thought to be renamed *only* if there already was a file with
1567 * exactly the same first cluster, but a different name.
1568 *
1569 * Further, the files/directories handled by this function are
1570 * assumed to be *not* deleted (and *only* those).
1571 */
1572 static uint32_t get_cluster_count_for_direntry(BDRVVVFATState* s,
1573 direntry_t* direntry, const char* path)
1574 {
1575 /*
1576 * This is a little bit tricky:
1577 * IF the guest OS just inserts a cluster into the file chain,
1578 * and leaves the rest alone, (i.e. the original file had clusters
1579 * 15 -> 16, but now has 15 -> 32 -> 16), then the following happens:
1580 *
1581 * - do_commit will write the cluster into the file at the given
1582 * offset, but
1583 *
1584 * - the cluster which is overwritten should be moved to a later
1585 * position in the file.
1586 *
1587 * I am not aware that any OS does something as braindead, but this
1588 * situation could happen anyway when not committing for a long time.
1589 * Just to be sure that this does not bite us, detect it, and copy the
1590 * contents of the clusters to-be-overwritten into the qcow.
1591 */
1592 int copy_it = 0;
1593 int was_modified = 0;
1594 int32_t ret = 0;
1595
1596 uint32_t cluster_num = begin_of_direntry(direntry);
1597 uint32_t offset = 0;
1598 int first_mapping_index = -1;
1599 mapping_t* mapping = NULL;
1600 const char* basename2 = NULL;
1601
1602 vvfat_close_current_file(s);
1603
1604 /* the root directory */
1605 if (cluster_num == 0)
1606 return 0;
1607
1608 /* write support */
1609 if (s->qcow) {
1610 basename2 = get_basename(path);
1611
1612 mapping = find_mapping_for_cluster(s, cluster_num);
1613
1614 if (mapping) {
1615 const char* basename;
1616
1617 assert(mapping->mode & MODE_DELETED);
1618 mapping->mode &= ~MODE_DELETED;
1619
1620 basename = get_basename(mapping->path);
1621
1622 assert(mapping->mode & MODE_NORMAL);
1623
1624 /* rename */
1625 if (strcmp(basename, basename2))
1626 schedule_rename(s, cluster_num, strdup(path));
1627 } else if (is_file(direntry))
1628 /* new file */
1629 schedule_new_file(s, strdup(path), cluster_num);
1630 else {
1631 assert(0);
1632 return 0;
1633 }
1634 }
1635
1636 while(1) {
1637 if (s->qcow) {
1638 if (!copy_it && cluster_was_modified(s, cluster_num)) {
1639 if (mapping == NULL ||
1640 mapping->begin > cluster_num ||
1641 mapping->end <= cluster_num)
1642 mapping = find_mapping_for_cluster(s, cluster_num);
1643
1644
1645 if (mapping &&
1646 (mapping->mode & MODE_DIRECTORY) == 0) {
1647
1648 /* was modified in qcow */
1649 if (offset != mapping->info.file.offset + s->cluster_size
1650 * (cluster_num - mapping->begin)) {
1651 /* offset of this cluster in file chain has changed */
1652 assert(0);
1653 copy_it = 1;
1654 } else if (offset == 0) {
1655 const char* basename = get_basename(mapping->path);
1656
1657 if (strcmp(basename, basename2))
1658 copy_it = 1;
1659 first_mapping_index = array_index(&(s->mapping), mapping);
1660 }
1661
1662 if (mapping->first_mapping_index != first_mapping_index
1663 && mapping->info.file.offset > 0) {
1664 assert(0);
1665 copy_it = 1;
1666 }
1667
1668 /* need to write out? */
1669 if (!was_modified && is_file(direntry)) {
1670 was_modified = 1;
1671 schedule_writeout(s, mapping->dir_index, offset);
1672 }
1673 }
1674 }
1675
1676 if (copy_it) {
1677 int i, dummy;
1678 /*
1679 * This is horribly inefficient, but that is okay, since
1680 * it is rarely executed, if at all.
1681 */
1682 int64_t offset = cluster2sector(s, cluster_num);
1683
1684 vvfat_close_current_file(s);
1685 for (i = 0; i < s->sectors_per_cluster; i++)
1686 if (!s->qcow->drv->bdrv_is_allocated(s->qcow,
1687 offset + i, 1, &dummy)) {
1688 if (vvfat_read(s->bs,
1689 offset, s->cluster_buffer, 1))
1690 return -1;
1691 if (s->qcow->drv->bdrv_write(s->qcow,
1692 offset, s->cluster_buffer, 1))
1693 return -2;
1694 }
1695 }
1696 }
1697
1698 ret++;
1699 if (s->used_clusters[cluster_num] & USED_ANY)
1700 return 0;
1701 s->used_clusters[cluster_num] = USED_FILE;
1702
1703 cluster_num = modified_fat_get(s, cluster_num);
1704
1705 if (fat_eof(s, cluster_num))
1706 return ret;
1707 else if (cluster_num < 2 || cluster_num > s->max_fat_value - 16)
1708 return -1;
1709
1710 offset += s->cluster_size;
1711 }
1712 }
1713
1714 /*
1715 * This function looks at the modified data (qcow).
1716 * It returns 0 upon inconsistency or error, and the number of clusters
1717 * used by the directory, its subdirectories and their files.
1718 */
1719 static int check_directory_consistency(BDRVVVFATState *s,
1720 int cluster_num, const char* path)
1721 {
1722 int ret = 0;
1723 unsigned char* cluster = malloc(s->cluster_size);
1724 direntry_t* direntries = (direntry_t*)cluster;
1725 mapping_t* mapping = find_mapping_for_cluster(s, cluster_num);
1726
1727 long_file_name lfn;
1728 int path_len = strlen(path);
1729 char path2[PATH_MAX];
1730
1731 assert(path_len < PATH_MAX); /* len was tested before! */
1732 strcpy(path2, path);
1733 path2[path_len] = '/';
1734 path2[path_len + 1] = '\0';
1735
1736 if (mapping) {
1737 const char* basename = get_basename(mapping->path);
1738 const char* basename2 = get_basename(path);
1739
1740 assert(mapping->mode & MODE_DIRECTORY);
1741
1742 assert(mapping->mode & MODE_DELETED);
1743 mapping->mode &= ~MODE_DELETED;
1744
1745 if (strcmp(basename, basename2))
1746 schedule_rename(s, cluster_num, strdup(path));
1747 } else
1748 /* new directory */
1749 schedule_mkdir(s, cluster_num, strdup(path));
1750
1751 lfn_init(&lfn);
1752 do {
1753 int i;
1754 int subret = 0;
1755
1756 ret++;
1757
1758 if (s->used_clusters[cluster_num] & USED_ANY) {
1759 fprintf(stderr, "cluster %d used more than once\n", (int)cluster_num);
1760 return 0;
1761 }
1762 s->used_clusters[cluster_num] = USED_DIRECTORY;
1763
1764 DLOG(fprintf(stderr, "read cluster %d (sector %d)\n", (int)cluster_num, (int)cluster2sector(s, cluster_num)));
1765 subret = vvfat_read(s->bs, cluster2sector(s, cluster_num), cluster,
1766 s->sectors_per_cluster);
1767 if (subret) {
1768 fprintf(stderr, "Error fetching direntries\n");
1769 fail:
1770 free(cluster);
1771 return 0;
1772 }
1773
1774 for (i = 0; i < 0x10 * s->sectors_per_cluster; i++) {
1775 int cluster_count;
1776
1777 DLOG(fprintf(stderr, "check direntry %d: \n", i); print_direntry(direntries + i));
1778 if (is_volume_label(direntries + i) || is_dot(direntries + i) ||
1779 is_free(direntries + i))
1780 continue;
1781
1782 subret = parse_long_name(&lfn, direntries + i);
1783 if (subret < 0) {
1784 fprintf(stderr, "Error in long name\n");
1785 goto fail;
1786 }
1787 if (subret == 0 || is_free(direntries + i))
1788 continue;
1789
1790 if (fat_chksum(direntries+i) != lfn.checksum) {
1791 subret = parse_short_name(s, &lfn, direntries + i);
1792 if (subret < 0) {
1793 fprintf(stderr, "Error in short name (%d)\n", subret);
1794 goto fail;
1795 }
1796 if (subret > 0 || !strcmp((char*)lfn.name, ".")
1797 || !strcmp((char*)lfn.name, ".."))
1798 continue;
1799 }
1800 lfn.checksum = 0x100; /* cannot use long name twice */
1801
1802 if (path_len + 1 + lfn.len >= PATH_MAX) {
1803 fprintf(stderr, "Name too long: %s/%s\n", path, lfn.name);
1804 goto fail;
1805 }
1806 strcpy(path2 + path_len + 1, (char*)lfn.name);
1807
1808 if (is_directory(direntries + i)) {
1809 if (begin_of_direntry(direntries + i) == 0) {
1810 DLOG(fprintf(stderr, "invalid begin for directory: %s\n", path2); print_direntry(direntries + i));
1811 goto fail;
1812 }
1813 cluster_count = check_directory_consistency(s,
1814 begin_of_direntry(direntries + i), path2);
1815 if (cluster_count == 0) {
1816 DLOG(fprintf(stderr, "problem in directory %s:\n", path2); print_direntry(direntries + i));
1817 goto fail;
1818 }
1819 } else if (is_file(direntries + i)) {
1820 /* check file size with FAT */
1821 cluster_count = get_cluster_count_for_direntry(s, direntries + i, path2);
1822 if (cluster_count !=
1823 (le32_to_cpu(direntries[i].size) + s->cluster_size
1824 - 1) / s->cluster_size) {
1825 DLOG(fprintf(stderr, "Cluster count mismatch\n"));
1826 goto fail;
1827 }
1828 } else
1829 assert(0); /* cluster_count = 0; */
1830
1831 ret += cluster_count;
1832 }
1833
1834 cluster_num = modified_fat_get(s, cluster_num);
1835 } while(!fat_eof(s, cluster_num));
1836
1837 free(cluster);
1838 return ret;
1839 }
1840
1841 /* returns 1 on success */
1842 static int is_consistent(BDRVVVFATState* s)
1843 {
1844 int i, check;
1845 int used_clusters_count = 0;
1846
1847 DLOG(checkpoint());
1848 /*
1849 * - get modified FAT
1850 * - compare the two FATs (TODO)
1851 * - get buffer for marking used clusters
1852 * - recurse direntries from root (using bs->bdrv_read to make
1853 * sure to get the new data)
1854 * - check that the FAT agrees with the size
1855 * - count the number of clusters occupied by this directory and
1856 * its files
1857 * - check that the cumulative used cluster count agrees with the
1858 * FAT
1859 * - if all is fine, return number of used clusters
1860 */
1861 if (s->fat2 == NULL) {
1862 int size = 0x200 * s->sectors_per_fat;
1863 s->fat2 = malloc(size);
1864 memcpy(s->fat2, s->fat.pointer, size);
1865 }
1866 check = vvfat_read(s->bs,
1867 s->first_sectors_number, s->fat2, s->sectors_per_fat);
1868 if (check) {
1869 fprintf(stderr, "Could not copy fat\n");
1870 return 0;
1871 }
1872 assert (s->used_clusters);
1873 for (i = 0; i < sector2cluster(s, s->sector_count); i++)
1874 s->used_clusters[i] &= ~USED_ANY;
1875
1876 clear_commits(s);
1877
1878 /* mark every mapped file/directory as deleted.
1879 * (check_directory_consistency() will unmark those still present). */
1880 if (s->qcow)
1881 for (i = 0; i < s->mapping.next; i++) {
1882 mapping_t* mapping = array_get(&(s->mapping), i);
1883 if (mapping->first_mapping_index < 0)
1884 mapping->mode |= MODE_DELETED;
1885 }
1886
1887 used_clusters_count = check_directory_consistency(s, 0, s->path);
1888 if (used_clusters_count <= 0) {
1889 DLOG(fprintf(stderr, "problem in directory\n"));
1890 return 0;
1891 }
1892
1893 check = s->last_cluster_of_root_directory;
1894 for (i = check; i < sector2cluster(s, s->sector_count); i++) {
1895 if (modified_fat_get(s, i)) {
1896 if(!s->used_clusters[i]) {
1897 DLOG(fprintf(stderr, "FAT was modified (%d), but cluster is not used?\n", i));
1898 return 0;
1899 }
1900 check++;
1901 }
1902
1903 if (s->used_clusters[i] == USED_ALLOCATED) {
1904 /* allocated, but not used... */
1905 DLOG(fprintf(stderr, "unused, modified cluster: %d\n", i));
1906 return 0;
1907 }
1908 }
1909
1910 if (check != used_clusters_count)
1911 return 0;
1912
1913 return used_clusters_count;
1914 }
1915
1916 static inline void adjust_mapping_indices(BDRVVVFATState* s,
1917 int offset, int adjust)
1918 {
1919 int i;
1920
1921 for (i = 0; i < s->mapping.next; i++) {
1922 mapping_t* mapping = array_get(&(s->mapping), i);
1923
1924 #define ADJUST_MAPPING_INDEX(name) \
1925 if (mapping->name >= offset) \
1926 mapping->name += adjust
1927
1928 ADJUST_MAPPING_INDEX(first_mapping_index);
1929 if (mapping->mode & MODE_DIRECTORY)
1930 ADJUST_MAPPING_INDEX(info.dir.parent_mapping_index);
1931 }
1932 }
1933
1934 /* insert or update mapping */
1935 static mapping_t* insert_mapping(BDRVVVFATState* s,
1936 uint32_t begin, uint32_t end)
1937 {
1938 /*
1939 * - find mapping where mapping->begin >= begin,
1940 * - if mapping->begin > begin: insert
1941 * - adjust all references to mappings!
1942 * - else: adjust
1943 * - replace name
1944 */
1945 int index = find_mapping_for_cluster_aux(s, begin, 0, s->mapping.next);
1946 mapping_t* mapping = NULL;
1947 mapping_t* first_mapping = array_get(&(s->mapping), 0);
1948
1949 if (index < s->mapping.next && (mapping = array_get(&(s->mapping), index))
1950 && mapping->begin < begin) {
1951 mapping->end = begin;
1952 index++;
1953 mapping = array_get(&(s->mapping), index);
1954 }
1955 if (index >= s->mapping.next || mapping->begin > begin) {
1956 mapping = array_insert(&(s->mapping), index, 1);
1957 mapping->path = NULL;
1958 adjust_mapping_indices(s, index, +1);
1959 }
1960
1961 mapping->begin = begin;
1962 mapping->end = end;
1963
1964 DLOG(mapping_t* next_mapping;
1965 assert(index + 1 >= s->mapping.next ||
1966 ((next_mapping = array_get(&(s->mapping), index + 1)) &&
1967 next_mapping->begin >= end)));
1968
1969 if (s->current_mapping && first_mapping != (mapping_t*)s->mapping.pointer)
1970 s->current_mapping = array_get(&(s->mapping),
1971 s->current_mapping - first_mapping);
1972
1973 return mapping;
1974 }
1975
1976 static int remove_mapping(BDRVVVFATState* s, int mapping_index)
1977 {
1978 mapping_t* mapping = array_get(&(s->mapping), mapping_index);
1979 mapping_t* first_mapping = array_get(&(s->mapping), 0);
1980
1981 /* free mapping */
1982 if (mapping->first_mapping_index < 0)
1983 free(mapping->path);
1984
1985 /* remove from s->mapping */
1986 array_remove(&(s->mapping), mapping_index);
1987
1988 /* adjust all references to mappings */
1989 adjust_mapping_indices(s, mapping_index, -1);
1990
1991 if (s->current_mapping && first_mapping != (mapping_t*)s->mapping.pointer)
1992 s->current_mapping = array_get(&(s->mapping),
1993 s->current_mapping - first_mapping);
1994
1995 return 0;
1996 }
1997
1998 static void adjust_dirindices(BDRVVVFATState* s, int offset, int adjust)
1999 {
2000 int i;
2001 for (i = 0; i < s->mapping.next; i++) {
2002 mapping_t* mapping = array_get(&(s->mapping), i);
2003 if (mapping->dir_index >= offset)
2004 mapping->dir_index += adjust;
2005 if ((mapping->mode & MODE_DIRECTORY) &&
2006 mapping->info.dir.first_dir_index >= offset)
2007 mapping->info.dir.first_dir_index += adjust;
2008 }
2009 }
2010
2011 static direntry_t* insert_direntries(BDRVVVFATState* s,
2012 int dir_index, int count)
2013 {
2014 /*
2015 * make room in s->directory,
2016 * adjust_dirindices
2017 */
2018 direntry_t* result = array_insert(&(s->directory), dir_index, count);
2019 if (result == NULL)
2020 return NULL;
2021 adjust_dirindices(s, dir_index, count);
2022 return result;
2023 }
2024
2025 static int remove_direntries(BDRVVVFATState* s, int dir_index, int count)
2026 {
2027 int ret = array_remove_slice(&(s->directory), dir_index, count);
2028 if (ret)
2029 return ret;
2030 adjust_dirindices(s, dir_index, -count);
2031 return 0;
2032 }
2033
2034 /*
2035 * Adapt the mappings of the cluster chain starting at first cluster
2036 * (i.e. if a file starts at first_cluster, the chain is followed according
2037 * to the modified fat, and the corresponding entries in s->mapping are
2038 * adjusted)
2039 */
2040 static int commit_mappings(BDRVVVFATState* s,
2041 uint32_t first_cluster, int dir_index)
2042 {
2043 mapping_t* mapping = find_mapping_for_cluster(s, first_cluster);
2044 direntry_t* direntry = array_get(&(s->directory), dir_index);
2045 uint32_t cluster = first_cluster;
2046
2047 vvfat_close_current_file(s);
2048
2049 assert(mapping);
2050 assert(mapping->begin == first_cluster);
2051 mapping->first_mapping_index = -1;
2052 mapping->dir_index = dir_index;
2053 mapping->mode = (dir_index <= 0 || is_directory(direntry)) ?
2054 MODE_DIRECTORY : MODE_NORMAL;
2055
2056 while (!fat_eof(s, cluster)) {
2057 uint32_t c, c1;
2058
2059 for (c = cluster, c1 = modified_fat_get(s, c); c + 1 == c1;
2060 c = c1, c1 = modified_fat_get(s, c1));
2061
2062 c++;
2063 if (c > mapping->end) {
2064 int index = array_index(&(s->mapping), mapping);
2065 int i, max_i = s->mapping.next - index;
2066 for (i = 1; i < max_i && mapping[i].begin < c; i++);
2067 while (--i > 0)
2068 remove_mapping(s, index + 1);
2069 }
2070 assert(mapping == array_get(&(s->mapping), s->mapping.next - 1)
2071 || mapping[1].begin >= c);
2072 mapping->end = c;
2073
2074 if (!fat_eof(s, c1)) {
2075 int i = find_mapping_for_cluster_aux(s, c1, 0, s->mapping.next);
2076 mapping_t* next_mapping = i >= s->mapping.next ? NULL :
2077 array_get(&(s->mapping), i);
2078
2079 if (next_mapping == NULL || next_mapping->begin > c1) {
2080 int i1 = array_index(&(s->mapping), mapping);
2081
2082 next_mapping = insert_mapping(s, c1, c1+1);
2083
2084 if (c1 < c)
2085 i1++;
2086 mapping = array_get(&(s->mapping), i1);
2087 }
2088
2089 next_mapping->dir_index = mapping->dir_index;
2090 next_mapping->first_mapping_index =
2091 mapping->first_mapping_index < 0 ?
2092 array_index(&(s->mapping), mapping) :
2093 mapping->first_mapping_index;
2094 next_mapping->path = mapping->path;
2095 next_mapping->mode = mapping->mode;
2096 next_mapping->read_only = mapping->read_only;
2097 if (mapping->mode & MODE_DIRECTORY) {
2098 next_mapping->info.dir.parent_mapping_index =
2099 mapping->info.dir.parent_mapping_index;
2100 next_mapping->info.dir.first_dir_index =
2101 mapping->info.dir.first_dir_index +
2102 0x10 * s->sectors_per_cluster *
2103 (mapping->end - mapping->begin);
2104 } else
2105 next_mapping->info.file.offset = mapping->info.file.offset +
2106 mapping->end - mapping->begin;
2107
2108 mapping = next_mapping;
2109 }
2110
2111 cluster = c1;
2112 }
2113
2114 return 0;
2115 }
2116
2117 static int commit_direntries(BDRVVVFATState* s,
2118 int dir_index, int parent_mapping_index)
2119 {
2120 direntry_t* direntry = array_get(&(s->directory), dir_index);
2121 uint32_t first_cluster = dir_index == 0 ? 0 : begin_of_direntry(direntry);
2122 mapping_t* mapping = find_mapping_for_cluster(s, first_cluster);
2123
2124 int factor = 0x10 * s->sectors_per_cluster;
2125 int old_cluster_count, new_cluster_count;
2126 int current_dir_index = mapping->info.dir.first_dir_index;
2127 int first_dir_index = current_dir_index;
2128 int ret, i;
2129 uint32_t c;
2130
2131 DLOG(fprintf(stderr, "commit_direntries for %s, parent_mapping_index %d\n", mapping->path, parent_mapping_index));
2132
2133 assert(direntry);
2134 assert(mapping);
2135 assert(mapping->begin == first_cluster);
2136 assert(mapping->info.dir.first_dir_index < s->directory.next);
2137 assert(mapping->mode & MODE_DIRECTORY);
2138 assert(dir_index == 0 || is_directory(direntry));
2139
2140 mapping->info.dir.parent_mapping_index = parent_mapping_index;
2141
2142 if (first_cluster == 0) {
2143 old_cluster_count = new_cluster_count =
2144 s->last_cluster_of_root_directory;
2145 } else {
2146 for (old_cluster_count = 0, c = first_cluster; !fat_eof(s, c);
2147 c = fat_get(s, c))
2148 old_cluster_count++;
2149
2150 for (new_cluster_count = 0, c = first_cluster; !fat_eof(s, c);
2151 c = modified_fat_get(s, c))
2152 new_cluster_count++;
2153 }
2154
2155 if (new_cluster_count > old_cluster_count) {
2156 if (insert_direntries(s,
2157 current_dir_index + factor * old_cluster_count,
2158 factor * (new_cluster_count - old_cluster_count)) == NULL)
2159 return -1;
2160 } else if (new_cluster_count < old_cluster_count)
2161 remove_direntries(s,
2162 current_dir_index + factor * new_cluster_count,
2163 factor * (old_cluster_count - new_cluster_count));
2164
2165 for (c = first_cluster; !fat_eof(s, c); c = modified_fat_get(s, c)) {
2166 void* direntry = array_get(&(s->directory), current_dir_index);
2167 int ret = vvfat_read(s->bs, cluster2sector(s, c), direntry,
2168 s->sectors_per_cluster);
2169 if (ret)
2170 return ret;
2171 assert(!strncmp(s->directory.pointer, "QEMU", 4));
2172 current_dir_index += factor;
2173 }
2174
2175 ret = commit_mappings(s, first_cluster, dir_index);
2176 if (ret)
2177 return ret;
2178
2179 /* recurse */
2180 for (i = 0; i < factor * new_cluster_count; i++) {
2181 direntry = array_get(&(s->directory), first_dir_index + i);
2182 if (is_directory(direntry) && !is_dot(direntry)) {
2183 mapping = find_mapping_for_cluster(s, first_cluster);
2184 assert(mapping->mode & MODE_DIRECTORY);
2185 ret = commit_direntries(s, first_dir_index + i,
2186 array_index(&(s->mapping), mapping));
2187 if (ret)
2188 return ret;
2189 }
2190 }
2191
2192 return 0;
2193 }
2194
2195 /* commit one file (adjust contents, adjust mapping),
2196 return first_mapping_index */
2197 static int commit_one_file(BDRVVVFATState* s,
2198 int dir_index, uint32_t offset)
2199 {
2200 direntry_t* direntry = array_get(&(s->directory), dir_index);
2201 uint32_t c = begin_of_direntry(direntry);
2202 uint32_t first_cluster = c;
2203 mapping_t* mapping = find_mapping_for_cluster(s, c);
2204 uint32_t size = filesize_of_direntry(direntry);
2205 char* cluster = malloc(s->cluster_size);
2206 uint32_t i;
2207 int fd = 0;
2208
2209 assert(offset < size);
2210 assert((offset % s->cluster_size) == 0);
2211
2212 for (i = s->cluster_size; i < offset; i += s->cluster_size)
2213 c = modified_fat_get(s, c);
2214
2215 fd = open(mapping->path, O_RDWR | O_CREAT | O_BINARY, 0666);
2216 if (fd < 0) {
2217 fprintf(stderr, "Could not open %s... (%s, %d)\n", mapping->path,
2218 strerror(errno), errno);
2219 return fd;
2220 }
2221 if (offset > 0)
2222 if (lseek(fd, offset, SEEK_SET) != offset)
2223 return -3;
2224
2225 while (offset < size) {
2226 uint32_t c1;
2227 int rest_size = (size - offset > s->cluster_size ?
2228 s->cluster_size : size - offset);
2229 int ret;
2230
2231 c1 = modified_fat_get(s, c);
2232
2233 assert((size - offset == 0 && fat_eof(s, c)) ||
2234 (size > offset && c >=2 && !fat_eof(s, c)));
2235 assert(size >= 0);
2236
2237 ret = vvfat_read(s->bs, cluster2sector(s, c),
2238 (uint8_t*)cluster, (rest_size + 0x1ff) / 0x200);
2239
2240 if (ret < 0)
2241 return ret;
2242
2243 if (write(fd, cluster, rest_size) < 0)
2244 return -2;
2245
2246 offset += rest_size;
2247 c = c1;
2248 }
2249
2250 if(ftruncate(fd, size)<0) return -1;
2251 close(fd);
2252
2253 return commit_mappings(s, first_cluster, dir_index);
2254 }
2255
2256 #ifdef DEBUG
2257 /* test, if all mappings point to valid direntries */
2258 static void check1(BDRVVVFATState* s)
2259 {
2260 int i;
2261 for (i = 0; i < s->mapping.next; i++) {
2262 mapping_t* mapping = array_get(&(s->mapping), i);
2263 if (mapping->mode & MODE_DELETED) {
2264 fprintf(stderr, "deleted\n");
2265 continue;
2266 }
2267 assert(mapping->dir_index >= 0);
2268 assert(mapping->dir_index < s->directory.next);
2269 direntry_t* direntry = array_get(&(s->directory), mapping->dir_index);
2270 assert(mapping->begin == begin_of_direntry(direntry) || mapping->first_mapping_index >= 0);
2271 if (mapping->mode & MODE_DIRECTORY) {
2272 assert(mapping->info.dir.first_dir_index + 0x10 * s->sectors_per_cluster * (mapping->end - mapping->begin) <= s->directory.next);
2273 assert((mapping->info.dir.first_dir_index % (0x10 * s->sectors_per_cluster)) == 0);
2274 }
2275 }
2276 }
2277
2278 /* test, if all direntries have mappings */
2279 static void check2(BDRVVVFATState* s)
2280 {
2281 int i;
2282 int first_mapping = -1;
2283
2284 for (i = 0; i < s->directory.next; i++) {
2285 direntry_t* direntry = array_get(&(s->directory), i);
2286
2287 if (is_short_name(direntry) && begin_of_direntry(direntry)) {
2288 mapping_t* mapping = find_mapping_for_cluster(s, begin_of_direntry(direntry));
2289 assert(mapping);
2290 assert(mapping->dir_index == i || is_dot(direntry));
2291 assert(mapping->begin == begin_of_direntry(direntry) || is_dot(direntry));
2292 }
2293
2294 if ((i % (0x10 * s->sectors_per_cluster)) == 0) {
2295 /* cluster start */
2296 int j, count = 0;
2297
2298 for (j = 0; j < s->mapping.next; j++) {
2299 mapping_t* mapping = array_get(&(s->mapping), j);
2300 if (mapping->mode & MODE_DELETED)
2301 continue;
2302 if (mapping->mode & MODE_DIRECTORY) {
2303 if (mapping->info.dir.first_dir_index <= i && mapping->info.dir.first_dir_index + 0x10 * s->sectors_per_cluster > i) {
2304 assert(++count == 1);
2305 if (mapping->first_mapping_index == -1)
2306 first_mapping = array_index(&(s->mapping), mapping);
2307 else
2308 assert(first_mapping == mapping->first_mapping_index);
2309 if (mapping->info.dir.parent_mapping_index < 0)
2310 assert(j == 0);
2311 else {
2312 mapping_t* parent = array_get(&(s->mapping), mapping->info.dir.parent_mapping_index);
2313 assert(parent->mode & MODE_DIRECTORY);
2314 assert(parent->info.dir.first_dir_index < mapping->info.dir.first_dir_index);
2315 }
2316 }
2317 }
2318 }
2319 if (count == 0)
2320 first_mapping = -1;
2321 }
2322 }
2323 }
2324 #endif
2325
2326 static int handle_renames_and_mkdirs(BDRVVVFATState* s)
2327 {
2328 int i;
2329
2330 #ifdef DEBUG
2331 fprintf(stderr, "handle_renames\n");
2332 for (i = 0; i < s->commits.next; i++) {
2333 commit_t* commit = array_get(&(s->commits), i);
2334 fprintf(stderr, "%d, %s (%d, %d)\n", i, commit->path ? commit->path : "(null)", commit->param.rename.cluster, commit->action);
2335 }
2336 #endif
2337
2338 for (i = 0; i < s->commits.next;) {
2339 commit_t* commit = array_get(&(s->commits), i);
2340 if (commit->action == ACTION_RENAME) {
2341 mapping_t* mapping = find_mapping_for_cluster(s,
2342 commit->param.rename.cluster);
2343 char* old_path = mapping->path;
2344
2345 assert(commit->path);
2346 mapping->path = commit->path;
2347 if (rename(old_path, mapping->path))
2348 return -2;
2349
2350 if (mapping->mode & MODE_DIRECTORY) {
2351 int l1 = strlen(mapping->path);
2352 int l2 = strlen(old_path);
2353 int diff = l1 - l2;
2354 direntry_t* direntry = array_get(&(s->directory),
2355 mapping->info.dir.first_dir_index);
2356 uint32_t c = mapping->begin;
2357 int i = 0;
2358
2359 /* recurse */
2360 while (!fat_eof(s, c)) {
2361 do {
2362 direntry_t* d = direntry + i;
2363
2364 if (is_file(d) || (is_directory(d) && !is_dot(d))) {
2365 mapping_t* m = find_mapping_for_cluster(s,
2366 begin_of_direntry(d));
2367 int l = strlen(m->path);
2368 char* new_path = malloc(l + diff + 1);
2369
2370 assert(!strncmp(m->path, mapping->path, l2));
2371
2372 strcpy(new_path, mapping->path);
2373 strcpy(new_path + l1, m->path + l2);
2374
2375 schedule_rename(s, m->begin, new_path);
2376 }
2377 i++;
2378 } while((i % (0x10 * s->sectors_per_cluster)) != 0);
2379 c = fat_get(s, c);
2380 }
2381 }
2382
2383 free(old_path);
2384 array_remove(&(s->commits), i);
2385 continue;
2386 } else if (commit->action == ACTION_MKDIR) {
2387 mapping_t* mapping;
2388 int j, parent_path_len;
2389
2390 #ifdef __MINGW32__
2391 if (mkdir(commit->path))
2392 return -5;
2393 #else
2394 if (mkdir(commit->path, 0755))
2395 return -5;
2396 #endif
2397
2398 mapping = insert_mapping(s, commit->param.mkdir.cluster,
2399 commit->param.mkdir.cluster + 1);
2400 if (mapping == NULL)
2401 return -6;
2402
2403 mapping->mode = MODE_DIRECTORY;
2404 mapping->read_only = 0;
2405 mapping->path = commit->path;
2406 j = s->directory.next;
2407 assert(j);
2408 insert_direntries(s, s->directory.next,
2409 0x10 * s->sectors_per_cluster);
2410 mapping->info.dir.first_dir_index = j;
2411
2412 parent_path_len = strlen(commit->path)
2413 - strlen(get_basename(commit->path)) - 1;
2414 for (j = 0; j < s->mapping.next; j++) {
2415 mapping_t* m = array_get(&(s->mapping), j);
2416 if (m->first_mapping_index < 0 && m != mapping &&
2417 !strncmp(m->path, mapping->path, parent_path_len) &&
2418 strlen(m->path) == parent_path_len)
2419 break;
2420 }
2421 assert(j < s->mapping.next);
2422 mapping->info.dir.parent_mapping_index = j;
2423
2424 array_remove(&(s->commits), i);
2425 continue;
2426 }
2427
2428 i++;
2429 }
2430 return 0;
2431 }
2432
2433 /*
2434 * TODO: make sure that the short name is not matching *another* file
2435 */
2436 static int handle_commits(BDRVVVFATState* s)
2437 {
2438 int i, fail = 0;
2439
2440 vvfat_close_current_file(s);
2441
2442 for (i = 0; !fail && i < s->commits.next; i++) {
2443 commit_t* commit = array_get(&(s->commits), i);
2444 switch(commit->action) {
2445 case ACTION_RENAME: case ACTION_MKDIR:
2446 assert(0);
2447 fail = -2;
2448 break;
2449 case ACTION_WRITEOUT: {
2450 direntry_t* entry = array_get(&(s->directory),
2451 commit->param.writeout.dir_index);
2452 uint32_t begin = begin_of_direntry(entry);
2453 mapping_t* mapping = find_mapping_for_cluster(s, begin);
2454
2455 assert(mapping);
2456 assert(mapping->begin == begin);
2457 assert(commit->path == NULL);
2458
2459 if (commit_one_file(s, commit->param.writeout.dir_index,
2460 commit->param.writeout.modified_offset))
2461 fail = -3;
2462
2463 break;
2464 }
2465 case ACTION_NEW_FILE: {
2466 int begin = commit->param.new_file.first_cluster;
2467 mapping_t* mapping = find_mapping_for_cluster(s, begin);
2468 direntry_t* entry;
2469 int i;
2470
2471 /* find direntry */
2472 for (i = 0; i < s->directory.next; i++) {
2473 entry = array_get(&(s->directory), i);
2474 if (is_file(entry) && begin_of_direntry(entry) == begin)
2475 break;
2476 }
2477
2478 if (i >= s->directory.next) {
2479 fail = -6;
2480 continue;
2481 }
2482
2483 /* make sure there exists an initial mapping */
2484 if (mapping && mapping->begin != begin) {
2485 mapping->end = begin;
2486 mapping = NULL;
2487 }
2488 if (mapping == NULL) {
2489 mapping = insert_mapping(s, begin, begin+1);
2490 }
2491 /* most members will be fixed in commit_mappings() */
2492 assert(commit->path);
2493 mapping->path = commit->path;
2494 mapping->read_only = 0;
2495 mapping->mode = MODE_NORMAL;
2496 mapping->info.file.offset = 0;
2497
2498 if (commit_one_file(s, i, 0))
2499 fail = -7;
2500
2501 break;
2502 }
2503 default:
2504 assert(0);
2505 }
2506 }
2507 if (i > 0 && array_remove_slice(&(s->commits), 0, i))
2508 return -1;
2509 return fail;
2510 }
2511
2512 static int handle_deletes(BDRVVVFATState* s)
2513 {
2514 int i, deferred = 1, deleted = 1;
2515
2516 /* delete files corresponding to mappings marked as deleted */
2517 /* handle DELETEs and unused mappings (modified_fat_get(s, mapping->begin) == 0) */
2518 while (deferred && deleted) {
2519 deferred = 0;
2520 deleted = 0;
2521
2522 for (i = 1; i < s->mapping.next; i++) {
2523 mapping_t* mapping = array_get(&(s->mapping), i);
2524 if (mapping->mode & MODE_DELETED) {
2525 direntry_t* entry = array_get(&(s->directory),
2526 mapping->dir_index);
2527
2528 if (is_free(entry)) {
2529 /* remove file/directory */
2530 if (mapping->mode & MODE_DIRECTORY) {
2531 int j, next_dir_index = s->directory.next,
2532 first_dir_index = mapping->info.dir.first_dir_index;
2533
2534 if (rmdir(mapping->path) < 0) {
2535 if (errno == ENOTEMPTY) {
2536 deferred++;
2537 continue;
2538 } else
2539 return -5;
2540 }
2541
2542 for (j = 1; j < s->mapping.next; j++) {
2543 mapping_t* m = array_get(&(s->mapping), j);
2544 if (m->mode & MODE_DIRECTORY &&
2545 m->info.dir.first_dir_index >
2546 first_dir_index &&
2547 m->info.dir.first_dir_index <
2548 next_dir_index)
2549 next_dir_index =
2550 m->info.dir.first_dir_index;
2551 }
2552 remove_direntries(s, first_dir_index,
2553 next_dir_index - first_dir_index);
2554
2555 deleted++;
2556 }
2557 } else {
2558 if (unlink(mapping->path))
2559 return -4;
2560 deleted++;
2561 }
2562 DLOG(fprintf(stderr, "DELETE (%d)\n", i); print_mapping(mapping); print_direntry(entry));
2563 remove_mapping(s, i);
2564 }
2565 }
2566 }
2567
2568 return 0;
2569 }
2570
2571 /*
2572 * synchronize mapping with new state:
2573 *
2574 * - copy FAT (with bdrv_read)
2575 * - mark all filenames corresponding to mappings as deleted
2576 * - recurse direntries from root (using bs->bdrv_read)
2577 * - delete files corresponding to mappings marked as deleted
2578 */
2579 static int do_commit(BDRVVVFATState* s)
2580 {
2581 int ret = 0;
2582
2583 /* the real meat are the commits. Nothing to do? Move along! */
2584 if (s->commits.next == 0)
2585 return 0;
2586
2587 vvfat_close_current_file(s);
2588
2589 ret = handle_renames_and_mkdirs(s);
2590 if (ret) {
2591 fprintf(stderr, "Error handling renames (%d)\n", ret);
2592 assert(0);
2593 return ret;
2594 }
2595
2596 /* copy FAT (with bdrv_read) */
2597 memcpy(s->fat.pointer, s->fat2, 0x200 * s->sectors_per_fat);
2598
2599 /* recurse direntries from root (using bs->bdrv_read) */
2600 ret = commit_direntries(s, 0, -1);
2601 if (ret) {
2602 fprintf(stderr, "Fatal: error while committing (%d)\n", ret);
2603 assert(0);
2604 return ret;
2605 }
2606
2607 ret = handle_commits(s);
2608 if (ret) {
2609 fprintf(stderr, "Error handling commits (%d)\n", ret);
2610 assert(0);
2611 return ret;
2612 }
2613
2614 ret = handle_deletes(s);
2615 if (ret) {
2616 fprintf(stderr, "Error deleting\n");
2617 assert(0);
2618 return ret;
2619 }
2620
2621 s->qcow->drv->bdrv_make_empty(s->qcow);
2622
2623 memset(s->used_clusters, 0, sector2cluster(s, s->sector_count));
2624
2625 DLOG(checkpoint());
2626 return 0;
2627 }
2628
2629 static int try_commit(BDRVVVFATState* s)
2630 {
2631 vvfat_close_current_file(s);
2632 DLOG(checkpoint());
2633 if(!is_consistent(s))
2634 return -1;
2635 return do_commit(s);
2636 }
2637
2638 static int vvfat_write(BlockDriverState *bs, int64_t sector_num,
2639 const uint8_t *buf, int nb_sectors)
2640 {
2641 BDRVVVFATState *s = bs->opaque;
2642 int i, ret;
2643
2644 DLOG(checkpoint());
2645
2646 vvfat_close_current_file(s);
2647
2648 /*
2649 * Some sanity checks:
2650 * - do not allow writing to the boot sector
2651 * - do not allow to write non-ASCII filenames
2652 */
2653
2654 if (sector_num < s->first_sectors_number)
2655 return -1;
2656
2657 for (i = sector2cluster(s, sector_num);
2658 i <= sector2cluster(s, sector_num + nb_sectors - 1);) {
2659 mapping_t* mapping = find_mapping_for_cluster(s, i);
2660 if (mapping) {
2661 if (mapping->read_only) {
2662 fprintf(stderr, "Tried to write to write-protected file %s\n",
2663 mapping->path);
2664 return -1;
2665 }
2666
2667 if (mapping->mode & MODE_DIRECTORY) {
2668 int begin = cluster2sector(s, i);
2669 int end = begin + s->sectors_per_cluster, k;
2670 int dir_index;
2671 const direntry_t* direntries;
2672 long_file_name lfn;
2673
2674 lfn_init(&lfn);
2675
2676 if (begin < sector_num)
2677 begin = sector_num;
2678 if (end > sector_num + nb_sectors)
2679 end = sector_num + nb_sectors;
2680 dir_index = mapping->dir_index +
2681 0x10 * (begin - mapping->begin * s->sectors_per_cluster);
2682 direntries = (direntry_t*)(buf + 0x200 * (begin - sector_num));
2683
2684 for (k = 0; k < (end - begin) * 0x10; k++) {
2685 /* do not allow non-ASCII filenames */
2686 if (parse_long_name(&lfn, direntries + k) < 0) {
2687 fprintf(stderr, "Warning: non-ASCII filename\n");
2688 return -1;
2689 }
2690 /* no access to the direntry of a read-only file */
2691 else if (is_short_name(direntries+k) &&
2692 (direntries[k].attributes & 1)) {
2693 if (memcmp(direntries + k,
2694 array_get(&(s->directory), dir_index + k),
2695 sizeof(direntry_t))) {
2696 fprintf(stderr, "Warning: tried to write to write-protected file\n");
2697 return -1;
2698 }
2699 }
2700 }
2701 }
2702 i = mapping->end;
2703 } else
2704 i++;
2705 }
2706
2707 /*
2708 * Use qcow backend. Commit later.
2709 */
2710 DLOG(fprintf(stderr, "Write to qcow backend: %d + %d\n", (int)sector_num, nb_sectors));
2711 ret = s->qcow->drv->bdrv_write(s->qcow, sector_num, buf, nb_sectors);
2712 if (ret < 0) {
2713 fprintf(stderr, "Error writing to qcow backend\n");
2714 return ret;
2715 }
2716
2717 for (i = sector2cluster(s, sector_num);
2718 i <= sector2cluster(s, sector_num + nb_sectors - 1); i++)
2719 if (i >= 0)
2720 s->used_clusters[i] |= USED_ALLOCATED;
2721
2722 DLOG(checkpoint());
2723 /* TODO: add timeout */
2724 try_commit(s);
2725
2726 DLOG(checkpoint());
2727 return 0;
2728 }
2729
2730 static int vvfat_is_allocated(BlockDriverState *bs,
2731 int64_t sector_num, int nb_sectors, int* n)
2732 {
2733 BDRVVVFATState* s = bs->opaque;
2734 *n = s->sector_count - sector_num;
2735 if (*n > nb_sectors)
2736 *n = nb_sectors;
2737 else if (*n < 0)
2738 return 0;
2739 return 1;
2740 }
2741
2742 static int write_target_commit(BlockDriverState *bs, int64_t sector_num,
2743 const uint8_t* buffer, int nb_sectors) {
2744 BDRVVVFATState* s = bs->opaque;
2745 return try_commit(s);
2746 }
2747
2748 static void write_target_close(BlockDriverState *bs) {
2749 BDRVVVFATState* s = bs->opaque;
2750 bdrv_delete(s->qcow);
2751 free(s->qcow_filename);
2752 }
2753
2754 static BlockDriver vvfat_write_target = {
2755 "vvfat_write_target", 0, NULL, NULL, NULL,
2756 write_target_commit,
2757 write_target_close,
2758 NULL, NULL, NULL
2759 };
2760
2761 static int enable_write_target(BDRVVVFATState *s)
2762 {
2763 int size = sector2cluster(s, s->sector_count);
2764 s->used_clusters = calloc(size, 1);
2765
2766 array_init(&(s->commits), sizeof(commit_t));
2767
2768 s->qcow_filename = malloc(1024);
2769 get_tmp_filename(s->qcow_filename, 1024);
2770 if (bdrv_create(&bdrv_qcow,
2771 s->qcow_filename, s->sector_count, "fat:", 0) < 0)
2772 return -1;
2773 s->qcow = bdrv_new("");
2774 if (s->qcow == NULL || bdrv_open(s->qcow, s->qcow_filename, 0) < 0)
2775 return -1;
2776
2777 #ifndef _WIN32
2778 unlink(s->qcow_filename);
2779 #endif
2780
2781 s->bs->backing_hd = calloc(sizeof(BlockDriverState), 1);
2782 s->bs->backing_hd->drv = &vvfat_write_target;
2783 s->bs->backing_hd->opaque = s;
2784
2785 return 0;
2786 }
2787
2788 static void vvfat_close(BlockDriverState *bs)
2789 {
2790 BDRVVVFATState *s = bs->opaque;
2791
2792 vvfat_close_current_file(s);
2793 array_free(&(s->fat));
2794 array_free(&(s->directory));
2795 array_free(&(s->mapping));
2796 if(s->cluster_buffer)
2797 free(s->cluster_buffer);
2798 }
2799
2800 BlockDriver bdrv_vvfat = {
2801 "vvfat",
2802 sizeof(BDRVVVFATState),
2803 NULL, /* no probe for protocols */
2804 vvfat_open,
2805 vvfat_read,
2806 vvfat_write,
2807 vvfat_close,
2808 NULL, /* ??? Not sure if we can do any meaningful flushing. */
2809 NULL,
2810 vvfat_is_allocated,
2811 .protocol_name = "fat",
2812 };
2813
2814 #ifdef DEBUG
2815 static void checkpoint() {
2816 assert(((mapping_t*)array_get(&(vvv->mapping), 0))->end == 2);
2817 check1(vvv);
2818 check2(vvv);
2819 assert(!vvv->current_mapping || vvv->current_fd || (vvv->current_mapping->mode & MODE_DIRECTORY));
2820 #if 0
2821 if (((direntry_t*)vvv->directory.pointer)[1].attributes != 0xf)
2822 fprintf(stderr, "Nonono!\n");
2823 mapping_t* mapping;
2824 direntry_t* direntry;
2825 assert(vvv->mapping.size >= vvv->mapping.item_size * vvv->mapping.next);
2826 assert(vvv->directory.size >= vvv->directory.item_size * vvv->directory.next);
2827 if (vvv->mapping.next<47)
2828 return;
2829 assert((mapping = array_get(&(vvv->mapping), 47)));
2830 assert(mapping->dir_index < vvv->directory.next);
2831 direntry = array_get(&(vvv->directory), mapping->dir_index);
2832 assert(!memcmp(direntry->name, "USB H ", 11) || direntry->name[0]==0);
2833 #endif
2834 return;
2835 /* avoid compiler warnings: */
2836 hexdump(NULL, 100);
2837 remove_mapping(vvv, NULL);
2838 print_mapping(NULL);
2839 print_direntry(NULL);
2840 }
2841 #endif
2842
0 /*
1 * QEMU System Emulator block driver
2 *
3 * Copyright (c) 2003 Fabrice Bellard
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #include "qemu-common.h"
24 #ifndef QEMU_IMG
25 #include "console.h"
26 #endif
27 #include "block_int.h"
28
29 #ifdef _BSD
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <sys/ioctl.h>
33 #include <sys/queue.h>
34 #include <sys/disk.h>
35 #endif
36
37 #define SECTOR_BITS 9
38 #define SECTOR_SIZE (1 << SECTOR_BITS)
39
40 typedef struct BlockDriverAIOCBSync {
41 BlockDriverAIOCB common;
42 QEMUBH *bh;
43 int ret;
44 } BlockDriverAIOCBSync;
45
46 static BlockDriverAIOCB *bdrv_aio_read_em(BlockDriverState *bs,
47 int64_t sector_num, uint8_t *buf, int nb_sectors,
48 BlockDriverCompletionFunc *cb, void *opaque);
49 static BlockDriverAIOCB *bdrv_aio_write_em(BlockDriverState *bs,
50 int64_t sector_num, const uint8_t *buf, int nb_sectors,
51 BlockDriverCompletionFunc *cb, void *opaque);
52 static void bdrv_aio_cancel_em(BlockDriverAIOCB *acb);
53 static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num,
54 uint8_t *buf, int nb_sectors);
55 static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
56 const uint8_t *buf, int nb_sectors);
57
58 BlockDriverState *bdrv_first;
59 static BlockDriver *first_drv;
60
61 int path_is_absolute(const char *path)
62 {
63 const char *p;
64 #ifdef _WIN32
65 /* specific case for names like: "\\.\d:" */
66 if (*path == '/' || *path == '\\')
67 return 1;
68 #endif
69 p = strchr(path, ':');
70 if (p)
71 p++;
72 else
73 p = path;
74 #ifdef _WIN32
75 return (*p == '/' || *p == '\\');
76 #else
77 return (*p == '/');
78 #endif
79 }
80
81 /* if filename is absolute, just copy it to dest. Otherwise, build a
82 path to it by considering it is relative to base_path. URL are
83 supported. */
84 void path_combine(char *dest, int dest_size,
85 const char *base_path,
86 const char *filename)
87 {
88 const char *p, *p1;
89 int len;
90
91 if (dest_size <= 0)
92 return;
93 if (path_is_absolute(filename)) {
94 pstrcpy(dest, dest_size, filename);
95 } else {
96 p = strchr(base_path, ':');
97 if (p)
98 p++;
99 else
100 p = base_path;
101 p1 = strrchr(base_path, '/');
102 #ifdef _WIN32
103 {
104 const char *p2;
105 p2 = strrchr(base_path, '\\');
106 if (!p1 || p2 > p1)
107 p1 = p2;
108 }
109 #endif
110 if (p1)
111 p1++;
112 else
113 p1 = base_path;
114 if (p1 > p)
115 p = p1;
116 len = p - base_path;
117 if (len > dest_size - 1)
118 len = dest_size - 1;
119 memcpy(dest, base_path, len);
120 dest[len] = '\0';
121 pstrcat(dest, dest_size, filename);
122 }
123 }
124
125
126 static void bdrv_register(BlockDriver *bdrv)
127 {
128 if (!bdrv->bdrv_aio_read) {
129 /* add AIO emulation layer */
130 bdrv->bdrv_aio_read = bdrv_aio_read_em;
131 bdrv->bdrv_aio_write = bdrv_aio_write_em;
132 bdrv->bdrv_aio_cancel = bdrv_aio_cancel_em;
133 bdrv->aiocb_size = sizeof(BlockDriverAIOCBSync);
134 } else if (!bdrv->bdrv_read && !bdrv->bdrv_pread) {
135 /* add synchronous IO emulation layer */
136 bdrv->bdrv_read = bdrv_read_em;
137 bdrv->bdrv_write = bdrv_write_em;
138 }
139 bdrv->next = first_drv;
140 first_drv = bdrv;
141 }
142
143 /* create a new block device (by default it is empty) */
144 BlockDriverState *bdrv_new(const char *device_name)
145 {
146 BlockDriverState **pbs, *bs;
147
148 bs = qemu_mallocz(sizeof(BlockDriverState));
149 if(!bs)
150 return NULL;
151 pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
152 if (device_name[0] != '\0') {
153 /* insert at the end */
154 pbs = &bdrv_first;
155 while (*pbs != NULL)
156 pbs = &(*pbs)->next;
157 *pbs = bs;
158 }
159 return bs;
160 }
161
162 BlockDriver *bdrv_find_format(const char *format_name)
163 {
164 BlockDriver *drv1;
165 for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) {
166 if (!strcmp(drv1->format_name, format_name))
167 return drv1;
168 }
169 return NULL;
170 }
171
172 int bdrv_create(BlockDriver *drv,
173 const char *filename, int64_t size_in_sectors,
174 const char *backing_file, int flags)
175 {
176 if (!drv->bdrv_create)
177 return -ENOTSUP;
178 return drv->bdrv_create(filename, size_in_sectors, backing_file, flags);
179 }
180
181 #ifdef _WIN32
182 void get_tmp_filename(char *filename, int size)
183 {
184 char temp_dir[MAX_PATH];
185
186 GetTempPath(MAX_PATH, temp_dir);
187 GetTempFileName(temp_dir, "qem", 0, filename);
188 }
189 #else
190 void get_tmp_filename(char *filename, int size)
191 {
192 int fd;
193 /* XXX: race condition possible */
194 pstrcpy(filename, size, "/tmp/vl.XXXXXX");
195 fd = mkstemp(filename);
196 close(fd);
197 }
198 #endif
199
200 #ifdef _WIN32
201 static int is_windows_drive_prefix(const char *filename)
202 {
203 return (((filename[0] >= 'a' && filename[0] <= 'z') ||
204 (filename[0] >= 'A' && filename[0] <= 'Z')) &&
205 filename[1] == ':');
206 }
207
208 static int is_windows_drive(const char *filename)
209 {
210 if (is_windows_drive_prefix(filename) &&
211 filename[2] == '\0')
212 return 1;
213 if (strstart(filename, "\\\\.\\", NULL) ||
214 strstart(filename, "//./", NULL))
215 return 1;
216 return 0;
217 }
218 #endif
219
220 static BlockDriver *find_protocol(const char *filename)
221 {
222 BlockDriver *drv1;
223 char protocol[128];
224 int len;
225 const char *p;
226
227 #ifdef _WIN32
228 if (is_windows_drive(filename) ||
229 is_windows_drive_prefix(filename))
230 return &bdrv_raw;
231 #endif
232 p = strchr(filename, ':');
233 if (!p)
234 return &bdrv_raw;
235 len = p - filename;
236 if (len > sizeof(protocol) - 1)
237 len = sizeof(protocol) - 1;
238 memcpy(protocol, filename, len);
239 protocol[len] = '\0';
240 for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) {
241 if (drv1->protocol_name &&
242 !strcmp(drv1->protocol_name, protocol))
243 return drv1;
244 }
245 return NULL;
246 }
247
248 /* XXX: force raw format if block or character device ? It would
249 simplify the BSD case */
250 static BlockDriver *find_image_format(const char *filename)
251 {
252 int ret, score, score_max;
253 BlockDriver *drv1, *drv;
254 uint8_t buf[2048];
255 BlockDriverState *bs;
256
257 /* detect host devices. By convention, /dev/cdrom[N] is always
258 recognized as a host CDROM */
259 if (strstart(filename, "/dev/cdrom", NULL))
260 return &bdrv_host_device;
261 #ifdef _WIN32
262 if (is_windows_drive(filename))
263 return &bdrv_host_device;
264 #else
265 {
266 struct stat st;
267 if (stat(filename, &st) >= 0 &&
268 (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
269 return &bdrv_host_device;
270 }
271 }
272 #endif
273
274 #if !defined(AFFLIB)
275 drv = find_protocol(filename);
276 /* no need to test disk image formats for vvfat */
277 if (drv == &bdrv_vvfat)
278 return drv;
279 #endif
280
281 ret = bdrv_file_open(&bs, filename, BDRV_O_RDONLY);
282 if (ret < 0)
283 return NULL;
284 ret = bdrv_pread(bs, 0, buf, sizeof(buf));
285 bdrv_delete(bs);
286 if (ret < 0) {
287 return NULL;
288 }
289
290 score_max = 0;
291 for(drv1 = first_drv; drv1 != NULL; drv1 = drv1->next) {
292 if (drv1->bdrv_probe) {
293 score = drv1->bdrv_probe(buf, ret, filename);
294 if (score > score_max) {
295 score_max = score;
296 drv = drv1;
297 }
298 }
299 }
300 return drv;
301 }
302
303 int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags)
304 {
305 BlockDriverState *bs;
306 int ret;
307
308 bs = bdrv_new("");
309 if (!bs)
310 return -ENOMEM;
311 ret = bdrv_open2(bs, filename, flags | BDRV_O_FILE, NULL);
312 if (ret < 0) {
313 bdrv_delete(bs);
314 return ret;
315 }
316 *pbs = bs;
317 return 0;
318 }
319
320 int bdrv_open(BlockDriverState *bs, const char *filename, int flags)
321 {
322 return bdrv_open2(bs, filename, flags, NULL);
323 }
324
325 int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
326 BlockDriver *drv)
327 {
328 int ret, open_flags;
329 char tmp_filename[PATH_MAX];
330 char backing_filename[PATH_MAX];
331
332 bs->read_only = 0;
333 bs->is_temporary = 0;
334 bs->encrypted = 0;
335
336 if (flags & BDRV_O_SNAPSHOT) {
337 BlockDriverState *bs1;
338 int64_t total_size;
339
340 /* if snapshot, we create a temporary backing file and open it
341 instead of opening 'filename' directly */
342
343 /* if there is a backing file, use it */
344 bs1 = bdrv_new("");
345 if (!bs1) {
346 return -ENOMEM;
347 }
348 if (bdrv_open(bs1, filename, 0) < 0) {
349 bdrv_delete(bs1);
350 return -1;
351 }
352 total_size = bdrv_getlength(bs1) >> SECTOR_BITS;
353 bdrv_delete(bs1);
354
355 get_tmp_filename(tmp_filename, sizeof(tmp_filename));
356 if(realpath(filename, backing_filename)==0) return -1;
357 if (bdrv_create(&bdrv_qcow2, tmp_filename,
358 total_size, backing_filename, 0) < 0) {
359 return -1;
360 }
361 filename = tmp_filename;
362 bs->is_temporary = 1;
363 }
364
365 pstrcpy(bs->filename, sizeof(bs->filename), filename);
366 if (flags & BDRV_O_FILE) {
367 drv = find_protocol(filename);
368 if (!drv)
369 return -ENOENT;
370 } else {
371 if (!drv) {
372 drv = find_image_format(filename);
373 if (!drv)
374 return -1;
375 }
376 }
377 bs->drv = drv;
378 bs->opaque = qemu_mallocz(drv->instance_size);
379 if (bs->opaque == NULL && drv->instance_size > 0)
380 return -1;
381 /* Note: for compatibility, we open disk image files as RDWR, and
382 RDONLY as fallback */
383 if (!(flags & BDRV_O_FILE))
384 open_flags = BDRV_O_RDWR | (flags & BDRV_O_DIRECT);
385 else
386 open_flags = flags & ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
387 ret = drv->bdrv_open(bs, filename, open_flags);
388 if (ret == -EACCES && !(flags & BDRV_O_FILE)) {
389 ret = drv->bdrv_open(bs, filename, BDRV_O_RDONLY);
390 bs->read_only = 1;
391 }
392 if (ret < 0) {
393 qemu_free(bs->opaque);
394 bs->opaque = NULL;
395 bs->drv = NULL;
396 return ret;
397 }
398 if (drv->bdrv_getlength) {
399 bs->total_sectors = bdrv_getlength(bs) >> SECTOR_BITS;
400 }
401 #ifndef _WIN32
402 if (bs->is_temporary) {
403 unlink(filename);
404 }
405 #endif
406 if (bs->backing_file[0] != '\0') {
407 /* if there is a backing file, use it */
408 bs->backing_hd = bdrv_new("");
409 if (!bs->backing_hd) {
410 fail:
411 bdrv_close(bs);
412 return -ENOMEM;
413 }
414 path_combine(backing_filename, sizeof(backing_filename),
415 filename, bs->backing_file);
416 if (bdrv_open(bs->backing_hd, backing_filename, 0) < 0)
417 goto fail;
418 }
419
420 /* call the change callback */
421 bs->media_changed = 1;
422 if (bs->change_cb)
423 bs->change_cb(bs->change_opaque);
424
425 return 0;
426 }
427
428 void bdrv_close(BlockDriverState *bs)
429 {
430 if (bs->drv) {
431 if (bs->backing_hd)
432 bdrv_delete(bs->backing_hd);
433 bs->drv->bdrv_close(bs);
434 qemu_free(bs->opaque);
435 #ifdef _WIN32
436 if (bs->is_temporary) {
437 unlink(bs->filename);
438 }
439 #endif
440 bs->opaque = NULL;
441 bs->drv = NULL;
442
443 /* call the change callback */
444 bs->media_changed = 1;
445 if (bs->change_cb)
446 bs->change_cb(bs->change_opaque);
447 }
448 }
449
450 void bdrv_delete(BlockDriverState *bs)
451 {
452 /* XXX: remove the driver list */
453 bdrv_close(bs);
454 qemu_free(bs);
455 }
456
457 /* commit COW file into the raw image */
458 int bdrv_commit(BlockDriverState *bs)
459 {
460 BlockDriver *drv = bs->drv;
461 int64_t i, total_sectors;
462 int n, j;
463 unsigned char sector[512];
464
465 if (!drv)
466 return -ENOMEDIUM;
467
468 if (bs->read_only) {
469 return -EACCES;
470 }
471
472 if (!bs->backing_hd) {
473 return -ENOTSUP;
474 }
475
476 total_sectors = bdrv_getlength(bs) >> SECTOR_BITS;
477 for (i = 0; i < total_sectors;) {
478 if (drv->bdrv_is_allocated(bs, i, 65536, &n)) {
479 for(j = 0; j < n; j++) {
480 if (bdrv_read(bs, i, sector, 1) != 0) {
481 return -EIO;
482 }
483
484 if (bdrv_write(bs->backing_hd, i, sector, 1) != 0) {
485 return -EIO;
486 }
487 i++;
488 }
489 } else {
490 i += n;
491 }
492 }
493
494 if (drv->bdrv_make_empty)
495 return drv->bdrv_make_empty(bs);
496
497 return 0;
498 }
499
500 /* return < 0 if error. See bdrv_write() for the return codes */
501 int bdrv_read(BlockDriverState *bs, int64_t sector_num,
502 uint8_t *buf, int nb_sectors)
503 {
504 BlockDriver *drv = bs->drv;
505
506 if (!drv)
507 return -ENOMEDIUM;
508
509 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
510 memcpy(buf, bs->boot_sector_data, 512);
511 sector_num++;
512 nb_sectors--;
513 buf += 512;
514 if (nb_sectors == 0)
515 return 0;
516 }
517 if (drv->bdrv_pread) {
518 int ret, len;
519 len = nb_sectors * 512;
520 ret = drv->bdrv_pread(bs, sector_num * 512, buf, len);
521 if (ret < 0)
522 return ret;
523 else if (ret != len)
524 return -EINVAL;
525 else {
526 bs->rd_bytes += (unsigned) len;
527 bs->rd_ops ++;
528 return 0;
529 }
530 } else {
531 return drv->bdrv_read(bs, sector_num, buf, nb_sectors);
532 }
533 }
534
535 /* Return < 0 if error. Important errors are:
536 -EIO generic I/O error (may happen for all errors)
537 -ENOMEDIUM No media inserted.
538 -EINVAL Invalid sector number or nb_sectors
539 -EACCES Trying to write a read-only device
540 */
541 int bdrv_write(BlockDriverState *bs, int64_t sector_num,
542 const uint8_t *buf, int nb_sectors)
543 {
544 BlockDriver *drv = bs->drv;
545 if (!bs->drv)
546 return -ENOMEDIUM;
547 if (bs->read_only)
548 return -EACCES;
549 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
550 memcpy(bs->boot_sector_data, buf, 512);
551 }
552 if (drv->bdrv_pwrite) {
553 int ret, len;
554 len = nb_sectors * 512;
555 ret = drv->bdrv_pwrite(bs, sector_num * 512, buf, len);
556 if (ret < 0)
557 return ret;
558 else if (ret != len)
559 return -EIO;
560 else {
561 bs->wr_bytes += (unsigned) len;
562 bs->wr_ops ++;
563 return 0;
564 }
565 } else {
566 return drv->bdrv_write(bs, sector_num, buf, nb_sectors);
567 }
568 }
569
570 static int bdrv_pread_em(BlockDriverState *bs, int64_t offset,
571 uint8_t *buf, int count1)
572 {
573 uint8_t tmp_buf[SECTOR_SIZE];
574 int len, nb_sectors, count;
575 int64_t sector_num;
576
577 count = count1;
578 /* first read to align to sector start */
579 len = (SECTOR_SIZE - offset) & (SECTOR_SIZE - 1);
580 if (len > count)
581 len = count;
582 sector_num = offset >> SECTOR_BITS;
583 if (len > 0) {
584 if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0)
585 return -EIO;
586 memcpy(buf, tmp_buf + (offset & (SECTOR_SIZE - 1)), len);
587 count -= len;
588 if (count == 0)
589 return count1;
590 sector_num++;
591 buf += len;
592 }
593
594 /* read the sectors "in place" */
595 nb_sectors = count >> SECTOR_BITS;
596 if (nb_sectors > 0) {
597 if (bdrv_read(bs, sector_num, buf, nb_sectors) < 0)
598 return -EIO;
599 sector_num += nb_sectors;
600 len = nb_sectors << SECTOR_BITS;
601 buf += len;
602 count -= len;
603 }
604
605 /* add data from the last sector */
606 if (count > 0) {
607 if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0)
608 return -EIO;
609 memcpy(buf, tmp_buf, count);
610 }
611 return count1;
612 }
613
614 static int bdrv_pwrite_em(BlockDriverState *bs, int64_t offset,
615 const uint8_t *buf, int count1)
616 {
617 uint8_t tmp_buf[SECTOR_SIZE];
618 int len, nb_sectors, count;
619 int64_t sector_num;
620
621 count = count1;
622 /* first write to align to sector start */
623 len = (SECTOR_SIZE - offset) & (SECTOR_SIZE - 1);
624 if (len > count)
625 len = count;
626 sector_num = offset >> SECTOR_BITS;
627 if (len > 0) {
628 if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0)
629 return -EIO;
630 memcpy(tmp_buf + (offset & (SECTOR_SIZE - 1)), buf, len);
631 if (bdrv_write(bs, sector_num, tmp_buf, 1) < 0)
632 return -EIO;
633 count -= len;
634 if (count == 0)
635 return count1;
636 sector_num++;
637 buf += len;
638 }
639
640 /* write the sectors "in place" */
641 nb_sectors = count >> SECTOR_BITS;
642 if (nb_sectors > 0) {
643 if (bdrv_write(bs, sector_num, buf, nb_sectors) < 0)
644 return -EIO;
645 sector_num += nb_sectors;
646 len = nb_sectors << SECTOR_BITS;
647 buf += len;
648 count -= len;
649 }
650
651 /* add data from the last sector */
652 if (count > 0) {
653 if (bdrv_read(bs, sector_num, tmp_buf, 1) < 0)
654 return -EIO;
655 memcpy(tmp_buf, buf, count);
656 if (bdrv_write(bs, sector_num, tmp_buf, 1) < 0)
657 return -EIO;
658 }
659 return count1;
660 }
661
662 /**
663 * Read with byte offsets (needed only for file protocols)
664 */
665 int bdrv_pread(BlockDriverState *bs, int64_t offset,
666 void *buf1, int count1)
667 {
668 BlockDriver *drv = bs->drv;
669
670 if (!drv)
671 return -ENOMEDIUM;
672 if (!drv->bdrv_pread)
673 return bdrv_pread_em(bs, offset, buf1, count1);
674 return drv->bdrv_pread(bs, offset, buf1, count1);
675 }
676
677 /**
678 * Write with byte offsets (needed only for file protocols)
679 */
680 int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
681 const void *buf1, int count1)
682 {
683 BlockDriver *drv = bs->drv;
684
685 if (!drv)
686 return -ENOMEDIUM;
687 if (!drv->bdrv_pwrite)
688 return bdrv_pwrite_em(bs, offset, buf1, count1);
689 return drv->bdrv_pwrite(bs, offset, buf1, count1);
690 }
691
692 /**
693 * Truncate file to 'offset' bytes (needed only for file protocols)
694 */
695 int bdrv_truncate(BlockDriverState *bs, int64_t offset)
696 {
697 BlockDriver *drv = bs->drv;
698 if (!drv)
699 return -ENOMEDIUM;
700 if (!drv->bdrv_truncate)
701 return -ENOTSUP;
702 return drv->bdrv_truncate(bs, offset);
703 }
704
705 /**
706 * Length of a file in bytes. Return < 0 if error or unknown.
707 */
708 int64_t bdrv_getlength(BlockDriverState *bs)
709 {
710 BlockDriver *drv = bs->drv;
711 if (!drv)
712 return -ENOMEDIUM;
713 if (!drv->bdrv_getlength) {
714 /* legacy mode */
715 return bs->total_sectors * SECTOR_SIZE;
716 }
717 return drv->bdrv_getlength(bs);
718 }
719
720 /* return 0 as number of sectors if no device present or error */
721 void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr)
722 {
723 int64_t length;
724 length = bdrv_getlength(bs);
725 if (length < 0)
726 length = 0;
727 else
728 length = length >> SECTOR_BITS;
729 *nb_sectors_ptr = length;
730 }
731
732 /* force a given boot sector. */
733 void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size)
734 {
735 bs->boot_sector_enabled = 1;
736 if (size > 512)
737 size = 512;
738 memcpy(bs->boot_sector_data, data, size);
739 memset(bs->boot_sector_data + size, 0, 512 - size);
740 }
741
742 void bdrv_set_geometry_hint(BlockDriverState *bs,
743 int cyls, int heads, int secs)
744 {
745 bs->cyls = cyls;
746 bs->heads = heads;
747 bs->secs = secs;
748 }
749
750 void bdrv_set_type_hint(BlockDriverState *bs, int type)
751 {
752 bs->type = type;
753 bs->removable = ((type == BDRV_TYPE_CDROM ||
754 type == BDRV_TYPE_FLOPPY));
755 }
756
757 void bdrv_set_translation_hint(BlockDriverState *bs, int translation)
758 {
759 bs->translation = translation;
760 }
761
762 void bdrv_get_geometry_hint(BlockDriverState *bs,
763 int *pcyls, int *pheads, int *psecs)
764 {
765 *pcyls = bs->cyls;
766 *pheads = bs->heads;
767 *psecs = bs->secs;
768 }
769
770 int bdrv_get_type_hint(BlockDriverState *bs)
771 {
772 return bs->type;
773 }
774
775 int bdrv_get_translation_hint(BlockDriverState *bs)
776 {
777 return bs->translation;
778 }
779
780 int bdrv_is_removable(BlockDriverState *bs)
781 {
782 return bs->removable;
783 }
784
785 int bdrv_is_read_only(BlockDriverState *bs)
786 {
787 return bs->read_only;
788 }
789
790 int bdrv_is_sg(BlockDriverState *bs)
791 {
792 return bs->sg;
793 }
794
795 /* XXX: no longer used */
796 void bdrv_set_change_cb(BlockDriverState *bs,
797 void (*change_cb)(void *opaque), void *opaque)
798 {
799 bs->change_cb = change_cb;
800 bs->change_opaque = opaque;
801 }
802
803 int bdrv_is_encrypted(BlockDriverState *bs)
804 {
805 if (bs->backing_hd && bs->backing_hd->encrypted)
806 return 1;
807 return bs->encrypted;
808 }
809
810 int bdrv_set_key(BlockDriverState *bs, const char *key)
811 {
812 int ret;
813 if (bs->backing_hd && bs->backing_hd->encrypted) {
814 ret = bdrv_set_key(bs->backing_hd, key);
815 if (ret < 0)
816 return ret;
817 if (!bs->encrypted)
818 return 0;
819 }
820 if (!bs->encrypted || !bs->drv || !bs->drv->bdrv_set_key)
821 return -1;
822 return bs->drv->bdrv_set_key(bs, key);
823 }
824
825 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size)
826 {
827 if (!bs->drv) {
828 buf[0] = '\0';
829 } else {
830 pstrcpy(buf, buf_size, bs->drv->format_name);
831 }
832 }
833
834 void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
835 void *opaque)
836 {
837 BlockDriver *drv;
838
839 for (drv = first_drv; drv != NULL; drv = drv->next) {
840 it(opaque, drv->format_name);
841 }
842 }
843
844 BlockDriverState *bdrv_find(const char *name)
845 {
846 BlockDriverState *bs;
847
848 for (bs = bdrv_first; bs != NULL; bs = bs->next) {
849 if (!strcmp(name, bs->device_name))
850 return bs;
851 }
852 return NULL;
853 }
854
855 void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque)
856 {
857 BlockDriverState *bs;
858
859 for (bs = bdrv_first; bs != NULL; bs = bs->next) {
860 it(opaque, bs->device_name);
861 }
862 }
863
864 const char *bdrv_get_device_name(BlockDriverState *bs)
865 {
866 return bs->device_name;
867 }
868
869 void bdrv_flush(BlockDriverState *bs)
870 {
871 if (bs->drv->bdrv_flush)
872 bs->drv->bdrv_flush(bs);
873 if (bs->backing_hd)
874 bdrv_flush(bs->backing_hd);
875 }
876
877 #ifndef QEMU_IMG
878 void bdrv_info(void)
879 {
880 BlockDriverState *bs;
881
882 for (bs = bdrv_first; bs != NULL; bs = bs->next) {
883 term_printf("%s:", bs->device_name);
884 term_printf(" type=");
885 switch(bs->type) {
886 case BDRV_TYPE_HD:
887 term_printf("hd");
888 break;
889 case BDRV_TYPE_CDROM:
890 term_printf("cdrom");
891 break;
892 case BDRV_TYPE_FLOPPY:
893 term_printf("floppy");
894 break;
895 }
896 term_printf(" removable=%d", bs->removable);
897 if (bs->removable) {
898 term_printf(" locked=%d", bs->locked);
899 }
900 if (bs->drv) {
901 term_printf(" file=");
902 term_print_filename(bs->filename);
903 if (bs->backing_file[0] != '\0') {
904 term_printf(" backing_file=");
905 term_print_filename(bs->backing_file);
906 }
907 term_printf(" ro=%d", bs->read_only);
908 term_printf(" drv=%s", bs->drv->format_name);
909 if (bs->encrypted)
910 term_printf(" encrypted");
911 } else {
912 term_printf(" [not inserted]");
913 }
914 term_printf("\n");
915 }
916 }
917
918 /* The "info blockstats" command. */
919 void bdrv_info_stats (void)
920 {
921 BlockDriverState *bs;
922
923 for (bs = bdrv_first; bs != NULL; bs = bs->next) {
924 term_printf ("%s:"
925 " rd_bytes=%" PRIu64
926 " wr_bytes=%" PRIu64
927 " rd_operations=%" PRIu64
928 " wr_operations=%" PRIu64
929 "\n",
930 bs->device_name,
931 bs->rd_bytes, bs->wr_bytes,
932 bs->rd_ops, bs->wr_ops);
933 }
934 }
935 #endif
936
937 void bdrv_get_backing_filename(BlockDriverState *bs,
938 char *filename, int filename_size)
939 {
940 if (!bs->backing_hd) {
941 pstrcpy(filename, filename_size, "");
942 } else {
943 pstrcpy(filename, filename_size, bs->backing_file);
944 }
945 }
946
947 int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
948 const uint8_t *buf, int nb_sectors)
949 {
950 BlockDriver *drv = bs->drv;
951 if (!drv)
952 return -ENOMEDIUM;
953 if (!drv->bdrv_write_compressed)
954 return -ENOTSUP;
955 return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors);
956 }
957
958 int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
959 {
960 BlockDriver *drv = bs->drv;
961 if (!drv)
962 return -ENOMEDIUM;
963 if (!drv->bdrv_get_info)
964 return -ENOTSUP;
965 memset(bdi, 0, sizeof(*bdi));
966 return drv->bdrv_get_info(bs, bdi);
967 }
968
969 /**************************************************************/
970 /* handling of snapshots */
971
972 int bdrv_snapshot_create(BlockDriverState *bs,
973 QEMUSnapshotInfo *sn_info)
974 {
975 BlockDriver *drv = bs->drv;
976 if (!drv)
977 return -ENOMEDIUM;
978 if (!drv->bdrv_snapshot_create)
979 return -ENOTSUP;
980 return drv->bdrv_snapshot_create(bs, sn_info);
981 }
982
983 int bdrv_snapshot_goto(BlockDriverState *bs,
984 const char *snapshot_id)
985 {
986 BlockDriver *drv = bs->drv;
987 if (!drv)
988 return -ENOMEDIUM;
989 if (!drv->bdrv_snapshot_goto)
990 return -ENOTSUP;
991 return drv->bdrv_snapshot_goto(bs, snapshot_id);
992 }
993
994 int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id)
995 {
996 BlockDriver *drv = bs->drv;
997 if (!drv)
998 return -ENOMEDIUM;
999 if (!drv->bdrv_snapshot_delete)
1000 return -ENOTSUP;
1001 return drv->bdrv_snapshot_delete(bs, snapshot_id);
1002 }
1003
1004 int bdrv_snapshot_list(BlockDriverState *bs,
1005 QEMUSnapshotInfo **psn_info)
1006 {
1007 BlockDriver *drv = bs->drv;
1008 if (!drv)
1009 return -ENOMEDIUM;
1010 if (!drv->bdrv_snapshot_list)
1011 return -ENOTSUP;
1012 return drv->bdrv_snapshot_list(bs, psn_info);
1013 }
1014
1015 #define NB_SUFFIXES 4
1016
1017 char *get_human_readable_size(char *buf, int buf_size, int64_t size)
1018 {
1019 static const char suffixes[NB_SUFFIXES] = "KMGT";
1020 int64_t base;
1021 int i;
1022
1023 if (size <= 999) {
1024 snprintf(buf, buf_size, "%" PRId64, size);
1025 } else {
1026 base = 1024;
1027 for(i = 0; i < NB_SUFFIXES; i++) {
1028 if (size < (10 * base)) {
1029 snprintf(buf, buf_size, "%0.1f%c",
1030 (double)size / base,
1031 suffixes[i]);
1032 break;
1033 } else if (size < (1000 * base) || i == (NB_SUFFIXES - 1)) {
1034 snprintf(buf, buf_size, "%" PRId64 "%c",
1035 ((size + (base >> 1)) / base),
1036 suffixes[i]);
1037 break;
1038 }
1039 base = base * 1024;
1040 }
1041 }
1042 return buf;
1043 }
1044
1045 char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
1046 {
1047 char buf1[128], date_buf[128], clock_buf[128];
1048 #ifdef _WIN32
1049 struct tm *ptm;
1050 #else
1051 struct tm tm;
1052 #endif
1053 time_t ti;
1054 int64_t secs;
1055
1056 if (!sn) {
1057 snprintf(buf, buf_size,
1058 "%-10s%-20s%7s%20s%15s",
1059 "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
1060 } else {
1061 ti = sn->date_sec;
1062 #ifdef _WIN32
1063 ptm = localtime(&ti);
1064 strftime(date_buf, sizeof(date_buf),
1065 "%Y-%m-%d %H:%M:%S", ptm);
1066 #else
1067 localtime_r(&ti, &tm);
1068 strftime(date_buf, sizeof(date_buf),
1069 "%Y-%m-%d %H:%M:%S", &tm);
1070 #endif
1071 secs = sn->vm_clock_nsec / 1000000000;
1072 snprintf(clock_buf, sizeof(clock_buf),
1073 "%02d:%02d:%02d.%03d",
1074 (int)(secs / 3600),
1075 (int)((secs / 60) % 60),
1076 (int)(secs % 60),
1077 (int)((sn->vm_clock_nsec / 1000000) % 1000));
1078 snprintf(buf, buf_size,
1079 "%-10s%-20s%7s%20s%15s",
1080 sn->id_str, sn->name,
1081 get_human_readable_size(buf1, sizeof(buf1), sn->vm_state_size),
1082 date_buf,
1083 clock_buf);
1084 }
1085 return buf;
1086 }
1087
1088
1089 /**************************************************************/
1090 /* async I/Os */
1091
1092 BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num,
1093 uint8_t *buf, int nb_sectors,
1094 BlockDriverCompletionFunc *cb, void *opaque)
1095 {
1096 BlockDriver *drv = bs->drv;
1097 BlockDriverAIOCB *ret;
1098
1099 if (!drv)
1100 return NULL;
1101
1102 /* XXX: we assume that nb_sectors == 0 is suppored by the async read */
1103 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
1104 memcpy(buf, bs->boot_sector_data, 512);
1105 sector_num++;
1106 nb_sectors--;
1107 buf += 512;
1108 }
1109
1110 ret = drv->bdrv_aio_read(bs, sector_num, buf, nb_sectors, cb, opaque);
1111
1112 if (ret) {
1113 /* Update stats even though technically transfer has not happened. */
1114 bs->rd_bytes += (unsigned) nb_sectors * SECTOR_SIZE;
1115 bs->rd_ops ++;
1116 }
1117
1118 return ret;
1119 }
1120
1121 BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
1122 const uint8_t *buf, int nb_sectors,
1123 BlockDriverCompletionFunc *cb, void *opaque)
1124 {
1125 BlockDriver *drv = bs->drv;
1126 BlockDriverAIOCB *ret;
1127
1128 if (!drv)
1129 return NULL;
1130 if (bs->read_only)
1131 return NULL;
1132 if (sector_num == 0 && bs->boot_sector_enabled && nb_sectors > 0) {
1133 memcpy(bs->boot_sector_data, buf, 512);
1134 }
1135
1136 ret = drv->bdrv_aio_write(bs, sector_num, buf, nb_sectors, cb, opaque);
1137
1138 if (ret) {
1139 /* Update stats even though technically transfer has not happened. */
1140 bs->wr_bytes += (unsigned) nb_sectors * SECTOR_SIZE;
1141 bs->wr_ops ++;
1142 }
1143
1144 return ret;
1145 }
1146
1147 void bdrv_aio_cancel(BlockDriverAIOCB *acb)
1148 {
1149 BlockDriver *drv = acb->bs->drv;
1150
1151 drv->bdrv_aio_cancel(acb);
1152 }
1153
1154
1155 /**************************************************************/
1156 /* async block device emulation */
1157
1158 #ifdef QEMU_IMG
1159 static BlockDriverAIOCB *bdrv_aio_read_em(BlockDriverState *bs,
1160 int64_t sector_num, uint8_t *buf, int nb_sectors,
1161 BlockDriverCompletionFunc *cb, void *opaque)
1162 {
1163 int ret;
1164 ret = bdrv_read(bs, sector_num, buf, nb_sectors);
1165 cb(opaque, ret);
1166 return NULL;
1167 }
1168
1169 static BlockDriverAIOCB *bdrv_aio_write_em(BlockDriverState *bs,
1170 int64_t sector_num, const uint8_t *buf, int nb_sectors,
1171 BlockDriverCompletionFunc *cb, void *opaque)
1172 {
1173 int ret;
1174 ret = bdrv_write(bs, sector_num, buf, nb_sectors);
1175 cb(opaque, ret);
1176 return NULL;
1177 }
1178
1179 static void bdrv_aio_cancel_em(BlockDriverAIOCB *acb)
1180 {
1181 }
1182 #else
1183 static void bdrv_aio_bh_cb(void *opaque)
1184 {
1185 BlockDriverAIOCBSync *acb = opaque;
1186 acb->common.cb(acb->common.opaque, acb->ret);
1187 qemu_aio_release(acb);
1188 }
1189
1190 static BlockDriverAIOCB *bdrv_aio_read_em(BlockDriverState *bs,
1191 int64_t sector_num, uint8_t *buf, int nb_sectors,
1192 BlockDriverCompletionFunc *cb, void *opaque)
1193 {
1194 BlockDriverAIOCBSync *acb;
1195 int ret;
1196
1197 acb = qemu_aio_get(bs, cb, opaque);
1198 if (!acb->bh)
1199 acb->bh = qemu_bh_new(bdrv_aio_bh_cb, acb);
1200 ret = bdrv_read(bs, sector_num, buf, nb_sectors);
1201 acb->ret = ret;
1202 qemu_bh_schedule(acb->bh);
1203 return &acb->common;
1204 }
1205
1206 static BlockDriverAIOCB *bdrv_aio_write_em(BlockDriverState *bs,
1207 int64_t sector_num, const uint8_t *buf, int nb_sectors,
1208 BlockDriverCompletionFunc *cb, void *opaque)
1209 {
1210 BlockDriverAIOCBSync *acb;
1211 int ret;
1212
1213 acb = qemu_aio_get(bs, cb, opaque);
1214 if (!acb->bh)
1215 acb->bh = qemu_bh_new(bdrv_aio_bh_cb, acb);
1216 ret = bdrv_write(bs, sector_num, buf, nb_sectors);
1217 acb->ret = ret;
1218 qemu_bh_schedule(acb->bh);
1219 return &acb->common;
1220 }
1221
1222 static void bdrv_aio_cancel_em(BlockDriverAIOCB *blockacb)
1223 {
1224 BlockDriverAIOCBSync *acb = (BlockDriverAIOCBSync *)blockacb;
1225 qemu_bh_cancel(acb->bh);
1226 qemu_aio_release(acb);
1227 }
1228 #endif /* !QEMU_IMG */
1229
1230 /**************************************************************/
1231 /* sync block device emulation */
1232
1233 static void bdrv_rw_em_cb(void *opaque, int ret)
1234 {
1235 *(int *)opaque = ret;
1236 }
1237
1238 #define NOT_DONE 0x7fffffff
1239
1240 static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num,
1241 uint8_t *buf, int nb_sectors)
1242 {
1243 int async_ret;
1244 BlockDriverAIOCB *acb;
1245
1246 async_ret = NOT_DONE;
1247 qemu_aio_wait_start();
1248 acb = bdrv_aio_read(bs, sector_num, buf, nb_sectors,
1249 bdrv_rw_em_cb, &async_ret);
1250 if (acb == NULL) {
1251 qemu_aio_wait_end();
1252 return -1;
1253 }
1254 while (async_ret == NOT_DONE) {
1255 qemu_aio_wait();
1256 }
1257 qemu_aio_wait_end();
1258 return async_ret;
1259 }
1260
1261 static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
1262 const uint8_t *buf, int nb_sectors)
1263 {
1264 int async_ret;
1265 BlockDriverAIOCB *acb;
1266
1267 async_ret = NOT_DONE;
1268 qemu_aio_wait_start();
1269 acb = bdrv_aio_write(bs, sector_num, buf, nb_sectors,
1270 bdrv_rw_em_cb, &async_ret);
1271 if (acb == NULL) {
1272 qemu_aio_wait_end();
1273 return -1;
1274 }
1275 while (async_ret == NOT_DONE) {
1276 qemu_aio_wait();
1277 }
1278 qemu_aio_wait_end();
1279 return async_ret;
1280 }
1281
1282 void bdrv_init(void)
1283 {
1284 // bdrv_register(&bdrv_raw);
1285 // bdrv_register(&bdrv_host_device);
1286 #ifndef _WIN32
1287 // bdrv_register(&bdrv_cow);
1288 #endif
1289 // bdrv_register(&bdrv_qcow);
1290 bdrv_register(&bdrv_vmdk);
1291 //bdrv_register(&bdrv_cloop);
1292 bdrv_register(&bdrv_dmg);
1293 //bdrv_register(&bdrv_bochs);
1294 //bdrv_register(&bdrv_vpc);
1295 //bdrv_register(&bdrv_vvfat);
1296 //bdrv_register(&bdrv_qcow2);
1297 bdrv_register(&bdrv_parallels);
1298 }
1299
1300 void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
1301 void *opaque)
1302 {
1303 BlockDriver *drv;
1304 BlockDriverAIOCB *acb;
1305
1306 drv = bs->drv;
1307 if (drv->free_aiocb) {
1308 acb = drv->free_aiocb;
1309 drv->free_aiocb = acb->next;
1310 } else {
1311 acb = qemu_mallocz(drv->aiocb_size);
1312 if (!acb)
1313 return NULL;
1314 }
1315 acb->bs = bs;
1316 acb->cb = cb;
1317 acb->opaque = opaque;
1318 return acb;
1319 }
1320
1321 void qemu_aio_release(void *p)
1322 {
1323 BlockDriverAIOCB *acb = p;
1324 BlockDriver *drv = acb->bs->drv;
1325 acb->next = drv->free_aiocb;
1326 drv->free_aiocb = acb;
1327 }
1328
1329 /**************************************************************/
1330 /* removable device support */
1331
1332 /**
1333 * Return TRUE if the media is present
1334 */
1335 int bdrv_is_inserted(BlockDriverState *bs)
1336 {
1337 BlockDriver *drv = bs->drv;
1338 int ret;
1339 if (!drv)
1340 return 0;
1341 if (!drv->bdrv_is_inserted)
1342 return 1;
1343 ret = drv->bdrv_is_inserted(bs);
1344 return ret;
1345 }
1346
1347 /**
1348 * Return TRUE if the media changed since the last call to this
1349 * function. It is currently only used for floppy disks
1350 */
1351 int bdrv_media_changed(BlockDriverState *bs)
1352 {
1353 BlockDriver *drv = bs->drv;
1354 int ret;
1355
1356 if (!drv || !drv->bdrv_media_changed)
1357 ret = -ENOTSUP;
1358 else
1359 ret = drv->bdrv_media_changed(bs);
1360 if (ret == -ENOTSUP)
1361 ret = bs->media_changed;
1362 bs->media_changed = 0;
1363 return ret;
1364 }
1365
1366 /**
1367 * If eject_flag is TRUE, eject the media. Otherwise, close the tray
1368 */
1369 void bdrv_eject(BlockDriverState *bs, int eject_flag)
1370 {
1371 BlockDriver *drv = bs->drv;
1372 int ret;
1373
1374 if (!drv || !drv->bdrv_eject) {
1375 ret = -ENOTSUP;
1376 } else {
1377 ret = drv->bdrv_eject(bs, eject_flag);
1378 }
1379 if (ret == -ENOTSUP) {
1380 if (eject_flag)
1381 bdrv_close(bs);
1382 }
1383 }
1384
1385 int bdrv_is_locked(BlockDriverState *bs)
1386 {
1387 return bs->locked;
1388 }
1389
1390 /**
1391 * Lock or unlock the media (if it is locked, the user won't be able
1392 * to eject it manually).
1393 */
1394 void bdrv_set_locked(BlockDriverState *bs, int locked)
1395 {
1396 BlockDriver *drv = bs->drv;
1397
1398 bs->locked = locked;
1399 if (drv && drv->bdrv_set_locked) {
1400 drv->bdrv_set_locked(bs, locked);
1401 }
1402 }
1403
1404 /* needed for generic scsi interface */
1405
1406 int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
1407 {
1408 BlockDriver *drv = bs->drv;
1409
1410 if (drv && drv->bdrv_ioctl)
1411 return drv->bdrv_ioctl(bs, req, buf);
1412 return -ENOTSUP;
1413 }
0 #ifndef BLOCK_H
1 #define BLOCK_H
2
3 /* block.c */
4 typedef struct BlockDriver BlockDriver;
5
6 extern BlockDriver bdrv_raw;
7 extern BlockDriver bdrv_host_device;
8 extern BlockDriver bdrv_cow;
9 extern BlockDriver bdrv_qcow;
10 extern BlockDriver bdrv_vmdk;
11 extern BlockDriver bdrv_cloop;
12 extern BlockDriver bdrv_dmg;
13 extern BlockDriver bdrv_bochs;
14 extern BlockDriver bdrv_vpc;
15 extern BlockDriver bdrv_vvfat;
16 extern BlockDriver bdrv_qcow2;
17 extern BlockDriver bdrv_parallels;
18
19 typedef struct BlockDriverInfo {
20 /* in bytes, 0 if irrelevant */
21 int cluster_size;
22 /* offset at which the VM state can be saved (0 if not possible) */
23 int64_t vm_state_offset;
24 } BlockDriverInfo;
25
26 typedef struct QEMUSnapshotInfo {
27 char id_str[128]; /* unique snapshot id */
28 /* the following fields are informative. They are not needed for
29 the consistency of the snapshot */
30 char name[256]; /* user choosen name */
31 uint32_t vm_state_size; /* VM state info size */
32 uint32_t date_sec; /* UTC date of the snapshot */
33 uint32_t date_nsec;
34 uint64_t vm_clock_nsec; /* VM clock relative to boot */
35 } QEMUSnapshotInfo;
36
37 #define BDRV_O_RDONLY 0x0000
38 #define BDRV_O_RDWR 0x0002
39 #define BDRV_O_ACCESS 0x0003
40 #define BDRV_O_CREAT 0x0004 /* create an empty file */
41 #define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */
42 #define BDRV_O_FILE 0x0010 /* open as a raw file (do not try to
43 use a disk image format on top of
44 it (default for
45 bdrv_file_open()) */
46 #define BDRV_O_DIRECT 0x0020
47
48 #ifndef QEMU_IMG
49 void bdrv_info(void);
50 void bdrv_info_stats(void);
51 #endif
52
53 void bdrv_init(void);
54 BlockDriver *bdrv_find_format(const char *format_name);
55 int bdrv_create(BlockDriver *drv,
56 const char *filename, int64_t size_in_sectors,
57 const char *backing_file, int flags);
58 BlockDriverState *bdrv_new(const char *device_name);
59 void bdrv_delete(BlockDriverState *bs);
60 int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags);
61 int bdrv_open(BlockDriverState *bs, const char *filename, int flags);
62 int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
63 BlockDriver *drv);
64 void bdrv_close(BlockDriverState *bs);
65 int bdrv_read(BlockDriverState *bs, int64_t sector_num,
66 uint8_t *buf, int nb_sectors);
67 int bdrv_write(BlockDriverState *bs, int64_t sector_num,
68 const uint8_t *buf, int nb_sectors);
69 int bdrv_pread(BlockDriverState *bs, int64_t offset,
70 void *buf, int count);
71 int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
72 const void *buf, int count);
73 int bdrv_truncate(BlockDriverState *bs, int64_t offset);
74 int64_t bdrv_getlength(BlockDriverState *bs);
75 void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
76 int bdrv_commit(BlockDriverState *bs);
77 void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
78 /* async block I/O */
79 typedef struct BlockDriverAIOCB BlockDriverAIOCB;
80 typedef void BlockDriverCompletionFunc(void *opaque, int ret);
81
82 BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num,
83 uint8_t *buf, int nb_sectors,
84 BlockDriverCompletionFunc *cb, void *opaque);
85 BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
86 const uint8_t *buf, int nb_sectors,
87 BlockDriverCompletionFunc *cb, void *opaque);
88 void bdrv_aio_cancel(BlockDriverAIOCB *acb);
89
90 void qemu_aio_init(void);
91 void qemu_aio_poll(void);
92 void qemu_aio_flush(void);
93 void qemu_aio_wait_start(void);
94 void qemu_aio_wait(void);
95 void qemu_aio_wait_end(void);
96
97 int qemu_key_check(BlockDriverState *bs, const char *name);
98
99 /* Ensure contents are flushed to disk. */
100 void bdrv_flush(BlockDriverState *bs);
101
102 #define BDRV_TYPE_HD 0
103 #define BDRV_TYPE_CDROM 1
104 #define BDRV_TYPE_FLOPPY 2
105 #define BIOS_ATA_TRANSLATION_AUTO 0
106 #define BIOS_ATA_TRANSLATION_NONE 1
107 #define BIOS_ATA_TRANSLATION_LBA 2
108 #define BIOS_ATA_TRANSLATION_LARGE 3
109 #define BIOS_ATA_TRANSLATION_RECHS 4
110
111 void bdrv_set_geometry_hint(BlockDriverState *bs,
112 int cyls, int heads, int secs);
113 void bdrv_set_type_hint(BlockDriverState *bs, int type);
114 void bdrv_set_translation_hint(BlockDriverState *bs, int translation);
115 void bdrv_get_geometry_hint(BlockDriverState *bs,
116 int *pcyls, int *pheads, int *psecs);
117 int bdrv_get_type_hint(BlockDriverState *bs);
118 int bdrv_get_translation_hint(BlockDriverState *bs);
119 int bdrv_is_removable(BlockDriverState *bs);
120 int bdrv_is_read_only(BlockDriverState *bs);
121 int bdrv_is_sg(BlockDriverState *bs);
122 int bdrv_is_inserted(BlockDriverState *bs);
123 int bdrv_media_changed(BlockDriverState *bs);
124 int bdrv_is_locked(BlockDriverState *bs);
125 void bdrv_set_locked(BlockDriverState *bs, int locked);
126 void bdrv_eject(BlockDriverState *bs, int eject_flag);
127 void bdrv_set_change_cb(BlockDriverState *bs,
128 void (*change_cb)(void *opaque), void *opaque);
129 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
130 BlockDriverState *bdrv_find(const char *name);
131 void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
132 int bdrv_is_encrypted(BlockDriverState *bs);
133 int bdrv_set_key(BlockDriverState *bs, const char *key);
134 void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
135 void *opaque);
136 const char *bdrv_get_device_name(BlockDriverState *bs);
137 int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
138 const uint8_t *buf, int nb_sectors);
139 int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
140
141 void bdrv_get_backing_filename(BlockDriverState *bs,
142 char *filename, int filename_size);
143 int bdrv_snapshot_create(BlockDriverState *bs,
144 QEMUSnapshotInfo *sn_info);
145 int bdrv_snapshot_goto(BlockDriverState *bs,
146 const char *snapshot_id);
147 int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id);
148 int bdrv_snapshot_list(BlockDriverState *bs,
149 QEMUSnapshotInfo **psn_info);
150 char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
151 int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf);
152
153 char *get_human_readable_size(char *buf, int buf_size, int64_t size);
154 int path_is_absolute(const char *path);
155 void path_combine(char *dest, int dest_size,
156 const char *base_path,
157 const char *filename);
158
159 #endif
0 /*
1 * QEMU System Emulator block driver
2 *
3 * Copyright (c) 2003 Fabrice Bellard
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23 #ifndef BLOCK_INT_H
24 #define BLOCK_INT_H
25
26 #include "block.h"
27
28 #define BLOCK_FLAG_ENCRYPT 1
29 #define BLOCK_FLAG_COMPRESS 2
30 #define BLOCK_FLAG_COMPAT6 4
31
32 struct BlockDriver {
33 const char *format_name;
34 int instance_size;
35 int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename);
36 int (*bdrv_open)(BlockDriverState *bs, const char *filename, int flags);
37 int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num,
38 uint8_t *buf, int nb_sectors);
39 int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num,
40 const uint8_t *buf, int nb_sectors);
41 void (*bdrv_close)(BlockDriverState *bs);
42 int (*bdrv_create)(const char *filename, int64_t total_sectors,
43 const char *backing_file, int flags);
44 void (*bdrv_flush)(BlockDriverState *bs);
45 int (*bdrv_is_allocated)(BlockDriverState *bs, int64_t sector_num,
46 int nb_sectors, int *pnum);
47 int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
48 int (*bdrv_make_empty)(BlockDriverState *bs);
49 /* aio */
50 BlockDriverAIOCB *(*bdrv_aio_read)(BlockDriverState *bs,
51 int64_t sector_num, uint8_t *buf, int nb_sectors,
52 BlockDriverCompletionFunc *cb, void *opaque);
53 BlockDriverAIOCB *(*bdrv_aio_write)(BlockDriverState *bs,
54 int64_t sector_num, const uint8_t *buf, int nb_sectors,
55 BlockDriverCompletionFunc *cb, void *opaque);
56 void (*bdrv_aio_cancel)(BlockDriverAIOCB *acb);
57 int aiocb_size;
58
59 const char *protocol_name;
60 int (*bdrv_pread)(BlockDriverState *bs, int64_t offset,
61 uint8_t *buf, int count);
62 int (*bdrv_pwrite)(BlockDriverState *bs, int64_t offset,
63 const uint8_t *buf, int count);
64 int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset);
65 int64_t (*bdrv_getlength)(BlockDriverState *bs);
66 int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,
67 const uint8_t *buf, int nb_sectors);
68
69 int (*bdrv_snapshot_create)(BlockDriverState *bs,
70 QEMUSnapshotInfo *sn_info);
71 int (*bdrv_snapshot_goto)(BlockDriverState *bs,
72 const char *snapshot_id);
73 int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char *snapshot_id);
74 int (*bdrv_snapshot_list)(BlockDriverState *bs,
75 QEMUSnapshotInfo **psn_info);
76 int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
77
78 /* removable device specific */
79 int (*bdrv_is_inserted)(BlockDriverState *bs);
80 int (*bdrv_media_changed)(BlockDriverState *bs);
81 int (*bdrv_eject)(BlockDriverState *bs, int eject_flag);
82 int (*bdrv_set_locked)(BlockDriverState *bs, int locked);
83
84 /* to control generic scsi devices */
85 int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf);
86
87 BlockDriverAIOCB *free_aiocb;
88 struct BlockDriver *next;
89 };
90
91 struct BlockDriverState {
92 int64_t total_sectors; /* if we are reading a disk image, give its
93 size in sectors */
94 int read_only; /* if true, the media is read only */
95 int removable; /* if true, the media can be removed */
96 int locked; /* if true, the media cannot temporarily be ejected */
97 int encrypted; /* if true, the media is encrypted */
98 int sg; /* if true, the device is a /dev/sg* */
99 /* event callback when inserting/removing */
100 void (*change_cb)(void *opaque);
101 void *change_opaque;
102
103 BlockDriver *drv; /* NULL means no media */
104 void *opaque;
105
106 int boot_sector_enabled;
107 uint8_t boot_sector_data[512];
108
109 char filename[1024];
110 char backing_file[1024]; /* if non zero, the image is a diff of
111 this file image */
112 int is_temporary;
113 int media_changed;
114
115 BlockDriverState *backing_hd;
116 /* async read/write emulation */
117
118 void *sync_aiocb;
119
120 /* I/O stats (display with "info blockstats"). */
121 uint64_t rd_bytes;
122 uint64_t wr_bytes;
123 uint64_t rd_ops;
124 uint64_t wr_ops;
125
126 /* NOTE: the following infos are only hints for real hardware
127 drivers. They are not used by the block driver */
128 int cyls, heads, secs, translation;
129 int type;
130 char device_name[32];
131 BlockDriverState *next;
132 };
133
134 struct BlockDriverAIOCB {
135 BlockDriverState *bs;
136 BlockDriverCompletionFunc *cb;
137 void *opaque;
138 BlockDriverAIOCB *next;
139 };
140
141 void get_tmp_filename(char *filename, int size);
142
143 void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
144 void *opaque);
145 void qemu_aio_release(void *p);
146
147 extern BlockDriverState *bdrv_first; // slg change
148
149 #endif /* BLOCK_INT_H */
0 #ifndef BSWAP_H
1 #define BSWAP_H
2
3 #include "config-host.h"
4
5 #include <inttypes.h>
6
7 #ifdef HAVE_BYTESWAP_H
8 #include <byteswap.h>
9 #else
10
11 #define bswap_16(x) \
12 ({ \
13 uint16_t __x = (x); \
14 ((uint16_t)( \
15 (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
16 (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
17 })
18
19 #define bswap_32(x) \
20 ({ \
21 uint32_t __x = (x); \
22 ((uint32_t)( \
23 (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
24 (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
25 (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
26 (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
27 })
28
29 #define bswap_64(x) \
30 ({ \
31 uint64_t __x = (x); \
32 ((uint64_t)( \
33 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
34 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
35 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
36 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
37 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
38 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
39 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
40 (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
41 })
42
43 #endif /* !HAVE_BYTESWAP_H */
44
45 static inline uint16_t bswap16(uint16_t x)
46 {
47 return bswap_16(x);
48 }
49
50 static inline uint32_t bswap32(uint32_t x)
51 {
52 return bswap_32(x);
53 }
54
55 static inline uint64_t bswap64(uint64_t x)
56 {
57 return bswap_64(x);
58 }
59
60 static inline void bswap16s(uint16_t *s)
61 {
62 *s = bswap16(*s);
63 }
64
65 static inline void bswap32s(uint32_t *s)
66 {
67 *s = bswap32(*s);
68 }
69
70 static inline void bswap64s(uint64_t *s)
71 {
72 *s = bswap64(*s);
73 }
74
75 #if defined(WORDS_BIGENDIAN)
76 #define be_bswap(v, size) (v)
77 #define le_bswap(v, size) bswap ## size(v)
78 #define be_bswaps(v, size)
79 #define le_bswaps(p, size) *p = bswap ## size(*p);
80 #else
81 #define le_bswap(v, size) (v)
82 #define be_bswap(v, size) bswap ## size(v)
83 #define le_bswaps(v, size)
84 #define be_bswaps(p, size) *p = bswap ## size(*p);
85 #endif
86
87 #define CPU_CONVERT(endian, size, type)\
88 static inline type endian ## size ## _to_cpu(type v)\
89 {\
90 return endian ## _bswap(v, size);\
91 }\
92 \
93 static inline type cpu_to_ ## endian ## size(type v)\
94 {\
95 return endian ## _bswap(v, size);\
96 }\
97 \
98 static inline void endian ## size ## _to_cpus(type *p)\
99 {\
100 endian ## _bswaps(p, size)\
101 }\
102 \
103 static inline void cpu_to_ ## endian ## size ## s(type *p)\
104 {\
105 endian ## _bswaps(p, size)\
106 }\
107 \
108 static inline type endian ## size ## _to_cpup(const type *p)\
109 {\
110 return endian ## size ## _to_cpu(*p);\
111 }\
112 \
113 static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\
114 {\
115 *p = cpu_to_ ## endian ## size(v);\
116 }
117
118 CPU_CONVERT(be, 16, uint16_t)
119 CPU_CONVERT(be, 32, uint32_t)
120 CPU_CONVERT(be, 64, uint64_t)
121
122 CPU_CONVERT(le, 16, uint16_t)
123 CPU_CONVERT(le, 32, uint32_t)
124 CPU_CONVERT(le, 64, uint64_t)
125
126 /* unaligned versions (optimized for frequent unaligned accesses)*/
127
128 #if defined(__i386__) || defined(__powerpc__)
129
130 #define cpu_to_le16wu(p, v) cpu_to_le16w(p, v)
131 #define cpu_to_le32wu(p, v) cpu_to_le32w(p, v)
132 #define le16_to_cpupu(p) le16_to_cpup(p)
133 #define le32_to_cpupu(p) le32_to_cpup(p)
134
135 #define cpu_to_be16wu(p, v) cpu_to_be16w(p, v)
136 #define cpu_to_be32wu(p, v) cpu_to_be32w(p, v)
137
138 #else
139
140 static inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
141 {
142 uint8_t *p1 = (uint8_t *)p;
143
144 p1[0] = v;
145 p1[1] = v >> 8;
146 }
147
148 static inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
149 {
150 uint8_t *p1 = (uint8_t *)p;
151
152 p1[0] = v;
153 p1[1] = v >> 8;
154 p1[2] = v >> 16;
155 p1[3] = v >> 24;
156 }
157
158 static inline uint16_t le16_to_cpupu(const uint16_t *p)
159 {
160 const uint8_t *p1 = (const uint8_t *)p;
161 return p1[0] | (p1[1] << 8);
162 }
163
164 static inline uint32_t le32_to_cpupu(const uint32_t *p)
165 {
166 const uint8_t *p1 = (const uint8_t *)p;
167 return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
168 }
169
170 static inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
171 {
172 uint8_t *p1 = (uint8_t *)p;
173
174 p1[0] = v >> 8;
175 p1[1] = v;
176 }
177
178 static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
179 {
180 uint8_t *p1 = (uint8_t *)p;
181
182 p1[0] = v >> 24;
183 p1[1] = v >> 16;
184 p1[2] = v >> 8;
185 p1[3] = v;
186 }
187
188 #endif
189
190 #ifdef WORDS_BIGENDIAN
191 #define cpu_to_32wu cpu_to_be32wu
192 #else
193 #define cpu_to_32wu cpu_to_le32wu
194 #endif
195
196 #undef le_bswap
197 #undef be_bswap
198 #undef le_bswaps
199 #undef be_bswaps
200
201 #endif /* BSWAP_H */
(New empty file)
(New empty file)
(New empty file)
0 #ifndef QEMU_OSDEP_H
1 #define QEMU_OSDEP_H
2
3 #include <stdarg.h>
4
5 #ifndef glue
6 #define xglue(x, y) x ## y
7 #define glue(x, y) xglue(x, y)
8 #define stringify(s) tostring(s)
9 #define tostring(s) #s
10 #endif
11
12 #ifndef likely
13 #if __GNUC__ < 3
14 #define __builtin_expect(x, n) (x)
15 #endif
16
17 #define likely(x) __builtin_expect(!!(x), 1)
18 #define unlikely(x) __builtin_expect(!!(x), 0)
19 #endif
20
21 #ifndef MIN
22 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
23 #endif
24 #ifndef MAX
25 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
26 #endif
27
28 #ifndef always_inline
29 #if (__GNUC__ < 3) || defined(__APPLE__)
30 #define always_inline inline
31 #else
32 #define always_inline __attribute__ (( always_inline )) __inline__
33 #endif
34 #endif
35 #define inline always_inline
36
37 #ifdef __i386__
38 #define REGPARM(n) __attribute((regparm(n)))
39 #else
40 #define REGPARM(n)
41 #endif
42
43 #define qemu_printf printf
44
45 void *qemu_malloc(size_t size);
46 void *qemu_mallocz(size_t size);
47 void qemu_free(void *ptr);
48 char *qemu_strdup(const char *str);
49
50 void *qemu_memalign(size_t alignment, size_t size);
51 void *qemu_vmalloc(size_t size);
52 void qemu_vfree(void *ptr);
53
54 void *get_mmap_addr(unsigned long size);
55
56 int qemu_create_pidfile(const char *filename);
57
58 #ifdef _WIN32
59 int ffs(int i);
60
61 typedef struct {
62 long tv_sec;
63 long tv_usec;
64 } qemu_timeval;
65 int qemu_gettimeofday(qemu_timeval *tp);
66 #else
67 typedef struct timeval qemu_timeval;
68 #define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
69 #endif /* !_WIN32 */
70
71 #endif
0 /* Common header file that is included by all of qemu. */
1 #ifndef QEMU_COMMON_H
2 #define QEMU_COMMON_H
3
4 /* we put basic includes here to avoid repeating them in device drivers */
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <stdarg.h>
8 #include <string.h>
9 #include <inttypes.h>
10 #include <limits.h>
11 #include <time.h>
12 #include <ctype.h>
13 #include <errno.h>
14 #include <unistd.h>
15 #include <fcntl.h>
16 #include <sys/stat.h>
17
18 #ifndef O_LARGEFILE
19 #define O_LARGEFILE 0
20 #endif
21 #ifndef O_BINARY
22 #define O_BINARY 0
23 #endif
24
25 #ifndef ENOMEDIUM
26 #define ENOMEDIUM ENODEV
27 #endif
28
29 #ifdef _WIN32
30 #define WIN32_LEAN_AND_MEAN
31 #include <windows.h>
32 #define fsync _commit
33 #define lseek _lseeki64
34 #define ENOTSUP 4096
35 extern int qemu_ftruncate64(int, int64_t);
36 #define ftruncate qemu_ftruncate64
37
38
39 static inline char *realpath(const char *path, char *resolved_path)
40 {
41 _fullpath(resolved_path, path, _MAX_PATH);
42 return resolved_path;
43 }
44
45 #define PRId64 "I64d"
46 #define PRIx64 "I64x"
47 #define PRIu64 "I64u"
48 #define PRIo64 "I64o"
49 #endif
50
51 /* FIXME: Remove NEED_CPU_H. */
52 #ifndef NEED_CPU_H
53
54 #include "config-host.h"
55 #include <setjmp.h>
56 #include "osdep.h"
57 #include "bswap.h"
58
59 #else
60
61 #include "cpu.h"
62
63 #endif /* !defined(NEED_CPU_H) */
64
65 /* bottom halves */
66 typedef struct QEMUBH QEMUBH;
67
68 typedef void QEMUBHFunc(void *opaque);
69
70 QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
71 void qemu_bh_schedule(QEMUBH *bh);
72 void qemu_bh_cancel(QEMUBH *bh);
73 void qemu_bh_delete(QEMUBH *bh);
74 int qemu_bh_poll(void);
75
76 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
77
78 /* cutils.c */
79 void pstrcpy(char *buf, int buf_size, const char *str);
80 char *pstrcat(char *buf, int buf_size, const char *s);
81 int strstart(const char *str, const char *val, const char **ptr);
82 int stristart(const char *str, const char *val, const char **ptr);
83 time_t mktimegm(struct tm *tm);
84
85 /* Error handling. */
86
87 void hw_error(const char *fmt, ...)
88 __attribute__ ((__format__ (__printf__, 1, 2)))
89 __attribute__ ((__noreturn__));
90
91 /* IO callbacks. */
92 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
93 typedef int IOCanRWHandler(void *opaque);
94 typedef void IOHandler(void *opaque);
95
96 struct ParallelIOArg {
97 void *buffer;
98 int count;
99 };
100
101 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
102
103 /* A load of opaque types so that device init declarations don't have to
104 pull in all the real definitions. */
105 typedef struct NICInfo NICInfo;
106 typedef struct AudioState AudioState;
107 typedef struct BlockDriverState BlockDriverState;
108 typedef struct DisplayState DisplayState;
109 typedef struct TextConsole TextConsole;
110 typedef struct CharDriverState CharDriverState;
111 typedef struct VLANState VLANState;
112 typedef struct QEMUFile QEMUFile;
113 typedef struct i2c_bus i2c_bus;
114 typedef struct i2c_slave i2c_slave;
115 typedef struct SMBusDevice SMBusDevice;
116 typedef struct QEMUTimer QEMUTimer;
117 typedef struct PCIBus PCIBus;
118 typedef struct PCIDevice PCIDevice;
119 typedef struct SerialState SerialState;
120 typedef struct IRQState *qemu_irq;
121 struct pcmcia_card_s;
122
123 #endif
(New empty file)
0 #include "qemu-common.h"
1 #include "block_int.h"
2
3 #include "affconfig.h"
4 #include "afflib.h"
5 #include "afflib_i.h"
6
7
8 void *get_mmap_addr(unsigned long size)
9 {
10 return NULL;
11 }
12
13 void qemu_free(void *ptr)
14 {
15 free(ptr);
16 }
17
18 void *qemu_malloc(size_t size)
19 {
20 return malloc(size);
21 }
22
23 void *qemu_mallocz(size_t size)
24 {
25 void *ptr;
26 ptr = qemu_malloc(size);
27 if (!ptr)
28 return NULL;
29 memset(ptr, 0, size);
30 return ptr;
31 }
32
33 char *qemu_strdup(const char *str)
34 {
35 char *ptr;
36 ptr = qemu_malloc(strlen(str) + 1);
37 if (!ptr)
38 return NULL;
39 strcpy(ptr, str);
40 return ptr;
41 }
42
43 void term_printf(const char *str)
44 {
45 puts(str);
46 }
47
48 void term_print_filename(const char *filename)
49 {
50 puts(filename);
51 }
52
53 void pstrcpy(char *buf, int buf_size, const char *str)
54 {
55 int c;
56 char *q = buf;
57
58 if (buf_size <= 0)
59 return;
60
61 for(;;) {
62 c = *str++;
63 if (c == 0 || q >= buf + buf_size - 1)
64 break;
65 *q++ = c;
66 }
67 *q = '\0';
68 }
69
70 /* strcat and truncate. */
71 char *pstrcat(char *buf, int buf_size, const char *s)
72 {
73 int len;
74 len = strlen(buf);
75 if (len < buf_size)
76 pstrcpy(buf + len, buf_size - len, s);
77 return buf;
78 }
79
80
81
82 int strstart(const char *str, const char *val, const char **ptr)
83 {
84 const char *p, *q;
85 p = str;
86 q = val;
87 while (*q != '\0') {
88 if (*p != *q)
89 return 0;
90 p++;
91 q++;
92 }
93 if (ptr)
94 *ptr = p;
95 return 1;
96 }
97
98
99
0 /*
1 * s3.cpp:
2 * The stand-alone S3 program.
3 *
4 * These features would be nice:
5 * have "ls" use Delimiter option to just list the drives
6 * Give "ls" an option to list just the AFF files.
7 * Have implementation read a list of all the segments on open, and cache this.
8 */
9
10 #include "affconfig.h"
11 #include "afflib.h"
12 #include "afflib_i.h"
13 #include "aftimer.h"
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <getopt.h>
18
19 #ifdef USE_S3
20 #include "s3_glue.h"
21
22 #include <errno.h>
23
24 #ifdef HAVE_OPENSSL_MD5_H
25 #include <openssl/md5.h>
26 #endif
27
28
29
30 char *outfile = 0;
31 char *opt_bucket = 0;
32 int opt_flag = 0;
33 int opt_meta = 0;
34 int verbose = 0;
35 int tag = 0;
36
37 using namespace s3;
38
39 #define BANDWIDTH_PREFIX ".bandwidth_test"
40 #define BANDWIDTH_DEFAULT_SIZE 1000000
41 int bandwidth_offset = 0;
42
43 #ifndef HAVE_STRLCPY
44 size_t strlcpy(char *dest,const char *src,size_t dest_size)
45 {
46 strncpy(dest,src,dest_size);
47 dest[dest_size-1] = '\000';
48 return strlen(dest);
49 }
50 #endif
51
52 #ifndef HAVE_STRLCAT
53 size_t strlcat(char *dest,const char *src,size_t dest_size)
54 {
55 int dest_len = strlen(dest);
56 int src_len = strlen(src);
57 int room = dest_size - (dest_len +src_len+1);
58 if(room>0){
59 /* There is room; just copy over what we have and return */
60 strcat(dest,src);
61 return strlen(dest);
62 }
63 /* Not room; figure out how many bytes we can copy... */
64 int left = dest_size - (dest_len+1);
65 strncpy(dest+dest_len,src,left);
66 dest[dest_len-1] = '\000';
67 return strlen(dest);
68 }
69 #endif
70
71
72 void s3_df()
73 {
74 class s3_result *e = list_buckets();
75 if(!e->lambr) errx(1,"S3 did not return ListAllMyBucketsResult.");
76 printf("Owner ID: %s\n",e->lambr->OwnerID.c_str());
77 printf("Owner Display Name: %s\n",e->lambr->OwnerDisplayName.c_str());
78 printf("\n");
79 for(vector<Bucket *>::const_iterator i = e->lambr->Buckets.begin();
80 i != e->lambr->Buckets.end();
81 i++){
82 printf("%s %s\n",(*i)->CreationDate.c_str(),(*i)->Name.c_str());
83 }
84 exit(0);
85 }
86
87 typedef vector <Contents> cvector;
88 void s3_ls(FILE *out,const char *prefix,cvector *cv)
89 {
90 uint64_t total=0;
91 string bucket = opt_bucket;
92 if(out) fprintf(out,"S3 BUCKET %s:",bucket.c_str());
93 if(strlen(prefix)>0){
94 if(out) fprintf(out,"PREFIX %s",prefix);
95 }
96 if(out) fprintf(out,"\n\n");
97 string marker;
98 class s3_result *e;
99 bool isTruncated = false;
100 do {
101 e = list_bucket(bucket,prefix,marker,00);
102 if(e==0) err(1,"Error loading bucket.");
103 if(e->lbr==0) err(1,"Error: no LBR");
104 if(e->lbr->contents.size()==0){
105 delete e;
106 break; //
107 }
108 for(vector<Contents *>::const_iterator i = e->lbr->contents.begin();
109 i != e->lbr->contents.end();
110 i++){
111
112 if(cv) cv->push_back(**i);
113 /* Make date nice */
114 char tstamp[64];
115 strlcpy(tstamp,(*i)->LastModified.c_str(),sizeof(tstamp));
116 tstamp[10] = ' ';
117 tstamp[19] = '\000';
118
119 if(out){
120 fprintf(out,"%s ",(*i)->OwnerDisplayName.c_str());
121 fprintf(out,"%8d ",(int)(*i)->Size);
122 fprintf(out,"%s ",tstamp);
123 fprintf(out,"%s ",(*i)->Key.c_str());
124 fprintf(out,"\n");
125 }
126 total += (*i)->Size;
127 }
128
129 /* "To get the next page of results use the last key of the
130 * current page as the marker."
131 */
132
133 marker = e->lbr->contents.back()->Key;
134 isTruncated = e->lbr->IsTruncated;
135 delete e;
136 } while(isTruncated);
137
138 char buf[64];
139 if(out) fprintf(out,"Total: %"PRId64"\n",total);
140 }
141
142 void s3_cat(int argc, char **argv)
143 {
144 argc--;argv++;
145 while(*argv){
146 string key(*argv);
147 class response_buffer *b = 0;
148 if(opt_meta==0){
149 b = object_get(opt_bucket,key,0);
150 }
151 else {
152 b = object_head(opt_bucket,key,0);
153 }
154 if(!b) errx(1,"HTTP transport error");
155 if(b->result == 404) errx(1,"S3: %s not found",key.c_str());
156 fwrite(b->base,1,b->len,stdout);
157 delete b;
158 argv++;
159 argc--;
160 }
161 }
162
163 /* s3 doesn't give an error if you try to delete an object that doesn't exist */
164 void s3_rm(int argc,char **argv)
165 {
166 argc--;argv++;
167 while(*argv){
168 printf("s3 rm %s\n",*argv);
169 int r = object_rm(opt_bucket,*argv);
170 if(r) errx(1,"HTTP transport error");
171 argv++;
172 argc--;
173 }
174 exit(0);
175 }
176
177 /* del prefix */
178 void s3_delp(int argc,char **argv)
179 {
180 argc--;argv++;
181
182 FILE *f = stdout;
183 char line[80];
184 cvector cv;
185 if(!strcmp(argv[0],"-q")){
186 f = fopen("/dev/null","w");
187 argv++;
188 argc--;
189 }
190
191
192 if(argc!=1) errx(1,"delp requires a single argument");
193 s3_ls(f,*argv,&cv);
194 if(cv.size()==0) errx(0,"No items to delete");
195 printf("Really delete %d item%s?\n",cv.size(),cv.size()==1 ? "" : "s");
196 fgets(line,sizeof(line),stdin);
197 if(line[0]!='y' && line[0]!='Y') errx(1,"Aborted");
198 for(cvector::iterator i=cv.begin();
199 i!=cv.end();
200 i++){
201 printf("s3 rm %s\n",i->Key.c_str());
202 if(object_rm(opt_bucket,i->Key.c_str())){
203 warn("HTTP error");
204 }
205 }
206 }
207
208 void s3_cp(int argc, char **argv)
209 {
210 argc--;
211 argv++;
212 char * fname = argv[0];
213 char * key = argv[1];
214 struct s3headers meta[2] = {{0,0},{0,0}};
215 char buf[64];
216
217 if(opt_flag){
218 snprintf(buf,sizeof(buf),"%d",opt_flag);
219 meta[0].name = AMAZON_METADATA_PREFIX "arg";
220 meta[0].value = buf;
221 }
222
223 /* Read from fname into a buffer.
224 * Note that we do this with read, so that we can read from stdin
225 */
226 FILE *f = fopen(fname,"r");
227 if(!f) err(1,"%s",fname);
228 class response_buffer inbuf;
229 while(!feof(f)){
230 char buf[65536];
231 int count;
232 count = fread(buf,1,sizeof(buf),f);
233 if(count>0){
234 inbuf.write(buf,count);
235 }
236 }
237 if(object_put(opt_bucket,key,inbuf.base,inbuf.len,meta)){
238 errx(1,"%s: ",fname);
239 }
240 exit(0);
241 }
242
243 void s3_mkdir(int argc,char **argv)
244 {
245 argc--;argv++;
246 while(argc>0){
247 if(bucket_mkdir(*argv)) err(1,"%s",*argv);
248 argc--;
249 argv++;
250 }
251 exit(0);
252 }
253
254 void s3_rmdir(int argc, char **argv)
255 {
256 argc--;argv++;
257 while(argc>0){
258 string bucket(*argv);
259 if(bucket_rmdir(bucket)) errx(1,"%s",bucket.c_str());
260 argc--;
261 argv++;
262 }
263 exit(0);
264 }
265
266
267
268 void usage()
269 {
270 printf("s3 testing program.\n\n");
271 printf("Usage:\n");
272 printf("s3 ls (or dir) [prefix] - list the bucket's contents\n");
273 printf("s3 mkdir - make a bucket\n");
274 printf("s3 rmdir - delete a bucket\n");
275 printf("s3 df - display all of the buckets\n");
276 printf("s3 rm key - delete key from the bucket\n");
277 printf("s3 cat key - send the contents of the key to stdout\n");
278 printf("s3 cp fname key - copy local file fname to key\n");
279 printf("s3 delp [-q] prefix - Delete all keys with 'prefix' as a prefix\n");
280 printf("\n");
281 printf("Debugging commands:\n");
282 printf("s3 regress - run regression tests\n");
283 printf("s3 bandwidth [-m] nn - measure bandwidth \n");
284 printf(" Use -m to make the files that are needed for read testing.\n");
285 printf("\n");
286 printf("Options:\n");
287 printf(" -d = enable HTTP debugging\n");
288 printf(" -b <bucket> = Specifies bucket\n");
289 printf(" -fnn = specify a 32-bit metadata 'flag'\n");
290 printf(" -m = just report the metadata (for cat)\n");
291 printf(" -O = set bandwidth offset (default 0)\n");
292 printf(" -u url = go to url instead of %s\n",aws_base_url);
293 printf(" -o fn = append output to file fn\n");
294 printf(" -V verbose\n");
295 printf(" -v print version number and exit\n");
296 printf(" -t tag = tag to append to output\n");
297 exit(0);
298 }
299
300 /****************************************************************/
301
302 /* Regression testing */
303 int regress()
304 {
305 /* Make some data */
306 for(int i=0;i<100;i++){
307 char name[1024];
308 char value[1024];
309 snprintf(name,sizeof(name),"bucket%d",i);
310 snprintf(value,sizeof(value),"This is the contents of bucket %d\n",i);
311 object_put(opt_bucket,name,value,strlen(value),0);
312 }
313
314 for(int i=0;i<100;i++){
315 if(i%10==0) printf("\n");
316 class s3_result *e = list_bucket(opt_bucket,"","",0);
317 if(!e->lbr) err(1,"Error loading bucket pass %d\n",i);
318 delete e;
319 printf("%d ",i);
320 fflush(stdout);
321 }
322 printf("Done. Check for memory leaks, then press any key...\n");
323 getchar();
324 exit(0);
325 }
326
327 void s3_bandwidth(int argc,char **argv)
328 {
329 int opt_make = opt_meta; // in case it was set
330 int read_retry=0;
331 int write_retry=0;
332 int write_err=0;
333 int opt_write_test=1;
334 const char *opt_url = 0;
335
336 argc--;argv++;
337
338 if(argc>0 && strcmp(argv[0],"-m")==0){
339 if(verbose) fprintf(stderr,"opt_make\n");
340 opt_make = 1;
341 argc--;
342 argv++;
343 }
344
345 /* Bandwidth testing requires bandwidth_test0 through 9.
346 * If they don't exist, make them.
347 */
348 #if defined(HAVE_SRANDOMDEV)
349 srandomdev();
350 #endif
351 #if !defined(HAVE_SRANDOMDEV) && defined(HAVE_SRANDOM)
352 srandom(time(0));
353 #endif
354
355 size_t size = BANDWIDTH_DEFAULT_SIZE;
356 if(argc>0) size=atoi(argv[0]);
357 if(verbose) fprintf(stderr,"size=%d\n",size);
358 if(size==0) err(1,"size=0");
359 char *buf = (char *)malloc(size);
360 if(!buf) err(1,"malloc");
361 memset(buf,'E',size);
362
363 if(argc>0) size=atoi(argv[0]);
364
365 if(strncmp(argv[0],"http://",7)==0){
366 opt_url = argv[0];
367 opt_write_test = 0;
368 }
369
370 char base[1024];
371 char randp[1024];
372 snprintf(base,sizeof(base),"%s.%d",BANDWIDTH_PREFIX,size);
373 snprintf(randp,sizeof(randp),"%s.%d.%d",BANDWIDTH_PREFIX,size,random() % 1000);
374
375
376 aftimer twrite;
377
378 if(opt_write_test || opt_make){
379 /* Measure the write bandwidth */
380 twrite.start();
381
382 if(opt_make) strcpy(randp,base); // just write to this one
383 char wkey[1024];
384 snprintf(wkey,sizeof(wkey),"%s.%d",randp,bandwidth_offset);
385 object_put(opt_bucket,wkey,buf,size,0);
386 if(verbose) fprintf(stderr," wrote %s/%s\n",opt_bucket,wkey);
387 write_retry += s3_request_retry_count;
388 write_err += s3_object_put_retry_count;
389
390 twrite.stop();
391
392 if(opt_make) exit(0); // file made
393
394 /* Delete the writes */
395 if(object_rm(opt_bucket,wkey)){
396 err(1,"object_rm failed\n");
397 }
398 if(verbose) fprintf(stderr," deleted %s/%s\n",opt_bucket,wkey);
399
400 }
401
402 /* Now measure the read bandwidth */
403 aftimer tread;
404 tread.start();
405
406 char rkey[1024];
407 snprintf(rkey,sizeof(rkey),"%s.%d",base,bandwidth_offset);
408 response_buffer *r=0;
409
410 if(opt_url==0){
411 r = object_get(opt_bucket,rkey,0);
412 if(!r || r->result==404){
413 err(1,"object_get(%s/%s) failed (%d)",opt_bucket,rkey,errno);
414 }
415 }
416 else {
417 r = s3::get_url(opt_url);
418 if(r) size = r->len;
419 }
420 read_retry += s3_request_retry_count;
421 tread.stop();
422 if(verbose) fprintf(stderr," read %s/%s\n",opt_bucket,rkey);
423
424 char line[1024];
425 memset(line,0,sizeof(line));
426 time_t t = time(0);
427 struct tm *tm = gmtime(&t);
428 char tbuf[64];
429 strftime(tbuf,sizeof(tbuf),"%F %T",tm);
430
431 char hextag[64];
432 memset(hextag,0,sizeof(hextag));
433 for(int i=0;i<16;i++){
434 sprintf(hextag+i*2,"%02x",r->ETag[i]);
435 }
436
437 FILE *out = outfile ? fopen(outfile,"a") : stdout;
438
439 //snprintf(line,sizeof(line),"v3: %s\t%d\t%d\t%f\t%f\t%d\t%d\t%d\t%s
440 fprintf(out,"v3: %s\t",tbuf);
441
442 fprintf(out,"%d\t%d\t",size,bandwidth_offset);
443 fprintf(out,"%f\t",twrite.elapsed_seconds());
444 fprintf(out,"%f\t",tread.elapsed_seconds());
445 fprintf(out,"%d\t%d\t%d\t",write_retry,write_err,read_retry);
446 fprintf(out," ");
447 /* Now verify the MD5 */
448 unsigned char md5[16];
449 memset(md5,0,sizeof(md5));
450 MD5((const unsigned char *)r->base,r->len,md5);
451 if(memcmp(r->ETag,md5,16)!=0){
452 fprintf(out," FAILED != ");
453 for(int i=0;i<16;i++) fprintf(out,"%02x",md5[i]);
454 }
455
456 if(tag) fprintf(out,"\t%d ",tag);
457 fprintf(out,"\n");
458 fclose(out);
459 if(r) delete r;
460 exit(0);
461 }
462
463
464 /****************************************************************/
465
466
467 int main(int argc,char **argv)
468 {
469 int bflag, ch;
470
471 bflag = 0;
472 opt_bucket = getenv(S3_DEFAULT_BUCKET);
473 while ((ch = getopt(argc, argv, "b:dVh?f:mc:O:u:o:vt:")) != -1) {
474 switch (ch) {
475 case 'O': bandwidth_offset = atoi(optarg);break;
476 case 'd': s3_debug++;break;
477 case 'b': opt_bucket = optarg;break;
478 case 'f': opt_flag = atoi(optarg);break;
479 case 'm': opt_meta = 1;break;
480 case 'v':
481 printf("%s version %s\n",argv[0],PACKAGE_VERSION);
482 exit(0);
483 case 'u': aws_base_url = optarg;break;
484 case 'o': outfile = optarg;break;
485 case 'V': verbose++;break;
486 case 't': tag = atoi(optarg);break;
487 case 'h':
488 case '?':
489 default:
490 usage();
491 }
492 }
493 argc -= optind;
494 argv += optind;
495
496 if(argc<1){
497 usage();
498 }
499
500 if(getenv(S3_DEBUG)){
501 s3_debug = atoi(getenv(S3_DEBUG));
502 fprintf(stderr,"s3_debug set to %d\n",s3_debug);
503 #ifdef HAVE_ERR_SET_EXIT
504 err_set_exit(s3_audit);
505 #endif
506 }
507
508 aws_access_key_id = getenv(AWS_ACCESS_KEY_ID);
509 aws_secret_access_key = getenv(AWS_SECRET_ACCESS_KEY);
510 if(!aws_access_key_id) fprintf(stderr,"s3: AWS_ACCESS_KEY_ID not defined\n");
511 if(!aws_secret_access_key) fprintf(stderr,"s3: AWS_SECRET_ACCESS_KEY not defined\n");
512 if(!aws_access_key_id || !aws_secret_access_key) return -1; /* can't open */
513 if(!opt_bucket) {
514 fprintf(stderr,"No bucket. Please setenv S3_DEFAULT_BUCKET or specify -b option.\n");
515 exit(1);
516 }
517
518
519 char *cmd = argv[0];
520
521 if(!strcmp(cmd,"ls") || !strcmp(cmd,"dir")){
522 const char *prefix = argc>1 ? argv[1] : "";
523 s3_ls(stdout,prefix,0);exit(0);
524 }
525 if(!strcmp(cmd,"df")) {s3_df();exit(0);}
526 if(!strcmp(cmd,"cat")) {s3_cat(argc,argv);exit(0);}
527 if(!strcmp(cmd,"rm")) {s3_rm(argc,argv);exit(0);}
528 if(!strcmp(cmd,"cp") || !strcmp(cmd,"put") || !strcmp(cmd,"send")) {
529 if ( argc != 3 ) {usage();exit(1);}
530 s3_cp(argc,argv);exit(0);
531 }
532 if(!strcmp(cmd,"mkdir")) {s3_mkdir(argc,argv);exit(0);}
533 if(!strcmp(cmd,"rmdir")) {s3_rmdir(argc,argv);exit(0);}
534 if(!strcmp(cmd,"regress")) {regress();exit(0);}
535 if(!strcmp(cmd,"delp")) {s3_delp(argc,argv);exit(0);}
536 if(!strcmp(cmd,"bandwidth")) {
537 s3_bandwidth(argc,argv);exit(0);
538 }
539 usage();
540 exit(0);
541 }
542 #else
543 int main(int argc,char **argv)
544 {
545 fprintf(stderr,"S3 is not compiled in.\n");
546 exit(0);
547 }
548 #endif
0 #include "affconfig.h"
1
2 #include <stdio.h>
3 #include <errno.h>
4 #include <stdlib.h>
5
6 #ifdef USE_S3
7
8 #ifdef HAVE_SYS_PARAM_H
9 #include <sys/param.h>
10 #endif
11
12 #if (defined(__FreeBSD_version)) && (__FreeBSD_version<500000) && (!defined(BAD_STL))
13 #define BAD_STL
14 #endif
15
16
17 #include "s3_glue.h"
18 #include "curl/curl.h"
19 #include "base64.h"
20
21 #include <expat.h>
22 #include <time.h>
23 #include <netinet/in.h>
24
25 #ifdef HAVE_OPENSSL_MD5_H
26 #include <openssl/md5.h>
27 #endif
28
29 #ifdef HAVE_OPENSSL_HMAC_H
30 #include <openssl/hmac.h>
31 #endif
32
33 #ifdef HAVE_ERR_H
34 #include <err.h>
35 #endif
36
37 #ifdef HAVE_CTYPE_H
38 #include <ctype.h>
39 #endif
40
41 #if !defined(HAVE_OPENSSL_MD5_H)
42 #error S3 support requires MD5 support
43 #endif
44
45 int s3_debug = 0;
46 int s3_retry_max = 5; // read by the code
47
48 /* debug levels:
49 * 1 - print retries
50 * 2- print queries
51 * 3- print full results
52 */
53
54 /* Counters that are used; they aren't threadsafe, but they are never referenced */
55 int s3_request_retry_count = 0;
56 int s3_object_put_retry_count = 0;
57 long long s3_bytes_written=0;
58 long long s3_bytes_read=0;
59
60 using namespace std;
61 using namespace s3;
62
63 const char *aws_access_key_id;
64 const char *aws_secret_access_key;
65 const char *aws_base_url = "http://s3.amazonaws.com/";
66
67 /* Simson's S3 implementation in C++.
68 * Note that libcurl and expat will both handle data in chunks, so
69 * technically we don't need to create a single buffer with the entire response
70 * from AWS. For AFFLIB, though, we want to work on data as buffers.
71 * As a result, we create and use a buffer for all work.
72 */
73
74 namespace s3 {
75
76 static string itos(int i)
77 {
78 char buf[64];
79 snprintf(buf,sizeof(buf),"%d",i);
80 return string(buf);
81 }
82
83 size_t buffer::write(const char *b,size_t count){
84 if(!writable) return false;
85 base = (char *)realloc(base,len+count);
86 if(base){
87 memcpy(base+len,b,count); // copy the memory over
88 len += count;
89 return count;
90 }
91 return 0;
92 }
93 size_t buffer::read(char *b,size_t count){
94 if(base){
95 if(count>len-ptr) count=len-ptr;
96 memcpy(b,base+ptr,count);
97 ptr += count;
98 return count;
99 }
100 return 0;
101 }
102
103 void buffer::print() {
104 fwrite(base,1,len,stdout);
105 }
106
107 void buffer::clear(){
108 if(base){
109 free(base);
110 base = 0;
111 }
112 len = 0;
113 }
114
115
116 static size_t buffer_write(void *buffer, size_t size, size_t nmemb, void *userp)
117 {
118 return ((class buffer *)userp)->write((const char *)buffer,size * nmemb);
119 }
120
121 static size_t buffer_read(void *buffer, size_t size, size_t nmemb, void *userp)
122 {
123 return ((class buffer *)userp)->read((char *)buffer,size * nmemb);
124 }
125
126
127 static void startElement(void *userData, const char *name, const char **atts)
128 {
129 class s3_result *einfo = (class s3_result *)userData;
130 einfo->depth++;
131 switch(einfo->depth){
132 case 1:
133 if(!strcmp(name,"ListBucketResult")) {einfo->lbr = new ListBucketResult();break;}
134 if(!strcmp(name,"ListAllMyBucketsResult")) {einfo->lambr = new ListAllMyBucketsResult();break;}
135 fprintf(stderr,"\ns3 buffer:\n%s",einfo->buf->base);
136 errx(1,"Unknown XML element from S3: '%s'",name);
137 break;
138 case 2:
139 if(einfo->lbr && !strcmp(name,"Contents")){ einfo->lbr->contents.push_back(new Contents());break;}
140 break;
141 case 3:
142 if(einfo->lambr && !strcmp(name,"Bucket")){ einfo->lambr->Buckets.push_back(new Bucket());break;}
143 break;
144 }
145 }
146
147 static void endElement(void *userData, const char *name)
148 {
149 class s3_result *einfo = (class s3_result *)userData;
150 if(einfo->lambr){
151 switch(einfo->depth){
152 case 3:
153 if(!strcmp(name,"ID")){ einfo->lambr->OwnerID = einfo->cbuf;break;}
154 if(!strcmp(name,"DisplayName")){ einfo->lambr->OwnerDisplayName = einfo->cbuf;break;}
155 break;
156 case 4:
157 if(!strcmp(name,"Name")) { einfo->lambr->Buckets.back()->Name = einfo->cbuf;break;}
158 if(!strcmp(name,"CreationDate")) { einfo->lambr->Buckets.back()->CreationDate = einfo->cbuf;break;}
159 }
160 }
161 if(einfo->lbr){
162 switch(einfo->depth){
163 case 2:
164 if(!strcmp(name,"Name")){ einfo->lbr->Name = einfo->cbuf; break;}
165 if(!strcmp(name,"Prefix")){ einfo->lbr->Prefix = einfo->cbuf;break;}
166 if(!strcmp(name,"Marker")){ einfo->lbr->Marker = einfo->cbuf;break;}
167 if(!strcmp(name,"MaxKeys")){ einfo->lbr->MaxKeys = atoi(einfo->cbuf.c_str());break;}
168 if(!strcmp(name,"IsTruncated")){ einfo->lbr->IsTruncated = tolower(einfo->cbuf[0]) == 't';break;}
169 break;
170 case 3:
171 if(!strcmp(name,"Key")){ einfo->lbr->contents.back()->Key = einfo->cbuf; break;}
172 if(!strcmp(name,"LastModified")){einfo->lbr->contents.back()->LastModified = einfo->cbuf;break;}
173 if(!strcmp(name,"ETag")){ einfo->lbr->contents.back()->ETag = einfo->cbuf;break;}
174 if(!strcmp(name,"Size")){ einfo->lbr->contents.back()->Size = atoi(einfo->cbuf.c_str());break;}
175 break;
176 case 4:
177 if(!strcmp(name,"ID")){ einfo->lbr->contents.back()->OwnerID = einfo->cbuf;break;}
178 if(!strcmp(name,"DisplayName")){ einfo->lbr->contents.back()->OwnerDisplayName = einfo->cbuf;break;}
179 break;
180 default:;
181 }
182 }
183 #ifdef BAD_STL
184 einfo->cbuf = "";
185 #else
186 einfo->cbuf.clear();
187 #endif
188 einfo->depth--;
189 }
190
191 static void characterDataHandler(void *userData,const XML_Char *s,int len)
192 {
193 class s3_result *einfo = (class s3_result *)userData;
194 einfo->cbuf.append((const char *)s,len);
195 }
196
197
198 static class s3_result *xml_extract_response(const class buffer *buf)
199 {
200 class s3_result *e = new s3_result();
201
202 e->buf = buf;
203 XML_Parser parser = XML_ParserCreate(NULL);
204 XML_SetUserData(parser, e);
205 XML_SetElementHandler(parser, startElement, endElement);
206 XML_SetCharacterDataHandler(parser,characterDataHandler);
207
208 if (!XML_Parse(parser, (const char *)buf->base, buf->len, 1)) {
209 char buf2[2048];
210 snprintf(buf2,sizeof(buf2),
211 "XML Error: %s at line %d",
212 XML_ErrorString(XML_GetErrorCode(parser)),(int)XML_GetCurrentLineNumber(parser));
213 fprintf(stderr,"%s:\n",buf2);
214 XML_ParserFree(parser);
215 return 0;
216 }
217 XML_ParserFree(parser);
218 return e;
219 }
220
221
222
223 /* Create the cannonical string for the headers */
224 static string canonical_string(string method,string path,curl_slist *headers, time_t expires)
225 {
226 /* Iterate through the headers a line at a time */
227 map<string,string> interesting_headers;
228
229 for(;headers;headers = headers->next){
230 char *line = strdup(headers->data);
231 char *word;
232 char *brk2;
233 word = strtok_r(line,": ",&brk2);
234 if(word){
235 if(strcasecmp(word,"Date")==0 ||
236 strcasecmp(word,"Range")==0 ||
237 strncmp(word,AMAZON_METADATA_PREFIX,strlen(AMAZON_METADATA_PREFIX))==0){
238 char *value = strtok_r(NULL,"",&brk2);
239 while(value && isspace(*value)) value++;
240 interesting_headers[word] = value;
241 }
242 }
243 free(line);
244 }
245 /* Add the headers that we don't have */
246
247 /* handle the date */
248
249 /* Get the sorted headers */
250 vector<string> sorted_header_keys;
251 for(map<string,string>::const_iterator i = interesting_headers.begin();
252 i!=interesting_headers.end();
253 i++){
254 sorted_header_keys.push_back(i->first);
255 }
256
257 #ifndef BAD_STL
258 sort(sorted_header_keys.begin(),sorted_header_keys.end());
259 #endif
260
261 string buf = method + "\n";
262 buf += "\n"; // content-md5 value
263 buf += "\n"; // content-type value
264
265 /* Either put in a date header or else do the expires */
266 if(expires){
267 char b[64];
268 snprintf(b,sizeof(b),"%d\n",(int)expires);
269 buf += b;
270 }
271 else {
272 buf += interesting_headers["Date"] + "\n"; // date
273 }
274
275 /* AMAON_HEADER_PREFIX headers only... */
276 for(vector<string>::const_iterator i = sorted_header_keys.begin();
277 i != sorted_header_keys.end();
278 i++){
279 if(i->substr(0,strlen(AMAZON_METADATA_PREFIX))==AMAZON_METADATA_PREFIX){
280 buf += *i + ":" + interesting_headers[*i] + "\n";
281 }
282 }
283 buf += "/" + path; // the resource
284
285 //printf("canonical: \n===========\n%s\n=========\n",buf.c_str());
286
287 return buf;
288
289 }
290
291 static string encode(const char *aws_secret_access_key,string str)
292 {
293 unsigned char md[20];
294 unsigned int md_len = sizeof(md);
295
296 /* Note: This MUST be sha1() */
297 HMAC(EVP_sha1(),aws_secret_access_key,strlen(aws_secret_access_key),
298 (const unsigned char *)str.c_str(),str.size(),
299 md,&md_len);
300 /* Now encode this to base64 */
301 char b64str[64];
302 memset(b64str,0,sizeof(b64str));
303 b64_ntop(md,md_len,b64str,sizeof(b64str));
304 return string(b64str);
305 }
306
307
308
309 static string quote_plus(string &url)
310 {
311 /* encode the URL */
312 string eurl;
313 char buf[6];
314 for(string::const_iterator c = url.begin(); c != url.end(); c++){
315 switch(*c){
316 case '%':
317 case ';':
318 case '/':
319 case '?':
320 case '@':
321 case '&':
322 case '=':
323 case '+':
324 case '$':
325 case ',':
326 sprintf(buf,"%%%02X",*c);
327 eurl += buf;
328 continue;
329 case ' ':
330 eurl += "+";
331 continue;
332 default:
333 eurl += *c;
334 continue;
335 }
336 }
337 return eurl;
338 }
339
340 #ifndef HAVE_ISDIGIT
341 static int isdigit(char ch)
342 {
343 return ch>='0' && ch<='9';
344 }
345 #endif
346
347 static int hexval(int ch) { return (isdigit(ch) ? ch-'0' : ch-'a'+10);}
348
349 /*
350 * Execute an S3 request:
351 * method - method to execute.
352 * path - path for the object.
353 * query - anything optional after the "?" in the path
354 * expires - When the authorization URL should expire.
355 * sendbuf - if we are sending something ,this is what is being sent.
356 * sendbuflen - how long that buffer is
357 * extraheaders - any additional headers that should be sent; useful for metadata
358 *
359 * Returns a response buffer
360 */
361
362 /* CURLINFO_RESPONSE_CODE is the new name for the option previously known as
363 * CURLINFO_HTTP_CODE.
364 */
365
366
367 #ifndef CURLINFO_RESPONSE_CODE
368 #define CURLINFO_RESPONSE_CODE CURLINFO_HTTP_CODE
369 #endif
370
371 class response_buffer *request(string method,string path,string query,time_t expires,
372 const char *sendbuf,size_t sendbuflen,
373 const s3headers *extraheaders)
374 {
375 /* Note: this function is not threadsafe */
376 static bool curl_initted = false;
377 if(!curl_initted){
378 curl_global_init(CURL_GLOBAL_ALL);
379 curl_initted=true;
380 }
381
382 int retry_count=0;
383 class response_buffer *b = 0;
384 class buffer *h = 0;
385 do {
386
387 if(s3_debug>1) printf("==================================================\n");
388 if(s3_debug && retry_count>0) printf("=== S3 RETRY %d ===\n",retry_count);
389
390 CURL *c = curl_easy_init();
391 struct curl_slist *headers=NULL;
392
393 if(expires==0){
394 /* Add the Date: field to the header */
395 struct tm tm;
396 time_t t = time(0);
397 char date[64];
398 strftime(date,sizeof(date),"Date: %a, %d %b %Y %X GMT",gmtime_r(&t,&tm));
399 headers = curl_slist_append(headers, date);
400 }
401
402 /* Add the extra headers */
403 while(extraheaders && extraheaders[0].name){
404 int len = strlen(extraheaders[0].name)+strlen(extraheaders[0].value)+4;
405 char *buf = (char *)alloca(len);
406 snprintf(buf,len,"%s: %s",extraheaders[0].name,extraheaders[0].value);
407 headers = curl_slist_append(headers, buf);
408 extraheaders++;
409 }
410
411 string url = aws_base_url + path;
412 string canonical_str = canonical_string(method,path,headers,expires);
413 string encoded_canonical = encode(aws_secret_access_key,canonical_str);
414
415 if(expires==0){
416 /* Create an Authorization header */
417
418 char authorization[96];
419
420 snprintf(authorization,sizeof(authorization),"Authorization: AWS %s:%s",
421 aws_access_key_id,encoded_canonical.c_str());
422 headers = curl_slist_append(headers, authorization);
423 curl_easy_setopt(c, CURLOPT_HTTPHEADER, headers);
424 }
425
426 if(expires){
427 /* Add authorization to the URL*/
428 if(query.size()>0) query += "&";
429 query += "Signature=" + quote_plus(encoded_canonical);
430 query += "&Expires=" + itos(expires);
431 query += "&AWSAccessKeyId=" + string(aws_access_key_id);
432 }
433
434 if(query.size()>0){
435 url += "?" + query;
436 }
437
438 if(b) delete b;
439 b = new response_buffer();
440 memset(b->ETag,0,sizeof(b->ETag));
441 if(s3_debug>1) curl_easy_setopt(c,CURLOPT_VERBOSE,1);
442 if(method != "GET"){
443 curl_easy_setopt(c,CURLOPT_CUSTOMREQUEST,method.c_str());
444 }
445
446 if(method == "HEAD"){
447 curl_easy_setopt(c,CURLOPT_NOBODY,1);
448 }
449
450 /* Queries that take longer than an hour should timeout */
451 curl_easy_setopt(c,CURLOPT_TIMEOUT,60*60);
452
453 /* Disable DNS cache */
454 curl_easy_setopt(c,CURLOPT_DNS_CACHE_TIMEOUT,0); // per amazon specification
455 curl_easy_setopt(c,CURLOPT_WRITEFUNCTION,buffer_write);
456 curl_easy_setopt(c,CURLOPT_WRITEDATA,b); // fourth argument
457 curl_easy_setopt(c,CURLOPT_URL,url.c_str());
458
459 /* Are we sending data */
460 class buffer *sendbuffer = 0;
461 if(sendbuf){
462 sendbuffer = new buffer(sendbuf,sendbuflen);
463 curl_easy_setopt(c,CURLOPT_READFUNCTION,buffer_read);
464 curl_easy_setopt(c,CURLOPT_READDATA,sendbuffer);
465 curl_easy_setopt(c,CURLOPT_UPLOAD,1);
466 curl_easy_setopt(c,CURLOPT_INFILESIZE,sendbuflen);
467 //fprintf(stderr,"***** sendbuflen= %d %qd\n",sizeof(sendbuflen),sendbuflen);
468 }
469
470 /* Make provisions to get the response headers */
471 if(h) delete h;
472 h = new buffer();
473 curl_easy_setopt(c,CURLOPT_HEADERFUNCTION,buffer_write);
474 curl_easy_setopt(c,CURLOPT_WRITEHEADER,h); // fourth argument
475
476 /* Make provisions for getting the headers */
477
478 int success = curl_easy_perform(c);
479
480 if(sendbuffer){
481 delete sendbuffer;
482 sendbuffer = 0;
483 if(success==0) s3_bytes_written += sendbuflen;
484 }
485
486 s3_bytes_read += h->len;
487 s3_bytes_read += b->len;
488
489 // CURL API says do not assume NULL terminate, so terminate it
490 h->write("\000",1);
491 curl_easy_getinfo(c,CURLINFO_RESPONSE_CODE,&b->result);
492
493 /* Now clean up */
494 s3_request_retry_count = retry_count;
495 if(headers) curl_slist_free_all(headers);
496 curl_easy_cleanup(c);
497
498 /* Process the results */
499 if(success!=0){
500 delete h;
501 delete b;
502 s3_request_retry_count = retry_count;
503 return 0; // internal CURL error
504 }
505 if(s3_debug>2){
506 printf("Header results:\n");
507 h->print();
508 printf("Data results:\n");
509 b->print();
510 printf("\n");
511 }
512 } while(b->result==500 && ++retry_count<s3_retry_max);
513
514 if(b->result==404) errno=ENOENT;
515
516 /* Pull out the headers */
517 char *line,*brkt;
518 for(line = strtok_r(h->base,"\r\n",&brkt);
519 line;
520 line = strtok_r(NULL,"\r\n",&brkt)){
521 char *cc = strchr(line,':');
522 if(cc){
523 *cc++ = '\000';
524 while(*cc && isspace(*cc)) cc++;
525 b->rheaders[line] = cc;
526 }
527 }
528
529 /* Find the ETag in the header and put in the buffer */
530 const char *e = b->rheaders["ETag"].c_str();
531 if(strlen(e)==34){
532 for(int i=0;i<16;i++){
533 b->ETag[i] = (hexval(e[i*2+1])<<4) + hexval(e[i*2+2]);
534 }
535 }
536
537 delete h; // we don't care about it
538 if(s3_debug>1) printf(".\n\n");
539 return b;
540 }
541
542 response_buffer *get_url(const char *url)
543 {
544 int retry_count = 0;
545 response_buffer *b = new response_buffer();
546 do {
547 CURL *c = curl_easy_init();
548 curl_easy_setopt(c,CURLOPT_WRITEFUNCTION,buffer_write);
549 curl_easy_setopt(c,CURLOPT_WRITEDATA,b);
550 curl_easy_setopt(c,CURLOPT_URL,url);
551 int success = curl_easy_perform(c);
552 curl_easy_getinfo(c,CURLINFO_RESPONSE_CODE,&b->result);
553 curl_easy_cleanup(c);
554 } while(b->result!=200 && ++retry_count<s3_retry_max);
555 s3_request_retry_count = retry_count;
556 return b;
557 }
558
559
560
561
562 class s3_result *list_buckets()
563 {
564 time_t expires = time(0)+60;
565 expires = 0;
566 class response_buffer *b = request("GET","","",expires,0,0,0);
567
568 class s3_result *r = xml_extract_response(b);
569 delete b;
570 return r;
571 }
572
573 class s3_result *list_bucket(string bucket,string prefix,string marker,int max_keys)
574 {
575 string query;
576
577
578 if(prefix.size()>0) query += "prefix=" + prefix;
579 if(marker.size()>0){
580 if(query.size()>0) query += "&";
581 query += "marker=" + marker;
582 }
583 if(max_keys>0){
584 if(query.size()>0) query += "&";;
585 query += "max-keys=" + itos(max_keys);
586 }
587 class response_buffer *b = request("GET",bucket,query,0,0,0,0);
588 if(!b) return 0;
589 class s3_result *r = xml_extract_response(b);
590 delete b;
591 return r;
592 }
593
594 /*
595 * af_hexbuf:
596 * Turn a binay string into a hex string, optionally with spaces.
597 */
598
599 #define HEXBUF_NO_SPACES 0
600 #define HEXBUF_SPACE2 0x0001 // space every 2 characters
601 #define HEXBUF_SPACE4 0x0002 // space every 4 characters
602 #define HEXBUF_UPPERCASE 0x1000 // uppercase
603 static const char *hexbuf(char *dst,int dst_len,const unsigned char *bin,int bytes,int flag)
604 {
605 int charcount = 0;
606 const char *start = dst; // remember where the start of the string is
607 const char *fmt = (flag & HEXBUF_UPPERCASE) ? "%02X" : "%02x";
608
609 *dst = 0; // begin with null termination
610 while(bytes>0 && dst_len > 3){
611 sprintf(dst,fmt,*bin); // convert the next byte
612 dst += 2;
613 bin += 1;
614 dst_len -= 2;
615 bytes--;
616 charcount++; // how many characters
617
618 bool add_spaces = false;
619 if(flag & HEXBUF_SPACE2) add_spaces = true;
620 if((flag & HEXBUF_SPACE4) && charcount%2==0){
621 *dst++ = ' ';
622 *dst = '\000';
623 dst_len -= 1;
624 }
625 }
626 return start; // return the start
627 }
628
629
630 /* object_put:
631 * Put an object. Make sure that the MD5 of the response matches..
632 * Makes a few retry attempts
633 * Return 0 if success, -1 if failure.
634 */
635 int object_put(string bucket,string path,
636 const char *buf,size_t buflen,
637 const struct s3headers *extraheaders)
638 {
639 unsigned char md5[16];
640 memset(md5,0,sizeof(md5));
641 MD5((const unsigned char *)buf,buflen,md5);
642 for(int i=0;i<s3_retry_max;i++){
643 s3_object_put_retry_count = i;
644 if(i>0){
645 fprintf(stderr,"S3: Attempt to write object '%s' failed. Retrying...\n",
646 path.c_str());
647 }
648
649 response_buffer *res = request("PUT",bucket + "/" + path,"",0,buf,buflen,extraheaders);
650 if(!res) {
651 fprintf(stderr,"S3 request: No response.\n");
652 continue;
653 }
654 if(memcmp(res->ETag,md5,16)==0){ /* Check the MD5 of the response */
655 delete res;
656 return 0;
657 }
658 char buf0[64],buf1[64];
659 fprintf(stderr,"S3: Expected ETag '%s' got '%s'\n",
660 hexbuf(buf0,sizeof(buf0),md5,16,HEXBUF_SPACE4),
661 hexbuf(buf1,sizeof(buf1),res->ETag,16,HEXBUF_SPACE4));
662 delete res;
663 }
664 /* Write failed. Delete the written object and return */
665 response_buffer *res = request("DELETE",bucket + "/" + path,"",0,0,0,0);
666 if(res) delete res;
667 errno = EIO;
668 return -1;
669 }
670
671 int bucket_mkdir(string bucket)
672 {
673 class response_buffer *b = request("PUT",bucket,"",0,0,0,0);
674 int result = b->result;
675 delete b;
676 switch(result){
677 case 409:errno=EEXIST; return -1;
678 case 200:errno=0;return 0;
679 }
680 return -1; // some unknown error
681 }
682
683 int bucket_rmdir(string bucket)
684 {
685 class response_buffer *b = request("DELETE",bucket,"",0,0,0,0);
686 int result = b->result;
687 delete b;
688 switch(result){
689 case 403:errno=EACCES; return -1;
690 case 404:errno=ENOENT; return -1;
691 case 409:errno=ENOTEMPTY; return -1;
692 case 204:errno=0;return 0; // no content is actually what it gives
693 case 200:errno=0;return 0; // doesn't seem to give this one
694 }
695 return -1; // some unknown error
696 }
697
698 class response_buffer *object_get(string bucket,string path,const s3headers *extra_headers)
699 {
700 return request("GET",bucket + "/" + path,"",0,0,0,extra_headers);
701 }
702
703 class response_buffer *object_head(string bucket,string path,const s3headers *extra_headers)
704 {
705 return request("HEAD",bucket + "/" + path,"",0,0,0,extra_headers);
706 }
707
708 int object_rm(string bucket,string path)
709 {
710 class response_buffer *b = request("DELETE",bucket + "/" + path,"",0,0,0,0);
711 if(b){
712 delete b;
713 return 0;
714 }
715 return -1;
716 }
717
718 }
719
720 void s3_audit(int i)
721 {
722 if(i>0 || s3_bytes_written>0 || s3_bytes_read>0){
723 fprintf(stderr,"\n");
724 fprintf(stderr,"S3 bytes written: %qu\n",s3_bytes_written);
725 fprintf(stderr,"S3 bytes read: %qu\n",s3_bytes_read);
726 }
727 }
728 #endif /* USE_S3 */
0 /*
1 * s3_glue.h:
2 *
3 * Glue logic to make AFFLIB work with Amazon's Simple Storage Service.
4 * This can also be compiled stand-alone by #define STAND.
5 * That's useful for testing
6 *
7 * Requires: expat, openssl (for base64 coding)
8 */
9
10 #ifndef S3_GLUE_H
11 #define S3_GLUE_H
12
13 #include <stdlib.h>
14 #include <sys/types.h>
15
16 #include <string>
17 #include <map>
18 #include <vector>
19 #include <cstring> // memcpy, strcmp, strlen
20 #include <algorithm> // sort
21
22 #define S3_DEFAULT_BUCKET "S3_DEFAULT_BUCKET"
23 #define S3_DEBUG "S3_DEBUG"
24 #define AWS_ACCESS_KEY_ID "AWS_ACCESS_KEY_ID"
25 #define AWS_SECRET_ACCESS_KEY "AWS_SECRET_ACCESS_KEY"
26
27 extern int s3_debug;
28 extern int s3_retry_max; // default 5; you can set however you wish
29 extern int s3_request_retry_count;
30 extern int s3_object_put_retry_count;
31 extern const char *aws_access_key_id;
32 extern const char *aws_secret_access_key;
33 extern const char *aws_base_url;
34 extern long long s3_total_written;
35 extern long long s3_total_read;
36
37 #define AMAZON_METADATA_PREFIX "x-amz-meta-"
38 #define S3_CONTENT_LENGTH "Content-Length"
39
40 void s3_audit(int x);
41
42 namespace s3 {
43 using namespace std;
44
45 struct s3headers {
46 const char *name; // do not include x-amz-meta-
47 const char *value;
48 };
49
50 class buffer {
51 public:
52 char *base; // array
53 size_t len; // length
54 int ptr; // for reading
55 bool writable;
56 buffer() : base(0),len(0),ptr(0),writable(true) {}
57 buffer(const char *base_,int len_) :
58 base((char *)base_),len(len_),ptr(0),writable(false) {}
59 ~buffer() { if(base && writable) free(base);}
60 /* Append bytes; return number of bytes appended */
61 size_t write(const char *b,size_t count);
62 size_t read(char *b,size_t count);
63 void print();
64 void clear();
65 };
66
67 class response_buffer : public buffer {
68 public:
69 long result; // HTTP result code
70 map<string,string> rheaders; // response headers
71 unsigned char ETag[16]; // if provided, in binary
72 };
73
74 /* S3 XML Objects */
75 class Contents {
76 public:
77 string Key;
78 string LastModified;
79 string ETag;
80 size_t Size;
81 string OwnerID;
82 string OwnerDisplayName;
83 string StorageClass;
84 };
85
86 class Bucket {
87 public:
88 string Name;
89 string CreationDate;
90 };
91
92 class ListAllMyBucketsResult {
93 public:
94 ~ListAllMyBucketsResult(){
95 for(vector<Bucket *>::iterator i = Buckets.begin();
96 i != Buckets.end();
97 i++){
98 delete *i;
99 }
100 }
101 string OwnerID;
102 string OwnerDisplayName;
103 vector<Bucket *> Buckets;
104 };
105
106 class ListBucketResult {
107 public:
108 ~ListBucketResult(){
109 for(vector<Contents *>::iterator i = contents.begin();
110 i != contents.end();
111 i++){
112 delete *i;
113 }
114 }
115 string Name;
116 string Prefix;
117 string Marker;
118 int MaxKeys;
119 bool IsTruncated;
120 vector<Contents *> contents; // list of objects
121 };
122
123 class s3_result {
124 public:
125 s3_result() : depth(0),lambr(0),lbr(0){};
126 ~s3_result() {
127 if(lambr) delete lambr;
128 if(lbr) delete lbr;
129 }
130 int depth;
131 string cbuf; // buffer of these characters
132 class ListAllMyBucketsResult *lambr;
133 class ListBucketResult *lbr; // list bucket results
134 const class buffer *buf; // what we are parsing
135 };
136
137 response_buffer *request(string method,string path,string query,time_t expires,
138 const char *sendbuf,size_t sendbuflen,
139 const s3headers *extra_headers);
140 response_buffer *get_url(const char *url);
141 s3_result *list_buckets();
142 s3_result *list_bucket(string bucket,string prefix,string marker,int max_keys);
143 int object_put(string bucket,string path,
144 const char *buf,size_t buflen,
145 const struct s3headers *meta);
146 int bucket_mkdir(string bucket);
147 int bucket_rmdir(string bucket);
148 response_buffer *object_get(string bucket,string path,
149 const s3headers *extra_headers);
150 response_buffer *object_head(string bucket,string path,
151 const s3headers *extra_headers);
152 int object_rm(string bucket,string path);
153 }
154
155 #endif
0 /*
1 * Threaded hash object.
2 * Note that this just has a second thread for hashing one block, then it blocks.
3 * We could chain the blocks together, but we don't.
4 */
5
6 #ifndef THREADED_HASH_H
7 #define THREADED_HASH_H
8 #include <openssl/evp.h>
9 #ifdef HAVE_ERR_H
10 #include <err.h>
11 #endif
12
13 #include <signal.h>
14 #include <assert.h>
15 #include <sys/types.h>
16 #include <stdint.h>
17
18 #ifndef MIN
19 #define MIN(x,y) ((x)<(y)?(x):(y))
20 #endif
21
22 #include <string>
23 #include <queue>
24
25 /* Currently this doesn't thread. */
26 /* threaded EVP hash object */
27 class threaded_hash {
28 static const u_int MAX_BYTES_IN_WORKLIST = 1024*1024*16; // don't use more than 16MB
29 private:;
30 #ifdef HAVE_PTHREAD
31 class buffer {
32 u_int flags;
33 public:
34 static const int SHOULD_MALLOC = 0x0001;
35 static const int SHOULD_FREE = 0x0002;
36 buffer():flags(0),buf(0),bufsize(0){ }
37 buffer(const u_char *buf,size_t bufsize,int flags){
38 if(flags & SHOULD_MALLOC){
39 this->buf = (u_char *)malloc(bufsize);
40 memcpy(this->buf,buf,bufsize);
41 }
42 else {
43 this->buf = (u_char *)buf;
44 }
45 this->bufsize = bufsize;
46 this->flags = flags;
47 }
48 void done(){
49 if(this->flags & SHOULD_FREE) free(buf);
50 }
51 u_char *buf;
52 size_t bufsize;
53 bool should_free;
54 };
55 /* These variables are all protected by the mutex */
56 std::queue<buffer> worklist;
57 size_t bytes_in_worklist; // how many do we have
58 public:
59 uint64_t max_bytes_in_worklist; // how big did it get?
60 private:
61 pthread_t worker_id; // the worker that is hashing, or 0
62 pthread_mutex_t mutex; // protects worklist and working
63 pthread_cond_t wakeup_worker;
64 pthread_cond_t wakeup_producer; // if worklist gets to big, the producer must sleep
65 bool be_threaded;
66 /* END OF MUTEX AREA */
67 #endif
68 const EVP_MD *md; // null means hash object is not valid
69 EVP_MD_CTX ctx; // hash context
70 mutable u_char *hashbuf; // null if needs to be calculated
71 mutable char *hexbuf; // mull if needs to be calculated
72 public:
73 std::string name(){return std::string(EVP_MD_name(md));}
74 static bool iszero(const u_char *buf,size_t bufsize);
75
76
77 /** The worker thread needs to be a static function because it is run in its own thread.
78 * It does the work on the worklist when there is work to do.
79 * If we are not multi-threaded then the update is simply called.
80 */
81
82 #ifdef HAVE_PTHREAD
83 static void *worker(void *arg){
84 threaded_hash *t = (threaded_hash *)arg;
85 while (1){
86 /* Wait until there is no work to do */
87 pthread_mutex_lock(&t->mutex);
88 while(t->worklist.size()==0){
89 pthread_cond_signal(&t->wakeup_producer); // make sure the producer is awake
90 pthread_cond_wait(&t->wakeup_worker,&t->mutex); // and wait for more data
91 }
92 class buffer b = t->worklist.front(); /* get the next bit of work */
93 t->worklist.pop();
94 t->bytes_in_worklist -= b.bufsize;
95 t->hashed_bytes += b.bufsize;
96 pthread_mutex_unlock(&t->mutex);
97 if(b.bufsize==0){ // we are done
98 break;
99 }
100 EVP_DigestUpdate(&t->ctx,b.buf,b.bufsize);
101 b.done(); // done with this buffer
102 }
103 return 0;
104 }
105 #endif
106
107 public:;
108 u_int hash_size; // MD5 is 16
109 size_t hashed_bytes; // number of bytes that have been hashed
110 threaded_hash(const EVP_MD *md,bool be_threaded){
111 this->md = md;
112 this->hashed_bytes= 0;
113 this->hashbuf = 0;
114 this->hexbuf = 0;
115 this->hash_size = 0;
116 if(md==0){
117 if(EVP_get_digestbyname("md5")==0){
118 fprintf(stderr,"fatal: Call OpenSSL_add_all_digests() prior to calling EVP_get_digestbyname()\n");
119 exit(1);
120 }
121 return; // invalid MD
122 }
123 EVP_DigestInit(&ctx,md);
124 this->hash_size = EVP_MD_size(md);
125 #ifdef HAVE_PTHREAD
126 this->worker_id = 0;
127 this->bytes_in_worklist = 0;
128 this->max_bytes_in_worklist = 0;
129 this->be_threaded = be_threaded;
130 pthread_mutex_init(&this->mutex,0);
131 pthread_cond_init(&this->wakeup_worker,0);
132 pthread_cond_init(&this->wakeup_producer,0);
133 if(be_threaded) launch(); // create another one
134 #endif
135 }
136 #ifdef HAVE_PTHREAD
137 void launch(){
138 pthread_create(&worker_id,NULL,worker,(void *)this);
139 assert(worker_id!=0);
140 }
141 void push(class buffer &b) {
142 pthread_mutex_lock(&mutex);
143 bytes_in_worklist += b.bufsize;
144 if(bytes_in_worklist > max_bytes_in_worklist) max_bytes_in_worklist = bytes_in_worklist;
145 worklist.push(b);
146 pthread_cond_signal(&wakeup_worker);
147 pthread_mutex_unlock(&mutex);
148 }
149 #endif
150 static class threaded_hash *new_threaded_hash(const char *name,bool be_threaded){
151 return new threaded_hash(EVP_get_digestbyname(name),be_threaded);
152 }
153
154 ~threaded_hash(){
155 #ifdef HAVE_PTHREAD
156 if(worker_id){ // thread is still present; just kill it
157 class buffer b; // send through a finish
158 push(b);
159 pthread_join(worker_id,0); // wait for the thread to finish
160 worker_id = 0;
161 }
162 pthread_mutex_destroy(&mutex);
163 pthread_cond_destroy(&wakeup_worker);
164 pthread_cond_destroy(&wakeup_producer);
165 #endif
166 if(md) EVP_MD_CTX_cleanup(&ctx);
167 if(hashbuf) free(hashbuf);
168 if(hexbuf) free(hexbuf);
169 }
170 /** Return if this hash object is usable */
171 bool valid(){
172 return this->md!=0;
173 }
174
175 /** reset the hash object */
176 void clear(){
177 if(this->md==0) return;
178 final(); // make sure that the hashing is done
179 EVP_MD_CTX_cleanup(&ctx);
180 EVP_DigestInit(&ctx,md);
181 this->hashed_bytes = 0;
182 if(hashbuf){ free(hashbuf);hashbuf=0;}
183 if(hexbuf){ free(hexbuf);hexbuf=0;}
184 #ifdef HAVE_PTHREAD
185 if(be_threaded) launch();
186 #endif
187 }
188
189 void update(const u_char *buf,size_t bufsize){
190 if(this->md==0) return; // no MD set
191 if(bufsize==0) return; // nothing to do
192
193 /** For the multi-threaded application, copy over the data to be hashed.
194 * Then lock the mutex and start a worker
195 * thread that will do the actual hash. The mutex will unlock when done.
196 * A more efficient implementation would use a thread pool and not constantly
197 * create and destroy the mutexes.
198 */
199 #ifdef HAVE_PTHREAD
200 if(worker_id){
201 pthread_mutex_lock(&mutex);
202 if(bytes_in_worklist > MAX_BYTES_IN_WORKLIST){
203 /* If too much in the worklist, wait until it clears before we allocate more */
204 pthread_cond_wait(&wakeup_producer,&mutex);
205 }
206 pthread_mutex_unlock(&mutex);
207 class buffer b(buf,bufsize,buffer::SHOULD_FREE|buffer::SHOULD_MALLOC);
208 push(b);
209 return;
210 }
211 #endif
212 EVP_DigestUpdate(&ctx,buf,bufsize);
213 hashed_bytes += bufsize;
214 }
215 /** If the hash hasn't been calculated,
216 * Perform the final and return a pointer to the buffer.
217 */
218 u_char *final(){
219 if(this->md==0) return 0;
220 if(this->hashbuf==0){
221 #ifdef HAVE_PTHREAD
222 if(worker_id!=0){ // make sure the other thread has stopped.
223 class buffer b; // send through a finish
224 push(b);
225 pthread_join(worker_id,0); // wait for the worker to be done
226 worker_id = 0; // the thread is gone
227 }
228 #endif
229 this->hashbuf = (u_char *)calloc(hash_size,1);
230 EVP_DigestFinal(&ctx,this->hashbuf,&hash_size);
231 }
232 return this->hashbuf;
233 }
234
235 void final(u_char *mdbuf,unsigned int md_len){
236 if(this->md==0) return;
237 memcpy(mdbuf,final(),MIN(md_len,hash_size));
238 }
239 /** Return the hash buffer */
240 u_char *hash(){ return final(); }
241
242 /** Returns the length of the hash in bytesn*/
243 size_t len(){return hash_size;}
244
245 /** Return the hex of the hash buffer, null terminated */
246 const char *hexhash(){
247 if(hexbuf==0){
248 this->hexbuf = (char *)calloc(hash_size*2+1,1);
249 u_char *hashbuf = final();
250 for(u_int i=0;i<hash_size;i++){
251 sprintf(hexbuf+i*2,"%02x",hashbuf[i]);
252 }
253 }
254 return hexbuf;
255 }
256 bool operator<( threaded_hash &s2);
257 bool operator==( threaded_hash &s2);
258 };
259
260 inline bool threaded_hash::iszero(const u_char *buf,size_t bufsize){
261 for(u_int i=0;i<bufsize;i++){
262 if(buf[i]!=0) return false;
263 }
264 return true;
265 }
266
267 inline bool threaded_hash::operator<( threaded_hash &s2) {
268 if(this->md==0 || s2.md==0) return false;
269 if(this->hash_size != s2.hash_size) return false;
270 return memcmp(hash(),s2.hash(),hash_size) < 0;
271 }
272
273 inline bool threaded_hash::operator==( threaded_hash &s2) {
274 if(this->md==0 || s2.md==0) return false;
275 if(this->hash_size != s2.hash_size) return false;
276 return memcmp(hash(),s2.hash(),s2.hash_size) == 0;
277 }
278
279
280
281 #endif
0 /*
1 * utils.cpp:
2 *
3 * Some handy utilities for working with AFF
4 */
5
6
7 #include "affconfig.h"
8 #include "afflib.h"
9 #include "afflib_i.h"
10 #include "utils.h"
11 #ifdef HAVE_ERR_H
12 #include "err.h"
13 #endif
14
15 #include <string>
16 #ifdef HAVE_CSTRING
17 #include <cstring>
18 #endif
19
20 #ifdef HAVE_READLINE_READLINE_H
21 #include <readline/readline.h>
22 #endif
23
24 namespace aff {
25
26 /** Given argc and argv, return a string with the command line */
27 std::string command_line(int argc,char **argv) {
28 std::string command = "";
29 for(int i=0;i<argc;i++){
30 if(i>0) command += " ";
31 command += argv[i];
32 }
33 return command;
34 }
35
36 bool ends_with(const char *buf,const char *with)
37 {
38 if(buf && with){
39 size_t buflen = strlen(buf);
40 size_t withlen = strlen(with);
41 if(buflen>withlen && strcmp(buf+buflen-withlen,with)==0) return 1;
42 }
43 return 0;
44 }
45
46 bool ends_with(const std::string &buf,const std::string &with)
47 {
48 return ends_with(buf.c_str(),with.c_str());
49 }
50
51 /* Given an AFFILE, return a seglist.
52 * Returns -1 if failure, 0 if success.
53 */
54 int seglist::get_seglist(AFFILE *af)
55 {
56 if(af_rewind_seg(af)) return -1;
57 char name_[AF_MAX_NAME_LEN];
58 size_t len_=0;
59 u_long arg_=0;
60 while(af_get_next_seg(af,name_,sizeof(name_),&arg_,0,&len_)==0){
61 // We shouldn't have 0-len segment names, but we do in some files.
62 // Don't copy these segments.
63 if(strlen(name_)>0){
64 seginfo si(name_,len_,arg_);
65 push_back(si);
66 }
67 }
68 return 0;
69 }
70
71 bool seglist::has_signed_segments()
72 {
73 for(seglist::const_iterator seg = begin(); seg!=end() ;seg++){
74 if(ends_with(seg->name.c_str(),AF_SIG256_SUFFIX)){
75 return true;
76 }
77 }
78 return false;
79 }
80
81
82 bool seglist::contains(std::string segname)
83 {
84 for(std::vector<seginfo>::const_iterator i = begin(); i!=end(); i++){
85 if(i->name == segname) return true;
86 }
87 return false;
88 }
89
90 }
91
0 /*
1 * utils.h:
2 * Some useful utilities for building AFF-aware programs.
3 */
4
5 #ifndef AFF_UTILS_H
6 #define AFF_UTILS_H
7
8 #ifdef __cplusplus
9 #include <algorithm>
10 #include <cstdlib>
11 #include <vector>
12 #include <string>
13 #include <cstring>
14 #include <map>
15 #include <iostream>
16
17 #ifdef HAVE_OPENSSL_PEM_H
18 #include <openssl/x509.h>
19 #include <openssl/pem.h>
20 #else
21 typedef void X509;
22 typedef void EVP_PKEY;
23 typedef void BIO;
24 #define BIO_free free
25 #endif
26
27 namespace aff {
28
29 std::string command_line(int argc,char **argv);
30 bool ends_with(const char *buf,const char *with);
31 bool ends_with(std::string str,std::string ending);
32
33 /* Structure for hash map */
34 struct less_c_str
35 {
36 inline bool operator()( const char* x, const char* y) const
37 { return ( strcmp( x,y ) < 0 );
38 }
39 };
40
41 struct md5blob {
42 unsigned char buf[16];
43 };
44
45 typedef std::map< const char*, struct md5blob, less_c_str > hashMapT;
46
47 /* The seginfo stores information about a segment other than its data*/
48 class seginfo {
49 public:
50 seginfo(std::string n1,size_t l1,u_int a1): name(n1),len(l1),arg(a1) {}
51 std::string name;
52 size_t len;
53 u_long arg;
54 /** pagenumber returns <0 for invalid pages, >= for a page */
55 int64_t pagenumber() const {return af_segname_page_number(name.c_str());}
56 bool inline operator==(const class seginfo &b) const {
57 return name == b.name;
58 }
59 };
60
61 /* the seglist provides AFF internal functions and tools an easy way to get
62 * a list of all of the segments in the currently open AFF file.
63 * Use the seglist(af) constructor to populate it with all the segments
64 * when you create. Each element is populated with the name, length and arg.
65 */
66 class seglist : public std::vector<seginfo> {
67 public:
68 bool contains(std::string segname);
69 bool has_signed_segments();
70 int get_seglist(AFFILE *af);
71 seglist(){}
72 seglist(AFFILE *af){
73 get_seglist(af);
74 }
75 };
76 }
77 #endif
78
79 #endif
0 @SET_MAKE@
1 #define AFFLIB_VERSION "@PACKAGE_VERSION@"
2
0 /*
1 * vnode_aff.cpp:
2 *
3 * Functions for the manipulation of AFF files...
4 */
5
6 #include "affconfig.h"
7 #include "afflib.h"
8 #include "afflib_i.h"
9 #include "vnode_afd.h"
10 #include "aff_db.h"
11
12 #ifndef F_OK
13 #define F_OK 00
14 #endif
15
16 #ifndef R_OK
17 #define R_OK 04
18 #endif
19
20
21 #ifdef WIN32
22 /**********************************************************************
23 * Implement dirent-style opendir/readdir/rewinddir/closedir on Win32
24 *
25 * Functions defined are opendir(), readdir(), rewinddir() and
26 * closedir() with the same prototypes as the normal dirent.h
27 * implementation.
28 *
29 * Does not implement telldir(), seekdir(), or scandir(). The dirent
30 * struct is compatible with Unix, except that d_ino is always 1 and
31 * d_off is made up as we go along.
32 *
33 * The DIR typedef is not compatible with Unix.
34 **********************************************************************/
35
36 extern "C" DIR *opendir(const char *dir)
37 {
38 DIR *dp;
39 char *filespec;
40 long handle;
41 int index;
42
43 filespec = (char *)malloc(strlen(dir) + 2 + 1);
44 strcpy(filespec, dir);
45 index = strlen(filespec) - 1;
46 if (index >= 0 && (filespec[index] == '/' ||
47 (filespec[index] == '\\' && !IsDBCSLeadByte(filespec[index-1]))))
48 filespec[index] = '\0';
49 strcat(filespec, "/*");
50
51 dp = (DIR *) malloc(sizeof(DIR));
52 dp->offset = 0;
53 dp->finished = 0;
54
55 if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) {
56 if (errno == ENOENT) {
57 dp->finished = 1;
58 } else {
59 free(dp);
60 free(filespec);
61 return NULL;
62 }
63 }
64 dp->dir = strdup(dir);
65 dp->handle = handle;
66 free(filespec);
67
68 return dp;
69 }
70
71 extern "C" struct dirent *readdir(DIR *dp)
72 {
73 if (!dp || dp->finished)
74 return NULL;
75
76 if (dp->offset != 0) {
77 if (_findnext(dp->handle, &(dp->fileinfo)) < 0) {
78 dp->finished = 1;
79 return NULL;
80 }
81 }
82 dp->offset++;
83
84 strlcpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME+1);
85 dp->dent.d_ino = 1;
86 dp->dent.d_reclen = strlen(dp->dent.d_name);
87 dp->dent.d_off = dp->offset;
88
89 return &(dp->dent);
90 }
91
92 extern "C" int readdir_r(DIR *dp, struct dirent *entry, struct dirent **result)
93 {
94 if (!dp || dp->finished) {
95 *result = NULL;
96 return 0;
97 }
98
99 if (dp->offset != 0) {
100 if (_findnext(dp->handle, &(dp->fileinfo)) < 0) {
101 dp->finished = 1;
102 *result = NULL;
103 return 0;
104 }
105 }
106 dp->offset++;
107
108 strlcpy(dp->dent.d_name, dp->fileinfo.name, _MAX_FNAME+1);
109 dp->dent.d_ino = 1;
110 dp->dent.d_reclen = strlen(dp->dent.d_name);
111 dp->dent.d_off = dp->offset;
112
113 memcpy(entry, &dp->dent, sizeof(*entry));
114
115 *result = &dp->dent;
116
117 return 0;
118 }
119
120 extern "C" int closedir(DIR *dp)
121 {
122 if (!dp)
123 return 0;
124 _findclose(dp->handle);
125 if (dp->dir)
126 free(dp->dir);
127 if (dp)
128 free(dp);
129
130 return 0;
131 }
132
133 extern "C" int rewinddir(DIR *dp)
134 {
135 /* Re-set to the beginning */
136 char *filespec;
137 long handle;
138 int index;
139
140 _findclose(dp->handle);
141
142 dp->offset = 0;
143 dp->finished = 0;
144
145 filespec = (char *)malloc(strlen(dp->dir) + 2 + 1);
146 strcpy(filespec, dp->dir);
147 index = strlen(filespec) - 1;
148 if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
149 filespec[index] = '\0';
150 strcat(filespec, "/*");
151
152 if ((handle = _findfirst(filespec, &(dp->fileinfo))) < 0) {
153 if (errno == ENOENT)
154 dp->finished = 1;
155 }
156 dp->handle = handle;
157 free(filespec);
158 return 0;
159 }
160 #endif
161
162
163 /****************************************************************
164 *** Service routines
165 ****************************************************************/
166
167 struct afd_private {
168 AFFILE **afs; // list of AFFILEs...
169 int num_afs; // number of them
170 int cur_file; // current segment number...
171 };
172
173 static inline struct afd_private *AFD_PRIVATE(AFFILE *af)
174 {
175 assert(af->v == &vnode_afd);
176 return (struct afd_private *)(af->vnodeprivate);
177 }
178
179
180 /* afd_file_with_seg:
181 * Returns the AFFILE for a given segment, or 0 if it isn't found.
182 */
183
184 static AFFILE *afd_file_with_seg(AFFILE *af,const char *name)
185 {
186 struct afd_private *ap = AFD_PRIVATE(af);
187
188 for(int i=0;i<ap->num_afs;i++){
189 if(af_get_seg(ap->afs[i],name,0,0,0)==0){
190 return ap->afs[i];
191 }
192 }
193 errno = ENOTDIR; // get ready for error return
194 return 0;
195 }
196
197 static void aff_filename(AFFILE *afd,char *buf,int buflen,int num)
198 {
199 snprintf(buf,buflen,"%s/file_%03d.aff",afd->fname,num);
200 }
201
202 /* Return 1 if a file is an AFF file */
203 static int afd_identify_file(const char *filename,int exists)
204 {
205 if(filename==0 || strlen(filename)==0) return 0; // zero-length filenames aren't welcome
206 if(exists && access(filename,R_OK)!=0) return 0; // needs to exist and it doesn't
207
208 /* If it ends with a '/', remove it */
209 char *fn = (char *)alloca(strlen(filename)+1);
210 strcpy(fn,filename);
211 char *lastc = fn + strlen(fn) - 1;
212 if(*lastc=='/') *lastc = '\000';
213
214 /* If filename exists and it is a dir, it needs to end afd */
215 struct stat sb;
216 if(stat(fn,&sb)==0){
217 if((sb.st_mode & S_IFMT)==S_IFDIR){
218 if(af_ext_is(fn,"afd")) return 1;
219 }
220 return 0; //
221 }
222 /* Doesn't exist. Does it end .afd ? */
223 if(af_ext_is(fn,"afd")) return 1;
224 return 0;
225 }
226
227
228
229
230 /* Add a file to the AFF system.
231 * if fname==0, create a new one and copy over the relevant metadata...
232 */
233 static int afd_add_file(AFFILE *af,const char *fname_)
234 {
235 struct afd_private *ap = AFD_PRIVATE(af);
236 const char *segs_to_copy[] = {AF_BADFLAG,
237 AF_CASE_NUM,
238 AF_IMAGE_GID,
239 AF_ACQUISITION_ISO_COUNTRY,
240 AF_ACQUISITION_COMMAND_LINE,
241 AF_ACQUISITION_DATE,
242 AF_ACQUISITION_NOTES,
243 AF_ACQUISITION_DEVICE,
244 AF_ACQUISITION_TECHNICIAN,
245 AF_DEVICE_MANUFACTURER,
246 AF_DEVICE_MODEL,
247 AF_DEVICE_SN,
248 AF_DEVICE_FIRMWARE,
249 AF_DEVICE_SOURCE,
250 AF_CYLINDERS,
251 AF_HEADS,
252 AF_SECTORS_PER_TRACK,
253 AF_LBA_SIZE,
254 AF_HPA_PRESENT,
255 AF_DCO_PRESENT,
256 AF_LOCATION_IN_COMPUTER,
257 AF_DEVICE_CAPABILITIES,
258 0};
259
260 char fname[MAXPATHLEN+1];
261 memset(fname,0,sizeof(fname));
262 if(fname_){
263 strlcpy(fname,fname_,sizeof(fname));
264 }
265 else {
266 aff_filename(af,fname,sizeof(fname),ap->num_afs);
267 }
268
269 int new_file = access(fname,F_OK)!=0; // Is this a new file?
270
271 AFFILE *af2 = af_open(fname,af->openflags,af->openmode);
272 if(af2==0){
273 (*af->error_reporter)("open(%s,%d,%d) failed: %s\n",
274 fname,af->openflags,af->openmode,strerror(errno));
275 return -1; // this is bad
276 }
277
278 ap->num_afs += 1;
279 ap->afs = (AFFILE **)realloc(ap->afs,sizeof(AFFILE *) * ap->num_afs);
280 ap->afs[ap->num_afs-1] = af2;
281
282 if(new_file){
283 /* Copy over configuration from AFD vnode*/
284 af_enable_compression(af2,af->compression_type,af->compression_level);
285 af_set_pagesize(af2,af->image_pagesize); //
286 af_set_sectorsize(af2,af->image_sectorsize);
287 af_update_seg(af,AF_AFF_FILE_TYPE,0,(const u_char *)"AFD",3);
288
289 /* If this is the second file, copy over additional metadata from first... */
290 if(ap->num_afs>0){
291 AFFILE *af0 = ap->afs[0];
292 memcpy(af2->badflag,af0->badflag,af->image_sectorsize);
293 af2->bytes_memcpy += af->image_sectorsize;
294
295 for(const char **segname=segs_to_copy;*segname;segname++){
296 unsigned char data[65536]; // big enough for most metadata
297 size_t datalen = sizeof(data);
298 unsigned long arg=0;
299
300 if(af_get_seg(af0,*segname,&arg,data,&datalen)==0){
301 int r = af_update_seg(af2,*segname,arg,data,datalen);
302 if(r!=0){
303 (*af->error_reporter)("afd_add_file: could not update %s in %s (r=%d)",
304 *segname,af_filename(af2),r);
305 }
306 }
307 }
308 }
309 }
310
311 return 0;
312 }
313
314
315
316 /****************************************************************
317 *** User-visible functions.
318 ****************************************************************/
319
320 static int afd_open(AFFILE *af)
321 {
322 if(af->fname==0 || strlen(af->fname)==0) return -1; // zero-length filenames aren't welcome
323
324 /* If the name ends with a '/', remove it */
325 char *lastc = af->fname + strlen(af->fname) - 1;
326 if(*lastc=='/') *lastc = '\000';
327
328
329 /* If the directory doesn't exist, make it (if we are O_CREAT) */
330 struct stat sb;
331 af->exists = 1; // assume that the directory eixsts
332 if(stat(af->fname,&sb)!=0){
333 if((af->openflags & O_CREAT) == 0){ // flag not set
334 errno = ENOTDIR;
335 return -1;
336 }
337 mode_t cmask = umask(0); // get the current umask
338 umask(cmask & 077); // make sure we will be able to write the file
339 mkdir(af->fname,af->openmode|0111); // make the directory
340 umask(cmask); // put back the old mask
341 af->exists = 0; // directory doesn't exist; we had to make it.
342 if(stat(af->fname,&sb)) return -1; // error if we can't stat it
343 }
344 /* If this is a regular file, don't open it */
345 if(!S_ISDIR(sb.st_mode)){
346 errno = ENOTDIR; // needs to be a directory
347 return -1;
348 }
349
350
351 af->maxsize = AFD_DEFAULT_MAXSIZE;
352 af->vnodeprivate = (void *)calloc(1,sizeof(struct afd_private));
353 struct afd_private *ap = AFD_PRIVATE(af);
354 ap->afs = (AFFILE **)malloc(sizeof(AFFILE *));
355
356 /* Open the directory and read all of the AFF files */
357 DIR *dirp = opendir(af->fname);
358 if(!dirp){
359 return -1; // something is wrong...
360 }
361 struct dirent *dp;
362 while ((dp = readdir(dirp)) != NULL){
363 if (af_ext_is(dp->d_name,"aff")){
364 char path[MAXPATHLEN+1];
365 strlcpy(path,af->fname,sizeof(path));
366 strlcat(path,"/",sizeof(path));
367 strlcat(path,dp->d_name,sizeof(path));
368 if(afd_add_file(af,path)){
369 return -1;
370 }
371 }
372 }
373 closedir(dirp);
374 if(ap->num_afs==0 && af->exists){
375 snprintf(af->error_str,sizeof(af->error_str),".afd directory contains no .aff files!");
376 return -1;
377 }
378 return 0; // "we were successful"
379 }
380
381
382 static int afd_close(AFFILE *af)
383 {
384 struct afd_private *ap = AFD_PRIVATE(af);
385
386 /* Close all of the subfiles, then free the memory, then close this file */
387 for(int i=0;i<ap->num_afs;i++){
388 ap->afs[i]->image_size = af->image_size; // set each to have correct imagesize
389 af_close(ap->afs[i]); // and close each file
390 }
391 free(ap->afs);
392 memset(ap,0,sizeof(*ap)); // clean object reuse
393 free(ap); // won't need it again
394 return 0;
395 }
396
397
398 #ifndef WIN32
399 static uint64_t max(uint64_t a,uint64_t b)
400 {
401 return a > b ? a : b;
402 }
403 #endif
404
405 static int afd_vstat(AFFILE *af,struct af_vnode_info *vni)
406 {
407 struct afd_private *ap = AFD_PRIVATE(af);
408 memset(vni,0,sizeof(*vni)); // clear it
409
410 /* See if there is some device that knows how big the disk is */
411 if(ap->num_afs>0){
412 af_vstat(ap->afs[0],vni); // get disk free bytes
413 }
414
415 /* Get the file with the largest imagesize from either the
416 * AFD or any of the sub AFDs...
417 */
418 vni->imagesize = af->image_size;
419 for(int i=0;i<ap->num_afs;i++){
420 vni->imagesize = max(vni->imagesize,ap->afs[i]->image_size);
421 }
422 vni->has_pages = 1;
423 vni->supports_metadata = 1;
424 return 0;
425 }
426
427 static int afd_get_seg(AFFILE *af,const char *name,unsigned long *arg,unsigned char *data,
428 size_t *datalen)
429 {
430 AFFILE *af2 = afd_file_with_seg(af,name);
431 if(af2){
432 return af_get_seg(af2,name,arg,data,datalen); // use this one
433 }
434 return -1; // not found
435 }
436
437
438 static int afd_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
439 unsigned char *data,size_t *datalen_)
440 {
441 /* See if there are any more in the current segment */
442 struct afd_private *ap = AFD_PRIVATE(af);
443 while (ap->cur_file < ap->num_afs) {
444 int r = af_get_next_seg(ap->afs[ap->cur_file],segname,segname_len,arg,data,datalen_);
445 if(r!=AF_ERROR_EOF){ // if it is not EOF
446 return r;
447 }
448 ap->cur_file++; // advance to the next file
449 if(ap->cur_file < ap->num_afs){ // rewind it to the beginning
450 af_rewind_seg(ap->afs[ap->cur_file]);
451 }
452 } while(ap->cur_file < ap->num_afs);
453 return AF_ERROR_EOF; // really made it to the end
454 }
455
456
457 /* Rewind all of the segments */
458 static int afd_rewind_seg(AFFILE *af)
459 {
460 struct afd_private *ap = AFD_PRIVATE(af);
461 ap->cur_file = 0;
462 for(int i=0;i<ap->num_afs;i++){
463 af_rewind_seg(ap->afs[i]);
464 }
465 return 0;
466 }
467
468
469
470 /* Update:
471 * If this segment is in any of the existing files, update it there.
472 * Otherwise, if the last file isn't too big, add it there.
473 * Otherwise, ada a new file.
474 */
475 static int afd_update_seg(AFFILE *af, const char *name,
476 unsigned long arg,const u_char *value,unsigned int vallen)
477
478 {
479 struct afd_private *ap = AFD_PRIVATE(af);
480 AFFILE *af2 = afd_file_with_seg(af,name);
481 if(af2){
482 return af_update_seg(af2,name,arg,value,vallen); // update where it was found
483 }
484 /* Segment doesn't exist anywhere... */
485 /* Append to the last file if there is space and a space limitation... */
486 if(ap->num_afs>0){
487 AFFILE *af3 = ap->afs[ap->num_afs-1];
488 FILE *aseg = af3->aseg;
489
490 uint64_t offset = ftello(aseg);
491 fseeko(aseg,0,SEEK_END);
492
493 uint64_t len = ftello(aseg);
494 fseeko(aseg,offset,SEEK_SET);
495
496 if((len + vallen + 1024 < af->maxsize) && (af->maxsize!=0)){
497 /* It should fit with room left over! */
498 return af_update_seg(af3,name,arg,value,vallen);
499 }
500 }
501
502 /* Create a new file and add the segment to it.*/
503 if(afd_add_file(af,0)) return -1;
504 AFFILE *af4 = ap->afs[ap->num_afs-1]; // this is the one just added
505 return af_update_seg(af4,name,arg,value,vallen);
506 }
507
508 int afd_del_seg(AFFILE *af,const char *segname)
509 {
510 AFFILE *af2 = afd_file_with_seg(af,segname);
511 if(af2){
512 return af_del_seg(af2,segname);
513 }
514 return -1; // not found
515 }
516
517
518 struct af_vnode vnode_afd = {
519 AF_IDENTIFY_AFD, //
520 AF_VNODE_TYPE_COMPOUND|AF_VNODE_TYPE_RELIABLE|AF_VNODE_NO_SEALING, //
521 "AFF Directory",
522 afd_identify_file,
523 afd_open, // open
524 afd_close, // close
525 afd_vstat, // vstat
526 afd_get_seg, // get_seg
527 afd_get_next_seg, // get_next_seg
528 afd_rewind_seg, // rewind_seg
529 afd_update_seg, // update_seg
530 afd_del_seg, // del_seg
531 0, // read
532 0 // write
533 };
0 extern struct af_vnode vnode_afd; /* vnode_afd.cpp */
1
2 #define AFD_DEFAULT_MAXSIZE 1024*1024*608
3
0 /*
1 * vnode_aff.cpp:
2 *
3 * Functions for the manipulation of AFF files...
4 */
5
6 #include "affconfig.h"
7 #include "afflib.h"
8 #include "afflib_i.h"
9 #include "vnode_aff.h"
10 #include "aff_db.h"
11
12 #ifdef HAVE_SYS_FILE_H
13 #include <sys/file.h>
14 #endif
15
16 #define xstr(s) str(s)
17 #define str(s) #s
18
19
20
21 static int aff_write_ignore(AFFILE *af,size_t bytes);
22 static int aff_write_seg(AFFILE *af,const char *name,unsigned long arg,
23 const u_char *value,size_t vallen);
24 static int aff_get_seg(AFFILE *af,const char *name,unsigned long *arg,
25 unsigned char *data,size_t *datalen);
26 static int aff_get_next_seg(AFFILE *af,char *segname,size_t segname_len,
27 unsigned long *arg, unsigned char *data, size_t *datalen);
28
29 /** aff_segment_overhead:
30 * @param segname - the name of a segment
31 * @return The number of bytes in the AFF file that the segment takes up without the data.
32 */
33
34 int aff_segment_overhead(const char *segname)
35 {
36 return sizeof(struct af_segment_head)+sizeof(struct af_segment_tail)+(segname?strlen(segname):0);
37 }
38
39 static int aff_write_ignore2(AFFILE *af,size_t bytes)
40 {
41 if(af_trace) fprintf(af_trace,"aff_write_ignore2(%p,%zd)\n",af,bytes);
42 unsigned char *invalidate_data = (unsigned char *)calloc(bytes,1);
43 aff_write_seg(af,AF_IGNORE,0,invalidate_data,bytes); // overwrite with NULLs
44 free(invalidate_data);
45 return 0;
46 }
47
48 static int aff_write_ignore(AFFILE *af,size_t bytes)
49 {
50 int64_t startpos = ftello(af->aseg); // remember start position
51 int r = 0;
52
53 if(af_trace) fprintf(af_trace,"aff_write_ignore(%p,%zd)\n",af,bytes);
54
55 /* First write the ignore */
56 r = aff_write_ignore2(af,bytes);
57
58 /* If the next one is also an ignore,
59 * then we should go back and make the ignore_size bigger.
60 * We could do this recursively,
61 * but it's probably not worth the added complexity.
62 */
63 char next[AF_MAX_NAME_LEN];
64 size_t segsize2=0;
65 int count=0;
66 while(af_probe_next_seg(af,next,sizeof(next),0,0,&segsize2,1)==0 && next[0]==0 && segsize2>=0){
67 count++;
68 if(count>10) break; // something is wrong; just get out.
69 //printf("*** next %d segment at %qd len=%d will be deleted\n",count,ftello(af->aseg),segsize2);
70 bytes += segsize2;
71 fseeko(af->aseg,startpos,SEEK_SET);
72 r = aff_write_ignore2(af,bytes);
73 if(r!=0) return r;
74 }
75
76 /* See if the previous segment is also blank; if so, collapse them */
77 fseeko(af->aseg,startpos,SEEK_SET);
78 if(af_backspace(af)==0){
79 uint64_t prev_segment_loc = ftello(af->aseg); // remember where we are
80 char prev_segment_name[AF_MAX_NAME_LEN];
81 size_t prev_segment_size=0;
82 if(af_probe_next_seg(af,prev_segment_name,sizeof(prev_segment_name),0,0,&prev_segment_size,1)==0){
83 //printf("** prev segment name='%s' len=%d\n",prev_segment_name,prev_segment_size);
84 if(prev_segment_name[0]==0){
85 bytes += prev_segment_size;
86 fseeko(af->aseg,prev_segment_loc,SEEK_SET);
87 r = aff_write_ignore2(af,bytes);
88 fseeko(af->aseg,prev_segment_loc,SEEK_SET);
89 }
90 }
91 }
92
93 return(r);
94 }
95
96
97 /* aff_write_seg:
98 * put the given named segment at the current position in the file.
99 * Return 0 for success, -1 for failure (probably disk full?)
100 * This is the only place where a segment actually gets written
101 */
102
103 int aff_write_seg(AFFILE *af, const char *segname,unsigned long arg,const u_char *data,size_t datalen)
104 {
105 if(af_trace) fprintf(af_trace,"aff_write_seg(%p,%s,%lu,%p,len=%zu)\n",af,segname,arg,data,datalen);
106
107 struct af_segment_head segh;
108 struct af_segment_tail segt;
109
110 if(af->debug){
111 (*af->error_reporter)("aff_write_seg(" POINTER_FMT ",'%s',%lu,data=" POINTER_FMT ",datalen=%u)",
112 af,segname,arg,data,datalen);
113 }
114
115 assert(sizeof(segh)==16);
116 assert(sizeof(segt)==8);
117
118 /* If the last command was not a probe (so we know where we are), and
119 * we are not at the end of the file, something is very wrong.
120 */
121
122 unsigned int segname_len = strlen(segname);
123
124 strcpy(segh.magic,AF_SEGHEAD);
125 segh.name_len = htonl(segname_len);
126 segh.data_len = htonl(datalen);
127 segh.flag = htonl(arg);
128
129 strcpy(segt.magic,AF_SEGTAIL);
130 segt.segment_len = htonl(sizeof(segh)+segname_len + datalen + sizeof(segt));
131 aff_toc_update(af,segname,ftello(af->aseg),datalen);
132
133
134 if(af_trace) fprintf(af_trace,"aff_write_seg: putting segment %s (datalen=%zd) offset=%"PRId64"\n",
135 segname,datalen,ftello(af->aseg));
136
137 if(fwrite(&segh,sizeof(segh),1,af->aseg)!=1) return -10;
138 if(fwrite(segname,1,segname_len,af->aseg)!=segname_len) return -11;
139 if(fwrite(data,1,datalen,af->aseg)!=datalen) return -12;
140 if(fwrite(&segt,sizeof(segt),1,af->aseg)!=1) return -13;
141 fflush(af->aseg); // make sure it is on the disk
142 return 0;
143 }
144
145
146 /****************************************************************
147 *** low-level routines for reading
148 ****************************************************************/
149
150 /* aff_get_segment:
151 * Get the named segment, using the toc cache.
152 */
153
154 static int aff_get_seg(AFFILE *af,const char *name,
155 unsigned long *arg,unsigned char *data,size_t *datalen)
156 {
157 if(af_trace) fprintf(af_trace,"aff_get_seg(%p,%s,arg=%p,data=%p,datalen=%p)\n",af,name,arg,data,datalen);
158
159 char next[AF_MAX_NAME_LEN];
160
161 /* If the segment is in the directory, then seek the file to that location.
162 * Otherwise, we'll probe the next segment, and if it is not there,
163 * we will rewind to the beginning and go to the end.
164 */
165 struct aff_toc_mem *adm = aff_toc(af,name);
166 if(!adm) return -1;
167
168 fseeko(af->aseg,adm->offset,SEEK_SET);
169 int ret = aff_get_next_seg(af,next,sizeof(next),arg,data,datalen);
170 assert(strcmp(next,name)==0); // hopefully this is what they asked for
171 return ret;
172 }
173
174
175
176 /**
177 * Get the next segment.
178 * @param af - The AFF file pointer
179 * @param segname - Array to hold the name of the segment.
180 * @param segname_len - Available space in the segname array.
181 * @param arg - pointer to the arg
182 * @param data - pointer to the data
183 * @param datalen_ - length of the data_ array. If *datalen_==0, set to the length of the data.
184 *
185 * @return
186 * 0 = success.
187 * -1 = end of file. (AF_ERROR_EOF)
188 * -2 = *data is not large enough to hold the segment (AF_ERROR_DATASMALL)
189 * -3 = af file is corrupt; no tail (AF_ERROR_TAIL)
190 */
191 static int aff_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
192 unsigned char *data,size_t *datalen_)
193 {
194 if(af_trace) fprintf(af_trace,"aff_get_next_seg()\n");
195 if(!af->aseg){
196 snprintf(af->error_str,sizeof(af->error_str),"af_get_next_segv only works with aff files");
197 return AF_ERROR_INVALID_ARG;
198 }
199
200 off_t start = ftello(af->aseg);
201 size_t data_len;
202
203 int r = af_probe_next_seg(af,segname,segname_len,arg,&data_len,0,0);
204 if(r<0) return r; // propigate error code
205 if(data){ /* Read the data? */
206 if(datalen_ == 0){
207 snprintf(af->error_str,sizeof(af->error_str),"af_get_next_seg: data provided but datalen is NULL");
208 return AF_ERROR_INVALID_ARG;
209 }
210 size_t read_size = data_len<=*datalen_ ? data_len : *datalen_;
211
212 if(fread(data,1,read_size,af->aseg)!=read_size){
213 snprintf(af->error_str,sizeof(af->error_str),"af_get_next_segv: EOF on reading segment? File is corrupt.");
214 return AF_ERROR_SEGH;
215 }
216 if(data_len > *datalen_){
217 /* Read was incomplete;
218 * go back to the beginning of the segment and return
219 * the incomplete code.
220 */
221 fseeko(af->aseg,start,SEEK_SET); // go back
222 errno = E2BIG;
223 return AF_ERROR_DATASMALL;
224 }
225 } else {
226 fseeko(af->aseg,data_len,SEEK_CUR); // skip past the data
227 }
228 if(datalen_) *datalen_ = data_len;
229
230 /* Now read the tail */
231 struct af_segment_tail segt;
232 memset(&segt,0,sizeof(segt)); // zero before reading
233 if(fread(&segt,sizeof(segt),1,af->aseg)!=1){
234 snprintf(af->error_str,sizeof(af->error_str),
235 "af_get_next_segv: end of file reading segment tail; AFF file is truncated (AF_ERROR_TAIL)");
236 return AF_ERROR_TAIL;
237 }
238 /* Validate tail */
239 unsigned long stl = ntohl(segt.segment_len);
240 unsigned long calculated_segment_len =
241 sizeof(struct af_segment_head)
242 + strlen(segname)
243 + data_len + sizeof(struct af_segment_tail);
244
245 if(strcmp(segt.magic,AF_SEGTAIL)!=0){
246 snprintf(af->error_str,sizeof(af->error_str),"af_get_next_segv: AF file is truncated (AF_ERROR_TAIL).");
247 fseeko(af->aseg,start,SEEK_SET); // go back to last good position
248 return AF_ERROR_TAIL;
249 }
250 if(stl != calculated_segment_len){
251 snprintf(af->error_str,sizeof(af->error_str),"af_get_next_segv: AF file corrupt (%lu!=%lu)/!",
252 stl,calculated_segment_len);
253 fseeko(af->aseg,start,SEEK_SET); // go back to last good position
254 return AF_ERROR_TAIL;
255 }
256 return 0;
257 }
258
259
260 static int aff_rewind_seg(AFFILE *af)
261 {
262 if(af_trace) fprintf(af_trace,"aff_rewind_seg()\n");
263 fseeko(af->aseg,sizeof(struct af_head),SEEK_SET); // go to the beginning
264 return 0;
265 }
266
267
268 /* Removes the last segment of an AFF file if it is blank.
269 * @return 0 for success, -1 for error */
270 int af_truncate_blank(AFFILE *af)
271 {
272 uint64_t last_loc = ftello(af->aseg); // remember where we are
273 if(af_backspace(af)==0){
274 uint64_t backspace_loc = ftello(af->aseg); // remember where we are
275 char next_segment_name[AF_MAX_NAME_LEN];
276 if(af_probe_next_seg(af,next_segment_name,sizeof(next_segment_name),0,0,0,1)==0){
277 if(next_segment_name[0]==0){
278 /* Remove it */
279 fflush(af->aseg);
280 if(ftruncate(fileno(af->aseg),backspace_loc)<0) return -1;
281 return 0;
282 }
283 }
284 }
285 fseeko(af->aseg,last_loc,SEEK_SET); // return to where we were
286 return -1; // say that we couldn't do it.
287 }
288
289
290
291
292 /****************************************************************
293 *** Update functions
294 ****************************************************************/
295
296 /*
297 * af_update_seg:
298 * Update the given named segment with the new value.
299 */
300
301 static int aff_update_seg(AFFILE *af, const char *name,
302 unsigned long arg,const u_char *value,unsigned int vallen)
303 {
304 char next_segment_name[AF_MAX_NAME_LEN];
305 size_t next_segsize = 0;
306 size_t next_datasize = 0;
307
308 /* if we are updating with a different size,
309 * remember the location and size of the AF_IGNORE segment that
310 * has the smallest size that is >= strlen(name)+vallen
311 */
312 size_t size_needed = vallen+aff_segment_overhead(name);
313 size_t size_closest = 0;
314 uint64_t loc_closest = 0;
315 struct aff_toc_mem *adm = aff_toc(af,name);
316
317 if(af_trace) fprintf(af_trace,"aff_update_seg(name=%s,arg=%lu,vallen=%u)\n",name,arg,vallen);
318
319
320 if(adm){
321 /* Segment is in the TOC; seek to it */
322 fseeko(af->aseg,adm->offset,SEEK_SET);
323 }
324 else {
325 /* Otherwise, go to the beginning of the file and try to find a suitable hole
326 * TK: This could be made significantly faster by just scanning the TOC for a hole.
327 */
328 af_rewind_seg(af); // start at the beginning
329 }
330
331 while(af_probe_next_seg(af,next_segment_name,sizeof(next_segment_name),0,&next_datasize,&next_segsize,1)==0){
332 /* Remember this information */
333 uint64_t next_segment_loc = ftello(af->aseg);
334 #ifdef DEBUG2
335 fprintf(stderr," next_segment_name=%s next_datasize=%d next_segsize=%d next_segment_loc=%qd\n",
336 next_segment_name, next_datasize, next_segsize,next_segment_loc);
337 #endif
338 if(strcmp(next_segment_name,name)==0){ // found the segment
339 if(next_datasize == vallen){ // Does it exactly fit?
340 int r = aff_write_seg(af,name,arg,value,vallen); // Yes, just write in place!
341 return r;
342 }
343
344 //printf("** Segment '%s' doesn't fit at %qd; invalidating.\n",name,ftello(af->aseg));
345 aff_write_ignore(af,next_datasize+strlen(name));
346
347 /* If we are in random mode, jump back to the beginning of the file.
348 * This does a good job filling in the holes.
349 */
350 if(af->random_access){
351 af_rewind_seg(af);
352 continue;
353 }
354
355 /* Otherwise just go to the end. Experience has shown that sequential access
356 * tends not to generate holes.
357 */
358 fseeko(af->aseg,(uint64_t)0,SEEK_END); // go to the end of the file
359 break; // and exit this loop
360
361 }
362
363 if((next_segment_name[0]==0) && (next_datasize>=size_needed)){
364 //printf(" >> %d byte blank\n",next_datasize);
365 }
366
367 /* If this is an AF_IGNORE, see if it is a close match */
368 if((next_segment_name[0]==AF_IGNORE[0]) &&
369 (next_datasize>=size_needed) &&
370 ((next_datasize<size_closest || size_closest==0)) &&
371 ((next_datasize<1024 && size_needed<1024) || (next_datasize>=1024 && size_needed>=1024))){
372 size_closest = next_datasize;
373 loc_closest = next_segment_loc;
374 }
375 fseeko(af->aseg,next_segsize,SEEK_CUR); // skip this segment
376 }
377
378 /* Ready to write */
379 if(size_closest>0){
380 /* Yes. Put it here and put a new AF_IGNORE in the space left-over
381 * TODO: If the following space is also an AF_IGNORE, then combine the two.
382 */
383 //printf("*** Squeezing it in at %qd. name=%s. vallen=%d size_closest=%d\n",loc_closest,name,vallen,size_closest);
384
385 fseeko(af->aseg,loc_closest,SEEK_SET); // move to the location
386 aff_write_seg(af,name,arg,value,vallen); // write the new segment
387
388 size_t newsize = size_closest - vallen - aff_segment_overhead(0) - strlen(name);
389 aff_write_ignore(af,newsize); // write the smaller ignore
390 return 0;
391 }
392 /* If we reach here we are positioned at the end of the file. */
393 /* If the last segment is an ignore, truncate the file before writing */
394 while(af_truncate_blank(af)==0){
395 /* Keep truncating until there is nothing left */
396 }
397 //printf("*** appending '%s' bytes=%d to the end\n",name,vallen);
398 fseeko(af->aseg,0L,SEEK_END); // move back to the end of the file
399 return aff_write_seg(af,name,arg,value,vallen); // just write at the end
400 }
401
402
403
404 /* Delete the first occurance of the named segment.
405 * Special case code: See if the segment being deleted
406 * is the last segment. If it is, truncate the file...
407 * This handles the case of AF_DIRECTORY and possibly other cases
408 * as well...
409 */
410
411 static int aff_del_seg(AFFILE *af,const char *segname)
412 {
413 if(af_trace) fprintf(af_trace,"aff_del_seg(%p,%s)\n",af,segname);
414
415 if(aff_toc_del(af,segname)){ // if del fails
416 return 0; // it's not present.
417 }
418
419 /* Find out if the last segment is the one we are deleting;
420 * If so, we can just truncate the file.
421 */
422 char last_segname[AF_MAX_NAME_LEN];
423 int64_t last_pos;
424 af_last_seg(af,last_segname,sizeof(last_segname),&last_pos);
425 if(strcmp(segname,last_segname)==0){
426 fflush(af->aseg); // flush any ouput
427 if(ftruncate(fileno(af->aseg),last_pos)) return -1; // make the file shorter
428 return 0;
429 }
430
431 size_t datasize=0,segsize=0;
432 if(aff_find_seg(af,segname,0,&datasize,&segsize)!=0){
433 return -1; // nothing to delete?
434 }
435 /* Now wipe it out */
436 size_t ignore_size = datasize+strlen(segname);
437 aff_write_ignore(af,ignore_size);
438
439 return 0;
440 }
441
442
443
444 #ifdef HAVE_OPENSSL_RAND_H
445 #include <openssl/rand.h>
446 #endif
447
448 /* aff_create:
449 * af is an empty file that is being set up.
450 */
451 static int aff_create(AFFILE *af)
452 {
453 fwrite(AF_HEADER,1,8,af->aseg); // writes the header
454 aff_toc_build(af); // build the toc (will be pretty small)
455 af_make_badflag(af); // writes the flag for bad blocks
456
457 const char *version = xstr(PACKAGE_VERSION);
458 aff_update_seg(af,AF_AFFLIB_VERSION,0,(const u_char *)version,strlen(version));
459
460 #ifdef HAVE_GETPROGNAME
461 const char *progname = getprogname();
462 if(aff_update_seg(af,AF_CREATOR,0,(const u_char *)progname,strlen(progname))) return -1;
463 #endif
464 if(aff_update_seg(af,AF_AFF_FILE_TYPE,0,(const u_char *)"AFF",3)) return -1;
465
466 return 0;
467 }
468
469
470 /****************************************************************
471 *** VNODE implementation functions
472 ****************************************************************/
473
474 /* Return 1 if a file is an AFF file */
475 static int aff_identify_file(const char *filename,int exists)
476 {
477 if(af_is_filestream(filename)==0) return 0; // not a file stream
478 if(strncmp(filename,"file://",7)==0){
479 /* Move file pointer past file:// then find a '/' and take the next character */
480 filename += 7;
481 while(*filename && *filename!='/'){
482 filename++;
483 }
484 /* At this point if *filename==0 then we never found the end of the URL.
485 * return 0, since it's not an AFF file.
486 */
487 if(*filename==0) return 0;
488
489 /* So *filename must == '/' */
490 assert(*filename == '/');
491 filename++;
492 }
493
494 if(exists && access(filename,R_OK)!=0) return 0; // needs to exist and it doesn't
495 int fd = open(filename,O_RDONLY | O_BINARY);
496 if(fd<0){
497 /* File doesn't exist. Is this an AFF name? */
498 if(af_ext_is(filename,"aff")) return 1;
499 return 0;
500 }
501
502 if(fd>0){
503 int len = strlen(AF_HEADER)+1;
504 char buf[64];
505 int r = read(fd,buf,len);
506 close(fd);
507 if(r==len){ // if I could read the header
508 if(strcmp(buf,AF_HEADER)==0) return 1; // must be an AFF file
509 return 0; // not an AFF file
510 }
511 /* If it is a zero-length file and the file extension ends AFF,
512 * then let it be an AFF file...
513 */
514 if(r==0 && af_ext_is(filename,"aff")) return 1;
515 return 0; // must not be an aff file
516 }
517 return 0;
518 }
519
520
521
522 static int aff_open(AFFILE *af)
523 {
524 if(af_is_filestream(af->fname)==0) return -1; // not a file stream
525
526 /* Open the raw file */
527 int fd = open(af->fname,af->openflags | O_BINARY,af->openmode);
528 if(fd<0){ // couldn't open
529 return -1;
530 }
531
532 /* Lock the file if writing */
533 #ifdef HAVE_FLOCK
534 if(af->openflags & O_RDWR){
535 int lockmode = LOCK_SH; // default
536 if((af->openflags & O_ACCMODE)==O_RDWR) lockmode = LOCK_EX; // there can be only one
537 if(flock(fd,lockmode)){
538 warn("Cannot exclusively lock %s:",af->fname);
539 }
540 }
541 #endif
542
543 /* Set defaults */
544
545 af->compression_type = AF_COMPRESSION_ALG_ZLIB;
546 af->compression_level = Z_DEFAULT_COMPRESSION;
547
548 /* Open the FILE for the AFFILE */
549 char strflag[8];
550 strcpy(strflag,"rb"); // we have to be able to read
551 if(af->openflags & O_RDWR) strcpy(strflag,"w+b");
552
553 af->aseg = fdopen(fd,strflag);
554 if(!af->aseg){
555 (*af->error_reporter)("fdopen(%d,%s)",fd,strflag);
556 return -1;
557 }
558
559 /* Get file size */
560 struct stat sb;
561 if(fstat(fd,&sb)){
562 (*af->error_reporter)("aff_open: fstat(%s): ",af->fname); // this should not happen
563 return -1;
564 }
565
566 /* If file is empty, then put out an AFF header, badflag, and AFF version */
567 if(sb.st_size==0){
568 return aff_create(af);
569 }
570
571 /* We are opening an existing file. Verify once more than it is an AFF file
572 * and skip past the header...
573 */
574
575 char buf[8];
576 if(fread(buf,sizeof(buf),1,af->aseg)!=1){
577 /* Hm. End of file. That shouldn't happen here. */
578 (*af->error_reporter)("aff_open: couldn't read AFF header on existing file?");
579 return -1; // should not happen
580 }
581
582 if(strcmp(buf,AF_HEADER)!=0){
583 buf[7] = 0;
584 (*af->error_reporter)("aff_open: %s is not an AFF file (header=%s)\n",
585 af->fname,buf);
586 return -1;
587 }
588
589 /* File has been validated */
590 if(aff_toc_build(af)) return -1; // build the TOC
591 return 0; // everything must be okay.
592 }
593
594
595 /*
596 * aff_close:
597 * If the imagesize changed, write out a new value.
598 */
599 static int aff_close(AFFILE *af)
600 {
601 aff_toc_free(af);
602 fclose(af->aseg);
603 return 0;
604 }
605
606
607 static int aff_vstat(AFFILE *af,struct af_vnode_info *vni)
608 {
609 memset(vni,0,sizeof(*vni)); // clear it
610 vni->imagesize = af->image_size; // we can just return this
611 vni->pagesize = af->image_pagesize;
612 vni->supports_compression = 1;
613 vni->has_pages = 1;
614 vni->supports_metadata = 1;
615 vni->cannot_decrypt = af_cannot_decrypt(af) ? 1 : 0;
616
617 /* Check for an encrypted page */
618 if(af->toc){
619 for(int i=0;i<af->toc_count;i++){
620 if(af->toc[i].name){
621 bool is_page = false;
622 vni->segment_count_total++;
623 if(af_segname_page_number(af->toc[i].name)>=0){
624 vni->page_count_total++;
625 is_page = true;
626 }
627 if(af_is_encrypted_segment(af->toc[i].name)){
628 vni->segment_count_encrypted++;
629 if(is_page) vni->page_count_encrypted++;
630 }
631 if(af_is_signature_segment(af->toc[i].name)){
632 vni->segment_count_signed++;
633 }
634 }
635 }
636 }
637 return 0;
638 }
639
640
641 struct af_vnode vnode_aff = {
642 AF_IDENTIFY_AFF,
643 AF_VNODE_TYPE_PRIMITIVE|AF_VNODE_TYPE_RELIABLE,
644 "AFF",
645 aff_identify_file,
646 aff_open,
647 aff_close,
648 aff_vstat,
649 aff_get_seg,
650 aff_get_next_seg,
651 aff_rewind_seg,
652 aff_update_seg,
653 aff_del_seg,
654 0, // read; keep 0
655 0 // write
656 };
657
0 extern struct af_vnode vnode_aff; /* vnode_aff.cpp */
1
2
0 /* vnode_afm: afm raw file implementation with optional metadata support
1 */
2
3 /*
4 * AFFLIB(tm)
5 *
6 * Copyright (c) 2005, 2006
7 * Simson L. Garfinkel and Basis Technology Corp.
8 * All rights reserved.
9 *
10 * This code is derrived from software contributed by
11 * Simson L. Garfinkel
12 *
13 * Support for split raw files and .afm files written by Joel N. Weber II
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. All advertising materials mentioning features or use of this software
24 * must display the following acknowledgement:
25 * This product includes software developed by Simson L. Garfinkel
26 * and Basis Technology Corp.
27 * 4. Neither the name of Simson L. Garfinkel, Basis Technology, or other
28 * contributors to this program may be used to endorse or promote
29 * products derived from this software without specific prior written
30 * permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY SIMSON L. GARFINKEL, BASIS TECHNOLOGY,
33 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
34 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 * DISCLAIMED. IN NO EVENT SHALL SIMSON L. GARFINKEL, BASIS TECHNOLOGy,
37 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
38 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
40 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
43 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * SUCH DAMAGE.
45 *
46 * AFF and AFFLIB is a trademark of Simson Garfinkel and Basis Technology Corp.
47 */
48
49 #include "affconfig.h"
50 #include "afflib.h"
51 #include "afflib_i.h"
52 #include "vnode_afm.h"
53 #include "vnode_aff.h"
54 #include "vnode_split_raw.h"
55
56 /*
57 * Notes on implementation:
58 * AF_PAGES_PER_IMAGE_FILE is a segment read as a 64-bit number.
59 * If its value is 0, then do not split the files.
60 */
61
62 struct afm_private {
63 AFFILE *aff; // the AFFILE we use for the actual metadata
64 AFFILE *sr; // the AFFILE we use for the splitraw
65 int sr_initialized; // has the split-raw been setup from AFM?
66 };
67
68
69 static inline struct afm_private *AFM_PRIVATE(AFFILE *af)
70 {
71 assert(af->v == &vnode_afm);
72 return (struct afm_private *)(af->vnodeprivate);
73 }
74
75 /* Return 1 if a file has the AFF header or if the file doesn't
76 * exist and its extension is .afm
77 */
78 static int afm_identify_file(const char *filename,int exists)
79 {
80 if(exists && access(filename,R_OK)!=0) return 0; // needs to exist and it doesn't
81 return af_ext_is(filename,"afm");
82 }
83
84
85 static int afm_close(AFFILE *af)
86 {
87 struct afm_private *ap = AFM_PRIVATE(af);
88 if(ap){
89 if(ap->sr) af_close(ap->sr); // close the split files
90 if(ap->aff) af_close(ap->aff); // and close the AFF file
91 memset(ap,0,sizeof(*ap));
92 free(ap);
93 }
94 return 0;
95 }
96
97
98 static int invalid_extension_char(const char *extension,int ext_len)
99 {
100 for(int i=0;i<ext_len;i++){
101 if(extension[1]=='\000') return 1;
102 if(extension[1]=='.') return 1;
103 if(extension[1]=='/') return 1;
104 }
105 return 0;
106 }
107
108
109 static int afm_create(AFFILE *af)
110 {
111 if (af_update_seg (af, AF_RAW_IMAGE_FILE_EXTENSION, 0, (const u_char *)SPLITRAW_DEFAULT_EXTENSION,
112 strlen(SPLITRAW_DEFAULT_EXTENSION))) {
113 (*af->error_reporter)("split_raw_read_write_setup: %s: failed to write %s\n",
114 af->fname, AF_RAW_IMAGE_FILE_EXTENSION);
115 afm_close(af); // close the sub-file
116 return -1; // we failed
117 }
118 af_set_pagesize(af,AFM_DEFAULT_PAGESIZE);
119 af_update_seg(af,AF_AFF_FILE_TYPE,0,(const u_char *)"AFM",3);
120 return 0;
121 }
122
123 /*
124 * The AFM is actually a shell that opens two
125 * sub-implementations in their own files: an AFF file
126 * and a split_raw file.
127 */
128
129 static int afm_open(AFFILE *af)
130 {
131 af->vnodeprivate = (void *)calloc(sizeof(struct afm_private),1);
132 struct afm_private *ap = AFM_PRIVATE(af);
133 ap->aff = af_open_with(af_filename(af),af->openflags,af->openmode,&vnode_aff);
134
135 if(ap->aff==0){ // open failed?
136 afm_close(af);
137 return -1;
138 }
139 ap->aff->parent = af;
140
141 /* If this is a new file, write out the default split raw extension */
142 if(af->exists == 0){
143 if(afm_create(af)) return -1;
144 }
145
146 /* If this is an old file, read the image_pagesize */
147 if(af->exists){
148 af->image_pagesize = ap->aff->image_pagesize;
149 }
150
151 /* Read the split raw extension */
152 char raw_file_extension[4];
153 size_t len=3; // don't overwrite the NUL
154
155 memset(raw_file_extension,0,sizeof(raw_file_extension));
156 if (af_get_seg(ap->aff,AF_RAW_IMAGE_FILE_EXTENSION,0,(unsigned char *)raw_file_extension,&len)) {
157 (*af->error_reporter)("afm_open: %s: %s segment missing or too large\n",
158 af_filename(af),AF_RAW_IMAGE_FILE_EXTENSION);
159 afm_close(af);
160 return -1;
161 }
162 if(invalid_extension_char(raw_file_extension,len)){
163 (*af->error_reporter)("afm_open: file extension contains invalid character\n",
164 af->fname, AF_RAW_IMAGE_FILE_EXTENSION);
165 afm_close(af);
166 return -1;
167 }
168
169 /* Now open the splitraw file */
170 char *sr_filename = strdup(af_filename(af));
171 char *ext = strrchr(sr_filename,'.');
172 if(!ext){
173 (*af->error_reporter)("afm_open: cannot find extension in '%s'",sr_filename);
174 free(sr_filename);
175 afm_close(af);
176 return -1;
177 }
178 ext++; // skip past '.'
179 if(strlen(ext) != strlen(raw_file_extension)){
180 (*af->error_reporter)("afm_open: file extension in '%s' too short",sr_filename);
181 free(sr_filename);
182 afm_close(af);
183 return -1;
184 }
185
186 strcpy(ext,raw_file_extension);
187 ap->sr = af_open_with(sr_filename,af->openflags,af->openmode,&vnode_split_raw);
188 if(ap->sr==0){
189 (*af->error_reporter)("afm_open: could not open '%s'",sr_filename);
190 free(sr_filename);
191 afm_close(af);
192 return -1;
193 }
194 ap->sr->parent = af;
195 free(sr_filename);
196
197 /* Additional setup will happen first time a data read/write call is made
198 * by the function afm_read_write_setup().
199 * This allows a new file to be created with af_open() and then to have
200 * the parameters set with af_update_seg() calls, yet the split_raw
201 * implementation gets the proper settings
202 */
203 return 0;
204 }
205
206
207
208 /* afm_split_raw_setup:
209 * Sets up the parameters of the split-raw by reading from the metadata file.
210 * The advantage of doing it this way is that a new file can be opened,
211 * the metadata parmeters set, and then an af_write() call made, and the values.
212 * get copied.
213 */
214 static int afm_split_raw_setup(AFFILE *af)
215 {
216 struct afm_private *ap = AFM_PRIVATE(af);
217 if(ap->sr_initialized) return 0; // already setup
218
219 /* The size of AF_PAGES_PER_RAW_IMAGE_FILE indicates whether the file is split.
220 * If it is not present, or if it is 0-length, assume that the file is not split.
221 */
222 uint64_t pages_per_file = 0;
223 size_t len = 0;
224 if (af_get_seg(ap->aff,AF_PAGES_PER_RAW_IMAGE_FILE,0,0,&len)) {
225
226 /* Not in file; put it there based on maxsize and image_pagesize,
227 * both of which better be set at this point
228 */
229 if (af->image_pagesize < 1) {
230 (*af->error_reporter)("afm_split_raw_setup: image_pagesize==0\n");
231 return -1;
232 }
233 if (af->maxsize % af->image_pagesize) {
234 (*af->error_reporter)("afm_split_raw_setup: maxsize (%"I64d") "
235 "not a multiple of image_pagesize (%d)\n",
236 af->maxsize,af->image_pagesize);
237 return -1;
238 }
239 pages_per_file = af->maxsize / af->image_pagesize;
240 if (af_update_segq (af, AF_PAGES_PER_RAW_IMAGE_FILE, pages_per_file)) {
241 (*af->error_reporter)("split_raw_read_write_setup: %s: failed to write %s\n",
242 af_filename(af), AF_PAGES_PER_RAW_IMAGE_FILE);
243 return -1;
244 }
245 }
246
247 /* Now, read the segment (which might have just been put there) and set up the split_raw file */
248 if(af_get_segq(af,AF_PAGES_PER_RAW_IMAGE_FILE,(int64_t *)&pages_per_file)){
249 (*af->error_reporter)("split_raw_read_write_setup: %s: failed to write %s\n",
250 af_filename(af), AF_PAGES_PER_RAW_IMAGE_FILE);
251 return -1;
252 }
253
254 /* Verify that splitraw's notion of the rawfilesize is the same as the
255 * metadata's notion if the AFF image_size has been set
256 */
257 if (ap->aff->image_size && ap->aff->image_size != ap->sr->image_size) {
258 (*af->error_reporter)("afm_split_raw_setup: internal error. "
259 "AFF image_size %"I64d" != SR image_size %"I64d"\n",
260 ap->aff->image_size,ap->sr->image_size);
261 return -1;
262 }
263
264 /* Uses pages_per_file to set the maxsize of the split_raw if it hasn't been set yet*/
265 if(ap->sr->maxsize==0){
266 ap->sr->maxsize = pages_per_file * af->image_pagesize;
267 }
268
269 /* Verify that the parameters make sense */
270 if (ap->sr->maxsize != (pages_per_file * af->image_pagesize) && pages_per_file>0) {
271 (*af->error_reporter)("afm_split_raw_setup: %s: per size indicated by metadata (%d * %d) "
272 "doesn't match maxsize (%"I64d")\n",
273 af_filename(af),pages_per_file,af->image_pagesize,ap->sr->maxsize);
274 return -1;
275 }
276
277 /* Push down the image_pagesize from the AFM to the split_raw */
278 unsigned long image_pagesize = af->image_pagesize; // default to what's in memory
279 af_get_seg(af,AF_PAGESIZE,&image_pagesize,0,0); // get from the AFF file if possible
280 ap->sr->image_pagesize = af->image_pagesize; // overwrite the default with what the AFM file
281
282 ap->sr_initialized = 1;
283 return 0;
284 }
285
286 /*
287 * the stat of the afm is the stat of the metafile,
288 * but we don't do compression.
289 */
290 static int afm_raw_vstat(AFFILE *af,struct af_vnode_info *vni)
291 {
292 memset(vni,0,sizeof(*vni)); // clear it
293 struct afm_private *ap = AFM_PRIVATE(af);
294 af_vstat(ap->aff,vni);
295 vni->supports_compression = 0;
296 vni->supports_metadata = 1;
297 return 0;
298 }
299
300
301 /*
302 * afm_get_seg:
303 * If it is a page segment, satisfy it from the splitraw,
304 * otherwise from the aff file.
305 */
306 static int afm_get_seg(AFFILE *af,const char *name,unsigned long *arg,unsigned char *data,size_t *datalen)
307 {
308 struct afm_private *ap = AFM_PRIVATE(af);
309 int64_t page_num = af_segname_page_number(name);
310 if(page_num>=0) return af_get_seg(ap->sr,name,arg,data,datalen);
311 return af_get_seg(ap->aff,name,arg,data,datalen);
312
313 }
314
315
316 /*
317 * afm_del_seg:
318 * If it is a page segment, generate an error.
319 * otherwise from the aff file.
320 */
321 static int afm_del_seg(AFFILE *af,const char *segname)
322 {
323 struct afm_private *ap = AFM_PRIVATE(af);
324 int64_t page_num = af_segname_page_number(segname);
325 if(page_num>=0){
326 errno = ENOTSUP;
327 return -1;
328 }
329 return af_del_seg(ap->aff,segname);
330 }
331
332
333 /*
334 * afm_get_next_seg:
335 * Try get_next_seg on the AFF file first until it has none left.
336 * Then call get_next_seg of the splitraw until it has noneleft.
337 */
338
339 static int afm_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
340 unsigned char *data,size_t *datalen_)
341 {
342 struct afm_private *ap = AFM_PRIVATE(af);
343 int r = af_get_next_seg(ap->aff,segname,segname_len,arg,data,datalen_);
344 if(r==-1) return af_get_next_seg(ap->sr,segname,segname_len,arg,data,datalen_);
345 return r;
346 }
347
348 /* afm_rewind_seg:
349 * Rewind both the AFF file and the split_raw file(s)
350 */
351 static int afm_rewind_seg(AFFILE *af)
352 {
353 struct afm_private *ap = AFM_PRIVATE(af);
354 if ( af_rewind_seg(ap->aff) ) return -1; // that's bad
355 return af_rewind_seg(ap->sr); // and rewind the splitraw
356 }
357
358
359 /* For afm_update_seg, hand off page updates to the split_raw implementation
360 * and metadata updates to the AFF implementation.
361 */
362 static int afm_update_seg(AFFILE *af, const char *name,
363 unsigned long arg,const u_char *value,unsigned int vallen)
364
365 {
366 struct afm_private *ap = AFM_PRIVATE(af);
367 int64_t page_num = af_segname_page_number(name); // <0 means update metadata
368 if(page_num<0){
369 return af_update_seg(ap->aff,name,arg,value,vallen);
370 }
371 return af_update_seg(ap->sr,name,arg,value,vallen);
372 }
373
374
375 static int afm_read(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
376 {
377 struct afm_private *ap = AFM_PRIVATE(af);
378 if(ap->sr_initialized==0 && afm_split_raw_setup(af)) return -1;
379 return (*ap->sr->v->read)(ap->sr,buf,pos,count);
380 }
381
382 static int afm_write(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
383 {
384 struct afm_private *ap = AFM_PRIVATE(af);
385 if(ap->sr_initialized==0 && afm_split_raw_setup(af)) return -1;
386 af_set_callback(ap->sr,af->w_callback); // update the callback
387 int r = (*ap->sr->v->write)(ap->sr,buf,pos,count); // call split_raw's write
388 if(ap->sr->image_size > af->image_size){
389 af->image_size = ap->sr->image_size; // image was extended; note this in parent & AFF file
390 ap->aff->image_size = ap->sr->image_size; // copy over the image size
391 }
392 return r;
393 }
394
395
396 struct af_vnode vnode_afm = {
397 AF_IDENTIFY_AFM,
398 AF_VNODE_TYPE_COMPOUND|AF_VNODE_TYPE_RELIABLE|AF_VNODE_MAXSIZE_MULTIPLE|AF_VNODE_NO_SEALING,
399 "AFM (AFF metadata with split raw file)",
400 afm_identify_file,
401 afm_open,
402 afm_close,
403 afm_raw_vstat, // nothing aff specific here.
404 afm_get_seg, // get seg
405 afm_get_next_seg, // get_next_seg
406 afm_rewind_seg, // rewind_seg
407 afm_update_seg, // update_seg
408 afm_del_seg, // del_seg (afm_open fills in aff_del_seg)
409 afm_read, // read
410 afm_write // write
411 };
412
0 extern struct af_vnode vnode_afm;
1 #define AFM_DEFAULT_PAGESIZE 1024*1024*16
0 /**
1 ** AFF/libewf glue
2 **
3 ** (C) 2006 by Simson L. Garfinkel
4 **
5 **
6 **/
7
8
9
10 #include "affconfig.h"
11 #include "afflib.h"
12 #include "afflib_i.h"
13
14 #ifdef USE_LIBEWF
15
16 #include <ctype.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include "vnode_ewf.h"
21
22 #ifdef HAVE_CSTRING
23 #include <cstring>
24 #endif
25
26 /* We're gonna include libewf.h now, which causes problems, because libewf.h currently
27 * includes an autoconf-generated affconfig.h file
28 */
29
30 #undef PACKAGE
31 #undef PACKAGE_BUGREPORT
32 #undef PACKAGE_NAME
33 #undef PACKAGE_STRING
34 #undef PACKAGE_TARNAME
35 #undef PACKAGE_VERSION
36 #undef VERSION
37
38 #ifdef HAVE_LIBEWF_H
39 #include "libewf.h"
40 #else
41 #error EWF support requires libewf, but HAVE_LIBEWF_H is not defined
42 #endif
43
44
45
46 /****************************************************************
47 *** Service routines
48 ****************************************************************/
49
50 #define EWF_HANDLE(af) ((libewf_handle_t *)af->vnodeprivate)
51
52 /****************************************************************
53 *** AFFLIB Glue Follows
54 ****************************************************************/
55
56
57 /* Return 1 if a file is a ewf file... */
58 static int ewf_identify_file(const char *filename,int exists)
59 {
60 return libewf_check_file_signature(filename)==1 ? 1 : 0;
61 }
62
63 static int ewf_open(AFFILE *af)
64 {
65
66 if(strchr(af->fname,'.')==0) return -1; // need a '.' in the filename
67
68 /* Find all of the EWF files to open*/
69 char **files = (char **)malloc(sizeof(char *));
70 int nfiles = 1;
71 files[0] = strdup(af->fname);
72
73 char fname[MAXPATHLEN+1];
74 strlcpy(fname,af->fname,sizeof(fname));
75 char *ext = strrchr(fname,'.')+1;
76 if(ext-fname > MAXPATHLEN-4){
77 warn("ewf_open: %s: filename too long",af->fname);
78 return -1;
79 }
80
81 /* Now open .E02 through .E99 and then .AAA through .ZZZ if they exist... */
82 for(int i=2;i<=99;i++){
83 sprintf(ext+1,"%02d",i);
84 if(access(fname,R_OK)!=0) break;
85 files = (char **)realloc(files,(nfiles+1) * sizeof(char *));
86 files[nfiles] = strdup(fname);
87 nfiles++;
88 }
89 for(int i=4*26*26;i<=26*26*26;i++){
90 sprintf(ext, "%c%c%c", i/26/26%26+'A', i/26%26+'A', i%26+'A');
91 if(access(fname,R_OK)!=0) break; // file can't be read
92 files = (char **)realloc(files,(nfiles+1) * sizeof(char *));
93 files[nfiles] = strdup(fname);
94 nfiles++;
95 }
96
97
98 LIBEWF_HANDLE *handle = libewf_open( files, nfiles, LIBEWF_OPEN_READ );
99
100 if(!handle){
101 warn("Unable to open EWF image file");
102 for(int i=0;i<nfiles;i++) free(files[i]);
103 free(files);
104 return -1;
105 }
106 #if defined( HAVE_LIBEWF_GET_MEDIA_SIZE_ARGUMENT_VALUE ) || (LIBEWF_VERSION>=20080501)
107 int r = libewf_get_media_size(handle,&af->image_size);
108 if(r < 0){
109 warn("EFW error: image size==0?");
110 for(int i=0;i<nfiles;i++) free(files[i]);
111 free(files);
112 return -1;
113 }
114 #else
115 af->image_size = libewf_get_media_size(handle);
116
117 if( af->image_size == 0 ){
118 warn("EFW error: image size==0?");
119 for(int i=0;i<nfiles;i++) free(files[i]);
120 free(files);
121 return -1;
122 }
123 #endif
124
125 af->vnodeprivate = (void *)handle;
126 #if defined( HAVE_LIBEWF_GET_CHUNK_SIZE_ARGUMENT_VALUE ) || LIBEWF_VERSION>=20080501
127 libewf_get_chunk_size(handle,(size32_t *)&af->image_pagesize);
128 #else
129 af->image_pagesize = libewf_get_chunk_size(handle);
130 #endif
131 for(int i=0;i<nfiles;i++) free(files[i]);
132 free(files);
133 return 0;
134 }
135
136
137 static int ewf_vstat(AFFILE *af,struct af_vnode_info *vni)
138 {
139 LIBEWF_HANDLE *handle = EWF_HANDLE(af);
140 #if defined( HAVE_LIBEWF_GET_MEDIA_SIZE_ARGUMENT_VALUE ) || LIBEWF_VERSION>=20080501
141 libewf_get_media_size(handle,(size64_t *)&vni->imagesize);
142 #else
143 vni->imagesize = (int64_t) libewf_get_media_size(handle);
144 #endif
145
146 vni->pagesize = 0;
147 #if defined( HAVE_LIBEWF_GET_CHUNK_SIZE_ARGUMENT_VALUE ) || LIBEWF_VERSION>=20080501
148 libewf_get_chunk_size(handle,(size32_t *)&vni->pagesize);
149 #else
150 vni->pagesize = libewf_get_chunk_size(handle);
151 #endif
152 vni->supports_metadata = 1;
153 vni->changable_pagesize = 0;
154 vni->changable_sectorsize = 0;
155 vni->supports_compression = 1;
156 vni->has_pages = 1; // debatable
157 return 0;
158 }
159
160 static int ewf_read(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
161 {
162 LIBEWF_HANDLE *handle = EWF_HANDLE(af);
163 return libewf_read_random(handle,buf,(uint64_t)count,pos);
164 }
165
166 static int ewf_write(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
167 {
168 LIBEWF_HANDLE *handle = EWF_HANDLE(af);
169 return libewf_write_random(handle,buf,(uint64_t)count,pos);
170 }
171
172 static int ewf_close(AFFILE *af)
173 {
174 LIBEWF_HANDLE *handle = EWF_HANDLE(af);
175 if(libewf_close(handle)<0) return -1;
176 return 0;
177 }
178
179
180 static int ewf_rewind_seg(AFFILE *af)
181 {
182 af->cur_page = -1; // starts at the metadata
183 return 0;
184 }
185
186
187 /* return the length of a string up to a max */
188 static int strlenp(const unsigned char *data,int max)
189 {
190 for(int i=0;i<max;i++){
191 if(data[i]==0) return i;
192 }
193 return max;
194 }
195
196 static uint32_t ewf_bytes_per_sector(LIBEWF_HANDLE *handle)
197 {
198 uint32_t bps = 0;
199 #if defined( HAVE_LIBEWF_GET_BYTES_PER_SECTOR_ARGUMENT_VALUE ) || LIBEWF_VERSION>=20080501
200 libewf_get_bytes_per_sector(handle,&bps);
201 #else
202 bps=libewf_get_bytes_per_sector(handle);
203 #endif
204 return bps;
205 }
206
207 static int ewf_get_seg(AFFILE *af,const char *name, unsigned long *arg,
208 unsigned char *data,size_t *datalen)
209 {
210 LIBEWF_HANDLE *handle = EWF_HANDLE(af);
211
212 /* Is the user asking for a page? */
213 int64_t segnum = af_segname_page_number(name);
214 if(segnum>=0){
215 /* Get the segment number */
216 if(data==0){
217 /* Need to make sure that the segment exists */
218 if(segnum*af->image_pagesize+af->image_pagesize > af->image_size ) return -1; // this segment does not exist
219 if(datalen) *datalen = af->image_pagesize; // just return the chunk size
220 return 0;
221 }
222 size_t r = libewf_read_random(handle,data,*datalen,segnum * af->image_pagesize);
223 return r>0 ? 0 : -1; // should probably put in some error checking
224 }
225
226 /* See if it is a page name we understand */
227 if(strcmp(name,AF_PAGESIZE)==0){
228 if(arg) *arg = af->image_pagesize;
229 return 0;
230 }
231 if(strcmp(name,AF_IMAGESIZE)==0){
232 if(arg) *arg = 0;
233 if(datalen==0) return 0;
234 if(*datalen==0){
235 *datalen = 8; // the structure is 8 bytes long
236 return 0;
237 }
238 if(*datalen<8) return -2;
239
240 struct aff_quad q;
241 q.low = htonl((unsigned long)(af->image_size & 0xffffffff));
242 q.high = htonl((unsigned long)(af->image_size >> 32));
243 memcpy(data,&q,8);
244 return 0;
245 }
246 if(strcmp(name,AF_SECTORSIZE)==0){
247 if(arg) *arg=(unsigned long)ewf_bytes_per_sector(handle);
248 if(datalen) *datalen = 0;
249 return 0;
250 }
251 if(strcmp(name,AF_DEVICE_SECTORS)==0){
252 /* Is this in flag or a quad word? */
253 uint32_t bps = ewf_bytes_per_sector(handle);
254 if(arg && bps>0) *arg = af->image_size / bps;
255 if(datalen) *datalen = 0;
256 return 0;
257 }
258
259
260 /* They are asking for a metdata segment. If we have wide character type
261 * compiled in for libewf, just ignore it, because afflib doesn't do wide characters
262 * at the moment...
263 */
264
265 #if !defined(LIBEWF_WIDE_CHARACTER_TYPE) && defined(LIBEWF_VERSION) && (LIBEWF_VERSION >= 20080322)
266 /* Can't guarentee character type in older versions of libewf */
267 if(strcmp(name,AF_CASE_NUM)==0){
268 if(data && datalen){
269 libewf_get_header_value_case_number(handle,(char *)data,*datalen);
270 *datalen = strlenp(data,*datalen);
271 if(arg) *arg = 0;
272 }
273 return 0;
274 }
275 if(strcmp(name,AF_IMAGE_GID)==0){
276 if(data && datalen){
277 libewf_get_guid(handle,data,*datalen);
278 if(arg) *arg = 0;
279 }
280 return 0;
281 }
282 if(strcmp(name,AF_ACQUISITION_NOTES)==0){
283 if(data && datalen){
284 libewf_get_header_value_notes(handle,(char *)data,*datalen);
285 *datalen = strlenp(data,*datalen);
286 }
287 if(data==0 && datalen){
288 /* Caller wants to learn size of the notes */
289 unsigned char tmp[128];
290 memset(tmp,0,sizeof(tmp));
291 *datalen = sizeof(tmp);
292 libewf_get_header_value_notes(handle,(char *)tmp,*datalen);
293 *datalen = strlenp(tmp,*datalen);
294 }
295 if(arg) *arg = 0;
296 return 0;
297 }
298 #endif
299 return -1; // don't know this header
300 }
301
302 static const char *emap[] = {
303 AF_PAGESIZE,
304 AF_IMAGESIZE,
305 AF_SECTORSIZE,
306 AF_DEVICE_SECTORS,
307 AF_CASE_NUM,
308 AF_IMAGE_GID,
309 AF_ACQUISITION_NOTES,
310 0
311 };
312
313
314 static int ewf_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
315 unsigned char *data,size_t *datalen)
316 {
317 /* Figure out what the next segment would be, then get it */
318 /* Metadata first */
319 if(af->cur_page<0){
320 /* Find out how many mapped segments there are */
321 int mapped=0;
322 for(mapped=0;emap[mapped];mapped++){
323 }
324 if(-af->cur_page >= mapped ){
325 af->cur_page = 0;
326 goto get_next_data_seg;
327 }
328 int which = 0 - af->cur_page; // which one to get
329 af->cur_page--; // go to the next one
330 if(segname_len < strlen(emap[which])) return -2; // not enough room for segname
331 strlcpy(segname,emap[which],segname_len); // give caller the name of the mapped segment.
332 return ewf_get_seg(af,segname,arg,data,datalen);
333 }
334
335 get_next_data_seg:
336 if(af->cur_page * af->image_pagesize >= af->image_size) return -1; // end of list
337 /* Make the segment name */
338 char pagename[AF_MAX_NAME_LEN]; //
339 memset(pagename,0,sizeof(pagename));
340 snprintf(pagename,sizeof(pagename),AF_PAGE,af->cur_page++);
341
342 int r = 0;
343 /* Get the segment, if it is wanted */
344 if(data) r = ewf_get_seg(af,pagename,arg,data,datalen);
345
346 /* If r==0 and there is room for copying in the segment name, return it */
347 if(r==0){
348 if(strlen(pagename)+1 < segname_len){
349 strlcpy(segname,pagename,segname_len);
350 return 0;
351 }
352 /* segname wasn't big enough */
353 return -2;
354 }
355 return r; // some other error
356 }
357
358 struct af_vnode vnode_ewf = {
359 AF_IDENTIFY_EWF,
360 AF_VNODE_TYPE_PRIMITIVE|AF_VNODE_NO_SIGNING|AF_VNODE_NO_SEALING,
361 "LIBEWF",
362 ewf_identify_file,
363 ewf_open,
364 ewf_close,
365 ewf_vstat,
366 ewf_get_seg, // get seg
367 ewf_get_next_seg, // get_next_seg
368 ewf_rewind_seg, // rewind_seg
369 0, // update_seg
370 0, // del_seg
371 ewf_read, // read
372 ewf_write // write
373 };
374
375 #endif
0 extern struct af_vnode vnode_ewf; /* vnode_ewf.cpp */
0 /**
1 ** AFF/qemu glue
2 **
3 ** 2008 by Simson L. Garfinkel
4 **
5 **
6 **/
7
8 #include "affconfig.h"
9 #include "afflib.h"
10 #include "afflib_i.h"
11
12 #ifdef USE_QEMU
13
14 extern "C" {
15 #include "qemu/qemu-common.h"
16 #include "qemu/block_int.h"
17 }
18
19
20 /* Return 1 if a file is a qemu file... */
21 static int vmdk_identify_file(const char *filename,int exists)
22 {
23 return af_ext_is(filename,"vmdk");
24 }
25
26 /* Return 1 if a file is a qemu file... */
27 static int dmg_identify_file(const char *filename,int exists)
28 {
29 return af_ext_is(filename,"dmg");
30 }
31
32 /* Return 1 if a file is a qemu file... */
33 static int sparseimage_identify_file(const char *filename,int exists)
34 {
35 return af_ext_is(filename,"sparseimage");
36 }
37
38 #define QEMU_HANDLE(af) ((BlockDriverState *)af->vnodeprivate)
39
40 static int qemu_open(AFFILE *af)
41 {
42 BlockDriverState *bs;
43 BlockDriver *drv=NULL;
44 uint64_t total_sectors=0;
45 static int bdrv_init_called = 0;
46
47 if(bdrv_init_called==0){ // DO NOT CALL MORE THAN ONCE
48 bdrv_init();
49 bdrv_init_called = 1;
50 }
51 bs = bdrv_new("");
52 bdrv_open2(bs,af_filename(af),0,drv);
53 bdrv_get_geometry(bs, &total_sectors);
54
55 af->image_pagesize = 1024*1024*1; // megabyte for now
56 af->image_size = total_sectors * 512;
57
58 af->vnodeprivate = (void *)bs;
59 return 0;
60 }
61
62
63 static int qemu_vstat(AFFILE *af,struct af_vnode_info *vni)
64 {
65 vni->imagesize = af->image_size;
66 vni->pagesize = af->image_pagesize;
67 vni->has_pages = 1; // use the AFF page system
68 return 0;
69 }
70
71 static int qemu_close(AFFILE *af)
72 {
73 bdrv_delete(QEMU_HANDLE(af));
74 return 0;
75 }
76
77
78 static int qemu_rewind_seg(AFFILE *af)
79 {
80 af->cur_page = -1; // starts at the metadata
81 return 0;
82 }
83
84
85 static int qemu_get_seg(AFFILE *af,const char *name, unsigned long *arg,
86 unsigned char *data,size_t *datalen)
87 {
88 /* Is the user asking for a page? */
89 int64_t segnum = af_segname_page_number(name);
90 if(segnum>=0){
91 /* Get the segment number */
92 if(data==0){
93 /* Need to make sure that the segment exists */
94 if(segnum*(af->image_pagesize+1) > (int64_t) af->image_size ){
95 return -1; // this segment does not exist
96 }
97 if(datalen) *datalen =af->image_pagesize; // just return the chunk size
98 return 0;
99 }
100 int64_t sector_start = segnum * af->image_pagesize / 512;
101 u_int sector_count = af->image_pagesize/512;
102 if(datalen==0) return -1;
103 if(sector_count*512 > *datalen) return -1; // no room
104 return bdrv_read(QEMU_HANDLE(af),sector_start,data,sector_count);
105 }
106
107 /* See if it is a page name we understand */
108 if(strcmp(name,AF_PAGESIZE)==0){
109 if(arg) *arg = af->image_pagesize;
110 return 0;
111 }
112 if(strcmp(name,AF_IMAGESIZE)==0){
113 if(arg) *arg = 0;
114 if(datalen==0) return 0;
115 if(*datalen==0){
116 *datalen = 8; // the structure is 8 bytes long
117 return 0;
118 }
119 if(*datalen<8) return -2;
120
121 struct aff_quad q;
122 q.low = htonl((unsigned long)(af->image_size & 0xffffffff));
123 q.high = htonl((unsigned long)(af->image_size >> 32));
124 memcpy(data,&q,8);
125 return 0;
126 }
127 if(strcmp(name,AF_SECTORSIZE)==0){
128 if(arg) *arg=512; // seems to be what QEMU uses
129 if(datalen) *datalen = 0;
130 return 0;
131 }
132 if(strcmp(name,AF_DEVICE_SECTORS)==0){
133 /* Is this in flag or a quad word? */
134 if(arg) *arg = af->image_size / 512;
135 if(datalen) *datalen = 0;
136 return 0;
137 }
138
139 /* They are asking for a metdata segment. If we have wide character type
140 * compiled in for libqemu, just ignore it, because afflib doesn't do wide characters
141 * at the moment...
142 */
143
144 return -1; // don't know this header
145 }
146
147 static const char *emap[] = {
148 AF_PAGESIZE,
149 AF_IMAGESIZE,
150 AF_SECTORSIZE,
151 AF_DEVICE_SECTORS,
152 0
153 };
154
155
156 static int qemu_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
157 unsigned char *data,size_t *datalen)
158 {
159 /* Figure out what the next segment would be, then get it */
160 /* Metadata first */
161 if(af->cur_page<0){
162 /* Find out how many mapped segments there are */
163 int mapped=0;
164 for(mapped=0;emap[mapped];mapped++){
165 }
166 if(-af->cur_page >= mapped ){
167 af->cur_page = 0;
168 goto get_next_data_seg;
169 }
170 int which = 0 - af->cur_page; // which one to get
171 af->cur_page--; // go to the next one
172 if(segname_len < strlen(emap[which])) return -2; // not enough room for segname
173 strlcpy(segname,emap[which],segname_len); // give caller the name of the mapped segment.
174 return qemu_get_seg(af,segname,arg,data,datalen);
175 }
176
177 get_next_data_seg:
178 if(af->cur_page * af->image_pagesize >= (int64_t)af->image_size) return -1; // end of list
179 /* Make the segment name */
180 char pagename[AF_MAX_NAME_LEN]; //
181 memset(pagename,0,sizeof(pagename));
182 snprintf(pagename,sizeof(pagename),AF_PAGE,af->cur_page++);
183
184 int r = 0;
185 /* Get the segment, if it is wanted */
186 if(data) r = qemu_get_seg(af,pagename,arg,data,datalen);
187
188 /* If r==0 and there is room for copying in the segment name, return it */
189 if(r==0){
190 if(strlen(pagename)+1 < segname_len){
191 strlcpy(segname,pagename,segname_len);
192 return 0;
193 }
194 /* segname wasn't big enough */
195 return -2;
196 }
197 return r; // some other error
198 }
199
200 struct af_vnode vnode_vmdk = {
201 AF_IDENTIFY_VMDK,
202 AF_VNODE_TYPE_PRIMITIVE|AF_VNODE_NO_SIGNING|AF_VNODE_NO_SEALING,
203 "VMDK(LIBQEMU)",
204 vmdk_identify_file,
205 qemu_open,
206 qemu_close,
207 qemu_vstat,
208 qemu_get_seg, // get seg
209 qemu_get_next_seg, // get_next_seg
210 qemu_rewind_seg, // rewind_seg
211 0, // update_seg
212 0, // del_seg
213 0, // read
214 0 // write
215 };
216
217
218 struct af_vnode vnode_dmg = {
219 AF_IDENTIFY_DMG,
220 AF_VNODE_TYPE_PRIMITIVE|AF_VNODE_NO_SIGNING|AF_VNODE_NO_SEALING,
221 "DMG(LIBQEMU)",
222 dmg_identify_file,
223 qemu_open,
224 qemu_close,
225 qemu_vstat,
226 qemu_get_seg, // get seg
227 qemu_get_next_seg, // get_next_seg
228 qemu_rewind_seg, // rewind_seg
229 0, // update_seg
230 0, // del_seg
231 0, // read
232 0 // write
233 };
234
235
236 struct af_vnode vnode_sparseimage = {
237 AF_IDENTIFY_SPARSEIMAGE,
238 AF_VNODE_TYPE_PRIMITIVE|AF_VNODE_NO_SIGNING|AF_VNODE_NO_SEALING,
239 "SPARSEIMAGE(LIBQEMU)",
240 sparseimage_identify_file,
241 qemu_open,
242 qemu_close,
243 qemu_vstat,
244 qemu_get_seg, // get seg
245 qemu_get_next_seg, // get_next_seg
246 qemu_rewind_seg, // rewind_seg
247 0, // update_seg
248 0, // del_seg
249 0, // read
250 0 // write
251 };
252
253
254 #endif
0 extern struct af_vnode vnode_vmdk;
1 extern struct af_vnode vnode_dmg;
2 extern struct af_vnode vnode_sparseimage;
3
0 #include "affconfig.h"
1 #include "afflib.h"
2 #include "afflib_i.h"
3 #include "vnode_raw.h"
4
5
6 /* the RAW_PAGESIZE is visible outside the module, but it's kind of irrevellant */
7 #define RAW_PAGESIZE 16*1024*1024
8
9 /* raw file implementation */
10 struct raw_private {
11 /* For Raw files */
12 FILE *raw; // if it is a raw file
13 int raw_popen; // opened with popen
14 };
15
16 #define RAW_PRIVATE(af) ((struct raw_private *)(af->vnodeprivate))
17
18 /* Return 1 if a file is a raw file... */
19 static int raw_identify_file(const char *filename,int exists)
20 {
21 if(exists && access(filename,R_OK)!=0) return 0; // needs to exist and it doesn't
22 return access(filename,R_OK)==0; // if we can read it, it's raw...
23 }
24
25
26 /* Return the size of the raw file */
27 static int64_t raw_filesize(AFFILE *af)
28 {
29 struct raw_private *rp = RAW_PRIVATE(af);
30
31 struct stat sb;
32 if(fstat(fileno(rp->raw),&sb)==0){
33 if(sb.st_mode & S_IFREG){ // only do this for regular files
34 return sb.st_size;
35 }
36
37 /* See if this is a device that we can figure */
38 struct af_figure_media_buf afb;
39 if(af_figure_media(fileno(rp->raw),&afb)==0){
40 if(afb.total_sectors>0 && afb.sector_size>0){
41 return afb.total_sectors * afb.sector_size;
42 }
43 }
44 }
45 return 0; // no clue
46 }
47
48 static int raw_open(AFFILE *af)
49 {
50 /* Raw is the passthrough system.
51 * Right now, it is read only...
52 */
53 const char *mode = "rb";
54 if(af->openflags && (O_RDWR | O_WRONLY)) mode = "r+b";
55
56 af->vnodeprivate = (void *)calloc(1,sizeof(struct raw_private));
57 struct raw_private *rp = RAW_PRIVATE(af);
58
59 if(af->fname) rp->raw=fopen(af->fname,mode);
60 if(rp->raw==0) return -1; // raw open failed
61 af->image_size = raw_filesize(af);
62 af->image_pagesize = RAW_PAGESIZE;
63 af->cur_page = 0;
64 return 0;
65 }
66
67 int raw_freopen(AFFILE *af,FILE *file)
68 {
69 af->fname = 0;
70 af->vnodeprivate = (void *)calloc(1,sizeof(struct raw_private));
71 struct raw_private *rp = RAW_PRIVATE(af);
72 rp->raw = file;
73 af->image_size = raw_filesize(af);
74 af->image_pagesize = RAW_PAGESIZE;
75 af->cur_page = 0;
76 return 0;
77 }
78
79
80 int raw_popen(AFFILE *af,const char *command,const char *type)
81 {
82 #ifdef HAVE_POPEN
83 if(strcmp(type,"r")!=0){
84 (*af->error_reporter)("af_popen: only type 'r' supported");
85 return -1;
86 }
87 /* If shell metacharacters exist in command, don't open it */
88 if(af_hasmeta(command)){
89 (*af->error_reporter)("raw_popen: invalid shell metacharacters in command '%s'",
90 command);
91 return -1;
92 }
93 af->fname = 0;
94 af->vnodeprivate = (void *)calloc(1,sizeof(struct raw_private));
95 struct raw_private *rp = RAW_PRIVATE(af);
96 rp->raw = popen(command,"r");
97 rp->raw_popen = 1;
98 return 0;
99 #else
100 (*af->error_reporter)("af_popen: popen not supported on this platform.");
101 return -1;
102 #endif
103 }
104
105
106 static int raw_close(AFFILE *af)
107 {
108 struct raw_private *rp = RAW_PRIVATE(af);
109
110 if(rp->raw_popen){
111 #ifdef HAVE_POPEN
112 pclose(rp->raw);
113 #endif
114 }
115 else {
116 fclose(rp->raw);
117 }
118 memset(rp,0,sizeof(*rp)); // clean object reuse
119 free(rp); // won't need it again
120 return 0;
121 }
122
123 static int raw_get_seg(AFFILE *af,const char *name,
124 unsigned long *arg,unsigned char *data,size_t *datalen)
125 {
126 struct raw_private *rp = RAW_PRIVATE(af);
127
128 int64_t segnum = af_segname_page_number(name);
129 if(segnum<0){
130 /* See if PAGESIZE or IMAGESIZE is being requested; we can fake those */
131 if(strcmp(name,AF_PAGESIZE)==0){
132 if(arg) *arg = af->image_pagesize;
133 if(datalen) *datalen = 0;
134 return 0;
135 }
136 if(strcmp(name,AF_IMAGESIZE)==0){
137 struct aff_quad q;
138 if(data && *datalen>=0){
139 q.low = htonl((unsigned long)(af->image_size & 0xffffffff));
140 q.high = htonl((unsigned long)(af->image_size >> 32));
141 memcpy(data,&q,8);
142 *datalen = 8;
143 }
144 return 0;
145 }
146 if(strcmp(name,AF_SECTORSIZE)==0){
147 if(arg) *arg = af->image_sectorsize;
148 if(datalen) *datalen = 0;
149 return 0;
150 }
151 if(strcmp(name,AF_DEVICE_SECTORS)==0){
152 int64_t devicesectors = af->image_size / af->image_sectorsize;
153 struct aff_quad q;
154 if(data && *datalen>=0){
155 q.low = htonl((unsigned long)(devicesectors & 0xffffffff));
156 q.high = htonl((unsigned long)(devicesectors >> 32));
157 memcpy(data,&q,8);
158 *datalen = 8;
159 }
160 return 0;
161 }
162
163 return -1; // don't know how to fake this
164 }
165
166 fflush(rp->raw); // make sure that any buffers are flushed
167
168 int64_t pos = (int64_t)segnum * af->image_pagesize; // where we are to start reading
169 int64_t bytes_left = af->image_size - pos; // how many bytes left in the file
170
171 if(bytes_left<0) bytes_left = 0;
172
173 int bytes_to_read = af->image_pagesize; // copy this many bytes, unless
174 if(bytes_to_read > bytes_left) bytes_to_read = bytes_left; // only this much is left
175
176 if(arg) *arg = 0; // arg is always 0
177 if(datalen){
178 if(data==0){ // asked for 0 bytes, so give the actual size
179 *datalen = bytes_to_read;
180 return 0;
181 }
182 if(*datalen < (unsigned)bytes_to_read){
183 *datalen = bytes_to_read;
184 return AF_ERROR_DATASMALL;
185 }
186 }
187 if(data){
188 fseeko(rp->raw,pos,SEEK_SET);
189 int bytes_read = fread(data,1,bytes_to_read,rp->raw);
190 if(bytes_read==bytes_to_read){
191 if(datalen) *datalen = bytes_read;
192 return 0;
193 }
194 return -1; // some kind of EOF?
195 }
196 return 0; // no problems!
197 }
198
199
200 int raw_update_seg(AFFILE *af, const char *name,
201 unsigned long arg,const u_char *value,unsigned int vallen)
202 {
203 struct raw_private *rp = RAW_PRIVATE(af);
204
205 /* Simple implementation; only updates data segments */
206 int64_t pagenum = af_segname_page_number(name);
207 if(pagenum<0){
208 errno = ENOTSUP;
209 return -1; // not a segment number
210 }
211 int64_t pos = pagenum * af->image_pagesize; // where we are to start reading
212 fseeko(rp->raw,pos,SEEK_SET);
213
214 if(fwrite(value,vallen,1,rp->raw)==1){
215 return 0;
216 }
217 return -1; // some kind of error...
218 }
219
220
221 static int raw_vstat(AFFILE *af,struct af_vnode_info *vni)
222 {
223 struct raw_private *rp = RAW_PRIVATE(af);
224
225 vni->imagesize = -1;
226 vni->pagesize = RAW_PAGESIZE; // decent page size
227 vni->supports_metadata = 0;
228 vni->is_raw = 1;
229 vni->changable_pagesize = 1; // change it at any time
230 vni->changable_sectorsize = 1; // change it at any time
231
232 /* If we can stat the file, use that. */
233 fflush(rp->raw);
234 vni->imagesize = raw_filesize(af);
235 vni->supports_compression = 0;
236 vni->has_pages = 1;
237
238 if(rp->raw_popen){
239 /* popen files require special handling */
240 vni->has_pages = 0;
241 vni->use_eof = 1;
242 vni->at_eof = feof(rp->raw); // are we there yet?
243 }
244 return 0;
245 }
246
247 static int raw_rewind_seg(AFFILE *af)
248 {
249 af->cur_page = 0;
250 return 0;
251 }
252
253
254 static int raw_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
255 unsigned char *data,size_t *datalen)
256 {
257
258 /* See if we are at the end of the "virtual" segment list */
259 if((u_int64_t)af->cur_page * af->image_pagesize >= af->image_size) return -1;
260
261 /* Make the segment name */
262 char pagename[AF_MAX_NAME_LEN]; //
263 memset(pagename,0,sizeof(pagename));
264 snprintf(pagename,sizeof(pagename),AF_PAGE,af->cur_page++);
265
266 /* Get the segment, if we can */
267 int r = raw_get_seg(af,pagename,arg,data,datalen);
268
269 /* If r==0 and there is room for copying in the segment name, return it */
270 if(r==0){
271 if(strlen(pagename)+1 < segname_len){
272 strcpy(segname,pagename);
273 return 0;
274 }
275 /* segname wasn't big enough */
276 return -2;
277 }
278 return r; // some other error
279 }
280
281 static int raw_read(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
282 {
283 struct raw_private *rp = RAW_PRIVATE(af);
284 fseeko(rp->raw,pos,SEEK_SET);
285 return fread(buf,1,count,rp->raw);
286 }
287
288 static int raw_write(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
289 {
290 struct raw_private *rp = RAW_PRIVATE(af);
291 if(fseeko(rp->raw,pos,SEEK_SET)<0) return -1;
292 return fwrite(buf,1,count,rp->raw);
293 }
294
295
296
297 struct af_vnode vnode_raw = {
298 AF_IDENTIFY_RAW,
299 AF_VNODE_TYPE_PRIMITIVE|AF_VNODE_TYPE_RELIABLE|AF_VNODE_NO_SIGNING|AF_VNODE_NO_SEALING,
300 "Raw",
301 raw_identify_file,
302 raw_open,
303 raw_close,
304 raw_vstat,
305 raw_get_seg, // get seg
306 raw_get_next_seg, // get_next_seg
307 raw_rewind_seg, // rewind_seg
308 raw_update_seg, // update_seg
309 0, // del_seg
310 raw_read, // read
311 raw_write // write
312 };
313
0 extern struct af_vnode vnode_raw; /* vnode_raw.cpp */
1
2 int raw_freopen(AFFILE *af,FILE *f);
3 int raw_popen(AFFILE *af,const char *command,const char *type);
0 /*
1 * vnode_aff.cpp:
2 *
3 * Functions for the manipulation of AFF files...
4 */
5
6 #include "affconfig.h"
7 #include "afflib.h"
8 #include "afflib_i.h"
9 #include "vnode_s3.h"
10 #include "s3_glue.h"
11
12 static int s3_close(AFFILE *af);
13
14 /* Return 1 if a file is an S3 URL */
15 static int s3_identify_file(const char *filename,int exists)
16 {
17 if(strlen(filename)<5 || strncmp(filename,"s3://",5)!=0) return 0; // not a valid URL
18 #ifdef USE_S3
19 if(exists==0) return 1; // don't need to check for existence; just return true
20
21 /* See if it exists */
22 AFFILE *af = af_open_with(filename,O_RDONLY,0,&vnode_s3); // can we open it with s3?
23 if(!af) return 0; // can't open it
24 s3_close(af);
25 #endif
26 return 1; // it's legit (or S3 support is not compiled in)
27 }
28
29 #ifdef USE_S3
30 #define S3_HEADER_ARG AMAZON_METADATA_PREFIX "arg" // XML metadata where the arg is stored
31
32
33 using namespace std;
34 using namespace s3;
35
36 /****************************************************************
37 *** Service routines
38 ****************************************************************/
39
40 class s3_private {
41 public:
42 s3_private():lbr(0) {}
43 ~s3_private(){
44 if(lbr) delete lbr;
45 }
46 string bucket;
47 string path; // of the S3 root object
48 string current_seg; // the segment we are currently on
49 ListBucketResult *lbr; // if we have one
50 };
51
52 static inline struct s3_private *S3_PRIVATE(AFFILE *af)
53 {
54 assert(af->v == &vnode_s3);
55 return (s3_private *)(af->vnodeprivate);
56 }
57
58
59 /****************************************************************
60 *** User-visible functions.
61 ****************************************************************/
62
63 #include <regex.h>
64 static int s3_open(AFFILE *af)
65 {
66 /* Set debug variable */
67 if(getenv(S3_DEBUG)){
68 s3_debug = atoi(getenv(S3_DEBUG));
69 #ifdef HAVE_ERR_SET_EXIT
70 err_set_exit(s3_audit);
71 #endif
72 }
73
74 /* Create the bucket if it doesn't exist */
75 aws_access_key_id = getenv(AWS_ACCESS_KEY_ID);
76 aws_secret_access_key = getenv(AWS_SECRET_ACCESS_KEY);
77
78 if(!aws_access_key_id) fprintf(stderr,"s3: AWS_ACCESS_KEY_ID not defined\n");
79 if(!aws_secret_access_key) fprintf(stderr,"s3: AWS_SECRET_ACCESS_KEY not defined\n");
80 if(!aws_access_key_id || !aws_secret_access_key) return -1; /* can't open */
81
82 /* URL host becomes bucket */
83 char bucket[1024]; memset(bucket,0,sizeof(bucket));
84 strcpy(bucket,af->hostname);
85
86 if(strlen(bucket)==0){
87 const char *b = getenv(S3_DEFAULT_BUCKET);
88 if(!b){
89 fprintf(stderr,"s3: S3_DEFAULT_BUCKET not defined and no bucket in URL.\n");
90 return -1;
91 }
92 strlcpy(bucket,b,sizeof(bucket));
93 }
94 if(strlen(af->fname)==0){
95 fprintf(stderr,"s3: No path specified in URL '%s'\n",af->fname);
96 return -1;
97 }
98
99 af->vnodeprivate = (void *)new s3_private();
100 struct s3_private *sp =S3_PRIVATE(af);
101 sp->bucket = bucket;
102 sp->path = string(af->fname) + "/";
103
104 /* If we are opening with O_CREAT and O_EXCL and the pagesize exists, then the
105 * file was already created. Return an error.
106 */
107 bool exists = af_get_seg(af,AF_PAGESIZE,0,0,0)==0;
108
109 if((af->openflags & O_CREAT) && (af->openflags & O_EXCL) && exists){
110 errno = EEXIST;
111 return -1;
112 }
113
114 /* If we are opening without O_CREAT and the pagesize does not exist, then the
115 * file was not created. Return an error.
116 */
117 if((af->openflags & O_CREAT)==0 && !exists){
118 errno = ENOENT;
119 return -1;
120 }
121 return 0; // "we were successful"
122 }
123
124
125 static int s3_close(AFFILE *af)
126 {
127 struct s3_private *sp =S3_PRIVATE(af);
128 if(sp) delete sp;
129 return 0;
130 }
131
132
133 static int s3_vstat(AFFILE *af,struct af_vnode_info *vni)
134 {
135 memset(vni,0,sizeof(*vni)); // clear it
136
137 vni->has_pages = 1;
138 vni->supports_metadata = 1;
139 if(af->image_size==0) af_read_sizes(af); // wasn't set?
140 vni->imagesize = af->image_size;
141 return 0;
142 }
143
144 static int s3_get_seg(AFFILE *af,const char *name,unsigned long *arg,unsigned char *data,
145 size_t *datalen)
146 {
147 /* TK: Don't get the whole object if we just want the size or the argument.
148 * Use Content-Range: as documented at http://docs.amazonwebservices.com/AmazonS3/2006-03-01/
149 **/
150
151 struct s3_private *sp =S3_PRIVATE(af);
152 sp->current_seg = name;
153 uint content_length = 0;
154
155 response_buffer *r = 0;
156
157 if(data) r = object_get(sp->bucket,sp->path + sp->current_seg,0);
158 else r = object_head(sp->bucket,sp->path + sp->current_seg,0);
159
160 if(r==0) return -1; // no response was returned?
161
162 if(r->result!=200){ // segment not found
163 delete r;
164 return -1;
165 }
166
167 /* Check for metadata headers */
168 if(arg) *arg=0; // default
169 for(map<string,string>::const_iterator i = r->rheaders.begin();
170 i != r->rheaders.end();
171 i++){
172 if( i->first == S3_HEADER_ARG && arg){
173 *arg = atoi(i->second.c_str());
174 continue;
175 }
176 if( i->first == S3_CONTENT_LENGTH){
177 content_length = atoi(i->second.c_str());
178 }
179 }
180
181 if(datalen==0) { // no clue the size of the data...
182 delete r;
183 return 0;
184 }
185 if(*datalen==0){
186 *datalen = data ? r->len : content_length; // use content_length if not getting data
187 delete r;
188 return 0; // datalen didn't have enough room
189 }
190 if(*datalen < r->len){
191 delete r;
192 return -2; // datalen not being enough
193 }
194 if(data) memcpy(data,r->base,r->len);
195 *datalen = r->len;
196 delete r;
197 return 0;
198 }
199
200
201 static int s3_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
202 unsigned char *data,size_t *datalen)
203 {
204 memset(segname,0,segname_len);
205
206 struct s3_private *sp =S3_PRIVATE(af);
207
208 if(sp->lbr && sp->lbr->contents.size()==0){ // this one is empty
209 delete sp->lbr;
210 sp->lbr = 0;
211 }
212 if(sp->lbr==0){ // need to get a new lbr..
213 s3_result *r = list_bucket(sp->bucket,sp->path,sp->path + sp->current_seg,0);
214 if(r->lbr==0){delete r;return -1;} // hm... didn't get the right response?
215 sp->lbr = r->lbr; // grab the lbr
216 r->lbr = 0; // and we won't let it be freed here.
217 delete r;
218 }
219
220 if(sp->lbr->contents.size()==0){
221 delete sp->lbr;
222 sp->lbr = 0;
223 return -1; // nothing left
224 }
225
226 sp->current_seg= sp->lbr->contents[0]->Key.substr(sp->path.size());
227
228 /* Set up the fields */
229 memset(segname,0,segname_len);
230 if(segname_len > sp->current_seg.size()){
231 strcpy(segname,sp->current_seg.c_str());
232 }
233 if(datalen) *datalen = sp->lbr->contents[0]->Size;
234
235 sp->lbr->contents.erase(sp->lbr->contents.begin()); // remove the first item
236
237 /* If the user has asked for either the arg or the data, we need to get the object */
238 if(arg || data) return s3_get_seg(af,segname,arg,data,datalen);
239 return 0; // otherwise, return success
240 }
241
242
243 /* Rewind all of the segments */
244 static int s3_rewind_seg(AFFILE *af)
245 {
246 struct s3_private *sp =S3_PRIVATE(af);
247 sp->current_seg = "";
248 if(sp->lbr){
249 delete sp->lbr;
250 sp->lbr = 0;
251 }
252 return 0;
253 }
254
255
256
257 /* Update:
258 * S3 implementation ignores append
259 */
260 static int s3_update_seg(AFFILE *af, const char *name,
261 unsigned long arg,const u_char *value,unsigned int vallen)
262
263 {
264 struct s3_private *sp =S3_PRIVATE(af);
265 char metabuf[64];
266 snprintf(metabuf,sizeof(metabuf),"%lu",arg); // get the arg
267 struct s3headers meta[] = {{S3_HEADER_ARG,metabuf},{0,0}};
268
269 sp->current_seg = name;
270 if(vallen==0){
271 value=(const u_char *)""; // point to a null string, so object_put knows to put
272 }
273 return object_put(sp->bucket,sp->path + sp->current_seg,(const char *)value,vallen,meta);
274 }
275
276 int s3_del_seg(AFFILE *af,const char *segname)
277 {
278 struct s3_private *sp =S3_PRIVATE(af);
279 sp->current_seg = segname;
280 return object_rm(sp->bucket,sp->path + sp->current_seg);
281 }
282
283
284 struct af_vnode vnode_s3 = {
285 AF_IDENTIFY_S3, //
286 AF_VNODE_TYPE_RELIABLE, //
287 "s3.amazonaws.com",
288 s3_identify_file,
289 s3_open, // open
290 s3_close, // close
291 s3_vstat, // vstat
292 s3_get_seg, // get_seg
293 s3_get_next_seg, // get_next_seg
294 s3_rewind_seg, // rewind_seg
295 s3_update_seg, // update_seg
296 s3_del_seg, // del_seg
297 0, // read
298 0 // write
299 };
300 #else
301 static int s3_cantopen(AFFILE *af)
302 {
303 err(1,"AFFLIB s3: Request to open %s, but S3 support is not compiled in.",af_filename(af));
304 return -1;
305 }
306
307 struct af_vnode vnode_s3 = {
308 AF_IDENTIFY_S3, //
309 AF_VNODE_TYPE_RELIABLE, //
310 "s3.amazonaws.com",
311 s3_identify_file,
312 s3_cantopen, // open
313 0, // close
314 0, // vstat
315 0, // get_seg
316 0, // get_next_seg
317 0, // rewind_seg
318 0, // update_seg
319 0, // del_seg
320 0, // read
321 0 // write
322 };
323
324
325 #endif // USE_S3
326
0 extern struct af_vnode vnode_s3; /* vnode_s3.cpp */
0 /*
1 * AFFLIB(tm)
2 *
3 * Copyright (c) 2005, 2006
4 * Simson L. Garfinkel and Basis Technology Corp.
5 * All rights reserved.
6 *
7 * This code is derrived from software contributed by Simson L. Garfinkel
8 *
9 * Support for split raw files and .afm files written by Joel N. Weber II
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by Simson L. Garfinkel
22 * and Basis Technology Corp.
23 * 4. Neither the name of Simson L. Garfinkel, Basis Technology, or other
24 * contributors to this program may be used to endorse or promote
25 * products derived from this software without specific prior written
26 * permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY SIMSON L. GARFINKEL, BASIS TECHNOLOGY,
29 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
30 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 * DISCLAIMED. IN NO EVENT SHALL SIMSON L. GARFINKEL, BASIS TECHNOLOGy,
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
36 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
39 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 * AFF and AFFLIB is a trademark of Simson Garfinkel and Basis Technology Corp.
43 */
44 #include "affconfig.h"
45 #include "afflib.h"
46 #include "afflib_i.h"
47 #include "vnode_split_raw.h"
48
49 #ifdef HAVE_CTYPE_H
50 #include <ctype.h>
51 #endif
52
53 #ifndef HAVE_ISDIGIT
54 static int isdigit(char ch)
55 {
56 return ch>='0' && ch<='9';
57 }
58 #endif
59
60
61
62 /* split raw file implementation with optional metadata support */
63 struct split_raw_private {
64 u_int num_raw_files; // number of raw files
65 int *fds; // array of file descriptors for each open raw file
66 uint64_t *pos; // where we are in each file
67 char *first_raw_fname; /* The filename of the first raw file. */
68 char *next_raw_fname; /* The filename of the next raw file, or 0
69 when one big file is used. */
70 int64_t cur_page; // current page number, used for split_raw_get_next_seg
71 };
72
73 static inline struct split_raw_private *SPLIT_RAW_PRIVATE(AFFILE *af)
74 {
75 assert(af->v == &vnode_split_raw);
76 return (struct split_raw_private *)(af->vnodeprivate);
77 }
78
79 /* Return 1 if a file is a split raw file... */
80 static int split_raw_identify_file(const char *filename,int exists)
81 {
82 if(exists && access(filename,R_OK)!=0) return 0; // needs to exist and it doesn't
83 return af_ext_is(filename,"000") ||
84 af_ext_is(filename,"001") ||
85 af_ext_is(filename,"aaa");
86 }
87
88 /* split_raw_close:
89 * Close each of the split files.
90 */
91
92 static int split_raw_close(AFFILE *af)
93 {
94 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
95
96 for (uint64_t i = 0; i < srp->num_raw_files; i++){
97 close (srp->fds[i]);
98 }
99 if (srp->fds) free (srp->fds);
100 if (srp->pos) free (srp->pos);
101 if (srp->first_raw_fname) free (srp->first_raw_fname);
102 if (srp->next_raw_fname) free (srp->next_raw_fname);
103 free(srp);
104 af->vnodeprivate = 0;
105 return 0;
106 }
107
108
109 /* increment_fname():
110 * takes filesname.000 and turns it into filename.001
111 * takes filename.aaa and makes it filename.aab
112 * fn must be at least 3 characters long.
113 * Returns 0 if successful, or -1 if it runs out of namespace.
114 */
115 static int increment_fname (char *fn)
116 {
117 /* Scan to the end of the string, minus 3 */
118 while (fn[3]) fn++;
119 if (fn[2] == '9') {
120 fn[2] = '0';
121 if (fn[1] == '9') {
122 fn[1] = '0';
123 if (fn[0] == '9')
124 return -1;
125 fn[0]++;
126 } else {
127 fn[1]++;
128 }
129 } else if (isdigit (fn[2])) {
130 fn[2]++;
131 } else if ((fn[2] == 'Z') || (fn[2] == 'z')) {
132 fn[2] -= 25;
133 fn[1]++;
134 } else if ((fn[2] == 'L') || (fn[2] == 'l')) {
135 /* We don't want to treat .afm as a valid raw file, since it is an
136 * AFF metadata file. So if we would end up with .afm as the name of the
137 * raw file, report being out of namespace instead.
138 */
139 if ((fn[1] == 'F') || (fn[1] == 'f'))
140 errno = EINVAL;
141 return -1;
142 fn[2]++;
143 } else {
144 fn[2]++;
145 }
146 return 0;
147 }
148
149
150 void srp_validate(AFFILE *af)
151 {
152 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
153 for(unsigned int i=0;i<srp->num_raw_files;i++){
154 assert(srp->fds[i]!=0);
155 }
156 }
157
158 void srp_dump(AFFILE *af)
159 {
160 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
161 for(unsigned int i=0;i<srp->num_raw_files;i++){
162 fprintf(stderr," fds[%d]=%d pos[%d]=%"I64d"\n",i,srp->fds[i],i,srp->pos[i]);
163 }
164 srp_validate(af);
165 fprintf(stderr,"===================\n");
166 }
167
168 static void srp_add_fd(AFFILE *af,int fd)
169 {
170 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
171 srp->num_raw_files++;
172 srp->fds = (int *)realloc (srp->fds, sizeof (int) * (srp->num_raw_files));
173 srp->fds[srp->num_raw_files - 1] = fd;
174 srp->pos = (uint64_t *)realloc (srp->pos, sizeof (uint64_t) * (srp->num_raw_files));
175 srp->pos[srp->num_raw_files - 1] = 0;
176 }
177
178
179 static int split_raw_open_internal(AFFILE *af, uint64_t *image_size)
180 {
181 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
182 int fd;
183 struct stat sb;
184
185 fd = open(srp->first_raw_fname, af->openflags|O_BINARY, 0666);
186 if (fd < 0) {
187 (*af->error_reporter)("split_raw_open_internal: open(%s): ",af->fname);
188 return -1;
189 }
190
191 srp->num_raw_files = 1;
192 srp->fds = (int *)malloc (sizeof (int));
193 srp->fds[0] = fd;
194 srp->pos = (uint64_t *)malloc (sizeof (uint64_t));
195 if (fstat (fd, &sb) != 0) {
196 (*af->error_reporter)("split_raw_open_internal: fstat(%s): ",af->fname);
197 close (fd);
198 return -1;
199 }
200
201 af->maxsize = 0;
202
203 /* If there's a next_raw_fname set by the caller of this function, we
204 * have a split file; otherwise we have one big file.
205 */
206 if (srp->next_raw_fname==0) {
207 (*image_size) = sb.st_size;
208 return 0;
209 }
210
211 /* This gets set to 1 the first time we find a file whose size doesn't
212 match the size of the first file. If we successfully open a file
213 when this flag is already 1, then our sanity checks fail. */
214 int current_file_must_be_last = 0;
215
216 do {
217 if (increment_fname (srp->next_raw_fname) != 0) {
218 fprintf (stderr, "split_raw_open_internal: too many files\n");
219 errno = EINVAL;
220 return -1;
221 }
222 fd = open(srp->next_raw_fname,
223 af->openflags & O_RDWR ? (O_RDWR|O_BINARY) : (O_RDONLY|O_BINARY));
224
225 if (fd < 0) {
226 if (errno != ENOENT) {
227 (af->error_reporter)("split_raw_open_internal errno=%d",errno);
228 return -1;
229 }
230 (*image_size) = sb.st_size + af->maxsize * (srp->num_raw_files - 1);
231 errno = 0; // reset errno
232 return 0; // end of files
233 }
234 srp_add_fd(af,fd);
235 if (current_file_must_be_last) {
236 fprintf(stderr,
237 "split_raw_open_internal: %s exists, "
238 "but previous file didn't match expected file size\n",af->fname);
239 return -1;
240 }
241 /* Set af->maxsize to the size of the first file, but only
242 if a second file exists. If no second file exists, then we want
243 to use af->maxsize, which cannot be set until after
244 af_open returns. */
245 if (!af->maxsize)
246 af->maxsize = sb.st_size;
247 if (fstat (fd, &sb) != 0) {
248 (*af->error_reporter)("split_raw_open_internal: fstat(%s): ",af->fname);
249 return -1;
250 }
251 if ((uint64_t)sb.st_size != af->maxsize){
252 current_file_must_be_last = 1;
253 }
254 } while (1);
255 return -1;
256 }
257
258 static int split_raw_open(AFFILE *af)
259 {
260 int ret;
261
262 af->vnodeprivate = (void *)calloc(sizeof(struct split_raw_private),1);
263 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
264
265 srp->first_raw_fname = strdup (af->fname);
266 srp->next_raw_fname = strdup (af->fname);
267 ret = split_raw_open_internal (af, &(af->image_size));
268
269 if (ret != 0) {
270 split_raw_close (af);
271 return ret;
272 }
273
274 /* Adaptively find the largest pagesize we can use that fits within maxsize */
275 af->image_pagesize = 512;
276 while ((af->image_pagesize < (16 * 1024 * 1024))
277 && !(af->maxsize % (af->image_pagesize * 2)))
278 af->image_pagesize *= 2;
279
280 if ((ret == 0) && (af->maxsize % af->image_pagesize!=0)) {
281 fprintf (stderr,
282 "split_raw_open: %s: raw_file_size (%"I64d" not a multiple of pagesize %lu\n",
283 af->fname, af->maxsize,af->image_pagesize);
284 split_raw_close (af);
285 return -1;
286 }
287
288 return 0;
289 }
290
291 static int split_raw_vstat(AFFILE *af,struct af_vnode_info *vni)
292 {
293 memset(vni,0,sizeof(*vni)); // clear it
294 vni->imagesize = af->image_size;
295 vni->pagesize = af->image_pagesize;
296 vni->supports_compression = 0;
297 vni->supports_metadata = 0;
298 vni->is_raw = 1;
299 vni->changable_pagesize = 1; // change it at any time
300 vni->changable_sectorsize = 1; // change it at any time
301 return 0;
302 }
303
304 static int split_raw_read(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
305 {
306 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
307 off_t c3;
308 int ret = 0; // how many bytes read
309
310 if ((af->image_size - pos) < (unsigned)count){
311 count = (off_t)(af->image_size - pos);
312 }
313
314 while (count > 0) {
315 int filenum = -1;
316 off_t file_offset = 0;
317
318 if (af->maxsize) { // if we do file segments
319 filenum = (int)(pos / af->maxsize);
320 file_offset = (off_t)(pos % af->maxsize);
321 } else {
322 filenum = 0;
323 file_offset = (off_t)pos;
324 }
325 if (file_offset != (off_t) srp->pos[filenum]) {
326 off_t c2 = lseek (srp->fds[filenum], file_offset, SEEK_SET);
327 if (file_offset != c2) { // seek failed; return work to date
328 if (ret) return ret; // some bytes were read; return that
329 else return -1; // no bytes read; return error
330 }
331 srp->pos[filenum] = c2; // this file starts here
332 }
333 if (af->maxsize && ((af->maxsize - file_offset) < (unsigned) count))
334 c3 = (off_t)(af->maxsize - file_offset);
335 else
336 c3 = count;
337 off_t c4 = read (srp->fds[filenum], buf, c3);
338 if (c4 <= 0) { // got an error
339 if (ret) return ret; // return how many bytes we read
340 else return -1; // otherwise, return -1
341 }
342 buf += c4;
343 count -= c4;
344 ret += c4;
345 pos += c4;
346 srp->pos[filenum] += c4; // position of this file pointer
347 if (c3 != c4) return ret; // incomplete?
348 }
349 return ret;
350 }
351
352 /*
353 * split_raw_write_internal2:
354 * If buf==0, assume we are writing zeros to the end of the file,
355 * and just seek to the last character and write a single NUL.
356 */
357
358 int split_raw_write_internal2(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
359 {
360 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
361 off_t c1, c3;
362 int i;
363 int ret = 0;
364 struct affcallback_info acbi;
365
366 /* Setup the callback structure */
367 memset(&acbi,0,sizeof(acbi));
368 acbi.info_version = 1;
369 acbi.af = af->parent ? af->parent : af;
370 acbi.pagenum = af->image_pagesize ? pos / af->image_pagesize : 0;
371 acbi.bytes_to_write = count;
372
373 while (count > 0) {
374 if (af->maxsize) { // do we need to possibly split into multiple file writes?
375 /* Figure out which file number we will need to write to... */
376 if (pos >= (af->maxsize * srp->num_raw_files)) {
377 int fd = open(srp->next_raw_fname, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0666);
378 if (fd < 0) {
379 (*af->error_reporter)("split_raw_write: open(%s): ",af->fname);
380 if (ret) return ret;
381 else return -1;
382 }
383 srp_add_fd(af,fd);
384 if (increment_fname (srp->next_raw_fname) != 0) {
385 (*af->error_reporter)("split_raw_write: too many files\n");
386 if (ret)
387 return ret;
388 else
389 return -1;
390 }
391 }
392 i = (int)(pos / af->maxsize);
393 c1 = (off_t)(pos % af->maxsize);
394 } else {
395 i = 0;
396 c1 = (off_t)pos;
397 }
398 if (c1 != (off_t)srp->pos[i]) { // do we need to seek this file?
399 off_t c2 = lseek (srp->fds[i], c1, SEEK_SET); // try to seek
400 if (c1 != c2) { // hm. Ended up in the wrong place. That's an error
401 if (ret>0) { // return how many bytes we got
402 return ret;
403 }
404 else {
405 return -1;
406 }
407 }
408 srp->pos[i] = c2;
409 }
410 if (af->maxsize && ((af->maxsize - c1) < (unsigned)count))
411 c3 = (off_t)(af->maxsize - c1);
412 else
413 c3 = count;
414 if(af->w_callback) {acbi.phase = 3;(*af->w_callback)(&acbi);}
415
416 /* WRITE THE DATA! */
417 off_t c4 = 0;
418
419 if(buf){
420 c4 = write (srp->fds[i], buf, c3);
421 }
422 else {
423 /* Extend with lseek() and write a single byte */
424 char z = 0;
425
426 lseek(srp->fds[i],c3-1,SEEK_CUR);
427 if(write(srp->fds[i],&z,1)!=1) return -1; // failure
428 c4 = c3;
429 }
430
431 /* DONE! */
432
433 acbi.bytes_written = c4;
434 if(af->w_callback) {acbi.phase = 4;(*af->w_callback)(&acbi);}
435 if (c4 <= 0) { // some error writing?
436 if (ret)
437 return ret;
438 else
439 return -1;
440 }
441 buf += c4;
442 count -= c4;
443 ret += c4;
444 pos += c4;
445 srp->pos[i] += c4;
446 if (af->image_size < pos) af->image_size = pos; // image was extended
447 if (c3 != c4){ // amount written doesn't equal request; return
448 return ret;
449 }
450 }
451 return ret;
452 }
453
454 int split_raw_write(AFFILE *af, unsigned char *buf, uint64_t pos,size_t count)
455 {
456 /* If we are being asked to start writing beyond the end of the file
457 * pad out the file (and possibly create one or more new image files.)
458 */
459
460 if (af->maxsize) {
461 if (pos > af->image_size) { // writing beyond the end...
462 while(pos > af->image_size){
463
464 /* repeat until file is as big as where we should be writing */
465 int64_t bytes_left = pos - af->image_size;
466 int bytes_to_write = (int)(af->maxsize - (af->image_size % af->maxsize));
467 if(bytes_to_write > bytes_left) bytes_to_write = (int)bytes_left;
468 int bytes_written = split_raw_write_internal2(af,0,af->image_size,bytes_to_write);
469 if(bytes_to_write != bytes_written){
470 return -1; // some kind of internal error
471 }
472 }
473 }
474 }
475
476 return split_raw_write_internal2 (af, buf, pos,count);
477 }
478
479
480
481 /* Get a segment; if a data page is being asked for, then fake it.
482 * Otherwise, return an error.
483 */
484
485 static int split_raw_get_seg(AFFILE *af,const char *name,unsigned long *arg,unsigned char *data,
486 size_t *datalen)
487 {
488 int64_t page_num = af_segname_page_number(name);
489 if(page_num<0){
490 errno = ENOTSUP; // sorry! We don't store metadata
491 return -1;
492 }
493
494 uint64_t pos = page_num * af->image_pagesize; // where we are to start reading
495 uint64_t bytes_left = af->image_size - pos; // how many bytes left in the file
496
497 unsigned int bytes_to_read = af->image_pagesize; // copy this many bytes, unless
498 if(bytes_to_read > bytes_left) bytes_to_read = (unsigned int)bytes_left; // only this much is left
499
500 if(arg) *arg = 0; // arg is always 0
501 if(datalen){
502 if(data==0){ // asked for 0 bytes, so give the actual size
503 *datalen = bytes_to_read;
504 return 0;
505 }
506 if(*datalen < (unsigned)bytes_to_read){
507 *datalen = bytes_to_read;
508 return AF_ERROR_DATASMALL;
509 }
510 }
511 if(data){
512 int bytes_read = split_raw_read(af,data,pos,bytes_to_read);
513 if(bytes_read>=0){
514 if(datalen) *datalen = bytes_read;
515 return 0;
516 }
517 return -1; // some kind of EOF?
518 }
519 return 0; // no problems!
520 }
521
522 /*
523 * split_raw_get_next_seg:
524 * Try get_next_seg on the AFF file first. If that fails,
525 * create the next virtual segment
526 */
527
528 static int split_raw_get_next_seg(AFFILE *af,char *segname,size_t segname_len,unsigned long *arg,
529 unsigned char *data,size_t *datalen_)
530 {
531 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
532
533 int64_t total_pages = (af->image_size + af->image_pagesize - 1) / af->image_pagesize;
534 if(srp->cur_page >= total_pages) return -1; // that's all there are
535
536 /* Make the segment name */
537 char pagename[AF_MAX_NAME_LEN];
538 memset(pagename,0,sizeof(pagename));
539 snprintf(pagename,sizeof(pagename),AF_PAGE,srp->cur_page++);
540
541 /* Get the segment, if we can */
542 int r = split_raw_get_seg(af,pagename,arg,data,datalen_);
543
544 /* If r==0 and there is room for copying in the segment name, return it */
545 if(r==0){
546 if(strlen(pagename)+1 < segname_len){
547 strcpy(segname,pagename);
548 return 0;
549 }
550 /* segname wasn't big enough */
551 return -2;
552 }
553 return r; // some other error
554 }
555
556
557 /* Rewind all of the segments */
558 static int split_raw_rewind_seg(AFFILE *af)
559 {
560 struct split_raw_private *srp = SPLIT_RAW_PRIVATE(af);
561 srp->cur_page = 0;
562 return 0;
563 }
564
565 static int split_raw_update_seg(AFFILE *af, const char *name,
566 unsigned long arg,const u_char *value,unsigned int vallen)
567
568 {
569 int64_t page_num = af_segname_page_number(name);
570 if(page_num<0){
571 errno = ENOTSUP; // sorry! We don't store metadata
572 return -1;
573 }
574
575 uint64_t pos = page_num * af->image_pagesize; // where we are to start reading
576 int written = split_raw_write(af, (unsigned char *)value, pos,vallen);
577 if(written==(int)vallen) return 0; // success
578 return -1;
579 }
580
581
582 struct af_vnode vnode_split_raw = {
583 AF_IDENTIFY_SPLIT_RAW,
584 AF_VNODE_TYPE_COMPOUND|AF_VNODE_TYPE_RELIABLE|AF_VNODE_MAXSIZE_MULTIPLE|AF_VNODE_NO_SIGNING|AF_VNODE_NO_SEALING,
585 "Split Raw",
586 split_raw_identify_file,
587 split_raw_open,
588 split_raw_close,
589 split_raw_vstat,
590 split_raw_get_seg, // get seg
591 split_raw_get_next_seg, // get_next_seg
592 split_raw_rewind_seg, // rewind_seg
593 split_raw_update_seg, // update_seg
594 0, // del_seg
595 split_raw_read, // read
596 split_raw_write // write
597 };
598
599
0 #define SPLITRAW_DEFAULT_EXTENSION "000"
1
2 extern struct af_vnode vnode_split_raw;
3
4
0 # Generated from ltmain.m4sh.
1
2 # ltmain.sh (GNU libtool) 2.2.4
3 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4
5 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
6 # This is free software; see the source for copying conditions. There is NO
7 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8
9 # GNU Libtool is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
13 #
14 # As a special exception to the GNU General Public License,
15 # if you distribute this file as part of a program or library that
16 # is built using GNU Libtool, you may include this file under the
17 # same distribution terms that you use for the rest of that program.
18 #
19 # GNU Libtool is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 # General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with GNU Libtool; see the file COPYING. If not, a copy
26 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
27 # or obtained by writing to the Free Software Foundation, Inc.,
28 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
30 # Usage: $progname [OPTION]... [MODE-ARG]...
31 #
32 # Provide generalized library-building support services.
33 #
34 # --config show all configuration variables
35 # --debug enable verbose shell tracing
36 # -n, --dry-run display commands without modifying any files
37 # --features display basic configuration information and exit
38 # --mode=MODE use operation mode MODE
39 # --preserve-dup-deps don't remove duplicate dependency libraries
40 # --quiet, --silent don't print informational messages
41 # --tag=TAG use configuration variables from tag TAG
42 # -v, --verbose print informational messages (default)
43 # --version print version information
44 # -h, --help print short or long help message
45 #
46 # MODE must be one of the following:
47 #
48 # clean remove files from the build directory
49 # compile compile a source file into a libtool object
50 # execute automatically set library path, then run a program
51 # finish complete the installation of libtool libraries
52 # install install libraries or executables
53 # link create a library or an executable
54 # uninstall remove libraries from an installed directory
55 #
56 # MODE-ARGS vary depending on the MODE.
57 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
58 #
59 # When reporting a bug, please describe a test case to reproduce it and
60 # include the following information:
61 #
62 # host-triplet: $host
63 # shell: $SHELL
64 # compiler: $LTCC
65 # compiler flags: $LTCFLAGS
66 # linker: $LD (gnu? $with_gnu_ld)
67 # $progname: (GNU libtool) 2.2.4
68 # automake: $automake_version
69 # autoconf: $autoconf_version
70 #
71 # Report bugs to <bug-libtool@gnu.org>.
72
73 PROGRAM=ltmain.sh
74 PACKAGE=libtool
75 VERSION=2.2.4
76 TIMESTAMP=""
77 package_revision=1.2976
78
79 # Be Bourne compatible
80 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
81 emulate sh
82 NULLCMD=:
83 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
84 # is contrary to our usage. Disable this feature.
85 alias -g '${1+"$@"}'='"$@"'
86 setopt NO_GLOB_SUBST
87 else
88 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
89 fi
90 BIN_SH=xpg4; export BIN_SH # for Tru64
91 DUALCASE=1; export DUALCASE # for MKS sh
92
93 # NLS nuisances: We save the old values to restore during execute mode.
94 # Only set LANG and LC_ALL to C if already set.
95 # These must not be set unconditionally because not all systems understand
96 # e.g. LANG=C (notably SCO).
97 lt_user_locale=
98 lt_safe_locale=
99 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
100 do
101 eval "if test \"\${$lt_var+set}\" = set; then
102 save_$lt_var=\$$lt_var
103 $lt_var=C
104 export $lt_var
105 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
106 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
107 fi"
108 done
109
110 $lt_unset CDPATH
111
112
113
114
115
116 : ${CP="cp -f"}
117 : ${ECHO="echo"}
118 : ${EGREP="/usr/bin/grep -E"}
119 : ${FGREP="/usr/bin/grep -F"}
120 : ${GREP="/usr/bin/grep"}
121 : ${LN_S="ln -s"}
122 : ${MAKE="make"}
123 : ${MKDIR="mkdir"}
124 : ${MV="mv -f"}
125 : ${RM="rm -f"}
126 : ${SED="/opt/local/bin/gsed"}
127 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
128 : ${Xsed="$SED -e 1s/^X//"}
129
130 # Global variables:
131 EXIT_SUCCESS=0
132 EXIT_FAILURE=1
133 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
134 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
135
136 exit_status=$EXIT_SUCCESS
137
138 # Make sure IFS has a sensible default
139 lt_nl='
140 '
141 IFS=" $lt_nl"
142
143 dirname="s,/[^/]*$,,"
144 basename="s,^.*/,,"
145
146 # func_dirname_and_basename file append nondir_replacement
147 # perform func_basename and func_dirname in a single function
148 # call:
149 # dirname: Compute the dirname of FILE. If nonempty,
150 # add APPEND to the result, otherwise set result
151 # to NONDIR_REPLACEMENT.
152 # value returned in "$func_dirname_result"
153 # basename: Compute filename of FILE.
154 # value retuned in "$func_basename_result"
155 # Implementation must be kept synchronized with func_dirname
156 # and func_basename. For efficiency, we do not delegate to
157 # those functions but instead duplicate the functionality here.
158 func_dirname_and_basename ()
159 {
160 # Extract subdirectory from the argument.
161 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
162 if test "X$func_dirname_result" = "X${1}"; then
163 func_dirname_result="${3}"
164 else
165 func_dirname_result="$func_dirname_result${2}"
166 fi
167 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
168 }
169
170 # Generated shell functions inserted here.
171
172 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
173 # is ksh but when the shell is invoked as "sh" and the current value of
174 # the _XPG environment variable is not equal to 1 (one), the special
175 # positional parameter $0, within a function call, is the name of the
176 # function.
177 progpath="$0"
178
179 # The name of this program:
180 # In the unlikely event $progname began with a '-', it would play havoc with
181 # func_echo (imagine progname=-n), so we prepend ./ in that case:
182 func_dirname_and_basename "$progpath"
183 progname=$func_basename_result
184 case $progname in
185 -*) progname=./$progname ;;
186 esac
187
188 # Make sure we have an absolute path for reexecution:
189 case $progpath in
190 [\\/]*|[A-Za-z]:\\*) ;;
191 *[\\/]*)
192 progdir=$func_dirname_result
193 progdir=`cd "$progdir" && pwd`
194 progpath="$progdir/$progname"
195 ;;
196 *)
197 save_IFS="$IFS"
198 IFS=:
199 for progdir in $PATH; do
200 IFS="$save_IFS"
201 test -x "$progdir/$progname" && break
202 done
203 IFS="$save_IFS"
204 test -n "$progdir" || progdir=`pwd`
205 progpath="$progdir/$progname"
206 ;;
207 esac
208
209 # Sed substitution that helps us do robust quoting. It backslashifies
210 # metacharacters that are still active within double-quoted strings.
211 Xsed="${SED}"' -e 1s/^X//'
212 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
213
214 # Same as above, but do not quote variable references.
215 double_quote_subst='s/\(["`\\]\)/\\\1/g'
216
217 # Re-`\' parameter expansions in output of double_quote_subst that were
218 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
219 # in input to double_quote_subst, that '$' was protected from expansion.
220 # Since each input `\' is now two `\'s, look for any number of runs of
221 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
222 bs='\\'
223 bs2='\\\\'
224 bs4='\\\\\\\\'
225 dollar='\$'
226 sed_double_backslash="\
227 s/$bs4/&\\
228 /g
229 s/^$bs2$dollar/$bs&/
230 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
231 s/\n//g"
232
233 # Standard options:
234 opt_dry_run=false
235 opt_help=false
236 opt_quiet=false
237 opt_verbose=false
238 opt_warning=:
239
240 # func_echo arg...
241 # Echo program name prefixed message, along with the current mode
242 # name if it has been set yet.
243 func_echo ()
244 {
245 $ECHO "$progname${mode+: }$mode: $*"
246 }
247
248 # func_verbose arg...
249 # Echo program name prefixed message in verbose mode only.
250 func_verbose ()
251 {
252 $opt_verbose && func_echo ${1+"$@"}
253
254 # A bug in bash halts the script if the last line of a function
255 # fails when set -e is in force, so we need another command to
256 # work around that:
257 :
258 }
259
260 # func_error arg...
261 # Echo program name prefixed message to standard error.
262 func_error ()
263 {
264 $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
265 }
266
267 # func_warning arg...
268 # Echo program name prefixed warning message to standard error.
269 func_warning ()
270 {
271 $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
272
273 # bash bug again:
274 :
275 }
276
277 # func_fatal_error arg...
278 # Echo program name prefixed message to standard error, and exit.
279 func_fatal_error ()
280 {
281 func_error ${1+"$@"}
282 exit $EXIT_FAILURE
283 }
284
285 # func_fatal_help arg...
286 # Echo program name prefixed message to standard error, followed by
287 # a help hint, and exit.
288 func_fatal_help ()
289 {
290 func_error ${1+"$@"}
291 func_fatal_error "$help"
292 }
293 help="Try \`$progname --help' for more information." ## default
294
295
296 # func_grep expression filename
297 # Check whether EXPRESSION matches any line of FILENAME, without output.
298 func_grep ()
299 {
300 $GREP "$1" "$2" >/dev/null 2>&1
301 }
302
303
304 # func_mkdir_p directory-path
305 # Make sure the entire path to DIRECTORY-PATH is available.
306 func_mkdir_p ()
307 {
308 my_directory_path="$1"
309 my_dir_list=
310
311 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
312
313 # Protect directory names starting with `-'
314 case $my_directory_path in
315 -*) my_directory_path="./$my_directory_path" ;;
316 esac
317
318 # While some portion of DIR does not yet exist...
319 while test ! -d "$my_directory_path"; do
320 # ...make a list in topmost first order. Use a colon delimited
321 # list incase some portion of path contains whitespace.
322 my_dir_list="$my_directory_path:$my_dir_list"
323
324 # If the last portion added has no slash in it, the list is done
325 case $my_directory_path in */*) ;; *) break ;; esac
326
327 # ...otherwise throw away the child directory and loop
328 my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
329 done
330 my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
331
332 save_mkdir_p_IFS="$IFS"; IFS=':'
333 for my_dir in $my_dir_list; do
334 IFS="$save_mkdir_p_IFS"
335 # mkdir can fail with a `File exist' error if two processes
336 # try to create one of the directories concurrently. Don't
337 # stop in that case!
338 $MKDIR "$my_dir" 2>/dev/null || :
339 done
340 IFS="$save_mkdir_p_IFS"
341
342 # Bail out if we (or some other process) failed to create a directory.
343 test -d "$my_directory_path" || \
344 func_fatal_error "Failed to create \`$1'"
345 fi
346 }
347
348
349 # func_mktempdir [string]
350 # Make a temporary directory that won't clash with other running
351 # libtool processes, and avoids race conditions if possible. If
352 # given, STRING is the basename for that directory.
353 func_mktempdir ()
354 {
355 my_template="${TMPDIR-/tmp}/${1-$progname}"
356
357 if test "$opt_dry_run" = ":"; then
358 # Return a directory name, but don't create it in dry-run mode
359 my_tmpdir="${my_template}-$$"
360 else
361
362 # If mktemp works, use that first and foremost
363 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
364
365 if test ! -d "$my_tmpdir"; then
366 # Failing that, at least try and use $RANDOM to avoid a race
367 my_tmpdir="${my_template}-${RANDOM-0}$$"
368
369 save_mktempdir_umask=`umask`
370 umask 0077
371 $MKDIR "$my_tmpdir"
372 umask $save_mktempdir_umask
373 fi
374
375 # If we're not in dry-run mode, bomb out on failure
376 test -d "$my_tmpdir" || \
377 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
378 fi
379
380 $ECHO "X$my_tmpdir" | $Xsed
381 }
382
383
384 # func_quote_for_eval arg
385 # Aesthetically quote ARG to be evaled later.
386 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
387 # is double-quoted, suitable for a subsequent eval, whereas
388 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
389 # which are still active within double quotes backslashified.
390 func_quote_for_eval ()
391 {
392 case $1 in
393 *[\\\`\"\$]*)
394 func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
395 *)
396 func_quote_for_eval_unquoted_result="$1" ;;
397 esac
398
399 case $func_quote_for_eval_unquoted_result in
400 # Double-quote args containing shell metacharacters to delay
401 # word splitting, command substitution and and variable
402 # expansion for a subsequent eval.
403 # Many Bourne shells cannot handle close brackets correctly
404 # in scan sets, so we specify it separately.
405 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
406 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
407 ;;
408 *)
409 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
410 esac
411 }
412
413
414 # func_quote_for_expand arg
415 # Aesthetically quote ARG to be evaled later; same as above,
416 # but do not quote variable references.
417 func_quote_for_expand ()
418 {
419 case $1 in
420 *[\\\`\"]*)
421 my_arg=`$ECHO "X$1" | $Xsed \
422 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
423 *)
424 my_arg="$1" ;;
425 esac
426
427 case $my_arg in
428 # Double-quote args containing shell metacharacters to delay
429 # word splitting and command substitution for a subsequent eval.
430 # Many Bourne shells cannot handle close brackets correctly
431 # in scan sets, so we specify it separately.
432 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
433 my_arg="\"$my_arg\""
434 ;;
435 esac
436
437 func_quote_for_expand_result="$my_arg"
438 }
439
440
441 # func_show_eval cmd [fail_exp]
442 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
443 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
444 # is given, then evaluate it.
445 func_show_eval ()
446 {
447 my_cmd="$1"
448 my_fail_exp="${2-:}"
449
450 ${opt_silent-false} || {
451 func_quote_for_expand "$my_cmd"
452 eval "func_echo $func_quote_for_expand_result"
453 }
454
455 if ${opt_dry_run-false}; then :; else
456 eval "$my_cmd"
457 my_status=$?
458 if test "$my_status" -eq 0; then :; else
459 eval "(exit $my_status); $my_fail_exp"
460 fi
461 fi
462 }
463
464
465 # func_show_eval_locale cmd [fail_exp]
466 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
467 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
468 # is given, then evaluate it. Use the saved locale for evaluation.
469 func_show_eval_locale ()
470 {
471 my_cmd="$1"
472 my_fail_exp="${2-:}"
473
474 ${opt_silent-false} || {
475 func_quote_for_expand "$my_cmd"
476 eval "func_echo $func_quote_for_expand_result"
477 }
478
479 if ${opt_dry_run-false}; then :; else
480 eval "$lt_user_locale
481 $my_cmd"
482 my_status=$?
483 eval "$lt_safe_locale"
484 if test "$my_status" -eq 0; then :; else
485 eval "(exit $my_status); $my_fail_exp"
486 fi
487 fi
488 }
489
490
491
492
493
494 # func_version
495 # Echo version message to standard output and exit.
496 func_version ()
497 {
498 $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
499 s/^# //
500 s/^# *$//
501 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
502 p
503 }' < "$progpath"
504 exit $?
505 }
506
507 # func_usage
508 # Echo short help message to standard output and exit.
509 func_usage ()
510 {
511 $SED -n '/^# Usage:/,/# -h/ {
512 s/^# //
513 s/^# *$//
514 s/\$progname/'$progname'/
515 p
516 }' < "$progpath"
517 $ECHO
518 $ECHO "run \`$progname --help | more' for full usage"
519 exit $?
520 }
521
522 # func_help
523 # Echo long help message to standard output and exit.
524 func_help ()
525 {
526 $SED -n '/^# Usage:/,/# Report bugs to/ {
527 s/^# //
528 s/^# *$//
529 s*\$progname*'$progname'*
530 s*\$host*'"$host"'*
531 s*\$SHELL*'"$SHELL"'*
532 s*\$LTCC*'"$LTCC"'*
533 s*\$LTCFLAGS*'"$LTCFLAGS"'*
534 s*\$LD*'"$LD"'*
535 s/\$with_gnu_ld/'"$with_gnu_ld"'/
536 s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
537 s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
538 p
539 }' < "$progpath"
540 exit $?
541 }
542
543 # func_missing_arg argname
544 # Echo program name prefixed message to standard error and set global
545 # exit_cmd.
546 func_missing_arg ()
547 {
548 func_error "missing argument for $1"
549 exit_cmd=exit
550 }
551
552 exit_cmd=:
553
554
555
556
557
558 # Check that we have a working $ECHO.
559 if test "X$1" = X--no-reexec; then
560 # Discard the --no-reexec flag, and continue.
561 shift
562 elif test "X$1" = X--fallback-echo; then
563 # Avoid inline document here, it may be left over
564 :
565 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
566 # Yippee, $ECHO works!
567 :
568 else
569 # Restart under the correct shell, and then maybe $ECHO will work.
570 exec $SHELL "$progpath" --no-reexec ${1+"$@"}
571 fi
572
573 if test "X$1" = X--fallback-echo; then
574 # used as fallback echo
575 shift
576 cat <<EOF
577 $*
578 EOF
579 exit $EXIT_SUCCESS
580 fi
581
582 magic="%%%MAGIC variable%%%"
583 magic_exe="%%%MAGIC EXE variable%%%"
584
585 # Global variables.
586 # $mode is unset
587 nonopt=
588 execute_dlfiles=
589 preserve_args=
590 lo2o="s/\\.lo\$/.${objext}/"
591 o2lo="s/\\.${objext}\$/.lo/"
592 extracted_archives=
593 extracted_serial=0
594
595 opt_dry_run=false
596 opt_duplicate_deps=false
597 opt_silent=false
598 opt_debug=:
599
600 # If this variable is set in any of the actions, the command in it
601 # will be execed at the end. This prevents here-documents from being
602 # left over by shells.
603 exec_cmd=
604
605 # func_fatal_configuration arg...
606 # Echo program name prefixed message to standard error, followed by
607 # a configuration failure hint, and exit.
608 func_fatal_configuration ()
609 {
610 func_error ${1+"$@"}
611 func_error "See the $PACKAGE documentation for more information."
612 func_fatal_error "Fatal configuration error."
613 }
614
615
616 # func_config
617 # Display the configuration for all the tags in this script.
618 func_config ()
619 {
620 re_begincf='^# ### BEGIN LIBTOOL'
621 re_endcf='^# ### END LIBTOOL'
622
623 # Default configuration.
624 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
625
626 # Now print the configurations for the tags.
627 for tagname in $taglist; do
628 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
629 done
630
631 exit $?
632 }
633
634 # func_features
635 # Display the features supported by this script.
636 func_features ()
637 {
638 $ECHO "host: $host"
639 if test "$build_libtool_libs" = yes; then
640 $ECHO "enable shared libraries"
641 else
642 $ECHO "disable shared libraries"
643 fi
644 if test "$build_old_libs" = yes; then
645 $ECHO "enable static libraries"
646 else
647 $ECHO "disable static libraries"
648 fi
649
650 exit $?
651 }
652
653 # func_enable_tag tagname
654 # Verify that TAGNAME is valid, and either flag an error and exit, or
655 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
656 # variable here.
657 func_enable_tag ()
658 {
659 # Global variable:
660 tagname="$1"
661
662 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
663 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
664 sed_extractcf="/$re_begincf/,/$re_endcf/p"
665
666 # Validate tagname.
667 case $tagname in
668 *[!-_A-Za-z0-9,/]*)
669 func_fatal_error "invalid tag name: $tagname"
670 ;;
671 esac
672
673 # Don't test for the "default" C tag, as we know it's
674 # there but not specially marked.
675 case $tagname in
676 CC) ;;
677 *)
678 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
679 taglist="$taglist $tagname"
680
681 # Evaluate the configuration. Be careful to quote the path
682 # and the sed script, to avoid splitting on whitespace, but
683 # also don't use non-portable quotes within backquotes within
684 # quotes we have to do it in 2 steps:
685 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
686 eval "$extractedcf"
687 else
688 func_error "ignoring unknown tag $tagname"
689 fi
690 ;;
691 esac
692 }
693
694 # Parse options once, thoroughly. This comes as soon as possible in
695 # the script to make things like `libtool --version' happen quickly.
696 {
697
698 # Shorthand for --mode=foo, only valid as the first argument
699 case $1 in
700 clean|clea|cle|cl)
701 shift; set dummy --mode clean ${1+"$@"}; shift
702 ;;
703 compile|compil|compi|comp|com|co|c)
704 shift; set dummy --mode compile ${1+"$@"}; shift
705 ;;
706 execute|execut|execu|exec|exe|ex|e)
707 shift; set dummy --mode execute ${1+"$@"}; shift
708 ;;
709 finish|finis|fini|fin|fi|f)
710 shift; set dummy --mode finish ${1+"$@"}; shift
711 ;;
712 install|instal|insta|inst|ins|in|i)
713 shift; set dummy --mode install ${1+"$@"}; shift
714 ;;
715 link|lin|li|l)
716 shift; set dummy --mode link ${1+"$@"}; shift
717 ;;
718 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
719 shift; set dummy --mode uninstall ${1+"$@"}; shift
720 ;;
721 esac
722
723 # Parse non-mode specific arguments:
724 while test "$#" -gt 0; do
725 opt="$1"
726 shift
727
728 case $opt in
729 --config) func_config ;;
730
731 --debug) preserve_args="$preserve_args $opt"
732 func_echo "enabling shell trace mode"
733 opt_debug='set -x'
734 $opt_debug
735 ;;
736
737 -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
738 execute_dlfiles="$execute_dlfiles $1"
739 shift
740 ;;
741
742 --dry-run | -n) opt_dry_run=: ;;
743 --features) func_features ;;
744 --finish) mode="finish" ;;
745
746 --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
747 case $1 in
748 # Valid mode arguments:
749 clean) ;;
750 compile) ;;
751 execute) ;;
752 finish) ;;
753 install) ;;
754 link) ;;
755 relink) ;;
756 uninstall) ;;
757
758 # Catch anything else as an error
759 *) func_error "invalid argument for $opt"
760 exit_cmd=exit
761 break
762 ;;
763 esac
764
765 mode="$1"
766 shift
767 ;;
768
769 --preserve-dup-deps)
770 opt_duplicate_deps=: ;;
771
772 --quiet|--silent) preserve_args="$preserve_args $opt"
773 opt_silent=:
774 ;;
775
776 --verbose| -v) preserve_args="$preserve_args $opt"
777 opt_silent=false
778 ;;
779
780 --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
781 preserve_args="$preserve_args $opt $1"
782 func_enable_tag "$1" # tagname is set here
783 shift
784 ;;
785
786 # Separate optargs to long options:
787 -dlopen=*|--mode=*|--tag=*)
788 func_opt_split "$opt"
789 set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
790 shift
791 ;;
792
793 -\?|-h) func_usage ;;
794 --help) opt_help=: ;;
795 --version) func_version ;;
796
797 -*) func_fatal_help "unrecognized option \`$opt'" ;;
798
799 *) nonopt="$opt"
800 break
801 ;;
802 esac
803 done
804
805
806 case $host in
807 *cygwin* | *mingw* | *pw32*)
808 # don't eliminate duplications in $postdeps and $predeps
809 opt_duplicate_compiler_generated_deps=:
810 ;;
811 *)
812 opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
813 ;;
814 esac
815
816 # Having warned about all mis-specified options, bail out if
817 # anything was wrong.
818 $exit_cmd $EXIT_FAILURE
819 }
820
821 # func_check_version_match
822 # Ensure that we are using m4 macros, and libtool script from the same
823 # release of libtool.
824 func_check_version_match ()
825 {
826 if test "$package_revision" != "$macro_revision"; then
827 if test "$VERSION" != "$macro_version"; then
828 if test -z "$macro_version"; then
829 cat >&2 <<_LT_EOF
830 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
831 $progname: definition of this LT_INIT comes from an older release.
832 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
833 $progname: and run autoconf again.
834 _LT_EOF
835 else
836 cat >&2 <<_LT_EOF
837 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
838 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
839 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
840 $progname: and run autoconf again.
841 _LT_EOF
842 fi
843 else
844 cat >&2 <<_LT_EOF
845 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
846 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
847 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
848 $progname: of $PACKAGE $VERSION and run autoconf again.
849 _LT_EOF
850 fi
851
852 exit $EXIT_MISMATCH
853 fi
854 }
855
856
857 ## ----------- ##
858 ## Main. ##
859 ## ----------- ##
860
861 $opt_help || {
862 # Sanity checks first:
863 func_check_version_match
864
865 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
866 func_fatal_configuration "not configured to build any kind of library"
867 fi
868
869 test -z "$mode" && func_fatal_error "error: you must specify a MODE."
870
871
872 # Darwin sucks
873 eval std_shrext=\"$shrext_cmds\"
874
875
876 # Only execute mode is allowed to have -dlopen flags.
877 if test -n "$execute_dlfiles" && test "$mode" != execute; then
878 func_error "unrecognized option \`-dlopen'"
879 $ECHO "$help" 1>&2
880 exit $EXIT_FAILURE
881 fi
882
883 # Change the help message to a mode-specific one.
884 generic_help="$help"
885 help="Try \`$progname --help --mode=$mode' for more information."
886 }
887
888
889 # func_lalib_p file
890 # True iff FILE is a libtool `.la' library or `.lo' object file.
891 # This function is only a basic sanity check; it will hardly flush out
892 # determined imposters.
893 func_lalib_p ()
894 {
895 $SED -e 4q "$1" 2>/dev/null \
896 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
897 }
898
899 # func_lalib_unsafe_p file
900 # True iff FILE is a libtool `.la' library or `.lo' object file.
901 # This function implements the same check as func_lalib_p without
902 # resorting to external programs. To this end, it redirects stdin and
903 # closes it afterwards, without saving the original file descriptor.
904 # As a safety measure, use it only where a negative result would be
905 # fatal anyway. Works if `file' does not exist.
906 func_lalib_unsafe_p ()
907 {
908 lalib_p=no
909 if test -r "$1" && exec 5<&0 <"$1"; then
910 for lalib_p_l in 1 2 3 4
911 do
912 read lalib_p_line
913 case "$lalib_p_line" in
914 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
915 esac
916 done
917 exec 0<&5 5<&-
918 fi
919 test "$lalib_p" = yes
920 }
921
922 # func_ltwrapper_script_p file
923 # True iff FILE is a libtool wrapper script
924 # This function is only a basic sanity check; it will hardly flush out
925 # determined imposters.
926 func_ltwrapper_script_p ()
927 {
928 func_lalib_p "$1"
929 }
930
931 # func_ltwrapper_executable_p file
932 # True iff FILE is a libtool wrapper executable
933 # This function is only a basic sanity check; it will hardly flush out
934 # determined imposters.
935 func_ltwrapper_executable_p ()
936 {
937 func_ltwrapper_exec_suffix=
938 case $1 in
939 *.exe) ;;
940 *) func_ltwrapper_exec_suffix=.exe ;;
941 esac
942 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
943 }
944
945 # func_ltwrapper_scriptname file
946 # Assumes file is an ltwrapper_executable
947 # uses $file to determine the appropriate filename for a
948 # temporary ltwrapper_script.
949 func_ltwrapper_scriptname ()
950 {
951 func_ltwrapper_scriptname_result=""
952 if func_ltwrapper_executable_p "$1"; then
953 func_dirname_and_basename "$1" "" "."
954 func_stripname '' '.exe' "$func_basename_result"
955 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
956 fi
957 }
958
959 # func_ltwrapper_p file
960 # True iff FILE is a libtool wrapper script or wrapper executable
961 # This function is only a basic sanity check; it will hardly flush out
962 # determined imposters.
963 func_ltwrapper_p ()
964 {
965 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
966 }
967
968
969 # func_execute_cmds commands fail_cmd
970 # Execute tilde-delimited COMMANDS.
971 # If FAIL_CMD is given, eval that upon failure.
972 # FAIL_CMD may read-access the current command in variable CMD!
973 func_execute_cmds ()
974 {
975 $opt_debug
976 save_ifs=$IFS; IFS='~'
977 for cmd in $1; do
978 IFS=$save_ifs
979 eval cmd=\"$cmd\"
980 func_show_eval "$cmd" "${2-:}"
981 done
982 IFS=$save_ifs
983 }
984
985
986 # func_source file
987 # Source FILE, adding directory component if necessary.
988 # Note that it is not necessary on cygwin/mingw to append a dot to
989 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
990 # behavior happens only for exec(3), not for open(2)! Also, sourcing
991 # `FILE.' does not work on cygwin managed mounts.
992 func_source ()
993 {
994 $opt_debug
995 case $1 in
996 */* | *\\*) . "$1" ;;
997 *) . "./$1" ;;
998 esac
999 }
1000
1001
1002 # func_infer_tag arg
1003 # Infer tagged configuration to use if any are available and
1004 # if one wasn't chosen via the "--tag" command line option.
1005 # Only attempt this if the compiler in the base compile
1006 # command doesn't match the default compiler.
1007 # arg is usually of the form 'gcc ...'
1008 func_infer_tag ()
1009 {
1010 $opt_debug
1011 if test -n "$available_tags" && test -z "$tagname"; then
1012 CC_quoted=
1013 for arg in $CC; do
1014 func_quote_for_eval "$arg"
1015 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1016 done
1017 case $@ in
1018 # Blanks in the command may have been stripped by the calling shell,
1019 # but not from the CC environment variable when configure was run.
1020 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1021 # Blanks at the start of $base_compile will cause this to fail
1022 # if we don't check for them as well.
1023 *)
1024 for z in $available_tags; do
1025 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1026 # Evaluate the configuration.
1027 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1028 CC_quoted=
1029 for arg in $CC; do
1030 # Double-quote args containing other shell metacharacters.
1031 func_quote_for_eval "$arg"
1032 CC_quoted="$CC_quoted $func_quote_for_eval_result"
1033 done
1034 case "$@ " in
1035 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1036 # The compiler in the base compile command matches
1037 # the one in the tagged configuration.
1038 # Assume this is the tagged configuration we want.
1039 tagname=$z
1040 break
1041 ;;
1042 esac
1043 fi
1044 done
1045 # If $tagname still isn't set, then no tagged configuration
1046 # was found and let the user know that the "--tag" command
1047 # line option must be used.
1048 if test -z "$tagname"; then
1049 func_echo "unable to infer tagged configuration"
1050 func_fatal_error "specify a tag with \`--tag'"
1051 # else
1052 # func_verbose "using $tagname tagged configuration"
1053 fi
1054 ;;
1055 esac
1056 fi
1057 }
1058
1059
1060
1061 # func_write_libtool_object output_name pic_name nonpic_name
1062 # Create a libtool object file (analogous to a ".la" file),
1063 # but don't create it if we're doing a dry run.
1064 func_write_libtool_object ()
1065 {
1066 write_libobj=${1}
1067 if test "$build_libtool_libs" = yes; then
1068 write_lobj=\'${2}\'
1069 else
1070 write_lobj=none
1071 fi
1072
1073 if test "$build_old_libs" = yes; then
1074 write_oldobj=\'${3}\'
1075 else
1076 write_oldobj=none
1077 fi
1078
1079 $opt_dry_run || {
1080 cat >${write_libobj}T <<EOF
1081 # $write_libobj - a libtool object file
1082 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1083 #
1084 # Please DO NOT delete this file!
1085 # It is necessary for linking the library.
1086
1087 # Name of the PIC object.
1088 pic_object=$write_lobj
1089
1090 # Name of the non-PIC object
1091 non_pic_object=$write_oldobj
1092
1093 EOF
1094 $MV "${write_libobj}T" "${write_libobj}"
1095 }
1096 }
1097
1098 # func_mode_compile arg...
1099 func_mode_compile ()
1100 {
1101 $opt_debug
1102 # Get the compilation command and the source file.
1103 base_compile=
1104 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
1105 suppress_opt=yes
1106 suppress_output=
1107 arg_mode=normal
1108 libobj=
1109 later=
1110 pie_flag=
1111
1112 for arg
1113 do
1114 case $arg_mode in
1115 arg )
1116 # do not "continue". Instead, add this to base_compile
1117 lastarg="$arg"
1118 arg_mode=normal
1119 ;;
1120
1121 target )
1122 libobj="$arg"
1123 arg_mode=normal
1124 continue
1125 ;;
1126
1127 normal )
1128 # Accept any command-line options.
1129 case $arg in
1130 -o)
1131 test -n "$libobj" && \
1132 func_fatal_error "you cannot specify \`-o' more than once"
1133 arg_mode=target
1134 continue
1135 ;;
1136
1137 -pie | -fpie | -fPIE)
1138 pie_flag="$pie_flag $arg"
1139 continue
1140 ;;
1141
1142 -shared | -static | -prefer-pic | -prefer-non-pic)
1143 later="$later $arg"
1144 continue
1145 ;;
1146
1147 -no-suppress)
1148 suppress_opt=no
1149 continue
1150 ;;
1151
1152 -Xcompiler)
1153 arg_mode=arg # the next one goes into the "base_compile" arg list
1154 continue # The current "srcfile" will either be retained or
1155 ;; # replaced later. I would guess that would be a bug.
1156
1157 -Wc,*)
1158 func_stripname '-Wc,' '' "$arg"
1159 args=$func_stripname_result
1160 lastarg=
1161 save_ifs="$IFS"; IFS=','
1162 for arg in $args; do
1163 IFS="$save_ifs"
1164 func_quote_for_eval "$arg"
1165 lastarg="$lastarg $func_quote_for_eval_result"
1166 done
1167 IFS="$save_ifs"
1168 func_stripname ' ' '' "$lastarg"
1169 lastarg=$func_stripname_result
1170
1171 # Add the arguments to base_compile.
1172 base_compile="$base_compile $lastarg"
1173 continue
1174 ;;
1175
1176 *)
1177 # Accept the current argument as the source file.
1178 # The previous "srcfile" becomes the current argument.
1179 #
1180 lastarg="$srcfile"
1181 srcfile="$arg"
1182 ;;
1183 esac # case $arg
1184 ;;
1185 esac # case $arg_mode
1186
1187 # Aesthetically quote the previous argument.
1188 func_quote_for_eval "$lastarg"
1189 base_compile="$base_compile $func_quote_for_eval_result"
1190 done # for arg
1191
1192 case $arg_mode in
1193 arg)
1194 func_fatal_error "you must specify an argument for -Xcompile"
1195 ;;
1196 target)
1197 func_fatal_error "you must specify a target with \`-o'"
1198 ;;
1199 *)
1200 # Get the name of the library object.
1201 test -z "$libobj" && {
1202 func_basename "$srcfile"
1203 libobj="$func_basename_result"
1204 }
1205 ;;
1206 esac
1207
1208 # Recognize several different file suffixes.
1209 # If the user specifies -o file.o, it is replaced with file.lo
1210 case $libobj in
1211 *.[cCFSifmso] | \
1212 *.ada | *.adb | *.ads | *.asm | \
1213 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1214 *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1215 func_xform "$libobj"
1216 libobj=$func_xform_result
1217 ;;
1218 esac
1219
1220 case $libobj in
1221 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1222 *)
1223 func_fatal_error "cannot determine name of library object from \`$libobj'"
1224 ;;
1225 esac
1226
1227 func_infer_tag $base_compile
1228
1229 for arg in $later; do
1230 case $arg in
1231 -shared)
1232 test "$build_libtool_libs" != yes && \
1233 func_fatal_configuration "can not build a shared library"
1234 build_old_libs=no
1235 continue
1236 ;;
1237
1238 -static)
1239 build_libtool_libs=no
1240 build_old_libs=yes
1241 continue
1242 ;;
1243
1244 -prefer-pic)
1245 pic_mode=yes
1246 continue
1247 ;;
1248
1249 -prefer-non-pic)
1250 pic_mode=no
1251 continue
1252 ;;
1253 esac
1254 done
1255
1256 func_quote_for_eval "$libobj"
1257 test "X$libobj" != "X$func_quote_for_eval_result" \
1258 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
1259 && func_warning "libobj name \`$libobj' may not contain shell special characters."
1260 func_dirname_and_basename "$obj" "/" ""
1261 objname="$func_basename_result"
1262 xdir="$func_dirname_result"
1263 lobj=${xdir}$objdir/$objname
1264
1265 test -z "$base_compile" && \
1266 func_fatal_help "you must specify a compilation command"
1267
1268 # Delete any leftover library objects.
1269 if test "$build_old_libs" = yes; then
1270 removelist="$obj $lobj $libobj ${libobj}T"
1271 else
1272 removelist="$lobj $libobj ${libobj}T"
1273 fi
1274
1275 # On Cygwin there's no "real" PIC flag so we must build both object types
1276 case $host_os in
1277 cygwin* | mingw* | pw32* | os2*)
1278 pic_mode=default
1279 ;;
1280 esac
1281 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1282 # non-PIC code in shared libraries is not supported
1283 pic_mode=default
1284 fi
1285
1286 # Calculate the filename of the output object if compiler does
1287 # not support -o with -c
1288 if test "$compiler_c_o" = no; then
1289 output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1290 lockfile="$output_obj.lock"
1291 else
1292 output_obj=
1293 need_locks=no
1294 lockfile=
1295 fi
1296
1297 # Lock this critical section if it is needed
1298 # We use this script file to make the link, it avoids creating a new file
1299 if test "$need_locks" = yes; then
1300 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1301 func_echo "Waiting for $lockfile to be removed"
1302 sleep 2
1303 done
1304 elif test "$need_locks" = warn; then
1305 if test -f "$lockfile"; then
1306 $ECHO "\
1307 *** ERROR, $lockfile exists and contains:
1308 `cat $lockfile 2>/dev/null`
1309
1310 This indicates that another process is trying to use the same
1311 temporary object file, and libtool could not work around it because
1312 your compiler does not support \`-c' and \`-o' together. If you
1313 repeat this compilation, it may succeed, by chance, but you had better
1314 avoid parallel builds (make -j) in this platform, or get a better
1315 compiler."
1316
1317 $opt_dry_run || $RM $removelist
1318 exit $EXIT_FAILURE
1319 fi
1320 removelist="$removelist $output_obj"
1321 $ECHO "$srcfile" > "$lockfile"
1322 fi
1323
1324 $opt_dry_run || $RM $removelist
1325 removelist="$removelist $lockfile"
1326 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1327
1328 if test -n "$fix_srcfile_path"; then
1329 eval srcfile=\"$fix_srcfile_path\"
1330 fi
1331 func_quote_for_eval "$srcfile"
1332 qsrcfile=$func_quote_for_eval_result
1333
1334 # Only build a PIC object if we are building libtool libraries.
1335 if test "$build_libtool_libs" = yes; then
1336 # Without this assignment, base_compile gets emptied.
1337 fbsd_hideous_sh_bug=$base_compile
1338
1339 if test "$pic_mode" != no; then
1340 command="$base_compile $qsrcfile $pic_flag"
1341 else
1342 # Don't build PIC code
1343 command="$base_compile $qsrcfile"
1344 fi
1345
1346 func_mkdir_p "$xdir$objdir"
1347
1348 if test -z "$output_obj"; then
1349 # Place PIC objects in $objdir
1350 command="$command -o $lobj"
1351 fi
1352
1353 func_show_eval_locale "$command" \
1354 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1355
1356 if test "$need_locks" = warn &&
1357 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1358 $ECHO "\
1359 *** ERROR, $lockfile contains:
1360 `cat $lockfile 2>/dev/null`
1361
1362 but it should contain:
1363 $srcfile
1364
1365 This indicates that another process is trying to use the same
1366 temporary object file, and libtool could not work around it because
1367 your compiler does not support \`-c' and \`-o' together. If you
1368 repeat this compilation, it may succeed, by chance, but you had better
1369 avoid parallel builds (make -j) in this platform, or get a better
1370 compiler."
1371
1372 $opt_dry_run || $RM $removelist
1373 exit $EXIT_FAILURE
1374 fi
1375
1376 # Just move the object if needed, then go on to compile the next one
1377 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1378 func_show_eval '$MV "$output_obj" "$lobj"' \
1379 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1380 fi
1381
1382 # Allow error messages only from the first compilation.
1383 if test "$suppress_opt" = yes; then
1384 suppress_output=' >/dev/null 2>&1'
1385 fi
1386 fi
1387
1388 # Only build a position-dependent object if we build old libraries.
1389 if test "$build_old_libs" = yes; then
1390 if test "$pic_mode" != yes; then
1391 # Don't build PIC code
1392 command="$base_compile $qsrcfile$pie_flag"
1393 else
1394 command="$base_compile $qsrcfile $pic_flag"
1395 fi
1396 if test "$compiler_c_o" = yes; then
1397 command="$command -o $obj"
1398 fi
1399
1400 # Suppress compiler output if we already did a PIC compilation.
1401 command="$command$suppress_output"
1402 func_show_eval_locale "$command" \
1403 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1404
1405 if test "$need_locks" = warn &&
1406 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1407 $ECHO "\
1408 *** ERROR, $lockfile contains:
1409 `cat $lockfile 2>/dev/null`
1410
1411 but it should contain:
1412 $srcfile
1413
1414 This indicates that another process is trying to use the same
1415 temporary object file, and libtool could not work around it because
1416 your compiler does not support \`-c' and \`-o' together. If you
1417 repeat this compilation, it may succeed, by chance, but you had better
1418 avoid parallel builds (make -j) in this platform, or get a better
1419 compiler."
1420
1421 $opt_dry_run || $RM $removelist
1422 exit $EXIT_FAILURE
1423 fi
1424
1425 # Just move the object if needed
1426 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1427 func_show_eval '$MV "$output_obj" "$obj"' \
1428 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1429 fi
1430 fi
1431
1432 $opt_dry_run || {
1433 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1434
1435 # Unlock the critical section if it was locked
1436 if test "$need_locks" != no; then
1437 removelist=$lockfile
1438 $RM "$lockfile"
1439 fi
1440 }
1441
1442 exit $EXIT_SUCCESS
1443 }
1444
1445 $opt_help || {
1446 test "$mode" = compile && func_mode_compile ${1+"$@"}
1447 }
1448
1449 func_mode_help ()
1450 {
1451 # We need to display help for each of the modes.
1452 case $mode in
1453 "")
1454 # Generic help is extracted from the usage comments
1455 # at the start of this file.
1456 func_help
1457 ;;
1458
1459 clean)
1460 $ECHO \
1461 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1462
1463 Remove files from the build directory.
1464
1465 RM is the name of the program to use to delete files associated with each FILE
1466 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1467 to RM.
1468
1469 If FILE is a libtool library, object or program, all the files associated
1470 with it are deleted. Otherwise, only FILE itself is deleted using RM."
1471 ;;
1472
1473 compile)
1474 $ECHO \
1475 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1476
1477 Compile a source file into a libtool library object.
1478
1479 This mode accepts the following additional options:
1480
1481 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
1482 -no-suppress do not suppress compiler output for multiple passes
1483 -prefer-pic try to building PIC objects only
1484 -prefer-non-pic try to building non-PIC objects only
1485 -shared do not build a \`.o' file suitable for static linking
1486 -static only build a \`.o' file suitable for static linking
1487
1488 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
1489 from the given SOURCEFILE.
1490
1491 The output file name is determined by removing the directory component from
1492 SOURCEFILE, then substituting the C source code suffix \`.c' with the
1493 library object suffix, \`.lo'."
1494 ;;
1495
1496 execute)
1497 $ECHO \
1498 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1499
1500 Automatically set library path, then run a program.
1501
1502 This mode accepts the following additional options:
1503
1504 -dlopen FILE add the directory containing FILE to the library path
1505
1506 This mode sets the library path environment variable according to \`-dlopen'
1507 flags.
1508
1509 If any of the ARGS are libtool executable wrappers, then they are translated
1510 into their corresponding uninstalled binary, and any of their required library
1511 directories are added to the library path.
1512
1513 Then, COMMAND is executed, with ARGS as arguments."
1514 ;;
1515
1516 finish)
1517 $ECHO \
1518 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1519
1520 Complete the installation of libtool libraries.
1521
1522 Each LIBDIR is a directory that contains libtool libraries.
1523
1524 The commands that this mode executes may require superuser privileges. Use
1525 the \`--dry-run' option if you just want to see what would be executed."
1526 ;;
1527
1528 install)
1529 $ECHO \
1530 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1531
1532 Install executables or libraries.
1533
1534 INSTALL-COMMAND is the installation command. The first component should be
1535 either the \`install' or \`cp' program.
1536
1537 The following components of INSTALL-COMMAND are treated specially:
1538
1539 -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation
1540
1541 The rest of the components are interpreted as arguments to that command (only
1542 BSD-compatible install options are recognized)."
1543 ;;
1544
1545 link)
1546 $ECHO \
1547 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1548
1549 Link object files or libraries together to form another library, or to
1550 create an executable program.
1551
1552 LINK-COMMAND is a command using the C compiler that you would use to create
1553 a program from several object files.
1554
1555 The following components of LINK-COMMAND are treated specially:
1556
1557 -all-static do not do any dynamic linking at all
1558 -avoid-version do not add a version suffix if possible
1559 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
1560 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
1561 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1562 -export-symbols SYMFILE
1563 try to export only the symbols listed in SYMFILE
1564 -export-symbols-regex REGEX
1565 try to export only the symbols matching REGEX
1566 -LLIBDIR search LIBDIR for required installed libraries
1567 -lNAME OUTPUT-FILE requires the installed library libNAME
1568 -module build a library that can dlopened
1569 -no-fast-install disable the fast-install mode
1570 -no-install link a not-installable executable
1571 -no-undefined declare that a library does not refer to external symbols
1572 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
1573 -objectlist FILE Use a list of object files found in FILE to specify objects
1574 -precious-files-regex REGEX
1575 don't remove output files matching REGEX
1576 -release RELEASE specify package release information
1577 -rpath LIBDIR the created library will eventually be installed in LIBDIR
1578 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
1579 -shared only do dynamic linking of libtool libraries
1580 -shrext SUFFIX override the standard shared library file extension
1581 -static do not do any dynamic linking of uninstalled libtool libraries
1582 -static-libtool-libs
1583 do not do any dynamic linking of libtool libraries
1584 -version-info CURRENT[:REVISION[:AGE]]
1585 specify library version info [each variable defaults to 0]
1586 -weak LIBNAME declare that the target provides the LIBNAME interface
1587
1588 All other options (arguments beginning with \`-') are ignored.
1589
1590 Every other argument is treated as a filename. Files ending in \`.la' are
1591 treated as uninstalled libtool libraries, other files are standard or library
1592 object files.
1593
1594 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1595 only library objects (\`.lo' files) may be specified, and \`-rpath' is
1596 required, except when creating a convenience library.
1597
1598 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1599 using \`ar' and \`ranlib', or on Windows using \`lib'.
1600
1601 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1602 is created, otherwise an executable program is created."
1603 ;;
1604
1605 uninstall)
1606 $ECHO \
1607 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1608
1609 Remove libraries from an installation directory.
1610
1611 RM is the name of the program to use to delete files associated with each FILE
1612 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
1613 to RM.
1614
1615 If FILE is a libtool library, all the files associated with it are deleted.
1616 Otherwise, only FILE itself is deleted using RM."
1617 ;;
1618
1619 *)
1620 func_fatal_help "invalid operation mode \`$mode'"
1621 ;;
1622 esac
1623
1624 $ECHO
1625 $ECHO "Try \`$progname --help' for more information about other modes."
1626
1627 exit $?
1628 }
1629
1630 # Now that we've collected a possible --mode arg, show help if necessary
1631 $opt_help && func_mode_help
1632
1633
1634 # func_mode_execute arg...
1635 func_mode_execute ()
1636 {
1637 $opt_debug
1638 # The first argument is the command name.
1639 cmd="$nonopt"
1640 test -z "$cmd" && \
1641 func_fatal_help "you must specify a COMMAND"
1642
1643 # Handle -dlopen flags immediately.
1644 for file in $execute_dlfiles; do
1645 test -f "$file" \
1646 || func_fatal_help "\`$file' is not a file"
1647
1648 dir=
1649 case $file in
1650 *.la)
1651 # Check to see that this really is a libtool archive.
1652 func_lalib_unsafe_p "$file" \
1653 || func_fatal_help "\`$lib' is not a valid libtool archive"
1654
1655 # Read the libtool library.
1656 dlname=
1657 library_names=
1658 func_source "$file"
1659
1660 # Skip this library if it cannot be dlopened.
1661 if test -z "$dlname"; then
1662 # Warn if it was a shared library.
1663 test -n "$library_names" && \
1664 func_warning "\`$file' was not linked with \`-export-dynamic'"
1665 continue
1666 fi
1667
1668 func_dirname "$file" "" "."
1669 dir="$func_dirname_result"
1670
1671 if test -f "$dir/$objdir/$dlname"; then
1672 dir="$dir/$objdir"
1673 else
1674 if test ! -f "$dir/$dlname"; then
1675 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1676 fi
1677 fi
1678 ;;
1679
1680 *.lo)
1681 # Just add the directory containing the .lo file.
1682 func_dirname "$file" "" "."
1683 dir="$func_dirname_result"
1684 ;;
1685
1686 *)
1687 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1688 continue
1689 ;;
1690 esac
1691
1692 # Get the absolute pathname.
1693 absdir=`cd "$dir" && pwd`
1694 test -n "$absdir" && dir="$absdir"
1695
1696 # Now add the directory to shlibpath_var.
1697 if eval "test -z \"\$$shlibpath_var\""; then
1698 eval "$shlibpath_var=\"\$dir\""
1699 else
1700 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1701 fi
1702 done
1703
1704 # This variable tells wrapper scripts just to set shlibpath_var
1705 # rather than running their programs.
1706 libtool_execute_magic="$magic"
1707
1708 # Check if any of the arguments is a wrapper script.
1709 args=
1710 for file
1711 do
1712 case $file in
1713 -*) ;;
1714 *)
1715 # Do a test to see if this is really a libtool program.
1716 if func_ltwrapper_script_p "$file"; then
1717 func_source "$file"
1718 # Transform arg to wrapped name.
1719 file="$progdir/$program"
1720 elif func_ltwrapper_executable_p "$file"; then
1721 func_ltwrapper_scriptname "$file"
1722 func_source "$func_ltwrapper_scriptname_result"
1723 # Transform arg to wrapped name.
1724 file="$progdir/$program"
1725 fi
1726 ;;
1727 esac
1728 # Quote arguments (to preserve shell metacharacters).
1729 func_quote_for_eval "$file"
1730 args="$args $func_quote_for_eval_result"
1731 done
1732
1733 if test "X$opt_dry_run" = Xfalse; then
1734 if test -n "$shlibpath_var"; then
1735 # Export the shlibpath_var.
1736 eval "export $shlibpath_var"
1737 fi
1738
1739 # Restore saved environment variables
1740 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1741 do
1742 eval "if test \"\${save_$lt_var+set}\" = set; then
1743 $lt_var=\$save_$lt_var; export $lt_var
1744 else
1745 $lt_unset $lt_var
1746 fi"
1747 done
1748
1749 # Now prepare to actually exec the command.
1750 exec_cmd="\$cmd$args"
1751 else
1752 # Display what would be done.
1753 if test -n "$shlibpath_var"; then
1754 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1755 $ECHO "export $shlibpath_var"
1756 fi
1757 $ECHO "$cmd$args"
1758 exit $EXIT_SUCCESS
1759 fi
1760 }
1761
1762 test "$mode" = execute && func_mode_execute ${1+"$@"}
1763
1764
1765 # func_mode_finish arg...
1766 func_mode_finish ()
1767 {
1768 $opt_debug
1769 libdirs="$nonopt"
1770 admincmds=
1771
1772 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1773 for dir
1774 do
1775 libdirs="$libdirs $dir"
1776 done
1777
1778 for libdir in $libdirs; do
1779 if test -n "$finish_cmds"; then
1780 # Do each command in the finish commands.
1781 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1782 '"$cmd"'"'
1783 fi
1784 if test -n "$finish_eval"; then
1785 # Do the single finish_eval.
1786 eval cmds=\"$finish_eval\"
1787 $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1788 $cmds"
1789 fi
1790 done
1791 fi
1792
1793 # Exit here if they wanted silent mode.
1794 $opt_silent && exit $EXIT_SUCCESS
1795
1796 $ECHO "X----------------------------------------------------------------------" | $Xsed
1797 $ECHO "Libraries have been installed in:"
1798 for libdir in $libdirs; do
1799 $ECHO " $libdir"
1800 done
1801 $ECHO
1802 $ECHO "If you ever happen to want to link against installed libraries"
1803 $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1804 $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1805 $ECHO "flag during linking and do at least one of the following:"
1806 if test -n "$shlibpath_var"; then
1807 $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable"
1808 $ECHO " during execution"
1809 fi
1810 if test -n "$runpath_var"; then
1811 $ECHO " - add LIBDIR to the \`$runpath_var' environment variable"
1812 $ECHO " during linking"
1813 fi
1814 if test -n "$hardcode_libdir_flag_spec"; then
1815 libdir=LIBDIR
1816 eval flag=\"$hardcode_libdir_flag_spec\"
1817
1818 $ECHO " - use the \`$flag' linker flag"
1819 fi
1820 if test -n "$admincmds"; then
1821 $ECHO " - have your system administrator run these commands:$admincmds"
1822 fi
1823 if test -f /etc/ld.so.conf; then
1824 $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1825 fi
1826 $ECHO
1827
1828 $ECHO "See any operating system documentation about shared libraries for"
1829 case $host in
1830 solaris2.[6789]|solaris2.1[0-9])
1831 $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1832 $ECHO "pages."
1833 ;;
1834 *)
1835 $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1836 ;;
1837 esac
1838 $ECHO "X----------------------------------------------------------------------" | $Xsed
1839 exit $EXIT_SUCCESS
1840 }
1841
1842 test "$mode" = finish && func_mode_finish ${1+"$@"}
1843
1844
1845 # func_mode_install arg...
1846 func_mode_install ()
1847 {
1848 $opt_debug
1849 # There may be an optional sh(1) argument at the beginning of
1850 # install_prog (especially on Windows NT).
1851 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1852 # Allow the use of GNU shtool's install command.
1853 $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1854 # Aesthetically quote it.
1855 func_quote_for_eval "$nonopt"
1856 install_prog="$func_quote_for_eval_result "
1857 arg=$1
1858 shift
1859 else
1860 install_prog=
1861 arg=$nonopt
1862 fi
1863
1864 # The real first argument should be the name of the installation program.
1865 # Aesthetically quote it.
1866 func_quote_for_eval "$arg"
1867 install_prog="$install_prog$func_quote_for_eval_result"
1868
1869 # We need to accept at least all the BSD install flags.
1870 dest=
1871 files=
1872 opts=
1873 prev=
1874 install_type=
1875 isdir=no
1876 stripme=
1877 for arg
1878 do
1879 if test -n "$dest"; then
1880 files="$files $dest"
1881 dest=$arg
1882 continue
1883 fi
1884
1885 case $arg in
1886 -d) isdir=yes ;;
1887 -f)
1888 case " $install_prog " in
1889 *[\\\ /]cp\ *) ;;
1890 *) prev=$arg ;;
1891 esac
1892 ;;
1893 -g | -m | -o)
1894 prev=$arg
1895 ;;
1896 -s)
1897 stripme=" -s"
1898 continue
1899 ;;
1900 -*)
1901 ;;
1902 *)
1903 # If the previous option needed an argument, then skip it.
1904 if test -n "$prev"; then
1905 prev=
1906 else
1907 dest=$arg
1908 continue
1909 fi
1910 ;;
1911 esac
1912
1913 # Aesthetically quote the argument.
1914 func_quote_for_eval "$arg"
1915 install_prog="$install_prog $func_quote_for_eval_result"
1916 done
1917
1918 test -z "$install_prog" && \
1919 func_fatal_help "you must specify an install program"
1920
1921 test -n "$prev" && \
1922 func_fatal_help "the \`$prev' option requires an argument"
1923
1924 if test -z "$files"; then
1925 if test -z "$dest"; then
1926 func_fatal_help "no file or destination specified"
1927 else
1928 func_fatal_help "you must specify a destination"
1929 fi
1930 fi
1931
1932 # Strip any trailing slash from the destination.
1933 func_stripname '' '/' "$dest"
1934 dest=$func_stripname_result
1935
1936 # Check to see that the destination is a directory.
1937 test -d "$dest" && isdir=yes
1938 if test "$isdir" = yes; then
1939 destdir="$dest"
1940 destname=
1941 else
1942 func_dirname_and_basename "$dest" "" "."
1943 destdir="$func_dirname_result"
1944 destname="$func_basename_result"
1945
1946 # Not a directory, so check to see that there is only one file specified.
1947 set dummy $files; shift
1948 test "$#" -gt 1 && \
1949 func_fatal_help "\`$dest' is not a directory"
1950 fi
1951 case $destdir in
1952 [\\/]* | [A-Za-z]:[\\/]*) ;;
1953 *)
1954 for file in $files; do
1955 case $file in
1956 *.lo) ;;
1957 *)
1958 func_fatal_help "\`$destdir' must be an absolute directory name"
1959 ;;
1960 esac
1961 done
1962 ;;
1963 esac
1964
1965 # This variable tells wrapper scripts just to set variables rather
1966 # than running their programs.
1967 libtool_install_magic="$magic"
1968
1969 staticlibs=
1970 future_libdirs=
1971 current_libdirs=
1972 for file in $files; do
1973
1974 # Do each installation.
1975 case $file in
1976 *.$libext)
1977 # Do the static libraries later.
1978 staticlibs="$staticlibs $file"
1979 ;;
1980
1981 *.la)
1982 # Check to see that this really is a libtool archive.
1983 func_lalib_unsafe_p "$file" \
1984 || func_fatal_help "\`$file' is not a valid libtool archive"
1985
1986 library_names=
1987 old_library=
1988 relink_command=
1989 func_source "$file"
1990
1991 # Add the libdir to current_libdirs if it is the destination.
1992 if test "X$destdir" = "X$libdir"; then
1993 case "$current_libdirs " in
1994 *" $libdir "*) ;;
1995 *) current_libdirs="$current_libdirs $libdir" ;;
1996 esac
1997 else
1998 # Note the libdir as a future libdir.
1999 case "$future_libdirs " in
2000 *" $libdir "*) ;;
2001 *) future_libdirs="$future_libdirs $libdir" ;;
2002 esac
2003 fi
2004
2005 func_dirname "$file" "/" ""
2006 dir="$func_dirname_result"
2007 dir="$dir$objdir"
2008
2009 if test -n "$relink_command"; then
2010 # Determine the prefix the user has applied to our future dir.
2011 inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2012
2013 # Don't allow the user to place us outside of our expected
2014 # location b/c this prevents finding dependent libraries that
2015 # are installed to the same prefix.
2016 # At present, this check doesn't affect windows .dll's that
2017 # are installed into $libdir/../bin (currently, that works fine)
2018 # but it's something to keep an eye on.
2019 test "$inst_prefix_dir" = "$destdir" && \
2020 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2021
2022 if test -n "$inst_prefix_dir"; then
2023 # Stick the inst_prefix_dir data into the link command.
2024 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2025 else
2026 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2027 fi
2028
2029 func_warning "relinking \`$file'"
2030 func_show_eval "$relink_command" \
2031 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2032 fi
2033
2034 # See the names of the shared library.
2035 set dummy $library_names; shift
2036 if test -n "$1"; then
2037 realname="$1"
2038 shift
2039
2040 srcname="$realname"
2041 test -n "$relink_command" && srcname="$realname"T
2042
2043 # Install the shared library and build the symlinks.
2044 func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2045 'exit $?'
2046 tstripme="$stripme"
2047 case $host_os in
2048 cygwin* | mingw* | pw32*)
2049 case $realname in
2050 *.dll.a)
2051 tstripme=""
2052 ;;
2053 esac
2054 ;;
2055 esac
2056 if test -n "$tstripme" && test -n "$striplib"; then
2057 func_show_eval "$striplib $destdir/$realname" 'exit $?'
2058 fi
2059
2060 if test "$#" -gt 0; then
2061 # Delete the old symlinks, and create new ones.
2062 # Try `ln -sf' first, because the `ln' binary might depend on
2063 # the symlink we replace! Solaris /bin/ln does not understand -f,
2064 # so we also need to try rm && ln -s.
2065 for linkname
2066 do
2067 test "$linkname" != "$realname" \
2068 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2069 done
2070 fi
2071
2072 # Do each command in the postinstall commands.
2073 lib="$destdir/$realname"
2074 func_execute_cmds "$postinstall_cmds" 'exit $?'
2075 fi
2076
2077 # Install the pseudo-library for information purposes.
2078 func_basename "$file"
2079 name="$func_basename_result"
2080 instname="$dir/$name"i
2081 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2082
2083 # Maybe install the static library, too.
2084 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2085 ;;
2086
2087 *.lo)
2088 # Install (i.e. copy) a libtool object.
2089
2090 # Figure out destination file name, if it wasn't already specified.
2091 if test -n "$destname"; then
2092 destfile="$destdir/$destname"
2093 else
2094 func_basename "$file"
2095 destfile="$func_basename_result"
2096 destfile="$destdir/$destfile"
2097 fi
2098
2099 # Deduce the name of the destination old-style object file.
2100 case $destfile in
2101 *.lo)
2102 func_lo2o "$destfile"
2103 staticdest=$func_lo2o_result
2104 ;;
2105 *.$objext)
2106 staticdest="$destfile"
2107 destfile=
2108 ;;
2109 *)
2110 func_fatal_help "cannot copy a libtool object to \`$destfile'"
2111 ;;
2112 esac
2113
2114 # Install the libtool object if requested.
2115 test -n "$destfile" && \
2116 func_show_eval "$install_prog $file $destfile" 'exit $?'
2117
2118 # Install the old object if enabled.
2119 if test "$build_old_libs" = yes; then
2120 # Deduce the name of the old-style object file.
2121 func_lo2o "$file"
2122 staticobj=$func_lo2o_result
2123 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2124 fi
2125 exit $EXIT_SUCCESS
2126 ;;
2127
2128 *)
2129 # Figure out destination file name, if it wasn't already specified.
2130 if test -n "$destname"; then
2131 destfile="$destdir/$destname"
2132 else
2133 func_basename "$file"
2134 destfile="$func_basename_result"
2135 destfile="$destdir/$destfile"
2136 fi
2137
2138 # If the file is missing, and there is a .exe on the end, strip it
2139 # because it is most likely a libtool script we actually want to
2140 # install
2141 stripped_ext=""
2142 case $file in
2143 *.exe)
2144 if test ! -f "$file"; then
2145 func_stripname '' '.exe' "$file"
2146 file=$func_stripname_result
2147 stripped_ext=".exe"
2148 fi
2149 ;;
2150 esac
2151
2152 # Do a test to see if this is really a libtool program.
2153 case $host in
2154 *cygwin*|*mingw*)
2155 if func_ltwrapper_executable_p "$file"; then
2156 func_ltwrapper_scriptname "$file"
2157 wrapper=$func_ltwrapper_scriptname_result
2158 else
2159 func_stripname '' '.exe' "$file"
2160 wrapper=$func_stripname_result
2161 fi
2162 ;;
2163 *)
2164 wrapper=$file
2165 ;;
2166 esac
2167 if func_ltwrapper_script_p "$wrapper"; then
2168 notinst_deplibs=
2169 relink_command=
2170
2171 func_source "$wrapper"
2172
2173 # Check the variables that should have been set.
2174 test -z "$generated_by_libtool_version" && \
2175 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2176
2177 finalize=yes
2178 for lib in $notinst_deplibs; do
2179 # Check to see that each library is installed.
2180 libdir=
2181 if test -f "$lib"; then
2182 func_source "$lib"
2183 fi
2184 libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2185 if test -n "$libdir" && test ! -f "$libfile"; then
2186 func_warning "\`$lib' has not been installed in \`$libdir'"
2187 finalize=no
2188 fi
2189 done
2190
2191 relink_command=
2192 func_source "$wrapper"
2193
2194 outputname=
2195 if test "$fast_install" = no && test -n "$relink_command"; then
2196 $opt_dry_run || {
2197 if test "$finalize" = yes; then
2198 tmpdir=`func_mktempdir`
2199 func_basename "$file$stripped_ext"
2200 file="$func_basename_result"
2201 outputname="$tmpdir/$file"
2202 # Replace the output file specification.
2203 relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2204
2205 $opt_silent || {
2206 func_quote_for_expand "$relink_command"
2207 eval "func_echo $func_quote_for_expand_result"
2208 }
2209 if eval "$relink_command"; then :
2210 else
2211 func_error "error: relink \`$file' with the above command before installing it"
2212 $opt_dry_run || ${RM}r "$tmpdir"
2213 continue
2214 fi
2215 file="$outputname"
2216 else
2217 func_warning "cannot relink \`$file'"
2218 fi
2219 }
2220 else
2221 # Install the binary that we compiled earlier.
2222 file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2223 fi
2224 fi
2225
2226 # remove .exe since cygwin /usr/bin/install will append another
2227 # one anyway
2228 case $install_prog,$host in
2229 */usr/bin/install*,*cygwin*)
2230 case $file:$destfile in
2231 *.exe:*.exe)
2232 # this is ok
2233 ;;
2234 *.exe:*)
2235 destfile=$destfile.exe
2236 ;;
2237 *:*.exe)
2238 func_stripname '' '.exe' "$destfile"
2239 destfile=$func_stripname_result
2240 ;;
2241 esac
2242 ;;
2243 esac
2244 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2245 $opt_dry_run || if test -n "$outputname"; then
2246 ${RM}r "$tmpdir"
2247 fi
2248 ;;
2249 esac
2250 done
2251
2252 for file in $staticlibs; do
2253 func_basename "$file"
2254 name="$func_basename_result"
2255
2256 # Set up the ranlib parameters.
2257 oldlib="$destdir/$name"
2258
2259 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2260
2261 if test -n "$stripme" && test -n "$old_striplib"; then
2262 func_show_eval "$old_striplib $oldlib" 'exit $?'
2263 fi
2264
2265 # Do each command in the postinstall commands.
2266 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2267 done
2268
2269 test -n "$future_libdirs" && \
2270 func_warning "remember to run \`$progname --finish$future_libdirs'"
2271
2272 if test -n "$current_libdirs"; then
2273 # Maybe just do a dry run.
2274 $opt_dry_run && current_libdirs=" -n$current_libdirs"
2275 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2276 else
2277 exit $EXIT_SUCCESS
2278 fi
2279 }
2280
2281 test "$mode" = install && func_mode_install ${1+"$@"}
2282
2283
2284 # func_generate_dlsyms outputname originator pic_p
2285 # Extract symbols from dlprefiles and create ${outputname}S.o with
2286 # a dlpreopen symbol table.
2287 func_generate_dlsyms ()
2288 {
2289 $opt_debug
2290 my_outputname="$1"
2291 my_originator="$2"
2292 my_pic_p="${3-no}"
2293 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2294 my_dlsyms=
2295
2296 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2297 if test -n "$NM" && test -n "$global_symbol_pipe"; then
2298 my_dlsyms="${my_outputname}S.c"
2299 else
2300 func_error "not configured to extract global symbols from dlpreopened files"
2301 fi
2302 fi
2303
2304 if test -n "$my_dlsyms"; then
2305 case $my_dlsyms in
2306 "") ;;
2307 *.c)
2308 # Discover the nlist of each of the dlfiles.
2309 nlist="$output_objdir/${my_outputname}.nm"
2310
2311 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2312
2313 # Parse the name list into a source file.
2314 func_verbose "creating $output_objdir/$my_dlsyms"
2315
2316 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2317 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2318 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2319
2320 #ifdef __cplusplus
2321 extern \"C\" {
2322 #endif
2323
2324 /* External symbol declarations for the compiler. */\
2325 "
2326
2327 if test "$dlself" = yes; then
2328 func_verbose "generating symbol list for \`$output'"
2329
2330 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2331
2332 # Add our own program objects to the symbol list.
2333 progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2334 for progfile in $progfiles; do
2335 func_verbose "extracting global C symbols from \`$progfile'"
2336 $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2337 done
2338
2339 if test -n "$exclude_expsyms"; then
2340 $opt_dry_run || {
2341 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2342 eval '$MV "$nlist"T "$nlist"'
2343 }
2344 fi
2345
2346 if test -n "$export_symbols_regex"; then
2347 $opt_dry_run || {
2348 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2349 eval '$MV "$nlist"T "$nlist"'
2350 }
2351 fi
2352
2353 # Prepare the list of exported symbols
2354 if test -z "$export_symbols"; then
2355 export_symbols="$output_objdir/$outputname.exp"
2356 $opt_dry_run || {
2357 $RM $export_symbols
2358 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2359 case $host in
2360 *cygwin* | *mingw* )
2361 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2362 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2363 ;;
2364 esac
2365 }
2366 else
2367 $opt_dry_run || {
2368 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2369 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2370 eval '$MV "$nlist"T "$nlist"'
2371 case $host in
2372 *cygwin | *mingw* )
2373 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2374 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2375 ;;
2376 esac
2377 }
2378 fi
2379 fi
2380
2381 for dlprefile in $dlprefiles; do
2382 func_verbose "extracting global C symbols from \`$dlprefile'"
2383 func_basename "$dlprefile"
2384 name="$func_basename_result"
2385 $opt_dry_run || {
2386 eval '$ECHO ": $name " >> "$nlist"'
2387 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2388 }
2389 done
2390
2391 $opt_dry_run || {
2392 # Make sure we have at least an empty file.
2393 test -f "$nlist" || : > "$nlist"
2394
2395 if test -n "$exclude_expsyms"; then
2396 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2397 $MV "$nlist"T "$nlist"
2398 fi
2399
2400 # Try sorting and uniquifying the output.
2401 if $GREP -v "^: " < "$nlist" |
2402 if sort -k 3 </dev/null >/dev/null 2>&1; then
2403 sort -k 3
2404 else
2405 sort +2
2406 fi |
2407 uniq > "$nlist"S; then
2408 :
2409 else
2410 $GREP -v "^: " < "$nlist" > "$nlist"S
2411 fi
2412
2413 if test -f "$nlist"S; then
2414 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2415 else
2416 $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2417 fi
2418
2419 $ECHO >> "$output_objdir/$my_dlsyms" "\
2420
2421 /* The mapping between symbol names and symbols. */
2422 typedef struct {
2423 const char *name;
2424 void *address;
2425 } lt_dlsymlist;
2426 "
2427 case $host in
2428 *cygwin* | *mingw* )
2429 $ECHO >> "$output_objdir/$my_dlsyms" "\
2430 /* DATA imports from DLLs on WIN32 con't be const, because
2431 runtime relocations are performed -- see ld's documentation
2432 on pseudo-relocs. */"
2433 lt_dlsym_const= ;;
2434 *osf5*)
2435 echo >> "$output_objdir/$my_dlsyms" "\
2436 /* This system does not cope well with relocations in const data */"
2437 lt_dlsym_const= ;;
2438 *)
2439 lt_dlsym_const=const ;;
2440 esac
2441
2442 $ECHO >> "$output_objdir/$my_dlsyms" "\
2443 extern $lt_dlsym_const lt_dlsymlist
2444 lt_${my_prefix}_LTX_preloaded_symbols[];
2445 $lt_dlsym_const lt_dlsymlist
2446 lt_${my_prefix}_LTX_preloaded_symbols[] =
2447 {\
2448 { \"$my_originator\", (void *) 0 },"
2449
2450 case $need_lib_prefix in
2451 no)
2452 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2453 ;;
2454 *)
2455 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2456 ;;
2457 esac
2458 $ECHO >> "$output_objdir/$my_dlsyms" "\
2459 {0, (void *) 0}
2460 };
2461
2462 /* This works around a problem in FreeBSD linker */
2463 #ifdef FREEBSD_WORKAROUND
2464 static const void *lt_preloaded_setup() {
2465 return lt_${my_prefix}_LTX_preloaded_symbols;
2466 }
2467 #endif
2468
2469 #ifdef __cplusplus
2470 }
2471 #endif\
2472 "
2473 } # !$opt_dry_run
2474
2475 pic_flag_for_symtable=
2476 case "$compile_command " in
2477 *" -static "*) ;;
2478 *)
2479 case $host in
2480 # compiling the symbol table file with pic_flag works around
2481 # a FreeBSD bug that causes programs to crash when -lm is
2482 # linked before any other PIC object. But we must not use
2483 # pic_flag when linking with -static. The problem exists in
2484 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2485 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2486 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2487 *-*-hpux*)
2488 pic_flag_for_symtable=" $pic_flag" ;;
2489 *)
2490 if test "X$my_pic_p" != Xno; then
2491 pic_flag_for_symtable=" $pic_flag"
2492 fi
2493 ;;
2494 esac
2495 ;;
2496 esac
2497 symtab_cflags=
2498 for arg in $LTCFLAGS; do
2499 case $arg in
2500 -pie | -fpie | -fPIE) ;;
2501 *) symtab_cflags="$symtab_cflags $arg" ;;
2502 esac
2503 done
2504
2505 # Now compile the dynamic symbol file.
2506 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2507
2508 # Clean up the generated files.
2509 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2510
2511 # Transform the symbol file into the correct name.
2512 symfileobj="$output_objdir/${my_outputname}S.$objext"
2513 case $host in
2514 *cygwin* | *mingw* )
2515 if test -f "$output_objdir/$my_outputname.def"; then
2516 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2517 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2518 else
2519 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2520 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2521 fi
2522 ;;
2523 *)
2524 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2525 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2526 ;;
2527 esac
2528 ;;
2529 *)
2530 func_fatal_error "unknown suffix for \`$my_dlsyms'"
2531 ;;
2532 esac
2533 else
2534 # We keep going just in case the user didn't refer to
2535 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
2536 # really was required.
2537
2538 # Nullify the symbol file.
2539 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2540 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2541 fi
2542 }
2543
2544 # func_win32_libid arg
2545 # return the library type of file 'arg'
2546 #
2547 # Need a lot of goo to handle *both* DLLs and import libs
2548 # Has to be a shell function in order to 'eat' the argument
2549 # that is supplied when $file_magic_command is called.
2550 func_win32_libid ()
2551 {
2552 $opt_debug
2553 win32_libid_type="unknown"
2554 win32_fileres=`file -L $1 2>/dev/null`
2555 case $win32_fileres in
2556 *ar\ archive\ import\ library*) # definitely import
2557 win32_libid_type="x86 archive import"
2558 ;;
2559 *ar\ archive*) # could be an import, or static
2560 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2561 $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2562 win32_nmres=`eval $NM -f posix -A $1 |
2563 $SED -n -e '
2564 1,100{
2565 / I /{
2566 s,.*,import,
2567 p
2568 q
2569 }
2570 }'`
2571 case $win32_nmres in
2572 import*) win32_libid_type="x86 archive import";;
2573 *) win32_libid_type="x86 archive static";;
2574 esac
2575 fi
2576 ;;
2577 *DLL*)
2578 win32_libid_type="x86 DLL"
2579 ;;
2580 *executable*) # but shell scripts are "executable" too...
2581 case $win32_fileres in
2582 *MS\ Windows\ PE\ Intel*)
2583 win32_libid_type="x86 DLL"
2584 ;;
2585 esac
2586 ;;
2587 esac
2588 $ECHO "$win32_libid_type"
2589 }
2590
2591
2592
2593 # func_extract_an_archive dir oldlib
2594 func_extract_an_archive ()
2595 {
2596 $opt_debug
2597 f_ex_an_ar_dir="$1"; shift
2598 f_ex_an_ar_oldlib="$1"
2599 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2600 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2601 :
2602 else
2603 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2604 fi
2605 }
2606
2607
2608 # func_extract_archives gentop oldlib ...
2609 func_extract_archives ()
2610 {
2611 $opt_debug
2612 my_gentop="$1"; shift
2613 my_oldlibs=${1+"$@"}
2614 my_oldobjs=""
2615 my_xlib=""
2616 my_xabs=""
2617 my_xdir=""
2618
2619 for my_xlib in $my_oldlibs; do
2620 # Extract the objects.
2621 case $my_xlib in
2622 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2623 *) my_xabs=`pwd`"/$my_xlib" ;;
2624 esac
2625 func_basename "$my_xlib"
2626 my_xlib="$func_basename_result"
2627 my_xlib_u=$my_xlib
2628 while :; do
2629 case " $extracted_archives " in
2630 *" $my_xlib_u "*)
2631 func_arith $extracted_serial + 1
2632 extracted_serial=$func_arith_result
2633 my_xlib_u=lt$extracted_serial-$my_xlib ;;
2634 *) break ;;
2635 esac
2636 done
2637 extracted_archives="$extracted_archives $my_xlib_u"
2638 my_xdir="$my_gentop/$my_xlib_u"
2639
2640 func_mkdir_p "$my_xdir"
2641
2642 case $host in
2643 *-darwin*)
2644 func_verbose "Extracting $my_xabs"
2645 # Do not bother doing anything if just a dry run
2646 $opt_dry_run || {
2647 darwin_orig_dir=`pwd`
2648 cd $my_xdir || exit $?
2649 darwin_archive=$my_xabs
2650 darwin_curdir=`pwd`
2651 darwin_base_archive=`basename "$darwin_archive"`
2652 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2653 if test -n "$darwin_arches"; then
2654 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2655 darwin_arch=
2656 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2657 for darwin_arch in $darwin_arches ; do
2658 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2659 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2660 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2661 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2662 cd "$darwin_curdir"
2663 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2664 done # $darwin_arches
2665 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2666 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2667 darwin_file=
2668 darwin_files=
2669 for darwin_file in $darwin_filelist; do
2670 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2671 $LIPO -create -output "$darwin_file" $darwin_files
2672 done # $darwin_filelist
2673 $RM -rf unfat-$$
2674 cd "$darwin_orig_dir"
2675 else
2676 cd $darwin_orig_dir
2677 func_extract_an_archive "$my_xdir" "$my_xabs"
2678 fi # $darwin_arches
2679 } # !$opt_dry_run
2680 ;;
2681 *)
2682 func_extract_an_archive "$my_xdir" "$my_xabs"
2683 ;;
2684 esac
2685 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2686 done
2687
2688 func_extract_archives_result="$my_oldobjs"
2689 }
2690
2691
2692
2693 # func_emit_wrapper arg
2694 #
2695 # emit a libtool wrapper script on stdout
2696 # don't directly open a file because we may want to
2697 # incorporate the script contents within a cygwin/mingw
2698 # wrapper executable. Must ONLY be called from within
2699 # func_mode_link because it depends on a number of variable
2700 # set therein.
2701 #
2702 # arg is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2703 # variable will take. If 'yes', then the emitted script
2704 # will assume that the directory in which it is stored is
2705 # the '.lib' directory. This is a cygwin/mingw-specific
2706 # behavior.
2707 func_emit_wrapper ()
2708 {
2709 func_emit_wrapper_arg1=no
2710 if test -n "$1" ; then
2711 func_emit_wrapper_arg1=$1
2712 fi
2713
2714 $ECHO "\
2715 #! $SHELL
2716
2717 # $output - temporary wrapper script for $objdir/$outputname
2718 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2719 #
2720 # The $output program cannot be directly executed until all the libtool
2721 # libraries that it depends on are installed.
2722 #
2723 # This wrapper script should never be moved out of the build directory.
2724 # If it is, it will not operate correctly.
2725
2726 # Sed substitution that helps us do robust quoting. It backslashifies
2727 # metacharacters that are still active within double-quoted strings.
2728 Xsed='${SED} -e 1s/^X//'
2729 sed_quote_subst='$sed_quote_subst'
2730
2731 # Be Bourne compatible
2732 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2733 emulate sh
2734 NULLCMD=:
2735 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2736 # is contrary to our usage. Disable this feature.
2737 alias -g '\${1+\"\$@\"}'='\"\$@\"'
2738 setopt NO_GLOB_SUBST
2739 else
2740 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2741 fi
2742 BIN_SH=xpg4; export BIN_SH # for Tru64
2743 DUALCASE=1; export DUALCASE # for MKS sh
2744
2745 # The HP-UX ksh and POSIX shell print the target directory to stdout
2746 # if CDPATH is set.
2747 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2748
2749 relink_command=\"$relink_command\"
2750
2751 # This environment variable determines our operation mode.
2752 if test \"\$libtool_install_magic\" = \"$magic\"; then
2753 # install mode needs the following variables:
2754 generated_by_libtool_version='$macro_version'
2755 notinst_deplibs='$notinst_deplibs'
2756 else
2757 # When we are sourced in execute mode, \$file and \$ECHO are already set.
2758 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2759 ECHO=\"$qecho\"
2760 file=\"\$0\"
2761 # Make sure echo works.
2762 if test \"X\$1\" = X--no-reexec; then
2763 # Discard the --no-reexec flag, and continue.
2764 shift
2765 elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2766 # Yippee, \$ECHO works!
2767 :
2768 else
2769 # Restart under the correct shell, and then maybe \$ECHO will work.
2770 exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2771 fi
2772 fi\
2773 "
2774 $ECHO "\
2775
2776 # Find the directory that this script lives in.
2777 thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2778 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2779
2780 # Follow symbolic links until we get to the real thisdir.
2781 file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2782 while test -n \"\$file\"; do
2783 destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2784
2785 # If there was a directory component, then change thisdir.
2786 if test \"x\$destdir\" != \"x\$file\"; then
2787 case \"\$destdir\" in
2788 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2789 *) thisdir=\"\$thisdir/\$destdir\" ;;
2790 esac
2791 fi
2792
2793 file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2794 file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2795 done
2796
2797 # Usually 'no', except on cygwin/mingw when embedded into
2798 # the cwrapper.
2799 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
2800 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2801 # special case for '.'
2802 if test \"\$thisdir\" = \".\"; then
2803 thisdir=\`pwd\`
2804 fi
2805 # remove .libs from thisdir
2806 case \"\$thisdir\" in
2807 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2808 $objdir ) thisdir=. ;;
2809 esac
2810 fi
2811
2812 # Try to get the absolute directory name.
2813 absdir=\`cd \"\$thisdir\" && pwd\`
2814 test -n \"\$absdir\" && thisdir=\"\$absdir\"
2815 "
2816
2817 if test "$fast_install" = yes; then
2818 $ECHO "\
2819 program=lt-'$outputname'$exeext
2820 progdir=\"\$thisdir/$objdir\"
2821
2822 if test ! -f \"\$progdir/\$program\" ||
2823 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2824 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2825
2826 file=\"\$\$-\$program\"
2827
2828 if test ! -d \"\$progdir\"; then
2829 $MKDIR \"\$progdir\"
2830 else
2831 $RM \"\$progdir/\$file\"
2832 fi"
2833
2834 $ECHO "\
2835
2836 # relink executable if necessary
2837 if test -n \"\$relink_command\"; then
2838 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2839 else
2840 $ECHO \"\$relink_command_output\" >&2
2841 $RM \"\$progdir/\$file\"
2842 exit 1
2843 fi
2844 fi
2845
2846 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2847 { $RM \"\$progdir/\$program\";
2848 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2849 $RM \"\$progdir/\$file\"
2850 fi"
2851 else
2852 $ECHO "\
2853 program='$outputname'
2854 progdir=\"\$thisdir/$objdir\"
2855 "
2856 fi
2857
2858 $ECHO "\
2859
2860 if test -f \"\$progdir/\$program\"; then"
2861
2862 # Export our shlibpath_var if we have one.
2863 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2864 $ECHO "\
2865 # Add our own library path to $shlibpath_var
2866 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2867
2868 # Some systems cannot cope with colon-terminated $shlibpath_var
2869 # The second colon is a workaround for a bug in BeOS R4 sed
2870 $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2871
2872 export $shlibpath_var
2873 "
2874 fi
2875
2876 # fixup the dll searchpath if we need to.
2877 if test -n "$dllsearchpath"; then
2878 $ECHO "\
2879 # Add the dll search path components to the executable PATH
2880 PATH=$dllsearchpath:\$PATH
2881 "
2882 fi
2883
2884 $ECHO "\
2885 if test \"\$libtool_execute_magic\" != \"$magic\"; then
2886 # Run the actual program with our arguments.
2887 "
2888 case $host in
2889 # Backslashes separate directories on plain windows
2890 *-*-mingw | *-*-os2*)
2891 $ECHO "\
2892 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2893 "
2894 ;;
2895
2896 *)
2897 $ECHO "\
2898 exec \"\$progdir/\$program\" \${1+\"\$@\"}
2899 "
2900 ;;
2901 esac
2902 $ECHO "\
2903 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2904 exit 1
2905 fi
2906 else
2907 # The program doesn't exist.
2908 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2909 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2910 $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2911 exit 1
2912 fi
2913 fi\
2914 "
2915 }
2916 # end: func_emit_wrapper
2917
2918 # func_emit_cwrapperexe_src
2919 # emit the source code for a wrapper executable on stdout
2920 # Must ONLY be called from within func_mode_link because
2921 # it depends on a number of variable set therein.
2922 func_emit_cwrapperexe_src ()
2923 {
2924 cat <<EOF
2925
2926 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
2927 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2928
2929 The $output program cannot be directly executed until all the libtool
2930 libraries that it depends on are installed.
2931
2932 This wrapper executable should never be moved out of the build directory.
2933 If it is, it will not operate correctly.
2934
2935 Currently, it simply execs the wrapper *script* "$SHELL $output",
2936 but could eventually absorb all of the scripts functionality and
2937 exec $objdir/$outputname directly.
2938 */
2939 EOF
2940 cat <<"EOF"
2941 #include <stdio.h>
2942 #include <stdlib.h>
2943 #ifdef _MSC_VER
2944 # include <direct.h>
2945 # include <process.h>
2946 # include <io.h>
2947 # define setmode _setmode
2948 #else
2949 # include <unistd.h>
2950 # include <stdint.h>
2951 # ifdef __CYGWIN__
2952 # include <io.h>
2953 # endif
2954 #endif
2955 #include <malloc.h>
2956 #include <stdarg.h>
2957 #include <assert.h>
2958 #include <string.h>
2959 #include <ctype.h>
2960 #include <errno.h>
2961 #include <fcntl.h>
2962 #include <sys/stat.h>
2963
2964 #if defined(PATH_MAX)
2965 # define LT_PATHMAX PATH_MAX
2966 #elif defined(MAXPATHLEN)
2967 # define LT_PATHMAX MAXPATHLEN
2968 #else
2969 # define LT_PATHMAX 1024
2970 #endif
2971
2972 #ifndef S_IXOTH
2973 # define S_IXOTH 0
2974 #endif
2975 #ifndef S_IXGRP
2976 # define S_IXGRP 0
2977 #endif
2978
2979 #ifdef _MSC_VER
2980 # define S_IXUSR _S_IEXEC
2981 # define stat _stat
2982 # ifndef _INTPTR_T_DEFINED
2983 # define intptr_t int
2984 # endif
2985 #endif
2986
2987 #ifndef DIR_SEPARATOR
2988 # define DIR_SEPARATOR '/'
2989 # define PATH_SEPARATOR ':'
2990 #endif
2991
2992 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
2993 defined (__OS2__)
2994 # define HAVE_DOS_BASED_FILE_SYSTEM
2995 # define FOPEN_WB "wb"
2996 # ifndef DIR_SEPARATOR_2
2997 # define DIR_SEPARATOR_2 '\\'
2998 # endif
2999 # ifndef PATH_SEPARATOR_2
3000 # define PATH_SEPARATOR_2 ';'
3001 # endif
3002 #endif
3003
3004 #ifndef DIR_SEPARATOR_2
3005 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3006 #else /* DIR_SEPARATOR_2 */
3007 # define IS_DIR_SEPARATOR(ch) \
3008 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3009 #endif /* DIR_SEPARATOR_2 */
3010
3011 #ifndef PATH_SEPARATOR_2
3012 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3013 #else /* PATH_SEPARATOR_2 */
3014 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3015 #endif /* PATH_SEPARATOR_2 */
3016
3017 #ifdef __CYGWIN__
3018 # define FOPEN_WB "wb"
3019 #endif
3020
3021 #ifndef FOPEN_WB
3022 # define FOPEN_WB "w"
3023 #endif
3024 #ifndef _O_BINARY
3025 # define _O_BINARY 0
3026 #endif
3027
3028 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
3029 #define XFREE(stale) do { \
3030 if (stale) { free ((void *) stale); stale = 0; } \
3031 } while (0)
3032
3033 #undef LTWRAPPER_DEBUGPRINTF
3034 #if defined DEBUGWRAPPER
3035 # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3036 static void
3037 ltwrapper_debugprintf (const char *fmt, ...)
3038 {
3039 va_list args;
3040 va_start (args, fmt);
3041 (void) vfprintf (stderr, fmt, args);
3042 va_end (args);
3043 }
3044 #else
3045 # define LTWRAPPER_DEBUGPRINTF(args)
3046 #endif
3047
3048 const char *program_name = NULL;
3049
3050 void *xmalloc (size_t num);
3051 char *xstrdup (const char *string);
3052 const char *base_name (const char *name);
3053 char *find_executable (const char *wrapper);
3054 char *chase_symlinks (const char *pathspec);
3055 int make_executable (const char *path);
3056 int check_executable (const char *path);
3057 char *strendzap (char *str, const char *pat);
3058 void lt_fatal (const char *message, ...);
3059
3060 static const char *script_text =
3061 EOF
3062
3063 func_emit_wrapper yes |
3064 $SED -e 's/\([\\"]\)/\\\1/g' \
3065 -e 's/^/ "/' -e 's/$/\\n"/'
3066 echo ";"
3067
3068 cat <<EOF
3069 const char * MAGIC_EXE = "$magic_exe";
3070
3071 int
3072 main (int argc, char *argv[])
3073 {
3074 char **newargz;
3075 char *tmp_pathspec;
3076 char *actual_cwrapper_path;
3077 char *shwrapper_name;
3078 intptr_t rval = 127;
3079 FILE *shwrapper;
3080
3081 const char *dumpscript_opt = "--lt-dump-script";
3082 int i;
3083
3084 program_name = (char *) xstrdup (base_name (argv[0]));
3085 LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
3086 LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3087
3088 /* very simple arg parsing; don't want to rely on getopt */
3089 for (i = 1; i < argc; i++)
3090 {
3091 if (strcmp (argv[i], dumpscript_opt) == 0)
3092 {
3093 EOF
3094 case "$host" in
3095 *mingw* | *cygwin* )
3096 # make stdout use "unix" line endings
3097 echo " setmode(1,_O_BINARY);"
3098 ;;
3099 esac
3100
3101 cat <<EOF
3102 printf ("%s", script_text);
3103 return 0;
3104 }
3105 }
3106
3107 newargz = XMALLOC (char *, argc + 2);
3108 EOF
3109
3110 if test -n "$TARGETSHELL" ; then
3111 # no path translation at all
3112 lt_newargv0=$TARGETSHELL
3113 else
3114 case "$host" in
3115 *mingw* )
3116 # awkward: cmd appends spaces to result
3117 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3118 lt_newargv0=`( cmd //c echo $SHELL | $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo $SHELL`
3119 case $lt_newargv0 in
3120 *.exe | *.EXE) ;;
3121 *) lt_newargv0=$lt_newargv0.exe ;;
3122 esac
3123 ;;
3124 * ) lt_newargv0=$SHELL ;;
3125 esac
3126 fi
3127
3128 cat <<EOF
3129 newargz[0] = (char *) xstrdup ("$lt_newargv0");
3130 EOF
3131
3132 cat <<"EOF"
3133 tmp_pathspec = find_executable (argv[0]);
3134 if (tmp_pathspec == NULL)
3135 lt_fatal ("Couldn't find %s", argv[0]);
3136 LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3137 tmp_pathspec));
3138
3139 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3140 LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3141 actual_cwrapper_path));
3142 XFREE (tmp_pathspec);
3143
3144 shwrapper_name = (char *) xstrdup (base_name (actual_cwrapper_path));
3145 strendzap (actual_cwrapper_path, shwrapper_name);
3146
3147 /* shwrapper_name transforms */
3148 strendzap (shwrapper_name, ".exe");
3149 tmp_pathspec = XMALLOC (char, (strlen (shwrapper_name) +
3150 strlen ("_ltshwrapperTMP") + 1));
3151 strcpy (tmp_pathspec, shwrapper_name);
3152 strcat (tmp_pathspec, "_ltshwrapperTMP");
3153 XFREE (shwrapper_name);
3154 shwrapper_name = tmp_pathspec;
3155 tmp_pathspec = 0;
3156 LTWRAPPER_DEBUGPRINTF (("(main) libtool shell wrapper name: %s\n",
3157 shwrapper_name));
3158 EOF
3159
3160 cat <<EOF
3161 newargz[1] =
3162 XMALLOC (char, (strlen (actual_cwrapper_path) +
3163 strlen ("$objdir") + 1 + strlen (shwrapper_name) + 1));
3164 strcpy (newargz[1], actual_cwrapper_path);
3165 strcat (newargz[1], "$objdir");
3166 strcat (newargz[1], "/");
3167 strcat (newargz[1], shwrapper_name);
3168 EOF
3169
3170
3171 case $host_os in
3172 mingw*)
3173 cat <<"EOF"
3174 {
3175 char* p;
3176 while ((p = strchr (newargz[1], '\\')) != NULL)
3177 {
3178 *p = '/';
3179 }
3180 }
3181 EOF
3182 ;;
3183 esac
3184
3185 cat <<"EOF"
3186 XFREE (shwrapper_name);
3187 XFREE (actual_cwrapper_path);
3188
3189 /* always write in binary mode */
3190 if ((shwrapper = fopen (newargz[1], FOPEN_WB)) == 0)
3191 {
3192 lt_fatal ("Could not open %s for writing", newargz[1]);
3193 }
3194 fprintf (shwrapper, "%s", script_text);
3195 fclose (shwrapper);
3196
3197 make_executable (newargz[1]);
3198
3199 for (i = 1; i < argc; i++)
3200 newargz[i + 1] = xstrdup (argv[i]);
3201 newargz[argc + 1] = NULL;
3202
3203 for (i = 0; i < argc + 1; i++)
3204 {
3205 LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, newargz[i]));
3206 }
3207
3208 EOF
3209
3210 case $host_os in
3211 mingw*)
3212 cat <<EOF
3213 /* execv doesn't actually work on mingw as expected on unix */
3214 rval = _spawnv (_P_WAIT, "$lt_newargv0", (const char * const *) newargz);
3215 if (rval == -1)
3216 {
3217 /* failed to start process */
3218 LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"$lt_newargv0\": errno = %d\n", errno));
3219 return 127;
3220 }
3221 return rval;
3222 }
3223 EOF
3224 ;;
3225 *)
3226 cat <<EOF
3227 execv ("$lt_newargv0", newargz);
3228 return rval; /* =127, but avoids unused variable warning */
3229 }
3230 EOF
3231 ;;
3232 esac
3233
3234 cat <<"EOF"
3235
3236 void *
3237 xmalloc (size_t num)
3238 {
3239 void *p = (void *) malloc (num);
3240 if (!p)
3241 lt_fatal ("Memory exhausted");
3242
3243 return p;
3244 }
3245
3246 char *
3247 xstrdup (const char *string)
3248 {
3249 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3250 string) : NULL;
3251 }
3252
3253 const char *
3254 base_name (const char *name)
3255 {
3256 const char *base;
3257
3258 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3259 /* Skip over the disk name in MSDOS pathnames. */
3260 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3261 name += 2;
3262 #endif
3263
3264 for (base = name; *name; name++)
3265 if (IS_DIR_SEPARATOR (*name))
3266 base = name + 1;
3267 return base;
3268 }
3269
3270 int
3271 check_executable (const char *path)
3272 {
3273 struct stat st;
3274
3275 LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
3276 path ? (*path ? path : "EMPTY!") : "NULL!"));
3277 if ((!path) || (!*path))
3278 return 0;
3279
3280 if ((stat (path, &st) >= 0)
3281 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3282 return 1;
3283 else
3284 return 0;
3285 }
3286
3287 int
3288 make_executable (const char *path)
3289 {
3290 int rval = 0;
3291 struct stat st;
3292
3293 LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
3294 path ? (*path ? path : "EMPTY!") : "NULL!"));
3295 if ((!path) || (!*path))
3296 return 0;
3297
3298 if (stat (path, &st) >= 0)
3299 {
3300 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3301 }
3302 return rval;
3303 }
3304
3305 /* Searches for the full path of the wrapper. Returns
3306 newly allocated full path name if found, NULL otherwise
3307 Does not chase symlinks, even on platforms that support them.
3308 */
3309 char *
3310 find_executable (const char *wrapper)
3311 {
3312 int has_slash = 0;
3313 const char *p;
3314 const char *p_next;
3315 /* static buffer for getcwd */
3316 char tmp[LT_PATHMAX + 1];
3317 int tmp_len;
3318 char *concat_name;
3319
3320 LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
3321 wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3322
3323 if ((wrapper == NULL) || (*wrapper == '\0'))
3324 return NULL;
3325
3326 /* Absolute path? */
3327 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3328 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3329 {
3330 concat_name = xstrdup (wrapper);
3331 if (check_executable (concat_name))
3332 return concat_name;
3333 XFREE (concat_name);
3334 }
3335 else
3336 {
3337 #endif
3338 if (IS_DIR_SEPARATOR (wrapper[0]))
3339 {
3340 concat_name = xstrdup (wrapper);
3341 if (check_executable (concat_name))
3342 return concat_name;
3343 XFREE (concat_name);
3344 }
3345 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3346 }
3347 #endif
3348
3349 for (p = wrapper; *p; p++)
3350 if (*p == '/')
3351 {
3352 has_slash = 1;
3353 break;
3354 }
3355 if (!has_slash)
3356 {
3357 /* no slashes; search PATH */
3358 const char *path = getenv ("PATH");
3359 if (path != NULL)
3360 {
3361 for (p = path; *p; p = p_next)
3362 {
3363 const char *q;
3364 size_t p_len;
3365 for (q = p; *q; q++)
3366 if (IS_PATH_SEPARATOR (*q))
3367 break;
3368 p_len = q - p;
3369 p_next = (*q == '\0' ? q : q + 1);
3370 if (p_len == 0)
3371 {
3372 /* empty path: current directory */
3373 if (getcwd (tmp, LT_PATHMAX) == NULL)
3374 lt_fatal ("getcwd failed");
3375 tmp_len = strlen (tmp);
3376 concat_name =
3377 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3378 memcpy (concat_name, tmp, tmp_len);
3379 concat_name[tmp_len] = '/';
3380 strcpy (concat_name + tmp_len + 1, wrapper);
3381 }
3382 else
3383 {
3384 concat_name =
3385 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3386 memcpy (concat_name, p, p_len);
3387 concat_name[p_len] = '/';
3388 strcpy (concat_name + p_len + 1, wrapper);
3389 }
3390 if (check_executable (concat_name))
3391 return concat_name;
3392 XFREE (concat_name);
3393 }
3394 }
3395 /* not found in PATH; assume curdir */
3396 }
3397 /* Relative path | not found in path: prepend cwd */
3398 if (getcwd (tmp, LT_PATHMAX) == NULL)
3399 lt_fatal ("getcwd failed");
3400 tmp_len = strlen (tmp);
3401 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3402 memcpy (concat_name, tmp, tmp_len);
3403 concat_name[tmp_len] = '/';
3404 strcpy (concat_name + tmp_len + 1, wrapper);
3405
3406 if (check_executable (concat_name))
3407 return concat_name;
3408 XFREE (concat_name);
3409 return NULL;
3410 }
3411
3412 char *
3413 chase_symlinks (const char *pathspec)
3414 {
3415 #ifndef S_ISLNK
3416 return xstrdup (pathspec);
3417 #else
3418 char buf[LT_PATHMAX];
3419 struct stat s;
3420 char *tmp_pathspec = xstrdup (pathspec);
3421 char *p;
3422 int has_symlinks = 0;
3423 while (strlen (tmp_pathspec) && !has_symlinks)
3424 {
3425 LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3426 tmp_pathspec));
3427 if (lstat (tmp_pathspec, &s) == 0)
3428 {
3429 if (S_ISLNK (s.st_mode) != 0)
3430 {
3431 has_symlinks = 1;
3432 break;
3433 }
3434
3435 /* search backwards for last DIR_SEPARATOR */
3436 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3437 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3438 p--;
3439 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3440 {
3441 /* no more DIR_SEPARATORS left */
3442 break;
3443 }
3444 *p = '\0';
3445 }
3446 else
3447 {
3448 char *errstr = strerror (errno);
3449 lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3450 }
3451 }
3452 XFREE (tmp_pathspec);
3453
3454 if (!has_symlinks)
3455 {
3456 return xstrdup (pathspec);
3457 }
3458
3459 tmp_pathspec = realpath (pathspec, buf);
3460 if (tmp_pathspec == 0)
3461 {
3462 lt_fatal ("Could not follow symlinks for %s", pathspec);
3463 }
3464 return xstrdup (tmp_pathspec);
3465 #endif
3466 }
3467
3468 char *
3469 strendzap (char *str, const char *pat)
3470 {
3471 size_t len, patlen;
3472
3473 assert (str != NULL);
3474 assert (pat != NULL);
3475
3476 len = strlen (str);
3477 patlen = strlen (pat);
3478
3479 if (patlen <= len)
3480 {
3481 str += len - patlen;
3482 if (strcmp (str, pat) == 0)
3483 *str = '\0';
3484 }
3485 return str;
3486 }
3487
3488 static void
3489 lt_error_core (int exit_status, const char *mode,
3490 const char *message, va_list ap)
3491 {
3492 fprintf (stderr, "%s: %s: ", program_name, mode);
3493 vfprintf (stderr, message, ap);
3494 fprintf (stderr, ".\n");
3495
3496 if (exit_status >= 0)
3497 exit (exit_status);
3498 }
3499
3500 void
3501 lt_fatal (const char *message, ...)
3502 {
3503 va_list ap;
3504 va_start (ap, message);
3505 lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3506 va_end (ap);
3507 }
3508 EOF
3509 }
3510 # end: func_emit_cwrapperexe_src
3511
3512 # func_mode_link arg...
3513 func_mode_link ()
3514 {
3515 $opt_debug
3516 case $host in
3517 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
3518 # It is impossible to link a dll without this setting, and
3519 # we shouldn't force the makefile maintainer to figure out
3520 # which system we are compiling for in order to pass an extra
3521 # flag for every libtool invocation.
3522 # allow_undefined=no
3523
3524 # FIXME: Unfortunately, there are problems with the above when trying
3525 # to make a dll which has undefined symbols, in which case not
3526 # even a static library is built. For now, we need to specify
3527 # -no-undefined on the libtool link line when we can be certain
3528 # that all symbols are satisfied, otherwise we get a static library.
3529 allow_undefined=yes
3530 ;;
3531 *)
3532 allow_undefined=yes
3533 ;;
3534 esac
3535 libtool_args=$nonopt
3536 base_compile="$nonopt $@"
3537 compile_command=$nonopt
3538 finalize_command=$nonopt
3539
3540 compile_rpath=
3541 finalize_rpath=
3542 compile_shlibpath=
3543 finalize_shlibpath=
3544 convenience=
3545 old_convenience=
3546 deplibs=
3547 old_deplibs=
3548 compiler_flags=
3549 linker_flags=
3550 dllsearchpath=
3551 lib_search_path=`pwd`
3552 inst_prefix_dir=
3553 new_inherited_linker_flags=
3554
3555 avoid_version=no
3556 dlfiles=
3557 dlprefiles=
3558 dlself=no
3559 export_dynamic=no
3560 export_symbols=
3561 export_symbols_regex=
3562 generated=
3563 libobjs=
3564 ltlibs=
3565 module=no
3566 no_install=no
3567 objs=
3568 non_pic_objects=
3569 precious_files_regex=
3570 prefer_static_libs=no
3571 preload=no
3572 prev=
3573 prevarg=
3574 release=
3575 rpath=
3576 xrpath=
3577 perm_rpath=
3578 temp_rpath=
3579 thread_safe=no
3580 vinfo=
3581 vinfo_number=no
3582 weak_libs=
3583 single_module="${wl}-single_module"
3584 func_infer_tag $base_compile
3585
3586 # We need to know -static, to get the right output filenames.
3587 for arg
3588 do
3589 case $arg in
3590 -shared)
3591 test "$build_libtool_libs" != yes && \
3592 func_fatal_configuration "can not build a shared library"
3593 build_old_libs=no
3594 break
3595 ;;
3596 -all-static | -static | -static-libtool-libs)
3597 case $arg in
3598 -all-static)
3599 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
3600 func_warning "complete static linking is impossible in this configuration"
3601 fi
3602 if test -n "$link_static_flag"; then
3603 dlopen_self=$dlopen_self_static
3604 fi
3605 prefer_static_libs=yes
3606 ;;
3607 -static)
3608 if test -z "$pic_flag" && test -n "$link_static_flag"; then
3609 dlopen_self=$dlopen_self_static
3610 fi
3611 prefer_static_libs=built
3612 ;;
3613 -static-libtool-libs)
3614 if test -z "$pic_flag" && test -n "$link_static_flag"; then
3615 dlopen_self=$dlopen_self_static
3616 fi
3617 prefer_static_libs=yes
3618 ;;
3619 esac
3620 build_libtool_libs=no
3621 build_old_libs=yes
3622 break
3623 ;;
3624 esac
3625 done
3626
3627 # See if our shared archives depend on static archives.
3628 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
3629
3630 # Go through the arguments, transforming them on the way.
3631 while test "$#" -gt 0; do
3632 arg="$1"
3633 shift
3634 func_quote_for_eval "$arg"
3635 qarg=$func_quote_for_eval_unquoted_result
3636 func_append libtool_args " $func_quote_for_eval_result"
3637
3638 # If the previous option needs an argument, assign it.
3639 if test -n "$prev"; then
3640 case $prev in
3641 output)
3642 func_append compile_command " @OUTPUT@"
3643 func_append finalize_command " @OUTPUT@"
3644 ;;
3645 esac
3646
3647 case $prev in
3648 dlfiles|dlprefiles)
3649 if test "$preload" = no; then
3650 # Add the symbol object into the linking commands.
3651 func_append compile_command " @SYMFILE@"
3652 func_append finalize_command " @SYMFILE@"
3653 preload=yes
3654 fi
3655 case $arg in
3656 *.la | *.lo) ;; # We handle these cases below.
3657 force)
3658 if test "$dlself" = no; then
3659 dlself=needless
3660 export_dynamic=yes
3661 fi
3662 prev=
3663 continue
3664 ;;
3665 self)
3666 if test "$prev" = dlprefiles; then
3667 dlself=yes
3668 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
3669 dlself=yes
3670 else
3671 dlself=needless
3672 export_dynamic=yes
3673 fi
3674 prev=
3675 continue
3676 ;;
3677 *)
3678 if test "$prev" = dlfiles; then
3679 dlfiles="$dlfiles $arg"
3680 else
3681 dlprefiles="$dlprefiles $arg"
3682 fi
3683 prev=
3684 continue
3685 ;;
3686 esac
3687 ;;
3688 expsyms)
3689 export_symbols="$arg"
3690 test -f "$arg" \
3691 || func_fatal_error "symbol file \`$arg' does not exist"
3692 prev=
3693 continue
3694 ;;
3695 expsyms_regex)
3696 export_symbols_regex="$arg"
3697 prev=
3698 continue
3699 ;;
3700 framework)
3701 case $host in
3702 *-*-darwin*)
3703 case "$deplibs " in
3704 *" $qarg.ltframework "*) ;;
3705 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
3706 ;;
3707 esac
3708 ;;
3709 esac
3710 prev=
3711 continue
3712 ;;
3713 inst_prefix)
3714 inst_prefix_dir="$arg"
3715 prev=
3716 continue
3717 ;;
3718 objectlist)
3719 if test -f "$arg"; then
3720 save_arg=$arg
3721 moreargs=
3722 for fil in `cat "$save_arg"`
3723 do
3724 # moreargs="$moreargs $fil"
3725 arg=$fil
3726 # A libtool-controlled object.
3727
3728 # Check to see that this really is a libtool object.
3729 if func_lalib_unsafe_p "$arg"; then
3730 pic_object=
3731 non_pic_object=
3732
3733 # Read the .lo file
3734 func_source "$arg"
3735
3736 if test -z "$pic_object" ||
3737 test -z "$non_pic_object" ||
3738 test "$pic_object" = none &&
3739 test "$non_pic_object" = none; then
3740 func_fatal_error "cannot find name of object for \`$arg'"
3741 fi
3742
3743 # Extract subdirectory from the argument.
3744 func_dirname "$arg" "/" ""
3745 xdir="$func_dirname_result"
3746
3747 if test "$pic_object" != none; then
3748 # Prepend the subdirectory the object is found in.
3749 pic_object="$xdir$pic_object"
3750
3751 if test "$prev" = dlfiles; then
3752 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
3753 dlfiles="$dlfiles $pic_object"
3754 prev=
3755 continue
3756 else
3757 # If libtool objects are unsupported, then we need to preload.
3758 prev=dlprefiles
3759 fi
3760 fi
3761
3762 # CHECK ME: I think I busted this. -Ossama
3763 if test "$prev" = dlprefiles; then
3764 # Preload the old-style object.
3765 dlprefiles="$dlprefiles $pic_object"
3766 prev=
3767 fi
3768
3769 # A PIC object.
3770 func_append libobjs " $pic_object"
3771 arg="$pic_object"
3772 fi
3773
3774 # Non-PIC object.
3775 if test "$non_pic_object" != none; then
3776 # Prepend the subdirectory the object is found in.
3777 non_pic_object="$xdir$non_pic_object"
3778
3779 # A standard non-PIC object
3780 func_append non_pic_objects " $non_pic_object"
3781 if test -z "$pic_object" || test "$pic_object" = none ; then
3782 arg="$non_pic_object"
3783 fi
3784 else
3785 # If the PIC object exists, use it instead.
3786 # $xdir was prepended to $pic_object above.
3787 non_pic_object="$pic_object"
3788 func_append non_pic_objects " $non_pic_object"
3789 fi
3790 else
3791 # Only an error if not doing a dry-run.
3792 if $opt_dry_run; then
3793 # Extract subdirectory from the argument.
3794 func_dirname "$arg" "/" ""
3795 xdir="$func_dirname_result"
3796
3797 func_lo2o "$arg"
3798 pic_object=$xdir$objdir/$func_lo2o_result
3799 non_pic_object=$xdir$func_lo2o_result
3800 func_append libobjs " $pic_object"
3801 func_append non_pic_objects " $non_pic_object"
3802 else
3803 func_fatal_error "\`$arg' is not a valid libtool object"
3804 fi
3805 fi
3806 done
3807 else
3808 func_fatal_error "link input file \`$arg' does not exist"
3809 fi
3810 arg=$save_arg
3811 prev=
3812 continue
3813 ;;
3814 precious_regex)
3815 precious_files_regex="$arg"
3816 prev=
3817 continue
3818 ;;
3819 release)
3820 release="-$arg"
3821 prev=
3822 continue
3823 ;;
3824 rpath | xrpath)
3825 # We need an absolute path.
3826 case $arg in
3827 [\\/]* | [A-Za-z]:[\\/]*) ;;
3828 *)
3829 func_fatal_error "only absolute run-paths are allowed"
3830 ;;
3831 esac
3832 if test "$prev" = rpath; then
3833 case "$rpath " in
3834 *" $arg "*) ;;
3835 *) rpath="$rpath $arg" ;;
3836 esac
3837 else
3838 case "$xrpath " in
3839 *" $arg "*) ;;
3840 *) xrpath="$xrpath $arg" ;;
3841 esac
3842 fi
3843 prev=
3844 continue
3845 ;;
3846 shrext)
3847 shrext_cmds="$arg"
3848 prev=
3849 continue
3850 ;;
3851 weak)
3852 weak_libs="$weak_libs $arg"
3853 prev=
3854 continue
3855 ;;
3856 xcclinker)
3857 linker_flags="$linker_flags $qarg"
3858 compiler_flags="$compiler_flags $qarg"
3859 prev=
3860 func_append compile_command " $qarg"
3861 func_append finalize_command " $qarg"
3862 continue
3863 ;;
3864 xcompiler)
3865 compiler_flags="$compiler_flags $qarg"
3866 prev=
3867 func_append compile_command " $qarg"
3868 func_append finalize_command " $qarg"
3869 continue
3870 ;;
3871 xlinker)
3872 linker_flags="$linker_flags $qarg"
3873 compiler_flags="$compiler_flags $wl$qarg"
3874 prev=
3875 func_append compile_command " $wl$qarg"
3876 func_append finalize_command " $wl$qarg"
3877 continue
3878 ;;
3879 *)
3880 eval "$prev=\"\$arg\""
3881 prev=
3882 continue
3883 ;;
3884 esac
3885 fi # test -n "$prev"
3886
3887 prevarg="$arg"
3888
3889 case $arg in
3890 -all-static)
3891 if test -n "$link_static_flag"; then
3892 # See comment for -static flag below, for more details.
3893 func_append compile_command " $link_static_flag"
3894 func_append finalize_command " $link_static_flag"
3895 fi
3896 continue
3897 ;;
3898
3899 -allow-undefined)
3900 # FIXME: remove this flag sometime in the future.
3901 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
3902 ;;
3903
3904 -avoid-version)
3905 avoid_version=yes
3906 continue
3907 ;;
3908
3909 -dlopen)
3910 prev=dlfiles
3911 continue
3912 ;;
3913
3914 -dlpreopen)
3915 prev=dlprefiles
3916 continue
3917 ;;
3918
3919 -export-dynamic)
3920 export_dynamic=yes
3921 continue
3922 ;;
3923
3924 -export-symbols | -export-symbols-regex)
3925 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
3926 func_fatal_error "more than one -exported-symbols argument is not allowed"
3927 fi
3928 if test "X$arg" = "X-export-symbols"; then
3929 prev=expsyms
3930 else
3931 prev=expsyms_regex
3932 fi
3933 continue
3934 ;;
3935
3936 -framework)
3937 prev=framework
3938 continue
3939 ;;
3940
3941 -inst-prefix-dir)
3942 prev=inst_prefix
3943 continue
3944 ;;
3945
3946 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
3947 # so, if we see these flags be careful not to treat them like -L
3948 -L[A-Z][A-Z]*:*)
3949 case $with_gcc/$host in
3950 no/*-*-irix* | /*-*-irix*)
3951 func_append compile_command " $arg"
3952 func_append finalize_command " $arg"
3953 ;;
3954 esac
3955 continue
3956 ;;
3957
3958 -L*)
3959 func_stripname '-L' '' "$arg"
3960 dir=$func_stripname_result
3961 # We need an absolute path.
3962 case $dir in
3963 [\\/]* | [A-Za-z]:[\\/]*) ;;
3964 *)
3965 absdir=`cd "$dir" && pwd`
3966 test -z "$absdir" && \
3967 func_fatal_error "cannot determine absolute directory name of \`$dir'"
3968 dir="$absdir"
3969 ;;
3970 esac
3971 case "$deplibs " in
3972 *" -L$dir "*) ;;
3973 *)
3974 deplibs="$deplibs -L$dir"
3975 lib_search_path="$lib_search_path $dir"
3976 ;;
3977 esac
3978 case $host in
3979 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
3980 testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
3981 case :$dllsearchpath: in
3982 *":$dir:"*) ;;
3983 *) dllsearchpath="$dllsearchpath:$dir";;
3984 esac
3985 case :$dllsearchpath: in
3986 *":$testbindir:"*) ;;
3987 *) dllsearchpath="$dllsearchpath:$testbindir";;
3988 esac
3989 ;;
3990 esac
3991 continue
3992 ;;
3993
3994 -l*)
3995 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
3996 case $host in
3997 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
3998 # These systems don't actually have a C or math library (as such)
3999 continue
4000 ;;
4001 *-*-os2*)
4002 # These systems don't actually have a C library (as such)
4003 test "X$arg" = "X-lc" && continue
4004 ;;
4005 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4006 # Do not include libc due to us having libc/libc_r.
4007 test "X$arg" = "X-lc" && continue
4008 ;;
4009 *-*-rhapsody* | *-*-darwin1.[012])
4010 # Rhapsody C and math libraries are in the System framework
4011 deplibs="$deplibs System.ltframework"
4012 continue
4013 ;;
4014 *-*-sco3.2v5* | *-*-sco5v6*)
4015 # Causes problems with __ctype
4016 test "X$arg" = "X-lc" && continue
4017 ;;
4018 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4019 # Compiler inserts libc in the correct place for threads to work
4020 test "X$arg" = "X-lc" && continue
4021 ;;
4022 esac
4023 elif test "X$arg" = "X-lc_r"; then
4024 case $host in
4025 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4026 # Do not include libc_r directly, use -pthread flag.
4027 continue
4028 ;;
4029 esac
4030 fi
4031 deplibs="$deplibs $arg"
4032 continue
4033 ;;
4034
4035 -module)
4036 module=yes
4037 continue
4038 ;;
4039
4040 # Tru64 UNIX uses -model [arg] to determine the layout of C++
4041 # classes, name mangling, and exception handling.
4042 # Darwin uses the -arch flag to determine output architecture.
4043 -model|-arch|-isysroot)
4044 compiler_flags="$compiler_flags $arg"
4045 func_append compile_command " $arg"
4046 func_append finalize_command " $arg"
4047 prev=xcompiler
4048 continue
4049 ;;
4050
4051 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4052 compiler_flags="$compiler_flags $arg"
4053 func_append compile_command " $arg"
4054 func_append finalize_command " $arg"
4055 case "$new_inherited_linker_flags " in
4056 *" $arg "*) ;;
4057 * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4058 esac
4059 continue
4060 ;;
4061
4062 -multi_module)
4063 single_module="${wl}-multi_module"
4064 continue
4065 ;;
4066
4067 -no-fast-install)
4068 fast_install=no
4069 continue
4070 ;;
4071
4072 -no-install)
4073 case $host in
4074 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
4075 # The PATH hackery in wrapper scripts is required on Windows
4076 # and Darwin in order for the loader to find any dlls it needs.
4077 func_warning "\`-no-install' is ignored for $host"
4078 func_warning "assuming \`-no-fast-install' instead"
4079 fast_install=no
4080 ;;
4081 *) no_install=yes ;;
4082 esac
4083 continue
4084 ;;
4085
4086 -no-undefined)
4087 allow_undefined=no
4088 continue
4089 ;;
4090
4091 -objectlist)
4092 prev=objectlist
4093 continue
4094 ;;
4095
4096 -o) prev=output ;;
4097
4098 -precious-files-regex)
4099 prev=precious_regex
4100 continue
4101 ;;
4102
4103 -release)
4104 prev=release
4105 continue
4106 ;;
4107
4108 -rpath)
4109 prev=rpath
4110 continue
4111 ;;
4112
4113 -R)
4114 prev=xrpath
4115 continue
4116 ;;
4117
4118 -R*)
4119 func_stripname '-R' '' "$arg"
4120 dir=$func_stripname_result
4121 # We need an absolute path.
4122 case $dir in
4123 [\\/]* | [A-Za-z]:[\\/]*) ;;
4124 *)
4125 func_fatal_error "only absolute run-paths are allowed"
4126 ;;
4127 esac
4128 case "$xrpath " in
4129 *" $dir "*) ;;
4130 *) xrpath="$xrpath $dir" ;;
4131 esac
4132 continue
4133 ;;
4134
4135 -shared)
4136 # The effects of -shared are defined in a previous loop.
4137 continue
4138 ;;
4139
4140 -shrext)
4141 prev=shrext
4142 continue
4143 ;;
4144
4145 -static | -static-libtool-libs)
4146 # The effects of -static are defined in a previous loop.
4147 # We used to do the same as -all-static on platforms that
4148 # didn't have a PIC flag, but the assumption that the effects
4149 # would be equivalent was wrong. It would break on at least
4150 # Digital Unix and AIX.
4151 continue
4152 ;;
4153
4154 -thread-safe)
4155 thread_safe=yes
4156 continue
4157 ;;
4158
4159 -version-info)
4160 prev=vinfo
4161 continue
4162 ;;
4163
4164 -version-number)
4165 prev=vinfo
4166 vinfo_number=yes
4167 continue
4168 ;;
4169
4170 -weak)
4171 prev=weak
4172 continue
4173 ;;
4174
4175 -Wc,*)
4176 func_stripname '-Wc,' '' "$arg"
4177 args=$func_stripname_result
4178 arg=
4179 save_ifs="$IFS"; IFS=','
4180 for flag in $args; do
4181 IFS="$save_ifs"
4182 func_quote_for_eval "$flag"
4183 arg="$arg $wl$func_quote_for_eval_result"
4184 compiler_flags="$compiler_flags $func_quote_for_eval_result"
4185 done
4186 IFS="$save_ifs"
4187 func_stripname ' ' '' "$arg"
4188 arg=$func_stripname_result
4189 ;;
4190
4191 -Wl,*)
4192 func_stripname '-Wl,' '' "$arg"
4193 args=$func_stripname_result
4194 arg=
4195 save_ifs="$IFS"; IFS=','
4196 for flag in $args; do
4197 IFS="$save_ifs"
4198 func_quote_for_eval "$flag"
4199 arg="$arg $wl$func_quote_for_eval_result"
4200 compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4201 linker_flags="$linker_flags $func_quote_for_eval_result"
4202 done
4203 IFS="$save_ifs"
4204 func_stripname ' ' '' "$arg"
4205 arg=$func_stripname_result
4206 ;;
4207
4208 -Xcompiler)
4209 prev=xcompiler
4210 continue
4211 ;;
4212
4213 -Xlinker)
4214 prev=xlinker
4215 continue
4216 ;;
4217
4218 -XCClinker)
4219 prev=xcclinker
4220 continue
4221 ;;
4222
4223 # -msg_* for osf cc
4224 -msg_*)
4225 func_quote_for_eval "$arg"
4226 arg="$func_quote_for_eval_result"
4227 ;;
4228
4229 # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4230 # -r[0-9][0-9]* specifies the processor on the SGI compiler
4231 # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4232 # +DA*, +DD* enable 64-bit mode on the HP compiler
4233 # -q* pass through compiler args for the IBM compiler
4234 # -m*, -t[45]*, -txscale* pass through architecture-specific
4235 # compiler args for GCC
4236 # -F/path gives path to uninstalled frameworks, gcc on darwin
4237 # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4238 # @file GCC response files
4239 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4240 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4241 func_quote_for_eval "$arg"
4242 arg="$func_quote_for_eval_result"
4243 func_append compile_command " $arg"
4244 func_append finalize_command " $arg"
4245 compiler_flags="$compiler_flags $arg"
4246 continue
4247 ;;
4248
4249 # Some other compiler flag.
4250 -* | +*)
4251 func_quote_for_eval "$arg"
4252 arg="$func_quote_for_eval_result"
4253 ;;
4254
4255 *.$objext)
4256 # A standard object.
4257 objs="$objs $arg"
4258 ;;
4259
4260 *.lo)
4261 # A libtool-controlled object.
4262
4263 # Check to see that this really is a libtool object.
4264 if func_lalib_unsafe_p "$arg"; then
4265 pic_object=
4266 non_pic_object=
4267
4268 # Read the .lo file
4269 func_source "$arg"
4270
4271 if test -z "$pic_object" ||
4272 test -z "$non_pic_object" ||
4273 test "$pic_object" = none &&
4274 test "$non_pic_object" = none; then
4275 func_fatal_error "cannot find name of object for \`$arg'"
4276 fi
4277
4278 # Extract subdirectory from the argument.
4279 func_dirname "$arg" "/" ""
4280 xdir="$func_dirname_result"
4281
4282 if test "$pic_object" != none; then
4283 # Prepend the subdirectory the object is found in.
4284 pic_object="$xdir$pic_object"
4285
4286 if test "$prev" = dlfiles; then
4287 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4288 dlfiles="$dlfiles $pic_object"
4289 prev=
4290 continue
4291 else
4292 # If libtool objects are unsupported, then we need to preload.
4293 prev=dlprefiles
4294 fi
4295 fi
4296
4297 # CHECK ME: I think I busted this. -Ossama
4298 if test "$prev" = dlprefiles; then
4299 # Preload the old-style object.
4300 dlprefiles="$dlprefiles $pic_object"
4301 prev=
4302 fi
4303
4304 # A PIC object.
4305 func_append libobjs " $pic_object"
4306 arg="$pic_object"
4307 fi
4308
4309 # Non-PIC object.
4310 if test "$non_pic_object" != none; then
4311 # Prepend the subdirectory the object is found in.
4312 non_pic_object="$xdir$non_pic_object"
4313
4314 # A standard non-PIC object
4315 func_append non_pic_objects " $non_pic_object"
4316 if test -z "$pic_object" || test "$pic_object" = none ; then
4317 arg="$non_pic_object"
4318 fi
4319 else
4320 # If the PIC object exists, use it instead.
4321 # $xdir was prepended to $pic_object above.
4322 non_pic_object="$pic_object"
4323 func_append non_pic_objects " $non_pic_object"
4324 fi
4325 else
4326 # Only an error if not doing a dry-run.
4327 if $opt_dry_run; then
4328 # Extract subdirectory from the argument.
4329 func_dirname "$arg" "/" ""
4330 xdir="$func_dirname_result"
4331
4332 func_lo2o "$arg"
4333 pic_object=$xdir$objdir/$func_lo2o_result
4334 non_pic_object=$xdir$func_lo2o_result
4335 func_append libobjs " $pic_object"
4336 func_append non_pic_objects " $non_pic_object"
4337 else
4338 func_fatal_error "\`$arg' is not a valid libtool object"
4339 fi
4340 fi
4341 ;;
4342
4343 *.$libext)
4344 # An archive.
4345 deplibs="$deplibs $arg"
4346 old_deplibs="$old_deplibs $arg"
4347 continue
4348 ;;
4349
4350 *.la)
4351 # A libtool-controlled library.
4352
4353 if test "$prev" = dlfiles; then
4354 # This library was specified with -dlopen.
4355 dlfiles="$dlfiles $arg"
4356 prev=
4357 elif test "$prev" = dlprefiles; then
4358 # The library was specified with -dlpreopen.
4359 dlprefiles="$dlprefiles $arg"
4360 prev=
4361 else
4362 deplibs="$deplibs $arg"
4363 fi
4364 continue
4365 ;;
4366
4367 # Some other compiler argument.
4368 *)
4369 # Unknown arguments in both finalize_command and compile_command need
4370 # to be aesthetically quoted because they are evaled later.
4371 func_quote_for_eval "$arg"
4372 arg="$func_quote_for_eval_result"
4373 ;;
4374 esac # arg
4375
4376 # Now actually substitute the argument into the commands.
4377 if test -n "$arg"; then
4378 func_append compile_command " $arg"
4379 func_append finalize_command " $arg"
4380 fi
4381 done # argument parsing loop
4382
4383 test -n "$prev" && \
4384 func_fatal_help "the \`$prevarg' option requires an argument"
4385
4386 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4387 eval arg=\"$export_dynamic_flag_spec\"
4388 func_append compile_command " $arg"
4389 func_append finalize_command " $arg"
4390 fi
4391
4392 oldlibs=
4393 # calculate the name of the file, without its directory
4394 func_basename "$output"
4395 outputname="$func_basename_result"
4396 libobjs_save="$libobjs"
4397
4398 if test -n "$shlibpath_var"; then
4399 # get the directories listed in $shlibpath_var
4400 eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4401 else
4402 shlib_search_path=
4403 fi
4404 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4405 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4406
4407 func_dirname "$output" "/" ""
4408 output_objdir="$func_dirname_result$objdir"
4409 # Create the object directory.
4410 func_mkdir_p "$output_objdir"
4411
4412 # Determine the type of output
4413 case $output in
4414 "")
4415 func_fatal_help "you must specify an output file"
4416 ;;
4417 *.$libext) linkmode=oldlib ;;
4418 *.lo | *.$objext) linkmode=obj ;;
4419 *.la) linkmode=lib ;;
4420 *) linkmode=prog ;; # Anything else should be a program.
4421 esac
4422
4423 specialdeplibs=
4424
4425 libs=
4426 # Find all interdependent deplibs by searching for libraries
4427 # that are linked more than once (e.g. -la -lb -la)
4428 for deplib in $deplibs; do
4429 if $opt_duplicate_deps ; then
4430 case "$libs " in
4431 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4432 esac
4433 fi
4434 libs="$libs $deplib"
4435 done
4436
4437 if test "$linkmode" = lib; then
4438 libs="$predeps $libs $compiler_lib_search_path $postdeps"
4439
4440 # Compute libraries that are listed more than once in $predeps
4441 # $postdeps and mark them as special (i.e., whose duplicates are
4442 # not to be eliminated).
4443 pre_post_deps=
4444 if $opt_duplicate_compiler_generated_deps; then
4445 for pre_post_dep in $predeps $postdeps; do
4446 case "$pre_post_deps " in
4447 *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4448 esac
4449 pre_post_deps="$pre_post_deps $pre_post_dep"
4450 done
4451 fi
4452 pre_post_deps=
4453 fi
4454
4455 deplibs=
4456 newdependency_libs=
4457 newlib_search_path=
4458 need_relink=no # whether we're linking any uninstalled libtool libraries
4459 notinst_deplibs= # not-installed libtool libraries
4460 notinst_path= # paths that contain not-installed libtool libraries
4461
4462 case $linkmode in
4463 lib)
4464 passes="conv dlpreopen link"
4465 for file in $dlfiles $dlprefiles; do
4466 case $file in
4467 *.la) ;;
4468 *)
4469 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
4470 ;;
4471 esac
4472 done
4473 ;;
4474 prog)
4475 compile_deplibs=
4476 finalize_deplibs=
4477 alldeplibs=no
4478 newdlfiles=
4479 newdlprefiles=
4480 passes="conv scan dlopen dlpreopen link"
4481 ;;
4482 *) passes="conv"
4483 ;;
4484 esac
4485
4486 for pass in $passes; do
4487 # The preopen pass in lib mode reverses $deplibs; put it back here
4488 # so that -L comes before libs that need it for instance...
4489 if test "$linkmode,$pass" = "lib,link"; then
4490 ## FIXME: Find the place where the list is rebuilt in the wrong
4491 ## order, and fix it there properly
4492 tmp_deplibs=
4493 for deplib in $deplibs; do
4494 tmp_deplibs="$deplib $tmp_deplibs"
4495 done
4496 deplibs="$tmp_deplibs"
4497 fi
4498
4499 if test "$linkmode,$pass" = "lib,link" ||
4500 test "$linkmode,$pass" = "prog,scan"; then
4501 libs="$deplibs"
4502 deplibs=
4503 fi
4504 if test "$linkmode" = prog; then
4505 case $pass in
4506 dlopen) libs="$dlfiles" ;;
4507 dlpreopen) libs="$dlprefiles" ;;
4508 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
4509 esac
4510 fi
4511 if test "$linkmode,$pass" = "lib,dlpreopen"; then
4512 # Collect and forward deplibs of preopened libtool libs
4513 for lib in $dlprefiles; do
4514 # Ignore non-libtool-libs
4515 dependency_libs=
4516 case $lib in
4517 *.la) func_source "$lib" ;;
4518 esac
4519
4520 # Collect preopened libtool deplibs, except any this library
4521 # has declared as weak libs
4522 for deplib in $dependency_libs; do
4523 deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
4524 case " $weak_libs " in
4525 *" $deplib_base "*) ;;
4526 *) deplibs="$deplibs $deplib" ;;
4527 esac
4528 done
4529 done
4530 libs="$dlprefiles"
4531 fi
4532 if test "$pass" = dlopen; then
4533 # Collect dlpreopened libraries
4534 save_deplibs="$deplibs"
4535 deplibs=
4536 fi
4537
4538 for deplib in $libs; do
4539 lib=
4540 found=no
4541 case $deplib in
4542 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4543 if test "$linkmode,$pass" = "prog,link"; then
4544 compile_deplibs="$deplib $compile_deplibs"
4545 finalize_deplibs="$deplib $finalize_deplibs"
4546 else
4547 compiler_flags="$compiler_flags $deplib"
4548 if test "$linkmode" = lib ; then
4549 case "$new_inherited_linker_flags " in
4550 *" $deplib "*) ;;
4551 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
4552 esac
4553 fi
4554 fi
4555 continue
4556 ;;
4557 -l*)
4558 if test "$linkmode" != lib && test "$linkmode" != prog; then
4559 func_warning "\`-l' is ignored for archives/objects"
4560 continue
4561 fi
4562 func_stripname '-l' '' "$deplib"
4563 name=$func_stripname_result
4564 if test "$linkmode" = lib; then
4565 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
4566 else
4567 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
4568 fi
4569 for searchdir in $searchdirs; do
4570 for search_ext in .la $std_shrext .so .a; do
4571 # Search the libtool library
4572 lib="$searchdir/lib${name}${search_ext}"
4573 if test -f "$lib"; then
4574 if test "$search_ext" = ".la"; then
4575 found=yes
4576 else
4577 found=no
4578 fi
4579 break 2
4580 fi
4581 done
4582 done
4583 if test "$found" != yes; then
4584 # deplib doesn't seem to be a libtool library
4585 if test "$linkmode,$pass" = "prog,link"; then
4586 compile_deplibs="$deplib $compile_deplibs"
4587 finalize_deplibs="$deplib $finalize_deplibs"
4588 else
4589 deplibs="$deplib $deplibs"
4590 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
4591 fi
4592 continue
4593 else # deplib is a libtool library
4594 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
4595 # We need to do some special things here, and not later.
4596 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
4597 case " $predeps $postdeps " in
4598 *" $deplib "*)
4599 if func_lalib_p "$lib"; then
4600 library_names=
4601 old_library=
4602 func_source "$lib"
4603 for l in $old_library $library_names; do
4604 ll="$l"
4605 done
4606 if test "X$ll" = "X$old_library" ; then # only static version available
4607 found=no
4608 func_dirname "$lib" "" "."
4609 ladir="$func_dirname_result"
4610 lib=$ladir/$old_library
4611 if test "$linkmode,$pass" = "prog,link"; then
4612 compile_deplibs="$deplib $compile_deplibs"
4613 finalize_deplibs="$deplib $finalize_deplibs"
4614 else
4615 deplibs="$deplib $deplibs"
4616 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
4617 fi
4618 continue
4619 fi
4620 fi
4621 ;;
4622 *) ;;
4623 esac
4624 fi
4625 fi
4626 ;; # -l
4627 *.ltframework)
4628 if test "$linkmode,$pass" = "prog,link"; then
4629 compile_deplibs="$deplib $compile_deplibs"
4630 finalize_deplibs="$deplib $finalize_deplibs"
4631 else
4632 deplibs="$deplib $deplibs"
4633 if test "$linkmode" = lib ; then
4634 case "$new_inherited_linker_flags " in
4635 *" $deplib "*) ;;
4636 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
4637 esac
4638 fi
4639 fi
4640 continue
4641 ;;
4642 -L*)
4643 case $linkmode in
4644 lib)
4645 deplibs="$deplib $deplibs"
4646 test "$pass" = conv && continue
4647 newdependency_libs="$deplib $newdependency_libs"
4648 func_stripname '-L' '' "$deplib"
4649 newlib_search_path="$newlib_search_path $func_stripname_result"
4650 ;;
4651 prog)
4652 if test "$pass" = conv; then
4653 deplibs="$deplib $deplibs"
4654 continue
4655 fi
4656 if test "$pass" = scan; then
4657 deplibs="$deplib $deplibs"
4658 else
4659 compile_deplibs="$deplib $compile_deplibs"
4660 finalize_deplibs="$deplib $finalize_deplibs"
4661 fi
4662 func_stripname '-L' '' "$deplib"
4663 newlib_search_path="$newlib_search_path $func_stripname_result"
4664 ;;
4665 *)
4666 func_warning "\`-L' is ignored for archives/objects"
4667 ;;
4668 esac # linkmode
4669 continue
4670 ;; # -L
4671 -R*)
4672 if test "$pass" = link; then
4673 func_stripname '-R' '' "$deplib"
4674 dir=$func_stripname_result
4675 # Make sure the xrpath contains only unique directories.
4676 case "$xrpath " in
4677 *" $dir "*) ;;
4678 *) xrpath="$xrpath $dir" ;;
4679 esac
4680 fi
4681 deplibs="$deplib $deplibs"
4682 continue
4683 ;;
4684 *.la) lib="$deplib" ;;
4685 *.$libext)
4686 if test "$pass" = conv; then
4687 deplibs="$deplib $deplibs"
4688 continue
4689 fi
4690 case $linkmode in
4691 lib)
4692 # Linking convenience modules into shared libraries is allowed,
4693 # but linking other static libraries is non-portable.
4694 case " $dlpreconveniencelibs " in
4695 *" $deplib "*) ;;
4696 *)
4697 valid_a_lib=no
4698 case $deplibs_check_method in
4699 match_pattern*)
4700 set dummy $deplibs_check_method; shift
4701 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
4702 if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
4703 | $EGREP "$match_pattern_regex" > /dev/null; then
4704 valid_a_lib=yes
4705 fi
4706 ;;
4707 pass_all)
4708 valid_a_lib=yes
4709 ;;
4710 esac
4711 if test "$valid_a_lib" != yes; then
4712 $ECHO
4713 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
4714 $ECHO "*** I have the capability to make that library automatically link in when"
4715 $ECHO "*** you link to this library. But I can only do this if you have a"
4716 $ECHO "*** shared version of the library, which you do not appear to have"
4717 $ECHO "*** because the file extensions .$libext of this argument makes me believe"
4718 $ECHO "*** that it is just a static archive that I should not use here."
4719 else
4720 $ECHO
4721 $ECHO "*** Warning: Linking the shared library $output against the"
4722 $ECHO "*** static library $deplib is not portable!"
4723 deplibs="$deplib $deplibs"
4724 fi
4725 ;;
4726 esac
4727 continue
4728 ;;
4729 prog)
4730 if test "$pass" != link; then
4731 deplibs="$deplib $deplibs"
4732 else
4733 compile_deplibs="$deplib $compile_deplibs"
4734 finalize_deplibs="$deplib $finalize_deplibs"
4735 fi
4736 continue
4737 ;;
4738 esac # linkmode
4739 ;; # *.$libext
4740 *.lo | *.$objext)
4741 if test "$pass" = conv; then
4742 deplibs="$deplib $deplibs"
4743 elif test "$linkmode" = prog; then
4744 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
4745 # If there is no dlopen support or we're linking statically,
4746 # we need to preload.
4747 newdlprefiles="$newdlprefiles $deplib"
4748 compile_deplibs="$deplib $compile_deplibs"
4749 finalize_deplibs="$deplib $finalize_deplibs"
4750 else
4751 newdlfiles="$newdlfiles $deplib"
4752 fi
4753 fi
4754 continue
4755 ;;
4756 %DEPLIBS%)
4757 alldeplibs=yes
4758 continue
4759 ;;
4760 esac # case $deplib
4761
4762 if test "$found" = yes || test -f "$lib"; then :
4763 else
4764 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
4765 fi
4766
4767 # Check to see that this really is a libtool archive.
4768 func_lalib_unsafe_p "$lib" \
4769 || func_fatal_error "\`$lib' is not a valid libtool archive"
4770
4771 func_dirname "$lib" "" "."
4772 ladir="$func_dirname_result"
4773
4774 dlname=
4775 dlopen=
4776 dlpreopen=
4777 libdir=
4778 library_names=
4779 old_library=
4780 inherited_linker_flags=
4781 # If the library was installed with an old release of libtool,
4782 # it will not redefine variables installed, or shouldnotlink
4783 installed=yes
4784 shouldnotlink=no
4785 avoidtemprpath=
4786
4787
4788 # Read the .la file
4789 func_source "$lib"
4790
4791 # Convert "-framework foo" to "foo.ltframework"
4792 if test -n "$inherited_linker_flags"; then
4793 tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
4794 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
4795 case " $new_inherited_linker_flags " in
4796 *" $tmp_inherited_linker_flag "*) ;;
4797 *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
4798 esac
4799 done
4800 fi
4801 dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
4802 if test "$linkmode,$pass" = "lib,link" ||
4803 test "$linkmode,$pass" = "prog,scan" ||
4804 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
4805 test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
4806 test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
4807 fi
4808
4809 if test "$pass" = conv; then
4810 # Only check for convenience libraries
4811 deplibs="$lib $deplibs"
4812 if test -z "$libdir"; then
4813 if test -z "$old_library"; then
4814 func_fatal_error "cannot find name of link library for \`$lib'"
4815 fi
4816 # It is a libtool convenience library, so add in its objects.
4817 convenience="$convenience $ladir/$objdir/$old_library"
4818 old_convenience="$old_convenience $ladir/$objdir/$old_library"
4819 elif test "$linkmode" != prog && test "$linkmode" != lib; then
4820 func_fatal_error "\`$lib' is not a convenience library"
4821 fi
4822 tmp_libs=
4823 for deplib in $dependency_libs; do
4824 deplibs="$deplib $deplibs"
4825 if $opt_duplicate_deps ; then
4826 case "$tmp_libs " in
4827 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4828 esac
4829 fi
4830 tmp_libs="$tmp_libs $deplib"
4831 done
4832 continue
4833 fi # $pass = conv
4834
4835
4836 # Get the name of the library we link against.
4837 linklib=
4838 for l in $old_library $library_names; do
4839 linklib="$l"
4840 done
4841 if test -z "$linklib"; then
4842 func_fatal_error "cannot find name of link library for \`$lib'"
4843 fi
4844
4845 # This library was specified with -dlopen.
4846 if test "$pass" = dlopen; then
4847 if test -z "$libdir"; then
4848 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
4849 fi
4850 if test -z "$dlname" ||
4851 test "$dlopen_support" != yes ||
4852 test "$build_libtool_libs" = no; then
4853 # If there is no dlname, no dlopen support or we're linking
4854 # statically, we need to preload. We also need to preload any
4855 # dependent libraries so libltdl's deplib preloader doesn't
4856 # bomb out in the load deplibs phase.
4857 dlprefiles="$dlprefiles $lib $dependency_libs"
4858 else
4859 newdlfiles="$newdlfiles $lib"
4860 fi
4861 continue
4862 fi # $pass = dlopen
4863
4864 # We need an absolute path.
4865 case $ladir in
4866 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
4867 *)
4868 abs_ladir=`cd "$ladir" && pwd`
4869 if test -z "$abs_ladir"; then
4870 func_warning "cannot determine absolute directory name of \`$ladir'"
4871 func_warning "passing it literally to the linker, although it might fail"
4872 abs_ladir="$ladir"
4873 fi
4874 ;;
4875 esac
4876 func_basename "$lib"
4877 laname="$func_basename_result"
4878
4879 # Find the relevant object directory and library name.
4880 if test "X$installed" = Xyes; then
4881 if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
4882 func_warning "library \`$lib' was moved."
4883 dir="$ladir"
4884 absdir="$abs_ladir"
4885 libdir="$abs_ladir"
4886 else
4887 dir="$libdir"
4888 absdir="$libdir"
4889 fi
4890 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
4891 else
4892 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
4893 dir="$ladir"
4894 absdir="$abs_ladir"
4895 # Remove this search path later
4896 notinst_path="$notinst_path $abs_ladir"
4897 else
4898 dir="$ladir/$objdir"
4899 absdir="$abs_ladir/$objdir"
4900 # Remove this search path later
4901 notinst_path="$notinst_path $abs_ladir"
4902 fi
4903 fi # $installed = yes
4904 func_stripname 'lib' '.la' "$laname"
4905 name=$func_stripname_result
4906
4907 # This library was specified with -dlpreopen.
4908 if test "$pass" = dlpreopen; then
4909 if test -z "$libdir" && test "$linkmode" = prog; then
4910 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
4911 fi
4912 # Prefer using a static library (so that no silly _DYNAMIC symbols
4913 # are required to link).
4914 if test -n "$old_library"; then
4915 newdlprefiles="$newdlprefiles $dir/$old_library"
4916 # Keep a list of preopened convenience libraries to check
4917 # that they are being used correctly in the link pass.
4918 test -z "$libdir" && \
4919 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
4920 # Otherwise, use the dlname, so that lt_dlopen finds it.
4921 elif test -n "$dlname"; then
4922 newdlprefiles="$newdlprefiles $dir/$dlname"
4923 else
4924 newdlprefiles="$newdlprefiles $dir/$linklib"
4925 fi
4926 fi # $pass = dlpreopen
4927
4928 if test -z "$libdir"; then
4929 # Link the convenience library
4930 if test "$linkmode" = lib; then
4931 deplibs="$dir/$old_library $deplibs"
4932 elif test "$linkmode,$pass" = "prog,link"; then
4933 compile_deplibs="$dir/$old_library $compile_deplibs"
4934 finalize_deplibs="$dir/$old_library $finalize_deplibs"
4935 else
4936 deplibs="$lib $deplibs" # used for prog,scan pass
4937 fi
4938 continue
4939 fi
4940
4941
4942 if test "$linkmode" = prog && test "$pass" != link; then
4943 newlib_search_path="$newlib_search_path $ladir"
4944 deplibs="$lib $deplibs"
4945
4946 linkalldeplibs=no
4947 if test "$link_all_deplibs" != no || test -z "$library_names" ||
4948 test "$build_libtool_libs" = no; then
4949 linkalldeplibs=yes
4950 fi
4951
4952 tmp_libs=
4953 for deplib in $dependency_libs; do
4954 case $deplib in
4955 -L*) func_stripname '-L' '' "$deplib"
4956 newlib_search_path="$newlib_search_path $func_stripname_result"
4957 ;;
4958 esac
4959 # Need to link against all dependency_libs?
4960 if test "$linkalldeplibs" = yes; then
4961 deplibs="$deplib $deplibs"
4962 else
4963 # Need to hardcode shared library paths
4964 # or/and link against static libraries
4965 newdependency_libs="$deplib $newdependency_libs"
4966 fi
4967 if $opt_duplicate_deps ; then
4968 case "$tmp_libs " in
4969 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4970 esac
4971 fi
4972 tmp_libs="$tmp_libs $deplib"
4973 done # for deplib
4974 continue
4975 fi # $linkmode = prog...
4976
4977 if test "$linkmode,$pass" = "prog,link"; then
4978 if test -n "$library_names" &&
4979 { { test "$prefer_static_libs" = no ||
4980 test "$prefer_static_libs,$installed" = "built,yes"; } ||
4981 test -z "$old_library"; }; then
4982 # We need to hardcode the library path
4983 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
4984 # Make sure the rpath contains only unique directories.
4985 case "$temp_rpath:" in
4986 *"$absdir:"*) ;;
4987 *) temp_rpath="$temp_rpath$absdir:" ;;
4988 esac
4989 fi
4990
4991 # Hardcode the library path.
4992 # Skip directories that are in the system default run-time
4993 # search path.
4994 case " $sys_lib_dlsearch_path " in
4995 *" $absdir "*) ;;
4996 *)
4997 case "$compile_rpath " in
4998 *" $absdir "*) ;;
4999 *) compile_rpath="$compile_rpath $absdir"
5000 esac
5001 ;;
5002 esac
5003 case " $sys_lib_dlsearch_path " in
5004 *" $libdir "*) ;;
5005 *)
5006 case "$finalize_rpath " in
5007 *" $libdir "*) ;;
5008 *) finalize_rpath="$finalize_rpath $libdir"
5009 esac
5010 ;;
5011 esac
5012 fi # $linkmode,$pass = prog,link...
5013
5014 if test "$alldeplibs" = yes &&
5015 { test "$deplibs_check_method" = pass_all ||
5016 { test "$build_libtool_libs" = yes &&
5017 test -n "$library_names"; }; }; then
5018 # We only need to search for static libraries
5019 continue
5020 fi
5021 fi
5022
5023 link_static=no # Whether the deplib will be linked statically
5024 use_static_libs=$prefer_static_libs
5025 if test "$use_static_libs" = built && test "$installed" = yes; then
5026 use_static_libs=no
5027 fi
5028 if test -n "$library_names" &&
5029 { test "$use_static_libs" = no || test -z "$old_library"; }; then
5030 case $host in
5031 *cygwin* | *mingw*)
5032 # No point in relinking DLLs because paths are not encoded
5033 notinst_deplibs="$notinst_deplibs $lib"
5034 need_relink=no
5035 ;;
5036 *)
5037 if test "$installed" = no; then
5038 notinst_deplibs="$notinst_deplibs $lib"
5039 need_relink=yes
5040 fi
5041 ;;
5042 esac
5043 # This is a shared library
5044
5045 # Warn about portability, can't link against -module's on some
5046 # systems (darwin). Don't bleat about dlopened modules though!
5047 dlopenmodule=""
5048 for dlpremoduletest in $dlprefiles; do
5049 if test "X$dlpremoduletest" = "X$lib"; then
5050 dlopenmodule="$dlpremoduletest"
5051 break
5052 fi
5053 done
5054 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5055 $ECHO
5056 if test "$linkmode" = prog; then
5057 $ECHO "*** Warning: Linking the executable $output against the loadable module"
5058 else
5059 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5060 fi
5061 $ECHO "*** $linklib is not portable!"
5062 fi
5063 if test "$linkmode" = lib &&
5064 test "$hardcode_into_libs" = yes; then
5065 # Hardcode the library path.
5066 # Skip directories that are in the system default run-time
5067 # search path.
5068 case " $sys_lib_dlsearch_path " in
5069 *" $absdir "*) ;;
5070 *)
5071 case "$compile_rpath " in
5072 *" $absdir "*) ;;
5073 *) compile_rpath="$compile_rpath $absdir"
5074 esac
5075 ;;
5076 esac
5077 case " $sys_lib_dlsearch_path " in
5078 *" $libdir "*) ;;
5079 *)
5080 case "$finalize_rpath " in
5081 *" $libdir "*) ;;
5082 *) finalize_rpath="$finalize_rpath $libdir"
5083 esac
5084 ;;
5085 esac
5086 fi
5087
5088 if test -n "$old_archive_from_expsyms_cmds"; then
5089 # figure out the soname
5090 set dummy $library_names
5091 shift
5092 realname="$1"
5093 shift
5094 libname=`eval "\\$ECHO \"$libname_spec\""`
5095 # use dlname if we got it. it's perfectly good, no?
5096 if test -n "$dlname"; then
5097 soname="$dlname"
5098 elif test -n "$soname_spec"; then
5099 # bleh windows
5100 case $host in
5101 *cygwin* | mingw*)
5102 func_arith $current - $age
5103 major=$func_arith_result
5104 versuffix="-$major"
5105 ;;
5106 esac
5107 eval soname=\"$soname_spec\"
5108 else
5109 soname="$realname"
5110 fi
5111
5112 # Make a new name for the extract_expsyms_cmds to use
5113 soroot="$soname"
5114 func_basename "$soroot"
5115 soname="$func_basename_result"
5116 func_stripname 'lib' '.dll' "$soname"
5117 newlib=libimp-$func_stripname_result.a
5118
5119 # If the library has no export list, then create one now
5120 if test -f "$output_objdir/$soname-def"; then :
5121 else
5122 func_verbose "extracting exported symbol list from \`$soname'"
5123 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5124 fi
5125
5126 # Create $newlib
5127 if test -f "$output_objdir/$newlib"; then :; else
5128 func_verbose "generating import library for \`$soname'"
5129 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5130 fi
5131 # make sure the library variables are pointing to the new library
5132 dir=$output_objdir
5133 linklib=$newlib
5134 fi # test -n "$old_archive_from_expsyms_cmds"
5135
5136 if test "$linkmode" = prog || test "$mode" != relink; then
5137 add_shlibpath=
5138 add_dir=
5139 add=
5140 lib_linked=yes
5141 case $hardcode_action in
5142 immediate | unsupported)
5143 if test "$hardcode_direct" = no; then
5144 add="$dir/$linklib"
5145 case $host in
5146 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5147 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5148 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5149 *-*-unixware7*) add_dir="-L$dir" ;;
5150 *-*-darwin* )
5151 # if the lib is a (non-dlopened) module then we can not
5152 # link against it, someone is ignoring the earlier warnings
5153 if /usr/bin/file -L $add 2> /dev/null |
5154 $GREP ": [^:]* bundle" >/dev/null ; then
5155 if test "X$dlopenmodule" != "X$lib"; then
5156 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
5157 if test -z "$old_library" ; then
5158 $ECHO
5159 $ECHO "*** And there doesn't seem to be a static archive available"
5160 $ECHO "*** The link will probably fail, sorry"
5161 else
5162 add="$dir/$old_library"
5163 fi
5164 elif test -n "$old_library"; then
5165 add="$dir/$old_library"
5166 fi
5167 fi
5168 esac
5169 elif test "$hardcode_minus_L" = no; then
5170 case $host in
5171 *-*-sunos*) add_shlibpath="$dir" ;;
5172 esac
5173 add_dir="-L$dir"
5174 add="-l$name"
5175 elif test "$hardcode_shlibpath_var" = no; then
5176 add_shlibpath="$dir"
5177 add="-l$name"
5178 else
5179 lib_linked=no
5180 fi
5181 ;;
5182 relink)
5183 if test "$hardcode_direct" = yes &&
5184 test "$hardcode_direct_absolute" = no; then
5185 add="$dir/$linklib"
5186 elif test "$hardcode_minus_L" = yes; then
5187 add_dir="-L$dir"
5188 # Try looking first in the location we're being installed to.
5189 if test -n "$inst_prefix_dir"; then
5190 case $libdir in
5191 [\\/]*)
5192 add_dir="$add_dir -L$inst_prefix_dir$libdir"
5193 ;;
5194 esac
5195 fi
5196 add="-l$name"
5197 elif test "$hardcode_shlibpath_var" = yes; then
5198 add_shlibpath="$dir"
5199 add="-l$name"
5200 else
5201 lib_linked=no
5202 fi
5203 ;;
5204 *) lib_linked=no ;;
5205 esac
5206
5207 if test "$lib_linked" != yes; then
5208 func_fatal_configuration "unsupported hardcode properties"
5209 fi
5210
5211 if test -n "$add_shlibpath"; then
5212 case :$compile_shlibpath: in
5213 *":$add_shlibpath:"*) ;;
5214 *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5215 esac
5216 fi
5217 if test "$linkmode" = prog; then
5218 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5219 test -n "$add" && compile_deplibs="$add $compile_deplibs"
5220 else
5221 test -n "$add_dir" && deplibs="$add_dir $deplibs"
5222 test -n "$add" && deplibs="$add $deplibs"
5223 if test "$hardcode_direct" != yes &&
5224 test "$hardcode_minus_L" != yes &&
5225 test "$hardcode_shlibpath_var" = yes; then
5226 case :$finalize_shlibpath: in
5227 *":$libdir:"*) ;;
5228 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5229 esac
5230 fi
5231 fi
5232 fi
5233
5234 if test "$linkmode" = prog || test "$mode" = relink; then
5235 add_shlibpath=
5236 add_dir=
5237 add=
5238 # Finalize command for both is simple: just hardcode it.
5239 if test "$hardcode_direct" = yes &&
5240 test "$hardcode_direct_absolute" = no; then
5241 add="$libdir/$linklib"
5242 elif test "$hardcode_minus_L" = yes; then
5243 add_dir="-L$libdir"
5244 add="-l$name"
5245 elif test "$hardcode_shlibpath_var" = yes; then
5246 case :$finalize_shlibpath: in
5247 *":$libdir:"*) ;;
5248 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5249 esac
5250 add="-l$name"
5251 elif test "$hardcode_automatic" = yes; then
5252 if test -n "$inst_prefix_dir" &&
5253 test -f "$inst_prefix_dir$libdir/$linklib" ; then
5254 add="$inst_prefix_dir$libdir/$linklib"
5255 else
5256 add="$libdir/$linklib"
5257 fi
5258 else
5259 # We cannot seem to hardcode it, guess we'll fake it.
5260 add_dir="-L$libdir"
5261 # Try looking first in the location we're being installed to.
5262 if test -n "$inst_prefix_dir"; then
5263 case $libdir in
5264 [\\/]*)
5265 add_dir="$add_dir -L$inst_prefix_dir$libdir"
5266 ;;
5267 esac
5268 fi
5269 add="-l$name"
5270 fi
5271
5272 if test "$linkmode" = prog; then
5273 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5274 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5275 else
5276 test -n "$add_dir" && deplibs="$add_dir $deplibs"
5277 test -n "$add" && deplibs="$add $deplibs"
5278 fi
5279 fi
5280 elif test "$linkmode" = prog; then
5281 # Here we assume that one of hardcode_direct or hardcode_minus_L
5282 # is not unsupported. This is valid on all known static and
5283 # shared platforms.
5284 if test "$hardcode_direct" != unsupported; then
5285 test -n "$old_library" && linklib="$old_library"
5286 compile_deplibs="$dir/$linklib $compile_deplibs"
5287 finalize_deplibs="$dir/$linklib $finalize_deplibs"
5288 else
5289 compile_deplibs="-l$name -L$dir $compile_deplibs"
5290 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5291 fi
5292 elif test "$build_libtool_libs" = yes; then
5293 # Not a shared library
5294 if test "$deplibs_check_method" != pass_all; then
5295 # We're trying link a shared library against a static one
5296 # but the system doesn't support it.
5297
5298 # Just print a warning and add the library to dependency_libs so
5299 # that the program can be linked against the static library.
5300 $ECHO
5301 $ECHO "*** Warning: This system can not link to static lib archive $lib."
5302 $ECHO "*** I have the capability to make that library automatically link in when"
5303 $ECHO "*** you link to this library. But I can only do this if you have a"
5304 $ECHO "*** shared version of the library, which you do not appear to have."
5305 if test "$module" = yes; then
5306 $ECHO "*** But as you try to build a module library, libtool will still create "
5307 $ECHO "*** a static module, that should work as long as the dlopening application"
5308 $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5309 if test -z "$global_symbol_pipe"; then
5310 $ECHO
5311 $ECHO "*** However, this would only work if libtool was able to extract symbol"
5312 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5313 $ECHO "*** not find such a program. So, this module is probably useless."
5314 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5315 fi
5316 if test "$build_old_libs" = no; then
5317 build_libtool_libs=module
5318 build_old_libs=yes
5319 else
5320 build_libtool_libs=no
5321 fi
5322 fi
5323 else
5324 deplibs="$dir/$old_library $deplibs"
5325 link_static=yes
5326 fi
5327 fi # link shared/static library?
5328
5329 if test "$linkmode" = lib; then
5330 if test -n "$dependency_libs" &&
5331 { test "$hardcode_into_libs" != yes ||
5332 test "$build_old_libs" = yes ||
5333 test "$link_static" = yes; }; then
5334 # Extract -R from dependency_libs
5335 temp_deplibs=
5336 for libdir in $dependency_libs; do
5337 case $libdir in
5338 -R*) func_stripname '-R' '' "$libdir"
5339 temp_xrpath=$func_stripname_result
5340 case " $xrpath " in
5341 *" $temp_xrpath "*) ;;
5342 *) xrpath="$xrpath $temp_xrpath";;
5343 esac;;
5344 *) temp_deplibs="$temp_deplibs $libdir";;
5345 esac
5346 done
5347 dependency_libs="$temp_deplibs"
5348 fi
5349
5350 newlib_search_path="$newlib_search_path $absdir"
5351 # Link against this library
5352 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5353 # ... and its dependency_libs
5354 tmp_libs=
5355 for deplib in $dependency_libs; do
5356 newdependency_libs="$deplib $newdependency_libs"
5357 if $opt_duplicate_deps ; then
5358 case "$tmp_libs " in
5359 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5360 esac
5361 fi
5362 tmp_libs="$tmp_libs $deplib"
5363 done
5364
5365 if test "$link_all_deplibs" != no; then
5366 # Add the search paths of all dependency libraries
5367 for deplib in $dependency_libs; do
5368 case $deplib in
5369 -L*) path="$deplib" ;;
5370 *.la)
5371 func_dirname "$deplib" "" "."
5372 dir="$func_dirname_result"
5373 # We need an absolute path.
5374 case $dir in
5375 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5376 *)
5377 absdir=`cd "$dir" && pwd`
5378 if test -z "$absdir"; then
5379 func_warning "cannot determine absolute directory name of \`$dir'"
5380 absdir="$dir"
5381 fi
5382 ;;
5383 esac
5384 if $GREP "^installed=no" $deplib > /dev/null; then
5385 case $host in
5386 *-*-darwin*)
5387 depdepl=
5388 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5389 if test -n "$deplibrary_names" ; then
5390 for tmp in $deplibrary_names ; do
5391 depdepl=$tmp
5392 done
5393 if test -f "$absdir/$objdir/$depdepl" ; then
5394 depdepl="$absdir/$objdir/$depdepl"
5395 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5396 if test -z "$darwin_install_name"; then
5397 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5398 fi
5399 compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5400 linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5401 path=
5402 fi
5403 fi
5404 ;;
5405 *)
5406 path="-L$absdir/$objdir"
5407 ;;
5408 esac
5409 else
5410 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5411 test -z "$libdir" && \
5412 func_fatal_error "\`$deplib' is not a valid libtool archive"
5413 test "$absdir" != "$libdir" && \
5414 func_warning "\`$deplib' seems to be moved"
5415
5416 path="-L$absdir"
5417 fi
5418 ;;
5419 esac
5420 case " $deplibs " in
5421 *" $path "*) ;;
5422 *) deplibs="$path $deplibs" ;;
5423 esac
5424 done
5425 fi # link_all_deplibs != no
5426 fi # linkmode = lib
5427 done # for deplib in $libs
5428 if test "$pass" = link; then
5429 if test "$linkmode" = "prog"; then
5430 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5431 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5432 else
5433 compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5434 fi
5435 fi
5436 dependency_libs="$newdependency_libs"
5437 if test "$pass" = dlpreopen; then
5438 # Link the dlpreopened libraries before other libraries
5439 for deplib in $save_deplibs; do
5440 deplibs="$deplib $deplibs"
5441 done
5442 fi
5443 if test "$pass" != dlopen; then
5444 if test "$pass" != conv; then
5445 # Make sure lib_search_path contains only unique directories.
5446 lib_search_path=
5447 for dir in $newlib_search_path; do
5448 case "$lib_search_path " in
5449 *" $dir "*) ;;
5450 *) lib_search_path="$lib_search_path $dir" ;;
5451 esac
5452 done
5453 newlib_search_path=
5454 fi
5455
5456 if test "$linkmode,$pass" != "prog,link"; then
5457 vars="deplibs"
5458 else
5459 vars="compile_deplibs finalize_deplibs"
5460 fi
5461 for var in $vars dependency_libs; do
5462 # Add libraries to $var in reverse order
5463 eval tmp_libs=\"\$$var\"
5464 new_libs=
5465 for deplib in $tmp_libs; do
5466 # FIXME: Pedantically, this is the right thing to do, so
5467 # that some nasty dependency loop isn't accidentally
5468 # broken:
5469 #new_libs="$deplib $new_libs"
5470 # Pragmatically, this seems to cause very few problems in
5471 # practice:
5472 case $deplib in
5473 -L*) new_libs="$deplib $new_libs" ;;
5474 -R*) ;;
5475 *)
5476 # And here is the reason: when a library appears more
5477 # than once as an explicit dependence of a library, or
5478 # is implicitly linked in more than once by the
5479 # compiler, it is considered special, and multiple
5480 # occurrences thereof are not removed. Compare this
5481 # with having the same library being listed as a
5482 # dependency of multiple other libraries: in this case,
5483 # we know (pedantically, we assume) the library does not
5484 # need to be listed more than once, so we keep only the
5485 # last copy. This is not always right, but it is rare
5486 # enough that we require users that really mean to play
5487 # such unportable linking tricks to link the library
5488 # using -Wl,-lname, so that libtool does not consider it
5489 # for duplicate removal.
5490 case " $specialdeplibs " in
5491 *" $deplib "*) new_libs="$deplib $new_libs" ;;
5492 *)
5493 case " $new_libs " in
5494 *" $deplib "*) ;;
5495 *) new_libs="$deplib $new_libs" ;;
5496 esac
5497 ;;
5498 esac
5499 ;;
5500 esac
5501 done
5502 tmp_libs=
5503 for deplib in $new_libs; do
5504 case $deplib in
5505 -L*)
5506 case " $tmp_libs " in
5507 *" $deplib "*) ;;
5508 *) tmp_libs="$tmp_libs $deplib" ;;
5509 esac
5510 ;;
5511 *) tmp_libs="$tmp_libs $deplib" ;;
5512 esac
5513 done
5514 eval $var=\"$tmp_libs\"
5515 done # for var
5516 fi
5517 # Last step: remove runtime libs from dependency_libs
5518 # (they stay in deplibs)
5519 tmp_libs=
5520 for i in $dependency_libs ; do
5521 case " $predeps $postdeps $compiler_lib_search_path " in
5522 *" $i "*)
5523 i=""
5524 ;;
5525 esac
5526 if test -n "$i" ; then
5527 tmp_libs="$tmp_libs $i"
5528 fi
5529 done
5530 dependency_libs=$tmp_libs
5531 done # for pass
5532 if test "$linkmode" = prog; then
5533 dlfiles="$newdlfiles"
5534 fi
5535 if test "$linkmode" = prog || test "$linkmode" = lib; then
5536 dlprefiles="$newdlprefiles"
5537 fi
5538
5539 case $linkmode in
5540 oldlib)
5541 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
5542 func_warning "\`-dlopen' is ignored for archives"
5543 fi
5544
5545 case " $deplibs" in
5546 *\ -l* | *\ -L*)
5547 func_warning "\`-l' and \`-L' are ignored for archives" ;;
5548 esac
5549
5550 test -n "$rpath" && \
5551 func_warning "\`-rpath' is ignored for archives"
5552
5553 test -n "$xrpath" && \
5554 func_warning "\`-R' is ignored for archives"
5555
5556 test -n "$vinfo" && \
5557 func_warning "\`-version-info/-version-number' is ignored for archives"
5558
5559 test -n "$release" && \
5560 func_warning "\`-release' is ignored for archives"
5561
5562 test -n "$export_symbols$export_symbols_regex" && \
5563 func_warning "\`-export-symbols' is ignored for archives"
5564
5565 # Now set the variables for building old libraries.
5566 build_libtool_libs=no
5567 oldlibs="$output"
5568 objs="$objs$old_deplibs"
5569 ;;
5570
5571 lib)
5572 # Make sure we only generate libraries of the form `libNAME.la'.
5573 case $outputname in
5574 lib*)
5575 func_stripname 'lib' '.la' "$outputname"
5576 name=$func_stripname_result
5577 eval shared_ext=\"$shrext_cmds\"
5578 eval libname=\"$libname_spec\"
5579 ;;
5580 *)
5581 test "$module" = no && \
5582 func_fatal_help "libtool library \`$output' must begin with \`lib'"
5583
5584 if test "$need_lib_prefix" != no; then
5585 # Add the "lib" prefix for modules if required
5586 func_stripname '' '.la' "$outputname"
5587 name=$func_stripname_result
5588 eval shared_ext=\"$shrext_cmds\"
5589 eval libname=\"$libname_spec\"
5590 else
5591 func_stripname '' '.la' "$outputname"
5592 libname=$func_stripname_result
5593 fi
5594 ;;
5595 esac
5596
5597 if test -n "$objs"; then
5598 if test "$deplibs_check_method" != pass_all; then
5599 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
5600 else
5601 $ECHO
5602 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
5603 $ECHO "*** objects $objs is not portable!"
5604 libobjs="$libobjs $objs"
5605 fi
5606 fi
5607
5608 test "$dlself" != no && \
5609 func_warning "\`-dlopen self' is ignored for libtool libraries"
5610
5611 set dummy $rpath
5612 shift
5613 test "$#" -gt 1 && \
5614 func_warning "ignoring multiple \`-rpath's for a libtool library"
5615
5616 install_libdir="$1"
5617
5618 oldlibs=
5619 if test -z "$rpath"; then
5620 if test "$build_libtool_libs" = yes; then
5621 # Building a libtool convenience library.
5622 # Some compilers have problems with a `.al' extension so
5623 # convenience libraries should have the same extension an
5624 # archive normally would.
5625 oldlibs="$output_objdir/$libname.$libext $oldlibs"
5626 build_libtool_libs=convenience
5627 build_old_libs=yes
5628 fi
5629
5630 test -n "$vinfo" && \
5631 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
5632
5633 test -n "$release" && \
5634 func_warning "\`-release' is ignored for convenience libraries"
5635 else
5636
5637 # Parse the version information argument.
5638 save_ifs="$IFS"; IFS=':'
5639 set dummy $vinfo 0 0 0
5640 shift
5641 IFS="$save_ifs"
5642
5643 test -n "$7" && \
5644 func_fatal_help "too many parameters to \`-version-info'"
5645
5646 # convert absolute version numbers to libtool ages
5647 # this retains compatibility with .la files and attempts
5648 # to make the code below a bit more comprehensible
5649
5650 case $vinfo_number in
5651 yes)
5652 number_major="$1"
5653 number_minor="$2"
5654 number_revision="$3"
5655 #
5656 # There are really only two kinds -- those that
5657 # use the current revision as the major version
5658 # and those that subtract age and use age as
5659 # a minor version. But, then there is irix
5660 # which has an extra 1 added just for fun
5661 #
5662 case $version_type in
5663 darwin|linux|osf|windows|none)
5664 func_arith $number_major + $number_minor
5665 current=$func_arith_result
5666 age="$number_minor"
5667 revision="$number_revision"
5668 ;;
5669 freebsd-aout|freebsd-elf|sunos)
5670 current="$number_major"
5671 revision="$number_minor"
5672 age="0"
5673 ;;
5674 irix|nonstopux)
5675 func_arith $number_major + $number_minor
5676 current=$func_arith_result
5677 age="$number_minor"
5678 revision="$number_minor"
5679 lt_irix_increment=no
5680 ;;
5681 esac
5682 ;;
5683 no)
5684 current="$1"
5685 revision="$2"
5686 age="$3"
5687 ;;
5688 esac
5689
5690 # Check that each of the things are valid numbers.
5691 case $current in
5692 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
5693 *)
5694 func_error "CURRENT \`$current' must be a nonnegative integer"
5695 func_fatal_error "\`$vinfo' is not valid version information"
5696 ;;
5697 esac
5698
5699 case $revision in
5700 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
5701 *)
5702 func_error "REVISION \`$revision' must be a nonnegative integer"
5703 func_fatal_error "\`$vinfo' is not valid version information"
5704 ;;
5705 esac
5706
5707 case $age in
5708 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
5709 *)
5710 func_error "AGE \`$age' must be a nonnegative integer"
5711 func_fatal_error "\`$vinfo' is not valid version information"
5712 ;;
5713 esac
5714
5715 if test "$age" -gt "$current"; then
5716 func_error "AGE \`$age' is greater than the current interface number \`$current'"
5717 func_fatal_error "\`$vinfo' is not valid version information"
5718 fi
5719
5720 # Calculate the version variables.
5721 major=
5722 versuffix=
5723 verstring=
5724 case $version_type in
5725 none) ;;
5726
5727 darwin)
5728 # Like Linux, but with the current version available in
5729 # verstring for coding it into the library header
5730 func_arith $current - $age
5731 major=.$func_arith_result
5732 versuffix="$major.$age.$revision"
5733 # Darwin ld doesn't like 0 for these options...
5734 func_arith $current + 1
5735 minor_current=$func_arith_result
5736 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
5737 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
5738 ;;
5739
5740 freebsd-aout)
5741 major=".$current"
5742 versuffix=".$current.$revision";
5743 ;;
5744
5745 freebsd-elf)
5746 major=".$current"
5747 versuffix=".$current"
5748 ;;
5749
5750 irix | nonstopux)
5751 if test "X$lt_irix_increment" = "Xno"; then
5752 func_arith $current - $age
5753 else
5754 func_arith $current - $age + 1
5755 fi
5756 major=$func_arith_result
5757
5758 case $version_type in
5759 nonstopux) verstring_prefix=nonstopux ;;
5760 *) verstring_prefix=sgi ;;
5761 esac
5762 verstring="$verstring_prefix$major.$revision"
5763
5764 # Add in all the interfaces that we are compatible with.
5765 loop=$revision
5766 while test "$loop" -ne 0; do
5767 func_arith $revision - $loop
5768 iface=$func_arith_result
5769 func_arith $loop - 1
5770 loop=$func_arith_result
5771 verstring="$verstring_prefix$major.$iface:$verstring"
5772 done
5773
5774 # Before this point, $major must not contain `.'.
5775 major=.$major
5776 versuffix="$major.$revision"
5777 ;;
5778
5779 linux)
5780 func_arith $current - $age
5781 major=.$func_arith_result
5782 versuffix="$major.$age.$revision"
5783 ;;
5784
5785 osf)
5786 func_arith $current - $age
5787 major=.$func_arith_result
5788 versuffix=".$current.$age.$revision"
5789 verstring="$current.$age.$revision"
5790
5791 # Add in all the interfaces that we are compatible with.
5792 loop=$age
5793 while test "$loop" -ne 0; do
5794 func_arith $current - $loop
5795 iface=$func_arith_result
5796 func_arith $loop - 1
5797 loop=$func_arith_result
5798 verstring="$verstring:${iface}.0"
5799 done
5800
5801 # Make executables depend on our current version.
5802 verstring="$verstring:${current}.0"
5803 ;;
5804
5805 qnx)
5806 major=".$current"
5807 versuffix=".$current"
5808 ;;
5809
5810 sunos)
5811 major=".$current"
5812 versuffix=".$current.$revision"
5813 ;;
5814
5815 windows)
5816 # Use '-' rather than '.', since we only want one
5817 # extension on DOS 8.3 filesystems.
5818 func_arith $current - $age
5819 major=$func_arith_result
5820 versuffix="-$major"
5821 ;;
5822
5823 *)
5824 func_fatal_configuration "unknown library version type \`$version_type'"
5825 ;;
5826 esac
5827
5828 # Clear the version info if we defaulted, and they specified a release.
5829 if test -z "$vinfo" && test -n "$release"; then
5830 major=
5831 case $version_type in
5832 darwin)
5833 # we can't check for "0.0" in archive_cmds due to quoting
5834 # problems, so we reset it completely
5835 verstring=
5836 ;;
5837 *)
5838 verstring="0.0"
5839 ;;
5840 esac
5841 if test "$need_version" = no; then
5842 versuffix=
5843 else
5844 versuffix=".0.0"
5845 fi
5846 fi
5847
5848 # Remove version info from name if versioning should be avoided
5849 if test "$avoid_version" = yes && test "$need_version" = no; then
5850 major=
5851 versuffix=
5852 verstring=""
5853 fi
5854
5855 # Check to see if the archive will have undefined symbols.
5856 if test "$allow_undefined" = yes; then
5857 if test "$allow_undefined_flag" = unsupported; then
5858 func_warning "undefined symbols not allowed in $host shared libraries"
5859 build_libtool_libs=no
5860 build_old_libs=yes
5861 fi
5862 else
5863 # Don't allow undefined symbols.
5864 allow_undefined_flag="$no_undefined_flag"
5865 fi
5866
5867 fi
5868
5869 func_generate_dlsyms "$libname" "$libname" "yes"
5870 libobjs="$libobjs $symfileobj"
5871 test "X$libobjs" = "X " && libobjs=
5872
5873 if test "$mode" != relink; then
5874 # Remove our outputs, but don't remove object files since they
5875 # may have been created when compiling PIC objects.
5876 removelist=
5877 tempremovelist=`$ECHO "$output_objdir/*"`
5878 for p in $tempremovelist; do
5879 case $p in
5880 *.$objext)
5881 ;;
5882 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
5883 if test "X$precious_files_regex" != "X"; then
5884 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
5885 then
5886 continue
5887 fi
5888 fi
5889 removelist="$removelist $p"
5890 ;;
5891 *) ;;
5892 esac
5893 done
5894 test -n "$removelist" && \
5895 func_show_eval "${RM}r \$removelist"
5896 fi
5897
5898 # Now set the variables for building old libraries.
5899 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
5900 oldlibs="$oldlibs $output_objdir/$libname.$libext"
5901
5902 # Transform .lo files to .o files.
5903 oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
5904 fi
5905
5906 # Eliminate all temporary directories.
5907 #for path in $notinst_path; do
5908 # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
5909 # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
5910 # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
5911 #done
5912
5913 if test -n "$xrpath"; then
5914 # If the user specified any rpath flags, then add them.
5915 temp_xrpath=
5916 for libdir in $xrpath; do
5917 temp_xrpath="$temp_xrpath -R$libdir"
5918 case "$finalize_rpath " in
5919 *" $libdir "*) ;;
5920 *) finalize_rpath="$finalize_rpath $libdir" ;;
5921 esac
5922 done
5923 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
5924 dependency_libs="$temp_xrpath $dependency_libs"
5925 fi
5926 fi
5927
5928 # Make sure dlfiles contains only unique files that won't be dlpreopened
5929 old_dlfiles="$dlfiles"
5930 dlfiles=
5931 for lib in $old_dlfiles; do
5932 case " $dlprefiles $dlfiles " in
5933 *" $lib "*) ;;
5934 *) dlfiles="$dlfiles $lib" ;;
5935 esac
5936 done
5937
5938 # Make sure dlprefiles contains only unique files
5939 old_dlprefiles="$dlprefiles"
5940 dlprefiles=
5941 for lib in $old_dlprefiles; do
5942 case "$dlprefiles " in
5943 *" $lib "*) ;;
5944 *) dlprefiles="$dlprefiles $lib" ;;
5945 esac
5946 done
5947
5948 if test "$build_libtool_libs" = yes; then
5949 if test -n "$rpath"; then
5950 case $host in
5951 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
5952 # these systems don't actually have a c library (as such)!
5953 ;;
5954 *-*-rhapsody* | *-*-darwin1.[012])
5955 # Rhapsody C library is in the System framework
5956 deplibs="$deplibs System.ltframework"
5957 ;;
5958 *-*-netbsd*)
5959 # Don't link with libc until the a.out ld.so is fixed.
5960 ;;
5961 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
5962 # Do not include libc due to us having libc/libc_r.
5963 ;;
5964 *-*-sco3.2v5* | *-*-sco5v6*)
5965 # Causes problems with __ctype
5966 ;;
5967 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
5968 # Compiler inserts libc in the correct place for threads to work
5969 ;;
5970 *)
5971 # Add libc to deplibs on all other systems if necessary.
5972 if test "$build_libtool_need_lc" = "yes"; then
5973 deplibs="$deplibs -lc"
5974 fi
5975 ;;
5976 esac
5977 fi
5978
5979 # Transform deplibs into only deplibs that can be linked in shared.
5980 name_save=$name
5981 libname_save=$libname
5982 release_save=$release
5983 versuffix_save=$versuffix
5984 major_save=$major
5985 # I'm not sure if I'm treating the release correctly. I think
5986 # release should show up in the -l (ie -lgmp5) so we don't want to
5987 # add it in twice. Is that correct?
5988 release=""
5989 versuffix=""
5990 major=""
5991 newdeplibs=
5992 droppeddeps=no
5993 case $deplibs_check_method in
5994 pass_all)
5995 # Don't check for shared/static. Everything works.
5996 # This might be a little naive. We might want to check
5997 # whether the library exists or not. But this is on
5998 # osf3 & osf4 and I'm not really sure... Just
5999 # implementing what was already the behavior.
6000 newdeplibs=$deplibs
6001 ;;
6002 test_compile)
6003 # This code stresses the "libraries are programs" paradigm to its
6004 # limits. Maybe even breaks it. We compile a program, linking it
6005 # against the deplibs as a proxy for the library. Then we can check
6006 # whether they linked in statically or dynamically with ldd.
6007 $opt_dry_run || $RM conftest.c
6008 cat > conftest.c <<EOF
6009 int main() { return 0; }
6010 EOF
6011 $opt_dry_run || $RM conftest
6012 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6013 ldd_output=`ldd conftest`
6014 for i in $deplibs; do
6015 case $i in
6016 -l*)
6017 func_stripname -l '' "$i"
6018 name=$func_stripname_result
6019 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6020 case " $predeps $postdeps " in
6021 *" $i "*)
6022 newdeplibs="$newdeplibs $i"
6023 i=""
6024 ;;
6025 esac
6026 fi
6027 if test -n "$i" ; then
6028 libname=`eval "\\$ECHO \"$libname_spec\""`
6029 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6030 set dummy $deplib_matches; shift
6031 deplib_match=$1
6032 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6033 newdeplibs="$newdeplibs $i"
6034 else
6035 droppeddeps=yes
6036 $ECHO
6037 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6038 $ECHO "*** I have the capability to make that library automatically link in when"
6039 $ECHO "*** you link to this library. But I can only do this if you have a"
6040 $ECHO "*** shared version of the library, which I believe you do not have"
6041 $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6042 $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6043 fi
6044 fi
6045 ;;
6046 *)
6047 newdeplibs="$newdeplibs $i"
6048 ;;
6049 esac
6050 done
6051 else
6052 # Error occurred in the first compile. Let's try to salvage
6053 # the situation: Compile a separate program for each library.
6054 for i in $deplibs; do
6055 case $i in
6056 -l*)
6057 func_stripname -l '' "$i"
6058 name=$func_stripname_result
6059 $opt_dry_run || $RM conftest
6060 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6061 ldd_output=`ldd conftest`
6062 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6063 case " $predeps $postdeps " in
6064 *" $i "*)
6065 newdeplibs="$newdeplibs $i"
6066 i=""
6067 ;;
6068 esac
6069 fi
6070 if test -n "$i" ; then
6071 libname=`eval "\\$ECHO \"$libname_spec\""`
6072 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6073 set dummy $deplib_matches; shift
6074 deplib_match=$1
6075 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6076 newdeplibs="$newdeplibs $i"
6077 else
6078 droppeddeps=yes
6079 $ECHO
6080 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6081 $ECHO "*** I have the capability to make that library automatically link in when"
6082 $ECHO "*** you link to this library. But I can only do this if you have a"
6083 $ECHO "*** shared version of the library, which you do not appear to have"
6084 $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6085 $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6086 fi
6087 fi
6088 else
6089 droppeddeps=yes
6090 $ECHO
6091 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
6092 $ECHO "*** make it link in! You will probably need to install it or some"
6093 $ECHO "*** library that it depends on before this library will be fully"
6094 $ECHO "*** functional. Installing it before continuing would be even better."
6095 fi
6096 ;;
6097 *)
6098 newdeplibs="$newdeplibs $i"
6099 ;;
6100 esac
6101 done
6102 fi
6103 ;;
6104 file_magic*)
6105 set dummy $deplibs_check_method; shift
6106 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6107 for a_deplib in $deplibs; do
6108 case $a_deplib in
6109 -l*)
6110 func_stripname -l '' "$a_deplib"
6111 name=$func_stripname_result
6112 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6113 case " $predeps $postdeps " in
6114 *" $a_deplib "*)
6115 newdeplibs="$newdeplibs $a_deplib"
6116 a_deplib=""
6117 ;;
6118 esac
6119 fi
6120 if test -n "$a_deplib" ; then
6121 libname=`eval "\\$ECHO \"$libname_spec\""`
6122 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6123 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6124 for potent_lib in $potential_libs; do
6125 # Follow soft links.
6126 if ls -lLd "$potent_lib" 2>/dev/null |
6127 $GREP " -> " >/dev/null; then
6128 continue
6129 fi
6130 # The statement above tries to avoid entering an
6131 # endless loop below, in case of cyclic links.
6132 # We might still enter an endless loop, since a link
6133 # loop can be closed while we follow links,
6134 # but so what?
6135 potlib="$potent_lib"
6136 while test -h "$potlib" 2>/dev/null; do
6137 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6138 case $potliblink in
6139 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6140 *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6141 esac
6142 done
6143 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6144 $SED -e 10q |
6145 $EGREP "$file_magic_regex" > /dev/null; then
6146 newdeplibs="$newdeplibs $a_deplib"
6147 a_deplib=""
6148 break 2
6149 fi
6150 done
6151 done
6152 fi
6153 if test -n "$a_deplib" ; then
6154 droppeddeps=yes
6155 $ECHO
6156 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6157 $ECHO "*** I have the capability to make that library automatically link in when"
6158 $ECHO "*** you link to this library. But I can only do this if you have a"
6159 $ECHO "*** shared version of the library, which you do not appear to have"
6160 $ECHO "*** because I did check the linker path looking for a file starting"
6161 if test -z "$potlib" ; then
6162 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6163 else
6164 $ECHO "*** with $libname and none of the candidates passed a file format test"
6165 $ECHO "*** using a file magic. Last file checked: $potlib"
6166 fi
6167 fi
6168 ;;
6169 *)
6170 # Add a -L argument.
6171 newdeplibs="$newdeplibs $a_deplib"
6172 ;;
6173 esac
6174 done # Gone through all deplibs.
6175 ;;
6176 match_pattern*)
6177 set dummy $deplibs_check_method; shift
6178 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6179 for a_deplib in $deplibs; do
6180 case $a_deplib in
6181 -l*)
6182 func_stripname -l '' "$a_deplib"
6183 name=$func_stripname_result
6184 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6185 case " $predeps $postdeps " in
6186 *" $a_deplib "*)
6187 newdeplibs="$newdeplibs $a_deplib"
6188 a_deplib=""
6189 ;;
6190 esac
6191 fi
6192 if test -n "$a_deplib" ; then
6193 libname=`eval "\\$ECHO \"$libname_spec\""`
6194 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6195 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6196 for potent_lib in $potential_libs; do
6197 potlib="$potent_lib" # see symlink-check above in file_magic test
6198 if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6199 $EGREP "$match_pattern_regex" > /dev/null; then
6200 newdeplibs="$newdeplibs $a_deplib"
6201 a_deplib=""
6202 break 2
6203 fi
6204 done
6205 done
6206 fi
6207 if test -n "$a_deplib" ; then
6208 droppeddeps=yes
6209 $ECHO
6210 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6211 $ECHO "*** I have the capability to make that library automatically link in when"
6212 $ECHO "*** you link to this library. But I can only do this if you have a"
6213 $ECHO "*** shared version of the library, which you do not appear to have"
6214 $ECHO "*** because I did check the linker path looking for a file starting"
6215 if test -z "$potlib" ; then
6216 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6217 else
6218 $ECHO "*** with $libname and none of the candidates passed a file format test"
6219 $ECHO "*** using a regex pattern. Last file checked: $potlib"
6220 fi
6221 fi
6222 ;;
6223 *)
6224 # Add a -L argument.
6225 newdeplibs="$newdeplibs $a_deplib"
6226 ;;
6227 esac
6228 done # Gone through all deplibs.
6229 ;;
6230 none | unknown | *)
6231 newdeplibs=""
6232 tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6233 -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6234 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6235 for i in $predeps $postdeps ; do
6236 # can't use Xsed below, because $i might contain '/'
6237 tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6238 done
6239 fi
6240 if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' |
6241 $GREP . >/dev/null; then
6242 $ECHO
6243 if test "X$deplibs_check_method" = "Xnone"; then
6244 $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6245 else
6246 $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6247 fi
6248 $ECHO "*** All declared inter-library dependencies are being dropped."
6249 droppeddeps=yes
6250 fi
6251 ;;
6252 esac
6253 versuffix=$versuffix_save
6254 major=$major_save
6255 release=$release_save
6256 libname=$libname_save
6257 name=$name_save
6258
6259 case $host in
6260 *-*-rhapsody* | *-*-darwin1.[012])
6261 # On Rhapsody replace the C library with the System framework
6262 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6263 ;;
6264 esac
6265
6266 if test "$droppeddeps" = yes; then
6267 if test "$module" = yes; then
6268 $ECHO
6269 $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6270 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
6271 $ECHO "*** a static module, that should work as long as the dlopening"
6272 $ECHO "*** application is linked with the -dlopen flag."
6273 if test -z "$global_symbol_pipe"; then
6274 $ECHO
6275 $ECHO "*** However, this would only work if libtool was able to extract symbol"
6276 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6277 $ECHO "*** not find such a program. So, this module is probably useless."
6278 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6279 fi
6280 if test "$build_old_libs" = no; then
6281 oldlibs="$output_objdir/$libname.$libext"
6282 build_libtool_libs=module
6283 build_old_libs=yes
6284 else
6285 build_libtool_libs=no
6286 fi
6287 else
6288 $ECHO "*** The inter-library dependencies that have been dropped here will be"
6289 $ECHO "*** automatically added whenever a program is linked with this library"
6290 $ECHO "*** or is declared to -dlopen it."
6291
6292 if test "$allow_undefined" = no; then
6293 $ECHO
6294 $ECHO "*** Since this library must not contain undefined symbols,"
6295 $ECHO "*** because either the platform does not support them or"
6296 $ECHO "*** it was explicitly requested with -no-undefined,"
6297 $ECHO "*** libtool will only create a static version of it."
6298 if test "$build_old_libs" = no; then
6299 oldlibs="$output_objdir/$libname.$libext"
6300 build_libtool_libs=module
6301 build_old_libs=yes
6302 else
6303 build_libtool_libs=no
6304 fi
6305 fi
6306 fi
6307 fi
6308 # Done checking deplibs!
6309 deplibs=$newdeplibs
6310 fi
6311 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6312 case $host in
6313 *-*-darwin*)
6314 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6315 new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6316 deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6317 ;;
6318 esac
6319
6320 # move library search paths that coincide with paths to not yet
6321 # installed libraries to the beginning of the library search list
6322 new_libs=
6323 for path in $notinst_path; do
6324 case " $new_libs " in
6325 *" -L$path/$objdir "*) ;;
6326 *)
6327 case " $deplibs " in
6328 *" -L$path/$objdir "*)
6329 new_libs="$new_libs -L$path/$objdir" ;;
6330 esac
6331 ;;
6332 esac
6333 done
6334 for deplib in $deplibs; do
6335 case $deplib in
6336 -L*)
6337 case " $new_libs " in
6338 *" $deplib "*) ;;
6339 *) new_libs="$new_libs $deplib" ;;
6340 esac
6341 ;;
6342 *) new_libs="$new_libs $deplib" ;;
6343 esac
6344 done
6345 deplibs="$new_libs"
6346
6347 # All the library-specific variables (install_libdir is set above).
6348 library_names=
6349 old_library=
6350 dlname=
6351
6352 # Test again, we may have decided not to build it any more
6353 if test "$build_libtool_libs" = yes; then
6354 if test "$hardcode_into_libs" = yes; then
6355 # Hardcode the library paths
6356 hardcode_libdirs=
6357 dep_rpath=
6358 rpath="$finalize_rpath"
6359 test "$mode" != relink && rpath="$compile_rpath$rpath"
6360 for libdir in $rpath; do
6361 if test -n "$hardcode_libdir_flag_spec"; then
6362 if test -n "$hardcode_libdir_separator"; then
6363 if test -z "$hardcode_libdirs"; then
6364 hardcode_libdirs="$libdir"
6365 else
6366 # Just accumulate the unique libdirs.
6367 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6368 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6369 ;;
6370 *)
6371 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6372 ;;
6373 esac
6374 fi
6375 else
6376 eval flag=\"$hardcode_libdir_flag_spec\"
6377 dep_rpath="$dep_rpath $flag"
6378 fi
6379 elif test -n "$runpath_var"; then
6380 case "$perm_rpath " in
6381 *" $libdir "*) ;;
6382 *) perm_rpath="$perm_rpath $libdir" ;;
6383 esac
6384 fi
6385 done
6386 # Substitute the hardcoded libdirs into the rpath.
6387 if test -n "$hardcode_libdir_separator" &&
6388 test -n "$hardcode_libdirs"; then
6389 libdir="$hardcode_libdirs"
6390 if test -n "$hardcode_libdir_flag_spec_ld"; then
6391 eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6392 else
6393 eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6394 fi
6395 fi
6396 if test -n "$runpath_var" && test -n "$perm_rpath"; then
6397 # We should set the runpath_var.
6398 rpath=
6399 for dir in $perm_rpath; do
6400 rpath="$rpath$dir:"
6401 done
6402 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6403 fi
6404 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6405 fi
6406
6407 shlibpath="$finalize_shlibpath"
6408 test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6409 if test -n "$shlibpath"; then
6410 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6411 fi
6412
6413 # Get the real and link names of the library.
6414 eval shared_ext=\"$shrext_cmds\"
6415 eval library_names=\"$library_names_spec\"
6416 set dummy $library_names
6417 shift
6418 realname="$1"
6419 shift
6420
6421 if test -n "$soname_spec"; then
6422 eval soname=\"$soname_spec\"
6423 else
6424 soname="$realname"
6425 fi
6426 if test -z "$dlname"; then
6427 dlname=$soname
6428 fi
6429
6430 lib="$output_objdir/$realname"
6431 linknames=
6432 for link
6433 do
6434 linknames="$linknames $link"
6435 done
6436
6437 # Use standard objects if they are pic
6438 test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6439 test "X$libobjs" = "X " && libobjs=
6440
6441 delfiles=
6442 if test -n "$export_symbols" && test -n "$include_expsyms"; then
6443 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6444 export_symbols="$output_objdir/$libname.uexp"
6445 delfiles="$delfiles $export_symbols"
6446 fi
6447
6448 orig_export_symbols=
6449 case $host_os in
6450 cygwin* | mingw*)
6451 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6452 # exporting using user supplied symfile
6453 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6454 # and it's NOT already a .def file. Must figure out
6455 # which of the given symbols are data symbols and tag
6456 # them as such. So, trigger use of export_symbols_cmds.
6457 # export_symbols gets reassigned inside the "prepare
6458 # the list of exported symbols" if statement, so the
6459 # include_expsyms logic still works.
6460 orig_export_symbols="$export_symbols"
6461 export_symbols=
6462 always_export_symbols=yes
6463 fi
6464 fi
6465 ;;
6466 esac
6467
6468 # Prepare the list of exported symbols
6469 if test -z "$export_symbols"; then
6470 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
6471 func_verbose "generating symbol list for \`$libname.la'"
6472 export_symbols="$output_objdir/$libname.exp"
6473 $opt_dry_run || $RM $export_symbols
6474 cmds=$export_symbols_cmds
6475 save_ifs="$IFS"; IFS='~'
6476 for cmd in $cmds; do
6477 IFS="$save_ifs"
6478 eval cmd=\"$cmd\"
6479 func_len " $cmd"
6480 len=$func_len_result
6481 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
6482 func_show_eval "$cmd" 'exit $?'
6483 skipped_export=false
6484 else
6485 # The command line is too long to execute in one step.
6486 func_verbose "using reloadable object file for export list..."
6487 skipped_export=:
6488 # Break out early, otherwise skipped_export may be
6489 # set to false by a later but shorter cmd.
6490 break
6491 fi
6492 done
6493 IFS="$save_ifs"
6494 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
6495 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
6496 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
6497 fi
6498 fi
6499 fi
6500
6501 if test -n "$export_symbols" && test -n "$include_expsyms"; then
6502 tmp_export_symbols="$export_symbols"
6503 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
6504 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
6505 fi
6506
6507 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
6508 # The given exports_symbols file has to be filtered, so filter it.
6509 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
6510 # FIXME: $output_objdir/$libname.filter potentially contains lots of
6511 # 's' commands which not all seds can handle. GNU sed should be fine
6512 # though. Also, the filter scales superlinearly with the number of
6513 # global variables. join(1) would be nice here, but unfortunately
6514 # isn't a blessed tool.
6515 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
6516 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
6517 export_symbols=$output_objdir/$libname.def
6518 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
6519 fi
6520
6521 tmp_deplibs=
6522 for test_deplib in $deplibs; do
6523 case " $convenience " in
6524 *" $test_deplib "*) ;;
6525 *)
6526 tmp_deplibs="$tmp_deplibs $test_deplib"
6527 ;;
6528 esac
6529 done
6530 deplibs="$tmp_deplibs"
6531
6532 if test -n "$convenience"; then
6533 if test -n "$whole_archive_flag_spec" &&
6534 test "$compiler_needs_object" = yes &&
6535 test -z "$libobjs"; then
6536 # extract the archives, so we have objects to list.
6537 # TODO: could optimize this to just extract one archive.
6538 whole_archive_flag_spec=
6539 fi
6540 if test -n "$whole_archive_flag_spec"; then
6541 save_libobjs=$libobjs
6542 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
6543 test "X$libobjs" = "X " && libobjs=
6544 else
6545 gentop="$output_objdir/${outputname}x"
6546 generated="$generated $gentop"
6547
6548 func_extract_archives $gentop $convenience
6549 libobjs="$libobjs $func_extract_archives_result"
6550 test "X$libobjs" = "X " && libobjs=
6551 fi
6552 fi
6553
6554 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
6555 eval flag=\"$thread_safe_flag_spec\"
6556 linker_flags="$linker_flags $flag"
6557 fi
6558
6559 # Make a backup of the uninstalled library when relinking
6560 if test "$mode" = relink; then
6561 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
6562 fi
6563
6564 # Do each of the archive commands.
6565 if test "$module" = yes && test -n "$module_cmds" ; then
6566 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
6567 eval test_cmds=\"$module_expsym_cmds\"
6568 cmds=$module_expsym_cmds
6569 else
6570 eval test_cmds=\"$module_cmds\"
6571 cmds=$module_cmds
6572 fi
6573 else
6574 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
6575 eval test_cmds=\"$archive_expsym_cmds\"
6576 cmds=$archive_expsym_cmds
6577 else
6578 eval test_cmds=\"$archive_cmds\"
6579 cmds=$archive_cmds
6580 fi
6581 fi
6582
6583 if test "X$skipped_export" != "X:" &&
6584 func_len " $test_cmds" &&
6585 len=$func_len_result &&
6586 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
6587 :
6588 else
6589 # The command line is too long to link in one step, link piecewise
6590 # or, if using GNU ld and skipped_export is not :, use a linker
6591 # script.
6592
6593 # Save the value of $output and $libobjs because we want to
6594 # use them later. If we have whole_archive_flag_spec, we
6595 # want to use save_libobjs as it was before
6596 # whole_archive_flag_spec was expanded, because we can't
6597 # assume the linker understands whole_archive_flag_spec.
6598 # This may have to be revisited, in case too many
6599 # convenience libraries get linked in and end up exceeding
6600 # the spec.
6601 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
6602 save_libobjs=$libobjs
6603 fi
6604 save_output=$output
6605 output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
6606
6607 # Clear the reloadable object creation command queue and
6608 # initialize k to one.
6609 test_cmds=
6610 concat_cmds=
6611 objlist=
6612 last_robj=
6613 k=1
6614
6615 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
6616 output=${output_objdir}/${output_la}.lnkscript
6617 func_verbose "creating GNU ld script: $output"
6618 $ECHO 'INPUT (' > $output
6619 for obj in $save_libobjs
6620 do
6621 $ECHO "$obj" >> $output
6622 done
6623 $ECHO ')' >> $output
6624 delfiles="$delfiles $output"
6625 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
6626 output=${output_objdir}/${output_la}.lnk
6627 func_verbose "creating linker input file list: $output"
6628 : > $output
6629 set x $save_libobjs
6630 shift
6631 firstobj=
6632 if test "$compiler_needs_object" = yes; then
6633 firstobj="$1 "
6634 shift
6635 fi
6636 for obj
6637 do
6638 $ECHO "$obj" >> $output
6639 done
6640 delfiles="$delfiles $output"
6641 output=$firstobj\"$file_list_spec$output\"
6642 else
6643 if test -n "$save_libobjs"; then
6644 func_verbose "creating reloadable object files..."
6645 output=$output_objdir/$output_la-${k}.$objext
6646 eval test_cmds=\"$reload_cmds\"
6647 func_len " $test_cmds"
6648 len0=$func_len_result
6649 len=$len0
6650
6651 # Loop over the list of objects to be linked.
6652 for obj in $save_libobjs
6653 do
6654 func_len " $obj"
6655 func_arith $len + $func_len_result
6656 len=$func_arith_result
6657 if test "X$objlist" = X ||
6658 test "$len" -lt "$max_cmd_len"; then
6659 func_append objlist " $obj"
6660 else
6661 # The command $test_cmds is almost too long, add a
6662 # command to the queue.
6663 if test "$k" -eq 1 ; then
6664 # The first file doesn't have a previous command to add.
6665 eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
6666 else
6667 # All subsequent reloadable object files will link in
6668 # the last one created.
6669 eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
6670 fi
6671 last_robj=$output_objdir/$output_la-${k}.$objext
6672 func_arith $k + 1
6673 k=$func_arith_result
6674 output=$output_objdir/$output_la-${k}.$objext
6675 objlist=$obj
6676 func_len " $last_robj"
6677 func_arith $len0 + $func_len_result
6678 len=$func_arith_result
6679 fi
6680 done
6681 # Handle the remaining objects by creating one last
6682 # reloadable object file. All subsequent reloadable object
6683 # files will link in the last one created.
6684 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
6685 eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
6686 if test -n "$last_robj"; then
6687 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
6688 fi
6689 delfiles="$delfiles $output"
6690
6691 else
6692 output=
6693 fi
6694
6695 if ${skipped_export-false}; then
6696 func_verbose "generating symbol list for \`$libname.la'"
6697 export_symbols="$output_objdir/$libname.exp"
6698 $opt_dry_run || $RM $export_symbols
6699 libobjs=$output
6700 # Append the command to create the export file.
6701 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
6702 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
6703 if test -n "$last_robj"; then
6704 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
6705 fi
6706 fi
6707
6708 test -n "$save_libobjs" &&
6709 func_verbose "creating a temporary reloadable object file: $output"
6710
6711 # Loop through the commands generated above and execute them.
6712 save_ifs="$IFS"; IFS='~'
6713 for cmd in $concat_cmds; do
6714 IFS="$save_ifs"
6715 $opt_silent || {
6716 func_quote_for_expand "$cmd"
6717 eval "func_echo $func_quote_for_expand_result"
6718 }
6719 $opt_dry_run || eval "$cmd" || {
6720 lt_exit=$?
6721
6722 # Restore the uninstalled library and exit
6723 if test "$mode" = relink; then
6724 ( cd "$output_objdir" && \
6725 $RM "${realname}T" && \
6726 $MV "${realname}U" "$realname" )
6727 fi
6728
6729 exit $lt_exit
6730 }
6731 done
6732 IFS="$save_ifs"
6733
6734 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
6735 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
6736 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
6737 fi
6738 fi
6739
6740 if ${skipped_export-false}; then
6741 if test -n "$export_symbols" && test -n "$include_expsyms"; then
6742 tmp_export_symbols="$export_symbols"
6743 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
6744 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
6745 fi
6746
6747 if test -n "$orig_export_symbols"; then
6748 # The given exports_symbols file has to be filtered, so filter it.
6749 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
6750 # FIXME: $output_objdir/$libname.filter potentially contains lots of
6751 # 's' commands which not all seds can handle. GNU sed should be fine
6752 # though. Also, the filter scales superlinearly with the number of
6753 # global variables. join(1) would be nice here, but unfortunately
6754 # isn't a blessed tool.
6755 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
6756 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
6757 export_symbols=$output_objdir/$libname.def
6758 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
6759 fi
6760 fi
6761
6762 libobjs=$output
6763 # Restore the value of output.
6764 output=$save_output
6765
6766 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
6767 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
6768 test "X$libobjs" = "X " && libobjs=
6769 fi
6770 # Expand the library linking commands again to reset the
6771 # value of $libobjs for piecewise linking.
6772
6773 # Do each of the archive commands.
6774 if test "$module" = yes && test -n "$module_cmds" ; then
6775 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
6776 cmds=$module_expsym_cmds
6777 else
6778 cmds=$module_cmds
6779 fi
6780 else
6781 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
6782 cmds=$archive_expsym_cmds
6783 else
6784 cmds=$archive_cmds
6785 fi
6786 fi
6787 fi
6788
6789 if test -n "$delfiles"; then
6790 # Append the command to remove temporary files to $cmds.
6791 eval cmds=\"\$cmds~\$RM $delfiles\"
6792 fi
6793
6794 # Add any objects from preloaded convenience libraries
6795 if test -n "$dlprefiles"; then
6796 gentop="$output_objdir/${outputname}x"
6797 generated="$generated $gentop"
6798
6799 func_extract_archives $gentop $dlprefiles
6800 libobjs="$libobjs $func_extract_archives_result"
6801 test "X$libobjs" = "X " && libobjs=
6802 fi
6803
6804 save_ifs="$IFS"; IFS='~'
6805 for cmd in $cmds; do
6806 IFS="$save_ifs"
6807 eval cmd=\"$cmd\"
6808 $opt_silent || {
6809 func_quote_for_expand "$cmd"
6810 eval "func_echo $func_quote_for_expand_result"
6811 }
6812 $opt_dry_run || eval "$cmd" || {
6813 lt_exit=$?
6814
6815 # Restore the uninstalled library and exit
6816 if test "$mode" = relink; then
6817 ( cd "$output_objdir" && \
6818 $RM "${realname}T" && \
6819 $MV "${realname}U" "$realname" )
6820 fi
6821
6822 exit $lt_exit
6823 }
6824 done
6825 IFS="$save_ifs"
6826
6827 # Restore the uninstalled library and exit
6828 if test "$mode" = relink; then
6829 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
6830
6831 if test -n "$convenience"; then
6832 if test -z "$whole_archive_flag_spec"; then
6833 func_show_eval '${RM}r "$gentop"'
6834 fi
6835 fi
6836
6837 exit $EXIT_SUCCESS
6838 fi
6839
6840 # Create links to the real library.
6841 for linkname in $linknames; do
6842 if test "$realname" != "$linkname"; then
6843 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
6844 fi
6845 done
6846
6847 # If -module or -export-dynamic was specified, set the dlname.
6848 if test "$module" = yes || test "$export_dynamic" = yes; then
6849 # On all known operating systems, these are identical.
6850 dlname="$soname"
6851 fi
6852 fi
6853 ;;
6854
6855 obj)
6856 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6857 func_warning "\`-dlopen' is ignored for objects"
6858 fi
6859
6860 case " $deplibs" in
6861 *\ -l* | *\ -L*)
6862 func_warning "\`-l' and \`-L' are ignored for objects" ;;
6863 esac
6864
6865 test -n "$rpath" && \
6866 func_warning "\`-rpath' is ignored for objects"
6867
6868 test -n "$xrpath" && \
6869 func_warning "\`-R' is ignored for objects"
6870
6871 test -n "$vinfo" && \
6872 func_warning "\`-version-info' is ignored for objects"
6873
6874 test -n "$release" && \
6875 func_warning "\`-release' is ignored for objects"
6876
6877 case $output in
6878 *.lo)
6879 test -n "$objs$old_deplibs" && \
6880 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
6881
6882 libobj=$output
6883 func_lo2o "$libobj"
6884 obj=$func_lo2o_result
6885 ;;
6886 *)
6887 libobj=
6888 obj="$output"
6889 ;;
6890 esac
6891
6892 # Delete the old objects.
6893 $opt_dry_run || $RM $obj $libobj
6894
6895 # Objects from convenience libraries. This assumes
6896 # single-version convenience libraries. Whenever we create
6897 # different ones for PIC/non-PIC, this we'll have to duplicate
6898 # the extraction.
6899 reload_conv_objs=
6900 gentop=
6901 # reload_cmds runs $LD directly, so let us get rid of
6902 # -Wl from whole_archive_flag_spec and hope we can get by with
6903 # turning comma into space..
6904 wl=
6905
6906 if test -n "$convenience"; then
6907 if test -n "$whole_archive_flag_spec"; then
6908 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
6909 reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
6910 else
6911 gentop="$output_objdir/${obj}x"
6912 generated="$generated $gentop"
6913
6914 func_extract_archives $gentop $convenience
6915 reload_conv_objs="$reload_objs $func_extract_archives_result"
6916 fi
6917 fi
6918
6919 # Create the old-style object.
6920 reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
6921
6922 output="$obj"
6923 func_execute_cmds "$reload_cmds" 'exit $?'
6924
6925 # Exit if we aren't doing a library object file.
6926 if test -z "$libobj"; then
6927 if test -n "$gentop"; then
6928 func_show_eval '${RM}r "$gentop"'
6929 fi
6930
6931 exit $EXIT_SUCCESS
6932 fi
6933
6934 if test "$build_libtool_libs" != yes; then
6935 if test -n "$gentop"; then
6936 func_show_eval '${RM}r "$gentop"'
6937 fi
6938
6939 # Create an invalid libtool object if no PIC, so that we don't
6940 # accidentally link it into a program.
6941 # $show "echo timestamp > $libobj"
6942 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
6943 exit $EXIT_SUCCESS
6944 fi
6945
6946 if test -n "$pic_flag" || test "$pic_mode" != default; then
6947 # Only do commands if we really have different PIC objects.
6948 reload_objs="$libobjs $reload_conv_objs"
6949 output="$libobj"
6950 func_execute_cmds "$reload_cmds" 'exit $?'
6951 fi
6952
6953 if test -n "$gentop"; then
6954 func_show_eval '${RM}r "$gentop"'
6955 fi
6956
6957 exit $EXIT_SUCCESS
6958 ;;
6959
6960 prog)
6961 case $host in
6962 *cygwin*) func_stripname '' '.exe' "$output"
6963 output=$func_stripname_result.exe;;
6964 esac
6965 test -n "$vinfo" && \
6966 func_warning "\`-version-info' is ignored for programs"
6967
6968 test -n "$release" && \
6969 func_warning "\`-release' is ignored for programs"
6970
6971 test "$preload" = yes \
6972 && test "$dlopen_support" = unknown \
6973 && test "$dlopen_self" = unknown \
6974 && test "$dlopen_self_static" = unknown && \
6975 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
6976
6977 case $host in
6978 *-*-rhapsody* | *-*-darwin1.[012])
6979 # On Rhapsody replace the C library is the System framework
6980 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6981 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6982 ;;
6983 esac
6984
6985 case $host in
6986 *-*-darwin*)
6987 # Don't allow lazy linking, it breaks C++ global constructors
6988 # But is supposedly fixed on 10.4 or later (yay!).
6989 if test "$tagname" = CXX ; then
6990 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
6991 10.[0123])
6992 compile_command="$compile_command ${wl}-bind_at_load"
6993 finalize_command="$finalize_command ${wl}-bind_at_load"
6994 ;;
6995 esac
6996 fi
6997 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6998 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6999 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7000 ;;
7001 esac
7002
7003
7004 # move library search paths that coincide with paths to not yet
7005 # installed libraries to the beginning of the library search list
7006 new_libs=
7007 for path in $notinst_path; do
7008 case " $new_libs " in
7009 *" -L$path/$objdir "*) ;;
7010 *)
7011 case " $compile_deplibs " in
7012 *" -L$path/$objdir "*)
7013 new_libs="$new_libs -L$path/$objdir" ;;
7014 esac
7015 ;;
7016 esac
7017 done
7018 for deplib in $compile_deplibs; do
7019 case $deplib in
7020 -L*)
7021 case " $new_libs " in
7022 *" $deplib "*) ;;
7023 *) new_libs="$new_libs $deplib" ;;
7024 esac
7025 ;;
7026 *) new_libs="$new_libs $deplib" ;;
7027 esac
7028 done
7029 compile_deplibs="$new_libs"
7030
7031
7032 compile_command="$compile_command $compile_deplibs"
7033 finalize_command="$finalize_command $finalize_deplibs"
7034
7035 if test -n "$rpath$xrpath"; then
7036 # If the user specified any rpath flags, then add them.
7037 for libdir in $rpath $xrpath; do
7038 # This is the magic to use -rpath.
7039 case "$finalize_rpath " in
7040 *" $libdir "*) ;;
7041 *) finalize_rpath="$finalize_rpath $libdir" ;;
7042 esac
7043 done
7044 fi
7045
7046 # Now hardcode the library paths
7047 rpath=
7048 hardcode_libdirs=
7049 for libdir in $compile_rpath $finalize_rpath; do
7050 if test -n "$hardcode_libdir_flag_spec"; then
7051 if test -n "$hardcode_libdir_separator"; then
7052 if test -z "$hardcode_libdirs"; then
7053 hardcode_libdirs="$libdir"
7054 else
7055 # Just accumulate the unique libdirs.
7056 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7057 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7058 ;;
7059 *)
7060 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7061 ;;
7062 esac
7063 fi
7064 else
7065 eval flag=\"$hardcode_libdir_flag_spec\"
7066 rpath="$rpath $flag"
7067 fi
7068 elif test -n "$runpath_var"; then
7069 case "$perm_rpath " in
7070 *" $libdir "*) ;;
7071 *) perm_rpath="$perm_rpath $libdir" ;;
7072 esac
7073 fi
7074 case $host in
7075 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
7076 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7077 case :$dllsearchpath: in
7078 *":$libdir:"*) ;;
7079 *) dllsearchpath="$dllsearchpath:$libdir";;
7080 esac
7081 case :$dllsearchpath: in
7082 *":$testbindir:"*) ;;
7083 *) dllsearchpath="$dllsearchpath:$testbindir";;
7084 esac
7085 ;;
7086 esac
7087 done
7088 # Substitute the hardcoded libdirs into the rpath.
7089 if test -n "$hardcode_libdir_separator" &&
7090 test -n "$hardcode_libdirs"; then
7091 libdir="$hardcode_libdirs"
7092 eval rpath=\" $hardcode_libdir_flag_spec\"
7093 fi
7094 compile_rpath="$rpath"
7095
7096 rpath=
7097 hardcode_libdirs=
7098 for libdir in $finalize_rpath; do
7099 if test -n "$hardcode_libdir_flag_spec"; then
7100 if test -n "$hardcode_libdir_separator"; then
7101 if test -z "$hardcode_libdirs"; then
7102 hardcode_libdirs="$libdir"
7103 else
7104 # Just accumulate the unique libdirs.
7105 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7106 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7107 ;;
7108 *)
7109 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7110 ;;
7111 esac
7112 fi
7113 else
7114 eval flag=\"$hardcode_libdir_flag_spec\"
7115 rpath="$rpath $flag"
7116 fi
7117 elif test -n "$runpath_var"; then
7118 case "$finalize_perm_rpath " in
7119 *" $libdir "*) ;;
7120 *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7121 esac
7122 fi
7123 done
7124 # Substitute the hardcoded libdirs into the rpath.
7125 if test -n "$hardcode_libdir_separator" &&
7126 test -n "$hardcode_libdirs"; then
7127 libdir="$hardcode_libdirs"
7128 eval rpath=\" $hardcode_libdir_flag_spec\"
7129 fi
7130 finalize_rpath="$rpath"
7131
7132 if test -n "$libobjs" && test "$build_old_libs" = yes; then
7133 # Transform all the library objects into standard objects.
7134 compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7135 finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7136 fi
7137
7138 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7139
7140 # template prelinking step
7141 if test -n "$prelink_cmds"; then
7142 func_execute_cmds "$prelink_cmds" 'exit $?'
7143 fi
7144
7145 wrappers_required=yes
7146 case $host in
7147 *cygwin* | *mingw* )
7148 if test "$build_libtool_libs" != yes; then
7149 wrappers_required=no
7150 fi
7151 ;;
7152 *)
7153 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7154 wrappers_required=no
7155 fi
7156 ;;
7157 esac
7158 if test "$wrappers_required" = no; then
7159 # Replace the output file specification.
7160 compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7161 link_command="$compile_command$compile_rpath"
7162
7163 # We have no uninstalled library dependencies, so finalize right now.
7164 exit_status=0
7165 func_show_eval "$link_command" 'exit_status=$?'
7166
7167 # Delete the generated files.
7168 if test -f "$output_objdir/${outputname}S.${objext}"; then
7169 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7170 fi
7171
7172 exit $exit_status
7173 fi
7174
7175 if test -n "$compile_shlibpath$finalize_shlibpath"; then
7176 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7177 fi
7178 if test -n "$finalize_shlibpath"; then
7179 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7180 fi
7181
7182 compile_var=
7183 finalize_var=
7184 if test -n "$runpath_var"; then
7185 if test -n "$perm_rpath"; then
7186 # We should set the runpath_var.
7187 rpath=
7188 for dir in $perm_rpath; do
7189 rpath="$rpath$dir:"
7190 done
7191 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7192 fi
7193 if test -n "$finalize_perm_rpath"; then
7194 # We should set the runpath_var.
7195 rpath=
7196 for dir in $finalize_perm_rpath; do
7197 rpath="$rpath$dir:"
7198 done
7199 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7200 fi
7201 fi
7202
7203 if test "$no_install" = yes; then
7204 # We don't need to create a wrapper script.
7205 link_command="$compile_var$compile_command$compile_rpath"
7206 # Replace the output file specification.
7207 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7208 # Delete the old output file.
7209 $opt_dry_run || $RM $output
7210 # Link the executable and exit
7211 func_show_eval "$link_command" 'exit $?'
7212 exit $EXIT_SUCCESS
7213 fi
7214
7215 if test "$hardcode_action" = relink; then
7216 # Fast installation is not supported
7217 link_command="$compile_var$compile_command$compile_rpath"
7218 relink_command="$finalize_var$finalize_command$finalize_rpath"
7219
7220 func_warning "this platform does not like uninstalled shared libraries"
7221 func_warning "\`$output' will be relinked during installation"
7222 else
7223 if test "$fast_install" != no; then
7224 link_command="$finalize_var$compile_command$finalize_rpath"
7225 if test "$fast_install" = yes; then
7226 relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7227 else
7228 # fast_install is set to needless
7229 relink_command=
7230 fi
7231 else
7232 link_command="$compile_var$compile_command$compile_rpath"
7233 relink_command="$finalize_var$finalize_command$finalize_rpath"
7234 fi
7235 fi
7236
7237 # Replace the output file specification.
7238 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
7239
7240 # Delete the old output files.
7241 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
7242
7243 func_show_eval "$link_command" 'exit $?'
7244
7245 # Now create the wrapper script.
7246 func_verbose "creating $output"
7247
7248 # Quote the relink command for shipping.
7249 if test -n "$relink_command"; then
7250 # Preserve any variables that may affect compiler behavior
7251 for var in $variables_saved_for_relink; do
7252 if eval test -z \"\${$var+set}\"; then
7253 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7254 elif eval var_value=\$$var; test -z "$var_value"; then
7255 relink_command="$var=; export $var; $relink_command"
7256 else
7257 func_quote_for_eval "$var_value"
7258 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
7259 fi
7260 done
7261 relink_command="(cd `pwd`; $relink_command)"
7262 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7263 fi
7264
7265 # Quote $ECHO for shipping.
7266 if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7267 case $progpath in
7268 [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7269 *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7270 esac
7271 qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7272 else
7273 qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7274 fi
7275
7276 # Only actually do things if not in dry run mode.
7277 $opt_dry_run || {
7278 # win32 will think the script is a binary if it has
7279 # a .exe suffix, so we strip it off here.
7280 case $output in
7281 *.exe) func_stripname '' '.exe' "$output"
7282 output=$func_stripname_result ;;
7283 esac
7284 # test for cygwin because mv fails w/o .exe extensions
7285 case $host in
7286 *cygwin*)
7287 exeext=.exe
7288 func_stripname '' '.exe' "$outputname"
7289 outputname=$func_stripname_result ;;
7290 *) exeext= ;;
7291 esac
7292 case $host in
7293 *cygwin* | *mingw* )
7294 func_dirname_and_basename "$output" "" "."
7295 output_name=$func_basename_result
7296 output_path=$func_dirname_result
7297 cwrappersource="$output_path/$objdir/lt-$output_name.c"
7298 cwrapper="$output_path/$output_name.exe"
7299 $RM $cwrappersource $cwrapper
7300 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7301
7302 func_emit_cwrapperexe_src > $cwrappersource
7303
7304 # we should really use a build-platform specific compiler
7305 # here, but OTOH, the wrappers (shell script and this C one)
7306 # are only useful if you want to execute the "real" binary.
7307 # Since the "real" binary is built for $host, then this
7308 # wrapper might as well be built for $host, too.
7309 $opt_dry_run || {
7310 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7311 $STRIP $cwrapper
7312 }
7313
7314 # Now, create the wrapper script for func_source use:
7315 func_ltwrapper_scriptname $cwrapper
7316 $RM $func_ltwrapper_scriptname_result
7317 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7318 $opt_dry_run || {
7319 # note: this script will not be executed, so do not chmod.
7320 if test "x$build" = "x$host" ; then
7321 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7322 else
7323 func_emit_wrapper no > $func_ltwrapper_scriptname_result
7324 fi
7325 }
7326 ;;
7327 * )
7328 $RM $output
7329 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
7330
7331 func_emit_wrapper no > $output
7332 chmod +x $output
7333 ;;
7334 esac
7335 }
7336 exit $EXIT_SUCCESS
7337 ;;
7338 esac
7339
7340 # See if we need to build an old-fashioned archive.
7341 for oldlib in $oldlibs; do
7342
7343 if test "$build_libtool_libs" = convenience; then
7344 oldobjs="$libobjs_save $symfileobj"
7345 addlibs="$convenience"
7346 build_libtool_libs=no
7347 else
7348 if test "$build_libtool_libs" = module; then
7349 oldobjs="$libobjs_save"
7350 build_libtool_libs=no
7351 else
7352 oldobjs="$old_deplibs $non_pic_objects"
7353 if test "$preload" = yes && test -f "$symfileobj"; then
7354 oldobjs="$oldobjs $symfileobj"
7355 fi
7356 fi
7357 addlibs="$old_convenience"
7358 fi
7359
7360 if test -n "$addlibs"; then
7361 gentop="$output_objdir/${outputname}x"
7362 generated="$generated $gentop"
7363
7364 func_extract_archives $gentop $addlibs
7365 oldobjs="$oldobjs $func_extract_archives_result"
7366 fi
7367
7368 # Do each command in the archive commands.
7369 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7370 cmds=$old_archive_from_new_cmds
7371 else
7372
7373 # Add any objects from preloaded convenience libraries
7374 if test -n "$dlprefiles"; then
7375 gentop="$output_objdir/${outputname}x"
7376 generated="$generated $gentop"
7377
7378 func_extract_archives $gentop $dlprefiles
7379 oldobjs="$oldobjs $func_extract_archives_result"
7380 fi
7381
7382 # POSIX demands no paths to be encoded in archives. We have
7383 # to avoid creating archives with duplicate basenames if we
7384 # might have to extract them afterwards, e.g., when creating a
7385 # static archive out of a convenience library, or when linking
7386 # the entirety of a libtool archive into another (currently
7387 # not supported by libtool).
7388 if (for obj in $oldobjs
7389 do
7390 func_basename "$obj"
7391 $ECHO "$func_basename_result"
7392 done | sort | sort -uc >/dev/null 2>&1); then
7393 :
7394 else
7395 $ECHO "copying selected object files to avoid basename conflicts..."
7396 gentop="$output_objdir/${outputname}x"
7397 generated="$generated $gentop"
7398 func_mkdir_p "$gentop"
7399 save_oldobjs=$oldobjs
7400 oldobjs=
7401 counter=1
7402 for obj in $save_oldobjs
7403 do
7404 func_basename "$obj"
7405 objbase="$func_basename_result"
7406 case " $oldobjs " in
7407 " ") oldobjs=$obj ;;
7408 *[\ /]"$objbase "*)
7409 while :; do
7410 # Make sure we don't pick an alternate name that also
7411 # overlaps.
7412 newobj=lt$counter-$objbase
7413 func_arith $counter + 1
7414 counter=$func_arith_result
7415 case " $oldobjs " in
7416 *[\ /]"$newobj "*) ;;
7417 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
7418 esac
7419 done
7420 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
7421 oldobjs="$oldobjs $gentop/$newobj"
7422 ;;
7423 *) oldobjs="$oldobjs $obj" ;;
7424 esac
7425 done
7426 fi
7427 eval cmds=\"$old_archive_cmds\"
7428
7429 func_len " $cmds"
7430 len=$func_len_result
7431 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7432 cmds=$old_archive_cmds
7433 else
7434 # the command line is too long to link in one step, link in parts
7435 func_verbose "using piecewise archive linking..."
7436 save_RANLIB=$RANLIB
7437 RANLIB=:
7438 objlist=
7439 concat_cmds=
7440 save_oldobjs=$oldobjs
7441 oldobjs=
7442 # Is there a better way of finding the last object in the list?
7443 for obj in $save_oldobjs
7444 do
7445 last_oldobj=$obj
7446 done
7447 eval test_cmds=\"$old_archive_cmds\"
7448 func_len " $test_cmds"
7449 len0=$func_len_result
7450 len=$len0
7451 for obj in $save_oldobjs
7452 do
7453 func_len " $obj"
7454 func_arith $len + $func_len_result
7455 len=$func_arith_result
7456 func_append objlist " $obj"
7457 if test "$len" -lt "$max_cmd_len"; then
7458 :
7459 else
7460 # the above command should be used before it gets too long
7461 oldobjs=$objlist
7462 if test "$obj" = "$last_oldobj" ; then
7463 RANLIB=$save_RANLIB
7464 fi
7465 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7466 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
7467 objlist=
7468 len=$len0
7469 fi
7470 done
7471 RANLIB=$save_RANLIB
7472 oldobjs=$objlist
7473 if test "X$oldobjs" = "X" ; then
7474 eval cmds=\"\$concat_cmds\"
7475 else
7476 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
7477 fi
7478 fi
7479 fi
7480 func_execute_cmds "$cmds" 'exit $?'
7481 done
7482
7483 test -n "$generated" && \
7484 func_show_eval "${RM}r$generated"
7485
7486 # Now create the libtool archive.
7487 case $output in
7488 *.la)
7489 old_library=
7490 test "$build_old_libs" = yes && old_library="$libname.$libext"
7491 func_verbose "creating $output"
7492
7493 # Preserve any variables that may affect compiler behavior
7494 for var in $variables_saved_for_relink; do
7495 if eval test -z \"\${$var+set}\"; then
7496 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7497 elif eval var_value=\$$var; test -z "$var_value"; then
7498 relink_command="$var=; export $var; $relink_command"
7499 else
7500 func_quote_for_eval "$var_value"
7501 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
7502 fi
7503 done
7504 # Quote the link command for shipping.
7505 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
7506 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7507 if test "$hardcode_automatic" = yes ; then
7508 relink_command=
7509 fi
7510
7511 # Only create the output if not a dry run.
7512 $opt_dry_run || {
7513 for installed in no yes; do
7514 if test "$installed" = yes; then
7515 if test -z "$install_libdir"; then
7516 break
7517 fi
7518 output="$output_objdir/$outputname"i
7519 # Replace all uninstalled libtool libraries with the installed ones
7520 newdependency_libs=
7521 for deplib in $dependency_libs; do
7522 case $deplib in
7523 *.la)
7524 func_basename "$deplib"
7525 name="$func_basename_result"
7526 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
7527 test -z "$libdir" && \
7528 func_fatal_error "\`$deplib' is not a valid libtool archive"
7529 newdependency_libs="$newdependency_libs $libdir/$name"
7530 ;;
7531 *) newdependency_libs="$newdependency_libs $deplib" ;;
7532 esac
7533 done
7534 dependency_libs="$newdependency_libs"
7535 newdlfiles=
7536
7537 for lib in $dlfiles; do
7538 case $lib in
7539 *.la)
7540 func_basename "$lib"
7541 name="$func_basename_result"
7542 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
7543 test -z "$libdir" && \
7544 func_fatal_error "\`$lib' is not a valid libtool archive"
7545 newdlfiles="$newdlfiles $libdir/$name"
7546 ;;
7547 *) newdlfiles="$newdlfiles $lib" ;;
7548 esac
7549 done
7550 dlfiles="$newdlfiles"
7551 newdlprefiles=
7552 for lib in $dlprefiles; do
7553 case $lib in
7554 *.la)
7555 # Only pass preopened files to the pseudo-archive (for
7556 # eventual linking with the app. that links it) if we
7557 # didn't already link the preopened objects directly into
7558 # the library:
7559 func_basename "$lib"
7560 name="$func_basename_result"
7561 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
7562 test -z "$libdir" && \
7563 func_fatal_error "\`$lib' is not a valid libtool archive"
7564 newdlprefiles="$newdlprefiles $libdir/$name"
7565 ;;
7566 esac
7567 done
7568 dlprefiles="$newdlprefiles"
7569 else
7570 newdlfiles=
7571 for lib in $dlfiles; do
7572 case $lib in
7573 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
7574 *) abs=`pwd`"/$lib" ;;
7575 esac
7576 newdlfiles="$newdlfiles $abs"
7577 done
7578 dlfiles="$newdlfiles"
7579 newdlprefiles=
7580 for lib in $dlprefiles; do
7581 case $lib in
7582 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
7583 *) abs=`pwd`"/$lib" ;;
7584 esac
7585 newdlprefiles="$newdlprefiles $abs"
7586 done
7587 dlprefiles="$newdlprefiles"
7588 fi
7589 $RM $output
7590 # place dlname in correct position for cygwin
7591 tdlname=$dlname
7592 case $host,$output,$installed,$module,$dlname in
7593 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
7594 esac
7595 $ECHO > $output "\
7596 # $outputname - a libtool library file
7597 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
7598 #
7599 # Please DO NOT delete this file!
7600 # It is necessary for linking the library.
7601
7602 # The name that we can dlopen(3).
7603 dlname='$tdlname'
7604
7605 # Names of this library.
7606 library_names='$library_names'
7607
7608 # The name of the static archive.
7609 old_library='$old_library'
7610
7611 # Linker flags that can not go in dependency_libs.
7612 inherited_linker_flags='$new_inherited_linker_flags'
7613
7614 # Libraries that this one depends upon.
7615 dependency_libs='$dependency_libs'
7616
7617 # Names of additional weak libraries provided by this library
7618 weak_library_names='$weak_libs'
7619
7620 # Version information for $libname.
7621 current=$current
7622 age=$age
7623 revision=$revision
7624
7625 # Is this an already installed library?
7626 installed=$installed
7627
7628 # Should we warn about portability when linking against -modules?
7629 shouldnotlink=$module
7630
7631 # Files to dlopen/dlpreopen
7632 dlopen='$dlfiles'
7633 dlpreopen='$dlprefiles'
7634
7635 # Directory that this library needs to be installed in:
7636 libdir='$install_libdir'"
7637 if test "$installed" = no && test "$need_relink" = yes; then
7638 $ECHO >> $output "\
7639 relink_command=\"$relink_command\""
7640 fi
7641 done
7642 }
7643
7644 # Do a symbolic link so that the libtool archive can be found in
7645 # LD_LIBRARY_PATH before the program is installed.
7646 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
7647 ;;
7648 esac
7649 exit $EXIT_SUCCESS
7650 }
7651
7652 { test "$mode" = link || test "$mode" = relink; } &&
7653 func_mode_link ${1+"$@"}
7654
7655
7656 # func_mode_uninstall arg...
7657 func_mode_uninstall ()
7658 {
7659 $opt_debug
7660 RM="$nonopt"
7661 files=
7662 rmforce=
7663 exit_status=0
7664
7665 # This variable tells wrapper scripts just to set variables rather
7666 # than running their programs.
7667 libtool_install_magic="$magic"
7668
7669 for arg
7670 do
7671 case $arg in
7672 -f) RM="$RM $arg"; rmforce=yes ;;
7673 -*) RM="$RM $arg" ;;
7674 *) files="$files $arg" ;;
7675 esac
7676 done
7677
7678 test -z "$RM" && \
7679 func_fatal_help "you must specify an RM program"
7680
7681 rmdirs=
7682
7683 origobjdir="$objdir"
7684 for file in $files; do
7685 func_dirname "$file" "" "."
7686 dir="$func_dirname_result"
7687 if test "X$dir" = X.; then
7688 objdir="$origobjdir"
7689 else
7690 objdir="$dir/$origobjdir"
7691 fi
7692 func_basename "$file"
7693 name="$func_basename_result"
7694 test "$mode" = uninstall && objdir="$dir"
7695
7696 # Remember objdir for removal later, being careful to avoid duplicates
7697 if test "$mode" = clean; then
7698 case " $rmdirs " in
7699 *" $objdir "*) ;;
7700 *) rmdirs="$rmdirs $objdir" ;;
7701 esac
7702 fi
7703
7704 # Don't error if the file doesn't exist and rm -f was used.
7705 if { test -L "$file"; } >/dev/null 2>&1 ||
7706 { test -h "$file"; } >/dev/null 2>&1 ||
7707 test -f "$file"; then
7708 :
7709 elif test -d "$file"; then
7710 exit_status=1
7711 continue
7712 elif test "$rmforce" = yes; then
7713 continue
7714 fi
7715
7716 rmfiles="$file"
7717
7718 case $name in
7719 *.la)
7720 # Possibly a libtool archive, so verify it.
7721 if func_lalib_p "$file"; then
7722 func_source $dir/$name
7723
7724 # Delete the libtool libraries and symlinks.
7725 for n in $library_names; do
7726 rmfiles="$rmfiles $objdir/$n"
7727 done
7728 test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
7729
7730 case "$mode" in
7731 clean)
7732 case " $library_names " in
7733 # " " in the beginning catches empty $dlname
7734 *" $dlname "*) ;;
7735 *) rmfiles="$rmfiles $objdir/$dlname" ;;
7736 esac
7737 test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
7738 ;;
7739 uninstall)
7740 if test -n "$library_names"; then
7741 # Do each command in the postuninstall commands.
7742 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
7743 fi
7744
7745 if test -n "$old_library"; then
7746 # Do each command in the old_postuninstall commands.
7747 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
7748 fi
7749 # FIXME: should reinstall the best remaining shared library.
7750 ;;
7751 esac
7752 fi
7753 ;;
7754
7755 *.lo)
7756 # Possibly a libtool object, so verify it.
7757 if func_lalib_p "$file"; then
7758
7759 # Read the .lo file
7760 func_source $dir/$name
7761
7762 # Add PIC object to the list of files to remove.
7763 if test -n "$pic_object" &&
7764 test "$pic_object" != none; then
7765 rmfiles="$rmfiles $dir/$pic_object"
7766 fi
7767
7768 # Add non-PIC object to the list of files to remove.
7769 if test -n "$non_pic_object" &&
7770 test "$non_pic_object" != none; then
7771 rmfiles="$rmfiles $dir/$non_pic_object"
7772 fi
7773 fi
7774 ;;
7775
7776 *)
7777 if test "$mode" = clean ; then
7778 noexename=$name
7779 case $file in
7780 *.exe)
7781 func_stripname '' '.exe' "$file"
7782 file=$func_stripname_result
7783 func_stripname '' '.exe' "$name"
7784 noexename=$func_stripname_result
7785 # $file with .exe has already been added to rmfiles,
7786 # add $file without .exe
7787 rmfiles="$rmfiles $file"
7788 ;;
7789 esac
7790 # Do a test to see if this is a libtool program.
7791 if func_ltwrapper_p "$file"; then
7792 if func_ltwrapper_executable_p "$file"; then
7793 func_ltwrapper_scriptname "$file"
7794 relink_command=
7795 func_source $func_ltwrapper_scriptname_result
7796 rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
7797 else
7798 relink_command=
7799 func_source $dir/$noexename
7800 fi
7801
7802 # note $name still contains .exe if it was in $file originally
7803 # as does the version of $file that was added into $rmfiles
7804 rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
7805 if test "$fast_install" = yes && test -n "$relink_command"; then
7806 rmfiles="$rmfiles $objdir/lt-$name"
7807 fi
7808 if test "X$noexename" != "X$name" ; then
7809 rmfiles="$rmfiles $objdir/lt-${noexename}.c"
7810 fi
7811 fi
7812 fi
7813 ;;
7814 esac
7815 func_show_eval "$RM $rmfiles" 'exit_status=1'
7816 done
7817 objdir="$origobjdir"
7818
7819 # Try to remove the ${objdir}s in the directories where we deleted files
7820 for dir in $rmdirs; do
7821 if test -d "$dir"; then
7822 func_show_eval "rmdir $dir >/dev/null 2>&1"
7823 fi
7824 done
7825
7826 exit $exit_status
7827 }
7828
7829 { test "$mode" = uninstall || test "$mode" = clean; } &&
7830 func_mode_uninstall ${1+"$@"}
7831
7832 test -z "$mode" && {
7833 help="$generic_help"
7834 func_fatal_help "you must specify a MODE"
7835 }
7836
7837 test -z "$exec_cmd" && \
7838 func_fatal_help "invalid operation mode \`$mode'"
7839
7840 if test -n "$exec_cmd"; then
7841 eval exec "$exec_cmd"
7842 exit $EXIT_FAILURE
7843 fi
7844
7845 exit $exit_status
7846
7847
7848 # The TAGs below are defined such that we never get into a situation
7849 # in which we disable both kinds of libraries. Given conflicting
7850 # choices, we go for a static library, that is the most portable,
7851 # since we can't tell whether shared libraries were disabled because
7852 # the user asked for that or because the platform doesn't support
7853 # them. This is particularly important on AIX, because we don't
7854 # support having both static and shared libraries enabled at the same
7855 # time on that platform, so we default to a shared-only configuration.
7856 # If a disable-shared tag is given, we'll fallback to a static-only
7857 # configuration. But we'll never go from static-only to shared-only.
7858
7859 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
7860 build_libtool_libs=no
7861 build_old_libs=yes
7862 # ### END LIBTOOL TAG CONFIG: disable-shared
7863
7864 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
7865 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
7866 # ### END LIBTOOL TAG CONFIG: disable-static
7867
7868 # Local Variables:
7869 # mode:shell-script
7870 # sh-indentation:2
7871 # End:
7872 # vi:sw=2
7873
0 7z ANSI-C Decoder 4.43
1 ----------------------
2
3 7z ANSI-C Decoder 4.43 Copyright (C) 1999-2006 Igor Pavlov
4
5 7z ANSI-C provides 7z/LZMA decoding.
6 7z ANSI-C version is simplified version ported from C++ code.
7
8 LZMA is default and general compression method of 7z format
9 in 7-Zip compression program (www.7-zip.org). LZMA provides high
10 compression ratio and very fast decompression.
11
12
13 LICENSE
14 -------
15
16 Read lzma.txt for information about license.
17
18
19 Files
20 ---------------------
21
22 7zAlloc.* - Allocate and Free
23 7zBuffer.* - Buffer structure
24 7zCrc.* - CRC32 code
25 7zDecode.* - Low level memory->memory decoding
26 7zExtract.* - High level stream->memory decoding
27 7zHeader.* - .7z format constants
28 7zIn.* - .7z archive opening
29 7zItem.* - .7z structures
30 7zMain.c - Test application
31 7zMethodID.* - MethodID structure
32 7zTypes.h - Base types and constants
33
34
35 How To Use
36 ----------
37
38 You must download 7-Zip program from www.7-zip.org.
39
40 You can create .7z archive with 7z.exe or 7za.exe:
41
42 7za.exe a archive.7z *.htm -r -mx -m0fb=255 -mf=off
43
44 If you have big number of files in archive, and you need fast extracting,
45 you can use partly-solid archives:
46
47 7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K -mf=off
48
49 In that example 7-Zip will use 512KB solid blocks. So it needs to decompress only
50 512KB for extracting one file from such archive.
51
52
53 Limitations of current version of 7z ANSI-C Decoder
54 ---------------------------------------------------
55
56 - It reads only "FileName", "Size", and "CRC" information for each file in archive.
57 - It supports only LZMA and Copy (no compression) methods.
58 - It converts original UTF-16 Unicode file names to UTF-8 Unicode file names.
59
60 These limitations will be fixed in future versions.
61
62
63 Using 7z ANSI-C Decoder Test application:
64 -----------------------------------------
65
66 Usage: 7zDec <command> <archive_name>
67
68 <Command>:
69 e: Extract files from archive
70 l: List contents of archive
71 t: Test integrity of archive
72
73 Example:
74
75 7zDec l archive.7z
76
77 lists contents of archive.7z
78
79 7zDec e archive.7z
80
81 extracts files from archive.7z to current folder.
82
83
84 How to use .7z Decoder
85 ----------------------
86
87 .7z Decoder can be compiled in one of two modes:
88
89 1) Default mode. In that mode 7z Decoder will read full compressed
90 block to RAM before decompressing.
91
92 2) Mode with defined _LZMA_IN_CB. In that mode 7z Decoder can read
93 compressed block by parts. And you can specify desired buffer size.
94 So memory requirements can be reduced. But decompressing speed will
95 be 5-10% lower and code size is slightly larger.
96
97
98 Memory allocation
99 ~~~~~~~~~~~~~~~~~
100
101 7z Decoder uses two memory pools:
102 1) Temporary pool
103 2) Main pool
104 Such scheme can allow you to avoid fragmentation of allocated blocks.
105
106 Steps for using 7z decoder
107 --------------------------
108
109 Use code at 7zMain.c as example.
110
111 1) Declare variables:
112 inStream /* implements ISzInStream interface */
113 CArchiveDatabaseEx db; /* 7z archive database structure */
114 ISzAlloc allocImp; /* memory functions for main pool */
115 ISzAlloc allocTempImp; /* memory functions for temporary pool */
116
117 2) call InitCrcTable(); function to initialize CRC structures.
118
119 3) call SzArDbExInit(&db); function to initialize db structures.
120
121 4) call SzArchiveOpen(inStream, &db, &allocMain, &allocTemp) to open archive
122
123 This function opens archive "inStream" and reads headers to "db".
124 All items in "db" will be allocated with "allocMain" functions.
125 SzArchiveOpen function allocates and frees temporary structures by "allocTemp" functions.
126
127 5) List items or Extract items
128
129 Listing code:
130 ~~~~~~~~~~~~~
131 {
132 UInt32 i;
133 for (i = 0; i < db.Database.NumFiles; i++)
134 {
135 CFileItem *f = db.Database.Files + i;
136 printf("%10d %s\n", (int)f->Size, f->Name);
137 }
138 }
139
140 Extracting code:
141 ~~~~~~~~~~~~~~~~
142
143 SZ_RESULT SzExtract(
144 ISzInStream *inStream,
145 CArchiveDatabaseEx *db,
146 UInt32 fileIndex, /* index of file */
147 UInt32 *blockIndex, /* index of solid block */
148 Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
149 size_t *outBufferSize, /* buffer size for output buffer */
150 size_t *offset, /* offset of stream for required file in *outBuffer */
151 size_t *outSizeProcessed, /* size of file in *outBuffer */
152 ISzAlloc *allocMain,
153 ISzAlloc *allocTemp);
154
155 If you need to decompress more than one file, you can send these values from previous call:
156 blockIndex,
157 outBuffer,
158 outBufferSize,
159 You can consider "outBuffer" as cache of solid block. If your archive is solid,
160 it will increase decompression speed.
161
162 After decompressing you must free "outBuffer":
163 allocImp.Free(outBuffer);
164
165 6) call SzArDbExFree(&db, allocImp.Free) to free allocated items in "db".
166
167
168
169
170 Memory requirements for .7z decoding
171 ------------------------------------
172
173 Memory usage for Archive opening:
174 - Temporary pool:
175 - Memory for compressed .7z headers (if _LZMA_IN_CB is not defined)
176 - Memory for uncompressed .7z headers
177 - some other temporary blocks
178 - Main pool:
179 - Memory for database:
180 Estimated size of one file structures in solid archive:
181 - Size (4 or 8 Bytes)
182 - CRC32 (4 bytes)
183 - Some file information (4 bytes)
184 - File Name (variable length) + pointer + allocation structures
185
186 Memory usage for archive Decompressing:
187 - Temporary pool:
188 - Memory for compressed solid block (if _LZMA_IN_CB is not defined)
189 - Memory for LZMA decompressing structures
190 - Main pool:
191 - Memory for decompressed solid block
192
193
194 If _LZMA_IN_CB is defined, 7z Decoder will not allocate memory for
195 compressed blocks. Instead of this, you must allocate buffer with desired
196 size before calling 7z Decoder. Use 7zMain.c as example.
197
198
199
200 EXIT codes
201 -----------
202
203 7z Decoder functions can return one of the following codes:
204
205 #define SZ_OK (0)
206 #define SZE_DATA_ERROR (1)
207 #define SZE_OUTOFMEMORY (2)
208 #define SZE_CRC_ERROR (3)
209
210 #define SZE_NOTIMPL (4)
211 #define SZE_FAIL (5)
212
213 #define SZE_ARCHIVE_ERROR (6)
214
215
216
217 LZMA Defines
218 ------------
219
220 _LZMA_IN_CB - Use special callback mode for input stream to reduce memory requirements
221
222 _SZ_FILE_SIZE_64 - define it if you need support for files larger than 4 GB
223 _SZ_NO_INT_64 - define it if your compiler doesn't support long long int
224
225 _LZMA_PROB32 - it can increase LZMA decompressing speed on some 32-bit CPUs.
226
227 _SZ_ONE_DIRECTORY - define it if you want to locate all source files to one directory
228 _SZ_ALLOC_DEBUG - define it if you want to debug alloc/free operations to stderr.
229
230
231 ---
232
233 http://www.7-zip.org
234 http://www.7-zip.org/support.html
0 7z Format description (2.30 Beta 25)
1 -----------------------------------
2
3 This file contains description of 7z archive format.
4 7z archive can contain files compressed with any method.
5 See "Methods.txt" for description for defined compressing methods.
6
7
8 Format structure Overview
9 -------------------------
10
11 Some fields can be optional.
12
13 Archive structure
14 ~~~~~~~~~~~~~~~~~
15 SignatureHeader
16 [PackedStreams]
17 [PackedStreamsForHeaders]
18 [
19 Header
20 or
21 {
22 Packed Header
23 HeaderInfo
24 }
25 ]
26
27
28
29 Header structure
30 ~~~~~~~~~~~~~~~~
31 {
32 ArchiveProperties
33 AdditionalStreams
34 {
35 PackInfo
36 {
37 PackPos
38 NumPackStreams
39 Sizes[NumPackStreams]
40 CRCs[NumPackStreams]
41 }
42 CodersInfo
43 {
44 NumFolders
45 Folders[NumFolders]
46 {
47 NumCoders
48 CodersInfo[NumCoders]
49 {
50 ID
51 NumInStreams;
52 NumOutStreams;
53 PropertiesSize
54 Properties[PropertiesSize]
55 }
56 NumBindPairs
57 BindPairsInfo[NumBindPairs]
58 {
59 InIndex;
60 OutIndex;
61 }
62 PackedIndices
63 }
64 UnPackSize[Folders][Folders.NumOutstreams]
65 CRCs[NumFolders]
66 }
67 SubStreamsInfo
68 {
69 NumUnPackStreamsInFolders[NumFolders];
70 UnPackSizes[]
71 CRCs[]
72 }
73 }
74 MainStreamsInfo
75 {
76 (Same as in AdditionalStreams)
77 }
78 FilesInfo
79 {
80 NumFiles
81 Properties[]
82 {
83 ID
84 Size
85 Data
86 }
87 }
88 }
89
90 HeaderInfo structure
91 ~~~~~~~~~~~~~~~~~~~~
92 {
93 (Same as in AdditionalStreams)
94 }
95
96
97
98 Notes about Notation and encoding
99 ---------------------------------
100
101 7z uses little endian encoding.
102
103 7z archive format has optional headers that are marked as
104 []
105 Header
106 []
107
108 REAL_UINT64 means real UINT64.
109
110 UINT64 means real UINT64 encoded with the following scheme:
111
112 Size of encoding sequence depends from first byte:
113 First_Byte Extra_Bytes Value
114 (binary)
115 0xxxxxxx : ( xxxxxxx )
116 10xxxxxx BYTE y[1] : ( xxxxxx << (8 * 1)) + y
117 110xxxxx BYTE y[2] : ( xxxxx << (8 * 2)) + y
118 ...
119 1111110x BYTE y[6] : ( x << (8 * 6)) + y
120 11111110 BYTE y[7] : y
121 11111111 BYTE y[8] : y
122
123
124
125 Property IDs
126 ------------
127
128 0x00 = kEnd,
129
130 0x01 = kHeader,
131
132 0x02 = kArchiveProperties,
133
134 0x03 = kAdditionalStreamsInfo,
135 0x04 = kMainStreamsInfo,
136 0x05 = kFilesInfo,
137
138 0x06 = kPackInfo,
139 0x07 = kUnPackInfo,
140 0x08 = kSubStreamsInfo,
141
142 0x09 = kSize,
143 0x0A = kCRC,
144
145 0x0B = kFolder,
146
147 0x0C = kCodersUnPackSize,
148 0x0D = kNumUnPackStream,
149
150 0x0E = kEmptyStream,
151 0x0F = kEmptyFile,
152 0x10 = kAnti,
153
154 0x11 = kName,
155 0x12 = kCreationTime,
156 0x13 = kLastAccessTime,
157 0x14 = kLastWriteTime,
158 0x15 = kWinAttributes,
159 0x16 = kComment,
160
161 0x17 = kEncodedHeader,
162
163
164 7z format headers
165 -----------------
166
167 SignatureHeader
168 ~~~~~~~~~~~~~~~
169 BYTE kSignature[6] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
170
171 ArchiveVersion
172 {
173 BYTE Major; // now = 0
174 BYTE Minor; // now = 2
175 };
176
177 UINT32 StartHeaderCRC;
178
179 StartHeader
180 {
181 REAL_UINT64 NextHeaderOffset
182 REAL_UINT64 NextHeaderSize
183 UINT32 NextHeaderCRC
184 }
185
186
187 ...........................
188
189
190 ArchiveProperties
191 ~~~~~~~~~~~~~~~~~
192 BYTE NID::kArchiveProperties (0x02)
193 while(true)
194 {
195 BYTE PropertyType;
196 if (aType == 0)
197 break;
198 UINT64 PropertySize;
199 BYTE PropertyData[PropertySize];
200 }
201
202
203 Digests (NumStreams)
204 ~~~~~~~~~~~~~~~~~~~~~
205 BYTE AllAreDefined
206 if (AllAreDefined == 0)
207 {
208 for(NumStreams)
209 BIT Defined
210 }
211 UINT32 CRCs[NumDefined]
212
213
214 PackInfo
215 ~~~~~~~~~~~~
216 BYTE NID::kPackInfo (0x06)
217 UINT64 PackPos
218 UINT64 NumPackStreams
219
220 []
221 BYTE NID::kSize (0x09)
222 UINT64 PackSizes[NumPackStreams]
223 []
224
225 []
226 BYTE NID::kCRC (0x0A)
227 PackStreamDigests[NumPackStreams]
228 []
229
230 BYTE NID::kEnd
231
232
233 Folder
234 ~~~~~~
235 UINT64 NumCoders;
236 for (NumCoders)
237 {
238 BYTE
239 {
240 0:3 DecompressionMethod.IDSize
241 4:
242 0 - IsSimple
243 1 - Is not simple
244 5:
245 0 - No Attributes
246 1 - There Are Attributes
247 7:
248 0 - Last Method in Alternative_Method_List
249 1 - There are more alternative methods
250 }
251 BYTE DecompressionMethod.ID[DecompressionMethod.IDSize]
252 if (!IsSimple)
253 {
254 UINT64 NumInStreams;
255 UINT64 NumOutStreams;
256 }
257 if (DecompressionMethod[0] != 0)
258 {
259 UINT64 PropertiesSize
260 BYTE Properties[PropertiesSize]
261 }
262 }
263
264 NumBindPairs = NumOutStreamsTotal - 1;
265
266 for (NumBindPairs)
267 {
268 UINT64 InIndex;
269 UINT64 OutIndex;
270 }
271
272 NumPackedStreams = NumInStreamsTotal - NumBindPairs;
273 if (NumPackedStreams > 1)
274 for(NumPackedStreams)
275 {
276 UINT64 Index;
277 };
278
279
280
281
282 Coders Info
283 ~~~~~~~~~~~
284
285 BYTE NID::kUnPackInfo (0x07)
286
287
288 BYTE NID::kFolder (0x0B)
289 UINT64 NumFolders
290 BYTE External
291 switch(External)
292 {
293 case 0:
294 Folders[NumFolders]
295 case 1:
296 UINT64 DataStreamIndex
297 }
298
299
300 BYTE ID::kCodersUnPackSize (0x0C)
301 for(Folders)
302 for(Folder.NumOutStreams)
303 UINT64 UnPackSize;
304
305
306 []
307 BYTE NID::kCRC (0x0A)
308 UnPackDigests[NumFolders]
309 []
310
311
312
313 BYTE NID::kEnd
314
315
316
317 SubStreams Info
318 ~~~~~~~~~~~~~~
319 BYTE NID::kSubStreamsInfo; (0x08)
320
321 []
322 BYTE NID::kNumUnPackStream; (0x0D)
323 UINT64 NumUnPackStreamsInFolders[NumFolders];
324 []
325
326
327 []
328 BYTE NID::kSize (0x09)
329 UINT64 UnPackSizes[]
330 []
331
332
333 []
334 BYTE NID::kCRC (0x0A)
335 Digests[Number of streams with unknown CRC]
336 []
337
338
339 BYTE NID::kEnd
340
341
342 Streams Info
343 ~~~~~~~~~~~~
344
345 []
346 PackInfo
347 []
348
349
350 []
351 CodersInfo
352 []
353
354
355 []
356 SubStreamsInfo
357 []
358
359 BYTE NID::kEnd
360
361
362 FilesInfo
363 ~~~~~~~~~
364 BYTE NID::kFilesInfo; (0x05)
365 UINT64 NumFiles
366
367 while(true)
368 {
369 BYTE PropertyType;
370 if (aType == 0)
371 break;
372
373 UINT64 Size;
374
375 switch(PropertyType)
376 {
377 kEmptyStream: (0x0E)
378 for(NumFiles)
379 BIT IsEmptyStream
380
381 kEmptyFile: (0x0F)
382 for(EmptyStreams)
383 BIT IsEmptyFile
384
385 kAnti: (0x10)
386 for(EmptyStreams)
387 BIT IsAntiFile
388
389 case kCreationTime: (0x12)
390 case kLastAccessTime: (0x13)
391 case kLastWriteTime: (0x14)
392 BYTE AllAreDefined
393 if (AllAreDefined == 0)
394 {
395 for(NumFiles)
396 BIT TimeDefined
397 }
398 BYTE External;
399 if(External != 0)
400 UINT64 DataIndex
401 []
402 for(Definded Items)
403 UINT32 Time
404 []
405
406 kNames: (0x11)
407 BYTE External;
408 if(External != 0)
409 UINT64 DataIndex
410 []
411 for(Files)
412 {
413 wchar_t Names[NameSize];
414 wchar_t 0;
415 }
416 []
417
418 kAttributes: (0x15)
419 BYTE AllAreDefined
420 if (AllAreDefined == 0)
421 {
422 for(NumFiles)
423 BIT AttributesAreDefined
424 }
425 BYTE External;
426 if(External != 0)
427 UINT64 DataIndex
428 []
429 for(Definded Attributes)
430 UINT32 Attributes
431 []
432 }
433 }
434
435
436 Header
437 ~~~~~~
438 BYTE NID::kHeader (0x01)
439
440 []
441 ArchiveProperties
442 []
443
444 []
445 BYTE NID::kAdditionalStreamsInfo; (0x03)
446 StreamsInfo
447 []
448
449 []
450 BYTE NID::kMainStreamsInfo; (0x04)
451 StreamsInfo
452 []
453
454 []
455 FilesInfo
456 []
457
458 BYTE NID::kEnd
459
460
461 HeaderInfo
462 ~~~~~~~~~~
463 []
464 BYTE NID::kEncodedHeader; (0x17)
465 StreamsInfo for Encoded Header
466 []
467
468
469 ---
470 End of document
0 /* 7zAlloc.c */
1
2 #include <stdlib.h>
3 #include "7zAlloc.h"
4
5 /* #define _SZ_ALLOC_DEBUG */
6 /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
7
8 #ifdef _SZ_ALLOC_DEBUG
9
10 #ifdef _WIN32
11 #include <windows.h>
12 #endif
13 #include <stdio.h>
14 int g_allocCount = 0;
15 int g_allocCountTemp = 0;
16 #endif
17
18 void *SzAlloc(size_t size)
19 {
20 if (size == 0)
21 return 0;
22 #ifdef _SZ_ALLOC_DEBUG
23 fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount);
24 g_allocCount++;
25 #endif
26 return malloc(size);
27 }
28
29 void SzFree(void *address)
30 {
31 #ifdef _SZ_ALLOC_DEBUG
32 if (address != 0)
33 {
34 g_allocCount--;
35 fprintf(stderr, "\nFree; count = %10d", g_allocCount);
36 }
37 #endif
38 free(address);
39 }
40
41 void *SzAllocTemp(size_t size)
42 {
43 if (size == 0)
44 return 0;
45 #ifdef _SZ_ALLOC_DEBUG
46 fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp);
47 g_allocCountTemp++;
48 #ifdef _WIN32
49 return HeapAlloc(GetProcessHeap(), 0, size);
50 #endif
51 #endif
52 return malloc(size);
53 }
54
55 void SzFreeTemp(void *address)
56 {
57 #ifdef _SZ_ALLOC_DEBUG
58 if (address != 0)
59 {
60 g_allocCountTemp--;
61 fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp);
62 }
63 #ifdef _WIN32
64 HeapFree(GetProcessHeap(), 0, address);
65 return;
66 #endif
67 #endif
68 free(address);
69 }
0 /* 7zAlloc.h */
1
2 #ifndef __7Z_ALLOC_H
3 #define __7Z_ALLOC_H
4
5 #include <stddef.h>
6
7 typedef struct _ISzAlloc
8 {
9 void *(*Alloc)(size_t size);
10 void (*Free)(void *address); /* address can be 0 */
11 } ISzAlloc;
12
13 void *SzAlloc(size_t size);
14 void SzFree(void *address);
15
16 void *SzAllocTemp(size_t size);
17 void SzFreeTemp(void *address);
18
19 #endif
0 /* 7zBuffer.c */
1
2 #include "7zBuffer.h"
3 #include "7zAlloc.h"
4
5 void SzByteBufferInit(CSzByteBuffer *buffer)
6 {
7 buffer->Capacity = 0;
8 buffer->Items = 0;
9 }
10
11 int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size))
12 {
13 buffer->Capacity = newCapacity;
14 if (newCapacity == 0)
15 {
16 buffer->Items = 0;
17 return 1;
18 }
19 buffer->Items = (Byte *)allocFunc(newCapacity);
20 return (buffer->Items != 0);
21 }
22
23 void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *))
24 {
25 freeFunc(buffer->Items);
26 buffer->Items = 0;
27 buffer->Capacity = 0;
28 }
0 /* 7zBuffer.h */
1
2 #ifndef __7Z_BUFFER_H
3 #define __7Z_BUFFER_H
4
5 #include <stddef.h>
6 #include "7zTypes.h"
7
8 typedef struct _CSzByteBuffer
9 {
10 size_t Capacity;
11 Byte *Items;
12 }CSzByteBuffer;
13
14 void SzByteBufferInit(CSzByteBuffer *buffer);
15 int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size));
16 void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *));
17
18 #endif
0 /* 7zCrc.c */
1
2 #include "7zCrc.h"
3
4 #define kCrcPoly 0xEDB88320
5
6 UInt32 g_CrcTable[256];
7
8 void InitCrcTable()
9 {
10 UInt32 i;
11 for (i = 0; i < 256; i++)
12 {
13 UInt32 r = i;
14 int j;
15 for (j = 0; j < 8; j++)
16 if (r & 1)
17 r = (r >> 1) ^ kCrcPoly;
18 else
19 r >>= 1;
20 g_CrcTable[i] = r;
21 }
22 }
23
24 void CrcInit(UInt32 *crc) { *crc = 0xFFFFFFFF; }
25 UInt32 CrcGetDigest(UInt32 *crc) { return *crc ^ 0xFFFFFFFF; }
26
27 void CrcUpdateByte(UInt32 *crc, Byte b)
28 {
29 *crc = g_CrcTable[((Byte)(*crc)) ^ b] ^ (*crc >> 8);
30 }
31
32 void CrcUpdateUInt16(UInt32 *crc, UInt16 v)
33 {
34 CrcUpdateByte(crc, (Byte)v);
35 CrcUpdateByte(crc, (Byte)(v >> 8));
36 }
37
38 void CrcUpdateUInt32(UInt32 *crc, UInt32 v)
39 {
40 int i;
41 for (i = 0; i < 4; i++)
42 CrcUpdateByte(crc, (Byte)(v >> (8 * i)));
43 }
44
45 void CrcUpdateUInt64(UInt32 *crc, UInt64 v)
46 {
47 int i;
48 for (i = 0; i < 8; i++)
49 {
50 CrcUpdateByte(crc, (Byte)(v));
51 v >>= 8;
52 }
53 }
54
55 void CrcUpdate(UInt32 *crc, const void *data, size_t size)
56 {
57 UInt32 v = *crc;
58 const Byte *p = (const Byte *)data;
59 for (; size > 0 ; size--, p++)
60 v = g_CrcTable[((Byte)(v)) ^ *p] ^ (v >> 8);
61 *crc = v;
62 }
63
64 UInt32 CrcCalculateDigest(const void *data, size_t size)
65 {
66 UInt32 crc;
67 CrcInit(&crc);
68 CrcUpdate(&crc, data, size);
69 return CrcGetDigest(&crc);
70 }
71
72 int CrcVerifyDigest(UInt32 digest, const void *data, size_t size)
73 {
74 return (CrcCalculateDigest(data, size) == digest);
75 }
0 /* 7zCrc.h */
1
2 #ifndef __7Z_CRC_H
3 #define __7Z_CRC_H
4
5 #include <stddef.h>
6
7 #include "7zTypes.h"
8
9 extern UInt32 g_CrcTable[256];
10 void InitCrcTable();
11
12 void CrcInit(UInt32 *crc);
13 UInt32 CrcGetDigest(UInt32 *crc);
14 void CrcUpdateByte(UInt32 *crc, Byte v);
15 void CrcUpdateUInt16(UInt32 *crc, UInt16 v);
16 void CrcUpdateUInt32(UInt32 *crc, UInt32 v);
17 void CrcUpdateUInt64(UInt32 *crc, UInt64 v);
18 void CrcUpdate(UInt32 *crc, const void *data, size_t size);
19
20 UInt32 CrcCalculateDigest(const void *data, size_t size);
21 int CrcVerifyDigest(UInt32 digest, const void *data, size_t size);
22
23 #endif
0 /* 7zDecode.c */
1
2 #include "7zDecode.h"
3 #ifdef _SZ_ONE_DIRECTORY
4 #include "LzmaDecode.h"
5 #else
6 #include "../../Compress/LZMA_C/LzmaDecode.h"
7 #endif
8
9 CMethodID k_Copy = { { 0x0 }, 1 };
10 CMethodID k_LZMA = { { 0x3, 0x1, 0x1 }, 3 };
11
12 #ifdef _LZMA_IN_CB
13
14 typedef struct _CLzmaInCallbackImp
15 {
16 ILzmaInCallback InCallback;
17 ISzInStream *InStream;
18 size_t Size;
19 } CLzmaInCallbackImp;
20
21 int LzmaReadImp(void *object, const unsigned char **buffer, SizeT *size)
22 {
23 CLzmaInCallbackImp *cb = (CLzmaInCallbackImp *)object;
24 size_t processedSize;
25 SZ_RESULT res;
26 *size = 0;
27 res = cb->InStream->Read((void *)cb->InStream, (void **)buffer, cb->Size, &processedSize);
28 *size = (SizeT)processedSize;
29 if (processedSize > cb->Size)
30 return (int)SZE_FAIL;
31 cb->Size -= processedSize;
32 if (res == SZ_OK)
33 return 0;
34 return (int)res;
35 }
36
37 #endif
38
39 SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
40 #ifdef _LZMA_IN_CB
41 ISzInStream *inStream,
42 #else
43 const Byte *inBuffer,
44 #endif
45 Byte *outBuffer, size_t outSize,
46 size_t *outSizeProcessed, ISzAlloc *allocMain)
47 {
48 UInt32 si;
49 size_t inSize = 0;
50 CCoderInfo *coder;
51 if (folder->NumPackStreams != 1)
52 return SZE_NOTIMPL;
53 if (folder->NumCoders != 1)
54 return SZE_NOTIMPL;
55 coder = folder->Coders;
56 *outSizeProcessed = 0;
57
58 for (si = 0; si < folder->NumPackStreams; si++)
59 inSize += (size_t)packSizes[si];
60
61 if (AreMethodsEqual(&coder->MethodID, &k_Copy))
62 {
63 size_t i;
64 if (inSize != outSize)
65 return SZE_DATA_ERROR;
66 #ifdef _LZMA_IN_CB
67 for (i = 0; i < inSize;)
68 {
69 size_t j;
70 Byte *inBuffer;
71 size_t bufferSize;
72 RINOK(inStream->Read((void *)inStream, (void **)&inBuffer, inSize - i, &bufferSize));
73 if (bufferSize == 0)
74 return SZE_DATA_ERROR;
75 if (bufferSize > inSize - i)
76 return SZE_FAIL;
77 *outSizeProcessed += bufferSize;
78 for (j = 0; j < bufferSize && i < inSize; j++, i++)
79 outBuffer[i] = inBuffer[j];
80 }
81 #else
82 for (i = 0; i < inSize; i++)
83 outBuffer[i] = inBuffer[i];
84 *outSizeProcessed = inSize;
85 #endif
86 return SZ_OK;
87 }
88
89 if (AreMethodsEqual(&coder->MethodID, &k_LZMA))
90 {
91 #ifdef _LZMA_IN_CB
92 CLzmaInCallbackImp lzmaCallback;
93 #else
94 SizeT inProcessed;
95 #endif
96
97 CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */
98 int result;
99 SizeT outSizeProcessedLoc;
100
101 #ifdef _LZMA_IN_CB
102 lzmaCallback.Size = inSize;
103 lzmaCallback.InStream = inStream;
104 lzmaCallback.InCallback.Read = LzmaReadImp;
105 #endif
106
107 if (LzmaDecodeProperties(&state.Properties, coder->Properties.Items,
108 coder->Properties.Capacity) != LZMA_RESULT_OK)
109 return SZE_FAIL;
110
111 state.Probs = (CProb *)allocMain->Alloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
112 if (state.Probs == 0)
113 return SZE_OUTOFMEMORY;
114
115 #ifdef _LZMA_OUT_READ
116 if (state.Properties.DictionarySize == 0)
117 state.Dictionary = 0;
118 else
119 {
120 state.Dictionary = (unsigned char *)allocMain->Alloc(state.Properties.DictionarySize);
121 if (state.Dictionary == 0)
122 {
123 allocMain->Free(state.Probs);
124 return SZE_OUTOFMEMORY;
125 }
126 }
127 LzmaDecoderInit(&state);
128 #endif
129
130 result = LzmaDecode(&state,
131 #ifdef _LZMA_IN_CB
132 &lzmaCallback.InCallback,
133 #else
134 inBuffer, (SizeT)inSize, &inProcessed,
135 #endif
136 outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
137 *outSizeProcessed = (size_t)outSizeProcessedLoc;
138 allocMain->Free(state.Probs);
139 #ifdef _LZMA_OUT_READ
140 allocMain->Free(state.Dictionary);
141 #endif
142 if (result == LZMA_RESULT_DATA_ERROR)
143 return SZE_DATA_ERROR;
144 if (result != LZMA_RESULT_OK)
145 return SZE_FAIL;
146 return SZ_OK;
147 }
148 return SZE_NOTIMPL;
149 }
0 /* 7zDecode.h */
1
2 #ifndef __7Z_DECODE_H
3 #define __7Z_DECODE_H
4
5 #include "7zItem.h"
6 #include "7zAlloc.h"
7 #ifdef _LZMA_IN_CB
8 #include "7zIn.h"
9 #endif
10
11 SZ_RESULT SzDecode(const CFileSize *packSizes, const CFolder *folder,
12 #ifdef _LZMA_IN_CB
13 ISzInStream *stream,
14 #else
15 const Byte *inBuffer,
16 #endif
17 Byte *outBuffer, size_t outSize,
18 size_t *outSizeProcessed, ISzAlloc *allocMain);
19
20 #endif
0 /* 7zExtract.c */
1
2 #include "7zExtract.h"
3 #include "7zDecode.h"
4 #include "7zCrc.h"
5
6 SZ_RESULT SzExtract(
7 ISzInStream *inStream,
8 CArchiveDatabaseEx *db,
9 UInt32 fileIndex,
10 UInt32 *blockIndex,
11 Byte **outBuffer,
12 size_t *outBufferSize,
13 size_t *offset,
14 size_t *outSizeProcessed,
15 ISzAlloc *allocMain,
16 ISzAlloc *allocTemp)
17 {
18 UInt32 folderIndex = db->FileIndexToFolderIndexMap[fileIndex];
19 SZ_RESULT res = SZ_OK;
20 *offset = 0;
21 *outSizeProcessed = 0;
22 if (folderIndex == (UInt32)-1)
23 {
24 allocMain->Free(*outBuffer);
25 *blockIndex = folderIndex;
26 *outBuffer = 0;
27 *outBufferSize = 0;
28 return SZ_OK;
29 }
30
31 if (*outBuffer == 0 || *blockIndex != folderIndex)
32 {
33 CFolder *folder = db->Database.Folders + folderIndex;
34 CFileSize unPackSize = SzFolderGetUnPackSize(folder);
35 #ifndef _LZMA_IN_CB
36 CFileSize packSize = SzArDbGetFolderFullPackSize(db, folderIndex);
37 Byte *inBuffer = 0;
38 size_t processedSize;
39 #endif
40 *blockIndex = folderIndex;
41 allocMain->Free(*outBuffer);
42 *outBuffer = 0;
43
44 RINOK(inStream->Seek(inStream, SzArDbGetFolderStreamPos(db, folderIndex, 0)));
45
46 #ifndef _LZMA_IN_CB
47 if (packSize != 0)
48 {
49 inBuffer = (Byte *)allocTemp->Alloc((size_t)packSize);
50 if (inBuffer == 0)
51 return SZE_OUTOFMEMORY;
52 }
53 res = inStream->Read(inStream, inBuffer, (size_t)packSize, &processedSize);
54 if (res == SZ_OK && processedSize != (size_t)packSize)
55 res = SZE_FAIL;
56 #endif
57 if (res == SZ_OK)
58 {
59 *outBufferSize = (size_t)unPackSize;
60 if (unPackSize != 0)
61 {
62 *outBuffer = (Byte *)allocMain->Alloc((size_t)unPackSize);
63 if (*outBuffer == 0)
64 res = SZE_OUTOFMEMORY;
65 }
66 if (res == SZ_OK)
67 {
68 size_t outRealSize;
69 res = SzDecode(db->Database.PackSizes +
70 db->FolderStartPackStreamIndex[folderIndex], folder,
71 #ifdef _LZMA_IN_CB
72 inStream,
73 #else
74 inBuffer,
75 #endif
76 *outBuffer, (size_t)unPackSize, &outRealSize, allocTemp);
77 if (res == SZ_OK)
78 {
79 if (outRealSize == (size_t)unPackSize)
80 {
81 if (folder->UnPackCRCDefined)
82 {
83 if (!CrcVerifyDigest(folder->UnPackCRC, *outBuffer, (size_t)unPackSize))
84 res = SZE_FAIL;
85 }
86 }
87 else
88 res = SZE_FAIL;
89 }
90 }
91 }
92 #ifndef _LZMA_IN_CB
93 allocTemp->Free(inBuffer);
94 #endif
95 }
96 if (res == SZ_OK)
97 {
98 UInt32 i;
99 CFileItem *fileItem = db->Database.Files + fileIndex;
100 *offset = 0;
101 for(i = db->FolderStartFileIndex[folderIndex]; i < fileIndex; i++)
102 *offset += (UInt32)db->Database.Files[i].Size;
103 *outSizeProcessed = (size_t)fileItem->Size;
104 if (*offset + *outSizeProcessed > *outBufferSize)
105 return SZE_FAIL;
106 {
107 if (fileItem->IsFileCRCDefined)
108 {
109 if (!CrcVerifyDigest(fileItem->FileCRC, *outBuffer + *offset, *outSizeProcessed))
110 res = SZE_FAIL;
111 }
112 }
113 }
114 return res;
115 }
0 /* 7zExtract.h */
1
2 #ifndef __7Z_EXTRACT_H
3 #define __7Z_EXTRACT_H
4
5 #include "7zIn.h"
6
7 /*
8 SzExtract extracts file from archive
9
10 *outBuffer must be 0 before first call for each new archive.
11
12 Extracting cache:
13 If you need to decompress more than one file, you can send
14 these values from previous call:
15 *blockIndex,
16 *outBuffer,
17 *outBufferSize
18 You can consider "*outBuffer" as cache of solid block. If your archive is solid,
19 it will increase decompression speed.
20
21 If you use external function, you can declare these 3 cache variables
22 (blockIndex, outBuffer, outBufferSize) as static in that external function.
23
24 Free *outBuffer and set *outBuffer to 0, if you want to flush cache.
25 */
26
27 SZ_RESULT SzExtract(
28 ISzInStream *inStream,
29 CArchiveDatabaseEx *db,
30 UInt32 fileIndex, /* index of file */
31 UInt32 *blockIndex, /* index of solid block */
32 Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
33 size_t *outBufferSize, /* buffer size for output buffer */
34 size_t *offset, /* offset of stream for required file in *outBuffer */
35 size_t *outSizeProcessed, /* size of file in *outBuffer */
36 ISzAlloc *allocMain,
37 ISzAlloc *allocTemp);
38
39 #endif
0 /* 7zHeader.c */
1
2 #include "7zHeader.h"
3
4 Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C};
0 /* 7zHeader.h */
1
2 #ifndef __7Z_HEADER_H
3 #define __7Z_HEADER_H
4
5 #include "7zTypes.h"
6
7 #define k7zSignatureSize 6
8 extern Byte k7zSignature[k7zSignatureSize];
9
10 #define k7zMajorVersion 0
11
12 #define k7zStartHeaderSize 0x20
13
14 enum EIdEnum
15 {
16 k7zIdEnd,
17
18 k7zIdHeader,
19
20 k7zIdArchiveProperties,
21
22 k7zIdAdditionalStreamsInfo,
23 k7zIdMainStreamsInfo,
24 k7zIdFilesInfo,
25
26 k7zIdPackInfo,
27 k7zIdUnPackInfo,
28 k7zIdSubStreamsInfo,
29
30 k7zIdSize,
31 k7zIdCRC,
32
33 k7zIdFolder,
34
35 k7zIdCodersUnPackSize,
36 k7zIdNumUnPackStream,
37
38 k7zIdEmptyStream,
39 k7zIdEmptyFile,
40 k7zIdAnti,
41
42 k7zIdName,
43 k7zIdCreationTime,
44 k7zIdLastAccessTime,
45 k7zIdLastWriteTime,
46 k7zIdWinAttributes,
47 k7zIdComment,
48
49 k7zIdEncodedHeader,
50
51 k7zIdStartPos
52 };
53
54 #endif
0 /* 7zIn.c */
1
2 #include "7zIn.h"
3 #include "7zCrc.h"
4 #include "7zDecode.h"
5
6 #define RINOM(x) { if((x) == 0) return SZE_OUTOFMEMORY; }
7
8 void SzArDbExInit(CArchiveDatabaseEx *db)
9 {
10 SzArchiveDatabaseInit(&db->Database);
11 db->FolderStartPackStreamIndex = 0;
12 db->PackStreamStartPositions = 0;
13 db->FolderStartFileIndex = 0;
14 db->FileIndexToFolderIndexMap = 0;
15 }
16
17 void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *))
18 {
19 freeFunc(db->FolderStartPackStreamIndex);
20 freeFunc(db->PackStreamStartPositions);
21 freeFunc(db->FolderStartFileIndex);
22 freeFunc(db->FileIndexToFolderIndexMap);
23 SzArchiveDatabaseFree(&db->Database, freeFunc);
24 SzArDbExInit(db);
25 }
26
27 /*
28 CFileSize GetFolderPackStreamSize(int folderIndex, int streamIndex) const
29 {
30 return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex];
31 }
32
33 CFileSize GetFilePackSize(int fileIndex) const
34 {
35 int folderIndex = FileIndexToFolderIndexMap[fileIndex];
36 if (folderIndex >= 0)
37 {
38 const CFolder &folderInfo = Folders[folderIndex];
39 if (FolderStartFileIndex[folderIndex] == fileIndex)
40 return GetFolderFullPackSize(folderIndex);
41 }
42 return 0;
43 }
44 */
45
46 #define MY_ALLOC(T, p, size, allocFunc) { if ((size) == 0) p = 0; else \
47 if ((p = (T *)allocFunc((size) * sizeof(T))) == 0) return SZE_OUTOFMEMORY; }
48
49 SZ_RESULT SzArDbExFill(CArchiveDatabaseEx *db, void * (*allocFunc)(size_t size))
50 {
51 UInt32 startPos = 0;
52 CFileSize startPosSize = 0;
53 UInt32 i;
54 UInt32 folderIndex = 0;
55 UInt32 indexInFolder = 0;
56 MY_ALLOC(UInt32, db->FolderStartPackStreamIndex, db->Database.NumFolders, allocFunc);
57 for(i = 0; i < db->Database.NumFolders; i++)
58 {
59 db->FolderStartPackStreamIndex[i] = startPos;
60 startPos += db->Database.Folders[i].NumPackStreams;
61 }
62
63 MY_ALLOC(CFileSize, db->PackStreamStartPositions, db->Database.NumPackStreams, allocFunc);
64
65 for(i = 0; i < db->Database.NumPackStreams; i++)
66 {
67 db->PackStreamStartPositions[i] = startPosSize;
68 startPosSize += db->Database.PackSizes[i];
69 }
70
71 MY_ALLOC(UInt32, db->FolderStartFileIndex, db->Database.NumFolders, allocFunc);
72 MY_ALLOC(UInt32, db->FileIndexToFolderIndexMap, db->Database.NumFiles, allocFunc);
73
74 for (i = 0; i < db->Database.NumFiles; i++)
75 {
76 CFileItem *file = db->Database.Files + i;
77 int emptyStream = !file->HasStream;
78 if (emptyStream && indexInFolder == 0)
79 {
80 db->FileIndexToFolderIndexMap[i] = (UInt32)-1;
81 continue;
82 }
83 if (indexInFolder == 0)
84 {
85 /*
86 v3.13 incorrectly worked with empty folders
87 v4.07: Loop for skipping empty folders
88 */
89 while(1)
90 {
91 if (folderIndex >= db->Database.NumFolders)
92 return SZE_ARCHIVE_ERROR;
93 db->FolderStartFileIndex[folderIndex] = i;
94 if (db->Database.Folders[folderIndex].NumUnPackStreams != 0)
95 break;
96 folderIndex++;
97 }
98 }
99 db->FileIndexToFolderIndexMap[i] = folderIndex;
100 if (emptyStream)
101 continue;
102 indexInFolder++;
103 if (indexInFolder >= db->Database.Folders[folderIndex].NumUnPackStreams)
104 {
105 folderIndex++;
106 indexInFolder = 0;
107 }
108 }
109 return SZ_OK;
110 }
111
112
113 CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder)
114 {
115 return db->ArchiveInfo.DataStartPosition +
116 db->PackStreamStartPositions[db->FolderStartPackStreamIndex[folderIndex] + indexInFolder];
117 }
118
119 CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex)
120 {
121 UInt32 packStreamIndex = db->FolderStartPackStreamIndex[folderIndex];
122 CFolder *folder = db->Database.Folders + folderIndex;
123 CFileSize size = 0;
124 UInt32 i;
125 for (i = 0; i < folder->NumPackStreams; i++)
126 size += db->Database.PackSizes[packStreamIndex + i];
127 return size;
128 }
129
130
131 /*
132 SZ_RESULT SzReadTime(const CObjectVector<CSzByteBuffer> &dataVector,
133 CObjectVector<CFileItem> &files, UInt64 type)
134 {
135 CBoolVector boolVector;
136 RINOK(ReadBoolVector2(files.Size(), boolVector))
137
138 CStreamSwitch streamSwitch;
139 RINOK(streamSwitch.Set(this, &dataVector));
140
141 for(int i = 0; i < files.Size(); i++)
142 {
143 CFileItem &file = files[i];
144 CArchiveFileTime fileTime;
145 bool defined = boolVector[i];
146 if (defined)
147 {
148 UInt32 low, high;
149 RINOK(SzReadUInt32(low));
150 RINOK(SzReadUInt32(high));
151 fileTime.dwLowDateTime = low;
152 fileTime.dwHighDateTime = high;
153 }
154 switch(type)
155 {
156 case k7zIdCreationTime:
157 file.IsCreationTimeDefined = defined;
158 if (defined)
159 file.CreationTime = fileTime;
160 break;
161 case k7zIdLastWriteTime:
162 file.IsLastWriteTimeDefined = defined;
163 if (defined)
164 file.LastWriteTime = fileTime;
165 break;
166 case k7zIdLastAccessTime:
167 file.IsLastAccessTimeDefined = defined;
168 if (defined)
169 file.LastAccessTime = fileTime;
170 break;
171 }
172 }
173 return SZ_OK;
174 }
175 */
176
177 SZ_RESULT SafeReadDirect(ISzInStream *inStream, Byte *data, size_t size)
178 {
179 #ifdef _LZMA_IN_CB
180 while (size > 0)
181 {
182 Byte *inBuffer;
183 size_t processedSize;
184 RINOK(inStream->Read(inStream, (void **)&inBuffer, size, &processedSize));
185 if (processedSize == 0 || processedSize > size)
186 return SZE_FAIL;
187 size -= processedSize;
188 do
189 {
190 *data++ = *inBuffer++;
191 }
192 while (--processedSize != 0);
193 }
194 #else
195 size_t processedSize;
196 RINOK(inStream->Read(inStream, data, size, &processedSize));
197 if (processedSize != size)
198 return SZE_FAIL;
199 #endif
200 return SZ_OK;
201 }
202
203 SZ_RESULT SafeReadDirectByte(ISzInStream *inStream, Byte *data)
204 {
205 return SafeReadDirect(inStream, data, 1);
206 }
207
208 SZ_RESULT SafeReadDirectUInt32(ISzInStream *inStream, UInt32 *value)
209 {
210 int i;
211 *value = 0;
212 for (i = 0; i < 4; i++)
213 {
214 Byte b;
215 RINOK(SafeReadDirectByte(inStream, &b));
216 *value |= ((UInt32)b << (8 * i));
217 }
218 return SZ_OK;
219 }
220
221 SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream, UInt64 *value)
222 {
223 int i;
224 *value = 0;
225 for (i = 0; i < 8; i++)
226 {
227 Byte b;
228 RINOK(SafeReadDirectByte(inStream, &b));
229 *value |= ((UInt32)b << (8 * i));
230 }
231 return SZ_OK;
232 }
233
234 int TestSignatureCandidate(Byte *testBytes)
235 {
236 size_t i;
237 for (i = 0; i < k7zSignatureSize; i++)
238 if (testBytes[i] != k7zSignature[i])
239 return 0;
240 return 1;
241 }
242
243 typedef struct _CSzState
244 {
245 Byte *Data;
246 size_t Size;
247 }CSzData;
248
249 SZ_RESULT SzReadByte(CSzData *sd, Byte *b)
250 {
251 if (sd->Size == 0)
252 return SZE_ARCHIVE_ERROR;
253 sd->Size--;
254 *b = *sd->Data++;
255 return SZ_OK;
256 }
257
258 SZ_RESULT SzReadBytes(CSzData *sd, Byte *data, size_t size)
259 {
260 size_t i;
261 for (i = 0; i < size; i++)
262 {
263 RINOK(SzReadByte(sd, data + i));
264 }
265 return SZ_OK;
266 }
267
268 SZ_RESULT SzReadUInt32(CSzData *sd, UInt32 *value)
269 {
270 int i;
271 *value = 0;
272 for (i = 0; i < 4; i++)
273 {
274 Byte b;
275 RINOK(SzReadByte(sd, &b));
276 *value |= ((UInt32)(b) << (8 * i));
277 }
278 return SZ_OK;
279 }
280
281 SZ_RESULT SzReadNumber(CSzData *sd, UInt64 *value)
282 {
283 Byte firstByte;
284 Byte mask = 0x80;
285 int i;
286 RINOK(SzReadByte(sd, &firstByte));
287 *value = 0;
288 for (i = 0; i < 8; i++)
289 {
290 Byte b;
291 if ((firstByte & mask) == 0)
292 {
293 UInt64 highPart = firstByte & (mask - 1);
294 *value += (highPart << (8 * i));
295 return SZ_OK;
296 }
297 RINOK(SzReadByte(sd, &b));
298 *value |= ((UInt64)b << (8 * i));
299 mask >>= 1;
300 }
301 return SZ_OK;
302 }
303
304 SZ_RESULT SzReadSize(CSzData *sd, CFileSize *value)
305 {
306 UInt64 value64;
307 RINOK(SzReadNumber(sd, &value64));
308 *value = (CFileSize)value64;
309 return SZ_OK;
310 }
311
312 SZ_RESULT SzReadNumber32(CSzData *sd, UInt32 *value)
313 {
314 UInt64 value64;
315 RINOK(SzReadNumber(sd, &value64));
316 if (value64 >= 0x80000000)
317 return SZE_NOTIMPL;
318 if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 2)))
319 return SZE_NOTIMPL;
320 *value = (UInt32)value64;
321 return SZ_OK;
322 }
323
324 SZ_RESULT SzReadID(CSzData *sd, UInt64 *value)
325 {
326 return SzReadNumber(sd, value);
327 }
328
329 SZ_RESULT SzSkeepDataSize(CSzData *sd, UInt64 size)
330 {
331 if (size > sd->Size)
332 return SZE_ARCHIVE_ERROR;
333 sd->Size -= (size_t)size;
334 sd->Data += (size_t)size;
335 return SZ_OK;
336 }
337
338 SZ_RESULT SzSkeepData(CSzData *sd)
339 {
340 UInt64 size;
341 RINOK(SzReadNumber(sd, &size));
342 return SzSkeepDataSize(sd, size);
343 }
344
345 SZ_RESULT SzReadArchiveProperties(CSzData *sd)
346 {
347 while(1)
348 {
349 UInt64 type;
350 RINOK(SzReadID(sd, &type));
351 if (type == k7zIdEnd)
352 break;
353 SzSkeepData(sd);
354 }
355 return SZ_OK;
356 }
357
358 SZ_RESULT SzWaitAttribute(CSzData *sd, UInt64 attribute)
359 {
360 while(1)
361 {
362 UInt64 type;
363 RINOK(SzReadID(sd, &type));
364 if (type == attribute)
365 return SZ_OK;
366 if (type == k7zIdEnd)
367 return SZE_ARCHIVE_ERROR;
368 RINOK(SzSkeepData(sd));
369 }
370 }
371
372 SZ_RESULT SzReadBoolVector(CSzData *sd, size_t numItems, Byte **v, void * (*allocFunc)(size_t size))
373 {
374 Byte b = 0;
375 Byte mask = 0;
376 size_t i;
377 MY_ALLOC(Byte, *v, numItems, allocFunc);
378 for(i = 0; i < numItems; i++)
379 {
380 if (mask == 0)
381 {
382 RINOK(SzReadByte(sd, &b));
383 mask = 0x80;
384 }
385 (*v)[i] = (Byte)(((b & mask) != 0) ? 1 : 0);
386 mask >>= 1;
387 }
388 return SZ_OK;
389 }
390
391 SZ_RESULT SzReadBoolVector2(CSzData *sd, size_t numItems, Byte **v, void * (*allocFunc)(size_t size))
392 {
393 Byte allAreDefined;
394 size_t i;
395 RINOK(SzReadByte(sd, &allAreDefined));
396 if (allAreDefined == 0)
397 return SzReadBoolVector(sd, numItems, v, allocFunc);
398 MY_ALLOC(Byte, *v, numItems, allocFunc);
399 for(i = 0; i < numItems; i++)
400 (*v)[i] = 1;
401 return SZ_OK;
402 }
403
404 SZ_RESULT SzReadHashDigests(
405 CSzData *sd,
406 size_t numItems,
407 Byte **digestsDefined,
408 UInt32 **digests,
409 void * (*allocFunc)(size_t size))
410 {
411 size_t i;
412 RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, allocFunc));
413 MY_ALLOC(UInt32, *digests, numItems, allocFunc);
414 for(i = 0; i < numItems; i++)
415 if ((*digestsDefined)[i])
416 {
417 RINOK(SzReadUInt32(sd, (*digests) + i));
418 }
419 return SZ_OK;
420 }
421
422 SZ_RESULT SzReadPackInfo(
423 CSzData *sd,
424 CFileSize *dataOffset,
425 UInt32 *numPackStreams,
426 CFileSize **packSizes,
427 Byte **packCRCsDefined,
428 UInt32 **packCRCs,
429 void * (*allocFunc)(size_t size))
430 {
431 UInt32 i;
432 RINOK(SzReadSize(sd, dataOffset));
433 RINOK(SzReadNumber32(sd, numPackStreams));
434
435 RINOK(SzWaitAttribute(sd, k7zIdSize));
436
437 MY_ALLOC(CFileSize, *packSizes, (size_t)*numPackStreams, allocFunc);
438
439 for(i = 0; i < *numPackStreams; i++)
440 {
441 RINOK(SzReadSize(sd, (*packSizes) + i));
442 }
443
444 while(1)
445 {
446 UInt64 type;
447 RINOK(SzReadID(sd, &type));
448 if (type == k7zIdEnd)
449 break;
450 if (type == k7zIdCRC)
451 {
452 RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, allocFunc));
453 continue;
454 }
455 RINOK(SzSkeepData(sd));
456 }
457 if (*packCRCsDefined == 0)
458 {
459 MY_ALLOC(Byte, *packCRCsDefined, (size_t)*numPackStreams, allocFunc);
460 MY_ALLOC(UInt32, *packCRCs, (size_t)*numPackStreams, allocFunc);
461 for(i = 0; i < *numPackStreams; i++)
462 {
463 (*packCRCsDefined)[i] = 0;
464 (*packCRCs)[i] = 0;
465 }
466 }
467 return SZ_OK;
468 }
469
470 SZ_RESULT SzReadSwitch(CSzData *sd)
471 {
472 Byte external;
473 RINOK(SzReadByte(sd, &external));
474 return (external == 0) ? SZ_OK: SZE_ARCHIVE_ERROR;
475 }
476
477 SZ_RESULT SzGetNextFolderItem(CSzData *sd, CFolder *folder, void * (*allocFunc)(size_t size))
478 {
479 UInt32 numCoders;
480 UInt32 numBindPairs;
481 UInt32 numPackedStreams;
482 UInt32 i;
483 UInt32 numInStreams = 0;
484 UInt32 numOutStreams = 0;
485 RINOK(SzReadNumber32(sd, &numCoders));
486 folder->NumCoders = numCoders;
487
488 MY_ALLOC(CCoderInfo, folder->Coders, (size_t)numCoders, allocFunc);
489
490 for (i = 0; i < numCoders; i++)
491 SzCoderInfoInit(folder->Coders + i);
492
493 for (i = 0; i < numCoders; i++)
494 {
495 Byte mainByte;
496 CCoderInfo *coder = folder->Coders + i;
497 {
498 RINOK(SzReadByte(sd, &mainByte));
499 coder->MethodID.IDSize = (Byte)(mainByte & 0xF);
500 RINOK(SzReadBytes(sd, coder->MethodID.ID, coder->MethodID.IDSize));
501 if ((mainByte & 0x10) != 0)
502 {
503 RINOK(SzReadNumber32(sd, &coder->NumInStreams));
504 RINOK(SzReadNumber32(sd, &coder->NumOutStreams));
505 }
506 else
507 {
508 coder->NumInStreams = 1;
509 coder->NumOutStreams = 1;
510 }
511 if ((mainByte & 0x20) != 0)
512 {
513 UInt64 propertiesSize = 0;
514 RINOK(SzReadNumber(sd, &propertiesSize));
515 if (!SzByteBufferCreate(&coder->Properties, (size_t)propertiesSize, allocFunc))
516 return SZE_OUTOFMEMORY;
517 RINOK(SzReadBytes(sd, coder->Properties.Items, (size_t)propertiesSize));
518 }
519 }
520 while ((mainByte & 0x80) != 0)
521 {
522 RINOK(SzReadByte(sd, &mainByte));
523 RINOK(SzSkeepDataSize(sd, (mainByte & 0xF)));
524 if ((mainByte & 0x10) != 0)
525 {
526 UInt32 n;
527 RINOK(SzReadNumber32(sd, &n));
528 RINOK(SzReadNumber32(sd, &n));
529 }
530 if ((mainByte & 0x20) != 0)
531 {
532 UInt64 propertiesSize = 0;
533 RINOK(SzReadNumber(sd, &propertiesSize));
534 RINOK(SzSkeepDataSize(sd, propertiesSize));
535 }
536 }
537 numInStreams += (UInt32)coder->NumInStreams;
538 numOutStreams += (UInt32)coder->NumOutStreams;
539 }
540
541 numBindPairs = numOutStreams - 1;
542 folder->NumBindPairs = numBindPairs;
543
544
545 MY_ALLOC(CBindPair, folder->BindPairs, (size_t)numBindPairs, allocFunc);
546
547 for (i = 0; i < numBindPairs; i++)
548 {
549 CBindPair *bindPair = folder->BindPairs + i;;
550 RINOK(SzReadNumber32(sd, &bindPair->InIndex));
551 RINOK(SzReadNumber32(sd, &bindPair->OutIndex));
552 }
553
554 numPackedStreams = numInStreams - (UInt32)numBindPairs;
555
556 folder->NumPackStreams = numPackedStreams;
557 MY_ALLOC(UInt32, folder->PackStreams, (size_t)numPackedStreams, allocFunc);
558
559 if (numPackedStreams == 1)
560 {
561 UInt32 j;
562 UInt32 pi = 0;
563 for (j = 0; j < numInStreams; j++)
564 if (SzFolderFindBindPairForInStream(folder, j) < 0)
565 {
566 folder->PackStreams[pi++] = j;
567 break;
568 }
569 }
570 else
571 for(i = 0; i < numPackedStreams; i++)
572 {
573 RINOK(SzReadNumber32(sd, folder->PackStreams + i));
574 }
575 return SZ_OK;
576 }
577
578 SZ_RESULT SzReadUnPackInfo(
579 CSzData *sd,
580 UInt32 *numFolders,
581 CFolder **folders, /* for allocFunc */
582 void * (*allocFunc)(size_t size),
583 ISzAlloc *allocTemp)
584 {
585 UInt32 i;
586 RINOK(SzWaitAttribute(sd, k7zIdFolder));
587 RINOK(SzReadNumber32(sd, numFolders));
588 {
589 RINOK(SzReadSwitch(sd));
590
591 MY_ALLOC(CFolder, *folders, (size_t)*numFolders, allocFunc);
592
593 for(i = 0; i < *numFolders; i++)
594 SzFolderInit((*folders) + i);
595
596 for(i = 0; i < *numFolders; i++)
597 {
598 RINOK(SzGetNextFolderItem(sd, (*folders) + i, allocFunc));
599 }
600 }
601
602 RINOK(SzWaitAttribute(sd, k7zIdCodersUnPackSize));
603
604 for(i = 0; i < *numFolders; i++)
605 {
606 UInt32 j;
607 CFolder *folder = (*folders) + i;
608 UInt32 numOutStreams = SzFolderGetNumOutStreams(folder);
609
610 MY_ALLOC(CFileSize, folder->UnPackSizes, (size_t)numOutStreams, allocFunc);
611
612 for(j = 0; j < numOutStreams; j++)
613 {
614 RINOK(SzReadSize(sd, folder->UnPackSizes + j));
615 }
616 }
617
618 while(1)
619 {
620 UInt64 type;
621 RINOK(SzReadID(sd, &type));
622 if (type == k7zIdEnd)
623 return SZ_OK;
624 if (type == k7zIdCRC)
625 {
626 SZ_RESULT res;
627 Byte *crcsDefined = 0;
628 UInt32 *crcs = 0;
629 res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp->Alloc);
630 if (res == SZ_OK)
631 {
632 for(i = 0; i < *numFolders; i++)
633 {
634 CFolder *folder = (*folders) + i;
635 folder->UnPackCRCDefined = crcsDefined[i];
636 folder->UnPackCRC = crcs[i];
637 }
638 }
639 allocTemp->Free(crcs);
640 allocTemp->Free(crcsDefined);
641 RINOK(res);
642 continue;
643 }
644 RINOK(SzSkeepData(sd));
645 }
646 }
647
648 SZ_RESULT SzReadSubStreamsInfo(
649 CSzData *sd,
650 UInt32 numFolders,
651 CFolder *folders,
652 UInt32 *numUnPackStreams,
653 CFileSize **unPackSizes,
654 Byte **digestsDefined,
655 UInt32 **digests,
656 ISzAlloc *allocTemp)
657 {
658 UInt64 type = 0;
659 UInt32 i;
660 UInt32 si = 0;
661 UInt32 numDigests = 0;
662
663 for(i = 0; i < numFolders; i++)
664 folders[i].NumUnPackStreams = 1;
665 *numUnPackStreams = numFolders;
666
667 while(1)
668 {
669 RINOK(SzReadID(sd, &type));
670 if (type == k7zIdNumUnPackStream)
671 {
672 *numUnPackStreams = 0;
673 for(i = 0; i < numFolders; i++)
674 {
675 UInt32 numStreams;
676 RINOK(SzReadNumber32(sd, &numStreams));
677 folders[i].NumUnPackStreams = numStreams;
678 *numUnPackStreams += numStreams;
679 }
680 continue;
681 }
682 if (type == k7zIdCRC || type == k7zIdSize)
683 break;
684 if (type == k7zIdEnd)
685 break;
686 RINOK(SzSkeepData(sd));
687 }
688
689 if (*numUnPackStreams == 0)
690 {
691 *unPackSizes = 0;
692 *digestsDefined = 0;
693 *digests = 0;
694 }
695 else
696 {
697 *unPackSizes = (CFileSize *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(CFileSize));
698 RINOM(*unPackSizes);
699 *digestsDefined = (Byte *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(Byte));
700 RINOM(*digestsDefined);
701 *digests = (UInt32 *)allocTemp->Alloc((size_t)*numUnPackStreams * sizeof(UInt32));
702 RINOM(*digests);
703 }
704
705 for(i = 0; i < numFolders; i++)
706 {
707 /*
708 v3.13 incorrectly worked with empty folders
709 v4.07: we check that folder is empty
710 */
711 CFileSize sum = 0;
712 UInt32 j;
713 UInt32 numSubstreams = folders[i].NumUnPackStreams;
714 if (numSubstreams == 0)
715 continue;
716 if (type == k7zIdSize)
717 for (j = 1; j < numSubstreams; j++)
718 {
719 CFileSize size;
720 RINOK(SzReadSize(sd, &size));
721 (*unPackSizes)[si++] = size;
722 sum += size;
723 }
724 (*unPackSizes)[si++] = SzFolderGetUnPackSize(folders + i) - sum;
725 }
726 if (type == k7zIdSize)
727 {
728 RINOK(SzReadID(sd, &type));
729 }
730
731 for(i = 0; i < *numUnPackStreams; i++)
732 {
733 (*digestsDefined)[i] = 0;
734 (*digests)[i] = 0;
735 }
736
737
738 for(i = 0; i < numFolders; i++)
739 {
740 UInt32 numSubstreams = folders[i].NumUnPackStreams;
741 if (numSubstreams != 1 || !folders[i].UnPackCRCDefined)
742 numDigests += numSubstreams;
743 }
744
745
746 si = 0;
747 while(1)
748 {
749 if (type == k7zIdCRC)
750 {
751 int digestIndex = 0;
752 Byte *digestsDefined2 = 0;
753 UInt32 *digests2 = 0;
754 SZ_RESULT res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp->Alloc);
755 if (res == SZ_OK)
756 {
757 for (i = 0; i < numFolders; i++)
758 {
759 CFolder *folder = folders + i;
760 UInt32 numSubstreams = folder->NumUnPackStreams;
761 if (numSubstreams == 1 && folder->UnPackCRCDefined)
762 {
763 (*digestsDefined)[si] = 1;
764 (*digests)[si] = folder->UnPackCRC;
765 si++;
766 }
767 else
768 {
769 UInt32 j;
770 for (j = 0; j < numSubstreams; j++, digestIndex++)
771 {
772 (*digestsDefined)[si] = digestsDefined2[digestIndex];
773 (*digests)[si] = digests2[digestIndex];
774 si++;
775 }
776 }
777 }
778 }
779 allocTemp->Free(digestsDefined2);
780 allocTemp->Free(digests2);
781 RINOK(res);
782 }
783 else if (type == k7zIdEnd)
784 return SZ_OK;
785 else
786 {
787 RINOK(SzSkeepData(sd));
788 }
789 RINOK(SzReadID(sd, &type));
790 }
791 }
792
793
794 SZ_RESULT SzReadStreamsInfo(
795 CSzData *sd,
796 CFileSize *dataOffset,
797 CArchiveDatabase *db,
798 UInt32 *numUnPackStreams,
799 CFileSize **unPackSizes, /* allocTemp */
800 Byte **digestsDefined, /* allocTemp */
801 UInt32 **digests, /* allocTemp */
802 void * (*allocFunc)(size_t size),
803 ISzAlloc *allocTemp)
804 {
805 while(1)
806 {
807 UInt64 type;
808 RINOK(SzReadID(sd, &type));
809 if ((UInt64)(int)type != type)
810 return SZE_FAIL;
811 switch((int)type)
812 {
813 case k7zIdEnd:
814 return SZ_OK;
815 case k7zIdPackInfo:
816 {
817 RINOK(SzReadPackInfo(sd, dataOffset, &db->NumPackStreams,
818 &db->PackSizes, &db->PackCRCsDefined, &db->PackCRCs, allocFunc));
819 break;
820 }
821 case k7zIdUnPackInfo:
822 {
823 RINOK(SzReadUnPackInfo(sd, &db->NumFolders, &db->Folders, allocFunc, allocTemp));
824 break;
825 }
826 case k7zIdSubStreamsInfo:
827 {
828 RINOK(SzReadSubStreamsInfo(sd, db->NumFolders, db->Folders,
829 numUnPackStreams, unPackSizes, digestsDefined, digests, allocTemp));
830 break;
831 }
832 default:
833 return SZE_FAIL;
834 }
835 }
836 }
837
838 Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
839
840 SZ_RESULT SzReadFileNames(CSzData *sd, UInt32 numFiles, CFileItem *files,
841 void * (*allocFunc)(size_t size))
842 {
843 UInt32 i;
844 for(i = 0; i < numFiles; i++)
845 {
846 UInt32 len = 0;
847 UInt32 pos = 0;
848 CFileItem *file = files + i;
849 while(pos + 2 <= sd->Size)
850 {
851 int numAdds;
852 UInt32 value = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
853 pos += 2;
854 len++;
855 if (value == 0)
856 break;
857 if (value < 0x80)
858 continue;
859 if (value >= 0xD800 && value < 0xE000)
860 {
861 UInt32 c2;
862 if (value >= 0xDC00)
863 return SZE_ARCHIVE_ERROR;
864 if (pos + 2 > sd->Size)
865 return SZE_ARCHIVE_ERROR;
866 c2 = (UInt32)(sd->Data[pos] | (((UInt32)sd->Data[pos + 1]) << 8));
867 pos += 2;
868 if (c2 < 0xDC00 || c2 >= 0xE000)
869 return SZE_ARCHIVE_ERROR;
870 value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
871 }
872 for (numAdds = 1; numAdds < 5; numAdds++)
873 if (value < (((UInt32)1) << (numAdds * 5 + 6)))
874 break;
875 len += numAdds;
876 }
877
878 MY_ALLOC(char, file->Name, (size_t)len, allocFunc);
879
880 len = 0;
881 while(2 <= sd->Size)
882 {
883 int numAdds;
884 UInt32 value = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
885 SzSkeepDataSize(sd, 2);
886 if (value < 0x80)
887 {
888 file->Name[len++] = (char)value;
889 if (value == 0)
890 break;
891 continue;
892 }
893 if (value >= 0xD800 && value < 0xE000)
894 {
895 UInt32 c2 = (UInt32)(sd->Data[0] | (((UInt32)sd->Data[1]) << 8));
896 SzSkeepDataSize(sd, 2);
897 value = ((value - 0xD800) << 10) | (c2 - 0xDC00);
898 }
899 for (numAdds = 1; numAdds < 5; numAdds++)
900 if (value < (((UInt32)1) << (numAdds * 5 + 6)))
901 break;
902 file->Name[len++] = (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds)));
903 do
904 {
905 numAdds--;
906 file->Name[len++] = (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F));
907 }
908 while(numAdds > 0);
909
910 len += numAdds;
911 }
912 }
913 return SZ_OK;
914 }
915
916 SZ_RESULT SzReadHeader2(
917 CSzData *sd,
918 CArchiveDatabaseEx *db, /* allocMain */
919 CFileSize **unPackSizes, /* allocTemp */
920 Byte **digestsDefined, /* allocTemp */
921 UInt32 **digests, /* allocTemp */
922 Byte **emptyStreamVector, /* allocTemp */
923 Byte **emptyFileVector, /* allocTemp */
924 ISzAlloc *allocMain,
925 ISzAlloc *allocTemp)
926 {
927 UInt64 type;
928 UInt32 numUnPackStreams = 0;
929 UInt32 numFiles = 0;
930 CFileItem *files = 0;
931 UInt32 numEmptyStreams = 0;
932 UInt32 i;
933
934 RINOK(SzReadID(sd, &type));
935
936 if (type == k7zIdArchiveProperties)
937 {
938 RINOK(SzReadArchiveProperties(sd));
939 RINOK(SzReadID(sd, &type));
940 }
941
942
943 if (type == k7zIdMainStreamsInfo)
944 {
945 RINOK(SzReadStreamsInfo(sd,
946 &db->ArchiveInfo.DataStartPosition,
947 &db->Database,
948 &numUnPackStreams,
949 unPackSizes,
950 digestsDefined,
951 digests, allocMain->Alloc, allocTemp));
952 db->ArchiveInfo.DataStartPosition += db->ArchiveInfo.StartPositionAfterHeader;
953 RINOK(SzReadID(sd, &type));
954 }
955
956 if (type == k7zIdEnd)
957 return SZ_OK;
958 if (type != k7zIdFilesInfo)
959 return SZE_ARCHIVE_ERROR;
960
961 RINOK(SzReadNumber32(sd, &numFiles));
962 db->Database.NumFiles = numFiles;
963
964 MY_ALLOC(CFileItem, files, (size_t)numFiles, allocMain->Alloc);
965
966 db->Database.Files = files;
967 for(i = 0; i < numFiles; i++)
968 SzFileInit(files + i);
969
970 while(1)
971 {
972 UInt64 type;
973 UInt64 size;
974 RINOK(SzReadID(sd, &type));
975 if (type == k7zIdEnd)
976 break;
977 RINOK(SzReadNumber(sd, &size));
978
979 if ((UInt64)(int)type != type)
980 {
981 RINOK(SzSkeepDataSize(sd, size));
982 }
983 else
984 switch((int)type)
985 {
986 case k7zIdName:
987 {
988 RINOK(SzReadSwitch(sd));
989 RINOK(SzReadFileNames(sd, numFiles, files, allocMain->Alloc))
990 break;
991 }
992 case k7zIdEmptyStream:
993 {
994 RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp->Alloc));
995 numEmptyStreams = 0;
996 for (i = 0; i < numFiles; i++)
997 if ((*emptyStreamVector)[i])
998 numEmptyStreams++;
999 break;
1000 }
1001 case k7zIdEmptyFile:
1002 {
1003 RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp->Alloc));
1004 break;
1005 }
1006 default:
1007 {
1008 RINOK(SzSkeepDataSize(sd, size));
1009 }
1010 }
1011 }
1012
1013 {
1014 UInt32 emptyFileIndex = 0;
1015 UInt32 sizeIndex = 0;
1016 for(i = 0; i < numFiles; i++)
1017 {
1018 CFileItem *file = files + i;
1019 file->IsAnti = 0;
1020 if (*emptyStreamVector == 0)
1021 file->HasStream = 1;
1022 else
1023 file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1);
1024 if(file->HasStream)
1025 {
1026 file->IsDirectory = 0;
1027 file->Size = (*unPackSizes)[sizeIndex];
1028 file->FileCRC = (*digests)[sizeIndex];
1029 file->IsFileCRCDefined = (Byte)(*digestsDefined)[sizeIndex];
1030 sizeIndex++;
1031 }
1032 else
1033 {
1034 if (*emptyFileVector == 0)
1035 file->IsDirectory = 1;
1036 else
1037 file->IsDirectory = (Byte)((*emptyFileVector)[emptyFileIndex] ? 0 : 1);
1038 emptyFileIndex++;
1039 file->Size = 0;
1040 file->IsFileCRCDefined = 0;
1041 }
1042 }
1043 }
1044 return SzArDbExFill(db, allocMain->Alloc);
1045 }
1046
1047 SZ_RESULT SzReadHeader(
1048 CSzData *sd,
1049 CArchiveDatabaseEx *db,
1050 ISzAlloc *allocMain,
1051 ISzAlloc *allocTemp)
1052 {
1053 CFileSize *unPackSizes = 0;
1054 Byte *digestsDefined = 0;
1055 UInt32 *digests = 0;
1056 Byte *emptyStreamVector = 0;
1057 Byte *emptyFileVector = 0;
1058 SZ_RESULT res = SzReadHeader2(sd, db,
1059 &unPackSizes, &digestsDefined, &digests,
1060 &emptyStreamVector, &emptyFileVector,
1061 allocMain, allocTemp);
1062 allocTemp->Free(unPackSizes);
1063 allocTemp->Free(digestsDefined);
1064 allocTemp->Free(digests);
1065 allocTemp->Free(emptyStreamVector);
1066 allocTemp->Free(emptyFileVector);
1067 return res;
1068 }
1069
1070 SZ_RESULT SzReadAndDecodePackedStreams2(
1071 ISzInStream *inStream,
1072 CSzData *sd,
1073 CSzByteBuffer *outBuffer,
1074 CFileSize baseOffset,
1075 CArchiveDatabase *db,
1076 CFileSize **unPackSizes,
1077 Byte **digestsDefined,
1078 UInt32 **digests,
1079 #ifndef _LZMA_IN_CB
1080 Byte **inBuffer,
1081 #endif
1082 ISzAlloc *allocTemp)
1083 {
1084
1085 UInt32 numUnPackStreams = 0;
1086 CFileSize dataStartPos;
1087 CFolder *folder;
1088 #ifndef _LZMA_IN_CB
1089 CFileSize packSize = 0;
1090 UInt32 i = 0;
1091 #endif
1092 CFileSize unPackSize;
1093 size_t outRealSize;
1094 SZ_RESULT res;
1095
1096 RINOK(SzReadStreamsInfo(sd, &dataStartPos, db,
1097 &numUnPackStreams, unPackSizes, digestsDefined, digests,
1098 allocTemp->Alloc, allocTemp));
1099
1100 dataStartPos += baseOffset;
1101 if (db->NumFolders != 1)
1102 return SZE_ARCHIVE_ERROR;
1103
1104 folder = db->Folders;
1105 unPackSize = SzFolderGetUnPackSize(folder);
1106
1107 RINOK(inStream->Seek(inStream, dataStartPos));
1108
1109 #ifndef _LZMA_IN_CB
1110 for (i = 0; i < db->NumPackStreams; i++)
1111 packSize += db->PackSizes[i];
1112
1113 MY_ALLOC(Byte, *inBuffer, (size_t)packSize, allocTemp->Alloc);
1114
1115 RINOK(SafeReadDirect(inStream, *inBuffer, (size_t)packSize));
1116 #endif
1117
1118 if (!SzByteBufferCreate(outBuffer, (size_t)unPackSize, allocTemp->Alloc))
1119 return SZE_OUTOFMEMORY;
1120
1121 res = SzDecode(db->PackSizes, folder,
1122 #ifdef _LZMA_IN_CB
1123 inStream,
1124 #else
1125 *inBuffer,
1126 #endif
1127 outBuffer->Items, (size_t)unPackSize,
1128 &outRealSize, allocTemp);
1129 RINOK(res)
1130 if (outRealSize != (UInt32)unPackSize)
1131 return SZE_FAIL;
1132 if (folder->UnPackCRCDefined)
1133 if (!CrcVerifyDigest(folder->UnPackCRC, outBuffer->Items, (size_t)unPackSize))
1134 return SZE_FAIL;
1135 return SZ_OK;
1136 }
1137
1138 SZ_RESULT SzReadAndDecodePackedStreams(
1139 ISzInStream *inStream,
1140 CSzData *sd,
1141 CSzByteBuffer *outBuffer,
1142 CFileSize baseOffset,
1143 ISzAlloc *allocTemp)
1144 {
1145 CArchiveDatabase db;
1146 CFileSize *unPackSizes = 0;
1147 Byte *digestsDefined = 0;
1148 UInt32 *digests = 0;
1149 #ifndef _LZMA_IN_CB
1150 Byte *inBuffer = 0;
1151 #endif
1152 SZ_RESULT res;
1153 SzArchiveDatabaseInit(&db);
1154 res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset,
1155 &db, &unPackSizes, &digestsDefined, &digests,
1156 #ifndef _LZMA_IN_CB
1157 &inBuffer,
1158 #endif
1159 allocTemp);
1160 SzArchiveDatabaseFree(&db, allocTemp->Free);
1161 allocTemp->Free(unPackSizes);
1162 allocTemp->Free(digestsDefined);
1163 allocTemp->Free(digests);
1164 #ifndef _LZMA_IN_CB
1165 allocTemp->Free(inBuffer);
1166 #endif
1167 return res;
1168 }
1169
1170 SZ_RESULT SzArchiveOpen2(
1171 ISzInStream *inStream,
1172 CArchiveDatabaseEx *db,
1173 ISzAlloc *allocMain,
1174 ISzAlloc *allocTemp)
1175 {
1176 Byte signature[k7zSignatureSize];
1177 Byte version;
1178 UInt32 crcFromArchive;
1179 UInt64 nextHeaderOffset;
1180 UInt64 nextHeaderSize;
1181 UInt32 nextHeaderCRC;
1182 UInt32 crc;
1183 CFileSize pos = 0;
1184 CSzByteBuffer buffer;
1185 CSzData sd;
1186 SZ_RESULT res;
1187
1188 RINOK(SafeReadDirect(inStream, signature, k7zSignatureSize));
1189
1190 if (!TestSignatureCandidate(signature))
1191 return SZE_ARCHIVE_ERROR;
1192
1193 /*
1194 db.Clear();
1195 db.ArchiveInfo.StartPosition = _arhiveBeginStreamPosition;
1196 */
1197 RINOK(SafeReadDirectByte(inStream, &version));
1198 if (version != k7zMajorVersion)
1199 return SZE_ARCHIVE_ERROR;
1200 RINOK(SafeReadDirectByte(inStream, &version));
1201
1202 RINOK(SafeReadDirectUInt32(inStream, &crcFromArchive));
1203
1204 CrcInit(&crc);
1205 RINOK(SafeReadDirectUInt64(inStream, &nextHeaderOffset));
1206 CrcUpdateUInt64(&crc, nextHeaderOffset);
1207 RINOK(SafeReadDirectUInt64(inStream, &nextHeaderSize));
1208 CrcUpdateUInt64(&crc, nextHeaderSize);
1209 RINOK(SafeReadDirectUInt32(inStream, &nextHeaderCRC));
1210 CrcUpdateUInt32(&crc, nextHeaderCRC);
1211
1212 pos = k7zStartHeaderSize;
1213 db->ArchiveInfo.StartPositionAfterHeader = pos;
1214
1215 if (CrcGetDigest(&crc) != crcFromArchive)
1216 return SZE_ARCHIVE_ERROR;
1217
1218 if (nextHeaderSize == 0)
1219 return SZ_OK;
1220
1221 RINOK(inStream->Seek(inStream, (CFileSize)(pos + nextHeaderOffset)));
1222
1223 if (!SzByteBufferCreate(&buffer, (size_t)nextHeaderSize, allocTemp->Alloc))
1224 return SZE_OUTOFMEMORY;
1225
1226 res = SafeReadDirect(inStream, buffer.Items, (size_t)nextHeaderSize);
1227 if (res == SZ_OK)
1228 {
1229 if (CrcVerifyDigest(nextHeaderCRC, buffer.Items, (UInt32)nextHeaderSize))
1230 {
1231 while (1)
1232 {
1233 UInt64 type;
1234 sd.Data = buffer.Items;
1235 sd.Size = buffer.Capacity;
1236 res = SzReadID(&sd, &type);
1237 if (res != SZ_OK)
1238 break;
1239 if (type == k7zIdHeader)
1240 {
1241 res = SzReadHeader(&sd, db, allocMain, allocTemp);
1242 break;
1243 }
1244 if (type != k7zIdEncodedHeader)
1245 {
1246 res = SZE_ARCHIVE_ERROR;
1247 break;
1248 }
1249 {
1250 CSzByteBuffer outBuffer;
1251 res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer,
1252 db->ArchiveInfo.StartPositionAfterHeader,
1253 allocTemp);
1254 if (res != SZ_OK)
1255 {
1256 SzByteBufferFree(&outBuffer, allocTemp->Free);
1257 break;
1258 }
1259 SzByteBufferFree(&buffer, allocTemp->Free);
1260 buffer.Items = outBuffer.Items;
1261 buffer.Capacity = outBuffer.Capacity;
1262 }
1263 }
1264 }
1265 }
1266 SzByteBufferFree(&buffer, allocTemp->Free);
1267 return res;
1268 }
1269
1270 SZ_RESULT SzArchiveOpen(
1271 ISzInStream *inStream,
1272 CArchiveDatabaseEx *db,
1273 ISzAlloc *allocMain,
1274 ISzAlloc *allocTemp)
1275 {
1276 SZ_RESULT res = SzArchiveOpen2(inStream, db, allocMain, allocTemp);
1277 if (res != SZ_OK)
1278 SzArDbExFree(db, allocMain->Free);
1279 return res;
1280 }
0 /* 7zIn.h */
1
2 #ifndef __7Z_IN_H
3 #define __7Z_IN_H
4
5 #include "7zHeader.h"
6 #include "7zItem.h"
7 #include "7zAlloc.h"
8
9 typedef struct _CInArchiveInfo
10 {
11 CFileSize StartPositionAfterHeader;
12 CFileSize DataStartPosition;
13 }CInArchiveInfo;
14
15 typedef struct _CArchiveDatabaseEx
16 {
17 CArchiveDatabase Database;
18 CInArchiveInfo ArchiveInfo;
19 UInt32 *FolderStartPackStreamIndex;
20 CFileSize *PackStreamStartPositions;
21 UInt32 *FolderStartFileIndex;
22 UInt32 *FileIndexToFolderIndexMap;
23 }CArchiveDatabaseEx;
24
25 void SzArDbExInit(CArchiveDatabaseEx *db);
26 void SzArDbExFree(CArchiveDatabaseEx *db, void (*freeFunc)(void *));
27 CFileSize SzArDbGetFolderStreamPos(CArchiveDatabaseEx *db, UInt32 folderIndex, UInt32 indexInFolder);
28 CFileSize SzArDbGetFolderFullPackSize(CArchiveDatabaseEx *db, UInt32 folderIndex);
29
30 typedef struct _ISzInStream
31 {
32 #ifdef _LZMA_IN_CB
33 SZ_RESULT (*Read)(
34 void *object, /* pointer to ISzInStream itself */
35 void **buffer, /* out: pointer to buffer with data */
36 size_t maxRequiredSize, /* max required size to read */
37 size_t *processedSize); /* real processed size.
38 processedSize can be less than maxRequiredSize.
39 If processedSize == 0, then there are no more
40 bytes in stream. */
41 #else
42 SZ_RESULT (*Read)(void *object, void *buffer, size_t size, size_t *processedSize);
43 #endif
44 SZ_RESULT (*Seek)(void *object, CFileSize pos);
45 } ISzInStream;
46
47
48 int SzArchiveOpen(
49 ISzInStream *inStream,
50 CArchiveDatabaseEx *db,
51 ISzAlloc *allocMain,
52 ISzAlloc *allocTemp);
53
54 #endif
0 /* 7zItem.c */
1
2 #include "7zItem.h"
3 #include "7zAlloc.h"
4
5 void SzCoderInfoInit(CCoderInfo *coder)
6 {
7 SzByteBufferInit(&coder->Properties);
8 }
9
10 void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p))
11 {
12 SzByteBufferFree(&coder->Properties, freeFunc);
13 SzCoderInfoInit(coder);
14 }
15
16 void SzFolderInit(CFolder *folder)
17 {
18 folder->NumCoders = 0;
19 folder->Coders = 0;
20 folder->NumBindPairs = 0;
21 folder->BindPairs = 0;
22 folder->NumPackStreams = 0;
23 folder->PackStreams = 0;
24 folder->UnPackSizes = 0;
25 folder->UnPackCRCDefined = 0;
26 folder->UnPackCRC = 0;
27 folder->NumUnPackStreams = 0;
28 }
29
30 void SzFolderFree(CFolder *folder, void (*freeFunc)(void *p))
31 {
32 UInt32 i;
33 for (i = 0; i < folder->NumCoders; i++)
34 SzCoderInfoFree(&folder->Coders[i], freeFunc);
35 freeFunc(folder->Coders);
36 freeFunc(folder->BindPairs);
37 freeFunc(folder->PackStreams);
38 freeFunc(folder->UnPackSizes);
39 SzFolderInit(folder);
40 }
41
42 UInt32 SzFolderGetNumOutStreams(CFolder *folder)
43 {
44 UInt32 result = 0;
45 UInt32 i;
46 for (i = 0; i < folder->NumCoders; i++)
47 result += folder->Coders[i].NumOutStreams;
48 return result;
49 }
50
51 int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex)
52 {
53 UInt32 i;
54 for(i = 0; i < folder->NumBindPairs; i++)
55 if (folder->BindPairs[i].InIndex == inStreamIndex)
56 return i;
57 return -1;
58 }
59
60
61 int SzFolderFindBindPairForOutStream(CFolder *folder, UInt32 outStreamIndex)
62 {
63 UInt32 i;
64 for(i = 0; i < folder->NumBindPairs; i++)
65 if (folder->BindPairs[i].OutIndex == outStreamIndex)
66 return i;
67 return -1;
68 }
69
70 CFileSize SzFolderGetUnPackSize(CFolder *folder)
71 {
72 int i = (int)SzFolderGetNumOutStreams(folder);
73 if (i == 0)
74 return 0;
75 for (i--; i >= 0; i--)
76 if (SzFolderFindBindPairForOutStream(folder, i) < 0)
77 return folder->UnPackSizes[i];
78 /* throw 1; */
79 return 0;
80 }
81
82 /*
83 int FindPackStreamArrayIndex(int inStreamIndex) const
84 {
85 for(int i = 0; i < PackStreams.Size(); i++)
86 if (PackStreams[i] == inStreamIndex)
87 return i;
88 return -1;
89 }
90 */
91
92 void SzFileInit(CFileItem *fileItem)
93 {
94 fileItem->IsFileCRCDefined = 0;
95 fileItem->HasStream = 1;
96 fileItem->IsDirectory = 0;
97 fileItem->IsAnti = 0;
98 fileItem->Name = 0;
99 }
100
101 void SzFileFree(CFileItem *fileItem, void (*freeFunc)(void *p))
102 {
103 freeFunc(fileItem->Name);
104 SzFileInit(fileItem);
105 }
106
107 void SzArchiveDatabaseInit(CArchiveDatabase *db)
108 {
109 db->NumPackStreams = 0;
110 db->PackSizes = 0;
111 db->PackCRCsDefined = 0;
112 db->PackCRCs = 0;
113 db->NumFolders = 0;
114 db->Folders = 0;
115 db->NumFiles = 0;
116 db->Files = 0;
117 }
118
119 void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *))
120 {
121 UInt32 i;
122 for (i = 0; i < db->NumFolders; i++)
123 SzFolderFree(&db->Folders[i], freeFunc);
124 for (i = 0; i < db->NumFiles; i++)
125 SzFileFree(&db->Files[i], freeFunc);
126 freeFunc(db->PackSizes);
127 freeFunc(db->PackCRCsDefined);
128 freeFunc(db->PackCRCs);
129 freeFunc(db->Folders);
130 freeFunc(db->Files);
131 SzArchiveDatabaseInit(db);
132 }
0 /* 7zItem.h */
1
2 #ifndef __7Z_ITEM_H
3 #define __7Z_ITEM_H
4
5 #include "7zMethodID.h"
6 #include "7zHeader.h"
7 #include "7zBuffer.h"
8
9 typedef struct _CCoderInfo
10 {
11 UInt32 NumInStreams;
12 UInt32 NumOutStreams;
13 CMethodID MethodID;
14 CSzByteBuffer Properties;
15 }CCoderInfo;
16
17 void SzCoderInfoInit(CCoderInfo *coder);
18 void SzCoderInfoFree(CCoderInfo *coder, void (*freeFunc)(void *p));
19
20 typedef struct _CBindPair
21 {
22 UInt32 InIndex;
23 UInt32 OutIndex;
24 }CBindPair;
25
26 typedef struct _CFolder
27 {
28 UInt32 NumCoders;
29 CCoderInfo *Coders;
30 UInt32 NumBindPairs;
31 CBindPair *BindPairs;
32 UInt32 NumPackStreams;
33 UInt32 *PackStreams;
34 CFileSize *UnPackSizes;
35 int UnPackCRCDefined;
36 UInt32 UnPackCRC;
37
38 UInt32 NumUnPackStreams;
39 }CFolder;
40
41 void SzFolderInit(CFolder *folder);
42 CFileSize SzFolderGetUnPackSize(CFolder *folder);
43 int SzFolderFindBindPairForInStream(CFolder *folder, UInt32 inStreamIndex);
44 UInt32 SzFolderGetNumOutStreams(CFolder *folder);
45 CFileSize SzFolderGetUnPackSize(CFolder *folder);
46
47 /* #define CArchiveFileTime UInt64 */
48
49 typedef struct _CFileItem
50 {
51 /*
52 CArchiveFileTime LastWriteTime;
53 CFileSize StartPos;
54 UInt32 Attributes;
55 */
56 CFileSize Size;
57 UInt32 FileCRC;
58 char *Name;
59
60 Byte IsFileCRCDefined;
61 Byte HasStream;
62 Byte IsDirectory;
63 Byte IsAnti;
64 /*
65 int AreAttributesDefined;
66 int IsLastWriteTimeDefined;
67 int IsStartPosDefined;
68 */
69 }CFileItem;
70
71 void SzFileInit(CFileItem *fileItem);
72
73 typedef struct _CArchiveDatabase
74 {
75 UInt32 NumPackStreams;
76 CFileSize *PackSizes;
77 Byte *PackCRCsDefined;
78 UInt32 *PackCRCs;
79 UInt32 NumFolders;
80 CFolder *Folders;
81 UInt32 NumFiles;
82 CFileItem *Files;
83 }CArchiveDatabase;
84
85 void SzArchiveDatabaseInit(CArchiveDatabase *db);
86 void SzArchiveDatabaseFree(CArchiveDatabase *db, void (*freeFunc)(void *));
87
88
89 #endif
0 /*
1 7zMain.c
2 Test application for 7z Decoder
3 LZMA SDK 4.43 Copyright (c) 1999-2006 Igor Pavlov (2006-06-04)
4 */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9
10 #include "7zCrc.h"
11 #include "7zIn.h"
12 #include "7zExtract.h"
13
14 typedef struct _CFileInStream
15 {
16 ISzInStream InStream;
17 FILE *File;
18 } CFileInStream;
19
20 #ifdef _LZMA_IN_CB
21
22 #define kBufferSize (1 << 12)
23 Byte g_Buffer[kBufferSize];
24
25 SZ_RESULT SzFileReadImp(void *object, void **buffer, size_t maxRequiredSize, size_t *processedSize)
26 {
27 CFileInStream *s = (CFileInStream *)object;
28 size_t processedSizeLoc;
29 if (maxRequiredSize > kBufferSize)
30 maxRequiredSize = kBufferSize;
31 processedSizeLoc = fread(g_Buffer, 1, maxRequiredSize, s->File);
32 *buffer = g_Buffer;
33 if (processedSize != 0)
34 *processedSize = processedSizeLoc;
35 return SZ_OK;
36 }
37
38 #else
39
40 SZ_RESULT SzFileReadImp(void *object, void *buffer, size_t size, size_t *processedSize)
41 {
42 CFileInStream *s = (CFileInStream *)object;
43 size_t processedSizeLoc = fread(buffer, 1, size, s->File);
44 if (processedSize != 0)
45 *processedSize = processedSizeLoc;
46 return SZ_OK;
47 }
48
49 #endif
50
51 SZ_RESULT SzFileSeekImp(void *object, CFileSize pos)
52 {
53 CFileInStream *s = (CFileInStream *)object;
54 int res = fseek(s->File, (long)pos, SEEK_SET);
55 if (res == 0)
56 return SZ_OK;
57 return SZE_FAIL;
58 }
59
60 void PrintError(char *sz)
61 {
62 printf("\nERROR: %s\n", sz);
63 }
64
65 int main(int numargs, char *args[])
66 {
67 CFileInStream archiveStream;
68 CArchiveDatabaseEx db;
69 SZ_RESULT res;
70 ISzAlloc allocImp;
71 ISzAlloc allocTempImp;
72
73 printf("\n7z ANSI-C Decoder 4.43 Copyright (c) 1999-2006 Igor Pavlov 2006-06-04\n");
74 if (numargs == 1)
75 {
76 printf(
77 "\nUsage: 7zDec <command> <archive_name>\n\n"
78 "<Commands>\n"
79 " e: Extract files from archive\n"
80 " l: List contents of archive\n"
81 " t: Test integrity of archive\n");
82 return 0;
83 }
84 if (numargs < 3)
85 {
86 PrintError("incorrect command");
87 return 1;
88 }
89
90 archiveStream.File = fopen(args[2], "rb");
91 if (archiveStream.File == 0)
92 {
93 PrintError("can not open input file");
94 return 1;
95 }
96
97 archiveStream.InStream.Read = SzFileReadImp;
98 archiveStream.InStream.Seek = SzFileSeekImp;
99
100 allocImp.Alloc = SzAlloc;
101 allocImp.Free = SzFree;
102
103 allocTempImp.Alloc = SzAllocTemp;
104 allocTempImp.Free = SzFreeTemp;
105
106 InitCrcTable();
107 SzArDbExInit(&db);
108 res = SzArchiveOpen(&archiveStream.InStream, &db, &allocImp, &allocTempImp);
109 if (res == SZ_OK)
110 {
111 char *command = args[1];
112 int listCommand = 0;
113 int testCommand = 0;
114 int extractCommand = 0;
115 if (strcmp(command, "l") == 0)
116 listCommand = 1;
117 if (strcmp(command, "t") == 0)
118 testCommand = 1;
119 else if (strcmp(command, "e") == 0)
120 extractCommand = 1;
121
122 if (listCommand)
123 {
124 UInt32 i;
125 for (i = 0; i < db.Database.NumFiles; i++)
126 {
127 CFileItem *f = db.Database.Files + i;
128 printf("%10d %s\n", (int)f->Size, f->Name);
129 }
130 }
131 else if (testCommand || extractCommand)
132 {
133 UInt32 i;
134
135 /*
136 if you need cache, use these 3 variables.
137 if you use external function, you can make these variable as static.
138 */
139 UInt32 blockIndex = 0xFFFFFFFF; /* it can have any value before first call (if outBuffer = 0) */
140 Byte *outBuffer = 0; /* it must be 0 before first call for each new archive. */
141 size_t outBufferSize = 0; /* it can have any value before first call (if outBuffer = 0) */
142
143 printf("\n");
144 for (i = 0; i < db.Database.NumFiles; i++)
145 {
146 size_t offset;
147 size_t outSizeProcessed;
148 CFileItem *f = db.Database.Files + i;
149 if (f->IsDirectory)
150 printf("Directory ");
151 else
152 printf(testCommand ?
153 "Testing ":
154 "Extracting");
155 printf(" %s", f->Name);
156 if (f->IsDirectory)
157 {
158 printf("\n");
159 continue;
160 }
161 res = SzExtract(&archiveStream.InStream, &db, i,
162 &blockIndex, &outBuffer, &outBufferSize,
163 &offset, &outSizeProcessed,
164 &allocImp, &allocTempImp);
165 if (res != SZ_OK)
166 break;
167 if (!testCommand)
168 {
169 FILE *outputHandle;
170 UInt32 processedSize;
171 char *fileName = f->Name;
172 size_t nameLen = strlen(f->Name);
173 for (; nameLen > 0; nameLen--)
174 if (f->Name[nameLen - 1] == '/')
175 {
176 fileName = f->Name + nameLen;
177 break;
178 }
179
180 outputHandle = fopen(fileName, "wb+");
181 if (outputHandle == 0)
182 {
183 PrintError("can not open output file");
184 res = SZE_FAIL;
185 break;
186 }
187 processedSize = fwrite(outBuffer + offset, 1, outSizeProcessed, outputHandle);
188 if (processedSize != outSizeProcessed)
189 {
190 PrintError("can not write output file");
191 res = SZE_FAIL;
192 break;
193 }
194 if (fclose(outputHandle))
195 {
196 PrintError("can not close output file");
197 res = SZE_FAIL;
198 break;
199 }
200 }
201 printf("\n");
202 }
203 allocImp.Free(outBuffer);
204 }
205 else
206 {
207 PrintError("incorrect command");
208 res = SZE_FAIL;
209 }
210 }
211 SzArDbExFree(&db, allocImp.Free);
212
213 fclose(archiveStream.File);
214 if (res == SZ_OK)
215 {
216 printf("\nEverything is Ok\n");
217 return 0;
218 }
219 if (res == SZE_OUTOFMEMORY)
220 PrintError("can not allocate memory");
221 else
222 printf("\nERROR #%d\n", res);
223 return 1;
224 }
0 /* 7zMethodID.c */
1
2 #include "7zMethodID.h"
3
4 int AreMethodsEqual(CMethodID *a1, CMethodID *a2)
5 {
6 int i;
7 if (a1->IDSize != a2->IDSize)
8 return 0;
9 for (i = 0; i < a1->IDSize; i++)
10 if (a1->ID[i] != a2->ID[i])
11 return 0;
12 return 1;
13 }
0 /* 7zMethodID.h */
1
2 #ifndef __7Z_METHOD_ID_H
3 #define __7Z_METHOD_ID_H
4
5 #include "7zTypes.h"
6
7 #define kMethodIDSize 15
8
9 typedef struct _CMethodID
10 {
11 Byte ID[kMethodIDSize];
12 Byte IDSize;
13 } CMethodID;
14
15 int AreMethodsEqual(CMethodID *a1, CMethodID *a2);
16
17 #endif
0 /* 7zTypes.h */
1
2 #ifndef __COMMON_TYPES_H
3 #define __COMMON_TYPES_H
4
5 #ifndef _7ZIP_BYTE_DEFINED
6 #define _7ZIP_BYTE_DEFINED
7 typedef unsigned char Byte;
8 #endif
9
10 #ifndef _7ZIP_UINT16_DEFINED
11 #define _7ZIP_UINT16_DEFINED
12 typedef unsigned short UInt16;
13 #endif
14
15 #ifndef _7ZIP_UINT32_DEFINED
16 #define _7ZIP_UINT32_DEFINED
17 #ifdef _LZMA_UINT32_IS_ULONG
18 typedef unsigned long UInt32;
19 #else
20 typedef unsigned int UInt32;
21 #endif
22 #endif
23
24 /* #define _SZ_NO_INT_64 */
25 /* define it your compiler doesn't support long long int */
26
27 #ifndef _7ZIP_UINT64_DEFINED
28 #define _7ZIP_UINT64_DEFINED
29 #ifdef _SZ_NO_INT_64
30 typedef unsigned long UInt64;
31 #else
32 #ifdef _MSC_VER
33 typedef unsigned __int64 UInt64;
34 #else
35 typedef unsigned long long int UInt64;
36 #endif
37 #endif
38 #endif
39
40
41 /* #define _SZ_FILE_SIZE_64 */
42 /* Use _SZ_FILE_SIZE_64 if you need support for files larger than 4 GB*/
43
44 #ifndef CFileSize
45 #ifdef _SZ_FILE_SIZE_64
46 typedef UInt64 CFileSize;
47 #else
48 typedef UInt32 CFileSize;
49 #endif
50 #endif
51
52 #define SZ_RESULT int
53
54 #define SZ_OK (0)
55 #define SZE_DATA_ERROR (1)
56 #define SZE_OUTOFMEMORY (2)
57 #define SZE_CRC_ERROR (3)
58
59 #define SZE_NOTIMPL (4)
60 #define SZE_FAIL (5)
61
62 #define SZE_ARCHIVE_ERROR (6)
63
64 #define RINOK(x) { int __result_ = (x); if(__result_ != 0) return __result_; }
65
66 #endif
0 # Microsoft Developer Studio Project File - Name="7z_C" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 6.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Console Application" 0x0103
5
6 CFG=7z_C - Win32 Debug
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "7z_C.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "7z_C.mak" CFG="7z_C - Win32 Debug"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "7z_C - Win32 Release" (based on "Win32 (x86) Console Application")
20 !MESSAGE "7z_C - Win32 Debug" (based on "Win32 (x86) Console Application")
21 !MESSAGE
22
23 # Begin Project
24 # PROP AllowPerConfigDependencies 0
25 # PROP Scc_ProjName ""
26 # PROP Scc_LocalPath ""
27 CPP=cl.exe
28 RSC=rc.exe
29
30 !IF "$(CFG)" == "7z_C - Win32 Release"
31
32 # PROP BASE Use_MFC 0
33 # PROP BASE Use_Debug_Libraries 0
34 # PROP BASE Output_Dir "Release"
35 # PROP BASE Intermediate_Dir "Release"
36 # PROP BASE Target_Dir ""
37 # PROP Use_MFC 0
38 # PROP Use_Debug_Libraries 0
39 # PROP Output_Dir "Release"
40 # PROP Intermediate_Dir "Release"
41 # PROP Ignore_Export_Lib 0
42 # PROP Target_Dir ""
43 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
44 # ADD CPP /nologo /W4 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /YX /FD /c
45 # ADD BASE RSC /l 0x419 /d "NDEBUG"
46 # ADD RSC /l 0x419 /d "NDEBUG"
47 BSC32=bscmake.exe
48 # ADD BASE BSC32 /nologo
49 # ADD BSC32 /nologo
50 LINK32=link.exe
51 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
52 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"Release/7zDec.exe"
53
54 !ELSEIF "$(CFG)" == "7z_C - Win32 Debug"
55
56 # PROP BASE Use_MFC 0
57 # PROP BASE Use_Debug_Libraries 1
58 # PROP BASE Output_Dir "Debug"
59 # PROP BASE Intermediate_Dir "Debug"
60 # PROP BASE Target_Dir ""
61 # PROP Use_MFC 0
62 # PROP Use_Debug_Libraries 1
63 # PROP Output_Dir "Debug"
64 # PROP Intermediate_Dir "Debug"
65 # PROP Ignore_Export_Lib 0
66 # PROP Target_Dir ""
67 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
68 # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "_LZMA_PROB32" /D "_LZMA_IN_CB" /YX /FD /GZ /c
69 # ADD BASE RSC /l 0x419 /d "_DEBUG"
70 # ADD RSC /l 0x419 /d "_DEBUG"
71 BSC32=bscmake.exe
72 # ADD BASE BSC32 /nologo
73 # ADD BSC32 /nologo
74 LINK32=link.exe
75 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
76 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug/7zDec.exe" /pdbtype:sept
77
78 !ENDIF
79
80 # Begin Target
81
82 # Name "7z_C - Win32 Release"
83 # Name "7z_C - Win32 Debug"
84 # Begin Group "LZMA"
85
86 # PROP Default_Filter ""
87 # Begin Source File
88
89 SOURCE=..\..\Compress\LZMA_C\LzmaDecode.c
90 # End Source File
91 # Begin Source File
92
93 SOURCE=..\..\Compress\LZMA_C\LzmaDecode.h
94 # End Source File
95 # Begin Source File
96
97 SOURCE=..\..\Compress\LZMA_C\LzmaTypes.h
98 # End Source File
99 # End Group
100 # Begin Source File
101
102 SOURCE=.\7zAlloc.c
103 # End Source File
104 # Begin Source File
105
106 SOURCE=.\7zAlloc.h
107 # End Source File
108 # Begin Source File
109
110 SOURCE=.\7zBuffer.c
111 # End Source File
112 # Begin Source File
113
114 SOURCE=.\7zBuffer.h
115 # End Source File
116 # Begin Source File
117
118 SOURCE=.\7zCrc.c
119 # End Source File
120 # Begin Source File
121
122 SOURCE=.\7zCrc.h
123 # End Source File
124 # Begin Source File
125
126 SOURCE=.\7zDecode.c
127 # End Source File
128 # Begin Source File
129
130 SOURCE=.\7zDecode.h
131 # End Source File
132 # Begin Source File
133
134 SOURCE=.\7zExtract.c
135 # End Source File
136 # Begin Source File
137
138 SOURCE=.\7zExtract.h
139 # End Source File
140 # Begin Source File
141
142 SOURCE=.\7zHeader.c
143 # End Source File
144 # Begin Source File
145
146 SOURCE=.\7zHeader.h
147 # End Source File
148 # Begin Source File
149
150 SOURCE=.\7zIn.c
151 # End Source File
152 # Begin Source File
153
154 SOURCE=.\7zIn.h
155 # End Source File
156 # Begin Source File
157
158 SOURCE=.\7zItem.c
159 # End Source File
160 # Begin Source File
161
162 SOURCE=.\7zItem.h
163 # End Source File
164 # Begin Source File
165
166 SOURCE=.\7zMain.c
167 # End Source File
168 # Begin Source File
169
170 SOURCE=.\7zMethodID.c
171 # End Source File
172 # Begin Source File
173
174 SOURCE=.\7zMethodID.h
175 # End Source File
176 # Begin Source File
177
178 SOURCE=.\7zTypes.h
179 # End Source File
180 # End Target
181 # End Project
0 Microsoft Developer Studio Workspace File, Format Version 6.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "7z_C"=.\7z_C.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 }}}
10
11 Package=<4>
12 {{{
13 }}}
14
15 ###############################################################################
16
17 Global:
18
19 Package=<5>
20 {{{
21 }}}
22
23 Package=<3>
24 {{{
25 }}}
26
27 ###############################################################################
28
0 PROG = 7zDec.exe
1
2 !IFNDEF O
3 !IFDEF CPU
4 O=$(CPU)
5 !ELSE
6 O=O
7 !ENDIF
8 !ENDIF
9
10 CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -GS-
11 CFLAGS_O1 = $(CFLAGS) -O1
12 CFLAGS_O2 = $(CFLAGS) -O2
13
14 LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98
15
16 PROGPATH = $O\$(PROG)
17
18 COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
19 COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
20 COMPL = $(CPP) $(CFLAGS_O1) $**
21
22
23 7Z_OBJS = \
24 $O\7zAlloc.obj \
25 $O\7zBuffer.obj \
26 $O\7zCrc.obj \
27 $O\7zDecode.obj \
28 $O\7zExtract.obj \
29 $O\7zHeader.obj \
30 $O\7zIn.obj \
31 $O\7zItem.obj \
32 $O\7zMain.obj \
33 $O\7zMethodID.obj \
34
35 OBJS = \
36 $(7Z_OBJS) \
37 $O\LzmaDecode.obj \
38
39 all: $(PROGPATH)
40
41 clean:
42 -del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch
43
44 $O:
45 if not exist "$O" mkdir "$O"
46
47 $(PROGPATH): $O $(OBJS)
48 link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)
49
50
51 $(7Z_OBJS): $(*B).c
52 $(COMPL)
53 $O\LzmaDecode.obj: ../../Compress/LZMA_C/$(*B).c
54 $(COMPL_O2)
0 PROG = 7zDec
1 CXX = g++
2 LIB =
3 RM = rm -f
4 CFLAGS = -c -O2 -Wall
5
6 OBJS = 7zAlloc.o 7zBuffer.o 7zCrc.o 7zDecode.o 7zExtract.o 7zHeader.o 7zIn.o 7zItem.o 7zMain.o 7zMethodID.o LzmaDecode.o
7
8 all: $(PROG)
9
10 $(PROG): $(OBJS)
11 $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
12
13 7zAlloc.o: 7zAlloc.c
14 $(CXX) $(CFLAGS) 7zAlloc.c
15
16 7zBuffer.o: 7zBuffer.c
17 $(CXX) $(CFLAGS) 7zBuffer.c
18
19 7zCrc.o: 7zCrc.c
20 $(CXX) $(CFLAGS) 7zCrc.c
21
22 7zDecode.o: 7zDecode.c
23 $(CXX) $(CFLAGS) 7zDecode.c
24
25 7zExtract.o: 7zExtract.c
26 $(CXX) $(CFLAGS) 7zExtract.c
27
28 7zHeader.o: 7zHeader.c
29 $(CXX) $(CFLAGS) 7zHeader.c
30
31 7zIn.o: 7zIn.c
32 $(CXX) $(CFLAGS) 7zIn.c
33
34 7zItem.o: 7zItem.c
35 $(CXX) $(CFLAGS) 7zItem.c
36
37 7zMain.o: 7zMain.c
38 $(CXX) $(CFLAGS) 7zMain.c
39
40 7zMethodID.o: 7zMethodID.c
41 $(CXX) $(CFLAGS) 7zMethodID.c
42
43 LzmaDecode.o: ../../Compress/LZMA_C/LzmaDecode.c
44 $(CXX) $(CFLAGS) ../../Compress/LZMA_C/LzmaDecode.c
45
46
47 clean:
48 -$(RM) $(PROG) $(OBJS)
49
0 // FileStreams.cpp
1
2 #include "StdAfx.h"
3
4 #ifndef _WIN32
5 #include <fcntl.h>
6 #include <unistd.h>
7 #include <errno.h>
8 #endif
9
10 #include "FileStreams.h"
11
12 static inline HRESULT ConvertBoolToHRESULT(bool result)
13 {
14 // return result ? S_OK: E_FAIL;
15 #ifdef _WIN32
16 return result ? S_OK: (::GetLastError());
17 #else
18 return result ? S_OK: E_FAIL;
19 #endif
20 }
21
22 bool CInFileStream::Open(LPCTSTR fileName)
23 {
24 return File.Open(fileName);
25 }
26
27 #ifdef _WIN32
28 #ifndef _UNICODE
29 bool CInFileStream::Open(LPCWSTR fileName)
30 {
31 return File.Open(fileName);
32 }
33 #endif
34 #endif
35
36 STDMETHODIMP CInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize)
37 {
38 #ifdef _WIN32
39
40 UInt32 realProcessedSize;
41 bool result = File.ReadPart(data, size, realProcessedSize);
42 if(processedSize != NULL)
43 *processedSize = realProcessedSize;
44 return ConvertBoolToHRESULT(result);
45
46 #else
47
48 if(processedSize != NULL)
49 *processedSize = 0;
50 ssize_t res = File.Read(data, (size_t)size);
51 if (res == -1)
52 return E_FAIL;
53 if(processedSize != NULL)
54 *processedSize = (UInt32)res;
55 return S_OK;
56
57 #endif
58 }
59
60 #ifndef _WIN32_WCE
61 STDMETHODIMP CStdInFileStream::Read(void *data, UInt32 size, UInt32 *processedSize)
62 {
63 #ifdef _WIN32
64 UInt32 realProcessedSize;
65 BOOL res = ::ReadFile(GetStdHandle(STD_INPUT_HANDLE),
66 data, size, (DWORD *)&realProcessedSize, NULL);
67 if(processedSize != NULL)
68 *processedSize = realProcessedSize;
69 if (res == FALSE && GetLastError() == ERROR_BROKEN_PIPE)
70 return S_OK;
71 return ConvertBoolToHRESULT(res != FALSE);
72
73 #else
74
75 if(processedSize != NULL)
76 *processedSize = 0;
77 ssize_t res;
78 do
79 {
80 res = read(0, data, (size_t)size);
81 }
82 while (res < 0 && (errno == EINTR));
83 if (res == -1)
84 return E_FAIL;
85 if(processedSize != NULL)
86 *processedSize = (UInt32)res;
87 return S_OK;
88
89 #endif
90 }
91
92 #endif
93
94 STDMETHODIMP CInFileStream::Seek(Int64 offset, UInt32 seekOrigin,
95 UInt64 *newPosition)
96 {
97 if(seekOrigin >= 3)
98 return STG_E_INVALIDFUNCTION;
99
100 #ifdef _WIN32
101
102 UInt64 realNewPosition;
103 bool result = File.Seek(offset, seekOrigin, realNewPosition);
104 if(newPosition != NULL)
105 *newPosition = realNewPosition;
106 return ConvertBoolToHRESULT(result);
107
108 #else
109
110 off_t res = File.Seek(offset, seekOrigin);
111 if (res == -1)
112 return E_FAIL;
113 if(newPosition != NULL)
114 *newPosition = (UInt64)res;
115 return S_OK;
116
117 #endif
118 }
119
120 STDMETHODIMP CInFileStream::GetSize(UInt64 *size)
121 {
122 return ConvertBoolToHRESULT(File.GetLength(*size));
123 }
124
125
126 //////////////////////////
127 // COutFileStream
128
129 bool COutFileStream::Create(LPCTSTR fileName, bool createAlways)
130 {
131 return File.Create(fileName, createAlways);
132 }
133
134 #ifdef _WIN32
135 #ifndef _UNICODE
136 bool COutFileStream::Create(LPCWSTR fileName, bool createAlways)
137 {
138 return File.Create(fileName, createAlways);
139 }
140 #endif
141 #endif
142
143 STDMETHODIMP COutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
144 {
145 #ifdef _WIN32
146
147 UInt32 realProcessedSize;
148 bool result = File.WritePart(data, size, realProcessedSize);
149 if(processedSize != NULL)
150 *processedSize = realProcessedSize;
151 return ConvertBoolToHRESULT(result);
152
153 #else
154
155 if(processedSize != NULL)
156 *processedSize = 0;
157 ssize_t res = File.Write(data, (size_t)size);
158 if (res == -1)
159 return E_FAIL;
160 if(processedSize != NULL)
161 *processedSize = (UInt32)res;
162 return S_OK;
163
164 #endif
165 }
166
167 STDMETHODIMP COutFileStream::Seek(Int64 offset, UInt32 seekOrigin,
168 UInt64 *newPosition)
169 {
170 if(seekOrigin >= 3)
171 return STG_E_INVALIDFUNCTION;
172 #ifdef _WIN32
173
174 UInt64 realNewPosition;
175 bool result = File.Seek(offset, seekOrigin, realNewPosition);
176 if(newPosition != NULL)
177 *newPosition = realNewPosition;
178 return ConvertBoolToHRESULT(result);
179
180 #else
181
182 off_t res = File.Seek(offset, seekOrigin);
183 if (res == -1)
184 return E_FAIL;
185 if(newPosition != NULL)
186 *newPosition = (UInt64)res;
187 return S_OK;
188
189 #endif
190 }
191
192 STDMETHODIMP COutFileStream::SetSize(Int64 newSize)
193 {
194 #ifdef _WIN32
195 UInt64 currentPos;
196 if(!File.Seek(0, FILE_CURRENT, currentPos))
197 return E_FAIL;
198 bool result = File.SetLength(newSize);
199 UInt64 currentPos2;
200 result = result && File.Seek(currentPos, currentPos2);
201 return result ? S_OK : E_FAIL;
202 #else
203 return E_FAIL;
204 #endif
205 }
206
207 #ifndef _WIN32_WCE
208 STDMETHODIMP CStdOutFileStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
209 {
210 if(processedSize != NULL)
211 *processedSize = 0;
212
213 #ifdef _WIN32
214 UInt32 realProcessedSize;
215 BOOL res = TRUE;
216 if (size > 0)
217 {
218 // Seems that Windows doesn't like big amounts writing to stdout.
219 // So we limit portions by 32KB.
220 UInt32 sizeTemp = (1 << 15);
221 if (sizeTemp > size)
222 sizeTemp = size;
223 res = ::WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
224 data, sizeTemp, (DWORD *)&realProcessedSize, NULL);
225 size -= realProcessedSize;
226 data = (const void *)((const Byte *)data + realProcessedSize);
227 if(processedSize != NULL)
228 *processedSize += realProcessedSize;
229 }
230 return ConvertBoolToHRESULT(res != FALSE);
231
232 #else
233
234 ssize_t res;
235 do
236 {
237 res = write(1, data, (size_t)size);
238 }
239 while (res < 0 && (errno == EINTR));
240 if (res == -1)
241 return E_FAIL;
242 if(processedSize != NULL)
243 *processedSize = (UInt32)res;
244 return S_OK;
245
246 return S_OK;
247 #endif
248 }
249
250 #endif
0 // FileStreams.h
1
2 #ifndef __FILESTREAMS_H
3 #define __FILESTREAMS_H
4
5 #ifdef _WIN32
6 #include "../../Windows/FileIO.h"
7 #else
8 #include "../../Common/C_FileIO.h"
9 #endif
10
11 #include "../IStream.h"
12 #include "../../Common/MyCom.h"
13
14 class CInFileStream:
15 public IInStream,
16 public IStreamGetSize,
17 public CMyUnknownImp
18 {
19 public:
20 #ifdef _WIN32
21 NWindows::NFile::NIO::CInFile File;
22 #else
23 NC::NFile::NIO::CInFile File;
24 #endif
25 CInFileStream() {}
26 virtual ~CInFileStream() {}
27
28 bool Open(LPCTSTR fileName);
29 #ifdef _WIN32
30 #ifndef _UNICODE
31 bool Open(LPCWSTR fileName);
32 #endif
33 #endif
34
35 MY_UNKNOWN_IMP2(IInStream, IStreamGetSize)
36
37 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
38 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
39
40 STDMETHOD(GetSize)(UInt64 *size);
41 };
42
43 #ifndef _WIN32_WCE
44 class CStdInFileStream:
45 public ISequentialInStream,
46 public CMyUnknownImp
47 {
48 public:
49 // HANDLE File;
50 // CStdInFileStream() File(INVALID_HANDLE_VALUE): {}
51 // void Open() { File = GetStdHandle(STD_INPUT_HANDLE); };
52 MY_UNKNOWN_IMP
53
54 virtual ~CStdInFileStream() {}
55 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
56 };
57 #endif
58
59 class COutFileStream:
60 public IOutStream,
61 public CMyUnknownImp
62 {
63 public:
64 #ifdef _WIN32
65 NWindows::NFile::NIO::COutFile File;
66 #else
67 NC::NFile::NIO::COutFile File;
68 #endif
69 virtual ~COutFileStream() {}
70 bool Create(LPCTSTR fileName, bool createAlways);
71 #ifdef _WIN32
72 #ifndef _UNICODE
73 bool Create(LPCWSTR fileName, bool createAlways);
74 #endif
75 #endif
76
77 MY_UNKNOWN_IMP1(IOutStream)
78
79 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
80 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition);
81 STDMETHOD(SetSize)(Int64 newSize);
82 };
83
84 #ifndef _WIN32_WCE
85 class CStdOutFileStream:
86 public ISequentialOutStream,
87 public CMyUnknownImp
88 {
89 public:
90 MY_UNKNOWN_IMP
91
92 virtual ~CStdOutFileStream() {}
93 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
94 };
95 #endif
96
97 #endif
0 // InBuffer.cpp
1
2 #include "StdAfx.h"
3
4 #include "InBuffer.h"
5
6 #include "../../Common/Alloc.h"
7
8 CInBuffer::CInBuffer():
9 _buffer(0),
10 _bufferLimit(0),
11 _bufferBase(0),
12 _stream(0),
13 _bufferSize(0)
14 {}
15
16 bool CInBuffer::Create(UInt32 bufferSize)
17 {
18 const UInt32 kMinBlockSize = 1;
19 if (bufferSize < kMinBlockSize)
20 bufferSize = kMinBlockSize;
21 if (_bufferBase != 0 && _bufferSize == bufferSize)
22 return true;
23 Free();
24 _bufferSize = bufferSize;
25 _bufferBase = (Byte *)::MidAlloc(bufferSize);
26 return (_bufferBase != 0);
27 }
28
29 void CInBuffer::Free()
30 {
31 ::MidFree(_bufferBase);
32 _bufferBase = 0;
33 }
34
35 void CInBuffer::SetStream(ISequentialInStream *stream)
36 {
37 _stream = stream;
38 }
39
40 void CInBuffer::Init()
41 {
42 _processedSize = 0;
43 _buffer = _bufferBase;
44 _bufferLimit = _buffer;
45 _wasFinished = false;
46 #ifdef _NO_EXCEPTIONS
47 ErrorCode = S_OK;
48 #endif
49 }
50
51 bool CInBuffer::ReadBlock()
52 {
53 #ifdef _NO_EXCEPTIONS
54 if (ErrorCode != S_OK)
55 return false;
56 #endif
57 if (_wasFinished)
58 return false;
59 _processedSize += (_buffer - _bufferBase);
60 UInt32 numProcessedBytes;
61 HRESULT result = _stream->Read(_bufferBase, _bufferSize, &numProcessedBytes);
62 #ifdef _NO_EXCEPTIONS
63 ErrorCode = result;
64 #else
65 if (result != S_OK)
66 throw CInBufferException(result);
67 #endif
68 _buffer = _bufferBase;
69 _bufferLimit = _buffer + numProcessedBytes;
70 _wasFinished = (numProcessedBytes == 0);
71 return (!_wasFinished);
72 }
73
74 Byte CInBuffer::ReadBlock2()
75 {
76 if(!ReadBlock())
77 return 0xFF;
78 return *_buffer++;
79 }
0 // InBuffer.h
1
2 #ifndef __INBUFFER_H
3 #define __INBUFFER_H
4
5 #include "../IStream.h"
6 #include "../../Common/MyCom.h"
7
8 #ifndef _NO_EXCEPTIONS
9 class CInBufferException
10 {
11 public:
12 HRESULT ErrorCode;
13 CInBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
14 };
15 #endif
16
17 class CInBuffer
18 {
19 Byte *_buffer;
20 Byte *_bufferLimit;
21 Byte *_bufferBase;
22 CMyComPtr<ISequentialInStream> _stream;
23 UInt64 _processedSize;
24 UInt32 _bufferSize;
25 bool _wasFinished;
26
27 bool ReadBlock();
28 Byte ReadBlock2();
29
30 public:
31 #ifdef _NO_EXCEPTIONS
32 HRESULT ErrorCode;
33 #endif
34
35 CInBuffer();
36 ~CInBuffer() { Free(); }
37
38 bool Create(UInt32 bufferSize);
39 void Free();
40
41 void SetStream(ISequentialInStream *stream);
42 void Init();
43 void ReleaseStream() { _stream.Release(); }
44
45 bool ReadByte(Byte &b)
46 {
47 if(_buffer >= _bufferLimit)
48 if(!ReadBlock())
49 return false;
50 b = *_buffer++;
51 return true;
52 }
53 Byte ReadByte()
54 {
55 if(_buffer >= _bufferLimit)
56 return ReadBlock2();
57 return *_buffer++;
58 }
59 void ReadBytes(void *data, UInt32 size, UInt32 &processedSize)
60 {
61 for(processedSize = 0; processedSize < size; processedSize++)
62 if (!ReadByte(((Byte *)data)[processedSize]))
63 return;
64 }
65 bool ReadBytes(void *data, UInt32 size)
66 {
67 UInt32 processedSize;
68 ReadBytes(data, size, processedSize);
69 return (processedSize == size);
70 }
71 UInt64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); }
72 bool WasFinished() const { return _wasFinished; }
73 };
74
75 #endif
0 // OutByte.cpp
1
2 #include "StdAfx.h"
3
4 #include "OutBuffer.h"
5
6 #include "../../Common/Alloc.h"
7
8 bool COutBuffer::Create(UInt32 bufferSize)
9 {
10 const UInt32 kMinBlockSize = 1;
11 if (bufferSize < kMinBlockSize)
12 bufferSize = kMinBlockSize;
13 if (_buffer != 0 && _bufferSize == bufferSize)
14 return true;
15 Free();
16 _bufferSize = bufferSize;
17 _buffer = (Byte *)::MidAlloc(bufferSize);
18 return (_buffer != 0);
19 }
20
21 void COutBuffer::Free()
22 {
23 ::MidFree(_buffer);
24 _buffer = 0;
25 }
26
27 void COutBuffer::SetStream(ISequentialOutStream *stream)
28 {
29 _stream = stream;
30 }
31
32 void COutBuffer::Init()
33 {
34 _streamPos = 0;
35 _limitPos = _bufferSize;
36 _pos = 0;
37 _processedSize = 0;
38 _overDict = false;
39 #ifdef _NO_EXCEPTIONS
40 ErrorCode = S_OK;
41 #endif
42 }
43
44 UInt64 COutBuffer::GetProcessedSize() const
45 {
46 UInt64 res = _processedSize + _pos - _streamPos;
47 if (_streamPos > _pos)
48 res += _bufferSize;
49 return res;
50 }
51
52
53 HRESULT COutBuffer::FlushPart()
54 {
55 // _streamPos < _bufferSize
56 UInt32 size = (_streamPos >= _pos) ? (_bufferSize - _streamPos) : (_pos - _streamPos);
57 HRESULT result = S_OK;
58 #ifdef _NO_EXCEPTIONS
59 result = ErrorCode;
60 #endif
61 if (_buffer2 != 0)
62 {
63 memmove(_buffer2, _buffer + _streamPos, size);
64 _buffer2 += size;
65 }
66
67 if (_stream != 0
68 #ifdef _NO_EXCEPTIONS
69 && (ErrorCode == S_OK)
70 #endif
71 )
72 {
73 UInt32 processedSize = 0;
74 result = _stream->Write(_buffer + _streamPos, size, &processedSize);
75 size = processedSize;
76 }
77 _streamPos += size;
78 if (_streamPos == _bufferSize)
79 _streamPos = 0;
80 if (_pos == _bufferSize)
81 {
82 _overDict = true;
83 _pos = 0;
84 }
85 _limitPos = (_streamPos > _pos) ? _streamPos : _bufferSize;
86 _processedSize += size;
87 return result;
88 }
89
90 HRESULT COutBuffer::Flush()
91 {
92 #ifdef _NO_EXCEPTIONS
93 if (ErrorCode != S_OK)
94 return ErrorCode;
95 #endif
96
97 while(_streamPos != _pos)
98 {
99 HRESULT result = FlushPart();
100 if (result != S_OK)
101 return result;
102 }
103 return S_OK;
104 }
105
106 void COutBuffer::FlushWithCheck()
107 {
108 HRESULT result = FlushPart();
109 #ifdef _NO_EXCEPTIONS
110 ErrorCode = result;
111 #else
112 if (result != S_OK)
113 throw COutBufferException(result);
114 #endif
115 }
0 // OutBuffer.h
1
2 #ifndef __OUTBUFFER_H
3 #define __OUTBUFFER_H
4
5 #include "../IStream.h"
6 #include "../../Common/MyCom.h"
7
8 #ifndef _NO_EXCEPTIONS
9 struct COutBufferException
10 {
11 HRESULT ErrorCode;
12 COutBufferException(HRESULT errorCode): ErrorCode(errorCode) {}
13 };
14 #endif
15
16 class COutBuffer
17 {
18 protected:
19 Byte *_buffer;
20 UInt32 _pos;
21 UInt32 _limitPos;
22 UInt32 _streamPos;
23 UInt32 _bufferSize;
24 CMyComPtr<ISequentialOutStream> _stream;
25 UInt64 _processedSize;
26 Byte *_buffer2;
27 bool _overDict;
28
29 HRESULT FlushPart();
30 void FlushWithCheck();
31 public:
32 #ifdef _NO_EXCEPTIONS
33 HRESULT ErrorCode;
34 #endif
35
36 COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {}
37 ~COutBuffer() { Free(); }
38
39 bool Create(UInt32 bufferSize);
40 void Free();
41
42 void SetMemStream(Byte *buffer) { _buffer2 = buffer; }
43 void SetStream(ISequentialOutStream *stream);
44 void Init();
45 HRESULT Flush();
46 void ReleaseStream() { _stream.Release(); }
47
48 void WriteByte(Byte b)
49 {
50 _buffer[_pos++] = b;
51 if(_pos == _limitPos)
52 FlushWithCheck();
53 }
54 void WriteBytes(const void *data, size_t size)
55 {
56 for (size_t i = 0; i < size; i++)
57 WriteByte(((const Byte *)data)[i]);
58 }
59
60 UInt64 GetProcessedSize() const;
61 };
62
63 #endif
0 // StdAfx.h
1
2 #ifndef __STDAFX_H
3 #define __STDAFX_H
4
5 #include "../../Common/MyWindows.h"
6 #include "../../Common/NewHandler.h"
7
8 #endif
0 // StreamUtils.cpp
1
2 #include "StdAfx.h"
3
4 #include "../../Common/MyCom.h"
5 #include "StreamUtils.h"
6
7 HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize)
8 {
9 if (processedSize != 0)
10 *processedSize = 0;
11 while(size != 0)
12 {
13 UInt32 processedSizeLoc;
14 HRESULT res = stream->Read(data, size, &processedSizeLoc);
15 if (processedSize != 0)
16 *processedSize += processedSizeLoc;
17 data = (Byte *)((Byte *)data + processedSizeLoc);
18 size -= processedSizeLoc;
19 RINOK(res);
20 if (processedSizeLoc == 0)
21 return S_OK;
22 }
23 return S_OK;
24 }
25
26 HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize)
27 {
28 if (processedSize != 0)
29 *processedSize = 0;
30 while(size != 0)
31 {
32 UInt32 processedSizeLoc;
33 HRESULT res = stream->Write(data, size, &processedSizeLoc);
34 if (processedSize != 0)
35 *processedSize += processedSizeLoc;
36 data = (const void *)((const Byte *)data + processedSizeLoc);
37 size -= processedSizeLoc;
38 RINOK(res);
39 if (processedSizeLoc == 0)
40 break;
41 }
42 return S_OK;
43 }
0 // StreamUtils.h
1
2 #ifndef __STREAMUTILS_H
3 #define __STREAMUTILS_H
4
5 #include "../IStream.h"
6
7 HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize);
8 HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize);
9
10 #endif
0 // ARM.cpp
1
2 #include "StdAfx.h"
3 #include "ARM.h"
4
5 #include "BranchARM.c"
6
7 UInt32 CBC_ARM_Encoder::SubFilter(Byte *data, UInt32 size)
8 {
9 return ::ARM_Convert(data, size, _bufferPos, 1);
10 }
11
12 UInt32 CBC_ARM_Decoder::SubFilter(Byte *data, UInt32 size)
13 {
14 return ::ARM_Convert(data, size, _bufferPos, 0);
15 }
0 // ARM.h
1
2 #ifndef __ARM_H
3 #define __ARM_H
4
5 #include "BranchCoder.h"
6
7 MyClassA(BC_ARM, 0x05, 1)
8
9 #endif
0 // ARMThumb.cpp
1
2 #include "StdAfx.h"
3 #include "ARMThumb.h"
4
5 #include "BranchARMThumb.c"
6
7 UInt32 CBC_ARMThumb_Encoder::SubFilter(Byte *data, UInt32 size)
8 {
9 return ::ARMThumb_Convert(data, size, _bufferPos, 1);
10 }
11
12 UInt32 CBC_ARMThumb_Decoder::SubFilter(Byte *data, UInt32 size)
13 {
14 return ::ARMThumb_Convert(data, size, _bufferPos, 0);
15 }
0 // ARMThumb.h
1
2 #ifndef __ARMTHUMB_H
3 #define __ARMTHUMB_H
4
5 #include "BranchCoder.h"
6
7 MyClassA(BC_ARMThumb, 0x07, 1)
8
9 #endif
0 /* BranchARM.c */
1
2 #include "BranchARM.h"
3
4 UInt32 ARM_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
5 {
6 UInt32 i;
7 for (i = 0; i + 4 <= size; i += 4)
8 {
9 if (data[i + 3] == 0xEB)
10 {
11 UInt32 src = (data[i + 2] << 16) | (data[i + 1] << 8) | (data[i + 0]);
12 src <<= 2;
13 UInt32 dest;
14 if (encoding)
15 dest = nowPos + i + 8 + src;
16 else
17 dest = src - (nowPos + i + 8);
18 dest >>= 2;
19 data[i + 2] = (dest >> 16);
20 data[i + 1] = (dest >> 8);
21 data[i + 0] = dest;
22 }
23 }
24 return i;
25 }
0 // BranchARM.h
1
2 #ifndef __BRANCH_ARM_H
3 #define __BRANCH_ARM_H
4
5 #include "BranchTypes.h"
6
7 UInt32 ARM_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
8
9 #endif
0 /* BranchARMThumb.c */
1
2 #include "BranchARMThumb.h"
3
4 UInt32 ARMThumb_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
5 {
6 UInt32 i;
7 for (i = 0; i + 4 <= size; i += 2)
8 {
9 if ((data[i + 1] & 0xF8) == 0xF0 &&
10 (data[i + 3] & 0xF8) == 0xF8)
11 {
12 UInt32 src =
13 ((data[i + 1] & 0x7) << 19) |
14 (data[i + 0] << 11) |
15 ((data[i + 3] & 0x7) << 8) |
16 (data[i + 2]);
17
18 src <<= 1;
19 UInt32 dest;
20 if (encoding)
21 dest = nowPos + i + 4 + src;
22 else
23 dest = src - (nowPos + i + 4);
24 dest >>= 1;
25
26 data[i + 1] = 0xF0 | ((dest >> 19) & 0x7);
27 data[i + 0] = (dest >> 11);
28 data[i + 3] = 0xF8 | ((dest >> 8) & 0x7);
29 data[i + 2] = (dest);
30 i += 2;
31 }
32 }
33 return i;
34 }
0 // BranchARMThumb.h
1
2 #ifndef __BRANCH_ARM_THUMB_H
3 #define __BRANCH_ARM_THUMB_H
4
5 #include "BranchTypes.h"
6
7 UInt32 ARMThumb_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
8
9 #endif
0 // BranchCoder.cpp
1
2 #include "StdAfx.h"
3 #include "BranchCoder.h"
4
5 STDMETHODIMP CBranchConverter::Init()
6 {
7 _bufferPos = 0;
8 SubInit();
9 return S_OK;
10 }
11
12 STDMETHODIMP_(UInt32) CBranchConverter::Filter(Byte *data, UInt32 size)
13 {
14 UInt32 processedSize = SubFilter(data, size);
15 _bufferPos += processedSize;
16 return processedSize;
17 }
0 // BranchCoder.h
1
2 #ifndef __BRANCH_CODER_H
3 #define __BRANCH_CODER_H
4
5 #include "Common/MyCom.h"
6 #include "Common/Types.h"
7 #include "Common/Alloc.h"
8
9 #include "../../ICoder.h"
10
11 class CBranchConverter:
12 public ICompressFilter,
13 public CMyUnknownImp
14 {
15 protected:
16 UInt32 _bufferPos;
17 virtual void SubInit() {}
18 virtual UInt32 SubFilter(Byte *data, UInt32 size) = 0;
19 public:
20 MY_UNKNOWN_IMP;
21 STDMETHOD(Init)();
22 STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size);
23 };
24
25 #define MyClassEncoderA(Name) class C ## Name: public CBranchConverter \
26 { public: UInt32 SubFilter(Byte *data, UInt32 size); };
27
28 #define MyClassDecoderA(Name) class C ## Name: public CBranchConverter \
29 { public: UInt32 SubFilter(Byte *data, UInt32 size); };
30
31 #define MyClassEncoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
32 { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
33
34 #define MyClassDecoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \
35 { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT};
36
37 #define MyClass2b(Name, id, subId, encodingId) \
38 DEFINE_GUID(CLSID_CCompressConvert ## Name, \
39 0x23170F69, 0x40C1, 0x278B, 0x03, 0x03, id, subId, 0x00, 0x00, encodingId, 0x00);
40
41 #define MyClassA(Name, id, subId) \
42 MyClass2b(Name ## _Encoder, id, subId, 0x01) \
43 MyClassEncoderA(Name ## _Encoder) \
44 MyClass2b(Name ## _Decoder, id, subId, 0x00) \
45 MyClassDecoderA(Name ## _Decoder)
46
47 #define MyClassB(Name, id, subId, ADD_ITEMS, ADD_INIT) \
48 MyClass2b(Name ## _Encoder, id, subId, 0x01) \
49 MyClassEncoderB(Name ## _Encoder, ADD_ITEMS, ADD_INIT) \
50 MyClass2b(Name ## _Decoder, id, subId, 0x00) \
51 MyClassDecoderB(Name ## _Decoder, ADD_ITEMS, ADD_INIT)
52
53 #endif
0 /* BranchIA64.c */
1
2 #include "BranchIA64.h"
3
4 const Byte kBranchTable[32] =
5 {
6 0, 0, 0, 0, 0, 0, 0, 0,
7 0, 0, 0, 0, 0, 0, 0, 0,
8 4, 4, 6, 6, 0, 0, 7, 7,
9 4, 4, 0, 0, 4, 4, 0, 0
10 };
11
12 UInt32 IA64_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
13 {
14 UInt32 i;
15 for (i = 0; i + 16 <= size; i += 16)
16 {
17 UInt32 instrTemplate = data[i] & 0x1F;
18 UInt32 mask = kBranchTable[instrTemplate];
19 UInt32 bitPos = 5;
20 for (int slot = 0; slot < 3; slot++, bitPos += 41)
21 {
22 if (((mask >> slot) & 1) == 0)
23 continue;
24 UInt32 bytePos = (bitPos >> 3);
25 UInt32 bitRes = bitPos & 0x7;
26 UInt64 instruction = 0;
27 int j;
28 for (j = 0; j < 6; j++)
29 instruction += (UInt64)(data[i + j + bytePos]) << (8 * j);
30
31 UInt64 instNorm = instruction >> bitRes;
32 if (((instNorm >> 37) & 0xF) == 0x5
33 && ((instNorm >> 9) & 0x7) == 0
34 /* && (instNorm & 0x3F)== 0 */
35 )
36 {
37 UInt32 src = UInt32((instNorm >> 13) & 0xFFFFF);
38 src |= ((instNorm >> 36) & 1) << 20;
39
40 src <<= 4;
41
42 UInt32 dest;
43 if (encoding)
44 dest = nowPos + i + src;
45 else
46 dest = src - (nowPos + i);
47
48 dest >>= 4;
49
50 instNorm &= ~(UInt64(0x8FFFFF) << 13);
51 instNorm |= (UInt64(dest & 0xFFFFF) << 13);
52 instNorm |= (UInt64(dest & 0x100000) << (36 - 20));
53
54 instruction &= (1 << bitRes) - 1;
55 instruction |= (instNorm << bitRes);
56 for (j = 0; j < 6; j++)
57 data[i + j + bytePos] = Byte(instruction >> (8 * j));
58 }
59 }
60 }
61 return i;
62 }
0 // BranchIA64.h
1
2 #ifndef __BRANCH_IA64_H
3 #define __BRANCH_IA64_H
4
5 #include "BranchTypes.h"
6
7 UInt32 IA64_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
8
9 #endif
0 /* BranchPPC.c */
1
2 #include "BranchPPC.h"
3
4 UInt32 PPC_B_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
5 {
6 UInt32 i;
7 for (i = 0; i + 4 <= size; i += 4)
8 {
9 /* PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link) */
10 if ((data[i] >> 2) == 0x12 &&
11 (
12 (data[i + 3] & 3) == 1
13 /* || (data[i+3] & 3) == 3 */
14 )
15 )
16 {
17 UInt32 src = ((data[i + 0] & 3) << 24) |
18 (data[i + 1] << 16) |
19 (data[i + 2] << 8) |
20 (data[i + 3] & (~3));
21
22 UInt32 dest;
23 if (encoding)
24 dest = nowPos + i + src;
25 else
26 dest = src - (nowPos + i);
27 data[i + 0] = 0x48 | ((dest >> 24) & 0x3);
28 data[i + 1] = (dest >> 16);
29 data[i + 2] = (dest >> 8);
30 data[i + 3] &= 0x3;
31 data[i + 3] |= dest;
32 }
33 }
34 return i;
35 }
0 // BranchPPC.h
1
2 #ifndef __BRANCH_PPC_H
3 #define __BRANCH_PPC_H
4
5 #include "BranchTypes.h"
6
7 UInt32 PPC_B_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
8
9 #endif
0 /* BranchSPARC.c */
1
2 #include "BranchSPARC.h"
3
4 UInt32 SPARC_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding)
5 {
6 UInt32 i;
7 for (i = 0; i + 4 <= size; i += 4)
8 {
9 if (data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00 ||
10 data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)
11 {
12 UInt32 src =
13 ((UInt32)data[i + 0] << 24) |
14 ((UInt32)data[i + 1] << 16) |
15 ((UInt32)data[i + 2] << 8) |
16 ((UInt32)data[i + 3]);
17
18 src <<= 2;
19 UInt32 dest;
20 if (encoding)
21 dest = nowPos + i + src;
22 else
23 dest = src - (nowPos + i);
24 dest >>= 2;
25
26 dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000;
27
28 data[i + 0] = (Byte)(dest >> 24);
29 data[i + 1] = (Byte)(dest >> 16);
30 data[i + 2] = (Byte)(dest >> 8);
31 data[i + 3] = (Byte)dest;
32 }
33 }
34 return i;
35 }
0 // BranchSPARC.h
1
2 #ifndef __BRANCH_SPARC_H
3 #define __BRANCH_SPARC_H
4
5 #include "BranchTypes.h"
6
7 UInt32 SPARC_B_Convert(Byte *data, UInt32 size, UInt32 nowPos, int encoding);
8
9 #endif
0 /* BranchTypes.h */
1
2 #ifndef __BRANCHTYPES_H
3 #define __BRANCHTYPES_H
4
5 #ifndef _7ZIP_BYTE_DEFINED
6 #define _7ZIP_BYTE_DEFINED
7 typedef unsigned char Byte;
8 #endif
9
10 #ifndef _7ZIP_UINT16_DEFINED
11 #define _7ZIP_UINT16_DEFINED
12 typedef unsigned short UInt16;
13 #endif
14
15 #ifndef _7ZIP_UINT32_DEFINED
16 #define _7ZIP_UINT32_DEFINED
17 #ifdef _LZMA_UINT32_IS_ULONG
18 typedef unsigned long UInt32;
19 #else
20 typedef unsigned int UInt32;
21 #endif
22 #endif
23
24 #endif
0 /* BranchX86.c */
1
2 #include "BranchX86.h"
3
4 /*
5 static int inline Test86MSByte(Byte b)
6 {
7 return (b == 0 || b == 0xFF);
8 }
9 */
10 #define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)
11
12 const int kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0};
13 const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3};
14
15 /*
16 void x86_Convert_Init(UInt32 *prevMask, UInt32 *prevPos)
17 {
18 *prevMask = 0;
19 *prevPos = (UInt32)(-5);
20 }
21 */
22
23 UInt32 x86_Convert(Byte *buffer, UInt32 endPos, UInt32 nowPos,
24 UInt32 *prevMask, UInt32 *prevPos, int encoding)
25 {
26 UInt32 bufferPos = 0;
27 UInt32 limit;
28
29 if (endPos < 5)
30 return 0;
31
32 if (nowPos - *prevPos > 5)
33 *prevPos = nowPos - 5;
34
35 limit = endPos - 5;
36 while(bufferPos <= limit)
37 {
38 Byte b = buffer[bufferPos];
39 UInt32 offset;
40 if (b != 0xE8 && b != 0xE9)
41 {
42 bufferPos++;
43 continue;
44 }
45 offset = (nowPos + bufferPos - *prevPos);
46 *prevPos = (nowPos + bufferPos);
47 if (offset > 5)
48 *prevMask = 0;
49 else
50 {
51 UInt32 i;
52 for (i = 0; i < offset; i++)
53 {
54 *prevMask &= 0x77;
55 *prevMask <<= 1;
56 }
57 }
58 b = buffer[bufferPos + 4];
59 if (Test86MSByte(b) && kMaskToAllowedStatus[(*prevMask >> 1) & 0x7] &&
60 (*prevMask >> 1) < 0x10)
61 {
62 UInt32 src =
63 ((UInt32)(b) << 24) |
64 ((UInt32)(buffer[bufferPos + 3]) << 16) |
65 ((UInt32)(buffer[bufferPos + 2]) << 8) |
66 (buffer[bufferPos + 1]);
67
68 UInt32 dest;
69 while(1)
70 {
71 UInt32 index;
72 if (encoding)
73 dest = (nowPos + bufferPos + 5) + src;
74 else
75 dest = src - (nowPos + bufferPos + 5);
76 if (*prevMask == 0)
77 break;
78 index = kMaskToBitNumber[*prevMask >> 1];
79 b = (Byte)(dest >> (24 - index * 8));
80 if (!Test86MSByte(b))
81 break;
82 src = dest ^ ((1 << (32 - index * 8)) - 1);
83 }
84 buffer[bufferPos + 4] = (Byte)(~(((dest >> 24) & 1) - 1));
85 buffer[bufferPos + 3] = (Byte)(dest >> 16);
86 buffer[bufferPos + 2] = (Byte)(dest >> 8);
87 buffer[bufferPos + 1] = (Byte)dest;
88 bufferPos += 5;
89 *prevMask = 0;
90 }
91 else
92 {
93 bufferPos++;
94 *prevMask |= 1;
95 if (Test86MSByte(b))
96 *prevMask |= 0x10;
97 }
98 }
99 return bufferPos;
100 }
0 /* BranchX86.h */
1
2 #ifndef __BRANCHX86_H
3 #define __BRANCHX86_H
4
5 #include "BranchTypes.h"
6
7 #define x86_Convert_Init(prevMask, prevPos) { prevMask = 0; prevPos = (UInt32)(-5); }
8
9 UInt32 x86_Convert(Byte *buffer, UInt32 endPos, UInt32 nowPos,
10 UInt32 *prevMask, UInt32 *prevPos, int encoding);
11
12 #endif
0 // IA64.cpp
1
2 #include "StdAfx.h"
3 #include "IA64.h"
4
5 #include "BranchIA64.c"
6
7 UInt32 CBC_IA64_Encoder::SubFilter(Byte *data, UInt32 size)
8 {
9 return ::IA64_Convert(data, size, _bufferPos, 1);
10 }
11
12 UInt32 CBC_IA64_Decoder::SubFilter(Byte *data, UInt32 size)
13 {
14 return ::IA64_Convert(data, size, _bufferPos, 0);
15 }
0 // IA64.h
1
2 #ifndef __IA64_H
3 #define __IA64_H
4
5 #include "BranchCoder.h"
6
7 MyClassA(BC_IA64, 0x04, 1)
8
9 #endif
0 // PPC.cpp
1
2 #include "StdAfx.h"
3 #include "PPC.h"
4
5 #include "Windows/Defs.h"
6 #include "BranchPPC.c"
7
8 UInt32 CBC_PPC_B_Encoder::SubFilter(Byte *data, UInt32 size)
9 {
10 return ::PPC_B_Convert(data, size, _bufferPos, 1);
11 }
12
13 UInt32 CBC_PPC_B_Decoder::SubFilter(Byte *data, UInt32 size)
14 {
15 return ::PPC_B_Convert(data, size, _bufferPos, 0);
16 }
0 // PPC.h
1
2 #ifndef __PPC_H
3 #define __PPC_H
4
5 #include "BranchCoder.h"
6
7 MyClassA(BC_PPC_B, 0x02, 5)
8
9 #endif
0 // SPARC.cpp
1
2 #include "StdAfx.h"
3 #include "SPARC.h"
4
5 #include "Windows/Defs.h"
6 #include "BranchSPARC.c"
7
8 UInt32 CBC_SPARC_Encoder::SubFilter(Byte *data, UInt32 size)
9 {
10 return ::SPARC_Convert(data, size, _bufferPos, 1);
11 }
12
13 UInt32 CBC_SPARC_Decoder::SubFilter(Byte *data, UInt32 size)
14 {
15 return ::SPARC_Convert(data, size, _bufferPos, 0);
16 }
0 // SPARC.h
1
2 #ifndef __SPARC_H
3 #define __SPARC_H
4
5 #include "BranchCoder.h"
6
7 MyClassA(BC_SPARC, 0x08, 5)
8
9 #endif
0 // StdAfx.h
1
2 #ifndef __STDAFX_H
3 #define __STDAFX_H
4
5 #include "../../../Common/MyWindows.h"
6
7 #endif
0 // x86.cpp
1
2 #include "StdAfx.h"
3 #include "x86.h"
4
5 #include "Windows/Defs.h"
6
7 #include "BranchX86.c"
8
9 UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size)
10 {
11 return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 1);
12 }
13
14 UInt32 CBCJ_x86_Decoder::SubFilter(Byte *data, UInt32 size)
15 {
16 return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 0);
17 }
0 // x86.h
1
2 #ifndef __X86_H
3 #define __X86_H
4
5 #include "BranchCoder.h"
6 #include "BranchX86.h"
7
8 struct CBranch86
9 {
10 UInt32 _prevMask;
11 UInt32 _prevPos;
12 void x86Init() { x86_Convert_Init(_prevMask, _prevPos); }
13 };
14
15 MyClassB(BCJ_x86, 0x01, 3, CBranch86 ,
16 virtual void SubInit() { x86Init(); })
17
18 #endif
0 // x86_2.cpp
1
2 #include "StdAfx.h"
3 #include "x86_2.h"
4
5 #include "../../../Common/Alloc.h"
6
7 static const int kBufferSize = 1 << 17;
8
9 inline bool IsJcc(Byte b0, Byte b1)
10 {
11 return (b0 == 0x0F && (b1 & 0xF0) == 0x80);
12 }
13
14 #ifndef EXTRACT_ONLY
15
16 static bool inline Test86MSByte(Byte b)
17 {
18 return (b == 0 || b == 0xFF);
19 }
20
21 bool CBCJ2_x86_Encoder::Create()
22 {
23 if (!_mainStream.Create(1 << 16))
24 return false;
25 if (!_callStream.Create(1 << 20))
26 return false;
27 if (!_jumpStream.Create(1 << 20))
28 return false;
29 if (!_rangeEncoder.Create(1 << 20))
30 return false;
31 if (_buffer == 0)
32 {
33 _buffer = (Byte *)MidAlloc(kBufferSize);
34 if (_buffer == 0)
35 return false;
36 }
37 return true;
38 }
39
40 CBCJ2_x86_Encoder::~CBCJ2_x86_Encoder()
41 {
42 ::MidFree(_buffer);
43 }
44
45 HRESULT CBCJ2_x86_Encoder::Flush()
46 {
47 RINOK(_mainStream.Flush());
48 RINOK(_callStream.Flush());
49 RINOK(_jumpStream.Flush());
50 _rangeEncoder.FlushData();
51 return _rangeEncoder.FlushStream();
52 }
53
54 const UInt32 kDefaultLimit = (1 << 24);
55
56 HRESULT CBCJ2_x86_Encoder::CodeReal(ISequentialInStream **inStreams,
57 const UInt64 **inSizes,
58 UInt32 numInStreams,
59 ISequentialOutStream **outStreams,
60 const UInt64 **outSizes,
61 UInt32 numOutStreams,
62 ICompressProgressInfo *progress)
63 {
64 if (numInStreams != 1 || numOutStreams != 4)
65 return E_INVALIDARG;
66
67 if (!Create())
68 return E_OUTOFMEMORY;
69
70 bool sizeIsDefined = false;
71 UInt64 inSize;
72 if (inSizes != NULL)
73 if (inSizes[0] != NULL)
74 {
75 inSize = *inSizes[0];
76 if (inSize <= kDefaultLimit)
77 sizeIsDefined = true;
78 }
79
80 ISequentialInStream *inStream = inStreams[0];
81
82 _mainStream.SetStream(outStreams[0]);
83 _mainStream.Init();
84 _callStream.SetStream(outStreams[1]);
85 _callStream.Init();
86 _jumpStream.SetStream(outStreams[2]);
87 _jumpStream.Init();
88 _rangeEncoder.SetStream(outStreams[3]);
89 _rangeEncoder.Init();
90 for (int i = 0; i < 256; i++)
91 _statusE8Encoder[i].Init();
92 _statusE9Encoder.Init();
93 _statusJccEncoder.Init();
94 CCoderReleaser releaser(this);
95
96 CMyComPtr<ICompressGetSubStreamSize> getSubStreamSize;
97 {
98 inStream->QueryInterface(IID_ICompressGetSubStreamSize, (void **)&getSubStreamSize);
99 }
100
101 UInt32 nowPos = 0;
102 UInt64 nowPos64 = 0;
103 UInt32 bufferPos = 0;
104
105 Byte prevByte = 0;
106
107 UInt64 subStreamIndex = 0;
108 UInt64 subStreamStartPos = 0;
109 UInt64 subStreamEndPos = 0;
110
111 while(true)
112 {
113 UInt32 processedSize = 0;
114 while(true)
115 {
116 UInt32 size = kBufferSize - (bufferPos + processedSize);
117 UInt32 processedSizeLoc;
118 if (size == 0)
119 break;
120 RINOK(inStream->Read(_buffer + bufferPos + processedSize, size, &processedSizeLoc));
121 if (processedSizeLoc == 0)
122 break;
123 processedSize += processedSizeLoc;
124 }
125 UInt32 endPos = bufferPos + processedSize;
126
127 if (endPos < 5)
128 {
129 // change it
130 for (bufferPos = 0; bufferPos < endPos; bufferPos++)
131 {
132 Byte b = _buffer[bufferPos];
133 _mainStream.WriteByte(b);
134 if (b == 0xE8)
135 _statusE8Encoder[prevByte].Encode(&_rangeEncoder, 0);
136 else if (b == 0xE9)
137 _statusE9Encoder.Encode(&_rangeEncoder, 0);
138 else if (IsJcc(prevByte, b))
139 _statusJccEncoder.Encode(&_rangeEncoder, 0);
140 prevByte = b;
141 }
142 return Flush();
143 }
144
145 bufferPos = 0;
146
147 UInt32 limit = endPos - 5;
148 while(bufferPos <= limit)
149 {
150 Byte b = _buffer[bufferPos];
151 _mainStream.WriteByte(b);
152 if (b != 0xE8 && b != 0xE9 && !IsJcc(prevByte, b))
153 {
154 bufferPos++;
155 prevByte = b;
156 continue;
157 }
158 Byte nextByte = _buffer[bufferPos + 4];
159 UInt32 src =
160 (UInt32(nextByte) << 24) |
161 (UInt32(_buffer[bufferPos + 3]) << 16) |
162 (UInt32(_buffer[bufferPos + 2]) << 8) |
163 (_buffer[bufferPos + 1]);
164 UInt32 dest = (nowPos + bufferPos + 5) + src;
165 // if (Test86MSByte(nextByte))
166 bool convert;
167 if (getSubStreamSize != NULL)
168 {
169 UInt64 currentPos = (nowPos64 + bufferPos);
170 while (subStreamEndPos < currentPos)
171 {
172 UInt64 subStreamSize;
173 HRESULT result = getSubStreamSize->GetSubStreamSize(subStreamIndex, &subStreamSize);
174 if (result == S_OK)
175 {
176 subStreamStartPos = subStreamEndPos;
177 subStreamEndPos += subStreamSize;
178 subStreamIndex++;
179 }
180 else if (result == S_FALSE || result == E_NOTIMPL)
181 {
182 getSubStreamSize.Release();
183 subStreamStartPos = 0;
184 subStreamEndPos = subStreamStartPos - 1;
185 }
186 else
187 return result;
188 }
189 if (getSubStreamSize == NULL)
190 {
191 if (sizeIsDefined)
192 convert = (dest < inSize);
193 else
194 convert = Test86MSByte(nextByte);
195 }
196 else if (subStreamEndPos - subStreamStartPos > kDefaultLimit)
197 convert = Test86MSByte(nextByte);
198 else
199 {
200 UInt64 dest64 = (currentPos + 5) + Int64(Int32(src));
201 convert = (dest64 >= subStreamStartPos && dest64 < subStreamEndPos);
202 }
203 }
204 else if (sizeIsDefined)
205 convert = (dest < inSize);
206 else
207 convert = Test86MSByte(nextByte);
208 if (convert)
209 {
210 if (b == 0xE8)
211 _statusE8Encoder[prevByte].Encode(&_rangeEncoder, 1);
212 else if (b == 0xE9)
213 _statusE9Encoder.Encode(&_rangeEncoder, 1);
214 else
215 _statusJccEncoder.Encode(&_rangeEncoder, 1);
216
217 bufferPos += 5;
218 if (b == 0xE8)
219 {
220 _callStream.WriteByte((Byte)(dest >> 24));
221 _callStream.WriteByte((Byte)(dest >> 16));
222 _callStream.WriteByte((Byte)(dest >> 8));
223 _callStream.WriteByte((Byte)(dest));
224 }
225 else
226 {
227 _jumpStream.WriteByte((Byte)(dest >> 24));
228 _jumpStream.WriteByte((Byte)(dest >> 16));
229 _jumpStream.WriteByte((Byte)(dest >> 8));
230 _jumpStream.WriteByte((Byte)(dest));
231 }
232 prevByte = nextByte;
233 }
234 else
235 {
236 if (b == 0xE8)
237 _statusE8Encoder[prevByte].Encode(&_rangeEncoder, 0);
238 else if (b == 0xE9)
239 _statusE9Encoder.Encode(&_rangeEncoder, 0);
240 else
241 _statusJccEncoder.Encode(&_rangeEncoder, 0);
242 bufferPos++;
243 prevByte = b;
244 }
245 }
246 nowPos += bufferPos;
247 nowPos64 += bufferPos;
248
249 if (progress != NULL)
250 {
251 RINOK(progress->SetRatioInfo(&nowPos64, NULL));
252 }
253
254 UInt32 i = 0;
255 while(bufferPos < endPos)
256 _buffer[i++] = _buffer[bufferPos++];
257 bufferPos = i;
258 }
259 }
260
261 STDMETHODIMP CBCJ2_x86_Encoder::Code(ISequentialInStream **inStreams,
262 const UInt64 **inSizes,
263 UInt32 numInStreams,
264 ISequentialOutStream **outStreams,
265 const UInt64 **outSizes,
266 UInt32 numOutStreams,
267 ICompressProgressInfo *progress)
268 {
269 try
270 {
271 return CodeReal(inStreams, inSizes, numInStreams,
272 outStreams, outSizes,numOutStreams, progress);
273 }
274 catch(const COutBufferException &e) { return e.ErrorCode; }
275 catch(...) { return S_FALSE; }
276 }
277
278 #endif
279
280 HRESULT CBCJ2_x86_Decoder::CodeReal(ISequentialInStream **inStreams,
281 const UInt64 **inSizes,
282 UInt32 numInStreams,
283 ISequentialOutStream **outStreams,
284 const UInt64 **outSizes,
285 UInt32 numOutStreams,
286 ICompressProgressInfo *progress)
287 {
288 if (numInStreams != 4 || numOutStreams != 1)
289 return E_INVALIDARG;
290
291 if (!_mainInStream.Create(1 << 16))
292 return E_OUTOFMEMORY;
293 if (!_callStream.Create(1 << 20))
294 return E_OUTOFMEMORY;
295 if (!_jumpStream.Create(1 << 16))
296 return E_OUTOFMEMORY;
297 if (!_rangeDecoder.Create(1 << 20))
298 return E_OUTOFMEMORY;
299 if (!_outStream.Create(1 << 16))
300 return E_OUTOFMEMORY;
301
302 _mainInStream.SetStream(inStreams[0]);
303 _callStream.SetStream(inStreams[1]);
304 _jumpStream.SetStream(inStreams[2]);
305 _rangeDecoder.SetStream(inStreams[3]);
306 _outStream.SetStream(outStreams[0]);
307
308 _mainInStream.Init();
309 _callStream.Init();
310 _jumpStream.Init();
311 _rangeDecoder.Init();
312 _outStream.Init();
313
314 for (int i = 0; i < 256; i++)
315 _statusE8Decoder[i].Init();
316 _statusE9Decoder.Init();
317 _statusJccDecoder.Init();
318
319 CCoderReleaser releaser(this);
320
321 Byte prevByte = 0;
322 UInt32 processedBytes = 0;
323 while(true)
324 {
325 if (processedBytes > (1 << 20) && progress != NULL)
326 {
327 UInt64 nowPos64 = _outStream.GetProcessedSize();
328 RINOK(progress->SetRatioInfo(NULL, &nowPos64));
329 processedBytes = 0;
330 }
331 processedBytes++;
332 Byte b;
333 if (!_mainInStream.ReadByte(b))
334 return Flush();
335 _outStream.WriteByte(b);
336 if (b != 0xE8 && b != 0xE9 && !IsJcc(prevByte, b))
337 {
338 prevByte = b;
339 continue;
340 }
341 bool status;
342 if (b == 0xE8)
343 status = (_statusE8Decoder[prevByte].Decode(&_rangeDecoder) == 1);
344 else if (b == 0xE9)
345 status = (_statusE9Decoder.Decode(&_rangeDecoder) == 1);
346 else
347 status = (_statusJccDecoder.Decode(&_rangeDecoder) == 1);
348 if (status)
349 {
350 UInt32 src;
351 if (b == 0xE8)
352 {
353 Byte b0;
354 if(!_callStream.ReadByte(b0))
355 return S_FALSE;
356 src = ((UInt32)b0) << 24;
357 if(!_callStream.ReadByte(b0))
358 return S_FALSE;
359 src |= ((UInt32)b0) << 16;
360 if(!_callStream.ReadByte(b0))
361 return S_FALSE;
362 src |= ((UInt32)b0) << 8;
363 if(!_callStream.ReadByte(b0))
364 return S_FALSE;
365 src |= ((UInt32)b0);
366 }
367 else
368 {
369 Byte b0;
370 if(!_jumpStream.ReadByte(b0))
371 return S_FALSE;
372 src = ((UInt32)b0) << 24;
373 if(!_jumpStream.ReadByte(b0))
374 return S_FALSE;
375 src |= ((UInt32)b0) << 16;
376 if(!_jumpStream.ReadByte(b0))
377 return S_FALSE;
378 src |= ((UInt32)b0) << 8;
379 if(!_jumpStream.ReadByte(b0))
380 return S_FALSE;
381 src |= ((UInt32)b0);
382 }
383 UInt32 dest = src - (UInt32(_outStream.GetProcessedSize()) + 4) ;
384 _outStream.WriteByte((Byte)(dest));
385 _outStream.WriteByte((Byte)(dest >> 8));
386 _outStream.WriteByte((Byte)(dest >> 16));
387 _outStream.WriteByte((Byte)(dest >> 24));
388 prevByte = (dest >> 24);
389 processedBytes += 4;
390 }
391 else
392 prevByte = b;
393 }
394 }
395
396 STDMETHODIMP CBCJ2_x86_Decoder::Code(ISequentialInStream **inStreams,
397 const UInt64 **inSizes,
398 UInt32 numInStreams,
399 ISequentialOutStream **outStreams,
400 const UInt64 **outSizes,
401 UInt32 numOutStreams,
402 ICompressProgressInfo *progress)
403 {
404 try
405 {
406 return CodeReal(inStreams, inSizes, numInStreams,
407 outStreams, outSizes,numOutStreams, progress);
408 }
409 catch(const COutBufferException &e) { return e.ErrorCode; }
410 catch(...) { return S_FALSE; }
411 }
0 // x86_2.h
1
2 #ifndef __BRANCH_X86_2_H
3 #define __BRANCH_X86_2_H
4
5 #include "../../../Common/MyCom.h"
6 #include "../RangeCoder/RangeCoderBit.h"
7 #include "../../ICoder.h"
8
9 // {23170F69-40C1-278B-0303-010100000100}
10 #define MyClass2_a(Name, id, subId, encodingId) \
11 DEFINE_GUID(CLSID_CCompressConvert ## Name, \
12 0x23170F69, 0x40C1, 0x278B, 0x03, 0x03, id, subId, 0x00, 0x00, encodingId, 0x00);
13
14 #define MyClass_a(Name, id, subId) \
15 MyClass2_a(Name ## _Encoder, id, subId, 0x01) \
16 MyClass2_a(Name ## _Decoder, id, subId, 0x00)
17
18 MyClass_a(BCJ2_x86, 0x01, 0x1B)
19
20 const int kNumMoveBits = 5;
21
22 #ifndef EXTRACT_ONLY
23
24 class CBCJ2_x86_Encoder:
25 public ICompressCoder2,
26 public CMyUnknownImp
27 {
28 Byte *_buffer;
29 public:
30 CBCJ2_x86_Encoder(): _buffer(0) {};
31 ~CBCJ2_x86_Encoder();
32 bool Create();
33
34 COutBuffer _mainStream;
35 COutBuffer _callStream;
36 COutBuffer _jumpStream;
37 NCompress::NRangeCoder::CEncoder _rangeEncoder;
38 NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusE8Encoder[256];
39 NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusE9Encoder;
40 NCompress::NRangeCoder::CBitEncoder<kNumMoveBits> _statusJccEncoder;
41
42 HRESULT Flush();
43 void ReleaseStreams()
44 {
45 _mainStream.ReleaseStream();
46 _callStream.ReleaseStream();
47 _jumpStream.ReleaseStream();
48 _rangeEncoder.ReleaseStream();
49 }
50
51 class CCoderReleaser
52 {
53 CBCJ2_x86_Encoder *_coder;
54 public:
55 CCoderReleaser(CBCJ2_x86_Encoder *coder): _coder(coder) {}
56 ~CCoderReleaser() { _coder->ReleaseStreams(); }
57 };
58
59 public:
60
61 MY_UNKNOWN_IMP
62
63 HRESULT CodeReal(ISequentialInStream **inStreams,
64 const UInt64 **inSizes,
65 UInt32 numInStreams,
66 ISequentialOutStream **outStreams,
67 const UInt64 **outSizes,
68 UInt32 numOutStreams,
69 ICompressProgressInfo *progress);
70 STDMETHOD(Code)(ISequentialInStream **inStreams,
71 const UInt64 **inSizes,
72 UInt32 numInStreams,
73 ISequentialOutStream **outStreams,
74 const UInt64 **outSizes,
75 UInt32 numOutStreams,
76 ICompressProgressInfo *progress);
77 };
78
79 #endif
80
81 class CBCJ2_x86_Decoder:
82 public ICompressCoder2,
83 public CMyUnknownImp
84 {
85 public:
86 CInBuffer _mainInStream;
87 CInBuffer _callStream;
88 CInBuffer _jumpStream;
89 NCompress::NRangeCoder::CDecoder _rangeDecoder;
90 NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusE8Decoder[256];
91 NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusE9Decoder;
92 NCompress::NRangeCoder::CBitDecoder<kNumMoveBits> _statusJccDecoder;
93
94 COutBuffer _outStream;
95
96 void ReleaseStreams()
97 {
98 _mainInStream.ReleaseStream();
99 _callStream.ReleaseStream();
100 _jumpStream.ReleaseStream();
101 _rangeDecoder.ReleaseStream();
102 _outStream.ReleaseStream();
103 }
104
105 HRESULT Flush() { return _outStream.Flush(); }
106 class CCoderReleaser
107 {
108 CBCJ2_x86_Decoder *_coder;
109 public:
110 CCoderReleaser(CBCJ2_x86_Decoder *coder): _coder(coder) {}
111 ~CCoderReleaser() { _coder->ReleaseStreams(); }
112 };
113
114 public:
115 MY_UNKNOWN_IMP
116 HRESULT CodeReal(ISequentialInStream **inStreams,
117 const UInt64 **inSizes,
118 UInt32 numInStreams,
119 ISequentialOutStream **outStreams,
120 const UInt64 **outSizes,
121 UInt32 numOutStreams,
122 ICompressProgressInfo *progress);
123 STDMETHOD(Code)(ISequentialInStream **inStreams,
124 const UInt64 **inSizes,
125 UInt32 numInStreams,
126 ISequentialOutStream **outStreams,
127 const UInt64 **outSizes,
128 UInt32 numOutStreams,
129 ICompressProgressInfo *progress);
130 };
131
132 #endif
0 // BinTree.h
1
2 #include "../LZInWindow.h"
3 #include "../IMatchFinder.h"
4
5 namespace BT_NAMESPACE {
6
7 typedef UInt32 CIndex;
8 const UInt32 kMaxValForNormalize = (UInt32(1) << 31) - 1;
9
10 class CMatchFinder:
11 public IMatchFinder,
12 public CLZInWindow,
13 public CMyUnknownImp,
14 public IMatchFinderSetNumPasses
15 {
16 UInt32 _cyclicBufferPos;
17 UInt32 _cyclicBufferSize; // it must be historySize + 1
18 UInt32 _matchMaxLen;
19 CIndex *_hash;
20 CIndex *_son;
21 UInt32 _hashMask;
22 UInt32 _cutValue;
23 UInt32 _hashSizeSum;
24
25 void Normalize();
26 void FreeThisClassMemory();
27 void FreeMemory();
28
29 MY_UNKNOWN_IMP
30
31 STDMETHOD(SetStream)(ISequentialInStream *inStream);
32 STDMETHOD_(void, ReleaseStream)();
33 STDMETHOD(Init)();
34 HRESULT MovePos();
35 STDMETHOD_(Byte, GetIndexByte)(Int32 index);
36 STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 back, UInt32 limit);
37 STDMETHOD_(UInt32, GetNumAvailableBytes)();
38 STDMETHOD_(const Byte *, GetPointerToCurrentPos)();
39 STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes);
40 STDMETHOD_(void, ChangeBufferPos)();
41
42 STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore,
43 UInt32 matchMaxLen, UInt32 keepAddBufferAfter);
44 STDMETHOD(GetMatches)(UInt32 *distances);
45 STDMETHOD(Skip)(UInt32 num);
46
47 public:
48 CMatchFinder();
49 virtual ~CMatchFinder();
50 virtual void SetNumPasses(UInt32 numPasses) { _cutValue = numPasses; }
51 };
52
53 }
0 // BinTree2.h
1
2 #ifndef __BINTREE2_H
3 #define __BINTREE2_H
4
5 #define BT_NAMESPACE NBT2
6
7 #include "BinTreeMain.h"
8
9 #undef BT_NAMESPACE
10
11 #endif
0 // BinTree3.h
1
2 #ifndef __BINTREE3_H
3 #define __BINTREE3_H
4
5 #define BT_NAMESPACE NBT3
6
7 #define HASH_ARRAY_2
8
9 #include "BinTreeMain.h"
10
11 #undef HASH_ARRAY_2
12
13 #undef BT_NAMESPACE
14
15 #endif
0 // BinTree3Z.h
1
2 #ifndef __BINTREE3Z_H
3 #define __BINTREE3Z_H
4
5 #define BT_NAMESPACE NBT3Z
6
7 #define HASH_ZIP
8
9 #include "BinTreeMain.h"
10
11 #undef HASH_ZIP
12
13 #undef BT_NAMESPACE
14
15 #endif
0 // BinTree4.h
1
2 #ifndef __BINTREE4_H
3 #define __BINTREE4_H
4
5 #define BT_NAMESPACE NBT4
6
7 #define HASH_ARRAY_2
8 #define HASH_ARRAY_3
9
10 #include "BinTreeMain.h"
11
12 #undef HASH_ARRAY_2
13 #undef HASH_ARRAY_3
14
15 #undef BT_NAMESPACE
16
17 #endif
0 // BinTreeMain.h
1
2 #include "../../../../Common/Defs.h"
3 #include "../../../../Common/CRC.h"
4 #include "../../../../Common/Alloc.h"
5
6 #include "BinTree.h"
7
8 // #include <xmmintrin.h>
9 // It's for prefetch
10 // But prefetch doesn't give big gain in K8.
11
12 namespace BT_NAMESPACE {
13
14 #ifdef HASH_ARRAY_2
15 static const UInt32 kHash2Size = 1 << 10;
16 #define kNumHashDirectBytes 0
17 #ifdef HASH_ARRAY_3
18 static const UInt32 kNumHashBytes = 4;
19 static const UInt32 kHash3Size = 1 << 16;
20 #else
21 static const UInt32 kNumHashBytes = 3;
22 #endif
23 static const UInt32 kHashSize = 0;
24 static const UInt32 kMinMatchCheck = kNumHashBytes;
25 static const UInt32 kStartMaxLen = 1;
26 #else
27 #ifdef HASH_ZIP
28 #define kNumHashDirectBytes 0
29 static const UInt32 kNumHashBytes = 3;
30 static const UInt32 kHashSize = 1 << 16;
31 static const UInt32 kMinMatchCheck = kNumHashBytes;
32 static const UInt32 kStartMaxLen = 1;
33 #else
34 #define kNumHashDirectBytes 2
35 static const UInt32 kNumHashBytes = 2;
36 static const UInt32 kHashSize = 1 << (8 * kNumHashBytes);
37 static const UInt32 kMinMatchCheck = kNumHashBytes + 1;
38 static const UInt32 kStartMaxLen = 1;
39 #endif
40 #endif
41
42 #ifdef HASH_ARRAY_2
43 #ifdef HASH_ARRAY_3
44 static const UInt32 kHash3Offset = kHash2Size;
45 #endif
46 #endif
47
48 static const UInt32 kFixHashSize = 0
49 #ifdef HASH_ARRAY_2
50 + kHash2Size
51 #ifdef HASH_ARRAY_3
52 + kHash3Size
53 #endif
54 #endif
55 ;
56
57 CMatchFinder::CMatchFinder():
58 _hash(0)
59 {
60 }
61
62 void CMatchFinder::FreeThisClassMemory()
63 {
64 BigFree(_hash);
65 _hash = 0;
66 }
67
68 void CMatchFinder::FreeMemory()
69 {
70 FreeThisClassMemory();
71 CLZInWindow::Free();
72 }
73
74 CMatchFinder::~CMatchFinder()
75 {
76 FreeMemory();
77 }
78
79 STDMETHODIMP CMatchFinder::Create(UInt32 historySize, UInt32 keepAddBufferBefore,
80 UInt32 matchMaxLen, UInt32 keepAddBufferAfter)
81 {
82 if (historySize > kMaxValForNormalize - 256)
83 {
84 FreeMemory();
85 return E_INVALIDARG;
86 }
87 _cutValue =
88 #ifdef _HASH_CHAIN
89 8 + (matchMaxLen >> 2);
90 #else
91 16 + (matchMaxLen >> 1);
92 #endif
93 UInt32 sizeReserv = (historySize + keepAddBufferBefore +
94 matchMaxLen + keepAddBufferAfter) / 2 + 256;
95 if (CLZInWindow::Create(historySize + keepAddBufferBefore,
96 matchMaxLen + keepAddBufferAfter, sizeReserv))
97 {
98 _matchMaxLen = matchMaxLen;
99 UInt32 newCyclicBufferSize = historySize + 1;
100 if (_hash != 0 && newCyclicBufferSize == _cyclicBufferSize)
101 return S_OK;
102 FreeThisClassMemory();
103 _cyclicBufferSize = newCyclicBufferSize; // don't change it
104
105 UInt32 hs = kHashSize;
106
107 #ifdef HASH_ARRAY_2
108 hs = historySize - 1;
109 hs |= (hs >> 1);
110 hs |= (hs >> 2);
111 hs |= (hs >> 4);
112 hs |= (hs >> 8);
113 hs >>= 1;
114 hs |= 0xFFFF;
115 if (hs > (1 << 24))
116 {
117 #ifdef HASH_ARRAY_3
118 hs >>= 1;
119 #else
120 hs = (1 << 24) - 1;
121 #endif
122 }
123 _hashMask = hs;
124 hs++;
125 #endif
126 _hashSizeSum = hs + kFixHashSize;
127 UInt32 numItems = _hashSizeSum + _cyclicBufferSize
128 #ifndef _HASH_CHAIN
129 * 2
130 #endif
131 ;
132 size_t sizeInBytes = (size_t)numItems * sizeof(CIndex);
133 if (sizeInBytes / sizeof(CIndex) != numItems)
134 return E_OUTOFMEMORY;
135 _hash = (CIndex *)BigAlloc(sizeInBytes);
136 _son = _hash + _hashSizeSum;
137 if (_hash != 0)
138 return S_OK;
139 }
140 FreeMemory();
141 return E_OUTOFMEMORY;
142 }
143
144 static const UInt32 kEmptyHashValue = 0;
145
146 STDMETHODIMP CMatchFinder::SetStream(ISequentialInStream *stream)
147 {
148 CLZInWindow::SetStream(stream);
149 return S_OK;
150 }
151
152 STDMETHODIMP CMatchFinder::Init()
153 {
154 RINOK(CLZInWindow::Init());
155 for(UInt32 i = 0; i < _hashSizeSum; i++)
156 _hash[i] = kEmptyHashValue;
157 _cyclicBufferPos = 0;
158 ReduceOffsets(-1);
159 return S_OK;
160 }
161
162 STDMETHODIMP_(void) CMatchFinder::ReleaseStream()
163 {
164 // ReleaseStream();
165 }
166
167 #ifdef HASH_ARRAY_2
168 #ifdef HASH_ARRAY_3
169
170 #define HASH_CALC { \
171 UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \
172 hash2Value = temp & (kHash2Size - 1); \
173 hash3Value = (temp ^ (UInt32(cur[2]) << 8)) & (kHash3Size - 1); \
174 hashValue = (temp ^ (UInt32(cur[2]) << 8) ^ (CCRC::Table[cur[3]] << 5)) & _hashMask; }
175
176 #else // no HASH_ARRAY_3
177 #define HASH_CALC { \
178 UInt32 temp = CCRC::Table[cur[0]] ^ cur[1]; \
179 hash2Value = temp & (kHash2Size - 1); \
180 hashValue = (temp ^ (UInt32(cur[2]) << 8)) & _hashMask; }
181 #endif // HASH_ARRAY_3
182 #else // no HASH_ARRAY_2
183 #ifdef HASH_ZIP
184 inline UInt32 Hash(const Byte *pointer)
185 {
186 return ((UInt32(pointer[0]) << 8) ^ CCRC::Table[pointer[1]] ^ pointer[2]) & (kHashSize - 1);
187 }
188 #else // no HASH_ZIP
189 inline UInt32 Hash(const Byte *pointer)
190 {
191 return pointer[0] ^ (UInt32(pointer[1]) << 8);
192 }
193 #endif // HASH_ZIP
194 #endif // HASH_ARRAY_2
195
196 STDMETHODIMP CMatchFinder::GetMatches(UInt32 *distances)
197 {
198 UInt32 lenLimit;
199 if (_pos + _matchMaxLen <= _streamPos)
200 lenLimit = _matchMaxLen;
201 else
202 {
203 lenLimit = _streamPos - _pos;
204 if(lenLimit < kMinMatchCheck)
205 {
206 distances[0] = 0;
207 return MovePos();
208 }
209 }
210
211 int offset = 1;
212
213 UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
214 const Byte *cur = _buffer + _pos;
215
216 UInt32 maxLen = kStartMaxLen; // to avoid items for len < hashSize;
217
218 #ifdef HASH_ARRAY_2
219 UInt32 hash2Value;
220 #ifdef HASH_ARRAY_3
221 UInt32 hash3Value;
222 #endif
223 UInt32 hashValue;
224 HASH_CALC;
225 #else
226 UInt32 hashValue = Hash(cur);
227 #endif
228
229 UInt32 curMatch = _hash[kFixHashSize + hashValue];
230 #ifdef HASH_ARRAY_2
231 UInt32 curMatch2 = _hash[hash2Value];
232 #ifdef HASH_ARRAY_3
233 UInt32 curMatch3 = _hash[kHash3Offset + hash3Value];
234 #endif
235 _hash[hash2Value] = _pos;
236 if(curMatch2 > matchMinPos)
237 if (_buffer[curMatch2] == cur[0])
238 {
239 distances[offset++] = maxLen = 2;
240 distances[offset++] = _pos - curMatch2 - 1;
241 }
242
243 #ifdef HASH_ARRAY_3
244 _hash[kHash3Offset + hash3Value] = _pos;
245 if(curMatch3 > matchMinPos)
246 if (_buffer[curMatch3] == cur[0])
247 {
248 if (curMatch3 == curMatch2)
249 offset -= 2;
250 distances[offset++] = maxLen = 3;
251 distances[offset++] = _pos - curMatch3 - 1;
252 curMatch2 = curMatch3;
253 }
254 #endif
255 if (offset != 1 && curMatch2 == curMatch)
256 {
257 offset -= 2;
258 maxLen = kStartMaxLen;
259 }
260 #endif
261
262 _hash[kFixHashSize + hashValue] = _pos;
263
264 CIndex *son = _son;
265
266 #ifdef _HASH_CHAIN
267 son[_cyclicBufferPos] = curMatch;
268 #else
269 CIndex *ptr0 = son + (_cyclicBufferPos << 1) + 1;
270 CIndex *ptr1 = son + (_cyclicBufferPos << 1);
271
272 UInt32 len0, len1;
273 len0 = len1 = kNumHashDirectBytes;
274 #endif
275
276 #if kNumHashDirectBytes != 0
277 if(curMatch > matchMinPos)
278 {
279 if (_buffer[curMatch + kNumHashDirectBytes] != cur[kNumHashDirectBytes])
280 {
281 distances[offset++] = maxLen = kNumHashDirectBytes;
282 distances[offset++] = _pos - curMatch - 1;
283 }
284 }
285 #endif
286 UInt32 count = _cutValue;
287 while(true)
288 {
289 if(curMatch <= matchMinPos || count-- == 0)
290 {
291 #ifndef _HASH_CHAIN
292 *ptr0 = *ptr1 = kEmptyHashValue;
293 #endif
294 break;
295 }
296 UInt32 delta = _pos - curMatch;
297 UInt32 cyclicPos = (delta <= _cyclicBufferPos) ?
298 (_cyclicBufferPos - delta):
299 (_cyclicBufferPos - delta + _cyclicBufferSize);
300 CIndex *pair = son +
301 #ifdef _HASH_CHAIN
302 cyclicPos;
303 #else
304 (cyclicPos << 1);
305 #endif
306
307 // _mm_prefetch((const char *)pair, _MM_HINT_T0);
308
309 const Byte *pb = _buffer + curMatch;
310 UInt32 len =
311 #ifdef _HASH_CHAIN
312 kNumHashDirectBytes;
313 if (pb[maxLen] == cur[maxLen])
314 #else
315 MyMin(len0, len1);
316 #endif
317 if (pb[len] == cur[len])
318 {
319 while(++len != lenLimit)
320 if (pb[len] != cur[len])
321 break;
322 if (maxLen < len)
323 {
324 distances[offset++] = maxLen = len;
325 distances[offset++] = delta - 1;
326 if (len == lenLimit)
327 {
328 #ifndef _HASH_CHAIN
329 *ptr1 = pair[0];
330 *ptr0 = pair[1];
331 #endif
332 break;
333 }
334 }
335 }
336 #ifdef _HASH_CHAIN
337 curMatch = *pair;
338 #else
339 if (pb[len] < cur[len])
340 {
341 *ptr1 = curMatch;
342 ptr1 = pair + 1;
343 curMatch = *ptr1;
344 len1 = len;
345 }
346 else
347 {
348 *ptr0 = curMatch;
349 ptr0 = pair;
350 curMatch = *ptr0;
351 len0 = len;
352 }
353 #endif
354 }
355 distances[0] = offset - 1;
356 if (++_cyclicBufferPos == _cyclicBufferSize)
357 _cyclicBufferPos = 0;
358 RINOK(CLZInWindow::MovePos());
359 if (_pos == kMaxValForNormalize)
360 Normalize();
361 return S_OK;
362 }
363
364 STDMETHODIMP CMatchFinder::Skip(UInt32 num)
365 {
366 do
367 {
368 #ifdef _HASH_CHAIN
369 if (_streamPos - _pos < kNumHashBytes)
370 {
371 RINOK(MovePos());
372 continue;
373 }
374 #else
375 UInt32 lenLimit;
376 if (_pos + _matchMaxLen <= _streamPos)
377 lenLimit = _matchMaxLen;
378 else
379 {
380 lenLimit = _streamPos - _pos;
381 if(lenLimit < kMinMatchCheck)
382 {
383 RINOK(MovePos());
384 continue;
385 }
386 }
387 UInt32 matchMinPos = (_pos > _cyclicBufferSize) ? (_pos - _cyclicBufferSize) : 0;
388 #endif
389 const Byte *cur = _buffer + _pos;
390
391 #ifdef HASH_ARRAY_2
392 UInt32 hash2Value;
393 #ifdef HASH_ARRAY_3
394 UInt32 hash3Value;
395 UInt32 hashValue;
396 HASH_CALC;
397 _hash[kHash3Offset + hash3Value] = _pos;
398 #else
399 UInt32 hashValue;
400 HASH_CALC;
401 #endif
402 _hash[hash2Value] = _pos;
403 #else
404 UInt32 hashValue = Hash(cur);
405 #endif
406
407 UInt32 curMatch = _hash[kFixHashSize + hashValue];
408 _hash[kFixHashSize + hashValue] = _pos;
409
410 #ifdef _HASH_CHAIN
411 _son[_cyclicBufferPos] = curMatch;
412 #else
413 CIndex *son = _son;
414 CIndex *ptr0 = son + (_cyclicBufferPos << 1) + 1;
415 CIndex *ptr1 = son + (_cyclicBufferPos << 1);
416
417 UInt32 len0, len1;
418 len0 = len1 = kNumHashDirectBytes;
419 UInt32 count = _cutValue;
420 while(true)
421 {
422 if(curMatch <= matchMinPos || count-- == 0)
423 {
424 *ptr0 = *ptr1 = kEmptyHashValue;
425 break;
426 }
427
428 UInt32 delta = _pos - curMatch;
429 UInt32 cyclicPos = (delta <= _cyclicBufferPos) ?
430 (_cyclicBufferPos - delta):
431 (_cyclicBufferPos - delta + _cyclicBufferSize);
432 CIndex *pair = son + (cyclicPos << 1);
433
434 // _mm_prefetch((const char *)pair, _MM_HINT_T0);
435
436 const Byte *pb = _buffer + curMatch;
437 UInt32 len = MyMin(len0, len1);
438
439 if (pb[len] == cur[len])
440 {
441 while(++len != lenLimit)
442 if (pb[len] != cur[len])
443 break;
444 if (len == lenLimit)
445 {
446 *ptr1 = pair[0];
447 *ptr0 = pair[1];
448 break;
449 }
450 }
451 if (pb[len] < cur[len])
452 {
453 *ptr1 = curMatch;
454 ptr1 = pair + 1;
455 curMatch = *ptr1;
456 len1 = len;
457 }
458 else
459 {
460 *ptr0 = curMatch;
461 ptr0 = pair;
462 curMatch = *ptr0;
463 len0 = len;
464 }
465 }
466 #endif
467 if (++_cyclicBufferPos == _cyclicBufferSize)
468 _cyclicBufferPos = 0;
469 RINOK(CLZInWindow::MovePos());
470 if (_pos == kMaxValForNormalize)
471 Normalize();
472 }
473 while(--num != 0);
474 return S_OK;
475 }
476
477 void CMatchFinder::Normalize()
478 {
479 UInt32 subValue = _pos - _cyclicBufferSize;
480 CIndex *items = _hash;
481 UInt32 numItems = (_hashSizeSum + _cyclicBufferSize
482 #ifndef _HASH_CHAIN
483 * 2
484 #endif
485 );
486 for (UInt32 i = 0; i < numItems; i++)
487 {
488 UInt32 value = items[i];
489 if (value <= subValue)
490 value = kEmptyHashValue;
491 else
492 value -= subValue;
493 items[i] = value;
494 }
495 ReduceOffsets(subValue);
496 }
497
498 HRESULT CMatchFinder::MovePos()
499 {
500 if (++_cyclicBufferPos == _cyclicBufferSize)
501 _cyclicBufferPos = 0;
502 RINOK(CLZInWindow::MovePos());
503 if (_pos == kMaxValForNormalize)
504 Normalize();
505 return S_OK;
506 }
507
508 STDMETHODIMP_(Byte) CMatchFinder::GetIndexByte(Int32 index)
509 { return CLZInWindow::GetIndexByte(index); }
510
511 STDMETHODIMP_(UInt32) CMatchFinder::GetMatchLen(Int32 index,
512 UInt32 back, UInt32 limit)
513 { return CLZInWindow::GetMatchLen(index, back, limit); }
514
515 STDMETHODIMP_(UInt32) CMatchFinder::GetNumAvailableBytes()
516 { return CLZInWindow::GetNumAvailableBytes(); }
517
518 STDMETHODIMP_(const Byte *) CMatchFinder::GetPointerToCurrentPos()
519 { return CLZInWindow::GetPointerToCurrentPos(); }
520
521 STDMETHODIMP_(Int32) CMatchFinder::NeedChangeBufferPos(UInt32 numCheckBytes)
522 { return CLZInWindow::NeedMove(numCheckBytes) ? 1: 0; }
523
524 STDMETHODIMP_(void) CMatchFinder::ChangeBufferPos()
525 { CLZInWindow::MoveBlock();}
526
527 #undef HASH_CALC
528 #undef kNumHashDirectBytes
529
530 }
0 // HC2.h
1
2 #ifndef __HC2_H
3 #define __HC2_H
4
5 #define BT_NAMESPACE NHC2
6
7 #include "HCMain.h"
8
9 #undef BT_NAMESPACE
10
11 #endif
12
0 // HC3.h
1
2 #ifndef __HC3_H
3 #define __HC3_H
4
5 #define BT_NAMESPACE NHC3
6
7 #define HASH_ARRAY_2
8
9 #include "HCMain.h"
10
11 #undef HASH_ARRAY_2
12 #undef BT_NAMESPACE
13
14 #endif
15
0 // HC4.h
1
2 #ifndef __HC4_H
3 #define __HC4_H
4
5 #define BT_NAMESPACE NHC4
6
7 #define HASH_ARRAY_2
8 #define HASH_ARRAY_3
9
10 #include "HCMain.h"
11
12 #undef HASH_ARRAY_2
13 #undef HASH_ARRAY_3
14
15 #undef BT_NAMESPACE
16
17 #endif
18
0 // HCMain.h
1
2 #define _HASH_CHAIN
3 #include "../BinTree/BinTreeMain.h"
4 #undef _HASH_CHAIN
5
0 // MatchFinders/IMatchFinder.h
1
2 #ifndef __IMATCHFINDER_H
3 #define __IMATCHFINDER_H
4
5 struct IInWindowStream: public IUnknown
6 {
7 STDMETHOD(SetStream)(ISequentialInStream *inStream) PURE;
8 STDMETHOD_(void, ReleaseStream)() PURE;
9 STDMETHOD(Init)() PURE;
10 STDMETHOD_(Byte, GetIndexByte)(Int32 index) PURE;
11 STDMETHOD_(UInt32, GetMatchLen)(Int32 index, UInt32 distance, UInt32 limit) PURE;
12 STDMETHOD_(UInt32, GetNumAvailableBytes)() PURE;
13 STDMETHOD_(const Byte *, GetPointerToCurrentPos)() PURE;
14 STDMETHOD_(Int32, NeedChangeBufferPos)(UInt32 numCheckBytes) PURE;
15 STDMETHOD_(void, ChangeBufferPos)() PURE;
16 };
17
18 struct IMatchFinder: public IInWindowStream
19 {
20 STDMETHOD(Create)(UInt32 historySize, UInt32 keepAddBufferBefore,
21 UInt32 matchMaxLen, UInt32 keepAddBufferAfter) PURE;
22 STDMETHOD(GetMatches)(UInt32 *distances) PURE;
23 STDMETHOD(Skip)(UInt32 num) PURE;
24 };
25
26 struct IMatchFinderSetNumPasses
27 {
28 virtual void SetNumPasses(UInt32 numPasses) PURE;
29 #ifndef _WIN32
30 virtual ~IMatchFinderSetNumPasses() {}
31 #endif
32 };
33
34 #endif
0 // LZInWindow.cpp
1
2 #include "StdAfx.h"
3
4 #include "LZInWindow.h"
5 #include "../../../Common/MyCom.h"
6 #include "../../../Common/Alloc.h"
7
8 void CLZInWindow::Free()
9 {
10 ::BigFree(_bufferBase);
11 _bufferBase = 0;
12 }
13
14 bool CLZInWindow::Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv)
15 {
16 _keepSizeBefore = keepSizeBefore;
17 _keepSizeAfter = keepSizeAfter;
18 UInt32 blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv;
19 if (_bufferBase == 0 || _blockSize != blockSize)
20 {
21 Free();
22 _blockSize = blockSize;
23 if (_blockSize != 0)
24 _bufferBase = (Byte *)::BigAlloc(_blockSize);
25 }
26 _pointerToLastSafePosition = _bufferBase + _blockSize - keepSizeAfter;
27 if (_blockSize == 0)
28 return true;
29 return (_bufferBase != 0);
30 }
31
32 void CLZInWindow::SetStream(ISequentialInStream *stream)
33 {
34 _stream = stream;
35 }
36
37 HRESULT CLZInWindow::Init()
38 {
39 _buffer = _bufferBase;
40 _pos = 0;
41 _streamPos = 0;
42 _streamEndWasReached = false;
43 return ReadBlock();
44 }
45
46 /*
47 void CLZInWindow::ReleaseStream()
48 {
49 _stream.Release();
50 }
51 */
52
53 ///////////////////////////////////////////
54 // ReadBlock
55
56 // In State:
57 // (_buffer + _streamPos) <= (_bufferBase + _blockSize)
58 // Out State:
59 // _posLimit <= _blockSize - _keepSizeAfter;
60 // if(_streamEndWasReached == false):
61 // _streamPos >= _pos + _keepSizeAfter
62 // _posLimit = _streamPos - _keepSizeAfter;
63 // else
64 //
65
66 HRESULT CLZInWindow::ReadBlock()
67 {
68 if(_streamEndWasReached)
69 return S_OK;
70 while(true)
71 {
72 UInt32 size = (UInt32)(_bufferBase - _buffer) + _blockSize - _streamPos;
73 if(size == 0)
74 return S_OK;
75 UInt32 numReadBytes;
76 RINOK(_stream->Read(_buffer + _streamPos, size, &numReadBytes));
77 if(numReadBytes == 0)
78 {
79 _posLimit = _streamPos;
80 const Byte *pointerToPostion = _buffer + _posLimit;
81 if(pointerToPostion > _pointerToLastSafePosition)
82 _posLimit = (UInt32)(_pointerToLastSafePosition - _buffer);
83 _streamEndWasReached = true;
84 return S_OK;
85 }
86 _streamPos += numReadBytes;
87 if(_streamPos >= _pos + _keepSizeAfter)
88 {
89 _posLimit = _streamPos - _keepSizeAfter;
90 return S_OK;
91 }
92 }
93 }
94
95 void CLZInWindow::MoveBlock()
96 {
97 UInt32 offset = (UInt32)(_buffer - _bufferBase) + _pos - _keepSizeBefore;
98 // we need one additional byte, since MovePos moves on 1 byte.
99 if (offset > 0)
100 offset--;
101 UInt32 numBytes = (UInt32)(_buffer - _bufferBase) + _streamPos - offset;
102 memmove(_bufferBase, _bufferBase + offset, numBytes);
103 _buffer -= offset;
104 }
0 // LZInWindow.h
1
2 #ifndef __LZ_IN_WINDOW_H
3 #define __LZ_IN_WINDOW_H
4
5 #include "../../IStream.h"
6
7 class CLZInWindow
8 {
9 Byte *_bufferBase; // pointer to buffer with data
10 ISequentialInStream *_stream;
11 UInt32 _posLimit; // offset (from _buffer) when new block reading must be done
12 bool _streamEndWasReached; // if (true) then _streamPos shows real end of stream
13 const Byte *_pointerToLastSafePosition;
14 protected:
15 Byte *_buffer; // Pointer to virtual Buffer begin
16 UInt32 _blockSize; // Size of Allocated memory block
17 UInt32 _pos; // offset (from _buffer) of curent byte
18 UInt32 _keepSizeBefore; // how many BYTEs must be kept in buffer before _pos
19 UInt32 _keepSizeAfter; // how many BYTEs must be kept buffer after _pos
20 UInt32 _streamPos; // offset (from _buffer) of first not read byte from Stream
21
22 void MoveBlock();
23 HRESULT ReadBlock();
24 void Free();
25 public:
26 CLZInWindow(): _bufferBase(0) {}
27 virtual ~CLZInWindow() { Free(); }
28
29 // keepSizeBefore + keepSizeAfter + keepSizeReserv < 4G)
30 bool Create(UInt32 keepSizeBefore, UInt32 keepSizeAfter, UInt32 keepSizeReserv = (1<<17));
31
32 void SetStream(ISequentialInStream *stream);
33 HRESULT Init();
34 // void ReleaseStream();
35
36 Byte *GetBuffer() const { return _buffer; }
37
38 const Byte *GetPointerToCurrentPos() const { return _buffer + _pos; }
39
40 HRESULT MovePos()
41 {
42 _pos++;
43 if (_pos > _posLimit)
44 {
45 const Byte *pointerToPostion = _buffer + _pos;
46 if(pointerToPostion > _pointerToLastSafePosition)
47 MoveBlock();
48 return ReadBlock();
49 }
50 else
51 return S_OK;
52 }
53 Byte GetIndexByte(Int32 index) const { return _buffer[(size_t)_pos + index]; }
54
55 // index + limit have not to exceed _keepSizeAfter;
56 // -2G <= index < 2G
57 UInt32 GetMatchLen(Int32 index, UInt32 distance, UInt32 limit) const
58 {
59 if(_streamEndWasReached)
60 if ((_pos + index) + limit > _streamPos)
61 limit = _streamPos - (_pos + index);
62 distance++;
63 const Byte *pby = _buffer + (size_t)_pos + index;
64 UInt32 i;
65 for(i = 0; i < limit && pby[i] == pby[(size_t)i - distance]; i++);
66 return i;
67 }
68
69 UInt32 GetNumAvailableBytes() const { return _streamPos - _pos; }
70
71 void ReduceOffsets(Int32 subValue)
72 {
73 _buffer += subValue;
74 _posLimit -= subValue;
75 _pos -= subValue;
76 _streamPos -= subValue;
77 }
78
79 bool NeedMove(UInt32 numCheckBytes)
80 {
81 UInt32 reserv = _pointerToLastSafePosition - (_buffer + _pos);
82 return (reserv <= numCheckBytes);
83 }
84 };
85
86 #endif
0 // LZOutWindow.cpp
1
2 #include "StdAfx.h"
3
4 #include "../../../Common/Alloc.h"
5 #include "LZOutWindow.h"
6
7 void CLZOutWindow::Init(bool solid)
8 {
9 if(!solid)
10 COutBuffer::Init();
11 #ifdef _NO_EXCEPTIONS
12 ErrorCode = S_OK;
13 #endif
14 }
15
16
0 // LZOutWindow.h
1
2 #ifndef __LZ_OUT_WINDOW_H
3 #define __LZ_OUT_WINDOW_H
4
5 #include "../../IStream.h"
6 #include "../../Common/OutBuffer.h"
7
8 #ifndef _NO_EXCEPTIONS
9 typedef COutBufferException CLZOutWindowException;
10 #endif
11
12 class CLZOutWindow: public COutBuffer
13 {
14 public:
15 void Init(bool solid = false);
16
17 // distance >= 0, len > 0,
18 bool CopyBlock(UInt32 distance, UInt32 len)
19 {
20 UInt32 pos = _pos - distance - 1;
21 if (distance >= _pos)
22 {
23 if (!_overDict || distance >= _bufferSize)
24 return false;
25 pos += _bufferSize;
26 }
27 do
28 {
29 if (pos == _bufferSize)
30 pos = 0;
31 _buffer[_pos++] = _buffer[pos++];
32 if (_pos == _limitPos)
33 FlushWithCheck();
34 }
35 while(--len != 0);
36 return true;
37 }
38
39 void PutByte(Byte b)
40 {
41 _buffer[_pos++] = b;
42 if (_pos == _limitPos)
43 FlushWithCheck();
44 }
45
46 Byte GetByte(UInt32 distance) const
47 {
48 UInt32 pos = _pos - distance - 1;
49 if (pos >= _bufferSize)
50 pos += _bufferSize;
51 return _buffer[pos];
52 }
53 };
54
55 #endif
0 // StdAfx.h
1
2 #ifndef __STDAFX_H
3 #define __STDAFX_H
4
5 #endif
0 // LZMA.h
1
2 #ifndef __LZMA_H
3 #define __LZMA_H
4
5 namespace NCompress {
6 namespace NLZMA {
7
8 const UInt32 kNumRepDistances = 4;
9
10 const int kNumStates = 12;
11
12 const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5};
13 const Byte kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10};
14 const Byte kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11};
15 const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11};
16
17 class CState
18 {
19 public:
20 Byte Index;
21 void Init() { Index = 0; }
22 void UpdateChar() { Index = kLiteralNextStates[Index]; }
23 void UpdateMatch() { Index = kMatchNextStates[Index]; }
24 void UpdateRep() { Index = kRepNextStates[Index]; }
25 void UpdateShortRep() { Index = kShortRepNextStates[Index]; }
26 bool IsCharState() const { return Index < 7; }
27 };
28
29 const int kNumPosSlotBits = 6;
30 const int kDicLogSizeMin = 0;
31 const int kDicLogSizeMax = 32;
32 const int kDistTableSizeMax = kDicLogSizeMax * 2;
33
34 const UInt32 kNumLenToPosStates = 4;
35
36 inline UInt32 GetLenToPosState(UInt32 len)
37 {
38 len -= 2;
39 if (len < kNumLenToPosStates)
40 return len;
41 return kNumLenToPosStates - 1;
42 }
43
44 namespace NLength {
45
46 const int kNumPosStatesBitsMax = 4;
47 const UInt32 kNumPosStatesMax = (1 << kNumPosStatesBitsMax);
48
49 const int kNumPosStatesBitsEncodingMax = 4;
50 const UInt32 kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax);
51
52 const int kNumLowBits = 3;
53 const int kNumMidBits = 3;
54 const int kNumHighBits = 8;
55 const UInt32 kNumLowSymbols = 1 << kNumLowBits;
56 const UInt32 kNumMidSymbols = 1 << kNumMidBits;
57 const UInt32 kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits);
58
59 }
60
61 const UInt32 kMatchMinLen = 2;
62 const UInt32 kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1;
63
64 const int kNumAlignBits = 4;
65 const UInt32 kAlignTableSize = 1 << kNumAlignBits;
66 const UInt32 kAlignMask = (kAlignTableSize - 1);
67
68 const UInt32 kStartPosModelIndex = 4;
69 const UInt32 kEndPosModelIndex = 14;
70 const UInt32 kNumPosModels = kEndPosModelIndex - kStartPosModelIndex;
71
72 const UInt32 kNumFullDistances = 1 << (kEndPosModelIndex / 2);
73
74 const int kNumLitPosStatesBitsEncodingMax = 4;
75 const int kNumLitContextBitsMax = 8;
76
77 const int kNumMoveBits = 5;
78
79 }}
80
81 #endif
0 // LZMADecoder.cpp
1
2 #include "StdAfx.h"
3
4 #include "LZMADecoder.h"
5 #include "../../../Common/Defs.h"
6
7 namespace NCompress {
8 namespace NLZMA {
9
10 const int kLenIdFinished = -1;
11 const int kLenIdNeedInit = -2;
12
13 void CDecoder::Init()
14 {
15 {
16 for(int i = 0; i < kNumStates; i++)
17 {
18 for (UInt32 j = 0; j <= _posStateMask; j++)
19 {
20 _isMatch[i][j].Init();
21 _isRep0Long[i][j].Init();
22 }
23 _isRep[i].Init();
24 _isRepG0[i].Init();
25 _isRepG1[i].Init();
26 _isRepG2[i].Init();
27 }
28 }
29 {
30 for (UInt32 i = 0; i < kNumLenToPosStates; i++)
31 _posSlotDecoder[i].Init();
32 }
33 {
34 for(UInt32 i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
35 _posDecoders[i].Init();
36 }
37 _posAlignDecoder.Init();
38 _lenDecoder.Init(_posStateMask + 1);
39 _repMatchLenDecoder.Init(_posStateMask + 1);
40 _literalDecoder.Init();
41
42 _state.Init();
43 _reps[0] = _reps[1] = _reps[2] = _reps[3] = 0;
44 }
45
46 HRESULT CDecoder::CodeSpec(UInt32 curSize)
47 {
48 if (_outSizeDefined)
49 {
50 const UInt64 rem = _outSize - _outWindowStream.GetProcessedSize();
51 if (curSize > rem)
52 curSize = (UInt32)rem;
53 }
54
55 if (_remainLen == kLenIdFinished)
56 return S_OK;
57 if (_remainLen == kLenIdNeedInit)
58 {
59 _rangeDecoder.Init();
60 Init();
61 _remainLen = 0;
62 }
63 if (curSize == 0)
64 return S_OK;
65
66 UInt32 rep0 = _reps[0];
67 UInt32 rep1 = _reps[1];
68 UInt32 rep2 = _reps[2];
69 UInt32 rep3 = _reps[3];
70 CState state = _state;
71 Byte previousByte;
72
73 while(_remainLen > 0 && curSize > 0)
74 {
75 previousByte = _outWindowStream.GetByte(rep0);
76 _outWindowStream.PutByte(previousByte);
77 _remainLen--;
78 curSize--;
79 }
80 UInt64 nowPos64 = _outWindowStream.GetProcessedSize();
81 if (nowPos64 == 0)
82 previousByte = 0;
83 else
84 previousByte = _outWindowStream.GetByte(0);
85
86 while(curSize > 0)
87 {
88 {
89 #ifdef _NO_EXCEPTIONS
90 if (_rangeDecoder.Stream.ErrorCode != S_OK)
91 return _rangeDecoder.Stream.ErrorCode;
92 #endif
93 if (_rangeDecoder.Stream.WasFinished())
94 return S_FALSE;
95 UInt32 posState = UInt32(nowPos64) & _posStateMask;
96 if (_isMatch[state.Index][posState].Decode(&_rangeDecoder) == 0)
97 {
98 if(!state.IsCharState())
99 previousByte = _literalDecoder.DecodeWithMatchByte(&_rangeDecoder,
100 (UInt32)nowPos64, previousByte, _outWindowStream.GetByte(rep0));
101 else
102 previousByte = _literalDecoder.DecodeNormal(&_rangeDecoder,
103 (UInt32)nowPos64, previousByte);
104 _outWindowStream.PutByte(previousByte);
105 state.UpdateChar();
106 curSize--;
107 nowPos64++;
108 }
109 else
110 {
111 UInt32 len;
112 if(_isRep[state.Index].Decode(&_rangeDecoder) == 1)
113 {
114 len = 0;
115 if(_isRepG0[state.Index].Decode(&_rangeDecoder) == 0)
116 {
117 if(_isRep0Long[state.Index][posState].Decode(&_rangeDecoder) == 0)
118 {
119 state.UpdateShortRep();
120 len = 1;
121 }
122 }
123 else
124 {
125 UInt32 distance;
126 if(_isRepG1[state.Index].Decode(&_rangeDecoder) == 0)
127 distance = rep1;
128 else
129 {
130 if (_isRepG2[state.Index].Decode(&_rangeDecoder) == 0)
131 distance = rep2;
132 else
133 {
134 distance = rep3;
135 rep3 = rep2;
136 }
137 rep2 = rep1;
138 }
139 rep1 = rep0;
140 rep0 = distance;
141 }
142 if (len == 0)
143 {
144 len = _repMatchLenDecoder.Decode(&_rangeDecoder, posState) + kMatchMinLen;
145 state.UpdateRep();
146 }
147 }
148 else
149 {
150 rep3 = rep2;
151 rep2 = rep1;
152 rep1 = rep0;
153 len = kMatchMinLen + _lenDecoder.Decode(&_rangeDecoder, posState);
154 state.UpdateMatch();
155 UInt32 posSlot = _posSlotDecoder[GetLenToPosState(len)].Decode(&_rangeDecoder);
156 if (posSlot >= kStartPosModelIndex)
157 {
158 UInt32 numDirectBits = (posSlot >> 1) - 1;
159 rep0 = ((2 | (posSlot & 1)) << numDirectBits);
160
161 if (posSlot < kEndPosModelIndex)
162 rep0 += NRangeCoder::ReverseBitTreeDecode(_posDecoders +
163 rep0 - posSlot - 1, &_rangeDecoder, numDirectBits);
164 else
165 {
166 rep0 += (_rangeDecoder.DecodeDirectBits(
167 numDirectBits - kNumAlignBits) << kNumAlignBits);
168 rep0 += _posAlignDecoder.ReverseDecode(&_rangeDecoder);
169 if (rep0 == 0xFFFFFFFF)
170 {
171 _remainLen = kLenIdFinished;
172 return S_OK;
173 }
174 }
175 }
176 else
177 rep0 = posSlot;
178 }
179 UInt32 locLen = len;
180 if (len > curSize)
181 locLen = (UInt32)curSize;
182 if (!_outWindowStream.CopyBlock(rep0, locLen))
183 return S_FALSE;
184 previousByte = _outWindowStream.GetByte(0);
185 curSize -= locLen;
186 nowPos64 += locLen;
187 len -= locLen;
188 if (len != 0)
189 {
190 _remainLen = (Int32)len;
191 break;
192 }
193
194 #ifdef _NO_EXCEPTIONS
195 if (_outWindowStream.ErrorCode != S_OK)
196 return _outWindowStream.ErrorCode;
197 #endif
198 }
199 }
200 }
201 if (_rangeDecoder.Stream.WasFinished())
202 return S_FALSE;
203 _reps[0] = rep0;
204 _reps[1] = rep1;
205 _reps[2] = rep2;
206 _reps[3] = rep3;
207 _state = state;
208
209 return S_OK;
210 }
211
212 STDMETHODIMP CDecoder::CodeReal(ISequentialInStream *inStream,
213 ISequentialOutStream *outStream,
214 const UInt64 *, const UInt64 *outSize,
215 ICompressProgressInfo *progress)
216 {
217 SetInStream(inStream);
218 _outWindowStream.SetStream(outStream);
219 SetOutStreamSize(outSize);
220 CDecoderFlusher flusher(this);
221
222 while (true)
223 {
224 UInt32 curSize = 1 << 18;
225 RINOK(CodeSpec(curSize));
226 if (_remainLen == kLenIdFinished)
227 break;
228 if (progress != NULL)
229 {
230 UInt64 inSize = _rangeDecoder.GetProcessedSize();
231 UInt64 nowPos64 = _outWindowStream.GetProcessedSize();
232 RINOK(progress->SetRatioInfo(&inSize, &nowPos64));
233 }
234 if (_outSizeDefined)
235 if (_outWindowStream.GetProcessedSize() >= _outSize)
236 break;
237 }
238 flusher.NeedFlush = false;
239 return Flush();
240 }
241
242
243 #ifdef _NO_EXCEPTIONS
244
245 #define LZMA_TRY_BEGIN
246 #define LZMA_TRY_END
247
248 #else
249
250 #define LZMA_TRY_BEGIN try {
251 #define LZMA_TRY_END } \
252 catch(const CInBufferException &e) { return e.ErrorCode; } \
253 catch(const CLZOutWindowException &e) { return e.ErrorCode; } \
254 catch(...) { return S_FALSE; }
255
256 #endif
257
258
259 STDMETHODIMP CDecoder::Code(ISequentialInStream *inStream,
260 ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
261 ICompressProgressInfo *progress)
262 {
263 LZMA_TRY_BEGIN
264 return CodeReal(inStream, outStream, inSize, outSize, progress);
265 LZMA_TRY_END
266 }
267
268 STDMETHODIMP CDecoder::SetDecoderProperties2(const Byte *properties, UInt32 size)
269 {
270 if (size < 5)
271 return E_INVALIDARG;
272 int lc = properties[0] % 9;
273 Byte remainder = (Byte)(properties[0] / 9);
274 int lp = remainder % 5;
275 int pb = remainder / 5;
276 if (pb > NLength::kNumPosStatesBitsMax)
277 return E_INVALIDARG;
278 _posStateMask = (1 << pb) - 1;
279 UInt32 dictionarySize = 0;
280 for (int i = 0; i < 4; i++)
281 dictionarySize += ((UInt32)(properties[1 + i])) << (i * 8);
282 if (!_outWindowStream.Create(dictionarySize))
283 return E_OUTOFMEMORY;
284 if (!_literalDecoder.Create(lp, lc))
285 return E_OUTOFMEMORY;
286 if (!_rangeDecoder.Create(1 << 20))
287 return E_OUTOFMEMORY;
288 return S_OK;
289 }
290
291 STDMETHODIMP CDecoder::GetInStreamProcessedSize(UInt64 *value)
292 {
293 *value = _rangeDecoder.GetProcessedSize();
294 return S_OK;
295 }
296
297 STDMETHODIMP CDecoder::SetInStream(ISequentialInStream *inStream)
298 {
299 _rangeDecoder.SetStream(inStream);
300 return S_OK;
301 }
302
303 STDMETHODIMP CDecoder::ReleaseInStream()
304 {
305 _rangeDecoder.ReleaseStream();
306 return S_OK;
307 }
308
309 STDMETHODIMP CDecoder::SetOutStreamSize(const UInt64 *outSize)
310 {
311 if ((_outSizeDefined = (outSize != NULL)))
312 _outSize = *outSize;
313 _remainLen = kLenIdNeedInit;
314 _outWindowStream.Init();
315 return S_OK;
316 }
317
318 #ifdef _ST_MODE
319
320 STDMETHODIMP CDecoder::Read(void *data, UInt32 size, UInt32 *processedSize)
321 {
322 LZMA_TRY_BEGIN
323 if (processedSize)
324 *processedSize = 0;
325 const UInt64 startPos = _outWindowStream.GetProcessedSize();
326 _outWindowStream.SetMemStream((Byte *)data);
327 RINOK(CodeSpec(size));
328 if (processedSize)
329 *processedSize = (UInt32)(_outWindowStream.GetProcessedSize() - startPos);
330 return Flush();
331 LZMA_TRY_END
332 }
333
334 #endif
335
336 }}
0 // LZMA/Decoder.h
1
2 #ifndef __LZMA_DECODER_H
3 #define __LZMA_DECODER_H
4
5 #include "../../../Common/MyCom.h"
6 #include "../../../Common/Alloc.h"
7 #include "../../ICoder.h"
8 #include "../LZ/LZOutWindow.h"
9 #include "../RangeCoder/RangeCoderBitTree.h"
10
11 #include "LZMA.h"
12
13 namespace NCompress {
14 namespace NLZMA {
15
16 typedef NRangeCoder::CBitDecoder<kNumMoveBits> CMyBitDecoder;
17
18 class CLiteralDecoder2
19 {
20 CMyBitDecoder _decoders[0x300];
21 public:
22 void Init()
23 {
24 for (int i = 0; i < 0x300; i++)
25 _decoders[i].Init();
26 }
27 Byte DecodeNormal(NRangeCoder::CDecoder *rangeDecoder)
28 {
29 UInt32 symbol = 1;
30 RC_INIT_VAR
31 do
32 {
33 // symbol = (symbol << 1) | _decoders[0][symbol].Decode(rangeDecoder);
34 RC_GETBIT(kNumMoveBits, _decoders[symbol].Prob, symbol)
35 }
36 while (symbol < 0x100);
37 RC_FLUSH_VAR
38 return (Byte)symbol;
39 }
40 Byte DecodeWithMatchByte(NRangeCoder::CDecoder *rangeDecoder, Byte matchByte)
41 {
42 UInt32 symbol = 1;
43 RC_INIT_VAR
44 do
45 {
46 UInt32 matchBit = (matchByte >> 7) & 1;
47 matchByte <<= 1;
48 // UInt32 bit = _decoders[1 + matchBit][symbol].Decode(rangeDecoder);
49 // symbol = (symbol << 1) | bit;
50 UInt32 bit;
51 RC_GETBIT2(kNumMoveBits, _decoders[0x100 + (matchBit << 8) + symbol].Prob, symbol,
52 bit = 0, bit = 1)
53 if (matchBit != bit)
54 {
55 while (symbol < 0x100)
56 {
57 // symbol = (symbol << 1) | _decoders[0][symbol].Decode(rangeDecoder);
58 RC_GETBIT(kNumMoveBits, _decoders[symbol].Prob, symbol)
59 }
60 break;
61 }
62 }
63 while (symbol < 0x100);
64 RC_FLUSH_VAR
65 return (Byte)symbol;
66 }
67 };
68
69 class CLiteralDecoder
70 {
71 CLiteralDecoder2 *_coders;
72 int _numPrevBits;
73 int _numPosBits;
74 UInt32 _posMask;
75 public:
76 CLiteralDecoder(): _coders(0) {}
77 ~CLiteralDecoder() { Free(); }
78 void Free()
79 {
80 MyFree(_coders);
81 _coders = 0;
82 }
83 bool Create(int numPosBits, int numPrevBits)
84 {
85 if (_coders == 0 || (numPosBits + numPrevBits) !=
86 (_numPrevBits + _numPosBits) )
87 {
88 Free();
89 UInt32 numStates = 1 << (numPosBits + numPrevBits);
90 _coders = (CLiteralDecoder2 *)MyAlloc(numStates * sizeof(CLiteralDecoder2));
91 }
92 _numPosBits = numPosBits;
93 _posMask = (1 << numPosBits) - 1;
94 _numPrevBits = numPrevBits;
95 return (_coders != 0);
96 }
97 void Init()
98 {
99 UInt32 numStates = 1 << (_numPrevBits + _numPosBits);
100 for (UInt32 i = 0; i < numStates; i++)
101 _coders[i].Init();
102 }
103 UInt32 GetState(UInt32 pos, Byte prevByte) const
104 { return ((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits)); }
105 Byte DecodeNormal(NRangeCoder::CDecoder *rangeDecoder, UInt32 pos, Byte prevByte)
106 { return _coders[GetState(pos, prevByte)].DecodeNormal(rangeDecoder); }
107 Byte DecodeWithMatchByte(NRangeCoder::CDecoder *rangeDecoder, UInt32 pos, Byte prevByte, Byte matchByte)
108 { return _coders[GetState(pos, prevByte)].DecodeWithMatchByte(rangeDecoder, matchByte); }
109 };
110
111 namespace NLength {
112
113 class CDecoder
114 {
115 CMyBitDecoder _choice;
116 CMyBitDecoder _choice2;
117 NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumLowBits> _lowCoder[kNumPosStatesMax];
118 NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumMidBits> _midCoder[kNumPosStatesMax];
119 NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumHighBits> _highCoder;
120 public:
121 void Init(UInt32 numPosStates)
122 {
123 _choice.Init();
124 _choice2.Init();
125 for (UInt32 posState = 0; posState < numPosStates; posState++)
126 {
127 _lowCoder[posState].Init();
128 _midCoder[posState].Init();
129 }
130 _highCoder.Init();
131 }
132 UInt32 Decode(NRangeCoder::CDecoder *rangeDecoder, UInt32 posState)
133 {
134 if(_choice.Decode(rangeDecoder) == 0)
135 return _lowCoder[posState].Decode(rangeDecoder);
136 if(_choice2.Decode(rangeDecoder) == 0)
137 return kNumLowSymbols + _midCoder[posState].Decode(rangeDecoder);
138 return kNumLowSymbols + kNumMidSymbols + _highCoder.Decode(rangeDecoder);
139 }
140 };
141
142 }
143
144 class CDecoder:
145 public ICompressCoder,
146 public ICompressSetDecoderProperties2,
147 public ICompressGetInStreamProcessedSize,
148 #ifdef _ST_MODE
149 public ICompressSetInStream,
150 public ICompressSetOutStreamSize,
151 public ISequentialInStream,
152 #endif
153 public CMyUnknownImp
154 {
155 CLZOutWindow _outWindowStream;
156 NRangeCoder::CDecoder _rangeDecoder;
157
158 CMyBitDecoder _isMatch[kNumStates][NLength::kNumPosStatesMax];
159 CMyBitDecoder _isRep[kNumStates];
160 CMyBitDecoder _isRepG0[kNumStates];
161 CMyBitDecoder _isRepG1[kNumStates];
162 CMyBitDecoder _isRepG2[kNumStates];
163 CMyBitDecoder _isRep0Long[kNumStates][NLength::kNumPosStatesMax];
164
165 NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumPosSlotBits> _posSlotDecoder[kNumLenToPosStates];
166
167 CMyBitDecoder _posDecoders[kNumFullDistances - kEndPosModelIndex];
168 NRangeCoder::CBitTreeDecoder<kNumMoveBits, kNumAlignBits> _posAlignDecoder;
169
170 NLength::CDecoder _lenDecoder;
171 NLength::CDecoder _repMatchLenDecoder;
172
173 CLiteralDecoder _literalDecoder;
174
175 UInt32 _posStateMask;
176
177 ///////////////////
178 // State
179 UInt32 _reps[4];
180 CState _state;
181 Int32 _remainLen; // -1 means end of stream. // -2 means need Init
182 UInt64 _outSize;
183 bool _outSizeDefined;
184
185 void Init();
186 HRESULT CodeSpec(UInt32 size);
187 public:
188
189 #ifdef _ST_MODE
190 MY_UNKNOWN_IMP5(
191 ICompressSetDecoderProperties2,
192 ICompressGetInStreamProcessedSize,
193 ICompressSetInStream,
194 ICompressSetOutStreamSize,
195 ISequentialInStream)
196 #else
197 MY_UNKNOWN_IMP2(
198 ICompressSetDecoderProperties2,
199 ICompressGetInStreamProcessedSize)
200 #endif
201
202 void ReleaseStreams()
203 {
204 _outWindowStream.ReleaseStream();
205 ReleaseInStream();
206 }
207
208 class CDecoderFlusher
209 {
210 CDecoder *_decoder;
211 public:
212 bool NeedFlush;
213 CDecoderFlusher(CDecoder *decoder): _decoder(decoder), NeedFlush(true) {}
214 ~CDecoderFlusher()
215 {
216 if (NeedFlush)
217 _decoder->Flush();
218 _decoder->ReleaseStreams();
219 }
220 };
221
222 HRESULT Flush() { return _outWindowStream.Flush(); }
223
224 STDMETHOD(CodeReal)(ISequentialInStream *inStream,
225 ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
226 ICompressProgressInfo *progress);
227
228 STDMETHOD(Code)(ISequentialInStream *inStream,
229 ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
230 ICompressProgressInfo *progress);
231
232 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size);
233
234 STDMETHOD(GetInStreamProcessedSize)(UInt64 *value);
235
236 STDMETHOD(SetInStream)(ISequentialInStream *inStream);
237 STDMETHOD(ReleaseInStream)();
238 STDMETHOD(SetOutStreamSize)(const UInt64 *outSize);
239
240 #ifdef _ST_MODE
241 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
242 #endif
243
244 CDecoder(): _outSizeDefined(false) {}
245 virtual ~CDecoder() {}
246 };
247
248 }}
249
250 #endif
0 // LZMA/Encoder.cpp
1
2 #include "StdAfx.h"
3
4 #include "../../../Common/Defs.h"
5 #include "../../Common/StreamUtils.h"
6
7 #include "LZMAEncoder.h"
8
9 // for minimal compressing code size define these:
10 // #define COMPRESS_MF_BT
11 // #define COMPRESS_MF_BT4
12
13 #if !defined(COMPRESS_MF_BT) && !defined(COMPRESS_MF_HC)
14 #define COMPRESS_MF_BT
15 #define COMPRESS_MF_HC
16 #endif
17
18 #ifdef COMPRESS_MF_BT
19 #if !defined(COMPRESS_MF_BT2) && !defined(COMPRESS_MF_BT3) && !defined(COMPRESS_MF_BT4)
20 #define COMPRESS_MF_BT2
21 #define COMPRESS_MF_BT3
22 #define COMPRESS_MF_BT4
23 #endif
24 #ifdef COMPRESS_MF_BT2
25 #include "../LZ/BinTree/BinTree2.h"
26 #endif
27 #ifdef COMPRESS_MF_BT3
28 #include "../LZ/BinTree/BinTree3.h"
29 #endif
30 #ifdef COMPRESS_MF_BT4
31 #include "../LZ/BinTree/BinTree4.h"
32 #endif
33 #endif
34
35 #ifdef COMPRESS_MF_HC
36 #include "../LZ/HashChain/HC4.h"
37 #endif
38
39 #ifdef COMPRESS_MF_MT
40 #include "../LZ/MT/MT.h"
41 #endif
42
43 namespace NCompress {
44 namespace NLZMA {
45
46 const int kDefaultDictionaryLogSize = 22;
47 const UInt32 kNumFastBytesDefault = 0x20;
48
49 enum
50 {
51 kBT2,
52 kBT3,
53 kBT4,
54 kHC4
55 };
56
57 static const wchar_t *kMatchFinderIDs[] =
58 {
59 L"BT2",
60 L"BT3",
61 L"BT4",
62 L"HC4"
63 };
64
65 Byte g_FastPos[1 << 11];
66
67 class CFastPosInit
68 {
69 public:
70 CFastPosInit() { Init(); }
71 void Init()
72 {
73 const Byte kFastSlots = 22;
74 int c = 2;
75 g_FastPos[0] = 0;
76 g_FastPos[1] = 1;
77
78 for (Byte slotFast = 2; slotFast < kFastSlots; slotFast++)
79 {
80 UInt32 k = (1 << ((slotFast >> 1) - 1));
81 for (UInt32 j = 0; j < k; j++, c++)
82 g_FastPos[c] = slotFast;
83 }
84 }
85 } g_FastPosInit;
86
87
88 void CLiteralEncoder2::Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol)
89 {
90 UInt32 context = 1;
91 int i = 8;
92 do
93 {
94 i--;
95 UInt32 bit = (symbol >> i) & 1;
96 _encoders[context].Encode(rangeEncoder, bit);
97 context = (context << 1) | bit;
98 }
99 while(i != 0);
100 }
101
102 void CLiteralEncoder2::EncodeMatched(NRangeCoder::CEncoder *rangeEncoder,
103 Byte matchByte, Byte symbol)
104 {
105 UInt32 context = 1;
106 int i = 8;
107 do
108 {
109 i--;
110 UInt32 bit = (symbol >> i) & 1;
111 UInt32 matchBit = (matchByte >> i) & 1;
112 _encoders[0x100 + (matchBit << 8) + context].Encode(rangeEncoder, bit);
113 context = (context << 1) | bit;
114 if (matchBit != bit)
115 {
116 while(i != 0)
117 {
118 i--;
119 UInt32 bit = (symbol >> i) & 1;
120 _encoders[context].Encode(rangeEncoder, bit);
121 context = (context << 1) | bit;
122 }
123 break;
124 }
125 }
126 while(i != 0);
127 }
128
129 UInt32 CLiteralEncoder2::GetPrice(bool matchMode, Byte matchByte, Byte symbol) const
130 {
131 UInt32 price = 0;
132 UInt32 context = 1;
133 int i = 8;
134 if (matchMode)
135 {
136 do
137 {
138 i--;
139 UInt32 matchBit = (matchByte >> i) & 1;
140 UInt32 bit = (symbol >> i) & 1;
141 price += _encoders[0x100 + (matchBit << 8) + context].GetPrice(bit);
142 context = (context << 1) | bit;
143 if (matchBit != bit)
144 break;
145 }
146 while (i != 0);
147 }
148 while(i != 0)
149 {
150 i--;
151 UInt32 bit = (symbol >> i) & 1;
152 price += _encoders[context].GetPrice(bit);
153 context = (context << 1) | bit;
154 }
155 return price;
156 };
157
158
159 namespace NLength {
160
161 void CEncoder::Init(UInt32 numPosStates)
162 {
163 _choice.Init();
164 _choice2.Init();
165 for (UInt32 posState = 0; posState < numPosStates; posState++)
166 {
167 _lowCoder[posState].Init();
168 _midCoder[posState].Init();
169 }
170 _highCoder.Init();
171 }
172
173 void CEncoder::Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState)
174 {
175 if(symbol < kNumLowSymbols)
176 {
177 _choice.Encode(rangeEncoder, 0);
178 _lowCoder[posState].Encode(rangeEncoder, symbol);
179 }
180 else
181 {
182 _choice.Encode(rangeEncoder, 1);
183 if(symbol < kNumLowSymbols + kNumMidSymbols)
184 {
185 _choice2.Encode(rangeEncoder, 0);
186 _midCoder[posState].Encode(rangeEncoder, symbol - kNumLowSymbols);
187 }
188 else
189 {
190 _choice2.Encode(rangeEncoder, 1);
191 _highCoder.Encode(rangeEncoder, symbol - kNumLowSymbols - kNumMidSymbols);
192 }
193 }
194 }
195
196 void CEncoder::SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const
197 {
198 UInt32 a0 = _choice.GetPrice0();
199 UInt32 a1 = _choice.GetPrice1();
200 UInt32 b0 = a1 + _choice2.GetPrice0();
201 UInt32 b1 = a1 + _choice2.GetPrice1();
202 UInt32 i = 0;
203 for (i = 0; i < kNumLowSymbols; i++)
204 {
205 if (i >= numSymbols)
206 return;
207 prices[i] = a0 + _lowCoder[posState].GetPrice(i);
208 }
209 for (; i < kNumLowSymbols + kNumMidSymbols; i++)
210 {
211 if (i >= numSymbols)
212 return;
213 prices[i] = b0 + _midCoder[posState].GetPrice(i - kNumLowSymbols);
214 }
215 for (; i < numSymbols; i++)
216 prices[i] = b1 + _highCoder.GetPrice(i - kNumLowSymbols - kNumMidSymbols);
217 }
218
219 }
220 CEncoder::CEncoder():
221 _numFastBytes(kNumFastBytesDefault),
222 _distTableSize(kDefaultDictionaryLogSize * 2),
223 _posStateBits(2),
224 _posStateMask(4 - 1),
225 _numLiteralPosStateBits(0),
226 _numLiteralContextBits(3),
227 _dictionarySize(1 << kDefaultDictionaryLogSize),
228 _dictionarySizePrev(UInt32(-1)),
229 _numFastBytesPrev(UInt32(-1)),
230 _matchFinderCycles(0),
231 _matchFinderIndex(kBT4),
232 #ifdef COMPRESS_MF_MT
233 _multiThread(false),
234 #endif
235 _writeEndMark(false),
236 setMfPasses(0)
237 {
238 // _maxMode = false;
239 _fastMode = false;
240 }
241
242 HRESULT CEncoder::Create()
243 {
244 if (!_rangeEncoder.Create(1 << 20))
245 return E_OUTOFMEMORY;
246 if (!_matchFinder)
247 {
248 switch(_matchFinderIndex)
249 {
250 #ifdef COMPRESS_MF_BT
251 #ifdef COMPRESS_MF_BT2
252 case kBT2:
253 {
254 NBT2::CMatchFinder *mfSpec = new NBT2::CMatchFinder;
255 setMfPasses = mfSpec;
256 _matchFinder = mfSpec;
257 break;
258 }
259 #endif
260 #ifdef COMPRESS_MF_BT3
261 case kBT3:
262 {
263 NBT3::CMatchFinder *mfSpec = new NBT3::CMatchFinder;
264 setMfPasses = mfSpec;
265 _matchFinder = mfSpec;
266 break;
267 }
268 #endif
269 #ifdef COMPRESS_MF_BT4
270 case kBT4:
271 {
272 NBT4::CMatchFinder *mfSpec = new NBT4::CMatchFinder;
273 setMfPasses = mfSpec;
274 _matchFinder = mfSpec;
275 break;
276 }
277 #endif
278 #endif
279
280 #ifdef COMPRESS_MF_HC
281 case kHC4:
282 {
283 NHC4::CMatchFinder *mfSpec = new NHC4::CMatchFinder;
284 setMfPasses = mfSpec;
285 _matchFinder = mfSpec;
286 break;
287 }
288 #endif
289 }
290 if (_matchFinder == 0)
291 return E_OUTOFMEMORY;
292
293 #ifdef COMPRESS_MF_MT
294 if (_multiThread && !(_fastMode && (_matchFinderIndex == kHC4)))
295 {
296 CMatchFinderMT *mfSpec = new CMatchFinderMT;
297 if (mfSpec == 0)
298 return E_OUTOFMEMORY;
299 CMyComPtr<IMatchFinder> mf = mfSpec;
300 RINOK(mfSpec->SetMatchFinder(_matchFinder));
301 _matchFinder.Release();
302 _matchFinder = mf;
303 }
304 #endif
305 }
306
307 if (!_literalEncoder.Create(_numLiteralPosStateBits, _numLiteralContextBits))
308 return E_OUTOFMEMORY;
309
310 if (_dictionarySize == _dictionarySizePrev && _numFastBytesPrev == _numFastBytes)
311 return S_OK;
312 RINOK(_matchFinder->Create(_dictionarySize, kNumOpts, _numFastBytes, kMatchMaxLen + 1)); // actually it's + _numFastBytes - _numFastBytes
313 if (_matchFinderCycles != 0 && setMfPasses != 0)
314 setMfPasses->SetNumPasses(_matchFinderCycles);
315 _dictionarySizePrev = _dictionarySize;
316 _numFastBytesPrev = _numFastBytes;
317 return S_OK;
318 }
319
320 static bool AreStringsEqual(const wchar_t *base, const wchar_t *testString)
321 {
322 while (true)
323 {
324 wchar_t c = *testString;
325 if (c >= 'a' && c <= 'z')
326 c -= 0x20;
327 if (*base != c)
328 return false;
329 if (c == 0)
330 return true;
331 base++;
332 testString++;
333 }
334 }
335
336 static int FindMatchFinder(const wchar_t *s)
337 {
338 for (int m = 0; m < (int)(sizeof(kMatchFinderIDs) / sizeof(kMatchFinderIDs[0])); m++)
339 if (AreStringsEqual(kMatchFinderIDs[m], s))
340 return m;
341 return -1;
342 }
343
344 STDMETHODIMP CEncoder::SetCoderProperties(const PROPID *propIDs,
345 const PROPVARIANT *properties, UInt32 numProperties)
346 {
347 for (UInt32 i = 0; i < numProperties; i++)
348 {
349 const PROPVARIANT &prop = properties[i];
350 switch(propIDs[i])
351 {
352 case NCoderPropID::kNumFastBytes:
353 {
354 if (prop.vt != VT_UI4)
355 return E_INVALIDARG;
356 UInt32 numFastBytes = prop.ulVal;
357 if(numFastBytes < 5 || numFastBytes > kMatchMaxLen)
358 return E_INVALIDARG;
359 _numFastBytes = numFastBytes;
360 break;
361 }
362 case NCoderPropID::kMatchFinderCycles:
363 {
364 if (prop.vt != VT_UI4)
365 return E_INVALIDARG;
366 _matchFinderCycles = prop.ulVal;
367 break;
368 }
369 case NCoderPropID::kAlgorithm:
370 {
371 if (prop.vt != VT_UI4)
372 return E_INVALIDARG;
373 UInt32 maximize = prop.ulVal;
374 _fastMode = (maximize == 0);
375 // _maxMode = (maximize >= 2);
376 break;
377 }
378 case NCoderPropID::kMatchFinder:
379 {
380 if (prop.vt != VT_BSTR)
381 return E_INVALIDARG;
382 int matchFinderIndexPrev = _matchFinderIndex;
383 int m = FindMatchFinder(prop.bstrVal);
384 if (m < 0)
385 return E_INVALIDARG;
386 _matchFinderIndex = m;
387 if (_matchFinder && matchFinderIndexPrev != _matchFinderIndex)
388 {
389 _dictionarySizePrev = (UInt32)-1;
390 ReleaseMatchFinder();
391 }
392 break;
393 }
394 #ifdef COMPRESS_MF_MT
395 case NCoderPropID::kMultiThread:
396 {
397 if (prop.vt != VT_BOOL)
398 return E_INVALIDARG;
399 bool newMultiThread = (prop.boolVal == VARIANT_TRUE);
400 if (newMultiThread != _multiThread)
401 {
402 _dictionarySizePrev = (UInt32)-1;
403 ReleaseMatchFinder();
404 _multiThread = newMultiThread;
405 }
406 break;
407 }
408 case NCoderPropID::kNumThreads:
409 {
410 if (prop.vt != VT_UI4)
411 return E_INVALIDARG;
412 bool newMultiThread = (prop.ulVal > 1);
413 if (newMultiThread != _multiThread)
414 {
415 _dictionarySizePrev = (UInt32)-1;
416 ReleaseMatchFinder();
417 _multiThread = newMultiThread;
418 }
419 break;
420 }
421 #endif
422 case NCoderPropID::kDictionarySize:
423 {
424 const int kDicLogSizeMaxCompress = 30;
425 if (prop.vt != VT_UI4)
426 return E_INVALIDARG;
427 UInt32 dictionarySize = prop.ulVal;
428 if (dictionarySize < UInt32(1 << kDicLogSizeMin) ||
429 dictionarySize > UInt32(1 << kDicLogSizeMaxCompress))
430 return E_INVALIDARG;
431 _dictionarySize = dictionarySize;
432 UInt32 dicLogSize;
433 for(dicLogSize = 0; dicLogSize < (UInt32)kDicLogSizeMaxCompress; dicLogSize++)
434 if (dictionarySize <= (UInt32(1) << dicLogSize))
435 break;
436 _distTableSize = dicLogSize * 2;
437 break;
438 }
439 case NCoderPropID::kPosStateBits:
440 {
441 if (prop.vt != VT_UI4)
442 return E_INVALIDARG;
443 UInt32 value = prop.ulVal;
444 if (value > (UInt32)NLength::kNumPosStatesBitsEncodingMax)
445 return E_INVALIDARG;
446 _posStateBits = value;
447 _posStateMask = (1 << _posStateBits) - 1;
448 break;
449 }
450 case NCoderPropID::kLitPosBits:
451 {
452 if (prop.vt != VT_UI4)
453 return E_INVALIDARG;
454 UInt32 value = prop.ulVal;
455 if (value > (UInt32)kNumLitPosStatesBitsEncodingMax)
456 return E_INVALIDARG;
457 _numLiteralPosStateBits = value;
458 break;
459 }
460 case NCoderPropID::kLitContextBits:
461 {
462 if (prop.vt != VT_UI4)
463 return E_INVALIDARG;
464 UInt32 value = prop.ulVal;
465 if (value > (UInt32)kNumLitContextBitsMax)
466 return E_INVALIDARG;
467 _numLiteralContextBits = value;
468 break;
469 }
470 case NCoderPropID::kEndMarker:
471 {
472 if (prop.vt != VT_BOOL)
473 return E_INVALIDARG;
474 SetWriteEndMarkerMode(prop.boolVal == VARIANT_TRUE);
475 break;
476 }
477 default:
478 return E_INVALIDARG;
479 }
480 }
481 return S_OK;
482 }
483
484 STDMETHODIMP CEncoder::WriteCoderProperties(ISequentialOutStream *outStream)
485 {
486 const UInt32 kPropSize = 5;
487 Byte properties[kPropSize];
488 properties[0] = (_posStateBits * 5 + _numLiteralPosStateBits) * 9 + _numLiteralContextBits;
489 for (int i = 0; i < 4; i++)
490 properties[1 + i] = Byte(_dictionarySize >> (8 * i));
491 return WriteStream(outStream, properties, kPropSize, NULL);
492 }
493
494 STDMETHODIMP CEncoder::SetOutStream(ISequentialOutStream *outStream)
495 {
496 _rangeEncoder.SetStream(outStream);
497 return S_OK;
498 }
499
500 STDMETHODIMP CEncoder::ReleaseOutStream()
501 {
502 _rangeEncoder.ReleaseStream();
503 return S_OK;
504 }
505
506 HRESULT CEncoder::Init()
507 {
508 CBaseState::Init();
509
510 // RINOK(_matchFinder->Init(inStream));
511 _rangeEncoder.Init();
512
513 for(int i = 0; i < kNumStates; i++)
514 {
515 for (UInt32 j = 0; j <= _posStateMask; j++)
516 {
517 _isMatch[i][j].Init();
518 _isRep0Long[i][j].Init();
519 }
520 _isRep[i].Init();
521 _isRepG0[i].Init();
522 _isRepG1[i].Init();
523 _isRepG2[i].Init();
524 }
525
526 _literalEncoder.Init();
527
528 {
529 for(UInt32 i = 0; i < kNumLenToPosStates; i++)
530 _posSlotEncoder[i].Init();
531 }
532 {
533 for(UInt32 i = 0; i < kNumFullDistances - kEndPosModelIndex; i++)
534 _posEncoders[i].Init();
535 }
536
537 _lenEncoder.Init(1 << _posStateBits);
538 _repMatchLenEncoder.Init(1 << _posStateBits);
539
540 _posAlignEncoder.Init();
541
542 _longestMatchWasFound = false;
543 _optimumEndIndex = 0;
544 _optimumCurrentIndex = 0;
545 _additionalOffset = 0;
546
547 return S_OK;
548 }
549
550 HRESULT CEncoder::MovePos(UInt32 num)
551 {
552 if (num == 0)
553 return S_OK;
554 _additionalOffset += num;
555 return _matchFinder->Skip(num);
556 }
557
558 UInt32 CEncoder::Backward(UInt32 &backRes, UInt32 cur)
559 {
560 _optimumEndIndex = cur;
561 UInt32 posMem = _optimum[cur].PosPrev;
562 UInt32 backMem = _optimum[cur].BackPrev;
563 do
564 {
565 if (_optimum[cur].Prev1IsChar)
566 {
567 _optimum[posMem].MakeAsChar();
568 _optimum[posMem].PosPrev = posMem - 1;
569 if (_optimum[cur].Prev2)
570 {
571 _optimum[posMem - 1].Prev1IsChar = false;
572 _optimum[posMem - 1].PosPrev = _optimum[cur].PosPrev2;
573 _optimum[posMem - 1].BackPrev = _optimum[cur].BackPrev2;
574 }
575 }
576 UInt32 posPrev = posMem;
577 UInt32 backCur = backMem;
578
579 backMem = _optimum[posPrev].BackPrev;
580 posMem = _optimum[posPrev].PosPrev;
581
582 _optimum[posPrev].BackPrev = backCur;
583 _optimum[posPrev].PosPrev = cur;
584 cur = posPrev;
585 }
586 while(cur != 0);
587 backRes = _optimum[0].BackPrev;
588 _optimumCurrentIndex = _optimum[0].PosPrev;
589 return _optimumCurrentIndex;
590 }
591
592 /*
593 Out:
594 (lenRes == 1) && (backRes == 0xFFFFFFFF) means Literal
595 */
596
597 HRESULT CEncoder::GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
598 {
599 if(_optimumEndIndex != _optimumCurrentIndex)
600 {
601 const COptimal &optimum = _optimum[_optimumCurrentIndex];
602 lenRes = optimum.PosPrev - _optimumCurrentIndex;
603 backRes = optimum.BackPrev;
604 _optimumCurrentIndex = optimum.PosPrev;
605 return S_OK;
606 }
607 _optimumCurrentIndex = _optimumEndIndex = 0;
608
609 UInt32 lenMain, numDistancePairs;
610 if (!_longestMatchWasFound)
611 {
612 RINOK(ReadMatchDistances(lenMain, numDistancePairs));
613 }
614 else
615 {
616 lenMain = _longestMatchLength;
617 numDistancePairs = _numDistancePairs;
618 _longestMatchWasFound = false;
619 }
620
621 const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
622 UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;
623 if (numAvailableBytes < 2)
624 {
625 backRes = (UInt32)(-1);
626 lenRes = 1;
627 return S_OK;
628 }
629 if (numAvailableBytes > kMatchMaxLen)
630 numAvailableBytes = kMatchMaxLen;
631
632 UInt32 reps[kNumRepDistances];
633 UInt32 repLens[kNumRepDistances];
634 UInt32 repMaxIndex = 0;
635 UInt32 i;
636 for(i = 0; i < kNumRepDistances; i++)
637 {
638 reps[i] = _repDistances[i];
639 UInt32 backOffset = reps[i] + 1;
640 if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
641 {
642 repLens[i] = 0;
643 continue;
644 }
645 UInt32 lenTest;
646 for (lenTest = 2; lenTest < numAvailableBytes &&
647 data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
648 repLens[i] = lenTest;
649 if (lenTest > repLens[repMaxIndex])
650 repMaxIndex = i;
651 }
652 if(repLens[repMaxIndex] >= _numFastBytes)
653 {
654 backRes = repMaxIndex;
655 lenRes = repLens[repMaxIndex];
656 return MovePos(lenRes - 1);
657 }
658
659 UInt32 *matchDistances = _matchDistances + 1;
660 if(lenMain >= _numFastBytes)
661 {
662 backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances;
663 lenRes = lenMain;
664 return MovePos(lenMain - 1);
665 }
666 Byte currentByte = *data;
667 Byte matchByte = data[(size_t)0 - reps[0] - 1];
668
669 if(lenMain < 2 && currentByte != matchByte && repLens[repMaxIndex] < 2)
670 {
671 backRes = (UInt32)-1;
672 lenRes = 1;
673 return S_OK;
674 }
675
676 _optimum[0].State = _state;
677
678 UInt32 posState = (position & _posStateMask);
679
680 _optimum[1].Price = _isMatch[_state.Index][posState].GetPrice0() +
681 _literalEncoder.GetSubCoder(position, _previousByte)->GetPrice(!_state.IsCharState(), matchByte, currentByte);
682 _optimum[1].MakeAsChar();
683
684 UInt32 matchPrice = _isMatch[_state.Index][posState].GetPrice1();
685 UInt32 repMatchPrice = matchPrice + _isRep[_state.Index].GetPrice1();
686
687 if(matchByte == currentByte)
688 {
689 UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(_state, posState);
690 if(shortRepPrice < _optimum[1].Price)
691 {
692 _optimum[1].Price = shortRepPrice;
693 _optimum[1].MakeAsShortRep();
694 }
695 }
696 UInt32 lenEnd = ((lenMain >= repLens[repMaxIndex]) ? lenMain : repLens[repMaxIndex]);
697
698 if(lenEnd < 2)
699 {
700 backRes = _optimum[1].BackPrev;
701 lenRes = 1;
702 return S_OK;
703 }
704
705 _optimum[1].PosPrev = 0;
706 for (i = 0; i < kNumRepDistances; i++)
707 _optimum[0].Backs[i] = reps[i];
708
709 UInt32 len = lenEnd;
710 do
711 _optimum[len--].Price = kIfinityPrice;
712 while (len >= 2);
713
714 for(i = 0; i < kNumRepDistances; i++)
715 {
716 UInt32 repLen = repLens[i];
717 if (repLen < 2)
718 continue;
719 UInt32 price = repMatchPrice + GetPureRepPrice(i, _state, posState);
720 do
721 {
722 UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(repLen - 2, posState);
723 COptimal &optimum = _optimum[repLen];
724 if (curAndLenPrice < optimum.Price)
725 {
726 optimum.Price = curAndLenPrice;
727 optimum.PosPrev = 0;
728 optimum.BackPrev = i;
729 optimum.Prev1IsChar = false;
730 }
731 }
732 while(--repLen >= 2);
733 }
734
735 UInt32 normalMatchPrice = matchPrice + _isRep[_state.Index].GetPrice0();
736
737 len = ((repLens[0] >= 2) ? repLens[0] + 1 : 2);
738 if (len <= lenMain)
739 {
740 UInt32 offs = 0;
741 while (len > matchDistances[offs])
742 offs += 2;
743 for(; ; len++)
744 {
745 UInt32 distance = matchDistances[offs + 1];
746 UInt32 curAndLenPrice = normalMatchPrice + GetPosLenPrice(distance, len, posState);
747 COptimal &optimum = _optimum[len];
748 if (curAndLenPrice < optimum.Price)
749 {
750 optimum.Price = curAndLenPrice;
751 optimum.PosPrev = 0;
752 optimum.BackPrev = distance + kNumRepDistances;
753 optimum.Prev1IsChar = false;
754 }
755 if (len == matchDistances[offs])
756 {
757 offs += 2;
758 if (offs == numDistancePairs)
759 break;
760 }
761 }
762 }
763
764 UInt32 cur = 0;
765
766 while(true)
767 {
768 cur++;
769 if(cur == lenEnd)
770 {
771 lenRes = Backward(backRes, cur);
772 return S_OK;
773 }
774 UInt32 newLen, numDistancePairs;
775 RINOK(ReadMatchDistances(newLen, numDistancePairs));
776 if(newLen >= _numFastBytes)
777 {
778 _numDistancePairs = numDistancePairs;
779 _longestMatchLength = newLen;
780 _longestMatchWasFound = true;
781 lenRes = Backward(backRes, cur);
782 return S_OK;
783 }
784 position++;
785 COptimal &curOptimum = _optimum[cur];
786 UInt32 posPrev = curOptimum.PosPrev;
787 CState state;
788 if (curOptimum.Prev1IsChar)
789 {
790 posPrev--;
791 if (curOptimum.Prev2)
792 {
793 state = _optimum[curOptimum.PosPrev2].State;
794 if (curOptimum.BackPrev2 < kNumRepDistances)
795 state.UpdateRep();
796 else
797 state.UpdateMatch();
798 }
799 else
800 state = _optimum[posPrev].State;
801 state.UpdateChar();
802 }
803 else
804 state = _optimum[posPrev].State;
805 if (posPrev == cur - 1)
806 {
807 if (curOptimum.IsShortRep())
808 state.UpdateShortRep();
809 else
810 state.UpdateChar();
811 }
812 else
813 {
814 UInt32 pos;
815 if (curOptimum.Prev1IsChar && curOptimum.Prev2)
816 {
817 posPrev = curOptimum.PosPrev2;
818 pos = curOptimum.BackPrev2;
819 state.UpdateRep();
820 }
821 else
822 {
823 pos = curOptimum.BackPrev;
824 if (pos < kNumRepDistances)
825 state.UpdateRep();
826 else
827 state.UpdateMatch();
828 }
829 const COptimal &prevOptimum = _optimum[posPrev];
830 if (pos < kNumRepDistances)
831 {
832 reps[0] = prevOptimum.Backs[pos];
833 UInt32 i;
834 for(i = 1; i <= pos; i++)
835 reps[i] = prevOptimum.Backs[i - 1];
836 for(; i < kNumRepDistances; i++)
837 reps[i] = prevOptimum.Backs[i];
838 }
839 else
840 {
841 reps[0] = (pos - kNumRepDistances);
842 for(UInt32 i = 1; i < kNumRepDistances; i++)
843 reps[i] = prevOptimum.Backs[i - 1];
844 }
845 }
846 curOptimum.State = state;
847 for(UInt32 i = 0; i < kNumRepDistances; i++)
848 curOptimum.Backs[i] = reps[i];
849 UInt32 curPrice = curOptimum.Price;
850 const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
851 const Byte currentByte = *data;
852 const Byte matchByte = data[(size_t)0 - reps[0] - 1];
853
854 UInt32 posState = (position & _posStateMask);
855
856 UInt32 curAnd1Price = curPrice +
857 _isMatch[state.Index][posState].GetPrice0() +
858 _literalEncoder.GetSubCoder(position, data[(size_t)0 - 1])->GetPrice(!state.IsCharState(), matchByte, currentByte);
859
860 COptimal &nextOptimum = _optimum[cur + 1];
861
862 bool nextIsChar = false;
863 if (curAnd1Price < nextOptimum.Price)
864 {
865 nextOptimum.Price = curAnd1Price;
866 nextOptimum.PosPrev = cur;
867 nextOptimum.MakeAsChar();
868 nextIsChar = true;
869 }
870
871 UInt32 matchPrice = curPrice + _isMatch[state.Index][posState].GetPrice1();
872 UInt32 repMatchPrice = matchPrice + _isRep[state.Index].GetPrice1();
873
874 if(matchByte == currentByte &&
875 !(nextOptimum.PosPrev < cur && nextOptimum.BackPrev == 0))
876 {
877 UInt32 shortRepPrice = repMatchPrice + GetRepLen1Price(state, posState);
878 if(shortRepPrice <= nextOptimum.Price)
879 {
880 nextOptimum.Price = shortRepPrice;
881 nextOptimum.PosPrev = cur;
882 nextOptimum.MakeAsShortRep();
883 nextIsChar = true;
884 }
885 }
886 /*
887 if(newLen == 2 && matchDistances[2] >= kDistLimit2) // test it maybe set 2000 ?
888 continue;
889 */
890
891 UInt32 numAvailableBytesFull = _matchFinder->GetNumAvailableBytes() + 1;
892 numAvailableBytesFull = MyMin(kNumOpts - 1 - cur, numAvailableBytesFull);
893 UInt32 numAvailableBytes = numAvailableBytesFull;
894
895 if (numAvailableBytes < 2)
896 continue;
897 if (numAvailableBytes > _numFastBytes)
898 numAvailableBytes = _numFastBytes;
899 if (!nextIsChar && matchByte != currentByte) // speed optimization
900 {
901 // try Literal + rep0
902 UInt32 backOffset = reps[0] + 1;
903 UInt32 limit = MyMin(numAvailableBytesFull, _numFastBytes + 1);
904 UInt32 temp;
905 for (temp = 1; temp < limit &&
906 data[temp] == data[(size_t)temp - backOffset]; temp++);
907 UInt32 lenTest2 = temp - 1;
908 if (lenTest2 >= 2)
909 {
910 CState state2 = state;
911 state2.UpdateChar();
912 UInt32 posStateNext = (position + 1) & _posStateMask;
913 UInt32 nextRepMatchPrice = curAnd1Price +
914 _isMatch[state2.Index][posStateNext].GetPrice1() +
915 _isRep[state2.Index].GetPrice1();
916 // for (; lenTest2 >= 2; lenTest2--)
917 {
918 UInt32 offset = cur + 1 + lenTest2;
919 while(lenEnd < offset)
920 _optimum[++lenEnd].Price = kIfinityPrice;
921 UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(
922 0, lenTest2, state2, posStateNext);
923 COptimal &optimum = _optimum[offset];
924 if (curAndLenPrice < optimum.Price)
925 {
926 optimum.Price = curAndLenPrice;
927 optimum.PosPrev = cur + 1;
928 optimum.BackPrev = 0;
929 optimum.Prev1IsChar = true;
930 optimum.Prev2 = false;
931 }
932 }
933 }
934 }
935
936 UInt32 startLen = 2; // speed optimization
937 for(UInt32 repIndex = 0; repIndex < kNumRepDistances; repIndex++)
938 {
939 // UInt32 repLen = _matchFinder->GetMatchLen(0 - 1, reps[repIndex], newLen); // test it;
940 UInt32 backOffset = reps[repIndex] + 1;
941 if (data[0] != data[(size_t)0 - backOffset] ||
942 data[1] != data[(size_t)1 - backOffset])
943 continue;
944 UInt32 lenTest;
945 for (lenTest = 2; lenTest < numAvailableBytes &&
946 data[lenTest] == data[(size_t)lenTest - backOffset]; lenTest++);
947 while(lenEnd < cur + lenTest)
948 _optimum[++lenEnd].Price = kIfinityPrice;
949 UInt32 lenTestTemp = lenTest;
950 UInt32 price = repMatchPrice + GetPureRepPrice(repIndex, state, posState);
951 do
952 {
953 UInt32 curAndLenPrice = price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState);
954 COptimal &optimum = _optimum[cur + lenTest];
955 if (curAndLenPrice < optimum.Price)
956 {
957 optimum.Price = curAndLenPrice;
958 optimum.PosPrev = cur;
959 optimum.BackPrev = repIndex;
960 optimum.Prev1IsChar = false;
961 }
962 }
963 while(--lenTest >= 2);
964 lenTest = lenTestTemp;
965
966 if (repIndex == 0)
967 startLen = lenTest + 1;
968
969 // if (_maxMode)
970 {
971 UInt32 lenTest2 = lenTest + 1;
972 UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
973 for (; lenTest2 < limit &&
974 data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
975 lenTest2 -= lenTest + 1;
976 if (lenTest2 >= 2)
977 {
978 CState state2 = state;
979 state2.UpdateRep();
980 UInt32 posStateNext = (position + lenTest) & _posStateMask;
981 UInt32 curAndLenCharPrice =
982 price + _repMatchLenEncoder.GetPrice(lenTest - 2, posState) +
983 _isMatch[state2.Index][posStateNext].GetPrice0() +
984 _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
985 true, data[(size_t)lenTest - backOffset], data[lenTest]);
986 state2.UpdateChar();
987 posStateNext = (position + lenTest + 1) & _posStateMask;
988 UInt32 nextRepMatchPrice = curAndLenCharPrice +
989 _isMatch[state2.Index][posStateNext].GetPrice1() +
990 _isRep[state2.Index].GetPrice1();
991
992 // for(; lenTest2 >= 2; lenTest2--)
993 {
994 UInt32 offset = cur + lenTest + 1 + lenTest2;
995 while(lenEnd < offset)
996 _optimum[++lenEnd].Price = kIfinityPrice;
997 UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(
998 0, lenTest2, state2, posStateNext);
999 COptimal &optimum = _optimum[offset];
1000 if (curAndLenPrice < optimum.Price)
1001 {
1002 optimum.Price = curAndLenPrice;
1003 optimum.PosPrev = cur + lenTest + 1;
1004 optimum.BackPrev = 0;
1005 optimum.Prev1IsChar = true;
1006 optimum.Prev2 = true;
1007 optimum.PosPrev2 = cur;
1008 optimum.BackPrev2 = repIndex;
1009 }
1010 }
1011 }
1012 }
1013 }
1014
1015 // for(UInt32 lenTest = 2; lenTest <= newLen; lenTest++)
1016 if (newLen > numAvailableBytes)
1017 {
1018 newLen = numAvailableBytes;
1019 for (numDistancePairs = 0; newLen > matchDistances[numDistancePairs]; numDistancePairs += 2);
1020 matchDistances[numDistancePairs] = newLen;
1021 numDistancePairs += 2;
1022 }
1023 if (newLen >= startLen)
1024 {
1025 UInt32 normalMatchPrice = matchPrice + _isRep[state.Index].GetPrice0();
1026 while(lenEnd < cur + newLen)
1027 _optimum[++lenEnd].Price = kIfinityPrice;
1028
1029 UInt32 offs = 0;
1030 while(startLen > matchDistances[offs])
1031 offs += 2;
1032 UInt32 curBack = matchDistances[offs + 1];
1033 UInt32 posSlot = GetPosSlot2(curBack);
1034 for(UInt32 lenTest = /*2*/ startLen; ; lenTest++)
1035 {
1036 UInt32 curAndLenPrice = normalMatchPrice;
1037 UInt32 lenToPosState = GetLenToPosState(lenTest);
1038 if (curBack < kNumFullDistances)
1039 curAndLenPrice += _distancesPrices[lenToPosState][curBack];
1040 else
1041 curAndLenPrice += _posSlotPrices[lenToPosState][posSlot] + _alignPrices[curBack & kAlignMask];
1042
1043 curAndLenPrice += _lenEncoder.GetPrice(lenTest - kMatchMinLen, posState);
1044
1045 COptimal &optimum = _optimum[cur + lenTest];
1046 if (curAndLenPrice < optimum.Price)
1047 {
1048 optimum.Price = curAndLenPrice;
1049 optimum.PosPrev = cur;
1050 optimum.BackPrev = curBack + kNumRepDistances;
1051 optimum.Prev1IsChar = false;
1052 }
1053
1054 if (/*_maxMode && */lenTest == matchDistances[offs])
1055 {
1056 // Try Match + Literal + Rep0
1057 UInt32 backOffset = curBack + 1;
1058 UInt32 lenTest2 = lenTest + 1;
1059 UInt32 limit = MyMin(numAvailableBytesFull, lenTest2 + _numFastBytes);
1060 for (; lenTest2 < limit &&
1061 data[lenTest2] == data[(size_t)lenTest2 - backOffset]; lenTest2++);
1062 lenTest2 -= lenTest + 1;
1063 if (lenTest2 >= 2)
1064 {
1065 CState state2 = state;
1066 state2.UpdateMatch();
1067 UInt32 posStateNext = (position + lenTest) & _posStateMask;
1068 UInt32 curAndLenCharPrice = curAndLenPrice +
1069 _isMatch[state2.Index][posStateNext].GetPrice0() +
1070 _literalEncoder.GetSubCoder(position + lenTest, data[(size_t)lenTest - 1])->GetPrice(
1071 true, data[(size_t)lenTest - backOffset], data[lenTest]);
1072 state2.UpdateChar();
1073 posStateNext = (posStateNext + 1) & _posStateMask;
1074 UInt32 nextRepMatchPrice = curAndLenCharPrice +
1075 _isMatch[state2.Index][posStateNext].GetPrice1() +
1076 _isRep[state2.Index].GetPrice1();
1077
1078 // for(; lenTest2 >= 2; lenTest2--)
1079 {
1080 UInt32 offset = cur + lenTest + 1 + lenTest2;
1081 while(lenEnd < offset)
1082 _optimum[++lenEnd].Price = kIfinityPrice;
1083 UInt32 curAndLenPrice = nextRepMatchPrice + GetRepPrice(0, lenTest2, state2, posStateNext);
1084 COptimal &optimum = _optimum[offset];
1085 if (curAndLenPrice < optimum.Price)
1086 {
1087 optimum.Price = curAndLenPrice;
1088 optimum.PosPrev = cur + lenTest + 1;
1089 optimum.BackPrev = 0;
1090 optimum.Prev1IsChar = true;
1091 optimum.Prev2 = true;
1092 optimum.PosPrev2 = cur;
1093 optimum.BackPrev2 = curBack + kNumRepDistances;
1094 }
1095 }
1096 }
1097 offs += 2;
1098 if (offs == numDistancePairs)
1099 break;
1100 curBack = matchDistances[offs + 1];
1101 if (curBack >= kNumFullDistances)
1102 posSlot = GetPosSlot2(curBack);
1103 }
1104 }
1105 }
1106 }
1107 }
1108
1109 static inline bool ChangePair(UInt32 smallDist, UInt32 bigDist)
1110 {
1111 return ((bigDist >> 7) > smallDist);
1112 }
1113
1114
1115 HRESULT CEncoder::ReadMatchDistances(UInt32 &lenRes, UInt32 &numDistancePairs)
1116 {
1117 lenRes = 0;
1118 RINOK(_matchFinder->GetMatches(_matchDistances));
1119 numDistancePairs = _matchDistances[0];
1120 if (numDistancePairs > 0)
1121 {
1122 lenRes = _matchDistances[1 + numDistancePairs - 2];
1123 if (lenRes == _numFastBytes)
1124 lenRes += _matchFinder->GetMatchLen(lenRes - 1, _matchDistances[1 + numDistancePairs - 1],
1125 kMatchMaxLen - lenRes);
1126 }
1127 _additionalOffset++;
1128 return S_OK;
1129 }
1130
1131 HRESULT CEncoder::GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRes)
1132 {
1133 UInt32 lenMain, numDistancePairs;
1134 if (!_longestMatchWasFound)
1135 {
1136 RINOK(ReadMatchDistances(lenMain, numDistancePairs));
1137 }
1138 else
1139 {
1140 lenMain = _longestMatchLength;
1141 numDistancePairs = _numDistancePairs;
1142 _longestMatchWasFound = false;
1143 }
1144
1145 const Byte *data = _matchFinder->GetPointerToCurrentPos() - 1;
1146 UInt32 numAvailableBytes = _matchFinder->GetNumAvailableBytes() + 1;
1147 if (numAvailableBytes > kMatchMaxLen)
1148 numAvailableBytes = kMatchMaxLen;
1149 if (numAvailableBytes < 2)
1150 {
1151 backRes = (UInt32)(-1);
1152 lenRes = 1;
1153 return S_OK;
1154 }
1155
1156 UInt32 repLens[kNumRepDistances];
1157 UInt32 repMaxIndex = 0;
1158
1159 for(UInt32 i = 0; i < kNumRepDistances; i++)
1160 {
1161 UInt32 backOffset = _repDistances[i] + 1;
1162 if (data[0] != data[(size_t)0 - backOffset] || data[1] != data[(size_t)1 - backOffset])
1163 {
1164 repLens[i] = 0;
1165 continue;
1166 }
1167 UInt32 len;
1168 for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
1169 if(len >= _numFastBytes)
1170 {
1171 backRes = i;
1172 lenRes = len;
1173 return MovePos(lenRes - 1);
1174 }
1175 repLens[i] = len;
1176 if (len > repLens[repMaxIndex])
1177 repMaxIndex = i;
1178 }
1179 UInt32 *matchDistances = _matchDistances + 1;
1180 if(lenMain >= _numFastBytes)
1181 {
1182 backRes = matchDistances[numDistancePairs - 1] + kNumRepDistances;
1183 lenRes = lenMain;
1184 return MovePos(lenMain - 1);
1185 }
1186
1187 UInt32 backMain = 0; // for GCC
1188 if (lenMain >= 2)
1189 {
1190 backMain = matchDistances[numDistancePairs - 1];
1191 while (numDistancePairs > 2 && lenMain == matchDistances[numDistancePairs - 4] + 1)
1192 {
1193 if (!ChangePair(matchDistances[numDistancePairs - 3], backMain))
1194 break;
1195 numDistancePairs -= 2;
1196 lenMain = matchDistances[numDistancePairs - 2];
1197 backMain = matchDistances[numDistancePairs - 1];
1198 }
1199 if (lenMain == 2 && backMain >= 0x80)
1200 lenMain = 1;
1201 }
1202
1203 if (repLens[repMaxIndex] >= 2)
1204 {
1205 if (repLens[repMaxIndex] + 1 >= lenMain ||
1206 (repLens[repMaxIndex] + 2 >= lenMain && (backMain > (1 << 9))) ||
1207 (repLens[repMaxIndex] + 3 >= lenMain && (backMain > (1 << 15))))
1208 {
1209 backRes = repMaxIndex;
1210 lenRes = repLens[repMaxIndex];
1211 return MovePos(lenRes - 1);
1212 }
1213 }
1214
1215 if (lenMain >= 2 && numAvailableBytes > 2)
1216 {
1217 RINOK(ReadMatchDistances(_longestMatchLength, _numDistancePairs));
1218 if (_longestMatchLength >= 2)
1219 {
1220 UInt32 newDistance = matchDistances[_numDistancePairs - 1];
1221 if ((_longestMatchLength >= lenMain && newDistance < backMain) ||
1222 (_longestMatchLength == lenMain + 1 && !ChangePair(backMain, newDistance)) ||
1223 _longestMatchLength > lenMain + 1 ||
1224 (_longestMatchLength + 1 >= lenMain && lenMain >= 3 && ChangePair(newDistance, backMain)))
1225 {
1226 _longestMatchWasFound = true;
1227 backRes = UInt32(-1);
1228 lenRes = 1;
1229 return S_OK;
1230 }
1231 }
1232 data++;
1233 numAvailableBytes--;
1234 for(UInt32 i = 0; i < kNumRepDistances; i++)
1235 {
1236 UInt32 backOffset = _repDistances[i] + 1;
1237 if (data[1] != data[(size_t)1 - backOffset] || data[2] != data[(size_t)2 - backOffset])
1238 {
1239 repLens[i] = 0;
1240 continue;
1241 }
1242 UInt32 len;
1243 for (len = 2; len < numAvailableBytes && data[len] == data[(size_t)len - backOffset]; len++);
1244 if (len + 1 >= lenMain)
1245 {
1246 _longestMatchWasFound = true;
1247 backRes = UInt32(-1);
1248 lenRes = 1;
1249 return S_OK;
1250 }
1251 }
1252 backRes = backMain + kNumRepDistances;
1253 lenRes = lenMain;
1254 return MovePos(lenMain - 2);
1255 }
1256 backRes = UInt32(-1);
1257 lenRes = 1;
1258 return S_OK;
1259 }
1260
1261 HRESULT CEncoder::Flush(UInt32 nowPos)
1262 {
1263 ReleaseMFStream();
1264 WriteEndMarker(nowPos & _posStateMask);
1265 _rangeEncoder.FlushData();
1266 return _rangeEncoder.FlushStream();
1267 }
1268
1269 void CEncoder::WriteEndMarker(UInt32 posState)
1270 {
1271 // This function for writing End Mark for stream version of LZMA.
1272 // In current version this feature is not used.
1273 if (!_writeEndMark)
1274 return;
1275
1276 _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);
1277 _isRep[_state.Index].Encode(&_rangeEncoder, 0);
1278 _state.UpdateMatch();
1279 UInt32 len = kMatchMinLen; // kMatchMaxLen;
1280 _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
1281 UInt32 posSlot = (1 << kNumPosSlotBits) - 1;
1282 UInt32 lenToPosState = GetLenToPosState(len);
1283 _posSlotEncoder[lenToPosState].Encode(&_rangeEncoder, posSlot);
1284 UInt32 footerBits = 30;
1285 UInt32 posReduced = (UInt32(1) << footerBits) - 1;
1286 _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
1287 _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);
1288 }
1289
1290 HRESULT CEncoder::CodeReal(ISequentialInStream *inStream,
1291 ISequentialOutStream *outStream,
1292 const UInt64 *inSize, const UInt64 *outSize,
1293 ICompressProgressInfo *progress)
1294 {
1295 _needReleaseMFStream = false;
1296 CCoderReleaser coderReleaser(this);
1297 RINOK(SetStreams(inStream, outStream, inSize, outSize));
1298 while(true)
1299 {
1300 UInt64 processedInSize;
1301 UInt64 processedOutSize;
1302 Int32 finished;
1303 RINOK(CodeOneBlock(&processedInSize, &processedOutSize, &finished));
1304 if (finished != 0)
1305 return S_OK;
1306 if (progress != 0)
1307 {
1308 RINOK(progress->SetRatioInfo(&processedInSize, &processedOutSize));
1309 }
1310 }
1311 }
1312
1313 HRESULT CEncoder::SetStreams(ISequentialInStream *inStream,
1314 ISequentialOutStream *outStream,
1315 const UInt64 *inSize, const UInt64 *outSize)
1316 {
1317 _inStream = inStream;
1318 _finished = false;
1319 RINOK(Create());
1320 RINOK(SetOutStream(outStream));
1321 RINOK(Init());
1322
1323 // CCoderReleaser releaser(this);
1324
1325 /*
1326 if (_matchFinder->GetNumAvailableBytes() == 0)
1327 return Flush();
1328 */
1329
1330 if (!_fastMode)
1331 {
1332 FillDistancesPrices();
1333 FillAlignPrices();
1334 }
1335
1336 _lenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
1337 _lenEncoder.UpdateTables(1 << _posStateBits);
1338 _repMatchLenEncoder.SetTableSize(_numFastBytes + 1 - kMatchMinLen);
1339 _repMatchLenEncoder.UpdateTables(1 << _posStateBits);
1340
1341 nowPos64 = 0;
1342 return S_OK;
1343 }
1344
1345 HRESULT CEncoder::CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished)
1346 {
1347 if (_inStream != 0)
1348 {
1349 RINOK(_matchFinder->SetStream(_inStream));
1350 RINOK(_matchFinder->Init());
1351 _needReleaseMFStream = true;
1352 _inStream = 0;
1353 }
1354
1355
1356 *finished = 1;
1357 if (_finished)
1358 return S_OK;
1359 _finished = true;
1360
1361 if (nowPos64 == 0)
1362 {
1363 if (_matchFinder->GetNumAvailableBytes() == 0)
1364 return Flush(UInt32(nowPos64));
1365 UInt32 len, numDistancePairs;
1366 RINOK(ReadMatchDistances(len, numDistancePairs));
1367 UInt32 posState = UInt32(nowPos64) & _posStateMask;
1368 _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);
1369 _state.UpdateChar();
1370 Byte curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);
1371 _literalEncoder.GetSubCoder(UInt32(nowPos64), _previousByte)->Encode(&_rangeEncoder, curByte);
1372 _previousByte = curByte;
1373 _additionalOffset--;
1374 nowPos64++;
1375 }
1376
1377 UInt32 nowPos32 = (UInt32)nowPos64;
1378 UInt32 progressPosValuePrev = nowPos32;
1379
1380 if (_matchFinder->GetNumAvailableBytes() == 0)
1381 return Flush(nowPos32);
1382
1383 while(true)
1384 {
1385 #ifdef _NO_EXCEPTIONS
1386 if (_rangeEncoder.Stream.ErrorCode != S_OK)
1387 return _rangeEncoder.Stream.ErrorCode;
1388 #endif
1389 UInt32 pos, len;
1390 HRESULT result;
1391 if (_fastMode)
1392 result = GetOptimumFast(nowPos32, pos, len);
1393 else
1394 result = GetOptimum(nowPos32, pos, len);
1395 RINOK(result);
1396
1397 UInt32 posState = nowPos32 & _posStateMask;
1398 if(len == 1 && pos == 0xFFFFFFFF)
1399 {
1400 _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 0);
1401 Byte curByte = _matchFinder->GetIndexByte(0 - _additionalOffset);
1402 CLiteralEncoder2 *subCoder = _literalEncoder.GetSubCoder(nowPos32, _previousByte);
1403 if(_state.IsCharState())
1404 subCoder->Encode(&_rangeEncoder, curByte);
1405 else
1406 {
1407 Byte matchByte = _matchFinder->GetIndexByte(0 - _repDistances[0] - 1 - _additionalOffset);
1408 subCoder->EncodeMatched(&_rangeEncoder, matchByte, curByte);
1409 }
1410 _state.UpdateChar();
1411 _previousByte = curByte;
1412 }
1413 else
1414 {
1415 _isMatch[_state.Index][posState].Encode(&_rangeEncoder, 1);
1416 if(pos < kNumRepDistances)
1417 {
1418 _isRep[_state.Index].Encode(&_rangeEncoder, 1);
1419 if(pos == 0)
1420 {
1421 _isRepG0[_state.Index].Encode(&_rangeEncoder, 0);
1422 _isRep0Long[_state.Index][posState].Encode(&_rangeEncoder, ((len == 1) ? 0 : 1));
1423 }
1424 else
1425 {
1426 UInt32 distance = _repDistances[pos];
1427 _isRepG0[_state.Index].Encode(&_rangeEncoder, 1);
1428 if (pos == 1)
1429 _isRepG1[_state.Index].Encode(&_rangeEncoder, 0);
1430 else
1431 {
1432 _isRepG1[_state.Index].Encode(&_rangeEncoder, 1);
1433 _isRepG2[_state.Index].Encode(&_rangeEncoder, pos - 2);
1434 if (pos == 3)
1435 _repDistances[3] = _repDistances[2];
1436 _repDistances[2] = _repDistances[1];
1437 }
1438 _repDistances[1] = _repDistances[0];
1439 _repDistances[0] = distance;
1440 }
1441 if (len == 1)
1442 _state.UpdateShortRep();
1443 else
1444 {
1445 _repMatchLenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
1446 _state.UpdateRep();
1447 }
1448 }
1449 else
1450 {
1451 _isRep[_state.Index].Encode(&_rangeEncoder, 0);
1452 _state.UpdateMatch();
1453 _lenEncoder.Encode(&_rangeEncoder, len - kMatchMinLen, posState, !_fastMode);
1454 pos -= kNumRepDistances;
1455 UInt32 posSlot = GetPosSlot(pos);
1456 _posSlotEncoder[GetLenToPosState(len)].Encode(&_rangeEncoder, posSlot);
1457
1458 if (posSlot >= kStartPosModelIndex)
1459 {
1460 UInt32 footerBits = ((posSlot >> 1) - 1);
1461 UInt32 base = ((2 | (posSlot & 1)) << footerBits);
1462 UInt32 posReduced = pos - base;
1463
1464 if (posSlot < kEndPosModelIndex)
1465 NRangeCoder::ReverseBitTreeEncode(_posEncoders + base - posSlot - 1,
1466 &_rangeEncoder, footerBits, posReduced);
1467 else
1468 {
1469 _rangeEncoder.EncodeDirectBits(posReduced >> kNumAlignBits, footerBits - kNumAlignBits);
1470 _posAlignEncoder.ReverseEncode(&_rangeEncoder, posReduced & kAlignMask);
1471 _alignPriceCount++;
1472 }
1473 }
1474 _repDistances[3] = _repDistances[2];
1475 _repDistances[2] = _repDistances[1];
1476 _repDistances[1] = _repDistances[0];
1477 _repDistances[0] = pos;
1478 _matchPriceCount++;
1479 }
1480 _previousByte = _matchFinder->GetIndexByte(len - 1 - _additionalOffset);
1481 }
1482 _additionalOffset -= len;
1483 nowPos32 += len;
1484 if (_additionalOffset == 0)
1485 {
1486 if (!_fastMode)
1487 {
1488 if (_matchPriceCount >= (1 << 7))
1489 FillDistancesPrices();
1490 if (_alignPriceCount >= kAlignTableSize)
1491 FillAlignPrices();
1492 }
1493 if (_matchFinder->GetNumAvailableBytes() == 0)
1494 return Flush(nowPos32);
1495 if (nowPos32 - progressPosValuePrev >= (1 << 14))
1496 {
1497 nowPos64 += nowPos32 - progressPosValuePrev;
1498 *inSize = nowPos64;
1499 *outSize = _rangeEncoder.GetProcessedSize();
1500 _finished = false;
1501 *finished = 0;
1502 return S_OK;
1503 }
1504 }
1505 }
1506 }
1507
1508 STDMETHODIMP CEncoder::Code(ISequentialInStream *inStream,
1509 ISequentialOutStream *outStream, const UInt64 *inSize, const UInt64 *outSize,
1510 ICompressProgressInfo *progress)
1511 {
1512 #ifndef _NO_EXCEPTIONS
1513 try
1514 {
1515 #endif
1516 return CodeReal(inStream, outStream, inSize, outSize, progress);
1517 #ifndef _NO_EXCEPTIONS
1518 }
1519 catch(const COutBufferException &e) { return e.ErrorCode; }
1520 catch(...) { return E_FAIL; }
1521 #endif
1522 }
1523
1524 void CEncoder::FillDistancesPrices()
1525 {
1526 UInt32 tempPrices[kNumFullDistances];
1527 for (UInt32 i = kStartPosModelIndex; i < kNumFullDistances; i++)
1528 {
1529 UInt32 posSlot = GetPosSlot(i);
1530 UInt32 footerBits = ((posSlot >> 1) - 1);
1531 UInt32 base = ((2 | (posSlot & 1)) << footerBits);
1532 tempPrices[i] = NRangeCoder::ReverseBitTreeGetPrice(_posEncoders +
1533 base - posSlot - 1, footerBits, i - base);
1534 }
1535
1536 for (UInt32 lenToPosState = 0; lenToPosState < kNumLenToPosStates; lenToPosState++)
1537 {
1538 UInt32 posSlot;
1539 NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> &encoder = _posSlotEncoder[lenToPosState];
1540 UInt32 *posSlotPrices = _posSlotPrices[lenToPosState];
1541 for (posSlot = 0; posSlot < _distTableSize; posSlot++)
1542 posSlotPrices[posSlot] = encoder.GetPrice(posSlot);
1543 for (posSlot = kEndPosModelIndex; posSlot < _distTableSize; posSlot++)
1544 posSlotPrices[posSlot] += ((((posSlot >> 1) - 1) - kNumAlignBits) << NRangeCoder::kNumBitPriceShiftBits);
1545
1546 UInt32 *distancesPrices = _distancesPrices[lenToPosState];
1547 UInt32 i;
1548 for (i = 0; i < kStartPosModelIndex; i++)
1549 distancesPrices[i] = posSlotPrices[i];
1550 for (; i < kNumFullDistances; i++)
1551 distancesPrices[i] = posSlotPrices[GetPosSlot(i)] + tempPrices[i];
1552 }
1553 _matchPriceCount = 0;
1554 }
1555
1556 void CEncoder::FillAlignPrices()
1557 {
1558 for (UInt32 i = 0; i < kAlignTableSize; i++)
1559 _alignPrices[i] = _posAlignEncoder.ReverseGetPrice(i);
1560 _alignPriceCount = 0;
1561 }
1562
1563 }}
0 // LZMA/Encoder.h
1
2 #ifndef __LZMA_ENCODER_H
3 #define __LZMA_ENCODER_H
4
5 #include "../../../Common/MyCom.h"
6 #include "../../../Common/Alloc.h"
7 #include "../../ICoder.h"
8 #include "../LZ/IMatchFinder.h"
9 #include "../RangeCoder/RangeCoderBitTree.h"
10
11 #include "LZMA.h"
12
13 namespace NCompress {
14 namespace NLZMA {
15
16 typedef NRangeCoder::CBitEncoder<kNumMoveBits> CMyBitEncoder;
17
18 class CBaseState
19 {
20 protected:
21 CState _state;
22 Byte _previousByte;
23 UInt32 _repDistances[kNumRepDistances];
24 void Init()
25 {
26 _state.Init();
27 _previousByte = 0;
28 for(UInt32 i = 0 ; i < kNumRepDistances; i++)
29 _repDistances[i] = 0;
30 }
31 };
32
33 struct COptimal
34 {
35 CState State;
36
37 bool Prev1IsChar;
38 bool Prev2;
39
40 UInt32 PosPrev2;
41 UInt32 BackPrev2;
42
43 UInt32 Price;
44 UInt32 PosPrev; // posNext;
45 UInt32 BackPrev;
46 UInt32 Backs[kNumRepDistances];
47 void MakeAsChar() { BackPrev = UInt32(-1); Prev1IsChar = false; }
48 void MakeAsShortRep() { BackPrev = 0; ; Prev1IsChar = false; }
49 bool IsShortRep() { return (BackPrev == 0); }
50 };
51
52
53 extern Byte g_FastPos[1 << 11];
54 inline UInt32 GetPosSlot(UInt32 pos)
55 {
56 if (pos < (1 << 11))
57 return g_FastPos[pos];
58 if (pos < (1 << 21))
59 return g_FastPos[pos >> 10] + 20;
60 return g_FastPos[pos >> 20] + 40;
61 }
62
63 inline UInt32 GetPosSlot2(UInt32 pos)
64 {
65 if (pos < (1 << 17))
66 return g_FastPos[pos >> 6] + 12;
67 if (pos < (1 << 27))
68 return g_FastPos[pos >> 16] + 32;
69 return g_FastPos[pos >> 26] + 52;
70 }
71
72 const UInt32 kIfinityPrice = 0xFFFFFFF;
73
74 const UInt32 kNumOpts = 1 << 12;
75
76
77 class CLiteralEncoder2
78 {
79 CMyBitEncoder _encoders[0x300];
80 public:
81 void Init()
82 {
83 for (int i = 0; i < 0x300; i++)
84 _encoders[i].Init();
85 }
86 void Encode(NRangeCoder::CEncoder *rangeEncoder, Byte symbol);
87 void EncodeMatched(NRangeCoder::CEncoder *rangeEncoder, Byte matchByte, Byte symbol);
88 UInt32 GetPrice(bool matchMode, Byte matchByte, Byte symbol) const;
89 };
90
91 class CLiteralEncoder
92 {
93 CLiteralEncoder2 *_coders;
94 int _numPrevBits;
95 int _numPosBits;
96 UInt32 _posMask;
97 public:
98 CLiteralEncoder(): _coders(0) {}
99 ~CLiteralEncoder() { Free(); }
100 void Free()
101 {
102 MyFree(_coders);
103 _coders = 0;
104 }
105 bool Create(int numPosBits, int numPrevBits)
106 {
107 if (_coders == 0 || (numPosBits + numPrevBits) != (_numPrevBits + _numPosBits))
108 {
109 Free();
110 UInt32 numStates = 1 << (numPosBits + numPrevBits);
111 _coders = (CLiteralEncoder2 *)MyAlloc(numStates * sizeof(CLiteralEncoder2));
112 }
113 _numPosBits = numPosBits;
114 _posMask = (1 << numPosBits) - 1;
115 _numPrevBits = numPrevBits;
116 return (_coders != 0);
117 }
118 void Init()
119 {
120 UInt32 numStates = 1 << (_numPrevBits + _numPosBits);
121 for (UInt32 i = 0; i < numStates; i++)
122 _coders[i].Init();
123 }
124 CLiteralEncoder2 *GetSubCoder(UInt32 pos, Byte prevByte)
125 { return &_coders[((pos & _posMask) << _numPrevBits) + (prevByte >> (8 - _numPrevBits))]; }
126 };
127
128 namespace NLength {
129
130 class CEncoder
131 {
132 CMyBitEncoder _choice;
133 CMyBitEncoder _choice2;
134 NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumLowBits> _lowCoder[kNumPosStatesEncodingMax];
135 NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumMidBits> _midCoder[kNumPosStatesEncodingMax];
136 NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumHighBits> _highCoder;
137 public:
138 void Init(UInt32 numPosStates);
139 void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState);
140 void SetPrices(UInt32 posState, UInt32 numSymbols, UInt32 *prices) const;
141 };
142
143 const UInt32 kNumSpecSymbols = kNumLowSymbols + kNumMidSymbols;
144
145 class CPriceTableEncoder: public CEncoder
146 {
147 UInt32 _prices[kNumPosStatesEncodingMax][kNumSymbolsTotal];
148 UInt32 _tableSize;
149 UInt32 _counters[kNumPosStatesEncodingMax];
150 public:
151 void SetTableSize(UInt32 tableSize) { _tableSize = tableSize; }
152 UInt32 GetPrice(UInt32 symbol, UInt32 posState) const { return _prices[posState][symbol]; }
153 void UpdateTable(UInt32 posState)
154 {
155 SetPrices(posState, _tableSize, _prices[posState]);
156 _counters[posState] = _tableSize;
157 }
158 void UpdateTables(UInt32 numPosStates)
159 {
160 for (UInt32 posState = 0; posState < numPosStates; posState++)
161 UpdateTable(posState);
162 }
163 void Encode(NRangeCoder::CEncoder *rangeEncoder, UInt32 symbol, UInt32 posState, bool updatePrice)
164 {
165 CEncoder::Encode(rangeEncoder, symbol, posState);
166 if (updatePrice)
167 if (--_counters[posState] == 0)
168 UpdateTable(posState);
169 }
170 };
171
172 }
173
174 class CEncoder :
175 public ICompressCoder,
176 public ICompressSetOutStream,
177 public ICompressSetCoderProperties,
178 public ICompressWriteCoderProperties,
179 public CBaseState,
180 public CMyUnknownImp
181 {
182 COptimal _optimum[kNumOpts];
183 CMyComPtr<IMatchFinder> _matchFinder; // test it
184 NRangeCoder::CEncoder _rangeEncoder;
185
186 CMyBitEncoder _isMatch[kNumStates][NLength::kNumPosStatesEncodingMax];
187 CMyBitEncoder _isRep[kNumStates];
188 CMyBitEncoder _isRepG0[kNumStates];
189 CMyBitEncoder _isRepG1[kNumStates];
190 CMyBitEncoder _isRepG2[kNumStates];
191 CMyBitEncoder _isRep0Long[kNumStates][NLength::kNumPosStatesEncodingMax];
192
193 NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumPosSlotBits> _posSlotEncoder[kNumLenToPosStates];
194
195 CMyBitEncoder _posEncoders[kNumFullDistances - kEndPosModelIndex];
196 NRangeCoder::CBitTreeEncoder<kNumMoveBits, kNumAlignBits> _posAlignEncoder;
197
198 NLength::CPriceTableEncoder _lenEncoder;
199 NLength::CPriceTableEncoder _repMatchLenEncoder;
200
201 CLiteralEncoder _literalEncoder;
202
203 UInt32 _matchDistances[kMatchMaxLen * 2 + 2 + 1];
204
205 bool _fastMode;
206 // bool _maxMode;
207 UInt32 _numFastBytes;
208 UInt32 _longestMatchLength;
209 UInt32 _numDistancePairs;
210
211 UInt32 _additionalOffset;
212
213 UInt32 _optimumEndIndex;
214 UInt32 _optimumCurrentIndex;
215
216 bool _longestMatchWasFound;
217
218 UInt32 _posSlotPrices[kNumLenToPosStates][kDistTableSizeMax];
219
220 UInt32 _distancesPrices[kNumLenToPosStates][kNumFullDistances];
221
222 UInt32 _alignPrices[kAlignTableSize];
223 UInt32 _alignPriceCount;
224
225 UInt32 _distTableSize;
226
227 UInt32 _posStateBits;
228 UInt32 _posStateMask;
229 UInt32 _numLiteralPosStateBits;
230 UInt32 _numLiteralContextBits;
231
232 UInt32 _dictionarySize;
233
234 UInt32 _dictionarySizePrev;
235 UInt32 _numFastBytesPrev;
236
237 UInt32 _matchPriceCount;
238 UInt64 nowPos64;
239 bool _finished;
240 ISequentialInStream *_inStream;
241
242 UInt32 _matchFinderCycles;
243 int _matchFinderIndex;
244 #ifdef COMPRESS_MF_MT
245 bool _multiThread;
246 #endif
247
248 bool _writeEndMark;
249
250 bool _needReleaseMFStream;
251
252 IMatchFinderSetNumPasses *setMfPasses;
253
254 void ReleaseMatchFinder()
255 {
256 setMfPasses = 0;
257 _matchFinder.Release();
258 }
259
260 HRESULT ReadMatchDistances(UInt32 &len, UInt32 &numDistancePairs);
261
262 HRESULT MovePos(UInt32 num);
263 UInt32 GetRepLen1Price(CState state, UInt32 posState) const
264 {
265 return _isRepG0[state.Index].GetPrice0() +
266 _isRep0Long[state.Index][posState].GetPrice0();
267 }
268
269 UInt32 GetPureRepPrice(UInt32 repIndex, CState state, UInt32 posState) const
270 {
271 UInt32 price;
272 if(repIndex == 0)
273 {
274 price = _isRepG0[state.Index].GetPrice0();
275 price += _isRep0Long[state.Index][posState].GetPrice1();
276 }
277 else
278 {
279 price = _isRepG0[state.Index].GetPrice1();
280 if (repIndex == 1)
281 price += _isRepG1[state.Index].GetPrice0();
282 else
283 {
284 price += _isRepG1[state.Index].GetPrice1();
285 price += _isRepG2[state.Index].GetPrice(repIndex - 2);
286 }
287 }
288 return price;
289 }
290 UInt32 GetRepPrice(UInt32 repIndex, UInt32 len, CState state, UInt32 posState) const
291 {
292 return _repMatchLenEncoder.GetPrice(len - kMatchMinLen, posState) +
293 GetPureRepPrice(repIndex, state, posState);
294 }
295 /*
296 UInt32 GetPosLen2Price(UInt32 pos, UInt32 posState) const
297 {
298 if (pos >= kNumFullDistances)
299 return kIfinityPrice;
300 return _distancesPrices[0][pos] + _lenEncoder.GetPrice(0, posState);
301 }
302 UInt32 GetPosLen3Price(UInt32 pos, UInt32 len, UInt32 posState) const
303 {
304 UInt32 price;
305 UInt32 lenToPosState = GetLenToPosState(len);
306 if (pos < kNumFullDistances)
307 price = _distancesPrices[lenToPosState][pos];
308 else
309 price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] +
310 _alignPrices[pos & kAlignMask];
311 return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
312 }
313 */
314 UInt32 GetPosLenPrice(UInt32 pos, UInt32 len, UInt32 posState) const
315 {
316 UInt32 price;
317 UInt32 lenToPosState = GetLenToPosState(len);
318 if (pos < kNumFullDistances)
319 price = _distancesPrices[lenToPosState][pos];
320 else
321 price = _posSlotPrices[lenToPosState][GetPosSlot2(pos)] +
322 _alignPrices[pos & kAlignMask];
323 return price + _lenEncoder.GetPrice(len - kMatchMinLen, posState);
324 }
325
326 UInt32 Backward(UInt32 &backRes, UInt32 cur);
327 HRESULT GetOptimum(UInt32 position, UInt32 &backRes, UInt32 &lenRes);
328 HRESULT GetOptimumFast(UInt32 position, UInt32 &backRes, UInt32 &lenRes);
329
330 void FillDistancesPrices();
331 void FillAlignPrices();
332
333 void ReleaseMFStream()
334 {
335 if (_matchFinder && _needReleaseMFStream)
336 {
337 _matchFinder->ReleaseStream();
338 _needReleaseMFStream = false;
339 }
340 }
341
342 void ReleaseStreams()
343 {
344 ReleaseMFStream();
345 ReleaseOutStream();
346 }
347
348 HRESULT Flush(UInt32 nowPos);
349 class CCoderReleaser
350 {
351 CEncoder *_coder;
352 public:
353 CCoderReleaser(CEncoder *coder): _coder(coder) {}
354 ~CCoderReleaser()
355 {
356 _coder->ReleaseStreams();
357 }
358 };
359 friend class CCoderReleaser;
360
361 void WriteEndMarker(UInt32 posState);
362
363 public:
364 CEncoder();
365 void SetWriteEndMarkerMode(bool writeEndMarker)
366 { _writeEndMark= writeEndMarker; }
367
368 HRESULT Create();
369
370 MY_UNKNOWN_IMP3(
371 ICompressSetOutStream,
372 ICompressSetCoderProperties,
373 ICompressWriteCoderProperties
374 )
375
376 HRESULT Init();
377
378 // ICompressCoder interface
379 HRESULT SetStreams(ISequentialInStream *inStream,
380 ISequentialOutStream *outStream,
381 const UInt64 *inSize, const UInt64 *outSize);
382 HRESULT CodeOneBlock(UInt64 *inSize, UInt64 *outSize, Int32 *finished);
383
384 HRESULT CodeReal(ISequentialInStream *inStream,
385 ISequentialOutStream *outStream,
386 const UInt64 *inSize, const UInt64 *outSize,
387 ICompressProgressInfo *progress);
388
389 // ICompressCoder interface
390 STDMETHOD(Code)(ISequentialInStream *inStream,
391 ISequentialOutStream *outStream,
392 const UInt64 *inSize, const UInt64 *outSize,
393 ICompressProgressInfo *progress);
394
395 // ICompressSetCoderProperties2
396 STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
397 const PROPVARIANT *properties, UInt32 numProperties);
398
399 // ICompressWriteCoderProperties
400 STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStream);
401
402 STDMETHOD(SetOutStream)(ISequentialOutStream *outStream);
403 STDMETHOD(ReleaseOutStream)();
404
405 virtual ~CEncoder() {}
406 };
407
408 }}
409
410 #endif
0 // StdAfx.h
1
2 #ifndef __STDAFX_H
3 #define __STDAFX_H
4
5 #include "../../../Common/MyWindows.h"
6
7 #endif
0 # Microsoft Developer Studio Project File - Name="AloneLZMA" - Package Owner=<4>
1 # Microsoft Developer Studio Generated Build File, Format Version 6.00
2 # ** DO NOT EDIT **
3
4 # TARGTYPE "Win32 (x86) Console Application" 0x0103
5
6 CFG=AloneLZMA - Win32 DebugU
7 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
8 !MESSAGE use the Export Makefile command and run
9 !MESSAGE
10 !MESSAGE NMAKE /f "AloneLZMA.mak".
11 !MESSAGE
12 !MESSAGE You can specify a configuration when running NMAKE
13 !MESSAGE by defining the macro CFG on the command line. For example:
14 !MESSAGE
15 !MESSAGE NMAKE /f "AloneLZMA.mak" CFG="AloneLZMA - Win32 DebugU"
16 !MESSAGE
17 !MESSAGE Possible choices for configuration are:
18 !MESSAGE
19 !MESSAGE "AloneLZMA - Win32 Release" (based on "Win32 (x86) Console Application")
20 !MESSAGE "AloneLZMA - Win32 Debug" (based on "Win32 (x86) Console Application")
21 !MESSAGE "AloneLZMA - Win32 ReleaseU" (based on "Win32 (x86) Console Application")
22 !MESSAGE "AloneLZMA - Win32 DebugU" (based on "Win32 (x86) Console Application")
23 !MESSAGE
24
25 # Begin Project
26 # PROP AllowPerConfigDependencies 0
27 # PROP Scc_ProjName ""
28 # PROP Scc_LocalPath ""
29 CPP=cl.exe
30 RSC=rc.exe
31
32 !IF "$(CFG)" == "AloneLZMA - Win32 Release"
33
34 # PROP BASE Use_MFC 0
35 # PROP BASE Use_Debug_Libraries 0
36 # PROP BASE Output_Dir "Release"
37 # PROP BASE Intermediate_Dir "Release"
38 # PROP BASE Target_Dir ""
39 # PROP Use_MFC 0
40 # PROP Use_Debug_Libraries 0
41 # PROP Output_Dir "Release"
42 # PROP Intermediate_Dir "Release"
43 # PROP Ignore_Export_Lib 0
44 # PROP Target_Dir ""
45 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
46 # ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /c
47 # ADD BASE RSC /l 0x419 /d "NDEBUG"
48 # ADD RSC /l 0x419 /d "NDEBUG"
49 BSC32=bscmake.exe
50 # ADD BASE BSC32 /nologo
51 # ADD BSC32 /nologo
52 LINK32=link.exe
53 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
54 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
55 # SUBTRACT LINK32 /pdb:none
56
57 !ELSEIF "$(CFG)" == "AloneLZMA - Win32 Debug"
58
59 # PROP BASE Use_MFC 0
60 # PROP BASE Use_Debug_Libraries 1
61 # PROP BASE Output_Dir "Debug"
62 # PROP BASE Intermediate_Dir "Debug"
63 # PROP BASE Target_Dir ""
64 # PROP Use_MFC 0
65 # PROP Use_Debug_Libraries 1
66 # PROP Output_Dir "Debug"
67 # PROP Intermediate_Dir "Debug"
68 # PROP Ignore_Export_Lib 0
69 # PROP Target_Dir ""
70 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
71 # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /GZ /c
72 # ADD BASE RSC /l 0x419 /d "_DEBUG"
73 # ADD RSC /l 0x419 /d "_DEBUG"
74 BSC32=bscmake.exe
75 # ADD BASE BSC32 /nologo
76 # ADD BSC32 /nologo
77 LINK32=link.exe
78 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
79 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
80
81 !ELSEIF "$(CFG)" == "AloneLZMA - Win32 ReleaseU"
82
83 # PROP BASE Use_MFC 0
84 # PROP BASE Use_Debug_Libraries 0
85 # PROP BASE Output_Dir "ReleaseU"
86 # PROP BASE Intermediate_Dir "ReleaseU"
87 # PROP BASE Ignore_Export_Lib 0
88 # PROP BASE Target_Dir ""
89 # PROP Use_MFC 0
90 # PROP Use_Debug_Libraries 0
91 # PROP Output_Dir "ReleaseU"
92 # PROP Intermediate_Dir "ReleaseU"
93 # PROP Ignore_Export_Lib 0
94 # PROP Target_Dir ""
95 # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /Yu"StdAfx.h" /FD /c
96 # ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /D "NDEBUG" /D "UNICODE" /D "_UNICODE" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /c
97 # ADD BASE RSC /l 0x419 /d "NDEBUG"
98 # ADD RSC /l 0x419 /d "NDEBUG"
99 BSC32=bscmake.exe
100 # ADD BASE BSC32 /nologo
101 # ADD BSC32 /nologo
102 LINK32=link.exe
103 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\7za2.exe" /opt:NOWIN98
104 # SUBTRACT BASE LINK32 /pdb:none
105 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"c:\UTIL\lzma.exe" /opt:NOWIN98
106 # SUBTRACT LINK32 /pdb:none
107
108 !ELSEIF "$(CFG)" == "AloneLZMA - Win32 DebugU"
109
110 # PROP BASE Use_MFC 0
111 # PROP BASE Use_Debug_Libraries 1
112 # PROP BASE Output_Dir "DebugU"
113 # PROP BASE Intermediate_Dir "DebugU"
114 # PROP BASE Ignore_Export_Lib 0
115 # PROP BASE Target_Dir ""
116 # PROP Use_MFC 0
117 # PROP Use_Debug_Libraries 1
118 # PROP Output_Dir "DebugU"
119 # PROP Intermediate_Dir "DebugU"
120 # PROP Ignore_Export_Lib 0
121 # PROP Target_Dir ""
122 # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "EXCLUDE_COM" /D "NO_REGISTRY" /D "FORMAT_7Z" /D "FORMAT_BZIP2" /D "FORMAT_ZIP" /D "FORMAT_TAR" /D "FORMAT_GZIP" /D "COMPRESS_LZMA" /D "COMPRESS_BCJ_X86" /D "COMPRESS_BCJ2" /D "COMPRESS_COPY" /D "COMPRESS_MF_PAT" /D "COMPRESS_MF_BT" /D "COMPRESS_PPMD" /D "COMPRESS_DEFLATE" /D "COMPRESS_IMPLODE" /D "COMPRESS_BZIP2" /D "CRYPTO_ZIP" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c
123 # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_UNICODE" /D "UNICODE" /D "WIN32" /D "_CONSOLE" /Yu"StdAfx.h" /FD /GZ /c
124 # ADD BASE RSC /l 0x419 /d "_DEBUG"
125 # ADD RSC /l 0x419 /d "_DEBUG"
126 BSC32=bscmake.exe
127 # ADD BASE BSC32 /nologo
128 # ADD BSC32 /nologo
129 LINK32=link.exe
130 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\7za2.exe" /pdbtype:sept
131 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"c:\UTIL\lzma.exe" /pdbtype:sept
132
133 !ENDIF
134
135 # Begin Target
136
137 # Name "AloneLZMA - Win32 Release"
138 # Name "AloneLZMA - Win32 Debug"
139 # Name "AloneLZMA - Win32 ReleaseU"
140 # Name "AloneLZMA - Win32 DebugU"
141 # Begin Group "Spec"
142
143 # PROP Default_Filter ""
144 # Begin Source File
145
146 SOURCE=.\StdAfx.cpp
147 # ADD CPP /Yc"StdAfx.h"
148 # End Source File
149 # Begin Source File
150
151 SOURCE=.\StdAfx.h
152 # End Source File
153 # End Group
154 # Begin Group "Compress"
155
156 # PROP Default_Filter ""
157 # Begin Group "LZMA"
158
159 # PROP Default_Filter ""
160 # Begin Source File
161
162 SOURCE=..\LZMA\LZMA.h
163 # End Source File
164 # Begin Source File
165
166 SOURCE=..\LZMA\LZMADecoder.cpp
167 # End Source File
168 # Begin Source File
169
170 SOURCE=..\LZMA\LZMADecoder.h
171 # End Source File
172 # Begin Source File
173
174 SOURCE=..\LZMA\LZMAEncoder.cpp
175 # End Source File
176 # Begin Source File
177
178 SOURCE=..\LZMA\LZMAEncoder.h
179 # End Source File
180 # End Group
181 # Begin Group "RangeCoder"
182
183 # PROP Default_Filter ""
184 # Begin Source File
185
186 SOURCE=..\RangeCoder\RangeCoder.h
187 # End Source File
188 # Begin Source File
189
190 SOURCE=..\RangeCoder\RangeCoderBit.cpp
191 # End Source File
192 # Begin Source File
193
194 SOURCE=..\RangeCoder\RangeCoderBit.h
195 # End Source File
196 # Begin Source File
197
198 SOURCE=..\RangeCoder\RangeCoderBitTree.h
199 # End Source File
200 # Begin Source File
201
202 SOURCE=..\RangeCoder\RangeCoderOpt.h
203 # End Source File
204 # End Group
205 # Begin Group "LZ"
206
207 # PROP Default_Filter ""
208 # Begin Group "BT"
209
210 # PROP Default_Filter ""
211 # Begin Source File
212
213 SOURCE=..\LZ\BinTree\BinTree.h
214 # End Source File
215 # Begin Source File
216
217 SOURCE=..\LZ\BinTree\BinTree2.h
218 # End Source File
219 # Begin Source File
220
221 SOURCE=..\LZ\BinTree\BinTree3.h
222 # End Source File
223 # Begin Source File
224
225 SOURCE=..\LZ\BinTree\BinTree3Z.h
226 # End Source File
227 # Begin Source File
228
229 SOURCE=..\LZ\BinTree\BinTree4.h
230 # End Source File
231 # Begin Source File
232
233 SOURCE=..\LZ\BinTree\BinTreeMain.h
234 # End Source File
235 # End Group
236 # Begin Group "HC"
237
238 # PROP Default_Filter ""
239 # Begin Source File
240
241 SOURCE=..\LZ\HashChain\HC4.h
242 # End Source File
243 # Begin Source File
244
245 SOURCE=..\LZ\HashChain\HCMain.h
246 # End Source File
247 # End Group
248 # Begin Source File
249
250 SOURCE=..\LZ\IMatchFinder.h
251 # End Source File
252 # Begin Source File
253
254 SOURCE=..\LZ\LZInWindow.cpp
255 # End Source File
256 # Begin Source File
257
258 SOURCE=..\LZ\LZInWindow.h
259 # End Source File
260 # Begin Source File
261
262 SOURCE=..\LZ\LZOutWindow.cpp
263 # End Source File
264 # Begin Source File
265
266 SOURCE=..\LZ\LZOutWindow.h
267 # End Source File
268 # End Group
269 # Begin Group "Branch"
270
271 # PROP Default_Filter ""
272 # Begin Source File
273
274 SOURCE=..\Branch\BranchTypes.h
275 # End Source File
276 # Begin Source File
277
278 SOURCE=..\Branch\BranchX86.c
279 # SUBTRACT CPP /YX /Yc /Yu
280 # End Source File
281 # Begin Source File
282
283 SOURCE=..\Branch\BranchX86.h
284 # End Source File
285 # End Group
286 # Begin Group "LZMA_C"
287
288 # PROP Default_Filter ""
289 # Begin Source File
290
291 SOURCE=..\LZMA_C\LzmaDecode.c
292 # SUBTRACT CPP /YX /Yc /Yu
293 # End Source File
294 # Begin Source File
295
296 SOURCE=..\LZMA_C\LzmaDecode.h
297 # End Source File
298 # Begin Source File
299
300 SOURCE=..\LZMA_C\LzmaTypes.h
301 # End Source File
302 # End Group
303 # End Group
304 # Begin Group "Windows"
305
306 # PROP Default_Filter ""
307 # Begin Source File
308
309 SOURCE=..\..\..\Windows\FileIO.cpp
310 # End Source File
311 # Begin Source File
312
313 SOURCE=..\..\..\Windows\FileIO.h
314 # End Source File
315 # End Group
316 # Begin Group "Common"
317
318 # PROP Default_Filter ""
319 # Begin Source File
320
321 SOURCE=..\..\..\Common\Alloc.cpp
322 # End Source File
323 # Begin Source File
324
325 SOURCE=..\..\..\Common\Alloc.h
326 # End Source File
327 # Begin Source File
328
329 SOURCE=..\..\..\Common\CommandLineParser.cpp
330 # End Source File
331 # Begin Source File
332
333 SOURCE=..\..\..\Common\CommandLineParser.h
334 # End Source File
335 # Begin Source File
336
337 SOURCE=..\..\..\Common\CRC.cpp
338 # End Source File
339 # Begin Source File
340
341 SOURCE=..\..\..\Common\CRC.h
342 # End Source File
343 # Begin Source File
344
345 SOURCE=..\..\..\Common\Defs.h
346 # End Source File
347 # Begin Source File
348
349 SOURCE=..\..\..\Windows\Defs.h
350 # End Source File
351 # Begin Source File
352
353 SOURCE=..\..\..\Common\MyCom.h
354 # End Source File
355 # Begin Source File
356
357 SOURCE=..\..\..\Common\MyWindows.h
358 # End Source File
359 # Begin Source File
360
361 SOURCE=..\..\..\Common\NewHandler.cpp
362 # End Source File
363 # Begin Source File
364
365 SOURCE=..\..\..\Common\NewHandler.h
366 # End Source File
367 # Begin Source File
368
369 SOURCE=..\..\..\Common\String.cpp
370 # End Source File
371 # Begin Source File
372
373 SOURCE=..\..\..\Common\String.h
374 # End Source File
375 # Begin Source File
376
377 SOURCE=..\..\..\Common\StringConvert.cpp
378 # End Source File
379 # Begin Source File
380
381 SOURCE=..\..\..\Common\StringConvert.h
382 # End Source File
383 # Begin Source File
384
385 SOURCE=..\..\..\Common\StringToInt.cpp
386 # End Source File
387 # Begin Source File
388
389 SOURCE=..\..\..\Common\StringToInt.h
390 # End Source File
391 # Begin Source File
392
393 SOURCE=..\..\..\Common\Types.h
394 # End Source File
395 # Begin Source File
396
397 SOURCE=..\..\..\Common\Vector.cpp
398 # End Source File
399 # Begin Source File
400
401 SOURCE=..\..\..\Common\Vector.h
402 # End Source File
403 # End Group
404 # Begin Group "7zip Common"
405
406 # PROP Default_Filter ""
407 # Begin Source File
408
409 SOURCE=..\..\Common\FileStreams.cpp
410 # End Source File
411 # Begin Source File
412
413 SOURCE=..\..\Common\FileStreams.h
414 # End Source File
415 # Begin Source File
416
417 SOURCE=..\..\Common\InBuffer.cpp
418 # End Source File
419 # Begin Source File
420
421 SOURCE=..\..\Common\InBuffer.h
422 # End Source File
423 # Begin Source File
424
425 SOURCE=..\..\Common\OutBuffer.cpp
426 # End Source File
427 # Begin Source File
428
429 SOURCE=..\..\Common\OutBuffer.h
430 # End Source File
431 # Begin Source File
432
433 SOURCE=..\..\Common\StreamUtils.cpp
434 # End Source File
435 # Begin Source File
436
437 SOURCE=..\..\Common\StreamUtils.h
438 # End Source File
439 # End Group
440 # Begin Source File
441
442 SOURCE=..\..\ICoder.h
443 # End Source File
444 # Begin Source File
445
446 SOURCE=.\LzmaAlone.cpp
447 # End Source File
448 # Begin Source File
449
450 SOURCE=.\LzmaBench.cpp
451 # End Source File
452 # Begin Source File
453
454 SOURCE=.\LzmaBench.h
455 # End Source File
456 # Begin Source File
457
458 SOURCE=.\LzmaRam.cpp
459 # End Source File
460 # Begin Source File
461
462 SOURCE=.\LzmaRam.h
463 # End Source File
464 # Begin Source File
465
466 SOURCE=.\LzmaRamDecode.c
467 # SUBTRACT CPP /YX /Yc /Yu
468 # End Source File
469 # Begin Source File
470
471 SOURCE=.\LzmaRamDecode.h
472 # End Source File
473 # End Target
474 # End Project
0 Microsoft Developer Studio Workspace File, Format Version 6.00
1 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
2
3 ###############################################################################
4
5 Project: "AloneLZMA"=.\AloneLZMA.dsp - Package Owner=<4>
6
7 Package=<5>
8 {{{
9 }}}
10
11 Package=<4>
12 {{{
13 }}}
14
15 ###############################################################################
16
17 Global:
18
19 Package=<5>
20 {{{
21 }}}
22
23 Package=<3>
24 {{{
25 }}}
26
27 ###############################################################################
28
0 // LzmaAlone.cpp
1
2 #include "StdAfx.h"
3
4 #include "../../../Common/MyWindows.h"
5 #include "../../../Common/MyInitGuid.h"
6
7 #include <stdio.h>
8
9 #if defined(_WIN32) || defined(OS2) || defined(MSDOS)
10 #include <fcntl.h>
11 #include <io.h>
12 #define MY_SET_BINARY_MODE(file) setmode(fileno(file),O_BINARY)
13 #else
14 #define MY_SET_BINARY_MODE(file)
15 #endif
16
17 #include "../../../Common/CommandLineParser.h"
18 #include "../../../Common/StringConvert.h"
19 #include "../../../Common/StringToInt.h"
20
21 #include "../../Common/FileStreams.h"
22 #include "../../Common/StreamUtils.h"
23
24 #include "../LZMA/LZMADecoder.h"
25 #include "../LZMA/LZMAEncoder.h"
26
27 #include "LzmaBench.h"
28 #include "LzmaRam.h"
29
30 extern "C"
31 {
32 #include "LzmaRamDecode.h"
33 }
34
35 using namespace NCommandLineParser;
36
37 #ifdef _WIN32
38 bool g_IsNT = false;
39 static inline bool IsItWindowsNT()
40 {
41 OSVERSIONINFO versionInfo;
42 versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
43 if (!::GetVersionEx(&versionInfo))
44 return false;
45 return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT);
46 }
47 #endif
48
49 static const char *kCantAllocate = "Can not allocate memory";
50 static const char *kReadError = "Read error";
51 static const char *kWriteError = "Write error";
52
53 namespace NKey {
54 enum Enum
55 {
56 kHelp1 = 0,
57 kHelp2,
58 kMode,
59 kDictionary,
60 kFastBytes,
61 kMatchFinderCycles,
62 kLitContext,
63 kLitPos,
64 kPosBits,
65 kMatchFinder,
66 kEOS,
67 kStdIn,
68 kStdOut,
69 kFilter86
70 };
71 }
72
73 static const CSwitchForm kSwitchForms[] =
74 {
75 { L"?", NSwitchType::kSimple, false },
76 { L"H", NSwitchType::kSimple, false },
77 { L"A", NSwitchType::kUnLimitedPostString, false, 1 },
78 { L"D", NSwitchType::kUnLimitedPostString, false, 1 },
79 { L"FB", NSwitchType::kUnLimitedPostString, false, 1 },
80 { L"MC", NSwitchType::kUnLimitedPostString, false, 1 },
81 { L"LC", NSwitchType::kUnLimitedPostString, false, 1 },
82 { L"LP", NSwitchType::kUnLimitedPostString, false, 1 },
83 { L"PB", NSwitchType::kUnLimitedPostString, false, 1 },
84 { L"MF", NSwitchType::kUnLimitedPostString, false, 1 },
85 { L"EOS", NSwitchType::kSimple, false },
86 { L"SI", NSwitchType::kSimple, false },
87 { L"SO", NSwitchType::kSimple, false },
88 { L"F86", NSwitchType::kSimple, false }
89 };
90
91 static const int kNumSwitches = sizeof(kSwitchForms) / sizeof(kSwitchForms[0]);
92
93 static void PrintHelp()
94 {
95 fprintf(stderr, "\nUsage: LZMA <e|d> inputFile outputFile [<switches>...]\n"
96 " e: encode file\n"
97 " d: decode file\n"
98 " b: Benchmark\n"
99 "<Switches>\n"
100 " -a{N}: set compression mode - [0, 1], default: 1 (max)\n"
101 " -d{N}: set dictionary - [0,30], default: 23 (8MB)\n"
102 " -fb{N}: set number of fast bytes - [5, 273], default: 128\n"
103 " -mc{N}: set number of cycles for match finder\n"
104 " -lc{N}: set number of literal context bits - [0, 8], default: 3\n"
105 " -lp{N}: set number of literal pos bits - [0, 4], default: 0\n"
106 " -pb{N}: set number of pos bits - [0, 4], default: 2\n"
107 " -mf{MF_ID}: set Match Finder: [bt2, bt3, bt4, hc4], default: bt4\n"
108 " -eos: write End Of Stream marker\n"
109 " -si: read data from stdin\n"
110 " -so: write data to stdout\n"
111 );
112 }
113
114 static void PrintHelpAndExit(const char *s)
115 {
116 fprintf(stderr, "\nError: %s\n\n", s);
117 PrintHelp();
118 throw -1;
119 }
120
121 static void IncorrectCommand()
122 {
123 PrintHelpAndExit("Incorrect command");
124 }
125
126 static void WriteArgumentsToStringList(int numArguments, const char *arguments[],
127 UStringVector &strings)
128 {
129 for(int i = 1; i < numArguments; i++)
130 strings.Add(MultiByteToUnicodeString(arguments[i]));
131 }
132
133 static bool GetNumber(const wchar_t *s, UInt32 &value)
134 {
135 value = 0;
136 if (MyStringLen(s) == 0)
137 return false;
138 const wchar_t *end;
139 UInt64 res = ConvertStringToUInt64(s, &end);
140 if (*end != L'\0')
141 return false;
142 if (res > 0xFFFFFFFF)
143 return false;
144 value = UInt32(res);
145 return true;
146 }
147
148 int main2(int n, const char *args[])
149 {
150 #ifdef _WIN32
151 g_IsNT = IsItWindowsNT();
152 #endif
153
154 fprintf(stderr, "\nLZMA 4.43 Copyright (c) 1999-2006 Igor Pavlov 2006-06-04\n");
155
156 if (n == 1)
157 {
158 PrintHelp();
159 return 0;
160 }
161
162 if (sizeof(Byte) != 1 || sizeof(UInt32) < 4 || sizeof(UInt64) < 4)
163 {
164 fprintf(stderr, "Unsupported base types. Edit Common/Types.h and recompile");
165 return 1;
166 }
167
168 UStringVector commandStrings;
169 WriteArgumentsToStringList(n, args, commandStrings);
170 CParser parser(kNumSwitches);
171 try
172 {
173 parser.ParseStrings(kSwitchForms, commandStrings);
174 }
175 catch(...)
176 {
177 IncorrectCommand();
178 }
179
180 if(parser[NKey::kHelp1].ThereIs || parser[NKey::kHelp2].ThereIs)
181 {
182 PrintHelp();
183 return 0;
184 }
185 const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
186
187 int paramIndex = 0;
188 if (paramIndex >= nonSwitchStrings.Size())
189 IncorrectCommand();
190 const UString &command = nonSwitchStrings[paramIndex++];
191
192 bool dictionaryIsDefined = false;
193 UInt32 dictionary = 1 << 21;
194 if(parser[NKey::kDictionary].ThereIs)
195 {
196 UInt32 dicLog;
197 if (!GetNumber(parser[NKey::kDictionary].PostStrings[0], dicLog))
198 IncorrectCommand();
199 dictionary = 1 << dicLog;
200 dictionaryIsDefined = true;
201 }
202 UString mf = L"BT4";
203 if (parser[NKey::kMatchFinder].ThereIs)
204 mf = parser[NKey::kMatchFinder].PostStrings[0];
205
206 if (command.CompareNoCase(L"b") == 0)
207 {
208 const UInt32 kNumDefaultItereations = 10;
209 UInt32 numIterations = kNumDefaultItereations;
210 {
211 if (paramIndex < nonSwitchStrings.Size())
212 if (!GetNumber(nonSwitchStrings[paramIndex++], numIterations))
213 numIterations = kNumDefaultItereations;
214 }
215 return LzmaBenchmark(stderr, numIterations, dictionary);
216 }
217
218 bool encodeMode = false;
219 if (command.CompareNoCase(L"e") == 0)
220 encodeMode = true;
221 else if (command.CompareNoCase(L"d") == 0)
222 encodeMode = false;
223 else
224 IncorrectCommand();
225
226 bool stdInMode = parser[NKey::kStdIn].ThereIs;
227 bool stdOutMode = parser[NKey::kStdOut].ThereIs;
228
229 CMyComPtr<ISequentialInStream> inStream;
230 CInFileStream *inStreamSpec = 0;
231 if (stdInMode)
232 {
233 inStream = new CStdInFileStream;
234 MY_SET_BINARY_MODE(stdin);
235 }
236 else
237 {
238 if (paramIndex >= nonSwitchStrings.Size())
239 IncorrectCommand();
240 const UString &inputName = nonSwitchStrings[paramIndex++];
241 inStreamSpec = new CInFileStream;
242 inStream = inStreamSpec;
243 if (!inStreamSpec->Open(GetSystemString(inputName)))
244 {
245 fprintf(stderr, "\nError: can not open input file %s\n",
246 (const char *)GetOemString(inputName));
247 return 1;
248 }
249 }
250
251 CMyComPtr<ISequentialOutStream> outStream;
252 if (stdOutMode)
253 {
254 outStream = new CStdOutFileStream;
255 MY_SET_BINARY_MODE(stdout);
256 }
257 else
258 {
259 if (paramIndex >= nonSwitchStrings.Size())
260 IncorrectCommand();
261 const UString &outputName = nonSwitchStrings[paramIndex++];
262 COutFileStream *outStreamSpec = new COutFileStream;
263 outStream = outStreamSpec;
264 if (!outStreamSpec->Create(GetSystemString(outputName), true))
265 {
266 fprintf(stderr, "\nError: can not open output file %s\n",
267 (const char *)GetOemString(outputName));
268 return 1;
269 }
270 }
271
272 if (parser[NKey::kFilter86].ThereIs)
273 {
274 // -f86 switch is for x86 filtered mode: BCJ + LZMA.
275 if (parser[NKey::kEOS].ThereIs || stdInMode)
276 throw "Can not use stdin in this mode";
277 UInt64 fileSize;
278 inStreamSpec->File.GetLength(fileSize);
279 if (fileSize > 0xF0000000)
280 throw "File is too big";
281 UInt32 inSize = (UInt32)fileSize;
282 Byte *inBuffer = 0;
283 if (inSize != 0)
284 {
285 inBuffer = (Byte *)MyAlloc((size_t)inSize);
286 if (inBuffer == 0)
287 throw kCantAllocate;
288 }
289
290 UInt32 processedSize;
291 if (ReadStream(inStream, inBuffer, (UInt32)inSize, &processedSize) != S_OK)
292 throw "Can not read";
293 if ((UInt32)inSize != processedSize)
294 throw "Read size error";
295
296 Byte *outBuffer = 0;
297 size_t outSizeProcessed;
298 if (encodeMode)
299 {
300 // we allocate 105% of original size for output buffer
301 size_t outSize = (size_t)fileSize / 20 * 21 + (1 << 16);
302 if (outSize != 0)
303 {
304 outBuffer = (Byte *)MyAlloc((size_t)outSize);
305 if (outBuffer == 0)
306 throw kCantAllocate;
307 }
308 if (!dictionaryIsDefined)
309 dictionary = 1 << 23;
310 int res = LzmaRamEncode(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed,
311 dictionary, SZ_FILTER_AUTO);
312 if (res != 0)
313 {
314 fprintf(stderr, "\nEncoder error = %d\n", (int)res);
315 return 1;
316 }
317 }
318 else
319 {
320 size_t outSize;
321 if (LzmaRamGetUncompressedSize(inBuffer, inSize, &outSize) != 0)
322 throw "data error";
323 if (outSize != 0)
324 {
325 outBuffer = (Byte *)MyAlloc(outSize);
326 if (outBuffer == 0)
327 throw kCantAllocate;
328 }
329 int res = LzmaRamDecompress(inBuffer, inSize, outBuffer, outSize, &outSizeProcessed, malloc, free);
330 if (res != 0)
331 throw "LzmaDecoder error";
332 }
333 if (WriteStream(outStream, outBuffer, (UInt32)outSizeProcessed, &processedSize) != S_OK)
334 throw kWriteError;
335 MyFree(outBuffer);
336 MyFree(inBuffer);
337 return 0;
338 }
339
340
341 UInt64 fileSize;
342 if (encodeMode)
343 {
344 NCompress::NLZMA::CEncoder *encoderSpec =
345 new NCompress::NLZMA::CEncoder;
346 CMyComPtr<ICompressCoder> encoder = encoderSpec;
347
348 if (!dictionaryIsDefined)
349 dictionary = 1 << 23;
350
351 UInt32 posStateBits = 2;
352 UInt32 litContextBits = 3; // for normal files
353 // UInt32 litContextBits = 0; // for 32-bit data
354 UInt32 litPosBits = 0;
355 // UInt32 litPosBits = 2; // for 32-bit data
356 UInt32 algorithm = 2;
357 UInt32 numFastBytes = 128;
358 UInt32 matchFinderCycles = 16 + numFastBytes / 2;
359 bool matchFinderCyclesDefined = false;
360
361 bool eos = parser[NKey::kEOS].ThereIs || stdInMode;
362
363 if(parser[NKey::kMode].ThereIs)
364 if (!GetNumber(parser[NKey::kMode].PostStrings[0], algorithm))
365 IncorrectCommand();
366
367 if(parser[NKey::kFastBytes].ThereIs)
368 if (!GetNumber(parser[NKey::kFastBytes].PostStrings[0], numFastBytes))
369 IncorrectCommand();
370 if (matchFinderCyclesDefined = parser[NKey::kMatchFinderCycles].ThereIs)
371 if (!GetNumber(parser[NKey::kMatchFinderCycles].PostStrings[0], matchFinderCycles))
372 IncorrectCommand();
373 if(parser[NKey::kLitContext].ThereIs)
374 if (!GetNumber(parser[NKey::kLitContext].PostStrings[0], litContextBits))
375 IncorrectCommand();
376 if(parser[NKey::kLitPos].ThereIs)
377 if (!GetNumber(parser[NKey::kLitPos].PostStrings[0], litPosBits))
378 IncorrectCommand();
379 if(parser[NKey::kPosBits].ThereIs)
380 if (!GetNumber(parser[NKey::kPosBits].PostStrings[0], posStateBits))
381 IncorrectCommand();
382
383 PROPID propIDs[] =
384 {
385 NCoderPropID::kDictionarySize,
386 NCoderPropID::kPosStateBits,
387 NCoderPropID::kLitContextBits,
388 NCoderPropID::kLitPosBits,
389 NCoderPropID::kAlgorithm,
390 NCoderPropID::kNumFastBytes,
391 NCoderPropID::kMatchFinder,
392 NCoderPropID::kEndMarker,
393 NCoderPropID::kMatchFinderCycles
394 };
395 const int kNumPropsMax = sizeof(propIDs) / sizeof(propIDs[0]);
396 /*
397 NWindows::NCOM::CPropVariant properties[kNumProps];
398 properties[0] = UInt32(dictionary);
399 properties[1] = UInt32(posStateBits);
400 properties[2] = UInt32(litContextBits);
401
402 properties[3] = UInt32(litPosBits);
403 properties[4] = UInt32(algorithm);
404 properties[5] = UInt32(numFastBytes);
405 properties[6] = mf;
406 properties[7] = eos;
407 */
408 PROPVARIANT properties[kNumPropsMax];
409 for (int p = 0; p < 6; p++)
410 properties[p].vt = VT_UI4;
411
412 properties[0].ulVal = UInt32(dictionary);
413 properties[1].ulVal = UInt32(posStateBits);
414 properties[2].ulVal = UInt32(litContextBits);
415 properties[3].ulVal = UInt32(litPosBits);
416 properties[4].ulVal = UInt32(algorithm);
417 properties[5].ulVal = UInt32(numFastBytes);
418
419 properties[8].vt = VT_UI4;
420 properties[8].ulVal = UInt32(matchFinderCycles);
421
422 properties[6].vt = VT_BSTR;
423 properties[6].bstrVal = (BSTR)(const wchar_t *)mf;
424
425 properties[7].vt = VT_BOOL;
426 properties[7].boolVal = eos ? VARIANT_TRUE : VARIANT_FALSE;
427
428 int numProps = kNumPropsMax;
429 if (!matchFinderCyclesDefined)
430 numProps--;
431
432 if (encoderSpec->SetCoderProperties(propIDs, properties, numProps) != S_OK)
433 IncorrectCommand();
434 encoderSpec->WriteCoderProperties(outStream);
435
436 if (eos || stdInMode)
437 fileSize = (UInt64)(Int64)-1;
438 else
439 inStreamSpec->File.GetLength(fileSize);
440
441 for (int i = 0; i < 8; i++)
442 {
443 Byte b = Byte(fileSize >> (8 * i));
444 if (outStream->Write(&b, 1, 0) != S_OK)
445 {
446 fprintf(stderr, kWriteError);
447 return 1;
448 }
449 }
450 HRESULT result = encoder->Code(inStream, outStream, 0, 0, 0);
451 if (result == E_OUTOFMEMORY)
452 {
453 fprintf(stderr, "\nError: Can not allocate memory\n");
454 return 1;
455 }
456 else if (result != S_OK)
457 {
458 fprintf(stderr, "\nEncoder error = %X\n", (unsigned int)result);
459 return 1;
460 }
461 }
462 else
463 {
464 NCompress::NLZMA::CDecoder *decoderSpec =
465 new NCompress::NLZMA::CDecoder;
466 CMyComPtr<ICompressCoder> decoder = decoderSpec;
467 const UInt32 kPropertiesSize = 5;
468 Byte properties[kPropertiesSize];
469 UInt32 processedSize;
470 if (ReadStream(inStream, properties, kPropertiesSize, &processedSize) != S_OK)
471 {
472 fprintf(stderr, kReadError);
473 return 1;
474 }
475 if (processedSize != kPropertiesSize)
476 {
477 fprintf(stderr, kReadError);
478 return 1;
479 }
480 if (decoderSpec->SetDecoderProperties2(properties, kPropertiesSize) != S_OK)
481 {
482 fprintf(stderr, "SetDecoderProperties error");
483 return 1;
484 }
485 fileSize = 0;
486 for (int i = 0; i < 8; i++)
487 {
488 Byte b;
489 if (inStream->Read(&b, 1, &processedSize) != S_OK)
490 {
491 fprintf(stderr, kReadError);
492 return 1;
493 }
494 if (processedSize != 1)
495 {
496 fprintf(stderr, kReadError);
497 return 1;
498 }
499 fileSize |= ((UInt64)b) << (8 * i);
500 }
501 if (decoder->Code(inStream, outStream, 0, &fileSize, 0) != S_OK)
502 {
503 fprintf(stderr, "Decoder error");
504 return 1;
505 }
506 }
507 return 0;
508 }
509
510 int main(int n, const char *args[])
511 {
512 try { return main2(n, args); }
513 catch(const char *s)
514 {
515 fprintf(stderr, "\nError: %s\n", s);
516 return 1;
517 }
518 catch(...)
519 {
520 fprintf(stderr, "\nError\n");
521 return 1;
522 }
523 }
0 // LzmaBench.cpp
1
2 #include "StdAfx.h"
3
4 #include "LzmaBench.h"
5
6 #ifndef _WIN32
7 #include <time.h>
8 #endif
9
10 #include "../../../Common/CRC.h"
11 #include "../LZMA/LZMADecoder.h"
12 #include "../LZMA/LZMAEncoder.h"
13
14 static const UInt32 kAdditionalSize =
15 #ifdef _WIN32_WCE
16 (1 << 20);
17 #else
18 (6 << 20);
19 #endif
20
21 static const UInt32 kCompressedAdditionalSize = (1 << 10);
22 static const UInt32 kMaxLzmaPropSize = 10;
23
24 class CRandomGenerator
25 {
26 UInt32 A1;
27 UInt32 A2;
28 public:
29 CRandomGenerator() { Init(); }
30 void Init() { A1 = 362436069; A2 = 521288629;}
31 UInt32 GetRnd()
32 {
33 return
34 ((A1 = 36969 * (A1 & 0xffff) + (A1 >> 16)) << 16) ^
35 ((A2 = 18000 * (A2 & 0xffff) + (A2 >> 16)) );
36 }
37 };
38
39 class CBitRandomGenerator
40 {
41 CRandomGenerator RG;
42 UInt32 Value;
43 int NumBits;
44 public:
45 void Init()
46 {
47 Value = 0;
48 NumBits = 0;
49 }
50 UInt32 GetRnd(int numBits)
51 {
52 if (NumBits > numBits)
53 {
54 UInt32 result = Value & ((1 << numBits) - 1);
55 Value >>= numBits;
56 NumBits -= numBits;
57 return result;
58 }
59 numBits -= NumBits;
60 UInt32 result = (Value << numBits);
61 Value = RG.GetRnd();
62 result |= Value & ((1 << numBits) - 1);
63 Value >>= numBits;
64 NumBits = 32 - numBits;
65 return result;
66 }
67 };
68
69 class CBenchRandomGenerator
70 {
71 CBitRandomGenerator RG;
72 UInt32 Pos;
73 UInt32 Rep0;
74 public:
75 UInt32 BufferSize;
76 Byte *Buffer;
77 CBenchRandomGenerator(): Buffer(0) {}
78 ~CBenchRandomGenerator() { Free(); }
79 void Free()
80 {
81 ::MidFree(Buffer);
82 Buffer = 0;
83 }
84 bool Alloc(UInt32 bufferSize)
85 {
86 if (Buffer != 0 && BufferSize == bufferSize)
87 return true;
88 Free();
89 Buffer = (Byte *)::MidAlloc(bufferSize);
90 Pos = 0;
91 BufferSize = bufferSize;
92 return (Buffer != 0);
93 }
94 UInt32 GetRndBit() { return RG.GetRnd(1); }
95 /*
96 UInt32 GetLogRand(int maxLen)
97 {
98 UInt32 len = GetRnd() % (maxLen + 1);
99 return GetRnd() & ((1 << len) - 1);
100 }
101 */
102 UInt32 GetLogRandBits(int numBits)
103 {
104 UInt32 len = RG.GetRnd(numBits);
105 return RG.GetRnd(len);
106 }
107 UInt32 GetOffset()
108 {
109 if (GetRndBit() == 0)
110 return GetLogRandBits(4);
111 return (GetLogRandBits(4) << 10) | RG.GetRnd(10);
112 }
113 UInt32 GetLen1() { return RG.GetRnd(1 + (int)RG.GetRnd(2)); }
114 UInt32 GetLen2() { return RG.GetRnd(2 + (int)RG.GetRnd(2)); }
115 void Generate()
116 {
117 RG.Init();
118 Rep0 = 1;
119 while(Pos < BufferSize)
120 {
121 if (GetRndBit() == 0 || Pos < 1)
122 Buffer[Pos++] = (Byte)RG.GetRnd(8);
123 else
124 {
125 UInt32 len;
126 if (RG.GetRnd(3) == 0)
127 len = 1 + GetLen1();
128 else
129 {
130 do
131 Rep0 = GetOffset();
132 while (Rep0 >= Pos);
133 Rep0++;
134 len = 2 + GetLen2();
135 }
136 for (UInt32 i = 0; i < len && Pos < BufferSize; i++, Pos++)
137 Buffer[Pos] = Buffer[Pos - Rep0];
138 }
139 }
140 }
141 };
142
143 class CBenchmarkInStream:
144 public ISequentialInStream,
145 public CMyUnknownImp
146 {
147 const Byte *Data;
148 UInt32 Pos;
149 UInt32 Size;
150 public:
151 MY_UNKNOWN_IMP
152 void Init(const Byte *data, UInt32 size)
153 {
154 Data = data;
155 Size = size;
156 Pos = 0;
157 }
158 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
159 };
160
161 STDMETHODIMP CBenchmarkInStream::Read(void *data, UInt32 size, UInt32 *processedSize)
162 {
163 UInt32 remain = Size - Pos;
164 if (size > remain)
165 size = remain;
166 for (UInt32 i = 0; i < size; i++)
167 ((Byte *)data)[i] = Data[Pos + i];
168 Pos += size;
169 if(processedSize != NULL)
170 *processedSize = size;
171 return S_OK;
172 }
173
174 class CBenchmarkOutStream:
175 public ISequentialOutStream,
176 public CMyUnknownImp
177 {
178 UInt32 BufferSize;
179 FILE *_f;
180 public:
181 UInt32 Pos;
182 Byte *Buffer;
183 CBenchmarkOutStream(): _f(0), Buffer(0) {}
184 virtual ~CBenchmarkOutStream() { delete []Buffer; }
185 void Init(FILE *f, UInt32 bufferSize)
186 {
187 delete []Buffer;
188 Buffer = 0;
189 Buffer = new Byte[bufferSize];
190 Pos = 0;
191 BufferSize = bufferSize;
192 _f = f;
193 }
194 MY_UNKNOWN_IMP
195 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
196 };
197
198 STDMETHODIMP CBenchmarkOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
199 {
200 UInt32 i;
201 for (i = 0; i < size && Pos < BufferSize; i++)
202 Buffer[Pos++] = ((const Byte *)data)[i];
203 if(processedSize != NULL)
204 *processedSize = i;
205 if (i != size)
206 {
207 fprintf(_f, "\nERROR: Buffer is full\n");
208 return E_FAIL;
209 }
210 return S_OK;
211 }
212
213 class CCrcOutStream:
214 public ISequentialOutStream,
215 public CMyUnknownImp
216 {
217 public:
218 CCRC CRC;
219 MY_UNKNOWN_IMP
220 void Init() { CRC.Init(); }
221 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
222 };
223
224 STDMETHODIMP CCrcOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
225 {
226 CRC.Update(data, size);
227 if(processedSize != NULL)
228 *processedSize = size;
229 return S_OK;
230 }
231
232 static UInt64 GetTimeCount()
233 {
234 #ifdef _WIN32
235 LARGE_INTEGER value;
236 if (::QueryPerformanceCounter(&value))
237 return value.QuadPart;
238 return GetTickCount();
239 #else
240 return clock();
241 #endif
242 }
243
244 static UInt64 GetFreq()
245 {
246 #ifdef _WIN32
247 LARGE_INTEGER value;
248 if (::QueryPerformanceFrequency(&value))
249 return value.QuadPart;
250 return 1000;
251 #else
252 return CLOCKS_PER_SEC;
253 #endif
254 }
255
256 struct CProgressInfo:
257 public ICompressProgressInfo,
258 public CMyUnknownImp
259 {
260 UInt64 ApprovedStart;
261 UInt64 InSize;
262 UInt64 Time;
263 void Init()
264 {
265 InSize = 0;
266 Time = 0;
267 }
268 MY_UNKNOWN_IMP
269 STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
270 };
271
272 STDMETHODIMP CProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize)
273 {
274 if (*inSize >= ApprovedStart && InSize == 0)
275 {
276 Time = ::GetTimeCount();
277 InSize = *inSize;
278 }
279 return S_OK;
280 }
281
282 static const int kSubBits = 8;
283
284 static UInt32 GetLogSize(UInt32 size)
285 {
286 for (int i = kSubBits; i < 32; i++)
287 for (UInt32 j = 0; j < (1 << kSubBits); j++)
288 if (size <= (((UInt32)1) << i) + (j << (i - kSubBits)))
289 return (i << kSubBits) + j;
290 return (32 << kSubBits);
291 }
292
293 static UInt64 MyMultDiv64(UInt64 value, UInt64 elapsedTime)
294 {
295 UInt64 freq = GetFreq();
296 UInt64 elTime = elapsedTime;
297 while(freq > 1000000)
298 {
299 freq >>= 1;
300 elTime >>= 1;
301 }
302 if (elTime == 0)
303 elTime = 1;
304 return value * freq / elTime;
305 }
306
307 static UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 size)
308 {
309 UInt64 t = GetLogSize(dictionarySize) - (18 << kSubBits);
310 UInt64 numCommandsForOne = 1060 + ((t * t * 10) >> (2 * kSubBits));
311 UInt64 numCommands = (UInt64)(size) * numCommandsForOne;
312 return MyMultDiv64(numCommands, elapsedTime);
313 }
314
315 static UInt64 GetDecompressRating(UInt64 elapsedTime,
316 UInt64 outSize, UInt64 inSize)
317 {
318 UInt64 numCommands = inSize * 220 + outSize * 20;
319 return MyMultDiv64(numCommands, elapsedTime);
320 }
321
322 /*
323 static UInt64 GetTotalRating(
324 UInt32 dictionarySize,
325 bool isBT4,
326 UInt64 elapsedTimeEn, UInt64 sizeEn,
327 UInt64 elapsedTimeDe,
328 UInt64 inSizeDe, UInt64 outSizeDe)
329 {
330 return (GetCompressRating(dictionarySize, isBT4, elapsedTimeEn, sizeEn) +
331 GetDecompressRating(elapsedTimeDe, inSizeDe, outSizeDe)) / 2;
332 }
333 */
334
335 static void PrintRating(FILE *f, UInt64 rating)
336 {
337 fprintf(f, "%5d MIPS", (unsigned int)(rating / 1000000));
338 }
339
340 static void PrintResults(
341 FILE *f,
342 UInt32 dictionarySize,
343 UInt64 elapsedTime,
344 UInt64 size,
345 bool decompressMode, UInt64 secondSize)
346 {
347 UInt64 speed = MyMultDiv64(size, elapsedTime);
348 fprintf(f, "%6d KB/s ", (unsigned int)(speed / 1024));
349 UInt64 rating;
350 if (decompressMode)
351 rating = GetDecompressRating(elapsedTime, size, secondSize);
352 else
353 rating = GetCompressRating(dictionarySize, elapsedTime, size);
354 PrintRating(f, rating);
355 }
356
357 static void ThrowError(FILE *f, HRESULT result, const char *s)
358 {
359 fprintf(f, "\nError: ");
360 if (result == E_ABORT)
361 fprintf(f, "User break");
362 if (result == E_OUTOFMEMORY)
363 fprintf(f, "Can not allocate memory");
364 else
365 fputs(s,f);
366 fprintf(f, "\n");
367 }
368
369 const wchar_t *bt2 = L"BT2";
370 const wchar_t *bt4 = L"BT4";
371
372 int LzmaBenchmark(FILE *f, UInt32 numIterations, UInt32 dictionarySize)
373 {
374 if (numIterations == 0)
375 return 0;
376 if (dictionarySize < (1 << 18))
377 {
378 fprintf(f, "\nError: dictionary size for benchmark must be >= 19 (512 KB)\n");
379 return 1;
380 }
381 fprintf(f, "\n Compressing Decompressing\n\n");
382 NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
383 CMyComPtr<ICompressCoder> encoder = encoderSpec;
384
385 NCompress::NLZMA::CDecoder *decoderSpec = new NCompress::NLZMA::CDecoder;
386 CMyComPtr<ICompressCoder> decoder = decoderSpec;
387
388 CBenchmarkOutStream *propStreamSpec = new CBenchmarkOutStream;
389 CMyComPtr<ISequentialOutStream> propStream = propStreamSpec;
390 propStreamSpec->Init(f, kMaxLzmaPropSize);
391
392 PROPID propIDs[] =
393 {
394 NCoderPropID::kDictionarySize
395 };
396 const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
397 PROPVARIANT properties[kNumProps];
398 properties[0].vt = VT_UI4;
399 properties[0].ulVal = UInt32(dictionarySize);
400
401 const UInt32 kBufferSize = dictionarySize + kAdditionalSize;
402 const UInt32 kCompressedBufferSize = (kBufferSize / 2) + kCompressedAdditionalSize;
403
404 if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
405 {
406 fprintf(f, "\nError: Incorrect command\n");
407 return 1;
408 }
409 encoderSpec->WriteCoderProperties(propStream);
410
411 CBenchRandomGenerator rg;
412 if (!rg.Alloc(kBufferSize))
413 {
414 fprintf(f, "\nError: Can't allocate memory\n");
415 return 1;
416 }
417
418 rg.Generate();
419 CCRC crc;
420 crc.Update(rg.Buffer, rg.BufferSize);
421
422 CProgressInfo *progressInfoSpec = new CProgressInfo;
423 CMyComPtr<ICompressProgressInfo> progressInfo = progressInfoSpec;
424
425 progressInfoSpec->ApprovedStart = dictionarySize;
426
427 UInt64 totalBenchSize = 0;
428 UInt64 totalEncodeTime = 0;
429 UInt64 totalDecodeTime = 0;
430 UInt64 totalCompressedSize = 0;
431
432 for (UInt32 i = 0; i < numIterations; i++)
433 {
434 progressInfoSpec->Init();
435 CBenchmarkInStream *inStreamSpec = new CBenchmarkInStream;
436 inStreamSpec->Init(rg.Buffer, rg.BufferSize);
437 CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
438 CBenchmarkOutStream *outStreamSpec = new CBenchmarkOutStream;
439 outStreamSpec->Init(f, kCompressedBufferSize);
440 CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
441 HRESULT result = encoder->Code(inStream, outStream, 0, 0, progressInfo);
442 UInt64 encodeTime = ::GetTimeCount() - progressInfoSpec->Time;
443 UInt32 compressedSize = outStreamSpec->Pos;
444 if(result != S_OK)
445 {
446 ThrowError(f, result, "Encoder Error");
447 return 1;
448 }
449 if (progressInfoSpec->InSize == 0)
450 {
451 fprintf(f, "\nError: Internal ERROR 1282\n");
452 return 1;
453 }
454
455 ///////////////////////
456 // Decompressing
457
458 CCrcOutStream *crcOutStreamSpec = new CCrcOutStream;
459 CMyComPtr<ISequentialOutStream> crcOutStream = crcOutStreamSpec;
460
461 UInt64 decodeTime;
462 for (int j = 0; j < 2; j++)
463 {
464 inStreamSpec->Init(outStreamSpec->Buffer, compressedSize);
465 crcOutStreamSpec->Init();
466
467 if (decoderSpec->SetDecoderProperties2(propStreamSpec->Buffer, propStreamSpec->Pos) != S_OK)
468 {
469 fprintf(f, "\nError: Set Decoder Properties Error\n");
470 return 1;
471 }
472 UInt64 outSize = kBufferSize;
473 UInt64 startTime = ::GetTimeCount();
474 result = decoder->Code(inStream, crcOutStream, 0, &outSize, 0);
475 decodeTime = ::GetTimeCount() - startTime;
476 if(result != S_OK)
477 {
478 ThrowError(f, result, "Decode Error");
479 return 1;
480 }
481 if (crcOutStreamSpec->CRC.GetDigest() != crc.GetDigest())
482 {
483 fprintf(f, "\nError: CRC Error\n");
484 return 1;
485 }
486 }
487 UInt64 benchSize = kBufferSize - progressInfoSpec->InSize;
488 PrintResults(f, dictionarySize, encodeTime, benchSize, false, 0);
489 fprintf(f, " ");
490 PrintResults(f, dictionarySize, decodeTime, kBufferSize, true, compressedSize);
491 fprintf(f, "\n");
492
493 totalBenchSize += benchSize;
494 totalEncodeTime += encodeTime;
495 totalDecodeTime += decodeTime;
496 totalCompressedSize += compressedSize;
497 }
498 fprintf(f, "---------------------------------------------------\n");
499 PrintResults(f, dictionarySize, totalEncodeTime, totalBenchSize, false, 0);
500 fprintf(f, " ");
501 PrintResults(f, dictionarySize, totalDecodeTime,
502 kBufferSize * numIterations, true, totalCompressedSize);
503 fprintf(f, " Average\n");
504 return 0;
505 }
0 // LzmaBench.h
1
2 #ifndef __LzmaBench_h
3 #define __LzmaBench_h
4
5 #include <stdio.h>
6 #include "../../../Common/Types.h"
7
8 int LzmaBenchmark(FILE *f, UInt32 numIterations, UInt32 dictionarySize);
9
10 #endif
0 // LzmaRam.cpp
1
2 #include "StdAfx.h"
3 #include "../../../Common/Types.h"
4 #include "../LZMA/LZMADecoder.h"
5 #include "../LZMA/LZMAEncoder.h"
6 #include "LzmaRam.h"
7
8 extern "C"
9 {
10 #include "../Branch/BranchX86.h"
11 }
12
13 class CInStreamRam:
14 public ISequentialInStream,
15 public CMyUnknownImp
16 {
17 const Byte *Data;
18 size_t Size;
19 size_t Pos;
20 public:
21 MY_UNKNOWN_IMP
22 void Init(const Byte *data, size_t size)
23 {
24 Data = data;
25 Size = size;
26 Pos = 0;
27 }
28 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
29 };
30
31 STDMETHODIMP CInStreamRam::Read(void *data, UInt32 size, UInt32 *processedSize)
32 {
33 UInt32 remain = Size - Pos;
34 if (size > remain)
35 size = remain;
36 for (UInt32 i = 0; i < size; i++)
37 ((Byte *)data)[i] = Data[Pos + i];
38 Pos += size;
39 if(processedSize != NULL)
40 *processedSize = size;
41 return S_OK;
42 }
43
44 class COutStreamRam:
45 public ISequentialOutStream,
46 public CMyUnknownImp
47 {
48 size_t Size;
49 public:
50 Byte *Data;
51 size_t Pos;
52 bool Overflow;
53 void Init(Byte *data, size_t size)
54 {
55 Data = data;
56 Size = size;
57 Pos = 0;
58 Overflow = false;
59 }
60 void SetPos(size_t pos)
61 {
62 Overflow = false;
63 Pos = pos;
64 }
65 MY_UNKNOWN_IMP
66 HRESULT WriteByte(Byte b)
67 {
68 if (Pos >= Size)
69 {
70 Overflow = true;
71 return E_FAIL;
72 }
73 Data[Pos++] = b;
74 return S_OK;
75 }
76 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
77 };
78
79 STDMETHODIMP COutStreamRam::Write(const void *data, UInt32 size, UInt32 *processedSize)
80 {
81 UInt32 i;
82 for (i = 0; i < size && Pos < Size; i++)
83 Data[Pos++] = ((const Byte *)data)[i];
84 if(processedSize != NULL)
85 *processedSize = i;
86 if (i != size)
87 {
88 Overflow = true;
89 return E_FAIL;
90 }
91 return S_OK;
92 }
93
94 #define SZE_FAIL (1)
95 #define SZE_OUTOFMEMORY (2)
96 #define SZE_OUT_OVERFLOW (3)
97
98 int LzmaRamEncode(
99 const Byte *inBuffer, size_t inSize,
100 Byte *outBuffer, size_t outSize, size_t *outSizeProcessed,
101 UInt32 dictionarySize, ESzFilterMode filterMode)
102 {
103 #ifndef _NO_EXCEPTIONS
104 try {
105 #endif
106
107 *outSizeProcessed = 0;
108 const size_t kIdSize = 1;
109 const size_t kLzmaPropsSize = 5;
110 const size_t kMinDestSize = kIdSize + kLzmaPropsSize + 8;
111 if (outSize < kMinDestSize)
112 return SZE_OUT_OVERFLOW;
113 NCompress::NLZMA::CEncoder *encoderSpec = new NCompress::NLZMA::CEncoder;
114 CMyComPtr<ICompressCoder> encoder = encoderSpec;
115
116 PROPID propIDs[] =
117 {
118 NCoderPropID::kAlgorithm,
119 NCoderPropID::kDictionarySize,
120 NCoderPropID::kNumFastBytes,
121 };
122 const int kNumProps = sizeof(propIDs) / sizeof(propIDs[0]);
123 PROPVARIANT properties[kNumProps];
124 properties[0].vt = VT_UI4;
125 properties[1].vt = VT_UI4;
126 properties[2].vt = VT_UI4;
127 properties[0].ulVal = (UInt32)2;
128 properties[1].ulVal = (UInt32)dictionarySize;
129 properties[2].ulVal = (UInt32)64;
130
131 if (encoderSpec->SetCoderProperties(propIDs, properties, kNumProps) != S_OK)
132 return 1;
133
134 COutStreamRam *outStreamSpec = new COutStreamRam;
135 if (outStreamSpec == 0)
136 return SZE_OUTOFMEMORY;
137 CMyComPtr<ISequentialOutStream> outStream = outStreamSpec;
138 CInStreamRam *inStreamSpec = new CInStreamRam;
139 if (inStreamSpec == 0)
140 return SZE_OUTOFMEMORY;
141 CMyComPtr<ISequentialInStream> inStream = inStreamSpec;
142
143 outStreamSpec->Init(outBuffer, outSize);
144 if (outStreamSpec->WriteByte(0) != S_OK)
145 return SZE_OUT_OVERFLOW;
146
147 if (encoderSpec->WriteCoderProperties(outStream) != S_OK)
148 return SZE_OUT_OVERFLOW;
149 if (outStreamSpec->Pos != kIdSize + kLzmaPropsSize)
150 return 1;
151
152 int i;
153 for (i = 0; i < 8; i++)
154 {
155 UInt64 t = (UInt64)(inSize);
156 if (outStreamSpec->WriteByte((Byte)((t) >> (8 * i))) != S_OK)
157 return SZE_OUT_OVERFLOW;
158 }
159
160 Byte *filteredStream = 0;
161
162 bool useFilter = (filterMode != SZ_FILTER_NO);
163 if (useFilter)
164 {
165 if (inSize != 0)
166 {
167 filteredStream = (Byte *)MyAlloc(inSize);
168 if (filteredStream == 0)
169 return SZE_OUTOFMEMORY;
170 memmove(filteredStream, inBuffer, inSize);
171 }
172 UInt32 _prevMask;
173 UInt32 _prevPos;
174 x86_Convert_Init(_prevMask, _prevPos);
175 x86_Convert(filteredStream, (UInt32)inSize, 0, &_prevMask, &_prevPos, 1);
176 }
177
178 UInt32 minSize = 0;
179 int numPasses = (filterMode == SZ_FILTER_AUTO) ? 3 : 1;
180 bool bestIsFiltered = false;
181 int mainResult = 0;
182 size_t startPos = outStreamSpec->Pos;
183 for (i = 0; i < numPasses; i++)
184 {
185 if (numPasses > 1 && i == numPasses - 1 && !bestIsFiltered)
186 break;
187 outStreamSpec->SetPos(startPos);
188 bool curModeIsFiltered = false;
189 if (useFilter && i == 0)
190 curModeIsFiltered = true;
191 if (numPasses > 1 && i == numPasses - 1)
192 curModeIsFiltered = true;
193
194 inStreamSpec->Init(curModeIsFiltered ? filteredStream : inBuffer, inSize);
195
196 HRESULT lzmaResult = encoder->Code(inStream, outStream, 0, 0, 0);
197
198 mainResult = 0;
199 if (lzmaResult == E_OUTOFMEMORY)
200 {
201 mainResult = SZE_OUTOFMEMORY;
202 break;
203 }
204 if (i == 0 || outStreamSpec->Pos <= minSize)
205 {
206 minSize = outStreamSpec->Pos;
207 bestIsFiltered = curModeIsFiltered;
208 }
209 if (outStreamSpec->Overflow)
210 mainResult = SZE_OUT_OVERFLOW;
211 else if (lzmaResult != S_OK)
212 {
213 mainResult = SZE_FAIL;
214 break;
215 }
216 }
217 *outSizeProcessed = outStreamSpec->Pos;
218 if (bestIsFiltered)
219 outBuffer[0] = 1;
220 if (useFilter)
221 MyFree(filteredStream);
222 return mainResult;
223
224 #ifndef _NO_EXCEPTIONS
225 } catch(...) { return SZE_OUTOFMEMORY; }
226 #endif
227 }
0 // LzmaRam.h
1
2 #ifndef __LzmaRam_h
3 #define __LzmaRam_h
4
5 #include <stdlib.h>
6 #include "../../../Common/Types.h"
7
8 /*
9 LzmaRamEncode: BCJ + LZMA RAM->RAM compressing.
10 It uses .lzma format, but it writes one additional byte to .lzma file:
11 0: - no filter
12 1: - x86(BCJ) filter.
13
14 To provide best compression ratio dictionarySize mustbe >= inSize
15
16 LzmaRamEncode allocates Data with MyAlloc/BigAlloc functions.
17 RAM Requirements:
18 RamSize = dictionarySize * 9.5 + 6MB + FilterBlockSize
19 FilterBlockSize = 0, if useFilter == false
20 FilterBlockSize = inSize, if useFilter == true
21
22 Return code:
23 0 - OK
24 1 - Unspecified Error
25 2 - Memory allocating error
26 3 - Output buffer OVERFLOW
27
28 If you use SZ_FILTER_AUTO mode, then encoder will use 2 or 3 passes:
29 2 passes when FILTER_NO provides better compression.
30 3 passes when FILTER_YES provides better compression.
31 */
32
33 enum ESzFilterMode
34 {
35 SZ_FILTER_NO,
36 SZ_FILTER_YES,
37 SZ_FILTER_AUTO
38 };
39
40 int LzmaRamEncode(
41 const Byte *inBuffer, size_t inSize,
42 Byte *outBuffer, size_t outSize, size_t *outSizeProcessed,
43 UInt32 dictionarySize, ESzFilterMode filterMode);
44
45 #endif
0 /* LzmaRamDecode.c */
1
2 #include "LzmaRamDecode.h"
3 #ifdef _SZ_ONE_DIRECTORY
4 #include "LzmaDecode.h"
5 #include "BranchX86.h"
6 #else
7 #include "../LZMA_C/LzmaDecode.h"
8 #include "../Branch/BranchX86.h"
9 #endif
10
11 #define LZMA_PROPS_SIZE 14
12 #define LZMA_SIZE_OFFSET 6
13
14 int LzmaRamGetUncompressedSize(
15 const unsigned char *inBuffer,
16 size_t inSize,
17 size_t *outSize)
18 {
19 unsigned int i;
20 if (inSize < LZMA_PROPS_SIZE)
21 return 1;
22 *outSize = 0;
23 for(i = 0; i < sizeof(size_t); i++)
24 *outSize += ((size_t)inBuffer[LZMA_SIZE_OFFSET + i]) << (8 * i);
25 for(; i < 8; i++)
26 if (inBuffer[LZMA_SIZE_OFFSET + i] != 0)
27 return 1;
28 return 0;
29 }
30
31 #define SZE_DATA_ERROR (1)
32 #define SZE_OUTOFMEMORY (2)
33
34 int LzmaRamDecompress(
35 const unsigned char *inBuffer,
36 size_t inSize,
37 unsigned char *outBuffer,
38 size_t outSize,
39 size_t *outSizeProcessed,
40 void * (*allocFunc)(size_t size),
41 void (*freeFunc)(void *))
42 {
43 CLzmaDecoderState state; /* it's about 24 bytes structure, if int is 32-bit */
44 int result;
45 SizeT outSizeProcessedLoc;
46 SizeT inProcessed;
47 int useFilter;
48
49 if (inSize < LZMA_PROPS_SIZE)
50 return 1;
51 useFilter = inBuffer[0];
52
53 *outSizeProcessed = 0;
54 if (useFilter > 1)
55 return 1;
56
57 if (LzmaDecodeProperties(&state.Properties, inBuffer + 1, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
58 return 1;
59 state.Probs = (CProb *)allocFunc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
60 if (state.Probs == 0)
61 return SZE_OUTOFMEMORY;
62
63 result = LzmaDecode(&state,
64 inBuffer + LZMA_PROPS_SIZE, (SizeT)inSize - LZMA_PROPS_SIZE, &inProcessed,
65 outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
66 freeFunc(state.Probs);
67 if (result != LZMA_RESULT_OK)
68 return 1;
69 *outSizeProcessed = (size_t)outSizeProcessedLoc;
70 if (useFilter == 1)
71 {
72 UInt32 _prevMask;
73 UInt32 _prevPos;
74 x86_Convert_Init(_prevMask, _prevPos);
75 x86_Convert(outBuffer, (UInt32)outSizeProcessedLoc, 0, &_prevMask, &_prevPos, 0);
76 }
77 return 0;
78 }
0 /* LzmaRamDecode.h */
1
2 #ifndef __LzmaRamDecode_h
3 #define __LzmaRamDecode_h
4
5 #include <stdlib.h>
6
7 /*
8 LzmaRamGetUncompressedSize:
9 In:
10 inBuffer - input data
11 inSize - input data size
12 Out:
13 outSize - uncompressed size
14 Return code:
15 0 - OK
16 1 - Error in headers
17 */
18
19 int LzmaRamGetUncompressedSize(
20 const unsigned char *inBuffer,
21 size_t inSize,
22 size_t *outSize);
23
24
25 /*
26 LzmaRamDecompress:
27 In:
28 inBuffer - input data
29 inSize - input data size
30 outBuffer - output data
31 outSize - output size
32 allocFunc - alloc function (can be malloc)
33 freeFunc - free function (can be free)
34 Out:
35 outSizeProcessed - processed size
36 Return code:
37 0 - OK
38 1 - Error in headers / data stream
39 2 - Memory allocating error
40
41 Memory requirements depend from properties of LZMA stream.
42 With default lzma settings it's about 16 KB.
43 */
44
45 int LzmaRamDecompress(
46 const unsigned char *inBuffer,
47 size_t inSize,
48 unsigned char *outBuffer,
49 size_t outSize,
50 size_t *outSizeProcessed,
51 void * (*allocFunc)(size_t size),
52 void (*freeFunc)(void *));
53
54 #endif
0 // StdAfx.cpp
1
2 #include "StdAfx.h"
0 // StdAfx.h
1
2 #ifndef __STDAFX_H
3 #define __STDAFX_H
4
5 #include "../../../Common/MyWindows.h"
6
7 #endif
0 PROG = lzma.exe
1 CFLAGS = $(CFLAGS) -I ../../../
2 LIBS = $(LIBS) oleaut32.lib user32.lib
3
4 !IFNDEF O
5 !IFDEF CPU
6 O=$(CPU)
7 !ELSE
8 O=O
9 !ENDIF
10 !ENDIF
11
12 CFLAGS = $(CFLAGS) -nologo -EHsc -c -Fo$O/ -GS-
13 CFLAGS_O1 = $(CFLAGS) -O1
14 CFLAGS_O2 = $(CFLAGS) -O2
15
16 LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98
17
18 PROGPATH = $O\$(PROG)
19
20 COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
21 COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
22 COMPL = $(CPP) $(CFLAGS_O1) $**
23
24
25 LZMA_OBJS = \
26 $O\LzmaAlone.obj \
27 $O\LzmaBench.obj \
28 $O\LzmaRam.obj \
29
30 LZMA_OPT_OBJS = \
31 $O\LZMADecoder.obj \
32 $O\LZMAEncoder.obj \
33
34 COMMON_OBJS = \
35 $O\Alloc.obj \
36 $O\CRC.obj \
37 $O\CommandLineParser.obj \
38 $O\String.obj \
39 $O\StringConvert.obj \
40 $O\StringToInt.obj \
41 $O\Vector.obj
42
43 7ZIP_COMMON_OBJS = \
44 $O\InBuffer.obj \
45 $O\OutBuffer.obj \
46 $O\StreamUtils.obj \
47
48 LZ_OBJS = \
49 $O\LZInWindow.obj \
50 $O\LZOutWindow.obj \
51
52
53 OBJS = \
54 $(LZMA_OBJS) \
55 $(LZMA_OPT_OBJS) \
56 $(COMMON_OBJS) \
57 $(7ZIP_COMMON_OBJS) \
58 $(LZ_OBJS) \
59 $O\LzmaRamDecode.obj \
60 $O\LzmaDecode.obj \
61 $O\FileStreams.obj \
62 $O\FileIO.obj \
63 $O\RangeCoderBit.obj \
64 $O\BranchX86.obj \
65
66 all: $(PROGPATH)
67
68 clean:
69 -del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch
70
71 $O:
72 if not exist "$O" mkdir "$O"
73
74 $(PROGPATH): $O $(OBJS)
75 link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)
76
77
78 $(LZMA_OBJS): $(*B).cpp
79 $(COMPL)
80 $(LZMA_OPT_OBJS): ../LZMA/$(*B).cpp
81 $(COMPL_O2)
82 $(COMMON_OBJS): ../../../Common/$(*B).cpp
83 $(COMPL)
84 $(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp
85 $(COMPL)
86 $(LZ_OBJS): ../LZ/$(*B).cpp
87 $(COMPL)
88 $O\RangeCoderBit.obj: ../RangeCoder/$(*B).cpp
89 $(COMPL)
90 $O\LzmaRamDecode.obj: LzmaRamDecode.c
91 $(COMPL_O1)
92 $O\LzmaDecode.obj: ../LZMA_C/LzmaDecode.c
93 $(COMPL_O2)
94 $O\BranchX86.obj: ../Branch/BranchX86.c
95 $(COMPL_O2)
96 $O\FileStreams.obj: ../../Common/FileStreams.cpp
97 $(COMPL)
98 $O\FileIO.obj: ../../../Windows/FileIO.cpp
99 $(COMPL)
0 PROG = lzma
1 CXX = g++ -O2 -Wall
2 CXX_C = gcc -O2 -Wall
3 LIB = -lm
4 RM = rm -f
5 CFLAGS = -c -I ../../../
6
7 OBJS = \
8 LzmaAlone.o \
9 LzmaBench.o \
10 LzmaRam.o \
11 LzmaRamDecode.o \
12 LzmaDecode.o \
13 BranchX86.o \
14 LZMADecoder.o \
15 LZMAEncoder.o \
16 LZInWindow.o \
17 LZOutWindow.o \
18 RangeCoderBit.o \
19 InBuffer.o \
20 OutBuffer.o \
21 FileStreams.o \
22 StreamUtils.o \
23 Alloc.o \
24 C_FileIO.o \
25 CommandLineParser.o \
26 CRC.o \
27 String.o \
28 StringConvert.o \
29 StringToInt.o \
30 Vector.o \
31
32
33 all: $(PROG)
34
35 $(PROG): $(OBJS)
36 $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
37
38 LzmaAlone.o: LzmaAlone.cpp
39 $(CXX) $(CFLAGS) LzmaAlone.cpp
40
41 LzmaBench.o: LzmaBench.cpp
42 $(CXX) $(CFLAGS) LzmaBench.cpp
43
44 LzmaRam.o: LzmaRam.cpp
45 $(CXX) $(CFLAGS) LzmaRam.cpp
46
47 LzmaRamDecode.o: LzmaRamDecode.c
48 $(CXX_C) $(CFLAGS) LzmaRamDecode.c
49
50 LzmaDecode.o: ../LZMA_C/LzmaDecode.c
51 $(CXX_C) $(CFLAGS) ../LZMA_C/LzmaDecode.c
52
53 BranchX86.o: ../Branch/BranchX86.c
54 $(CXX_C) $(CFLAGS) ../Branch/BranchX86.c
55
56 LZMADecoder.o: ../LZMA/LZMADecoder.cpp
57 $(CXX) $(CFLAGS) ../LZMA/LZMADecoder.cpp
58
59 LZMAEncoder.o: ../LZMA/LZMAEncoder.cpp
60 $(CXX) $(CFLAGS) ../LZMA/LZMAEncoder.cpp
61
62 LZInWindow.o: ../LZ/LZInWindow.cpp
63 $(CXX) $(CFLAGS) ../LZ/LZInWindow.cpp
64
65 LZOutWindow.o: ../LZ/LZOutWindow.cpp
66 $(CXX) $(CFLAGS) ../LZ/LZOutWindow.cpp
67
68 RangeCoderBit.o: ../RangeCoder/RangeCoderBit.cpp
69 $(CXX) $(CFLAGS) ../RangeCoder/RangeCoderBit.cpp
70
71 InBuffer.o: ../../Common/InBuffer.cpp
72 $(CXX) $(CFLAGS) ../../Common/InBuffer.cpp
73
74 OutBuffer.o: ../../Common/OutBuffer.cpp
75 $(CXX) $(CFLAGS) ../../Common/OutBuffer.cpp
76
77 FileStreams.o: ../../Common/FileStreams.cpp
78 $(CXX) $(CFLAGS) ../../Common/FileStreams.cpp
79
80 StreamUtils.o: ../../Common/StreamUtils.cpp
81 $(CXX) $(CFLAGS) ../../Common/StreamUtils.cpp
82
83 Alloc.o: ../../../Common/Alloc.cpp
84 $(CXX) $(CFLAGS) ../../../Common/Alloc.cpp
85
86 C_FileIO.o: ../../../Common/C_FileIO.cpp
87 $(CXX) $(CFLAGS) ../../../Common/C_FileIO.cpp
88
89 CommandLineParser.o: ../../../Common/CommandLineParser.cpp
90 $(CXX) $(CFLAGS) ../../../Common/CommandLineParser.cpp
91
92 CRC.o: ../../../Common/CRC.cpp
93 $(CXX) $(CFLAGS) ../../../Common/CRC.cpp
94
95 MyWindows.o: ../../../Common/MyWindows.cpp
96 $(CXX) $(CFLAGS) ../../../Common/MyWindows.cpp
97
98 String.o: ../../../Common/String.cpp
99 $(CXX) $(CFLAGS) ../../../Common/String.cpp
100
101 StringConvert.o: ../../../Common/StringConvert.cpp
102 $(CXX) $(CFLAGS) ../../../Common/StringConvert.cpp
103
104 StringToInt.o: ../../../Common/StringToInt.cpp
105 $(CXX) $(CFLAGS) ../../../Common/StringToInt.cpp
106
107 Vector.o: ../../../Common/Vector.cpp
108 $(CXX) $(CFLAGS) ../../../Common/Vector.cpp
109
110 clean:
111 -$(RM) $(PROG) $(OBJS)
112
0 /*
1 LzmaDecode.c
2 LZMA Decoder (optimized for Speed version)
3
4 LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
5 http://www.7-zip.org/
6
7 LZMA SDK is licensed under two licenses:
8 1) GNU Lesser General Public License (GNU LGPL)
9 2) Common Public License (CPL)
10 It means that you can select one of these two licenses and
11 follow rules of that license.
12
13 SPECIAL EXCEPTION:
14 Igor Pavlov, as the author of this Code, expressly permits you to
15 statically or dynamically link your Code (or bind by name) to the
16 interfaces of this file without subjecting your linked Code to the
17 terms of the CPL or GNU LGPL. Any modifications or additions
18 to this file, however, are subject to the LGPL or CPL terms.
19 */
20
21 #include "LzmaDecode.h"
22
23 #define kNumTopBits 24
24 #define kTopValue ((UInt32)1 << kNumTopBits)
25
26 #define kNumBitModelTotalBits 11
27 #define kBitModelTotal (1 << kNumBitModelTotalBits)
28 #define kNumMoveBits 5
29
30 #define RC_READ_BYTE (*Buffer++)
31
32 #define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
33 { int i; for(i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
34
35 #ifdef _LZMA_IN_CB
36
37 #define RC_TEST { if (Buffer == BufferLim) \
38 { SizeT size; int result = InCallback->Read(InCallback, &Buffer, &size); if (result != LZMA_RESULT_OK) return result; \
39 BufferLim = Buffer + size; if (size == 0) return LZMA_RESULT_DATA_ERROR; }}
40
41 #define RC_INIT Buffer = BufferLim = 0; RC_INIT2
42
43 #else
44
45 #define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
46
47 #define RC_INIT(buffer, bufferSize) Buffer = buffer; BufferLim = buffer + bufferSize; RC_INIT2
48
49 #endif
50
51 #define RC_NORMALIZE if (Range < kTopValue) { RC_TEST; Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
52
53 #define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
54 #define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
55 #define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
56
57 #define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
58 { UpdateBit0(p); mi <<= 1; A0; } else \
59 { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
60
61 #define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
62
63 #define RangeDecoderBitTreeDecode(probs, numLevels, res) \
64 { int i = numLevels; res = 1; \
65 do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
66 res -= (1 << numLevels); }
67
68
69 #define kNumPosBitsMax 4
70 #define kNumPosStatesMax (1 << kNumPosBitsMax)
71
72 #define kLenNumLowBits 3
73 #define kLenNumLowSymbols (1 << kLenNumLowBits)
74 #define kLenNumMidBits 3
75 #define kLenNumMidSymbols (1 << kLenNumMidBits)
76 #define kLenNumHighBits 8
77 #define kLenNumHighSymbols (1 << kLenNumHighBits)
78
79 #define LenChoice 0
80 #define LenChoice2 (LenChoice + 1)
81 #define LenLow (LenChoice2 + 1)
82 #define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
83 #define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
84 #define kNumLenProbs (LenHigh + kLenNumHighSymbols)
85
86
87 #define kNumStates 12
88 #define kNumLitStates 7
89
90 #define kStartPosModelIndex 4
91 #define kEndPosModelIndex 14
92 #define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
93
94 #define kNumPosSlotBits 6
95 #define kNumLenToPosStates 4
96
97 #define kNumAlignBits 4
98 #define kAlignTableSize (1 << kNumAlignBits)
99
100 #define kMatchMinLen 2
101
102 #define IsMatch 0
103 #define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
104 #define IsRepG0 (IsRep + kNumStates)
105 #define IsRepG1 (IsRepG0 + kNumStates)
106 #define IsRepG2 (IsRepG1 + kNumStates)
107 #define IsRep0Long (IsRepG2 + kNumStates)
108 #define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
109 #define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
110 #define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
111 #define LenCoder (Align + kAlignTableSize)
112 #define RepLenCoder (LenCoder + kNumLenProbs)
113 #define Literal (RepLenCoder + kNumLenProbs)
114
115 #if Literal != LZMA_BASE_SIZE
116 StopCompilingDueBUG
117 #endif
118
119 int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
120 {
121 unsigned char prop0;
122 if (size < LZMA_PROPERTIES_SIZE)
123 return LZMA_RESULT_DATA_ERROR;
124 prop0 = propsData[0];
125 if (prop0 >= (9 * 5 * 5))
126 return LZMA_RESULT_DATA_ERROR;
127 {
128 for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
129 for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
130 propsRes->lc = prop0;
131 /*
132 unsigned char remainder = (unsigned char)(prop0 / 9);
133 propsRes->lc = prop0 % 9;
134 propsRes->pb = remainder / 5;
135 propsRes->lp = remainder % 5;
136 */
137 }
138
139 #ifdef _LZMA_OUT_READ
140 {
141 int i;
142 propsRes->DictionarySize = 0;
143 for (i = 0; i < 4; i++)
144 propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
145 if (propsRes->DictionarySize == 0)
146 propsRes->DictionarySize = 1;
147 }
148 #endif
149 return LZMA_RESULT_OK;
150 }
151
152 #define kLzmaStreamWasFinishedId (-1)
153
154 int LzmaDecode(CLzmaDecoderState *vs,
155 #ifdef _LZMA_IN_CB
156 ILzmaInCallback *InCallback,
157 #else
158 const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
159 #endif
160 unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
161 {
162 CProb *p = vs->Probs;
163 SizeT nowPos = 0;
164 Byte previousByte = 0;
165 UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
166 UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
167 int lc = vs->Properties.lc;
168
169 #ifdef _LZMA_OUT_READ
170
171 UInt32 Range = vs->Range;
172 UInt32 Code = vs->Code;
173 #ifdef _LZMA_IN_CB
174 const Byte *Buffer = vs->Buffer;
175 const Byte *BufferLim = vs->BufferLim;
176 #else
177 const Byte *Buffer = inStream;
178 const Byte *BufferLim = inStream + inSize;
179 #endif
180 int state = vs->State;
181 UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
182 int len = vs->RemainLen;
183 UInt32 globalPos = vs->GlobalPos;
184 UInt32 distanceLimit = vs->DistanceLimit;
185
186 Byte *dictionary = vs->Dictionary;
187 UInt32 dictionarySize = vs->Properties.DictionarySize;
188 UInt32 dictionaryPos = vs->DictionaryPos;
189
190 Byte tempDictionary[4];
191
192 #ifndef _LZMA_IN_CB
193 *inSizeProcessed = 0;
194 #endif
195 *outSizeProcessed = 0;
196 if (len == kLzmaStreamWasFinishedId)
197 return LZMA_RESULT_OK;
198
199 if (dictionarySize == 0)
200 {
201 dictionary = tempDictionary;
202 dictionarySize = 1;
203 tempDictionary[0] = vs->TempDictionary[0];
204 }
205
206 if (len == kLzmaNeedInitId)
207 {
208 {
209 UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
210 UInt32 i;
211 for (i = 0; i < numProbs; i++)
212 p[i] = kBitModelTotal >> 1;
213 rep0 = rep1 = rep2 = rep3 = 1;
214 state = 0;
215 globalPos = 0;
216 distanceLimit = 0;
217 dictionaryPos = 0;
218 dictionary[dictionarySize - 1] = 0;
219 #ifdef _LZMA_IN_CB
220 RC_INIT;
221 #else
222 RC_INIT(inStream, inSize);
223 #endif
224 }
225 len = 0;
226 }
227 while(len != 0 && nowPos < outSize)
228 {
229 UInt32 pos = dictionaryPos - rep0;
230 if (pos >= dictionarySize)
231 pos += dictionarySize;
232 outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
233 if (++dictionaryPos == dictionarySize)
234 dictionaryPos = 0;
235 len--;
236 }
237 if (dictionaryPos == 0)
238 previousByte = dictionary[dictionarySize - 1];
239 else
240 previousByte = dictionary[dictionaryPos - 1];
241
242 #else /* if !_LZMA_OUT_READ */
243
244 int state = 0;
245 UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
246 int len = 0;
247 const Byte *Buffer;
248 const Byte *BufferLim;
249 UInt32 Range;
250 UInt32 Code;
251
252 #ifndef _LZMA_IN_CB
253 *inSizeProcessed = 0;
254 #endif
255 *outSizeProcessed = 0;
256
257 {
258 UInt32 i;
259 UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
260 for (i = 0; i < numProbs; i++)
261 p[i] = kBitModelTotal >> 1;
262 }
263
264 #ifdef _LZMA_IN_CB
265 RC_INIT;
266 #else
267 RC_INIT(inStream, inSize);
268 #endif
269
270 #endif /* _LZMA_OUT_READ */
271
272 while(nowPos < outSize)
273 {
274 CProb *prob;
275 UInt32 bound;
276 int posState = (int)(
277 (nowPos
278 #ifdef _LZMA_OUT_READ
279 + globalPos
280 #endif
281 )
282 & posStateMask);
283
284 prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
285 IfBit0(prob)
286 {
287 int symbol = 1;
288 UpdateBit0(prob)
289 prob = p + Literal + (LZMA_LIT_SIZE *
290 (((
291 (nowPos
292 #ifdef _LZMA_OUT_READ
293 + globalPos
294 #endif
295 )
296 & literalPosMask) << lc) + (previousByte >> (8 - lc))));
297
298 if (state >= kNumLitStates)
299 {
300 int matchByte;
301 #ifdef _LZMA_OUT_READ
302 UInt32 pos = dictionaryPos - rep0;
303 if (pos >= dictionarySize)
304 pos += dictionarySize;
305 matchByte = dictionary[pos];
306 #else
307 matchByte = outStream[nowPos - rep0];
308 #endif
309 do
310 {
311 int bit;
312 CProb *probLit;
313 matchByte <<= 1;
314 bit = (matchByte & 0x100);
315 probLit = prob + 0x100 + bit + symbol;
316 RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
317 }
318 while (symbol < 0x100);
319 }
320 while (symbol < 0x100)
321 {
322 CProb *probLit = prob + symbol;
323 RC_GET_BIT(probLit, symbol)
324 }
325 previousByte = (Byte)symbol;
326
327 outStream[nowPos++] = previousByte;
328 #ifdef _LZMA_OUT_READ
329 if (distanceLimit < dictionarySize)
330 distanceLimit++;
331
332 dictionary[dictionaryPos] = previousByte;
333 if (++dictionaryPos == dictionarySize)
334 dictionaryPos = 0;
335 #endif
336 if (state < 4) state = 0;
337 else if (state < 10) state -= 3;
338 else state -= 6;
339 }
340 else
341 {
342 UpdateBit1(prob);
343 prob = p + IsRep + state;
344 IfBit0(prob)
345 {
346 UpdateBit0(prob);
347 rep3 = rep2;
348 rep2 = rep1;
349 rep1 = rep0;
350 state = state < kNumLitStates ? 0 : 3;
351 prob = p + LenCoder;
352 }
353 else
354 {
355 UpdateBit1(prob);
356 prob = p + IsRepG0 + state;
357 IfBit0(prob)
358 {
359 UpdateBit0(prob);
360 prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
361 IfBit0(prob)
362 {
363 #ifdef _LZMA_OUT_READ
364 UInt32 pos;
365 #endif
366 UpdateBit0(prob);
367
368 #ifdef _LZMA_OUT_READ
369 if (distanceLimit == 0)
370 #else
371 if (nowPos == 0)
372 #endif
373 return LZMA_RESULT_DATA_ERROR;
374
375 state = state < kNumLitStates ? 9 : 11;
376 #ifdef _LZMA_OUT_READ
377 pos = dictionaryPos - rep0;
378 if (pos >= dictionarySize)
379 pos += dictionarySize;
380 previousByte = dictionary[pos];
381 dictionary[dictionaryPos] = previousByte;
382 if (++dictionaryPos == dictionarySize)
383 dictionaryPos = 0;
384 #else
385 previousByte = outStream[nowPos - rep0];
386 #endif
387 outStream[nowPos++] = previousByte;
388 #ifdef _LZMA_OUT_READ
389 if (distanceLimit < dictionarySize)
390 distanceLimit++;
391 #endif
392
393 continue;
394 }
395 else
396 {
397 UpdateBit1(prob);
398 }
399 }
400 else
401 {
402 UInt32 distance;
403 UpdateBit1(prob);
404 prob = p + IsRepG1 + state;
405 IfBit0(prob)
406 {
407 UpdateBit0(prob);
408 distance = rep1;
409 }
410 else
411 {
412 UpdateBit1(prob);
413 prob = p + IsRepG2 + state;
414 IfBit0(prob)
415 {
416 UpdateBit0(prob);
417 distance = rep2;
418 }
419 else
420 {
421 UpdateBit1(prob);
422 distance = rep3;
423 rep3 = rep2;
424 }
425 rep2 = rep1;
426 }
427 rep1 = rep0;
428 rep0 = distance;
429 }
430 state = state < kNumLitStates ? 8 : 11;
431 prob = p + RepLenCoder;
432 }
433 {
434 int numBits, offset;
435 CProb *probLen = prob + LenChoice;
436 IfBit0(probLen)
437 {
438 UpdateBit0(probLen);
439 probLen = prob + LenLow + (posState << kLenNumLowBits);
440 offset = 0;
441 numBits = kLenNumLowBits;
442 }
443 else
444 {
445 UpdateBit1(probLen);
446 probLen = prob + LenChoice2;
447 IfBit0(probLen)
448 {
449 UpdateBit0(probLen);
450 probLen = prob + LenMid + (posState << kLenNumMidBits);
451 offset = kLenNumLowSymbols;
452 numBits = kLenNumMidBits;
453 }
454 else
455 {
456 UpdateBit1(probLen);
457 probLen = prob + LenHigh;
458 offset = kLenNumLowSymbols + kLenNumMidSymbols;
459 numBits = kLenNumHighBits;
460 }
461 }
462 RangeDecoderBitTreeDecode(probLen, numBits, len);
463 len += offset;
464 }
465
466 if (state < 4)
467 {
468 int posSlot;
469 state += kNumLitStates;
470 prob = p + PosSlot +
471 ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
472 kNumPosSlotBits);
473 RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
474 if (posSlot >= kStartPosModelIndex)
475 {
476 int numDirectBits = ((posSlot >> 1) - 1);
477 rep0 = (2 | ((UInt32)posSlot & 1));
478 if (posSlot < kEndPosModelIndex)
479 {
480 rep0 <<= numDirectBits;
481 prob = p + SpecPos + rep0 - posSlot - 1;
482 }
483 else
484 {
485 numDirectBits -= kNumAlignBits;
486 do
487 {
488 RC_NORMALIZE
489 Range >>= 1;
490 rep0 <<= 1;
491 if (Code >= Range)
492 {
493 Code -= Range;
494 rep0 |= 1;
495 }
496 }
497 while (--numDirectBits != 0);
498 prob = p + Align;
499 rep0 <<= kNumAlignBits;
500 numDirectBits = kNumAlignBits;
501 }
502 {
503 int i = 1;
504 int mi = 1;
505 do
506 {
507 CProb *prob3 = prob + mi;
508 RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
509 i <<= 1;
510 }
511 while(--numDirectBits != 0);
512 }
513 }
514 else
515 rep0 = posSlot;
516 if (++rep0 == (UInt32)(0))
517 {
518 /* it's for stream version */
519 len = kLzmaStreamWasFinishedId;
520 break;
521 }
522 }
523
524 len += kMatchMinLen;
525 #ifdef _LZMA_OUT_READ
526 if (rep0 > distanceLimit)
527 #else
528 if (rep0 > nowPos)
529 #endif
530 return LZMA_RESULT_DATA_ERROR;
531
532 #ifdef _LZMA_OUT_READ
533 if (dictionarySize - distanceLimit > (UInt32)len)
534 distanceLimit += len;
535 else
536 distanceLimit = dictionarySize;
537 #endif
538
539 do
540 {
541 #ifdef _LZMA_OUT_READ
542 UInt32 pos = dictionaryPos - rep0;
543 if (pos >= dictionarySize)
544 pos += dictionarySize;
545 previousByte = dictionary[pos];
546 dictionary[dictionaryPos] = previousByte;
547 if (++dictionaryPos == dictionarySize)
548 dictionaryPos = 0;
549 #else
550 previousByte = outStream[nowPos - rep0];
551 #endif
552 len--;
553 outStream[nowPos++] = previousByte;
554 }
555 while(len != 0 && nowPos < outSize);
556 }
557 }
558 RC_NORMALIZE;
559
560 #ifdef _LZMA_OUT_READ
561 vs->Range = Range;
562 vs->Code = Code;
563 vs->DictionaryPos = dictionaryPos;
564 vs->GlobalPos = globalPos + (UInt32)nowPos;
565 vs->DistanceLimit = distanceLimit;
566 vs->Reps[0] = rep0;
567 vs->Reps[1] = rep1;
568 vs->Reps[2] = rep2;
569 vs->Reps[3] = rep3;
570 vs->State = state;
571 vs->RemainLen = len;
572 vs->TempDictionary[0] = tempDictionary[0];
573 #endif
574
575 #ifdef _LZMA_IN_CB
576 vs->Buffer = Buffer;
577 vs->BufferLim = BufferLim;
578 #else
579 *inSizeProcessed = (SizeT)(Buffer - inStream);
580 #endif
581 *outSizeProcessed = nowPos;
582 return LZMA_RESULT_OK;
583 }
0 /*
1 LzmaDecode.h
2 LZMA Decoder interface
3
4 LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
5 http://www.7-zip.org/
6
7 LZMA SDK is licensed under two licenses:
8 1) GNU Lesser General Public License (GNU LGPL)
9 2) Common Public License (CPL)
10 It means that you can select one of these two licenses and
11 follow rules of that license.
12
13 SPECIAL EXCEPTION:
14 Igor Pavlov, as the author of this code, expressly permits you to
15 statically or dynamically link your code (or bind by name) to the
16 interfaces of this file without subjecting your linked code to the
17 terms of the CPL or GNU LGPL. Any modifications or additions
18 to this file, however, are subject to the LGPL or CPL terms.
19 */
20
21 #ifndef __LZMADECODE_H
22 #define __LZMADECODE_H
23
24 #include "LzmaTypes.h"
25
26 /* #define _LZMA_IN_CB */
27 /* Use callback for input data */
28
29 /* #define _LZMA_OUT_READ */
30 /* Use read function for output data */
31
32 /* #define _LZMA_PROB32 */
33 /* It can increase speed on some 32-bit CPUs,
34 but memory usage will be doubled in that case */
35
36 /* #define _LZMA_LOC_OPT */
37 /* Enable local speed optimizations inside code */
38
39 #ifdef _LZMA_PROB32
40 #define CProb UInt32
41 #else
42 #define CProb UInt16
43 #endif
44
45 #define LZMA_RESULT_OK 0
46 #define LZMA_RESULT_DATA_ERROR 1
47
48 #ifdef _LZMA_IN_CB
49 typedef struct _ILzmaInCallback
50 {
51 int (*Read)(void *object, const unsigned char **buffer, SizeT *bufferSize);
52 } ILzmaInCallback;
53 #endif
54
55 #define LZMA_BASE_SIZE 1846
56 #define LZMA_LIT_SIZE 768
57
58 #define LZMA_PROPERTIES_SIZE 5
59
60 typedef struct _CLzmaProperties
61 {
62 int lc;
63 int lp;
64 int pb;
65 #ifdef _LZMA_OUT_READ
66 UInt32 DictionarySize;
67 #endif
68 }CLzmaProperties;
69
70 int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
71
72 #define LzmaGetNumProbs(Properties) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
73
74 #define kLzmaNeedInitId (-2)
75
76 typedef struct _CLzmaDecoderState
77 {
78 CLzmaProperties Properties;
79 CProb *Probs;
80
81 #ifdef _LZMA_IN_CB
82 const unsigned char *Buffer;
83 const unsigned char *BufferLim;
84 #endif
85
86 #ifdef _LZMA_OUT_READ
87 unsigned char *Dictionary;
88 UInt32 Range;
89 UInt32 Code;
90 UInt32 DictionaryPos;
91 UInt32 GlobalPos;
92 UInt32 DistanceLimit;
93 UInt32 Reps[4];
94 int State;
95 int RemainLen;
96 unsigned char TempDictionary[4];
97 #endif
98 } CLzmaDecoderState;
99
100 #ifdef _LZMA_OUT_READ
101 #define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; }
102 #endif
103
104 int LzmaDecode(CLzmaDecoderState *vs,
105 #ifdef _LZMA_IN_CB
106 ILzmaInCallback *inCallback,
107 #else
108 const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
109 #endif
110 unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
111
112 #endif
0 /*
1 LzmaDecodeSize.c
2 LZMA Decoder (optimized for Size version)
3
4 LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
5 http://www.7-zip.org/
6
7 LZMA SDK is licensed under two licenses:
8 1) GNU Lesser General Public License (GNU LGPL)
9 2) Common Public License (CPL)
10 It means that you can select one of these two licenses and
11 follow rules of that license.
12
13 SPECIAL EXCEPTION:
14 Igor Pavlov, as the author of this code, expressly permits you to
15 statically or dynamically link your code (or bind by name) to the
16 interfaces of this file without subjecting your linked code to the
17 terms of the CPL or GNU LGPL. Any modifications or additions
18 to this file, however, are subject to the LGPL or CPL terms.
19 */
20
21 #include "LzmaDecode.h"
22
23 #define kNumTopBits 24
24 #define kTopValue ((UInt32)1 << kNumTopBits)
25
26 #define kNumBitModelTotalBits 11
27 #define kBitModelTotal (1 << kNumBitModelTotalBits)
28 #define kNumMoveBits 5
29
30 typedef struct _CRangeDecoder
31 {
32 const Byte *Buffer;
33 const Byte *BufferLim;
34 UInt32 Range;
35 UInt32 Code;
36 #ifdef _LZMA_IN_CB
37 ILzmaInCallback *InCallback;
38 int Result;
39 #endif
40 int ExtraBytes;
41 } CRangeDecoder;
42
43 Byte RangeDecoderReadByte(CRangeDecoder *rd)
44 {
45 if (rd->Buffer == rd->BufferLim)
46 {
47 #ifdef _LZMA_IN_CB
48 SizeT size;
49 rd->Result = rd->InCallback->Read(rd->InCallback, &rd->Buffer, &size);
50 rd->BufferLim = rd->Buffer + size;
51 if (size == 0)
52 #endif
53 {
54 rd->ExtraBytes = 1;
55 return 0xFF;
56 }
57 }
58 return (*rd->Buffer++);
59 }
60
61 /* #define ReadByte (*rd->Buffer++) */
62 #define ReadByte (RangeDecoderReadByte(rd))
63
64 void RangeDecoderInit(CRangeDecoder *rd
65 #ifndef _LZMA_IN_CB
66 , const Byte *stream, SizeT bufferSize
67 #endif
68 )
69 {
70 int i;
71 #ifdef _LZMA_IN_CB
72 rd->Buffer = rd->BufferLim = 0;
73 #else
74 rd->Buffer = stream;
75 rd->BufferLim = stream + bufferSize;
76 #endif
77 rd->ExtraBytes = 0;
78 rd->Code = 0;
79 rd->Range = (0xFFFFFFFF);
80 for(i = 0; i < 5; i++)
81 rd->Code = (rd->Code << 8) | ReadByte;
82 }
83
84 #define RC_INIT_VAR UInt32 range = rd->Range; UInt32 code = rd->Code;
85 #define RC_FLUSH_VAR rd->Range = range; rd->Code = code;
86 #define RC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | ReadByte; }
87
88 UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits)
89 {
90 RC_INIT_VAR
91 UInt32 result = 0;
92 int i;
93 for (i = numTotalBits; i != 0; i--)
94 {
95 /* UInt32 t; */
96 range >>= 1;
97
98 result <<= 1;
99 if (code >= range)
100 {
101 code -= range;
102 result |= 1;
103 }
104 /*
105 t = (code - range) >> 31;
106 t &= 1;
107 code -= range & (t - 1);
108 result = (result + result) | (1 - t);
109 */
110 RC_NORMALIZE
111 }
112 RC_FLUSH_VAR
113 return result;
114 }
115
116 int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd)
117 {
118 UInt32 bound = (rd->Range >> kNumBitModelTotalBits) * *prob;
119 if (rd->Code < bound)
120 {
121 rd->Range = bound;
122 *prob += (kBitModelTotal - *prob) >> kNumMoveBits;
123 if (rd->Range < kTopValue)
124 {
125 rd->Code = (rd->Code << 8) | ReadByte;
126 rd->Range <<= 8;
127 }
128 return 0;
129 }
130 else
131 {
132 rd->Range -= bound;
133 rd->Code -= bound;
134 *prob -= (*prob) >> kNumMoveBits;
135 if (rd->Range < kTopValue)
136 {
137 rd->Code = (rd->Code << 8) | ReadByte;
138 rd->Range <<= 8;
139 }
140 return 1;
141 }
142 }
143
144 #define RC_GET_BIT2(prob, mi, A0, A1) \
145 UInt32 bound = (range >> kNumBitModelTotalBits) * *prob; \
146 if (code < bound) \
147 { A0; range = bound; *prob += (kBitModelTotal - *prob) >> kNumMoveBits; mi <<= 1; } \
148 else \
149 { A1; range -= bound; code -= bound; *prob -= (*prob) >> kNumMoveBits; mi = (mi + mi) + 1; } \
150 RC_NORMALIZE
151
152 #define RC_GET_BIT(prob, mi) RC_GET_BIT2(prob, mi, ; , ;)
153
154 int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
155 {
156 int mi = 1;
157 int i;
158 #ifdef _LZMA_LOC_OPT
159 RC_INIT_VAR
160 #endif
161 for(i = numLevels; i != 0; i--)
162 {
163 #ifdef _LZMA_LOC_OPT
164 CProb *prob = probs + mi;
165 RC_GET_BIT(prob, mi)
166 #else
167 mi = (mi + mi) + RangeDecoderBitDecode(probs + mi, rd);
168 #endif
169 }
170 #ifdef _LZMA_LOC_OPT
171 RC_FLUSH_VAR
172 #endif
173 return mi - (1 << numLevels);
174 }
175
176 int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
177 {
178 int mi = 1;
179 int i;
180 int symbol = 0;
181 #ifdef _LZMA_LOC_OPT
182 RC_INIT_VAR
183 #endif
184 for(i = 0; i < numLevels; i++)
185 {
186 #ifdef _LZMA_LOC_OPT
187 CProb *prob = probs + mi;
188 RC_GET_BIT2(prob, mi, ; , symbol |= (1 << i))
189 #else
190 int bit = RangeDecoderBitDecode(probs + mi, rd);
191 mi = mi + mi + bit;
192 symbol |= (bit << i);
193 #endif
194 }
195 #ifdef _LZMA_LOC_OPT
196 RC_FLUSH_VAR
197 #endif
198 return symbol;
199 }
200
201 Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd)
202 {
203 int symbol = 1;
204 #ifdef _LZMA_LOC_OPT
205 RC_INIT_VAR
206 #endif
207 do
208 {
209 #ifdef _LZMA_LOC_OPT
210 CProb *prob = probs + symbol;
211 RC_GET_BIT(prob, symbol)
212 #else
213 symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd);
214 #endif
215 }
216 while (symbol < 0x100);
217 #ifdef _LZMA_LOC_OPT
218 RC_FLUSH_VAR
219 #endif
220 return symbol;
221 }
222
223 Byte LzmaLiteralDecodeMatch(CProb *probs, CRangeDecoder *rd, Byte matchByte)
224 {
225 int symbol = 1;
226 #ifdef _LZMA_LOC_OPT
227 RC_INIT_VAR
228 #endif
229 do
230 {
231 int bit;
232 int matchBit = (matchByte >> 7) & 1;
233 matchByte <<= 1;
234 #ifdef _LZMA_LOC_OPT
235 {
236 CProb *prob = probs + 0x100 + (matchBit << 8) + symbol;
237 RC_GET_BIT2(prob, symbol, bit = 0, bit = 1)
238 }
239 #else
240 bit = RangeDecoderBitDecode(probs + 0x100 + (matchBit << 8) + symbol, rd);
241 symbol = (symbol << 1) | bit;
242 #endif
243 if (matchBit != bit)
244 {
245 while (symbol < 0x100)
246 {
247 #ifdef _LZMA_LOC_OPT
248 CProb *prob = probs + symbol;
249 RC_GET_BIT(prob, symbol)
250 #else
251 symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd);
252 #endif
253 }
254 break;
255 }
256 }
257 while (symbol < 0x100);
258 #ifdef _LZMA_LOC_OPT
259 RC_FLUSH_VAR
260 #endif
261 return symbol;
262 }
263
264 #define kNumPosBitsMax 4
265 #define kNumPosStatesMax (1 << kNumPosBitsMax)
266
267 #define kLenNumLowBits 3
268 #define kLenNumLowSymbols (1 << kLenNumLowBits)
269 #define kLenNumMidBits 3
270 #define kLenNumMidSymbols (1 << kLenNumMidBits)
271 #define kLenNumHighBits 8
272 #define kLenNumHighSymbols (1 << kLenNumHighBits)
273
274 #define LenChoice 0
275 #define LenChoice2 (LenChoice + 1)
276 #define LenLow (LenChoice2 + 1)
277 #define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
278 #define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
279 #define kNumLenProbs (LenHigh + kLenNumHighSymbols)
280
281 int LzmaLenDecode(CProb *p, CRangeDecoder *rd, int posState)
282 {
283 if(RangeDecoderBitDecode(p + LenChoice, rd) == 0)
284 return RangeDecoderBitTreeDecode(p + LenLow +
285 (posState << kLenNumLowBits), kLenNumLowBits, rd);
286 if(RangeDecoderBitDecode(p + LenChoice2, rd) == 0)
287 return kLenNumLowSymbols + RangeDecoderBitTreeDecode(p + LenMid +
288 (posState << kLenNumMidBits), kLenNumMidBits, rd);
289 return kLenNumLowSymbols + kLenNumMidSymbols +
290 RangeDecoderBitTreeDecode(p + LenHigh, kLenNumHighBits, rd);
291 }
292
293 #define kNumStates 12
294 #define kNumLitStates 7
295
296 #define kStartPosModelIndex 4
297 #define kEndPosModelIndex 14
298 #define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
299
300 #define kNumPosSlotBits 6
301 #define kNumLenToPosStates 4
302
303 #define kNumAlignBits 4
304 #define kAlignTableSize (1 << kNumAlignBits)
305
306 #define kMatchMinLen 2
307
308 #define IsMatch 0
309 #define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
310 #define IsRepG0 (IsRep + kNumStates)
311 #define IsRepG1 (IsRepG0 + kNumStates)
312 #define IsRepG2 (IsRepG1 + kNumStates)
313 #define IsRep0Long (IsRepG2 + kNumStates)
314 #define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
315 #define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
316 #define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
317 #define LenCoder (Align + kAlignTableSize)
318 #define RepLenCoder (LenCoder + kNumLenProbs)
319 #define Literal (RepLenCoder + kNumLenProbs)
320
321 #if Literal != LZMA_BASE_SIZE
322 StopCompilingDueBUG
323 #endif
324
325 int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
326 {
327 unsigned char prop0;
328 if (size < LZMA_PROPERTIES_SIZE)
329 return LZMA_RESULT_DATA_ERROR;
330 prop0 = propsData[0];
331 if (prop0 >= (9 * 5 * 5))
332 return LZMA_RESULT_DATA_ERROR;
333 {
334 for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
335 for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
336 propsRes->lc = prop0;
337 /*
338 unsigned char remainder = (unsigned char)(prop0 / 9);
339 propsRes->lc = prop0 % 9;
340 propsRes->pb = remainder / 5;
341 propsRes->lp = remainder % 5;
342 */
343 }
344
345 #ifdef _LZMA_OUT_READ
346 {
347 int i;
348 propsRes->DictionarySize = 0;
349 for (i = 0; i < 4; i++)
350 propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
351 if (propsRes->DictionarySize == 0)
352 propsRes->DictionarySize = 1;
353 }
354 #endif
355 return LZMA_RESULT_OK;
356 }
357
358 #define kLzmaStreamWasFinishedId (-1)
359
360 int LzmaDecode(CLzmaDecoderState *vs,
361 #ifdef _LZMA_IN_CB
362 ILzmaInCallback *InCallback,
363 #else
364 const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
365 #endif
366 unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
367 {
368 CProb *p = vs->Probs;
369 SizeT nowPos = 0;
370 Byte previousByte = 0;
371 UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
372 UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
373 int lc = vs->Properties.lc;
374 CRangeDecoder rd;
375
376 #ifdef _LZMA_OUT_READ
377
378 int state = vs->State;
379 UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
380 int len = vs->RemainLen;
381 UInt32 globalPos = vs->GlobalPos;
382 UInt32 distanceLimit = vs->DistanceLimit;
383
384 Byte *dictionary = vs->Dictionary;
385 UInt32 dictionarySize = vs->Properties.DictionarySize;
386 UInt32 dictionaryPos = vs->DictionaryPos;
387
388 Byte tempDictionary[4];
389
390 rd.Range = vs->Range;
391 rd.Code = vs->Code;
392 #ifdef _LZMA_IN_CB
393 rd.InCallback = InCallback;
394 rd.Buffer = vs->Buffer;
395 rd.BufferLim = vs->BufferLim;
396 #else
397 rd.Buffer = inStream;
398 rd.BufferLim = inStream + inSize;
399 #endif
400
401 #ifndef _LZMA_IN_CB
402 *inSizeProcessed = 0;
403 #endif
404 *outSizeProcessed = 0;
405 if (len == kLzmaStreamWasFinishedId)
406 return LZMA_RESULT_OK;
407
408 if (dictionarySize == 0)
409 {
410 dictionary = tempDictionary;
411 dictionarySize = 1;
412 tempDictionary[0] = vs->TempDictionary[0];
413 }
414
415 if (len == kLzmaNeedInitId)
416 {
417 {
418 UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
419 UInt32 i;
420 for (i = 0; i < numProbs; i++)
421 p[i] = kBitModelTotal >> 1;
422 rep0 = rep1 = rep2 = rep3 = 1;
423 state = 0;
424 globalPos = 0;
425 distanceLimit = 0;
426 dictionaryPos = 0;
427 dictionary[dictionarySize - 1] = 0;
428 RangeDecoderInit(&rd
429 #ifndef _LZMA_IN_CB
430 , inStream, inSize
431 #endif
432 );
433 #ifdef _LZMA_IN_CB
434 if (rd.Result != LZMA_RESULT_OK)
435 return rd.Result;
436 #endif
437 if (rd.ExtraBytes != 0)
438 return LZMA_RESULT_DATA_ERROR;
439 }
440 len = 0;
441 }
442 while(len != 0 && nowPos < outSize)
443 {
444 UInt32 pos = dictionaryPos - rep0;
445 if (pos >= dictionarySize)
446 pos += dictionarySize;
447 outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
448 if (++dictionaryPos == dictionarySize)
449 dictionaryPos = 0;
450 len--;
451 }
452 if (dictionaryPos == 0)
453 previousByte = dictionary[dictionarySize - 1];
454 else
455 previousByte = dictionary[dictionaryPos - 1];
456
457 #ifdef _LZMA_IN_CB
458 rd.Result = LZMA_RESULT_OK;
459 #endif
460 rd.ExtraBytes = 0;
461
462 #else /* if !_LZMA_OUT_READ */
463
464 int state = 0;
465 UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
466 int len = 0;
467
468 #ifndef _LZMA_IN_CB
469 *inSizeProcessed = 0;
470 #endif
471 *outSizeProcessed = 0;
472
473 {
474 UInt32 i;
475 UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
476 for (i = 0; i < numProbs; i++)
477 p[i] = kBitModelTotal >> 1;
478 }
479
480 #ifdef _LZMA_IN_CB
481 rd.InCallback = InCallback;
482 #endif
483 RangeDecoderInit(&rd
484 #ifndef _LZMA_IN_CB
485 , inStream, inSize
486 #endif
487 );
488
489 #ifdef _LZMA_IN_CB
490 if (rd.Result != LZMA_RESULT_OK)
491 return rd.Result;
492 #endif
493 if (rd.ExtraBytes != 0)
494 return LZMA_RESULT_DATA_ERROR;
495
496 #endif /* _LZMA_OUT_READ */
497
498
499 while(nowPos < outSize)
500 {
501 int posState = (int)(
502 (nowPos
503 #ifdef _LZMA_OUT_READ
504 + globalPos
505 #endif
506 )
507 & posStateMask);
508 #ifdef _LZMA_IN_CB
509 if (rd.Result != LZMA_RESULT_OK)
510 return rd.Result;
511 #endif
512 if (rd.ExtraBytes != 0)
513 return LZMA_RESULT_DATA_ERROR;
514 if (RangeDecoderBitDecode(p + IsMatch + (state << kNumPosBitsMax) + posState, &rd) == 0)
515 {
516 CProb *probs = p + Literal + (LZMA_LIT_SIZE *
517 (((
518 (nowPos
519 #ifdef _LZMA_OUT_READ
520 + globalPos
521 #endif
522 )
523 & literalPosMask) << lc) + (previousByte >> (8 - lc))));
524
525 if (state >= kNumLitStates)
526 {
527 Byte matchByte;
528 #ifdef _LZMA_OUT_READ
529 UInt32 pos = dictionaryPos - rep0;
530 if (pos >= dictionarySize)
531 pos += dictionarySize;
532 matchByte = dictionary[pos];
533 #else
534 matchByte = outStream[nowPos - rep0];
535 #endif
536 previousByte = LzmaLiteralDecodeMatch(probs, &rd, matchByte);
537 }
538 else
539 previousByte = LzmaLiteralDecode(probs, &rd);
540 outStream[nowPos++] = previousByte;
541 #ifdef _LZMA_OUT_READ
542 if (distanceLimit < dictionarySize)
543 distanceLimit++;
544
545 dictionary[dictionaryPos] = previousByte;
546 if (++dictionaryPos == dictionarySize)
547 dictionaryPos = 0;
548 #endif
549 if (state < 4) state = 0;
550 else if (state < 10) state -= 3;
551 else state -= 6;
552 }
553 else
554 {
555 if (RangeDecoderBitDecode(p + IsRep + state, &rd) == 1)
556 {
557 if (RangeDecoderBitDecode(p + IsRepG0 + state, &rd) == 0)
558 {
559 if (RangeDecoderBitDecode(p + IsRep0Long + (state << kNumPosBitsMax) + posState, &rd) == 0)
560 {
561 #ifdef _LZMA_OUT_READ
562 UInt32 pos;
563 #endif
564
565 #ifdef _LZMA_OUT_READ
566 if (distanceLimit == 0)
567 #else
568 if (nowPos == 0)
569 #endif
570 return LZMA_RESULT_DATA_ERROR;
571
572 state = state < 7 ? 9 : 11;
573 #ifdef _LZMA_OUT_READ
574 pos = dictionaryPos - rep0;
575 if (pos >= dictionarySize)
576 pos += dictionarySize;
577 previousByte = dictionary[pos];
578 dictionary[dictionaryPos] = previousByte;
579 if (++dictionaryPos == dictionarySize)
580 dictionaryPos = 0;
581 #else
582 previousByte = outStream[nowPos - rep0];
583 #endif
584 outStream[nowPos++] = previousByte;
585
586 #ifdef _LZMA_OUT_READ
587 if (distanceLimit < dictionarySize)
588 distanceLimit++;
589 #endif
590 continue;
591 }
592 }
593 else
594 {
595 UInt32 distance;
596 if(RangeDecoderBitDecode(p + IsRepG1 + state, &rd) == 0)
597 distance = rep1;
598 else
599 {
600 if(RangeDecoderBitDecode(p + IsRepG2 + state, &rd) == 0)
601 distance = rep2;
602 else
603 {
604 distance = rep3;
605 rep3 = rep2;
606 }
607 rep2 = rep1;
608 }
609 rep1 = rep0;
610 rep0 = distance;
611 }
612 len = LzmaLenDecode(p + RepLenCoder, &rd, posState);
613 state = state < 7 ? 8 : 11;
614 }
615 else
616 {
617 int posSlot;
618 rep3 = rep2;
619 rep2 = rep1;
620 rep1 = rep0;
621 state = state < 7 ? 7 : 10;
622 len = LzmaLenDecode(p + LenCoder, &rd, posState);
623 posSlot = RangeDecoderBitTreeDecode(p + PosSlot +
624 ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
625 kNumPosSlotBits), kNumPosSlotBits, &rd);
626 if (posSlot >= kStartPosModelIndex)
627 {
628 int numDirectBits = ((posSlot >> 1) - 1);
629 rep0 = ((2 | ((UInt32)posSlot & 1)) << numDirectBits);
630 if (posSlot < kEndPosModelIndex)
631 {
632 rep0 += RangeDecoderReverseBitTreeDecode(
633 p + SpecPos + rep0 - posSlot - 1, numDirectBits, &rd);
634 }
635 else
636 {
637 rep0 += RangeDecoderDecodeDirectBits(&rd,
638 numDirectBits - kNumAlignBits) << kNumAlignBits;
639 rep0 += RangeDecoderReverseBitTreeDecode(p + Align, kNumAlignBits, &rd);
640 }
641 }
642 else
643 rep0 = posSlot;
644 if (++rep0 == (UInt32)(0))
645 {
646 /* it's for stream version */
647 len = kLzmaStreamWasFinishedId;
648 break;
649 }
650 }
651
652 len += kMatchMinLen;
653 #ifdef _LZMA_OUT_READ
654 if (rep0 > distanceLimit)
655 #else
656 if (rep0 > nowPos)
657 #endif
658 return LZMA_RESULT_DATA_ERROR;
659
660 #ifdef _LZMA_OUT_READ
661 if (dictionarySize - distanceLimit > (UInt32)len)
662 distanceLimit += len;
663 else
664 distanceLimit = dictionarySize;
665 #endif
666
667 do
668 {
669 #ifdef _LZMA_OUT_READ
670 UInt32 pos = dictionaryPos - rep0;
671 if (pos >= dictionarySize)
672 pos += dictionarySize;
673 previousByte = dictionary[pos];
674 dictionary[dictionaryPos] = previousByte;
675 if (++dictionaryPos == dictionarySize)
676 dictionaryPos = 0;
677 #else
678 previousByte = outStream[nowPos - rep0];
679 #endif
680 len--;
681 outStream[nowPos++] = previousByte;
682 }
683 while(len != 0 && nowPos < outSize);
684 }
685 }
686
687
688 #ifdef _LZMA_OUT_READ
689 vs->Range = rd.Range;
690 vs->Code = rd.Code;
691 vs->DictionaryPos = dictionaryPos;
692 vs->GlobalPos = globalPos + (UInt32)nowPos;
693 vs->DistanceLimit = distanceLimit;
694 vs->Reps[0] = rep0;
695 vs->Reps[1] = rep1;
696 vs->Reps[2] = rep2;
697 vs->Reps[3] = rep3;
698 vs->State = state;
699 vs->RemainLen = len;
700 vs->TempDictionary[0] = tempDictionary[0];
701 #endif
702
703 #ifdef _LZMA_IN_CB
704 vs->Buffer = rd.Buffer;
705 vs->BufferLim = rd.BufferLim;
706 #else
707 *inSizeProcessed = (SizeT)(rd.Buffer - inStream);
708 #endif
709 *outSizeProcessed = nowPos;
710 return LZMA_RESULT_OK;
711 }
0 /*
1 LzmaStateDecode.c
2 LZMA Decoder (State version)
3
4 LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
5 http://www.7-zip.org/
6
7 LZMA SDK is licensed under two licenses:
8 1) GNU Lesser General Public License (GNU LGPL)
9 2) Common Public License (CPL)
10 It means that you can select one of these two licenses and
11 follow rules of that license.
12
13 SPECIAL EXCEPTION:
14 Igor Pavlov, as the author of this Code, expressly permits you to
15 statically or dynamically link your Code (or bind by name) to the
16 interfaces of this file without subjecting your linked Code to the
17 terms of the CPL or GNU LGPL. Any modifications or additions
18 to this file, however, are subject to the LGPL or CPL terms.
19 */
20
21 #include "LzmaStateDecode.h"
22
23 #define kNumTopBits 24
24 #define kTopValue ((UInt32)1 << kNumTopBits)
25
26 #define kNumBitModelTotalBits 11
27 #define kBitModelTotal (1 << kNumBitModelTotalBits)
28 #define kNumMoveBits 5
29
30 #define RC_READ_BYTE (*Buffer++)
31
32 #define RC_INIT Code = 0; Range = 0xFFFFFFFF; \
33 { int i; for(i = 0; i < 5; i++) { Code = (Code << 8) | RC_READ_BYTE; }}
34
35 #define RC_NORMALIZE if (Range < kTopValue) { Range <<= 8; Code = (Code << 8) | RC_READ_BYTE; }
36
37 #define IfBit0(p) RC_NORMALIZE; bound = (Range >> kNumBitModelTotalBits) * *(p); if (Code < bound)
38 #define UpdateBit0(p) Range = bound; *(p) += (kBitModelTotal - *(p)) >> kNumMoveBits;
39 #define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
40
41 #define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
42 { UpdateBit0(p); mi <<= 1; A0; } else \
43 { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
44
45 #define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
46
47 #define RangeDecoderBitTreeDecode(probs, numLevels, res) \
48 { int i = numLevels; res = 1; \
49 do { CProb *p = probs + res; RC_GET_BIT(p, res) } while(--i != 0); \
50 res -= (1 << numLevels); }
51
52
53 #define kNumPosBitsMax 4
54 #define kNumPosStatesMax (1 << kNumPosBitsMax)
55
56 #define kLenNumLowBits 3
57 #define kLenNumLowSymbols (1 << kLenNumLowBits)
58 #define kLenNumMidBits 3
59 #define kLenNumMidSymbols (1 << kLenNumMidBits)
60 #define kLenNumHighBits 8
61 #define kLenNumHighSymbols (1 << kLenNumHighBits)
62
63 #define LenChoice 0
64 #define LenChoice2 (LenChoice + 1)
65 #define LenLow (LenChoice2 + 1)
66 #define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
67 #define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
68 #define kNumLenProbs (LenHigh + kLenNumHighSymbols)
69
70
71 #define kNumStates 12
72 #define kNumLitStates 7
73
74 #define kStartPosModelIndex 4
75 #define kEndPosModelIndex 14
76 #define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
77
78 #define kNumPosSlotBits 6
79 #define kNumLenToPosStates 4
80
81 #define kNumAlignBits 4
82 #define kAlignTableSize (1 << kNumAlignBits)
83
84 #define kMatchMinLen 2
85
86 #define IsMatch 0
87 #define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
88 #define IsRepG0 (IsRep + kNumStates)
89 #define IsRepG1 (IsRepG0 + kNumStates)
90 #define IsRepG2 (IsRepG1 + kNumStates)
91 #define IsRep0Long (IsRepG2 + kNumStates)
92 #define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
93 #define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
94 #define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
95 #define LenCoder (Align + kAlignTableSize)
96 #define RepLenCoder (LenCoder + kNumLenProbs)
97 #define Literal (RepLenCoder + kNumLenProbs)
98
99 #if Literal != LZMA_BASE_SIZE
100 StopCompilingDueBUG
101 #endif
102
103 /* kRequiredInBufferSize = number of required input bytes for worst case:
104 longest match with longest distance.
105 kLzmaInBufferSize must be larger than kRequiredInBufferSize
106 23 bits = 2 (match select) + 10 (len) + 6 (distance) + 4(align) + 1 (RC_NORMALIZE)
107 */
108
109 #define kRequiredInBufferSize ((23 * (kNumBitModelTotalBits - kNumMoveBits + 1) + 26 + 9) / 8)
110
111 #define kLzmaStreamWasFinishedId (-1)
112
113 int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
114 {
115 unsigned char prop0;
116 if (size < LZMA_PROPERTIES_SIZE)
117 return LZMA_RESULT_DATA_ERROR;
118 prop0 = propsData[0];
119 if (prop0 >= (9 * 5 * 5))
120 return LZMA_RESULT_DATA_ERROR;
121 {
122 for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5));
123 for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9);
124 propsRes->lc = prop0;
125 /*
126 unsigned char remainder = (unsigned char)(prop0 / 9);
127 propsRes->lc = prop0 % 9;
128 propsRes->pb = remainder / 5;
129 propsRes->lp = remainder % 5;
130 */
131 }
132
133 {
134 int i;
135 propsRes->DictionarySize = 0;
136 for (i = 0; i < 4; i++)
137 propsRes->DictionarySize += (UInt32)(propsData[1 + i]) << (i * 8);
138 if (propsRes->DictionarySize == 0)
139 propsRes->DictionarySize = 1;
140 return LZMA_RESULT_OK;
141 }
142 }
143
144 int LzmaDecode(
145 CLzmaDecoderState *vs,
146 const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
147 unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed,
148 int finishDecoding)
149 {
150 UInt32 Range = vs->Range;
151 UInt32 Code = vs->Code;
152
153 unsigned char *Buffer = vs->Buffer;
154 int BufferSize = vs->BufferSize; /* don't change it to unsigned int */
155 CProb *p = vs->Probs;
156
157 int state = vs->State;
158 unsigned char previousByte;
159 UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
160 SizeT nowPos = 0;
161 UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
162 UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
163 int lc = vs->Properties.lc;
164 int len = vs->RemainLen;
165 UInt32 globalPos = vs->GlobalPos;
166 UInt32 distanceLimit = vs->DistanceLimit;
167
168 unsigned char *dictionary = vs->Dictionary;
169 UInt32 dictionarySize = vs->Properties.DictionarySize;
170 UInt32 dictionaryPos = vs->DictionaryPos;
171
172 unsigned char tempDictionary[4];
173
174 (*inSizeProcessed) = 0;
175 (*outSizeProcessed) = 0;
176 if (len == kLzmaStreamWasFinishedId)
177 return LZMA_RESULT_OK;
178
179 if (dictionarySize == 0)
180 {
181 dictionary = tempDictionary;
182 dictionarySize = 1;
183 tempDictionary[0] = vs->TempDictionary[0];
184 }
185
186 if (len == kLzmaNeedInitId)
187 {
188 while (inSize > 0 && BufferSize < kLzmaInBufferSize)
189 {
190 Buffer[BufferSize++] = *inStream++;
191 (*inSizeProcessed)++;
192 inSize--;
193 }
194 if (BufferSize < 5)
195 {
196 vs->BufferSize = BufferSize;
197 return finishDecoding ? LZMA_RESULT_DATA_ERROR : LZMA_RESULT_OK;
198 }
199 {
200 UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
201 UInt32 i;
202 for (i = 0; i < numProbs; i++)
203 p[i] = kBitModelTotal >> 1;
204 rep0 = rep1 = rep2 = rep3 = 1;
205 state = 0;
206 globalPos = 0;
207 distanceLimit = 0;
208 dictionaryPos = 0;
209 dictionary[dictionarySize - 1] = 0;
210 RC_INIT;
211 }
212 len = 0;
213 }
214 while(len != 0 && nowPos < outSize)
215 {
216 UInt32 pos = dictionaryPos - rep0;
217 if (pos >= dictionarySize)
218 pos += dictionarySize;
219 outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
220 if (++dictionaryPos == dictionarySize)
221 dictionaryPos = 0;
222 len--;
223 }
224 if (dictionaryPos == 0)
225 previousByte = dictionary[dictionarySize - 1];
226 else
227 previousByte = dictionary[dictionaryPos - 1];
228
229 while(1)
230 {
231 int bufferPos = (int)(Buffer - vs->Buffer);
232 if (BufferSize - bufferPos < kRequiredInBufferSize)
233 {
234 int i;
235 BufferSize -= bufferPos;
236 if (BufferSize < 0)
237 return LZMA_RESULT_DATA_ERROR;
238 for (i = 0; i < BufferSize; i++)
239 vs->Buffer[i] = Buffer[i];
240 Buffer = vs->Buffer;
241 while (inSize > 0 && BufferSize < kLzmaInBufferSize)
242 {
243 Buffer[BufferSize++] = *inStream++;
244 (*inSizeProcessed)++;
245 inSize--;
246 }
247 if (BufferSize < kRequiredInBufferSize && !finishDecoding)
248 break;
249 }
250 if (nowPos >= outSize)
251 break;
252 {
253 CProb *prob;
254 UInt32 bound;
255 int posState = (int)((nowPos + globalPos) & posStateMask);
256
257 prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
258 IfBit0(prob)
259 {
260 int symbol = 1;
261 UpdateBit0(prob)
262 prob = p + Literal + (LZMA_LIT_SIZE *
263 ((((nowPos + globalPos)& literalPosMask) << lc) + (previousByte >> (8 - lc))));
264
265 if (state >= kNumLitStates)
266 {
267 int matchByte;
268 UInt32 pos = dictionaryPos - rep0;
269 if (pos >= dictionarySize)
270 pos += dictionarySize;
271 matchByte = dictionary[pos];
272 do
273 {
274 int bit;
275 CProb *probLit;
276 matchByte <<= 1;
277 bit = (matchByte & 0x100);
278 probLit = prob + 0x100 + bit + symbol;
279 RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
280 }
281 while (symbol < 0x100);
282 }
283 while (symbol < 0x100)
284 {
285 CProb *probLit = prob + symbol;
286 RC_GET_BIT(probLit, symbol)
287 }
288 previousByte = (unsigned char)symbol;
289
290 outStream[nowPos++] = previousByte;
291 if (distanceLimit < dictionarySize)
292 distanceLimit++;
293
294 dictionary[dictionaryPos] = previousByte;
295 if (++dictionaryPos == dictionarySize)
296 dictionaryPos = 0;
297 if (state < 4) state = 0;
298 else if (state < 10) state -= 3;
299 else state -= 6;
300 }
301 else
302 {
303 UpdateBit1(prob);
304 prob = p + IsRep + state;
305 IfBit0(prob)
306 {
307 UpdateBit0(prob);
308 rep3 = rep2;
309 rep2 = rep1;
310 rep1 = rep0;
311 state = state < kNumLitStates ? 0 : 3;
312 prob = p + LenCoder;
313 }
314 else
315 {
316 UpdateBit1(prob);
317 prob = p + IsRepG0 + state;
318 IfBit0(prob)
319 {
320 UpdateBit0(prob);
321 prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
322 IfBit0(prob)
323 {
324 UInt32 pos;
325 UpdateBit0(prob);
326 if (distanceLimit == 0)
327 return LZMA_RESULT_DATA_ERROR;
328 if (distanceLimit < dictionarySize)
329 distanceLimit++;
330 state = state < kNumLitStates ? 9 : 11;
331 pos = dictionaryPos - rep0;
332 if (pos >= dictionarySize)
333 pos += dictionarySize;
334 previousByte = dictionary[pos];
335 dictionary[dictionaryPos] = previousByte;
336 if (++dictionaryPos == dictionarySize)
337 dictionaryPos = 0;
338 outStream[nowPos++] = previousByte;
339 continue;
340 }
341 else
342 {
343 UpdateBit1(prob);
344 }
345 }
346 else
347 {
348 UInt32 distance;
349 UpdateBit1(prob);
350 prob = p + IsRepG1 + state;
351 IfBit0(prob)
352 {
353 UpdateBit0(prob);
354 distance = rep1;
355 }
356 else
357 {
358 UpdateBit1(prob);
359 prob = p + IsRepG2 + state;
360 IfBit0(prob)
361 {
362 UpdateBit0(prob);
363 distance = rep2;
364 }
365 else
366 {
367 UpdateBit1(prob);
368 distance = rep3;
369 rep3 = rep2;
370 }
371 rep2 = rep1;
372 }
373 rep1 = rep0;
374 rep0 = distance;
375 }
376 state = state < kNumLitStates ? 8 : 11;
377 prob = p + RepLenCoder;
378 }
379 {
380 int numBits, offset;
381 CProb *probLen = prob + LenChoice;
382 IfBit0(probLen)
383 {
384 UpdateBit0(probLen);
385 probLen = prob + LenLow + (posState << kLenNumLowBits);
386 offset = 0;
387 numBits = kLenNumLowBits;
388 }
389 else
390 {
391 UpdateBit1(probLen);
392 probLen = prob + LenChoice2;
393 IfBit0(probLen)
394 {
395 UpdateBit0(probLen);
396 probLen = prob + LenMid + (posState << kLenNumMidBits);
397 offset = kLenNumLowSymbols;
398 numBits = kLenNumMidBits;
399 }
400 else
401 {
402 UpdateBit1(probLen);
403 probLen = prob + LenHigh;
404 offset = kLenNumLowSymbols + kLenNumMidSymbols;
405 numBits = kLenNumHighBits;
406 }
407 }
408 RangeDecoderBitTreeDecode(probLen, numBits, len);
409 len += offset;
410 }
411
412 if (state < 4)
413 {
414 int posSlot;
415 state += kNumLitStates;
416 prob = p + PosSlot +
417 ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
418 kNumPosSlotBits);
419 RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
420 if (posSlot >= kStartPosModelIndex)
421 {
422 int numDirectBits = ((posSlot >> 1) - 1);
423 rep0 = (2 | ((UInt32)posSlot & 1));
424 if (posSlot < kEndPosModelIndex)
425 {
426 rep0 <<= numDirectBits;
427 prob = p + SpecPos + rep0 - posSlot - 1;
428 }
429 else
430 {
431 numDirectBits -= kNumAlignBits;
432 do
433 {
434 RC_NORMALIZE
435 Range >>= 1;
436 rep0 <<= 1;
437 if (Code >= Range)
438 {
439 Code -= Range;
440 rep0 |= 1;
441 }
442 }
443 while (--numDirectBits != 0);
444 prob = p + Align;
445 rep0 <<= kNumAlignBits;
446 numDirectBits = kNumAlignBits;
447 }
448 {
449 int i = 1;
450 int mi = 1;
451 do
452 {
453 CProb *prob3 = prob + mi;
454 RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
455 i <<= 1;
456 }
457 while(--numDirectBits != 0);
458 }
459 }
460 else
461 rep0 = posSlot;
462 if (++rep0 == (UInt32)(0))
463 {
464 /* it's for stream version */
465 len = kLzmaStreamWasFinishedId;
466 break;
467 }
468 }
469
470 len += kMatchMinLen;
471 if (rep0 > distanceLimit)
472 return LZMA_RESULT_DATA_ERROR;
473 if (dictionarySize - distanceLimit > (UInt32)len)
474 distanceLimit += len;
475 else
476 distanceLimit = dictionarySize;
477
478 do
479 {
480 UInt32 pos = dictionaryPos - rep0;
481 if (pos >= dictionarySize)
482 pos += dictionarySize;
483 previousByte = dictionary[pos];
484 dictionary[dictionaryPos] = previousByte;
485 if (++dictionaryPos == dictionarySize)
486 dictionaryPos = 0;
487 len--;
488 outStream[nowPos++] = previousByte;
489 }
490 while(len != 0 && nowPos < outSize);
491 }
492 }
493 }
494 RC_NORMALIZE;
495
496 BufferSize -= (int)(Buffer - vs->Buffer);
497 if (BufferSize < 0)
498 return LZMA_RESULT_DATA_ERROR;
499 {
500 int i;
501 for (i = 0; i < BufferSize; i++)
502 vs->Buffer[i] = Buffer[i];
503 }
504 vs->BufferSize = BufferSize;
505 vs->Range = Range;
506 vs->Code = Code;
507 vs->DictionaryPos = dictionaryPos;
508 vs->GlobalPos = (UInt32)(globalPos + nowPos);
509 vs->DistanceLimit = distanceLimit;
510 vs->Reps[0] = rep0;
511 vs->Reps[1] = rep1;
512 vs->Reps[2] = rep2;
513 vs->Reps[3] = rep3;
514 vs->State = state;
515 vs->RemainLen = len;
516 vs->TempDictionary[0] = tempDictionary[0];
517
518 (*outSizeProcessed) = nowPos;
519 return LZMA_RESULT_OK;
520 }
0 /*
1 LzmaStateDecode.h
2 LZMA Decoder interface (State version)
3
4 LZMA SDK 4.40 Copyright (c) 1999-2006 Igor Pavlov (2006-05-01)
5 http://www.7-zip.org/
6
7 LZMA SDK is licensed under two licenses:
8 1) GNU Lesser General Public License (GNU LGPL)
9 2) Common Public License (CPL)
10 It means that you can select one of these two licenses and
11 follow rules of that license.
12
13 SPECIAL EXCEPTION:
14 Igor Pavlov, as the author of this code, expressly permits you to
15 statically or dynamically link your code (or bind by name) to the
16 interfaces of this file without subjecting your linked code to the
17 terms of the CPL or GNU LGPL. Any modifications or additions
18 to this file, however, are subject to the LGPL or CPL terms.
19 */
20
21 #ifndef __LZMASTATEDECODE_H
22 #define __LZMASTATEDECODE_H
23
24 #include "LzmaTypes.h"
25
26 /* #define _LZMA_PROB32 */
27 /* It can increase speed on some 32-bit CPUs,
28 but memory usage will be doubled in that case */
29
30 #ifdef _LZMA_PROB32
31 #define CProb UInt32
32 #else
33 #define CProb UInt16
34 #endif
35
36 #define LZMA_RESULT_OK 0
37 #define LZMA_RESULT_DATA_ERROR 1
38
39 #define LZMA_BASE_SIZE 1846
40 #define LZMA_LIT_SIZE 768
41
42 #define LZMA_PROPERTIES_SIZE 5
43
44 typedef struct _CLzmaProperties
45 {
46 int lc;
47 int lp;
48 int pb;
49 UInt32 DictionarySize;
50 }CLzmaProperties;
51
52 int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
53
54 #define LzmaGetNumProbs(lzmaProps) (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((lzmaProps)->lc + (lzmaProps)->lp)))
55
56 #define kLzmaInBufferSize 64 /* don't change it. it must be larger than kRequiredInBufferSize */
57
58 #define kLzmaNeedInitId (-2)
59
60 typedef struct _CLzmaDecoderState
61 {
62 CLzmaProperties Properties;
63 CProb *Probs;
64 unsigned char *Dictionary;
65
66 unsigned char Buffer[kLzmaInBufferSize];
67 int BufferSize;
68
69 UInt32 Range;
70 UInt32 Code;
71 UInt32 DictionaryPos;
72 UInt32 GlobalPos;
73 UInt32 DistanceLimit;
74 UInt32 Reps[4];
75 int State;
76 int RemainLen; /* -2: decoder needs internal initialization
77 -1: stream was finished,
78 0: ok
79 > 0: need to write RemainLen bytes as match Reps[0],
80 */
81 unsigned char TempDictionary[4]; /* it's required when DictionarySize = 0 */
82 } CLzmaDecoderState;
83
84 #define LzmaDecoderInit(vs) { (vs)->RemainLen = kLzmaNeedInitId; (vs)->BufferSize = 0; }
85
86 /* LzmaDecode: decoding from input stream to output stream.
87 If finishDecoding != 0, then there are no more bytes in input stream
88 after inStream[inSize - 1]. */
89
90 int LzmaDecode(CLzmaDecoderState *vs,
91 const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
92 unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed,
93 int finishDecoding);
94
95 #endif
0 /*
1 LzmaStateTest.c
2 Test application for LZMA Decoder (State version)
3
4 This file written and distributed to public domain by Igor Pavlov.
5 This file is part of LZMA SDK 4.26 (2005-08-02)
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #include "LzmaStateDecode.h"
13
14 const char *kCantReadMessage = "Can not read input file";
15 const char *kCantWriteMessage = "Can not write output file";
16 const char *kCantAllocateMessage = "Can not allocate memory";
17
18 #define kInBufferSize (1 << 15)
19 #define kOutBufferSize (1 << 15)
20
21 unsigned char g_InBuffer[kInBufferSize];
22 unsigned char g_OutBuffer[kOutBufferSize];
23
24 size_t MyReadFile(FILE *file, void *data, size_t size)
25 { return fread(data, 1, size, file); }
26
27 int MyReadFileAndCheck(FILE *file, void *data, size_t size)
28 { return (MyReadFile(file, data, size) == size); }
29
30 int PrintError(char *buffer, const char *message)
31 {
32 sprintf(buffer + strlen(buffer), "\nError: ");
33 sprintf(buffer + strlen(buffer), message);
34 return 1;
35 }
36
37 int main3(FILE *inFile, FILE *outFile, char *rs)
38 {
39 /* We use two 32-bit integers to construct 64-bit integer for file size.
40 You can remove outSizeHigh, if you don't need >= 4GB supporting,
41 or you can use UInt64 outSize, if your compiler supports 64-bit integers*/
42 UInt32 outSize = 0;
43 UInt32 outSizeHigh = 0;
44
45 int waitEOS = 1;
46 /* waitEOS = 1, if there is no uncompressed size in headers,
47 so decoder will wait EOS (End of Stream Marker) in compressed stream */
48
49 int i;
50 int res = 0;
51 CLzmaDecoderState state; /* it's about 140 bytes structure, if int is 32-bit */
52 unsigned char properties[LZMA_PROPERTIES_SIZE];
53 SizeT inAvail = 0;
54 unsigned char *inBuffer = 0;
55
56 if (sizeof(UInt32) < 4)
57 return PrintError(rs, "LZMA decoder needs correct UInt32");
58
59 /* Read LZMA properties for compressed stream */
60
61 if (!MyReadFileAndCheck(inFile, properties, sizeof(properties)))
62 return PrintError(rs, kCantReadMessage);
63
64 /* Read uncompressed size */
65
66 for (i = 0; i < 8; i++)
67 {
68 unsigned char b;
69 if (!MyReadFileAndCheck(inFile, &b, 1))
70 return PrintError(rs, kCantReadMessage);
71 if (b != 0xFF)
72 waitEOS = 0;
73 if (i < 4)
74 outSize += (UInt32)(b) << (i * 8);
75 else
76 outSizeHigh += (UInt32)(b) << ((i - 4) * 8);
77 }
78
79 /* Decode LZMA properties and allocate memory */
80
81 if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
82 return PrintError(rs, "Incorrect stream properties");
83 state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
84 if (state.Probs == 0)
85 return PrintError(rs, kCantAllocateMessage);
86
87 if (state.Properties.DictionarySize == 0)
88 state.Dictionary = 0;
89 else
90 {
91 state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
92 if (state.Dictionary == 0)
93 {
94 free(state.Probs);
95 return PrintError(rs, kCantAllocateMessage);
96 }
97 }
98
99 /* Decompress */
100
101 LzmaDecoderInit(&state);
102
103 do
104 {
105 SizeT inProcessed, outProcessed;
106 int finishDecoding;
107 UInt32 outAvail = kOutBufferSize;
108 if (!waitEOS && outSizeHigh == 0 && outAvail > outSize)
109 outAvail = outSize;
110 if (inAvail == 0)
111 {
112 inAvail = (SizeT)MyReadFile(inFile, g_InBuffer, kInBufferSize);
113 inBuffer = g_InBuffer;
114 }
115 finishDecoding = (inAvail == 0);
116 res = LzmaDecode(&state,
117 inBuffer, inAvail, &inProcessed,
118 g_OutBuffer, outAvail, &outProcessed,
119 finishDecoding);
120 if (res != 0)
121 {
122 sprintf(rs + strlen(rs), "\nDecoding error = %d\n", res);
123 res = 1;
124 break;
125 }
126 inAvail -= inProcessed;
127 inBuffer += inProcessed;
128
129 if (outFile != 0)
130 if (fwrite(g_OutBuffer, 1, outProcessed, outFile) != outProcessed)
131 {
132 PrintError(rs, kCantWriteMessage);
133 res = 1;
134 break;
135 }
136
137 if (outSize < outProcessed)
138 outSizeHigh--;
139 outSize -= (UInt32)outProcessed;
140 outSize &= 0xFFFFFFFF;
141
142 if (outProcessed == 0 && finishDecoding)
143 {
144 if (!waitEOS && (outSize != 0 || outSizeHigh != 0))
145 res = 1;
146 break;
147 }
148 }
149 while ((outSize != 0 && outSizeHigh == 0) || outSizeHigh != 0 || waitEOS);
150
151 free(state.Dictionary);
152 free(state.Probs);
153 return res;
154 }
155
156 int main2(int numArgs, const char *args[], char *rs)
157 {
158 FILE *inFile = 0;
159 FILE *outFile = 0;
160 int res;
161
162 sprintf(rs + strlen(rs), "\nLZMA Decoder 4.26 Copyright (c) 1999-2005 Igor Pavlov 2005-08-02\n");
163 if (numArgs < 2 || numArgs > 3)
164 {
165 sprintf(rs + strlen(rs), "\nUsage: lzmadec file.lzma [outFile]\n");
166 return 1;
167 }
168
169 inFile = fopen(args[1], "rb");
170 if (inFile == 0)
171 return PrintError(rs, "Can not open input file");
172
173 if (numArgs > 2)
174 {
175 outFile = fopen(args[2], "wb+");
176 if (outFile == 0)
177 return PrintError(rs, "Can not open output file");
178 }
179
180 res = main3(inFile, outFile, rs);
181
182 if (outFile != 0)
183 fclose(outFile);
184 fclose(inFile);
185 return res;
186 }
187
188 int main(int numArgs, const char *args[])
189 {
190 char rs[800] = { 0 };
191 int res = main2(numArgs, args, rs);
192 printf(rs);
193 return res;
194 }
0 /*
1 LzmaTest.c
2 Test application for LZMA Decoder
3
4 This file written and distributed to public domain by Igor Pavlov.
5 This file is part of LZMA SDK 4.26 (2005-08-05)
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11
12 #include "LzmaDecode.h"
13
14 const char *kCantReadMessage = "Can not read input file";
15 const char *kCantWriteMessage = "Can not write output file";
16 const char *kCantAllocateMessage = "Can not allocate memory";
17
18 size_t MyReadFile(FILE *file, void *data, size_t size)
19 {
20 if (size == 0)
21 return 0;
22 return fread(data, 1, size, file);
23 }
24
25 int MyReadFileAndCheck(FILE *file, void *data, size_t size)
26 { return (MyReadFile(file, data, size) == size);}
27
28 size_t MyWriteFile(FILE *file, const void *data, size_t size)
29 {
30 if (size == 0)
31 return 0;
32 return fwrite(data, 1, size, file);
33 }
34
35 int MyWriteFileAndCheck(FILE *file, const void *data, size_t size)
36 { return (MyWriteFile(file, data, size) == size); }
37
38 #ifdef _LZMA_IN_CB
39 #define kInBufferSize (1 << 15)
40 typedef struct _CBuffer
41 {
42 ILzmaInCallback InCallback;
43 FILE *File;
44 unsigned char Buffer[kInBufferSize];
45 } CBuffer;
46
47 int LzmaReadCompressed(void *object, const unsigned char **buffer, SizeT *size)
48 {
49 CBuffer *b = (CBuffer *)object;
50 *buffer = b->Buffer;
51 *size = (SizeT)MyReadFile(b->File, b->Buffer, kInBufferSize);
52 return LZMA_RESULT_OK;
53 }
54 CBuffer g_InBuffer;
55
56 #endif
57
58 #ifdef _LZMA_OUT_READ
59 #define kOutBufferSize (1 << 15)
60 unsigned char g_OutBuffer[kOutBufferSize];
61 #endif
62
63 int PrintError(char *buffer, const char *message)
64 {
65 sprintf(buffer + strlen(buffer), "\nError: ");
66 sprintf(buffer + strlen(buffer), message);
67 return 1;
68 }
69
70 int main3(FILE *inFile, FILE *outFile, char *rs)
71 {
72 /* We use two 32-bit integers to construct 64-bit integer for file size.
73 You can remove outSizeHigh, if you don't need >= 4GB supporting,
74 or you can use UInt64 outSize, if your compiler supports 64-bit integers*/
75 UInt32 outSize = 0;
76 UInt32 outSizeHigh = 0;
77 #ifndef _LZMA_OUT_READ
78 SizeT outSizeFull;
79 unsigned char *outStream;
80 #endif
81
82 int waitEOS = 1;
83 /* waitEOS = 1, if there is no uncompressed size in headers,
84 so decoder will wait EOS (End of Stream Marker) in compressed stream */
85
86 #ifndef _LZMA_IN_CB
87 SizeT compressedSize;
88 unsigned char *inStream;
89 #endif
90
91 CLzmaDecoderState state; /* it's about 24-80 bytes structure, if int is 32-bit */
92 unsigned char properties[LZMA_PROPERTIES_SIZE];
93
94 int res;
95
96 #ifdef _LZMA_IN_CB
97 g_InBuffer.File = inFile;
98 #endif
99
100 if (sizeof(UInt32) < 4)
101 return PrintError(rs, "LZMA decoder needs correct UInt32");
102
103 #ifndef _LZMA_IN_CB
104 {
105 long length;
106 fseek(inFile, 0, SEEK_END);
107 length = ftell(inFile);
108 fseek(inFile, 0, SEEK_SET);
109 if ((long)(SizeT)length != length)
110 return PrintError(rs, "Too big compressed stream");
111 compressedSize = (SizeT)(length - (LZMA_PROPERTIES_SIZE + 8));
112 }
113 #endif
114
115 /* Read LZMA properties for compressed stream */
116
117 if (!MyReadFileAndCheck(inFile, properties, sizeof(properties)))
118 return PrintError(rs, kCantReadMessage);
119
120 /* Read uncompressed size */
121
122 {
123 int i;
124 for (i = 0; i < 8; i++)
125 {
126 unsigned char b;
127 if (!MyReadFileAndCheck(inFile, &b, 1))
128 return PrintError(rs, kCantReadMessage);
129 if (b != 0xFF)
130 waitEOS = 0;
131 if (i < 4)
132 outSize += (UInt32)(b) << (i * 8);
133 else
134 outSizeHigh += (UInt32)(b) << ((i - 4) * 8);
135 }
136
137 #ifndef _LZMA_OUT_READ
138 if (waitEOS)
139 return PrintError(rs, "Stream with EOS marker is not supported");
140 outSizeFull = (SizeT)outSize;
141 if (sizeof(SizeT) >= 8)
142 outSizeFull |= (((SizeT)outSizeHigh << 16) << 16);
143 else if (outSizeHigh != 0 || (UInt32)(SizeT)outSize != outSize)
144 return PrintError(rs, "Too big uncompressed stream");
145 #endif
146 }
147
148 /* Decode LZMA properties and allocate memory */
149
150 if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
151 return PrintError(rs, "Incorrect stream properties");
152 state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
153
154 #ifdef _LZMA_OUT_READ
155 if (state.Properties.DictionarySize == 0)
156 state.Dictionary = 0;
157 else
158 state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
159 #else
160 if (outSizeFull == 0)
161 outStream = 0;
162 else
163 outStream = (unsigned char *)malloc(outSizeFull);
164 #endif
165
166 #ifndef _LZMA_IN_CB
167 if (compressedSize == 0)
168 inStream = 0;
169 else
170 inStream = (unsigned char *)malloc(compressedSize);
171 #endif
172
173 if (state.Probs == 0
174 #ifdef _LZMA_OUT_READ
175 || (state.Dictionary == 0 && state.Properties.DictionarySize != 0)
176 #else
177 || (outStream == 0 && outSizeFull != 0)
178 #endif
179 #ifndef _LZMA_IN_CB
180 || (inStream == 0 && compressedSize != 0)
181 #endif
182 )
183 {
184 free(state.Probs);
185 #ifdef _LZMA_OUT_READ
186 free(state.Dictionary);
187 #else
188 free(outStream);
189 #endif
190 #ifndef _LZMA_IN_CB
191 free(inStream);
192 #endif
193 return PrintError(rs, kCantAllocateMessage);
194 }
195
196 /* Decompress */
197
198 #ifdef _LZMA_IN_CB
199 g_InBuffer.InCallback.Read = LzmaReadCompressed;
200 #else
201 if (!MyReadFileAndCheck(inFile, inStream, compressedSize))
202 return PrintError(rs, kCantReadMessage);
203 #endif
204
205 #ifdef _LZMA_OUT_READ
206 {
207 #ifndef _LZMA_IN_CB
208 SizeT inAvail = compressedSize;
209 const unsigned char *inBuffer = inStream;
210 #endif
211 LzmaDecoderInit(&state);
212 do
213 {
214 #ifndef _LZMA_IN_CB
215 SizeT inProcessed;
216 #endif
217 SizeT outProcessed;
218 SizeT outAvail = kOutBufferSize;
219 if (!waitEOS && outSizeHigh == 0 && outAvail > outSize)
220 outAvail = (SizeT)outSize;
221 res = LzmaDecode(&state,
222 #ifdef _LZMA_IN_CB
223 &g_InBuffer.InCallback,
224 #else
225 inBuffer, inAvail, &inProcessed,
226 #endif
227 g_OutBuffer, outAvail, &outProcessed);
228 if (res != 0)
229 {
230 sprintf(rs + strlen(rs), "\nDecoding error = %d\n", res);
231 res = 1;
232 break;
233 }
234 #ifndef _LZMA_IN_CB
235 inAvail -= inProcessed;
236 inBuffer += inProcessed;
237 #endif
238
239 if (outFile != 0)
240 if (!MyWriteFileAndCheck(outFile, g_OutBuffer, (size_t)outProcessed))
241 {
242 PrintError(rs, kCantWriteMessage);
243 res = 1;
244 break;
245 }
246
247 if (outSize < outProcessed)
248 outSizeHigh--;
249 outSize -= (UInt32)outProcessed;
250 outSize &= 0xFFFFFFFF;
251
252 if (outProcessed == 0)
253 {
254 if (!waitEOS && (outSize != 0 || outSizeHigh != 0))
255 res = 1;
256 break;
257 }
258 }
259 while ((outSize != 0 && outSizeHigh == 0) || outSizeHigh != 0 || waitEOS);
260 }
261
262 #else
263 {
264 #ifndef _LZMA_IN_CB
265 SizeT inProcessed;
266 #endif
267 SizeT outProcessed;
268 res = LzmaDecode(&state,
269 #ifdef _LZMA_IN_CB
270 &g_InBuffer.InCallback,
271 #else
272 inStream, compressedSize, &inProcessed,
273 #endif
274 outStream, outSizeFull, &outProcessed);
275 if (res != 0)
276 {
277 sprintf(rs + strlen(rs), "\nDecoding error = %d\n", res);
278 res = 1;
279 }
280 else if (outFile != 0)
281 {
282 if (!MyWriteFileAndCheck(outFile, outStream, (size_t)outProcessed))
283 {
284 PrintError(rs, kCantWriteMessage);
285 res = 1;
286 }
287 }
288 }
289 #endif
290
291 free(state.Probs);
292 #ifdef _LZMA_OUT_READ
293 free(state.Dictionary);
294 #else
295 free(outStream);
296 #endif
297 #ifndef _LZMA_IN_CB
298 free(inStream);
299 #endif
300 return res;
301 }
302
303 int main2(int numArgs, const char *args[], char *rs)
304 {
305 FILE *inFile = 0;
306 FILE *outFile = 0;
307 int res;
308
309 sprintf(rs + strlen(rs), "\nLZMA Decoder 4.26 Copyright (c) 1999-2005 Igor Pavlov 2005-08-05\n");
310 if (numArgs < 2 || numArgs > 3)
311 {
312 sprintf(rs + strlen(rs), "\nUsage: lzmadec file.lzma [outFile]\n");
313 return 1;
314 }
315
316 inFile = fopen(args[1], "rb");
317 if (inFile == 0)
318 return PrintError(rs, "Can not open input file");
319
320 if (numArgs > 2)
321 {
322 outFile = fopen(args[2], "wb+");
323 if (outFile == 0)
324 return PrintError(rs, "Can not open output file");
325 }
326
327 res = main3(inFile, outFile, rs);
328
329 if (outFile != 0)
330 fclose(outFile);
331 fclose(inFile);
332 return res;
333 }
334
335 int main(int numArgs, const char *args[])
336 {
337 char rs[800] = { 0 };
338 int res = main2(numArgs, args, rs);
339 printf(rs);
340 return res;
341 }
0 /*
1 LzmaTypes.h
2
3 Types for LZMA Decoder
4
5 This file written and distributed to public domain by Igor Pavlov.
6 This file is part of LZMA SDK 4.40 (2006-05-01)
7 */
8
9 #ifndef __LZMATYPES_H
10 #define __LZMATYPES_H
11
12 #ifndef _7ZIP_BYTE_DEFINED
13 #define _7ZIP_BYTE_DEFINED
14 typedef unsigned char Byte;
15 #endif
16
17 #ifndef _7ZIP_UINT16_DEFINED
18 #define _7ZIP_UINT16_DEFINED
19 typedef unsigned short UInt16;
20 #endif
21
22 #ifndef _7ZIP_UINT32_DEFINED
23 #define _7ZIP_UINT32_DEFINED
24 #ifdef _LZMA_UINT32_IS_ULONG
25 typedef unsigned long UInt32;
26 #else
27 typedef unsigned int UInt32;
28 #endif
29 #endif
30
31 /* #define _LZMA_SYSTEM_SIZE_T */
32 /* Use system's size_t. You can use it to enable 64-bit sizes supporting */
33
34 #ifndef _7ZIP_SIZET_DEFINED
35 #define _7ZIP_SIZET_DEFINED
36 #ifdef _LZMA_SYSTEM_SIZE_T
37 #include <stddef.h>
38 typedef size_t SizeT;
39 #else
40 typedef UInt32 SizeT;
41 #endif
42 #endif
43
44 #endif
0 PROG = lzmaDec.exe
1
2 !IFNDEF O
3 !IFDEF CPU
4 O=$(CPU)
5 !ELSE
6 O=O
7 !ENDIF
8 !ENDIF
9
10 CFLAGS = $(CFLAGS) -nologo -c -Fo$O/ -GS-
11 CFLAGS_O1 = $(CFLAGS) -O1
12 CFLAGS_O2 = $(CFLAGS) -O2
13
14 LFLAGS = $(LFLAGS) -nologo -OPT:NOWIN98
15
16 PROGPATH = $O\$(PROG)
17
18 COMPL_O1 = $(CPP) $(CFLAGS_O1) $**
19 COMPL_O2 = $(CPP) $(CFLAGS_O2) $**
20 COMPL = $(CPP) $(CFLAGS_O1) $**
21
22
23 OBJS = \
24 $O\LzmaTest.obj \
25 $O\LzmaDecode.obj \
26
27 all: $(PROGPATH)
28
29 clean:
30 -del /Q $(PROGPATH) $O\*.exe $O\*.dll $O\*.obj $O\*.lib $O\*.exp $O\*.res $O\*.pch
31
32 $O:
33 if not exist "$O" mkdir "$O"
34
35 $(PROGPATH): $O $(OBJS)
36 link $(LFLAGS) -out:$(PROGPATH) $(OBJS) $(LIBS)
37
38
39 $O\LzmaTest.obj: $(*B).c
40 $(COMPL)
41 $O\LzmaDecode.obj: ../../Compress/LZMA_C/$(*B).c
42 $(COMPL_O2)
0 PROG = lzmadec
1 CXX = gcc
2 LIB =
3 RM = rm -f
4 CFLAGS = -c -O2 -Wall -pedantic -D _LZMA_PROB32
5
6 OBJS = LzmaTest.o LzmaDecode.o
7
8 all: $(PROG)
9
10 $(PROG): $(OBJS)
11 $(CXX) -o $(PROG) $(LDFLAGS) $(OBJS) $(LIB)
12
13 LzmaTest.o: LzmaTest.c
14 $(CXX) $(CFLAGS) LzmaTest.c
15
16 LzmaDecode.o: LzmaDecode.c
17 $(CXX) $(CFLAGS) LzmaDecode.c
18
19
20 clean:
21 -$(RM) $(PROG) $(OBJS)
22
0 // Compress/RangeCoder/RangeCoder.h
1
2 #ifndef __COMPRESS_RANGECODER_H
3 #define __COMPRESS_RANGECODER_H
4
5 #include "../../Common/InBuffer.h"
6 #include "../../Common/OutBuffer.h"
7
8 namespace NCompress {
9 namespace NRangeCoder {
10
11 const int kNumTopBits = 24;
12 const UInt32 kTopValue = (1 << kNumTopBits);
13
14 class CEncoder
15 {
16 UInt32 _cacheSize;
17 Byte _cache;
18 public:
19 UInt64 Low;
20 UInt32 Range;
21 COutBuffer Stream;
22 bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
23
24 void SetStream(ISequentialOutStream *stream) { Stream.SetStream(stream); }
25 void Init()
26 {
27 Stream.Init();
28 Low = 0;
29 Range = 0xFFFFFFFF;
30 _cacheSize = 1;
31 _cache = 0;
32 }
33
34 void FlushData()
35 {
36 // Low += 1;
37 for(int i = 0; i < 5; i++)
38 ShiftLow();
39 }
40
41 HRESULT FlushStream() { return Stream.Flush(); }
42
43 void ReleaseStream() { Stream.ReleaseStream(); }
44
45 void Encode(UInt32 start, UInt32 size, UInt32 total)
46 {
47 Low += start * (Range /= total);
48 Range *= size;
49 while (Range < kTopValue)
50 {
51 Range <<= 8;
52 ShiftLow();
53 }
54 }
55
56 void ShiftLow()
57 {
58 if ((UInt32)Low < (UInt32)0xFF000000 || (int)(Low >> 32) != 0)
59 {
60 Byte temp = _cache;
61 do
62 {
63 Stream.WriteByte((Byte)(temp + (Byte)(Low >> 32)));
64 temp = 0xFF;
65 }
66 while(--_cacheSize != 0);
67 _cache = (Byte)((UInt32)Low >> 24);
68 }
69 _cacheSize++;
70 Low = (UInt32)Low << 8;
71 }
72
73 void EncodeDirectBits(UInt32 value, int numTotalBits)
74 {
75 for (int i = numTotalBits - 1; i >= 0; i--)
76 {
77 Range >>= 1;
78 if (((value >> i) & 1) == 1)
79 Low += Range;
80 if (Range < kTopValue)
81 {
82 Range <<= 8;
83 ShiftLow();
84 }
85 }
86 }
87
88 void EncodeBit(UInt32 size0, UInt32 numTotalBits, UInt32 symbol)
89 {
90 UInt32 newBound = (Range >> numTotalBits) * size0;
91 if (symbol == 0)
92 Range = newBound;
93 else
94 {
95 Low += newBound;
96 Range -= newBound;
97 }
98 while (Range < kTopValue)
99 {
100 Range <<= 8;
101 ShiftLow();
102 }
103 }
104
105 UInt64 GetProcessedSize() { return Stream.GetProcessedSize() + _cacheSize + 4; }
106 };
107
108 class CDecoder
109 {
110 public:
111 CInBuffer Stream;
112 UInt32 Range;
113 UInt32 Code;
114 bool Create(UInt32 bufferSize) { return Stream.Create(bufferSize); }
115
116 void Normalize()
117 {
118 while (Range < kTopValue)
119 {
120 Code = (Code << 8) | Stream.ReadByte();
121 Range <<= 8;
122 }
123 }
124
125 void SetStream(ISequentialInStream *stream) { Stream.SetStream(stream); }
126 void Init()
127 {
128 Stream.Init();
129 Code = 0;
130 Range = 0xFFFFFFFF;
131 for(int i = 0; i < 5; i++)
132 Code = (Code << 8) | Stream.ReadByte();
133 }
134
135 void ReleaseStream() { Stream.ReleaseStream(); }
136
137 UInt32 GetThreshold(UInt32 total)
138 {
139 return (Code) / ( Range /= total);
140 }
141
142 void Decode(UInt32 start, UInt32 size)
143 {
144 Code -= start * Range;
145 Range *= size;
146 Normalize();
147 }
148
149 UInt32 DecodeDirectBits(int numTotalBits)
150 {
151 UInt32 range = Range;
152 UInt32 code = Code;
153 UInt32 result = 0;
154 for (int i = numTotalBits; i != 0; i--)
155 {
156 range >>= 1;
157 /*
158 result <<= 1;
159 if (code >= range)
160 {
161 code -= range;
162 result |= 1;
163 }
164 */
165 UInt32 t = (code - range) >> 31;
166 code -= range & (t - 1);
167 result = (result << 1) | (1 - t);
168
169 if (range < kTopValue)
170 {
171 code = (code << 8) | Stream.ReadByte();
172 range <<= 8;
173 }
174 }
175 Range = range;
176 Code = code;
177 return result;
178 }
179
180 UInt32 DecodeBit(UInt32 size0, UInt32 numTotalBits)
181 {
182 UInt32 newBound = (Range >> numTotalBits) * size0;
183 UInt32 symbol;
184 if (Code < newBound)
185 {
186 symbol = 0;
187 Range = newBound;
188 }
189 else
190 {
191 symbol = 1;
192 Code -= newBound;
193 Range -= newBound;
194 }
195 Normalize();
196 return symbol;
197 }
198
199 UInt64 GetProcessedSize() {return Stream.GetProcessedSize(); }
200 };
201
202 }}
203
204 #endif
0 // Compress/RangeCoder/RangeCoderBit.cpp
1
2 #include "StdAfx.h"
3
4 #include "RangeCoderBit.h"
5
6 namespace NCompress {
7 namespace NRangeCoder {
8
9 UInt32 CPriceTables::ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
10 static CPriceTables g_PriceTables;
11
12 CPriceTables::CPriceTables() { Init(); }
13
14 void CPriceTables::Init()
15 {
16 const int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits);
17 for(int i = kNumBits - 1; i >= 0; i--)
18 {
19 UInt32 start = 1 << (kNumBits - i - 1);
20 UInt32 end = 1 << (kNumBits - i);
21 for (UInt32 j = start; j < end; j++)
22 ProbPrices[j] = (i << kNumBitPriceShiftBits) +
23 (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1));
24 }
25
26 /*
27 // simplest: bad solution
28 for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
29 ProbPrices[i] = kBitPrice;
30 */
31
32 /*
33 const double kDummyMultMid = (1.0 / kBitPrice) / 2;
34 const double kDummyMultMid = 0;
35 // float solution
36 double ln2 = log(double(2));
37 double lnAll = log(double(kBitModelTotal >> kNumMoveReducingBits));
38 for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
39 ProbPrices[i] = UInt32((fabs(lnAll - log(double(i))) / ln2 + kDummyMultMid) * kBitPrice);
40 */
41
42 /*
43 // experimental, slow, solution:
44 for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++)
45 {
46 const int kCyclesBits = 5;
47 const UInt32 kCycles = (1 << kCyclesBits);
48
49 UInt32 range = UInt32(-1);
50 UInt32 bitCount = 0;
51 for (UInt32 j = 0; j < kCycles; j++)
52 {
53 range >>= (kNumBitModelTotalBits - kNumMoveReducingBits);
54 range *= i;
55 while(range < (1 << 31))
56 {
57 range <<= 1;
58 bitCount++;
59 }
60 }
61 bitCount <<= kNumBitPriceShiftBits;
62 range -= (1 << 31);
63 for (int k = kNumBitPriceShiftBits - 1; k >= 0; k--)
64 {
65 range <<= 1;
66 if (range > (1 << 31))
67 {
68 bitCount += (1 << k);
69 range -= (1 << 31);
70 }
71 }
72 ProbPrices[i] = (bitCount
73 // + (1 << (kCyclesBits - 1))
74 ) >> kCyclesBits;
75 }
76 */
77 }
78
79 }}
0 // Compress/RangeCoder/RangeCoderBit.h
1
2 #ifndef __COMPRESS_RANGECODER_BIT_H
3 #define __COMPRESS_RANGECODER_BIT_H
4
5 #include "RangeCoder.h"
6
7 namespace NCompress {
8 namespace NRangeCoder {
9
10 const int kNumBitModelTotalBits = 11;
11 const UInt32 kBitModelTotal = (1 << kNumBitModelTotalBits);
12
13 const int kNumMoveReducingBits = 2;
14
15 const int kNumBitPriceShiftBits = 6;
16 const UInt32 kBitPrice = 1 << kNumBitPriceShiftBits;
17
18 class CPriceTables
19 {
20 public:
21 static UInt32 ProbPrices[kBitModelTotal >> kNumMoveReducingBits];
22 static void Init();
23 CPriceTables();
24 };
25
26 template <int numMoveBits>
27 class CBitModel
28 {
29 public:
30 UInt32 Prob;
31 void UpdateModel(UInt32 symbol)
32 {
33 /*
34 Prob -= (Prob + ((symbol - 1) & ((1 << numMoveBits) - 1))) >> numMoveBits;
35 Prob += (1 - symbol) << (kNumBitModelTotalBits - numMoveBits);
36 */
37 if (symbol == 0)
38 Prob += (kBitModelTotal - Prob) >> numMoveBits;
39 else
40 Prob -= (Prob) >> numMoveBits;
41 }
42 public:
43 void Init() { Prob = kBitModelTotal / 2; }
44 };
45
46 template <int numMoveBits>
47 class CBitEncoder: public CBitModel<numMoveBits>
48 {
49 public:
50 void Encode(CEncoder *encoder, UInt32 symbol)
51 {
52 /*
53 encoder->EncodeBit(this->Prob, kNumBitModelTotalBits, symbol);
54 this->UpdateModel(symbol);
55 */
56 UInt32 newBound = (encoder->Range >> kNumBitModelTotalBits) * this->Prob;
57 if (symbol == 0)
58 {
59 encoder->Range = newBound;
60 this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
61 }
62 else
63 {
64 encoder->Low += newBound;
65 encoder->Range -= newBound;
66 this->Prob -= (this->Prob) >> numMoveBits;
67 }
68 if (encoder->Range < kTopValue)
69 {
70 encoder->Range <<= 8;
71 encoder->ShiftLow();
72 }
73 }
74 UInt32 GetPrice(UInt32 symbol) const
75 {
76 return CPriceTables::ProbPrices[
77 (((this->Prob - symbol) ^ ((-(int)symbol))) & (kBitModelTotal - 1)) >> kNumMoveReducingBits];
78 }
79 UInt32 GetPrice0() const { return CPriceTables::ProbPrices[this->Prob >> kNumMoveReducingBits]; }
80 UInt32 GetPrice1() const { return CPriceTables::ProbPrices[(kBitModelTotal - this->Prob) >> kNumMoveReducingBits]; }
81 };
82
83
84 template <int numMoveBits>
85 class CBitDecoder: public CBitModel<numMoveBits>
86 {
87 public:
88 UInt32 Decode(CDecoder *decoder)
89 {
90 UInt32 newBound = (decoder->Range >> kNumBitModelTotalBits) * this->Prob;
91 if (decoder->Code < newBound)
92 {
93 decoder->Range = newBound;
94 this->Prob += (kBitModelTotal - this->Prob) >> numMoveBits;
95 if (decoder->Range < kTopValue)
96 {
97 decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
98 decoder->Range <<= 8;
99 }
100 return 0;
101 }
102 else
103 {
104 decoder->Range -= newBound;
105 decoder->Code -= newBound;
106 this->Prob -= (this->Prob) >> numMoveBits;
107 if (decoder->Range < kTopValue)
108 {
109 decoder->Code = (decoder->Code << 8) | decoder->Stream.ReadByte();
110 decoder->Range <<= 8;
111 }
112 return 1;
113 }
114 }
115 };
116
117 }}
118
119 #endif
0 // Compress/RangeCoder/RangeCoderBitTree.h
1
2 #ifndef __COMPRESS_RANGECODER_BIT_TREE_H
3 #define __COMPRESS_RANGECODER_BIT_TREE_H
4
5 #include "RangeCoderBit.h"
6 #include "RangeCoderOpt.h"
7
8 namespace NCompress {
9 namespace NRangeCoder {
10
11 template <int numMoveBits, int NumBitLevels>
12 class CBitTreeEncoder
13 {
14 CBitEncoder<numMoveBits> Models[1 << NumBitLevels];
15 public:
16 void Init()
17 {
18 for(UInt32 i = 1; i < (1 << NumBitLevels); i++)
19 Models[i].Init();
20 }
21 void Encode(CEncoder *rangeEncoder, UInt32 symbol)
22 {
23 UInt32 modelIndex = 1;
24 for (int bitIndex = NumBitLevels; bitIndex != 0 ;)
25 {
26 bitIndex--;
27 UInt32 bit = (symbol >> bitIndex) & 1;
28 Models[modelIndex].Encode(rangeEncoder, bit);
29 modelIndex = (modelIndex << 1) | bit;
30 }
31 };
32 void ReverseEncode(CEncoder *rangeEncoder, UInt32 symbol)
33 {
34 UInt32 modelIndex = 1;
35 for (int i = 0; i < NumBitLevels; i++)
36 {
37 UInt32 bit = symbol & 1;
38 Models[modelIndex].Encode(rangeEncoder, bit);
39 modelIndex = (modelIndex << 1) | bit;
40 symbol >>= 1;
41 }
42 }
43 UInt32 GetPrice(UInt32 symbol) const
44 {
45 symbol |= (1 << NumBitLevels);
46 UInt32 price = 0;
47 while (symbol != 1)
48 {
49 price += Models[symbol >> 1].GetPrice(symbol & 1);
50 symbol >>= 1;
51 }
52 return price;
53 }
54 UInt32 ReverseGetPrice(UInt32 symbol) const
55 {
56 UInt32 price = 0;
57 UInt32 modelIndex = 1;
58 for (int i = NumBitLevels; i != 0; i--)
59 {
60 UInt32 bit = symbol & 1;
61 symbol >>= 1;
62 price += Models[modelIndex].GetPrice(bit);
63 modelIndex = (modelIndex << 1) | bit;
64 }
65 return price;
66 }
67 };
68
69 template <int numMoveBits, int NumBitLevels>
70 class CBitTreeDecoder
71 {
72 CBitDecoder<numMoveBits> Models[1 << NumBitLevels];
73 public:
74 void Init()
75 {
76 for(UInt32 i = 1; i < (1 << NumBitLevels); i++)
77 Models[i].Init();
78 }
79 UInt32 Decode(CDecoder *rangeDecoder)
80 {
81 UInt32 modelIndex = 1;
82 RC_INIT_VAR
83 for(int bitIndex = NumBitLevels; bitIndex != 0; bitIndex--)
84 {
85 // modelIndex = (modelIndex << 1) + Models[modelIndex].Decode(rangeDecoder);
86 RC_GETBIT(numMoveBits, Models[modelIndex].Prob, modelIndex)
87 }
88 RC_FLUSH_VAR
89 return modelIndex - (1 << NumBitLevels);
90 };
91 UInt32 ReverseDecode(CDecoder *rangeDecoder)
92 {
93 UInt32 modelIndex = 1;
94 UInt32 symbol = 0;
95 RC_INIT_VAR
96 for(int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
97 {
98 // UInt32 bit = Models[modelIndex].Decode(rangeDecoder);
99 // modelIndex <<= 1;
100 // modelIndex += bit;
101 // symbol |= (bit << bitIndex);
102 RC_GETBIT2(numMoveBits, Models[modelIndex].Prob, modelIndex, ; , symbol |= (1 << bitIndex))
103 }
104 RC_FLUSH_VAR
105 return symbol;
106 }
107 };
108
109 template <int numMoveBits>
110 void ReverseBitTreeEncode(CBitEncoder<numMoveBits> *Models,
111 CEncoder *rangeEncoder, int NumBitLevels, UInt32 symbol)
112 {
113 UInt32 modelIndex = 1;
114 for (int i = 0; i < NumBitLevels; i++)
115 {
116 UInt32 bit = symbol & 1;
117 Models[modelIndex].Encode(rangeEncoder, bit);
118 modelIndex = (modelIndex << 1) | bit;
119 symbol >>= 1;
120 }
121 }
122
123 template <int numMoveBits>
124 UInt32 ReverseBitTreeGetPrice(CBitEncoder<numMoveBits> *Models,
125 UInt32 NumBitLevels, UInt32 symbol)
126 {
127 UInt32 price = 0;
128 UInt32 modelIndex = 1;
129 for (int i = NumBitLevels; i != 0; i--)
130 {
131 UInt32 bit = symbol & 1;
132 symbol >>= 1;
133 price += Models[modelIndex].GetPrice(bit);
134 modelIndex = (modelIndex << 1) | bit;
135 }
136 return price;
137 }
138
139 template <int numMoveBits>
140 UInt32 ReverseBitTreeDecode(CBitDecoder<numMoveBits> *Models,
141 CDecoder *rangeDecoder, int NumBitLevels)
142 {
143 UInt32 modelIndex = 1;
144 UInt32 symbol = 0;
145 RC_INIT_VAR
146 for(int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
147 {
148 // UInt32 bit = Models[modelIndex].Decode(rangeDecoder);
149 // modelIndex <<= 1;
150 // modelIndex += bit;
151 // symbol |= (bit << bitIndex);
152 RC_GETBIT2(numMoveBits, Models[modelIndex].Prob, modelIndex, ; , symbol |= (1 << bitIndex))
153 }
154 RC_FLUSH_VAR
155 return symbol;
156 }
157
158 }}
159
160 #endif
0 // Compress/RangeCoder/RangeCoderOpt.h
1
2 #ifndef __COMPRESS_RANGECODER_OPT_H
3 #define __COMPRESS_RANGECODER_OPT_H
4
5 #define RC_INIT_VAR \
6 UInt32 range = rangeDecoder->Range; \
7 UInt32 code = rangeDecoder->Code;
8
9 #define RC_FLUSH_VAR \
10 rangeDecoder->Range = range; \
11 rangeDecoder->Code = code;
12
13 #define RC_NORMALIZE \
14 if (range < NCompress::NRangeCoder::kTopValue) \
15 { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; }
16
17 #define RC_GETBIT2(numMoveBits, prob, mi, A0, A1) \
18 { UInt32 bound = (range >> NCompress::NRangeCoder::kNumBitModelTotalBits) * prob; \
19 if (code < bound) \
20 { A0; range = bound; \
21 prob += (NCompress::NRangeCoder::kBitModelTotal - prob) >> numMoveBits; \
22 mi <<= 1; } \
23 else \
24 { A1; range -= bound; code -= bound; prob -= (prob) >> numMoveBits; \
25 mi = (mi + mi) + 1; }} \
26 RC_NORMALIZE
27
28 #define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;)
29
30 #endif
0 // StdAfx.h
1
2 #ifndef __STDAFX_H
3 #define __STDAFX_H
4
5 #endif
0 // ICoder.h
1
2 #ifndef __ICODER_H
3 #define __ICODER_H
4
5 #include "IStream.h"
6
7 // "23170F69-40C1-278A-0000-000400xx0000"
8 #define CODER_INTERFACE(i, x) \
9 DEFINE_GUID(IID_ ## i, \
10 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x04, 0x00, x, 0x00, 0x00); \
11 struct i: public IUnknown
12
13 CODER_INTERFACE(ICompressProgressInfo, 0x04)
14 {
15 STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize) PURE;
16 };
17
18 CODER_INTERFACE(ICompressCoder, 0x05)
19 {
20 STDMETHOD(Code)(ISequentialInStream *inStream,
21 ISequentialOutStream *outStream,
22 const UInt64 *inSize,
23 const UInt64 *outSize,
24 ICompressProgressInfo *progress) PURE;
25 };
26
27 CODER_INTERFACE(ICompressCoder2, 0x18)
28 {
29 STDMETHOD(Code)(ISequentialInStream **inStreams,
30 const UInt64 **inSizes,
31 UInt32 numInStreams,
32 ISequentialOutStream **outStreams,
33 const UInt64 **outSizes,
34 UInt32 numOutStreams,
35 ICompressProgressInfo *progress) PURE;
36 };
37
38 namespace NCoderPropID
39 {
40 enum EEnum
41 {
42 kDictionarySize = 0x400,
43 kUsedMemorySize,
44 kOrder,
45 kPosStateBits = 0x440,
46 kLitContextBits,
47 kLitPosBits,
48 kNumFastBytes = 0x450,
49 kMatchFinder,
50 kMatchFinderCycles,
51 kNumPasses = 0x460,
52 kAlgorithm = 0x470,
53 kMultiThread = 0x480,
54 kNumThreads,
55 kEndMarker = 0x490
56 };
57 }
58
59 CODER_INTERFACE(ICompressSetCoderProperties, 0x20)
60 {
61 STDMETHOD(SetCoderProperties)(const PROPID *propIDs,
62 const PROPVARIANT *properties, UInt32 numProperties) PURE;
63 };
64
65 /*
66 CODER_INTERFACE(ICompressSetCoderProperties, 0x21)
67 {
68 STDMETHOD(SetDecoderProperties)(ISequentialInStream *inStream) PURE;
69 };
70 */
71
72 CODER_INTERFACE(ICompressSetDecoderProperties2, 0x22)
73 {
74 STDMETHOD(SetDecoderProperties2)(const Byte *data, UInt32 size) PURE;
75 };
76
77 CODER_INTERFACE(ICompressWriteCoderProperties, 0x23)
78 {
79 STDMETHOD(WriteCoderProperties)(ISequentialOutStream *outStreams) PURE;
80 };
81
82 CODER_INTERFACE(ICompressGetInStreamProcessedSize, 0x24)
83 {
84 STDMETHOD(GetInStreamProcessedSize)(UInt64 *value) PURE;
85 };
86
87 CODER_INTERFACE(ICompressSetCoderMt, 0x25)
88 {
89 STDMETHOD(SetNumberOfThreads)(UInt32 numThreads) PURE;
90 };
91
92 CODER_INTERFACE(ICompressGetSubStreamSize, 0x30)
93 {
94 STDMETHOD(GetSubStreamSize)(UInt64 subStream, UInt64 *value) PURE;
95 };
96
97 CODER_INTERFACE(ICompressSetInStream, 0x31)
98 {
99 STDMETHOD(SetInStream)(ISequentialInStream *inStream) PURE;
100 STDMETHOD(ReleaseInStream)() PURE;
101 };
102
103 CODER_INTERFACE(ICompressSetOutStream, 0x32)
104 {
105 STDMETHOD(SetOutStream)(ISequentialOutStream *outStream) PURE;
106 STDMETHOD(ReleaseOutStream)() PURE;
107 };
108
109 CODER_INTERFACE(ICompressSetInStreamSize, 0x33)
110 {
111 STDMETHOD(SetInStreamSize)(const UInt64 *inSize) PURE;
112 };
113
114 CODER_INTERFACE(ICompressSetOutStreamSize, 0x34)
115 {
116 STDMETHOD(SetOutStreamSize)(const UInt64 *outSize) PURE;
117 };
118
119 CODER_INTERFACE(ICompressFilter, 0x40)
120 {
121 STDMETHOD(Init)() PURE;
122 STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size) PURE;
123 // Filter return outSize (UInt32)
124 // if (outSize <= size): Filter have converted outSize bytes
125 // if (outSize > size): Filter have not converted anything.
126 // and it needs at least outSize bytes to convert one block
127 // (it's for crypto block algorithms).
128 };
129
130 CODER_INTERFACE(ICryptoProperties, 0x80)
131 {
132 STDMETHOD(SetKey)(const Byte *data, UInt32 size) PURE;
133 STDMETHOD(SetInitVector)(const Byte *data, UInt32 size) PURE;
134 };
135
136 CODER_INTERFACE(ICryptoSetPassword, 0x90)
137 {
138 STDMETHOD(CryptoSetPassword)(const Byte *data, UInt32 size) PURE;
139 };
140
141 CODER_INTERFACE(ICryptoSetCRC, 0xA0)
142 {
143 STDMETHOD(CryptoSetCRC)(UInt32 crc) PURE;
144 };
145
146 //////////////////////
147 // It's for DLL file
148 namespace NMethodPropID
149 {
150 enum EEnum
151 {
152 kID,
153 kName,
154 kDecoder,
155 kEncoder,
156 kInStreams,
157 kOutStreams,
158 kDescription
159 };
160 }
161
162 #endif
0 // IStream.h
1
2 #ifndef __ISTREAM_H
3 #define __ISTREAM_H
4
5 #include "../Common/MyUnknown.h"
6 #include "../Common/Types.h"
7
8 // "23170F69-40C1-278A-0000-000300xx0000"
9
10 #define STREAM_INTERFACE_SUB(i, b, x) \
11 DEFINE_GUID(IID_ ## i, \
12 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, x, 0x00, 0x00); \
13 struct i: public b
14
15 #define STREAM_INTERFACE(i, x) STREAM_INTERFACE_SUB(i, IUnknown, x)
16
17 STREAM_INTERFACE(ISequentialInStream, 0x01)
18 {
19 STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE;
20 /*
21 Out: if size != 0, return_value = S_OK and (*processedSize == 0),
22 then there are no more bytes in stream.
23 if (size > 0) && there are bytes in stream,
24 this function must read at least 1 byte.
25 This function is allowed to read less than number of remaining bytes in stream.
26 You must call Read function in loop, if you need exact amount of data
27 */
28 };
29
30 STREAM_INTERFACE(ISequentialOutStream, 0x02)
31 {
32 STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE;
33 /*
34 if (size > 0) this function must write at least 1 byte.
35 This function is allowed to write less than "size".
36 You must call Write function in loop, if you need to write exact amount of data
37 */
38 };
39
40 STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03)
41 {
42 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
43 };
44
45 STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04)
46 {
47 STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE;
48 STDMETHOD(SetSize)(Int64 newSize) PURE;
49 };
50
51 STREAM_INTERFACE(IStreamGetSize, 0x06)
52 {
53 STDMETHOD(GetSize)(UInt64 *size) PURE;
54 };
55
56 STREAM_INTERFACE(IOutStreamFlush, 0x07)
57 {
58 STDMETHOD(Flush)() PURE;
59 };
60
61 #endif
0 // Common/Alloc.cpp
1
2 #include "StdAfx.h"
3
4 #ifdef _WIN32
5 #include "MyWindows.h"
6 #else
7 #include <stdlib.h>
8 #endif
9
10 #include "Alloc.h"
11
12 /* #define _SZ_ALLOC_DEBUG */
13 /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
14 #ifdef _SZ_ALLOC_DEBUG
15 #include <stdio.h>
16 int g_allocCount = 0;
17 int g_allocCountMid = 0;
18 int g_allocCountBig = 0;
19 #endif
20
21 void *MyAlloc(size_t size) throw()
22 {
23 if (size == 0)
24 return 0;
25 #ifdef _SZ_ALLOC_DEBUG
26 fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount++);
27 #endif
28 return ::malloc(size);
29 }
30
31 void MyFree(void *address) throw()
32 {
33 #ifdef _SZ_ALLOC_DEBUG
34 if (address != 0)
35 fprintf(stderr, "\nFree; count = %10d", --g_allocCount);
36 #endif
37
38 ::free(address);
39 }
40
41 #ifdef _WIN32
42
43 void *MidAlloc(size_t size) throw()
44 {
45 if (size == 0)
46 return 0;
47 #ifdef _SZ_ALLOC_DEBUG
48 fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
49 #endif
50 return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
51 }
52
53 void MidFree(void *address) throw()
54 {
55 #ifdef _SZ_ALLOC_DEBUG
56 if (address != 0)
57 fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
58 #endif
59 if (address == 0)
60 return;
61 ::VirtualFree(address, 0, MEM_RELEASE);
62 }
63
64 static SIZE_T g_LargePageSize =
65 #ifdef _WIN64
66 (1 << 21);
67 #else
68 (1 << 22);
69 #endif
70
71 typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
72
73 bool SetLargePageSize()
74 {
75 GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
76 ::GetProcAddress(::GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
77 if (largePageMinimum == 0)
78 return false;
79 SIZE_T size = largePageMinimum();
80 if (size == 0 || (size & (size - 1)) != 0)
81 return false;
82 g_LargePageSize = size;
83 return true;
84 }
85
86
87 void *BigAlloc(size_t size) throw()
88 {
89 if (size == 0)
90 return 0;
91 #ifdef _SZ_ALLOC_DEBUG
92 fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
93 #endif
94
95 if (size >= (1 << 18))
96 {
97 void *res = ::VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
98 MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
99 if (res != 0)
100 return res;
101 }
102 return ::VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
103 }
104
105 void BigFree(void *address) throw()
106 {
107 #ifdef _SZ_ALLOC_DEBUG
108 if (address != 0)
109 fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
110 #endif
111
112 if (address == 0)
113 return;
114 ::VirtualFree(address, 0, MEM_RELEASE);
115 }
116
117 #endif
0 // Common/Alloc.h
1
2 #ifndef __COMMON_ALLOC_H
3 #define __COMMON_ALLOC_H
4
5 #include <stddef.h>
6
7 void *MyAlloc(size_t size) throw();
8 void MyFree(void *address) throw();
9
10 #ifdef _WIN32
11
12 bool SetLargePageSize();
13
14 void *MidAlloc(size_t size) throw();
15 void MidFree(void *address) throw();
16 void *BigAlloc(size_t size) throw();
17 void BigFree(void *address) throw();
18
19 #else
20
21 #define MidAlloc(size) MyAlloc(size)
22 #define MidFree(address) MyFree(address)
23 #define BigAlloc(size) MyAlloc(size)
24 #define BigFree(address) MyFree(address)
25
26 #endif
27
28 #endif
0 // Common/CRC.cpp
1
2 #include "StdAfx.h"
3
4 #include "CRC.h"
5
6 static const UInt32 kCRCPoly = 0xEDB88320;
7
8 UInt32 CCRC::Table[256];
9
10 void CCRC::InitTable()
11 {
12 for (UInt32 i = 0; i < 256; i++)
13 {
14 UInt32 r = i;
15 for (int j = 0; j < 8; j++)
16 if (r & 1)
17 r = (r >> 1) ^ kCRCPoly;
18 else
19 r >>= 1;
20 CCRC::Table[i] = r;
21 }
22 }
23
24 class CCRCTableInit
25 {
26 public:
27 CCRCTableInit() { CCRC::InitTable(); }
28 } g_CRCTableInit;
29
30 void CCRC::UpdateByte(Byte b)
31 {
32 _value = Table[((Byte)(_value)) ^ b] ^ (_value >> 8);
33 }
34
35 void CCRC::UpdateUInt16(UInt16 v)
36 {
37 UpdateByte(Byte(v));
38 UpdateByte(Byte(v >> 8));
39 }
40
41 void CCRC::UpdateUInt32(UInt32 v)
42 {
43 for (int i = 0; i < 4; i++)
44 UpdateByte((Byte)(v >> (8 * i)));
45 }
46
47 void CCRC::UpdateUInt64(UInt64 v)
48 {
49 for (int i = 0; i < 8; i++)
50 UpdateByte((Byte)(v >> (8 * i)));
51 }
52
53 void CCRC::Update(const void *data, size_t size)
54 {
55 UInt32 v = _value;
56 const Byte *p = (const Byte *)data;
57 for (; size > 0 ; size--, p++)
58 v = Table[((Byte)(v)) ^ *p] ^ (v >> 8);
59 _value = v;
60 }
0 // Common/CRC.h
1
2 #ifndef __COMMON_CRC_H
3 #define __COMMON_CRC_H
4
5 #include <stddef.h>
6 #include "Types.h"
7
8 class CCRC
9 {
10 UInt32 _value;
11 public:
12 static UInt32 Table[256];
13 static void InitTable();
14
15 CCRC(): _value(0xFFFFFFFF){};
16 void Init() { _value = 0xFFFFFFFF; }
17 void UpdateByte(Byte v);
18 void UpdateUInt16(UInt16 v);
19 void UpdateUInt32(UInt32 v);
20 void UpdateUInt64(UInt64 v);
21 void Update(const void *data, size_t size);
22 UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; }
23 static UInt32 CalculateDigest(const void *data, size_t size)
24 {
25 CCRC crc;
26 crc.Update(data, size);
27 return crc.GetDigest();
28 }
29 static bool VerifyDigest(UInt32 digest, const void *data, size_t size)
30 {
31 return (CalculateDigest(data, size) == digest);
32 }
33 };
34
35 #endif
0 // Common/C_FileIO.h
1
2 #include "C_FileIO.h"
3
4 #include <fcntl.h>
5 #include <unistd.h>
6
7 namespace NC {
8 namespace NFile {
9 namespace NIO {
10
11 bool CFileBase::OpenBinary(const char *name, int flags)
12 {
13 #ifdef O_BINARY
14 flags |= O_BINARY;
15 #endif
16 Close();
17 _handle = ::open(name, flags, 0666);
18 return _handle != -1;
19 }
20
21 bool CFileBase::Close()
22 {
23 if(_handle == -1)
24 return true;
25 if (close(_handle) != 0)
26 return false;
27 _handle = -1;
28 return true;
29 }
30
31 bool CFileBase::GetLength(UInt64 &length) const
32 {
33 off_t curPos = Seek(0, SEEK_CUR);
34 off_t lengthTemp = Seek(0, SEEK_END);
35 Seek(curPos, SEEK_SET);
36 length = (UInt64)lengthTemp;
37 return true;
38 }
39
40 off_t CFileBase::Seek(off_t distanceToMove, int moveMethod) const
41 {
42 return ::lseek(_handle, distanceToMove, moveMethod);
43 }
44
45 /////////////////////////
46 // CInFile
47
48 bool CInFile::Open(const char *name)
49 {
50 return CFileBase::OpenBinary(name, O_RDONLY);
51 }
52
53 ssize_t CInFile::Read(void *data, size_t size)
54 {
55 return read(_handle, data, size);
56 }
57
58 /////////////////////////
59 // COutFile
60
61 bool COutFile::Create(const char *name, bool createAlways)
62 {
63 if (createAlways)
64 {
65 Close();
66 _handle = ::creat(name, 0666);
67 return _handle != -1;
68 }
69 return OpenBinary(name, O_CREAT | O_EXCL | O_WRONLY);
70 }
71
72 ssize_t COutFile::Write(const void *data, size_t size)
73 {
74 return write(_handle, data, size);
75 }
76
77 }}}
0 // Common/C_FileIO.h
1
2 #ifndef __COMMON_C_FILEIO_H
3 #define __COMMON_C_FILEIO_H
4
5 #include <stdio.h>
6 #include <sys/types.h>
7
8 #include "Types.h"
9 #include "MyWindows.h"
10
11 namespace NC {
12 namespace NFile {
13 namespace NIO {
14
15 class CFileBase
16 {
17 protected:
18 int _handle;
19 bool OpenBinary(const char *name, int flags);
20 public:
21 CFileBase(): _handle(-1) {};
22 ~CFileBase() { Close(); }
23 bool Close();
24 bool GetLength(UInt64 &length) const;
25 off_t Seek(off_t distanceToMove, int moveMethod) const;
26 };
27
28 class CInFile: public CFileBase
29 {
30 public:
31 bool Open(const char *name);
32 ssize_t Read(void *data, size_t size);
33 };
34
35 class COutFile: public CFileBase
36 {
37 public:
38 bool Create(const char *name, bool createAlways);
39 ssize_t Write(const void *data, size_t size);
40 };
41
42 }}}
43
44 #endif
0 // ComTry.h
1
2 #ifndef __COM_TRY_H
3 #define __COM_TRY_H
4
5 #include "MyWindows.h"
6 // #include "Exception.h"
7 // #include "NewHandler.h"
8
9 #define COM_TRY_BEGIN try {
10 #define COM_TRY_END } catch(...) { return E_OUTOFMEMORY; }
11
12 // catch(const CNewException &) { return E_OUTOFMEMORY; }\
13 // catch(const CSystemException &e) { return e.ErrorCode; }\
14 // catch(...) { return E_FAIL; }
15
16 #endif
0 // CommandLineParser.cpp
1
2 #include "StdAfx.h"
3
4 #include "CommandLineParser.h"
5
6 namespace NCommandLineParser {
7
8 void SplitCommandLine(const UString &src, UString &dest1, UString &dest2)
9 {
10 dest1.Empty();
11 dest2.Empty();
12 bool quoteMode = false;
13 int i;
14 for (i = 0; i < src.Length(); i++)
15 {
16 wchar_t c = src[i];
17 if (c == L'\"')
18 quoteMode = !quoteMode;
19 else if (c == L' ' && !quoteMode)
20 {
21 i++;
22 break;
23 }
24 else
25 dest1 += c;
26 }
27 dest2 = src.Mid(i);
28 }
29
30 void SplitCommandLine(const UString &s, UStringVector &parts)
31 {
32 UString sTemp = s;
33 sTemp.Trim();
34 parts.Clear();
35 while (true)
36 {
37 UString s1, s2;
38 SplitCommandLine(sTemp, s1, s2);
39 // s1.Trim();
40 // s2.Trim();
41 if (!s1.IsEmpty())
42 parts.Add(s1);
43 if (s2.IsEmpty())
44 return;
45 sTemp = s2;
46 }
47 }
48
49
50 static const wchar_t kSwitchID1 = '-';
51 // static const wchar_t kSwitchID2 = '/';
52
53 static const wchar_t kSwitchMinus = '-';
54 static const wchar_t *kStopSwitchParsing = L"--";
55
56 static bool IsItSwitchChar(wchar_t c)
57 {
58 return (c == kSwitchID1 /*|| c == kSwitchID2 */);
59 }
60
61 CParser::CParser(int numSwitches):
62 _numSwitches(numSwitches)
63 {
64 _switches = new CSwitchResult[_numSwitches];
65 }
66
67 CParser::~CParser()
68 {
69 delete []_switches;
70 }
71
72 void CParser::ParseStrings(const CSwitchForm *switchForms,
73 const UStringVector &commandStrings)
74 {
75 int numCommandStrings = commandStrings.Size();
76 bool stopSwitch = false;
77 for (int i = 0; i < numCommandStrings; i++)
78 {
79 const UString &s = commandStrings[i];
80 if (stopSwitch)
81 NonSwitchStrings.Add(s);
82 else
83 if (s == kStopSwitchParsing)
84 stopSwitch = true;
85 else
86 if (!ParseString(s, switchForms))
87 NonSwitchStrings.Add(s);
88 }
89 }
90
91 // if string contains switch then function updates switch structures
92 // out: (string is a switch)
93 bool CParser::ParseString(const UString &s, const CSwitchForm *switchForms)
94 {
95 int len = s.Length();
96 if (len == 0)
97 return false;
98 int pos = 0;
99 if (!IsItSwitchChar(s[pos]))
100 return false;
101 while(pos < len)
102 {
103 if (IsItSwitchChar(s[pos]))
104 pos++;
105 const int kNoLen = -1;
106 int matchedSwitchIndex = 0; // GCC Warning
107 int maxLen = kNoLen;
108 for(int switchIndex = 0; switchIndex < _numSwitches; switchIndex++)
109 {
110 int switchLen = MyStringLen(switchForms[switchIndex].IDString);
111 if (switchLen <= maxLen || pos + switchLen > len)
112 continue;
113
114 UString temp = s + pos;
115 temp = temp.Left(switchLen);
116 if(temp.CompareNoCase(switchForms[switchIndex].IDString) == 0)
117 // if(_strnicmp(switchForms[switchIndex].IDString, LPCSTR(s) + pos, switchLen) == 0)
118 {
119 matchedSwitchIndex = switchIndex;
120 maxLen = switchLen;
121 }
122 }
123 if (maxLen == kNoLen)
124 throw "maxLen == kNoLen";
125 CSwitchResult &matchedSwitch = _switches[matchedSwitchIndex];
126 const CSwitchForm &switchForm = switchForms[matchedSwitchIndex];
127 if ((!switchForm.Multi) && matchedSwitch.ThereIs)
128 throw "switch must be single";
129 matchedSwitch.ThereIs = true;
130 pos += maxLen;
131 int tailSize = len - pos;
132 NSwitchType::EEnum type = switchForm.Type;
133 switch(type)
134 {
135 case NSwitchType::kPostMinus:
136 {
137 if (tailSize == 0)
138 matchedSwitch.WithMinus = false;
139 else
140 {
141 matchedSwitch.WithMinus = (s[pos] == kSwitchMinus);
142 if (matchedSwitch.WithMinus)
143 pos++;
144 }
145 break;
146 }
147 case NSwitchType::kPostChar:
148 {
149 if (tailSize < switchForm.MinLen)
150 throw "switch is not full";
151 UString set = switchForm.PostCharSet;
152 const int kEmptyCharValue = -1;
153 if (tailSize == 0)
154 matchedSwitch.PostCharIndex = kEmptyCharValue;
155 else
156 {
157 int index = set.Find(s[pos]);
158 if (index < 0)
159 matchedSwitch.PostCharIndex = kEmptyCharValue;
160 else
161 {
162 matchedSwitch.PostCharIndex = index;
163 pos++;
164 }
165 }
166 break;
167 }
168 case NSwitchType::kLimitedPostString:
169 case NSwitchType::kUnLimitedPostString:
170 {
171 int minLen = switchForm.MinLen;
172 if (tailSize < minLen)
173 throw "switch is not full";
174 if (type == NSwitchType::kUnLimitedPostString)
175 {
176 matchedSwitch.PostStrings.Add(s.Mid(pos));
177 return true;
178 }
179 int maxLen = switchForm.MaxLen;
180 UString stringSwitch = s.Mid(pos, minLen);
181 pos += minLen;
182 for(int i = minLen; i < maxLen && pos < len; i++, pos++)
183 {
184 wchar_t c = s[pos];
185 if (IsItSwitchChar(c))
186 break;
187 stringSwitch += c;
188 }
189 matchedSwitch.PostStrings.Add(stringSwitch);
190 break;
191 }
192 case NSwitchType::kSimple:
193 break;
194 }
195 }
196 return true;
197 }
198
199 const CSwitchResult& CParser::operator[](size_t index) const
200 {
201 return _switches[index];
202 }
203
204 /////////////////////////////////
205 // Command parsing procedures
206
207 int ParseCommand(int numCommandForms, const CCommandForm *commandForms,
208 const UString &commandString, UString &postString)
209 {
210 for(int i = 0; i < numCommandForms; i++)
211 {
212 const UString id = commandForms[i].IDString;
213 if (commandForms[i].PostStringMode)
214 {
215 if(commandString.Find(id) == 0)
216 {
217 postString = commandString.Mid(id.Length());
218 return i;
219 }
220 }
221 else
222 if (commandString == id)
223 {
224 postString.Empty();
225 return i;
226 }
227 }
228 return -1;
229 }
230
231 }
0 // Common/CommandLineParser.h
1
2 #ifndef __COMMON_COMMANDLINEPARSER_H
3 #define __COMMON_COMMANDLINEPARSER_H
4
5 #include "Common/String.h"
6
7 namespace NCommandLineParser {
8
9 void SplitCommandLine(const UString &src, UString &dest1, UString &dest2);
10 void SplitCommandLine(const UString &s, UStringVector &parts);
11
12 namespace NSwitchType {
13 enum EEnum
14 {
15 kSimple,
16 kPostMinus,
17 kLimitedPostString,
18 kUnLimitedPostString,
19 kPostChar
20 };
21 }
22
23 struct CSwitchForm
24 {
25 const wchar_t *IDString;
26 NSwitchType::EEnum Type;
27 bool Multi;
28 int MinLen;
29 int MaxLen;
30 const wchar_t *PostCharSet;
31 };
32
33 struct CSwitchResult
34 {
35 bool ThereIs;
36 bool WithMinus;
37 UStringVector PostStrings;
38 int PostCharIndex;
39 CSwitchResult(): ThereIs(false) {};
40 };
41
42 class CParser
43 {
44 int _numSwitches;
45 CSwitchResult *_switches;
46 bool ParseString(const UString &s, const CSwitchForm *switchForms);
47 public:
48 UStringVector NonSwitchStrings;
49 CParser(int numSwitches);
50 ~CParser();
51 void ParseStrings(const CSwitchForm *switchForms,
52 const UStringVector &commandStrings);
53 const CSwitchResult& operator[](size_t index) const;
54 };
55
56 /////////////////////////////////
57 // Command parsing procedures
58
59 struct CCommandForm
60 {
61 wchar_t *IDString;
62 bool PostStringMode;
63 };
64
65 // Returns: Index of form and postString; -1, if there is no match
66 int ParseCommand(int numCommandForms, const CCommandForm *commandForms,
67 const UString &commandString, UString &postString);
68
69 }
70
71 #endif
0 // Common/Defs.h
1
2 #ifndef __COMMON_DEFS_H
3 #define __COMMON_DEFS_H
4
5 template <class T> inline T MyMin(T a, T b)
6 { return a < b ? a : b; }
7 template <class T> inline T MyMax(T a, T b)
8 { return a > b ? a : b; }
9
10 template <class T> inline int MyCompare(T a, T b)
11 { return a < b ? -1 : (a == b ? 0 : 1); }
12
13 inline int BoolToInt(bool value)
14 { return (value ? 1: 0); }
15
16 inline bool IntToBool(int value)
17 { return (value != 0); }
18
19 #endif
0 // MyCom.h
1
2 #ifndef __MYCOM_H
3 #define __MYCOM_H
4
5 #include "MyWindows.h"
6
7 #define RINOK(x) { HRESULT __result_ = (x); if(__result_ != S_OK) return __result_; }
8
9 template <class T>
10 class CMyComPtr
11 {
12 T* _p;
13 public:
14 // typedef T _PtrClass;
15 CMyComPtr() { _p = NULL;}
16 CMyComPtr(T* p) {if ((_p = p) != NULL) p->AddRef(); }
17 CMyComPtr(const CMyComPtr<T>& lp)
18 {
19 if ((_p = lp._p) != NULL)
20 _p->AddRef();
21 }
22 ~CMyComPtr() { if (_p) _p->Release(); }
23 void Release() { if (_p) { _p->Release(); _p = NULL; } }
24 operator T*() const { return (T*)_p; }
25 // T& operator*() const { return *_p; }
26 T** operator&() { return &_p; }
27 T* operator->() const { return _p; }
28 T* operator=(T* p)
29 {
30 if (p != 0)
31 p->AddRef();
32 if (_p)
33 _p->Release();
34 _p = p;
35 return p;
36 }
37 T* operator=(const CMyComPtr<T>& lp) { return (*this = lp._p); }
38 bool operator!() const { return (_p == NULL); }
39 // bool operator==(T* pT) const { return _p == pT; }
40 // Compare two objects for equivalence
41 void Attach(T* p2)
42 {
43 Release();
44 _p = p2;
45 }
46 T* Detach()
47 {
48 T* pt = _p;
49 _p = NULL;
50 return pt;
51 }
52 #ifdef _WIN32
53 HRESULT CoCreateInstance(REFCLSID rclsid, REFIID iid, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
54 {
55 return ::CoCreateInstance(rclsid, pUnkOuter, dwClsContext, iid, (void**)&_p);
56 }
57 #endif
58 /*
59 HRESULT CoCreateInstance(LPCOLESTR szProgID, LPUNKNOWN pUnkOuter = NULL, DWORD dwClsContext = CLSCTX_ALL)
60 {
61 CLSID clsid;
62 HRESULT hr = CLSIDFromProgID(szProgID, &clsid);
63 ATLASSERT(_p == NULL);
64 if (SUCCEEDED(hr))
65 hr = ::CoCreateInstance(clsid, pUnkOuter, dwClsContext, __uuidof(T), (void**)&_p);
66 return hr;
67 }
68 */
69 template <class Q>
70 HRESULT QueryInterface(REFGUID iid, Q** pp) const
71 {
72 return _p->QueryInterface(iid, (void**)pp);
73 }
74 };
75
76 //////////////////////////////////////////////////////////
77
78 class CMyComBSTR
79 {
80 public:
81 BSTR m_str;
82 CMyComBSTR() { m_str = NULL; }
83 CMyComBSTR(LPCOLESTR pSrc) { m_str = ::SysAllocString(pSrc); }
84 // CMyComBSTR(int nSize) { m_str = ::SysAllocStringLen(NULL, nSize); }
85 // CMyComBSTR(int nSize, LPCOLESTR sz) { m_str = ::SysAllocStringLen(sz, nSize); }
86 CMyComBSTR(const CMyComBSTR& src) { m_str = src.MyCopy(); }
87 /*
88 CMyComBSTR(REFGUID src)
89 {
90 LPOLESTR szGuid;
91 StringFromCLSID(src, &szGuid);
92 m_str = ::SysAllocString(szGuid);
93 CoTaskMemFree(szGuid);
94 }
95 */
96 ~CMyComBSTR() { ::SysFreeString(m_str); }
97 CMyComBSTR& operator=(const CMyComBSTR& src)
98 {
99 if (m_str != src.m_str)
100 {
101 if (m_str)
102 ::SysFreeString(m_str);
103 m_str = src.MyCopy();
104 }
105 return *this;
106 }
107 CMyComBSTR& operator=(LPCOLESTR pSrc)
108 {
109 ::SysFreeString(m_str);
110 m_str = ::SysAllocString(pSrc);
111 return *this;
112 }
113 unsigned int Length() const { return ::SysStringLen(m_str); }
114 operator BSTR() const { return m_str; }
115 BSTR* operator&() { return &m_str; }
116 BSTR MyCopy() const
117 {
118 int byteLen = ::SysStringByteLen(m_str);
119 BSTR res = ::SysAllocStringByteLen(NULL, byteLen);
120 memmove(res, m_str, byteLen);
121 return res;
122 }
123 void Attach(BSTR src) { m_str = src; }
124 BSTR Detach()
125 {
126 BSTR s = m_str;
127 m_str = NULL;
128 return s;
129 }
130 void Empty()
131 {
132 ::SysFreeString(m_str);
133 m_str = NULL;
134 }
135 bool operator!() const { return (m_str == NULL); }
136 };
137
138
139 //////////////////////////////////////////////////////////
140
141 class CMyUnknownImp
142 {
143 public:
144 ULONG __m_RefCount;
145 CMyUnknownImp(): __m_RefCount(0) {}
146 };
147
148 #define MY_QUERYINTERFACE_BEGIN STDMETHOD(QueryInterface) \
149 (REFGUID iid, void **outObject) {
150
151 #define MY_QUERYINTERFACE_ENTRY(i) if (iid == IID_ ## i) \
152 { *outObject = (void *)(i *)this; AddRef(); return S_OK; }
153
154 #define MY_QUERYINTERFACE_END return E_NOINTERFACE; }
155
156 #define MY_ADDREF_RELEASE \
157 STDMETHOD_(ULONG, AddRef)() { return ++__m_RefCount; } \
158 STDMETHOD_(ULONG, Release)() { if (--__m_RefCount != 0) \
159 return __m_RefCount; delete this; return 0; }
160
161 #define MY_UNKNOWN_IMP_SPEC(i) \
162 MY_QUERYINTERFACE_BEGIN \
163 i \
164 MY_QUERYINTERFACE_END \
165 MY_ADDREF_RELEASE
166
167
168 #define MY_UNKNOWN_IMP STDMETHOD(QueryInterface)(REFGUID, void **) { \
169 MY_QUERYINTERFACE_END \
170 MY_ADDREF_RELEASE
171
172 #define MY_UNKNOWN_IMP1(i) MY_UNKNOWN_IMP_SPEC( \
173 MY_QUERYINTERFACE_ENTRY(i) \
174 )
175
176 #define MY_UNKNOWN_IMP2(i1, i2) MY_UNKNOWN_IMP_SPEC( \
177 MY_QUERYINTERFACE_ENTRY(i1) \
178 MY_QUERYINTERFACE_ENTRY(i2) \
179 )
180
181 #define MY_UNKNOWN_IMP3(i1, i2, i3) MY_UNKNOWN_IMP_SPEC( \
182 MY_QUERYINTERFACE_ENTRY(i1) \
183 MY_QUERYINTERFACE_ENTRY(i2) \
184 MY_QUERYINTERFACE_ENTRY(i3) \
185 )
186
187 #define MY_UNKNOWN_IMP4(i1, i2, i3, i4) MY_UNKNOWN_IMP_SPEC( \
188 MY_QUERYINTERFACE_ENTRY(i1) \
189 MY_QUERYINTERFACE_ENTRY(i2) \
190 MY_QUERYINTERFACE_ENTRY(i3) \
191 MY_QUERYINTERFACE_ENTRY(i4) \
192 )
193
194 #define MY_UNKNOWN_IMP5(i1, i2, i3, i4, i5) MY_UNKNOWN_IMP_SPEC( \
195 MY_QUERYINTERFACE_ENTRY(i1) \
196 MY_QUERYINTERFACE_ENTRY(i2) \
197 MY_QUERYINTERFACE_ENTRY(i3) \
198 MY_QUERYINTERFACE_ENTRY(i4) \
199 MY_QUERYINTERFACE_ENTRY(i5) \
200 )
201
202 #endif
0 // Common/MyGuidDef.h
1
2 #ifndef GUID_DEFINED
3 #define GUID_DEFINED
4
5 #include "Types.h"
6
7 typedef struct {
8 UInt32 Data1;
9 UInt16 Data2;
10 UInt16 Data3;
11 unsigned char Data4[8];
12 } GUID;
13
14 #ifdef __cplusplus
15 #define REFGUID const GUID &
16 #else
17 #define REFGUID const GUID *
18 #endif
19
20 #define REFCLSID REFGUID
21 #define REFIID REFGUID
22
23 #ifdef __cplusplus
24 inline bool operator==(REFGUID g1, REFGUID g2)
25 {
26 for (int i = 0; i < (int)sizeof(g1); i++)
27 if (((unsigned char *)&g1)[i] != ((unsigned char *)&g2)[i])
28 return false;
29 return true;
30 }
31 inline bool operator!=(REFGUID g1, REFGUID g2) { return !(g1 == g2); }
32 #endif
33
34 #ifdef __cplusplus
35 #define MY_EXTERN_C extern "C"
36 #else
37 #define MY_EXTERN_C extern
38 #endif
39
40 #endif // GUID_DEFINED
41
42
43 #ifdef DEFINE_GUID
44 #undef DEFINE_GUID
45 #endif
46
47 #ifdef INITGUID
48 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
49 MY_EXTERN_C const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
50 #else
51 #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
52 MY_EXTERN_C const GUID name
53 #endif
0 // Common/MyInitGuid.h
1
2 #ifndef __COMMON_MYINITGUID_H
3 #define __COMMON_MYINITGUID_H
4
5 #ifdef _WIN32
6 #include <initguid.h>
7 #else
8 #define INITGUID
9 #include "MyGuidDef.h"
10 #endif
11
12 #endif
0 // MyUnknown.h
1
2 #ifndef __MYUNKNOWN_H
3 #define __MYUNKNOWN_H
4
5 #ifdef _WIN32
6
7 #ifdef _WIN32_WCE
8 #if (_WIN32_WCE > 300)
9 #include <basetyps.h>
10 #else
11 #define MIDL_INTERFACE(x) struct
12 #endif
13 #else
14 #include <basetyps.h>
15 #endif
16
17 #include <unknwn.h>
18
19 #else
20 #include "MyWindows.h"
21 #endif
22
23 #endif
0 // MyWindows.h
1
2 #ifndef __MYWINDOWS_H
3 #define __MYWINDOWS_H
4
5 #ifdef _WIN32
6
7 #include <windows.h>
8
9 #define CHAR_PATH_SEPARATOR '\\'
10 #define WCHAR_PATH_SEPARATOR L'\\'
11 #define STRING_PATH_SEPARATOR "\\"
12 #define WSTRING_PATH_SEPARATOR L"\\"
13
14 #else
15
16 #define CHAR_PATH_SEPARATOR '/'
17 #define WCHAR_PATH_SEPARATOR L'/'
18 #define STRING_PATH_SEPARATOR "/"
19 #define WSTRING_PATH_SEPARATOR L"/"
20
21 #include <stddef.h> // for wchar_t
22 #include <string.h>
23
24 #include "MyGuidDef.h"
25
26 typedef char CHAR;
27 typedef unsigned char UCHAR;
28
29 #undef BYTE
30 typedef unsigned char BYTE;
31
32 typedef short SHORT;
33 typedef unsigned short USHORT;
34
35 #undef WORD
36 typedef unsigned short WORD;
37 typedef short VARIANT_BOOL;
38
39 typedef int INT;
40 typedef Int32 INT32;
41 typedef unsigned int UINT;
42 typedef UInt32 UINT32;
43 typedef INT32 LONG; // LONG, ULONG and DWORD must be 32-bit
44 typedef UINT32 ULONG;
45
46 #undef DWORD
47 typedef UINT32 DWORD;
48
49 typedef Int64 LONGLONG;
50 typedef UInt64 ULONGLONG;
51
52 typedef struct LARGE_INTEGER { LONGLONG QuadPart; }LARGE_INTEGER;
53 typedef struct _ULARGE_INTEGER { ULONGLONG QuadPart;} ULARGE_INTEGER;
54
55 typedef const CHAR *LPCSTR;
56 typedef CHAR TCHAR;
57 typedef const TCHAR *LPCTSTR;
58 typedef wchar_t WCHAR;
59 typedef WCHAR OLECHAR;
60 typedef const WCHAR *LPCWSTR;
61 typedef OLECHAR *BSTR;
62 typedef const OLECHAR *LPCOLESTR;
63 typedef OLECHAR *LPOLESTR;
64
65 typedef struct _FILETIME
66 {
67 DWORD dwLowDateTime;
68 DWORD dwHighDateTime;
69 }FILETIME;
70
71 #define HRESULT LONG
72 #define FAILED(Status) ((HRESULT)(Status)<0)
73 typedef ULONG PROPID;
74 typedef LONG SCODE;
75
76 #define S_OK ((HRESULT)0x00000000L)
77 #define S_FALSE ((HRESULT)0x00000001L)
78 #define E_NOTIMPL ((HRESULT)0x80004001L)
79 #define E_NOINTERFACE ((HRESULT)0x80004002L)
80 #define E_ABORT ((HRESULT)0x80004004L)
81 #define E_FAIL ((HRESULT)0x80004005L)
82 #define STG_E_INVALIDFUNCTION ((HRESULT)0x80030001L)
83 #define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
84 #define E_INVALIDARG ((HRESULT)0x80070057L)
85
86 #ifdef _MSC_VER
87 #define STDMETHODCALLTYPE __stdcall
88 #else
89 #define STDMETHODCALLTYPE
90 #endif
91
92 #define STDMETHOD_(t, f) virtual t STDMETHODCALLTYPE f
93 #define STDMETHOD(f) STDMETHOD_(HRESULT, f)
94 #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
95 #define STDMETHODIMP STDMETHODIMP_(HRESULT)
96
97 #define PURE = 0
98
99 #define MIDL_INTERFACE(x) struct
100
101 struct IUnknown
102 {
103 STDMETHOD(QueryInterface) (REFIID iid, void **outObject) PURE;
104 STDMETHOD_(ULONG, AddRef)() PURE;
105 STDMETHOD_(ULONG, Release)() PURE;
106 #ifndef _WIN32
107 virtual ~IUnknown() {}
108 #endif
109 };
110
111 typedef IUnknown *LPUNKNOWN;
112
113 #define VARIANT_TRUE ((VARIANT_BOOL)-1)
114 #define VARIANT_FALSE ((VARIANT_BOOL)0)
115
116 enum VARENUM
117 {
118 VT_EMPTY = 0,
119 VT_NULL = 1,
120 VT_I2 = 2,
121 VT_I4 = 3,
122 VT_R4 = 4,
123 VT_R8 = 5,
124 VT_CY = 6,
125 VT_DATE = 7,
126 VT_BSTR = 8,
127 VT_DISPATCH = 9,
128 VT_ERROR = 10,
129 VT_BOOL = 11,
130 VT_VARIANT = 12,
131 VT_UNKNOWN = 13,
132 VT_DECIMAL = 14,
133 VT_I1 = 16,
134 VT_UI1 = 17,
135 VT_UI2 = 18,
136 VT_UI4 = 19,
137 VT_I8 = 20,
138 VT_UI8 = 21,
139 VT_INT = 22,
140 VT_UINT = 23,
141 VT_VOID = 24,
142 VT_HRESULT = 25,
143 VT_FILETIME = 64
144 };
145
146 typedef unsigned short VARTYPE;
147 typedef WORD PROPVAR_PAD1;
148 typedef WORD PROPVAR_PAD2;
149 typedef WORD PROPVAR_PAD3;
150
151 typedef struct tagPROPVARIANT
152 {
153 VARTYPE vt;
154 PROPVAR_PAD1 wReserved1;
155 PROPVAR_PAD2 wReserved2;
156 PROPVAR_PAD3 wReserved3;
157 union
158 {
159 CHAR cVal;
160 UCHAR bVal;
161 SHORT iVal;
162 USHORT uiVal;
163 LONG lVal;
164 ULONG ulVal;
165 INT intVal;
166 UINT uintVal;
167 LARGE_INTEGER hVal;
168 ULARGE_INTEGER uhVal;
169 VARIANT_BOOL boolVal;
170 SCODE scode;
171 FILETIME filetime;
172 BSTR bstrVal;
173 };
174 } PROPVARIANT;
175
176 typedef PROPVARIANT tagVARIANT;
177 typedef tagVARIANT VARIANT;
178 typedef VARIANT VARIANTARG;
179
180 MY_EXTERN_C BSTR SysAllocStringByteLen(LPCSTR psz, UINT len);
181 MY_EXTERN_C BSTR SysAllocString(const OLECHAR *sz);
182 MY_EXTERN_C void SysFreeString(BSTR bstr);
183 MY_EXTERN_C UINT SysStringByteLen(BSTR bstr);
184 MY_EXTERN_C UINT SysStringLen(BSTR bstr);
185
186 MY_EXTERN_C DWORD GetLastError();
187 MY_EXTERN_C HRESULT VariantClear(VARIANTARG *prop);
188 MY_EXTERN_C HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src);
189 MY_EXTERN_C LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2);
190
191 #define CP_ACP 0
192 #define CP_OEMCP 1
193
194 typedef enum tagSTREAM_SEEK
195 {
196 STREAM_SEEK_SET = 0,
197 STREAM_SEEK_CUR = 1,
198 STREAM_SEEK_END = 2
199 } STREAM_SEEK;
200
201 #endif
202 #endif
0 // NewHandler.cpp
1
2 #include "StdAfx.h"
3
4 #include <stdlib.h>
5
6 #include "NewHandler.h"
7
8 // #define DEBUG_MEMORY_LEAK
9
10 #ifndef DEBUG_MEMORY_LEAK
11
12 #ifdef _WIN32
13 void *
14 #ifdef _MSC_VER
15 __cdecl
16 #endif
17 operator new(size_t size)
18 {
19 // void *p = ::HeapAlloc(::GetProcessHeap(), 0, size);
20 void *p = ::malloc(size);
21 if (p == 0)
22 throw CNewException();
23 return p;
24 }
25
26 void
27 #ifdef _MSC_VER
28 __cdecl
29 #endif
30 operator delete(void *p) throw()
31 {
32 /*
33 if (p == 0)
34 return;
35 ::HeapFree(::GetProcessHeap(), 0, p);
36 */
37 ::free(p);
38 }
39 #endif
40
41 #else
42
43 #pragma init_seg(lib)
44 const int kDebugSize = 1000000;
45 static void *a[kDebugSize];
46 static int index = 0;
47
48 static int numAllocs = 0;
49 void * __cdecl operator new(size_t size)
50 {
51 numAllocs++;
52 void *p = HeapAlloc(GetProcessHeap(), 0, size);
53 if (index == 40)
54 {
55 int t = 1;
56 }
57 if (index < kDebugSize)
58 {
59 a[index] = p;
60 index++;
61 }
62 if (p == 0)
63 throw CNewException();
64 printf("Alloc %6d, size = %8d\n", numAllocs, size);
65 return p;
66 }
67
68 class CC
69 {
70 public:
71 CC()
72 {
73 for (int i = 0; i < kDebugSize; i++)
74 a[i] = 0;
75 }
76 ~CC()
77 {
78 for (int i = 0; i < kDebugSize; i++)
79 if (a[i] != 0)
80 return;
81 }
82 } g_CC;
83
84
85 void __cdecl operator delete(void *p)
86 {
87 if (p == 0)
88 return;
89 /*
90 for (int i = 0; i < index; i++)
91 if (a[i] == p)
92 a[i] = 0;
93 */
94 HeapFree(GetProcessHeap(), 0, p);
95 numAllocs--;
96 printf("Free %d\n", numAllocs);
97 }
98
99 #endif
100
101 /*
102 int MemErrorVC(size_t)
103 {
104 throw CNewException();
105 // return 1;
106 }
107 CNewHandlerSetter::CNewHandlerSetter()
108 {
109 // MemErrorOldVCFunction = _set_new_handler(MemErrorVC);
110 }
111 CNewHandlerSetter::~CNewHandlerSetter()
112 {
113 // _set_new_handler(MemErrorOldVCFunction);
114 }
115 */
0 // Common/NewHandler.h
1
2 #ifndef __COMMON_NEWHANDLER_H
3 #define __COMMON_NEWHANDLER_H
4
5 class CNewException {};
6
7 #ifdef _WIN32
8 void
9 #ifdef _MSC_VER
10 __cdecl
11 #endif
12 operator delete(void *p) throw();
13 #endif
14
15 #endif
0 // StdAfx.h
1
2 #ifndef __STDAFX_H
3 #define __STDAFX_H
4
5 // #include "MyWindows.h"
6 #include "NewHandler.h"
7
8 #endif
0 // Common/String.cpp
1
2 #include "StdAfx.h"
3
4 #ifdef _WIN32
5 #include "StringConvert.h"
6 #else
7 #include <ctype.h>
8 #endif
9
10 #include "Common/String.h"
11
12
13 #ifdef _WIN32
14
15 #ifndef _UNICODE
16
17 wchar_t MyCharUpper(wchar_t c)
18 {
19 if (c == 0)
20 return 0;
21 wchar_t *res = CharUpperW((LPWSTR)(unsigned int)c);
22 if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
23 return (wchar_t)(unsigned int)res;
24 const int kBufferSize = 4;
25 char s[kBufferSize + 1];
26 int numChars = ::WideCharToMultiByte(CP_ACP, 0, &c, 1, s, kBufferSize, 0, 0);
27 if (numChars == 0 || numChars > kBufferSize)
28 return c;
29 s[numChars] = 0;
30 ::CharUpperA(s);
31 ::MultiByteToWideChar(CP_ACP, 0, s, numChars, &c, 1);
32 return c;
33 }
34
35 wchar_t MyCharLower(wchar_t c)
36 {
37 if (c == 0)
38 return 0;
39 wchar_t *res = CharLowerW((LPWSTR)(unsigned int)c);
40 if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
41 return (wchar_t)(unsigned int)res;
42 const int kBufferSize = 4;
43 char s[kBufferSize + 1];
44 int numChars = ::WideCharToMultiByte(CP_ACP, 0, &c, 1, s, kBufferSize, 0, 0);
45 if (numChars == 0 || numChars > kBufferSize)
46 return c;
47 s[numChars] = 0;
48 ::CharLowerA(s);
49 ::MultiByteToWideChar(CP_ACP, 0, s, numChars, &c, 1);
50 return c;
51 }
52
53 wchar_t * MyStringUpper(wchar_t *s)
54 {
55 if (s == 0)
56 return 0;
57 wchar_t *res = CharUpperW(s);
58 if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
59 return res;
60 AString a = UnicodeStringToMultiByte(s);
61 a.MakeUpper();
62 return MyStringCopy(s, (const wchar_t *)MultiByteToUnicodeString(a));
63 }
64
65 wchar_t * MyStringLower(wchar_t *s)
66 {
67 if (s == 0)
68 return 0;
69 wchar_t *res = CharLowerW(s);
70 if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
71 return res;
72 AString a = UnicodeStringToMultiByte(s);
73 a.MakeLower();
74 return MyStringCopy(s, (const wchar_t *)MultiByteToUnicodeString(a));
75 }
76
77 #endif
78
79 /*
80 inline int ConvertCompareResult(int r) { return r - 2; }
81
82 int MyStringCollate(const wchar_t *s1, const wchar_t *s2)
83 {
84 int res = CompareStringW(
85 LOCALE_USER_DEFAULT, SORT_STRINGSORT, s1, -1, s2, -1);
86 #ifdef _UNICODE
87 return ConvertCompareResult(res);
88 #else
89 if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
90 return ConvertCompareResult(res);
91 return MyStringCollate(UnicodeStringToMultiByte(s1),
92 UnicodeStringToMultiByte(s2));
93 #endif
94 }
95
96 #ifndef _WIN32_WCE
97 int MyStringCollate(const char *s1, const char *s2)
98 {
99 return ConvertCompareResult(CompareStringA(
100 LOCALE_USER_DEFAULT, SORT_STRINGSORT, s1, -1, s2, -1));
101 }
102
103 int MyStringCollateNoCase(const char *s1, const char *s2)
104 {
105 return ConvertCompareResult(CompareStringA(
106 LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, s1, -1, s2, -1));
107 }
108 #endif
109
110 int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2)
111 {
112 int res = CompareStringW(
113 LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, s1, -1, s2, -1);
114 #ifdef _UNICODE
115 return ConvertCompareResult(res);
116 #else
117 if (res != 0 || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
118 return ConvertCompareResult(res);
119 return MyStringCollateNoCase(UnicodeStringToMultiByte(s1),
120 UnicodeStringToMultiByte(s2));
121 #endif
122 }
123 */
124
125 #else
126
127 wchar_t MyCharUpper(wchar_t c)
128 {
129 return toupper(c);
130 }
131
132 /*
133 int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2)
134 {
135 while (true)
136 {
137 wchar_t c1 = *s1++;
138 wchar_t c2 = *s2++;
139 wchar_t u1 = MyCharUpper(c1);
140 wchar_t u2 = MyCharUpper(c2);
141
142 if (u1 < u2) return -1;
143 if (u1 > u2) return 1;
144 if (u1 == 0) return 0;
145 }
146 }
147 */
148
149 #endif
150
151 int MyStringCompare(const char *s1, const char *s2)
152 {
153 while (true)
154 {
155 unsigned char c1 = (unsigned char)*s1++;
156 unsigned char c2 = (unsigned char)*s2++;
157 if (c1 < c2) return -1;
158 if (c1 > c2) return 1;
159 if (c1 == 0) return 0;
160 }
161 }
162
163 int MyStringCompare(const wchar_t *s1, const wchar_t *s2)
164 {
165 while (true)
166 {
167 wchar_t c1 = *s1++;
168 wchar_t c2 = *s2++;
169 if (c1 < c2) return -1;
170 if (c1 > c2) return 1;
171 if (c1 == 0) return 0;
172 }
173 }
174
175 int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2)
176 {
177 while (true)
178 {
179 wchar_t c1 = *s1++;
180 wchar_t c2 = *s2++;
181 if (c1 != c2)
182 {
183 wchar_t u1 = MyCharUpper(c1);
184 wchar_t u2 = MyCharUpper(c2);
185 if (u1 < u2) return -1;
186 if (u1 > u2) return 1;
187 }
188 if (c1 == 0) return 0;
189 }
190 }
191
192 #ifdef _WIN32
193 int MyStringCompareNoCase(const char *s1, const char *s2)
194 {
195 return MyStringCompareNoCase(MultiByteToUnicodeString(s1), MultiByteToUnicodeString(s2));
196 }
197 #endif
0 // Common/String.h
1
2 #ifndef __COMMON_STRING_H
3 #define __COMMON_STRING_H
4
5 #include <string.h>
6 // #include <wchar.h>
7
8 #include "Vector.h"
9
10 #ifdef _WIN32
11 #include "MyWindows.h"
12 #endif
13
14 static const char *kTrimDefaultCharSet = " \n\t";
15
16 template <class T>
17 inline int MyStringLen(const T *s)
18 {
19 int i;
20 for (i = 0; s[i] != '\0'; i++);
21 return i;
22 }
23
24 template <class T>
25 inline T * MyStringCopy(T *dest, const T *src)
26 {
27 T *destStart = dest;
28 while((*dest++ = *src++) != 0);
29 return destStart;
30 }
31
32 inline wchar_t* MyStringGetNextCharPointer(wchar_t *p)
33 { return (p + 1); }
34 inline const wchar_t* MyStringGetNextCharPointer(const wchar_t *p)
35 { return (p + 1); }
36 inline wchar_t* MyStringGetPrevCharPointer(const wchar_t *, wchar_t *p)
37 { return (p - 1); }
38 inline const wchar_t* MyStringGetPrevCharPointer(const wchar_t *, const wchar_t *p)
39 { return (p - 1); }
40
41 #ifdef _WIN32
42
43 inline char* MyStringGetNextCharPointer(char *p)
44 { return CharNextA(p); }
45 inline const char* MyStringGetNextCharPointer(const char *p)
46 { return CharNextA(p); }
47
48 inline char* MyStringGetPrevCharPointer(char *base, char *p)
49 { return CharPrevA(base, p); }
50 inline const char* MyStringGetPrevCharPointer(const char *base, const char *p)
51 { return CharPrevA(base, p); }
52
53 inline char MyCharUpper(char c)
54 { return (char)(unsigned int)CharUpperA((LPSTR)(unsigned int)(unsigned char)c); }
55 #ifdef _UNICODE
56 inline wchar_t MyCharUpper(wchar_t c)
57 { return (wchar_t)CharUpperW((LPWSTR)c); }
58 #else
59 wchar_t MyCharUpper(wchar_t c);
60 #endif
61
62 inline char MyCharLower(char c)
63 { return (char)(unsigned int)CharLowerA((LPSTR)(unsigned int)(unsigned char)c); }
64 #ifdef _UNICODE
65 inline wchar_t MyCharLower(wchar_t c)
66 { return (wchar_t)CharLowerW((LPWSTR)c); }
67 #else
68 wchar_t MyCharLower(wchar_t c);
69 #endif
70
71 inline char * MyStringUpper(char *s) { return CharUpperA(s); }
72 #ifdef _UNICODE
73 inline wchar_t * MyStringUpper(wchar_t *s) { return CharUpperW(s); }
74 #else
75 wchar_t * MyStringUpper(wchar_t *s);
76 #endif
77
78 inline char * MyStringLower(char *s) { return CharLowerA(s); }
79 #ifdef _UNICODE
80 inline wchar_t * MyStringLower(wchar_t *s) { return CharLowerW(s); }
81 #else
82 wchar_t * MyStringLower(wchar_t *s);
83 #endif
84
85 #else // Standard-C
86 wchar_t MyCharUpper(wchar_t c);
87 #endif
88
89 //////////////////////////////////////
90 // Compare
91
92 /*
93 #ifndef _WIN32_WCE
94 int MyStringCollate(const char *s1, const char *s2);
95 int MyStringCollateNoCase(const char *s1, const char *s2);
96 #endif
97 int MyStringCollate(const wchar_t *s1, const wchar_t *s2);
98 int MyStringCollateNoCase(const wchar_t *s1, const wchar_t *s2);
99 */
100
101 int MyStringCompare(const char *s1, const char *s2);
102 int MyStringCompare(const wchar_t *s1, const wchar_t *s2);
103
104 #ifdef _WIN32
105 int MyStringCompareNoCase(const char *s1, const char *s2);
106 #endif
107
108 int MyStringCompareNoCase(const wchar_t *s1, const wchar_t *s2);
109
110 template <class T>
111 class CStringBase
112 {
113 void TrimLeftWithCharSet(const CStringBase &charSet)
114 {
115 const T *p = _chars;
116 while (charSet.Find(*p) >= 0 && (*p != 0))
117 p = GetNextCharPointer(p);
118 Delete(0, (int)(p - _chars));
119 }
120 void TrimRightWithCharSet(const CStringBase &charSet)
121 {
122 const T *p = _chars;
123 const T *pLast = NULL;
124 while (*p != 0)
125 {
126 if (charSet.Find(*p) >= 0)
127 {
128 if (pLast == NULL)
129 pLast = p;
130 }
131 else
132 pLast = NULL;
133 p = GetNextCharPointer(p);
134 }
135 if(pLast != NULL)
136 {
137 int i = (int)(pLast - _chars);
138 Delete(i, _length - i);
139 }
140
141 }
142 void MoveItems(int destIndex, int srcIndex)
143 {
144 memmove(_chars + destIndex, _chars + srcIndex,
145 sizeof(T) * (_length - srcIndex + 1));
146 }
147
148 void InsertSpace(int &index, int size)
149 {
150 CorrectIndex(index);
151 GrowLength(size);
152 MoveItems(index + size, index);
153 }
154
155 static T *GetNextCharPointer(T *p)
156 { return MyStringGetNextCharPointer(p); }
157 static const T *GetNextCharPointer(const T *p)
158 { return MyStringGetNextCharPointer(p); }
159 static T *GetPrevCharPointer(T *base, T *p)
160 { return MyStringGetPrevCharPointer(base, p); }
161 static const T *GetPrevCharPointer(const T *base, const T *p)
162 { return MyStringGetPrevCharPointer(base, p); }
163 protected:
164 T *_chars;
165 int _length;
166 int _capacity;
167
168 void SetCapacity(int newCapacity)
169 {
170 int realCapacity = newCapacity + 1;
171 if(realCapacity == _capacity)
172 return;
173 /*
174 const int kMaxStringSize = 0x20000000;
175 #ifndef _WIN32_WCE
176 if(newCapacity > kMaxStringSize || newCapacity < _length)
177 throw 1052337;
178 #endif
179 */
180 T *newBuffer = new T[realCapacity];
181 if(_capacity > 0)
182 {
183 for (int i = 0; i < (_length + 1); i++)
184 newBuffer[i] = _chars[i];
185 delete []_chars;
186 _chars = newBuffer;
187 }
188 else
189 {
190 _chars = newBuffer;
191 _chars[0] = 0;
192 }
193 _capacity = realCapacity;
194 }
195
196 void GrowLength(int n)
197 {
198 int freeSize = _capacity - _length - 1;
199 if (n <= freeSize)
200 return;
201 int delta;
202 if (_capacity > 64)
203 delta = _capacity / 2;
204 else if (_capacity > 8)
205 delta = 16;
206 else
207 delta = 4;
208 if (freeSize + delta < n)
209 delta = n - freeSize;
210 SetCapacity(_capacity + delta);
211 }
212
213 void CorrectIndex(int &index) const
214 {
215 if (index > _length)
216 index = _length;
217 }
218
219 public:
220 CStringBase(): _chars(0), _length(0), _capacity(0)
221 { SetCapacity(16 - 1); }
222 CStringBase(T c): _chars(0), _length(0), _capacity(0)
223 {
224 SetCapacity(1);
225 _chars[0] = c;
226 _chars[1] = 0;
227 _length = 1;
228 }
229 CStringBase(const T *chars): _chars(0), _length(0), _capacity(0)
230 {
231 int length = MyStringLen(chars);
232 SetCapacity(length);
233 MyStringCopy(_chars, chars); // can be optimized by memove()
234 _length = length;
235 }
236 CStringBase(const CStringBase &s): _chars(0), _length(0), _capacity(0)
237 {
238 SetCapacity(s._length);
239 MyStringCopy(_chars, s._chars);
240 _length = s._length;
241 }
242 ~CStringBase() { delete []_chars; }
243
244 operator const T*() const { return _chars;}
245
246 // The minimum size of the character buffer in characters.
247 // This value does not include space for a null terminator.
248 T* GetBuffer(int minBufLength)
249 {
250 if(minBufLength >= _capacity)
251 SetCapacity(minBufLength + 1);
252 return _chars;
253 }
254 void ReleaseBuffer() { ReleaseBuffer(MyStringLen(_chars)); }
255 void ReleaseBuffer(int newLength)
256 {
257 /*
258 #ifndef _WIN32_WCE
259 if(newLength >= _capacity)
260 throw 282217;
261 #endif
262 */
263 _chars[newLength] = 0;
264 _length = newLength;
265 }
266
267 CStringBase& operator=(T c)
268 {
269 Empty();
270 SetCapacity(1);
271 _chars[0] = c;
272 _chars[1] = 0;
273 _length = 1;
274 return *this;
275 }
276 CStringBase& operator=(const T *chars)
277 {
278 Empty();
279 int length = MyStringLen(chars);
280 SetCapacity(length);
281 MyStringCopy(_chars, chars);
282 _length = length;
283 return *this;
284 }
285 CStringBase& operator=(const CStringBase& s)
286 {
287 if(&s == this)
288 return *this;
289 Empty();
290 SetCapacity(s._length);
291 MyStringCopy(_chars, s._chars);
292 _length = s._length;
293 return *this;
294 }
295
296 CStringBase& operator+=(T c)
297 {
298 GrowLength(1);
299 _chars[_length] = c;
300 _chars[++_length] = 0;
301 return *this;
302 }
303 CStringBase& operator+=(const T *s)
304 {
305 int len = MyStringLen(s);
306 GrowLength(len);
307 MyStringCopy(_chars + _length, s);
308 _length += len;
309 return *this;
310 }
311 CStringBase& operator+=(const CStringBase &s)
312 {
313 GrowLength(s._length);
314 MyStringCopy(_chars + _length, s._chars);
315 _length += s._length;
316 return *this;
317 }
318 void Empty()
319 {
320 _length = 0;
321 _chars[0] = 0;
322 }
323 int Length() const { return _length; }
324 bool IsEmpty() const { return (_length == 0); }
325
326 CStringBase Mid(int startIndex) const
327 { return Mid(startIndex, _length - startIndex); }
328 CStringBase Mid(int startIndex, int count ) const
329 {
330 if (startIndex + count > _length)
331 count = _length - startIndex;
332
333 if (startIndex == 0 && startIndex + count == _length)
334 return *this;
335
336 CStringBase<T> result;
337 result.SetCapacity(count);
338 // MyStringNCopy(result._chars, _chars + startIndex, count);
339 for (int i = 0; i < count; i++)
340 result._chars[i] = _chars[startIndex + i];
341 result._chars[count] = 0;
342 result._length = count;
343 return result;
344 }
345 CStringBase Left(int count) const
346 { return Mid(0, count); }
347 CStringBase Right(int count) const
348 {
349 if (count > _length)
350 count = _length;
351 return Mid(_length - count, count);
352 }
353
354 void MakeUpper()
355 { MyStringUpper(_chars); }
356 void MakeLower()
357 { MyStringLower(_chars); }
358
359 int Compare(const CStringBase& s) const
360 { return MyStringCompare(_chars, s._chars); }
361
362 int CompareNoCase(const CStringBase& s) const
363 { return MyStringCompareNoCase(_chars, s._chars); }
364 /*
365 int Collate(const CStringBase& s) const
366 { return MyStringCollate(_chars, s._chars); }
367 int CollateNoCase(const CStringBase& s) const
368 { return MyStringCollateNoCase(_chars, s._chars); }
369 */
370
371 int Find(T c) const { return Find(c, 0); }
372 int Find(T c, int startIndex) const
373 {
374 T *p = _chars + startIndex;
375 while (true)
376 {
377 if (*p == c)
378 return (int)(p - _chars);
379 if (*p == 0)
380 return -1;
381 p = GetNextCharPointer(p);
382 }
383 }
384 int Find(const CStringBase &s) const { return Find(s, 0); }
385 int Find(const CStringBase &s, int startIndex) const
386 {
387 if (s.IsEmpty())
388 return startIndex;
389 for (; startIndex < _length; startIndex++)
390 {
391 int j;
392 for (j = 0; j < s._length && startIndex + j < _length; j++)
393 if (_chars[startIndex+j] != s._chars[j])
394 break;
395 if (j == s._length)
396 return startIndex;
397 }
398 return -1;
399 }
400 int ReverseFind(T c) const
401 {
402 if (_length == 0)
403 return -1;
404 T *p = _chars + _length - 1;
405 while (true)
406 {
407 if (*p == c)
408 return (int)(p - _chars);
409 if (p == _chars)
410 return -1;
411 p = GetPrevCharPointer(_chars, p);
412 }
413 }
414 int FindOneOf(const CStringBase &s) const
415 {
416 for(int i = 0; i < _length; i++)
417 if (s.Find(_chars[i]) >= 0)
418 return i;
419 return -1;
420 }
421
422 void TrimLeft(T c)
423 {
424 const T *p = _chars;
425 while (c == *p)
426 p = GetNextCharPointer(p);
427 Delete(0, p - _chars);
428 }
429 private:
430 CStringBase GetTrimDefaultCharSet()
431 {
432 CStringBase<T> charSet;
433 for(int i = 0; i < (int)(sizeof(kTrimDefaultCharSet) /
434 sizeof(kTrimDefaultCharSet[0])); i++)
435 charSet += (T)kTrimDefaultCharSet[i];
436 return charSet;
437 }
438 public:
439
440 void TrimLeft()
441 {
442 TrimLeftWithCharSet(GetTrimDefaultCharSet());
443 }
444 void TrimRight()
445 {
446 TrimRightWithCharSet(GetTrimDefaultCharSet());
447 }
448 void TrimRight(T c)
449 {
450 const T *p = _chars;
451 const T *pLast = NULL;
452 while (*p != 0)
453 {
454 if (*p == c)
455 {
456 if (pLast == NULL)
457 pLast = p;
458 }
459 else
460 pLast = NULL;
461 p = GetNextCharPointer(p);
462 }
463 if(pLast != NULL)
464 {
465 int i = pLast - _chars;
466 Delete(i, _length - i);
467 }
468 }
469 void Trim()
470 {
471 TrimRight();
472 TrimLeft();
473 }
474
475 int Insert(int index, T c)
476 {
477 InsertSpace(index, 1);
478 _chars[index] = c;
479 _length++;
480 return _length;
481 }
482 int Insert(int index, const CStringBase &s)
483 {
484 CorrectIndex(index);
485 if (s.IsEmpty())
486 return _length;
487 int numInsertChars = s.Length();
488 InsertSpace(index, numInsertChars);
489 for(int i = 0; i < numInsertChars; i++)
490 _chars[index + i] = s[i];
491 _length += numInsertChars;
492 return _length;
493 }
494
495 // !!!!!!!!!!!!!!! test it if newChar = '\0'
496 int Replace(T oldChar, T newChar)
497 {
498 if (oldChar == newChar)
499 return 0;
500 int number = 0;
501 int pos = 0;
502 while (pos < Length())
503 {
504 pos = Find(oldChar, pos);
505 if (pos < 0)
506 break;
507 _chars[pos] = newChar;
508 pos++;
509 number++;
510 }
511 return number;
512 }
513 int Replace(const CStringBase &oldString, const CStringBase &newString)
514 {
515 if (oldString.IsEmpty())
516 return 0;
517 if (oldString == newString)
518 return 0;
519 int oldStringLength = oldString.Length();
520 int newStringLength = newString.Length();
521 int number = 0;
522 int pos = 0;
523 while (pos < _length)
524 {
525 pos = Find(oldString, pos);
526 if (pos < 0)
527 break;
528 Delete(pos, oldStringLength);
529 Insert(pos, newString);
530 pos += newStringLength;
531 number++;
532 }
533 return number;
534 }
535 int Delete(int index, int count = 1 )
536 {
537 if (index + count > _length)
538 count = _length - index;
539 if (count > 0)
540 {
541 MoveItems(index, index + count);
542 _length -= count;
543 }
544 return _length;
545 }
546 };
547
548 template <class T>
549 CStringBase<T> operator+(const CStringBase<T>& s1, const CStringBase<T>& s2)
550 {
551 CStringBase<T> result(s1);
552 result += s2;
553 return result;
554 }
555
556 template <class T>
557 CStringBase<T> operator+(const CStringBase<T>& s, T c)
558 {
559 CStringBase<T> result(s);
560 result += c;
561 return result;
562 }
563
564 template <class T>
565 CStringBase<T> operator+(T c, const CStringBase<T>& s)
566 {
567 CStringBase<T> result(c);
568 result += s;
569 return result;
570 }
571
572 template <class T>
573 CStringBase<T> operator+(const CStringBase<T>& s, const T * chars)
574 {
575 CStringBase<T> result(s);
576 result += chars;
577 return result;
578 }
579
580 template <class T>
581 CStringBase<T> operator+(const T * chars, const CStringBase<T>& s)
582 {
583 CStringBase<T> result(chars);
584 result += s;
585 return result;
586 }
587
588 template <class T>
589 bool operator==(const CStringBase<T>& s1, const CStringBase<T>& s2)
590 { return (s1.Compare(s2) == 0); }
591
592 template <class T>
593 bool operator<(const CStringBase<T>& s1, const CStringBase<T>& s2)
594 { return (s1.Compare(s2) < 0); }
595
596 template <class T>
597 bool operator==(const T *s1, const CStringBase<T>& s2)
598 { return (s2.Compare(s1) == 0); }
599
600 template <class T>
601 bool operator==(const CStringBase<T>& s1, const T *s2)
602 { return (s1.Compare(s2) == 0); }
603
604 template <class T>
605 bool operator!=(const CStringBase<T>& s1, const CStringBase<T>& s2)
606 { return (s1.Compare(s2) != 0); }
607
608 template <class T>
609 bool operator!=(const T *s1, const CStringBase<T>& s2)
610 { return (s2.Compare(s1) != 0); }
611
612 template <class T>
613 bool operator!=(const CStringBase<T>& s1, const T *s2)
614 { return (s1.Compare(s2) != 0); }
615
616 typedef CStringBase<char> AString;
617 typedef CStringBase<wchar_t> UString;
618
619 typedef CObjectVector<AString> AStringVector;
620 typedef CObjectVector<UString> UStringVector;
621
622 #ifdef _UNICODE
623 typedef UString CSysString;
624 #else
625 typedef AString CSysString;
626 #endif
627
628 typedef CObjectVector<CSysString> CSysStringVector;
629
630 #endif
0 // Common/StringConvert.cpp
1
2 #include "StdAfx.h"
3
4 #include "StringConvert.h"
5
6 #ifndef _WIN32
7 #include <stdlib.h>
8 #endif
9
10 #ifdef _WIN32
11 UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
12 {
13 UString resultString;
14 if(!srcString.IsEmpty())
15 {
16 int numChars = MultiByteToWideChar(codePage, 0, srcString,
17 srcString.Length(), resultString.GetBuffer(srcString.Length()),
18 srcString.Length() + 1);
19 #ifndef _WIN32_WCE
20 if(numChars == 0)
21 throw 282228;
22 #endif
23 resultString.ReleaseBuffer(numChars);
24 }
25 return resultString;
26 }
27
28 AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
29 {
30 AString resultString;
31 if(!srcString.IsEmpty())
32 {
33 int numRequiredBytes = srcString.Length() * 2;
34 int numChars = WideCharToMultiByte(codePage, 0, srcString,
35 srcString.Length(), resultString.GetBuffer(numRequiredBytes),
36 numRequiredBytes + 1, NULL, NULL);
37 #ifndef _WIN32_WCE
38 if(numChars == 0)
39 throw 282229;
40 #endif
41 resultString.ReleaseBuffer(numChars);
42 }
43 return resultString;
44 }
45
46 #ifndef _WIN32_WCE
47 AString SystemStringToOemString(const CSysString &srcString)
48 {
49 AString result;
50 CharToOem(srcString, result.GetBuffer(srcString.Length() * 2));
51 result.ReleaseBuffer();
52 return result;
53 }
54 #endif
55
56 #else
57
58 UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
59 {
60 UString resultString;
61 for (int i = 0; i < srcString.Length(); i++)
62 resultString += wchar_t(srcString[i]);
63 /*
64 if(!srcString.IsEmpty())
65 {
66 int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()), srcString, srcString.Length() + 1);
67 if (numChars < 0) throw "Your environment does not support UNICODE";
68 resultString.ReleaseBuffer(numChars);
69 }
70 */
71 return resultString;
72 }
73
74 AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage)
75 {
76 AString resultString;
77 for (int i = 0; i < srcString.Length(); i++)
78 resultString += char(srcString[i]);
79 /*
80 if(!srcString.IsEmpty())
81 {
82 int numRequiredBytes = srcString.Length() * 6 + 1;
83 int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes), srcString, numRequiredBytes);
84 if (numChars < 0) throw "Your environment does not support UNICODE";
85 resultString.ReleaseBuffer(numChars);
86 }
87 */
88 return resultString;
89 }
90
91 #endif
92
0 // Common/StringConvert.h
1
2 #ifndef __COMMON_STRINGCONVERT_H
3 #define __COMMON_STRINGCONVERT_H
4
5 #include "MyWindows.h"
6 #include "Common/String.h"
7 #include "Types.h"
8
9 UString MultiByteToUnicodeString(const AString &srcString, UINT codePage = CP_ACP);
10 AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage = CP_ACP);
11
12 inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString)
13 { return unicodeString; }
14 inline const UString& GetUnicodeString(const UString &unicodeString)
15 { return unicodeString; }
16 inline UString GetUnicodeString(const AString &ansiString)
17 { return MultiByteToUnicodeString(ansiString); }
18 inline UString GetUnicodeString(const AString &multiByteString, UINT codePage)
19 { return MultiByteToUnicodeString(multiByteString, codePage); }
20 inline const wchar_t* GetUnicodeString(const wchar_t* unicodeString, UINT)
21 { return unicodeString; }
22 inline const UString& GetUnicodeString(const UString &unicodeString, UINT)
23 { return unicodeString; }
24
25 inline const char* GetAnsiString(const char* ansiString)
26 { return ansiString; }
27 inline const AString& GetAnsiString(const AString &ansiString)
28 { return ansiString; }
29 inline AString GetAnsiString(const UString &unicodeString)
30 { return UnicodeStringToMultiByte(unicodeString); }
31
32 inline const char* GetOemString(const char* oemString)
33 { return oemString; }
34 inline const AString& GetOemString(const AString &oemString)
35 { return oemString; }
36 inline AString GetOemString(const UString &unicodeString)
37 { return UnicodeStringToMultiByte(unicodeString, CP_OEMCP); }
38
39
40 #ifdef _UNICODE
41 inline const wchar_t* GetSystemString(const wchar_t* unicodeString)
42 { return unicodeString;}
43 inline const UString& GetSystemString(const UString &unicodeString)
44 { return unicodeString;}
45 inline const wchar_t* GetSystemString(const wchar_t* unicodeString, UINT codePage)
46 { return unicodeString;}
47 inline const UString& GetSystemString(const UString &unicodeString, UINT codePage)
48 { return unicodeString;}
49 inline UString GetSystemString(const AString &multiByteString, UINT codePage)
50 { return MultiByteToUnicodeString(multiByteString, codePage);}
51 inline UString GetSystemString(const AString &multiByteString)
52 { return MultiByteToUnicodeString(multiByteString);}
53 #else
54 inline const char* GetSystemString(const char *ansiString)
55 { return ansiString; }
56 inline const AString& GetSystemString(const AString &multiByteString, UINT)
57 { return multiByteString; }
58 inline const char * GetSystemString(const char *multiByteString, UINT)
59 { return multiByteString; }
60 inline AString GetSystemString(const UString &unicodeString)
61 { return UnicodeStringToMultiByte(unicodeString); }
62 inline AString GetSystemString(const UString &unicodeString, UINT codePage)
63 { return UnicodeStringToMultiByte(unicodeString, codePage); }
64 #endif
65
66 #ifndef _WIN32_WCE
67 AString SystemStringToOemString(const CSysString &srcString);
68 #endif
69
70 #endif
0 // Common/StringToInt.cpp
1
2 #include "StdAfx.h"
3
4 #include "StringToInt.h"
5
6 UInt64 ConvertStringToUInt64(const char *s, const char **end)
7 {
8 UInt64 result = 0;
9 while(true)
10 {
11 char c = *s;
12 if (c < '0' || c > '9')
13 {
14 if (end != NULL)
15 *end = s;
16 return result;
17 }
18 result *= 10;
19 result += (c - '0');
20 s++;
21 }
22 }
23
24 UInt64 ConvertOctStringToUInt64(const char *s, const char **end)
25 {
26 UInt64 result = 0;
27 while(true)
28 {
29 char c = *s;
30 if (c < '0' || c > '7')
31 {
32 if (end != NULL)
33 *end = s;
34 return result;
35 }
36 result <<= 3;
37 result += (c - '0');
38 s++;
39 }
40 }
41
42
43 UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end)
44 {
45 UInt64 result = 0;
46 while(true)
47 {
48 wchar_t c = *s;
49 if (c < '0' || c > '9')
50 {
51 if (end != NULL)
52 *end = s;
53 return result;
54 }
55 result *= 10;
56 result += (c - '0');
57 s++;
58 }
59 }
60
61
62 Int64 ConvertStringToInt64(const char *s, const char **end)
63 {
64 if (*s == '-')
65 return -(Int64)ConvertStringToUInt64(s + 1, end);
66 return ConvertStringToUInt64(s, end);
67 }
0 // Common/StringToInt.h
1
2 #ifndef __COMMON_STRINGTOINT_H
3 #define __COMMON_STRINGTOINT_H
4
5 #include <string.h>
6 #include "Types.h"
7
8 UInt64 ConvertStringToUInt64(const char *s, const char **end);
9 UInt64 ConvertOctStringToUInt64(const char *s, const char **end);
10 UInt64 ConvertStringToUInt64(const wchar_t *s, const wchar_t **end);
11
12 Int64 ConvertStringToInt64(const char *s, const char **end);
13
14 #endif
15
16
0 // Common/Types.h
1
2 #ifndef __COMMON_TYPES_H
3 #define __COMMON_TYPES_H
4
5 #ifndef _7ZIP_BYTE_DEFINED
6 #define _7ZIP_BYTE_DEFINED
7 typedef unsigned char Byte;
8 #endif
9
10 #ifndef _7ZIP_INT16_DEFINED
11 #define _7ZIP_INT16_DEFINED
12 typedef short Int16;
13 #endif
14
15 #ifndef _7ZIP_UINT16_DEFINED
16 #define _7ZIP_UINT16_DEFINED
17 typedef unsigned short UInt16;
18 #endif
19
20 #ifndef _7ZIP_INT32_DEFINED
21 #define _7ZIP_INT32_DEFINED
22 typedef int Int32;
23 #endif
24
25 #ifndef _7ZIP_UINT32_DEFINED
26 #define _7ZIP_UINT32_DEFINED
27 typedef unsigned int UInt32;
28 #endif
29
30 #ifdef _MSC_VER
31
32 #ifndef _7ZIP_INT64_DEFINED
33 #define _7ZIP_INT64_DEFINED
34 typedef __int64 Int64;
35 #endif
36
37 #ifndef _7ZIP_UINT64_DEFINED
38 #define _7ZIP_UINT64_DEFINED
39 typedef unsigned __int64 UInt64;
40 #endif
41
42 #else
43
44 #ifndef _7ZIP_INT64_DEFINED
45 #define _7ZIP_INT64_DEFINED
46 typedef long long int Int64;
47 #endif
48
49 #ifndef _7ZIP_UINT64_DEFINED
50 #define _7ZIP_UINT64_DEFINED
51 typedef unsigned long long int UInt64;
52 #endif
53
54 #endif
55
56 #endif
0 // Common/Vector.cpp
1
2 #include "StdAfx.h"
3
4 #include <string.h>
5
6 #include "Vector.h"
7
8 CBaseRecordVector::~CBaseRecordVector()
9 { delete []((unsigned char *)_items); }
10 void CBaseRecordVector::Clear()
11 { DeleteFrom(0); }
12 void CBaseRecordVector::DeleteBack()
13 { Delete(_size - 1); }
14 void CBaseRecordVector::DeleteFrom(int index)
15 { Delete(index, _size - index); }
16
17 void CBaseRecordVector::ReserveOnePosition()
18 {
19 if(_size != _capacity)
20 return;
21 int delta;
22 if (_capacity > 64)
23 delta = _capacity / 2;
24 else if (_capacity > 8)
25 delta = 8;
26 else
27 delta = 4;
28 Reserve(_capacity + delta);
29 }
30
31 void CBaseRecordVector::Reserve(int newCapacity)
32 {
33 if(newCapacity <= _capacity)
34 return;
35 /*
36 #ifndef _DEBUG
37 static const unsigned int kMaxVectorSize = 0xF0000000;
38 if(newCapacity < _size ||
39 ((unsigned int )newCapacity * (unsigned int )_itemSize) > kMaxVectorSize)
40 throw 1052354;
41 #endif
42 */
43 unsigned char *p = new unsigned char[newCapacity * _itemSize];
44 int numRecordsToMove = _capacity;
45 memmove(p, _items, _itemSize * numRecordsToMove);
46 delete [](unsigned char *)_items;
47 _items = p;
48 _capacity = newCapacity;
49 }
50
51 void CBaseRecordVector::MoveItems(int destIndex, int srcIndex)
52 {
53 memmove(((unsigned char *)_items) + destIndex * _itemSize,
54 ((unsigned char *)_items) + srcIndex * _itemSize,
55 _itemSize * (_size - srcIndex));
56 }
57
58 void CBaseRecordVector::InsertOneItem(int index)
59 {
60 ReserveOnePosition();
61 MoveItems(index + 1, index);
62 _size++;
63 }
64
65 void CBaseRecordVector::Delete(int index, int num)
66 {
67 TestIndexAndCorrectNum(index, num);
68 if (num > 0)
69 {
70 MoveItems(index, index + num);
71 _size -= num;
72 }
73 }
0 // Common/Vector.h
1
2 #ifndef __COMMON_VECTOR_H
3 #define __COMMON_VECTOR_H
4
5 #include "Defs.h"
6
7 class CBaseRecordVector
8 {
9 void MoveItems(int destIndex, int srcIndex);
10 protected:
11 int _capacity;
12 int _size;
13 void *_items;
14 size_t _itemSize;
15
16 void ReserveOnePosition();
17 void InsertOneItem(int index);
18 void TestIndexAndCorrectNum(int index, int &num) const
19 { if (index + num > _size) num = _size - index; }
20 public:
21 CBaseRecordVector(size_t itemSize):
22 _capacity(0), _size(0), _items(0), _itemSize(itemSize) {}
23 virtual ~CBaseRecordVector();
24 int Size() const { return _size; }
25 bool IsEmpty() const { return (_size == 0); }
26 void Reserve(int newCapacity);
27 virtual void Delete(int index, int num = 1);
28 void Clear();
29 void DeleteFrom(int index);
30 void DeleteBack();
31 };
32
33 template <class T>
34 class CRecordVector: public CBaseRecordVector
35 {
36 public:
37 CRecordVector():CBaseRecordVector(sizeof(T)){};
38 CRecordVector(const CRecordVector &v):
39 CBaseRecordVector(sizeof(T)) { *this = v;}
40 CRecordVector& operator=(const CRecordVector &v)
41 {
42 Clear();
43 return (*this += v);
44 }
45 CRecordVector& operator+=(const CRecordVector &v)
46 {
47 int size = v.Size();
48 Reserve(Size() + size);
49 for(int i = 0; i < size; i++)
50 Add(v[i]);
51 return *this;
52 }
53 int Add(T item)
54 {
55 ReserveOnePosition();
56 ((T *)_items)[_size] = item;
57 return _size++;
58 }
59 void Insert(int index, T item)
60 {
61 InsertOneItem(index);
62 ((T *)_items)[index] = item;
63 }
64 // T* GetPointer() const { return (T*)_items; }
65 // operator const T *() const { return _items; };
66 const T& operator[](int index) const { return ((T *)_items)[index]; }
67 T& operator[](int index) { return ((T *)_items)[index]; }
68 const T& Front() const { return operator[](0); }
69 T& Front() { return operator[](0); }
70 const T& Back() const { return operator[](_size - 1); }
71 T& Back() { return operator[](_size - 1); }
72
73 void Swap(int i, int j)
74 {
75 T temp = operator[](i);
76 operator[](i) = operator[](j);
77 operator[](j) = temp;
78 }
79
80 int FindInSorted(const T& item) const
81 {
82 int left = 0, right = Size();
83 while (left != right)
84 {
85 int mid = (left + right) / 2;
86 const T& midValue = (*this)[mid];
87 if (item == midValue)
88 return mid;
89 if (item < midValue)
90 right = mid;
91 else
92 left = mid + 1;
93 }
94 return -1;
95 }
96
97 void Sort(int left, int right)
98 {
99 if (right - left < 2)
100 return;
101 Swap(left, (left + right) / 2);
102 int last = left;
103 for (int i = left; i < right; i++)
104 if (operator[](i) < operator[](left))
105 Swap(++last, i);
106 Swap(left, last);
107 Sort(left, last);
108 Sort(last + 1, right);
109 }
110 void Sort() { Sort(0, Size()); }
111 void Sort(int left, int right, int (*compare)(const T*, const T*, void *), void *param)
112 {
113 if (right - left < 2)
114 return;
115 Swap(left, (left + right) / 2);
116 int last = left;
117 for (int i = left; i < right; i++)
118 if (compare(&operator[](i), &operator[](left), param) < 0)
119 Swap(++last, i);
120 Swap(left, last);
121 Sort(left, last, compare, param);
122 Sort(last + 1, right, compare, param);
123 }
124
125 void Sort(int (*compare)(const T*, const T*, void *), void *param)
126 {
127 Sort(0, Size(), compare, param);
128 }
129 };
130
131 typedef CRecordVector<int> CIntVector;
132 typedef CRecordVector<unsigned int> CUIntVector;
133 typedef CRecordVector<bool> CBoolVector;
134 typedef CRecordVector<unsigned char> CByteVector;
135 typedef CRecordVector<void *> CPointerVector;
136
137 template <class T>
138 class CObjectVector: public CPointerVector
139 {
140 public:
141 CObjectVector(){};
142 ~CObjectVector() { Clear(); }
143 CObjectVector(const CObjectVector &objectVector)
144 { *this = objectVector; }
145 CObjectVector& operator=(const CObjectVector &objectVector)
146 {
147 Clear();
148 return (*this += objectVector);
149 }
150 CObjectVector& operator+=(const CObjectVector &objectVector)
151 {
152 int size = objectVector.Size();
153 Reserve(Size() + size);
154 for(int i = 0; i < size; i++)
155 Add(objectVector[i]);
156 return *this;
157 }
158 const T& operator[](int index) const { return *((T *)CPointerVector::operator[](index)); }
159 T& operator[](int index) { return *((T *)CPointerVector::operator[](index)); }
160 T& Front() { return operator[](0); }
161 const T& Front() const { return operator[](0); }
162 T& Back() { return operator[](_size - 1); }
163 const T& Back() const { return operator[](_size - 1); }
164 int Add(const T& item)
165 { return CPointerVector::Add(new T(item)); }
166 void Insert(int index, const T& item)
167 { CPointerVector::Insert(index, new T(item)); }
168 virtual void Delete(int index, int num = 1)
169 {
170 TestIndexAndCorrectNum(index, num);
171 for(int i = 0; i < num; i++)
172 delete (T *)(((void **)_items)[index + i]);
173 CPointerVector::Delete(index, num);
174 }
175 int Find(const T& item) const
176 {
177 for(int i = 0; i < Size(); i++)
178 if (item == (*this)[i])
179 return i;
180 return -1;
181 }
182 int FindInSorted(const T& item) const
183 {
184 int left = 0, right = Size();
185 while (left != right)
186 {
187 int mid = (left + right) / 2;
188 const T& midValue = (*this)[mid];
189 if (item == midValue)
190 return mid;
191 if (item < midValue)
192 right = mid;
193 else
194 left = mid + 1;
195 }
196 return -1;
197 }
198 int AddToSorted(const T& item)
199 {
200 int left = 0, right = Size();
201 while (left != right)
202 {
203 int mid = (left + right) / 2;
204 const T& midValue = (*this)[mid];
205 if (item == midValue)
206 {
207 right = mid + 1;
208 break;
209 }
210 if (item < midValue)
211 right = mid;
212 else
213 left = mid + 1;
214 }
215 Insert(right, item);
216 return right;
217 }
218
219 void Sort(int (*compare)(void *const *, void *const *, void *), void *param)
220 { CPointerVector::Sort(compare, param); }
221
222 static int CompareObjectItems(void *const *a1, void *const *a2, void *param)
223 { return MyCompare(*(*((const T **)a1)), *(*((const T **)a2))); }
224 void Sort() { CPointerVector::Sort(CompareObjectItems, 0); }
225 };
226
227 #endif
0 // Windows/Defs.h
1
2 #ifndef __WINDOWS_DEFS_H
3 #define __WINDOWS_DEFS_H
4
5 inline bool BOOLToBool(BOOL value)
6 { return (value != FALSE); }
7
8 inline BOOL BoolToBOOL(bool value)
9 { return (value ? TRUE: FALSE); }
10
11 inline VARIANT_BOOL BoolToVARIANT_BOOL(bool value)
12 { return (value ? VARIANT_TRUE: VARIANT_FALSE); }
13
14 inline bool VARIANT_BOOLToBool(VARIANT_BOOL value)
15 { return (value != VARIANT_FALSE); }
16
17 #endif
0 // Windows/FileIO.cpp
1
2 #include "StdAfx.h"
3
4 #include "FileIO.h"
5 #include "Defs.h"
6 #ifndef _UNICODE
7 #include "../Common/StringConvert.h"
8 #endif
9
10 #ifndef _UNICODE
11 extern bool g_IsNT;
12 #endif
13
14 namespace NWindows {
15 namespace NFile {
16 namespace NIO {
17
18 CFileBase::~CFileBase() { Close(); }
19
20 bool CFileBase::Create(LPCTSTR fileName, DWORD desiredAccess,
21 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
22 {
23 Close();
24 _handle = ::CreateFile(fileName, desiredAccess, shareMode,
25 (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
26 flagsAndAttributes, (HANDLE) NULL);
27 return (_fileIsOpen = (_handle != INVALID_HANDLE_VALUE));
28 }
29
30 #ifndef _UNICODE
31 bool CFileBase::Create(LPCWSTR fileName, DWORD desiredAccess,
32 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
33 {
34 if (g_IsNT)
35 {
36 Close();
37 _handle = ::CreateFileW(fileName, desiredAccess, shareMode,
38 (LPSECURITY_ATTRIBUTES)NULL, creationDisposition,
39 flagsAndAttributes, (HANDLE) NULL);
40 return (_fileIsOpen = (_handle != INVALID_HANDLE_VALUE));
41 }
42 return Create(UnicodeStringToMultiByte(fileName, ::AreFileApisANSI() ? CP_ACP : CP_OEMCP),
43 desiredAccess, shareMode, creationDisposition, flagsAndAttributes);
44 }
45 #endif
46
47 bool CFileBase::Close()
48 {
49 if(!_fileIsOpen)
50 return true;
51 bool result = BOOLToBool(::CloseHandle(_handle));
52 _fileIsOpen = !result;
53 return result;
54 }
55
56 bool CFileBase::GetPosition(UInt64 &position) const
57 {
58 return Seek(0, FILE_CURRENT, position);
59 }
60
61 bool CFileBase::GetLength(UInt64 &length) const
62 {
63 DWORD sizeHigh;
64 DWORD sizeLow = ::GetFileSize(_handle, &sizeHigh);
65 if(sizeLow == 0xFFFFFFFF)
66 if(::GetLastError() != NO_ERROR)
67 return false;
68 length = (((UInt64)sizeHigh) << 32) + sizeLow;
69 return true;
70 }
71
72 bool CFileBase::Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const
73 {
74 LARGE_INTEGER value;
75 value.QuadPart = distanceToMove;
76 value.LowPart = ::SetFilePointer(_handle, value.LowPart, &value.HighPart, moveMethod);
77 if (value.LowPart == 0xFFFFFFFF)
78 if(::GetLastError() != NO_ERROR)
79 return false;
80 newPosition = value.QuadPart;
81 return true;
82 }
83
84 bool CFileBase::Seek(UInt64 position, UInt64 &newPosition)
85 {
86 return Seek(position, FILE_BEGIN, newPosition);
87 }
88
89 bool CFileBase::SeekToBegin()
90 {
91 UInt64 newPosition;
92 return Seek(0, newPosition);
93 }
94
95 bool CFileBase::SeekToEnd(UInt64 &newPosition)
96 {
97 return Seek(0, FILE_END, newPosition);
98 }
99
100 bool CFileBase::GetFileInformation(CByHandleFileInfo &fileInfo) const
101 {
102 BY_HANDLE_FILE_INFORMATION winFileInfo;
103 if(!::GetFileInformationByHandle(_handle, &winFileInfo))
104 return false;
105 fileInfo.Attributes = winFileInfo.dwFileAttributes;
106 fileInfo.CreationTime = winFileInfo.ftCreationTime;
107 fileInfo.LastAccessTime = winFileInfo.ftLastAccessTime;
108 fileInfo.LastWriteTime = winFileInfo.ftLastWriteTime;
109 fileInfo.VolumeSerialNumber = winFileInfo.dwFileAttributes;
110 fileInfo.Size = (((UInt64)winFileInfo.nFileSizeHigh) << 32) + winFileInfo.nFileSizeLow;
111 fileInfo.NumberOfLinks = winFileInfo.nNumberOfLinks;
112 fileInfo.FileIndex = (((UInt64)winFileInfo.nFileIndexHigh) << 32) + winFileInfo.nFileIndexLow;
113 return true;
114 }
115
116 /////////////////////////
117 // CInFile
118
119 bool CInFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
120 { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
121
122 bool CInFile::Open(LPCTSTR fileName)
123 { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
124
125 #ifndef _UNICODE
126 bool CInFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
127 { return Create(fileName, GENERIC_READ, shareMode, creationDisposition, flagsAndAttributes); }
128
129 bool CInFile::Open(LPCWSTR fileName)
130 { return Open(fileName, FILE_SHARE_READ, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL); }
131 #endif
132
133 // ReadFile and WriteFile functions in Windows have BUG:
134 // If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
135 // from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
136 // (Insufficient system resources exist to complete the requested service).
137
138 static UInt32 kChunkSizeMax = (1 << 24);
139
140 bool CInFile::ReadPart(void *data, UInt32 size, UInt32 &processedSize)
141 {
142 if (size > kChunkSizeMax)
143 size = kChunkSizeMax;
144 DWORD processedLoc = 0;
145 bool res = BOOLToBool(::ReadFile(_handle, data, size, &processedLoc, NULL));
146 processedSize = (UInt32)processedLoc;
147 return res;
148 }
149
150 bool CInFile::Read(void *data, UInt32 size, UInt32 &processedSize)
151 {
152 processedSize = 0;
153 do
154 {
155 UInt32 processedLoc = 0;
156 bool res = ReadPart(data, size, processedLoc);
157 processedSize += processedLoc;
158 if (!res)
159 return false;
160 if (processedLoc == 0)
161 return true;
162 data = (void *)((unsigned char *)data + processedLoc);
163 size -= processedLoc;
164 }
165 while (size > 0);
166 return true;
167 }
168
169 /////////////////////////
170 // COutFile
171
172 bool COutFile::Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
173 { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
174
175 static inline DWORD GetCreationDisposition(bool createAlways)
176 { return createAlways? CREATE_ALWAYS: CREATE_NEW; }
177
178 bool COutFile::Open(LPCTSTR fileName, DWORD creationDisposition)
179 { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
180
181 bool COutFile::Create(LPCTSTR fileName, bool createAlways)
182 { return Open(fileName, GetCreationDisposition(createAlways)); }
183
184 #ifndef _UNICODE
185
186 bool COutFile::Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes)
187 { return CFileBase::Create(fileName, GENERIC_WRITE, shareMode, creationDisposition, flagsAndAttributes); }
188
189 bool COutFile::Open(LPCWSTR fileName, DWORD creationDisposition)
190 { return Open(fileName, FILE_SHARE_READ, creationDisposition, FILE_ATTRIBUTE_NORMAL); }
191
192 bool COutFile::Create(LPCWSTR fileName, bool createAlways)
193 { return Open(fileName, GetCreationDisposition(createAlways)); }
194
195 #endif
196
197 bool COutFile::SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime)
198 { return BOOLToBool(::SetFileTime(_handle, creationTime, lastAccessTime, lastWriteTime)); }
199
200 bool COutFile::SetLastWriteTime(const FILETIME *lastWriteTime)
201 { return SetTime(NULL, NULL, lastWriteTime); }
202
203 bool COutFile::WritePart(const void *data, UInt32 size, UInt32 &processedSize)
204 {
205 if (size > kChunkSizeMax)
206 size = kChunkSizeMax;
207 DWORD processedLoc = 0;
208 bool res = BOOLToBool(::WriteFile(_handle, data, size, &processedLoc, NULL));
209 processedSize = (UInt32)processedLoc;
210 return res;
211 }
212
213 bool COutFile::Write(const void *data, UInt32 size, UInt32 &processedSize)
214 {
215 processedSize = 0;
216 do
217 {
218 UInt32 processedLoc = 0;
219 bool res = WritePart(data, size, processedLoc);
220 processedSize += processedLoc;
221 if (!res)
222 return false;
223 if (processedLoc == 0)
224 return true;
225 data = (const void *)((const unsigned char *)data + processedLoc);
226 size -= processedLoc;
227 }
228 while (size > 0);
229 return true;
230 }
231
232 bool COutFile::SetEndOfFile() { return BOOLToBool(::SetEndOfFile(_handle)); }
233
234 bool COutFile::SetLength(UInt64 length)
235 {
236 UInt64 newPosition;
237 if(!Seek(length, newPosition))
238 return false;
239 if(newPosition != length)
240 return false;
241 return SetEndOfFile();
242 }
243
244 }}}
0 // Windows/FileIO.h
1
2 #ifndef __WINDOWS_FILEIO_H
3 #define __WINDOWS_FILEIO_H
4
5 #include "../Common/Types.h"
6
7 namespace NWindows {
8 namespace NFile {
9 namespace NIO {
10
11 struct CByHandleFileInfo
12 {
13 DWORD Attributes;
14 FILETIME CreationTime;
15 FILETIME LastAccessTime;
16 FILETIME LastWriteTime;
17 DWORD VolumeSerialNumber;
18 UInt64 Size;
19 DWORD NumberOfLinks;
20 UInt64 FileIndex;
21 };
22
23 class CFileBase
24 {
25 protected:
26 bool _fileIsOpen;
27 HANDLE _handle;
28 bool Create(LPCTSTR fileName, DWORD desiredAccess,
29 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
30 #ifndef _UNICODE
31 bool Create(LPCWSTR fileName, DWORD desiredAccess,
32 DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
33 #endif
34
35 public:
36 CFileBase(): _fileIsOpen(false){};
37 virtual ~CFileBase();
38
39 virtual bool Close();
40
41 bool GetPosition(UInt64 &position) const;
42 bool GetLength(UInt64 &length) const;
43
44 bool Seek(Int64 distanceToMove, DWORD moveMethod, UInt64 &newPosition) const;
45 bool Seek(UInt64 position, UInt64 &newPosition);
46 bool SeekToBegin();
47 bool SeekToEnd(UInt64 &newPosition);
48
49 bool GetFileInformation(CByHandleFileInfo &fileInfo) const;
50 };
51
52 class CInFile: public CFileBase
53 {
54 public:
55 bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
56 bool Open(LPCTSTR fileName);
57 #ifndef _UNICODE
58 bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
59 bool Open(LPCWSTR fileName);
60 #endif
61 bool ReadPart(void *data, UInt32 size, UInt32 &processedSize);
62 bool Read(void *data, UInt32 size, UInt32 &processedSize);
63 };
64
65 class COutFile: public CFileBase
66 {
67 // DWORD m_CreationDisposition;
68 public:
69 // COutFile(): m_CreationDisposition(CREATE_NEW){};
70 bool Open(LPCTSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
71 bool Open(LPCTSTR fileName, DWORD creationDisposition);
72 bool Create(LPCTSTR fileName, bool createAlways);
73
74 #ifndef _UNICODE
75 bool Open(LPCWSTR fileName, DWORD shareMode, DWORD creationDisposition, DWORD flagsAndAttributes);
76 bool Open(LPCWSTR fileName, DWORD creationDisposition);
77 bool Create(LPCWSTR fileName, bool createAlways);
78 #endif
79
80 /*
81 void SetOpenCreationDisposition(DWORD creationDisposition)
82 { m_CreationDisposition = creationDisposition; }
83 void SetOpenCreationDispositionCreateAlways()
84 { m_CreationDisposition = CREATE_ALWAYS; }
85 */
86
87 bool SetTime(const FILETIME *creationTime, const FILETIME *lastAccessTime, const FILETIME *lastWriteTime);
88 bool SetLastWriteTime(const FILETIME *lastWriteTime);
89 bool WritePart(const void *data, UInt32 size, UInt32 &processedSize);
90 bool Write(const void *data, UInt32 size, UInt32 &processedSize);
91 bool SetEndOfFile();
92 bool SetLength(UInt64 length);
93 };
94
95 }}}
96
97 #endif
0 // StdAfx.h
1
2 #ifndef __STDAFX_H
3 #define __STDAFX_H
4
5 #include "../Common/MyWindows.h"
6 #include "../Common/NewHandler.h"
7
8 #endif
0 GNU LESSER GENERAL PUBLIC LICENSE
1 Version 2.1, February 1999
2
3 Copyright (C) 1991, 1999 Free Software Foundation, Inc.
4 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5 Everyone is permitted to copy and distribute verbatim copies
6 of this license document, but changing it is not allowed.
7
8 [This is the first released version of the Lesser GPL. It also counts
9 as the successor of the GNU Library Public License, version 2, hence
10 the version number 2.1.]
11
12 Preamble
13
14 The licenses for most software are designed to take away your
15 freedom to share and change it. By contrast, the GNU General Public
16 Licenses are intended to guarantee your freedom to share and change
17 free software--to make sure the software is free for all its users.
18
19 This license, the Lesser General Public License, applies to some
20 specially designated software packages--typically libraries--of the
21 Free Software Foundation and other authors who decide to use it. You
22 can use it too, but we suggest you first think carefully about whether
23 this license or the ordinary General Public License is the better
24 strategy to use in any particular case, based on the explanations below.
25
26 When we speak of free software, we are referring to freedom of use,
27 not price. Our General Public Licenses are designed to make sure that
28 you have the freedom to distribute copies of free software (and charge
29 for this service if you wish); that you receive source code or can get
30 it if you want it; that you can change the software and use pieces of
31 it in new free programs; and that you are informed that you can do
32 these things.
33
34 To protect your rights, we need to make restrictions that forbid
35 distributors to deny you these rights or to ask you to surrender these
36 rights. These restrictions translate to certain responsibilities for
37 you if you distribute copies of the library or if you modify it.
38
39 For example, if you distribute copies of the library, whether gratis
40 or for a fee, you must give the recipients all the rights that we gave
41 you. You must make sure that they, too, receive or can get the source
42 code. If you link other code with the library, you must provide
43 complete object files to the recipients, so that they can relink them
44 with the library after making changes to the library and recompiling
45 it. And you must show them these terms so they know their rights.
46
47 We protect your rights with a two-step method: (1) we copyright the
48 library, and (2) we offer you this license, which gives you legal
49 permission to copy, distribute and/or modify the library.
50
51 To protect each distributor, we want to make it very clear that
52 there is no warranty for the free library. Also, if the library is
53 modified by someone else and passed on, the recipients should know
54 that what they have is not the original version, so that the original
55 author's reputation will not be affected by problems that might be
56 introduced by others.
57
58 Finally, software patents pose a constant threat to the existence of
59 any free program. We wish to make sure that a company cannot
60 effectively restrict the users of a free program by obtaining a
61 restrictive license from a patent holder. Therefore, we insist that
62 any patent license obtained for a version of the library must be
63 consistent with the full freedom of use specified in this license.
64
65 Most GNU software, including some libraries, is covered by the
66 ordinary GNU General Public License. This license, the GNU Lesser
67 General Public License, applies to certain designated libraries, and
68 is quite different from the ordinary General Public License. We use
69 this license for certain libraries in order to permit linking those
70 libraries into non-free programs.
71
72 When a program is linked with a library, whether statically or using
73 a shared library, the combination of the two is legally speaking a
74 combined work, a derivative of the original library. The ordinary
75 General Public License therefore permits such linking only if the
76 entire combination fits its criteria of freedom. The Lesser General
77 Public License permits more lax criteria for linking other code with
78 the library.
79
80 We call this license the "Lesser" General Public License because it
81 does Less to protect the user's freedom than the ordinary General
82 Public License. It also provides other free software developers Less
83 of an advantage over competing non-free programs. These disadvantages
84 are the reason we use the ordinary General Public License for many
85 libraries. However, the Lesser license provides advantages in certain
86 special circumstances.
87
88 For example, on rare occasions, there may be a special need to
89 encourage the widest possible use of a certain library, so that it becomes
90 a de-facto standard. To achieve this, non-free programs must be
91 allowed to use the library. A more frequent case is that a free
92 library does the same job as widely used non-free libraries. In this
93 case, there is little to gain by limiting the free library to free
94 software only, so we use the Lesser General Public License.
95
96 In other cases, permission to use a particular library in non-free
97 programs enables a greater number of people to use a large body of
98 free software. For example, permission to use the GNU C Library in
99 non-free programs enables many more people to use the whole GNU
100 operating system, as well as its variant, the GNU/Linux operating
101 system.
102
103 Although the Lesser General Public License is Less protective of the
104 users' freedom, it does ensure that the user of a program that is
105 linked with the Library has the freedom and the wherewithal to run
106 that program using a modified version of the Library.
107
108 The precise terms and conditions for copying, distribution and
109 modification follow. Pay close attention to the difference between a
110 "work based on the library" and a "work that uses the library". The
111 former contains code derived from the library, whereas the latter must
112 be combined with the library in order to run.
113
114 GNU LESSER GENERAL PUBLIC LICENSE
115 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
116
117 0. This License Agreement applies to any software library or other
118 program which contains a notice placed by the copyright holder or
119 other authorized party saying it may be distributed under the terms of
120 this Lesser General Public License (also called "this License").
121 Each licensee is addressed as "you".
122
123 A "library" means a collection of software functions and/or data
124 prepared so as to be conveniently linked with application programs
125 (which use some of those functions and data) to form executables.
126
127 The "Library", below, refers to any such software library or work
128 which has been distributed under these terms. A "work based on the
129 Library" means either the Library or any derivative work under
130 copyright law: that is to say, a work containing the Library or a
131 portion of it, either verbatim or with modifications and/or translated
132 straightforwardly into another language. (Hereinafter, translation is
133 included without limitation in the term "modification".)
134
135 "Source code" for a work means the preferred form of the work for
136 making modifications to it. For a library, complete source code means
137 all the source code for all modules it contains, plus any associated
138 interface definition files, plus the scripts used to control compilation
139 and installation of the library.
140
141 Activities other than copying, distribution and modification are not
142 covered by this License; they are outside its scope. The act of
143 running a program using the Library is not restricted, and output from
144 such a program is covered only if its contents constitute a work based
145 on the Library (independent of the use of the Library in a tool for
146 writing it). Whether that is true depends on what the Library does
147 and what the program that uses the Library does.
148
149 1. You may copy and distribute verbatim copies of the Library's
150 complete source code as you receive it, in any medium, provided that
151 you conspicuously and appropriately publish on each copy an
152 appropriate copyright notice and disclaimer of warranty; keep intact
153 all the notices that refer to this License and to the absence of any
154 warranty; and distribute a copy of this License along with the
155 Library.
156
157 You may charge a fee for the physical act of transferring a copy,
158 and you may at your option offer warranty protection in exchange for a
159 fee.
160
161 2. You may modify your copy or copies of the Library or any portion
162 of it, thus forming a work based on the Library, and copy and
163 distribute such modifications or work under the terms of Section 1
164 above, provided that you also meet all of these conditions:
165
166 a) The modified work must itself be a software library.
167
168 b) You must cause the files modified to carry prominent notices
169 stating that you changed the files and the date of any change.
170
171 c) You must cause the whole of the work to be licensed at no
172 charge to all third parties under the terms of this License.
173
174 d) If a facility in the modified Library refers to a function or a
175 table of data to be supplied by an application program that uses
176 the facility, other than as an argument passed when the facility
177 is invoked, then you must make a good faith effort to ensure that,
178 in the event an application does not supply such function or
179 table, the facility still operates, and performs whatever part of
180 its purpose remains meaningful.
181
182 (For example, a function in a library to compute square roots has
183 a purpose that is entirely well-defined independent of the
184 application. Therefore, Subsection 2d requires that any
185 application-supplied function or table used by this function must
186 be optional: if the application does not supply it, the square
187 root function must still compute square roots.)
188
189 These requirements apply to the modified work as a whole. If
190 identifiable sections of that work are not derived from the Library,
191 and can be reasonably considered independent and separate works in
192 themselves, then this License, and its terms, do not apply to those
193 sections when you distribute them as separate works. But when you
194 distribute the same sections as part of a whole which is a work based
195 on the Library, the distribution of the whole must be on the terms of
196 this License, whose permissions for other licensees extend to the
197 entire whole, and thus to each and every part regardless of who wrote
198 it.
199
200 Thus, it is not the intent of this section to claim rights or contest
201 your rights to work written entirely by you; rather, the intent is to
202 exercise the right to control the distribution of derivative or
203 collective works based on the Library.
204
205 In addition, mere aggregation of another work not based on the Library
206 with the Library (or with a work based on the Library) on a volume of
207 a storage or distribution medium does not bring the other work under
208 the scope of this License.
209
210 3. You may opt to apply the terms of the ordinary GNU General Public
211 License instead of this License to a given copy of the Library. To do
212 this, you must alter all the notices that refer to this License, so
213 that they refer to the ordinary GNU General Public License, version 2,
214 instead of to this License. (If a newer version than version 2 of the
215 ordinary GNU General Public License has appeared, then you can specify
216 that version instead if you wish.) Do not make any other change in
217 these notices.
218
219 Once this change is made in a given copy, it is irreversible for
220 that copy, so the ordinary GNU General Public License applies to all
221 subsequent copies and derivative works made from that copy.
222
223 This option is useful when you wish to copy part of the code of
224 the Library into a program that is not a library.
225
226 4. You may copy and distribute the Library (or a portion or
227 derivative of it, under Section 2) in object code or executable form
228 under the terms of Sections 1 and 2 above provided that you accompany
229 it with the complete corresponding machine-readable source code, which
230 must be distributed under the terms of Sections 1 and 2 above on a
231 medium customarily used for software interchange.
232
233 If distribution of object code is made by offering access to copy
234 from a designated place, then offering equivalent access to copy the
235 source code from the same place satisfies the requirement to
236 distribute the source code, even though third parties are not
237 compelled to copy the source along with the object code.
238
239 5. A program that contains no derivative of any portion of the
240 Library, but is designed to work with the Library by being compiled or
241 linked with it, is called a "work that uses the Library". Such a
242 work, in isolation, is not a derivative work of the Library, and
243 therefore falls outside the scope of this License.
244
245 However, linking a "work that uses the Library" with the Library
246 creates an executable that is a derivative of the Library (because it
247 contains portions of the Library), rather than a "work that uses the
248 library". The executable is therefore covered by this License.
249 Section 6 states terms for distribution of such executables.
250
251 When a "work that uses the Library" uses material from a header file
252 that is part of the Library, the object code for the work may be a
253 derivative work of the Library even though the source code is not.
254 Whether this is true is especially significant if the work can be
255 linked without the Library, or if the work is itself a library. The
256 threshold for this to be true is not precisely defined by law.
257
258 If such an object file uses only numerical parameters, data
259 structure layouts and accessors, and small macros and small inline
260 functions (ten lines or less in length), then the use of the object
261 file is unrestricted, regardless of whether it is legally a derivative
262 work. (Executables containing this object code plus portions of the
263 Library will still fall under Section 6.)
264
265 Otherwise, if the work is a derivative of the Library, you may
266 distribute the object code for the work under the terms of Section 6.
267 Any executables containing that work also fall under Section 6,
268 whether or not they are linked directly with the Library itself.
269
270 6. As an exception to the Sections above, you may also combine or
271 link a "work that uses the Library" with the Library to produce a
272 work containing portions of the Library, and distribute that work
273 under terms of your choice, provided that the terms permit
274 modification of the work for the customer's own use and reverse
275 engineering for debugging such modifications.
276
277 You must give prominent notice with each copy of the work that the
278 Library is used in it and that the Library and its use are covered by
279 this License. You must supply a copy of this License. If the work
280 during execution displays copyright notices, you must include the
281 copyright notice for the Library among them, as well as a reference
282 directing the user to the copy of this License. Also, you must do one
283 of these things:
284
285 a) Accompany the work with the complete corresponding
286 machine-readable source code for the Library including whatever
287 changes were used in the work (which must be distributed under
288 Sections 1 and 2 above); and, if the work is an executable linked
289 with the Library, with the complete machine-readable "work that
290 uses the Library", as object code and/or source code, so that the
291 user can modify the Library and then relink to produce a modified
292 executable containing the modified Library. (It is understood
293 that the user who changes the contents of definitions files in the
294 Library will not necessarily be able to recompile the application
295 to use the modified definitions.)
296
297 b) Use a suitable shared library mechanism for linking with the
298 Library. A suitable mechanism is one that (1) uses at run time a
299 copy of the library already present on the user's computer system,
300 rather than copying library functions into the executable, and (2)
301 will operate properly with a modified version of the library, if
302 the user installs one, as long as the modified version is
303 interface-compatible with the version that the work was made with.
304
305 c) Accompany the work with a written offer, valid for at
306 least three years, to give the same user the materials
307 specified in Subsection 6a, above, for a charge no more
308 than the cost of performing this distribution.
309
310 d) If distribution of the work is made by offering access to copy
311 from a designated place, offer equivalent access to copy the above
312 specified materials from the same place.
313
314 e) Verify that the user has already received a copy of these
315 materials or that you have already sent this user a copy.
316
317 For an executable, the required form of the "work that uses the
318 Library" must include any data and utility programs needed for
319 reproducing the executable from it. However, as a special exception,
320 the materials to be distributed need not include anything that is
321 normally distributed (in either source or binary form) with the major
322 components (compiler, kernel, and so on) of the operating system on
323 which the executable runs, unless that component itself accompanies
324 the executable.
325
326 It may happen that this requirement contradicts the license
327 restrictions of other proprietary libraries that do not normally
328 accompany the operating system. Such a contradiction means you cannot
329 use both them and the Library together in an executable that you
330 distribute.
331
332 7. You may place library facilities that are a work based on the
333 Library side-by-side in a single library together with other library
334 facilities not covered by this License, and distribute such a combined
335 library, provided that the separate distribution of the work based on
336 the Library and of the other library facilities is otherwise
337 permitted, and provided that you do these two things:
338
339 a) Accompany the combined library with a copy of the same work
340 based on the Library, uncombined with any other library
341 facilities. This must be distributed under the terms of the
342 Sections above.
343
344 b) Give prominent notice with the combined library of the fact
345 that part of it is a work based on the Library, and explaining
346 where to find the accompanying uncombined form of the same work.
347
348 8. You may not copy, modify, sublicense, link with, or distribute
349 the Library except as expressly provided under this License. Any
350 attempt otherwise to copy, modify, sublicense, link with, or
351 distribute the Library is void, and will automatically terminate your
352 rights under this License. However, parties who have received copies,
353 or rights, from you under this License will not have their licenses
354 terminated so long as such parties remain in full compliance.
355
356 9. You are not required to accept this License, since you have not
357 signed it. However, nothing else grants you permission to modify or
358 distribute the Library or its derivative works. These actions are
359 prohibited by law if you do not accept this License. Therefore, by
360 modifying or distributing the Library (or any work based on the
361 Library), you indicate your acceptance of this License to do so, and
362 all its terms and conditions for copying, distributing or modifying
363 the Library or works based on it.
364
365 10. Each time you redistribute the Library (or any work based on the
366 Library), the recipient automatically receives a license from the
367 original licensor to copy, distribute, link with or modify the Library
368 subject to these terms and conditions. You may not impose any further
369 restrictions on the recipients' exercise of the rights granted herein.
370 You are not responsible for enforcing compliance by third parties with
371 this License.
372
373 11. If, as a consequence of a court judgment or allegation of patent
374 infringement or for any other reason (not limited to patent issues),
375 conditions are imposed on you (whether by court order, agreement or
376 otherwise) that contradict the conditions of this License, they do not
377 excuse you from the conditions of this License. If you cannot
378 distribute so as to satisfy simultaneously your obligations under this
379 License and any other pertinent obligations, then as a consequence you
380 may not distribute the Library at all. For example, if a patent
381 license would not permit royalty-free redistribution of the Library by
382 all those who receive copies directly or indirectly through you, then
383 the only way you could satisfy both it and this License would be to
384 refrain entirely from distribution of the Library.
385
386 If any portion of this section is held invalid or unenforceable under any
387 particular circumstance, the balance of the section is intended to apply,
388 and the section as a whole is intended to apply in other circumstances.
389
390 It is not the purpose of this section to induce you to infringe any
391 patents or other property right claims or to contest validity of any
392 such claims; this section has the sole purpose of protecting the
393 integrity of the free software distribution system which is
394 implemented by public license practices. Many people have made
395 generous contributions to the wide range of software distributed
396 through that system in reliance on consistent application of that
397 system; it is up to the author/donor to decide if he or she is willing
398 to distribute software through any other system and a licensee cannot
399 impose that choice.
400
401 This section is intended to make thoroughly clear what is believed to
402 be a consequence of the rest of this License.
403
404 12. If the distribution and/or use of the Library is restricted in
405 certain countries either by patents or by copyrighted interfaces, the
406 original copyright holder who places the Library under this License may add
407 an explicit geographical distribution limitation excluding those countries,
408 so that distribution is permitted only in or among countries not thus
409 excluded. In such case, this License incorporates the limitation as if
410 written in the body of this License.
411
412 13. The Free Software Foundation may publish revised and/or new
413 versions of the Lesser General Public License from time to time.
414 Such new versions will be similar in spirit to the present version,
415 but may differ in detail to address new problems or concerns.
416
417 Each version is given a distinguishing version number. If the Library
418 specifies a version number of this License which applies to it and
419 "any later version", you have the option of following the terms and
420 conditions either of that version or of any later version published by
421 the Free Software Foundation. If the Library does not specify a
422 license version number, you may choose any version ever published by
423 the Free Software Foundation.
424
425 14. If you wish to incorporate parts of the Library into other free
426 programs whose distribution conditions are incompatible with these,
427 write to the author to ask for permission. For software which is
428 copyrighted by the Free Software Foundation, write to the Free
429 Software Foundation; we sometimes make exceptions for this. Our
430 decision will be guided by the two goals of preserving the free status
431 of all derivatives of our free software and of promoting the sharing
432 and reuse of software generally.
433
434 NO WARRANTY
435
436 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
437 WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
438 EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
439 OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
440 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
441 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
442 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
443 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
444 THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
445
446 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
447 WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
448 AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
449 FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
450 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
451 LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
452 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
453 FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
454 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
455 DAMAGES.
456
457 END OF TERMS AND CONDITIONS
458
459 How to Apply These Terms to Your New Libraries
460
461 If you develop a new library, and you want it to be of the greatest
462 possible use to the public, we recommend making it free software that
463 everyone can redistribute and change. You can do so by permitting
464 redistribution under these terms (or, alternatively, under the terms of the
465 ordinary General Public License).
466
467 To apply these terms, attach the following notices to the library. It is
468 safest to attach them to the start of each source file to most effectively
469 convey the exclusion of warranty; and each file should have at least the
470 "copyright" line and a pointer to where the full notice is found.
471
472 <one line to give the library's name and a brief idea of what it does.>
473 Copyright (C) <year> <name of author>
474
475 This library is free software; you can redistribute it and/or
476 modify it under the terms of the GNU Lesser General Public
477 License as published by the Free Software Foundation; either
478 version 2.1 of the License, or (at your option) any later version.
479
480 This library is distributed in the hope that it will be useful,
481 but WITHOUT ANY WARRANTY; without even the implied warranty of
482 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
483 Lesser General Public License for more details.
484
485 You should have received a copy of the GNU Lesser General Public
486 License along with this library; if not, write to the Free Software
487 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
488
489 Also add information on how to contact you by electronic and paper mail.
490
491 You should also get your employer (if you work as a programmer) or your
492 school, if any, to sign a "copyright disclaimer" for the library, if
493 necessary. Here is a sample; alter the names:
494
495 Yoyodyne, Inc., hereby disclaims all copyright interest in the
496 library `Frob' (a library for tweaking knobs) written by James Random Hacker.
497
498 <signature of Ty Coon>, 1 April 1990
499 Ty Coon, President of Vice
500
501 That's all there is to it!
502
503
0 # We don't actually build LZMA; we just
1 # want to bring along the source code to satisfy LGPL requirements.
2
3 EXTRA_DIST = \
4 7zC.txt \
5 7zFormat.txt \
6 C/7zip/Archive/7z_C/7zAlloc.c \
7 C/7zip/Archive/7z_C/7zAlloc.h \
8 C/7zip/Archive/7z_C/7zBuffer.c \
9 C/7zip/Archive/7z_C/7zBuffer.h \
10 C/7zip/Archive/7z_C/7zCrc.c \
11 C/7zip/Archive/7z_C/7zCrc.h \
12 C/7zip/Archive/7z_C/7zDecode.c \
13 C/7zip/Archive/7z_C/7zDecode.h \
14 C/7zip/Archive/7z_C/7zExtract.c \
15 C/7zip/Archive/7z_C/7zExtract.h \
16 C/7zip/Archive/7z_C/7zHeader.c \
17 C/7zip/Archive/7z_C/7zHeader.h \
18 C/7zip/Archive/7z_C/7zIn.c \
19 C/7zip/Archive/7z_C/7zIn.h \
20 C/7zip/Archive/7z_C/7zItem.c \
21 C/7zip/Archive/7z_C/7zItem.h \
22 C/7zip/Archive/7z_C/7zMain.c \
23 C/7zip/Archive/7z_C/7zMethodID.c \
24 C/7zip/Archive/7z_C/7zMethodID.h \
25 C/7zip/Archive/7z_C/7zTypes.h \
26 C/7zip/Archive/7z_C/7z_C.dsp \
27 C/7zip/Archive/7z_C/7z_C.dsw \
28 C/7zip/Archive/7z_C/makefile \
29 C/7zip/Archive/7z_C/makefile.gcc \
30 C/7zip/Common/FileStreams.cpp \
31 C/7zip/Common/FileStreams.h \
32 C/7zip/Common/InBuffer.cpp \
33 C/7zip/Common/InBuffer.h \
34 C/7zip/Common/OutBuffer.cpp \
35 C/7zip/Common/OutBuffer.h \
36 C/7zip/Common/StdAfx.h \
37 C/7zip/Common/StreamUtils.cpp \
38 C/7zip/Common/StreamUtils.h \
39 C/7zip/Compress/Branch/ARM.cpp \
40 C/7zip/Compress/Branch/ARM.h \
41 C/7zip/Compress/Branch/ARMThumb.cpp \
42 C/7zip/Compress/Branch/ARMThumb.h \
43 C/7zip/Compress/Branch/BranchARM.c \
44 C/7zip/Compress/Branch/BranchARM.h \
45 C/7zip/Compress/Branch/BranchARMThumb.c \
46 C/7zip/Compress/Branch/BranchARMThumb.h \
47 C/7zip/Compress/Branch/BranchCoder.cpp \
48 C/7zip/Compress/Branch/BranchCoder.h \
49 C/7zip/Compress/Branch/BranchIA64.c \
50 C/7zip/Compress/Branch/BranchIA64.h \
51 C/7zip/Compress/Branch/BranchPPC.c \
52 C/7zip/Compress/Branch/BranchPPC.h \
53 C/7zip/Compress/Branch/BranchSPARC.c \
54 C/7zip/Compress/Branch/BranchSPARC.h \
55 C/7zip/Compress/Branch/BranchTypes.h \
56 C/7zip/Compress/Branch/BranchX86.c \
57 C/7zip/Compress/Branch/BranchX86.h \
58 C/7zip/Compress/Branch/IA64.cpp \
59 C/7zip/Compress/Branch/IA64.h \
60 C/7zip/Compress/Branch/PPC.cpp \
61 C/7zip/Compress/Branch/PPC.h \
62 C/7zip/Compress/Branch/SPARC.cpp \
63 C/7zip/Compress/Branch/SPARC.h \
64 C/7zip/Compress/Branch/StdAfx.h \
65 C/7zip/Compress/Branch/x86.cpp \
66 C/7zip/Compress/Branch/x86.h \
67 C/7zip/Compress/Branch/x86_2.cpp \
68 C/7zip/Compress/Branch/x86_2.h \
69 C/7zip/Compress/LZ/BinTree/BinTree.h \
70 C/7zip/Compress/LZ/BinTree/BinTree2.h \
71 C/7zip/Compress/LZ/BinTree/BinTree3.h \
72 C/7zip/Compress/LZ/BinTree/BinTree3Z.h \
73 C/7zip/Compress/LZ/BinTree/BinTree4.h \
74 C/7zip/Compress/LZ/BinTree/BinTreeMain.h \
75 C/7zip/Compress/LZ/HashChain/HC2.h \
76 C/7zip/Compress/LZ/HashChain/HC3.h \
77 C/7zip/Compress/LZ/HashChain/HC4.h \
78 C/7zip/Compress/LZ/HashChain/HCMain.h \
79 C/7zip/Compress/LZ/IMatchFinder.h \
80 C/7zip/Compress/LZ/LZInWindow.cpp \
81 C/7zip/Compress/LZ/LZInWindow.h \
82 C/7zip/Compress/LZ/LZOutWindow.cpp \
83 C/7zip/Compress/LZ/LZOutWindow.h \
84 C/7zip/Compress/LZ/StdAfx.h \
85 C/7zip/Compress/LZMA/LZMA.h \
86 C/7zip/Compress/LZMA/LZMADecoder.cpp \
87 C/7zip/Compress/LZMA/LZMADecoder.h \
88 C/7zip/Compress/LZMA/LZMAEncoder.cpp \
89 C/7zip/Compress/LZMA/LZMAEncoder.h \
90 C/7zip/Compress/LZMA/StdAfx.h \
91 C/7zip/Compress/LZMA_Alone/AloneLZMA.dsp \
92 C/7zip/Compress/LZMA_Alone/AloneLZMA.dsw \
93 C/7zip/Compress/LZMA_Alone/LzmaAlone.cpp \
94 C/7zip/Compress/LZMA_Alone/LzmaBench.cpp \
95 C/7zip/Compress/LZMA_Alone/LzmaBench.h \
96 C/7zip/Compress/LZMA_Alone/LzmaRam.cpp \
97 C/7zip/Compress/LZMA_Alone/LzmaRam.h \
98 C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c \
99 C/7zip/Compress/LZMA_Alone/LzmaRamDecode.h \
100 C/7zip/Compress/LZMA_Alone/StdAfx.cpp \
101 C/7zip/Compress/LZMA_Alone/StdAfx.h \
102 C/7zip/Compress/LZMA_Alone/makefile \
103 C/7zip/Compress/LZMA_Alone/makefile.gcc \
104 C/7zip/Compress/LZMA_C/LzmaDecode.c \
105 C/7zip/Compress/LZMA_C/LzmaDecode.h \
106 C/7zip/Compress/LZMA_C/LzmaDecodeSize.c \
107 C/7zip/Compress/LZMA_C/LzmaStateDecode.c \
108 C/7zip/Compress/LZMA_C/LzmaStateDecode.h \
109 C/7zip/Compress/LZMA_C/LzmaStateTest.c \
110 C/7zip/Compress/LZMA_C/LzmaTest.c \
111 C/7zip/Compress/LZMA_C/LzmaTypes.h \
112 C/7zip/Compress/LZMA_C/makefile \
113 C/7zip/Compress/LZMA_C/makefile.gcc \
114 C/7zip/Compress/RangeCoder/RangeCoder.h \
115 C/7zip/Compress/RangeCoder/RangeCoderBit.cpp \
116 C/7zip/Compress/RangeCoder/RangeCoderBit.h \
117 C/7zip/Compress/RangeCoder/RangeCoderBitTree.h \
118 C/7zip/Compress/RangeCoder/RangeCoderOpt.h \
119 C/7zip/Compress/RangeCoder/StdAfx.h \
120 C/7zip/ICoder.h \
121 C/7zip/IStream.h \
122 C/Common/Alloc.cpp \
123 C/Common/Alloc.h \
124 C/Common/CRC.cpp \
125 C/Common/CRC.h \
126 C/Common/C_FileIO.cpp \
127 C/Common/C_FileIO.h \
128 C/Common/ComTry.h \
129 C/Common/CommandLineParser.cpp \
130 C/Common/CommandLineParser.h \
131 C/Common/Defs.h \
132 C/Common/MyCom.h \
133 C/Common/MyGuidDef.h \
134 C/Common/MyInitGuid.h \
135 C/Common/MyUnknown.h \
136 C/Common/MyWindows.h \
137 C/Common/NewHandler.cpp \
138 C/Common/NewHandler.h \
139 C/Common/StdAfx.h \
140 C/Common/String.cpp \
141 C/Common/String.h \
142 C/Common/StringConvert.cpp \
143 C/Common/StringConvert.h \
144 C/Common/StringToInt.cpp \
145 C/Common/StringToInt.h \
146 C/Common/Types.h \
147 C/Common/Vector.cpp \
148 C/Common/Vector.h \
149 C/Windows/Defs.h \
150 C/Windows/FileIO.cpp \
151 C/Windows/FileIO.h \
152 C/Windows/StdAfx.h \
153 LGPL.txt \
154 Methods.txt \
155 history.txt \
156 lzma.txt
0 # Makefile.in generated by automake 1.10 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 # We don't actually build LZMA; we just
17 # want to bring along the source code to satisfy LGPL requirements.
18 VPATH = @srcdir@
19 pkgdatadir = $(datadir)/@PACKAGE@
20 pkglibdir = $(libdir)/@PACKAGE@
21 pkgincludedir = $(includedir)/@PACKAGE@
22 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
23 install_sh_DATA = $(install_sh) -c -m 644
24 install_sh_PROGRAM = $(install_sh) -c
25 install_sh_SCRIPT = $(install_sh) -c
26 INSTALL_HEADER = $(INSTALL_DATA)
27 transform = $(program_transform_name)
28 NORMAL_INSTALL = :
29 PRE_INSTALL = :
30 POST_INSTALL = :
31 NORMAL_UNINSTALL = :
32 PRE_UNINSTALL = :
33 POST_UNINSTALL = :
34 build_triplet = @build@
35 host_triplet = @host@
36 subdir = lzma443
37 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
38 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
39 am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
40 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
41 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
42 $(ACLOCAL_M4)
43 mkinstalldirs = $(install_sh) -d
44 CONFIG_HEADER = $(top_builddir)/affconfig.h
45 CONFIG_CLEAN_FILES =
46 SOURCES =
47 DIST_SOURCES =
48 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
49 ACLOCAL = @ACLOCAL@
50 AFFUSE_BIN = @AFFUSE_BIN@
51 ALLOCA = @ALLOCA@
52 AMTAR = @AMTAR@
53 AR = @AR@
54 AUTOCONF = @AUTOCONF@
55 AUTOHEADER = @AUTOHEADER@
56 AUTOMAKE = @AUTOMAKE@
57 AWK = @AWK@
58 CC = @CC@
59 CCDEPMODE = @CCDEPMODE@
60 CFLAGS = @CFLAGS@
61 CPP = @CPP@
62 CPPFLAGS = @CPPFLAGS@
63 CURL_CONFIG = @CURL_CONFIG@
64 CXX = @CXX@
65 CXXCPP = @CXXCPP@
66 CXXDEPMODE = @CXXDEPMODE@
67 CXXFLAGS = @CXXFLAGS@
68 CYGPATH_W = @CYGPATH_W@
69 DEFS = @DEFS@
70 DEPDIR = @DEPDIR@
71 DSYMUTIL = @DSYMUTIL@
72 DUMPBIN = @DUMPBIN@
73 ECHO_C = @ECHO_C@
74 ECHO_N = @ECHO_N@
75 ECHO_T = @ECHO_T@
76 EGREP = @EGREP@
77 EXEEXT = @EXEEXT@
78 FGREP = @FGREP@
79 FUSE_CFLAGS = @FUSE_CFLAGS@
80 FUSE_LIBS = @FUSE_LIBS@
81 GREP = @GREP@
82 INSTALL = @INSTALL@
83 INSTALL_DATA = @INSTALL_DATA@
84 INSTALL_PROGRAM = @INSTALL_PROGRAM@
85 INSTALL_SCRIPT = @INSTALL_SCRIPT@
86 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
87 LD = @LD@
88 LDFLAGS = @LDFLAGS@
89 LIBOBJS = @LIBOBJS@
90 LIBS = @LIBS@
91 LIBTOOL = @LIBTOOL@
92 LIPO = @LIPO@
93 LN_S = @LN_S@
94 LTLIBOBJS = @LTLIBOBJS@
95 MAINT = @MAINT@
96 MAKEINFO = @MAKEINFO@
97 MKDIR_P = @MKDIR_P@
98 NM = @NM@
99 NMEDIT = @NMEDIT@
100 OBJEXT = @OBJEXT@
101 OTOOL = @OTOOL@
102 OTOOL64 = @OTOOL64@
103 PACKAGE = @PACKAGE@
104 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
105 PACKAGE_NAME = @PACKAGE_NAME@
106 PACKAGE_STRING = @PACKAGE_STRING@
107 PACKAGE_TARNAME = @PACKAGE_TARNAME@
108 PACKAGE_VERSION = @PACKAGE_VERSION@
109 PATH_SEPARATOR = @PATH_SEPARATOR@
110 PTHREAD_CC = @PTHREAD_CC@
111 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
112 PTHREAD_LIBS = @PTHREAD_LIBS@
113 PYTHON = @PYTHON@
114 PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
115 PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
116 PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
117 PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
118 PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
119 PYTHON_PLATFORM = @PYTHON_PLATFORM@
120 PYTHON_PREFIX = @PYTHON_PREFIX@
121 PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
122 PYTHON_VERSION = @PYTHON_VERSION@
123 RANLIB = @RANLIB@
124 S3_BIN = @S3_BIN@
125 SED = @SED@
126 SET_MAKE = @SET_MAKE@
127 SHELL = @SHELL@
128 STRIP = @STRIP@
129 VERSION = @VERSION@
130 abs_builddir = @abs_builddir@
131 abs_srcdir = @abs_srcdir@
132 abs_top_builddir = @abs_top_builddir@
133 abs_top_srcdir = @abs_top_srcdir@
134 ac_ct_CC = @ac_ct_CC@
135 ac_ct_CXX = @ac_ct_CXX@
136 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
137 ac_prefix_program = @ac_prefix_program@
138 acx_pthread_config = @acx_pthread_config@
139 am__include = @am__include@
140 am__leading_dot = @am__leading_dot@
141 am__quote = @am__quote@
142 am__tar = @am__tar@
143 am__untar = @am__untar@
144 bindir = @bindir@
145 build = @build@
146 build_alias = @build_alias@
147 build_cpu = @build_cpu@
148 build_os = @build_os@
149 build_vendor = @build_vendor@
150 builddir = @builddir@
151 datadir = @datadir@
152 datarootdir = @datarootdir@
153 docdir = @docdir@
154 dvidir = @dvidir@
155 exec_prefix = @exec_prefix@
156 host = @host@
157 host_alias = @host_alias@
158 host_cpu = @host_cpu@
159 host_os = @host_os@
160 host_vendor = @host_vendor@
161 htmldir = @htmldir@
162 includedir = @includedir@
163 infodir = @infodir@
164 install_sh = @install_sh@
165 libdir = @libdir@
166 libexecdir = @libexecdir@
167 localedir = @localedir@
168 localstatedir = @localstatedir@
169 lt_ECHO = @lt_ECHO@
170 mandir = @mandir@
171 mkdir_p = @mkdir_p@
172 oldincludedir = @oldincludedir@
173 pdfdir = @pdfdir@
174 pkgpyexecdir = @pkgpyexecdir@
175 pkgpythondir = @pkgpythondir@
176 prefix = @prefix@
177 program_transform_name = @program_transform_name@
178 psdir = @psdir@
179 pyexecdir = @pyexecdir@
180 pythondir = @pythondir@
181 sbindir = @sbindir@
182 sharedstatedir = @sharedstatedir@
183 srcdir = @srcdir@
184 sysconfdir = @sysconfdir@
185 target_alias = @target_alias@
186 top_builddir = @top_builddir@
187 top_srcdir = @top_srcdir@
188 EXTRA_DIST = \
189 7zC.txt \
190 7zFormat.txt \
191 C/7zip/Archive/7z_C/7zAlloc.c \
192 C/7zip/Archive/7z_C/7zAlloc.h \
193 C/7zip/Archive/7z_C/7zBuffer.c \
194 C/7zip/Archive/7z_C/7zBuffer.h \
195 C/7zip/Archive/7z_C/7zCrc.c \
196 C/7zip/Archive/7z_C/7zCrc.h \
197 C/7zip/Archive/7z_C/7zDecode.c \
198 C/7zip/Archive/7z_C/7zDecode.h \
199 C/7zip/Archive/7z_C/7zExtract.c \
200 C/7zip/Archive/7z_C/7zExtract.h \
201 C/7zip/Archive/7z_C/7zHeader.c \
202 C/7zip/Archive/7z_C/7zHeader.h \
203 C/7zip/Archive/7z_C/7zIn.c \
204 C/7zip/Archive/7z_C/7zIn.h \
205 C/7zip/Archive/7z_C/7zItem.c \
206 C/7zip/Archive/7z_C/7zItem.h \
207 C/7zip/Archive/7z_C/7zMain.c \
208 C/7zip/Archive/7z_C/7zMethodID.c \
209 C/7zip/Archive/7z_C/7zMethodID.h \
210 C/7zip/Archive/7z_C/7zTypes.h \
211 C/7zip/Archive/7z_C/7z_C.dsp \
212 C/7zip/Archive/7z_C/7z_C.dsw \
213 C/7zip/Archive/7z_C/makefile \
214 C/7zip/Archive/7z_C/makefile.gcc \
215 C/7zip/Common/FileStreams.cpp \
216 C/7zip/Common/FileStreams.h \
217 C/7zip/Common/InBuffer.cpp \
218 C/7zip/Common/InBuffer.h \
219 C/7zip/Common/OutBuffer.cpp \
220 C/7zip/Common/OutBuffer.h \
221 C/7zip/Common/StdAfx.h \
222 C/7zip/Common/StreamUtils.cpp \
223 C/7zip/Common/StreamUtils.h \
224 C/7zip/Compress/Branch/ARM.cpp \
225 C/7zip/Compress/Branch/ARM.h \
226 C/7zip/Compress/Branch/ARMThumb.cpp \
227 C/7zip/Compress/Branch/ARMThumb.h \
228 C/7zip/Compress/Branch/BranchARM.c \
229 C/7zip/Compress/Branch/BranchARM.h \
230 C/7zip/Compress/Branch/BranchARMThumb.c \
231 C/7zip/Compress/Branch/BranchARMThumb.h \
232 C/7zip/Compress/Branch/BranchCoder.cpp \
233 C/7zip/Compress/Branch/BranchCoder.h \
234 C/7zip/Compress/Branch/BranchIA64.c \
235 C/7zip/Compress/Branch/BranchIA64.h \
236 C/7zip/Compress/Branch/BranchPPC.c \
237 C/7zip/Compress/Branch/BranchPPC.h \
238 C/7zip/Compress/Branch/BranchSPARC.c \
239 C/7zip/Compress/Branch/BranchSPARC.h \
240 C/7zip/Compress/Branch/BranchTypes.h \
241 C/7zip/Compress/Branch/BranchX86.c \
242 C/7zip/Compress/Branch/BranchX86.h \
243 C/7zip/Compress/Branch/IA64.cpp \
244 C/7zip/Compress/Branch/IA64.h \
245 C/7zip/Compress/Branch/PPC.cpp \
246 C/7zip/Compress/Branch/PPC.h \
247 C/7zip/Compress/Branch/SPARC.cpp \
248 C/7zip/Compress/Branch/SPARC.h \
249 C/7zip/Compress/Branch/StdAfx.h \
250 C/7zip/Compress/Branch/x86.cpp \
251 C/7zip/Compress/Branch/x86.h \
252 C/7zip/Compress/Branch/x86_2.cpp \
253 C/7zip/Compress/Branch/x86_2.h \
254 C/7zip/Compress/LZ/BinTree/BinTree.h \
255 C/7zip/Compress/LZ/BinTree/BinTree2.h \
256 C/7zip/Compress/LZ/BinTree/BinTree3.h \
257 C/7zip/Compress/LZ/BinTree/BinTree3Z.h \
258 C/7zip/Compress/LZ/BinTree/BinTree4.h \
259 C/7zip/Compress/LZ/BinTree/BinTreeMain.h \
260 C/7zip/Compress/LZ/HashChain/HC2.h \
261 C/7zip/Compress/LZ/HashChain/HC3.h \
262 C/7zip/Compress/LZ/HashChain/HC4.h \
263 C/7zip/Compress/LZ/HashChain/HCMain.h \
264 C/7zip/Compress/LZ/IMatchFinder.h \
265 C/7zip/Compress/LZ/LZInWindow.cpp \
266 C/7zip/Compress/LZ/LZInWindow.h \
267 C/7zip/Compress/LZ/LZOutWindow.cpp \
268 C/7zip/Compress/LZ/LZOutWindow.h \
269 C/7zip/Compress/LZ/StdAfx.h \
270 C/7zip/Compress/LZMA/LZMA.h \
271 C/7zip/Compress/LZMA/LZMADecoder.cpp \
272 C/7zip/Compress/LZMA/LZMADecoder.h \
273 C/7zip/Compress/LZMA/LZMAEncoder.cpp \
274 C/7zip/Compress/LZMA/LZMAEncoder.h \
275 C/7zip/Compress/LZMA/StdAfx.h \
276 C/7zip/Compress/LZMA_Alone/AloneLZMA.dsp \
277 C/7zip/Compress/LZMA_Alone/AloneLZMA.dsw \
278 C/7zip/Compress/LZMA_Alone/LzmaAlone.cpp \
279 C/7zip/Compress/LZMA_Alone/LzmaBench.cpp \
280 C/7zip/Compress/LZMA_Alone/LzmaBench.h \
281 C/7zip/Compress/LZMA_Alone/LzmaRam.cpp \
282 C/7zip/Compress/LZMA_Alone/LzmaRam.h \
283 C/7zip/Compress/LZMA_Alone/LzmaRamDecode.c \
284 C/7zip/Compress/LZMA_Alone/LzmaRamDecode.h \
285 C/7zip/Compress/LZMA_Alone/StdAfx.cpp \
286 C/7zip/Compress/LZMA_Alone/StdAfx.h \
287 C/7zip/Compress/LZMA_Alone/makefile \
288 C/7zip/Compress/LZMA_Alone/makefile.gcc \
289 C/7zip/Compress/LZMA_C/LzmaDecode.c \
290 C/7zip/Compress/LZMA_C/LzmaDecode.h \
291 C/7zip/Compress/LZMA_C/LzmaDecodeSize.c \
292 C/7zip/Compress/LZMA_C/LzmaStateDecode.c \
293 C/7zip/Compress/LZMA_C/LzmaStateDecode.h \
294 C/7zip/Compress/LZMA_C/LzmaStateTest.c \
295 C/7zip/Compress/LZMA_C/LzmaTest.c \
296 C/7zip/Compress/LZMA_C/LzmaTypes.h \
297 C/7zip/Compress/LZMA_C/makefile \
298 C/7zip/Compress/LZMA_C/makefile.gcc \
299 C/7zip/Compress/RangeCoder/RangeCoder.h \
300 C/7zip/Compress/RangeCoder/RangeCoderBit.cpp \
301 C/7zip/Compress/RangeCoder/RangeCoderBit.h \
302 C/7zip/Compress/RangeCoder/RangeCoderBitTree.h \
303 C/7zip/Compress/RangeCoder/RangeCoderOpt.h \
304 C/7zip/Compress/RangeCoder/StdAfx.h \
305 C/7zip/ICoder.h \
306 C/7zip/IStream.h \
307 C/Common/Alloc.cpp \
308 C/Common/Alloc.h \
309 C/Common/CRC.cpp \
310 C/Common/CRC.h \
311 C/Common/C_FileIO.cpp \
312 C/Common/C_FileIO.h \
313 C/Common/ComTry.h \
314 C/Common/CommandLineParser.cpp \
315 C/Common/CommandLineParser.h \
316 C/Common/Defs.h \
317 C/Common/MyCom.h \
318 C/Common/MyGuidDef.h \
319 C/Common/MyInitGuid.h \
320 C/Common/MyUnknown.h \
321 C/Common/MyWindows.h \
322 C/Common/NewHandler.cpp \
323 C/Common/NewHandler.h \
324 C/Common/StdAfx.h \
325 C/Common/String.cpp \
326 C/Common/String.h \
327 C/Common/StringConvert.cpp \
328 C/Common/StringConvert.h \
329 C/Common/StringToInt.cpp \
330 C/Common/StringToInt.h \
331 C/Common/Types.h \
332 C/Common/Vector.cpp \
333 C/Common/Vector.h \
334 C/Windows/Defs.h \
335 C/Windows/FileIO.cpp \
336 C/Windows/FileIO.h \
337 C/Windows/StdAfx.h \
338 LGPL.txt \
339 Methods.txt \
340 history.txt \
341 lzma.txt
342
343 all: all-am
344
345 .SUFFIXES:
346 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
347 @for dep in $?; do \
348 case '$(am__configure_deps)' in \
349 *$$dep*) \
350 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
351 && exit 0; \
352 exit 1;; \
353 esac; \
354 done; \
355 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lzma443/Makefile'; \
356 cd $(top_srcdir) && \
357 $(AUTOMAKE) --gnu lzma443/Makefile
358 .PRECIOUS: Makefile
359 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
360 @case '$?' in \
361 *config.status*) \
362 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
363 *) \
364 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
365 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
366 esac;
367
368 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
369 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
370
371 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
372 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
373 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
374 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
375
376 mostlyclean-libtool:
377 -rm -f *.lo
378
379 clean-libtool:
380 -rm -rf .libs _libs
381 tags: TAGS
382 TAGS:
383
384 ctags: CTAGS
385 CTAGS:
386
387
388 distdir: $(DISTFILES)
389 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
390 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
391 list='$(DISTFILES)'; \
392 dist_files=`for file in $$list; do echo $$file; done | \
393 sed -e "s|^$$srcdirstrip/||;t" \
394 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
395 case $$dist_files in \
396 */*) $(MKDIR_P) `echo "$$dist_files" | \
397 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
398 sort -u` ;; \
399 esac; \
400 for file in $$dist_files; do \
401 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
402 if test -d $$d/$$file; then \
403 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
404 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
405 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
406 fi; \
407 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
408 else \
409 test -f $(distdir)/$$file \
410 || cp -p $$d/$$file $(distdir)/$$file \
411 || exit 1; \
412 fi; \
413 done
414 check-am: all-am
415 check: check-am
416 all-am: Makefile
417 installdirs:
418 install: install-am
419 install-exec: install-exec-am
420 install-data: install-data-am
421 uninstall: uninstall-am
422
423 install-am: all-am
424 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
425
426 installcheck: installcheck-am
427 install-strip:
428 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
429 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
430 `test -z '$(STRIP)' || \
431 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
432 mostlyclean-generic:
433
434 clean-generic:
435
436 distclean-generic:
437 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
438
439 maintainer-clean-generic:
440 @echo "This command is intended for maintainers to use"
441 @echo "it deletes files that may require special tools to rebuild."
442 clean: clean-am
443
444 clean-am: clean-generic clean-libtool mostlyclean-am
445
446 distclean: distclean-am
447 -rm -f Makefile
448 distclean-am: clean-am distclean-generic
449
450 dvi: dvi-am
451
452 dvi-am:
453
454 html: html-am
455
456 info: info-am
457
458 info-am:
459
460 install-data-am:
461
462 install-dvi: install-dvi-am
463
464 install-exec-am:
465
466 install-html: install-html-am
467
468 install-info: install-info-am
469
470 install-man:
471
472 install-pdf: install-pdf-am
473
474 install-ps: install-ps-am
475
476 installcheck-am:
477
478 maintainer-clean: maintainer-clean-am
479 -rm -f Makefile
480 maintainer-clean-am: distclean-am maintainer-clean-generic
481
482 mostlyclean: mostlyclean-am
483
484 mostlyclean-am: mostlyclean-generic mostlyclean-libtool
485
486 pdf: pdf-am
487
488 pdf-am:
489
490 ps: ps-am
491
492 ps-am:
493
494 uninstall-am:
495
496 .MAKE: install-am install-strip
497
498 .PHONY: all all-am check check-am clean clean-generic clean-libtool \
499 distclean distclean-generic distclean-libtool distdir dvi \
500 dvi-am html html-am info info-am install install-am \
501 install-data install-data-am install-dvi install-dvi-am \
502 install-exec install-exec-am install-html install-html-am \
503 install-info install-info-am install-man install-pdf \
504 install-pdf-am install-ps install-ps-am install-strip \
505 installcheck installcheck-am installdirs maintainer-clean \
506 maintainer-clean-generic mostlyclean mostlyclean-generic \
507 mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am
508
509 # Tell versions [3.59,3.63) of GNU make to not export all variables.
510 # Otherwise a system limit (for SysV at least) may be exceeded.
511 .NOEXPORT:
0 Compression method IDs (4.38)
1 -----------------------------
2
3 Each compression method in 7z has unique binary value (ID).
4 The length of ID in bytes is arbitrary but it can not exceed 15 bytes.
5
6 If you want to add some new ID, you have two ways:
7 1) Write request for allocating IDs to 7-zip developers.
8 2) Use such random ID:
9 03 E0 ZZ ... ZZ MM ... MM VV ... VV
10
11 ZZ != 0, MM != 0, VV != 0
12
13 03 E0 - Prefix for random IDs
14 ZZ ... ZZ - Developer ID. (length >= 4). Use real random bytes.
15 You can notify 7-Zip developers about your Developer ID.
16 MM ... MM - Method ID (length >= 1)
17 VV ... VV - Version (length >= 1)
18
19 Note: Use new ID (MM ... MM VV .. VV) only if old codec can not decode
20 data encoded with new version.
21
22
23 List of defined IDs
24 -------------------
25
26 00 - Copy
27 01 - Reserved
28 02 - Common
29 03 Swap
30 - 2 Swap2
31 - 4 Swap4
32 04 Delta (subject to change)
33
34 03 - 7z
35 01 - LZMA
36 01 - Version
37
38 03 - Branch
39 01 - x86
40 03 - BCJ
41 1B - BCJ2
42 02 - PPC
43 05 - BC_PPC_B (Big Endian)
44 03 - Alpha
45 01 - BC_Alpha
46 04 - IA64
47 01 - BC_IA64
48 05 - ARM
49 01 - BC_ARM
50 06 - M68
51 05 - BC_M68_B (Big Endian)
52 07 - ARM Thumb
53 01 - BC_ARMThumb
54 08 - SPARC
55 05 - BC_SPARC
56
57 04 - PPMD
58 01 - Version
59
60 80 - reserved for independent developers
61
62 E0 - Random IDs
63
64 04 - Misc
65 00 - Reserved
66 01 - Zip
67 00 - Copy (not used). Use {00} instead
68 01 - Shrink
69 06 - Implode
70 08 - Deflate
71 09 - Deflate64
72 12 - BZip2 (not used). Use {04 02 02} instead
73 02 - BZip
74 02 - BZip2
75 03 - Rar
76 01 - Rar15
77 02 - Rar20
78 03 - Rar29
79 04 - Arj
80 01 - Arj (1,2,3)
81 02 - Arj 4
82 05 - Z
83 06 - Lzh
84 07 - Reserved for 7z
85 08 - Cab
86 09 - NSIS
87 01 - DeflateNSIS
88 02 - BZip2NSIS
89
90
91 06 - Crypto
92 00 -
93 01 - AES
94 0x - AES-128
95 4x - AES-192
96 8x - AES-256
97
98 x0 - ECB
99 x1 - CBC
100 x2 - CFB
101 x3 - OFB
102
103 07 - Reserved
104 0F - Reserved
105
106 F0 - Misc Ciphers (Real Ciphers without hashing algo)
107
108 F1 - Misc Ciphers (Combine)
109 01 - Zip
110 01 - Main Zip crypto algo
111 03 - RAR
112 02 -
113 03 - Rar29 AES-128 + (modified SHA-1)
114 07 - 7z
115 01 - AES-256 + SHA-256
116
117 07 - Hash (subject to change)
118 00 -
119 01 - CRC
120 02 - SHA-1
121 03 - SHA-256
122 04 - SHA-384
123 05 - SHA-512
124
125 F0 - Misc Hash
126
127 F1 - Misc
128 03 - RAR
129 03 - Rar29 Password Hashing (modified SHA1)
130 07 - 7z
131 01 - SHA-256 Password Hashing
132
133
134
135
136 ---
137 End of document
0 HISTORY of the LZMA SDK
1 -----------------------
2
3 Version 4.43 2006-06-04
4 --------------------------------------
5 - Small changes for more compatibility with some C/C++ compilers.
6
7
8 Version 4.42 2006-05-15
9 --------------------------------------
10 - Small changes in .h files in ANSI-C version.
11
12
13 Version 4.39 beta 2006-04-14
14 --------------------------------------
15 - Bug in versions 4.33b:4.38b was fixed:
16 C++ version of LZMA encoder could not correctly compress
17 files larger than 2 GB with HC4 match finder (-mfhc4).
18
19
20 Version 4.37 beta 2005-04-06
21 --------------------------------------
22 - Fixes in C++ code: code could no be compiled if _NO_EXCEPTIONS was defined.
23
24
25 Version 4.35 beta 2005-03-02
26 --------------------------------------
27 - Bug was fixed in C++ version of LZMA Decoder:
28 If encoded stream was corrupted, decoder could access memory
29 outside of allocated range.
30
31
32 Version 4.34 beta 2006-02-27
33 --------------------------------------
34 - Compressing speed and memory requirements for compressing were increased
35 - LZMA now can use only these match finders: HC4, BT2, BT3, BT4
36
37
38 Version 4.32 2005-12-09
39 --------------------------------------
40 - Java version of LZMA SDK was included
41
42
43 Version 4.30 2005-11-20
44 --------------------------------------
45 - Compression ratio was improved in -a2 mode
46 - Speed optimizations for compressing in -a2 mode
47 - -fb switch now supports values up to 273
48 - Bug in 7z_C (7zIn.c) was fixed:
49 It used Alloc/Free functions from different memory pools.
50 So if program used two memory pools, it worked incorrectly.
51 - 7z_C: .7z format supporting was improved
52 - LZMA# SDK (C#.NET version) was included
53
54
55 Version 4.27 (Updated) 2005-09-21
56 --------------------------------------
57 - Some GUIDs/interfaces in C++ were changed.
58 IStream.h:
59 ISequentialInStream::Read now works as old ReadPart
60 ISequentialOutStream::Write now works as old WritePart
61
62
63 Version 4.27 2005-08-07
64 --------------------------------------
65 - Bug in LzmaDecodeSize.c was fixed:
66 if _LZMA_IN_CB and _LZMA_OUT_READ were defined,
67 decompressing worked incorrectly.
68
69
70 Version 4.26 2005-08-05
71 --------------------------------------
72 - Fixes in 7z_C code and LzmaTest.c:
73 previous versions could work incorrectly,
74 if malloc(0) returns 0
75
76
77 Version 4.23 2005-06-29
78 --------------------------------------
79 - Small fixes in C++ code
80
81
82 Version 4.22 2005-06-10
83 --------------------------------------
84 - Small fixes
85
86
87 Version 4.21 2005-06-08
88 --------------------------------------
89 - Interfaces for ANSI-C LZMA Decoder (LzmaDecode.c) were changed
90 - New additional version of ANSI-C LZMA Decoder with zlib-like interface:
91 - LzmaStateDecode.h
92 - LzmaStateDecode.c
93 - LzmaStateTest.c
94 - ANSI-C LZMA Decoder now can decompress files larger than 4 GB
95
96
97 Version 4.17 2005-04-18
98 --------------------------------------
99 - New example for RAM->RAM compressing/decompressing:
100 LZMA + BCJ (filter for x86 code):
101 - LzmaRam.h
102 - LzmaRam.cpp
103 - LzmaRamDecode.h
104 - LzmaRamDecode.c
105 - -f86 switch for lzma.exe
106
107
108 Version 4.16 2005-03-29
109 --------------------------------------
110 - Bug was fixed in LzmaDecode.c (ANSI-C LZMA Decoder):
111 If _LZMA_OUT_READ was defined, and if encoded stream was corrupted,
112 decoder could access memory outside of allocated range.
113 - Speed optimization of ANSI-C LZMA Decoder (now it's about 20% faster).
114 Old version of LZMA Decoder now is in file LzmaDecodeSize.c.
115 LzmaDecodeSize.c can provide slightly smaller code than LzmaDecode.c
116 - Small speed optimization in LZMA C++ code
117 - filter for SPARC's code was added
118 - Simplified version of .7z ANSI-C Decoder was included
119
120
121 Version 4.06 2004-09-05
122 --------------------------------------
123 - Bug in v4.05 was fixed:
124 LZMA-Encoder didn't release output stream in some cases.
125
126
127 Version 4.05 2004-08-25
128 --------------------------------------
129 - Source code of filters for x86, IA-64, ARM, ARM-Thumb
130 and PowerPC code was included to SDK
131 - Some internal minor changes
132
133
134 Version 4.04 2004-07-28
135 --------------------------------------
136 - More compatibility with some C++ compilers
137
138
139 Version 4.03 2004-06-18
140 --------------------------------------
141 - "Benchmark" command was added. It measures compressing
142 and decompressing speed and shows rating values.
143 Also it checks hardware errors.
144
145
146 Version 4.02 2004-06-10
147 --------------------------------------
148 - C++ LZMA Encoder/Decoder code now is more portable
149 and it can be compiled by GCC on Linux.
150
151
152 Version 4.01 2004-02-15
153 --------------------------------------
154 - Some detection of data corruption was enabled.
155 LzmaDecode.c / RangeDecoderReadByte
156 .....
157 {
158 rd->ExtraBytes = 1;
159 return 0xFF;
160 }
161
162
163 Version 4.00 2004-02-13
164 --------------------------------------
165 - Original version of LZMA SDK
166
167
168
169 HISTORY of the LZMA
170 -------------------
171 2001-2006: Improvements to LZMA compressing/decompressing code,
172 keeping compatibility with original LZMA format
173 1996-2001: Development of LZMA compression format
174
175 Some milestones:
176
177 2001-08-30: LZMA compression was added to 7-Zip
178 1999-01-02: First version of 7-Zip was released
179
180
181 End of document
0 LZMA SDK 4.43
1 -------------
2
3 LZMA SDK Copyright (C) 1999-2006 Igor Pavlov
4
5 LZMA SDK provides the documentation, samples, header files, libraries,
6 and tools you need to develop applications that use LZMA compression.
7
8 LZMA is default and general compression method of 7z format
9 in 7-Zip compression program (www.7-zip.org). LZMA provides high
10 compression ratio and very fast decompression.
11
12 LZMA is an improved version of famous LZ77 compression algorithm.
13 It was improved in way of maximum increasing of compression ratio,
14 keeping high decompression speed and low memory requirements for
15 decompressing.
16
17
18
19 LICENSE
20 -------
21
22 LZMA SDK is available under any of the following licenses:
23
24 1) GNU Lesser General Public License (GNU LGPL)
25 2) Common Public License (CPL)
26 3) Simplified license for unmodified code (read SPECIAL EXCEPTION)
27 4) Proprietary license
28
29 It means that you can select one of these four options and follow rules of that license.
30
31
32 1,2) GNU LGPL and CPL licenses are pretty similar and both these
33 licenses are classified as
34 - "Free software licenses" at http://www.gnu.org/
35 - "OSI-approved" at http://www.opensource.org/
36
37
38 3) SPECIAL EXCEPTION
39
40 Igor Pavlov, as the author of this code, expressly permits you
41 to statically or dynamically link your code (or bind by name)
42 to the files from LZMA SDK without subjecting your linked
43 code to the terms of the CPL or GNU LGPL.
44 Any modifications or additions to files from LZMA SDK, however,
45 are subject to the GNU LGPL or CPL terms.
46
47 SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code,
48 while you keep LZMA SDK code unmodified.
49
50
51 SPECIAL EXCEPTION #2: Igor Pavlov, as the author of this code, expressly permits
52 you to use this code under the same terms and conditions contained in the License
53 Agreement you have for any previous version of LZMA SDK developed by Igor Pavlov.
54
55 SPECIAL EXCEPTION #2 allows owners of proprietary licenses to use latest version
56 of LZMA SDK as update for previous versions.
57
58
59 SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits
60 you to use code of the following files:
61 BranchTypes.h, LzmaTypes.h, LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp,
62 LzmaAlone.cs, LzmaAlone.java
63 as public domain code.
64
65
66 4) Proprietary license
67
68 LZMA SDK also can be available under a proprietary license which
69 can include:
70
71 1) Right to modify code without subjecting modified code to the
72 terms of the CPL or GNU LGPL
73 2) Technical support for code
74
75 To request such proprietary license or any additional consultations,
76 send email message from that page:
77 http://www.7-zip.org/support.html
78
79
80 You should have received a copy of the GNU Lesser General Public
81 License along with this library; if not, write to the Free Software
82 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
83
84 You should have received a copy of the Common Public License
85 along with this library.
86
87
88 LZMA SDK Contents
89 -----------------
90
91 LZMA SDK includes:
92
93 - C++ source code of LZMA compressing and decompressing
94 - ANSI-C compatible source code for LZMA decompressing
95 - C# source code for LZMA compressing and decompressing
96 - Java source code for LZMA compressing and decompressing
97 - Compiled file->file LZMA compressing/decompressing program for Windows system
98
99 ANSI-C LZMA decompression code was ported from original C++ sources to C.
100 Also it was simplified and optimized for code size.
101 But it is fully compatible with LZMA from 7-Zip.
102
103
104 UNIX/Linux version
105 ------------------
106 To compile C++ version of file->file LZMA, go to directory
107 C/7zip/Compress/LZMA_Alone
108 and type "make" or "make clean all" to recompile all.
109
110 In some UNIX/Linux versions you must compile LZMA with static libraries.
111 To compile with static libraries, change string in makefile
112 LIB = -lm
113 to string
114 LIB = -lm -static
115
116
117 Files
118 ---------------------
119 C - C / CPP source code
120 CS - C# source code
121 Java - Java source code
122 lzma.txt - LZMA SDK description (this file)
123 7zFormat.txt - 7z Format description
124 7zC.txt - 7z ANSI-C Decoder description (this file)
125 methods.txt - Compression method IDs for .7z
126 LGPL.txt - GNU Lesser General Public License
127 CPL.html - Common Public License
128 lzma.exe - Compiled file->file LZMA encoder/decoder for Windows
129 history.txt - history of the LZMA SDK
130
131
132 Source code structure
133 ---------------------
134
135 C - C / CPP files
136 Common - common files for C++ projects
137 Windows - common files for Windows related code
138 7zip - files related to 7-Zip Project
139 Common - common files for 7-Zip
140 Compress - files related to compression/decompression
141 LZ - files related to LZ (Lempel-Ziv) compression algorithm
142 BinTree - Binary Tree Match Finder for LZ algorithm
143 HashChain - Hash Chain Match Finder for LZ algorithm
144 Patricia - Patricia Match Finder for LZ algorithm
145 RangeCoder - Range Coder (special code of compression/decompression)
146 LZMA - LZMA compression/decompression on C++
147 LZMA_Alone - file->file LZMA compression/decompression
148 LZMA_C - ANSI-C compatible LZMA decompressor
149 LzmaDecode.h - interface for LZMA decoding on ANSI-C
150 LzmaDecode.c - LZMA decoding on ANSI-C (new fastest version)
151 LzmaDecodeSize.c - LZMA decoding on ANSI-C (old size-optimized version)
152 LzmaTest.c - test application that decodes LZMA encoded file
153 LzmaTypes.h - basic types for LZMA Decoder
154 LzmaStateDecode.h - interface for LZMA decoding (State version)
155 LzmaStateDecode.c - LZMA decoding on ANSI-C (State version)
156 LzmaStateTest.c - test application (State version)
157 Branch - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
158 Archive - files related to archiving
159 7z_C - 7z ANSI-C Decoder
160
161 CS - C# files
162 7zip
163 Common - some common files for 7-Zip
164 Compress - files related to compression/decompression
165 LZ - files related to LZ (Lempel-Ziv) compression algorithm
166 LZMA - LZMA compression/decompression
167 LzmaAlone - file->file LZMA compression/decompression
168 RangeCoder - Range Coder (special code of compression/decompression)
169
170 Java - Java files
171 SevenZip
172 Compression - files related to compression/decompression
173 LZ - files related to LZ (Lempel-Ziv) compression algorithm
174 LZMA - LZMA compression/decompression
175 RangeCoder - Range Coder (special code of compression/decompression)
176
177 C/C++ source code of LZMA SDK is part of 7-Zip project.
178
179 You can find ANSI-C LZMA decompressing code at folder
180 C/7zip/Compress/LZMA_C
181 7-Zip doesn't use that ANSI-C LZMA code and that code was developed
182 specially for this SDK. And files from LZMA_C do not need files from
183 other directories of SDK for compiling.
184
185 7-Zip source code can be downloaded from 7-Zip's SourceForge page:
186
187 http://sourceforge.net/projects/sevenzip/
188
189
190 LZMA features
191 -------------
192 - Variable dictionary size (up to 1 GB)
193 - Estimated compressing speed: about 1 MB/s on 1 GHz CPU
194 - Estimated decompressing speed:
195 - 8-12 MB/s on 1 GHz Intel Pentium 3 or AMD Athlon
196 - 500-1000 KB/s on 100 MHz ARM, MIPS, PowerPC or other simple RISC
197 - Small memory requirements for decompressing (8-32 KB + DictionarySize)
198 - Small code size for decompressing: 2-8 KB (depending from
199 speed optimizations)
200
201 LZMA decoder uses only integer operations and can be
202 implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).
203
204 Some critical operations that affect to speed of LZMA decompression:
205 1) 32*16 bit integer multiply
206 2) Misspredicted branches (penalty mostly depends from pipeline length)
207 3) 32-bit shift and arithmetic operations
208
209 Speed of LZMA decompressing mostly depends from CPU speed.
210 Memory speed has no big meaning. But if your CPU has small data cache,
211 overall weight of memory speed will slightly increase.
212
213
214 How To Use
215 ----------
216
217 Using LZMA encoder/decoder executable
218 --------------------------------------
219
220 Usage: LZMA <e|d> inputFile outputFile [<switches>...]
221
222 e: encode file
223
224 d: decode file
225
226 b: Benchmark. There are two tests: compressing and decompressing
227 with LZMA method. Benchmark shows rating in MIPS (million
228 instructions per second). Rating value is calculated from
229 measured speed and it is normalized with AMD Athlon 64 X2 CPU
230 results. Also Benchmark checks possible hardware errors (RAM
231 errors in most cases). Benchmark uses these settings:
232 (-a1, -d21, -fb32, -mfbt4). You can change only -d. Also you
233 can change number of iterations. Example for 30 iterations:
234 LZMA b 30
235 Default number of iterations is 10.
236
237 <Switches>
238
239
240 -a{N}: set compression mode 0 = fast, 1 = normal
241 default: 1 (normal)
242
243 d{N}: Sets Dictionary size - [0, 30], default: 23 (8MB)
244 The maximum value for dictionary size is 1 GB = 2^30 bytes.
245 Dictionary size is calculated as DictionarySize = 2^N bytes.
246 For decompressing file compressed by LZMA method with dictionary
247 size D = 2^N you need about D bytes of memory (RAM).
248
249 -fb{N}: set number of fast bytes - [5, 273], default: 128
250 Usually big number gives a little bit better compression ratio
251 and slower compression process.
252
253 -lc{N}: set number of literal context bits - [0, 8], default: 3
254 Sometimes lc=4 gives gain for big files.
255
256 -lp{N}: set number of literal pos bits - [0, 4], default: 0
257 lp switch is intended for periodical data when period is
258 equal 2^N. For example, for 32-bit (4 bytes)
259 periodical data you can use lp=2. Often it's better to set lc0,
260 if you change lp switch.
261
262 -pb{N}: set number of pos bits - [0, 4], default: 2
263 pb switch is intended for periodical data
264 when period is equal 2^N.
265
266 -mf{MF_ID}: set Match Finder. Default: bt4.
267 Algorithms from hc* group doesn't provide good compression
268 ratio, but they often works pretty fast in combination with
269 fast mode (-a0).
270
271 Memory requirements depend from dictionary size
272 (parameter "d" in table below).
273
274 MF_ID Memory Description
275
276 bt2 d * 9.5 + 4MB Binary Tree with 2 bytes hashing.
277 bt3 d * 11.5 + 4MB Binary Tree with 3 bytes hashing.
278 bt4 d * 11.5 + 4MB Binary Tree with 4 bytes hashing.
279 hc4 d * 7.5 + 4MB Hash Chain with 4 bytes hashing.
280
281 -eos: write End Of Stream marker. By default LZMA doesn't write
282 eos marker, since LZMA decoder knows uncompressed size
283 stored in .lzma file header.
284
285 -si: Read data from stdin (it will write End Of Stream marker).
286 -so: Write data to stdout
287
288
289 Examples:
290
291 1) LZMA e file.bin file.lzma -d16 -lc0
292
293 compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)
294 and 0 literal context bits. -lc0 allows to reduce memory requirements
295 for decompression.
296
297
298 2) LZMA e file.bin file.lzma -lc0 -lp2
299
300 compresses file.bin to file.lzma with settings suitable
301 for 32-bit periodical data (for example, ARM or MIPS code).
302
303 3) LZMA d file.lzma file.bin
304
305 decompresses file.lzma to file.bin.
306
307
308 Compression ratio hints
309 -----------------------
310
311 Recommendations
312 ---------------
313
314 To increase compression ratio for LZMA compressing it's desirable
315 to have aligned data (if it's possible) and also it's desirable to locate
316 data in such order, where code is grouped in one place and data is
317 grouped in other place (it's better than such mixing: code, data, code,
318 data, ...).
319
320
321 Using Filters
322 -------------
323 You can increase compression ratio for some data types, using
324 special filters before compressing. For example, it's possible to
325 increase compression ratio on 5-10% for code for those CPU ISAs:
326 x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.
327
328 You can find C/C++ source code of such filters in folder "7zip/Compress/Branch"
329
330 You can check compression ratio gain of these filters with such
331 7-Zip commands (example for ARM code):
332 No filter:
333 7z a a1.7z a.bin -m0=lzma
334
335 With filter for little-endian ARM code:
336 7z a a2.7z a.bin -m0=bc_arm -m1=lzma
337
338 With filter for big-endian ARM code (using additional Swap4 filter):
339 7z a a3.7z a.bin -m0=swap4 -m1=bc_arm -m2=lzma
340
341 It works in such manner:
342 Compressing = Filter_encoding + LZMA_encoding
343 Decompressing = LZMA_decoding + Filter_decoding
344
345 Compressing and decompressing speed of such filters is very high,
346 so it will not increase decompressing time too much.
347 Moreover, it reduces decompression time for LZMA_decoding,
348 since compression ratio with filtering is higher.
349
350 These filters convert CALL (calling procedure) instructions
351 from relative offsets to absolute addresses, so such data becomes more
352 compressible. Source code of these CALL filters is pretty simple
353 (about 20 lines of C++), so you can convert it from C++ version yourself.
354
355 For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.
356
357
358 LZMA compressed file format
359 ---------------------------
360 Offset Size Description
361 0 1 Special LZMA properties for compressed data
362 1 4 Dictionary size (little endian)
363 5 8 Uncompressed size (little endian). -1 means unknown size
364 13 Compressed data
365
366
367 ANSI-C LZMA Decoder
368 ~~~~~~~~~~~~~~~~~~~
369
370 To compile ANSI-C LZMA Decoder you can use one of the following files sets:
371 1) LzmaDecode.h + LzmaDecode.c + LzmaTest.c (fastest version)
372 2) LzmaDecode.h + LzmaDecodeSize.c + LzmaTest.c (old size-optimized version)
373 3) LzmaStateDecode.h + LzmaStateDecode.c + LzmaStateTest.c (zlib-like interface)
374
375
376 Memory requirements for LZMA decoding
377 -------------------------------------
378
379 LZMA decoder doesn't allocate memory itself, so you must
380 allocate memory and send it to LZMA.
381
382 Stack usage of LZMA decoding function for local variables is not
383 larger than 200 bytes.
384
385 How To decompress data
386 ----------------------
387
388 LZMA Decoder (ANSI-C version) now supports 5 interfaces:
389 1) Single-call Decompressing
390 2) Single-call Decompressing with input stream callback
391 3) Multi-call Decompressing with output buffer
392 4) Multi-call Decompressing with input callback and output buffer
393 5) Multi-call State Decompressing (zlib-like interface)
394
395 Variant-5 is similar to Variant-4, but Variant-5 doesn't use callback functions.
396
397 Decompressing steps
398 -------------------
399
400 1) read LZMA properties (5 bytes):
401 unsigned char properties[LZMA_PROPERTIES_SIZE];
402
403 2) read uncompressed size (8 bytes, little-endian)
404
405 3) Decode properties:
406
407 CLzmaDecoderState state; /* it's 24-140 bytes structure, if int is 32-bit */
408
409 if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
410 return PrintError(rs, "Incorrect stream properties");
411
412 4) Allocate memory block for internal Structures:
413
414 state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
415 if (state.Probs == 0)
416 return PrintError(rs, kCantAllocateMessage);
417
418 LZMA decoder uses array of CProb variables as internal structure.
419 By default, CProb is unsigned_short. But you can define _LZMA_PROB32 to make
420 it unsigned_int. It can increase speed on some 32-bit CPUs, but memory
421 usage will be doubled in that case.
422
423
424 5) Main Decompressing
425
426 You must use one of the following interfaces:
427
428 5.1 Single-call Decompressing
429 -----------------------------
430 When to use: RAM->RAM decompressing
431 Compile files: LzmaDecode.h, LzmaDecode.c
432 Compile defines: no defines
433 Memory Requirements:
434 - Input buffer: compressed size
435 - Output buffer: uncompressed size
436 - LZMA Internal Structures (~16 KB for default settings)
437
438 Interface:
439 int res = LzmaDecode(&state,
440 inStream, compressedSize, &inProcessed,
441 outStream, outSize, &outProcessed);
442
443
444 5.2 Single-call Decompressing with input stream callback
445 --------------------------------------------------------
446 When to use: File->RAM or Flash->RAM decompressing.
447 Compile files: LzmaDecode.h, LzmaDecode.c
448 Compile defines: _LZMA_IN_CB
449 Memory Requirements:
450 - Buffer for input stream: any size (for example, 16 KB)
451 - Output buffer: uncompressed size
452 - LZMA Internal Structures (~16 KB for default settings)
453
454 Interface:
455 typedef struct _CBuffer
456 {
457 ILzmaInCallback InCallback;
458 FILE *File;
459 unsigned char Buffer[kInBufferSize];
460 } CBuffer;
461
462 int LzmaReadCompressed(void *object, const unsigned char **buffer, SizeT *size)
463 {
464 CBuffer *bo = (CBuffer *)object;
465 *buffer = bo->Buffer;
466 *size = MyReadFile(bo->File, bo->Buffer, kInBufferSize);
467 return LZMA_RESULT_OK;
468 }
469
470 CBuffer g_InBuffer;
471
472 g_InBuffer.File = inFile;
473 g_InBuffer.InCallback.Read = LzmaReadCompressed;
474 int res = LzmaDecode(&state,
475 &g_InBuffer.InCallback,
476 outStream, outSize, &outProcessed);
477
478
479 5.3 Multi-call decompressing with output buffer
480 -----------------------------------------------
481 When to use: RAM->File decompressing
482 Compile files: LzmaDecode.h, LzmaDecode.c
483 Compile defines: _LZMA_OUT_READ
484 Memory Requirements:
485 - Input buffer: compressed size
486 - Buffer for output stream: any size (for example, 16 KB)
487 - LZMA Internal Structures (~16 KB for default settings)
488 - LZMA dictionary (dictionary size is encoded in stream properties)
489
490 Interface:
491
492 state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
493
494 LzmaDecoderInit(&state);
495 do
496 {
497 LzmaDecode(&state,
498 inBuffer, inAvail, &inProcessed,
499 g_OutBuffer, outAvail, &outProcessed);
500 inAvail -= inProcessed;
501 inBuffer += inProcessed;
502 }
503 while you need more bytes
504
505 see LzmaTest.c for more details.
506
507
508 5.4 Multi-call decompressing with input callback and output buffer
509 ------------------------------------------------------------------
510 When to use: File->File decompressing
511 Compile files: LzmaDecode.h, LzmaDecode.c
512 Compile defines: _LZMA_IN_CB, _LZMA_OUT_READ
513 Memory Requirements:
514 - Buffer for input stream: any size (for example, 16 KB)
515 - Buffer for output stream: any size (for example, 16 KB)
516 - LZMA Internal Structures (~16 KB for default settings)
517 - LZMA dictionary (dictionary size is encoded in stream properties)
518
519 Interface:
520
521 state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
522
523 LzmaDecoderInit(&state);
524 do
525 {
526 LzmaDecode(&state,
527 &bo.InCallback,
528 g_OutBuffer, outAvail, &outProcessed);
529 }
530 while you need more bytes
531
532 see LzmaTest.c for more details:
533
534
535 5.5 Multi-call State Decompressing (zlib-like interface)
536 ------------------------------------------------------------------
537 When to use: file->file decompressing
538 Compile files: LzmaStateDecode.h, LzmaStateDecode.c
539 Compile defines:
540 Memory Requirements:
541 - Buffer for input stream: any size (for example, 16 KB)
542 - Buffer for output stream: any size (for example, 16 KB)
543 - LZMA Internal Structures (~16 KB for default settings)
544 - LZMA dictionary (dictionary size is encoded in stream properties)
545
546 Interface:
547
548 state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
549
550
551 LzmaDecoderInit(&state);
552 do
553 {
554 res = LzmaDecode(&state,
555 inBuffer, inAvail, &inProcessed,
556 g_OutBuffer, outAvail, &outProcessed,
557 finishDecoding);
558 inAvail -= inProcessed;
559 inBuffer += inProcessed;
560 }
561 while you need more bytes
562
563 see LzmaStateTest.c for more details:
564
565
566 6) Free all allocated blocks
567
568
569 Note
570 ----
571 LzmaDecodeSize.c is size-optimized version of LzmaDecode.c.
572 But compiled code of LzmaDecodeSize.c can be larger than
573 compiled code of LzmaDecode.c. So it's better to use
574 LzmaDecode.c in most cases.
575
576
577 EXIT codes
578 -----------
579
580 LZMA decoder can return one of the following codes:
581
582 #define LZMA_RESULT_OK 0
583 #define LZMA_RESULT_DATA_ERROR 1
584
585 If you use callback function for input data and you return some
586 error code, LZMA Decoder also returns that code.
587
588
589
590 LZMA Defines
591 ------------
592
593 _LZMA_IN_CB - Use callback for input data
594
595 _LZMA_OUT_READ - Use read function for output data
596
597 _LZMA_LOC_OPT - Enable local speed optimizations inside code.
598 _LZMA_LOC_OPT is only for LzmaDecodeSize.c (size-optimized version).
599 _LZMA_LOC_OPT doesn't affect LzmaDecode.c (speed-optimized version)
600 and LzmaStateDecode.c
601
602 _LZMA_PROB32 - It can increase speed on some 32-bit CPUs,
603 but memory usage will be doubled in that case
604
605 _LZMA_UINT32_IS_ULONG - Define it if int is 16-bit on your compiler
606 and long is 32-bit.
607
608 _LZMA_SYSTEM_SIZE_T - Define it if you want to use system's size_t.
609 You can use it to enable 64-bit sizes supporting
610
611
612
613 C++ LZMA Encoder/Decoder
614 ~~~~~~~~~~~~~~~~~~~~~~~~
615 C++ LZMA code use COM-like interfaces. So if you want to use it,
616 you can study basics of COM/OLE.
617
618 By default, LZMA Encoder contains all Match Finders.
619 But for compressing it's enough to have just one of them.
620 So for reducing size of compressing code you can define:
621 #define COMPRESS_MF_BT
622 #define COMPRESS_MF_BT4
623 and it will use only bt4 match finder.
624
625
626 ---
627
628 http://www.7-zip.org
629 http://www.7-zip.org/support.html
0 dist_man_MANS = afcat.1
0 # Makefile.in generated by automake 1.10 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 pkgdatadir = $(datadir)/@PACKAGE@
17 pkglibdir = $(libdir)/@PACKAGE@
18 pkgincludedir = $(includedir)/@PACKAGE@
19 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
20 install_sh_DATA = $(install_sh) -c -m 644
21 install_sh_PROGRAM = $(install_sh) -c
22 install_sh_SCRIPT = $(install_sh) -c
23 INSTALL_HEADER = $(INSTALL_DATA)
24 transform = $(program_transform_name)
25 NORMAL_INSTALL = :
26 PRE_INSTALL = :
27 POST_INSTALL = :
28 NORMAL_UNINSTALL = :
29 PRE_UNINSTALL = :
30 POST_UNINSTALL = :
31 build_triplet = @build@
32 host_triplet = @host@
33 subdir = man
34 DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
35 $(srcdir)/Makefile.in
36 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
37 am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
38 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
39 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
40 $(ACLOCAL_M4)
41 mkinstalldirs = $(install_sh) -d
42 CONFIG_HEADER = $(top_builddir)/affconfig.h
43 CONFIG_CLEAN_FILES =
44 SOURCES =
45 DIST_SOURCES =
46 man1dir = $(mandir)/man1
47 am__installdirs = "$(DESTDIR)$(man1dir)"
48 NROFF = nroff
49 MANS = $(dist_man_MANS)
50 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
51 ACLOCAL = @ACLOCAL@
52 AFFUSE_BIN = @AFFUSE_BIN@
53 ALLOCA = @ALLOCA@
54 AMTAR = @AMTAR@
55 AR = @AR@
56 AUTOCONF = @AUTOCONF@
57 AUTOHEADER = @AUTOHEADER@
58 AUTOMAKE = @AUTOMAKE@
59 AWK = @AWK@
60 CC = @CC@
61 CCDEPMODE = @CCDEPMODE@
62 CFLAGS = @CFLAGS@
63 CPP = @CPP@
64 CPPFLAGS = @CPPFLAGS@
65 CURL_CONFIG = @CURL_CONFIG@
66 CXX = @CXX@
67 CXXCPP = @CXXCPP@
68 CXXDEPMODE = @CXXDEPMODE@
69 CXXFLAGS = @CXXFLAGS@
70 CYGPATH_W = @CYGPATH_W@
71 DEFS = @DEFS@
72 DEPDIR = @DEPDIR@
73 DSYMUTIL = @DSYMUTIL@
74 DUMPBIN = @DUMPBIN@
75 ECHO_C = @ECHO_C@
76 ECHO_N = @ECHO_N@
77 ECHO_T = @ECHO_T@
78 EGREP = @EGREP@
79 EXEEXT = @EXEEXT@
80 FGREP = @FGREP@
81 FUSE_CFLAGS = @FUSE_CFLAGS@
82 FUSE_LIBS = @FUSE_LIBS@
83 GREP = @GREP@
84 INSTALL = @INSTALL@
85 INSTALL_DATA = @INSTALL_DATA@
86 INSTALL_PROGRAM = @INSTALL_PROGRAM@
87 INSTALL_SCRIPT = @INSTALL_SCRIPT@
88 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
89 LD = @LD@
90 LDFLAGS = @LDFLAGS@
91 LIBOBJS = @LIBOBJS@
92 LIBS = @LIBS@
93 LIBTOOL = @LIBTOOL@
94 LIPO = @LIPO@
95 LN_S = @LN_S@
96 LTLIBOBJS = @LTLIBOBJS@
97 MAINT = @MAINT@
98 MAKEINFO = @MAKEINFO@
99 MKDIR_P = @MKDIR_P@
100 NM = @NM@
101 NMEDIT = @NMEDIT@
102 OBJEXT = @OBJEXT@
103 OTOOL = @OTOOL@
104 OTOOL64 = @OTOOL64@
105 PACKAGE = @PACKAGE@
106 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
107 PACKAGE_NAME = @PACKAGE_NAME@
108 PACKAGE_STRING = @PACKAGE_STRING@
109 PACKAGE_TARNAME = @PACKAGE_TARNAME@
110 PACKAGE_VERSION = @PACKAGE_VERSION@
111 PATH_SEPARATOR = @PATH_SEPARATOR@
112 PTHREAD_CC = @PTHREAD_CC@
113 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
114 PTHREAD_LIBS = @PTHREAD_LIBS@
115 PYTHON = @PYTHON@
116 PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
117 PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
118 PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
119 PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
120 PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
121 PYTHON_PLATFORM = @PYTHON_PLATFORM@
122 PYTHON_PREFIX = @PYTHON_PREFIX@
123 PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
124 PYTHON_VERSION = @PYTHON_VERSION@
125 RANLIB = @RANLIB@
126 S3_BIN = @S3_BIN@
127 SED = @SED@
128 SET_MAKE = @SET_MAKE@
129 SHELL = @SHELL@
130 STRIP = @STRIP@
131 VERSION = @VERSION@
132 abs_builddir = @abs_builddir@
133 abs_srcdir = @abs_srcdir@
134 abs_top_builddir = @abs_top_builddir@
135 abs_top_srcdir = @abs_top_srcdir@
136 ac_ct_CC = @ac_ct_CC@
137 ac_ct_CXX = @ac_ct_CXX@
138 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
139 ac_prefix_program = @ac_prefix_program@
140 acx_pthread_config = @acx_pthread_config@
141 am__include = @am__include@
142 am__leading_dot = @am__leading_dot@
143 am__quote = @am__quote@
144 am__tar = @am__tar@
145 am__untar = @am__untar@
146 bindir = @bindir@
147 build = @build@
148 build_alias = @build_alias@
149 build_cpu = @build_cpu@
150 build_os = @build_os@
151 build_vendor = @build_vendor@
152 builddir = @builddir@
153 datadir = @datadir@
154 datarootdir = @datarootdir@
155 docdir = @docdir@
156 dvidir = @dvidir@
157 exec_prefix = @exec_prefix@
158 host = @host@
159 host_alias = @host_alias@
160 host_cpu = @host_cpu@
161 host_os = @host_os@
162 host_vendor = @host_vendor@
163 htmldir = @htmldir@
164 includedir = @includedir@
165 infodir = @infodir@
166 install_sh = @install_sh@
167 libdir = @libdir@
168 libexecdir = @libexecdir@
169 localedir = @localedir@
170 localstatedir = @localstatedir@
171 lt_ECHO = @lt_ECHO@
172 mandir = @mandir@
173 mkdir_p = @mkdir_p@
174 oldincludedir = @oldincludedir@
175 pdfdir = @pdfdir@
176 pkgpyexecdir = @pkgpyexecdir@
177 pkgpythondir = @pkgpythondir@
178 prefix = @prefix@
179 program_transform_name = @program_transform_name@
180 psdir = @psdir@
181 pyexecdir = @pyexecdir@
182 pythondir = @pythondir@
183 sbindir = @sbindir@
184 sharedstatedir = @sharedstatedir@
185 srcdir = @srcdir@
186 sysconfdir = @sysconfdir@
187 target_alias = @target_alias@
188 top_builddir = @top_builddir@
189 top_srcdir = @top_srcdir@
190 dist_man_MANS = afcat.1
191 all: all-am
192
193 .SUFFIXES:
194 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
195 @for dep in $?; do \
196 case '$(am__configure_deps)' in \
197 *$$dep*) \
198 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
199 && exit 0; \
200 exit 1;; \
201 esac; \
202 done; \
203 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \
204 cd $(top_srcdir) && \
205 $(AUTOMAKE) --gnu man/Makefile
206 .PRECIOUS: Makefile
207 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
208 @case '$?' in \
209 *config.status*) \
210 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
211 *) \
212 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
213 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
214 esac;
215
216 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
217 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
218
219 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
220 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
221 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
222 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
223
224 mostlyclean-libtool:
225 -rm -f *.lo
226
227 clean-libtool:
228 -rm -rf .libs _libs
229 install-man1: $(man1_MANS) $(man_MANS)
230 @$(NORMAL_INSTALL)
231 test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
232 @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
233 l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
234 for i in $$l2; do \
235 case "$$i" in \
236 *.1*) list="$$list $$i" ;; \
237 esac; \
238 done; \
239 for i in $$list; do \
240 if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
241 else file=$$i; fi; \
242 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
243 case "$$ext" in \
244 1*) ;; \
245 *) ext='1' ;; \
246 esac; \
247 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
248 inst=`echo $$inst | sed -e 's/^.*\///'`; \
249 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
250 echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
251 $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
252 done
253 uninstall-man1:
254 @$(NORMAL_UNINSTALL)
255 @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
256 l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
257 for i in $$l2; do \
258 case "$$i" in \
259 *.1*) list="$$list $$i" ;; \
260 esac; \
261 done; \
262 for i in $$list; do \
263 ext=`echo $$i | sed -e 's/^.*\\.//'`; \
264 case "$$ext" in \
265 1*) ;; \
266 *) ext='1' ;; \
267 esac; \
268 inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
269 inst=`echo $$inst | sed -e 's/^.*\///'`; \
270 inst=`echo $$inst | sed '$(transform)'`.$$ext; \
271 echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
272 rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
273 done
274 tags: TAGS
275 TAGS:
276
277 ctags: CTAGS
278 CTAGS:
279
280
281 distdir: $(DISTFILES)
282 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
283 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
284 list='$(DISTFILES)'; \
285 dist_files=`for file in $$list; do echo $$file; done | \
286 sed -e "s|^$$srcdirstrip/||;t" \
287 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
288 case $$dist_files in \
289 */*) $(MKDIR_P) `echo "$$dist_files" | \
290 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
291 sort -u` ;; \
292 esac; \
293 for file in $$dist_files; do \
294 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
295 if test -d $$d/$$file; then \
296 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
297 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
298 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
299 fi; \
300 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
301 else \
302 test -f $(distdir)/$$file \
303 || cp -p $$d/$$file $(distdir)/$$file \
304 || exit 1; \
305 fi; \
306 done
307 check-am: all-am
308 check: check-am
309 all-am: Makefile $(MANS)
310 installdirs:
311 for dir in "$(DESTDIR)$(man1dir)"; do \
312 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
313 done
314 install: install-am
315 install-exec: install-exec-am
316 install-data: install-data-am
317 uninstall: uninstall-am
318
319 install-am: all-am
320 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
321
322 installcheck: installcheck-am
323 install-strip:
324 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
325 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
326 `test -z '$(STRIP)' || \
327 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
328 mostlyclean-generic:
329
330 clean-generic:
331
332 distclean-generic:
333 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
334
335 maintainer-clean-generic:
336 @echo "This command is intended for maintainers to use"
337 @echo "it deletes files that may require special tools to rebuild."
338 clean: clean-am
339
340 clean-am: clean-generic clean-libtool mostlyclean-am
341
342 distclean: distclean-am
343 -rm -f Makefile
344 distclean-am: clean-am distclean-generic
345
346 dvi: dvi-am
347
348 dvi-am:
349
350 html: html-am
351
352 info: info-am
353
354 info-am:
355
356 install-data-am: install-man
357
358 install-dvi: install-dvi-am
359
360 install-exec-am:
361
362 install-html: install-html-am
363
364 install-info: install-info-am
365
366 install-man: install-man1
367
368 install-pdf: install-pdf-am
369
370 install-ps: install-ps-am
371
372 installcheck-am:
373
374 maintainer-clean: maintainer-clean-am
375 -rm -f Makefile
376 maintainer-clean-am: distclean-am maintainer-clean-generic
377
378 mostlyclean: mostlyclean-am
379
380 mostlyclean-am: mostlyclean-generic mostlyclean-libtool
381
382 pdf: pdf-am
383
384 pdf-am:
385
386 ps: ps-am
387
388 ps-am:
389
390 uninstall-am: uninstall-man
391
392 uninstall-man: uninstall-man1
393
394 .MAKE: install-am install-strip
395
396 .PHONY: all all-am check check-am clean clean-generic clean-libtool \
397 distclean distclean-generic distclean-libtool distdir dvi \
398 dvi-am html html-am info info-am install install-am \
399 install-data install-data-am install-dvi install-dvi-am \
400 install-exec install-exec-am install-html install-html-am \
401 install-info install-info-am install-man install-man1 \
402 install-pdf install-pdf-am install-ps install-ps-am \
403 install-strip installcheck installcheck-am installdirs \
404 maintainer-clean maintainer-clean-generic mostlyclean \
405 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
406 uninstall uninstall-am uninstall-man uninstall-man1
407
408 # Tell versions [3.59,3.63) of GNU make to not export all variables.
409 # Otherwise a system limit (for SysV at least) may be exceeded.
410 .NOEXPORT:
0 .\" Process this file with
1 .\" groff -man -Tascii foo.1
2 .\"
3 .TH AFCAT 1 "OCT 2008" "User Manuals"
4 .SH NAME
5 afcat \- Output contents of an image file to stdout.
6 .SH SYNOPSIS
7 .B afcat [options]
8 .I image [images]
9 .SH DESCRIPTION
10 .B affcat
11 outputs the contents of an image file to stdout. Image files that are not raw but are recognized
12 by AFF will be output in raw format. Missing pages will not be padded, but the fact that they are missing
13 will be noted on STDERR.
14
15 The options are as follows:
16 .IP "-s name"
17 Output the named segment, instead of the image data. This is a way to output metadata.
18 .IP "-p nnn"
19 Just output page number
20 .B nnn
21 .IP "-S nnn"
22 Just output data sector number
23 .B nnn.
24 Sector #0 is the first sector.
25 .IP "-q"
26 Quiet mode. Don't print to STDERR if a page is skipped because it is not present.
27 .IP "-n"
28 Noisy mode. Tell when pages are skipped.
29 .IP "-l"
30 List all the segment names, rather than outputing data.
31 .IP "-L"
32 List Long. Prints segment names, lengths, and args.
33 .IP "-d"
34 Debug mode. Print the page numbers to stderr as data goes to stdout.
35 .IP "-b"
36 Output BADFALG for bad blocks (default is to output NULLs).
37 .IP "-v"
38 Just print the version number and exit.
39 .IP "-r offset:count"
40 Seek to the given byte offset and output count characters in each file; may be repeated.
41 .SH HISTORY
42 .BR "afcat" " first appeared in " "AFFLIB" " v1.00."
43 .SH AUTHOR
44 Simson Garfinkel <simsong@acm.org>
45
0 #! /bin/sh
1 # Common stub for a few missing GNU programs while installing.
2
3 scriptversion=2005-06-08.21
4
5 # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
6 # Free Software Foundation, Inc.
7 # Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # 02110-1301, USA.
23
24 # As a special exception to the GNU General Public License, if you
25 # distribute this file as part of a program that contains a
26 # configuration script generated by Autoconf, you may include it under
27 # the same distribution terms that you use for the rest of that program.
28
29 if test $# -eq 0; then
30 echo 1>&2 "Try \`$0 --help' for more information"
31 exit 1
32 fi
33
34 run=:
35
36 # In the cases where this matters, `missing' is being run in the
37 # srcdir already.
38 if test -f configure.ac; then
39 configure_ac=configure.ac
40 else
41 configure_ac=configure.in
42 fi
43
44 msg="missing on your system"
45
46 case "$1" in
47 --run)
48 # Try to run requested program, and just exit if it succeeds.
49 run=
50 shift
51 "$@" && exit 0
52 # Exit code 63 means version mismatch. This often happens
53 # when the user try to use an ancient version of a tool on
54 # a file that requires a minimum version. In this case we
55 # we should proceed has if the program had been absent, or
56 # if --run hadn't been passed.
57 if test $? = 63; then
58 run=:
59 msg="probably too old"
60 fi
61 ;;
62
63 -h|--h|--he|--hel|--help)
64 echo "\
65 $0 [OPTION]... PROGRAM [ARGUMENT]...
66
67 Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
68 error status if there is no known handling for PROGRAM.
69
70 Options:
71 -h, --help display this help and exit
72 -v, --version output version information and exit
73 --run try to run the given command, and emulate it if it fails
74
75 Supported PROGRAM values:
76 aclocal touch file \`aclocal.m4'
77 autoconf touch file \`configure'
78 autoheader touch file \`config.h.in'
79 automake touch all \`Makefile.in' files
80 bison create \`y.tab.[ch]', if possible, from existing .[ch]
81 flex create \`lex.yy.c', if possible, from existing .c
82 help2man touch the output file
83 lex create \`lex.yy.c', if possible, from existing .c
84 makeinfo touch the output file
85 tar try tar, gnutar, gtar, then tar without non-portable flags
86 yacc create \`y.tab.[ch]', if possible, from existing .[ch]
87
88 Send bug reports to <bug-automake@gnu.org>."
89 exit $?
90 ;;
91
92 -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
93 echo "missing $scriptversion (GNU Automake)"
94 exit $?
95 ;;
96
97 -*)
98 echo 1>&2 "$0: Unknown \`$1' option"
99 echo 1>&2 "Try \`$0 --help' for more information"
100 exit 1
101 ;;
102
103 esac
104
105 # Now exit if we have it, but it failed. Also exit now if we
106 # don't have it and --version was passed (most likely to detect
107 # the program).
108 case "$1" in
109 lex|yacc)
110 # Not GNU programs, they don't have --version.
111 ;;
112
113 tar)
114 if test -n "$run"; then
115 echo 1>&2 "ERROR: \`tar' requires --run"
116 exit 1
117 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
118 exit 1
119 fi
120 ;;
121
122 *)
123 if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
124 # We have it, but it failed.
125 exit 1
126 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
127 # Could not run --version or --help. This is probably someone
128 # running `$TOOL --version' or `$TOOL --help' to check whether
129 # $TOOL exists and not knowing $TOOL uses missing.
130 exit 1
131 fi
132 ;;
133 esac
134
135 # If it does not exist, or fails to run (possibly an outdated version),
136 # try to emulate it.
137 case "$1" in
138 aclocal*)
139 echo 1>&2 "\
140 WARNING: \`$1' is $msg. You should only need it if
141 you modified \`acinclude.m4' or \`${configure_ac}'. You might want
142 to install the \`Automake' and \`Perl' packages. Grab them from
143 any GNU archive site."
144 touch aclocal.m4
145 ;;
146
147 autoconf)
148 echo 1>&2 "\
149 WARNING: \`$1' is $msg. You should only need it if
150 you modified \`${configure_ac}'. You might want to install the
151 \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
152 archive site."
153 touch configure
154 ;;
155
156 autoheader)
157 echo 1>&2 "\
158 WARNING: \`$1' is $msg. You should only need it if
159 you modified \`acconfig.h' or \`${configure_ac}'. You might want
160 to install the \`Autoconf' and \`GNU m4' packages. Grab them
161 from any GNU archive site."
162 files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
163 test -z "$files" && files="config.h"
164 touch_files=
165 for f in $files; do
166 case "$f" in
167 *:*) touch_files="$touch_files "`echo "$f" |
168 sed -e 's/^[^:]*://' -e 's/:.*//'`;;
169 *) touch_files="$touch_files $f.in";;
170 esac
171 done
172 touch $touch_files
173 ;;
174
175 automake*)
176 echo 1>&2 "\
177 WARNING: \`$1' is $msg. You should only need it if
178 you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
179 You might want to install the \`Automake' and \`Perl' packages.
180 Grab them from any GNU archive site."
181 find . -type f -name Makefile.am -print |
182 sed 's/\.am$/.in/' |
183 while read f; do touch "$f"; done
184 ;;
185
186 autom4te)
187 echo 1>&2 "\
188 WARNING: \`$1' is needed, but is $msg.
189 You might have modified some files without having the
190 proper tools for further handling them.
191 You can get \`$1' as part of \`Autoconf' from any GNU
192 archive site."
193
194 file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
195 test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
196 if test -f "$file"; then
197 touch $file
198 else
199 test -z "$file" || exec >$file
200 echo "#! /bin/sh"
201 echo "# Created by GNU Automake missing as a replacement of"
202 echo "# $ $@"
203 echo "exit 0"
204 chmod +x $file
205 exit 1
206 fi
207 ;;
208
209 bison|yacc)
210 echo 1>&2 "\
211 WARNING: \`$1' $msg. You should only need it if
212 you modified a \`.y' file. You may need the \`Bison' package
213 in order for those modifications to take effect. You can get
214 \`Bison' from any GNU archive site."
215 rm -f y.tab.c y.tab.h
216 if [ $# -ne 1 ]; then
217 eval LASTARG="\${$#}"
218 case "$LASTARG" in
219 *.y)
220 SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
221 if [ -f "$SRCFILE" ]; then
222 cp "$SRCFILE" y.tab.c
223 fi
224 SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
225 if [ -f "$SRCFILE" ]; then
226 cp "$SRCFILE" y.tab.h
227 fi
228 ;;
229 esac
230 fi
231 if [ ! -f y.tab.h ]; then
232 echo >y.tab.h
233 fi
234 if [ ! -f y.tab.c ]; then
235 echo 'main() { return 0; }' >y.tab.c
236 fi
237 ;;
238
239 lex|flex)
240 echo 1>&2 "\
241 WARNING: \`$1' is $msg. You should only need it if
242 you modified a \`.l' file. You may need the \`Flex' package
243 in order for those modifications to take effect. You can get
244 \`Flex' from any GNU archive site."
245 rm -f lex.yy.c
246 if [ $# -ne 1 ]; then
247 eval LASTARG="\${$#}"
248 case "$LASTARG" in
249 *.l)
250 SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
251 if [ -f "$SRCFILE" ]; then
252 cp "$SRCFILE" lex.yy.c
253 fi
254 ;;
255 esac
256 fi
257 if [ ! -f lex.yy.c ]; then
258 echo 'main() { return 0; }' >lex.yy.c
259 fi
260 ;;
261
262 help2man)
263 echo 1>&2 "\
264 WARNING: \`$1' is $msg. You should only need it if
265 you modified a dependency of a manual page. You may need the
266 \`Help2man' package in order for those modifications to take
267 effect. You can get \`Help2man' from any GNU archive site."
268
269 file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
270 if test -z "$file"; then
271 file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
272 fi
273 if [ -f "$file" ]; then
274 touch $file
275 else
276 test -z "$file" || exec >$file
277 echo ".ab help2man is required to generate this page"
278 exit 1
279 fi
280 ;;
281
282 makeinfo)
283 echo 1>&2 "\
284 WARNING: \`$1' is $msg. You should only need it if
285 you modified a \`.texi' or \`.texinfo' file, or any other file
286 indirectly affecting the aspect of the manual. The spurious
287 call might also be the consequence of using a buggy \`make' (AIX,
288 DU, IRIX). You might want to install the \`Texinfo' package or
289 the \`GNU make' package. Grab either from any GNU archive site."
290 # The file to touch is that specified with -o ...
291 file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
292 if test -z "$file"; then
293 # ... or it is the one specified with @setfilename ...
294 infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
295 file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
296 # ... or it is derived from the source name (dir/f.texi becomes f.info)
297 test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
298 fi
299 # If the file does not exist, the user really needs makeinfo;
300 # let's fail without touching anything.
301 test -f $file || exit 1
302 touch $file
303 ;;
304
305 tar)
306 shift
307
308 # We have already tried tar in the generic part.
309 # Look for gnutar/gtar before invocation to avoid ugly error
310 # messages.
311 if (gnutar --version > /dev/null 2>&1); then
312 gnutar "$@" && exit 0
313 fi
314 if (gtar --version > /dev/null 2>&1); then
315 gtar "$@" && exit 0
316 fi
317 firstarg="$1"
318 if shift; then
319 case "$firstarg" in
320 *o*)
321 firstarg=`echo "$firstarg" | sed s/o//`
322 tar "$firstarg" "$@" && exit 0
323 ;;
324 esac
325 case "$firstarg" in
326 *h*)
327 firstarg=`echo "$firstarg" | sed s/h//`
328 tar "$firstarg" "$@" && exit 0
329 ;;
330 esac
331 fi
332
333 echo 1>&2 "\
334 WARNING: I can't seem to be able to run \`tar' with the given arguments.
335 You may want to install GNU tar or Free paxutils, or check the
336 command line arguments."
337 exit 1
338 ;;
339
340 *)
341 echo 1>&2 "\
342 WARNING: \`$1' is needed, and is $msg.
343 You might have modified some files without having the
344 proper tools for further handling them. Check the \`README' file,
345 it often tells you about the needed prerequisites for installing
346 this package. You may also peek at any GNU archive site, in case
347 some other package would contain this missing \`$1' program."
348 exit 1
349 ;;
350 esac
351
352 exit 0
353
354 # Local variables:
355 # eval: (add-hook 'write-file-hooks 'time-stamp)
356 # time-stamp-start: "scriptversion="
357 # time-stamp-format: "%:y-%02m-%02d.%02H"
358 # time-stamp-end: "$"
359 # End:
0 EXTRA_DIST = PKG-INFO README pyaff.c setup.py
1
2 if HAVE_PYTHON
3 AM_CFLAGS = -I$(top_srcdir)/lib -include affconfig.h
4
5 # This is for the pyaff python module
6 pyexec_LTLIBRARIES = pyaff.la
7
8 pyaff_la_SOURCES = pyaff.c
9 pyaff_la_LIBADD = ../lib/libafflib.la
10 pyaff_la_CPPFLAGS = $(PYTHON_CPPFLAGS)
11 pyaff_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS)
12 endif
0 # Makefile.in generated by automake 1.10 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 pkgdatadir = $(datadir)/@PACKAGE@
18 pkglibdir = $(libdir)/@PACKAGE@
19 pkgincludedir = $(includedir)/@PACKAGE@
20 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
21 install_sh_DATA = $(install_sh) -c -m 644
22 install_sh_PROGRAM = $(install_sh) -c
23 install_sh_SCRIPT = $(install_sh) -c
24 INSTALL_HEADER = $(INSTALL_DATA)
25 transform = $(program_transform_name)
26 NORMAL_INSTALL = :
27 PRE_INSTALL = :
28 POST_INSTALL = :
29 NORMAL_UNINSTALL = :
30 PRE_UNINSTALL = :
31 POST_UNINSTALL = :
32 build_triplet = @build@
33 host_triplet = @host@
34 subdir = pyaff
35 DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
36 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
37 am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
38 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
39 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
40 $(ACLOCAL_M4)
41 mkinstalldirs = $(install_sh) -d
42 CONFIG_HEADER = $(top_builddir)/affconfig.h
43 CONFIG_CLEAN_FILES =
44 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
45 am__vpath_adj = case $$p in \
46 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
47 *) f=$$p;; \
48 esac;
49 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
50 am__installdirs = "$(DESTDIR)$(pyexecdir)"
51 pyexecLTLIBRARIES_INSTALL = $(INSTALL)
52 LTLIBRARIES = $(pyexec_LTLIBRARIES)
53 @HAVE_PYTHON_TRUE@pyaff_la_DEPENDENCIES = ../lib/libafflib.la
54 am__pyaff_la_SOURCES_DIST = pyaff.c
55 @HAVE_PYTHON_TRUE@am_pyaff_la_OBJECTS = pyaff_la-pyaff.lo
56 pyaff_la_OBJECTS = $(am_pyaff_la_OBJECTS)
57 pyaff_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
58 --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(pyaff_la_LDFLAGS) \
59 $(LDFLAGS) -o $@
60 @HAVE_PYTHON_TRUE@am_pyaff_la_rpath = -rpath $(pyexecdir)
61 DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
62 depcomp = $(SHELL) $(top_srcdir)/depcomp
63 am__depfiles_maybe = depfiles
64 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
65 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
66 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
67 --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
68 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
69 CCLD = $(CC)
70 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
71 --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
72 $(LDFLAGS) -o $@
73 SOURCES = $(pyaff_la_SOURCES)
74 DIST_SOURCES = $(am__pyaff_la_SOURCES_DIST)
75 ETAGS = etags
76 CTAGS = ctags
77 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
78 ACLOCAL = @ACLOCAL@
79 AFFUSE_BIN = @AFFUSE_BIN@
80 ALLOCA = @ALLOCA@
81 AMTAR = @AMTAR@
82 AR = @AR@
83 AUTOCONF = @AUTOCONF@
84 AUTOHEADER = @AUTOHEADER@
85 AUTOMAKE = @AUTOMAKE@
86 AWK = @AWK@
87 CC = @CC@
88 CCDEPMODE = @CCDEPMODE@
89 CFLAGS = @CFLAGS@
90 CPP = @CPP@
91 CPPFLAGS = @CPPFLAGS@
92 CURL_CONFIG = @CURL_CONFIG@
93 CXX = @CXX@
94 CXXCPP = @CXXCPP@
95 CXXDEPMODE = @CXXDEPMODE@
96 CXXFLAGS = @CXXFLAGS@
97 CYGPATH_W = @CYGPATH_W@
98 DEFS = @DEFS@
99 DEPDIR = @DEPDIR@
100 DSYMUTIL = @DSYMUTIL@
101 DUMPBIN = @DUMPBIN@
102 ECHO_C = @ECHO_C@
103 ECHO_N = @ECHO_N@
104 ECHO_T = @ECHO_T@
105 EGREP = @EGREP@
106 EXEEXT = @EXEEXT@
107 FGREP = @FGREP@
108 FUSE_CFLAGS = @FUSE_CFLAGS@
109 FUSE_LIBS = @FUSE_LIBS@
110 GREP = @GREP@
111 INSTALL = @INSTALL@
112 INSTALL_DATA = @INSTALL_DATA@
113 INSTALL_PROGRAM = @INSTALL_PROGRAM@
114 INSTALL_SCRIPT = @INSTALL_SCRIPT@
115 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
116 LD = @LD@
117 LDFLAGS = @LDFLAGS@
118 LIBOBJS = @LIBOBJS@
119 LIBS = @LIBS@
120 LIBTOOL = @LIBTOOL@
121 LIPO = @LIPO@
122 LN_S = @LN_S@
123 LTLIBOBJS = @LTLIBOBJS@
124 MAINT = @MAINT@
125 MAKEINFO = @MAKEINFO@
126 MKDIR_P = @MKDIR_P@
127 NM = @NM@
128 NMEDIT = @NMEDIT@
129 OBJEXT = @OBJEXT@
130 OTOOL = @OTOOL@
131 OTOOL64 = @OTOOL64@
132 PACKAGE = @PACKAGE@
133 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
134 PACKAGE_NAME = @PACKAGE_NAME@
135 PACKAGE_STRING = @PACKAGE_STRING@
136 PACKAGE_TARNAME = @PACKAGE_TARNAME@
137 PACKAGE_VERSION = @PACKAGE_VERSION@
138 PATH_SEPARATOR = @PATH_SEPARATOR@
139 PTHREAD_CC = @PTHREAD_CC@
140 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
141 PTHREAD_LIBS = @PTHREAD_LIBS@
142 PYTHON = @PYTHON@
143 PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
144 PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
145 PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
146 PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
147 PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
148 PYTHON_PLATFORM = @PYTHON_PLATFORM@
149 PYTHON_PREFIX = @PYTHON_PREFIX@
150 PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
151 PYTHON_VERSION = @PYTHON_VERSION@
152 RANLIB = @RANLIB@
153 S3_BIN = @S3_BIN@
154 SED = @SED@
155 SET_MAKE = @SET_MAKE@
156 SHELL = @SHELL@
157 STRIP = @STRIP@
158 VERSION = @VERSION@
159 abs_builddir = @abs_builddir@
160 abs_srcdir = @abs_srcdir@
161 abs_top_builddir = @abs_top_builddir@
162 abs_top_srcdir = @abs_top_srcdir@
163 ac_ct_CC = @ac_ct_CC@
164 ac_ct_CXX = @ac_ct_CXX@
165 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
166 ac_prefix_program = @ac_prefix_program@
167 acx_pthread_config = @acx_pthread_config@
168 am__include = @am__include@
169 am__leading_dot = @am__leading_dot@
170 am__quote = @am__quote@
171 am__tar = @am__tar@
172 am__untar = @am__untar@
173 bindir = @bindir@
174 build = @build@
175 build_alias = @build_alias@
176 build_cpu = @build_cpu@
177 build_os = @build_os@
178 build_vendor = @build_vendor@
179 builddir = @builddir@
180 datadir = @datadir@
181 datarootdir = @datarootdir@
182 docdir = @docdir@
183 dvidir = @dvidir@
184 exec_prefix = @exec_prefix@
185 host = @host@
186 host_alias = @host_alias@
187 host_cpu = @host_cpu@
188 host_os = @host_os@
189 host_vendor = @host_vendor@
190 htmldir = @htmldir@
191 includedir = @includedir@
192 infodir = @infodir@
193 install_sh = @install_sh@
194 libdir = @libdir@
195 libexecdir = @libexecdir@
196 localedir = @localedir@
197 localstatedir = @localstatedir@
198 lt_ECHO = @lt_ECHO@
199 mandir = @mandir@
200 mkdir_p = @mkdir_p@
201 oldincludedir = @oldincludedir@
202 pdfdir = @pdfdir@
203 pkgpyexecdir = @pkgpyexecdir@
204 pkgpythondir = @pkgpythondir@
205 prefix = @prefix@
206 program_transform_name = @program_transform_name@
207 psdir = @psdir@
208 pyexecdir = @pyexecdir@
209 pythondir = @pythondir@
210 sbindir = @sbindir@
211 sharedstatedir = @sharedstatedir@
212 srcdir = @srcdir@
213 sysconfdir = @sysconfdir@
214 target_alias = @target_alias@
215 top_builddir = @top_builddir@
216 top_srcdir = @top_srcdir@
217 EXTRA_DIST = PKG-INFO README pyaff.c setup.py
218 @HAVE_PYTHON_TRUE@AM_CFLAGS = -I$(top_srcdir)/lib -include affconfig.h
219
220 # This is for the pyaff python module
221 @HAVE_PYTHON_TRUE@pyexec_LTLIBRARIES = pyaff.la
222 @HAVE_PYTHON_TRUE@pyaff_la_SOURCES = pyaff.c
223 @HAVE_PYTHON_TRUE@pyaff_la_LIBADD = ../lib/libafflib.la
224 @HAVE_PYTHON_TRUE@pyaff_la_CPPFLAGS = $(PYTHON_CPPFLAGS)
225 @HAVE_PYTHON_TRUE@pyaff_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS)
226 all: all-am
227
228 .SUFFIXES:
229 .SUFFIXES: .c .lo .o .obj
230 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
231 @for dep in $?; do \
232 case '$(am__configure_deps)' in \
233 *$$dep*) \
234 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
235 && exit 0; \
236 exit 1;; \
237 esac; \
238 done; \
239 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu pyaff/Makefile'; \
240 cd $(top_srcdir) && \
241 $(AUTOMAKE) --gnu pyaff/Makefile
242 .PRECIOUS: Makefile
243 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
244 @case '$?' in \
245 *config.status*) \
246 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
247 *) \
248 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
249 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
250 esac;
251
252 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
253 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
254
255 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
256 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
257 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
258 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
259 install-pyexecLTLIBRARIES: $(pyexec_LTLIBRARIES)
260 @$(NORMAL_INSTALL)
261 test -z "$(pyexecdir)" || $(MKDIR_P) "$(DESTDIR)$(pyexecdir)"
262 @list='$(pyexec_LTLIBRARIES)'; for p in $$list; do \
263 if test -f $$p; then \
264 f=$(am__strip_dir) \
265 echo " $(LIBTOOL) --mode=install $(pyexecLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(pyexecdir)/$$f'"; \
266 $(LIBTOOL) --mode=install $(pyexecLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(pyexecdir)/$$f"; \
267 else :; fi; \
268 done
269
270 uninstall-pyexecLTLIBRARIES:
271 @$(NORMAL_UNINSTALL)
272 @list='$(pyexec_LTLIBRARIES)'; for p in $$list; do \
273 p=$(am__strip_dir) \
274 echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(pyexecdir)/$$p'"; \
275 $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(pyexecdir)/$$p"; \
276 done
277
278 clean-pyexecLTLIBRARIES:
279 -test -z "$(pyexec_LTLIBRARIES)" || rm -f $(pyexec_LTLIBRARIES)
280 @list='$(pyexec_LTLIBRARIES)'; for p in $$list; do \
281 dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
282 test "$$dir" != "$$p" || dir=.; \
283 echo "rm -f \"$${dir}/so_locations\""; \
284 rm -f "$${dir}/so_locations"; \
285 done
286 pyaff.la: $(pyaff_la_OBJECTS) $(pyaff_la_DEPENDENCIES)
287 $(pyaff_la_LINK) $(am_pyaff_la_rpath) $(pyaff_la_OBJECTS) $(pyaff_la_LIBADD) $(LIBS)
288
289 mostlyclean-compile:
290 -rm -f *.$(OBJEXT)
291
292 distclean-compile:
293 -rm -f *.tab.c
294
295 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pyaff_la-pyaff.Plo@am__quote@
296
297 .c.o:
298 @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
299 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
300 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
301 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
302 @am__fastdepCC_FALSE@ $(COMPILE) -c $<
303
304 .c.obj:
305 @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
306 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
307 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
308 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
309 @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
310
311 .c.lo:
312 @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
313 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
314 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
315 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
316 @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
317
318 pyaff_la-pyaff.lo: pyaff.c
319 @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pyaff_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pyaff_la-pyaff.lo -MD -MP -MF $(DEPDIR)/pyaff_la-pyaff.Tpo -c -o pyaff_la-pyaff.lo `test -f 'pyaff.c' || echo '$(srcdir)/'`pyaff.c
320 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/pyaff_la-pyaff.Tpo $(DEPDIR)/pyaff_la-pyaff.Plo
321 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pyaff.c' object='pyaff_la-pyaff.lo' libtool=yes @AMDEPBACKSLASH@
322 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
323 @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pyaff_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pyaff_la-pyaff.lo `test -f 'pyaff.c' || echo '$(srcdir)/'`pyaff.c
324
325 mostlyclean-libtool:
326 -rm -f *.lo
327
328 clean-libtool:
329 -rm -rf .libs _libs
330
331 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
332 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
333 unique=`for i in $$list; do \
334 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
335 done | \
336 $(AWK) ' { files[$$0] = 1; } \
337 END { for (i in files) print i; }'`; \
338 mkid -fID $$unique
339 tags: TAGS
340
341 TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
342 $(TAGS_FILES) $(LISP)
343 tags=; \
344 here=`pwd`; \
345 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
346 unique=`for i in $$list; do \
347 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
348 done | \
349 $(AWK) ' { files[$$0] = 1; } \
350 END { for (i in files) print i; }'`; \
351 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
352 test -n "$$unique" || unique=$$empty_fix; \
353 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
354 $$tags $$unique; \
355 fi
356 ctags: CTAGS
357 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
358 $(TAGS_FILES) $(LISP)
359 tags=; \
360 here=`pwd`; \
361 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
362 unique=`for i in $$list; do \
363 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
364 done | \
365 $(AWK) ' { files[$$0] = 1; } \
366 END { for (i in files) print i; }'`; \
367 test -z "$(CTAGS_ARGS)$$tags$$unique" \
368 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
369 $$tags $$unique
370
371 GTAGS:
372 here=`$(am__cd) $(top_builddir) && pwd` \
373 && cd $(top_srcdir) \
374 && gtags -i $(GTAGS_ARGS) $$here
375
376 distclean-tags:
377 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
378
379 distdir: $(DISTFILES)
380 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
381 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
382 list='$(DISTFILES)'; \
383 dist_files=`for file in $$list; do echo $$file; done | \
384 sed -e "s|^$$srcdirstrip/||;t" \
385 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
386 case $$dist_files in \
387 */*) $(MKDIR_P) `echo "$$dist_files" | \
388 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
389 sort -u` ;; \
390 esac; \
391 for file in $$dist_files; do \
392 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
393 if test -d $$d/$$file; then \
394 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
395 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
396 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
397 fi; \
398 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
399 else \
400 test -f $(distdir)/$$file \
401 || cp -p $$d/$$file $(distdir)/$$file \
402 || exit 1; \
403 fi; \
404 done
405 check-am: all-am
406 check: check-am
407 all-am: Makefile $(LTLIBRARIES)
408 installdirs:
409 for dir in "$(DESTDIR)$(pyexecdir)"; do \
410 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
411 done
412 install: install-am
413 install-exec: install-exec-am
414 install-data: install-data-am
415 uninstall: uninstall-am
416
417 install-am: all-am
418 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
419
420 installcheck: installcheck-am
421 install-strip:
422 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
423 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
424 `test -z '$(STRIP)' || \
425 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
426 mostlyclean-generic:
427
428 clean-generic:
429
430 distclean-generic:
431 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
432
433 maintainer-clean-generic:
434 @echo "This command is intended for maintainers to use"
435 @echo "it deletes files that may require special tools to rebuild."
436 clean: clean-am
437
438 clean-am: clean-generic clean-libtool clean-pyexecLTLIBRARIES \
439 mostlyclean-am
440
441 distclean: distclean-am
442 -rm -rf ./$(DEPDIR)
443 -rm -f Makefile
444 distclean-am: clean-am distclean-compile distclean-generic \
445 distclean-tags
446
447 dvi: dvi-am
448
449 dvi-am:
450
451 html: html-am
452
453 info: info-am
454
455 info-am:
456
457 install-data-am:
458
459 install-dvi: install-dvi-am
460
461 install-exec-am: install-pyexecLTLIBRARIES
462
463 install-html: install-html-am
464
465 install-info: install-info-am
466
467 install-man:
468
469 install-pdf: install-pdf-am
470
471 install-ps: install-ps-am
472
473 installcheck-am:
474
475 maintainer-clean: maintainer-clean-am
476 -rm -rf ./$(DEPDIR)
477 -rm -f Makefile
478 maintainer-clean-am: distclean-am maintainer-clean-generic
479
480 mostlyclean: mostlyclean-am
481
482 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
483 mostlyclean-libtool
484
485 pdf: pdf-am
486
487 pdf-am:
488
489 ps: ps-am
490
491 ps-am:
492
493 uninstall-am: uninstall-pyexecLTLIBRARIES
494
495 .MAKE: install-am install-strip
496
497 .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
498 clean-libtool clean-pyexecLTLIBRARIES ctags distclean \
499 distclean-compile distclean-generic distclean-libtool \
500 distclean-tags distdir dvi dvi-am html html-am info info-am \
501 install install-am install-data install-data-am install-dvi \
502 install-dvi-am install-exec install-exec-am install-html \
503 install-html-am install-info install-info-am install-man \
504 install-pdf install-pdf-am install-ps install-ps-am \
505 install-pyexecLTLIBRARIES install-strip installcheck \
506 installcheck-am installdirs maintainer-clean \
507 maintainer-clean-generic mostlyclean mostlyclean-compile \
508 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
509 tags uninstall uninstall-am uninstall-pyexecLTLIBRARIES
510
511 # Tell versions [3.59,3.63) of GNU make to not export all variables.
512 # Otherwise a system limit (for SysV at least) may be exceeded.
513 .NOEXPORT:
0 Metadata-Version: 1.0
1 Name: PyAFF
2 Version: 0.1
3 Summary: Python wrapper for AFFLIB
4 Home-page: www.pyflag.net
5 Author: David Collett
6 Author-email: david.collett@gmail.com
7 License: GPL
8 Description: UNKNOWN
9 Platform: UNKNOWN
0 ==================================
1 PyAFF - Python bindings for AFFLIB
2 ==================================
3
4 These bindings currently support a read-only file-like interface to AFFLIB and
5 basic metadata accessor functions. The binding is not currently complete.
6
7 --------
8 BUILDING
9 --------
10
11 python setup.py build
12 python setup.py install
13
14 -----
15 USAGE
16 -----
17
18 Basic usage example:
19
20 #/usr/bin/python
21 import pyaff
22
23 fd = pyaff("diskimage.aff")
24 data = fd.read(1000)
25 fd.seek(0, SEEK_SET)
26
27 print fd.get_seg_names()
28 print fd.get_seg("afflib_version")
29
0 /******************************************************
1 * Copyright 2008: David Collett <david.collett@gmail.com>
2
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public License
5 * (LGPL) as published by the Free Software Foundation; either version
6 * 3 of the License as of 29 June 2007, or (at your option) any later
7 * version.
8 *
9 * See http://www.gnu.org/licenses/lgpl.txt
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02
19 * -1307, USA.
20 ****************************************************/
21
22 #include "Python.h"
23 #include "lib/afflib.h"
24
25 #include <string.h>
26 #include <stdlib.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <fcntl.h>
30
31 /******************************************************************
32 * pyaff - afflib python binding
33 * ***************************************************************/
34
35 typedef struct {
36 PyObject_HEAD
37 AFFILE *af;
38 uint64_t size;
39 } affile;
40
41 static void affile_dealloc(affile *self);
42 static int affile_init(affile *self, PyObject *args, PyObject *kwds);
43 static PyObject *affile_read(affile *self, PyObject *args, PyObject *kwds);
44 static PyObject *affile_seek(affile *self, PyObject *args, PyObject *kwds);
45 static PyObject *affile_get_seg(affile *self, PyObject *args, PyObject *kwds);
46 static PyObject *affile_get_seg_names(affile *self);
47 static PyObject *affile_tell(affile *self);
48 static PyObject *affile_close(affile *self);
49
50 static PyMethodDef affile_methods[] = {
51 {"read", (PyCFunction)affile_read, METH_VARARGS|METH_KEYWORDS,
52 "Read data from file" },
53 {"seek", (PyCFunction)affile_seek, METH_VARARGS|METH_KEYWORDS,
54 "Seek within a file" },
55 {"get_seg", (PyCFunction)affile_get_seg, METH_VARARGS|METH_KEYWORDS,
56 "Retrieve an aff segment by name" },
57 {"get_seg_names", (PyCFunction)affile_get_seg_names, METH_NOARGS,
58 "Retrieve a list of segments present" },
59 {"tell", (PyCFunction)affile_tell, METH_NOARGS,
60 "Return possition within file" },
61 {"close", (PyCFunction)affile_close, METH_NOARGS,
62 "Close the file" },
63 {NULL} /* Sentinel */
64 };
65
66 static PyTypeObject affileType = {
67 PyObject_HEAD_INIT(NULL)
68 0, /* ob_size */
69 "pyaff.affile", /* tp_name */
70 sizeof(affile), /* tp_basicsize */
71 0, /* tp_itemsize */
72 (destructor)affile_dealloc,/* tp_dealloc */
73 0, /* tp_print */
74 0, /* tp_getattr */
75 0, /* tp_setattr */
76 0, /* tp_compare */
77 0, /* tp_repr */
78 0, /* tp_as_number */
79 0, /* tp_as_sequence */
80 0, /* tp_as_mapping */
81 0, /* tp_hash */
82 0, /* tp_call */
83 0, /* tp_str */
84 0, /* tp_getattro */
85 0, /* tp_setattro */
86 0, /* tp_as_buffer */
87 Py_TPFLAGS_DEFAULT, /* tp_flags */
88 "afflib File Object", /* tp_doc */
89 0, /* tp_traverse */
90 0, /* tp_clear */
91 0, /* tp_richcompare */
92 0, /* tp_weaklistoffset */
93 0, /* tp_iter */
94 0, /* tp_iternext */
95 affile_methods, /* tp_methods */
96 0, /* tp_members */
97 0, /* tp_getset */
98 0, /* tp_base */
99 0, /* tp_dict */
100 0, /* tp_descr_get */
101 0, /* tp_descr_set */
102 0, /* tp_dictoffset */
103 (initproc)affile_init, /* tp_init */
104 0, /* tp_alloc */
105 0, /* tp_new */
106 };
107
108 static void
109 affile_dealloc(affile *self) {
110 self->ob_type->tp_free((PyObject*)self);
111 }
112
113 static int
114 affile_init(affile *self, PyObject *args, PyObject *kwds) {
115 char *filename;
116 static char *kwlist[] = {"filename", NULL};
117
118 self->size = 0;
119
120 if(!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &filename))
121 return -1;
122
123 self->af = af_open(filename, O_RDONLY, 0);
124 if(self->af == NULL) {
125 PyErr_Format(PyExc_IOError, "Failed to initialise afflib");
126 return -1;
127 }
128
129 self->size = af_get_imagesize(self->af);
130 return 0;
131 }
132
133 static PyObject *
134 affile_read(affile *self, PyObject *args, PyObject *kwds) {
135 int written;
136 PyObject *retdata;
137 int readlen=-1;
138
139 static char *kwlist[] = {"size", NULL};
140 if(!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &readlen))
141 return NULL;
142
143 if(readlen < 0 || readlen > self->size)
144 readlen = self->size;
145
146 retdata = PyString_FromStringAndSize(NULL, readlen);
147 written = af_read(self->af, (unsigned char *)PyString_AsString(retdata), readlen);
148
149 if(readlen != written) {
150 return PyErr_Format(PyExc_IOError, "Failed to read all data: wanted %d, got %d", readlen, written);
151 }
152
153 return retdata;
154 }
155
156 static PyObject *
157 affile_seek(affile *self, PyObject *args, PyObject *kwds) {
158 int64_t offset=0;
159 int whence=0;
160
161 static char *kwlist[] = {"offset", "whence", NULL};
162 if(!PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwlist,
163 &offset, &whence))
164 return NULL;
165
166 if(af_seek(self->af, offset, whence) < 0)
167 return PyErr_Format(PyExc_IOError, "libaff_seek_offset failed");
168
169 Py_RETURN_NONE;
170 }
171
172 static PyObject *
173 affile_tell(affile *self) {
174 return PyLong_FromLongLong(af_tell(self->af));
175 }
176
177 static PyObject *
178 affile_close(affile *self) {
179 af_close(self->af);
180 Py_RETURN_NONE;
181 }
182
183 static PyObject *affile_get_seg(affile *self, PyObject *args, PyObject *kwds) {
184 PyObject *retdata;
185 char *buf;
186 size_t buflen=0;
187 char *segname=NULL;
188 static char *kwlist[] = {"segname", NULL};
189
190 if(!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &segname))
191 return NULL;
192
193 // first get the size
194 if(af_get_seg(self->af, segname, 0, 0, &buflen) != 0) {
195 return PyErr_Format(PyExc_IOError, "error reading libaff segment\n");
196 }
197
198 // allocate a string to return data in
199 retdata = PyString_FromStringAndSize(NULL, buflen);
200 buf = PyString_AsString(retdata);
201
202 if(af_get_seg(self->af, segname, 0, (unsigned char *)buf, &buflen) != 0) {
203 Py_DECREF(retdata);
204 return PyErr_Format(PyExc_IOError, "error reading libaff segment\n");
205 }
206
207 return retdata;
208 }
209
210 static PyObject *affile_get_seg_names(affile *self) {
211 PyObject *headers, *tmp;
212 char segname[AF_MAX_NAME_LEN];
213
214 af_rewind_seg(self->af);
215 headers = PyList_New(0);
216
217 while(af_get_next_seg(self->af, segname, sizeof(segname), 0, 0, 0) == 0){
218 tmp = PyString_FromString(segname);
219 PyList_Append(headers, tmp);
220 Py_DECREF(tmp);
221 }
222
223 return headers;
224 }
225
226 static PyObject *pyaff_open(PyObject *self, PyObject *args, PyObject *kwds) {
227 int ret;
228 affile *file;
229 PyObject *files, *fileargs, *filekwds;
230 static char *kwlist[] = {"filename", NULL};
231
232 if(!PyArg_ParseTupleAndKeywords(args, kwds, "O", kwlist, &files))
233 return NULL;
234
235 /* create an affile object and return it */
236 fileargs = PyTuple_New(0);
237 filekwds = Py_BuildValue("{sO}", "filename", files);
238 if(!filekwds) return NULL;
239
240 file = PyObject_New(affile, &affileType);
241 ret = affile_init(file, fileargs, filekwds);
242 Py_DECREF(fileargs);
243 Py_DECREF(filekwds);
244
245 if(ret == -1) {
246 Py_DECREF(file);
247 return NULL;
248 }
249 return (PyObject *)file;
250 }
251
252 /* these are the module methods */
253 static PyMethodDef pyaff_methods[] = {
254 {"open", (PyCFunction)pyaff_open, METH_VARARGS|METH_KEYWORDS,
255 "Open afflib file (or set of files)" },
256 {NULL, NULL, 0, NULL} /* Sentinel */
257 };
258
259 #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
260 #define PyMODINIT_FUNC void
261 #endif
262 PyMODINIT_FUNC
263 initpyaff(void)
264 {
265 PyObject* m;
266
267 /* create module */
268 m = Py_InitModule3("pyaff", pyaff_methods, "Python libaff module.");
269
270 /* setup affile type */
271 affileType.tp_new = PyType_GenericNew;
272 if (PyType_Ready(&affileType) < 0)
273 return;
274
275 Py_INCREF(&affileType);
276 PyModule_AddObject(m, "affile", (PyObject *)&affileType);
277 }
278
0 from distutils.core import setup, Extension
1
2 pyaff = Extension('pyaff',
3 libraries = ['afflib'],
4 sources = ['pyaff.c'])
5
6 setup (name = 'PyAFF',
7 version = '0.1',
8 description = 'Python wrapper for AFFLIB',
9 author = 'David Collett',
10 author_email = 'david.collett@gmail.com',
11 url = 'www.pyflag.net',
12 license = "GPL",
13 ext_modules = [pyaff])
0 TESTS = test_decryption.sh
1 EXTRA_DIST = makeimage.cpp speedtests.py verify.py encrypted.aff encrypted.iso test_decryption.sh
2
3
0 # Makefile.in generated by automake 1.10 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 pkgdatadir = $(datadir)/@PACKAGE@
17 pkglibdir = $(libdir)/@PACKAGE@
18 pkgincludedir = $(includedir)/@PACKAGE@
19 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
20 install_sh_DATA = $(install_sh) -c -m 644
21 install_sh_PROGRAM = $(install_sh) -c
22 install_sh_SCRIPT = $(install_sh) -c
23 INSTALL_HEADER = $(INSTALL_DATA)
24 transform = $(program_transform_name)
25 NORMAL_INSTALL = :
26 PRE_INSTALL = :
27 POST_INSTALL = :
28 NORMAL_UNINSTALL = :
29 PRE_UNINSTALL = :
30 POST_UNINSTALL = :
31 build_triplet = @build@
32 host_triplet = @host@
33 subdir = tests
34 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
35 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
36 am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
37 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
38 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
39 $(ACLOCAL_M4)
40 mkinstalldirs = $(install_sh) -d
41 CONFIG_HEADER = $(top_builddir)/affconfig.h
42 CONFIG_CLEAN_FILES =
43 SOURCES =
44 DIST_SOURCES =
45 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
46 ACLOCAL = @ACLOCAL@
47 AFFUSE_BIN = @AFFUSE_BIN@
48 ALLOCA = @ALLOCA@
49 AMTAR = @AMTAR@
50 AR = @AR@
51 AUTOCONF = @AUTOCONF@
52 AUTOHEADER = @AUTOHEADER@
53 AUTOMAKE = @AUTOMAKE@
54 AWK = @AWK@
55 CC = @CC@
56 CCDEPMODE = @CCDEPMODE@
57 CFLAGS = @CFLAGS@
58 CPP = @CPP@
59 CPPFLAGS = @CPPFLAGS@
60 CURL_CONFIG = @CURL_CONFIG@
61 CXX = @CXX@
62 CXXCPP = @CXXCPP@
63 CXXDEPMODE = @CXXDEPMODE@
64 CXXFLAGS = @CXXFLAGS@
65 CYGPATH_W = @CYGPATH_W@
66 DEFS = @DEFS@
67 DEPDIR = @DEPDIR@
68 DSYMUTIL = @DSYMUTIL@
69 DUMPBIN = @DUMPBIN@
70 ECHO_C = @ECHO_C@
71 ECHO_N = @ECHO_N@
72 ECHO_T = @ECHO_T@
73 EGREP = @EGREP@
74 EXEEXT = @EXEEXT@
75 FGREP = @FGREP@
76 FUSE_CFLAGS = @FUSE_CFLAGS@
77 FUSE_LIBS = @FUSE_LIBS@
78 GREP = @GREP@
79 INSTALL = @INSTALL@
80 INSTALL_DATA = @INSTALL_DATA@
81 INSTALL_PROGRAM = @INSTALL_PROGRAM@
82 INSTALL_SCRIPT = @INSTALL_SCRIPT@
83 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
84 LD = @LD@
85 LDFLAGS = @LDFLAGS@
86 LIBOBJS = @LIBOBJS@
87 LIBS = @LIBS@
88 LIBTOOL = @LIBTOOL@
89 LIPO = @LIPO@
90 LN_S = @LN_S@
91 LTLIBOBJS = @LTLIBOBJS@
92 MAINT = @MAINT@
93 MAKEINFO = @MAKEINFO@
94 MKDIR_P = @MKDIR_P@
95 NM = @NM@
96 NMEDIT = @NMEDIT@
97 OBJEXT = @OBJEXT@
98 OTOOL = @OTOOL@
99 OTOOL64 = @OTOOL64@
100 PACKAGE = @PACKAGE@
101 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
102 PACKAGE_NAME = @PACKAGE_NAME@
103 PACKAGE_STRING = @PACKAGE_STRING@
104 PACKAGE_TARNAME = @PACKAGE_TARNAME@
105 PACKAGE_VERSION = @PACKAGE_VERSION@
106 PATH_SEPARATOR = @PATH_SEPARATOR@
107 PTHREAD_CC = @PTHREAD_CC@
108 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
109 PTHREAD_LIBS = @PTHREAD_LIBS@
110 PYTHON = @PYTHON@
111 PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
112 PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
113 PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
114 PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
115 PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
116 PYTHON_PLATFORM = @PYTHON_PLATFORM@
117 PYTHON_PREFIX = @PYTHON_PREFIX@
118 PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
119 PYTHON_VERSION = @PYTHON_VERSION@
120 RANLIB = @RANLIB@
121 S3_BIN = @S3_BIN@
122 SED = @SED@
123 SET_MAKE = @SET_MAKE@
124 SHELL = @SHELL@
125 STRIP = @STRIP@
126 VERSION = @VERSION@
127 abs_builddir = @abs_builddir@
128 abs_srcdir = @abs_srcdir@
129 abs_top_builddir = @abs_top_builddir@
130 abs_top_srcdir = @abs_top_srcdir@
131 ac_ct_CC = @ac_ct_CC@
132 ac_ct_CXX = @ac_ct_CXX@
133 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
134 ac_prefix_program = @ac_prefix_program@
135 acx_pthread_config = @acx_pthread_config@
136 am__include = @am__include@
137 am__leading_dot = @am__leading_dot@
138 am__quote = @am__quote@
139 am__tar = @am__tar@
140 am__untar = @am__untar@
141 bindir = @bindir@
142 build = @build@
143 build_alias = @build_alias@
144 build_cpu = @build_cpu@
145 build_os = @build_os@
146 build_vendor = @build_vendor@
147 builddir = @builddir@
148 datadir = @datadir@
149 datarootdir = @datarootdir@
150 docdir = @docdir@
151 dvidir = @dvidir@
152 exec_prefix = @exec_prefix@
153 host = @host@
154 host_alias = @host_alias@
155 host_cpu = @host_cpu@
156 host_os = @host_os@
157 host_vendor = @host_vendor@
158 htmldir = @htmldir@
159 includedir = @includedir@
160 infodir = @infodir@
161 install_sh = @install_sh@
162 libdir = @libdir@
163 libexecdir = @libexecdir@
164 localedir = @localedir@
165 localstatedir = @localstatedir@
166 lt_ECHO = @lt_ECHO@
167 mandir = @mandir@
168 mkdir_p = @mkdir_p@
169 oldincludedir = @oldincludedir@
170 pdfdir = @pdfdir@
171 pkgpyexecdir = @pkgpyexecdir@
172 pkgpythondir = @pkgpythondir@
173 prefix = @prefix@
174 program_transform_name = @program_transform_name@
175 psdir = @psdir@
176 pyexecdir = @pyexecdir@
177 pythondir = @pythondir@
178 sbindir = @sbindir@
179 sharedstatedir = @sharedstatedir@
180 srcdir = @srcdir@
181 sysconfdir = @sysconfdir@
182 target_alias = @target_alias@
183 top_builddir = @top_builddir@
184 top_srcdir = @top_srcdir@
185 TESTS = test_decryption.sh
186 EXTRA_DIST = makeimage.cpp speedtests.py verify.py encrypted.aff encrypted.iso test_decryption.sh
187 all: all-am
188
189 .SUFFIXES:
190 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
191 @for dep in $?; do \
192 case '$(am__configure_deps)' in \
193 *$$dep*) \
194 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
195 && exit 0; \
196 exit 1;; \
197 esac; \
198 done; \
199 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
200 cd $(top_srcdir) && \
201 $(AUTOMAKE) --gnu tests/Makefile
202 .PRECIOUS: Makefile
203 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
204 @case '$?' in \
205 *config.status*) \
206 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
207 *) \
208 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
209 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
210 esac;
211
212 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
213 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
214
215 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
216 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
217 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
218 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
219
220 mostlyclean-libtool:
221 -rm -f *.lo
222
223 clean-libtool:
224 -rm -rf .libs _libs
225 tags: TAGS
226 TAGS:
227
228 ctags: CTAGS
229 CTAGS:
230
231
232 check-TESTS: $(TESTS)
233 @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
234 srcdir=$(srcdir); export srcdir; \
235 list=' $(TESTS) '; \
236 if test -n "$$list"; then \
237 for tst in $$list; do \
238 if test -f ./$$tst; then dir=./; \
239 elif test -f $$tst; then dir=; \
240 else dir="$(srcdir)/"; fi; \
241 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
242 all=`expr $$all + 1`; \
243 case " $(XFAIL_TESTS) " in \
244 *$$ws$$tst$$ws*) \
245 xpass=`expr $$xpass + 1`; \
246 failed=`expr $$failed + 1`; \
247 echo "XPASS: $$tst"; \
248 ;; \
249 *) \
250 echo "PASS: $$tst"; \
251 ;; \
252 esac; \
253 elif test $$? -ne 77; then \
254 all=`expr $$all + 1`; \
255 case " $(XFAIL_TESTS) " in \
256 *$$ws$$tst$$ws*) \
257 xfail=`expr $$xfail + 1`; \
258 echo "XFAIL: $$tst"; \
259 ;; \
260 *) \
261 failed=`expr $$failed + 1`; \
262 echo "FAIL: $$tst"; \
263 ;; \
264 esac; \
265 else \
266 skip=`expr $$skip + 1`; \
267 echo "SKIP: $$tst"; \
268 fi; \
269 done; \
270 if test "$$failed" -eq 0; then \
271 if test "$$xfail" -eq 0; then \
272 banner="All $$all tests passed"; \
273 else \
274 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
275 fi; \
276 else \
277 if test "$$xpass" -eq 0; then \
278 banner="$$failed of $$all tests failed"; \
279 else \
280 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
281 fi; \
282 fi; \
283 dashes="$$banner"; \
284 skipped=""; \
285 if test "$$skip" -ne 0; then \
286 skipped="($$skip tests were not run)"; \
287 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
288 dashes="$$skipped"; \
289 fi; \
290 report=""; \
291 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
292 report="Please report to $(PACKAGE_BUGREPORT)"; \
293 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
294 dashes="$$report"; \
295 fi; \
296 dashes=`echo "$$dashes" | sed s/./=/g`; \
297 echo "$$dashes"; \
298 echo "$$banner"; \
299 test -z "$$skipped" || echo "$$skipped"; \
300 test -z "$$report" || echo "$$report"; \
301 echo "$$dashes"; \
302 test "$$failed" -eq 0; \
303 else :; fi
304
305 distdir: $(DISTFILES)
306 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
307 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
308 list='$(DISTFILES)'; \
309 dist_files=`for file in $$list; do echo $$file; done | \
310 sed -e "s|^$$srcdirstrip/||;t" \
311 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
312 case $$dist_files in \
313 */*) $(MKDIR_P) `echo "$$dist_files" | \
314 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
315 sort -u` ;; \
316 esac; \
317 for file in $$dist_files; do \
318 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
319 if test -d $$d/$$file; then \
320 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
321 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
322 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
323 fi; \
324 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
325 else \
326 test -f $(distdir)/$$file \
327 || cp -p $$d/$$file $(distdir)/$$file \
328 || exit 1; \
329 fi; \
330 done
331 check-am: all-am
332 $(MAKE) $(AM_MAKEFLAGS) check-TESTS
333 check: check-am
334 all-am: Makefile
335 installdirs:
336 install: install-am
337 install-exec: install-exec-am
338 install-data: install-data-am
339 uninstall: uninstall-am
340
341 install-am: all-am
342 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
343
344 installcheck: installcheck-am
345 install-strip:
346 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
347 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
348 `test -z '$(STRIP)' || \
349 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
350 mostlyclean-generic:
351
352 clean-generic:
353
354 distclean-generic:
355 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
356
357 maintainer-clean-generic:
358 @echo "This command is intended for maintainers to use"
359 @echo "it deletes files that may require special tools to rebuild."
360 clean: clean-am
361
362 clean-am: clean-generic clean-libtool mostlyclean-am
363
364 distclean: distclean-am
365 -rm -f Makefile
366 distclean-am: clean-am distclean-generic
367
368 dvi: dvi-am
369
370 dvi-am:
371
372 html: html-am
373
374 info: info-am
375
376 info-am:
377
378 install-data-am:
379
380 install-dvi: install-dvi-am
381
382 install-exec-am:
383
384 install-html: install-html-am
385
386 install-info: install-info-am
387
388 install-man:
389
390 install-pdf: install-pdf-am
391
392 install-ps: install-ps-am
393
394 installcheck-am:
395
396 maintainer-clean: maintainer-clean-am
397 -rm -f Makefile
398 maintainer-clean-am: distclean-am maintainer-clean-generic
399
400 mostlyclean: mostlyclean-am
401
402 mostlyclean-am: mostlyclean-generic mostlyclean-libtool
403
404 pdf: pdf-am
405
406 pdf-am:
407
408 ps: ps-am
409
410 ps-am:
411
412 uninstall-am:
413
414 .MAKE: install-am install-strip
415
416 .PHONY: all all-am check check-TESTS check-am clean clean-generic \
417 clean-libtool distclean distclean-generic distclean-libtool \
418 distdir dvi dvi-am html html-am info info-am install \
419 install-am install-data install-data-am install-dvi \
420 install-dvi-am install-exec install-exec-am install-html \
421 install-html-am install-info install-info-am install-man \
422 install-pdf install-pdf-am install-ps install-ps-am \
423 install-strip installcheck installcheck-am installdirs \
424 maintainer-clean maintainer-clean-generic mostlyclean \
425 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
426 uninstall uninstall-am
427
428 # Tell versions [3.59,3.63) of GNU make to not export all variables.
429 # Otherwise a system limit (for SysV at least) may be exceeded.
430 .NOEXPORT:
Binary diff not shown
0 AFF decryption appears to work.
0 /*
1 * makeimage.cpp:
2 *
3 * Make an image with a given number of sectors.
4 */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <err.h>
10
11 const char *progname = "makeimage";
12
13 void usage()
14 {
15 errx(1,"usage: %s file blockcount\n",progname);
16 }
17
18 int main(int argc,char **argv)
19 {
20 if(argc!=3) usage();
21
22 int count = atoi(argv[2]);
23 char buf[512];
24
25 FILE *out = fopen(argv[1],"wb");
26 if(!out) err(1,"fopen(%s)",argv[1]);
27
28 memset(buf,' ',sizeof(buf));
29 buf[511] = '\000';
30 for(int i=0;i<count;i++){
31 sprintf(buf,"Block %d\n",i);
32 fwrite(buf,sizeof(buf),1,out);
33 }
34 fclose(out);
35 }
0 #
1 # python speed test jig.
2 # Note: this currently doesn't work.
3 #
4
5 opt_megabytes = 4096
6 min_range = 7
7 max_range = 20
8
9 #max_range = 14
10
11 import time,re,os
12
13
14 #def do_command(cmd):
15 # """ Run a command and return the clock time """
16 # print cmd
17 # start = time.time()
18 # os.system(cmd)
19 # end = time.time()
20 # return end-start
21
22 def dd_test(infile="/dev/zero",outfile="/dev/null",bs=16384):
23 transfer = 1024*1024*opt_megabytes
24 count = transfer / bs
25 res = re.compile("(\d+) bytes/sec")
26 cmd = "dd if=%s of=%s bs=%d count=%d 2>&1" % (infile,outfile,bs,count)
27 print cmd
28 for line in os.popen(cmd,"r"):
29 print "*",line
30 m = res.search(line)
31 if(m):
32 print "yum",m.group(1)
33 return int(m.group(1))
34 return False
35
36 def grep(fn,what):
37 import re
38 m = re.compile(what)
39 for line in open(fn,"r"):
40 if(m.search(line)): return line.strip()
41 return False
42
43 def dd_speed_tests():
44 cpu = grep("/var/run/dmesg.boot","CPU")
45 mem = grep("/var/run/dmesg.boot","real memory")
46
47 print "\n\nRunning write tests..."
48 block_sizes = []
49 for i in range(min_range,max_range):
50 block_sizes.append(2**i)
51
52 write_speeds = {}
53 for bs in block_sizes:
54 write_speeds[bs] = dd_test(outfile="speed.tmp",bs=bs) / 1000000.0
55
56 print "\n\nRunning read tests..."
57 read_speeds = {}
58 for bs in block_sizes:
59 read_speeds[bs] = dd_test(infile="speed.tmp",bs=bs) / 1000000.0
60
61 print "\n\n"
62 print cpu
63 print mem
64 print "Transfer Size: ",opt_megabytes,"MB"
65
66 def print_sorted(title,dict):
67 print title
68 print "bs=nn\t\tMBytes/sec"
69 keys = dict.keys()
70 keys.sort()
71 for k in keys:
72 print "%d\t\t%.2f" % (k,dict[k])
73
74 print_sorted("Write Results\ndd if=/dev/zero of=speed.tmp\n",write_speeds)
75 print_sorted("Read Results\ndd if=/speed.tmp of=/dev/null",read_speeds)
76
77
78 if(__name__=='__main__'):
79 dd_speed_tests()
0 #!/bin/sh
1 echo === VERIFY THAT WE CAN STILL DECRYPT encrypted.aff ===
2 unset AFFLIB_PASSPHRASE
3
4 if test "x$srcdir" = x; then
5 srcdir=.
6 fi
7
8 if ( ../tools/afcompare file://:password@/$srcdir/encrypted.aff $srcdir/encrypted.iso ) ; then
9 echo Verifies with correct decryption passphrase.
10 else
11 echo Does not verify with correct decryption passphrase.
12 exit 1
13 fi
14
15
16 echo This next afcompare should generate an error:
17 if ( ../tools/afcompare file://:wrongphrase@/$srcdir/encrypted.aff $srcdir/encrypted.iso ) ; then
18 echo Does not verify with correct decryption passphrase.
19 exit 1
20 else
21 echo Cannot verify with the wrong passphrase!
22 fi
23
24 echo ALL TESTS PASS
25 exit 0
26
27
28
29
0 #!/usr/bin/python
1
2 import os,sys
3 d = "/tmp/"
4
5 def cmd(s):
6 print s
7 if(os.system(s)):
8 print "** TEST FAILED"
9 sys.exit(1)
10
11 def runtest(ext,maxsize):
12 iso = d + "image.iso"
13 iso2 = d + "image2.iso"
14 i1 = d + "image1." + ext
15 i2 = d + "image2." + ext
16 cmd("rm -rf %s %s %s %s" % (iso,iso2,i1,i2))
17 cmd("./makeimage %s 100000",(iso))
18 cmd("../aimage/aimage %s -q -E %s %s" % (maxsize,iso,i1))
19 cmd("../tools/afconvert %s -o %s %s" % (maxsize,i2,iso))
20 cmd("../tools/afinfo -mS %s" % (i1))
21 cmd("../tools/afinfo -mS %s" % (i2))
22 cmd("../tools/afcompare %s %s" % (iso,i1))
23 cmd("../tools/afcompare %s %s" % (iso,i2))
24 cmd("../tools/afconvert -r -o %s %s" % (iso,i1))
25 cmd("../tools/afcat %s > %s" % (i2,iso2))
26 cmd("cmp %s %s" % (iso,iso2))
27 cmd("rm -rf %s %s %s %s" % (iso,iso2,i1,i2))
28
29
30 if(__name__=='__main__'):
31 runtest("aff","")
32 runtest("aff","-M33554432b")
33 runtest("afd","")
34 runtest("afd","-M33554432b")
35 runtest("afm","")
36 runtest("afm","-M33554432b")
37
0 bin_PROGRAMS = afcat afcompare afconvert afcopy afcrypto affix afinfo afsegment \
1 afstats afverify afxml affuse afrecover afsign afdiskprint
2
3 EXTRA_DIST = test_make_random_iso.sh test_crypto.sh test_signing.sh test_recovery.sh \
4 test_passphrase.sh test_afsegment.sh
5
6 TESTS = test_signing.sh test_recovery.sh test_passphrase.sh test_afsegment.sh test_crypto.sh
7
8 # See http://www.gnu.org/software/libtool/manual.html # Using-Automake
9
10 AM_LDFLAGS = -static # staticly link our tools (easier debugging)
11
12 afcat_SOURCES = afcat.cpp
13
14 afcrypto_SOURCES = afcrypto.cpp
15 afcompare_SOURCES = afcompare.cpp unix4win32.h
16 afconvert_SOURCES = afconvert.cpp unix4win32.h
17 afcopy_SOURCES = afcopy.cpp unix4win32.h aff_bom.h aff_bom.cpp
18 afdiskprint_SOURCES = afdiskprint.cpp unix4win32.h hashextent.h
19 affix_SOURCES = affix.cpp unix4win32.h
20 affuse_SOURCES = affuse.c
21 afinfo_SOURCES = afinfo.cpp unix4win32.h
22 afrecover_SOURCES = afrecover.cpp unix4win32.h
23 afsegment_SOURCES = afsegment.cpp
24 afsign_SOURCES = afsign.cpp aff_bom.h aff_bom.cpp
25 afstats_SOURCES = afstats.cpp
26 afverify_SOURCES = afverify.cpp aff_bom.h aff_bom.cpp
27 afxml_SOURCES = afxml.cpp unix4win32.h
28
29 INCLUDES = -I@top_srcdir@/lib/
30 LDADD = @top_builddir@/lib/libafflib.la
31
32 affuse_CFLAGS = @FUSE_CFLAGS@
33 affuse_LDADD = @top_builddir@/lib/libafflib.la @FUSE_LIBS@
34 affuse_LINK = $(CXXLINK)
35
36 CLEANFILES = deskclerk.pem test_password.sh blank.iso archives.pem password_signed.aff signed.aff \
37 random.iso agent.pem r3.iso random*.aff blank.aff blanke.aff words r3.iso evidence1.aff
0 # Makefile.in generated by automake 1.10 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15
16 VPATH = @srcdir@
17 pkgdatadir = $(datadir)/@PACKAGE@
18 pkglibdir = $(libdir)/@PACKAGE@
19 pkgincludedir = $(includedir)/@PACKAGE@
20 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
21 install_sh_DATA = $(install_sh) -c -m 644
22 install_sh_PROGRAM = $(install_sh) -c
23 install_sh_SCRIPT = $(install_sh) -c
24 INSTALL_HEADER = $(INSTALL_DATA)
25 transform = $(program_transform_name)
26 NORMAL_INSTALL = :
27 PRE_INSTALL = :
28 POST_INSTALL = :
29 NORMAL_UNINSTALL = :
30 PRE_UNINSTALL = :
31 POST_UNINSTALL = :
32 build_triplet = @build@
33 host_triplet = @host@
34 bin_PROGRAMS = afcat$(EXEEXT) afcompare$(EXEEXT) afconvert$(EXEEXT) \
35 afcopy$(EXEEXT) afcrypto$(EXEEXT) affix$(EXEEXT) \
36 afinfo$(EXEEXT) afsegment$(EXEEXT) afstats$(EXEEXT) \
37 afverify$(EXEEXT) afxml$(EXEEXT) affuse$(EXEEXT) \
38 afrecover$(EXEEXT) afsign$(EXEEXT) afdiskprint$(EXEEXT)
39 subdir = tools
40 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
41 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
42 am__aclocal_m4_deps = $(top_srcdir)/acx_pthread.m4 \
43 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
44 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
45 $(ACLOCAL_M4)
46 mkinstalldirs = $(install_sh) -d
47 CONFIG_HEADER = $(top_builddir)/affconfig.h
48 CONFIG_CLEAN_FILES =
49 am__installdirs = "$(DESTDIR)$(bindir)"
50 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
51 PROGRAMS = $(bin_PROGRAMS)
52 am_afcat_OBJECTS = afcat.$(OBJEXT)
53 afcat_OBJECTS = $(am_afcat_OBJECTS)
54 afcat_LDADD = $(LDADD)
55 afcat_DEPENDENCIES = @top_builddir@/lib/libafflib.la
56 am_afcompare_OBJECTS = afcompare.$(OBJEXT)
57 afcompare_OBJECTS = $(am_afcompare_OBJECTS)
58 afcompare_LDADD = $(LDADD)
59 afcompare_DEPENDENCIES = @top_builddir@/lib/libafflib.la
60 am_afconvert_OBJECTS = afconvert.$(OBJEXT)
61 afconvert_OBJECTS = $(am_afconvert_OBJECTS)
62 afconvert_LDADD = $(LDADD)
63 afconvert_DEPENDENCIES = @top_builddir@/lib/libafflib.la
64 am_afcopy_OBJECTS = afcopy.$(OBJEXT) aff_bom.$(OBJEXT)
65 afcopy_OBJECTS = $(am_afcopy_OBJECTS)
66 afcopy_LDADD = $(LDADD)
67 afcopy_DEPENDENCIES = @top_builddir@/lib/libafflib.la
68 am_afcrypto_OBJECTS = afcrypto.$(OBJEXT)
69 afcrypto_OBJECTS = $(am_afcrypto_OBJECTS)
70 afcrypto_LDADD = $(LDADD)
71 afcrypto_DEPENDENCIES = @top_builddir@/lib/libafflib.la
72 am_afdiskprint_OBJECTS = afdiskprint.$(OBJEXT)
73 afdiskprint_OBJECTS = $(am_afdiskprint_OBJECTS)
74 afdiskprint_LDADD = $(LDADD)
75 afdiskprint_DEPENDENCIES = @top_builddir@/lib/libafflib.la
76 am_affix_OBJECTS = affix.$(OBJEXT)
77 affix_OBJECTS = $(am_affix_OBJECTS)
78 affix_LDADD = $(LDADD)
79 affix_DEPENDENCIES = @top_builddir@/lib/libafflib.la
80 am_affuse_OBJECTS = affuse-affuse.$(OBJEXT)
81 affuse_OBJECTS = $(am_affuse_OBJECTS)
82 affuse_DEPENDENCIES = @top_builddir@/lib/libafflib.la
83 am_afinfo_OBJECTS = afinfo.$(OBJEXT)
84 afinfo_OBJECTS = $(am_afinfo_OBJECTS)
85 afinfo_LDADD = $(LDADD)
86 afinfo_DEPENDENCIES = @top_builddir@/lib/libafflib.la
87 am_afrecover_OBJECTS = afrecover.$(OBJEXT)
88 afrecover_OBJECTS = $(am_afrecover_OBJECTS)
89 afrecover_LDADD = $(LDADD)
90 afrecover_DEPENDENCIES = @top_builddir@/lib/libafflib.la
91 am_afsegment_OBJECTS = afsegment.$(OBJEXT)
92 afsegment_OBJECTS = $(am_afsegment_OBJECTS)
93 afsegment_LDADD = $(LDADD)
94 afsegment_DEPENDENCIES = @top_builddir@/lib/libafflib.la
95 am_afsign_OBJECTS = afsign.$(OBJEXT) aff_bom.$(OBJEXT)
96 afsign_OBJECTS = $(am_afsign_OBJECTS)
97 afsign_LDADD = $(LDADD)
98 afsign_DEPENDENCIES = @top_builddir@/lib/libafflib.la
99 am_afstats_OBJECTS = afstats.$(OBJEXT)
100 afstats_OBJECTS = $(am_afstats_OBJECTS)
101 afstats_LDADD = $(LDADD)
102 afstats_DEPENDENCIES = @top_builddir@/lib/libafflib.la
103 am_afverify_OBJECTS = afverify.$(OBJEXT) aff_bom.$(OBJEXT)
104 afverify_OBJECTS = $(am_afverify_OBJECTS)
105 afverify_LDADD = $(LDADD)
106 afverify_DEPENDENCIES = @top_builddir@/lib/libafflib.la
107 am_afxml_OBJECTS = afxml.$(OBJEXT)
108 afxml_OBJECTS = $(am_afxml_OBJECTS)
109 afxml_LDADD = $(LDADD)
110 afxml_DEPENDENCIES = @top_builddir@/lib/libafflib.la
111 DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
112 depcomp = $(SHELL) $(top_srcdir)/depcomp
113 am__depfiles_maybe = depfiles
114 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
115 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
116 LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
117 --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
118 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
119 CCLD = $(CC)
120 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
121 --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
122 $(LDFLAGS) -o $@
123 CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
124 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
125 LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
126 --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
127 $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
128 CXXLD = $(CXX)
129 CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
130 --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
131 $(LDFLAGS) -o $@
132 SOURCES = $(afcat_SOURCES) $(afcompare_SOURCES) $(afconvert_SOURCES) \
133 $(afcopy_SOURCES) $(afcrypto_SOURCES) $(afdiskprint_SOURCES) \
134 $(affix_SOURCES) $(affuse_SOURCES) $(afinfo_SOURCES) \
135 $(afrecover_SOURCES) $(afsegment_SOURCES) $(afsign_SOURCES) \
136 $(afstats_SOURCES) $(afverify_SOURCES) $(afxml_SOURCES)
137 DIST_SOURCES = $(afcat_SOURCES) $(afcompare_SOURCES) \
138 $(afconvert_SOURCES) $(afcopy_SOURCES) $(afcrypto_SOURCES) \
139 $(afdiskprint_SOURCES) $(affix_SOURCES) $(affuse_SOURCES) \
140 $(afinfo_SOURCES) $(afrecover_SOURCES) $(afsegment_SOURCES) \
141 $(afsign_SOURCES) $(afstats_SOURCES) $(afverify_SOURCES) \
142 $(afxml_SOURCES)
143 ETAGS = etags
144 CTAGS = ctags
145 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
146 ACLOCAL = @ACLOCAL@
147 AFFUSE_BIN = @AFFUSE_BIN@
148 ALLOCA = @ALLOCA@
149 AMTAR = @AMTAR@
150 AR = @AR@
151 AUTOCONF = @AUTOCONF@
152 AUTOHEADER = @AUTOHEADER@
153 AUTOMAKE = @AUTOMAKE@
154 AWK = @AWK@
155 CC = @CC@
156 CCDEPMODE = @CCDEPMODE@
157 CFLAGS = @CFLAGS@
158 CPP = @CPP@
159 CPPFLAGS = @CPPFLAGS@
160 CURL_CONFIG = @CURL_CONFIG@
161 CXX = @CXX@
162 CXXCPP = @CXXCPP@
163 CXXDEPMODE = @CXXDEPMODE@
164 CXXFLAGS = @CXXFLAGS@
165 CYGPATH_W = @CYGPATH_W@
166 DEFS = @DEFS@
167 DEPDIR = @DEPDIR@
168 DSYMUTIL = @DSYMUTIL@
169 DUMPBIN = @DUMPBIN@
170 ECHO_C = @ECHO_C@
171 ECHO_N = @ECHO_N@
172 ECHO_T = @ECHO_T@
173 EGREP = @EGREP@
174 EXEEXT = @EXEEXT@
175 FGREP = @FGREP@
176 FUSE_CFLAGS = @FUSE_CFLAGS@
177 FUSE_LIBS = @FUSE_LIBS@
178 GREP = @GREP@
179 INSTALL = @INSTALL@
180 INSTALL_DATA = @INSTALL_DATA@
181 INSTALL_PROGRAM = @INSTALL_PROGRAM@
182 INSTALL_SCRIPT = @INSTALL_SCRIPT@
183 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
184 LD = @LD@
185 LDFLAGS = @LDFLAGS@
186 LIBOBJS = @LIBOBJS@
187 LIBS = @LIBS@
188 LIBTOOL = @LIBTOOL@
189 LIPO = @LIPO@
190 LN_S = @LN_S@
191 LTLIBOBJS = @LTLIBOBJS@
192 MAINT = @MAINT@
193 MAKEINFO = @MAKEINFO@
194 MKDIR_P = @MKDIR_P@
195 NM = @NM@
196 NMEDIT = @NMEDIT@
197 OBJEXT = @OBJEXT@
198 OTOOL = @OTOOL@
199 OTOOL64 = @OTOOL64@
200 PACKAGE = @PACKAGE@
201 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
202 PACKAGE_NAME = @PACKAGE_NAME@
203 PACKAGE_STRING = @PACKAGE_STRING@
204 PACKAGE_TARNAME = @PACKAGE_TARNAME@
205 PACKAGE_VERSION = @PACKAGE_VERSION@
206 PATH_SEPARATOR = @PATH_SEPARATOR@
207 PTHREAD_CC = @PTHREAD_CC@
208 PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
209 PTHREAD_LIBS = @PTHREAD_LIBS@
210 PYTHON = @PYTHON@
211 PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@
212 PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
213 PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@
214 PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@
215 PYTHON_LDFLAGS = @PYTHON_LDFLAGS@
216 PYTHON_PLATFORM = @PYTHON_PLATFORM@
217 PYTHON_PREFIX = @PYTHON_PREFIX@
218 PYTHON_SITE_PKG = @PYTHON_SITE_PKG@
219 PYTHON_VERSION = @PYTHON_VERSION@
220 RANLIB = @RANLIB@
221 S3_BIN = @S3_BIN@
222 SED = @SED@
223 SET_MAKE = @SET_MAKE@
224 SHELL = @SHELL@
225 STRIP = @STRIP@
226 VERSION = @VERSION@
227 abs_builddir = @abs_builddir@
228 abs_srcdir = @abs_srcdir@
229 abs_top_builddir = @abs_top_builddir@
230 abs_top_srcdir = @abs_top_srcdir@
231 ac_ct_CC = @ac_ct_CC@
232 ac_ct_CXX = @ac_ct_CXX@
233 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
234 ac_prefix_program = @ac_prefix_program@
235 acx_pthread_config = @acx_pthread_config@
236 am__include = @am__include@
237 am__leading_dot = @am__leading_dot@
238 am__quote = @am__quote@
239 am__tar = @am__tar@
240 am__untar = @am__untar@
241 bindir = @bindir@
242 build = @build@
243 build_alias = @build_alias@
244 build_cpu = @build_cpu@
245 build_os = @build_os@
246 build_vendor = @build_vendor@
247 builddir = @builddir@
248 datadir = @datadir@
249 datarootdir = @datarootdir@
250 docdir = @docdir@
251 dvidir = @dvidir@
252 exec_prefix = @exec_prefix@
253 host = @host@
254 host_alias = @host_alias@
255 host_cpu = @host_cpu@
256 host_os = @host_os@
257 host_vendor = @host_vendor@
258 htmldir = @htmldir@
259 includedir = @includedir@
260 infodir = @infodir@
261 install_sh = @install_sh@
262 libdir = @libdir@
263 libexecdir = @libexecdir@
264 localedir = @localedir@
265 localstatedir = @localstatedir@
266 lt_ECHO = @lt_ECHO@
267 mandir = @mandir@
268 mkdir_p = @mkdir_p@
269 oldincludedir = @oldincludedir@
270 pdfdir = @pdfdir@
271 pkgpyexecdir = @pkgpyexecdir@
272 pkgpythondir = @pkgpythondir@
273 prefix = @prefix@
274 program_transform_name = @program_transform_name@
275 psdir = @psdir@
276 pyexecdir = @pyexecdir@
277 pythondir = @pythondir@
278 sbindir = @sbindir@
279 sharedstatedir = @sharedstatedir@
280 srcdir = @srcdir@
281 sysconfdir = @sysconfdir@
282 target_alias = @target_alias@
283 top_builddir = @top_builddir@
284 top_srcdir = @top_srcdir@
285 EXTRA_DIST = test_make_random_iso.sh test_crypto.sh test_signing.sh test_recovery.sh \
286 test_passphrase.sh test_afsegment.sh
287
288 TESTS = test_signing.sh test_recovery.sh test_passphrase.sh test_afsegment.sh test_crypto.sh
289
290 # See http://www.gnu.org/software/libtool/manual.html # Using-Automake
291 AM_LDFLAGS = -static # staticly link our tools (easier debugging)
292 afcat_SOURCES = afcat.cpp
293 afcrypto_SOURCES = afcrypto.cpp
294 afcompare_SOURCES = afcompare.cpp unix4win32.h
295 afconvert_SOURCES = afconvert.cpp unix4win32.h
296 afcopy_SOURCES = afcopy.cpp unix4win32.h aff_bom.h aff_bom.cpp
297 afdiskprint_SOURCES = afdiskprint.cpp unix4win32.h hashextent.h
298 affix_SOURCES = affix.cpp unix4win32.h
299 affuse_SOURCES = affuse.c
300 afinfo_SOURCES = afinfo.cpp unix4win32.h
301 afrecover_SOURCES = afrecover.cpp unix4win32.h
302 afsegment_SOURCES = afsegment.cpp
303 afsign_SOURCES = afsign.cpp aff_bom.h aff_bom.cpp
304 afstats_SOURCES = afstats.cpp
305 afverify_SOURCES = afverify.cpp aff_bom.h aff_bom.cpp
306 afxml_SOURCES = afxml.cpp unix4win32.h
307 INCLUDES = -I@top_srcdir@/lib/
308 LDADD = @top_builddir@/lib/libafflib.la
309 affuse_CFLAGS = @FUSE_CFLAGS@
310 affuse_LDADD = @top_builddir@/lib/libafflib.la @FUSE_LIBS@
311 affuse_LINK = $(CXXLINK)
312 CLEANFILES = deskclerk.pem test_password.sh blank.iso archives.pem password_signed.aff signed.aff \
313 random.iso agent.pem r3.iso random*.aff blank.aff blanke.aff words r3.iso evidence1.aff
314
315 all: all-am
316
317 .SUFFIXES:
318 .SUFFIXES: .c .cpp .lo .o .obj
319 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
320 @for dep in $?; do \
321 case '$(am__configure_deps)' in \
322 *$$dep*) \
323 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
324 && exit 0; \
325 exit 1;; \
326 esac; \
327 done; \
328 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tools/Makefile'; \
329 cd $(top_srcdir) && \
330 $(AUTOMAKE) --gnu tools/Makefile
331 .PRECIOUS: Makefile
332 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
333 @case '$?' in \
334 *config.status*) \
335 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
336 *) \
337 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
338 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
339 esac;
340
341 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
342 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
343
344 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
345 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
346 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
347 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
348 install-binPROGRAMS: $(bin_PROGRAMS)
349 @$(NORMAL_INSTALL)
350 test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
351 @list='$(bin_PROGRAMS)'; for p in $$list; do \
352 p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
353 if test -f $$p \
354 || test -f $$p1 \
355 ; then \
356 f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
357 echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
358 $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
359 else :; fi; \
360 done
361
362 uninstall-binPROGRAMS:
363 @$(NORMAL_UNINSTALL)
364 @list='$(bin_PROGRAMS)'; for p in $$list; do \
365 f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
366 echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
367 rm -f "$(DESTDIR)$(bindir)/$$f"; \
368 done
369
370 clean-binPROGRAMS:
371 @list='$(bin_PROGRAMS)'; for p in $$list; do \
372 f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
373 echo " rm -f $$p $$f"; \
374 rm -f $$p $$f ; \
375 done
376 afcat$(EXEEXT): $(afcat_OBJECTS) $(afcat_DEPENDENCIES)
377 @rm -f afcat$(EXEEXT)
378 $(CXXLINK) $(afcat_OBJECTS) $(afcat_LDADD) $(LIBS)
379 afcompare$(EXEEXT): $(afcompare_OBJECTS) $(afcompare_DEPENDENCIES)
380 @rm -f afcompare$(EXEEXT)
381 $(CXXLINK) $(afcompare_OBJECTS) $(afcompare_LDADD) $(LIBS)
382 afconvert$(EXEEXT): $(afconvert_OBJECTS) $(afconvert_DEPENDENCIES)
383 @rm -f afconvert$(EXEEXT)
384 $(CXXLINK) $(afconvert_OBJECTS) $(afconvert_LDADD) $(LIBS)
385 afcopy$(EXEEXT): $(afcopy_OBJECTS) $(afcopy_DEPENDENCIES)
386 @rm -f afcopy$(EXEEXT)
387 $(CXXLINK) $(afcopy_OBJECTS) $(afcopy_LDADD) $(LIBS)
388 afcrypto$(EXEEXT): $(afcrypto_OBJECTS) $(afcrypto_DEPENDENCIES)
389 @rm -f afcrypto$(EXEEXT)
390 $(CXXLINK) $(afcrypto_OBJECTS) $(afcrypto_LDADD) $(LIBS)
391 afdiskprint$(EXEEXT): $(afdiskprint_OBJECTS) $(afdiskprint_DEPENDENCIES)
392 @rm -f afdiskprint$(EXEEXT)
393 $(CXXLINK) $(afdiskprint_OBJECTS) $(afdiskprint_LDADD) $(LIBS)
394 affix$(EXEEXT): $(affix_OBJECTS) $(affix_DEPENDENCIES)
395 @rm -f affix$(EXEEXT)
396 $(CXXLINK) $(affix_OBJECTS) $(affix_LDADD) $(LIBS)
397 affuse$(EXEEXT): $(affuse_OBJECTS) $(affuse_DEPENDENCIES)
398 @rm -f affuse$(EXEEXT)
399 $(affuse_LINK) $(affuse_OBJECTS) $(affuse_LDADD) $(LIBS)
400 afinfo$(EXEEXT): $(afinfo_OBJECTS) $(afinfo_DEPENDENCIES)
401 @rm -f afinfo$(EXEEXT)
402 $(CXXLINK) $(afinfo_OBJECTS) $(afinfo_LDADD) $(LIBS)
403 afrecover$(EXEEXT): $(afrecover_OBJECTS) $(afrecover_DEPENDENCIES)
404 @rm -f afrecover$(EXEEXT)
405 $(CXXLINK) $(afrecover_OBJECTS) $(afrecover_LDADD) $(LIBS)
406 afsegment$(EXEEXT): $(afsegment_OBJECTS) $(afsegment_DEPENDENCIES)
407 @rm -f afsegment$(EXEEXT)
408 $(CXXLINK) $(afsegment_OBJECTS) $(afsegment_LDADD) $(LIBS)
409 afsign$(EXEEXT): $(afsign_OBJECTS) $(afsign_DEPENDENCIES)
410 @rm -f afsign$(EXEEXT)
411 $(CXXLINK) $(afsign_OBJECTS) $(afsign_LDADD) $(LIBS)
412 afstats$(EXEEXT): $(afstats_OBJECTS) $(afstats_DEPENDENCIES)
413 @rm -f afstats$(EXEEXT)
414 $(CXXLINK) $(afstats_OBJECTS) $(afstats_LDADD) $(LIBS)
415 afverify$(EXEEXT): $(afverify_OBJECTS) $(afverify_DEPENDENCIES)
416 @rm -f afverify$(EXEEXT)
417 $(CXXLINK) $(afverify_OBJECTS) $(afverify_LDADD) $(LIBS)
418 afxml$(EXEEXT): $(afxml_OBJECTS) $(afxml_DEPENDENCIES)
419 @rm -f afxml$(EXEEXT)
420 $(CXXLINK) $(afxml_OBJECTS) $(afxml_LDADD) $(LIBS)
421
422 mostlyclean-compile:
423 -rm -f *.$(OBJEXT)
424
425 distclean-compile:
426 -rm -f *.tab.c
427
428 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afcat.Po@am__quote@
429 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afcompare.Po@am__quote@
430 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afconvert.Po@am__quote@
431 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afcopy.Po@am__quote@
432 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afcrypto.Po@am__quote@
433 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afdiskprint.Po@am__quote@
434 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aff_bom.Po@am__quote@
435 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/affix.Po@am__quote@
436 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/affuse-affuse.Po@am__quote@
437 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afinfo.Po@am__quote@
438 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afrecover.Po@am__quote@
439 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afsegment.Po@am__quote@
440 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afsign.Po@am__quote@
441 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afstats.Po@am__quote@
442 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afverify.Po@am__quote@
443 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/afxml.Po@am__quote@
444
445 .c.o:
446 @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
447 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
448 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
449 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
450 @am__fastdepCC_FALSE@ $(COMPILE) -c $<
451
452 .c.obj:
453 @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
454 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
455 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
456 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
457 @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
458
459 .c.lo:
460 @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
461 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
462 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
463 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
464 @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
465
466 affuse-affuse.o: affuse.c
467 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(affuse_CFLAGS) $(CFLAGS) -MT affuse-affuse.o -MD -MP -MF $(DEPDIR)/affuse-affuse.Tpo -c -o affuse-affuse.o `test -f 'affuse.c' || echo '$(srcdir)/'`affuse.c
468 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/affuse-affuse.Tpo $(DEPDIR)/affuse-affuse.Po
469 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='affuse.c' object='affuse-affuse.o' libtool=no @AMDEPBACKSLASH@
470 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
471 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(affuse_CFLAGS) $(CFLAGS) -c -o affuse-affuse.o `test -f 'affuse.c' || echo '$(srcdir)/'`affuse.c
472
473 affuse-affuse.obj: affuse.c
474 @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(affuse_CFLAGS) $(CFLAGS) -MT affuse-affuse.obj -MD -MP -MF $(DEPDIR)/affuse-affuse.Tpo -c -o affuse-affuse.obj `if test -f 'affuse.c'; then $(CYGPATH_W) 'affuse.c'; else $(CYGPATH_W) '$(srcdir)/affuse.c'; fi`
475 @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/affuse-affuse.Tpo $(DEPDIR)/affuse-affuse.Po
476 @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='affuse.c' object='affuse-affuse.obj' libtool=no @AMDEPBACKSLASH@
477 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
478 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(affuse_CFLAGS) $(CFLAGS) -c -o affuse-affuse.obj `if test -f 'affuse.c'; then $(CYGPATH_W) 'affuse.c'; else $(CYGPATH_W) '$(srcdir)/affuse.c'; fi`
479
480 .cpp.o:
481 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
482 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
483 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
484 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
485 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
486
487 .cpp.obj:
488 @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
489 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
490 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
491 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
492 @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
493
494 .cpp.lo:
495 @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
496 @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
497 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
498 @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
499 @am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
500
501 mostlyclean-libtool:
502 -rm -f *.lo
503
504 clean-libtool:
505 -rm -rf .libs _libs
506
507 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
508 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
509 unique=`for i in $$list; do \
510 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
511 done | \
512 $(AWK) ' { files[$$0] = 1; } \
513 END { for (i in files) print i; }'`; \
514 mkid -fID $$unique
515 tags: TAGS
516
517 TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
518 $(TAGS_FILES) $(LISP)
519 tags=; \
520 here=`pwd`; \
521 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
522 unique=`for i in $$list; do \
523 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
524 done | \
525 $(AWK) ' { files[$$0] = 1; } \
526 END { for (i in files) print i; }'`; \
527 if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
528 test -n "$$unique" || unique=$$empty_fix; \
529 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
530 $$tags $$unique; \
531 fi
532 ctags: CTAGS
533 CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
534 $(TAGS_FILES) $(LISP)
535 tags=; \
536 here=`pwd`; \
537 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
538 unique=`for i in $$list; do \
539 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
540 done | \
541 $(AWK) ' { files[$$0] = 1; } \
542 END { for (i in files) print i; }'`; \
543 test -z "$(CTAGS_ARGS)$$tags$$unique" \
544 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
545 $$tags $$unique
546
547 GTAGS:
548 here=`$(am__cd) $(top_builddir) && pwd` \
549 && cd $(top_srcdir) \
550 && gtags -i $(GTAGS_ARGS) $$here
551
552 distclean-tags:
553 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
554
555 check-TESTS: $(TESTS)
556 @failed=0; all=0; xfail=0; xpass=0; skip=0; ws='[ ]'; \
557 srcdir=$(srcdir); export srcdir; \
558 list=' $(TESTS) '; \
559 if test -n "$$list"; then \
560 for tst in $$list; do \
561 if test -f ./$$tst; then dir=./; \
562 elif test -f $$tst; then dir=; \
563 else dir="$(srcdir)/"; fi; \
564 if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
565 all=`expr $$all + 1`; \
566 case " $(XFAIL_TESTS) " in \
567 *$$ws$$tst$$ws*) \
568 xpass=`expr $$xpass + 1`; \
569 failed=`expr $$failed + 1`; \
570 echo "XPASS: $$tst"; \
571 ;; \
572 *) \
573 echo "PASS: $$tst"; \
574 ;; \
575 esac; \
576 elif test $$? -ne 77; then \
577 all=`expr $$all + 1`; \
578 case " $(XFAIL_TESTS) " in \
579 *$$ws$$tst$$ws*) \
580 xfail=`expr $$xfail + 1`; \
581 echo "XFAIL: $$tst"; \
582 ;; \
583 *) \
584 failed=`expr $$failed + 1`; \
585 echo "FAIL: $$tst"; \
586 ;; \
587 esac; \
588 else \
589 skip=`expr $$skip + 1`; \
590 echo "SKIP: $$tst"; \
591 fi; \
592 done; \
593 if test "$$failed" -eq 0; then \
594 if test "$$xfail" -eq 0; then \
595 banner="All $$all tests passed"; \
596 else \
597 banner="All $$all tests behaved as expected ($$xfail expected failures)"; \
598 fi; \
599 else \
600 if test "$$xpass" -eq 0; then \
601 banner="$$failed of $$all tests failed"; \
602 else \
603 banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \
604 fi; \
605 fi; \
606 dashes="$$banner"; \
607 skipped=""; \
608 if test "$$skip" -ne 0; then \
609 skipped="($$skip tests were not run)"; \
610 test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
611 dashes="$$skipped"; \
612 fi; \
613 report=""; \
614 if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
615 report="Please report to $(PACKAGE_BUGREPORT)"; \
616 test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
617 dashes="$$report"; \
618 fi; \
619 dashes=`echo "$$dashes" | sed s/./=/g`; \
620 echo "$$dashes"; \
621 echo "$$banner"; \
622 test -z "$$skipped" || echo "$$skipped"; \
623 test -z "$$report" || echo "$$report"; \
624 echo "$$dashes"; \
625 test "$$failed" -eq 0; \
626 else :; fi
627
628 distdir: $(DISTFILES)
629 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
630 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
631 list='$(DISTFILES)'; \
632 dist_files=`for file in $$list; do echo $$file; done | \
633 sed -e "s|^$$srcdirstrip/||;t" \
634 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
635 case $$dist_files in \
636 */*) $(MKDIR_P) `echo "$$dist_files" | \
637 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
638 sort -u` ;; \
639 esac; \
640 for file in $$dist_files; do \
641 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
642 if test -d $$d/$$file; then \
643 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
644 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
645 cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
646 fi; \
647 cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
648 else \
649 test -f $(distdir)/$$file \
650 || cp -p $$d/$$file $(distdir)/$$file \
651 || exit 1; \
652 fi; \
653 done
654 check-am: all-am
655 $(MAKE) $(AM_MAKEFLAGS) check-TESTS
656 check: check-am
657 all-am: Makefile $(PROGRAMS)
658 installdirs:
659 for dir in "$(DESTDIR)$(bindir)"; do \
660 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
661 done
662 install: install-am
663 install-exec: install-exec-am
664 install-data: install-data-am
665 uninstall: uninstall-am
666
667 install-am: all-am
668 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
669
670 installcheck: installcheck-am
671 install-strip:
672 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
673 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
674 `test -z '$(STRIP)' || \
675 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
676 mostlyclean-generic:
677
678 clean-generic:
679 -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
680
681 distclean-generic:
682 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
683
684 maintainer-clean-generic:
685 @echo "This command is intended for maintainers to use"
686 @echo "it deletes files that may require special tools to rebuild."
687 clean: clean-am
688
689 clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
690
691 distclean: distclean-am
692 -rm -rf ./$(DEPDIR)
693 -rm -f Makefile
694 distclean-am: clean-am distclean-compile distclean-generic \
695 distclean-tags
696
697 dvi: dvi-am
698
699 dvi-am:
700
701 html: html-am
702
703 info: info-am
704
705 info-am:
706
707 install-data-am:
708
709 install-dvi: install-dvi-am
710
711 install-exec-am: install-binPROGRAMS
712
713 install-html: install-html-am
714
715 install-info: install-info-am
716
717 install-man:
718
719 install-pdf: install-pdf-am
720
721 install-ps: install-ps-am
722
723 installcheck-am:
724
725 maintainer-clean: maintainer-clean-am
726 -rm -rf ./$(DEPDIR)
727 -rm -f Makefile
728 maintainer-clean-am: distclean-am maintainer-clean-generic
729
730 mostlyclean: mostlyclean-am
731
732 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
733 mostlyclean-libtool
734
735 pdf: pdf-am
736
737 pdf-am:
738
739 ps: ps-am
740
741 ps-am:
742
743 uninstall-am: uninstall-binPROGRAMS
744
745 .MAKE: install-am install-strip
746
747 .PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
748 clean-binPROGRAMS clean-generic clean-libtool ctags distclean \
749 distclean-compile distclean-generic distclean-libtool \
750 distclean-tags distdir dvi dvi-am html html-am info info-am \
751 install install-am install-binPROGRAMS install-data \
752 install-data-am install-dvi install-dvi-am install-exec \
753 install-exec-am install-html install-html-am install-info \
754 install-info-am install-man install-pdf install-pdf-am \
755 install-ps install-ps-am install-strip installcheck \
756 installcheck-am installdirs maintainer-clean \
757 maintainer-clean-generic mostlyclean mostlyclean-compile \
758 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
759 tags uninstall uninstall-am uninstall-binPROGRAMS
760
761 # Tell versions [3.59,3.63) of GNU make to not export all variables.
762 # Otherwise a system limit (for SysV at least) may be exceeded.
763 .NOEXPORT:
0 /*
1 * afcat.cpp:
2 *
3 * cat the contents of an AFF file...
4 */
5
6 /*
7 * Copyright (c) 2005, 2006
8 * Simson L. Garfinkel and Basis Technology, Inc.
9 * All rights reserved.
10 *
11 * This code is derrived from software contributed by
12 * Simson L. Garfinkel
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Simson L. Garfinkel
25 * and Basis Technology Corp.
26 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
27 * contributors to this program may be used to endorse or promote
28 * products derived from this software without specific prior written
29 * permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
32 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
33 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
36 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46 #include "affconfig.h"
47 #include "afflib.h"
48 #include "afflib_i.h"
49
50 #include <stdio.h>
51 #include <algorithm>
52 #include <vector>
53 #include <string>
54 #ifdef HAVE_CSTRING
55 #include <cstring>
56 #endif
57
58
59 using namespace std;
60
61 vector <int64_t> pages;
62
63 const char *progname = "afcat";
64 int opt_info = 0;
65 char *opt_segname=0;
66 int64_t opt_pagenum = -1;
67 int opt_quiet = 1;
68 int opt_list= 0 ;
69 int opt_list_long = 0;
70 int opt_debug = 0;
71 int64_t opt_sector = -1;
72 int opt_badflag = 0;
73 vector<string> opt_r;
74
75
76 void usage()
77 {
78 printf("afcat version %s\n",PACKAGE_VERSION);
79 printf("usage: afcat [options] infile [... more infiles]\n");
80 printf("options:\n");
81 printf(" -s name --- Just output segment name\n");
82 printf(" -p ### --- just output data page number ###\n");
83 printf(" -S ### --- Just output data sector ### (assumes 512-byte sectors). Sector #0 is first\n");
84 printf(" -q --- quiet; don't print to STDERR if a page is skipped\n");
85 printf(" -n --- noisy; tell when pages are skipped.\n");
86 printf(" -l --- List all of the segment names\n");
87 printf(" -L --- List segment names, lengths, and args\n");
88 printf(" -d --- debug. Print the page numbers to stderr as data goes to stdout\n");
89 printf(" -b --- Output BADFALG for bad blocks (default is NULLs)\n");
90 printf(" -v --- Just print the version number and exit.\n");
91 printf(" -r offset:count --- seek to offset and output count characters in each file; may be repeated\n");
92 exit(0);
93 }
94
95
96 const char *current_fname = 0;
97 int64_t current_page = -1;
98 void sig_info(int arg)
99 {
100 fprintf(stderr,"afcat ");
101 if(current_fname) fprintf(stderr,"%s: ",current_fname);
102 if(current_page>=0) fprintf(stderr,"[%"PRId64"] ",current_page);
103 fflush(stderr);
104 }
105
106
107
108 int compar(const void *a_,const void *b_)
109 {
110 int64_t a = *(int *)a_;
111 int64_t b = *(int *)b_;
112 if(a<b) return -1;
113 if(a>b) return 1;
114 return 0;
115 }
116
117 struct afm_private {
118 AFFILE *aff; // the AFFILE we use for the actual metadata
119 AFFILE *sr; // the AFFILE we use for the splitraw
120 int sr_initialized; // has the split-raw been setup from AFM?
121 };
122
123 int output_page(AFFILE *af,FILE *outfile,int64_t pagenum)
124 {
125 current_fname = af_filename(af);
126 current_page = pagenum;
127 unsigned char *buf = (unsigned char *)malloc(af->image_pagesize);
128 if(buf==0){
129 err(1,"malloc(%d) failed",(int)af->image_pagesize);
130 }
131 uint64_t offset = (uint64_t)pagenum * af->image_pagesize; // go to that location
132
133
134 af_seek(af,offset,SEEK_SET);
135
136
137 int bytes = af_read(af,buf,af->image_pagesize); // read what we can
138
139 if(bytes<0){
140 if(opt_debug) fprintf(stderr,"afcat: cannot read page %"I64d"\n",pagenum);
141 return -1;
142 }
143
144 if(opt_debug){
145 fprintf(stderr,"afcat: page:%"I64d" bytes: %d offset:%"I64d"\n",
146 pagenum, bytes,offset);
147 }
148
149 /* Check each sector to see if it is badflag or not.
150 * If it is and if opt_badflag is not set, make it all NULs.
151 */
152 for(unsigned char *cc=buf;cc<buf+bytes;cc+=af->image_sectorsize){
153 if(af_is_badsector(af,cc) && opt_badflag==0){
154 memset(cc,0,af->image_sectorsize);
155 }
156 }
157
158 if(opt_debug) fprintf(stderr," outputing %d bytes\n",bytes);
159 fwrite(buf,1,bytes,outfile); // send to the output
160 free(buf);
161 return bytes;
162 }
163
164
165 int afcat(AFFILE *af)
166 {
167 int64_t total_bytes_written = 0;
168
169 /* Read all of the pages from beginning to end and capture
170 * all the segment numbers...
171 */
172
173 #ifdef WIN32
174 _setmode(fileno(stdout),_O_BINARY);
175 #endif
176 if(opt_debug) fprintf(stderr,"afcat(%s)\n",af_filename(af));
177
178 if(opt_segname){
179 /* First figure out how big the segment is */
180 size_t datalen = 0;
181 if(af_get_seg(af,opt_segname,0,0,&datalen)){
182 fprintf(stderr,"%s: segment '%s' does not exist\n",
183 af_filename(af),opt_segname);
184 return -1;
185 }
186 unsigned char *data = (unsigned char *)malloc(datalen);
187 if(data==0) err(1,"malloc");
188 if(af_get_seg(af,opt_segname,0,data,&datalen)){
189 free(data);
190 fprintf(stderr,"%s: could not read segment '%s'\n",
191 af_filename(af),opt_segname);
192 return -1;
193 }
194 fwrite(data,1,datalen,stdout);
195 free(data);
196 return 0;
197 }
198
199 if(opt_pagenum != -1){ // just write a particular page?
200 int r = output_page(af,stdout,opt_pagenum);
201 return r>=0 ? 0 : -1;
202 }
203
204 if(opt_sector>=0){
205 unsigned char *buf = (unsigned char *)malloc(af->image_sectorsize);
206 af_seek(af,(uint64_t)opt_sector*af->image_sectorsize,SEEK_SET);
207 int r = af_read(af,buf,af->image_sectorsize);
208 if(r>0){
209 fwrite(buf,1,r,stdout);
210 }
211 free(buf);
212 return 0;
213 }
214
215 /* Get a list of all the segments. If we are doing a list, just print them.
216 * If we are not doing a list, capture the data pages and put their numbers
217 * into an array.
218 */
219
220 if(opt_debug) fprintf(stderr,"af_rewind_seg()\n");
221
222 if(opt_r.size()>0){
223 unsigned char *buf = (unsigned char *)malloc(af->image_pagesize);
224 for(vector<string>::const_iterator offset_count=opt_r.begin(); offset_count != opt_r.end(); offset_count++){
225 string opts = *offset_count;
226 const char *opt = opts.c_str();
227 uint64_t offset=0;
228 int count=0;
229 if(sscanf(opt,"%"I64u":%d",&offset,&count)!=2){
230 err(1,"Cannot decode '%s'\n",opt);
231 }
232 af_seek(af,offset,SEEK_SET);
233 int r= af_read(af,buf,count);
234 if(r>0){
235 fwrite(buf,1,r,stdout);
236 }
237 }
238 free(buf);
239 return 0;
240 }
241
242
243 af_rewind_seg(af); // start at the beginning
244 char segname[AF_MAX_NAME_LEN];
245 unsigned long arg;
246 size_t datalen = 0;
247 memset(segname,0,sizeof(segname));
248
249 int encrypted_segments = 0;
250 while(af_get_next_seg(af,segname,sizeof(segname),&arg,0,&datalen)==0){
251 if(opt_debug) fprintf(stderr,"af_get_next_seg found segment %s\n",segname);
252 if(segname[0]==0) continue; // ignore sector
253 if(opt_list){
254 printf("%s",segname);
255 if(opt_list_long){
256 printf("\targ:%lu\tlen:%d",arg,(int)datalen);
257 }
258 putchar('\n');
259 }
260 else {
261 int64_t pagenum = af_segname_page_number(segname);
262 if(pagenum>=0) pages.push_back(pagenum);
263 if(af_is_encrypted_segment(segname)) encrypted_segments++;
264 }
265 datalen = 0; // allow to get the next one
266 }
267 if(opt_list) return 0; // that's all that was wanted.
268
269
270 sort(pages.begin(),pages.end());
271
272 if(pages.size()==0 && encrypted_segments){
273 fprintf(stderr,"afcat: This file has %d encrypted segments.\n",encrypted_segments);
274 fprintf(stderr,"afcat: No unencrypted pages could be found.\n");
275 }
276
277 /* Now I have a list of pages; cat each one */
278 int next_page = 0; // starting page number
279 int64_t imagesize = af_get_imagesize(af);
280 for(vector<int64_t>::iterator i = pages.begin(); i != pages.end(); i++){
281
282 int page = *i;
283 if(page != next_page && opt_quiet==0){
284 if(page == next_page+1 ){
285 fprintf(stderr,"afcat: page %d not in file\n",next_page);
286 }
287 else{
288 fprintf(stderr,"afcat: pages %d through %d not in file\n",
289 next_page,page-1);
290 }
291 }
292 int r = output_page(af,stdout,page);
293 if(r<0) return -1;
294 total_bytes_written += r;
295 next_page = page + 1; // note what should be next
296
297 //fprintf(stderr,"bytes written=%qd imagesize=%qd\n",total_bytes_written,imagesize);
298 if((total_bytes_written > imagesize) && (imagesize>0)){
299 err(1,"afcat internal error. bytes written=%"I64d" imagesize=%" I64d,
300 (int64_t)total_bytes_written,
301 (int64_t)imagesize);
302 return -1;
303 }
304 }
305 return 0;
306 }
307
308
309 int64_t atoi64(const char *buf)
310 {
311 int64_t r=0;
312 char ch;
313 if(sscanf(buf,"%"I64d"%c",&r,&ch)==1) return r;
314 fprintf(stderr,"Cannot parse '%s'\n",buf);
315 exit(0);
316 }
317
318
319 int main(int argc,char **argv)
320 {
321 int bflag, ch;
322
323 #ifdef SIGINFO
324 signal(SIGINFO,sig_info);
325 #endif
326
327 bflag = 0;
328 while ((ch = getopt(argc, argv, "s:S:p:lLh?dqnvr:")) != -1) {
329 switch (ch) {
330 case 's':
331 opt_segname = optarg;
332 break;
333 case 'S':
334 opt_sector = atoi64(optarg);
335 break;
336 case 'p':
337 opt_pagenum = atoi64(optarg);
338 break;
339 case 'q':
340 opt_quiet = 1;
341 break;
342 case 'n':
343 opt_quiet = 0;
344 break;
345 case 'l':
346 opt_list = 1;
347 break;
348 case 'r':
349 opt_r.push_back(optarg);
350 break;
351 case 'L':
352 opt_list = 1;
353 opt_list_long = 1;
354 break;
355 case 'b':
356 opt_badflag = 1;
357 break;
358 case 'd':
359 opt_debug++;
360 break;
361 case 'h':
362 case '?':
363 default:
364 usage();
365 break;
366 case 'v':
367 printf("%s version %s\n",progname,PACKAGE_VERSION);
368 exit(0);
369 }
370 }
371 argc -= optind;
372 argv += optind;
373
374 if(argc<1){
375 usage();
376 }
377
378 while(*argv){
379 AFFILE *af = af_open(*argv,O_RDONLY,0);
380 if(!af) af_err(1,"afcat(%s)",*argv);
381 if(afcat(af)) err(1,"afcat");
382 af_close(af);
383 argv++;
384 argc--;
385 }
386 }
0 /*
1 * acompare.cpp:
2 *
3 * Compare the contents of an ISO file to an AFF file.
4 * Optionally, if they are equal, delete the ISO file
5 */
6
7 /*
8 * Copyright (c) 2005--2008
9 * Simson L. Garfinkel and Basis Technology, Inc.
10 * All rights reserved.
11 *
12 * This code is derrived from software contributed by
13 * Simson L. Garfinkel
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. All advertising materials mentioning features or use of this software
24 * must display the following acknowledgement:
25 * This product includes software developed by Simson L. Garfinkel
26 * and Basis Technology Corp.
27 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
28 * contributors to this program may be used to endorse or promote
29 * products derived from this software without specific prior written
30 * permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
33 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
34 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
36 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
37 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
38 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
40 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
43 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * SUCH DAMAGE.
45 */
46
47 #include "affconfig.h"
48 #include "afflib.h"
49 #include "afflib_i.h"
50 #include "utils.h"
51
52 using namespace std;
53 using namespace aff;
54
55
56 #ifdef WIN32
57 #include "unix4win32.h"
58 #endif
59
60
61 #ifdef UNIX
62 #include <sys/signal.h>
63 #include <unistd.h>
64 #endif
65
66 #include <ctype.h>
67 #include <stdio.h>
68 #include <stdlib.h>
69 #include <sys/types.h>
70 #include <sys/stat.h>
71 #include <fcntl.h>
72 #include <limits.h>
73 #include <string.h>
74 #include <zlib.h>
75 #include <openssl/md5.h>
76 #include <openssl/sha.h>
77 #include <assert.h>
78
79 #ifdef HAVE_CSTRING
80 #include <cstring>
81 #endif
82
83 #ifdef linux
84 #include <sys/time.h>
85 #endif
86
87
88
89 const char *progname = "afcompare";
90
91 int opt_quiet = 0;
92 int opt_all = 0;
93 int opt_print_sectors = 0;
94 int opt_print_sector_contents = 0;
95 int opt_page = -1;
96 int opt_preen = 0;
97 int opt_exist = 0;
98 int opt_ignore_metadata = 0;
99 int opt_s3 = 0;
100 int opt_verbose = 0;
101 const char *batch_ext = "";
102
103 vector<string> errors;
104
105 const char *current_source = 0;
106
107 void sig_info(int arg)
108 {
109 if(current_source){
110 printf("%s... ",current_source);
111 }
112 printf("\n");
113 fflush(stdout);
114 }
115
116 void print_title(char *title)
117 {
118 if(title[0]){
119 puts(title);
120 title[0] = 0;
121 }
122 }
123
124 void usage()
125 {
126 printf("afcompare version %s\n",PACKAGE_VERSION);
127 printf("\n");
128 printf("usage: afcompare [options] file1 file2\n");
129 printf(" compares file1 with file2\n");
130 printf("\n");
131 printf("or afcompare [options] -r dir1 dir2\n");
132 printf(" comparses similarly-named files in dir1 and dir2\n");
133 printf("\n");
134 printf("or afcompare [options] -s file1 file2...\n");
135 printf(" Reports if file was successfully copied to Amazon S3\n");
136 printf(" checking only for existence, not reading back the bytes.\n");
137 printf(" (Because all writes to S3 are validated by the MD5 of the object\n");
138 #ifndef USE_S3
139 printf(" NOTE: S3 support is not provided in this version\n");
140 #endif
141
142 printf("fast options:\n");
143 printf("(These compare segments but not their contents.)\n");
144 printf(" -p --- report about the results of preening\n");
145 printf(" -e --- Just report about existence (use with -r)\n");
146 printf(" -s --- Just see if all of the segments are present, but don't\n");
147 printf(" validate the contents. (Primarily for use with Amazon S3)\n");
148
149 printf("other options:\n");
150 printf(" -V --- just print the version number and exit\n");
151 printf(" -v --- Verbose; each file as it is compared.\n");
152 printf(" -q --- Quiet. No output except for errors\n");
153 printf(" -a --- print what's the same (all)\n");
154 printf(" -b --- print the numbers of differing sectors\n");
155 printf(" -c --- print the contents of differing sectors\n");
156 printf(" -m --- Just report about the data (ignore metadata)\n");
157 printf(" -P ### --- Just examine the differences on page ###\n");
158 printf(" -q --- Quiet; no output except for errors.\n");
159 printf("\n");
160 printf("Options documented above:\n");
161 printf(" -r dir1 dir2 --- recursively compare what's in dir1 with dir2, and\n");
162 printf(" report what's in dir1 that's not in dir2\n");
163 printf(" -s --- Check to see if named files are on Amazon S3\n");
164 printf("\n");
165 printf(" afcompare file1.aff file2.aff --- compare file1.aff and file2.aff\n");
166 printf(" afcompare f1.aff f2.aff dir1/ --- compare f1.aff with dir1/f1.aff and f2.aff with dir2/f2.aff\n");
167 printf(" note: dir1/ must end with a slash.\n");
168 printf(" afcompare -b img file.aff --- compare file.aff and file.img\n");
169 printf(" afcompare -b img file1.aff file2.aff... --- compare file1.aff, file1.img, etc.\n");
170 printf(" afcompare -re dir1 dir2 --- report AFF files in dir1 but not in dir2\n");
171 printf(" afcompare -rse dir1 s3:/// --- report AFF files in dir1 but not on S3 (low bandwidth)\n");
172 printf(" afcompare -rs dir1 s3:/// --- report AFF files in dir1 but incomplete on on S3 (more bandwidth)\n");
173 printf("\n");
174 exit(0);
175 }
176
177 void print_sector(AFFILE *af,unsigned char *buf)
178 {
179 for(unsigned int i=0;i<af->image_sectorsize;i++){
180 if(isprint(buf[i])){
181 putchar(buf[i]);
182 }
183 else {
184 putchar('.');
185 }
186 if(i%64==63) putchar('\n');
187 }
188 }
189
190
191 void print_info(char dir,const char *segname,unsigned long arg,size_t len,
192 unsigned char *data,int mcr)
193 {
194 printf(" %c %s arg=%lu len=%d\n",dir,segname,arg,(int)len);
195 printf(" ");
196 if((arg == AF_SEG_QUADWORD) && (len==8)){
197 printf("data=%"I64d" as a 64-bit value\n",af_decode_q(data));
198 return;
199 }
200 /* Otherwise, just print some stuff... */
201 for(unsigned int i=0;i<len && i<60;i++){
202 if(data[i]==' '){
203 putchar(' ');
204 continue;
205 }
206 if(!isprint(data[i])){
207 putchar('.');
208 continue;
209 }
210 putchar(data[i]);
211 }
212 putchar('\n');
213 }
214
215 int compare_aff_metadata_segments(char *title,AFFILE *af1,AFFILE *af2,const char *segname,int mode)
216 {
217 int ret = 0;
218
219 unsigned long arg1 = 0;
220 size_t data1_len = 0;
221 int r1 = af_get_seg(af1,segname,&arg1,0,&data1_len);
222
223 unsigned long arg2 = 0;
224 size_t data2_len = 0;
225 int r2 = af_get_seg(af2,segname,&arg2,0,&data2_len);
226
227 if(r1==0 && r2!=0){
228 if(mode==1){
229 print_title(title);
230 printf(" %s \n",segname);
231 }
232 return 1;
233 }
234
235 if(r1!=0 && r2==0){
236 if(mode==2){
237 print_title(title);
238 printf(" %s \n",segname);
239 }
240 return 1;
241 }
242 if(mode!=3) return 0; // only report differences in mode 3
243 /* Get the actual data... */
244
245 unsigned char *data1 = (unsigned char *)malloc(data1_len);
246 unsigned char *data2 = (unsigned char *)malloc(data2_len);
247
248 int s1 = af_get_seg(af1,segname,&arg1,data1,&data1_len);
249 if(s1!=0) err(1,"Couldn't read data segment %s in %s",segname,af_filename(af1));
250
251 int s2 = af_get_seg(af2,segname,&arg2,data2,&data2_len);
252 if(s2!=0) err(1,"Couldn't read data segment %s in %s",segname,af_filename(af2));
253
254 int mcr = 0;
255
256 if(data1_len != data2_len) mcr = 1;
257 else mcr = memcmp(data1,data2,data1_len);
258 if(arg1!=arg2 || data1_len!=data2_len || mcr!=0){
259 print_title(title);
260 print_info('<',segname,arg1,data1_len,data1,mcr);
261 print_info('>',segname,arg2,data2_len,data2,mcr);
262 if(mcr){
263 printf(" *** Metadata segment are different ");
264 if(strcmp(segname,AF_BADFLAG)==0){
265 printf("(bad flags should be different!)");
266 }
267 putchar('\n');
268 }
269 putchar('\n');
270 ret = 1;
271 }
272 else {
273 if(opt_all){
274 print_title(title);
275 printf(" %s (same in both) \n",segname);
276 }
277 }
278 free(data1);
279 free(data2);
280 return ret;
281 }
282
283 int compare_aff_data_segments(char *title,AFFILE *af1,AFFILE *af2,int64_t pagenum,int mode)
284 {
285 int ret = 0;
286 char pagename[65];
287 snprintf(pagename,sizeof(pagename),AF_PAGE,pagenum);
288
289 char segname[65];
290 snprintf(segname,sizeof(segname),AF_SEG_D,pagenum);
291
292 unsigned long arg1=0;
293 size_t data1_len=0;
294 int r1 = af_get_seg(af1,pagename,&arg1,0,&data1_len);
295 if(r1==-1) r1=af_get_seg(af1,segname,&arg1,0,&data1_len);
296
297 unsigned long arg2=0;
298 size_t data2_len=0;
299 int r2 = af_get_seg(af2,pagename,&arg2,0,&data2_len);
300 if(r2 == -1) r2=af_get_seg(af2,segname,&arg2,0,&data2_len);
301
302 if(r1<0 && r2<0) return 0; // no data segment in either file
303 if(r1==0 && r2!=0){
304 if(mode==1){
305 print_title(title);
306 printf(" %s \n",pagename);
307 }
308 return 1;
309 }
310
311 if(r2==0 && r1!=0){
312 if(mode==2){
313 print_title(title);
314 printf(" %s \n",pagename);
315 }
316 return 1;
317 }
318 if(mode!=3) return 0; // only report differences in mode 3
319
320 /* Get the actual data... */
321 unsigned char *data1 = (unsigned char *)malloc(af_page_size(af1));
322 unsigned char *data2 = (unsigned char *)malloc(af_page_size(af2));
323
324 data1_len = af_page_size(af1);
325 data2_len = af_page_size(af2);
326
327 uint64_t start_sector_number = (pagenum * data1_len) / af1->image_sectorsize;
328
329 /* Find the size of each page, then get the page */
330 if(af_get_page(af1,pagenum,0,&data1_len)<0)
331 err(1,"Cannot read page %"I64d" size from %s\n",pagenum,af_filename(af1));
332 if(af_get_page(af1,pagenum,data1,&data1_len)<0)
333 err(1,"Cannot read page %"I64d" from %s",pagenum,af_filename(af1));
334
335 if(af_get_page(af2,pagenum,0,&data2_len)<0)
336 err(1,"Cannot read page %"I64d" size from %s\n",pagenum,af_filename(af2));
337 if(af_get_page(af2,pagenum,data2,&data2_len)<0)
338 err(1,"Cannot read page %"I64d" from %s",pagenum,af_filename(af2));
339
340 if(data1_len != data2_len){
341 printf("page %"I64d" size %zd != size %zd\n",pagenum,data1_len,data2_len);
342 return 1;
343 }
344
345 /* Now look at the pages sector-by-sector. */
346 int af1_bad=0;
347 int af2_bad=0;
348 int matching_bad_sectors = 0;
349 int matching_sectors = 0;
350 int total_sectors = 0;
351 int no_match = 0;
352 vector<uint64_t> different_sectors;
353
354 for(unsigned int offset=0;offset<data1_len;offset+=af1->image_sectorsize){
355 uint64_t this_sector = start_sector_number + offset/af1->image_sectorsize;
356 total_sectors++;
357 if(af_is_badsector(af1,data1+offset) &&
358 af_is_badsector(af2,data2+offset)){
359 matching_bad_sectors++;
360 continue;
361 }
362 if(af_is_badsector(af1,data1+offset)){
363 af1_bad++;
364 continue;
365 }
366 if(af_is_badsector(af2,data2+offset)){
367 af2_bad++;
368 continue;
369 }
370 if(memcmp(data1+offset,data2+offset,af1->image_sectorsize)==0){
371 matching_sectors++;
372 continue;
373 }
374 no_match++;
375 different_sectors.push_back(this_sector);
376 }
377
378 char outline[256];
379 outline[0] = 0;
380 if(opt_all || (no_match>0) || af1_bad || af2_bad){
381 snprintf(outline,sizeof(outline),
382 " page%"I64d" sectors:%4d matching: %3d different:%3d",
383 pagenum,total_sectors,matching_sectors,no_match);
384 }
385 if(af1_bad){
386 snprintf(outline+strlen(outline),sizeof(outline)-strlen(outline),
387 " file 1 bad: %3d ",af1_bad);
388 }
389 if(af2_bad){
390 snprintf(outline+strlen(outline),sizeof(outline)-strlen(outline),
391 " file 2 bad: %3d ",af2_bad);
392 }
393 if(matching_bad_sectors){
394 if(opt_all){
395 snprintf(outline+strlen(outline),sizeof(outline)-strlen(outline),
396 " bad both:%3d ",matching_bad_sectors);
397 }
398 }
399
400 if(outline[0]){
401 print_title(title);
402 puts(outline);
403 }
404 if(opt_print_sectors && different_sectors.size()>0){
405 print_title(title);
406 printf(" Sectors with differences:");
407 int i=0;
408 for(vector<uint64_t>::iterator j = different_sectors.begin();
409 j != different_sectors.end();
410 j++){
411 if(i==0){
412 printf("\n ");
413 }
414 printf(" %"I64d,*j);
415 i = (i+1) % 10;
416 }
417 putchar('\n');
418 ret = 1;
419 }
420 if(opt_print_sector_contents && different_sectors.size()>0){
421 print_title(title);
422 printf(" Sectors with differences:");
423 for(vector<uint64_t>::iterator j = different_sectors.begin();
424 j != different_sectors.end(); j++){
425 int offset = (*j - start_sector_number)*af1->image_sectorsize;
426 char b2[16];
427 printf("offset=%d\n",offset);
428
429 memcpy(b2,data1+offset,16);
430 b2[15]=0;
431
432 printf("=== sector %"I64d" (offset=%d) ===\n",*j,offset);
433 printf(" %s:\n",af_filename(af1));
434 print_sector(af1,data1+offset);
435 printf("-------------------------------------\n");
436 printf(" %s:\n",af_filename(af2));
437 print_sector(af2,data2+offset);
438 printf("=====================================\n\n");
439 }
440 ret = 1;
441 }
442 free(data1);
443 free(data2);
444 return ret;
445 }
446
447 /* Compare the results of two files that were preened */
448 int compare_preen(AFFILE *af1,AFFILE *af2)
449 {
450 vector<int64_t> pages;
451 int comp_zero=0;
452 int comp_lzma=0;
453 int comp_unchanged=0;
454 uint64_t bytes_old = 0;
455 uint64_t bytes_new = 0;
456
457 af_rewind_seg(af1);
458 /* Build a list of all the pages */
459 char segname[AF_MAX_NAME_LEN];
460 while(af_get_next_seg(af1,segname,sizeof(segname),0,0,0)==0){
461 int64_t pagenumber = af_segname_page_number(segname);
462 if(pagenumber>=0) pages.push_back(pagenumber);
463 }
464 /* Now, compare each one */
465 for(vector<int64_t>::const_iterator i = pages.begin(); i != pages.end(); i++){
466 unsigned long arg1,arg2;
467 size_t len1,len2;
468
469 if(af_get_page_raw(af1,*i,&arg1,0,&len1)){
470 err(1,"Could not read page %"I64d" in file %s\n",*i,af_filename(af1));
471 }
472 if(af_get_page_raw(af2,*i,&arg2,0,&len2)){
473 err(1,"Page %"I64d" is in file %s but not in %s\n",*i,af_filename(af1),
474 af_filename(af2));
475 }
476 if(arg1==arg2 && len1==len2){
477 comp_unchanged++;
478 continue;
479 }
480 if((arg2 & AF_PAGE_COMP_ALG_MASK)==AF_PAGE_COMP_ALG_ZERO){
481 comp_zero++;
482 continue;
483 }
484 if((arg2 & AF_PAGE_COMP_ALG_MASK)==AF_PAGE_COMP_ALG_LZMA){
485 comp_lzma++;
486 bytes_old += len1;
487 bytes_new += len2;
488 continue;
489 }
490 }
491 printf("%s -> %s Nochg: %d NUL: %d LZMA: %d old: %"I64d" new: %"I64d" LZred: %6.2f%%\n",
492 af_filename(af1),
493 af_filename(af2),
494 comp_unchanged,comp_zero,comp_lzma,bytes_old,bytes_new,(bytes_old-bytes_new)*100.0/bytes_old);
495 return 0;
496 }
497
498
499 /* Compare two AFF files.
500 * Return 0 if they are equal.
501 */
502 int compare_aff_aff(const char *file1,const char *file2)
503 {
504 bool no_data_segments = false;
505 int ret = 0;
506
507 current_source = file1;
508
509 if(opt_all) printf("compare %s and %s:\n",file1,file2);
510
511 AFFILE *af1 = af_open(file1,O_RDONLY,0);
512 if(!af1) af_err(1,"af_open(%s)",file1);
513
514 AFFILE *af2 = af_open(file2,O_RDONLY,0);
515 if(!af2) af_err(1,"af_open(%s)",file2);
516
517 af_vnode_info vni1,vni2;
518
519 if(af_vstat(af1,&vni1) || af_vstat(af2,&vni2)){
520 err(1,"af_vstat failed?");
521 }
522
523 if(af_cannot_decrypt(af1) != af_cannot_decrypt(af2)){
524 printf("%s: %s decrypt\n",file1,af_cannot_decrypt(af1) ? "cannot" : "can");
525 printf("%s: %s decrypt\n",file2,af_cannot_decrypt(af2) ? "cannot" : "can");
526 fprintf(stderr,"afcompare must be able to decrypt both files or neither of the files.\n");
527 exit(1);
528 }
529
530 if(af1->image_pagesize != af2->image_pagesize){
531 fprintf(stderr,"Currently, %s requires that both images have the "
532 "same image datsegsize.\n"
533 "pagesize(%s)=%ld\n"
534 "pagesize(%s)=%ld\n",
535 progname,file1,af1->image_pagesize,
536 file2,af2->image_pagesize);
537 fprintf(stderr,"Data segments will be ignored.\n");
538 no_data_segments = true;
539 }
540
541 if(af1->image_sectorsize != af2->image_sectorsize){
542 fprintf(stderr,"Currently, %s requires that both images have the "
543 "same image sectorsize.\n"
544 "sectorsize(%s)=%ld\n"
545 "sectorsize(%s)=%ld\n",
546 progname,file1,af1->image_sectorsize, file2,af2->image_sectorsize);
547 fprintf(stderr,"Data segments will be ignored.\n");
548 no_data_segments = true;
549 }
550
551 if(opt_preen){
552 compare_preen(af1,af2);
553 af_close(af1);
554 af_close(af2);
555 return 0;
556 }
557
558 if(opt_s3){
559 printf("bypass\n");
560 seglist list1(af1);
561 seglist list2(af2);
562
563 /* Just compare the presence/absence of each segment */
564 char title[1024];
565 snprintf(title,sizeof(title),"\nPresent in %s but not %s:",af_filename(af1),af_filename(af2));
566 for(seglist::const_iterator i=list1.begin(); i!=list1.end(); i++){
567 if(find(list2.begin(),list2.end(),*i)==list2.end()){
568 print_title(title);
569 printf(" %s\n",(*i).name.c_str());
570 }
571 }
572 snprintf(title,sizeof(title),"\nPresent in %s but not %s:",af_filename(af2),af_filename(af1));
573 for(seglist::const_iterator i=list2.begin(); i!=list2.end(); i++){
574 if(find(list1.begin(),list1.end(),*i)==list1.end()){
575 print_title(title);
576 printf(" %s\n",(*i).name.c_str());
577 }
578 }
579 return 0;
580 }
581
582 /* Compare all of the metadata segments in af1 with a2.
583 * Report those that are missing or different. Then report
584 * all of the segments in a2 but not in af1
585 */
586
587 /* First build a list of the segments in each */
588
589 vector <string> segs_with_dups;
590
591 AFFILE *af[2] = {af1,af2};
592 for(int i=0;i<2;i++){
593 if(opt_verbose) printf("\n%s:\n",af_filename(af[i]));
594 af_rewind_seg(af[i]);
595 char segname[AF_MAX_NAME_LEN];
596 while(af_get_next_seg(af[i],segname,sizeof(segname),0,0,0)==0){
597 if(segname[0]){
598 string s;
599 s = segname;
600 segs_with_dups.push_back(s); // may give duplicates
601 if(opt_verbose) printf(" %s\n",segname);
602 }
603 }
604 }
605 sort(segs_with_dups.begin(),segs_with_dups.end());
606 vector<string>segs;
607
608 /* Make a list of segs without duplicates */
609 string last;
610 for(vector<string>::iterator i = segs_with_dups.begin();
611 i != segs_with_dups.end(); i++){
612 if(last != *i){
613 segs.push_back(*i);
614 }
615 last = *i;
616 }
617
618 int lowest_page = -1;
619 int highest_page = -1;
620 /* Scan for the lowest and highest numbers */
621 for(vector<string>::iterator i = segs.begin();i != segs.end(); i++){
622 int64_t num = af_segname_page_number(i->c_str());
623 if(num!=-1){
624 if(num<lowest_page ||lowest_page==-1) lowest_page = num;
625 if(num>highest_page||highest_page==-1) highest_page = num;
626 }
627 }
628
629
630 if(opt_page != -1){
631 lowest_page = opt_page;
632 highest_page = opt_page;
633 }
634
635
636 if(opt_page == -1
637 && vni1.supports_metadata
638 && vni2.supports_metadata
639 && opt_ignore_metadata==0 ){
640 if(opt_all) puts("Inspecting metadata...");
641 for(int mode=1;mode<=3;mode++){
642 const char *title = "Metadata segments ";
643 char mode_title[1024];
644 switch(mode){
645 case 1:
646 snprintf(mode_title,sizeof(mode_title)," %s only in %s:\n",
647 title,af_filename(af1));
648 break;
649 case 2:
650 snprintf(mode_title,sizeof(mode_title)," %s only in %s:\n",
651 title,af_filename(af2));
652 break;
653 case 3:
654 snprintf(mode_title,sizeof(mode_title)," %s in both files:\n",title);
655 break;
656 }
657
658 for(vector<string>::iterator i = segs.begin();i != segs.end();i++){
659 int64_t num = af_segname_page_number(i->c_str());
660 if(num==-1){
661 int r = compare_aff_metadata_segments(mode_title, af1,af2,
662 i->c_str(),mode);
663 if(r!=0) ret = r;
664 }
665 }
666 }
667 }
668
669 if(no_data_segments==false){
670 if(opt_all) puts("Inspecting data...");
671 for(int mode=1;mode<=3;mode++){
672 char mode_title[1024];
673 switch(mode){
674 case 1: snprintf(mode_title,sizeof(mode_title),
675 " Pages only in %s:\n", af_filename(af1));break;
676 case 2: snprintf(mode_title,sizeof(mode_title),
677 " Pages only in %s:\n", af_filename(af2));break;
678 case 3: snprintf(mode_title,sizeof(mode_title)," Pages in both files:\n");break;
679 }
680
681 for(int i=lowest_page;i<=highest_page;i++){
682 int r = compare_aff_data_segments(mode_title,af1,af2,i,mode);
683 if(r!=0) ret = r;
684 }
685 }
686 }
687 current_source = 0;
688 #ifdef HAVE_ISATTY
689 if(ret==0 && isatty(fileno(stdout))) printf("%s and %s: files compare okay\n",file1,file2);
690 #endif
691 return ret;
692 }
693
694 int recurse(const char *dir1,const char *dir2)
695 {
696 vector<string> only_in_dir1;
697
698 DIR *dirp = opendir(dir1);
699 struct dirent *dp;
700 if(!dirp) err(1,"opendir: %s",dir1);
701 while ((dp = readdir(dirp)) != NULL){
702
703 char fn1[MAXPATHLEN+1]; memset(fn1,0,sizeof(fn1));
704 char fn2[MAXPATHLEN+1]; memset(fn2,0,sizeof(fn2));
705
706 strlcpy(fn1,dir1,sizeof(fn1));
707 if(fn1[strlen(fn1)-1]!='/') strlcat(fn1,"/",sizeof(fn1));
708 strlcat(fn1,dp->d_name,sizeof(fn1));
709
710 current_source = fn1;
711 if(opt_verbose) printf("%s...\n",fn1);
712
713 switch(af_identify_file_type(fn1,1)){
714 case AF_IDENTIFY_ERR:
715 case AF_IDENTIFY_NOEXIST:
716 only_in_dir1.push_back(fn1);
717 break;
718 case AF_IDENTIFY_AFF:
719 case AF_IDENTIFY_AFD:
720 case AF_IDENTIFY_AFM:
721 strlcpy(fn2,dir2,sizeof(fn2));
722 if(fn2[strlen(fn2)-1]!='/') strlcat(fn2,"/",sizeof(fn2));
723 strlcat(fn2,dp->d_name,sizeof(fn2));
724 if(af_identify_file_type(fn2,1)<0){
725 char buf[1024];
726 snprintf(buf,sizeof(buf),"%s not in %s\n",dp->d_name,dir2);
727 errors.push_back(buf);
728 break;
729 }
730 if(opt_exist==0){
731 compare_aff_aff(fn1,fn2);
732 }
733 break;
734 default:
735 break;
736 }
737 }
738 closedir(dirp);
739 printf("========================\n");
740 printf("Only in %s\n",dir1);
741 for(vector<string>::const_iterator i = only_in_dir1.begin();
742 i != only_in_dir1.end();
743 i++){
744 printf("%s\n",i->c_str());
745 }
746 return 0;
747 }
748
749 int main(int argc,char **argv)
750 {
751 int bflag, ch;
752 int opt_recurse=0;
753
754 #ifdef SIGINFO
755 signal(SIGINFO,sig_info);
756 #endif
757
758 bflag = 0;
759 while ((ch = getopt(argc, argv, "P:Vabcempqrsh?v")) != -1) {
760 switch (ch) {
761 case 'P': opt_page = atoi(optarg); break;
762 case 'V': printf("%s version %s\n",progname,PACKAGE_VERSION); exit(0);
763 case 'a': opt_all++; break;
764 case 'b': opt_print_sectors=1; break;
765 case 'c': opt_print_sector_contents=1; break;
766 case 'e': opt_exist++; break;
767 case 'm': opt_ignore_metadata++; break;
768 case 'p': opt_preen++; break;
769 case 'q': opt_quiet++; break;
770 case 'r': opt_recurse++; break;
771 case 's': opt_s3++;break;
772 case 'v': opt_verbose++;break;
773 case 'h':
774 case '?':
775 default:
776 usage();
777 }
778 }
779 argc -= optind;
780 argv += optind;
781
782 if(opt_recurse){
783 if(argc!=2) usage();
784 char *dir1 = *argv++;
785 char *dir2 = *argv++;
786 recurse(dir1,dir2);
787 if(errors.size()>0){
788 fprintf(stderr,"================================\n");
789 fprintf(stderr,"%zd afcompare errors:\n",errors.size());
790 for(vector<string>::const_iterator i=errors.begin();
791 i!=errors.end();
792 i++){
793 fputs(i->c_str(),stderr);
794 }
795 exit(1);
796 }
797 exit(0);
798 }
799
800 if(argc>1){
801 char *last = argv[argc-1];
802 if(last[strlen(last)-1]=='/'){
803 while(argc>1){
804 char *file1 = *argv;
805 char *name1 = file1;
806 char *cc;
807
808 cc = strrchr(file1,'/');
809 if(cc) name1 = cc+1;
810
811 char file2[MAXPATHLEN+1];
812 strlcpy(file2,last,sizeof(file2));
813 strlcat(file2,name1,sizeof(file2));
814 int e_code = compare_aff_aff(file1,file2);
815 if(e_code) exit(e_code);
816 argv++;
817 argc--;
818 }
819 }
820 }
821
822 if(argc!=2) usage(); // if just 2, compare them
823
824 char *file1 = *argv++;
825 char *file2 = *argv++;
826
827 if(opt_verbose) printf("%s...\n",file1);
828 int e_code = compare_aff_aff(file1,file2);
829 exit(e_code);
830 }
0 /*
1 * afconvert.cpp:
2 *
3 * Convert raw -> aff
4 * aff -> raw
5 * aff -> aff (recompressing/uncompressing)
6 */
7
8 /*
9 * Copyright (c) 2005--2008
10 * Simson L. Garfinkel and Basis Technology, Inc.
11 * All rights reserved.
12 *
13 * This code is derrived from software contributed by
14 * Simson L. Garfinkel
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by Simson L. Garfinkel,
27 * Basis Technology, and its contributors.
28 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
29 * contributors to this program may be used to endorse or promote
30 * products derived from this software without specific prior written
31 * permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
34 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
35 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
36 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
38 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
41 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
44 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * SUCH DAMAGE.
46 */
47
48
49
50 #include "affconfig.h"
51 #include "afflib.h"
52 #include "afflib_i.h" // we do enough mucking, we need the internal version
53 #include "utils.h"
54
55 #include <openssl/md5.h>
56 #include <openssl/sha.h>
57
58 #ifdef WIN32
59 #include "unix4win32.h"
60 #endif
61
62 #ifdef HAVE_CURSES_H
63 #include <curses.h>
64 #endif
65
66 #ifdef HAVE_TERM_H
67 #include <term.h>
68 #endif
69
70
71 #ifdef HAVE_SYS_TIME_H
72 #include <sys/time.h>
73 #endif
74
75 #include <sys/stat.h>
76 #include <string>
77
78 #ifdef HAVE_UNISTD_H
79 #include <unistd.h>
80 #endif
81
82 #ifdef HAVE_GETOPT_H
83 #include <getopt.h>
84 #endif
85
86
87
88 const char *progname = "afconvert";
89
90 int image_pagesize = 16*1024*1024; // default seg size --- 16MB
91 int opt_compression_alg = AF_COMPRESSION_ALG_ZLIB;
92 int opt_compress_level = AF_COMPRESSION_DEFAULT;
93 int64_t bytes_to_convert = 0;
94 int opt_batch = 1;
95 int opt_zap = 0;
96 int opt_quiet = 0;
97 int opt_write_raw = 0; // output
98 int opt_probe_compressed = 1; // probe for compressed files
99 const char *opt_write_raw_ext = "raw";
100 const char *opt_outdir = 0;
101 const char *opt_aff_ext = "aff";
102 int64_t opt_maxsize = 0;
103 int opt_yes = 0;
104 int opt_debug = 0;
105 std::string command_line;
106
107
108 char *append(char *base,const char *str)
109 {
110 base = (char *)realloc(base,strlen(base)+strlen(str)+1);
111 strcat(base,str); // can't fail
112 return base;
113 }
114
115
116
117 void usage()
118 {
119 printf("%s version %s\n",progname,PACKAGE_VERSION);
120 printf("\n");
121 printf("usage: %s [options] file1 [... files] \n",progname);
122 printf("\n");
123 printf("examples:\n");
124 printf(" %s file1.iso --- convert file1.iso to file1.aff\n",progname);
125 printf(" %s file1.iso file2.iso file3.iso... --- batch convert files\n",progname);
126 printf(" %s -r -e iso image.aff --- convert image.aff to image.iso\n",progname);
127 printf(" %s -M4g -o/media/dvd.afd bigfile.aff --- split an AFF file into 4GB chunks for archiving to DVD\n",
128 progname);
129 //printf(" %s -p image.aff --- recompress image.aff to maximum compression\n",progname);
130 printf("\n");
131 printf("\nGeneral options:\n");
132 printf(" -q -- Quiet mode. Don't ask questions, don't print status.\n");
133
134 printf("\nAFF output options:\n");
135 printf(" -a ext -- use 'ext' for aff files (default is %s)\n",opt_aff_ext);
136 printf(" (use .afd for AFD files)\n");
137 printf(" -Mn[kgm] -- set maximum size of output file. Suffix with g, m or k.\n");
138 printf(" -sn -- set the image_pagesize (default %d)\n",image_pagesize);
139 printf(" -x -- don't compress AFF file.\n");
140 printf(" -O dir -- use 'dir' as the output directory\n");
141 printf(" -o file -- output to 'file' (can only convert one at a time)\n");
142 printf(" File is AFF is file ends .aff; otherwise assumes raw.\n");
143 printf(" -Xn -- Set compression to n; default is 7\n");
144 printf(" -L -- Use the LZMA compression algorithm (better but slower)\n");
145
146 printf("\nRaw output options:\n");
147 printf(" -r -- force raw output. \n");
148 printf(" -e ext -- use 'ext' for the raw files (default %s)\n",opt_write_raw_ext);
149 printf(" (implies -r)\n");
150
151 printf("\nDangerous input options:\n");
152 printf(" -z -- zap; delete the output file if it already exists.\n");
153 printf(" -Z -- Do not automatically probe for gzip/bzip2 compression.\n");
154 printf(" -y -- Always answer yes/no questions 'yes.'\n");
155 printf(" -V = Just print the version number and exit.\n");
156 printf("\n");
157 exit(0);
158 }
159
160
161 /* probe_gzip():
162 * Is this a gzip file?
163 * Right now it just looks at the file extension.
164 */
165
166 int probe_gzip(const char *infile)
167 {
168 int len = strlen(infile);
169
170 if(len>3 && strcmp(infile+len-3,".gz")==0){
171 return 1;
172 }
173 return 0;
174 }
175
176 int probe_bzip2(const char *infile)
177 {
178 int len = strlen(infile);
179
180 if(len>4 && strcmp(infile+len-4,".bz2")==0){
181 return 1;
182 }
183 return 0;
184 }
185
186 /* yesno():
187 * As a yes/no question. Return 1 if yes, 0 if no.
188 */
189
190 int yesno(const char *statement,const char *question,const char *affirmative)
191 {
192 if(opt_yes){
193 if(!opt_quiet) printf("%s. %s.\n",statement,affirmative);
194 return 1;
195 }
196
197 printf("%s. ",statement);
198 char buf[256];
199 do {
200 printf("%s [y/n]: ",question);
201 memset(buf,0,sizeof(buf));
202 if(fgets(buf,sizeof(buf)-1,stdin)==0) return 0;
203 if(buf[0]=='y' || buf[0]=='Y'){
204 printf("%s.\n",affirmative);
205 return 1;
206 }
207 } while(buf[0]!='n' && buf[0]!='N');
208 return 0;
209 }
210
211
212 /*
213 * Basic conversion:
214 * We have an input, which may be raw or aff,
215 * and we have an output, which may be raw or aff.
216 * We are going to want to read a segment at a time.
217 */
218
219
220 #include <algorithm>
221 #include <cstdlib>
222 #include <vector>
223 #include <string>
224
225 #ifdef HAVE_CSTRING
226 #include <cstring>
227 #endif
228
229
230 using namespace std;
231
232 /** Do the conversion.
233 * return 0 if success, code if fail.
234 */
235 int convert(const char *infile,char *outfile)
236 {
237
238 if(opt_debug) fprintf(stderr,"convert(%s,%s)\n",infile,outfile);
239
240 if(infile && outfile && strcmp(infile,outfile)==0){
241 errx(1,"Can't convert a file to itself\n");
242 }
243
244 /****************************************************************
245 *** Open Input
246 ****************************************************************/
247
248 AFFILE *a_in = 0; // input file, if aff
249
250 #ifdef UNIX
251 /* Check to see if it is a gzip file... */
252 if(opt_probe_compressed
253 && probe_gzip(infile)
254 && yesno("infile looks like a gzip file","Uncompress it","Uncompressing")){
255 /* Open with a subprocess. We will need to use zlib when we move to Windows. */
256 if(af_hasmeta(infile)) return -1; // don't covert with shell metacharacters
257 char buf[256];
258 snprintf(buf,sizeof(buf),"gzcat %s",infile);
259 a_in = af_popen(buf,"r");
260 }
261
262 /* Check to see if it is a bzip2 file... */
263 if(!a_in
264 && opt_probe_compressed
265 && probe_bzip2(infile)
266 && yesno("infile looks like a bzip2 file","Uncompress it","Uncompressing")){
267 /* Open with a subprocess. We will need to use bzip2zlib when we move to Windows. */
268 if(af_hasmeta(infile)) return -1; // don't covert with shell metacharacters
269 char buf[256];
270 snprintf(buf,sizeof(buf),"bzcat %s",infile);
271 a_in = af_popen(buf,"r");
272 }
273 #endif
274
275 /* If the file isn't open, try to open it... */
276 if(!a_in){
277 a_in = af_open(infile,O_RDONLY,0);
278 if(!a_in) af_err(1,"%s",infile); // give up
279 if(af_identify(a_in)==AF_IDENTIFY_RAW){
280 af_set_pagesize(a_in,image_pagesize); // match the page size we want to use
281 }
282 else {
283 image_pagesize = a_in->image_pagesize; // that's what we are using
284 }
285 }
286
287 const char *ain_fn = af_filename(a_in);
288 struct stat si;
289 memset((char *)&si,0,sizeof(si));
290 if(ain_fn && stat(ain_fn,&si)){
291 warn("Cannot stat %s",ain_fn);
292 }
293
294
295 /****************************************************************
296 *** Open Ouptut
297 ****************************************************************/
298
299
300 if(opt_zap) unlink(outfile); // we were told to zap it
301
302 AFFILE *a_out = 0; // output file, if aff or raw...
303 if(access(outfile,F_OK)==0){
304 /* If outfile is a device, ask user... */
305 struct stat so;
306 if(stat(outfile,&so)){
307 err(1,"%s exists but can't be stat?",outfile);
308 }
309 if((so.st_mode & S_IFMT)==S_IFCHR ||
310 (so.st_mode & S_IFMT)==S_IFBLK){
311 char buf[1024];
312 snprintf(buf,sizeof(buf),"%s is a raw device.\n",outfile);
313 if(yesno(buf,"Overwrite raw device?","yes")){
314 goto doit;
315 }
316 }
317 fprintf(stderr,"%s: file exists. Delete it before converting.\n",outfile);
318 exit(-1);
319 }
320 /* Check for splitraw names */
321 if(af_ext_is(outfile,"afm")){
322 char file000[MAXPATHLEN+1];
323 strlcpy(file000,outfile,sizeof(file000));
324 char *cc = strrchr(file000,'.');
325 if(!cc) err(1,"Cannot file '.' in %s\n",file000);
326 for(int i=0;i<2;i++){
327 sprintf(cc,".%03d",i);
328 if(access(file000,F_OK)==0){
329 fprintf(stderr,"%s: file exists. Delete it before converting.\n",file000);
330 fprintf(stderr,"NOTE: -z option will not delete %s\n",file000);
331 return -1;
332 }
333 }
334 }
335
336 doit:;
337
338 if(opt_write_raw){
339 /* Easy way to make a raw output is to reopen an existing output file... */
340 FILE *f = fopen(outfile,"w+b");
341 if(!f){
342 err(1,"%s",outfile);
343 }
344 a_out = af_freopen(f);
345 }
346 else {
347 a_out = af_open(outfile,O_RDWR|O_CREAT|O_BINARY,0777);
348 if(!a_out) af_err(1,"%s",outfile);
349 if(opt_maxsize){
350 af_set_maxsize(a_out,opt_maxsize);
351 }
352
353 }
354 if(a_out == 0) af_err(1,"af_open: %s",outfile);
355
356 if(!opt_quiet) printf("convert %s --> %s\n",infile,outfile);
357
358 af_update_seg(a_out,AF_ACQUISITION_COMMAND_LINE,0,
359 (const u_char *)command_line.c_str(),
360 command_line.size());
361
362 /****************************************************************
363 *** Set up the AFF file (assuming it's an aff file)
364 *** stuff that we keep at the beginning of the file...
365 ****************************************************************/
366
367 MD5_CTX md5;
368 MD5_Init(&md5);
369
370 SHA_CTX sha;
371 SHA1_Init(&sha);
372
373 /* Setup writing */
374 if(a_in->image_pagesize){
375 image_pagesize = a_in->image_pagesize;
376 }
377 af_set_pagesize(a_out,image_pagesize);
378 af_set_sectorsize(a_out,a_in->image_sectorsize);
379
380 struct af_vnode_info vni;
381 af_vstat(a_out,&vni);
382 if(vni.supports_compression){
383 if(opt_compression_alg){
384 af_enable_compression(a_out,opt_compression_alg,opt_compress_level);
385 }
386 else{
387 af_enable_compression(a_out,0,0);
388 }
389 }
390
391 /* Get a list of all the metadata segments and the pages
392 * (if this is a raw file, then the vnode raw driver will give us those segments)
393 */
394
395 char segname[AF_MAX_NAME_LEN];
396 vector <string> metadata_segments;
397 vector <int64_t> pages;
398 af_rewind_seg(a_in); // start at the beginning
399 int64_t highest_pagenum = 0;
400 while(af_get_next_seg(a_in,segname,sizeof(segname),0,0,0)==0){
401 int64_t page_num = af_segname_page_number(segname);
402 if(page_num>=0){
403 pages.push_back(page_num);
404 if(page_num>highest_pagenum) highest_pagenum = page_num;
405 }
406 else {
407 metadata_segments.push_back(segname);
408 }
409 }
410
411 /* Copy over all of the metadata segments.
412 * But don't bother if we are creating raw output
413 */
414 if(opt_write_raw==0){
415 for(vector<string>::iterator i = metadata_segments.begin();
416 i != metadata_segments.end();
417 i++){
418 strlcpy(segname,i->c_str(),sizeof(segname));
419 size_t data_len = 0;
420 unsigned long arg;
421
422 /* First find out how big the segment is */
423 if(af_get_seg(a_in,segname,&arg,0,&data_len)){
424 warn("af_get_seg_1");
425 continue;
426 }
427 /* Now get the data */
428 unsigned char *data = (unsigned char *)malloc(data_len);
429 if(af_get_seg(a_in,segname,0,data,&data_len)){
430 warn("af_get_seg_2");
431 free(data);
432 continue;
433 }
434 /* Now put the data */
435 if(af_update_seg(a_out,segname,arg,data,data_len)){
436 err(1,"af_update_seg");
437 }
438 free(data);
439 }
440 }
441
442 /* Now sort the pages and copy them over. If there is no break,
443 * we can compute the hashes...
444 */
445 sort(pages.begin(),pages.end());
446
447 int64_t prev_pagenum = -1;
448 bool hash_valid = true;
449 uint64_t last_byte_in_image = 0;
450 uint64_t total_bytes_converted = 0;
451
452 bool copy_by_pages = af_has_pages(a_in);
453
454 unsigned char *data = (unsigned char *)malloc(image_pagesize);
455 if(copy_by_pages){
456 /* Copy over data one page at a time */
457 for(vector<int64_t>::iterator i = pages.begin(); i != pages.end(); i++){
458
459 int64_t pagenum = *i;
460
461 if(!opt_quiet) printf("Converting page %"I64d" of %"I64d"\r",pagenum,highest_pagenum);fflush(stdout);
462
463 size_t data_len = image_pagesize;
464 if(af_get_page(a_in,pagenum,data,&data_len)){
465 err(1,"af_get_page(file=%s,page=%"I64d")",
466 af_filename(a_in),pagenum);
467 }
468 if(af_update_page(a_out,pagenum,data,data_len)){
469 err(1,"af_update_page(file=%s,page=%"I64d")",
470 af_filename(a_out),pagenum);
471 }
472
473 if(pagenum != prev_pagenum + 1) hash_valid = false;
474
475 if(hash_valid && vni.supports_metadata){
476 MD5_Update(&md5,data,data_len);
477 SHA1_Update(&sha,data,data_len);
478 prev_pagenum = pagenum;
479 }
480 last_byte_in_image = (int64_t)image_pagesize * pagenum + (int64_t)data_len;
481 total_bytes_converted += data_len;
482 }
483 /* Go back and update the image size (necessary since I have been writing page-by-page) */
484 if(af_update_segq(a_out,AF_IMAGESIZE,last_byte_in_image)
485 && errno!=ENOTSUP){
486 err(1,"Could not upate AF_IMAGESIZE");
487 }
488 } else {
489 /* No page support; Copy from beginning to end */
490 while(!af_eof(a_in)){
491 int data_len = af_read(a_in,data,image_pagesize);
492 if(data_len>0){
493 if(!opt_quiet){
494 printf("Writing to page %" I64d " with %d bytes read from input... \r",
495 total_bytes_converted / image_pagesize,data_len);
496 fflush(stdout);
497 }
498 if(af_write(a_out,data,data_len)!=data_len){
499 err(1,"af_write");
500 }
501 if(vni.supports_metadata){
502 MD5_Update(&md5,data,data_len);
503 SHA1_Update(&sha,data,data_len);
504 }
505 }
506 if(data_len<0) err(1,"af_read");
507 if(data_len==0){
508 if(!opt_quiet) printf("af_read returned 0. Reached a sparse region or end of pipe.\n");
509 break;
510 }
511 last_byte_in_image += data_len;
512 total_bytes_converted += data_len;
513 }
514 }
515 free(data);
516 if(!opt_quiet) printf("\n");
517
518 /* Write out the new hash if it is valid */
519 if(hash_valid && vni.supports_metadata){
520 u_char md5_buf[32],sha1_buf[40];
521 char buf[256];
522 MD5_Final(md5_buf,&md5);
523 if(af_update_seg(a_out,AF_MD5,0,md5_buf,16) && errno!=ENOTSUP){
524 err(1,"Could not update AF_MD5");
525 }
526 if(!opt_quiet) printf("md5: %s\n",af_hexbuf(buf,sizeof(buf),md5_buf,16,1));
527
528 SHA1_Final(sha1_buf,&sha);
529 if(af_update_seg(a_out,AF_SHA1,0,sha1_buf,20) && errno!=ENOTSUP){
530 err(1,"Could not update AF_SHA1");
531 }
532 if(!opt_quiet) printf("sha1: %s\n",af_hexbuf(buf,sizeof(buf),sha1_buf,20,1));
533 }
534
535 /* Finish the hash calculations and write to the db */
536 if(!opt_quiet){
537 printf("bytes converted: %"I64d" \n",total_bytes_converted);
538 /* If the vnode implementation tracked segments written, report it. */
539 if(a_out->pages_written || a_out->pages_compressed){
540 printf("Total pages: %"I64u" (%"I64u" compressed)\n",
541 a_out->pages_written,a_out->pages_compressed);
542 }
543 }
544
545 if(vni.supports_metadata){
546 /* make an AF_IMAGE_GID if it doesn't exist */
547 af_make_gid(a_out);
548 af_set_acquisition_date(a_out,si.st_mtime);
549 }
550
551 /* Make a copy of the a_out filename if we can get it */
552 char *a_out_fn=0; // output filename, to remember for utimes
553 const char *a_ = af_filename(a_out); // remember the output filename
554 if(a_){
555 a_out_fn = strdup(a_); // make a copy of it
556 }
557 if(af_close(a_out)) err(1,"af_close(a_out)");
558
559 if(!opt_quiet){
560 printf("Conversion finished.\n");
561 if(af_cannot_decrypt(a_in)){
562 printf("*** encrypted pages are present which could not be decrypted ***\n");
563 }
564 printf("\n\n");
565 }
566 if(af_close(a_in)) err(1,"af_close(a_in)");
567
568 /* Set the utime on the resulting file if we can stat it */
569 struct timeval times[2];
570
571 memset(times,0,sizeof(times));
572 times[0].tv_sec = si.st_atime;
573 times[1].tv_sec = si.st_mtime;
574 #ifdef HAVE_UTIMES
575 if(a_out_fn){
576 if(utimes(a_out_fn,times)) warn("utimes(%s):",outfile);
577 free(a_out_fn);
578 a_out_fn = 0;
579 }
580 #endif
581 return(0);
582 }
583
584
585 int64_t atoi64(const char *buf)
586 {
587 int64_t r=0;
588 sscanf(buf,"%"I64d,&r);
589 return r;
590 }
591
592 int64_t atoi64m(const char *optarg)
593 {
594 int multiplier;
595 switch(optarg[strlen(optarg)-1]){
596 case 'g':
597 case 'G':
598 multiplier=1024*1024*1024;break;
599 case 'm':
600 case 'M':
601 multiplier=1024*1024; break;
602 case 'k':
603 case 'K':
604 multiplier=1024; break;
605 case 'b':
606 case 'B':
607 multiplier=1;break;
608 default:
609 err(1,"Specify multiplier units of g, m, k or b in '%s'\n",optarg);
610 }
611 return atoi64(optarg) * multiplier;
612 }
613
614
615 int main(int argc,char **argv)
616 {
617 char *outfile = 0;
618 int ch;
619
620 command_line = aff::command_line(argc,argv);
621 while ((ch = getopt(argc, argv, "a:e:Lo:zqrs:xX:Zh?M:O::ydV")) != -1) {
622 switch (ch) {
623 case 'a':
624 opt_aff_ext = optarg;
625 break;
626 case 'e':
627 opt_write_raw++;
628 opt_write_raw_ext = optarg;
629 break;
630 case 'o':
631 outfile = optarg;
632 break;
633 case 'z':
634 opt_zap ++;
635 break;
636 case 'q':
637 opt_quiet++;
638 break;
639 case 'L':
640 opt_compression_alg = AF_COMPRESSION_ALG_LZMA;
641 break;
642 case 'r':
643 opt_write_raw++;
644 break;
645 case 's':
646 image_pagesize = atoi64m(optarg);
647 break;
648 case 'x':
649 opt_compression_alg=AF_COMPRESSION_ALG_NONE;
650 break;
651 case 'X':
652 opt_compress_level = atoi(optarg);
653 break;
654 case 'Z':
655 opt_probe_compressed = 0;
656 break;
657 case 'y':
658 opt_yes = 1;
659 break;
660 case 'M':
661 opt_maxsize = atoi64m(optarg);
662 break;
663 case 'O':
664 if(!optarg) err(1,"-O flag requires a directory");
665 opt_outdir = optarg;
666 break;
667 case 'd':
668 opt_debug++;
669 break;
670 case 'h':
671 case '?':
672 default:
673 usage();
674 exit(0);
675 case 'V':
676 printf("%s version %s\n",progname,PACKAGE_VERSION);
677 exit(0);
678
679 }
680 }
681 argc -= optind;
682 argv += optind;
683
684 if(argc<1){
685 usage();
686 }
687
688 if(outfile){
689 return convert(*argv,outfile);
690 }
691
692 /* Check for "-o filename" at the end of the command line... */
693 if(argc==3 && !strcmp(argv[1],"-o")){
694 return convert(argv[0],argv[2]);
695 }
696
697 /* Convert each file*/
698
699 while(*argv){
700 char outfile[MAXPATHLEN+1];
701 memset(outfile,0,sizeof(outfile));
702
703 const char *ext = opt_write_raw ? opt_write_raw_ext : opt_aff_ext;
704 char *infile = *argv;
705 argv++;
706 argc--;
707
708 /* Copy over the filename and change the extension */
709 strlcpy(outfile,infile,sizeof(outfile));
710 char *cc = strrchr(outfile,'.'); // to strip off extension
711 if(cc){
712 /* Found an extension; copy over mine. */
713 strlcpy(cc+1,ext,sizeof(outfile)-(cc-outfile));
714 }
715 else {
716 /* No extension; make one */
717 strlcat(outfile,".",sizeof(outfile));
718 strlcat(outfile,ext,sizeof(outfile));
719 }
720
721 /* The user might want us to put things
722 * in a different directory. Pull off the filename...
723 */
724 if(opt_outdir){
725 cc = strrchr(outfile,'/');
726 char filename[PATH_MAX];
727 if(cc){
728 strlcpy(filename,cc+1,sizeof(filename)); // just the filename
729 }
730 else{
731 strlcpy(filename,outfile,sizeof(filename)); // the outfile is the filename
732 }
733 strlcpy(outfile,opt_outdir,sizeof(outfile));
734 strlcat(outfile,"/",sizeof(outfile));
735 strlcat(outfile,filename,sizeof(outfile));
736 }
737 if(convert(infile,outfile)){
738 exit(1);
739 }
740 }
741 exit(0);
742 }
0 /*
1 * afcopy.cpp:
2 *
3 * Copy one AFF file to another.
4 * Resulting file is re-ordered and possibly re-compressed.
5 */
6
7 /*
8 * Copyright (c) 2006
9 * Simson L. Garfinkel
10 * All rights reserved.
11 *
12 * This code is derrived from software contributed by
13 * Simson L. Garfinkel
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. [Omitted]
24 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
25 * contributors to this program may be used to endorse or promote
26 * products derived from this software without specific prior written
27 * permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL AND CONTRIBUTORS ``AS
30 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SIMSON
33 * GARFINKEL, BAIS TECHNOLOGy, OR CONTRIBUTORS BE LIABLE FOR ANY
34 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
36 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
38 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
39 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
40 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 */
42
43
44 #include "affconfig.h"
45 #include "afflib.h"
46 #include "afflib_i.h"
47 #include "utils.h"
48 #include "base64.h"
49 #include "aff_bom.h"
50
51 using namespace std;
52 using namespace aff;
53
54 #ifdef HAVE_SYS_SIGNAL_H
55 #include <sys/signal.h>
56 #endif
57
58 #ifdef HAVE_TIME_H
59 #include <time.h>
60 #endif
61
62 #ifdef HAVE_SYS_TIME_H
63 #include <sys/time.h>
64 #endif
65
66 #include <ctype.h>
67 #include <zlib.h>
68 #include <openssl/md5.h>
69 #include <openssl/sha.h>
70 #include <assert.h>
71
72 #ifdef HAVE_UNISTD_H
73 #include <unistd.h>
74 #endif
75
76 #ifdef HAVE_TERM_H
77 #include <term.h>
78 #endif
79
80 #ifdef HAVE_NCURSES_TERM_H
81 #include <ncurses/term.h>
82 #endif
83
84 #ifdef WIN32
85 #include "unix4win32.h"
86 #endif
87
88 const char *progname = "afcopy";
89
90 int opt_verbose = 0;
91 int opt_debug = 0;
92 int opt_x = 0;
93 int opt_X = AF_COMPRESSION_DEFAULT;
94 int opt_noverify = 0;
95 int opt_preen = 0;
96 int opt_zap =0;
97 int opt_missing = 0;
98 int opt_preen_alg_arg = 0; // algorithm for recompressing
99 int opt_preen_alg_flag = 0;
100 int opt_sign = 0;
101
102 int opt_note = 0;
103 const char *opt_sign_key_file = 0;
104 const char *opt_sign_cert_file = 0;
105
106 void usage()
107 {
108 printf("%s version %s\n",progname,PACKAGE_VERSION);
109 printf("usage: %s [options] file1 file\n",progname);
110 printf(" Copies file1 to file2\n");
111 printf(" %s [options] file1 file2 file3 ... dir\n",progname);
112 printf(" Copies file1.. into dir\n");
113 printf(" %s [options] file1 file2 file3 ... dir1 dir2...\n",progname);
114 printf(" Copies file1.. into dirs1, dir2, ...\n");
115 printf("\n");
116 printf("By default, all page MACs are verified on read and all segments\n");
117 printf("are verified after write.\n");
118
119 printf("Options:\n");
120 printf(" -v = verbose: print each file as it is copied\n");
121 printf(" -vv = very verbose: print each segment as it is copied\n");
122 printf(" -d = print debugging information as well\n");
123 printf(" -x = don't verify hashes on reads\n");
124 printf(" -y = don't verify writes\n");
125 printf(" -Xn = recompress pages (preen) with zlib level n\n");
126 printf(" -L = recompress pages (preen) with LZMA (smaller but slower)\n");
127 printf("\n");
128 printf(" -h = help; print this message.\n");
129 printf(" -V = print the program version and exit.\n");
130 printf(" -z = zap; copy even if the destination exists.\n");
131 printf(" -m = just copy the missing segments\n");
132 printf("\nSignature Options:\n");
133 printf(" -k filename.key = specify private key for signing\n");
134 printf(" -c filename.cer = specify a X.509 certificate that matches the private key\n");
135 printf(" (by default, the file is assumed to be the same one\n");
136 printf(" provided with the -k option.)");
137 printf(" -n = read notes to accompany the copy from standard in.\n");
138 printf("\n");
139 printf("\nEncryption Options:");
140 printf(" Specify passphrase encryption for filename.aff with:\n");
141 printf(" file://:passphrase@/filename.aff\n");
142 printf("\n");
143 printf("Examples:\n");
144 printf(" %s file.aff file://:mypassword@/file-encrypted.aff - encrypt file.aff\n",progname);
145 #ifdef USE_S3
146 printf(" %s -vy -X9 *.aff s3:/// Copy all files in current\n",progname);
147 printf(" directory to S3 default bucket with X9 compression\n");
148 #endif
149 exit(1);
150 }
151
152
153 const char *current_source = 0;
154 const char *current_dest = 0;
155 const char *current_seg = 0;
156 void sig_info(int arg)
157 {
158 if(current_source){
159 printf("Copying %s ",current_source);
160 if(current_dest){
161 printf("--> %s",current_dest);
162 if(current_seg) printf(" (%s) ",current_seg);
163 }
164 }
165 printf("\n");
166 }
167
168
169 void unlink_outfiles(vector<string> outfiles)
170 {
171 int failure=0;
172 for(vector<string>::const_iterator o = outfiles.begin();
173 o != outfiles.end();
174 o++){
175 char *protocol=0;
176 char *path = 0;
177 af_parse_url(o->c_str(),&protocol,0,0,0,0,&path);
178 if(strcmp(protocol,"file")==0){
179 unlink(path);
180 }
181 else{
182 fprintf(stderr,"Cannot unlink %s\n",o->c_str());
183 failure=1;
184 }
185 if(protocol) free(protocol);
186 if(path) free(path);
187 }
188 if(failure) exit(1);
189 }
190
191 #if !defined( __BSD_VISIBLE) && !defined(isnumber)
192 #define isnumber(x) isdigit(x)
193 #endif
194
195 #ifdef WIN32
196 #include <windows.h>
197 #include <windowsx.h>
198 int gettimeofday (struct timeval *tv, void* tz)
199 {
200 union {
201 int64_t ns100; /*time since 1 Jan 1601 in 100ns units */
202 FILETIME ft;
203 } now;
204
205 GetSystemTimeAsFileTime (&now.ft);
206 tv->tv_usec = (long) ((now.ns100 / 10LL) % 1000000LL);
207 tv->tv_sec = (long) ((now.ns100 - 116444736000000000LL) / 10000000LL);
208 return (0);
209 }
210 #endif
211
212 void open_outfiles(AFFILE *ain,outlist &afouts,const vector<string> &outfiles)
213 {
214 /* Open every output file */
215 for(vector<string>::const_iterator o = outfiles.begin();
216 o != outfiles.end(); o++){
217
218 const char *outfilename = o->c_str();
219 outelement out;
220
221 /* First see if the output file exists */
222 out.af = 0;
223 int ident = af_identify_file_type(outfilename,1);
224 if(ident!=AF_IDENTIFY_NOEXIST){
225 fprintf(stderr,"%s: file exists... ",outfilename);
226 if(opt_zap==0 && opt_missing==0){
227 fprintf(stderr,"\n Will not overwrite; use -m or -z\n");
228 continue;
229 }
230 if(opt_missing){
231 fprintf(stderr,"Will fill in missing segments...\n");
232 out.af = af_open(outfilename,O_RDWR|O_EXCL,0666);
233 if(!out.af) af_err(1,outfilename);
234 if(af_page_size(ain) != af_page_size(out.af)){
235 fprintf(stderr,"%s and %s have different page sizes (%d != %d)\n",
236 af_filename(ain),
237 af_filename(out.af),
238 af_page_size(ain),
239 af_page_size(out.af));
240 af_close(out.af);
241 out.af=0;
242 continue;
243 }
244 }
245 }
246
247
248
249 if(out.af==0){
250 out.af = af_open(outfilename,O_RDWR|O_EXCL|O_CREAT,0666);
251 if(!out.af){
252 warn("%s",outfilename);
253 continue;
254 }
255 if(af_set_pagesize(out.af,af_page_size(ain))){
256 errx(1,"%s: cannot set page size to %d\n", af_filename(out.af),af_page_size(ain));
257 }
258 }
259 if(o != outfiles.begin()) printf("\t ");
260 if(opt_verbose){
261 printf(" => %s ",outfilename);
262 if(opt_preen) printf(" (preening) ");
263 printf("\n");
264 }
265 if(opt_missing) out.segs.get_seglist(out.af);
266 afouts.push_back(out);
267 }
268 }
269
270 /* Copy pagenumber from ain to aout.
271 * Return 0 if success, -1 if can't do it.
272 * Properly handles signing and preening if requested.
273 */
274 int copy_page(AFFILE *ain,AFFILE *aout,int64_t pagenum,unsigned long arg,u_char *seghash,u_int *seghash_len)
275 {
276 /* If we are preening but not signing, see if we can get out fast */
277 if(opt_sign==0 && opt_preen==0) return -1; // not preening and not signing
278
279 /* If we are not signing, don't bother decompressing and recompressing*/
280 if(opt_sign==0 && opt_preen){
281 int alg = (arg & AF_PAGE_COMP_ALG_MASK);
282 if(alg==AF_PAGE_COMP_ALG_ZERO) return -1; // don't preen ZERO
283 if(alg==opt_preen_alg_arg) return -1; // don't decompress then re-compress with old alg
284 }
285
286 /* If we get here, page must be read into memory and decompressed */
287 size_t pagesize = af_page_size(ain);
288 if(pagesize<=0) return -1; // couldn't get pagesize
289
290 u_char *pagebuf = (unsigned char *)malloc(pagesize);
291 if(!pagebuf) return -1; // couldn't allocate memory for page?
292
293 if(af_get_page(ain,pagenum,pagebuf,&pagesize)){ // note --- this may make pagesize smaller
294 free(pagebuf);
295 return -1;
296 }
297
298 if(opt_preen){ // set compression if we are preening
299 af_enable_compression(aout,opt_preen_alg_flag,opt_X);
300 }
301
302 #ifdef USE_AFFSIGS
303 /* If calculating a bom, calculate the bom! */
304 if(opt_sign){
305 char segname[AF_MAX_NAME_LEN];
306 sprintf(segname,AF_PAGE,pagenum);
307 aff_bom::make_hash(seghash,arg,segname,pagebuf,pagesize);
308 }
309 #endif
310
311 /* Write out the page */
312 int ret = af_update_page(aout,pagenum,pagebuf,pagesize);
313 free(pagebuf);
314 return ret;
315 }
316
317 string base64(const u_char *buf,size_t buflen)
318 {
319 size_t len = buflen*2+1;
320 char *str = (char *)malloc(len);
321 b64_ntop(buf,buflen,str,len);
322 string ret = string(str);
323 free(str);
324 return ret;
325 }
326
327 #ifndef HAVE_ISATTY
328 int isatty(int fd)
329 {
330 return 1; // have to assume it's a tty
331 }
332 #endif
333
334 int afcopy(char *infile,vector<string> &outfiles)
335 {
336 #ifdef SIGINFO
337 signal(SIGINFO,sig_info);
338 #endif
339 hashMapT hashMap;
340
341 /* Open the input file */
342 AFFILE *ain = af_open(infile,O_RDONLY,0);
343 if(opt_debug) printf("af_open(%s,O_RDONLY)=%p\n",infile,ain);
344 if(!ain) af_err(1,"%s",infile);
345 seglist segments(ain);
346
347 if(opt_zap) unlink_outfiles(outfiles);
348
349 outlist afouts; // vector of output AFFs
350 vector<int64_t>preened_pages;
351 open_outfiles(ain,afouts,outfiles);
352
353 /* Now, try to open the output files, to see if they exist */
354 current_source = infile;
355 if(opt_verbose) printf("%s: ",infile);
356 if(opt_verbose>1) putchar('\n');
357
358 /* If we couldn't open any output files, return */
359 if(afouts.size()==0){
360 af_close(ain); // close the input file
361 return -1;
362 }
363
364 #ifdef USE_AFFSIGS
365 /* If we are signing, initialize the signing machinery */
366 aff_bom bom(opt_note);
367 if(opt_sign){
368 if(bom.read_files(opt_sign_cert_file,opt_sign_key_file)){
369 opt_sign = 0; // can't sign
370 }
371 }
372 #endif
373
374 /* Now the files are open. For each output file:
375 * 1. Initialize signing if options were set and the segments aren't already signed.
376 * 2. Sign all of the segments that are unsigned
377 */
378 for(outlist::iterator aout = afouts.begin(); aout != afouts.end(); aout++){
379 if(opt_sign_key_file && segments.has_signed_segments()==false){
380 if(af_set_sign_files(aout->af,opt_sign_key_file,opt_sign_cert_file)){
381 err(1,"%s",opt_sign_key_file);
382 }
383 af_sign_all_unsigned_segments(aout->af);
384 opt_sign = true;
385 }
386 }
387
388 /* Start the copying */
389 struct timeval t0,t1;
390 gettimeofday(&t0,0);
391 for(seglist::const_iterator seg = segments.begin(); seg!= segments.end();seg++){
392 /* For each segment, get the size of the segment */
393 const char *segname = seg->name.c_str();
394 current_seg = segname; // for printing
395 size_t seglen=0;
396
397 if(af_get_seg(ain,segname,0,0,&seglen)){
398 unlink_outfiles(outfiles);
399 err(1,"Cannot read length of segment '%s' on input file %s", segname,af_filename(ain));
400 }
401 unsigned char *segbuf = (unsigned char *)malloc(seglen);
402 if(!segbuf){
403 unlink_outfiles(outfiles);
404 err(1,"Cannot allocated %d bytes for segment '%s' in %s",
405 (int)seglen,segname,af_filename(ain));
406 }
407
408 /* Now get the raw source segment */
409 unsigned long arg=0;
410 if(af_get_seg(ain,segname,&arg,segbuf,&seglen)){
411 unlink_outfiles(outfiles); // failure; unlink the output files
412 err(1,"Cannot read segment '%s' in %s. Deleteing output file", segname,af_filename(ain));
413 }
414
415 /* Calculate the MD5 of this segment and remember it in the map */
416 md5blob md5;
417 MD5(segbuf,seglen,md5.buf);
418 hashMap[segname] = md5;
419
420 /* See if this is a page; if so, it is handled specially */
421 int64_t pagenumber = af_segname_page_number(segname);
422
423 /* Write the segment to each file */
424 for(outlist::iterator aout = afouts.begin(); aout != afouts.end(); aout++){
425 current_dest = af_filename(aout->af);
426 if(opt_verbose>1 || opt_debug){
427 if(aout != afouts.begin()) printf("\n ");
428 printf(" %s -> %s:%s ...", segname,af_filename(aout->af),segname);
429 }
430
431 /** COPY THE DATA **/
432
433 u_char seghash[32]; /* resultant message digest; could be any size */
434 unsigned int seghash_len = sizeof(seghash); /* big enough to hold SHA256 */
435 int sigmode = AF_SIGNATURE_MODE0;
436
437 memset(seghash,0,sizeof(seghash));
438
439 bool copied = false;
440
441 /* If we are preening, signing, or building a ToC, we need to copy the raw page */
442 if(pagenumber>=0 && (opt_preen || opt_sign_key_file)){
443 if(copy_page(ain,aout->af,pagenumber,arg,seghash,&seghash_len)==0){
444 preened_pages.push_back(pagenumber); // preened pages won't be verified by md5
445 if(opt_debug && opt_preen) printf(" (PREENED) ");
446 sigmode = AF_SIGNATURE_MODE1;
447 copied = true;
448 }
449 }
450
451 /* Copy the page if it is not in the destination */
452 if(copied==false){
453 if(!aout->segs.contains(segname)){
454 if(af_update_seg(aout->af,segname,arg,segbuf,seglen)){
455 unlink_outfiles(outfiles);
456 err(1,"Cannot write segment '%s' to %s.", segname,af_filename(aout->af));
457 }
458
459 #ifdef USE_AFFSIGS
460 if(opt_sign){
461 aff_bom::make_hash(seghash,arg,segname,segbuf,seglen);
462 }
463 #endif
464 }
465 else{
466 if(opt_verbose>1 || opt_debug) printf(" [already in %s] ",af_filename(aout->af));
467 }
468 }
469 #ifdef USE_AFFSIGS
470 if(opt_sign) bom.add(segname,sigmode,seghash,seghash_len);
471 #endif
472 }
473 free(segbuf);
474 current_dest = 0;
475 if(opt_verbose>1 || opt_debug) putchar('\n');
476 }
477 current_seg = 0;
478
479 #ifdef USE_AFFSIGS
480 /* For each open file, make an AF_IMAGE_GID if one doesn't exist */
481 for(outlist::iterator aout = afouts.begin(); aout != afouts.end(); aout++){
482 if(af_make_gid(aout->af)>0){
483 if(opt_sign){
484 af_sign_seg(aout->af,AF_IMAGE_GID); // make sure the GID is signed
485 bom.add(aout->af,AF_IMAGE_GID);
486 bom.add(aout->af,AF_IMAGE_GID AF_SIG256_SUFFIX);
487
488 }
489 }
490 }
491
492 if(opt_sign){
493 bom.close();
494 /* Now write to each of the output files */
495 for(outlist::iterator aout = afouts.begin(); aout != afouts.end(); aout++){
496 bom.write(aout->af,segments);
497 }
498 }
499 #endif
500
501 gettimeofday(&t1,0);
502 if(afouts.size()==1){
503 AFFILE *af = afouts.begin()->af;
504 uint64_t w = af->bytes_written;
505 double sec = ((t1.tv_sec-t0.tv_sec)+(t1.tv_usec-t0.tv_usec)/1000000.0);
506 printf("%s: %"I64d" bytes transfered in %.2f seconds. xfer rate: %.2f MBytes/sec\n",
507 af_filename(af),w,sec,(w/1000000.0) / sec);
508 }
509
510 if(opt_noverify==0){
511 current_seg = "VERIFYING";
512 /* Now verify all of the hashes */
513 if(opt_verbose || opt_debug) printf("\n\nFiles copied. Verifying...\n");
514 for(seglist::const_iterator seg = segments.begin(); seg!= segments.end();seg++){
515
516 const char *segname = seg->name.c_str();
517 for(outlist::iterator aout = afouts.begin(); aout != afouts.end(); aout++){
518 size_t seglen=0;
519 char b2[1024];
520
521 if((aout->af)->v->flag & AF_VNODE_TYPE_RELIABLE){
522 continue; // no need to verify a reliable write
523 }
524 if(opt_verbose>1 || opt_debug) printf(" verifying %s...\n",segname);
525
526 again:
527 if(af_get_seg(aout->af,segname,0,0,&seglen)){
528 if(segname != b2 &&
529 segname[0]=='s' && segname[1]=='e' && segname[2]=='g' &&
530 isnumber(segname[3])){
531 /* Looks like a legacy segname name was renamed.
532 * Try the new name
533 */
534 snprintf(b2,sizeof(b2),"page%s",segname+3);
535 if(opt_verbose) printf(" Couldn't read %s; looking for %s\n",
536 segname,b2);
537 segname = b2;
538 goto again;
539 }
540 unlink_outfiles(outfiles);
541 errx(1,"Cannot read length of segment '%s' in output file %s",
542 segname,af_filename(aout->af));
543 }
544 int64_t pagenumber = af_segname_page_number(segname);
545 if(find(preened_pages.begin(),preened_pages.end(),pagenumber) !=preened_pages.end()){
546 /* TK: page pagenumber was preened.
547 * It should probably be checked against the original hash...
548 */
549 continue;
550 }
551
552 unsigned char *segbuf = (unsigned char *)malloc(seglen);
553 if(!segbuf){
554 err(1,"Cannot allocated %d bytes for segment '%s' in %s",
555 (int)seglen,segname,af_filename(ain));
556 }
557 unsigned long arg;
558 if(af_get_seg(aout->af,segname,&arg,segbuf,&seglen)){
559 err(1,"Cannot read segment '%s' in %s",
560 segname,af_filename(aout->af));
561 }
562
563 /* Calculate the MD5 of this segment and see if it matches the map.
564 * (But don't do this for preened segments.
565 */
566 unsigned char md5_read[16];
567 MD5(segbuf,seglen,md5_read);
568 if(memcmp(hashMap[segname].buf,md5_read,16)!=0){
569 unlink_outfiles(outfiles);
570 errx(1,"Hash read from %s for segment %s doesn't validate.",
571 af_filename(aout->af),segname);
572 }
573 free(segbuf); // free the buffer
574 }
575 }
576 }
577
578 /* Finally, close the output files*/
579 for(outlist::iterator aout = afouts.begin(); aout != afouts.end(); aout++){
580 af_close(aout->af);
581 }
582 af_close(ain);
583 if(opt_verbose>1 || opt_debug) printf("==============================\n");
584 current_source = 0;
585 return 0;
586 }
587
588 int main(int argc,char **argv)
589 {
590 int ch;
591
592 setvbuf(stdout,0,_IONBF,0); // turn off buffering on stdout
593 while ((ch = getopt(argc, argv, "vdVxyh?zmX:Lp:P:k:c:n")) != -1) {
594 switch (ch) {
595 case 'v': opt_verbose++; break;
596 case 'd': opt_debug++; break;
597 case 'X':
598 opt_preen =1;
599 opt_X = optarg[0] - '0';
600 opt_preen_alg_arg = AF_PAGE_COMP_ALG_ZLIB;
601 opt_preen_alg_flag = AF_COMPRESSION_ALG_ZLIB;
602 if(opt_X<0 || opt_X>9) opt_X = AF_COMPRESSION_DEFAULT;
603 break;
604 case 'L':
605 opt_preen=1;
606 opt_preen_alg_arg = AF_PAGE_COMP_ALG_LZMA;
607 opt_preen_alg_flag = AF_COMPRESSION_ALG_LZMA;
608 break;
609 case 'x': opt_x++;break;
610 case 'y': opt_noverify++;break;
611 case 'z': opt_zap++;break;
612 case 'm': opt_missing++;break;
613 case 'n': opt_note++;break;
614 case 'k':
615 if(access(optarg,R_OK)) err(1,"%s",optarg);
616 opt_sign_key_file = optarg;
617 if(opt_sign_cert_file==0) opt_sign_cert_file=optarg;
618 opt_sign = true;
619 break;
620 case 'c':
621 if(access(optarg,R_OK)) err(1,"%s",optarg);
622 opt_sign_cert_file = optarg;
623 break;
624 case 'V':
625 printf("%s version %s\n",progname,PACKAGE_VERSION);
626 exit(0);
627 case 'h':
628 case '?':
629 default:
630 usage();
631 break;
632 }
633 }
634 argc -= optind;
635 argv += optind;
636
637 if(argc<2){ // at this point, we need at least two args
638 usage();
639 }
640
641 /* We either need both a key file and a cert file, or neither */
642 if((opt_sign_key_file==0) != (opt_sign_cert_file==0)){
643 errx(1,"Both a private key and a certificate must be specified.");
644 }
645
646 /* Find any directories */
647 vector<string> dirlist;
648 for(int i=argc-1;i>0;i--){
649 struct stat st;
650
651 // s3 names that do not end with ".aff" are directories
652 const char *last4 = strlen(argv[i])>4 ? argv[i]+strlen(argv[i])-4 : "";
653 if(strncmp(argv[i],"s3://",5)==0 &&
654 strcmp(last4,".aff")!=0){
655 dirlist.push_back(argv[i]);
656 argc--;
657 continue;
658 }
659
660 if(stat(argv[i],&st)!=0) break; // out of directories
661 if((st.st_mode & S_IFMT)!=S_IFDIR) break; // found a non-dir
662 dirlist.push_back(argv[i]);
663 argc--; // ignore the last
664 }
665
666 /* If I found no directories, then there better just be two values */
667 if(dirlist.size()==0){
668 if(argc!=2){
669 fprintf(stderr,"Please specify a directory or just two AFF files.\n\n");
670 usage();
671 }
672 /* Must be copying from file1 to file2. Make sure file2 does not exist */
673 if(access(argv[1],R_OK)==0){
674 fprintf(stderr,"File exists: %s\n",argv[1]);
675 if(!opt_zap) exit(1);
676 }
677
678 vector<string> outfiles;
679 outfiles.push_back(argv[1]);
680 return afcopy(argv[0],outfiles);
681 }
682
683 /* Loop for each file and each directory */
684
685 while(argc--){
686 /* Open the output files */
687 vector<string> outfiles;
688 for(u_int i=0;i<dirlist.size();i++){
689 string outfilename;
690 const char *name = strrchr(*argv,'/');
691 if(name) name++;
692 else name = *argv;
693
694 outfilename.append(dirlist[i]);
695 if(outfilename[outfilename.size()-1]!='/') {
696 outfilename.append("/");
697 }
698 outfilename.append(name);
699 outfiles.push_back(outfilename);
700 }
701 afcopy(argv[0],outfiles); // old outfiles will get GCed
702 argv++;
703 }
704 exit(0);
705 }
706
707
0 /*
1 * afcrypto.cpp:
2 *
3 * command for dealing with encryption issues
4 */
5
6 /*
7 * Copyright (c) 2007, 2008
8 * Simson L. Garfinkel
9 * All rights reserved.
10 *
11 * This code is derrived from software contributed by
12 * Simson L. Garfinkel
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. [omitted]
23 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
24 * contributors to this program may be used to endorse or promote
25 * products derived from this software without specific prior written
26 * permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL
29 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
30 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
36 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
39 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 */
42
43 #include "affconfig.h"
44 #include "afflib.h"
45 #include "afflib_i.h"
46 #include "utils.h"
47
48 #include <stdio.h>
49 #include <algorithm>
50 #include <vector>
51
52 const char *progname = "afcrypto";
53 #define DEFAULT_PASSPHRASE_FILE ".affpassphrase"
54 int opt_debug = 0;
55 int opt_verbose = 0;
56 int opt_just_print_encrypted_count = 0;
57 int opt_just_print_unencrypted_count = 0;
58 char *opt_unsealing_private_key_file= 0;
59 int opt_xml = 0;
60
61 void change_passphrase(const char *fn,const char *old_passphrase,const char *new_passphrase)
62 {
63 int fail = 0;
64
65 AFFILE *af = af_open(fn,O_RDWR,0666);
66 if(!af) af_err(1,fn);
67 if(af_change_aes_passphrase(af,old_passphrase,new_passphrase)){
68 warnx("%s: af_change_aes_passphrase failed",fn);
69 fail = 1;
70 }
71 af_close(af);
72 if(!fail) printf("%s: passphrase changed.\n",fn);
73 }
74
75 void get_and_change_passphrase(const char *fn)
76 {
77 char old_passphrase[1024];
78 char new_passphrase[1024];
79
80 memset(old_passphrase,0,sizeof(old_passphrase));
81 memset(new_passphrase,0,sizeof(new_passphrase));
82
83 printf("Enter old passphrase: ");
84 if(fgets(old_passphrase,sizeof(old_passphrase),stdin)==0) return;
85 char *cc = strchr(old_passphrase,'\n');if(cc) *cc='\000';
86
87 /* See if this passphrase works*/
88
89 AFFILE *af = af_open(fn,O_RDONLY,0666);
90 if(!af) af_err(1,fn);
91 if(af_use_aes_passphrase(af,old_passphrase)){
92 errx(1,"passphrase incorrect");
93 }
94 af_close(af);
95
96 printf("Enter new passphrase: ");
97 if(fgets(new_passphrase,sizeof(new_passphrase),stdin)==0) return;
98 cc = strchr(new_passphrase,'\n');if(cc) *cc='\000';
99 change_passphrase(fn,old_passphrase,new_passphrase);
100 }
101
102 void usage()
103 {
104 printf("afcrypto version %s\n",PACKAGE_VERSION);
105 printf("usage: afcrypto [options] filename.aff [filename2.aff ... ]\n");
106 printf(" prints if each file is encrypted or not.\n");
107 printf("options:\n");
108 printf(" -x --- output in XML\n");
109 printf(" -j --- Just print the number of encrypted segments\n");
110 printf(" -J --- Just print the number of unencrypted segments\n");
111
112 printf("\nData conversion options:\n");
113 printf(" -e --- encrypt the unencrypted non-signature segments\n");
114 printf(" -r --- change passphrase (take old and new from stdin)\n");
115 printf(" -O old --- specify old passphrase\n");
116 printf(" -N new --- specify new passphrase\n");
117 printf(" -K mykey.key -- specifies a private keyfile for unsealing (may not be repeated)\n");
118 printf(" -C mycert.crt -- specifies a certificate file for sealing (may be repeated)\n");
119 printf(" -S --- add symmetric encryptiong (passphrase) to AFFILE encrypted with public key\n");
120 printf(" (requires a private key and a specified passphrase).\n");
121 printf(" -A --- add asymmetric encryption to a AFFILE encrypted with a passphrase\n");
122 printf(" (requires a certificate file spcified with the -C option\n");
123
124
125 printf("\nPassword Cracking Options:\n");
126 printf(" -p passphrase --- checks to see if passphrase is the passphrase of the file\n");
127 printf(" exit code is 0 if it is, -1 if it is not\n");
128 printf(" -k --- attempt to crack passwords by reading a list of passwords from ~/.affpassphrase\n");
129 printf(" -f file --- Crack passwords but read them from file.\n");
130
131 printf("\nDebugging:\n");
132 printf(" -V --- Just print the version number and exit.\n");
133 printf(" -d --- debug; print out each key as it is tried\n");
134 printf(" -l --- List the installed hash and encryption algorithms \n");
135 printf("Note: This program ignores the environment variables:\n");
136 puts(AFFLIB_PASSPHRASE);
137 puts(AFFLIB_PASSPHRASE_FILE);
138 puts(AFFLIB_PASSPHRASE_FD);
139 puts(AFFLIB_DECRYPTING_PRIVATE_KEYFILE);
140 exit(0);
141 }
142
143 /* Try each of the passphrases in the file against the passphrase. If it is found, return it. */
144 char *check_file(AFFILE *af,const char *passphrase_file)
145 {
146 char *ret = 0;
147 FILE *f = fopen(passphrase_file,"r");
148 if(!f) return 0;
149
150 char buf[1024];
151 memset(buf,0,sizeof(buf));
152 while(fgets(buf,sizeof(buf)-1,f)){
153 char *cc = index(buf,'\n');
154 if(cc) *cc = 0;
155 if(opt_debug){
156 if(opt_debug) printf("checking with '%s' ... ",buf);
157 fflush(stdout);
158 }
159 int r= af_use_aes_passphrase(af,buf);
160 if(r==0){
161 if(opt_debug) printf("YES!\n");
162 ret = strdup(buf);
163 break;
164 }
165 }
166 fclose(f);
167 return ret;
168 }
169
170 /**
171 * Encrypts the non-signature segments that are not encrypted.
172 * There is no reason to encrypt the signature segments.
173 *
174 * @param af - the AFFILE to open
175 * @param count - The number of pages actually encrypted
176 */
177
178 int af_encrypt_unencrypted_nonsignature_segments(AFFILE *af,int *count,int mode)
179 {
180 af_set_option(af,AF_OPTION_AUTO_DECRYPT,0); // do not automatically decrypt
181 aff::seglist sl(af);
182 for(aff::seglist::const_iterator si = sl.begin();si!=sl.end();si++){
183 if(si->name == AF_AFFKEY) continue; // don't encrypt the affkey!
184 if(strstr(si->name.c_str(),"affkey_evp")) continue;
185 if(!af_is_encrypted_segment(si->name.c_str()) &&
186 !af_is_signature_segment(si->name.c_str())){
187
188 if(mode == O_RDONLY){ // if readonly, just tally
189 (*count) ++;
190 continue;
191 }
192
193 /* Get the segment and put it, which will force the encryption to take place */
194 if(opt_debug) printf(" encrypting segment %s\n",si->name.c_str());
195 u_char *buf = (u_char *)malloc(si->len);
196 if(!buf) warn("Cannot encrypt segment '%s' --- too large (%zd bytes) --- malloc failed",
197 si->name.c_str(),si->len);
198 else {
199 unsigned long arg;
200 size_t datalen = si->len;
201 if(af_get_seg(af,si->name.c_str(),&arg,buf,&datalen)){
202 warn("Could not read segment '%s'",si->name.c_str());
203 }
204 else{
205 /* make sure that what we read is what we thought we were going to read */
206 assert(si->len==datalen);
207 assert(si->arg==arg);
208 if(af_update_seg(af,si->name.c_str(),arg,buf,datalen)){
209 warn("Could not encrypt segment '%s'",si->name.c_str());
210 } else {
211 (*count) ++;
212 }
213 }
214 free(buf);
215 }
216 } else {
217 if(opt_debug) printf(" already encrypted or signed: %s\n",si->name.c_str());
218 }
219 }
220 af_set_option(af,AF_OPTION_AUTO_DECRYPT,1); // go back to automatically decrypting
221 return 0;
222 }
223
224 void list_openssl_hashes()
225 {
226 const char *digests[] = {"md5","sha1","sha256",0};
227 OpenSSL_add_all_algorithms();
228 for(int i=0;digests[i];i++){
229 printf("OpenSSL has %s: %s\n",digests[i],EVP_get_digestbyname(digests[i]) ? "YES" : "NO");
230 }
231 exit(0);
232 }
233
234 int main(int argc,char **argv)
235 {
236 int bflag, ch;
237 const char *old_passphrase=0;
238 const char *new_passphrase=0;
239 const char *check_passphrase = 0;
240 char *passphrase_file = 0;
241 const char *progname = argv[0];
242 int opt_encrypt = 0;
243 int opt_add_passphrase_to_public_key = 0;
244 int opt_add_public_key_to_passphrase = 0;
245
246 int mode = O_RDONLY; // mode for opening AFF file
247 const char **certificates = (const char **)malloc(0);
248 int num_certificates = 0;
249
250 /* Don't use auto-supplied passphrases */
251 unsetenv(AFFLIB_PASSPHRASE);
252 unsetenv(AFFLIB_PASSPHRASE_FILE);
253 unsetenv(AFFLIB_PASSPHRASE_FD);
254 unsetenv(AFFLIB_DECRYPTING_PRIVATE_KEYFILE);
255
256 bflag = 0;
257 int opt_change = 0;
258 const char *home = getenv("HOME");
259 while ((ch = getopt(argc, argv, "reC:SAO:N:p:f:kdh?VK:vljJx")) != -1) {
260 switch (ch) {
261
262 case 'x': opt_xml = 1; break;
263 case 'j': opt_just_print_encrypted_count =1;break;
264 case 'J': opt_just_print_unencrypted_count =1;break;
265
266 /* These options make the mode read-write */
267 case 'r': opt_change = 1; mode = O_RDWR; break;
268 case 'e': opt_encrypt = 1; mode = O_RDWR; break;
269 case 'S': opt_add_passphrase_to_public_key = 1; mode = O_RDWR; break;
270 case 'A': opt_add_public_key_to_passphrase = 1; mode = O_RDWR; break;
271 /* These just set up variables */
272 case 'C':
273 certificates = (const char **)realloc(certificates,sizeof(int *)*(num_certificates+1));
274 certificates[num_certificates] = optarg;
275 num_certificates++;
276 break;
277 case 'K': opt_unsealing_private_key_file = optarg;break;
278 case 'O': old_passphrase = optarg;break;
279 case 'N': new_passphrase = optarg;break;
280 case 'p': check_passphrase = optarg;break;
281 case 'f': passphrase_file = optarg;break;
282 case 'k':
283 if(!home) home = "/";
284 passphrase_file = (char *)malloc(strlen(home)+strlen(DEFAULT_PASSPHRASE_FILE)+2);
285 strcpy(passphrase_file,home);
286 strcat(passphrase_file,"/");
287 strcat(passphrase_file,DEFAULT_PASSPHRASE_FILE);
288 break;
289 case 'd': opt_debug = 1;break;
290 case 'v': opt_verbose = 1;break;
291 case 'l': list_openssl_hashes(); exit(0);
292 case 'h':
293 case '?':
294 default:
295 usage();
296 break;
297 case 'V':
298 printf("%s version %s\n",progname,PACKAGE_VERSION);
299 exit(0);
300 }
301 }
302 argc -= optind;
303 argv += optind;
304 if(argc<1){
305 usage();
306 }
307
308 if(opt_just_print_encrypted_count && opt_just_print_unencrypted_count){
309 errx(1,"Options -j and -J conflict\n");
310 }
311
312 if(num_certificates>0 && (opt_encrypt==0 && opt_add_public_key_to_passphrase==0)){
313 errx(1,"Encryption certificates specified by -e option not set. "
314 "What do you want me to do with these certificates? ");
315 }
316
317 if((check_passphrase || passphrase_file) && opt_encrypt){
318 err(1,"Sorry, can't both encrypt and password crack. Pick one.\n");
319 }
320
321 if(opt_encrypt && (new_passphrase==0 && num_certificates==0) && mode!=O_RDONLY){
322 err(1,"Currently -e requires that the passphrase be specified on the command line or that one or more encryption certificates be provided\n");
323 }
324
325 while(argc--){
326 const char *fname = *argv++;
327
328 if(opt_change){
329 if(old_passphrase && new_passphrase) change_passphrase(fname,old_passphrase,new_passphrase);
330 else get_and_change_passphrase(fname);
331 }
332
333 /* Get the information */
334 AFFILE *af = af_open(fname,mode,0);
335 if(!af) af_err(1,"af_open(%s)",fname);
336 if(af_identify(af)!=AF_IDENTIFY_AFF && af_identify(af)!=AF_IDENTIFY_AFD){
337 errx(1,"Cannot encrypt %s: %s only supports AFF and AFD files.",af_filename(af),progname);
338 }
339
340 if(opt_encrypt && new_passphrase){
341 int r = af_establish_aes_passphrase(af,new_passphrase);
342 switch(r){
343 case AF_ERROR_NO_AES: errx(1,"AFFLIB: AES256 not available; cannot continue");
344 case AF_ERROR_NO_SHA256: errx(1,"AFFLIB: SHA256 not available; cannot continue");
345 default: err(1,"%s: cannot establish passphrase (error %d)",fname,r);
346 case 0:
347 case AF_ERROR_AFFKEY_EXISTS:
348 /* no matter if we established it or if a phrase already exists, try to use it now */
349 /* File already has a passphrase; see if this is it. */
350 break;
351 }
352 r = af_use_aes_passphrase(af,new_passphrase);
353 switch(r){
354 case 0: break; // everything okay
355 case AF_ERROR_WRONG_PASSPHRASE: errx(1,"%s: wrong passphrase",fname);
356 default: errx(1,"%s: passphrase already established (error %d)",fname,r);
357 }
358 }
359
360 if (opt_add_public_key_to_passphrase){
361 if(!num_certificates) errx(1,"You must specify a certificate with the -C option");
362 if(!check_passphrase) errx(1,"You must specify a passphrase with the -p option");
363 printf("Attepmting to add public key to AFFILE...\n");
364 if(af->crypto->sealing_key_set) return AF_ERROR_KEY_SET; // already enabled
365 unsigned char affkey[32];
366 int r = af_get_aes_key_from_passphrase(af,check_passphrase,affkey);
367 if(r) errx(1, "%s: cannot get aes key. Failed to add Public Key", fname);
368 af_seal_affkey_using_certificates(af, certificates, num_certificates, affkey);
369 printf("...Public key added successfully.\n");
370 }
371
372 if(opt_encrypt && num_certificates){
373 if(af_set_seal_certificates(af,certificates,num_certificates)){
374 errx(1,"%s: can't set encryption certificate%s",fname,num_certificates==1 ? "" : "s");
375 }
376 }
377 if(opt_encrypt){
378 int count = 0;
379 if(af_encrypt_unencrypted_nonsignature_segments(af,&count,mode)){
380 errx(1,"%s: can't encrypt unsigned, unencrypted segments",fname);
381 }
382 if(mode==O_RDONLY){ // if it is readonly just print the number of segments that would be changed.
383 printf("%d\n",count);
384 af_close(af);
385 continue;
386 }
387 }
388
389 if(opt_add_passphrase_to_public_key) {
390 if(!new_passphrase) errx(1,"You must specify a new passphrase with the -N option");
391 printf("Attempting to add passphrase...\n");
392 u_char affkey[32];
393 if(af_get_affkey_using_keyfile(af, opt_unsealing_private_key_file,affkey)){
394 errx(1,"%s: cannot unseal AFFKEY",fname);
395 }
396 if(af_save_aes_key_with_passphrase(af,new_passphrase,affkey)){
397 af_err(1,"%s: could not set the passphrase",fname);
398 }
399 printf("... new passphrase established.\n");
400 }
401
402
403 af_vnode_info vni;
404 memset(&vni,0,sizeof(vni));
405 if(af_vstat(af,&vni)) err(1,"%s: af_vstat failed: ",fname);
406 const char *the_passphrase = 0; // the correct passphrase
407
408 if(opt_just_print_encrypted_count){
409 printf("%d\n",vni.segment_count_encrypted);
410 af_close(af);
411 continue;
412 }
413
414 if(opt_just_print_unencrypted_count){
415 printf("%d\n",vni.segment_count_total-vni.segment_count_encrypted);
416 af_close(af);
417 continue;
418 }
419
420
421 /* were we supposed to try a check_passphrase? */
422 if(check_passphrase){
423 if(af_use_aes_passphrase(af,check_passphrase)==0){
424 the_passphrase = check_passphrase;
425 }
426 af_use_aes_passphrase(af,0); // clear the passphrase
427 }
428
429 /* Is a passphrase file provided? */
430 if(!the_passphrase && passphrase_file){
431 the_passphrase = check_file(af,passphrase_file);
432 if(the_passphrase){
433 af_use_aes_passphrase(af,0); // clear the passphrase
434 }
435 }
436
437 if(opt_xml){
438 /* This should be replaced with our xml.cpp object */
439 printf("<afcrypto>\n");
440 printf(" <image_filename>%s</image_filename>\n",fname);
441 printf(" <segment_count_total>%d</segment_count_total>\n",vni.segment_count_total);
442 printf(" <segment_count_signed>%d</segment_count_signed>\n",vni.segment_count_signed);
443 printf(" <segment_count_encrypted>%d</segment_count_encrypted>\n",vni.segment_count_encrypted);
444 printf(" <page_count_total>%d</page_count_total>\n",vni.page_count_total);
445 printf(" <page_count_encrypted>%d</page_count_encrypted>\n",vni.page_count_encrypted);
446 if(the_passphrase){
447 printf(" <passphrase correct='1'>%s</passphrase>\n",the_passphrase);
448 }
449 printf("</afcrypto>\n");
450 }
451 else{
452 printf("%s: %5d segments; %5d signed; %5d encrypted; %5d pages; %5d encrypted pages",
453 fname,vni.segment_count_total,vni.segment_count_signed,vni.segment_count_encrypted,
454 vni.page_count_total,vni.page_count_encrypted );
455 if(the_passphrase) printf("passphrase correct (\"%s\")",the_passphrase);
456 putchar('\n');
457 }
458 af_close(af);
459 }
460 return(0);
461 }
0 /*
1 * afdiskprint.cpp:
2 *
3 * Creates a diskprint AFF structure
4 */
5
6 /*
7 * PUBLIC DOMAIN
8 * By Simson L. Garfinkel
9 *
10 * The software provided here is released by the Naval Postgraduate
11 * School (NPS), an agency of the U.S. Department of Navy.The software
12 * bears no warranty, either expressed or implied. NPS does not assume
13 * legal liability nor responsibility for a User's use of the software
14 * or the results of such use.
15 *
16 * Please note that within the United States, copyright protection,
17 * under Section 105 of the United States Code, Title 17, is not
18 * available for any work of the United States Government and/or for
19 * any works created by United States Government employees. User
20 * acknowledges that this software contains work which was created by
21 * NPS employees and is therefore in the public domain and not
22 * subject to copyright.
23 */
24
25
26 #include "affconfig.h"
27 #include "afflib.h"
28 #include "afflib_i.h"
29 #include "base64.h"
30 #include "hashextent.h"
31
32 #ifdef HAVE_EXPAT
33
34 #include <openssl/evp.h>
35
36 #ifdef WIN32
37 #include "unix4win32.h"
38 #endif
39
40 #include <vector>
41 #include <string>
42 #include <iostream>
43 #include <sstream>
44 #include <map>
45 #include <set>
46
47 #ifdef HAVE_CSTRING
48 #include <cstring>
49 #endif
50
51 const char *hashes[] = {"SHA256","SHA1",0}; // what should we hash?
52
53 using namespace std;
54
55 #if HAVE_CTYPE_H
56 #include <ctype.h>
57 #endif
58
59 #if !defined(HAVE_ISALPHANUM) && defined(HAVE_ISALNUM)
60 #define isalphanum(c) isalnum(c)
61 #endif
62
63 #if !defined(HAVE_ISALPHANUM) && !defined(HAVE_ISALNUM)
64 #define isalphanum(c) (isalpha(c)||isdigit(c))
65 #endif
66
67 #if !defined(O_BINARY)
68 #define O_BINARY 0
69 #endif
70
71 const char *progname = "afdiskprint";
72 const char *xml_special_chars = "<>\r\n&'\"";
73
74 void usage()
75 {
76 printf("%s version %s\n",progname,PACKAGE_VERSION);
77 printf("usage: %s [options] infile \n",progname);
78 printf(" -x XML = Verify the diskprint\n");
79 printf(" -V = Just print the version number and exit.\n");
80 printf(" -h = Print this help.\n");
81 exit(0);
82 }
83
84 /****************************************************************
85 ** Support routines...
86 */
87
88 /**
89 * Return a random 64-bit number
90 */
91 uint64_t random64()
92 {
93 return (((uint64_t)random())<<32) | random();
94 }
95
96 uint64_t atoi64(const char *buf)
97 {
98 uint64_t ret=0;
99 sscanf(buf,"%"PRIu64,&ret);
100 return ret;
101 }
102
103
104 static int *hexcharvals = 0;
105 static void nsrl_bloom_init()
106 {
107 if(hexcharvals==0){
108 /* Need to initialize this */
109 int i;
110 hexcharvals = (int *)calloc(sizeof(int),256);
111 for(i=0;i<10;i++){
112 hexcharvals['0'+i] = i;
113 }
114 for(i=10;i<16;i++){
115 hexcharvals['A'+i-10] = i;
116 hexcharvals['a'+i-10] = i;
117 }
118 }
119 }
120
121
122 /**
123 * Convert a hex representation to binary, and return
124 * the number of bits converted.
125 * @param binbuf output buffer
126 * @param binbuf_size size of output buffer in bytes.
127 * @param hex input buffer (in hex)
128 */
129 int nsrl_hex2bin(unsigned char *binbuf,size_t hexbuf_size,const char *hex)
130 {
131 int bits = 0;
132 if(hexcharvals==0) nsrl_bloom_init();
133 while(hex[0] && hex[1] && hexbuf_size>0){
134 *binbuf++ = ((hexcharvals[(unsigned char)hex[0]]<<4) |
135 hexcharvals[(unsigned char)hex[1]]);
136 hex += 2;
137 bits += 8;
138 hexbuf_size -= 1;
139 }
140 if(hexbuf_size>0) binbuf[0] = 0; // might as well null-terminate if there is room
141 return bits;
142 }
143
144
145
146 /**
147 * Strip an XML string as necessary for a tag name.
148 */
149
150 void out_xmlstr(ostream &ostr,int indent,const char *tag,const char *value)
151 {
152 for(int i=0;i<indent;i++) ostr << " ";
153 ostr << "<" << tag << ">";
154 for(const char *ch=value;*ch;ch++){
155 if(isprint(*ch) && !strchr(xml_special_chars,*ch)){
156 ostr << *ch;
157 }
158 }
159 ostr << "</" << tag << ">";
160 }
161
162 void out_xmlhex(ostream &ostr,int indent,const char *tag,const char **attribs,
163 unsigned char *md,int len)
164 {
165 for(int i=0;i<indent;i++) ostr << ' ';
166 ostr << "<" << tag << " coding='base16'";
167 for(int i=0;attribs && attribs[i];i++){
168 ostr << " ";
169 ostr << attribs[i];
170 }
171 ostr << ">" << hashextent::bin2hex(md,len) << "</" << tag << ">\n";
172 }
173
174 /**
175 * Calculate the disk fingerprint for a spcific file and output it to stdout.
176 * Includes other named segments.
177 *
178 * @param infile the file to process.
179 */
180
181 int diskprint(const char *infile)
182 {
183 /** segments to include in output.
184 */
185 const char *segments[] = {AF_MD5,AF_SHA1,AF_SHA256,AF_CREATOR,AF_CASE_NUM,AF_IMAGE_GID,
186 AF_ACQUISITION_ISO_COUNTRY,
187 AF_ACQUISITION_COMMAND_LINE,AF_ACQUISITION_DATE,
188 AF_ACQUISITION_NOTES,AF_ACQUISITION_TECHNICIAN,
189 AF_BATCH_NAME,AF_BATCH_ITEM_NAME,0};
190 AFFILE *af = af_open(infile,O_RDONLY,0);
191 if(!af){
192 warn("%s",infile);
193 return -1;
194 }
195
196 cout << "<!-- XML generated by " << progname << " version " << PACKAGE_VERSION << " -->\n";
197 cout << "<diskprint image_filename='" << infile << "'>\n";
198
199 /* First handle the imagesize */
200 int64_t imagesize = af_get_imagesize(af);
201 if(imagesize>0){
202 char buf[32];
203 snprintf(buf,sizeof(buf),"%"PRIu64,imagesize);
204 out_xmlstr(cout,2,AF_IMAGESIZE,buf);
205 cout << "\n";
206 }
207 /* Get sector size and number of sectors */
208 unsigned long sectorsize=512; // default sectorsize
209 af_get_seg(af,AF_SECTORSIZE,&sectorsize,0,0);
210 if(sectorsize==0) sectorsize=512; // default sectorsize
211 int64_t sectors = imagesize/sectorsize;
212 if(sectors>0){
213 char buf[32];
214 snprintf(buf,sizeof(buf),"%lu",sectorsize);
215 out_xmlstr(cout,2,AF_SECTORSIZE,buf);
216 cout << "\n";
217 }
218
219 /* Output specific named segments */
220 for(int i=0;segments[i];i++){
221 char buf[65536];
222 size_t buflen = sizeof(buf);
223 if(af_get_seg(af,segments[i],0,(u_char *)buf,&buflen)==0){
224 buf[buflen] = 0; // null terminate it
225 if(af_display_as_hex(segments[i])){
226 out_xmlhex(cout,2,segments[i],0,(u_char *)buf,buflen);
227 } else {
228 out_xmlstr(cout,2,segments[i],buf);
229 }
230 }
231 }
232
233 /**
234 * The list of segments to hash is defined by:
235 * 1. The first 128K sectors.
236 * 2. The last 128K sectors.
237 * 3. A random set of 64K sectors.
238 */
239 hashvector hashextents;
240
241 for(int i=0;i<8;i++){
242 hashextents.push_back(hashextent(131072*i,131072));
243 }
244 for(int i=0;i<8;i++){
245 hashextents.push_back(hashextent(imagesize-131072*(8-i),131072));
246 }
247
248 /* Pick some random hashextents as well */
249 for(int i=0;i<100;i++){
250 uint64_t sector = random64() % (sectors-128);
251 hashextents.push_back(hashextent(sector*sectorsize,65536));
252 }
253
254 /** Sort the segments for maximal seek efficiency.
255 */
256 sort(hashextents.begin(),hashextents.end(),hashextent::compare);
257
258 /** Send the hashes to stdout using print_hash.
259 */
260 cout << " <hashes>\n";
261 for(hashvector::iterator it=hashextents.begin(); it!=hashextents.end(); it++){
262 for(int i=0;hashes[i];i++){
263 if((*it).compute_digest(af,hashes[i])==0){
264 cout << " " << (*it).toXML() << "\n";
265 }
266 }
267 }
268 cout << " </hashes>\n";
269 cout << "</diskprint>\n";
270 af_close(af);
271 return 0;
272 }
273
274
275 /**
276 * Code for reading the hashvector XML structure.
277 */
278 #include <expat.h>
279
280 class diskprintReader {
281 public:
282 /* General EXPAT stuff */
283 XML_Parser parser;
284 bool get_cdata; // this is cdata worth getting
285 string cdata; // the cdata that has been gotten
286 diskprintReader():get_cdata(false),hash(0){
287 parser = XML_ParserCreate(NULL);
288 XML_SetUserData(parser,this);
289 XML_SetElementHandler(parser,startElement,endElement);
290 XML_SetCharacterDataHandler(parser,cHandler);
291 }
292 int parse(const char *buf,int len) { return XML_Parse(parser, buf, len, 1);}
293 void clear(){
294 cdata = "";
295 get_cdata = false;
296 }
297
298 /* Specific stuff for XML diskprint */
299 hashextent *hash; // current hash
300 hashvector hashextents; // all discovered hashes
301 /* Turn the static functions into method calls */
302 static void startElement(void *userData,const char *name,const char **attrs){
303 ((diskprintReader *)userData)->startElement(name,attrs);
304 }
305 static void endElement(void *userData,const char *name){
306 ((diskprintReader *)userData)->endElement(name);
307 }
308 static void cHandler(void *userData,const XML_Char *s,int len){
309 diskprintReader *dh = (diskprintReader *)userData;
310 if(dh->get_cdata) dh->cdata.append(s,len);
311 }
312 void startElement(string name,const char **attrs){
313 clear();
314 /* If this is an element that we want, indicate such */
315 if(name=="hash"){
316 hash = new hashextent();
317 for(int i=0;attrs[i];i+=2){
318 if(strcmp(attrs[i],"coding")==0){ hash->coding = attrs[i+1]; continue;}
319 if(strcmp(attrs[i],"start")==0){ hash->start = atoi64(attrs[i+1]); continue;}
320 if(strcmp(attrs[i],"bytes")==0){ hash->bytes = atoi64(attrs[i+1]); continue;}
321 if(strcmp(attrs[i],"alg")==0){ hash->digest_name = attrs[i+1]; continue;}
322 }
323 get_cdata = true;
324 }
325 }
326 void endElement(const char *name){
327 if(get_cdata==false) return; // don't care about it.
328 if(!strcmp(name,"hash")){
329 if(hash->coding=="base16"){
330 hash->hexdigest = cdata;
331 }
332 hashextents.push_back(*hash);
333 }
334 if(!strcmp(name,"diskprint")){
335 XML_StopParser(parser,0); // stop the parser
336 return;
337 }
338 get_cdata = false;
339 }
340 };
341
342 void diskprint_verify(const char *filename,const char *xmlfile)
343 {
344 AFFILE *af = af_open(filename,O_RDONLY,0);
345 if(!af) err(1,"af_open(%s): ",filename);
346
347 /* Let's read the XML file */
348 int fd = open(xmlfile,O_RDONLY|O_BINARY);
349 if(!fd) err(1,"open: %s",xmlfile);
350 struct stat st;
351 if(fstat(fd,&st)) err(1,"stat: %s",xmlfile);
352 char *buf = (char *)malloc(st.st_size+1);
353 if(!buf) err(1,"malloc");
354
355 if(read(fd,buf,st.st_size)!=st.st_size) err(1,"cannot read XML file");
356 buf[st.st_size]=0; // terminate the buffer (not strictly needed)
357
358 diskprintReader dp;
359 dp.parse(buf,st.st_size);
360 cout << "Number of digests read: "<< dp.hashextents.size() << "\n";
361 const EVP_MD *strongest = dp.hashextents.strongest_available();
362 cout << "Strongest hash available: " << EVP_MD_name(strongest) << "\n";
363 /* Now verify each hash */
364 int matched=0;
365 int notmatched=0;
366 for(hashvector::iterator it = dp.hashextents.begin(); it!=dp.hashextents.end() && notmatched==0;it++){
367 if(EVP_MD_name(strongest) == (*it).digest_name){
368 hashextent &hp = (*it); // hash print
369 hashextent hs(af,hp.digest_name,hp.start,hp.bytes);
370 //cout << "hp: " << hp << "\n";
371 //cout << "hs: " << hs << "\n";
372 if(hp==hs){
373 matched++;
374 } else {
375 notmatched++;
376 }
377 }
378 }
379 if(notmatched){
380 cout << "Diskprint does not match.\n";
381 }
382 if(notmatched==0 && matched){
383 cout << "Diskprint matches.\n";
384 }
385 if(notmatched==0 && matched==0){
386 cout << "Cannot verify Diskprint; no available hash functions.\n";
387 }
388 exit(0);
389 }
390
391 int main(int argc,char **argv)
392 {
393 int ch;
394 const char *opt_x=0;
395
396 /* Initialize */
397 #ifdef HAVE_SRANDOMEDEV
398 srandomdev();
399 #endif
400 OpenSSL_add_all_digests();/* Dynamically loads the digests */
401
402
403 /* Parse arguments */
404 while ((ch = getopt(argc, argv, "x:h?V")) != -1) {
405 switch (ch) {
406 case 'h':
407 case '?':
408 default:
409 usage();
410 break;
411 case 'x': opt_x = optarg; break;
412 case 'V':
413 printf("%s version %s\n",progname,PACKAGE_VERSION);
414 exit(0);
415 }
416 }
417 argc -= optind;
418 argv += optind;
419
420 if(argc!=1){ // currently only generates for one file
421 usage();
422 }
423
424 if(opt_x){
425 diskprint_verify(argv[0],opt_x);
426 return(0);
427 }
428
429 /* Loop through all of the files */
430 printf("<?xml version='1.0' encoding='UTF-8'?>\n");
431 printf("<diskprints>\n");
432 while(*argv){
433 if(opt_x){
434 diskprint_verify(*argv,opt_x);
435 }
436 else {
437 diskprint(*argv);
438 }
439 argv++;
440 argc--;
441 }
442 printf("</diskprints>\n");
443 exit(0);
444 }
445 #else
446 int main(int argc,char **argv)
447 {
448 fprintf(stderr,"afdiskprint requires EXPAT. Cannot continue.\n");
449 exit(-1);
450 }
451 #endif
452
0 /*
1 * aff_bom.cpp:
2 *
3 * PUBLIC DOMAIN SOFTWARE.
4 *
5 * The software provided here is released by the Naval Postgradaute
6 * School (NPS), an agency of the US Department of the Navy, USA. The
7 * software bears no warranty, either expressed or implied. NPS does
8 * not assume legal liability nor responsibility for a User's use of
9 * the software or the results of such use. Please note that within
10 * the United States, copyright protection, under Section 105 of the
11 * United States Code, Title 17, is not available for any work of the
12 * United States Government and/or for any works created by United
13 * States Government employees. User acknowledges that this software
14 * contains work which was created by NPS employee(s) and is therefore
15 * in the public domain and not subject to copyright.
16 * --------------------------------------------------------------------
17 *
18 * Change History:
19 * Simson L. Garfinkel - 2008 - Created
20 */
21
22
23 #include "affconfig.h"
24 #include "afflib.h"
25 #include "afflib_i.h"
26 #include "utils.h"
27 #ifdef HAVE_ERR_H
28 #include "err.h"
29 #endif
30
31 #include "aff_bom.h"
32
33 #ifdef HAVE_READLINE_READLINE_H
34 #include <readline/readline.h>
35 #endif
36
37 using namespace std;
38
39 int parse_chain(const string &name)
40 {
41 char ch;
42 int num;
43 if(sscanf(name.c_str(),AF_BOM_SEG"%c",&num,&ch)==1) return num;
44 return -1;
45 }
46
47 int highest_chain(aff::seglist &segments)
48 {
49 int highest_chain = -1;
50 for(aff::seglist::const_iterator seg = segments.begin(); seg!=segments.end() ;seg++){
51 /* Are any of the segments in the input file signed?
52 * If so, we can't use the AFFLIB signing mechanisms, only the
53 * chain-of-custody mechanisms in this program.
54 */
55 /* Are there any chain of custody segments? */
56 int num= parse_chain(seg->name);
57 if(num>highest_chain) highest_chain = num;
58 }
59 return highest_chain;
60
61 }
62
63 #ifdef HAVE_OPENSSL_BIO_H
64 /* BIO_xmlescape:
65 * sends str to the bio, escaping for XML.
66 */
67 int BIO_write_xml_escape(BIO *bio,const char *str,int parsed)
68 {
69 while(*str){
70 switch(*str){
71 case '&': BIO_write(bio,"&amp;",5);break;
72 case '<': BIO_write(bio,"&lt;",4);break;
73 case '>': BIO_write(bio,"&gt;",4);break;
74 case '"': BIO_write(bio,"&quot;",6);break;
75 case '\'': BIO_write(bio,"&apos;",6);break;
76 case '\\':
77 if(parsed) BIO_write(bio,str,1);
78 else BIO_write(bio,"\\\\",2);
79 break;
80 default: BIO_write(bio,str,1);break;
81 }
82 str++;
83 }
84 return 0;
85 }
86 #endif
87
88 #ifdef USE_AFFSIGS
89 char *aff_bom::get_notes()
90 {
91 if(isatty(fileno(stdin))){
92 printf("Enter notes. Terminate input with a '.' on a line by itself:\n");
93 }
94 if(notes) return notes;
95 notes = (char *)calloc(1,1);
96 while(notes){
97 char buf2[1024];
98 char *val=0;
99
100 #ifdef HAVE_LIBREADLINE
101 if(isatty(fileno(stdin))){
102 val = readline("");
103 }
104 #endif
105 if(val==0){
106 memset(buf2,0,sizeof(buf2));
107 val = fgets(buf2,sizeof(buf2)-1,stdin);
108 if(val==0) break;
109 }
110 if(strcmp(val,".")==0) break;
111 notes = (char *)realloc(notes,strlen(notes)+strlen(val)+1);
112 strcat(notes,val);
113 }
114 printf("Thank you.\n");
115 return notes;
116 }
117
118 #ifdef HAVE_OPENSSL_BIO_H
119 int aff_bom::read_files(const char *cert_file,const char *key_file)
120 {
121 BIO *bp_cert = BIO_new_file(cert_file,"r"); // read the certfile
122 PEM_read_bio_X509(bp_cert,&cert,0,0); // get an x509 cert
123 BIO_free(bp_cert);
124 if(!cert) return -1; // can't read certificate file
125
126 /* Now read the private key */
127 BIO *bp_privkey = BIO_new_file(key_file,"r");
128 privkey = PEM_read_bio_PrivateKey(bp_privkey,0,0,0);
129 BIO_free(bp_privkey);
130 if(privkey==0){
131 X509_free(cert);
132 cert = 0;
133 return -1;
134 }
135
136 bom_open = true;
137 xml = BIO_new(BIO_s_mem()); // where we are writing
138 time_t clock = time(0);
139 struct tm *tm = localtime(&clock);
140 char timebuf[1024];
141 strftime(timebuf,sizeof(timebuf),"<date type='ISO 8601'>%FT%T</date>",tm);
142
143 BIO_printf(xml,"<%s version=\"1\">\n",AF_XML_AFFBOM);
144 BIO_printf(xml," %s\n",timebuf);
145 BIO_printf(xml," <program>afcopy</program>\n");
146 if(opt_note){
147 BIO_printf(xml," <notes>");
148 BIO_write_xml_escape(xml,get_notes(),0);
149 BIO_printf(xml," </notes>\n");
150 }
151 BIO_printf(xml," <signingcertificate>\n");
152 PEM_write_bio_X509(xml,cert);
153 BIO_printf(xml," </signingcertificate>\n");
154 BIO_printf(xml," <affsegments>\n");
155 return 0;
156 }
157
158 /* Add to the Bill of Materials */
159 void aff_bom::add(const char *segname,int sigmode,const u_char *seghash,size_t seghash_len)
160 {
161 BIO_printf(xml,"<%s segname='%s' sigmode='%d' alg='sha256'>\n",
162 AF_XML_SEGMENT_HASH,segname,sigmode);
163 if(BIO_flush(xml)!=1) return; // something is wrong
164 BIO *b64 = BIO_new(BIO_f_base64());
165 xml = BIO_push(b64,xml);
166 BIO_write(xml,seghash,seghash_len);
167 if(BIO_flush(xml)!=1) return; // another error...
168 xml = BIO_pop(b64);
169 BIO_printf(xml,"</%s>\n",AF_XML_SEGMENT_HASH);
170 }
171
172 void aff_bom::close()
173 {
174 /* Terminate the XML block*/
175 BIO_printf(xml,"</affsegments>\n");
176 BIO_printf(xml,"</%s>\n",AF_XML_AFFBOM);
177
178 OpenSSL_add_all_digests();
179 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
180
181 if(sha256){
182 /* now sign the XML */
183 char *xbuf=0;
184 size_t xlen = BIO_get_mem_data(xml,&xbuf);
185 unsigned char sig[1024];
186 u_int siglen = sizeof(sig);
187
188 EVP_MD_CTX md;
189 EVP_SignInit(&md,sha256);
190 EVP_SignUpdate(&md,xbuf,xlen);
191 EVP_SignFinal(&md,sig,&siglen,privkey);
192
193 /* Write the signature in base64 encoding... */
194 BIO *b64 = BIO_new(BIO_f_base64());
195 xml = BIO_push(b64,xml);
196 BIO_write(xml,sig,siglen);
197 if(BIO_flush(xml)!=1) return; // something wrong
198
199 /* Remove the base64 bio */
200 xml = BIO_pop(b64);
201 }
202 bom_open = false;
203 }
204
205 int aff_bom::write(AFFILE *af,aff::seglist &segments)
206 {
207 assert(!bom_open);
208 char segname[AF_MAX_NAME_LEN];
209 snprintf(segname,sizeof(segname),AF_BOM_SEG,highest_chain(segments)+1);
210 return af_update_seg_frombio(af,segname,0,xml);
211 }
212
213
214 void aff_bom::make_hash(u_char seghash[32], unsigned long arg,const char *segname,
215 const u_char *segbuf, unsigned long segsize)
216 {
217 OpenSSL_add_all_digests(); // probably a good idea
218 const EVP_MD *sha256 = EVP_get_digestbyname("SHA256");
219
220 if(sha256){
221 unsigned int seghash_len = sizeof(seghash);
222 unsigned long arg_net = htonl(arg);
223 EVP_MD_CTX md; /* EVP message digest */
224 EVP_DigestInit(&md,sha256);
225 EVP_DigestUpdate(&md,(const unsigned char *)segname,strlen(segname)+1);
226 EVP_DigestUpdate(&md,(const unsigned char *)&arg_net,sizeof(arg_net));
227 EVP_DigestUpdate(&md,segbuf,segsize);
228 EVP_DigestFinal(&md,seghash,&seghash_len);
229 }
230 }
231
232 int aff_bom::add(AFFILE *af,const char *segname)
233 {
234 /* Get the segment length first */
235 size_t datalen = 0;
236 if(af_get_seg(af,segname,0,0,&datalen)<0) return -1;
237 unsigned long arg;
238 u_char *segdata = (u_char *)malloc(datalen);/* Allocate memory */
239 if(segdata<0) return -1;
240 if(af_get_seg(af,segname,&arg,segdata,&datalen)<0){
241 free(segdata);
242 return -1;
243 }
244 u_char seghash[32];
245 make_hash(seghash,arg,segname,segdata,datalen);
246 add(segname,AF_SIGNATURE_MODE0,seghash,sizeof(seghash));
247 free(segdata);
248 return(0);
249
250 }
251
252
253 #endif /* have_openssl_bio_h */
254 #endif /* use_affsigs */
255
256
0 /*
1 * aff_bom.h
2 *
3 * PUBLIC DOMAIN SOFTWARE.
4 *
5 * The software provided here is released by the Naval Postgradaute
6 * School (NPS), an agency of the US Department of the Navy, USA. The
7 * software bears no warranty, either expressed or implied. NPS does
8 * not assume legal liability nor responsibility for a User's use of
9 * the software or the results of such use. Please note that within
10 * the United States, copyright protection, under Section 105 of the
11 * United States Code, Title 17, is not available for any work of the
12 * United States Government and/or for any works created by United
13 * States Government employees. User acknowledges that this software
14 * contains work which was created by NPS employee(s) and is therefore
15 * in the public domain and not subject to copyright.
16 * --------------------------------------------------------------------
17 *
18 * Change History:
19 * Simson L. Garfinkel - 2008 - Created
20 */
21
22
23
24 #ifndef AFF_BOM_H
25 #define AFF_BOM_H
26
27 #include <algorithm>
28 #include <cstdlib>
29 #include <vector>
30 #include <string>
31 #include <map>
32 #include <iostream>
33 #include <assert.h>
34 #ifdef HAVE_OPENSSL_PEM_H
35 #include <openssl/x509.h>
36 #include <openssl/pem.h>
37 #else
38 typedef void X509;
39 typedef void EVP_PKEY;
40 typedef void BIO;
41 #define BIO_free free
42 #endif
43
44
45
46 class outelement {
47 public:
48 outelement(){}
49 AFFILE *af; // where output goes
50 aff::seglist segs; // list of existing segments in output
51 };
52 typedef std::vector<outelement> outlist;
53
54 int parse_chain(const std::string &name);
55 int highest_chain(aff::seglist &slist);
56
57 #ifdef USE_AFFSIGS
58 class aff_bom {
59 X509 *cert;
60 EVP_PKEY *privkey;
61 char *notes;
62 bool bom_open;
63 public:
64 static void make_hash(u_char seghash[32], unsigned long arg,const char *segname,
65 const u_char *pagebuf, unsigned long pagesize);
66 bool opt_note;
67 BIO *xml;
68 aff_bom(bool flag):cert(0),privkey(0),notes(0),bom_open(false),opt_note(flag),xml(0) { }
69 ~aff_bom(){
70 assert(!bom_open);
71 if(notes) free(notes);
72 if(xml) BIO_free(xml);
73 }
74 int read_files(const char *cert_file,const char *key_file); // returns 0 if success
75 void add(const char *segname,int sigmode,const u_char *seghash,size_t seghash_len); // add to BOM
76 int add(AFFILE *af,const char *segname); // get the seg, hash it, and add it to the BOM
77 void close(); // close the BoM
78 int write(AFFILE *af,aff::seglist &segments); // write the BoM
79 char *get_notes();
80 };
81 #endif
82
83 #endif
0 /**
1 * affix.cpp
2 *
3 * Fix an aff file that is corrupt.
4 * Current methodologies:
5 * - If file does not have a GUID, create one.
6 */
7
8 /*
9 * Copyright (c) 2005
10 * Simson L. Garfinkel and Basis Technology, Inc.
11 * All rights reserved.
12 *
13 * This code is derrived from software contributed by
14 * Simson L. Garfinkel
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by Simson L. Garfinkel
27 * and Basis Technology Corp.
28 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
29 * contributors to this program may be used to endorse or promote
30 * products derived from this software without specific prior written
31 * permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
34 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
35 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
36 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
38 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
41 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
44 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * SUCH DAMAGE.
46 */
47
48
49 #include "affconfig.h"
50 #include "afflib.h"
51 #include "afflib_i.h"
52 #include "vnode_aff.h" // so we can use magical af_open_with...
53
54 #include <ctype.h>
55
56 #include <zlib.h>
57 #include <openssl/md5.h>
58 #include <openssl/sha.h>
59 #include <assert.h>
60
61 #ifdef HAVE_UNISTD_H
62 #include <unistd.h>
63 #endif
64
65 #ifdef HAVE_TERM_H
66 #include <term.h>
67 #endif
68
69 #ifdef HAVE_NCURSES_TERM_H
70 #include <ncurses/term.h>
71 #endif
72
73 #ifdef WIN32
74 #include "unix4win32.h"
75 #include <malloc.h>
76 #endif
77
78 const char *progname = "affix";
79 int opt_fix = 0;
80
81
82 void usage()
83 {
84 printf("usage: %s [options] file1 [...]\n",progname);
85 printf(" -y = Actually modify the files; normally just reports the problems\n");
86 printf(" -v = Just print the version number and exit.\n");
87 exit(0);
88 }
89
90
91
92 /* Returns 0 if this is a valid AFF file, code if it isn't. */
93 int af_is_valid_afffile(const char *file)
94 {
95 return 0; // I should write this
96 }
97
98 int fix(const char *infile)
99 {
100 char buf[1024];
101 int flags = (opt_fix ? O_RDWR : O_RDONLY) | O_BINARY;
102 switch(af_identify_file_type(infile,1)){
103 case AF_IDENTIFY_ERR:
104 perror(infile);
105 return 0;
106 default:
107 fprintf(stderr,"%s is not an AFF file\n",infile);
108 return 0;
109 case AF_IDENTIFY_AFF:
110 break;
111 }
112
113 printf("%s ",infile);
114 int r=0;
115
116 /* First see if the if the file begins with an AFF flag */
117 int fd = open(infile,flags,0666);
118 if(fd<0) err(1,"fopen(%s)",infile);
119 if(read(fd,buf,strlen(AF_HEADER)+1)!=strlen(AF_HEADER)+1)
120 err(1,"can't read AFF file header. Stop.");
121 if(strcmp(buf,AF_HEADER)!=0)
122 err(1,"%s does not begin with an AF_HEADER. Stop.",infile);
123 if(read(fd,buf,strlen(AF_SEGHEAD)+1)!=strlen(AF_SEGHEAD)+1)
124 err(1,"Can't read AF_SEGHEAD after AF_HEADER. Stop.");
125 if(strcmp(buf,AF_SEGHEAD)!=0)
126 err(1,"%s does not have an AF_SEGHEAD after AF_SEGEADER. Stop.",infile);
127
128 /* Figure out length */
129 off_t len = lseek(fd,0,SEEK_END);
130 if(len<0) err(1,"Can't seek to end of %s. Stop.",infile);
131 close(fd);
132
133 AFFILE *af = af_open_with(infile,AF_HALF_OPEN|flags,0,&vnode_aff);
134 printf("Scanning AFF file...\n");
135 r = (*af->v->open)(af);
136 /* See if we can build a TOC */
137 if(r<0){
138 printf("AFF file corrupt at %"I64d" out of %"I64d" (%"I64d" bytes from end)\n",
139 ftello(af->aseg),len,len-ftello(af->aseg));
140 if(opt_fix){
141 printf("Truncating... %d \n",fileno(af->aseg));
142 if(ftruncate(fileno(af->aseg),ftello(af->aseg))){
143 err(1,"ftruncate");
144 }
145 }
146 }
147
148 /* See if it has a GID or an encrypted GID */
149 if(af_get_seg(af,AF_IMAGE_GID,0,0,0)!=0 &&
150 af_get_seg(af,AF_IMAGE_GID AF_AES256_SUFFIX,0,0,0)!=0){
151 printf("AFF file is missing a GID. ");
152 if(opt_fix){
153 printf("Making one...");
154 if(af_make_gid(af)<0) af_err(1,"af_make_gid");
155 }
156 putchar('\n');
157 }
158
159 af_close(af);
160
161 return 0;
162 }
163 #if 0
164
165
166 /* See if it ends properly */
167 off_t len;
168
169 printf("File is %"I64d" bytes long\n",len);
170
171 if(lseek(fd,len-4,SEEK_SET)<0)
172 err(1,"Can't backup %d bytes. Stop.",-4);
173 r = read(fd,buf,4);
174 if(r!=4)
175 err(1,"Can't read last %d bytes of file. Read %d. Stop. ", strlen(AF_SEGTAIL)+1,r);
176 if(strcmp(buf,AF_SEGTAIL)!=0){
177 printf("Does not end with an AF_SEGTAIL. Scanning backwards to find last complete AF_SEGTAIL.\n");
178 for(off_t end=len-4;end>4;end--){
179 if(lseek(fd,end,SEEK_SET)<0) err(1,"lseek bad=%"I64d,end);
180 r = read(fd,buf,4);
181 if(r!=4) err(1,"Can't read 4 bytes at %"I64d);
182 if(strcmp(buf,AF_SEGTAIL)==0){
183 printf("Valid AF_SEGTAIL found at %"I64d" (%"I64d" bytes in)\n",end,len-end);
184 if(!opt_fix) errx(0,"Rerun with -y flag to fix");
185 printf("Truncating at %"I64d"\n",end);
186 if(ftruncate(fd,end+4)) err(0,"ftruncate");
187 break;
188 }
189 }
190 }
191 close(fd);
192 exit(0);
193
194
195
196 AFFILE *af = af_open(infile,O_RDONLY,0);
197 if(!af) af_err(1,infile);
198 int fix = 0;
199 bool fix_add_gid = false;
200
201 if(af_get_seg(af,AF_IMAGE_GID,0,0,0)){
202 printf("no GID (%s)",AF_IMAGE_GID);
203 fix++;
204 fix_add_gid = true;
205 }
206 af_close(af);
207 if(opt_fix==0 || fix==0) return 0;
208
209 if(fix){
210 af = af_open(infile,O_RDWR,0);
211 if(!af){
212 warn(infile);
213 return -1;
214 }
215 if(fix_add_gid) {
216 printf(" ... adding GID ",infile);
217 unsigned char bit128[16];
218 RAND_pseudo_bytes(bit128,sizeof(bit128));
219 if(af_update_seg(af,AF_IMAGE_GID,0,bit128,sizeof(bit128))){
220 warn("Cannot write %s: ",AF_IMAGE_GID);
221 }
222 }
223 if(af_close(af)){
224 warn("Cannot close %s",infile);
225 }
226 }
227 putchar('\n');
228 return 0;
229 }
230 #endif
231
232 int main(int argc,char **argv)
233 {
234 int bflag, ch;
235
236 setvbuf(stdout,0,_IONBF,0); // turn off buffering
237
238 /* Figure out how many cols the screen has... */
239 bflag = 0;
240 while ((ch = getopt(argc, argv, "yh?v")) != -1) {
241 switch (ch) {
242 case 'y':
243 opt_fix = 1;
244 break;
245 case 'h':
246 case '?':
247 default:
248 usage();
249 break;
250 case 'v':
251 printf("%s version %s\n",progname,PACKAGE_VERSION);
252 exit(0);
253
254 }
255 }
256 argc -= optind;
257 argv += optind;
258
259 if(argc<1){
260 usage();
261 }
262
263
264 /* Loop through all of the files */
265 while(*argv){
266 fix(*argv++); // get the file
267 argc--; // decrement argument counter
268 }
269 exit(0);
270 }
271
272
0 /************************************************************
1 *
2 * (c) 2007 Olivier Castan castan.o@free.fr
3 * Modifications (C) 2007 Simson Garfinkel, to fit into the AFFLIB build system.
4 *
5 * License: LGPL or AFFLIB. Take your choice.
6 *
7 * KISS: based on fuse hello.c example
8 *
9 * TODO: - use xattr to display informations from segments
10 * - use AF_ACQUISITION_DATE for creation date
11 * - option between BADFLAG and NULLs
12 * - ...
13 *
14 * *********************************************************/
15
16 #if HAVE_CONFIG_H
17 #include "affconfig.h"
18 #endif
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <errno.h>
24
25 #ifdef USE_FUSE
26
27 /* bool used in afflib.h but not defined within C */
28 #ifndef bool
29 #define bool int
30 #endif
31 #include "afflib.h"
32 #include <fuse.h>
33 #include <fcntl.h>
34 #include <libgen.h>
35
36
37 #define XCALLOC(type, num) \
38 ((type *) xcalloc ((num), sizeof(type)))
39 #define XMALLOC(type, num) \
40 ((type *) xmalloc ((num) * sizeof(type)))
41 #define XFREE(stale) do { \
42 if (stale) { free ((void *) stale); stale = 0; } \
43 } while (0)
44
45
46
47 static char *raw_path = NULL;
48 static off_t raw_size = 0;
49 static AFFILE *af_image = NULL;
50 static const char *raw_ext = ".raw";
51
52 static void *
53 xmalloc (size_t num)
54 {
55 void *alloc = malloc (num);
56 if (!alloc) {
57 perror ("Memory exhausted");
58 exit(EXIT_FAILURE);
59 }
60 return alloc;
61 }
62
63 static void *
64 xcalloc (size_t num, size_t size)
65 {
66 void *alloc = xmalloc (num * size);
67 memset (alloc, 0, num * size);
68 return alloc;
69 }
70
71 static char *
72 xstrdup(char *string)
73 {
74 return strcpy((char *)xmalloc(strlen(string) + 1), string);
75 }
76
77 static int
78 affuse_getattr(const char *path, struct stat *stbuf)
79 {
80 int res = 0;
81
82 memset(stbuf, 0, sizeof(struct stat));
83 if(strcmp(path, "/") == 0) {
84 stbuf->st_mode = S_IFDIR | 0755;
85 stbuf->st_nlink = 2;
86 }
87 else if(strcmp(path, raw_path) == 0) {
88 stbuf->st_mode = S_IFREG | 0444;
89 stbuf->st_nlink = 1;
90 stbuf->st_size = raw_size;
91 }
92 else
93 res = -ENOENT;
94
95 return res;
96 }
97
98 static int
99 affuse_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
100 off_t offset, struct fuse_file_info *fi)
101 {
102 (void) offset;
103 (void) fi;
104
105 if(strcmp(path, "/") != 0)
106 return -ENOENT;
107
108 filler(buf, ".", NULL, 0);
109 filler(buf, "..", NULL, 0);
110 filler(buf, raw_path + 1, NULL, 0);
111
112 return 0;
113 }
114
115 static int
116 affuse_open(const char *path, struct fuse_file_info *fi)
117 {
118 if(strcmp(path, raw_path) != 0)
119 return -ENOENT;
120
121 if((fi->flags & 3) != O_RDONLY)
122 return -EACCES;
123
124 return 0;
125 }
126
127 static int
128 affuse_read(const char *path, char *buf, size_t size, off_t offset,
129 struct fuse_file_info *fi)
130 {
131 int res = 0;
132 (void) fi;
133 if(strcmp(path, raw_path) != 0){
134 return -ENOENT;
135 }
136
137 /* TODO: change to sector aligned readings to write NULLs to bad
138 * blocks... */
139 /* looks like af_seek never fails */
140 af_seek(af_image, (uint64_t)offset, SEEK_SET);
141 errno = 0;
142 res = af_read(af_image, (unsigned char *)buf, (int)size);
143 if (res<0){
144 if (errno==0) errno=-EIO;
145 else res = -errno;
146 }
147 return res;
148 }
149
150 static void
151 affuse_destroy(void* param)
152 {
153 af_close(af_image);
154 XFREE(raw_path);
155 return;
156 }
157
158 static struct fuse_operations affuse_oper = {
159 .getattr = affuse_getattr,
160 .readdir = affuse_readdir,
161 .open = affuse_open,
162 .read = affuse_read,
163 .destroy = affuse_destroy,
164 };
165
166 static void
167 usage(void)
168 {
169 char *cmdline[] = {"affuse", "-ho"};
170 printf("affuse version %s\n", PACKAGE_VERSION);
171 printf("Usage: affuse [<FUSE library options>] af_image mount_point\n");
172 /* dirty, just to get current libfuse option list */
173 fuse_main(2, cmdline, &affuse_oper, NULL);
174 printf("\nUse fusermount -u mount_point, to unmount\n");
175 }
176
177 int main(int argc, char **argv)
178 {
179 char *af_path = NULL, *af_basename = NULL;
180 size_t raw_path_len = 0;
181 char **fargv = NULL;
182 int fargc = 0;
183
184 if (argc < 3) {
185 usage();
186 exit(EXIT_FAILURE);
187 }
188
189 /* Prepare fuse args, af_image is omitted, but "-s" is added */
190 fargv = XCALLOC(char *, argc); /* usually not free'd */
191 fargv[0] = argv[0];
192 fargv[1] = argv[argc - 1];
193 fargc = 2;
194 while (fargc <= (argc - 2)) {
195 fargv[fargc] = argv[fargc - 1];
196 if (strcmp(fargv[fargc], "-h") == 0 ||
197 strcmp(fargv[fargc], "--help") == 0 ) {
198 usage();
199 XFREE(fargv);
200 exit(EXIT_SUCCESS);
201 }
202 fargc++;
203 }
204 /* disable multi-threaded operation
205 * (we don't know if afflib is thread safe!)
206 */
207 fargv[fargc] = "-s";
208 fargc++;
209
210 if ((af_image = af_open(argv[argc - 2], O_RDONLY|O_EXCL, 0)) == NULL) {
211 perror("Can't open image file");
212 XFREE(fargv);
213 exit(EXIT_FAILURE);
214 }
215
216 af_path = xstrdup(argv[argc - 2]);
217 af_basename = basename(af_path);
218 /* "/" af_basename raw_ext "/0"*/
219 raw_path_len = 1 + strlen(af_basename) + strlen(raw_ext) + 1;
220 raw_path = XCALLOC(char, raw_path_len);
221 raw_path[0] = '/';
222 strcat(raw_path, af_basename);
223 strcat(raw_path, raw_ext);
224 raw_path[raw_path_len -1] = 0;
225 XFREE(af_path);
226 raw_size = af_get_imagesize(af_image);
227
228 return fuse_main(fargc, fargv, &affuse_oper, NULL);
229 }
230 #else
231 int main(int argc,char **argv)
232 {
233 fprintf(stderr,"affuse: FUSE support is disabled.\n");
234 #ifndef linux
235 fprintf(stderr,"affuse was compiled on a platform that does not support FUSE\n");
236 #else
237 fprintf(stderr,"affuse was compiled on a Linux system that did not\n");
238 fprintf(stderr,"have the FUSE developer libraries installed\n");
239 #endif
240 exit(1);
241 }
242 #endif
0 /*
1 * afinfo.cpp:
2 *
3 * print information about an aff file
4 */
5
6 /*
7 * Copyright (c) 2005--2008
8 * Simson L. Garfinkel and Basis Technology, Inc.
9 * All rights reserved.
10 *
11 * This code is derrived from software contributed by
12 * Simson L. Garfinkel
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Simson L. Garfinkel
25 * and Basis Technology Corp.
26 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
27 * contributors to this program may be used to endorse or promote
28 * products derived from this software without specific prior written
29 * permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
32 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
33 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
36 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46
47 #include "affconfig.h"
48 #include "afflib.h"
49 #include "utils.h"
50 #include "afflib_i.h"
51
52 #ifdef USE_S3
53 #include "s3_glue.h"
54 #endif
55
56 #include <ctype.h>
57 #include <zlib.h>
58 #include <openssl/md5.h>
59 #include <openssl/sha.h>
60 #include <assert.h>
61
62 #include <algorithm>
63 #include <cstdlib>
64 #include <vector>
65 #include <string>
66
67 #ifdef HAVE_CSTRING
68 #include <cstring>
69 #endif
70
71 using namespace std;
72
73 #ifdef HAVE_CURSES_H
74 #include <curses.h>
75 #endif
76
77 #ifdef HAVE_TERM_H
78 #include <term.h>
79 #endif
80
81 #ifdef HAVE_NCURSES_TERM_H
82 #include <ncurses/term.h>
83 #endif
84
85 #ifdef WIN32
86 #include "unix4win32.h"
87 #endif
88
89 const char *progname = "afinfo";
90
91 #define VALIDATE_MD5 0x01
92 #define VALIDATE_SHA1 0x02
93
94 int opt_validate = 0;
95 int opt_info = 1;
96 int opt_all = 0;
97 int opt_wide = 0;
98 int opt_l = 0;
99 unsigned int cols = 80; // default
100 int opt_x = 0;
101 int opt_b = 0;
102 int opt_identify = 1;
103 int opt_verbose = 0;
104 int opt_y = 0;
105 int opt_hexbuf = AF_HEXBUF_SPACE4 | AF_HEXBUF_UPPERCASE;
106 int opt_page_validate = 0;
107 int opt_no_preview = 0;
108 int opt_preview_md5 = 0;
109 int opt_debug = 0;
110 int opt_figure_media = 0;
111 const char *opt_passphrase = 0;
112
113 vector<string> opt_seglist; // just info these segments
114 bool something_was_decrypted = false;
115 const char *term = 0;
116
117
118 /**
119 * select bold on or off
120 */
121 void bold(int on)
122 {
123 if(!term) return;
124 #if defined(HAVE_LIBNCURSES)
125 #ifdef HAVE_ISATTY
126 if(!isatty(fileno(stdout))) return;
127 #endif
128 if(on) tputs(enter_bold_mode,1,putchar);
129 else tputs(exit_attribute_mode,0,putchar);
130 #endif
131 }
132
133 /**
134 * select a color.
135 * @param num - 0 is black; 1 red; 2 green; 3 yellow; 4 blue; 5 magenta; 6 cyan; 7 white;
136 */
137
138 #define RED 1
139 #define WHITE 7
140
141 void color(int num)
142 {
143 #ifdef HAVE_ISATTY
144 if(!isatty(fileno(stdout))) return;
145 #endif
146 #ifdef HAVE_CURSES_H
147 char *setf = tigetstr((char *)"setf");
148 if(!setf) setf = tigetstr((char *)"setaf");
149 if(setf){
150 putp(tparm(setf,num));
151 }
152 #endif
153 }
154
155
156 void usage()
157 {
158 printf("%s version %s\n",progname,PACKAGE_VERSION);
159 printf("usage: %s [options] infile\n",progname);
160 printf(" -a = print ALL segments (normally data segments are suppressed)\n");
161 printf(" -b = print how many bad blocks in each segment (implies -a)\n");
162 printf(" -i = identify the files, don't do info on them.\n");
163 printf(" -w = wide output; print more than 1 line if necessary.\n");
164 printf(" -s segment = Just print information about 'segment'.\n");
165 printf(" (may be repeated)\n");
166 printf(" -m = validate MD5 hash of entire image\n");
167 printf(" -S = validate SHA1 hash of entire image\n");
168 printf(" -v = validate the hash of each page (if present)\n");
169 printf(" -y = don't print segments of lengths 16 and 20 as hex)\n");
170 printf(" -p<passphrase> = Specify <passphrase> to decrypt file\n");
171 printf(" -l = Just print the segment names and exit\n");
172 printf(" -V = Just print the version number and exit.\n");
173
174 printf("\nPreview Options:\n");
175 printf(" -X = no data preview; just print the segment names\n");
176 printf(" -x = print binary values in hex (default is ASCII)\n");
177 printf("\nMisc:\n");
178 printf(" -d = debug\n");
179 printf(" -A = if infile is a device, print the number of sectors\n");
180 printf(" and sector size to stdout in XML. Otherwise error\n");
181 printf("\nCompilation:\n");
182 printf(" LZMA compression: Enabled\n");
183 #ifdef USE_LIBEWF
184 printf(" LIBEWF enabled\n");
185 #endif
186 #ifdef USE_QEMU
187 printf(" QEMU enabled\n");
188 #endif
189 #ifdef USE_FUSE
190 printf(" FUSE enabled\n");
191 #endif
192 #ifdef USE_S3
193 printf(" Amazon S3 enabled\n");
194 #endif
195 #ifdef HAVE_LIBEXPAT
196 printf(" HAVE_LIBEXPAT ");
197 #endif
198 printf("\n");
199
200 if(opt_debug){
201 for(int i=0;i<9;i++){
202 color(i);printf("Color %d\n",i);color(7);
203 }
204 }
205
206 exit(0);
207 }
208
209
210 AFFILE *af=0;
211
212 void sig_info(int arg)
213 {
214 if(af==0) return;
215 printf("Validating %"I64d" of %"I64d"\n", af->pos,af->image_size);
216 }
217
218
219
220
221 void validate(const char *infile)
222 {
223 af = af_open(infile,O_RDONLY,0);
224 if(!af) af_err(1,infile);
225 switch(af_identify(af)){
226 case AF_IDENTIFY_AFF:
227 case AF_IDENTIFY_AFM:
228 case AF_IDENTIFY_AFD:
229 break;
230 default:
231 printf("%s is not an AFF file\n",infile);
232 af_close(af);
233 return;
234 }
235
236 printf("\nValidating ");
237 if(opt_validate & VALIDATE_MD5) printf("MD5 ");
238 if(opt_validate == (VALIDATE_MD5|VALIDATE_SHA1)) printf("and ");
239 if(opt_validate & VALIDATE_SHA1) printf("SHA1 ");
240 printf("hash codes.\n");
241
242
243 #ifdef SIGINFO
244 signal(SIGINFO,sig_info);
245 #endif
246
247 /* Get a list of all the segments to see if there is a space */
248 af_rewind_seg(af);
249 char segname[AF_MAX_NAME_LEN];
250 vector <int> pages;
251 memset(segname,0,sizeof(segname));
252 while(af_get_next_seg(af,segname,sizeof(segname),0,0,0)==0){
253 int64_t page_num = af_segname_page_number(segname);
254 if(page_num>=0) pages.push_back(page_num);
255 }
256
257 if(pages.size()==0){
258 printf("No pages to validate.\n");
259 af_close(af);
260 }
261
262 sort(pages.begin(),pages.end());
263 vector<int>::iterator i = pages.begin();
264 int last = *i;
265 i++;
266 for(; i!= pages.end();i++){
267 if(last+1 != *i){
268 printf("gap in pages (%d!=%d); %s can't be validated.\n",last+1,*i,infile);
269 af_close(af);
270 return;
271 }
272 last = *i;
273 }
274
275 /* Set up the hash machinery */
276 MD5_CTX md5;
277 MD5_Init(&md5);
278
279 SHA_CTX sha;
280 SHA1_Init(&sha);
281
282 uint64_t total_bytes = 0;
283 while(!af_eof(af)){
284 unsigned char buf[65536]; // a decent size
285 size_t bytes = af_read(af,buf,sizeof(buf));
286 if(bytes==0) break; // reached sparse region of file
287 total_bytes += bytes;
288 if(opt_validate & VALIDATE_MD5) MD5_Update(&md5,buf,bytes);
289 if(opt_validate & VALIDATE_SHA1) SHA1_Update(&sha,buf,bytes);
290 }
291
292 /* Finish the hash calculations and write to the db */
293
294 if(opt_validate & VALIDATE_MD5){
295 unsigned char md5_stored[16];
296 size_t md5len = sizeof(md5_stored);
297 unsigned char md5_computed[16];
298 char buf[256];
299
300 MD5_Final(md5_computed,&md5);
301 printf("computed md5: %s\n",
302 af_hexbuf(buf,sizeof(buf),md5_computed,16,opt_hexbuf));
303 if(af_get_seg(af,AF_MD5,0,md5_stored,&md5len)==0){
304 printf(" stored md5: %s ",
305 af_hexbuf(buf,sizeof(buf),md5_stored,16,opt_hexbuf));
306 if(md5len==16 && !memcmp((const char *)md5_stored,
307 (const char *)md5_computed,16)){
308 printf(" MATCH\n");
309 }
310 else {
311 printf(" NO MATCH!\n");
312 }
313 }
314 else {
315 printf("(no MD5 in AFF file)\n");
316 }
317 }
318
319
320 if(opt_validate & VALIDATE_SHA1){
321 unsigned char sha1_stored[20];
322 size_t sha1len = sizeof(sha1_stored);
323 unsigned char sha1_computed[20];
324 char buf[256];
325
326 SHA1_Final(sha1_computed,&sha);
327 printf("computed sha1: %s \n",af_hexbuf(buf,sizeof(buf),sha1_computed,20,opt_hexbuf));
328 if(af_get_seg(af,AF_SHA1,0,sha1_stored,&sha1len)==0){
329 printf(" stored sha1: %s ",af_hexbuf(buf,sizeof(buf),sha1_stored,20,opt_hexbuf));
330 if(sha1len==20 && !memcmp((const char *)sha1_stored,
331 (const char *)sha1_computed,20)){
332 printf(" MATCH\n");
333 }
334 else {
335 printf(" NO MATCH!\n");
336 }
337 }
338 else {
339 printf("(no SHA1 in AFF file)\n");
340 }
341 }
342
343 af_close(af);
344 }
345
346 #define OUTLINE_LEN 65536
347
348
349 bool display_as_time(const char *segname)
350 {
351 if(strcmp(segname,AF_ACQUISITION_SECONDS)==0) return true;
352 return false;
353 }
354
355 bool display_as_hex(const char *segname,int data_len)
356 {
357 if(af_display_as_hex(segname)) return true;
358 if(data_len==16 && strstr(segname,"md5")) return true;
359 if(data_len==20 && strstr(segname,"sha1")) return true;
360 if(opt_x) return true;
361 if(opt_preview_md5) return true;
362 return false;
363 }
364
365 void badscan(AFFILE *af,int page_number,size_t data_len)
366 {
367 size_t page_size = af->image_pagesize;
368 unsigned char *buf = (unsigned char *)malloc(page_size);
369 if(af_get_page(af,page_number,buf,&page_size)){
370 err(1,"Could not read page %d",page_number);
371 }
372 printf("page_size = %d\n",(int)page_size);
373 int sectors = 0;
374 int bad_sectors = 0;
375 int funny_sectors = 0;
376 for(unsigned int offset=0;offset<page_size;offset+=af->image_sectorsize){
377 sectors++;
378 if(af_is_badsector(af,buf+offset)){
379 bad_sectors ++;
380 continue;
381 }
382 #ifdef __FreeBSD__
383 /* Look for the part of the bad flag that we know and love */
384 if(strnstr((char *)buf+offset,"BAD SECTOR",af->image_sectorsize)){
385 funny_sectors++;
386 continue;
387 }
388 #endif
389 }
390 printf(" sectors scanned: %d bad: %d ", sectors,bad_sectors);
391 if(funny_sectors){
392 printf("suspicious: %d ",funny_sectors);
393 }
394 printf("\n");
395 free(buf);
396 }
397
398
399 /* print_info:
400 * Print the info on a given segment name
401 */
402 void print_info(AFFILE *af,const char *segname)
403 {
404 unsigned long arg;
405 unsigned char *data = 0;
406 int dots = 0;
407 u_int display_len = 0;
408 char *cc = 0;
409
410 /* Check to see if this is a null page. */
411 if(segname[0]==0 && opt_all==0){
412 return;
413 }
414 if(segname[0]=='[' && opt_all){
415 puts(segname);
416 return;
417 }
418
419 /* Check to see if this is a data page */
420 int64_t page_num = af_segname_page_number(segname);
421
422 size_t data_len = 0;
423 /* First find out how big the segment is, then get the data */
424 if(af_get_seg(af,segname,&arg,0,&data_len)){
425 printf("%-25s SEGMENT NOT FOUND\n",segname);
426 return;
427 }
428
429 /* is this an encrypted segment that I have decrypted?
430 * Turn off automatic decryption and see if I can get it again...
431 * If we can get it again, then it wasn't decrypted.
432 */
433 int prev = af_set_option(af,AF_OPTION_AUTO_DECRYPT,0);
434 bool was_decrypted = ( af_get_seg(af,segname,0,0,0)!=0) ;
435 af_set_option(af,AF_OPTION_AUTO_DECRYPT,prev);
436
437 if(was_decrypted){
438 bold(1);
439 something_was_decrypted = true; // print key at bottom
440 }
441
442 /* Start the output line */
443 char output_line[OUTLINE_LEN];
444 memset(output_line,0,sizeof(output_line));
445
446 /* Now append the arg and the data len */
447 sprintf(output_line,"%-24s %8ld %8zd ",segname,arg,data_len);
448
449 if(opt_no_preview){
450 printf("%s\n",output_line);
451 goto done;
452 }
453
454 data = (unsigned char *)malloc(data_len);
455 if(af_get_seg(af,segname,0,data,&data_len)){
456 warn("af_get_seg_2 failed: segname=%s data_len=%zd",segname,data_len);
457 goto done;
458 }
459
460 /* Special handling of values that should be displayed as time */
461 if(display_as_time(segname)){
462 int hours = arg / 3600;
463 int minutes = (arg / 60) % 60;
464 int seconds = arg % 60;
465 printf("%s= %02d:%02d:%02d (hh:mm:ss)\n",output_line,hours,minutes,seconds);
466 goto done;
467 }
468
469 /* Special handling of quadwords that should be printed as such? */
470 if(((arg == AF_SEG_QUADWORD) && (data_len==8)) || af_display_as_quad(segname)){
471 /* Print it as a 64-bit value.
472 * The strcmp is there because early AF_IMAGESIZE segs didn't set
473 * AF_SEG_QUADWORD...
474 */
475 switch(data_len){
476 case 8:
477 printf("%s= %"I64d" (64-bit value)\n",
478 output_line,af_decode_q(data));
479 break;
480 case 0:
481 printf("%s= 0 (0-length segment)\n",output_line);
482 break;
483 default:
484 printf("%s= CANNOT DECODE %d byte segment\n",output_line,(int)data_len);
485 }
486 goto done;
487 }
488
489
490 /* See if I need to truncate */
491 display_len = data_len;
492 if(opt_wide==0 && data_len>32){ // don't bother showing more than first 32 bytes
493 dots = 1;
494 display_len = 32;
495 }
496
497 cc = output_line + strlen(output_line);
498
499 if(opt_preview_md5){
500 u_char md5[32];
501 MD5(data,data_len,md5);
502 memcpy(data,md5,32);
503 data_len = 32;
504 }
505 if(display_as_hex(segname,display_len)){
506 char buf[80];
507 snprintf(cc,sizeof(output_line)-strlen(output_line),
508 "%s%s",af_hexbuf(buf,sizeof(buf),data,display_len,opt_hexbuf),
509 dots ? "..." : "");
510 /* Special code for SHA1 */
511 if(!opt_wide && strcmp(segname,AF_SHA1)==0){
512 fwrite(output_line,1,82,stdout);
513 printf("\n%62s\n",output_line+82);
514 goto done;
515 }
516 }
517 else {
518 /* Fill it out with some printable data */
519 unsigned int i;
520 if(display_len > sizeof(output_line)-strlen(output_line)){
521 display_len = sizeof(output_line)-strlen(output_line);
522 }
523 for(i=0;i<display_len;i++){
524 *cc = data[i];
525 if(isprint(*cc)==0) *cc='.';
526 if(*cc=='\n' || *cc=='\r') *cc=' ';
527 cc++;
528 }
529 *cc = 0;
530 }
531
532 /* Now print the results... */
533 if(!opt_wide){
534 if(strlen(output_line)>cols){
535 output_line[cols-4] = '.';
536 output_line[cols-3] = '.';
537 output_line[cols-2] = '.';
538 output_line[cols-1] = '\000';
539 }
540 }
541 fputs(output_line,stdout);
542 if(page_num>=0 && opt_b){
543 badscan(af,page_num,data_len);
544 }
545 if(opt_page_validate && page_num>=0){
546 /* Get the page again; this may involve decompression */
547 unsigned char *page_data = (unsigned char *)malloc(af->image_pagesize);
548 size_t page_data_len = af->image_pagesize;
549 if(af_get_page(af,page_num,page_data,&page_data_len)){
550 printf("** COULD NOT READ UNCOMPRESSED PAGE ");
551 goto skip1;
552 }
553
554 char hash_segname[32];
555 unsigned char hash_buf[16];
556 unsigned char hash_calc[16];
557 size_t hash_len = sizeof(hash_buf);
558 snprintf(hash_segname,sizeof(hash_segname),AF_PAGE_MD5,page_num);
559 printf(" ");
560 if(af_get_seg(af,hash_segname,0,hash_buf,&hash_len)){
561 printf("** NO SEGMENT %s ** ",hash_segname);
562 goto skip1;
563 }
564
565 MD5(page_data,page_data_len,hash_calc);
566 if(memcmp(hash_buf,hash_calc,sizeof(hash_buf))!=0){
567 char hb[32];
568 printf("** HASH INVALID **\n%30s Calculated %s\n","",
569 af_hexbuf(hb,sizeof(hb),hash_calc,16,opt_hexbuf));
570 printf("%30s Wanted %s ","",af_hexbuf(hb,sizeof(hb),hash_buf,16,opt_hexbuf));
571 printf("data_len=%d\n",(int)data_len);
572 } else{
573 printf("HASH OK ");
574 }
575 free(page_data);
576 }
577 skip1:;
578 putchar('\n');
579 done:
580 if(data) free(data);
581 bold(0); // make sure bold is off
582
583 //color(WHITE); // make sure we are back to normal color
584 }
585
586
587 /* Print the information on a specific file. */
588 int info_file(const char *infile)
589 {
590 unsigned long total_segs = 0;
591 unsigned long total_pages = 0;
592 unsigned long total_hashes = 0;
593 unsigned long total_signatures =0;
594 unsigned long total_nulls = 0;
595 struct af_vnode_info vni;
596
597 AFFILE *af = af_open(infile,O_RDONLY,0);
598 if(!af) af_err(1,"Cannot open %s",infile);
599 if(af_vstat(af,&vni)) err(1,"%s: af_vstat failed",infile);
600
601 if(opt_l){
602 /* Just list the segments and exit */
603 aff::seglist sl;
604 sl.get_seglist(af);
605 for(aff::seglist::const_iterator i = sl.begin(); i!=sl.end(); i++){
606 printf("%s\n",(*i).name.c_str());
607 }
608 af_close(af);
609 return 0;
610 }
611
612 if(vni.segment_count_encrypted>0 || vni.segment_count_signed>0){
613 printf("%s: has %s%s%ssegments\n",infile,
614 (vni.segment_count_encrypted ? "encrypted " : ""),
615 ((vni.segment_count_encrypted && vni.segment_count_signed) ? "and ": ""),
616 (vni.segment_count_signed ? "signed " : ""));
617 }
618
619
620 if(opt_passphrase){
621 if(af_use_aes_passphrase(af,opt_passphrase)){
622 errx(1,"%s: cannot use passphrase",opt_passphrase);
623 }
624 }
625
626 printf("\n%s\n",af_filename(af));
627 const char *v1 = "data";
628 const char *v2 = "====";
629
630 if(opt_all==0) printf("[skipping data segments]\n");
631 if(opt_all==0 && vni.segment_count_encrypted) printf("[skipping encrypted segments]\n");
632 if(opt_no_preview){
633 v1 = "";
634 v2 = "";
635 }
636 if(opt_preview_md5){
637 v1 = "md5";
638 }
639
640 printf(" data \n");
641 printf("Segment arg length %s\n",v1);
642 printf("======= ========= ======== %s\n",v2);
643
644 /* If a list of segments was specified by the user, just use that list */
645 if(opt_seglist.size()>0){
646 for(vector<string>::iterator i = opt_seglist.begin();
647 i != opt_seglist.end();
648 i++){
649 const char *segname = i->c_str();
650 print_info(af,segname);
651 }
652 af_close(af);
653 return 0;
654 }
655
656 /* Go through the whole file, get all of the segments, put them in a list */
657 vector <string> segments;
658 char segname[AF_MAX_NAME_LEN];
659 af_rewind_seg(af); // start at the beginning
660 int64_t total_datalen = 0;
661 size_t total_segname_len = 0;
662 size_t datalen = 0;
663 int aes_segs=0;
664 while(af_get_next_seg(af,segname,sizeof(segname),0,0,&datalen)==0){
665 total_segs ++;
666 total_datalen += datalen;
667 total_segname_len += strlen(segname);
668 if(segname[0]==0) total_nulls++;
669
670 /* Check to see if this is a regular page or a hash page */
671 char hash[64];
672 int64_t page_num = af_segname_page_number(segname);
673 int64_t hash_num = af_segname_hash_page_number(segname,hash,sizeof(hash));
674 if(page_num>=0) total_pages++;
675 if(hash_num>=0) total_hashes++;
676 if(strstr(segname,AF_SIG256_SUFFIX)) total_signatures++;
677 if(strstr(segname,AF_AES256_SUFFIX)) aes_segs++;
678 if(opt_all==0 && (page_num>=0||hash_num>=0)) continue; // skip
679 if(opt_all==0 && af_is_encrypted_segment(segname)) continue; // skip
680
681 if(segname[0]==0 && datalen>0 && opt_all){
682 snprintf(segname,sizeof(segname),"[null %zd bytes]",datalen);
683 }
684 segments.push_back(segname);
685 }
686
687 /* Now process the segments */
688 for(vector<string>::const_iterator i = segments.begin();
689 i != segments.end(); i++){
690 print_info(af,i->c_str());
691 }
692
693 /* Print the key */
694 if(something_was_decrypted){
695 bold(1);
696 printf("Bold indicates segments that were decrypted.\n");
697 bold(0);
698 }
699
700
701 printf("\n");
702 printf("Total segments: %8lu (%lu real)\n", total_segs,total_segs-total_nulls);
703 if(aes_segs){
704 printf(" Encrypted segments: %8u\n",aes_segs);
705 }
706 printf(" Page segments: %8lu\n",total_pages);
707 printf(" Hash segments: %8lu\n",total_hashes);
708 printf(" Signature segments: %8lu\n",total_signatures);
709 printf(" Null segments: %8lu\n",total_nulls);
710 if(opt_all){
711 printf(" Empty segments: %8lu\n",total_nulls);
712 printf("\n");
713 printf("Total data bytes in segments: %"I64d"\n",total_datalen);
714
715 printf("Total space in file dedicated to segment names: %zd\n",
716 total_segname_len);
717 printf("Total overhead for %lu segments: %zd bytes (%lu*(%zd+%zd))\n",
718 total_segs,
719 (size_t) total_segs*(sizeof(struct af_segment_head) +sizeof(struct af_segment_tail)),
720 total_segs,
721 sizeof(struct af_segment_head),
722 sizeof(struct af_segment_tail));
723 printf("Overhead for AFF file header: %zd bytes\n",sizeof(struct af_head));
724 }
725
726 int64_t device_sectors = 0;
727 af_get_segq(af,AF_DEVICE_SECTORS,&device_sectors);
728 if(device_sectors==0){
729 /* See if we can fake it */
730 unsigned long cylinders=0;
731 unsigned long heads=0;
732 unsigned long sectors_per_track=0;
733 af_get_seg(af,AF_CYLINDERS,&cylinders,0,0);
734 af_get_seg(af,AF_HEADS,&heads,0,0);
735 af_get_seg(af,AF_SECTORS_PER_TRACK,&sectors_per_track,0,0);
736 device_sectors = cylinders * heads * sectors_per_track;
737 }
738 //printf("device_sectors=%"I64d"\n",device_sectors);
739
740
741 int some_missing_pages = 1;
742 if(af->image_pagesize && af->image_sectorsize && device_sectors){
743 int64_t device_bytes = (int64_t)device_sectors * af->image_sectorsize;
744 int64_t device_pages = (device_bytes+af->image_pagesize-1) / af->image_pagesize;
745 int64_t missing_pages = device_pages - total_pages;
746 //printf("device_bytes=%"I64d"\n",device_bytes);
747 //printf("device_pages=%"I64d"\n",device_pages);
748 if(missing_pages!=0){
749 printf("Missing page segments: %8"I64u"\n",missing_pages);
750 }
751 else {
752 some_missing_pages=0;
753 }
754 }
755 if (some_missing_pages){
756 if(((total_pages-1) * af->image_pagesize <= af->image_size) &&
757 ((total_pages) * af->image_pagesize >= af->image_size)){
758 some_missing_pages = 0;
759 }
760 }
761
762 if(some_missing_pages && opt_debug){
763 printf("Cannot calculate missing pages\n");
764 printf(" device_sectors=%"I64d" image_pagesize=%lu sectorsize=%lu\n",
765 device_sectors,af->image_pagesize,af->image_sectorsize);
766 }
767 af_close(af);
768 return 0;
769
770 }
771
772
773 void figure_media(const char *fn)
774 {
775 int fd = open(fn,O_RDONLY,0);
776 if(fd<0) err(1,"open(%s)",fn);
777 struct af_figure_media_buf afb;
778 if(af_figure_media(fd,&afb)){
779 err(1,"af_figure_media(%s)",fn);
780 }
781 printf("<?xml version='1.0' encoding='UTF-8'?>\n");
782 printf("<!DOCTYPE Server >\n");
783 printf("<device name='%s'>\n",fn);
784 printf(" <sector_size>%d</sector_size>\n",afb.sector_size);
785 printf(" <total_sectors>%"PRId64"</total_sectors>\n",afb.total_sectors);
786 printf(" <max_read_blocks>%"PRIu64"</max_read_blocks>\n",afb.max_read_blocks);
787 printf("</device>\n");
788 close(fd);
789 }
790
791 int main(int argc,char **argv)
792 {
793 int ch;
794 const char *infile;
795
796 /* Figure out how many cols the screen has... */
797 #ifdef HAVE_LIBNCURSES
798 term = getenv("TERM");
799 if(term){
800 setupterm((char *)0,1,(int *)0);
801 start_color();
802 cols = tgetnum((char *)"co");
803 }
804 #endif
805
806 while ((ch = getopt(argc, argv, "abh?s:SmiIwj:p:xvVX5dAl")) != -1) {
807 switch (ch) {
808 case 'a': opt_all++; break;
809 case 'b': opt_all ++; opt_b ++; break;
810 case 'i': opt_info=0; opt_identify = 1; break;
811 case 'w': opt_wide++; break;
812 case 'X': opt_no_preview++;break;
813 case 'x': opt_x++; break;
814 case 'y': opt_y++; break;
815 case 'l': opt_l++;break;
816 case 'm': opt_validate |= VALIDATE_MD5; break;
817 case 'S': opt_validate |= VALIDATE_SHA1; break;
818 case 'v': opt_page_validate = 1;break;
819 case 'p': opt_passphrase = optarg; break;
820 case '5': opt_preview_md5 = 1;break;
821 case 'd': opt_debug = 1;break;
822 case 'A': opt_figure_media = 1 ; break;
823
824 case 'h':
825 case '?':
826 default:
827 usage();
828 break;
829 case 's':
830 opt_seglist.push_back(optarg); // add to the list of segments to info
831 break;
832 case 'V':
833 printf("%s version %s\n",progname,PACKAGE_VERSION);
834 exit(0);
835 }
836 }
837 argc -= optind;
838 argv += optind;
839
840 if(argc<1){
841 usage();
842 }
843
844
845 /* Loop through all of the files */
846 while(*argv){
847 infile = *argv++; // get the file
848 argc--; // decrement argument counter
849
850 const char *name = af_identify_file_name(infile,1);
851 if(!name) err(1,"%s",infile);
852
853 if(opt_figure_media){ figure_media(infile);continue;}
854 if(opt_identify) printf("%s is a %s file\n",infile,name);
855 if(opt_info) info_file(infile);
856 if(opt_validate) validate(infile);
857 }
858 #ifdef USE_S3
859 s3_audit(0);
860 #endif
861 return(0);
862 }
863
864
0 /*
1 * afrecover.cpp
2 *
3 * Recover broken pages of an AFF file using the party bits
4 */
5
6 /*
7 * Copyright (c) 2005
8 * Simson L. Garfinkel and Basis Technology, Inc.
9 * All rights reserved.
10 *
11 * This code is derrived from software contributed by
12 * Simson L. Garfinkel
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Simson L. Garfinkel
25 * and Basis Technology Corp.
26 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
27 * contributors to this program may be used to endorse or promote
28 * products derived from this software without specific prior written
29 * permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
32 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
33 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
36 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46
47 #include "affconfig.h"
48 #include "afflib.h"
49 #include "afflib_i.h"
50 #include "utils.h"
51
52 #include <ctype.h>
53
54 #include <zlib.h>
55 #include <openssl/md5.h>
56 #include <openssl/sha.h>
57 #include <assert.h>
58
59 #ifdef HAVE_UNISTD_H
60 #include <unistd.h>
61 #endif
62
63 #ifdef HAVE_TERM_H
64 #include <term.h>
65 #endif
66
67 #ifdef HAVE_NCURSES_TERM_H
68 #include <ncurses/term.h>
69 #endif
70
71 #ifdef WIN32
72 #include "unix4win32.h"
73 #include <malloc.h>
74 #endif
75
76 using namespace std;
77 using namespace aff;
78
79 const char *progname = "affix";
80
81
82 int opt_b = 0;
83
84
85 void usage()
86 {
87 printf("usage: %s filename\n",progname);
88 exit(0);
89 }
90
91
92
93 int recover(const char *fname)
94 {
95 AFFILE *af = af_open(fname,O_RDWR,0);
96 if(!af) af_err(1,fname);
97
98 /* Get the parity page */
99 size_t pagesize = af_page_size(af);
100 u_char *pagebuf = (unsigned char *)calloc(pagesize,1);
101 u_char *parity_buf = (unsigned char *)calloc(pagesize,1);
102 u_char *my_parity_buf = (unsigned char *)calloc(pagesize,1);
103
104
105 if(af_get_seg(af,AF_PARITY0,0,parity_buf,&pagesize)){
106 err(1,"Cannot read %s segment; cannot continue",AF_PARITY0);
107 }
108
109 /* Now, for every page:
110 * 1. Read the page & the signature
111 * 2. If the signature is good, add it into the parity buffer.
112 * - If not, put it on the list of bad segments.
113 */
114 seglist segments(af);
115 seglist bad_sigs;
116 seglist good_sigs;
117 for(seglist::const_iterator seg = segments.begin();
118 seg != segments.end();
119 seg++){
120
121 if (seg->pagenumber()<0) continue; // only look for pages
122 switch(af_sig_verify_seg(af,seg->name.c_str())){
123 case AF_ERROR_SIG_NO_CERT:
124 errx(1,"%s: no public key in AFF file\n",af_filename(af));
125 case AF_ERROR_SIG_READ_ERROR:
126 errx(1,"no signature for segment '%s' --- recovery cannot continue",seg->name.c_str());
127 case AF_ERROR_SIG_BAD:
128 printf("%s has a bad signature\n",af_filename(af));
129 bad_sigs.push_back(*seg);
130 break;
131 case AF_SIG_GOOD:
132 good_sigs.push_back(*seg);
133 /* While the page is in the cache, make our parity buf */
134 pagesize = af_page_size(af);
135 if(af_get_page(af,seg->pagenumber(),pagebuf,&pagesize)){
136 err(1,"cannot read %s\n",seg->name.c_str());
137 }
138 for(u_int i=0;i<pagesize;i++){
139 my_parity_buf[i] ^= pagebuf[i];
140 }
141 break;
142 default:
143 break;
144 }
145 }
146 u_char *new_pagebuf = (unsigned char *)calloc(pagesize,1);
147
148 if(bad_sigs.size()>1) errx(1,"This program can only repair 1 bad page at the moment.");
149 if(bad_sigs.size()==0) errx(1,"There are no bad pages for this program to repair.");
150 printf("Attempting to repair %s\n",bad_sigs[0].name.c_str());
151
152 /* Calculate the page buf */
153 for(u_int i=0;i<pagesize;i++){
154 new_pagebuf[i] = parity_buf[i] ^ my_parity_buf[i];
155 }
156
157 /* Write the page back */
158 if(af_update_page(af,bad_sigs[0].pagenumber(),new_pagebuf,pagesize)){
159 err(1,"Cannot put page back");
160 }
161
162 /* Now verify the signature */
163 int r = af_sig_verify_seg(af,bad_sigs[0].name.c_str());
164 if(r==AF_SIG_GOOD){
165 printf("Page %s successfully repaired\n",bad_sigs[0].name.c_str());
166 }
167 else{
168 printf("Page %s could not be repaired; signature error code=%d\n",bad_sigs[0].name.c_str(),r);
169 exit(1);
170 }
171 af_close(af);
172 return 0;
173 }
174
175
176
177 int main(int argc,char **argv)
178 {
179 setvbuf(stdout,0,_IONBF,0); // turn off buffering
180 int ch;
181 while ((ch = getopt(argc, argv, "bh?v")) != -1) {
182 switch (ch) {
183 case 'h':
184 case '?':
185 default:
186 usage();
187 break;
188 case 'v':
189 printf("%s version %s\n",progname,PACKAGE_VERSION);
190 exit(0);
191
192 }
193 }
194 argc -= optind;
195 argv += optind;
196
197 if(argc<1){
198 usage();
199 }
200
201 recover(argv[0]);
202 exit(0);
203 }
204
205
0 /*
1 * afsegment.cpp
2 *
3 * segment manipulation tool
4 */
5
6 /*
7 * Copyright (c) 2006
8 * Simson L. Garfinkel and Basis Technology, Inc.
9 * All rights reserved.
10 *
11 * This code is derrived from software contributed by
12 * Simson L. Garfinkel
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Simson L. Garfinkel
25 * and Basis Technology Corp.
26 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
27 * contributors to this program may be used to endorse or promote
28 * products derived from this software without specific prior written
29 * permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
32 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
33 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
36 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46
47 #include "affconfig.h"
48 #include "afflib.h"
49 #include "afflib_i.h"
50
51 #include <limits.h>
52 #include <regex.h>
53
54 #include <algorithm>
55 #include <cstdlib>
56 #include <vector>
57 #include <string>
58
59 #ifdef HAVE_CSTRING
60 #include <cstring>
61 #endif
62
63 using namespace std;
64
65
66 const char *progname = "afsegment";
67
68 int opt_create = 0;
69 int opt_quad = 0;
70 int opt_arg = 0;
71 int opt_verbose = 0;
72 int filecount = 0;
73 int opt_debug = 0;
74 int opt_x = 0;
75
76 void usage()
77 {
78 printf("afsegment version %s\n",PACKAGE_VERSION);
79 printf("usage: afsegment [options] file1.aff [file2.aff ...]\n");
80 printf("options:\n");
81 printf(" -c Create AFF files if they do not exist\n");
82 printf(" -ssegval Sets the value of a segment; may be repeated\n");
83 printf(" -psegname Prints the contents of the segment name for each file\n");
84 printf(" -V Just print the version number and exit.\n");
85 printf(" -dname Delete segment 'name'\n");
86 printf(" -h, -? Print this message\n");
87 printf(" -Q interpert 8-byte segments as a 64-bit value\n");
88 printf(" -A Print the 32-bit arg, not the segment value\n");
89 printf(" -x Print the segment as a hex string\n");
90 printf("\n");
91 printf("Values for segval:\n");
92 printf("\n");
93 printf("Setting the segment values:\n");
94 printf(" -sname=- Take the new value of segment 'name' from stdin\n");
95 printf(" -sname=val Sets segment 'name' to be 'val' \n");
96 printf(" -sname=<val Sets segment 'name' to be contents of file 'val'\n");
97 printf("\n");
98 printf("Setting the segment args:\n");
99 printf(" -sname/arg Sets segment 'name' arg to be 'arg' (may be repeated)\n");
100 printf("\n");
101 printf("Setting both the segment value and the arg:\n");
102 printf(" -sname/arg=val Sets both arg and val for segment 'name'\n");
103 printf(" -sname/arg=<file Sets the arg and take contents from file 'file'\n");
104 printf(" -sname/arg=- Sets the arg of segment 'name' and take the contents from stdin\n");
105 printf("\n");
106 printf("Note: All deletions are done first, then all updates. Don't specify the\n");
107 printf("same segment twice on one command line.\n");
108 exit(0);
109 }
110
111 int get_segment_from_file(AFFILE *af,const char *segname,unsigned long arg,FILE *in)
112 {
113 u_char *value = (u_char *)malloc(0);
114 int value_len = 0;
115
116 while(!feof(in)){
117 char buf[4096];
118 int count;
119 count = fread(buf,1,sizeof(buf),in);
120 if(count>0){
121 value = (u_char *)realloc(value,value_len+count);
122 memcpy(value+value_len,buf,count);
123 value_len += count;
124 }
125 }
126 int r = af_update_seg(af,segname,arg,value,value_len);
127 free(value);
128 return r;
129 }
130
131
132 void update_segment(AFFILE *af,const char *segname,
133 const char *argstr,const char *segval)
134 {
135 unsigned long arg = 0;
136
137 if(strlen(argstr)>1) arg = atoi(argstr+1);
138
139 if(!strcmp(segval,"=-")){
140 get_segment_from_file(af,segname,arg,stdin);
141 return;
142 }
143 if(!strncmp(segval,"=<",2)){
144 FILE *f = fopen(segval+2,"rb");
145 if(!f) err(1,"fopen(%s)",segval+2);
146 get_segment_from_file(af,segname,arg,f);
147 fclose(f);
148 return;
149 }
150 segval++; // skip past the "="
151 int r = af_update_seg(af,segname,arg,(const u_char *)segval,strlen(segval));
152 if(r) warn("af_update(%s,%s) ",af_filename(af),segname);
153 }
154
155
156 char *make_re_string(const char *buf,regmatch_t *match,int num)
157 {
158 int len = match[num].rm_eo - match[num].rm_so;
159 char *ret = (char *)malloc(len+1);
160 memcpy(ret,buf+match[num].rm_so,len);
161 ret[len] = '\000';
162 return ret;
163 }
164
165
166 vector<string>del_segs;
167 vector<string>new_segs;
168 vector<string>print_segs;
169 int flags=O_RDONLY;
170 int openmode = 0666;
171 regex_t re;
172
173 void process(const char *fn)
174 {
175 AFFILE *af = af_open(fn,flags,openmode);
176 if(af){
177 vector<string>::iterator i;
178
179 for(i=del_segs.begin();i!=del_segs.end();i++){
180 if(af_del_seg(af,i->c_str())){
181 warnx("af_del_seg(%s): cannot delete segment '%s' ",fn,i->c_str());
182 }
183 else {
184 printf("%s: '%s' deleted\n",fn,i->c_str());
185 }
186 }
187 for(i=new_segs.begin();i!=new_segs.end();i++){
188 regmatch_t match[10];
189 memset(match,0,sizeof(match));
190 if(regexec(&re,i->c_str(),10,match,0)==0){
191 char *segname = make_re_string(i->c_str(),match,1);
192 char *argstr = make_re_string(i->c_str(),match,2);
193 char *segval = make_re_string(i->c_str(),match,3);
194 update_segment(af,segname,argstr,segval);
195 free(segname);
196 free(argstr);
197 free(segval);
198 }
199 }
200 for(i=print_segs.begin();i!=print_segs.end();i++){
201 size_t len = 0;
202 const char *segname = i->c_str();
203 if(opt_debug) fprintf(stderr," %s: \n",segname);
204 unsigned char *buf=0;
205 if(af_get_seg(af,segname,0,0,&len)){
206 #if HAVE_ISATTY
207 if(isatty(fileno(stdout))){
208 fprintf(stderr,"%s: segment %s not found\n",fn,segname);
209 continue;
210 }
211 #endif
212 if(opt_debug) fprintf(stderr," <<not found>>\n");
213 continue;
214 }
215
216 buf = (u_char *)malloc(len+1);
217 if(!buf) err(1,"malloc");
218 unsigned long arg = 0;
219 buf[len] = 0;
220 if(af_get_seg(af,segname,&arg,buf,&len)){
221 af_err(1,"af_get_seg"); // this shoudln't fail here
222 free(buf);
223 continue;
224 }
225 if(opt_debug) fprintf(stderr," arg=%lu len=%zd\n",arg,len);
226 int p = 1;
227
228 if(filecount>1) printf("%s:",fn);
229 if(print_segs.size()>1) printf("%s=",segname);
230 if(opt_quad && len==8){
231 uint64_t quad = af_decode_q(buf);
232 printf("%"I64u"\n",quad);
233 p = 0;
234 }
235
236 if(opt_arg){
237 printf("%lu\n",arg);
238 p = 0;
239 }
240
241 if(p){
242 for(u_int i=0;i<len;i++){
243 putchar(buf[i]);
244 }
245 }
246 if(filecount>1) printf("\n");
247 fflush(stdout);
248 if(buf) free(buf);
249 }
250 af_close(af);
251 if(opt_x) printf("\n");
252 }
253 else {
254 af_err(1,"af_open(%s) ",fn);
255 }
256 }
257
258 int main(int argc,char **argv)
259 {
260
261 int ch;
262 while ((ch = getopt(argc, argv, "cd:Vp:s::h?QADx")) != -1) {
263 switch (ch) {
264 case 'c':
265 flags |= O_CREAT;
266 openmode = 0666;
267 break;
268 case 'Q': opt_quad=1;break;
269 case 'A': opt_arg=1;break;
270 case 'd':
271 if(optarg==0) usage();
272 del_segs.push_back(optarg); flags |= O_RDWR;break;
273 case 'D':
274 opt_debug=1;
275 break;
276 case 'p':
277 if(optarg==0) usage();
278 print_segs.push_back(optarg); break;
279 case 's':
280 if(optarg==0) usage();
281 if(strlen(optarg)==0) usage();
282 new_segs.push_back(optarg); flags |= O_RDWR;break;
283 case 'x':
284 opt_x++;
285 break;
286 case 'h':
287 case '?':
288 default:
289 usage();
290 exit(0);
291 case 'V':
292 printf("%s version %s\n",progname,PACKAGE_VERSION);
293 exit(0);
294 }
295 }
296 argc -= optind;
297 argv += optind;
298
299 if(argc<1){
300 usage();
301 }
302
303 if(regcomp(&re,"([^/=]*)(/[0-9]+)?(=.*)?",REG_EXTENDED|REG_ICASE)){
304 err(1,"regcomp");
305 }
306
307 filecount = argc;
308 while(*argv){
309 fflush(stdout);
310 if(opt_debug) fprintf(stderr,"%s:\n",*argv);
311 process(*argv);
312 argv++;
313 argc--;
314 }
315 exit(0);
316 }
0 /*
1 * afsign.cpp:
2 *
3 * Sign an existing AFF file.
4 */
5
6 /*
7 * Copyright (c) 2007
8 * Simson L. Garfinkel and Basis Technology, Inc.
9 * All rights reserved.
10 *
11 * This code is derrived from software contributed by
12 * Simson L. Garfinkel
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Simson L. Garfinkel
25 * and Basis Technology Corp.
26 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
27 * contributors to this program may be used to endorse or promote
28 * products derived from this software without specific prior written
29 * permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
32 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
33 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
36 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46 #include "affconfig.h"
47 #include "afflib.h"
48 #include "afflib_i.h"
49
50 #ifdef USE_AFFSIGS
51
52 #include "utils.h"
53 #include "base64.h"
54
55 #include <stdio.h>
56 #include <algorithm>
57 #include <vector>
58 #include <iostream>
59 #include <openssl/pem.h>
60 #include <openssl/x509.h>
61
62
63 #include "aff_bom.h"
64
65 int opt_note = 0;
66 const char *opt_sign_key_file = 0;
67 const char *opt_sign_cert_file = 0;
68
69 using namespace std;
70 using namespace aff;
71
72 const char *progname = "afsign";
73
74 void usage()
75 {
76 printf("%s version %s\n",progname,PACKAGE_VERSION);
77 printf("usage: %s [options] filename.aff\n",progname);
78 printf("This program will:\n");
79 printf(" * Sign each segment if there are no segment signatures.\n");
80 printf(" * Write signed chain-of-custody Bill of Materials segment.\n");
81 printf("\nSignature Options:\n");
82 printf(" -k filename.key = specify private key for signing\n");
83 printf(" -c filename.cer = specify a X.509 certificate that matches the private key\n");
84 printf(" (by default, the file is assumed to be the same one\n");
85 printf(" provided with the -k option.)\n");
86 printf(" -Z = ZAP (remove) all signature segments.\n");
87 printf("options:\n");
88 printf(" -n --- ask for a chain-of-custody note.\n");
89 printf(" -v --- Just print the version number and exit.\n");
90 exit(0);
91 }
92
93
94 int afsign(const char *fn)
95 {
96 AFFILE *af = af_open(fn,O_RDWR,0);
97 if(!af) af_err(1,"%s",fn);
98
99 struct af_vnode_info vni;
100 if(af_vstat(af,&vni)) err(1,"af_vstat");
101
102 if(vni.supports_metadata==0){
103 /* If it is a raw file, we can create an AFM file to sign */
104 if(vni.is_raw==0) errx(1,"%s: file does not support metadata. Cannot sign\n",fn);
105 af_close(af); // afm will open it
106 char afmfile[MAXPATHLEN+1];
107 char file000[MAXPATHLEN+1];
108 char extension[MAXPATHLEN+1];
109 strcpy(afmfile,fn);
110 char *period = strrchr(afmfile,'.');
111 if(!period) errx(1,"%s: file does not support metadata and lacks a file extension,\n"
112 "which is needed to create an AFM file '%s\n",afmfile,fn);
113 strcpy(extension,period+1); // get the extension
114
115 /* If the file being opened is not a .000 file, and a .000 file exists, do not proceed */
116 strcpy(period,".000");
117 strcpy(file000,afmfile); // make the 000 file
118 strcpy(period,".afm");
119
120 if(strcmp(extension,"000")!=0){
121 if(access(file000,F_OK)==0){
122 errx(1,"Can't create .afm file because %s exists.\n",file000);
123 }
124 }
125
126 strcpy(period,".afm"); // we are now going to make an afm file
127 af = af_open(afmfile,O_RDWR|O_CREAT,0600);
128 if(!af) af_err(1,"%s: file does not support metadata and cannot create AFM file '%s\n",fn,afmfile);
129 if(strcmp(extension,"000")!=0){
130 af_update_seg(af,AF_RAW_IMAGE_FILE_EXTENSION,0,(const u_char *)extension,strlen(extension));
131 af_close(af);
132 unlink(file000); // get rid of that .000 file
133 af = af_open(afmfile,O_RDWR,0600);
134 if(!af) af_err(1,"%s: Created AFM file but cannot re-open it\n",fn);
135 /* Read the first byte to force a call to afm_split_raw_setup().
136 * The results of the read don't matter, but we better be able to read.
137 */
138 u_char buf[1];
139 if(af_read(af,buf,1)!=1){
140 err(1,"Cannot read first byte of %s",fn);
141 }
142 af_seek(af,0L,0);
143 }
144 }
145
146 seglist segments(af);
147
148 if(isatty(fileno(stdout))){
149 printf("Signing segments...\n");
150 fflush(stdout);
151 }
152
153 bool signed_unsigned_segments = false;
154 if(segments.has_signed_segments()==false){
155 if(af_set_sign_files(af,opt_sign_key_file,opt_sign_cert_file)){
156 errx(1,"key file '%s' or certificate file '%s' is invalid",
157 opt_sign_key_file,opt_sign_cert_file);
158 }
159 int r = af_sign_all_unsigned_segments(af);
160 if(r<0) af_err(1,"%s: all unsigned segments cannot be signed.",fn);
161 if(r>0) signed_unsigned_segments = true;
162 }
163
164 aff_bom bom(opt_note);
165 if(bom.read_files(opt_sign_cert_file,opt_sign_key_file)) err(1,"Can't read signature files???");
166
167 u_char *pagebuf = (unsigned char *)calloc(af_page_size(af),1);
168 u_char *parity_buf = (unsigned char *)calloc(af_page_size(af),1);
169 bool compute_parity = true; // do we need to compute the parity?
170
171 /* Create the parity buffer if it doesn't exist. If the parity buffer exists, we'll just trust it.
172 * We could do a two-pass here, one for creating the parity buffer, another for creating the BOM.
173 * But that would require reading the data twice; hence this extra layer of complexity.
174 */
175 size_t parity_buf_len = af_page_size(af);
176 if(af_get_seg(af,AF_PARITY0,0,parity_buf,&parity_buf_len)==0){
177 compute_parity = false; // no need to compute it; we read it
178 }
179
180 for(seglist::const_iterator seg = segments.begin(); seg!= segments.end();seg++){
181 const char *segname = seg->name.c_str();
182
183 if(isatty(fileno(stdout))){
184 printf("\rCalculating BOM for segment %s... ",segname);
185 printf("\n");
186 fflush(stdout);
187 }
188
189 u_char seghash[32]; /* resultant message digest; could be any size */
190 unsigned int seghash_len = sizeof(seghash); /* big enough to hold SHA256 */
191 int sigmode = 0;
192 int64_t pagenumber = af_segname_page_number(segname);
193 if(pagenumber>=0){
194 /* Page segments must run in SIGNATURE_MODE1 - the actual data in the page */
195 size_t this_pagesize = af_page_size(af);
196 if(af_get_page(af,pagenumber,pagebuf,&this_pagesize)){
197 free(pagebuf);
198 return -1;
199 }
200 /* Add to parity buf if we are making a parity page*/
201 if(compute_parity){
202 for(u_int i=0;i<this_pagesize;i++){
203 parity_buf[i] ^= pagebuf[i];
204 }
205 }
206 aff_bom::make_hash(seghash,0,segname,pagebuf,this_pagesize);
207 sigmode = AF_SIGNATURE_MODE1;
208 }
209 else{
210 /* Non-Page segments can be run in SIGNATURE_MODE0 - the actual data in the file */
211 size_t seglen=0;
212 if(af_get_seg(af,segname,0,0,&seglen)){
213 err(1,"Cannot read length of segment '%s' on input file %s", segname,af_filename(af));
214 }
215 unsigned char *segbuf = (unsigned char *)malloc(seglen);
216 if(!segbuf){
217 err(1,"Cannot allocated %d bytes for segment '%s' in %s",
218 (int)seglen,segname,af_filename(af));
219 }
220 /* Now get the raw source segment */
221 unsigned long arg=0;
222 if(af_get_seg(af,segname,&arg,segbuf,&seglen)){
223 err(1,"Cannot read segment '%s' in %s. Deleteing output file", segname,af_filename(af));
224 }
225 aff_bom::make_hash(seghash,arg,segname,segbuf,seglen);
226 sigmode = AF_SIGNATURE_MODE0;
227 free(segbuf);
228 }
229 bom.add(segname,sigmode,seghash,seghash_len); // add to the BOM
230 }
231
232 /* If we have been making the parity buf:
233 * 1 - Write it out; add it to the BOM
234 * 2 - Write out the signature segment for the parity buf; add it to the bom
235 */
236 if(compute_parity){
237 if(af_update_seg(af,AF_PARITY0,0,parity_buf,af_page_size(af))) err(1,"Can't write %s",AF_PARITY0);
238
239 /* Add the parity page that we made to the BOM */
240 u_char seghash[32]; /* resultant message digest; could be any size */
241 unsigned int seghash_len = sizeof(seghash); /* big enough to hold SHA256 */
242
243 aff_bom::make_hash(seghash,0,AF_PARITY0,parity_buf,af_page_size(af));
244 bom.add(AF_PARITY0,AF_SIGNATURE_MODE0,seghash,seghash_len);
245
246
247 /* If we are signing segments for the first time, we need to sign the parity page
248 * and then add the parity page's signature segment to the BOM as well.
249 */
250 if(signed_unsigned_segments){
251 af_sign_seg(af,AF_PARITY0); // sign the parity segment if we signed the other segments
252 bom.add(af,AF_PARITY0_SIG);
253
254 u_char buf[1024];
255 size_t buflen = sizeof(buf);
256
257 const char *segname = AF_PARITY0_SIG;
258 if(af_get_seg(af,segname,0,buf,&buflen)==0){ // Get the signature
259 aff_bom::make_hash(seghash,0,segname,buf,buflen); // and add it to the BOM
260 bom.add(segname,AF_SIGNATURE_MODE0,seghash,seghash_len);
261 }
262 }
263 }
264
265 if(isatty(fileno(stdout))){
266 printf(" \r\n");
267 fflush(stdout);
268 }
269
270 bom.close();
271 bom.write(af,segments);
272 af_close(af);
273 return 0;
274 }
275
276 int remove_signatures(const char *fn)
277 {
278 AFFILE *af = af_open(fn,O_RDWR,0);
279 if(!af) af_err(1,"%s",fn);
280
281 aff::seglist sl(af);
282 for(aff::seglist::const_iterator i = sl.begin();
283 i!= sl.end();
284 i++){
285 if(af_is_signature_segment(i->name.c_str()) || i->name==AF_SIGN256_CERT){
286 cout << "Deleting " << i->name << "\n";
287 af_del_seg(af,i->name.c_str());
288 }
289 }
290 af_close(af);
291 return 0;
292 }
293
294 int main(int argc,char **argv)
295 {
296 int bflag, ch;
297 int opt_zap = 0;
298
299 bflag = 0;
300 while ((ch = getopt(argc, argv, "nk:c:h?vZ")) != -1) {
301 switch (ch) {
302 case 'n': opt_note = 1;break;
303 case 'k':
304 if(access(optarg,R_OK)) err(1,"%s",optarg);
305 opt_sign_key_file = optarg;
306 break;
307 case 'c':
308 if(access(optarg,R_OK)) err(1,"%s",optarg);
309 opt_sign_cert_file = optarg;
310 break;
311 case 'v':
312 printf("%s version %s\n",progname,PACKAGE_VERSION);
313 exit(0);
314 case 'Z':
315 opt_zap = 1;
316 break;
317 case 'h':
318 case '?':
319 default:
320 usage();
321 break;
322 }
323 }
324 argc -= optind;
325 argv += optind;
326
327 if(opt_sign_cert_file==0) opt_sign_cert_file=opt_sign_key_file; // if not set, make same as key file
328
329
330 if(argc!=1){
331 usage();
332 }
333
334 if(opt_zap) return remove_signatures(argv[0]);
335
336 /* We either need both a key file and a cert file, or neither */
337 if((opt_sign_key_file==0) || (opt_sign_cert_file==0)){
338 errx(1,"Both a private key and a certificate must be specified.");
339 }
340
341
342 return afsign(argv[0]);
343 }
344 #else
345 int main(int argc,char **argv)
346 {
347 fprintf(stderr,"afflib compiled without USE_AFFSIGS. afsign cannot run.\n");
348 exit(-1);
349 }
350
351 #endif
352
0 /*
1 * afstats.cpp:
2 *
3 * print specific statistics about one or more AFF files.
4 * Ideally, we can get the stats from the metadata, but this program will
5 * calculate it if necessary.
6 */
7
8 /*
9 * Copyright (c) 2005
10 * Simson L. Garfinkel and Basis Technology, Inc.
11 * All rights reserved.
12 *
13 * This code is derrived from software contributed by
14 * Simson L. Garfinkel
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by Simson L. Garfinkel
27 * and Basis Technology Corp.
28 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
29 * contributors to this program may be used to endorse or promote
30 * products derived from this software without specific prior written
31 * permission.
32 *
33 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
34 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
35 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
36 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
38 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
41 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
42 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
44 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 * SUCH DAMAGE.
46 */
47
48
49 #include "affconfig.h"
50 #include "afflib.h"
51 #include "afflib_i.h"
52
53 #include <openssl/md5.h>
54 #include <openssl/sha.h>
55 #include <zlib.h>
56 #include <assert.h>
57
58 #ifdef HAVE_ERR_H
59 #include <err.h>
60 #endif
61
62 #ifdef HAVE_UNISTD_H
63 #include <unistd.h>
64 #endif
65
66 #ifdef HAVE_UNISTD_H
67 #include <unistd.h>
68 #endif
69
70 #ifdef HAVE_TERM_H
71 #include <term.h>
72 #endif
73
74 #ifdef HAVE_NCURSES_TERM_H
75 #include <ncurses/term.h>
76 #endif
77
78 #ifdef HAVE_NCURSES_H
79 #include <ncurses.h>
80 #endif
81
82 #ifdef WIN32
83 #include "unix4win32.h"
84 #include <malloc.h>
85 #endif
86
87 const char *progname = "afstats";
88 int opt_m = 0;
89
90 void usage()
91 {
92 printf("%s version %s\n\n",progname,PACKAGE_VERSION);
93 printf("usage: %s [options] infile(s)\n",progname);
94 printf(" -m = print all output in megabytes\n");
95 printf(" -v = Just print the version number and exit.\n");
96 exit(0);
97 }
98
99
100 void title()
101 {
102 printf("fname\tbytes\tcompressed\n");
103 }
104
105 void print_size(uint64_t s)
106 {
107 if(opt_m){
108 printf("%u",(unsigned int)(s/(1024*1024)));
109 return;
110 }
111 printf("%"I64u,s);
112 }
113
114 void afstats_title()
115 {
116 printf("Name\tAF_IMAGESIZE\tCompressed\tUncompressed\tBlank\tBad\n");
117 }
118
119 void afstats(const char *fname)
120 {
121 AFFILE *af = af_open(fname,O_RDONLY,0);
122 if(!af) af_err(1,"af_open(%s)",fname);
123
124 printf("%s\t",fname);
125
126 long unsigned int segsize=0;
127
128 int64_t imagesize=0;
129 int64_t blanksectors=0;
130 int64_t badsectors=0;
131 af_get_segq(af,AF_IMAGESIZE,&imagesize);
132 if(af_get_seg(af,AF_PAGESIZE,&segsize,0,0)){
133 af_get_seg(af,AF_SEGSIZE_D,&segsize,0,0); // check for oldstype
134 }
135 af_get_segq(af,AF_BADSECTORS,&badsectors);
136 af_get_segq(af,AF_BLANKSECTORS,&blanksectors);
137
138 print_size(imagesize);
139 printf("\t");
140 fflush(stdout);
141
142 int64_t compressed_bytes = 0;
143 int64_t uncompressed_bytes = 0;
144
145 /* Now read through all of the segments and count the number of
146 * data segments. We know the uncompressed size...
147 */
148 af_rewind_seg(af);
149 char segname[AF_MAX_NAME_LEN+1];
150 size_t datalen;
151 while(af_get_next_seg(af,segname,sizeof(segname),0,0,&datalen)==0){
152 int64_t page_num = af_segname_page_number(segname);
153 if(page_num>=0){
154 compressed_bytes += datalen;
155 uncompressed_bytes += segsize;
156 }
157 }
158 if(uncompressed_bytes > imagesize) uncompressed_bytes = imagesize;
159
160 print_size(compressed_bytes);
161 printf("\t");
162 print_size(uncompressed_bytes);
163 printf(" %"I64d" %"I64d,blanksectors,badsectors);
164 putchar('\n');
165
166
167 }
168
169
170
171
172 int main(int argc,char **argv)
173 {
174 int ch;
175 while ((ch = getopt(argc, argv, "mh?V")) != -1) {
176 switch (ch) {
177 case 'm':
178 opt_m = 1;
179 break;
180 case 'h':
181 case '?':
182 default:
183 usage();
184 break;
185 case 'V':
186 printf("%s version %s\n",progname,PACKAGE_VERSION);
187 exit(0);
188 }
189 }
190 argc -= optind;
191 argv += optind;
192
193 if(argc<1){
194 usage();
195 }
196
197 /* Each argument is now a file. Process each one */
198 afstats_title();
199 while(*argv){
200 afstats(*argv++);
201 argc--;
202 }
203 exit(0);
204 }
205
206
0 /*
1 * afverify.cpp:
2 *
3 * Verify the digital signature on a signed file
4 */
5
6 /*
7 * Copyright (c) 2007
8 * Simson L. Garfinkel and Basis Technology, Inc.
9 * All rights reserved.
10 *
11 * This code is derrived from software contributed by
12 * Simson L. Garfinkel
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Simson L. Garfinkel
25 * and Basis Technology Corp.
26 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
27 * contributors to this program may be used to endorse or promote
28 * products derived from this software without specific prior written
29 * permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
32 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
33 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
36 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46 #include "affconfig.h"
47 #include "afflib.h"
48 #include "afflib_i.h"
49
50 #include "utils.h"
51 #include "base64.h"
52
53 #include "aff_bom.h"
54
55 #include <stdio.h>
56 #include <algorithm>
57 #include <vector>
58 #include <iostream>
59 #include <openssl/pem.h>
60 #include <openssl/x509.h>
61
62 using namespace std;
63 using namespace aff;
64
65 const char *progname = "afcrypto";
66 int opt_change = 0;
67 int opt_verbose = 0;
68 int opt_all = 0;
69
70 void usage()
71 {
72 printf("afverify version %s\n",PACKAGE_VERSION);
73 printf("usage: afverify [options] filename.aff\n");
74 printf("Verifies the digital signatures on a file\n");
75 printf("options:\n");
76 printf(" -a --- print all segments\n");
77 printf(" -V --- Just print the version number and exit.\n");
78 printf(" -v --- verbose\n");
79
80 OpenSSL_add_all_digests();
81 const EVP_MD *sha256 = EVP_get_digestbyname("sha256");
82 if(sha256){
83 printf(" SHA256 is operational\n");
84 } else {
85 printf("Warning: EVP_get_digestbyname(\"sha256\") fails\n");
86 }
87 exit(0);
88 }
89
90 void print_x509_info(X509 *cert)
91 {
92 printf("SIGNING CERTIFICATE :\n");
93 printf(" Subject: "); X509_NAME_print_ex_fp(stdout,X509_get_subject_name(cert),0,XN_FLAG_SEP_CPLUS_SPC);
94 printf("\n");
95 printf(" Issuer: "); X509_NAME_print_ex_fp(stdout,X509_get_issuer_name(cert),0,XN_FLAG_SEP_CPLUS_SPC);
96 printf("\n");
97 ASN1_INTEGER *sn = X509_get_serialNumber(cert);
98 if(sn){
99 long num = ASN1_INTEGER_get(sn);
100 if(num>0) printf(" Certificate serial number: %ld\n",num);
101 }
102 printf("\n");
103 }
104
105 #ifdef USE_AFFSIGS
106 #include "expat.h"
107 void startElement(void *userData, const char *name, const char **atts);
108 void endElement(void *userData, const char *name);
109 void cHandler(void *userData,const XML_Char *s,int len);
110
111 class segmenthash {
112 public:
113 segmenthash():total_validated(0),total_invalid(0),sigmode(0),in_cert(false),
114 in_seghash(false),get_cdata(false),arg(0),seglen(0),
115 get_cdata_segment(0),af(0),cert(0),pubkey(0) {
116
117 parser = XML_ParserCreate(NULL);
118 XML_SetUserData(parser, this);
119 XML_SetElementHandler(parser, ::startElement, ::endElement);
120 XML_SetCharacterDataHandler(parser,cHandler);
121 };
122 int parse(const char *buf,int len) { return XML_Parse(parser, buf, len, 1);}
123 XML_Parser parser;
124 int total_validated;
125 int total_invalid;
126 int sigmode;
127 bool in_cert;
128 bool in_seghash;
129 bool get_cdata;
130 string segname;
131 string alg;
132 string cdata;
133 int arg;
134 int seglen;
135 const char *get_cdata_segment; // just get this segment
136 AFFILE *af; // if set, we are parsing crypto
137 X509 *cert; // public key used to sign
138 EVP_PKEY *pubkey;
139 void clear(){
140 segname="";
141 cdata="";
142 sigmode=0;
143 alg="";
144 seglen=0;
145 }
146 ~segmenthash(){
147 if(cert) X509_free(cert);
148 if(parser) XML_ParserFree(parser);
149 }
150 void startElement(const char *name,const char **atts);
151 void endElement(const char *name);
152 };
153
154 int count=0;
155 void startElement(void *userData, const char *name, const char **atts)
156 {
157 segmenthash *sh = (segmenthash *)userData;
158 sh->startElement(name,atts);
159 }
160
161 void segmenthash::startElement(const char *name,const char **atts)
162 {
163 clear();
164 if(strcmp(name,AF_XML_SEGMENT_HASH)==0){
165 for(int i=0;atts[i];i+=2){
166 const char *name = atts[i];
167 const char *value = atts[i+1];
168 if(!strcmp(name,"segname")) segname = value;
169 if(!strcmp(name,"sigmode")) sigmode = atoi(value);
170 if(!strcmp(name,"alg")) alg = value;
171 if(!strcmp(name,"seglen")) seglen = atoi(value);
172 }
173 in_seghash = true;
174 get_cdata = true;
175 return;
176 }
177 if(strcmp(name,"signingcertificate")==0){
178 in_cert = true;
179 get_cdata = true;
180 return;
181 }
182 if(get_cdata_segment && strcmp(name,get_cdata_segment)==0){
183 get_cdata = true;
184 return;
185 }
186 }
187
188 void cHandler(void *userData,const XML_Char *s,int len)
189 {
190 segmenthash *sh = (segmenthash *)userData;
191 if(sh->get_cdata==false) return; // don't want cdata
192 sh->cdata.append(s,len);
193 }
194
195 void endElement(void *userData, const char *name)
196 {
197 segmenthash *sh = (segmenthash *)userData;
198 sh->endElement(name);
199 }
200
201
202 void segmenthash::endElement(const char *name)
203 {
204 if(get_cdata_segment && strcmp(name,get_cdata_segment)==0){
205 get_cdata = false;
206 XML_StopParser(parser,0);
207 return;
208 }
209 if(in_seghash && af){
210 if(segname.size()==0) return; // don't have a segment name
211 /* Try to validate this one */
212 size_t hashbuf_len = cdata.size() + 2;
213 u_char *hashbuf = (u_char *)malloc(hashbuf_len);
214 hashbuf_len = b64_pton_slg((char *)cdata.c_str(),cdata.size(),hashbuf,hashbuf_len);
215 if(alg=="sha256"){
216 /* TODO: Don't re-validate something that's already validated */
217 int r = af_hash_verify_seg2(af,segname.c_str(),hashbuf,hashbuf_len,sigmode);
218 if(r==AF_HASH_VERIFIES){
219 total_validated++;
220 }
221 else total_invalid++;
222 }
223 free(hashbuf);
224 in_seghash = false;
225 }
226 if(in_cert && af){
227 BIO *cert_bio = BIO_new_mem_buf((char *)cdata.c_str(),cdata.size());
228 PEM_read_bio_X509(cert_bio,&cert,0,0);
229 BIO_free(cert_bio);
230 pubkey = X509_get_pubkey(cert);
231 in_cert = false;
232 }
233 cdata = ""; // erase it
234 }
235
236 string get_xml_field(const char *buf,const char *field)
237 {
238 segmenthash sh;
239 sh.get_cdata_segment = field;
240 sh.parse(buf,strlen(buf));
241 return sh.cdata;
242 }
243
244 /* verify the chain signature; return 0 if successful, -1 if failed.
245 * The signature is a block of XML with a base64 encoded at the end.
246 */
247 int verify_bom_signature(AFFILE *af,const char *buf)
248 {
249 OpenSSL_add_all_digests();
250 const EVP_MD *sha256 = EVP_get_digestbyname("sha256");
251
252 if(!sha256){
253 fprintf(stderr,"OpenSSL does not have SHA256; signatures cannot be verified.\n");
254 return -1;
255 }
256
257 const char *cce = "</" AF_XML_AFFBOM ">\n";
258 const char *chain_end = strstr(buf,cce);
259 if(!chain_end){
260 warn("end of chain XML can't be found\n");
261 return -1; // can't find it
262 }
263 const char *sig_start = chain_end + strlen(cce);
264
265 BIO *seg = BIO_new_mem_buf((void *)buf,strlen(buf));
266 if(BIO_seek(seg,0)!=0){
267 printf("Cannot seek to beginning of BIO mem?");
268 return -1;
269 }
270 X509 *cert = 0;
271 PEM_read_bio_X509(seg,&cert,0,0); // get the contained x509 cert
272 BIO_free(seg);
273
274 /* Now get the binary signature */
275 u_char sigbuf[1024];
276 int sigbuf_len = b64_pton_slg(sig_start,strlen(sig_start),sigbuf,sizeof(sigbuf));
277 if(sigbuf_len<80){
278 warn("BOM is not signed");
279 return -1;
280 }
281
282 /* Try to verify it */
283 EVP_MD_CTX md;
284 EVP_VerifyInit(&md,sha256);
285 EVP_VerifyUpdate(&md,buf,sig_start-buf);
286 int r = EVP_VerifyFinal(&md,sigbuf,sigbuf_len,X509_get_pubkey(cert));
287 if(r!=1){
288 printf("BAD SIGNATURE ON BOM\n");
289 return -1;
290 }
291
292 print_x509_info(cert);
293 printf("Date: %s\n",get_xml_field(buf,"date").c_str());
294 printf("Notes: \n%s\n",get_xml_field(buf,"notes").c_str());
295
296 /* Now extract the XML block, terminating at the beginning of the XML signature */
297 char *buffer_without_signature = strdup(buf);
298 char *sigend = strstr(buffer_without_signature,cce);
299 if(sigend){
300 sigend[strlen(cce)] = 0;/* terminate the XML to remove the signature */
301 }
302
303 segmenthash sh;
304 sh.af = af;
305 if (!sh.parse(buffer_without_signature, strlen(buffer_without_signature))){
306 fprintf(stderr, "expat error: %s at line %d\n",
307 XML_ErrorString(XML_GetErrorCode(sh.parser)),
308 (int)XML_GetCurrentLineNumber(sh.parser));
309 fprintf(stderr,"buffer without signature:\n%s\n",buffer_without_signature);
310 return 1;
311 }
312 free(buffer_without_signature);
313 return 0;
314 }
315 #endif
316
317 int process(const char *fn)
318 {
319 AFFILE *af = af_open(fn,O_RDONLY,0666);
320 if(!af) af_err(1,fn);
321
322 /* Get the public key */
323 unsigned char certbuf[65536];
324 size_t certbuf_len = sizeof(certbuf);
325 if(af_get_seg(af,AF_SIGN256_CERT,0,certbuf,&certbuf_len)){
326 /* See if it is present, but encrypted */
327 if(af_get_seg(af,AF_SIGN256_CERT AF_AES256_SUFFIX,0,0,0)==0){
328 errx(1,"%s: signed file is encrypted; present decryption key to verify signature",fn);
329 }
330 errx(1,"%s: no signing certificate present. Cannot continue.",fn);
331 }
332
333 seglist segments(af);
334 seglist no_sigs;
335 seglist bad_sigs;
336 seglist good_sigs;
337 seglist unknown_errors;
338
339 for(seglist::const_iterator seg = segments.begin();
340 seg != segments.end();
341 seg++){
342
343 if(parse_chain(seg->name)>=0) continue; // chain of custody segments don't need signatures
344
345 const char *segname = seg->name.c_str();
346 int i =af_sig_verify_seg(af,segname);
347 if(opt_verbose){
348 printf("af_sig_verify_seg(af,%s)=%d\n",segname,i);
349 }
350 switch(i){
351 case AF_ERROR_SIG_NO_CERT:
352 err(1,"%s: no public key in AFF file\n",af_filename(af));
353 case AF_ERROR_SIG_BAD:
354 bad_sigs.push_back(*seg);
355 break;
356 case AF_ERROR_SIG_READ_ERROR:
357 no_sigs.push_back(*seg);
358 break;
359 case AF_SIG_GOOD:
360 good_sigs.push_back(*seg);
361 break;
362 case AF_ERROR_SIG_SIG_SEG:
363 break; // can't verify the sig on a sig seg
364 case AF_ERROR_SIG_NOT_COMPILED:
365 errx(1,"AFFLIB was compiled without signature support. Cannot continue.\n");
366 default:
367 unknown_errors.push_back(*seg);
368 break;
369 }
370 }
371 const char *prn = "";
372 /* Tell us something about the certificate */
373 BIO *cert_bio = BIO_new_mem_buf(certbuf,certbuf_len);
374 X509 *cert = 0;
375 PEM_read_bio_X509(cert_bio,&cert,0,0);
376 if(!cert) errx(1,"Cannot decode certificate");
377 printf("\n");
378 printf("Filename: %s\n",fn);
379 printf("# Segments signed and Verified: %d\n",(int)good_sigs.size());
380 printf("# Segments unsigned: %d\n",(int)no_sigs.size());
381 printf("# Segments with corrupted signatures: %d\n",(int)bad_sigs.size());
382 printf("\n");
383 print_x509_info(cert);
384
385 int compromised = 0;
386 for(seglist::const_iterator seg = good_sigs.begin(); seg != good_sigs.end() && opt_all;
387 seg++){
388 if(*seg==good_sigs.front()) printf("%sSegments with valid signatures:\n",prn);
389 printf("\t%s\n",seg->name.c_str());
390 prn = "\n";
391 }
392 for(seglist::const_iterator seg = no_sigs.begin();
393 seg != no_sigs.end();
394 seg++){
395 if(*seg==no_sigs.front()) printf("%sUnsigned segments:\n",prn);
396 printf("\t%s\n",seg->name.c_str());
397 prn = "\n";
398
399 /* Only unsigned data segments are a problem */
400 if(af_segname_page_number(seg->name.c_str())>=0){
401 compromised++;
402 }
403 }
404 for(seglist::const_iterator seg = bad_sigs.begin();
405 seg != bad_sigs.end();
406 seg++){
407 if(*seg==bad_sigs.front()) printf("%sBad signature segments:\n",prn);
408 printf("\t%s\n",seg->name.c_str());
409 prn = "\n";
410 compromised++;
411 }
412 for(seglist::const_iterator seg = unknown_errors.begin();
413 seg != unknown_errors.end();
414 seg++){
415 if(*seg==unknown_errors.front()) printf("%sUnknown error segments:\n",prn);
416 printf("\t%s\n",seg->name.c_str());
417 prn = "\n";
418 compromised++;
419 }
420
421 int highest = highest_chain(segments);
422 printf("\nNumber of custody chains: %d\n",highest+1);
423 for(int i=0;i<=highest;i++){
424 /* Now print each one */
425 printf("---------------------\n");
426 printf("Signed Bill of Material #%d:\n\n",i+1);
427
428 /* Get the segment and verify */
429 size_t chainbuf_len = 0;
430 char segname[AF_MAX_NAME_LEN];
431 snprintf(segname,sizeof(segname),AF_BOM_SEG,i);
432 if(af_get_seg(af,segname,0,0,&chainbuf_len)){
433 printf("*** BOM MISSING ***\n");
434 compromised++;
435 }
436 char *chainbuf = (char *)malloc(chainbuf_len+1);
437 if(af_get_seg(af,segname,0,(u_char *)chainbuf,&chainbuf_len)){
438 printf("*** CANNOT READ BOM ***\n");
439 compromised++;
440 }
441
442 chainbuf[chainbuf_len]=0; // terminate
443 #ifdef USE_AFFSIGS
444 if(verify_bom_signature(af,chainbuf)){
445 printf("*** BOM SIGNATURE INVALID ***\n");
446 compromised++;
447 }
448 #else
449 printf("BOM signature cannot be verified beause libxpat is not available.\n");
450 #endif
451 }
452 printf("---------------------\n");
453 af_close(af);
454 #ifdef USE_AFFSIGS
455 if(compromised){
456 printf("\nEVIDENCE FILE DOES NOT VERIFY.\n");
457 printf("ERRORS DETECTED: %d\n",compromised);
458 printf("EVIDENTUARY VALUE MAY BE COMPROMISED.\n");
459 return -1;
460 }
461 printf("\nEVIDENCE FILE VERIFIES.\n");
462 return 0;
463 #endif
464 printf("\n");
465 return -1;
466 }
467
468
469 int main(int argc,char **argv)
470 {
471 int bflag, ch;
472
473 bflag = 0;
474 while ((ch = getopt(argc, argv, "ach?vV")) != -1) {
475 switch (ch) {
476 case 'a': opt_all = 1; break;
477 case 'c': opt_change = 1; break;
478 case 'v': opt_verbose++; break;
479 case 'h':
480 case '?':
481 default:
482 usage();
483 break;
484 case 'V':
485 printf("%s version %s\n",progname,PACKAGE_VERSION);
486 exit(0);
487 }
488 }
489 argc -= optind;
490 argv += optind;
491
492 if(argc!=1){
493 usage();
494 }
495
496 OpenSSL_add_all_digests();
497 return process(argv[0]);
498 }
0 /*
1 * afxml.cpp:
2 *
3 * print AFF information as an XML
4 */
5
6 /*
7 * Copyright (c) 2005
8 * Simson L. Garfinkel and Basis Technology, Inc.
9 * All rights reserved.
10 *
11 * This code is derrived from software contributed by
12 * Simson L. Garfinkel
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Simson L. Garfinkel
25 * and Basis Technology Corp.
26 * 4. Neither the name of Simson Garfinkel, Basis Technology, or other
27 * contributors to this program may be used to endorse or promote
28 * products derived from this software without specific prior written
29 * permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY SIMSON GARFINKEL, BASIS TECHNOLOGY,
32 * AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
33 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
34 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 * DISCLAIMED. IN NO EVENT SHALL SIMSON GARFINKEL, BAIS TECHNOLOGy,
36 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
37 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
39 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
40 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
41 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
42 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 * SUCH DAMAGE.
44 */
45
46
47 #include "affconfig.h"
48 #include "afflib.h"
49 #include "afflib_i.h"
50 #include "base64.h"
51
52 #ifdef WIN32
53 #include "unix4win32.h"
54 #endif
55
56 #include <vector>
57 #include <string>
58
59 #ifdef HAVE_CSTRING
60 #include <cstring>
61 #endif
62
63 using namespace std;
64
65 #if HAVE_CTYPE_H
66 #include <ctype.h>
67 #endif
68
69 #if !defined(HAVE_ISALPHANUM) && defined(HAVE_ISALNUM)
70 #define isalphanum(c) isalnum(c)
71 #endif
72
73 #if !defined(HAVE_ISALPHANUM) && !defined(HAVE_ISALNUM)
74 #define isalphanum(c) (isalpha(c)||isdigit(c))
75 #endif
76
77 const char *progname = "afxml";
78
79 int opt_x = 0;
80 char **opt_j = 0;
81 int opt_j_count = 0;
82 int opt_stats = 0;
83
84 struct page_stat_block {
85 unsigned long long zsectors; // number of sectors that are all blank
86 unsigned long long badsectors; // number of bad sectors
87 unsigned long long zpages; // number of pages that are all blank
88 unsigned long long pages; // total number of pages
89 unsigned long long sectors; // total number of sectors
90 };
91
92
93 void usage()
94 {
95 printf("%s version %s\n",progname,PACKAGE_VERSION);
96 printf("usage: %s [options] infile... \n",progname);
97 printf(" -V = Just print the version number and exit\n");
98 printf(" -x = Don't include the infile filename in output.\n");
99 printf(" -j segname = Just print information about segname \n");
100 printf(" (may be repeated)\n");
101 printf(" -s = output 'stats' for the file data (may a long time)\n");
102 exit(0);
103 }
104
105
106
107 /* Return true if segname is in the optj list */
108 bool in_opt_j_list(char *segname)
109 {
110 for(int i=0;i<opt_j_count;i++){
111 if(strcmp(segname,opt_j[i])==0) return true;
112 }
113 return false;
114 }
115
116 /* It's okay to print if there are no funky characters in it...
117 * (avoids problems with invalid UTF-8
118 */
119 bool okay_to_print(const char *data,int datalen)
120 {
121 for(const char *cc=data;cc<data+datalen;cc++){
122 if (*cc <= 0) return false;
123 if (*cc == 10 || *cc==13) continue;
124 if (*cc<32) return false;
125 if (*cc>=127) return false;
126 }
127 return true;
128 }
129
130 bool is_blank(const u_char *buf,size_t len)
131 {
132 for(size_t i=0;i<len;i++){
133 if(buf[i]) return false;
134 }
135 return true;
136 }
137
138 void print_xml64(const char *name,int64_t val)
139 {
140 printf(" <%s coding='base10'>%"I64d"</%s>\n\n",name,val,name);
141 }
142
143 int xml_info(const char *infile)
144 {
145 AFFILE *af = af_open(infile,O_RDONLY,0);
146 if(!af){
147 warn("%s",infile);
148 return -1;
149 }
150
151 struct page_stat_block psb;
152 memset(&psb,0,sizeof(psb));
153
154 printf("<!-- XML generated by afxml version %s -->\n",PACKAGE_VERSION);
155 printf("<affinfo");
156 if(!opt_x) printf(" image_filename='%s'",infile);
157 printf(">\n");
158
159 af_rewind_seg(af); // start at the beginning
160
161 char segname[AF_MAX_NAME_LEN];
162 int pages = 0;
163 vector<string> seglist; // list of segments we will get
164 vector<int64_t> pagelist; // list of segments we will get
165
166 while(af_get_next_seg(af,segname,sizeof(segname),0,0,0)==0){
167 if(segname[0]==0) continue; // segment to ignore
168 if(strcmp(segname,AF_DIRECTORY)==0) continue; // don't output the directories
169 if(strstr(segname,AF_AES256_SUFFIX)) continue; // don't output encrypted segments that won't decrypt
170
171 /* check optj */
172 if(opt_j_count > 0 && in_opt_j_list(segname)==false){
173 continue;
174 }
175
176 int64_t page_num = af_segname_page_number(segname);
177 if(page_num>=0){
178 pages += 1;
179 pagelist.push_back(page_num);
180 }
181 else {
182 seglist.push_back(segname);
183 }
184 }
185
186 printf(" <pages coding='base10'>%d</pages>\n",pages); // tell how many pages we have
187
188 /* If we have been asked to create stats, create the states */
189 if(opt_stats){
190 unsigned char *data= (unsigned char *)malloc(af_page_size(af));
191 if(!data) err(1,"Can't allocate page with %d bytes.",af_page_size(af));
192 for(vector<int64_t>::const_iterator it = pagelist.begin(); it != pagelist.end(); it++){
193 size_t pagesize = af_page_size(af);
194 size_t sectorsize = af_get_sectorsize(af);
195 if(af_get_page(af,*it,data,&pagesize)){
196 err(1,"Can't read page %"PRId64,*it);
197 }
198 psb.pages++;
199 bool allblank = true;
200 for(const unsigned char *s = data; s < data+pagesize; s+=sectorsize){
201 psb.sectors ++;
202 if(is_blank(s,sectorsize)){
203 psb.zsectors++;
204 continue;
205 }
206 allblank = false;
207 if(af_is_badsector(af,s)){
208 psb.badsectors++;
209 continue;
210 }
211 }
212 if(allblank) psb.zpages++;
213 }
214 free(data);
215 printf(" <calculated>\n");
216 print_xml64("pages",psb.pages);
217 print_xml64("zpages",psb.zpages);
218 print_xml64("sectors",psb.sectors);
219 print_xml64("zsectors",psb.zsectors);
220 print_xml64("badsectors",psb.badsectors);
221 printf(" </calculated>\n");
222 }
223
224 /* Now that we have a list of segments, print them */
225 for(vector<string>::const_iterator it = seglist.begin();
226 it != seglist.end();
227 it++){
228
229 /* See how long the data is */
230 size_t datalen = 0;
231 unsigned long arg=0;
232
233 strcpy(segname,it->c_str());
234
235 if(af_get_seg(af,segname,&arg,0,&datalen)){
236 err(1,"Can't read info for segment '%s'",segname);
237 }
238
239 unsigned char *data= (unsigned char *)malloc(datalen);
240 if(data==0) err(1,"Can't allocate %zd bytes for data",datalen);
241 if(af_get_seg(af,segname,&arg,data,&datalen)!=0){
242 err(1,"Can't read data for segment '%s'",segname);
243 }
244
245 /* Change non-XML characters in segname to _ */
246 for(char *cc=segname;*cc;cc++){
247 if(!isalphanum(*cc)) *cc = '_';
248 }
249
250 if(datalen==8 && (arg & AF_SEG_QUADWORD || af_display_as_quad(segname))){
251 /* Print it as a 64-bit value.
252 * The strcmp is there because early AF_IMAGESIZE segs didn't set
253 * AF_SEG_QUADWORD...
254 */
255 printf(" <%s coding='base10'>%"I64d"</%s>\n",segname,af_decode_q(data),segname);
256 free(data);
257 continue;
258 }
259
260 /* If datalen==0, just print the arg as an unsigned number */
261 if(datalen==0){
262 printf(" <%s coding='base10'>%ld</%s>\n",segname,arg,segname);
263 free(data);
264 continue;
265 }
266
267 /* Just handle it as binhex ... */
268 printf(" <%s",segname);
269 if(datalen==0){
270 printf(" arg='%lu' />\n",arg);
271 free(data);
272 continue;
273 }
274
275 /* If segname ends 'md5', code in hex */
276 if(strlen(segname)>=3 && strcmp(segname+strlen(segname)-3,"md5")==0){
277 char hex_buf[40];
278 printf(" coding='base16'>%s</%s>\n",
279 af_hexbuf(hex_buf,sizeof(hex_buf),data,datalen,0),
280 segname);
281 free(data);
282 continue;
283 }
284
285 /* If all segment contents are printable ascii with no CRs, LFs, or brackets,
286 * just print as-is...
287 */
288 if(okay_to_print((const char *)data,datalen)){
289 putchar('>');
290 for(const char *cc=(const char *)data;cc<(const char *)data+datalen;cc++){
291 switch(*cc){
292 case '>': fputs("&lt;",stdout);break;
293 case '<': fputs("&gt;",stdout);break;
294 case '&': fputs("&amp;",stdout);break;
295 case '\'': fputs("&apos;",stdout);break;
296 case '"': fputs("&quot;",stdout);break;
297 default: putchar(*cc);
298 }
299 }
300 printf("</%s>\n",segname);
301 free(data);
302 continue;
303 }
304
305 /* Default coding: base64 */
306 int b64size = datalen*2+2;
307 char *b64buf = (char *)calloc(b64size,1);
308 int b64size_real = b64_ntop(data,datalen,b64buf,b64size);
309 data[b64size_real] = 0; // be sure it is null terminated
310
311 printf(" coding='base64'>");
312 fputs(b64buf,stdout);
313 printf("</%s>\n",segname);
314 free(b64buf);
315 free(data);
316 }
317 af_close(af);
318
319 printf("</affinfo>\n");
320 return 0;
321 }
322
323
324 int main(int argc,char **argv)
325 {
326 int bflag, ch;
327 const char *infile;
328
329 /* Figure out how many cols the screen has... */
330
331 bflag = 0;
332 while ((ch = getopt(argc, argv, "xj:h?Vs")) != -1) {
333 switch (ch) {
334 case 'j':
335 if(opt_j==0) opt_j = (char **)malloc(0);
336 opt_j_count++;
337 opt_j = (char **)realloc(opt_j,sizeof(char *)*opt_j_count);
338 opt_j[opt_j_count-1] = strdup(optarg); // make a copy
339 case 'x': opt_x++; break;
340 case 's': opt_stats++; break;
341 case 'h':
342 case '?':
343 default:
344 usage();
345 break;
346 case 'V':
347 printf("%s version %s\n",progname,PACKAGE_VERSION);
348 exit(0);
349 }
350 }
351 argc -= optind;
352 argv += optind;
353
354 if(argc<1){
355 usage();
356 }
357
358
359 /* Loop through all of the files */
360 printf("<?xml version='1.0' encoding='UTF-8'?>\n");
361 printf("<affobjects>\n");
362 while(*argv){
363 infile = *argv++; // get the file
364 argc--; // decrement argument counter
365 xml_info(infile);
366 }
367 printf("</affobjects>\n");
368 exit(0);
369 }
370
371
0 #ifndef HASHEXTENT_H
1 #define HASHEXTENT_H
2
3 /**
4 * hashextent: class to track a hash request or value
5 *
6 * Simson L. Garfinkel
7 * 2009-09-18: SLG - Added to repository
8 */
9
10 #include <vector>
11 #include <string>
12 #include <iostream>
13 #include <sstream>
14 #include <map>
15 #include <set>
16 #include <algorithm>
17
18
19 using std::string;
20 using std::ostream;
21 using std::vector;
22 using std::map;
23
24 class hashextent {
25 public:
26 hashextent():digest(0),digest_bits_(0){}
27 ~hashextent(){
28 if(digest) free(digest);
29 }
30 uint64_t start;
31 uint64_t bytes;
32 hashextent(uint64_t aStart,uint64_t aBytes):start(aStart),bytes(aBytes),digest(0){}
33 hashextent(AFFILE *af,string alg,uint64_t aStart,uint64_t aBytes):start(aStart),bytes(aBytes),digest(0){
34 compute_digest(af,alg);
35 }
36 static bool compare(const hashextent &e1,const hashextent &e2){
37 return e1.start < e2.start;
38 }
39
40 static int hexcharval(char hex){
41 if(hex>='0' && hex<='9') return hex-'0';
42 if(hex>='A' && hex<='F') return hex+10-'A';
43 if(hex>='a' && hex<='f') return hex+10-'a';
44 return 0;
45 }
46
47 static string bin2hex(unsigned char *md,int len){
48 std::stringstream sbuf;
49 while(len>0){
50 char buf[3];
51 snprintf(buf,sizeof(buf),"%02x",md[0]);
52 sbuf << buf;
53 md ++;
54 len --;
55 }
56 return sbuf.str();
57 }
58
59 static int hex2bin(unsigned char *binbuf,size_t hexbuf_size,const char *hex){
60 int bits = 0;
61 while(hex[0] && hex[1] && hexbuf_size>0){
62 *binbuf++ = ((hexcharval(hex[0])<<4) |
63 hexcharval(hex[1]));
64 hex += 2;
65 bits += 8;
66 hexbuf_size -= 1;
67 }
68 if(hexbuf_size>0) binbuf[0] = 0; // might as well null-terminate if there is room
69 return bits;
70 }
71
72
73 u_char *get_digest(){
74 if(!digest){
75 int bytes = hexdigest.size()/2;
76 digest = (u_char *)malloc(bytes);
77 digest_bits_ = hex2bin(digest,bytes,hexdigest.c_str());
78 }
79 return digest;
80 }
81 /* These parameters are for when the structure is read */
82 int digest_bits() {
83 if(!digest) get_digest();
84 return digest_bits_;
85 }
86 string digest_name;
87 string coding;
88 string hexdigest;
89
90 /** Compute the digest from the disk and set all the fields.
91 * Return 0 if success, -1 if failure.
92 */
93 int compute_digest(AFFILE *af,string digestToUse){
94 const EVP_MD *md = EVP_get_digestbyname(digestToUse.c_str());
95 EVP_MD_CTX ctx;
96 if(!md) return -1; // digest not available
97 EVP_DigestInit(&ctx,md);
98 if(af_seek(af,start,0)!=start) return -1; // can't seek
99
100 uint64_t bytes_read = 0;
101 while(bytes_read < this->bytes){
102 u_char buf[65536];
103 int to_read = (this->bytes-bytes_read) < sizeof(buf) ? (this->bytes-bytes_read) : sizeof(buf);
104 if(af_read(af,buf,to_read)!=to_read) return -1; // error reading
105 /* compute the hash */
106 EVP_DigestUpdate(&ctx,buf,to_read);
107 bytes_read += to_read;
108 }
109 /* Compute the results */
110 if(digest!=0) free(digest);
111 u_int digest_bytes = 1024;
112 digest = (u_char *)malloc(digest_bytes); // big enough for any conceivable digest
113 EVP_DigestFinal(&ctx,digest,&digest_bytes);
114 digest_bits_ = digest_bytes*8;
115 digest_name = digestToUse;
116 hexdigest = bin2hex(digest,digest_bits_/8);
117 return 0;
118 }
119 /** Return XML for the digest */
120 string toXML(){
121 std::stringstream sstart,sbytes;
122 sstart << start;
123 sbytes << bytes;
124 return string("<hash coding='base16' start='") + sstart.str() + "' bytes='" + sbytes.str() +
125 "' alg='"+digest_name+"'>"+hexdigest+"</hash>";
126 }
127 private:;
128 u_char *digest;
129 u_int digest_bits_;
130 };
131 ostream & operator << (ostream &os, const hashextent &he){
132 os << "[" << he.digest_name << " @ " << he.start << "(" << he.bytes << " bytes) " << he.hexdigest << "]";
133 return os;
134 }
135
136 bool operator == (const hashextent &h1,const hashextent &h2) {
137 return h1.start==h2.start && h1.bytes==h2.bytes && h1.hexdigest==h2.hexdigest;
138 }
139
140 class hashvector:public vector<hashextent> {
141 public:
142 static int ireverse(int a,int b){
143 return a<b ? 1 : -1;
144 }
145
146 /**
147 * return a list of digests, sorted by inverse bitlength,
148 * in the hashvector
149 */
150 vector<string> digests(){
151 vector<int> bits_vector;
152 std::set<int> bits_set; // why isn't find working on vector? set shouldn't be needed
153 map<int,string> bits_to_hash;
154 for(hashvector::iterator it = begin();it!=end();it++){
155 (*it).get_digest(); // parse the digest to determine length
156 int bits = (*it).digest_bits();
157 if(bits_set.find(bits)==bits_set.end()){
158 bits_set.insert(bits);
159 bits_vector.push_back(bits);
160 bits_to_hash[bits] = (*it).digest_name;
161 }
162 }
163 /* Now reverse sort it */
164 sort(bits_vector.begin(),bits_vector.end(),ireverse);
165 //sort(bits_vector.begin(),bits_vector.end());
166 //reverse(bits_vector.begin(),bits_vector.end());
167 /* Generate the result */
168 vector<string> ret;
169 for(vector<int>::const_iterator it = bits_vector.begin();it != bits_vector.end(); it++){
170 ret.push_back(bits_to_hash[*it]);
171 }
172 return ret;
173 }
174 /**
175 * Return the strongest digest in the hashvector that OpenSSL
176 * makes avilable on the runtime system.
177 */
178 const EVP_MD *strongest_available(){
179 vector<std::string> algs = digests();
180 for(vector<std::string>::const_iterator it = algs.begin(); it!=algs.end(); it++){
181 const EVP_MD *ret = EVP_get_digestbyname((*it).c_str());
182 if(ret) return ret;
183 }
184 return 0; // no digest available
185 }
186 };
187
188
189 #endif
0 #!/bin/sh
1 # Test the afsegment command
2
3 PATH=$PATH:../tools:../../tools:.:$srcdir
4 BLANK_BASE=`mktemp -t blankXXXXX`
5 BLANK_AFF=$BLANK_BASE.aff
6 unset AFFLIB_PASSPHRASE
7
8 echo === Putting a new metadata segment into blank.aff ===
9
10 /bin/rm -f $BLANK_AFF
11 afcopy /dev/null $BLANK_AFF
12 afsegment -ssegname=testseg1 $BLANK_AFF
13 if [ x"testseg1" = x`afsegment -p segname $BLANK_AFF` ] ; then
14 echo afsegment worked!
15 else
16 echo afsegment does not work properly
17 exit 1
18 fi
19 /bin/rm -f $BLANK_AFF
20
0 #!/bin/sh
1 #
2 # test to make sure that the encrypted aff that is distributed with
3 # the AFFLIB can be decrypted using a known passphrase.
4 #
5
6 unset AFFLIB_PASSPHRASE
7 PATH=$PATH:../tools:../../tools:.:$srcdir
8
9 BASE=`mktemp -t encryptedXXXXXX`
10 ENCRYPTED_AFF=$BASE.aff
11 ENCRYPTED_ISO=$BASE.iso
12
13 openssl base64 -d > $ENCRYPTED_AFF <<EOF
14 QUZGMTANCgBBRkYAAAAABwAAAgAAAAAAYmFkZmxhZ0JBRCBTRUNUT1IAQwRKkA4whVoweN599xo5
15 vqbYfLdYMdk2LnCdr+RCsR2fpKER5NHqWK0HjZ2aWm1pLSrV+FVyjO6iZRmD/oQ2EeME+gfZChM6
16 6HYobG44YeW5aExzF53XWQ8CcLMfCl2C70sefisTUJXm+ldEyaUp2anrFMYb1TMDe6SpZKE4fG0J
17 qrUVRk3TpvsfX5x1bExUGPbxmeRC66ueFP3e0N1v6hL61HWnYJ02EbhvGtuISNA3xMTWVLfjKrE2
18 9NdpKKBqdL6V9PTR+g6lIN/XKeV+dKixP3DFULiCLoLIF9spIn0FVQvWTHaAbCVVWzEVBlLK/5u6
19 wh3qevx03yYeKGJnGWHTLAJYrzXBe1rcjK0KWphN9vF37/+o8bNFyUm7/o5iqif+bLGU4sFdrRcx
20 R/7uGFkx6fa5ZqjUWgNyom0w8UnuXBUtKJAd/EPPcN+/+/cAkOR+ci46bOswwI1kL7yMn6sJnZA0
21 nBGgLnmRVCYhbwHCoY5XzJp6DUmfEQP++dXdKfSXcKMsi9sqa43rH/bXz4lCUh+l+BqiR8hps3i1
22 37Ir0wpI9Emye4sqIq6hLdzXreWMeO0d1ag+RwU9L9byjEPfBGiH5lFkqBzD+AUvtOeUWPmducwe
23 CThvm7jU1NYKgQ7lplX1XhOb/qCVx8/our86b+LsQVRUAAAAAh9BRkYAAAAACgAAAAgAAAACYmFk
24 c2VjdG9ycwAAAAAAAAAAQVRUAAAAACpBRkYAAAAADgAAAAkAAAAAYWZmbGliX3ZlcnNpb24iMy4w
25 LjBhNiJBVFQAAAAAL0FGRgAAAAANAAAAAwAAAABhZmZfZmlsZV90eXBlQUZGQVRUAAAAAChBRkYA
26 AAAADQAAADgAAAAAYWZma2V5X2FlczI1NgAAAAEoymitfh6PClmv5NuhF2G9CogbB4AlMBwMIK92
27 u2zaLlLpWPiaWURRi/h3ptg0u6AAAAAAQVRUAAAAAF1BRkYAAAAADwAAAAABAAAAcGFnZXNpemUv
28 YWVzMjU2QVRUAAAAACdBRkYAAAAADAAAACAAAAAAcGFnZTAvYWVzMjU2JY1RIwMyLqCQDSS3t1gC
29 uydwNotCzenReTJdzn7fdMlBVFQAAAAARA==
30 EOF
31
32 openssl base64 -d > $ENCRYPTED_ISO <<EOF
33 QUZGIGRlY3J5cHRpb24gYXBwZWFycyB0byB3b3JrLgo=
34 EOF
35
36 # file://:password@/$ENCRYPTED_AFF
37 echo afcompare $ENCRYPTED_ISO $ENCRYPTED_ISO
38 if ! afcompare $ENCRYPTED_ISO $ENCRYPTED_ISO ; then
39 echo $ENCRYPTED_ISO does not decrypt properly.
40 exit 1
41 fi
42 /bin/rm -f $ENCRYPTED_ISO $ENCRYPTED_AFF
43 exit 0
0 #!/bin/sh
1 #
2 # Make a random ISO, used by all of the test programs
3 # Make sure that it is more than 3 pages in length (at least 48MB)
4
5 unset AFFLIB_PASSPHRASE
6
7 if [ x"" = x$1 ] ;
8 then echo usage: $0 filename
9 exit 1
10 fi
11
12 echo Making the random ISO $1
13 /bin/rm -f $1
14 touch $1
15 dd if=/dev/urandom of=$1 bs=65536 count=24 2>/dev/null
16 dd if=/dev/zero bs=16777216 count=2 >> $1 2>/dev/null
17 for i in 1 2 3 4 5 6 7 8 9 0 ; do \
18 for fn in /usr/share/dict/* ; do \
19 cat $fn >> $1 ;
20 done ; \
21 done
22 ls -l $1
23 openssl md5 $1
24 exit 0
25
0 #!/bin/sh
1 #
2 # test the passphrase tools
3
4 PATH=$PATH:../tools:../../tools:.:$srcdir
5
6 echo === MAKING THE TEST FILES ==
7 unset AFFLIB_PASSPHRASE
8
9 BLANK_BASE=`mktemp -t blankXXXXX`
10 BLANK_AFF=$BLANK_BASE.aff
11 BLANK_ISO=$BLANK_BASE.iso
12 BLANK_ENCRYPTED_AFF=${BLANK_BASE}_encrypted.aff
13 WORDS=`mktemp -t wordsXXXX`
14
15 rm -f $BLANK_ISO $BLANK_AFF $BLANK_ENCRYPTED_AFF $WORDS
16 test_make_random_iso.sh $BLANK_ISO || (echo Cannot run test_make_random_iso.sh && exit -1)
17
18 if [ ! -r $BLANK_ISO ]; then
19 echo CANNOT CREATE $BLANK_ISO
20 echo Permission error prevents test from continuing.
21 exit 0
22 fi
23
24 afconvert -o $BLANK_AFF $BLANK_ISO
25 afconvert -o file://:passphrase@/$BLANK_ENCRYPTED_AFF $BLANK_ISO
26
27 if [ ! -r $BLANK_ENCRYPTED_AFF ]; then
28 echo CANNOT CREATE $BLANK_ENCRYPTED_AFF
29 echo Permission error prevents test from continuing.
30 exit 0
31 fi
32
33
34 # Make sure afcrypto reports properly for with and with no encrypted segments
35 if (afcrypto $BLANK_AFF | grep " 0 encrypted" > /dev/null ) ; then
36 echo $BLANK_ENCRYPTED_AFF properly created
37 else
38 echo ENCRYPTED SEGMENTS IN $BLANK_ENCRYPTED_AFF --- STOP
39 exit 1
40 fi
41
42 # Now test afcrypto
43 echo Encrypted segment count: `afcrypto -j $BLANK_ENCRYPTED_AFF`
44 if [ `afcrypto -j $BLANK_ENCRYPTED_AFF` = "0" ]; then
45 echo NO ENCRYPTED SEGMENTS IN $BLANK_ENCRYPTED_AFF --- STOP
46 exit 1
47 else
48 echo $BLANK_ENCRYPTED_AFF properly created
49 fi
50
51 echo "sleepy" > $WORDS
52 echo "dopey" >> $WORDS
53 echo "doc" >> $WORDS
54 echo "passphrase" >> $WORDS
55 echo "foobar" >> $WORDS
56 if [ "`afcrypto -k -f $WORDS $BLANK_ENCRYPTED_AFF|grep correct|grep passphrase`"x = x ] ; then
57 echo afcrypto did not find the right passphrase
58 exit 1
59 else
60 echo afcrypto found the correct pasphrase
61 fi
62
63 rm $BLANK_ISO $BLANK_AFF $BLANK_ENCRYPTED_AFF $WORDS
64
65 echo ALL TESTS PASS
66 exit 0
0 #!/bin/sh
1 #
2 # test the signing tools
3 #
4
5 PATH=$PATH:../tools:../../tools:.:$srcdir
6
7 RECOVERY_BASE=`mktemp -t recoveryXXXX`
8 RECOVERY_KEY=$RECOVERY_BASE.key
9 RECOVERY_BAK=$RECOVERY_BASE.bak
10 RECOVERY_ISO=$RECOVERY_BASE.iso
11 RECOVERY_AFM=$RECOVERY_BASE.afm
12 RECOVERY_PEM=$RECOVERY_BASE.pem
13
14 /bin/rm -f $RECOVERY_KEY $RECOVERY_BAK $RECOVERY_ISO $RECOVERY_AFM
15
16 unset AFFLIB_PASSPHRASE
17
18 test_make_random_iso.sh $RECOVERY_ISO
19
20 echo ==== AFRECOVERY TEST ===
21 echo Make an X509 key
22
23 SUBJECT="/CN=Mr. Recovery/emailAddress=recovery@investiations.com"
24 openssl req -x509 -newkey rsa:1024 -keyout $RECOVERY_PEM -out $RECOVERY_PEM -nodes -subj "$SUBJECT"
25
26
27 if [ ! -r $RECOVERY_ISO ]; then
28 echo $RECOVERY_ISO was not created.
29 printenv
30 echo current directory: `pwd`
31 exit 0
32 fi
33
34
35 cp $RECOVERY_ISO $RECOVERY_BAK
36 echo ===========
37 echo Step 1: SIGNING $RECOVERY_ISO
38 if ! afsign -k $RECOVERY_PEM $RECOVERY_ISO ; then exit 1 ; fi
39 ls -l $RECOVERY_ISO $RECOVERY_AFM
40 echo ===========
41 echo Step 2: VERIFYING SIGNATURE
42 if ! afverify $RECOVERY_AFM ; then exit 1 ; fi
43 echo ===========
44 echo Step 3: CORRUPTING FILE recovery.iso
45 dd if=/dev/random of=$RECOVERY_ISO count=1 skip=1 conv=notrunc
46 echo ===========
47 echo Step 4: ATTEMPTING RECOVERY
48 if ! afrecover $RECOVERY_AFM ; then exit 1 ; fi
49 echo ==========
50 echo Step 5: MAKING SURE THAT THE MD5 HAS NOT CHANGED
51 if ! cmp $RECOVERY_BAK $RECOVERY_ISO ; then echo file changed ; exit 1 ; fi
52 echo MD5 has not changed
53 echo ==========
54 echo Step 6: See if Digital Signature is still good
55 if ! afverify $RECOVERY_AFM ; then echo signature no longer good ; exit 1 ; fi
56 echo Signature still good
57 echo ALL TESTS PASS
58 /bin/rm -f $RECOVERY_KEY $RECOVERY_BAK $RECOVERY_ISO $RECOVERY_AFM $RECOVERY_PEM
0 #!/bin/sh
1 #
2 # test the signing tools
3
4 unset AFFLIB_PASSPHRASE
5
6 BASE=`mktemp -t baseXXXXX`
7 AGENT_PEM=$BASE.agent.pem
8 ANALYST_PEM=$BASE.analyst.pem
9 ARCHIVES_PEM=$BASE.archives.pem
10 EVIDENCE=$BASE.evidence.aff
11 EVIDENCE2=$BASE.evidence2.aff
12 EVIDENCE3=$BASE.evidence3.aff
13
14 /bin/rm -f $AGENT_PEM $ANALYST_PEM $ARCHIVES_PEM $EVIDENCE $EVIDENCE2 $EVIDENCE3
15
16 echo === MAKING THE TEST FILES ===
17
18 PATH=$PATH:../tools:../../tools:.:$srcdir
19 test_make_random_iso.sh rawevidence.iso
20
21
22 echo ==== AFSIGN TEST ===
23 echo Making X.509 keys
24
25 openssl req -x509 -newkey rsa:1024 -keyout $AGENT_PEM -out $AGENT_PEM -nodes -subj "/C=US/ST=California/L=Remote/O=Country Govt./OU=Sherif Dept/CN=Mr. Agent/emailAddress=agent@investiations.com"
26
27 openssl req -x509 -newkey rsa:1024 -keyout $ANALYST_PEM -out $ANALYST_PEM -nodes -subj "/C=US/ST=California/L=Remote/O=State Police/OU=Forensics/CN=Ms. Analyst/emailAddress=analyst@investiations.com"
28 openssl req -x509 -newkey rsa:1024 -keyout $ARCHIVES_PEM -out $ARCHIVES_PEM -nodes -subj "/C=US/ST=CA/L=Remote/O=Archives/OU=Electronic/CN=Dr. Librarian/emailAddress=drbits@investiations.com"
29
30 echo Making an AFF file to sign
31 rm -f $EVIDENCE evidence?.aff
32 afconvert -o $EVIDENCE rawevidence.iso
33 echo Initial AFF file
34 if ! afinfo -a $EVIDENCE ; then exit 1 ; fi
35
36 echo Signing AFF file...
37 echo afsign -k $AGENT_PEM $EVIDENCE
38 if ! afsign -k $AGENT_PEM $EVIDENCE ; then echo afsign failed ; exit 1 ; fi
39
40 echo Verifying Signature...
41 echo afverify $EVIDENCE
42 if ! afverify $EVIDENCE ; then echo afverify failed ; exit 1 ; fi ;
43
44 echo Signature test 1 passed
45
46 echo Testing chain-of-custody signatures
47 echo Copying original raw file to evidence1.aff
48
49 if ! afcopy -z -k $AGENT_PEM rawevidence.iso evidence1.aff ; then exit 1; fi
50 if ! afinfo -a evidence1.aff ; then exit 1 ; fi
51 if ! afcompare rawevidence.iso evidence1.aff ; then exit 1 ; fi
52 if ! afverify evidence1.aff ; then exit 1 ; fi
53
54 echo
55 echo Making the second generation copy
56 echo "This copy was made by the analyst" | afcopy -z -k $ANALYST_PEM -n evidence1.aff $EVIDENCE2
57 if ! afinfo -a $EVIDENCE2 ; then exit 1 ; fi
58 if ! afcompare rawevidence.iso $EVIDENCE2 ; then exit 1 ; fi
59 if ! afverify $EVIDENCE2 ; then exit 1 ; fi
60 echo
61 echo Making the third generation copy
62 echo "This copy was made by the archives" | afcopy -z -k $ARCHIVES_PEM -n $EVIDENCE2 $EVIDENCE3
63 if ! afinfo -a $EVIDENCE3 ; then exit 1 ; fi
64 if ! afcompare rawevidence.iso $EVIDENCE3 ; then exit 1 ; fi
65 if ! afverify $EVIDENCE3 ; then exit 1 ; fi
66
67
68 echo All tests passed successfully
69 echo Erasing temporary files.
70 rm -f $AGENT_PEM $ARCHIVES_PEM $ANALYST_PEM $EVIDENCE evidence.afm rawevidence.iso cevidence.iso $EVIDENCE2 $EVIDENCE3 $EVIDENCE
71 exit 0
72
0 #ifdef WIN32
1 #include "getopt.h" // will pull from win32 directory
2 #include <malloc.h>
3 #include <windows.h>
4 #include <io.h>
5 #ifndef F_OK
6 #define F_OK 00
7 #endif
8
9 #ifndef R_OK
10 #define R_OK 04
11 #endif
12
13 #ifndef S_IFBLK
14 #define S_IFBLK -1 // will never be used
15 #endif
16
17 #ifndef PATH_MAX
18 #define PATH_MAX MAXPATHLEN
19 #endif
20 #endif
21
22