OSDN Git Service

aeba9bfad375f069c50fa645ea4b939453cb62cb
[pf3gnuchains/gcc-fork.git] / libjava / classpath / lib / gen-classlist.sh.in
1 #! @SHELL@
2 # @configure_input@
3
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
9
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 -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
26
27 # The same, but for the external code.
28 # Right now all external code is in org/.
29 for dir in @top_srcdir@/external/w3c_dom \
30    @top_srcdir@/external/sax @top_srcdir@/external/relaxngDatatype; do
31   (cd $dir
32   @FIND@ org -follow -name '*.java' -print |
33   sort -r | sed -e 's,/\([^/]*\)$, \1,' |
34   while read pkg file; do
35      echo $pkg $dir $pkg/$file
36   done)
37 done >> ${top_builddir}/lib/classes.1
38
39 # Generate files for the VM classes.
40 : > vm.omit
41 : > vm.add
42 vm_dirlist=`echo "@vm_classes@" | sed -e 's/:/ /g'`
43 for dir in $vm_dirlist; do
44    echo "Adding java source files from VM directory $dir"
45    (cd $dir
46    for subdir in java javax gnu org com; do
47       if test -d $subdir; then
48          @FIND@ $subdir -name '*.java' -print
49       fi
50    done) | sed -e 's,/\([^/]*\)$, \1,' |
51    while read pkg file; do
52       echo $pkg $dir $pkg/$file >> vm.add
53       echo $pkg/$file >> vm.omit
54    done
55 done
56
57 # Only include generated files once.
58 if test ! "${top_builddir}" -ef "@top_srcdir@"; then
59   echo "Adding generated files in builddir '${top_builddir}'."
60   # Currently the only generated files are in gnu.*.
61   (cd ${top_builddir}; @FIND@ gnu -follow -name '*.java' -print) |
62   sort | sed -e 's,/\([^/]*\)$, \1,' |
63   while read pkg file; do
64      echo $pkg $top_builddir $pkg/$file
65   done >> ${top_builddir}/lib/classes.1
66 fi
67
68
69 cat @top_srcdir@/lib/$1.omit vm.omit > tmp.omit
70 for dir in $vm_dirlist; do
71    if test -f $dir/$1.omit; then
72       cat $dir/$1.omit >> tmp.omit
73    fi
74 done
75
76 # FIXME: could be more efficient by constructing a series of greps.
77 for filexp in `cat tmp.omit`; do
78    grep -v ${filexp} < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.tmp
79    mv ${top_builddir}/lib/classes.tmp ${top_builddir}/lib/classes.1
80 done
81
82
83 for dir in $vm_dirlist; do
84    if test -f $dir/$1.omit; then
85       for filexp in `cat $dir/$1.omit`; do
86          grep -v $filexp < vm.add > vm.add.1
87          mv vm.add.1 vm.add
88       done
89    fi
90 done
91 cat vm.add >> classes.1
92
93 rm vm.omit
94 rm vm.add
95 rm tmp.omit
96
97 new=
98 if test -e ${top_builddir}/lib/classes.2; then
99   p=`diff ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1`
100   if test "$p" != ""; then
101     new="true"
102   fi
103 else
104   new="true"
105 fi
106
107 if test "$new" = "true"; then
108   cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes.2
109   # Strip the package part.
110   sed -e 's/^[^ ]* //' -e 's, ,/,' < ${top_builddir}/lib/classes.1 \
111      > ${top_builddir}/lib/classes
112   echo "JAVA_SRCS = \\" > ${top_builddir}/lib/java.dep
113   for i in `cat ${top_builddir}/lib/classes` ; do
114     echo $i "\\" >> ${top_builddir}/lib/java.dep
115   done
116 fi
117
118 exit 0