Merged gcj-eclipse branch to trunk.
[official-gcc.git] / libjava / classpath / lib / gen-classlist.sh.in
blob1c704116b1979e29f6140b4c752bd3c4f7451759
1 #! @SHELL@
2 # @configure_input@
4 # Make sure sorting is done the same on all configurations
5 # Note the use of sort -r below. This is done explicitly to work around
6 # a gcj bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21418)
7 LC_ALL=C; export LC_ALL
8 LANG=C; export LANG
10 echo "Adding java source files from srcdir '@top_srcdir@'."
11 # We construct 'classes.1' as a series of lines. Each line
12 # has three fields, which are separated by spaces. The first
13 # field is the package of this class (separated by "/"s).
14 # The second field is the name of the top-level directory for
15 # this file, relative to the build directory. E.g., it might
16 # look like "../../classpath/vm/reference".
17 # The third field is the file name, like "java/lang/Object.java".
18 # We do this because it makes splitting for the gcj build much
19 # cheaper.
20 (cd @top_srcdir@
21 @FIND@ java javax gnu org sun -follow -name '*.java' -print |
22 sort -r | sed -e 's,/\([^/]*\)$, \1,' |
23 while read pkg file; do
24 echo $pkg @top_srcdir@ $pkg/$file
25 done) > ${top_builddir}/lib/classes.1
27 # The same, but for the external code.
28 for dir in \
29 @top_srcdir@/external/w3c_dom \
30 @top_srcdir@/external/sax \
31 @top_srcdir@/external/relaxngDatatype \
32 @top_srcdir@/external/jsr166 \
33 ; do
34 (cd $dir
35 for subdir in java javax gnu org sun; do
36 if test -d $subdir; then
37 @FIND@ $subdir -follow -name '*.java' -print |
38 sort -r | sed -e 's,/\([^/]*\)$, \1,' |
39 while read pkg file; do
40 echo $pkg $dir $pkg/$file
41 done
43 done)
44 done >> ${top_builddir}/lib/classes.1
46 # Generate files for the VM classes.
47 : > vm.omit
48 : > vm.add
49 vm_dirlist=`echo "@vm_classes@" | sed -e 's/:/ /g'`
50 for dir in $vm_dirlist; do
51 echo "Adding java source files from VM directory $dir"
52 (cd $dir
53 for subdir in java javax gnu org com sun; do
54 if test -d $subdir; then
55 @FIND@ $subdir -name '*.java' -print
57 done) | sed -e 's,/\([^/]*\)$, \1,' |
58 while read pkg file; do
59 echo $pkg $dir $pkg/$file >> vm.add
60 echo $pkg/$file >> vm.omit
61 done
62 done
64 # Only include generated files once.
65 abs_top_builddir=`cd "${top_builddir}"; pwd`
66 abs_top_srcdir=`cd "@top_srcdir@"; pwd`
67 if test "$abs_top_builddir" != "$abs_top_srcdir"; then
68 echo "Adding generated files in builddir '${top_builddir}'."
69 # Currently the only generated files are in gnu.*.
70 (cd ${top_builddir}; @FIND@ gnu -follow -name '*.java' -print) |
71 sort | sed -e 's,/\([^/]*\)$, \1,' |
72 while read pkg file; do
73 echo $pkg $top_builddir $pkg/$file
74 done >> ${top_builddir}/lib/classes.1
78 cat $1.omit vm.omit > tmp.omit
79 for dir in $vm_dirlist; do
80 if test -f $dir/$1.omit; then
81 cat $dir/$1.omit >> tmp.omit
83 done
85 # FIXME: could be more efficient by constructing a series of greps.
86 for filexp in `cat tmp.omit`; do
87 grep -v ${filexp} < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.tmp
88 mv ${top_builddir}/lib/classes.tmp ${top_builddir}/lib/classes.1
89 done
92 for dir in $vm_dirlist; do
93 if test -f $dir/$1.omit; then
94 for filexp in `cat $dir/$1.omit`; do
95 grep -v $filexp < vm.add > vm.add.1
96 mv vm.add.1 vm.add
97 done
99 done
100 cat vm.add >> classes.1
102 rm vm.omit
103 rm vm.add
104 rm tmp.omit
106 new=
107 if test -f ${top_builddir}/lib/classes.2; then
108 p=`diff ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1`
109 if test "$p" != ""; then
110 new="true"
112 else
113 new="true"
116 if test "$new" = "true"; then
117 cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes.2
118 # Strip the package part.
119 sed -e 's/^[^ ]* //' -e 's, ,/,' < ${top_builddir}/lib/classes.1 \
120 > ${top_builddir}/lib/classes
121 echo "JAVA_SRCS = \\" > ${top_builddir}/lib/java.dep
122 for i in `cat ${top_builddir}/lib/classes` ; do
123 echo $i "\\" >> ${top_builddir}/lib/java.dep
124 done
127 exit 0