Blame build-aux/ar-lib

rpm-build 0a0c83
#! /bin/sh
rpm-build 0a0c83
# Wrapper for Microsoft lib.exe
rpm-build 0a0c83
rpm-build 0a0c83
me=ar-lib
rpm-build 0a0c83
scriptversion=2012-03-01.08; # UTC
rpm-build 0a0c83
rpm-build 0a0c83
# Copyright (C) 2010-2017 Free Software Foundation, Inc.
rpm-build 0a0c83
# Written by Peter Rosin <peda@lysator.liu.se>.
rpm-build 0a0c83
#
rpm-build 0a0c83
# This program is free software; you can redistribute it and/or modify
rpm-build 0a0c83
# it under the terms of the GNU General Public License as published by
rpm-build 0a0c83
# the Free Software Foundation; either version 2, or (at your option)
rpm-build 0a0c83
# any later version.
rpm-build 0a0c83
#
rpm-build 0a0c83
# This program is distributed in the hope that it will be useful,
rpm-build 0a0c83
# but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build 0a0c83
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
rpm-build 0a0c83
# GNU General Public License for more details.
rpm-build 0a0c83
#
rpm-build 0a0c83
# You should have received a copy of the GNU General Public License
rpm-build 0a0c83
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
rpm-build 0a0c83
rpm-build 0a0c83
# As a special exception to the GNU General Public License, if you
rpm-build 0a0c83
# distribute this file as part of a program that contains a
rpm-build 0a0c83
# configuration script generated by Autoconf, you may include it under
rpm-build 0a0c83
# the same distribution terms that you use for the rest of that program.
rpm-build 0a0c83
rpm-build 0a0c83
# This file is maintained in Automake, please report
rpm-build 0a0c83
# bugs to <bug-automake@gnu.org> or send patches to
rpm-build 0a0c83
# <automake-patches@gnu.org>.
rpm-build 0a0c83
rpm-build 0a0c83
rpm-build 0a0c83
# func_error message
rpm-build 0a0c83
func_error ()
rpm-build 0a0c83
{
rpm-build 0a0c83
  echo "$me: $1" 1>&2
rpm-build 0a0c83
  exit 1
rpm-build 0a0c83
}
rpm-build 0a0c83
rpm-build 0a0c83
file_conv=
rpm-build 0a0c83
rpm-build 0a0c83
# func_file_conv build_file
rpm-build 0a0c83
# Convert a $build file to $host form and store it in $file
rpm-build 0a0c83
# Currently only supports Windows hosts.
rpm-build 0a0c83
func_file_conv ()
rpm-build 0a0c83
{
rpm-build 0a0c83
  file=$1
rpm-build 0a0c83
  case $file in
rpm-build 0a0c83
    / | /[!/]*) # absolute file, and not a UNC file
rpm-build 0a0c83
      if test -z "$file_conv"; then
rpm-build 0a0c83
	# lazily determine how to convert abs files
rpm-build 0a0c83
	case `uname -s` in
rpm-build 0a0c83
	  MINGW*)
rpm-build 0a0c83
	    file_conv=mingw
rpm-build 0a0c83
	    ;;
rpm-build 0a0c83
	  CYGWIN*)
rpm-build 0a0c83
	    file_conv=cygwin
rpm-build 0a0c83
	    ;;
rpm-build 0a0c83
	  *)
rpm-build 0a0c83
	    file_conv=wine
rpm-build 0a0c83
	    ;;
rpm-build 0a0c83
	esac
rpm-build 0a0c83
      fi
rpm-build 0a0c83
      case $file_conv in
rpm-build 0a0c83
	mingw)
rpm-build 0a0c83
	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
rpm-build 0a0c83
	  ;;
rpm-build 0a0c83
	cygwin)
rpm-build 0a0c83
	  file=`cygpath -m "$file" || echo "$file"`
rpm-build 0a0c83
	  ;;
rpm-build 0a0c83
	wine)
rpm-build 0a0c83
	  file=`winepath -w "$file" || echo "$file"`
rpm-build 0a0c83
	  ;;
rpm-build 0a0c83
      esac
rpm-build 0a0c83
      ;;
rpm-build 0a0c83
  esac
