/build/m4/shave/shave-libtool.in
Autoconf | 109 lines | 61 code | 12 blank | 36 comment | 5 complexity | cea230cdabd8e5e356bab16645357a29 MD5 | raw file
1#!/bin/sh 2# 3# Copyright (c) 2009, Damien Lespiau <damien.lespiau@gmail.com> 4# 5# Permission is hereby granted, free of charge, to any person 6# obtaining a copy of this software and associated documentation 7# files (the "Software"), to deal in the Software without 8# restriction, including without limitation the rights to use, 9# copy, modify, merge, publish, distribute, sublicense, and/or sell 10# copies of the Software, and to permit persons to whom the 11# Software is furnished to do so, subject to the following 12# conditions: 13# 14# The above copyright notice and this permission notice shall be 15# included in all copies or substantial portions of the Software. 16# 17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 19# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 21# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 22# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24# OTHER DEALINGS IN THE SOFTWARE. 25 26# we need sed 27SED=@SED@ 28if test -z "$SED" ; then 29SED=sed 30fi 31 32lt_unmangle () 33{ 34 last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'` 35} 36 37# the real libtool to use 38LIBTOOL="$1" 39shift 40 41# if 1, don't print anything, the underlaying wrapper will do it 42pass_though=0 43 44# scan the arguments, keep the right ones for libtool, and discover the mode 45preserved_args= 46 47# have we seen the --tag option of libtool in the command line ? 48tag_seen=0 49 50while test "$#" -gt 0; do 51 opt="$1" 52 shift 53 54 case $opt in 55 --mode=*) 56 mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'` 57 preserved_args="$preserved_args $opt" 58 ;; 59 -o) 60 lt_output="$1" 61 preserved_args="$preserved_args $opt" 62 ;; 63 --tag=*) 64 tag_seen=1 65 preserved_args="$preserved_args $opt" 66 ;; 67 *) 68 preserved_args="$preserved_args $opt" 69 ;; 70 esac 71done 72 73case "$mode" in 74compile) 75 # shave will be called and print the actual CC/CXX/LINK line 76 preserved_args="$preserved_args --shave-mode=$mode" 77 pass_though=1 78 ;; 79link) 80 preserved_args="$preserved_args --shave-mode=$mode" 81 Q=" LINK " 82 ;; 83*) 84 # let's u 85 # echo "*** libtool: Unimplemented mode: $mode, fill a bug report" 86 ;; 87esac 88 89lt_unmangle "$lt_output" 90output=$last_result 91 92# automake does not add a --tag switch to its libtool invocation when 93# assembling a .s file and rely on libtool to infer the right action based 94# on the compiler name. As shave is using CC to hook a wrapper, libtool gets 95# confused. Let's detect these cases and add a --tag=CC option. 96tag="" 97if test $tag_seen -eq 0 -a x"$mode" = xcompile; then 98 tag="--tag=CC" 99fi 100 101if test -z $V; then 102 if test $pass_though -eq 0; then 103 echo "$Q$output" 104 fi 105 $LIBTOOL --silent $tag $preserved_args 106else 107 echo $LIBTOOL $tag $preserved_args 108 $LIBTOOL $tag $preserved_args 109fi