2010-12-08 Arnaud Lacombe <lacombar@gmail.com>
+ * ar.c (long_options): Add target.
+ (decode_options): Handle the --target option.
+ (open_inarch): Check for plugin's target, default to --target
+ (replace_members): Use generic `target'.
+
* ar.c (operation): New global variable.
(show_version): Likewise.
(show_help): Likewise.
static const char *plugin_target = NULL;
+static const char *target = NULL;
+
#define OPTION_PLUGIN 201
+#define OPTION_TARGET 202
static struct option long_options[] =
{
{"help", no_argument, &show_help, 1},
{"plugin", required_argument, NULL, OPTION_PLUGIN},
+ {"target", required_argument, NULL, OPTION_TARGET},
{"version", no_argument, &show_version, 1},
{NULL, no_argument, NULL, 0}
};
xexit (1);
#endif
break;
+ case OPTION_TARGET:
+ target = optarg;
+ break;
case 0: /* A long option that just sets a flag. */
break;
default:
bfd *
open_inarch (const char *archive_filename, const char *file)
{
- const char *target;
bfd **last_one;
bfd *next_one;
struct stat sbuf;
bfd_set_error (bfd_error_no_error);
- target = plugin_target;
+ if (target == NULL)
+ target = plugin_target;
if (stat (archive_filename, &sbuf) != 0)
{
after_bfd = get_pos_bfd (&arch->archive_next, pos_after,
current->filename);
if (ar_emul_replace (after_bfd, *files_to_move,
- plugin_target, verbose))
+ target, verbose))
{
/* Snip out this entry from the chain. */
*current_ptr = (*current_ptr)->archive_next;
/* Add to the end of the archive. */
after_bfd = get_pos_bfd (&arch->archive_next, pos_end, NULL);
- if (ar_emul_append (after_bfd, *files_to_move, plugin_target,
+ if (ar_emul_append (after_bfd, *files_to_move, target,
verbose, make_thin_archive))
changed = TRUE;