~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/scripts/ldAix

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# ldAix ldArg ldArg ...
 
4
#
 
5
# This shell script provides a wrapper for ld under AIX in order to
 
6
# create the .exp file required for linking.  Its arguments consist
 
7
# of the name and arguments that would normally be provided to the
 
8
# ld command.  This script extracts the names of the object files
 
9
# from the argument list, creates a .exp file describing all of the
 
10
# symbols exported by those files, and then invokes "ldCmd" to
 
11
# perform the real link.
 
12
#
 
13
# This shell script has been copied from the TCL project, see copyright 
 
14
# note below.
 
15
 
16
# This software is copyrighted by the Regents of the University of
 
17
# California, Sun Microsystems, Inc., Scriptics Corporation,
 
18
# and other parties.  The following terms apply to all files associated
 
19
# with the software unless explicitly disclaimed in individual files.
 
20
#  
 
21
# The authors hereby grant permission to use, copy, modify, distribute,
 
22
# and license this software and its documentation for any purpose, provided
 
23
# that existing copyright notices are retained in all copies and that this
 
24
# notice is included verbatim in any distributions. No written agreement,
 
25
# license, or royalty fee is required for any of the authorized uses.
 
26
# Modifications to this software may be copyrighted by their authors
 
27
# and need not follow the licensing terms described here, provided that
 
28
# the new terms are clearly indicated on the first page of each file where
 
29
# they apply.
 
30
#  
 
31
# IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
 
32
# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
 
33
# ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
 
34
# DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
 
35
# POSSIBILITY OF SUCH DAMAGE.
 
36
#  
 
37
# THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
 
38
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
 
39
# FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
 
40
# IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
 
41
# NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
 
42
# MODIFICATIONS.
 
43
#  
 
44
# GOVERNMENT USE: If you are acquiring this software on behalf of the
 
45
# U.S. government, the Government shall have only "Restricted Rights"
 
46
# in the software and related documentation as defined in the Federal
 
47
# Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2).  If you
 
48
# are acquiring the software on behalf of the Department of Defense, the
 
49
# software shall be classified as "Commercial Computer Software" and the
 
50
# Government shall have only "Restricted Rights" as defined in Clause
 
51
# 252.227-7013 (c) (1) of DFARs.  Notwithstanding the foregoing, the
 
52
# authors grant the U.S. Government and others acting in its behalf
 
53
# permission to use and distribute the software in accordance with the
 
54
# terms specified in this license.
 
55
 
56
# Extract from the arguments the names of all of the object files.
 
57
 
 
58
args=$*
 
59
ofiles=""
 
60
for i do
 
61
    x=`echo $i | grep '[^.]\.o$'`
 
62
    if test "$x" != ""; then
 
63
        ofiles="$ofiles $i"
 
64
    fi
 
65
done
 
66
# Extract the name of the object file that we're linking.
 
67
outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'`
 
68
 
 
69
# Create the export file from all of the object files, using nm followed
 
70
# by sed editing.  Here are some tricky aspects of this:
 
71
#
 
72
# 1. Nm produces different output under AIX 4.1 than under AIX 3.2.5;
 
73
#    the following statements handle both versions.
 
74
# 2. Use the -g switch to nm instead of -e under 4.1 (this shows just
 
75
#    externals, not statics;  -g isn't available under 3.2.5, though).
 
76
# 3. Eliminate lines that end in ":": these are the names of object
 
77
#    files (relevant in 4.1 only).
 
78
# 4. Eliminate entries with the "U" key letter;  these are undefined
 
79
#    symbols (relevant in 4.1 only).
 
80
# 5. Eliminate lines that contain the string "0|extern" preceded by space;
 
81
#    in 3.2.5, these are undefined symbols (address 0).
 
82
# 6. Eliminate lines containing the "unamex" symbol.  In 3.2.5, these
 
83
#    are also undefined symbols.
 
84
# 7. If a line starts with ".", delete the leading ".", since this will
 
85
#    just cause confusion later.
 
86
# 8. Eliminate everything after the first field in a line, so that we're
 
87
#    left with just the symbol name.
 
88
 
 
89
nmopts="-g -C"
 
90
osver=`uname -v`
 
91
if test $osver -eq 3; then
 
92
  nmopts="-e"
 
93
fi
 
94
rm -f lib.exp
 
95
echo "#! $outputFile" >lib.exp
 
96
/usr/ccs/bin/nm $nmopts -h $ofiles | sed -e '/:$/d' -e '/ U /d' -e '/[  ]0|extern/d' -e '/unamex/d' -e 's/^\.//' -e 's/[        |].*//' | sort | uniq >>lib.exp
 
97
 
 
98
# If we're linking a .a file, then link all the objects together into a 
 
99
# single file "shr.o" and then put that into the archive.  Otherwise link 
 
100
# the object files directly into the .a file.
 
101
 
 
102
outputFile=`echo $args | sed -e 's/.*-o \([^ ]*\).*/\1/'`
 
103
noDotA=`echo $outputFile | sed -e '/\.a$/d'`
 
104
echo "noDotA=\"$noDotA\""
 
105
if test "$noDotA" = "" ; then
 
106
    linkArgs=`echo $args | sed -e 's/-o .*\.a /-o shr.o /'`
 
107
    echo $linkArgs
 
108
    eval $linkArgs
 
109
    echo ar cr $outputFile shr.o
 
110
    ar cr $outputFile shr.o
 
111
    rm -f shr.o
 
112
else
 
113
    eval /usr/bin/ld $args
 
114
fi