1 :: Copyright 2012 The Go Authors. All rights reserved.
2 :: Use of this source code is governed by a BSD-style
3 :: license that can be found in the LICENSE file.
5 :: Environment variables that control make.bat:
7 :: GOROOT_FINAL: The expected final Go root, baked into binaries.
8 :: The default is the location of the Go tree during the build.
10 :: GOHOSTARCH: The architecture for host tools (compilers and
11 :: binaries). Binaries of this type must be executable on the current
12 :: system, so the only common reason to set this is to set
13 :: GOHOSTARCH=386 on an amd64 machine.
15 :: GOARCH: The target architecture for installed packages and tools.
17 :: GOOS: The target operating system for installed packages and tools.
19 :: GO_GCFLAGS: Additional go tool compile arguments to use when
20 :: building the packages and commands.
22 :: GO_LDFLAGS: Additional go tool link arguments to use when
23 :: building the commands.
25 :: CGO_ENABLED: Controls cgo usage during the build. Set it to 1
26 :: to include all cgo related files, .c and .go file with "cgo"
27 :: build directive, in the build. Set it to 0 to ignore them.
29 :: CC: Command line to run to compile C code for GOHOSTARCH.
32 :: CC_FOR_TARGET: Command line to run compile C code for GOARCH.
33 :: This is used by cgo. Default is CC.
35 :: FC: Command line to run to compile Fortran code.
36 :: This is used by cgo. Default is "gfortran".
40 :: Keep environment variables within this script
41 :: unless invoked with --no-local.
42 if x%1==x--no-local goto nolocal
43 if x%2==x--no-local goto nolocal
49 if exist make.bat goto ok
50 echo Must run make.bat from Go src directory.
54 :: Clean old generated file that will cause problems in the build.
55 del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
57 :: Set GOROOT for build.
62 echo ##### Building Go bootstrap tool.
64 if not exist ..\bin\tool mkdir ..\bin\tool
65 if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
66 if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail
68 set GOROOT=%GOROOT_BOOTSTRAP%
71 "%GOROOT_BOOTSTRAP%\bin\go" build -o cmd\dist\dist.exe .\cmd\dist
73 if errorlevel 1 goto fail
74 .\cmd\dist\dist env -w -p >env.bat
75 if errorlevel 1 goto fail
80 if x%1==x--dist-tool goto copydist
81 if x%2==x--dist-tool goto copydist
84 if x%1==x--no-clean set buildall=
85 .\cmd\dist\dist bootstrap %buildall% -v
86 if errorlevel 1 goto fail
87 :: Delay move of dist tool to now, because bootstrap cleared tool directory.
88 move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
91 if not %GOHOSTARCH% == %GOARCH% goto localbuild
92 if not %GOHOSTOS% == %GOOS% goto localbuild
96 echo ##### Building packages and commands for host, %GOHOSTOS%/%GOHOSTARCH%.
97 :: CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the
98 :: host, however, use the host compiler, CC, from `cmd/dist/dist env` instead.
101 set GOARCH=%GOHOSTARCH%
102 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -v std cmd
104 if errorlevel 1 goto fail
108 echo ##### Building packages and commands for %GOOS%/%GOARCH%.
110 set CC=%CC_FOR_TARGET%
111 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -a -v std cmd
113 if errorlevel 1 goto fail
114 del "%GOTOOLDIR%\go_bootstrap.exe"
117 if x%1==x--no-banner goto nobanner
118 "%GOTOOLDIR%\dist" banner
124 mkdir "%GOTOOLDIR%" 2>NUL
125 copy cmd\dist\dist.exe "%GOTOOLDIR%\"
129 echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
130 echo "Set GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4."
134 if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%