]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - usr.bin/ar/ar.1
MFC r216717:
[FreeBSD/stable/8.git] / usr.bin / ar / ar.1
1 .\" Copyright (c) 2007 Joseph Koshy.  All rights reserved.
2 .\"
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions
5 .\" are met:
6 .\" 1. Redistributions of source code must retain the above copyright
7 .\"    notice, this list of conditions and the following disclaimer.
8 .\" 2. Redistributions in binary form must reproduce the above copyright
9 .\"    notice, this list of conditions and the following disclaimer in the
10 .\"    documentation and/or other materials provided with the distribution.
11 .\"
12 .\" This software is provided by Joseph Koshy ``as is'' and
13 .\" any express or implied warranties, including, but not limited to, the
14 .\" implied warranties of merchantability and fitness for a particular purpose
15 .\" are disclaimed.  in no event shall Joseph Koshy be liable
16 .\" for any direct, indirect, incidental, special, exemplary, or consequential
17 .\" damages (including, but not limited to, procurement of substitute goods
18 .\" or services; loss of use, data, or profits; or business interruption)
19 .\" however caused and on any theory of liability, whether in contract, strict
20 .\" liability, or tort (including negligence or otherwise) arising in any way
21 .\" out of the use of this software, even if advised of the possibility of
22 .\" such damage.
23 .\"
24 .\" $FreeBSD$
25 .\"
26 .Dd May 17, 2010
27 .Dt AR 1
28 .Os
29 .Sh NAME
30 .Nm ar ,
31 .Nm ranlib
32 .Nd manage archives
33 .Sh SYNOPSIS
34 .Nm
35 .Fl d
36 .Op Fl T
37 .Op Fl f
38 .Op Fl j
39 .Op Fl v
40 .Op Fl z
41 .Ar archive
42 .Ar
43 .Nm
44 .Fl m
45 .Op Fl T
46 .Op Fl a Ar position-after
47 .Op Fl b Ar position-before
48 .Op Fl f
49 .Op Fl i Ar position-before
50 .Op Fl j
51 .Op Fl s | Fl S
52 .Op Fl z
53 .Ar archive
54 .Ar
55 .Nm
56 .Fl p
57 .Op Fl T
58 .Op Fl f
59 .Op Fl v
60 .Ar archive
61 .Op Ar
62 .Nm
63 .Fl q
64 .Op Fl T
65 .Op Fl c
66 .Op Fl D
67 .Op Fl f
68 .Op Fl s | Fl S
69 .Op Fl v
70 .Op Fl z
71 .Ar archive
72 .Ar
73 .Nm
74 .Fl r
75 .Op Fl T
76 .Op Fl a Ar position-after
77 .Op Fl b Ar position-before
78 .Op Fl c
79 .Op Fl D
80 .Op Fl f
81 .Op Fl i Ar position-before
82 .Op Fl j
83 .Op Fl s | Fl S
84 .Op Fl u
85 .Op Fl v
86 .Op Fl z
87 .Ar archive
88 .Ar
89 .Nm
90 .Fl s
91 .Op Fl j
92 .Op Fl z
93 .Ar archive
94 .Nm
95 .Fl t
96 .Op Fl f
97 .Op Fl T
98 .Op Fl v
99 .Ar archive
100 .Op Ar
101 .Nm
102 .Fl x
103 .Op Fl C
104 .Op Fl T
105 .Op Fl f
106 .Op Fl o
107 .Op Fl u
108 .Op Fl v
109 .Ar archive
110 .Op Ar
111 .Nm
112 .Fl M
113 .Nm ranlib
114 .Op Fl D
115 .Ar archive ...
116 .Sh DESCRIPTION
117 The
118 .Nm
119 utility creates and maintains groups of files combined into an
120 archive.
121 Once an archive has been created, new files can be added to it, and
122 existing files can be extracted, deleted or replaced.
123 .Pp
124 Files are named in the archive by their last file name component,
125 so if a file referenced by a path containing a
126 .Dq /
127 is archived, it will be named by the last component of the path.
128 Similarly when matching paths listed on the command line against
129 file names stored in the archive, only the last component of the
130 path will be compared.
131 .Pp
132 The normal use of
133 .Nm
134 is for the creation and maintenance of libraries suitable for use
135 with the link editor
136 .Xr ld 1 ,
137 although it is not restricted to this purpose.
138 The
139 .Nm
140 utility can create and manage an archive symbol table (see
141 .Xr ar 5 )
142 used to speed up link editing operations.
143 If a symbol table is present in an archive, it will be
144 kept up-to-date by subsequent operations on the archive.
145 .Pp
146 The
147 .Nm ranlib
148 utility is used to add an archive symbol table
149 to an existing archive.
150 .Sh OPTIONS
151 The
152 .Nm
153 utility supports the following options:
154 .Bl -tag -width indent
155 .It Fl a Ar member-after
156 When used with option
157 .Fl m
158 this option specifies that the archive members specified by
159 arguments
160 .Ar
161 are moved to after the archive member named by argument
162 .Ar member-after .
163 When used with option
164 .Fl r
165 this option specifies that the files specified by arguments
166 .Ar
167 are added after the archive member named by argument
168 .Ar member-after .
169 .It Fl b Ar member-before
170 When used with option
171 .Fl m
172 this option specifies that the archive members specified by
173 arguments
174 .Ar
175 are moved to before the archive member named by argument
176 .Ar member-before .
177 When used with option
178 .Fl r
179 this option specifies that the files specified by arguments
180 .Ar
181 are added before the archive member named by argument
182 .Ar member-before .
183 .It Fl c
184 Suppress the informational message printed when a new archive is
185 created using the
186 .Fl r
187 and
188 .Fl q
189 options.
190 .It Fl C
191 Prevent extracted files from replacing like-named files
192 in the file system.
193 .It Fl d
194 Delete the members named by arguments
195 .Ar
196 from the archive specified by argument
197 .Ar archive .
198 The archive's symbol table, if present, is updated to reflect
199 the new contents of the archive.
200 .It Fl D
201 When used in combination with the 
202 .Fl r
203 or
204 .Fl q
205 option, insert 0's instead of the real mtime, uid and gid values 
206 and 0644 instead of file mode from the members named by arguments
207 .Ar .
208 This ensures that checksums on the resulting archives are reproducible
209 when member contents are identical.
210 .It Fl f
211 Synonymous with option
212 .Fl T .
213 .It Fl i Ar member-before
214 Synonymous with option
215 .Fl b .
216 .It Fl j
217 This option is accepted but ignored.
218 .It Fl l
219 This option is accepted for compatibility with GNU
220 .Xr ar 1 ,
221 but is ignored.
222 .It Fl m
223 Move archive members specified by arguments
224 .Ar
225 within the archive.
226 If a position has been specified by one of the
227 .Fl a ,
228 .Fl b
229 or
230 .Fl i
231 options, the members are moved to before or after the specified
232 position.
233 If no position has been specified, the specified members are moved
234 to the end of the archive.
235 If the archive has a symbol table, it is updated to reflect the
236 new contents of the archive.
237 .It Fl M
238 Read and execute MRI librarian commands from standard input.
239 .It Fl o
240 Preserve the original modification times of members when extracting
241 them.
242 .It Fl p
243 Write the contents of the specified archive members named by
244 arguments
245 .Ar
246 to standard output.
247 If no members were specified, the contents of all the files in the
248 archive are written in the order they appear in the archive.
249 .It Fl q
250 Append the files specified by arguments
251 .Ar
252 to the archive specified by argument
253 .Ar archive
254 without checking if the files already exist in the archive.
255 The archive symbol table will be updated as needed.
256 If the file specified by the argument
257 .Ar archive
258 does not already exist, a new archive will be created.
259 .It Fl r
260 Replace (add) the files specified by arguments
261 .Ar
262 in the archive specified by argument
263 .Ar archive ,
264 creating the archive if necessary.
265 Replacing existing members will not change the order of members within
266 the archive.
267 If a file named in arguments
268 .Ar
269 does not exist, existing members in the archive that match that
270 name are not changed.
271 New files are added to the end of the archive unless one of the
272 positioning options
273 .Fl a ,
274 .Fl b
275 or
276 .Fl i
277 is specified.
278 The archive symbol table, if it exists, is updated to reflect the
279 new state of the archive.
280 .It Fl s
281 Add an archive symbol table (see
282 .Xr ar 5 )
283 to the archive specified by argument
284 .Ar archive .
285 Invoking
286 .Nm
287 with the
288 .Fl s
289 option alone is equivalent to invoking
290 .Nm ranlib .
291 .It Fl S
292 Do not generate an archive symbol table.
293 .It Fl t
294 List the files specified by arguments
295 .Ar
296 in the order in which they appear in the archive, one per line.
297 If no files are specified, all files in the archive are listed.
298 .It Fl T
299 Use only the first fifteen characters of the archive member name or
300 command line file name argument when naming archive members.
301 .It Fl u
302 Conditionally update the archive or extract members.
303 When used with the
304 .Fl r
305 option, files named by arguments
306 .Ar
307 will be replaced in the archive if they are newer than their
308 archived versions.
309 When used with the
310 .Fl x
311 option, the members specified by arguments
312 .Ar
313 will be extracted only if they are newer than the corresponding
314 files in the file system.
315 .It Fl v
316 Provide verbose output.
317 When used with the
318 .Fl d ,
319 .Fl m ,
320 .Fl q
321 or
322 .Fl x
323 options,
324 .Nm
325 gives a file-by-file description of the archive modification being
326 performed, which consists of three white-space separated fields:
327 the option letter, a dash
328 .Dq "-" ,
329 and the file name.
330 When used with the
331 .Fl r
332 option,
333 .Nm
334 displays the description as above, but the initial letter is an
335 .Dq a
336 if the file is added to the archive, or an
337 .Dq r
338 if the file replaces a file already in the archive.
339 When used with the
340 .Fl p
341 option, the name of the file enclosed in
342 .Dq <
343 and
344 .Dq >
345 characters is written to standard output preceded by a single newline
346 character and followed by two newline characters.
347 The contents of the named file follow the file name.
348 When used with the
349 .Fl t
350 option,
351 .Nm
352 displays eight whitespace separated fields:
353 the file permissions as displayed by
354 .Xr strmode 3 ,
355 decimal user and group IDs separated by a slash (
356 .Dq / Ns ) ,
357 the file size in bytes, the file modification time in
358 .Xr strftime 3
359 format
360 .Dq "%b %e %H:%M %Y" ,
361 and the name of the file.
362 .It Fl V
363 Print a version string and exit.
364 .It Fl x
365 Extract archive members specified by arguments
366 .Ar
367 into the current directory.
368 If no members have been specified, extract all members of the archive.
369 If the file corresponding to an extracted member does not exist it
370 will be created.
371 If the file corresponding to an extracted member does exist, its owner
372 and group will not be changed while its contents will be overwritten
373 and its permissions will set to that entered in the archive.
374 The file's access and modification time would be that of the time
375 of extraction unless the
376 .Fl o
377 option was specified.
378 .It Fl z
379 This option is accepted but ignored.
380 .El
381 .Sh EXAMPLES
382 To create a new archive
383 .Pa ex.a
384 containing three files
385 .Pa ex1.o ,
386 .Pa ex2.o
387 and
388 .Pa ex3.o ,
389 use:
390 .Dl "ar -rc ex.a ex1.o ex2.o ex3.o"
391 .Pp
392 To add an archive symbol table to an existing archive
393 .Pa ex.a ,
394 use:
395 .Dl "ar -s ex.a"
396 .Pp
397 To delete file
398 .Pa ex1.o
399 from archive
400 .Pa ex.a ,
401 use:
402 .D1 "ar -d ex.a ex1.o"
403 .Pp
404 To verbosely list the contents of archive
405 .Pa ex.a ,
406 use:
407 .D1 "ar -tv ex.a"
408 .Sh DIAGNOSTICS
409 .Ex -std
410 .Sh SEE ALSO
411 .Xr ld 1 ,
412 .Xr archive 3 ,
413 .Xr elf 3 ,
414 .Xr strftime 3 ,
415 .Xr strmode 3 ,
416 .Xr ar 5
417 .Sh STANDARDS COMPLIANCE
418 The
419 .Nm
420 utility's support for the
421 .Fl a ,
422 .Fl b ,
423 .Fl c ,
424 .Fl i ,
425 .Fl m ,
426 .Fl p ,
427 .Fl q ,
428 .Fl r ,
429 .Fl s ,
430 .Fl t ,
431 .Fl u ,
432 .Fl v ,
433 .Fl C
434 and
435 .Fl T
436 options is believed to be compliant with
437 .St -p1003.2 .
438 .Sh HISTORY
439 An
440 .Nm
441 command first appeared in AT&T UNIX Version 1.
442 In
443 .Fx 8.0 ,
444 .An "Kai Wang" Aq kaiw@FreeBSD.org
445 reimplemented
446 .Nm
447 and
448 .Nm ranlib
449 using the
450 .Lb libarchive
451 and the
452 .Lb libelf .