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 pack Java class
10## files. We need to wrap  this  as  SUN's jar does not understand
11## UNIX filename notation on Cygwin.
12test -z "${verbose}" && {
13  verbose=@VERBOSE@
14}
15
16## check whether we have something to do ..
17test -z "$1" && exit 0
18
19
20case @build_os@ in
21  cygwin)
22    ARGV="`cygpath -m $*`"
23    ;;
24  *)
25    ARGV="$*"
26    ;;
27esac
28
29
30## Command JAR is precomputed but user may override.
31if test -z "${JAR}" ; then
32  JAR="@JAR@"
33  jar="@jar@"
34else
35  jar="`basename $JAR`"
36  jar="`echo $jar|sed 's,\..*$,,'`"
37fi
38
39test -z "${DEBUG}" && {
40  DEBUG="@DEBUG@"
41}
42
43##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
44##       Here we set flags for well know programs         ##
45##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
46##
47## Do not set variable JARFLAGS here, just use it's sister
48## variable 'jarflags'. This  allows  the call to override
49## this settings - see handling of JARFLAGS below.
50
51case "${jar}" in
52  jar)
53    jarflags="cf"
54    ;;
55  *)
56    jarflags="cf"
57    ;;
58esac
59
60##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
61## **NO CHANGE NECESSARY BELOW THIS LINE - EXPERTS ONLY** ##
62##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
63
64
65## If specific flags have been configured then they overrule
66## our precomputed flags. Still a user can override by using
67## environment variable $JARFLAGS - see below.
68test -n "@JARFLAGS@" && {
69  set x @JARFLAGS@  ; shift
70  case $1 in
71    +)
72      shift
73      JARFLAGS="${jarflags} $*"
74      ;;
75    -)
76      shift
77      jarflags="$* ${jarflags}"
78      ;;
79    =)
80      shift
81      jarflags="$*"
82      ;;
83    *)
84      if test -z "$1" ; then
85        jarflags="${jarflags}"
86      else
87        jarflags="$*"
88      fi
89      ;;
90  esac
91}
92
93## Regardless what has been configured, a user should always
94## be able to  override  without  the need to reconfigure or
95## change this file. Therefore we check variable $JARFLAGS.
96## In almost all cases the precomputed flags are just ok but
97## some  additional  flags are needed. To support this in an
98## easy way, we check for the very first value. If this val-
99## ue is
100## '+'  -> append content of JARFLAGS to precomputed flags
101## '-'  -> prepend content    -*-
102## '='  -> do not use precomputed flags
103## If none of these characters are given, the behaviour will
104## be the same as if "=" would have been given.
105
106set x ${JARFLAGS}  ; shift
107case $1 in
108  +)
109    shift
110    JARFLAGS="${jarflags} $*"
111    ;;
112  -)
113    shift
114    JARFLAGS="$* ${jarflags}"
115    ;;
116  =)
117    shift
118    JARFLAGS="$*"
119    ;;
120  *)
121    if test -z "$1" ; then
122      JARFLAGS="${jarflags}"
123    else
124      JARFLAGS="$*"
125    fi
126    ;;
127esac
128
129## Any special treatment goes here ..
130case "${jar}" in
131  jar)
132    ;;
133  *)
134    ;;
135esac
136
137##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
138##    This shall be the command to be excuted below       ##
139##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
140
141cmd="${JAR} ${JARFLAGS} ${ARGV}"
142
143##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
144##        standard template to execute a command          ##
145##xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx##
146case "${verbose}" in
147  0|no|nein|non)
148    set x ${ARGV}
149    echo "*** creating $2 .."
150    ;;
151  *)
152    echo $cmd
153    ;;
154esac
155
156$cmd || {
157  rc=$?
158  cat <<EOF
159
160xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
161                      >> E R R O R <<
162============================================================
163
164$cmd
165
166============================================================
167Got an error while trying to execute  command  above.  Error
168messages (if any) must have shown before. The exit code was:
169exit($rc)
170xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
171EOF
172  exit $rc
173}
174exit 0
175