makemk.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. # this file is used only to bootstrap mk onto a platform
  3. # that currently lacks a binary for mk. after that, mk can
  4. # look after itself.
  5. # support@vitanuova.com
  6. # change these defines as appropriate here or in mkconfig
  7. # ROOT should be the root of the Inferno tree
  8. ROOT=/usr/inferno
  9. SYSTARG=FreeBSD
  10. OBJTYPE=386
  11. SYSTYPE=posix
  12. # if you have already changed mkconfig from the distribution, we'll use the definitions from that
  13. grep -s 'SYSTARG=Plan9' mkconfig || . ./mkconfig
  14. PLAT=$ROOT/$SYSTARG/$OBJTYPE
  15. # you might need to adjust the CC, LD, AR, and RANLIB definitions after this point
  16. CC="p gcc -m32 -c -I$PLAT/include -I$ROOT/include -I$ROOT/utils/include"
  17. LD="p gcc -m32"
  18. AR="p ar crvs"
  19. RANLIB=":" # some systems still require `ranlib'
  20. error() {
  21. echo $* >&2
  22. exit 1
  23. }
  24. ofiles() {
  25. echo $* | sed 's/\.c/.o/g'
  26. }
  27. p() {
  28. echo $*
  29. "$@"
  30. }
  31. # make sure we start off clean
  32. echo removing old libraries and binaries
  33. rm -f $PLAT/lib/*.a $PLAT/bin/*
  34. rm -f utils/cc/y.tab.?
  35. # ensure the output directories exist
  36. mkdir -p $PLAT/lib $PLAT/bin
  37. # libregexp
  38. cd $ROOT/utils/libregexp || error cannot find libregexp directory
  39. CFILES="regaux.c regcomp.c regerror.c regexec.c regsub.c rregexec.c rregsub.c"
  40. $CC $CFILES || error libregexp compilation failed
  41. $AR $PLAT/lib/libregexp.a `ofiles $CFILES` || error libregexp ar failed
  42. $RANLIB $PLAT/lib/libregexp.a || error libregexp ranlib failed
  43. # libbio
  44. cd $ROOT/libbio || error cannot find libbio directory
  45. $CC *.c || error libbio compilation failed
  46. $AR $PLAT/lib/libbio.a *.o || error libbio ar failed
  47. $RANLIB $PLAT/lib/libbio.a || error libbio ranlib failed
  48. # lib9
  49. cd $ROOT/lib9 || error cannot find lib9 directory
  50. CFILES="dirstat-$SYSTYPE.c rerrstr.c errstr-$SYSTYPE.c getuser-$SYSTYPE.c" # system specific
  51. CFILES="$CFILES charstod.c cleanname.c create.c dirwstat.c *print*.c *fmt*.c exits.c getfields.c pow10.c print.c qsort.c rune.c runestrlen.c seek.c strdup.c strtoll.c utflen.c utfrrune.c utfrune.c utf*.c *str*cpy*.c"
  52. $CC $CFILES || error lib9 compilation failed
  53. $AR $PLAT/lib/lib9.a `ofiles $CFILES` || error lib9 ar failed
  54. $RANLIB $PLAT/lib/lib9.a || error lib9 ranlib failed
  55. # mk itself
  56. cd $ROOT/utils/mk
  57. CFILES="Posix.c sh.c" # system specific
  58. CFILES="$CFILES arc.c archive.c bufblock.c env.c file.c graph.c job.c lex.c main.c match.c mk.c parse.c recipe.c rule.c run.c shprint.c symtab.c var.c varsub.c word.c"
  59. $CC $CFILES || error mk compilation failed
  60. $LD -o mk `ofiles $CFILES` $PLAT/lib/libregexp.a $PLAT/lib/libbio.a $PLAT/lib/lib9.a || error mk link failed
  61. cp mk $PLAT/bin || error mk binary install failed
  62. echo mk binary built successfully!