test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / java-extra.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Check use of EXTRA with the JAVA primary.  Also test interaction
18 # of JAVA with conditionals (it's natural to test it here, since
19 # EXTRA_JAVA exists mostly for ensuring interoperation with Automake
20 # conditionals).
21
22 required=javac
23 . test-init.sh
24
25 cat >> configure.ac << 'END'
26 AM_CONDITIONAL([COND], [test x"$cond" = x"yes"])
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am << 'END'
31 javadir = $(pkgdatadir)/java
32
33 EXTRA_JAVA = Class1.java Class2.java Class3.java
34
35 java_JAVA = Class1.java
36
37 if COND
38 java_JAVA += Class2.java
39 else !COND
40 java_JAVA += Class3.java
41 endif !COND
42
43 Class3.java: Makefile
44         echo 'class Class3 {}' > $@
45 CLEANFILES = Class3.java
46 END
47
48 echo "class Class1 {}" > Class1.java
49 echo "class Class2 {}" > Class2.java
50
51 $ACLOCAL
52 $AUTOCONF
53 $AUTOMAKE
54
55 ./configure cond=yes
56 $MAKE
57 ls -l
58 test -f Class1.class
59 test -f Class2.class
60 test ! -e Class3.class
61 test ! -e Class3.java
62
63 $MAKE distclean
64
65 ./configure cond=no
66 $MAKE
67 ls -l
68 test -f Class1.class
69 test ! -e Class2.class
70 test -f Class3.class
71 test -f Class3.java
72
73 :