2 # Wrapper for Microsoft lib.exe
5 scriptversion=2010-09-02.19; # UTC
7 # Copyright (C) 2010 Free Software
9 # Written by Peter Rosin <peda@lysator.liu.se>.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2, or (at your option)
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # As a special exception to the GNU General Public License, if you
25 # distribute this file as part of a program that contains a
26 # configuration script generated by Autoconf, you may include it under
27 # the same distribution terms that you use for the rest of that program.
29 # This file is maintained in Automake, please report
30 # bugs to <bug-automake@gnu.org> or send patches to
31 # <automake-patches@gnu.org>.
43 # func_file_conv build_file
44 # Convert a $build file to $host form and store it in $file
45 # Currently only supports Win32 hosts.
50 / | /[!/]*) # absolute file, and not a UNC file
51 if test -z "$file_conv"; then
52 # lazily determine how to convert abs files
67 file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
70 file=`cygpath -m "$file" || echo "$file"`
73 file=`winepath -w "$file" || echo "$file"`
80 # func_at_file at_file operation archive
81 # Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
83 # When interpreting the content of the @FILE, do NOT use func_file_conv,
84 # since the user would need to supply preconverted file names to
85 # binutils ar, at least for MinGW.
90 at_file_contents=`cat "$1"`
91 eval set x "$at_file_contents"
96 $AR -NOLOGO $operation:"$member" "$archive" || exit $?
102 func_error "no command. Try \`$0 --help' for more information."
106 Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
108 Members may be specified in a file named with @FILE.
113 echo "$me, version $scriptversion"
118 if test $# -lt 3; then
119 func_error "you must specify a program, an action and an archive"
126 if test $# -lt 2; then
127 func_error "you must specify a program, an action and an archive"
132 | -machine* | -MACHINE* \
133 | -subsystem* | -SUBSYSTEM* \
134 | -verbose | -VERBOSE \
148 func_file_conv "$orig_archive"
151 # strip leading dash in $action
160 while test -n "$action"
168 u*) ;; # TODO: don't ignore the update modifier
170 func_error "unknown action specified"
176 case $delete$extract$list$replace in
180 func_error "more than one action specified"
183 func_error "no action specified"
187 if test -n "$delete"; then
188 if test ! -f "$orig_archive"; then
189 func_error "archive not found"
195 func_at_file "${1#@}" -REMOVE "$archive"
199 $AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
204 elif test -n "$extract"; then
205 if test ! -f "$orig_archive"; then
206 func_error "archive not found"
208 if test $# -gt 0; then
213 func_at_file "${1#@}" -EXTRACT "$archive"
217 $AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
222 $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
224 $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
228 elif test -n "$replace"; then
229 if test ! -f "$orig_archive"; then
230 if test -z "$create"; then
231 echo "$me: creating $orig_archive"
235 orig_archive=$archive
242 func_file_conv "${1#@}"
254 if test -n "$orig_archive"; then
255 $AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
257 $AR -NOLOGO -OUT:"$archive" "$@" || exit $?
260 elif test -n "$list"; then
261 if test ! -f "$orig_archive"; then
262 func_error "archive not found"
264 $AR -NOLOGO -LIST "$archive" || exit $?