2 # Wrapper for Microsoft lib.exe
5 scriptversion=2012-01-04.17; # UTC
7 # Copyright (C) 2010, 2012 Free Software Foundation, Inc.
8 # Written by Peter Rosin <peda@lysator.liu.se>.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2, or (at your option)
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
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.
28 # This file is maintained in Automake, please report
29 # bugs to <bug-automake@gnu.org> or send patches to
30 # <automake-patches@gnu.org>.
42 # func_file_conv build_file
43 # Convert a $build file to $host form and store it in $file
44 # Currently only supports Windows hosts.
49 / | /[!/]*) # absolute file, and not a UNC file
50 if test -z "$file_conv"; then
51 # lazily determine how to convert abs files
66 file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
69 file=`cygpath -m "$file" || echo "$file"`
72 file=`winepath -w "$file" || echo "$file"`
79 # func_at_file at_file operation archive
80 # Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
82 # When interpreting the content of the @FILE, do NOT use func_file_conv,
83 # since the user would need to supply preconverted file names to
84 # binutils ar, at least for MinGW.
89 at_file_contents=`cat "$1"`
90 eval set x "$at_file_contents"
95 $AR -NOLOGO $operation:"$member" "$archive" || exit $?
101 func_error "no command. Try '$0 --help' for more information."
105 Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
107 Members may be specified in a file named with @FILE.
112 echo "$me, version $scriptversion"
117 if test $# -lt 3; then
118 func_error "you must specify a program, an action and an archive"
125 if test $# -lt 2; then
126 func_error "you must specify a program, an action and an archive"
131 | -machine* | -MACHINE* \
132 | -subsystem* | -SUBSYSTEM* \
133 | -verbose | -VERBOSE \
147 func_file_conv "$orig_archive"
150 # strip leading dash in $action
159 while test -n "$action"
167 u*) ;; # TODO: don't ignore the update modifier
169 func_error "unknown action specified"
175 case $delete$extract$list$replace in
179 func_error "more than one action specified"
182 func_error "no action specified"
186 if test -n "$delete"; then
187 if test ! -f "$orig_archive"; then
188 func_error "archive not found"
194 func_at_file "${1#@}" -REMOVE "$archive"
198 $AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
203 elif test -n "$extract"; then
204 if test ! -f "$orig_archive"; then
205 func_error "archive not found"
207 if test $# -gt 0; then
212 func_at_file "${1#@}" -EXTRACT "$archive"
216 $AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
221 $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
223 $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
227 elif test -n "$replace"; then
228 if test ! -f "$orig_archive"; then
229 if test -z "$create"; then
230 echo "$me: creating $orig_archive"
234 orig_archive=$archive
241 func_file_conv "${1#@}"
253 if test -n "$orig_archive"; then
254 $AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
256 $AR -NOLOGO -OUT:"$archive" "$@" || exit $?
259 elif test -n "$list"; then
260 if test ! -f "$orig_archive"; then
261 func_error "archive not found"
263 $AR -NOLOGO -LIST "$archive" || exit $?