split-for-gcj.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #! /bin/sh
  2. # This script is used when compiling Classpath with gcj. The idea is
  3. # to compile one package at a time, and only recompile packages when
  4. # actually required.
  5. # We build java->class by package so we need to know what .java files
  6. # correspond to what package.
  7. # We have a .stamp file for each package; this is the makefile target.
  8. # We also have a .list file for each package, which lists all the
  9. # input files in that package.
  10. # gen-classlist.sh makes a list of all the .java files we are going to compile.
  11. # This script generates Makefile.deps, which looks like this:
  12. #
  13. # java/awt/AWTUtilities.class: lists/java-awt.stamp
  14. # lists/java-awt.list: /home/aph/gcc/gcc/libjava/classpath/gnu/java/awt/AWTUtilities.java
  15. # java/awt/BitMaskExtent.class: lists/java-awt.stamp
  16. # lists/java-awt.list: /home/aph/gcc/gcc/libjava/classpath/gnu/java/awt/BitMaskExtent.java
  17. # java/awt/BitwiseXORComposite.class: lists/java-awt.stamp
  18. # lists/java-awt.list: /home/aph/gcc/gcc/libjava/classpath/gnu/java/awt/BitwiseXORComposite.java
  19. echo "Splitting for gcj"
  20. rm -f Makefile.dtmp > /dev/null 2>&1
  21. test -d lists || mkdir lists
  22. # Much more efficient to do processing outside the loop...
  23. # The first expression computes the .class file name.
  24. # We only want the first three package components, and
  25. # we want them separated by '-'; this is the remaining expressions.
  26. sed -e 's, \(.*\)[.]java$, \1.java \1.class,' \
  27. -e 's,^\([^/ ]*\)/\([^/ ]*\) ,\1-\2 ,' \
  28. -e 's,^\([^/ ]*\)/\([^/ ]*\)/\([^/ ]*\) ,\1-\2-\3 ,' \
  29. -e 's,^\([^/ ]*\)/\([^/ ]*\)/\([^/ ]*\)/[^ ]* ,\1-\2-\3 ,' \
  30. classes.2 |
  31. while read pkg dir file f2; do
  32. list=lists/$pkg
  33. echo "$dir/$file" >> ${list}.list.1
  34. echo "$f2: ${list}.stamp" >> Makefile.dtmp
  35. echo "${list}.list: $dir/$file" >> Makefile.dtmp
  36. done
  37. # Only update a .list file if it changed.
  38. for file in lists/*.list.1; do
  39. real=`echo "$file" | sed -e 's/.1$//'`
  40. if cmp -s $real $file; then
  41. rm $file
  42. else
  43. mv $file $real
  44. fi
  45. done
  46. # If we were run we must update Makefile.deps.
  47. mv Makefile.dtmp Makefile.deps