Reading the manual page (for ar) is a good start:
c
Create the archive. The specified archive is always created if it
did not exist, when you request an update. But a warning is issued
unless you specify in advance that you expect to create it, by
using this modifier.
r
Insert the files member... into archive (with replacement). This
operation differs from q in that any previously existing members
are deleted if their names match those being added.
s
Write an object-file index into the archive, or update an existing
one, even if no other change is made to the archive. You may use
this modifier flag either with any operation, or alone. Running "ar s
" on an archive is equivalent to running ranlib on it.
Comparing with POSIX, you may notice one difference: GNU ar makes the "-" prefixing options optional in itself.
An archive can contain other items than object-files (though this is not done often). Archives containing object-files require additional maintenance (e.g., done by ranlib
) to make them usable by the linker.
According to the Rationale in POSIX ar, the -s
option originated in BSD (System V did this automatically). However, running ranlib
by itself is the prevailing practice (-s
is rarely used). Interestingly enough, POSIX does not have ranlib
, and ultimately the -s
option will replace ranlib
in the multitude of makefiles which were written to run on a variety of platforms.