mkmulti 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/rc
  2. targ=multi
  3. n=0
  4. dir=`{pwd}
  5. fn grab {
  6. echo using $*
  7. for(i){
  8. n=`{echo 1+$n|hoc}
  9. mv $i $dir/a.$n.8
  10. }
  11. }
  12. fn getfiles {
  13. sed -n 's/^(pcc|8\^l|8l) +(-o [^ ]* +)?([^\-].*)/ \3/p' | sed 's/ -[^ ]*//g' |
  14. sed 's/ [^ ]*\.a//g'
  15. }
  16. rm a.*.8
  17. >multi.h
  18. >multiproto.h
  19. for(i){
  20. echo $i...
  21. b=`{basename $i}
  22. p=$b
  23. if(~ $b [0-9]*)
  24. p=_$b
  25. echo void $p^_main'(int, char**);' >>$dir/multiproto.h
  26. echo "$b", $p^_main, >>$dir/multi.h
  27. d=`{basename -d $i}
  28. if(~ $i disk/prep disk/fdisk){
  29. cd /sys/src/cmd/disk/prep
  30. rm 8.$b
  31. files=`{mk 8.$b | getfiles}
  32. }
  33. if not if(test -d /sys/src/cmd/$i && @{cd /sys/src/cmd/$i && mk 8.out}){
  34. cd /sys/src/cmd/$i
  35. rm 8.out
  36. files=`{mk 8.out | getfiles}
  37. }
  38. if not if(test -d /sys/src/cmd/$i && @{cd /sys/src/cmd/$i && mk 8.$b}){
  39. cd /sys/src/cmd/$i
  40. rm 8.out
  41. files=`{mk 8.$b | getfiles}
  42. }
  43. if not if(test -d /sys/src/cmd/$d && @{cd /sys/src/cmd/$d && mk 8.$b}){
  44. cd /sys/src/cmd/$d
  45. rm 8.$b
  46. files=`{mk 8.$b | getfiles}
  47. }
  48. if not{
  49. echo do not know how to make $i
  50. exit oops
  51. }
  52. aux/8prefix $p^_ $files
  53. grab $files
  54. switch(`{pwd}){
  55. case /sys/src/cmd /sys/src/cmd/aux /sys/src/cmd/ip
  56. rm 8.$b
  57. case *
  58. mk clean
  59. }
  60. }
  61. cd $dir
  62. 8c -FVw multi.c
  63. 8l -o 8.$targ multi.8 a.*.8
  64. # rm a.*.8