Update from GNU gettext 0.15. Accept source and target versions.
[gnulib.git] / build-aux / javacomp.sh.in
1 #!/bin/sh
2 # Compile a Java program.
3
4 # Copyright (C) 2001-2002, 2006 Free Software Foundation, Inc.
5 # Written by Bruno Haible <haible@clisp.cons.org>, 2001.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21 # This uses the same choices as javacomp.c, but instead of relying on the
22 # environment settings at run time, it uses the environment variables
23 # present at configuration time.
24 #
25 # This is a separate shell script, because it must be able to unset JAVA_HOME
26 # in some cases, which a simple shell command cannot do.
27 #
28 # The extra CLASSPATH must have been set prior to calling this script.
29 # Options that can be passed are -O, -g and "-d DIRECTORY".
30
31 CONF_JAVAC='@CONF_JAVAC@'
32 CONF_CLASSPATH='@CLASSPATH@'
33 if test -n "@HAVE_JAVAC_ENVVAR@"; then
34   # Combine given CLASSPATH and configured CLASSPATH.
35   if test -n "$CLASSPATH"; then
36     CLASSPATH="$CLASSPATH${CONF_CLASSPATH:+@CLASSPATH_SEPARATOR@$CONF_CLASSPATH}"
37   else
38     CLASSPATH="$CONF_CLASSPATH"
39   fi
40   export CLASSPATH
41   test -z "$JAVA_VERBOSE" || echo "$CONF_JAVAC $@"
42   exec $CONF_JAVAC "$@"
43 else
44   unset JAVA_HOME
45   if test -n "@HAVE_GCJ_C@"; then
46     # In this case, $CONF_JAVAC starts with "gcj -C".
47     CLASSPATH="$CLASSPATH"
48     export CLASSPATH
49     test -z "$JAVA_VERBOSE" || echo "$CONF_JAVAC $@"
50     exec $CONF_JAVAC "$@"
51   else
52     if test -n "@HAVE_JAVAC@"; then
53       # In this case, $CONF_JAVAC starts with "javac".
54       CLASSPATH="$CLASSPATH"
55       export CLASSPATH
56       test -z "$JAVA_VERBOSE" || echo "$CONF_JAVAC $@"
57       exec $CONF_JAVAC "$@"
58     else
59       if test -n "@HAVE_JIKES@"; then
60         # In this case, $CONF_JAVAC starts with "jikes".
61         # Combine given CLASSPATH and configured CLASSPATH.
62         if test -n "$CLASSPATH"; then
63           CLASSPATH="$CLASSPATH${CONF_CLASSPATH:+@CLASSPATH_SEPARATOR@$CONF_CLASSPATH}"
64         else
65           CLASSPATH="$CONF_CLASSPATH"
66         fi
67         export CLASSPATH
68         test -z "$JAVA_VERBOSE" || echo "$CONF_JAVAC $@"
69         exec $CONF_JAVAC "$@"
70       else
71         echo 'Java compiler not found, try installing gcj or set $JAVAC, then reconfigure' 1>&2
72         exit 1
73       fi
74     fi
75   fi
76 fi