OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [libtool-ldflags] - Diff between revs 154 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 154 Rev 816
#! /bin/sh
#! /bin/sh
# Script to translate LDFLAGS into a form suitable for use with libtool.
# Script to translate LDFLAGS into a form suitable for use with libtool.
# Copyright (C) 2005 Free Software Foundation, Inc.
# Copyright (C) 2005 Free Software Foundation, Inc.
#
#
# This file is free software; you can redistribute it and/or modify
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
# MA 02110-1301, USA.
# Contributed by CodeSourcery, LLC.
# Contributed by CodeSourcery, LLC.
# This script is designed to be used from a Makefile that uses libtool
# This script is designed to be used from a Makefile that uses libtool
# to build libraries as follows:
# to build libraries as follows:
#
#
#   LTLDFLAGS = $(shell libtool-ldflags $(LDFLAGS))
#   LTLDFLAGS = $(shell libtool-ldflags $(LDFLAGS))
#
#
# Then, use (LTLDFLAGS) in place of $(LDFLAGS) in your link line.
# Then, use (LTLDFLAGS) in place of $(LDFLAGS) in your link line.
# The output of the script.  This string is built up as we process the
# The output of the script.  This string is built up as we process the
# arguments.
# arguments.
result=
result=
for arg
for arg
do
do
    case $arg in
    case $arg in
        -f*|--*)
        -f*|--*)
            # Libtool does not ascribe any special meaning options
            # Libtool does not ascribe any special meaning options
            # that begin with -f or with a double-dash.  So, it will
            # that begin with -f or with a double-dash.  So, it will
            # think these options are linker options, and prefix them
            # think these options are linker options, and prefix them
            # with "-Wl,".  Then, the compiler driver will ignore the
            # with "-Wl,".  Then, the compiler driver will ignore the
            # options.  So, we prefix these options with -Xcompiler to
            # options.  So, we prefix these options with -Xcompiler to
            # make clear to libtool that they are in fact compiler
            # make clear to libtool that they are in fact compiler
            # options.
            # options.
            result="$result -Xcompiler"
            result="$result -Xcompiler"
            ;;
            ;;
        *)
        *)
            # We do not want to add -Xcompiler to other options because
            # We do not want to add -Xcompiler to other options because
            # that would prevent libtool itself from recognizing them.
            # that would prevent libtool itself from recognizing them.
            ;;
            ;;
    esac
    esac
    # If $(LDFLAGS) is (say):
    # If $(LDFLAGS) is (say):
    #   a "b'c d" e
    #   a "b'c d" e
    # then the user expects that:
    # then the user expects that:
    #   $(LD) $(LDFLAGS)
    #   $(LD) $(LDFLAGS)
    # will pass three arguments to $(LD):
    # will pass three arguments to $(LD):
    #   1) a
    #   1) a
    #   2) b'c d
    #   2) b'c d
    #   3) e
    #   3) e
    # We must ensure, therefore, that the arguments are appropriately
    # We must ensure, therefore, that the arguments are appropriately
    # quoted so that using:
    # quoted so that using:
    #   libtool --mode=link ... $(LTLDFLAGS)
    #   libtool --mode=link ... $(LTLDFLAGS)
    # will result in the same number of arguments being passed to
    # will result in the same number of arguments being passed to
    # libtool.   In other words, when this script was invoked, the shell
    # libtool.   In other words, when this script was invoked, the shell
    # removed one level of quoting, present in $(LDFLAGS); we have to put
    # removed one level of quoting, present in $(LDFLAGS); we have to put
    # it back.
    # it back.
    # Quote any embedded single quotes.
    # Quote any embedded single quotes.
    case $arg in
    case $arg in
        *"'"*)
        *"'"*)
            # The following command creates the script:
            # The following command creates the script:
            #   1s,^X,,;s|'|'"'"'|g
            #   1s,^X,,;s|'|'"'"'|g
            # which removes a leading X, and then quotes and embedded single
            # which removes a leading X, and then quotes and embedded single
            # quotes.
            # quotes.
            sed_script="1s,^X,,;s|'|'\"'\"'|g"
            sed_script="1s,^X,,;s|'|'\"'\"'|g"
            # Add a leading "X" so that if $arg starts with a dash,
            # Add a leading "X" so that if $arg starts with a dash,
            # the echo command will not try to interpret the argument
            # the echo command will not try to interpret the argument
            # as a command-line option.
            # as a command-line option.
            arg="X$arg"
            arg="X$arg"
            # Generate the quoted string.
            # Generate the quoted string.
            quoted_arg=`echo "$arg" | sed -e "$sed_script"`
            quoted_arg=`echo "$arg" | sed -e "$sed_script"`
            ;;
            ;;
        *)
        *)
            quoted_arg=$arg
            quoted_arg=$arg
            ;;
            ;;
    esac
    esac
    # Surround the entire argument with single quotes.
    # Surround the entire argument with single quotes.
    quoted_arg="'"$quoted_arg"'"
    quoted_arg="'"$quoted_arg"'"
    # Add it to the string.
    # Add it to the string.
    result="$result $quoted_arg"
    result="$result $quoted_arg"
done
done
# Output the string we have built up.
# Output the string we have built up.
echo "$result"
echo "$result"
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.