Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 1 | #!/bin/rc -e |
| 2 | # Copyright 2012 The Go Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style |
| 4 | # license that can be found in the LICENSE file. |
| 5 | |
David du Colombier | b46b942 | 2015-01-13 08:01:18 +0100 | [diff] [blame] | 6 | # See golang.org/s/go15bootstrap for an overview of the build process. |
| 7 | |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 8 | # Environment variables that control make.rc: |
| 9 | # |
| 10 | # GOROOT_FINAL: The expected final Go root, baked into binaries. |
| 11 | # The default is the location of the Go tree during the build. |
| 12 | # |
| 13 | # GOHOSTARCH: The architecture for host tools (compilers and |
| 14 | # binaries). Binaries of this type must be executable on the current |
| 15 | # system, so the only common reason to set this is to set |
| 16 | # GOHOSTARCH=386 on an amd64 machine. |
| 17 | # |
| 18 | # GOARCH: The target architecture for installed packages and tools. |
| 19 | # |
| 20 | # GOOS: The target operating system for installed packages and tools. |
| 21 | # |
Jeremy Jackins | 7354978 | 2015-05-28 16:13:23 +0900 | [diff] [blame] | 22 | # GO_GCFLAGS: Additional go tool compile arguments to use when |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 23 | # building the packages and commands. |
| 24 | # |
Jeremy Jackins | 7354978 | 2015-05-28 16:13:23 +0900 | [diff] [blame] | 25 | # GO_LDFLAGS: Additional go tool link arguments to use when |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 26 | # building the commands. |
| 27 | # |
Anthony Martin | f08acae | 2013-02-26 09:25:46 -0800 | [diff] [blame] | 28 | # CGO_ENABLED: Controls cgo usage during the build. Set it to 1 |
| 29 | # to include all cgo related files, .c and .go file with "cgo" |
| 30 | # build directive, in the build. Set it to 0 to ignore them. |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 31 | |
| 32 | rfork e |
Anthony Martin | f08acae | 2013-02-26 09:25:46 -0800 | [diff] [blame] | 33 | if(! test -f run.rc){ |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 34 | echo 'make.rc must be run from $GOROOT/src' >[1=2] |
| 35 | exit wrongdir |
| 36 | } |
| 37 | |
| 38 | # Clean old generated file that will cause problems in the build. |
Russ Cox | 220a6de | 2014-09-08 00:06:45 -0400 | [diff] [blame] | 39 | rm -f ./runtime/runtime_defs.go |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 40 | |
| 41 | # Determine the host compiler toolchain. |
| 42 | eval `{grep '^(CC|LD|O)=' /$objtype/mkfile} |
| 43 | |
Jeremy Jackins | 7354978 | 2015-05-28 16:13:23 +0900 | [diff] [blame] | 44 | echo '##### Building Go bootstrap tool.' |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 45 | echo cmd/dist |
| 46 | GOROOT = `{cd .. && pwd} |
David du Colombier | b46b942 | 2015-01-13 08:01:18 +0100 | [diff] [blame] | 47 | if(! ~ $#GOROOT_BOOTSTRAP 1) |
| 48 | GOROOT_BOOTSTRAP = $home/go1.4 |
| 49 | if(! test -x $GOROOT_BOOTSTRAP/bin/go){ |
| 50 | echo 'ERROR: Cannot find '$GOROOT_BOOTSTRAP'/bin/go.' >[1=2] |
| 51 | echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.' >[1=2] |
| 52 | exit bootstrap |
| 53 | } |
| 54 | rm -f cmd/dist/dist |
Russ Cox | 1fac6d1 | 2015-01-14 15:14:54 -0500 | [diff] [blame] | 55 | GOROOT=$GOROOT_BOOTSTRAP GOOS='' GOARCH='' $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 56 | |
| 57 | eval `{./cmd/dist/dist env -9} |
| 58 | echo |
| 59 | |
| 60 | if(~ $1 --dist-tool){ |
| 61 | # Stop after building dist tool. |
| 62 | mkdir -p $GOTOOLDIR |
| 63 | if(! ~ $2 '') |
| 64 | cp cmd/dist/dist $2 |
| 65 | mv cmd/dist/dist $GOTOOLDIR/dist |
| 66 | exit |
| 67 | } |
| 68 | |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 69 | buildall = -a |
| 70 | if(~ $1 --no-clean) |
| 71 | buildall = () |
| 72 | ./cmd/dist/dist bootstrap $buildall -v # builds go_bootstrap |
| 73 | # Delay move of dist tool to now, because bootstrap may clear tool directory. |
| 74 | mv cmd/dist/dist $GOTOOLDIR/dist |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 75 | echo |
| 76 | |
Anthony Martin | f08acae | 2013-02-26 09:25:46 -0800 | [diff] [blame] | 77 | # Run only one process at a time on 9vx. |
| 78 | if(~ $sysname vx32) |
| 79 | pflag = (-p 1) |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 80 | |
| 81 | if(! ~ $GOHOSTARCH $GOARCH || ! ~ $GOHOSTOS $GOOS){ |
Jeremy Jackins | 7354978 | 2015-05-28 16:13:23 +0900 | [diff] [blame] | 82 | echo '##### Building packages and commands for host,' $GOHOSTOS/$GOHOSTARCH^. |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 83 | GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \ |
Russ Cox | 096b294 | 2015-02-22 12:41:32 -0500 | [diff] [blame] | 84 | $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std cmd |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 85 | echo |
| 86 | } |
| 87 | |
Jeremy Jackins | 7354978 | 2015-05-28 16:13:23 +0900 | [diff] [blame] | 88 | echo '##### Building packages and commands for' $GOOS/$GOARCH^. |
Russ Cox | 096b294 | 2015-02-22 12:41:32 -0500 | [diff] [blame] | 89 | $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std cmd |
Anthony Martin | 3859032 | 2012-05-01 22:32:46 -0700 | [diff] [blame] | 90 | echo |
| 91 | |
| 92 | rm -f $GOTOOLDIR/go_bootstrap |
| 93 | |
| 94 | if(! ~ $1 --no-banner) |
| 95 | $GOTOOLDIR/dist banner |
David du Colombier | ffe8a3c | 2013-05-24 13:55:19 -0700 | [diff] [blame] | 96 | |
| 97 | status='' |