1 | #!/bin/sh |
---|
2 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
3 | ## This file is part of ANTLR. See LICENSE.txt for licence ## |
---|
4 | ## details. Written by W. Haefelinger. ## |
---|
5 | ## ## |
---|
6 | ## Copyright (C) Wolfgang Haefelinger, 2004 ## |
---|
7 | ## ## |
---|
8 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
9 | test -z "$1" && exit 0 |
---|
10 | ## This script shall wrap/hide how we are going to link C++ |
---|
11 | ## object files within the ANTLR (www.antlr.org) project. |
---|
12 | CXX="g++" |
---|
13 | CXXFLAGS="" |
---|
14 | |
---|
15 | LIBNAME="/usr/neuro/local/yao/yao9/share/antlr-2.7.7/lib/cpp/src/libantlr.a" |
---|
16 | TARGET="$1" ; shift |
---|
17 | |
---|
18 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
19 | ## Prepate input arguments ## |
---|
20 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
21 | case "linux-gnu" in |
---|
22 | cygwin) |
---|
23 | ARGV="`cygpath -m ${*}`" |
---|
24 | test -n "${TARGET}" && { |
---|
25 | TARGET=`cygpath -m ${TARGET}` |
---|
26 | } |
---|
27 | test -n "${LIBNAME}" && { |
---|
28 | LIBNAME="`cygpath -m ${LIBNAME}`" |
---|
29 | } |
---|
30 | ;; |
---|
31 | *) |
---|
32 | ARGV="${*}" |
---|
33 | ;; |
---|
34 | esac |
---|
35 | |
---|
36 | # RK: Disabled it strips -l<lib> arguments |
---|
37 | #L="${ARGV}" ; ARGV="" |
---|
38 | #for x in $L ; do |
---|
39 | # if test -f "${x}" ; then |
---|
40 | # ARGV="$ARGV ${x}" |
---|
41 | # fi |
---|
42 | #done |
---|
43 | #unset L |
---|
44 | |
---|
45 | if test -z "${ARGV}" ; then |
---|
46 | cat <<EOF |
---|
47 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
48 | Uuups, something went wrong. Have not been able to collect |
---|
49 | a list of object files. Perhaps nothing has been compiled |
---|
50 | so far? |
---|
51 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
52 | EOF |
---|
53 | exit 0 |
---|
54 | fi |
---|
55 | |
---|
56 | if test -z "${LD}" ; then |
---|
57 | LD="g++" |
---|
58 | ld="gcc" |
---|
59 | else |
---|
60 | ld="`basename $LD`" |
---|
61 | ld="`echo $ld|sed 's,\..*$,,'`" |
---|
62 | fi |
---|
63 | |
---|
64 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
65 | ## Here we set flags for well know programs ## |
---|
66 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
67 | ## |
---|
68 | ## Do not set variable LDFLAGS here, just use it's sister |
---|
69 | ## variable 'ldflags'. This allows the call to override |
---|
70 | ## this settings - see handling of LDFLAGS below. |
---|
71 | |
---|
72 | ldflags="" |
---|
73 | case "${ld}" in |
---|
74 | cxx) |
---|
75 | # DEC/COMAPC "DECCXX" on Tru64 according to Kurt McCall. |
---|
76 | # It's a bit strange that we need to set here library paths for |
---|
77 | # the linker. Anyway, here we go.. |
---|
78 | ldflags="${ldflags} -L/usr/lib/cmplrs/cxx -L/usr/lib/cmplrs/cxx/V6.5-042 -o ${TARGET}" |
---|
79 | ;; |
---|
80 | cl) |
---|
81 | ldflags="${ldflags} -o${TARGET}.exe" |
---|
82 | ;; |
---|
83 | bcc32) |
---|
84 | ldflags="${ldflags} -e${TARGET}.exe" |
---|
85 | ;; |
---|
86 | *) |
---|
87 | ldflags="${ldflags} -o ${TARGET}" |
---|
88 | ;; |
---|
89 | esac |
---|
90 | |
---|
91 | test -f "${LIBNAME}" && { |
---|
92 | case "${ld}" in |
---|
93 | *) |
---|
94 | ARGV="${ARGV} ${LIBNAME}" |
---|
95 | ;; |
---|
96 | esac |
---|
97 | } |
---|
98 | |
---|
99 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
100 | ## **NO CHANGE NECESSARY BELOW THIS LINE - EXPERTS ONLY** ## |
---|
101 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
102 | |
---|
103 | ## If specific flags have been configured then they overrule |
---|
104 | ## our precomputed flags. Still a user can override by using |
---|
105 | ## environment variable $LDFLAGS - see below. |
---|
106 | test -n "" && { |
---|
107 | set x ; shift |
---|
108 | case $1 in |
---|
109 | +) |
---|
110 | shift |
---|
111 | LDFLAGS="${ldflags} $*" |
---|
112 | ;; |
---|
113 | -) |
---|
114 | shift |
---|
115 | ldflags="$* ${ldflags}" |
---|
116 | ;; |
---|
117 | =) |
---|
118 | shift |
---|
119 | ldflags="$*" |
---|
120 | ;; |
---|
121 | *) |
---|
122 | if test -z "$1" ; then |
---|
123 | ldflags="${ldflags}" |
---|
124 | else |
---|
125 | ldflags="$*" |
---|
126 | fi |
---|
127 | ;; |
---|
128 | esac |
---|
129 | } |
---|
130 | |
---|
131 | ## Regardless what has been configured, a user should always |
---|
132 | ## be able to override without the need to reconfigure or |
---|
133 | ## change this file. Therefore we check variable $LDFLAGS. |
---|
134 | ## In almost all cases the precomputed flags are just ok but |
---|
135 | ## some additional flags are needed. To support this in an |
---|
136 | ## easy way, we check for the very first value. If this val- |
---|
137 | ## ue is |
---|
138 | ## '+' -> append content of LDFLAGS to precomputed flags |
---|
139 | ## '-' -> prepend content -*- |
---|
140 | ## '=' -> do not use precomputed flags |
---|
141 | ## If none of these characters are given, the behaviour will |
---|
142 | ## be the same as if "=" would have been given. |
---|
143 | |
---|
144 | set x ${LDFLAGS} ; shift |
---|
145 | case $1 in |
---|
146 | +) |
---|
147 | shift |
---|
148 | LDFLAGS="${ldflags} $*" |
---|
149 | ;; |
---|
150 | -) |
---|
151 | shift |
---|
152 | LDFLAGS="$* ${ldflags}" |
---|
153 | ;; |
---|
154 | =) |
---|
155 | shift |
---|
156 | LDFLAGS="$*" |
---|
157 | ;; |
---|
158 | *) |
---|
159 | if test -z "$1" ; then |
---|
160 | LDFLAGS="${ldflags}" |
---|
161 | else |
---|
162 | LDFLAGS="$*" |
---|
163 | fi |
---|
164 | ;; |
---|
165 | esac |
---|
166 | |
---|
167 | ## Any special treatment goes here .. |
---|
168 | case "${ld}" in |
---|
169 | ld) |
---|
170 | ;; |
---|
171 | *) |
---|
172 | ;; |
---|
173 | esac |
---|
174 | |
---|
175 | ##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%## |
---|
176 | ## No c u s t o m i z a t i o n below this line ## |
---|
177 | ##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%## |
---|
178 | test -z "${verbose}" && { |
---|
179 | verbose=0 |
---|
180 | } |
---|
181 | |
---|
182 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
183 | ## This shall be the command to be excuted below ## |
---|
184 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
185 | |
---|
186 | cmd="${LD} ${LDFLAGS} ${ARGV}" |
---|
187 | |
---|
188 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
189 | ## standard template to execute a command ## |
---|
190 | ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## |
---|
191 | case "${verbose}" in |
---|
192 | 0|no|nein|non) |
---|
193 | echo "*** creating ${TARGET} .." |
---|
194 | ;; |
---|
195 | *) |
---|
196 | echo $cmd |
---|
197 | ;; |
---|
198 | esac |
---|
199 | |
---|
200 | $cmd || { |
---|
201 | rc=$? |
---|
202 | cat <<EOF |
---|
203 | |
---|
204 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
---|
205 | >> E R R O R << |
---|
206 | ============================================================ |
---|
207 | |
---|
208 | $cmd |
---|
209 | |
---|
210 | ============================================================ |
---|
211 | Got an error while trying to execute command above. Error |
---|
212 | messages (if any) must have shown before. The exit code was: |
---|
213 | exit($rc) |
---|
214 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
---|
215 | EOF |
---|
216 | exit $rc |
---|
217 | } |
---|
218 | exit 0 |
---|