File: link.sh.in

package info (click to toggle)
antlr 2.7.7%2Bdfsg-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,020 kB
  • sloc: java: 54,649; cs: 12,537; makefile: 8,852; cpp: 7,359; pascal: 5,273; sh: 4,333; python: 4,299; lisp: 1,969; xml: 220; lex: 192; ansic: 127
file content (218 lines) | stat: -rwxr-xr-x 5,517 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/sh
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
## This file is part of ANTLR. See LICENSE.txt for licence  ##
## details. Written by W. Haefelinger.                      ##
##                                                          ##
##       Copyright (C) Wolfgang Haefelinger, 2004           ##
##                                                          ##
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
test -z "$1" && exit 0
## This script shall wrap/hide how we are going to link C++
## object files within the ANTLR (www.antlr.org) project.
CXX="@CXX@"
CXXFLAGS="@LDFLAGS@"

LIBNAME="@ANTLR_LIB@"
TARGET="$1" ; shift

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
##             Prepate input arguments                    ##
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
case "@build_os@" in
  cygwin)
    ARGV="`cygpath -m ${*}`"
    test -n "${TARGET}" && {
      TARGET=`cygpath -m ${TARGET}`
    }
    test -n "${LIBNAME}" && {
      LIBNAME="`cygpath -m ${LIBNAME}`"
    }
    ;;
  *)
    ARGV="${*}"
    ;;
esac

# RK: Disabled it strips -l<lib> arguments
#L="${ARGV}" ; ARGV=""
#for x in $L ; do
#  if test -f "${x}" ; then
#    ARGV="$ARGV ${x}"
#  fi
#done
#unset L

if test -z "${ARGV}" ; then
cat <<EOF
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Uuups, something went wrong. Have not been able to collect
a list of object files. Perhaps nothing has been compiled
so far?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
EOF
exit 0
fi

if test -z "${LD}" ; then
  LD="@CXX@"
  ld="@cxx@"
else
  ld="`basename $LD`"
  ld="`echo $ld|sed 's,\..*$,,'`"
fi

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
##       Here we set flags for well know programs         ##
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
##
## Do not set variable LDFLAGS here, just use it's sister
## variable 'ldflags'. This  allows  the call to override
## this settings - see handling of LDFLAGS below.

ldflags=""
case "${ld}" in
  cxx)
    # DEC/COMAPC "DECCXX" on Tru64 according to Kurt McCall.
    # It's a bit strange that we need to set here library paths for
    # the linker. Anyway, here we go..
    ldflags="${ldflags} -L/usr/lib/cmplrs/cxx -L/usr/lib/cmplrs/cxx/V6.5-042 -o ${TARGET}"
    ;;
  cl)
    ldflags="${ldflags} -o${TARGET}.exe"
    ;;
  bcc32)
    ldflags="${ldflags} -e${TARGET}.exe"
    ;;
  *)
    ldflags="${ldflags} -o ${TARGET}"
    ;;
esac

test -f "${LIBNAME}" && {
  case "${ld}" in
    *)
      ARGV="${ARGV} ${LIBNAME}"
      ;;
  esac
}

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
## **NO CHANGE NECESSARY BELOW THIS LINE - EXPERTS ONLY** ##
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##

## If specific flags have been configured then they overrule
## our precomputed flags. Still a user can override by using
## environment variable $LDFLAGS - see below.
test -n "@LDFLAGS@" && {
  set x @LDFLAGS@  ; shift
  case $1 in
    +)
      shift
      LDFLAGS="${ldflags} $*"
      ;;
    -)
      shift
      ldflags="$* ${ldflags}"
      ;;
    =)
      shift
      ldflags="$*"
      ;;
    *)
      if test -z "$1" ; then
        ldflags="${ldflags}"
      else
        ldflags="$*"
      fi
      ;;
  esac
}

## Regardless what has been configured, a user should always
## be able to  override  without  the need to reconfigure or
## change this file. Therefore we check variable $LDFLAGS.
## In almost all cases the precomputed flags are just ok but
## some  additional  flags are needed. To support this in an
## easy way, we check for the very first value. If this val-
## ue is
## '+'  -> append content of LDFLAGS to precomputed flags
## '-'  -> prepend content    -*-
## '='  -> do not use precomputed flags
## If none of these characters are given, the behaviour will
## be the same as if "=" would have been given.

set x ${LDFLAGS}  ; shift
case $1 in
  +)
    shift
    LDFLAGS="${ldflags} $*"
    ;;
  -)
    shift
    LDFLAGS="$* ${ldflags}"
    ;;
  =)
    shift
    LDFLAGS="$*"
    ;;
  *)
    if test -z "$1" ; then
      LDFLAGS="${ldflags}"
    else
      LDFLAGS="$*"
    fi
    ;;
esac

## Any special treatment goes here ..
case "${ld}" in
  ld)
    ;;
  *)
    ;;
esac

##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##
##    No  c u s t o m i z a t i o n  below this line          ##
##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##
test -z "${verbose}" && {
  verbose=@VERBOSE@
}

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
##    This shall be the command to be excuted below       ##
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##

cmd="${LD} ${LDFLAGS} ${ARGV}"

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
##        standard template to execute a command          ##
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
case "${verbose}" in
  0|no|nein|non)
    echo "*** creating ${TARGET} .."
    ;;
  *)
    echo $cmd
    ;;
esac

$cmd || {
  rc=$?
  cat <<EOF

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                      >> E R R O R <<
============================================================

$cmd

============================================================
Got an error while trying to execute  command  above.  Error
messages (if any) must have shown before. The exit code was:
exit($rc)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
EOF
  exit $rc
}
exit 0