github.com/mattn/go@v0.0.0-20171011075504-07f7db3ea99f/src/make.rc (about) 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 6 # See golang.org/s/go15bootstrap for an overview of the build process. 7 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 # 22 # GO_GCFLAGS: Additional go tool compile arguments to use when 23 # building the packages and commands. 24 # 25 # GO_LDFLAGS: Additional go tool link arguments to use when 26 # building the commands. 27 # 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. 31 32 rfork e 33 if(! test -f run.rc){ 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. 39 rm -f ./runtime/runtime_defs.go 40 41 # Determine the host compiler toolchain. 42 eval `{grep '^(CC|LD|O)=' /$objtype/mkfile} 43 44 echo '##### Building Go bootstrap tool.' 45 echo cmd/dist 46 GOROOT = `{cd .. && pwd} 47 if(! ~ $#GOROOT_BOOTSTRAP 1) 48 GOROOT_BOOTSTRAP = $home/go1.4 49 for(p in $path){ 50 if(! test -x $GOROOT_BOOTSTRAP/bin/go){ 51 if(go_exe = `{path=$p whatis go}){ 52 goroot = `{GOROOT='' $go_exe env GOROOT} 53 if(! ~ $goroot $GOROOT){ 54 GOROOT_BOOTSTRAP = $goroot 55 } 56 } 57 } 58 } 59 if(! test -x $GOROOT_BOOTSTRAP/bin/go){ 60 echo 'ERROR: Cannot find '$GOROOT_BOOTSTRAP'/bin/go.' >[1=2] 61 echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.' >[1=2] 62 exit bootstrap 63 } 64 if(~ $GOROOT_BOOTSTRAP $GOROOT){ 65 echo 'ERROR: $GOROOT_BOOTSTRAP must not be set to $GOROOT' >[1=2] 66 echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.' >[1=2] 67 exit bootstrap 68 } 69 rm -f cmd/dist/dist 70 GOROOT=$GOROOT_BOOTSTRAP GOOS='' GOARCH='' $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist 71 72 eval `{./cmd/dist/dist env -9} 73 echo 74 75 if(~ $1 --dist-tool){ 76 # Stop after building dist tool. 77 mkdir -p $GOTOOLDIR 78 if(! ~ $2 '') 79 cp cmd/dist/dist $2 80 mv cmd/dist/dist $GOTOOLDIR/dist 81 exit 82 } 83 84 buildall = -a 85 if(~ $1 --no-clean) 86 buildall = () 87 ./cmd/dist/dist bootstrap $buildall -v # builds go_bootstrap 88 # Delay move of dist tool to now, because bootstrap may clear tool directory. 89 mv cmd/dist/dist $GOTOOLDIR/dist 90 echo 91 92 # Run only one process at a time on 9vx. 93 if(~ $sysname vx32) 94 pflag = (-p 1) 95 96 if(! ~ $GOHOSTARCH $GOARCH || ! ~ $GOHOSTOS $GOOS){ 97 echo '##### Building packages and commands for host,' $GOHOSTOS/$GOHOSTARCH^. 98 GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH GOBIN=() \ 99 $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std cmd 100 echo 101 } 102 103 echo '##### Building packages and commands for' $GOOS/$GOARCH^. 104 $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std cmd 105 echo 106 107 rm -f $GOTOOLDIR/go_bootstrap 108 109 if(! ~ $1 --no-banner) 110 $GOTOOLDIR/dist banner 111 112 status=''