PageRenderTime 33ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/boo/boo-lang
Shell | 212 lines | 135 code | 21 blank | 56 comment | 12 complexity | 8c4da7eece124824ec5279116682068b 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. 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. LIBNAME="/home/rodrigob/java/antlr-2.7.5/lib/cpp/src/libantlr.a"
  15. TARGET="$1" ; shift
  16. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  17. ## Prepate input arguments ##
  18. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  19. case "linux-gnu" in
  20. cygwin)
  21. ARGV="`cygpath -m ${*}`"
  22. test -n "${TARGET}" && {
  23. TARGET=`cygpath -m ${TARGET}`
  24. }
  25. test -n "${LIBNAME}" && {
  26. LIBNAME="`cygpath -m ${LIBNAME}`"
  27. }
  28. ;;
  29. *)
  30. ARGV="${*}"
  31. ;;
  32. esac
  33. # RK: Disabled it strips -l<lib> arguments
  34. #L="${ARGV}" ; ARGV=""
  35. #for x in $L ; do
  36. # if test -f "${x}" ; then
  37. # ARGV="$ARGV ${x}"
  38. # fi
  39. #done
  40. #unset L
  41. if test -z "${ARGV}" ; then
  42. cat <<EOF
  43. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  44. Uuups, something went wrong. Have not been able to collect
  45. a list of object files. Perhaps nothing has been compiled
  46. so far?
  47. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  48. EOF
  49. exit 0
  50. fi
  51. if test -z "${LD}" ; then
  52. LD="g++"
  53. ld="gcc"
  54. else
  55. ld="`basename $LD`"
  56. ld="`echo $ld|sed 's,\..*$,,'`"
  57. fi
  58. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  59. ## Here we set flags for well know programs ##
  60. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  61. ##
  62. ## Do not set variable LDFLAGS here, just use it's sister
  63. ## variable 'ldflags'. This allows the call to override
  64. ## this settings - see handling of LDFLAGS below.
  65. ldflags=""
  66. case "${ld}" in
  67. cl)
  68. ldflags="${ldflags} /o${TARGET}.exe"
  69. ;;
  70. bcc32)
  71. ldflags="${ldflags} -e${TARGET}.exe"
  72. ;;
  73. *)
  74. ldflags="${ldflags} -o ${TARGET}"
  75. ;;
  76. esac
  77. test -f "${LIBNAME}" && {
  78. case "${ld}" in
  79. *)
  80. ARGV="${ARGV} ${LIBNAME}"
  81. ;;
  82. esac
  83. }
  84. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  85. ## **NO CHANGE NECESSARY BELOW THIS LINE - EXPERTS ONLY** ##
  86. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  87. ## If specific flags have been configured then they overrule
  88. ## our precomputed flags. Still a user can override by using
  89. ## environment variable $LDFLAGS - see below.
  90. test -n "" && {
  91. set x ; shift
  92. case $1 in
  93. +)
  94. shift
  95. LDFLAGS="${ldflags} $*"
  96. ;;
  97. -)
  98. shift
  99. ldflags="$* ${ldflags}"
  100. ;;
  101. =)
  102. shift
  103. ldflags="$*"
  104. ;;
  105. *)
  106. if test -z "$1" ; then
  107. ldflags="${ldflags}"
  108. else
  109. ldflags="$*"
  110. fi
  111. ;;
  112. esac
  113. }
  114. ## Regardless what has been configured, a user should always
  115. ## be able to override without the need to reconfigure or
  116. ## change this file. Therefore we check variable $LDFLAGS.
  117. ## In almost all cases the precomputed flags are just ok but
  118. ## some additional flags are needed. To support this in an
  119. ## easy way, we check for the very first value. If this val-
  120. ## ue is
  121. ## '+' -> append content of LDFLAGS to precomputed flags
  122. ## '-' -> prepend content -*-
  123. ## '=' -> do not use precomputed flags
  124. ## If none of these characters are given, the behaviour will
  125. ## be the same as if "=" would have been given.
  126. set x ${LDFLAGS} ; shift
  127. case $1 in
  128. +)
  129. shift
  130. LDFLAGS="${ldflags} $*"
  131. ;;
  132. -)
  133. shift
  134. LDFLAGS="$* ${ldflags}"
  135. ;;
  136. =)
  137. shift
  138. LDFLAGS="$*"
  139. ;;
  140. *)
  141. if test -z "$1" ; then
  142. LDFLAGS="${ldflags}"
  143. else
  144. LDFLAGS="$*"
  145. fi
  146. ;;
  147. esac
  148. ## Any special treatment goes here ..
  149. case "${ld}" in
  150. ld)
  151. ;;
  152. *)
  153. ;;
  154. esac
  155. ##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##
  156. ## No c u s t o m i z a t i o n below this line ##
  157. ##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%##
  158. test -z "${verbose}" && {
  159. verbose=0
  160. }
  161. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  162. ## This shall be the command to be excuted below ##
  163. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  164. cmd="${LD} ${LDFLAGS} ${ARGV}"
  165. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  166. ## standard template to execute a command ##
  167. ##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
  168. case "${verbose}" in
  169. 0|no|nein|non)
  170. echo "*** creating ${TARGET} .."
  171. ;;
  172. *)
  173. echo $cmd
  174. ;;
  175. esac
  176. $cmd || {
  177. rc=$?
  178. cat <<EOF
  179. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  180. >> E R R O R <<
  181. ============================================================
  182. $cmd
  183. ============================================================
  184. Got an error while trying to execute command above. Error
  185. messages (if any) must have shown before. The exit code was:
  186. exit($rc)
  187. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  188. EOF
  189. exit $rc
  190. }
  191. exit 0