boolangstudio /Dependencies/boo/lib/antlr-2.7.5/scripts/lib.sh

Language Bourne Shell Lines 276
MD5 Hash a0a5339139426da380eea3e60155ac27
Repository https://github.com/w4x/boolangstudio.git View Raw File View Project SPDX
  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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/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##
## This script shall wrap/hide how we are going to build a library
## within the ANTLR (www.antlr.org) project.
test -z "${1}" && exit 0

if test -z "${AR}" ; then
  AR="/usr/bin/ar"
  ar="@ar@"
else
  ar="`basename $AR`"
  ar="`echo $ar|sed 's,\..*$,,'`"
fi

test -z "${DEBUG}" && {
  DEBUG="0"
}

RANLIB="ranlib"
LIBNAME="/home/rodrigob/java/antlr-2.7.5/lib/cpp/src/libantlr.a"

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
##             Prepate input arguments                    ##
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
case "linux-gnu" in
  cygwin)
    LIBNAME="`cygpath -m ${LIBNAME}`"
    ARGV="`cygpath -m ${*}`"
    ;;
  *)
    ARGV="${*}"
    ;;
esac

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

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

case "gcc" in
  cl)    
    ## I'm shamelessly override what has been configured --   
    ## nothing more than a hack.   
    AR='lib'   
    arflags="/nologo /verbose /out:${LIBNAME}"
    cmd_pfx="rm -f ${LIBNAME}"
    ## no runlib required   
    unset RANLIB 
    ;;
  bcc32)
    ## I'm shamelessly override what has been configured --   
    ## nothing more than a hack.   
    AR='tlib'  
    ## to make the general command work   
    b=`basename "${LIBNAME}"`
    cmd_pfx="rm -f ${b} ${LIBNAME}"
    cmd_sfx="cp $b .${b} ; rm ${b}; cp .${b} ${LIBNAME}"
    arflags="/P128 ${b}" 
      ## no runlib required   
    unset RANLIB
    
    ## Borland's interface for tlib (making a static library)
    ## is most stupid ever seen. For example,  it  does  not
    ## accept "-" in file  names,  not  is it able to handle 
    ## forward  slashes  in pathnames. Even Microsoft can do 
    ## this..
    L="${ARGV}" ; ARGV=""
    for x in $L ; do
      ARGV="$ARGV +`basename ${x}`"
    done
    unset L
    ;;
  CC)
    AR="g++"
    arflags="-xar -o ${LIBNAME}"
    cmd_pfx="rm -f ${LIBNAME}"
    ;;
  *)
    arflags="rus"
    ARGV="${LIBNAME} ${ARGV}"
    cmd_pfx="rm -f ${LIBNAME}"
    ;;
esac

##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
## **NO CHANGE NECESSARY BELOW THIS LINE - EXPERTS ONLY** ##
##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
test -z "${verbose}" && { 
  verbose=0
}

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

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

##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##
##    No  c u s t o m i z a t i o n  below this line          ##
##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##


## Reset positional args
set x ${ARGV} ; shift

## This is how we would run 'ranlib' ..
test -n "${RANLIB}" && {
  ranlib_cmd="${RANLIB} ${LIBNAME}"
}



## This extra copy is a hack for Borland's TLIB which does
## not accept '-' in filenames.
cmd="${AR} ${ARFLAGS} ${ARGV}"

## If there's something to be done ..
test -n "${cmd}" && {
  
  test -n "${cmd_pfx}" && {
    test $verbose -gt 0 && {
      echo $cmd_pfx
    }
    eval ${cmd_pfx} || exit 1
  }

  ## be verbose of required  
  case "${verbose}" in
    0|no|nein|non)
      echo "*** creating ${LIBNAME}"
      ;;
    *)
      echo $cmd
      ;;
  esac
   
  ## remove library - just in case.
  test -n "${LIBNAME}" -a -f "${LIBNAME}" && {
    rm -f ${LIBNAME}
  }

 
  ## eventually ..
  $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
  }
  
  test -n "${cmd_sfx}" && {
    test $verbose -gt 0 && {
      echo $cmd_sfx
    }
    eval ${cmd_sfx} || exit 1
  }

  ## and even later ..
  test -n "${RANLIB}" && {
    cmd="${RANLIB} ${LIBNAME}"
    test $verbose -gt 0 && {
      echo $cmd
    }
    $cmd || {
      exit 1
    }
  }
}

exit 0
Back to Top