rpm-build 0a0c83
}
rpm-build 0a0c83
rpm-build 0a0c83
# func_at_file at_file operation archive
rpm-build 0a0c83
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
rpm-build 0a0c83
# for each of them.
rpm-build 0a0c83
# When interpreting the content of the @FILE, do NOT use func_file_conv,
rpm-build 0a0c83
# since the user would need to supply preconverted file names to
rpm-build 0a0c83
# binutils ar, at least for MinGW.
rpm-build 0a0c83
func_at_file ()
rpm-build 0a0c83
{
rpm-build 0a0c83
  operation=$2
rpm-build 0a0c83
  archive=$3
rpm-build 0a0c83
  at_file_contents=`cat "$1"`
rpm-build 0a0c83
  eval set x "$at_file_contents"
rpm-build 0a0c83
  shift
rpm-build 0a0c83
rpm-build 0a0c83
  for member
rpm-build 0a0c83
  do
rpm-build 0a0c83
    $AR -NOLOGO $operation:"$member" "$archive" || exit $?
rpm-build 0a0c83
  done
rpm-build 0a0c83
}
rpm-build 0a0c83
rpm-build 0a0c83
case $1 in
rpm-build 0a0c83
  '')
rpm-build 0a0c83
     func_error "no command.  Try '$0 --help' for more information."
rpm-build 0a0c83
     ;;
rpm-build 0a0c83
  -h | --h*)
rpm-build 0a0c83
    cat <
rpm-build 0a0c83
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
rpm-build 0a0c83
rpm-build 0a0c83
Members may be specified in a file named with @FILE.
rpm-build 0a0c83
EOF
rpm-build 0a0c83
    exit $?
rpm-build 0a0c83
    ;;
rpm-build 0a0c83
  -v | --v*)
rpm-build 0a0c83
    echo "$me, version $scriptversion"
rpm-build 0a0c83
    exit $?
rpm-build 0a0c83
    ;;
rpm-build 0a0c83
esac
rpm-build 0a0c83
rpm-build 0a0c83
if test $# -lt 3; then
rpm-build 0a0c83
  func_error "you must specify a program, an action and an archive"
rpm-build 0a0c83
fi
rpm-build 0a0c83
rpm-build 0a0c83
AR=$1
rpm-build 0a0c83
shift
rpm-build 0a0c83
while :
rpm-build 0a0c83
do
rpm-build 0a0c83
  if test $# -lt 2; then
rpm-build 0a0c83
    func_error "you must specify a program, an action and an archive"
rpm-build 0a0c83
  fi
rpm-build 0a0c83
  case $1 in
rpm-build 0a0c83
    -lib | -LIB \
rpm-build 0a0c83
    | -ltcg | -LTCG \
rpm-build 0a0c83
    | -machine* | -MACHINE* \
rpm-build 0a0c83
    | -subsystem* | -SUBSYSTEM* \
rpm-build 0a0c83
    | -verbose | -VERBOSE \
rpm-build 0a0c83
    | -wx* | -WX* )
rpm-build 0a0c83
      AR="$AR $1"
rpm-build 0a0c83
      shift
rpm-build 0a0c83
      ;;
rpm-build 0a0c83
    *)
rpm-build 0a0c83
      action=$1
rpm-build 0a0c83
      shift
rpm-build 0a0c83
      break
rpm-build 0a0c83
      ;;
rpm-build 0a0c83
  esac
rpm-build 0a0c83
done
rpm-build 0a0c83
orig_archive=$1
rpm-build 0a0c83
shift
rpm-build 0a0c83
func_file_conv "$orig_archive"
rpm-build 0a0c83
archive=$file
rpm-build 0a0c83
rpm-build 0a0c83
# strip leading dash in $action
rpm-build 0a0c83
action=${action#-}
rpm-build 0a0c83
rpm-build 0a0c83
delete=
rpm-build 0a0c83
extract=
rpm-build 0a0c83
list=
rpm-build 0a0c83
quick=
rpm-build 0a0c83
replace=
rpm-build 0a0c83
index=
rpm-build 0a0c83
create=
rpm-build 0a0c83
rpm-build 0a0c83
while test -n "$action"
rpm-build 0a0c83
do
rpm-build 0a0c83
  case $action in
rpm-build 0a0c83
    d*) delete=yes  ;;
rpm-build 0a0c83
    x*) extract=yes ;;
rpm-build 0a0c83
    t*) list=yes    ;;
rpm-build 0a0c83
    q*) quick=yes   ;;
rpm-build 0a0c83
    r*) replace=yes ;;
rpm-build 0a0c83
    s*) index=yes   ;;
rpm-build 0a0c83
    S*)             ;; # the index is always updated implicitly
rpm-build 0a0c83
    c*) create=yes  ;;
rpm-build 0a0c83
    u*)             ;; # TODO: don't ignore the update modifier
rpm-build 0a0c83
    v*)             ;; # TODO: don't ignore the verbose modifier
rpm-build 0a0c83
    *)
rpm-build 0a0c83
      func_error "unknown action specified"
rpm-build 0a0c83
      ;;
