ROOT= /go
<$ROOT/$objtype/mkfile

LIB=\
	gc.a\

HFILES=\
	go.h\
	y.tab.h\
	md5.h\
	opnames.h\

YFILES=\
	go.y\

OFILES=\
	align.$O\
	bits.$O\
	builtin.$O\
	closure.$O\
	const.$O\
	dcl.$O\
	esc.$O\
	export.$O\
	fmt.$O\
	gen.$O\
	init.$O\
	lex.$O\
	md5.$O\
	mparith1.$O\
	mparith2.$O\
	mparith3.$O\
	obj.$O\
	range.$O\
	reflect.$O\
	select.$O\
	sinit.$O\
	subr.$O\
	swt.$O\
	typecheck.$O\
	unsafe.$O\
	walk.$O\
	y1.tab.$O\

fake:V:
	cp y.tab.c.bison y.tab.c
	cp y.tab.h.bison y.tab.h

</sys/src/cmd/mklib

CFLAGS= -I$ROOT/include -I$ROOT/$objtype/include -D'GOEXPERIMENT=""' $CFLAGS
YFLAGS= $YFLAGS -D1 -v

install:V:	$LIB$O

y1.tab.$O:	y1.tab.c
	$CC -p -+ -D__STDC__ -D'YYSIZE_T=unsigned long' -D'lint=""' $CFLAGS -o $target y1.tab.c

y1.tab.c: y.tab.c	# make yystate global, yytname mutable
	sed '/ int yystate;/d; s/int yychar;/int yychar, yystate;/; s/static const char \*const yytname/const char *yytname/; s/char const \*yymsgp/char *yymsgp/' <y.tab.c >y1.tab.c

dcl.$O:	dcl.c y.tab.h
	$CC -p -+ $CFLAGS -o $target dcl.c

export.$O:	export.c y.tab.h
	$CC -p -+ $CFLAGS -o $target export.c

lex.$O: lex.c y.tab.h
	$CC -p -+ $CFLAGS -o $target lex.c

subr.$O:	subr.c y.tab.h yerr.h
	$CC -p -+ $CFLAGS -o $target subr.c

fmt.$O:	opnames.h

yerr.h: yaccerrors go.errors y.tab.h	# y.tab.h rule generates y.output too
	cp yerr.h.boot yerr.h
	# awk -f yaccerrors y.output go.errors >yerr.h

builtin.c: builtin.c.boot
	cp builtin.c.boot builtin.c

mkbuiltin1: mkbuiltin1.$O
	$LD -o $target $prereq

opnames.h:	mkopnames.rc go.h
	chmod o-w mkopnames.rc
	chmod +x mkopnames.rc
	./mkopnames.rc go.h >opnames.h

$LIB$O:	$LIBOBJ
	ar vu $LIB$O $OFILES

CLEANFILES= y[12].tab.c yerr.h mkbuiltin1 builtin.c _builtin.c opnames.h $LIB
