2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / libjava / classpath / lib / gen-classlist.sh.in
blob1768c15c7fba6034c1eb6998572a0ea391e76bfd
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 # Mangle the omit expressions into a script suitable for old awk.
86 # Exploit the fact that many omissions are not regular expressions:
87 # assume a single file is listed if it does not contain '*', '$',
88 # and ends in '.java'.
89 sed_omit_hash='
90 1i\
91 BEGIN {\
92 omit[""] = 1
93 $a\
95 /[*$]/d
96 /\.java$/!d
97 s|^| omit["|
98 s|$|"] = 1|'
99 sed_omit_main_loop='
102 if (omit[$3]) next
104 print\
106 /^[^*$]*\.java$/d
107 s|/|\\/|g
108 s|^| if ($3 ~ /|
109 s|$|/) next|'
111 sed "$sed_omit_hash" <tmp.omit >tmp.awk
112 sed "$sed_omit_main_loop" <tmp.omit >>tmp.awk
113 @AWK@ -f tmp.awk < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.tmp
114 mv ${top_builddir}/lib/classes.tmp ${top_builddir}/lib/classes.1
116 vm_omitlist=
117 for dir in $vm_dirlist; do
118 if test -f $dir/$1.omit; then
119 vm_omitlist="$vm_omitlist $dir/$1.omit"
121 done
122 cat $vm_omitlist | sed "$sed_omit_hash" > tmp.awk
123 cat $vm_omitlist | sed "$sed_omit_main_loop" >> tmp.awk
124 @AWK@ -f tmp.awk < vm.add >>${top_builddir}/lib/classes.1
126 rm -f vm.omit vm.add tmp.omit tmp.awk
128 new=
129 if test -f ${top_builddir}/lib/classes.2; then
130 p=`diff ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1`
131 if test "$p" != ""; then
132 new="true"
134 else
135 new="true"
138 if test "$new" = "true"; then
139 cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes.2
140 # Strip the package part.
141 sed -e 's/^[^ ]* //' -e 's, ,/,' < ${top_builddir}/lib/classes.1 \
142 > ${top_builddir}/lib/classes
143 echo "JAVA_SRCS = \\" > ${top_builddir}/lib/java.dep
144 for i in `cat ${top_builddir}/lib/classes` ; do
145 echo $i "\\" >> ${top_builddir}/lib/java.dep
146 done
149 exit 0