xref: /inferno-os/makemk-AIX.sh (revision 0195c4e25fc394097552c7f5ebf3085ec2d201f5)
1#!/bin/sh
2
3# this file is used only to bootstrap mk onto a platform
4# that currently lacks a binary for mk.  after that, mk can
5# look after itself.
6
7#	support@vitanuova.com
8
9# change these defines as appropriate here or in mkconfig
10# ROOT should be the root of the Inferno tree
11ROOT=/usr/inferno
12SYSTARG=AIX
13OBJTYPE=power
14SYSTYPE=posix
15
16# if you have already changed mkconfig from the distribution, we'll use the definitions from that
17grep -s 'SYSTARG=Plan9' mkconfig || . ./mkconfig
18
19PLAT=$ROOT/$SYSTARG/$OBJTYPE
20
21# you might need to adjust the CC, LD, AR, and RANLIB definitions after this point
22CC="p xlc -g -O -qsuppress=1506-224 -c -I$PLAT/include -I$ROOT/include -I$ROOT/utils/include"
23LD="p xlc"
24AR="p ar crvs"
25RANLIB=":"	# some systems still require `ranlib'
26
27error() {
28	echo $* >&2
29	exit 1
30}
31
32ofiles() {
33	echo $* | sed 's/\.c/.o/g'
34}
35
36p() {
37	echo $*
38	"$@"
39}
40
41# make sure we start off clean
42echo removing old libraries and binaries
43rm -f $PLAT/lib/*.a $PLAT/bin/*
44rm -f utils/cc/y.tab.?
45
46# ensure the output directories exist
47mkdir -p $PLAT/lib $PLAT/bin
48
49# libregexp
50cd $ROOT/utils/libregexp || error cannot find libregexp directory
51CFILES="regaux.c regcomp.c regerror.c regexec.c regsub.c rregexec.c rregsub.c"
52$CC $CFILES || error libregexp compilation failed
53$AR $PLAT/lib/libregexp.a `ofiles $CFILES` || error libregexp ar failed
54$RANLIB $PLAT/lib/libregexp.a || error libregexp ranlib failed
55
56# libbio
57cd $ROOT/libbio || error cannot find libbio directory
58$CC *.c || error libbio compilation failed
59$AR $PLAT/lib/libbio.a *.o || error libbio ar failed
60$RANLIB $PLAT/lib/libbio.a || error libbio ranlib failed
61
62# lib9
63cd $ROOT/lib9 || error cannot find lib9 directory
64CFILES="dirstat-$SYSTYPE.c rerrstr.c errstr-$SYSTYPE.c getuser-$SYSTYPE.c"	# system specific
65CFILES="$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"
66$CC $CFILES || error lib9 compilation failed
67$AR $PLAT/lib/lib9.a `ofiles $CFILES` || error lib9 ar failed
68$RANLIB $PLAT/lib/lib9.a || error lib9 ranlib failed
69
70# mk itself
71cd $ROOT/utils/mk
72CFILES="Posix.c sh.c"	# system specific
73CFILES="$CFILES arc.c archive-AIX.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"
74$CC $CFILES || error mk compilation failed
75$LD -o mk `ofiles $CFILES` $PLAT/lib/libregexp.a $PLAT/lib/libbio.a $PLAT/lib/lib9.a || error mk link failed
76cp mk $PLAT/bin || error mk binary install failed
77
78echo mk binary built successfully!
79