LEFT | RIGHT |
1 #!/bin/rc -e | 1 #!/bin/rc -e |
2 # Copyright 2012 The Go Authors. All rights reserved. | 2 # Copyright 2012 The Go Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style | 3 # Use of this source code is governed by a BSD-style |
4 # license that can be found in the LICENSE file. | 4 # license that can be found in the LICENSE file. |
5 | 5 |
6 rfork en | 6 # Environment variables that control make.rc: |
| 7 # |
| 8 # GOROOT_FINAL: The expected final Go root, baked into binaries. |
| 9 # The default is the location of the Go tree during the build. |
| 10 # |
| 11 # GOHOSTARCH: The architecture for host tools (compilers and |
| 12 # binaries). Binaries of this type must be executable on the current |
| 13 # system, so the only common reason to set this is to set |
| 14 # GOHOSTARCH=386 on an amd64 machine. |
| 15 # |
| 16 # GOARCH: The target architecture for installed packages and tools. |
| 17 # |
| 18 # GOOS: The target operating system for installed packages and tools. |
| 19 # |
| 20 # GO_GCFLAGS: Additional 5g/6g/8g arguments to use when |
| 21 # building the packages and commands. |
| 22 # |
| 23 # GO_LDFLAGS: Additional 5l/6l/8l arguments to use when |
| 24 # building the commands. |
| 25 # |
| 26 # CGO_ENABLED: Setting this to 0 disables the use of cgo |
| 27 # in the built and installed packages and tools. |
7 | 28 |
| 29 rfork e |
8 if(! test -f run.bash){ | 30 if(! test -f run.bash){ |
9 echo 'make.rc must be run from $GOROOT/src' >[1=2] | 31 echo 'make.rc must be run from $GOROOT/src' >[1=2] |
10 exit wrongdir | 32 exit wrongdir |
11 } | 33 } |
12 | 34 |
13 switch($objtype){ | 35 # Clean old generated file that will cause problems in the build. |
14 case arm | 36 rm -rf ./pkg/runtime/runtime_defs.go |
15 » O = 5 | 37 |
16 case amd64 | 38 # Determine the host compiler toolchain. |
17 » O = 6 | 39 eval `{grep '^(CC|LD|O)=' /$objtype/mkfile} |
18 case 386 | 40 |
19 » O = 8 | 41 echo '# Building C bootstrap tool.' |
20 case * | 42 echo cmd/dist |
21 » echo 'unknown $objtype:' $objtype >[1=2] | 43 GOROOT = `{cd .. && pwd} |
22 » exit objtype | 44 if(! ~ $#GOROOT_FINAL 1) |
| 45 » GOROOT_FINAL = $GOROOT |
| 46 DEFGOROOT='-DGOROOT_FINAL="'$GOROOT_FINAL'"' |
| 47 |
| 48 for(i in cmd/dist/*.c) |
| 49 » $CC -FTVwp+ -DPLAN9 $DEFGOROOT $i |
| 50 $LD -o cmd/dist/dist *.$O |
| 51 rm *.$O |
| 52 |
| 53 eval `{./cmd/dist/dist env -9} |
| 54 echo |
| 55 |
| 56 if(~ $1 --dist-tool){ |
| 57 » # Stop after building dist tool. |
| 58 » mkdir -p $GOTOOLDIR |
| 59 » if(! ~ $2 '') |
| 60 » » cp cmd/dist/dist $2 |
| 61 » mv cmd/dist/dist $GOTOOLDIR/dist |
| 62 » exit |
23 } | 63 } |
24 | 64 |
25 # The go tool will be installed here. | 65 echo '# Building compilers and Go bootstrap tool for host,' $GOHOSTOS/$GOHOSTARC
H^. |
26 if(! ~ $#GOBIN 1) | 66 buildall = -a |
27 » GOBIN = /$objtype/bin | 67 if(~ $1 --no-clean) |
28 | 68 » buildall = () |
29 echo '# Building C bootstrap tool.' | 69 ./cmd/dist/dist bootstrap $buildall -v # builds go_bootstrap |
30 mkdir -p ../bin/tool | 70 # Delay move of dist tool to now, because bootstrap may clear tool directory. |
31 @{ | 71 mv cmd/dist/dist $GOTOOLDIR/dist |
32 » cd ../bin/tool | 72 $GOTOOLDIR/go_bootstrap clean -i std |
33 » for(i in ../../src/cmd/dist/*.c) | |
34 » » $O^c -FTVwp+ -DPLAN9 -DDEFAULT_GOROOT'="'$GOROOT'"' $i | |
35 » $O^l -o dist *.$O | |
36 » rm -f *.$O | |
37 } | |
38 echo | |
39 | |
40 echo '# Building compilers and Go bootstrap tool.' | |
41 ../bin/tool/dist bootstrap -v # builds go_bootstrap | |
42 echo | 73 echo |
43 | 74 |
44 # TODO(ality): remove the -p flag once the exec/await/RFNOTEG race is fixed. | 75 # TODO(ality): remove the -p flag once the exec/await/RFNOTEG race is fixed. |
45 | 76 |
46 echo '# Building packages and commands.' | 77 if(! ~ $GOHOSTARCH $GOARCH || ! ~ $GOHOSTOS $GOOS){ |
47 ../bin/tool/go_bootstrap clean std | 78 » echo '# Building packages and commands for host,' $GOHOSTOS/$GOHOSTARCH^
. |
48 ../bin/tool/go_bootstrap install -a -v -p 1 std | 79 » GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \ |
49 rm -f ../bin/tool/go_bootstrap | 80 » » $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $
"GO_LDFLAGS -v -p 1 std |
| 81 » echo |
| 82 } |
| 83 |
| 84 echo '# Building packages and commands for' $GOOS/$GOARCH^. |
| 85 $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v -
p 1 std |
50 echo | 86 echo |
51 | 87 |
52 if(~ $1 --no-banner) | 88 rm -f $GOTOOLDIR/go_bootstrap |
53 » shift | 89 |
54 if not | 90 if(! ~ $1 --no-banner) |
55 » ../bin/tool/dist banner | 91 » $GOTOOLDIR/dist banner |
LEFT | RIGHT |