/lib/gen-classlist.sh.in

https://github.com/penberg/classpath · Autoconf · 153 lines · 114 code · 16 blank · 23 comment · 24 complexity · 3cd607172f963196c629d4dcce0ea74b MD5 · raw file

  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. echo "Adding java source files from VM directory $vm_dirlist"
  49. for dir in $vm_dirlist; do
  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. if test -n "$vm_omitlist"; then
  113. cat $vm_omitlist | sed "$sed_omit_hash" > tmp.awk
  114. cat $vm_omitlist | sed "$sed_omit_main_loop" >> tmp.awk
  115. fi
  116. @AWK@ -f tmp.awk < vm.add >>${top_builddir}/lib/classes.1
  117. rm -f vm.omit vm.add tmp.omit tmp.awk
  118. new=
  119. if test -f ${top_builddir}/lib/classes.2; then
  120. p=`diff ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1`
  121. if test "$p" != ""; then
  122. new="true"
  123. fi
  124. else
  125. new="true"
  126. fi
  127. if test "$new" = "true"; then
  128. cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes.2
  129. # Strip the package part.
  130. sed -e 's/^[^ ]* //' -e 's, ,/,' < ${top_builddir}/lib/classes.1 \
  131. > ${top_builddir}/lib/classes
  132. echo "JAVA_SRCS = \\" > ${top_builddir}/lib/java.dep
  133. for i in `cat ${top_builddir}/lib/classes` ; do
  134. echo $i "\\" >> ${top_builddir}/lib/java.dep
  135. done
  136. fi
  137. exit 0