146439007SCharles.Forsyth#!/bin/sh 246439007SCharles.Forsyth 346439007SCharles.Forsyth# this file is used only to bootstrap mk onto a platform 446439007SCharles.Forsyth# that currently lacks a binary for mk. after that, mk can 546439007SCharles.Forsyth# look after itself. 646439007SCharles.Forsyth 746439007SCharles.Forsyth# support@vitanuova.com 846439007SCharles.Forsyth 9b26197beSCharles.Forsyth# change these defines as appropriate here or in mkconfig 1046439007SCharles.Forsyth# ROOT should be the root of the Inferno tree 1146439007SCharles.ForsythROOT=/usr/inferno 1246439007SCharles.ForsythSYSTARG=FreeBSD 1346439007SCharles.ForsythOBJTYPE=386 1446439007SCharles.ForsythSYSTYPE=posix 15b26197beSCharles.Forsyth 16b26197beSCharles.Forsyth# if you have already changed mkconfig from the distribution, we'll use the definitions from that 17b26197beSCharles.Forsythgrep -s 'SYSTARG=Plan9' mkconfig || . ./mkconfig 18b26197beSCharles.Forsyth 1946439007SCharles.ForsythPLAT=$ROOT/$SYSTARG/$OBJTYPE 20b26197beSCharles.Forsyth 21b26197beSCharles.Forsyth# you might need to adjust the CC, LD, AR, and RANLIB definitions after this point 22*00f00efcSPaul BoddieCC="p gcc -c -I$PLAT/include -I$ROOT/include -I$ROOT/utils/include" 23*00f00efcSPaul BoddieLD="p gcc" 2446439007SCharles.ForsythAR="p ar crvs" 2546439007SCharles.ForsythRANLIB=":" # some systems still require `ranlib' 2646439007SCharles.Forsyth 2746439007SCharles.Forsytherror() { 2846439007SCharles.Forsyth echo $* >&2 2946439007SCharles.Forsyth exit 1 3046439007SCharles.Forsyth} 3146439007SCharles.Forsyth 3246439007SCharles.Forsythofiles() { 3346439007SCharles.Forsyth echo $* | sed 's/\.c/.o/g' 3446439007SCharles.Forsyth} 3546439007SCharles.Forsyth 3646439007SCharles.Forsythp() { 3746439007SCharles.Forsyth echo $* 3846439007SCharles.Forsyth "$@" 3946439007SCharles.Forsyth} 4046439007SCharles.Forsyth 4146439007SCharles.Forsyth# make sure we start off clean 4246439007SCharles.Forsythecho removing old libraries and binaries 4346439007SCharles.Forsythrm -f $PLAT/lib/*.a $PLAT/bin/* 4446439007SCharles.Forsythrm -f utils/cc/y.tab.? 4546439007SCharles.Forsyth 46af48bc57Sforsyth# ensure the output directories exist 47af48bc57Sforsythmkdir -p $PLAT/lib $PLAT/bin 48af48bc57Sforsyth 4946439007SCharles.Forsyth# libregexp 5046439007SCharles.Forsythcd $ROOT/utils/libregexp || error cannot find libregexp directory 5146439007SCharles.ForsythCFILES="regaux.c regcomp.c regerror.c regexec.c regsub.c rregexec.c rregsub.c" 5246439007SCharles.Forsyth$CC $CFILES || error libregexp compilation failed 5346439007SCharles.Forsyth$AR $PLAT/lib/libregexp.a `ofiles $CFILES` || error libregexp ar failed 5446439007SCharles.Forsyth$RANLIB $PLAT/lib/libregexp.a || error libregexp ranlib failed 5546439007SCharles.Forsyth 5646439007SCharles.Forsyth# libbio 5746439007SCharles.Forsythcd $ROOT/libbio || error cannot find libbio directory 5846439007SCharles.Forsyth$CC *.c || error libbio compilation failed 5946439007SCharles.Forsyth$AR $PLAT/lib/libbio.a *.o || error libbio ar failed 6046439007SCharles.Forsyth$RANLIB $PLAT/lib/libbio.a || error libbio ranlib failed 6146439007SCharles.Forsyth 6246439007SCharles.Forsyth# lib9 6346439007SCharles.Forsythcd $ROOT/lib9 || error cannot find lib9 directory 6446439007SCharles.ForsythCFILES="dirstat-$SYSTYPE.c rerrstr.c errstr-$SYSTYPE.c getuser-$SYSTYPE.c" # system specific 6546439007SCharles.ForsythCFILES="$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" 6646439007SCharles.Forsyth$CC $CFILES || error lib9 compilation failed 6746439007SCharles.Forsyth$AR $PLAT/lib/lib9.a `ofiles $CFILES` || error lib9 ar failed 6846439007SCharles.Forsyth$RANLIB $PLAT/lib/lib9.a || error lib9 ranlib failed 6946439007SCharles.Forsyth 7046439007SCharles.Forsyth# mk itself 7146439007SCharles.Forsythcd $ROOT/utils/mk 7246439007SCharles.ForsythCFILES="Posix.c sh.c" # system specific 7346439007SCharles.ForsythCFILES="$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" 7446439007SCharles.Forsyth$CC $CFILES || error mk compilation failed 7546439007SCharles.Forsyth$LD -o mk `ofiles $CFILES` $PLAT/lib/libregexp.a $PLAT/lib/libbio.a $PLAT/lib/lib9.a || error mk link failed 7646439007SCharles.Forsythcp mk $PLAT/bin || error mk binary install failed 7746439007SCharles.Forsyth 7846439007SCharles.Forsythecho mk binary built successfully! 79