rpm-build 0a0c83
  esac
rpm-build 0a0c83
  action=${action#?}
rpm-build 0a0c83
done
rpm-build 0a0c83
rpm-build 0a0c83
case $delete$extract$list$quick$replace,$index in
rpm-build 0a0c83
  yes,* | ,yes)
rpm-build 0a0c83
    ;;
rpm-build 0a0c83
  yesyes*)
rpm-build 0a0c83
    func_error "more than one action specified"
rpm-build 0a0c83
    ;;
rpm-build 0a0c83
  *)
rpm-build 0a0c83
    func_error "no action specified"
rpm-build 0a0c83
    ;;
rpm-build 0a0c83
esac
rpm-build 0a0c83
rpm-build 0a0c83
if test -n "$delete"; then
rpm-build 0a0c83
  if test ! -f "$orig_archive"; then
rpm-build 0a0c83
    func_error "archive not found"
rpm-build 0a0c83
  fi
rpm-build 0a0c83
  for member
rpm-build 0a0c83
  do
rpm-build 0a0c83
    case $1 in
rpm-build 0a0c83
      @*)
rpm-build 0a0c83
        func_at_file "${1#@}" -REMOVE "$archive"
rpm-build 0a0c83
        ;;
rpm-build 0a0c83
      *)
rpm-build 0a0c83
        func_file_conv "$1"
rpm-build 0a0c83
        $AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
rpm-build 0a0c83
        ;;
rpm-build 0a0c83
    esac
rpm-build 0a0c83
  done
rpm-build 0a0c83
rpm-build 0a0c83
elif test -n "$extract"; then
rpm-build 0a0c83
  if test ! -f "$orig_archive"; then
rpm-build 0a0c83
    func_error "archive not found"
rpm-build 0a0c83
  fi
rpm-build 0a0c83
  if test $# -gt 0; then
rpm-build 0a0c83
    for member
rpm-build 0a0c83
    do
rpm-build 0a0c83
      case $1 in
rpm-build 0a0c83
        @*)
rpm-build 0a0c83
          func_at_file "${1#@}" -EXTRACT "$archive"
rpm-build 0a0c83
          ;;
rpm-build 0a0c83
        *)
rpm-build 0a0c83
          func_file_conv "$1"
rpm-build 0a0c83
          $AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
rpm-build 0a0c83
          ;;
rpm-build 0a0c83
      esac
rpm-build 0a0c83
    done
rpm-build 0a0c83
  else
rpm-build 0a0c83
    $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
rpm-build 0a0c83
    do
rpm-build 0a0c83
      $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
rpm-build 0a0c83
    done
rpm-build 0a0c83
  fi
rpm-build 0a0c83
rpm-build 0a0c83
elif test -n "$quick$replace"; then
rpm-build 0a0c83
  if test ! -f "$orig_archive"; then
rpm-build 0a0c83
    if test -z "$create"; then
rpm-build 0a0c83
      echo "$me: creating $orig_archive"
rpm-build 0a0c83
    fi
rpm-build 0a0c83
    orig_archive=
rpm-build 0a0c83
  else
rpm-build 0a0c83
    orig_archive=$archive
rpm-build 0a0c83
  fi
rpm-build 0a0c83
rpm-build 0a0c83
  for member
rpm-build 0a0c83
  do
rpm-build 0a0c83
    case $1 in
rpm-build 0a0c83
    @*)
rpm-build 0a0c83
      func_file_conv "${1#@}"
rpm-build 0a0c83
      set x "$@" "@$file"
rpm-build 0a0c83
      ;;
rpm-build 0a0c83
    *)
rpm-build 0a0c83
      func_file_conv "$1"
rpm-build 0a0c83
      set x "$@" "$file"
rpm-build 0a0c83
      ;;
rpm-build 0a0c83
    esac
rpm-build 0a0c83
    shift
rpm-build 0a0c83
    shift
rpm-build 0a0c83
  done
rpm-build 0a0c83
rpm-build 0a0c83
  if test -n "$orig_archive"; then
rpm-build 0a0c83
    $AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
rpm-build 0a0c83
  else
rpm-build 0a0c83
    $AR -NOLOGO -OUT:"$archive" "$@" || exit $?
rpm-build 0a0c83
  fi
rpm-build 0a0c83
rpm-build 0a0c83
elif test -n "$list"; then
rpm-build 0a0c83
  if test ! -f "$orig_archive"; then
rpm-build 0a0c83
    func_error "archive not found"
rpm-build 0a0c83
  fi
rpm-build 0a0c83
  $AR -NOLOGO -LIST "$archive" || exit $?
rpm-build 0a0c83
fi