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
44 if x%3==x--no-local goto nolocal
45 if x%4==x--no-local goto nolocal
53 if exist make.bat goto ok
54 echo Must run make.bat from Go src directory.
58 :: Clean old generated file that will cause problems in the build.
59 del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
61 :: Set GOROOT for build.
66 if x%1==x-v set vflag=-v
67 if x%2==x-v set vflag=-v
68 if x%3==x-v set vflag=-v
69 if x%4==x-v set vflag=-v
71 if not exist ..\bin\tool mkdir ..\bin\tool
72 if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
73 if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail
74 echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%
75 if x%vflag==x-v echo cmd/dist
77 set GOROOT=%GOROOT_BOOTSTRAP%
81 "%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist
83 if errorlevel 1 goto fail
84 .\cmd\dist\dist.exe env -w -p >env.bat
85 if errorlevel 1 goto fail
90 if x%1==x--dist-tool goto copydist
91 if x%2==x--dist-tool goto copydist
92 if x%3==x--dist-tool goto copydist
93 if x%4==x--dist-tool goto copydist
96 if x%1==x--no-clean set buildall=
97 if x%2==x--no-clean set buildall=
98 if x%3==x--no-clean set buildall=
99 if x%4==x--no-clean set buildall=
100 if x%1==x--no-banner set buildall=%buildall% --no-banner
101 if x%2==x--no-banner set buildall=%buildall% --no-banner
102 if x%3==x--no-banner set buildall=%buildall% --no-banner
103 if x%4==x--no-banner set buildall=%buildall% --no-banner
105 :: Run dist bootstrap to complete make.bash.
106 :: Bootstrap installs a proper cmd/dist, built with the new toolchain.
107 :: Throw ours, built with Go 1.4, away after bootstrap.
108 .\cmd\dist\dist.exe bootstrap %vflag% %buildall%
109 if errorlevel 1 goto fail
110 del .\cmd\dist\dist.exe
113 :: DO NOT ADD ANY NEW CODE HERE.
114 :: The bootstrap+del above are the final step of make.bat.
115 :: If something must be added, add it to cmd/dist's cmdbootstrap,
116 :: to avoid needing three copies in three different shell languages
117 :: (make.bash, make.bat, make.rc).
120 mkdir "%GOTOOLDIR%" 2>NUL
121 copy cmd\dist\dist.exe "%GOTOOLDIR%\"
125 echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
126 echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go 1.4.
130 if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%