gen-classlist.sh.in 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #! @SHELL@
  2. # @configure_input@
  3. # Make sure sorting is done the same on all configurations
  4. # Note the use of sort -r below. This is done explicitly to work around
  5. # a gcj bug (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21418)
  6. LC_ALL=C; export LC_ALL
  7. LANG=C; export LANG
  8. abs_top_builddir=`cd "${top_builddir}"; pwd`
  9. abs_top_srcdir=`cd "@top_srcdir@"; pwd`
  10. echo "Adding java source files from srcdir '${abs_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 absolute pathname of the top-level directory
  15. # for this file. E.g., it might look like
  16. # "/home/jezebel/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 ${abs_top_srcdir} $pkg/$file
  25. done) > ${top_builddir}/lib/classes.1
  26. # The same, but for the external code.
  27. for dir in \
  28. ${abs_top_srcdir}/external/w3c_dom \
  29. ${abs_top_srcdir}/external/sax \
  30. ${abs_top_srcdir}/external/relaxngDatatype \
  31. ${abs_top_srcdir}/external/jsr166 \
  32. ; do
  33. (cd $dir
  34. for subdir in java javax gnu org sun; do
  35. if test -d $subdir; then
  36. @FIND@ $subdir -follow -name '*.java' -print |
  37. sort -r | sed -e 's,/\([^/]*\)$, \1,' |
  38. while read pkg file; do
  39. echo $pkg $dir $pkg/$file
  40. done
  41. fi
  42. done)
  43. done >> ${top_builddir}/lib/classes.1
  44. # Generate files for the VM classes.
  45. : > vm.omit
  46. : > vm.add
  47. vm_dirlist=`echo "@vm_classes@" | sed -e 's/:/ /g'`
  48. for dir in $vm_dirlist; do
  49. echo "Adding java source files from VM directory $dir"
  50. (cd $dir
  51. for subdir in java javax gnu org com sun; do
  52. if test -d $subdir; then
  53. @FIND@ $subdir -name '*.java' -print
  54. fi
  55. done) | sed -e 's,/\([^/]*\)$, \1,' |
  56. while read pkg file; do
  57. echo $pkg $dir $pkg/$file >> vm.add
  58. echo $pkg/$file >> vm.omit
  59. done
  60. done
  61. # Only include generated files once.
  62. if test "$abs_top_builddir" != "$abs_top_srcdir"; then
  63. echo "Adding generated files in builddir '${top_builddir}'."
  64. # Currently the only generated files are in gnu.*.
  65. (cd ${top_builddir}; @FIND@ gnu -follow -name '*.java' -print) |
  66. sort | sed -e 's,/\([^/]*\)$, \1,' |
  67. while read pkg file; do
  68. echo $pkg $top_builddir $pkg/$file
  69. done >> ${top_builddir}/lib/classes.1
  70. fi
  71. cat $1.omit vm.omit > tmp.omit
  72. for dir in $vm_dirlist; do
  73. if test -f $dir/$1.omit; then
  74. cat $dir/$1.omit >> tmp.omit
  75. fi
  76. done
  77. # Mangle the omit expressions into a script suitable for old awk.
  78. # Exploit the fact that many omissions are not regular expressions:
  79. # assume a single file is listed if it does not contain '*', '$',
  80. # and ends in '.java'.
  81. sed_omit_hash='
  82. 1i\
  83. BEGIN {\
  84. omit[""] = 1
  85. $a\
  86. }
  87. /[*$]/d
  88. /\.java$/!d
  89. s|^| omit["|
  90. s|$|"] = 1|'
  91. sed_omit_main_loop='
  92. 1i\
  93. {\
  94. if (omit[$3]) next
  95. $a\
  96. print\
  97. }
  98. /^[^*$]*\.java$/d
  99. s|/|\\/|g
  100. s|^| if ($3 ~ /|
  101. s|$|/) next|'
  102. sed "$sed_omit_hash" <tmp.omit >tmp.awk
  103. sed "$sed_omit_main_loop" <tmp.omit >>tmp.awk
  104. @AWK@ -f tmp.awk < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.tmp
  105. mv ${top_builddir}/lib/classes.tmp ${top_builddir}/lib/classes.1
  106. vm_omitlist=
  107. for dir in $vm_dirlist; do
  108. if test -f $dir/$1.omit; then
  109. vm_omitlist="$vm_omitlist $dir/$1.omit"
  110. fi
  111. done
  112. cat $vm_omitlist | sed "$sed_omit_hash" > tmp.awk
  113. cat $vm_omitlist | sed "$sed_omit_main_loop" >> tmp.awk
  114. @AWK@ -f tmp.awk < vm.add >>${top_builddir}/lib/classes.1
  115. rm -f vm.omit vm.add tmp.omit tmp.awk
  116. new=
  117. if test -f ${top_builddir}/lib/classes.2; then
  118. p=`diff ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1`
  119. if test "$p" != ""; then
  120. new="true"
  121. fi
  122. else
  123. new="true"
  124. fi
  125. if test "$new" = "true"; then
  126. cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes.2
  127. # Strip the package part.
  128. sed -e 's/^[^ ]* //' -e 's, ,/,' < ${top_builddir}/lib/classes.1 \
  129. > ${top_builddir}/lib/classes
  130. echo "JAVA_SRCS = \\" > ${top_builddir}/lib/java.dep
  131. for i in `cat ${top_builddir}/lib/classes` ; do
  132. echo $i "\\" >> ${top_builddir}/lib/java.dep
  133. done
  134. fi
  135. exit 0