PageRenderTime 39ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/antlr-2.7.5/scripts/lib.sh

https://github.com/boo/boo-lang
Shell | 276 lines | 180 code | 33 blank | 63 comment | 25 complexity | a0a5339139426da380eea3e60155ac27 MD5 | raw file
Possible License(s): GPL-2.0
  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. ## This script shall wrap/hide how we are going to build a library
  10. ## within the ANTLR (www.antlr.org) project.
  11. test -z "${1}" && exit 0
  12. if test -z "${AR}" ; then
  13. AR="/usr/bin/ar"
  14. ar="@ar@"
  15. else
  16. ar="`basename $AR`"
  17. ar="`echo $ar|sed 's,\..*$,,'`"
  18. fi
  19. test -z "${DEBUG}" && {
  20. DEBUG="0"
  21. }
  22. RANLIB="ranlib"
  23. LIBNAME="/home/rodrigob/java/antlr-2.7.5/lib/cpp/src/libantlr.a"
  24. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  25. ## Prepate input arguments ##
  26. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  27. case "linux-gnu" in
  28. cygwin)
  29. LIBNAME="`cygpath -m ${LIBNAME}`"
  30. ARGV="`cygpath -m ${*}`"
  31. ;;
  32. *)
  33. ARGV="${*}"
  34. ;;
  35. esac
  36. L="${ARGV}" ; ARGV=""
  37. for x in $L ; do
  38. if test -f "${x}" ; then
  39. ARGV="$ARGV ${x}"
  40. fi
  41. done
  42. unset L
  43. if test -z "${ARGV}" ; then
  44. cat <<EOF
  45. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  46. Uuups, something went wrong. Have not been able to collect
  47. a list of object files. Perhaps nothing has been compiled
  48. so far?
  49. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  50. EOF
  51. exit 0
  52. fi
  53. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  54. ## Here we set flags for well know programs ##
  55. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  56. ##
  57. ## Do not set variable ARFLAGS here, just use it's sister
  58. ## variable 'arflags'. This allows the call to override
  59. ## this settings - see handling of ARFLAGS below.
  60. case "gcc" in
  61. cl)
  62. ## I'm shamelessly override what has been configured --
  63. ## nothing more than a hack.
  64. AR='lib'
  65. arflags="/nologo /verbose /out:${LIBNAME}"
  66. cmd_pfx="rm -f ${LIBNAME}"
  67. ## no runlib required
  68. unset RANLIB
  69. ;;
  70. bcc32)
  71. ## I'm shamelessly override what has been configured --
  72. ## nothing more than a hack.
  73. AR='tlib'
  74. ## to make the general command work
  75. b=`basename "${LIBNAME}"`
  76. cmd_pfx="rm -f ${b} ${LIBNAME}"
  77. cmd_sfx="cp $b .${b} ; rm ${b}; cp .${b} ${LIBNAME}"
  78. arflags="/P128 ${b}"
  79. ## no runlib required
  80. unset RANLIB
  81. ## Borland's interface for tlib (making a static library)
  82. ## is most stupid ever seen. For example, it does not
  83. ## accept "-" in file names, not is it able to handle
  84. ## forward slashes in pathnames. Even Microsoft can do
  85. ## this..
  86. L="${ARGV}" ; ARGV=""
  87. for x in $L ; do
  88. ARGV="$ARGV +`basename ${x}`"
  89. done
  90. unset L
  91. ;;
  92. CC)
  93. AR="g++"
  94. arflags="-xar -o ${LIBNAME}"
  95. cmd_pfx="rm -f ${LIBNAME}"
  96. ;;
  97. *)
  98. arflags="rus"
  99. ARGV="${LIBNAME} ${ARGV}"
  100. cmd_pfx="rm -f ${LIBNAME}"
  101. ;;
  102. esac
  103. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  104. ## **NO CHANGE NECESSARY BELOW THIS LINE - EXPERTS ONLY** ##
  105. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  106. test -z "${verbose}" && {
  107. verbose=0
  108. }
  109. ## If specific flags have been configured then they overrule
  110. ## our precomputed flags. Still a user can override by using
  111. ## environment variable $ARFLAGS - see below.
  112. test -n "" && {
  113. set x ; shift
  114. case $1 in
  115. +)
  116. shift
  117. ARFLAGS="${arflags} $*"
  118. ;;
  119. -)
  120. shift
  121. arflags="$* ${arflags}"
  122. ;;
  123. =)
  124. shift
  125. arflags="$*"
  126. ;;
  127. *)
  128. if test -z "$1" ; then
  129. arflags="${arflags}"
  130. else
  131. arflags="$*"
  132. fi
  133. ;;
  134. esac
  135. }
  136. ## Regardless what has been configured, a user should always
  137. ## be able to override without the need to reconfigure or
  138. ## change this file. Therefore we check variable $ARFLAGS.
  139. ## In almost all cases the precomputed flags are just ok but
  140. ## some additional flags are needed. To support this in an
  141. ## easy way, we check for the very first value. If this val-
  142. ## ue is
  143. ## '+' -> append content of ARFLAGS to precomputed flags
  144. ## '-' -> prepend content -*-
  145. ## '=' -> do not use precomputed flags
  146. ## If none of these characters are given, the behaviour will
  147. ## be the same as if "=" would have been given.
  148. set x ${ARFLAGS} ; shift
  149. case $1 in
  150. +)
  151. shift
  152. ARFLAGS="${arflags} $*"
  153. ;;
  154. -)
  155. shift
  156. ARFLAGS="$* ${arflags}"
  157. ;;
  158. =)
  159. shift
  160. ARFLAGS="$*"
  161. ;;
  162. *)
  163. if test -z "$1" ; then
  164. ARFLAGS="${arflags}"
  165. else
  166. ARFLAGS="$*"
  167. fi
  168. ;;
  169. esac
  170. ## Any special treatment goes here ..
  171. case "${ar}" in
  172. ar)
  173. ;;
  174. *)
  175. ;;
  176. esac
  177. ##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##
  178. ## No c u s t o m i z a t i o n below this line ##
  179. ##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##
  180. ## Reset positional args
  181. set x ${ARGV} ; shift
  182. ## This is how we would run 'ranlib' ..
  183. test -n "${RANLIB}" && {
  184. ranlib_cmd="${RANLIB} ${LIBNAME}"
  185. }
  186. ## This extra copy is a hack for Borland's TLIB which does
  187. ## not accept '-' in filenames.
  188. cmd="${AR} ${ARFLAGS} ${ARGV}"
  189. ## If there's something to be done ..
  190. test -n "${cmd}" && {
  191. test -n "${cmd_pfx}" && {
  192. test $verbose -gt 0 && {
  193. echo $cmd_pfx
  194. }
  195. eval ${cmd_pfx} || exit 1
  196. }
  197. ## be verbose of required
  198. case "${verbose}" in
  199. 0|no|nein|non)
  200. echo "*** creating ${LIBNAME}"
  201. ;;
  202. *)
  203. echo $cmd
  204. ;;
  205. esac
  206. ## remove library - just in case.
  207. test -n "${LIBNAME}" -a -f "${LIBNAME}" && {
  208. rm -f ${LIBNAME}
  209. }
  210. ## eventually ..
  211. $cmd || {
  212. rc=$?
  213. cat <<EOF
  214. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  215. >> E R R O R <<
  216. ============================================================
  217. $cmd
  218. ============================================================
  219. Got an error while trying to execute command above. Error
  220. messages (if any) must have shown before. The exit code was:
  221. exit($rc)
  222. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  223. EOF
  224. exit $rc
  225. }
  226. test -n "${cmd_sfx}" && {
  227. test $verbose -gt 0 && {
  228. echo $cmd_sfx
  229. }
  230. eval ${cmd_sfx} || exit 1
  231. }
  232. ## and even later ..
  233. test -n "${RANLIB}" && {
  234. cmd="${RANLIB} ${LIBNAME}"
  235. test $verbose -gt 0 && {
  236. echo $cmd
  237. }
  238. $cmd || {
  239. exit 1
  240. }
  241. }
  242. }
  243. exit 0