summaryrefslogtreecommitdiff
path: root/src/make.rc
diff options
context:
space:
mode:
authorAnthony Martin <ality@pbrane.org>2012-05-01 22:32:46 -0700
committerAnthony Martin <ality@pbrane.org>2012-05-01 22:32:46 -0700
commite52cc72dfcc31dbb98e23c75c26509c1ae318335 (patch)
treeb2a9cea0e8ec03e6ef7977d83184529eaac684fe /src/make.rc
parentea5ec22f166b33c54df3ba39faa511bb01eb941e (diff)
downloadgo-e52cc72dfcc31dbb98e23c75c26509c1ae318335.tar.gz
build: dist-based build for Plan 9
R=rsc, iant, iant, seed CC=golang-dev http://codereview.appspot.com/5608059
Diffstat (limited to 'src/make.rc')
-rwxr-xr-xsrc/make.rc91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/make.rc b/src/make.rc
new file mode 100755
index 000000000..986ce8546
--- /dev/null
+++ b/src/make.rc
@@ -0,0 +1,91 @@
+#!/bin/rc -e
+# Copyright 2012 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.
+
+# Environment variables that control make.rc:
+#
+# GOROOT_FINAL: The expected final Go root, baked into binaries.
+# The default is the location of the Go tree during the build.
+#
+# GOHOSTARCH: The architecture for host tools (compilers and
+# binaries). Binaries of this type must be executable on the current
+# system, so the only common reason to set this is to set
+# GOHOSTARCH=386 on an amd64 machine.
+#
+# GOARCH: The target architecture for installed packages and tools.
+#
+# GOOS: The target operating system for installed packages and tools.
+#
+# GO_GCFLAGS: Additional 5g/6g/8g arguments to use when
+# building the packages and commands.
+#
+# GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
+# building the commands.
+#
+# CGO_ENABLED: Setting this to 0 disables the use of cgo
+# in the built and installed packages and tools.
+
+rfork e
+if(! test -f run.bash){
+ echo 'make.rc must be run from $GOROOT/src' >[1=2]
+ exit wrongdir
+}
+
+# Clean old generated file that will cause problems in the build.
+rm -rf ./pkg/runtime/runtime_defs.go
+
+# Determine the host compiler toolchain.
+eval `{grep '^(CC|LD|O)=' /$objtype/mkfile}
+
+echo '# Building C bootstrap tool.'
+echo cmd/dist
+GOROOT = `{cd .. && pwd}
+if(! ~ $#GOROOT_FINAL 1)
+ GOROOT_FINAL = $GOROOT
+DEFGOROOT='-DGOROOT_FINAL="'$GOROOT_FINAL'"'
+
+for(i in cmd/dist/*.c)
+ $CC -FTVwp+ -DPLAN9 $DEFGOROOT $i
+$LD -o cmd/dist/dist *.$O
+rm *.$O
+
+eval `{./cmd/dist/dist env -9}
+echo
+
+if(~ $1 --dist-tool){
+ # Stop after building dist tool.
+ mkdir -p $GOTOOLDIR
+ if(! ~ $2 '')
+ cp cmd/dist/dist $2
+ mv cmd/dist/dist $GOTOOLDIR/dist
+ exit
+}
+
+echo '# Building compilers and Go bootstrap tool for host,' $GOHOSTOS/$GOHOSTARCH^.
+buildall = -a
+if(~ $1 --no-clean)
+ buildall = ()
+./cmd/dist/dist bootstrap $buildall -v # builds go_bootstrap
+# Delay move of dist tool to now, because bootstrap may clear tool directory.
+mv cmd/dist/dist $GOTOOLDIR/dist
+$GOTOOLDIR/go_bootstrap clean -i std
+echo
+
+# TODO(ality): remove the -p flag once the exec/await/RFNOTEG race is fixed.
+
+if(! ~ $GOHOSTARCH $GOARCH || ! ~ $GOHOSTOS $GOOS){
+ echo '# Building packages and commands for host,' $GOHOSTOS/$GOHOSTARCH^.
+ GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
+ $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v -p 1 std
+ echo
+}
+
+echo '# Building packages and commands for' $GOOS/$GOARCH^.
+$GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v -p 1 std
+echo
+
+rm -f $GOTOOLDIR/go_bootstrap
+
+if(! ~ $1 --no-banner)
+ $GOTOOLDIR/dist banner