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## 9test -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. 12CXX="@CXX@" 13CXXFLAGS="@LDFLAGS@" 14 15LIBNAME="@ANTLR_LIB@" 16TARGET="$1" ; shift 17 18##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## 19## Prepate input arguments ## 20##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## 21case "@build_os@" 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 ;; 34esac 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 45if test -z "${ARGV}" ; then 46cat <<EOF 47%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 48Uuups, something went wrong. Have not been able to collect 49a list of object files. Perhaps nothing has been compiled 50so far? 51%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 52EOF 53exit 0 54fi 55 56if test -z "${LD}" ; then 57 LD="@CXX@" 58 ld="@cxx@" 59else 60 ld="`basename $LD`" 61 ld="`echo $ld|sed 's,\..*$,,'`" 62fi 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 72ldflags="" 73case "${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 ;; 89esac 90 91test -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. 106test -n "@LDFLAGS@" && { 107 set x @LDFLAGS@ ; 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 144set x ${LDFLAGS} ; shift 145case $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 ;; 165esac 166 167## Any special treatment goes here .. 168case "${ld}" in 169 ld) 170 ;; 171 *) 172 ;; 173esac 174 175##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%## 176## No c u s t o m i z a t i o n below this line ## 177##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%## 178test -z "${verbose}" && { 179 verbose=@VERBOSE@ 180} 181 182##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## 183## This shall be the command to be excuted below ## 184##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## 185 186cmd="${LD} ${LDFLAGS} ${ARGV}" 187 188##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## 189## standard template to execute a command ## 190##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx## 191case "${verbose}" in 192 0|no|nein|non) 193 echo "*** creating ${TARGET} .." 194 ;; 195 *) 196 echo $cmd 197 ;; 198esac 199 200$cmd || { 201 rc=$? 202 cat <<EOF 203 204xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 205 >> E R R O R << 206============================================================ 207 208$cmd 209 210============================================================ 211Got an error while trying to execute command above. Error 212messages (if any) must have shown before. The exit code was: 213exit($rc) 214xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 215EOF 216 exit $rc 217} 218exit 0 219