# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

all:V: package

package:V: _obj/$TARG.a

testpackage:V: _test/$TARG.a

pkgdir=$GOROOT/pkg/${GOOS}_$GOARCH

INSTALLFILES= $TARGDIR/$TARG.a

coverage:
	gotest
	6cov -g `{pwd} $O.out | grep -v '_test\.go:'

CLEANFILES= _obj _test _testmain.go *.exe _cgo* *.cgo[12].* test.out build.out

test:
	gotest

testshort:
	gotest -test.short -'test.timeout=120'

bench:
	gotest -'test.bench=.' -'test.run="Do not run tests"'

nuke: clean
	rm -f $TARGDIR/$TARG.a

testpackage-clean:
	rm -f _test/$TARG.a

install: $INSTALLFILES

$TARGDIR/$TARG.a: _obj/$TARG.a
	mkdir $TARGDIR $TARGDIR/$dir
	cp _obj/$TARG.a $target

_go_.$O: $GOFILES $PREREQ
	$GC $GCIMPORTS -o $target $GOFILES

_gotest_.$O: $GOFILES $GOTESTFILES $PREREQ
	$GC $GCIMPORTS -o $target $GOFILES $GOTESTFILES

_obj/$TARG.a: _go_.$O $OFILES
	mkdir _obj _obj/$dir
	rm -f _obj/$TARG.a
	gopack grc $@ _go_.$O $OFILES

_test/$TARG.a: _gotest_.$O $OFILES
	mkdir _test _test/$dir
	rm -f _test/$TARG.a
	gopack grc $@ _gotest_.$O $OFILES

# Generic build rules.
&.$O: &.c $HFILES
	$CC $CFLAGS $stem.c

(asm|memmove|vlop).$O:R: $GOARCH/\1.s
	$AS $GOARCH/\1.s

(atomic|closure|vlrt).$O:R: $GOARCH/\1.c
	$CC $CFLAGS $GOARCH/\1.c
