OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [libtool-ldflags] - Blame information for rev 606

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
#! /bin/sh
2
 
3
# Script to translate LDFLAGS into a form suitable for use with libtool.
4
 
5
# Copyright (C) 2005 Free Software Foundation, Inc.
6
#
7
# This file is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
11
#
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
# MA 02110-1301, USA.
21
 
22
# Contributed by CodeSourcery, LLC.
23
 
24
# This script is designed to be used from a Makefile that uses libtool
25
# to build libraries as follows:
26
#
27
#   LTLDFLAGS = $(shell libtool-ldflags $(LDFLAGS))
28
#
29
# Then, use (LTLDFLAGS) in place of $(LDFLAGS) in your link line.
30
 
31
# The output of the script.  This string is built up as we process the
32
# arguments.
33
result=
34
 
35
for arg
36
do
37
    case $arg in
38
        -f*|--*)
39
            # Libtool does not ascribe any special meaning options
40
            # that begin with -f or with a double-dash.  So, it will
41
            # think these options are linker options, and prefix them
42
            # with "-Wl,".  Then, the compiler driver will ignore the
43
            # options.  So, we prefix these options with -Xcompiler to
44
            # make clear to libtool that they are in fact compiler
45
            # options.
46
            result="$result -Xcompiler"
47
            ;;
48
        *)
49
            # We do not want to add -Xcompiler to other options because
50
            # that would prevent libtool itself from recognizing them.
51
            ;;
52
    esac
53
 
54
    # If $(LDFLAGS) is (say):
55
    #   a "b'c d" e
56
    # then the user expects that:
57
    #   $(LD) $(LDFLAGS)
58
    # will pass three arguments to $(LD):
59
    #   1) a
60
    #   2) b'c d
61
    #   3) e
62
    # We must ensure, therefore, that the arguments are appropriately
63
    # quoted so that using:
64
    #   libtool --mode=link ... $(LTLDFLAGS)
65
    # will result in the same number of arguments being passed to
66
    # libtool.   In other words, when this script was invoked, the shell
67
    # removed one level of quoting, present in $(LDFLAGS); we have to put
68
    # it back.
69
 
70
    # Quote any embedded single quotes.
71
    case $arg in
72
        *"'"*)
73
            # The following command creates the script:
74
            #   1s,^X,,;s|'|'"'"'|g
75
            # which removes a leading X, and then quotes and embedded single
76
            # quotes.
77
            sed_script="1s,^X,,;s|'|'\"'\"'|g"
78
            # Add a leading "X" so that if $arg starts with a dash,
79
            # the echo command will not try to interpret the argument
80
            # as a command-line option.
81
            arg="X$arg"
82
            # Generate the quoted string.
83
            quoted_arg=`echo "$arg" | sed -e "$sed_script"`
84
            ;;
85
        *)
86
            quoted_arg=$arg
87
            ;;
88
    esac
89
    # Surround the entire argument with single quotes.
90
    quoted_arg="'"$quoted_arg"'"
91
 
92
    # Add it to the string.
93
    result="$result $quoted_arg"
94
done
95
 
96
# Output the string we have built up.
97
echo "$result"

powered by: WebSVN 2.1.0

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