maint: Update HACKING
[automake.git] / t / java-rebuild.sh
blob3f10a6499038596124dd4cf0c602872d448839d6
1 #! /bin/sh
2 # Copyright (C) 2011-2017 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Test rebuild rules for Java class files.
19 required='javac'
20 . test-init.sh
22 cat >> configure.ac <<'END'
23 AC_OUTPUT
24 END
26 cat > Makefile.am <<'END'
27 AM_JAVACFLAGS = -verbose
28 foodir = $(datadir)/java
29 foo_JAVA = a.java
30 dist_foo_JAVA = d.java
31 nodist_foo_JAVA = n.java
32 nobase_foo_JAVA = Nobase.java
33 nobase_dist_foo_JAVA = NobaseDist.java
34 nobase_nodist_foo_JAVA = NobaseNoDist.java
35 END
37 echo 'class _x {}' > a.java
38 echo 'class x_ {}' > d.java
39 echo 'class a {} class d {}' > n.java
40 echo 'class Nobase_Foo {} class Nobase_Bar {}' > Nobase.java
41 echo 'class NobaseDist {}' > NobaseDist.java
42 echo 'class NobaseNoDist {}' > NobaseNoDist.java
44 $ACLOCAL
45 $AUTOCONF
46 $AUTOMAKE
48 all_classes='_x x_ a d Nobase_Foo Nobase_Bar NobaseDist NobaseNoDist'
50 for vpath in : false; do
52 if $vpath; then
53 srcdir=..
54 mkdir build
55 cd build
56 else
57 srcdir=.
60 $srcdir/configure
61 $MAKE
62 ls -l # For debugging.
64 # Sanity check.
65 test -f classfoo.stamp
66 for cls in $all_classes; do
67 test -f $cls.class
68 done
70 # When the stampfile is removed, all the *.class files should
71 # be considered out-of-date.
72 echo timestamp > older
73 $sleep
74 rm -f classfoo.stamp
75 $MAKE
76 for cls in $all_classes; do
77 is_newest $cls.class older
78 done
80 # When only a java file is modified, only the *.class files derived from
81 # it should be updated.
82 # The strings we loop on here have the following format:
83 # "JAVA-FILES-TO-BE-TOUCHED -- CLASSES-THAT-SHOULD-BE-UPDATED"
84 for args in \
85 'a -- _x' \
86 'd -- x_' \
87 'n -- a d' \
88 'a d Nobase -- _x x_ Nobase_Foo Nobase_Bar' \
89 'n NobaseDist -- a d NobaseDist' \
90 'd NobaseNoDist -- x_ NobaseNoDist' \
91 "a d n Nobase NobaseDist NobaseNoDist -- $all_classes" \
92 ; do
93 set $args
94 touched_javas=
95 while test $# -gt 0; do
96 if test x"$1" = x"--"; then
97 shift
98 break
99 else
100 touched_javas="$touched_javas $1"
101 shift
103 done
104 updated_classes=$*
105 echo timestamp > older
106 $sleep
107 for j in $touched_javas; do
108 touch $srcdir/$j.java
109 done
110 $MAKE
111 is_newest classfoo.stamp older
112 for cls in $all_classes; do
113 case " $updated_classes " in
114 *" $cls "*) is_newest $cls.class older;;
115 *) is_newest older $cls.class;;
116 esac
117 done
118 done # $args ...
120 cd $srcdir
122 done # $vpath ...