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 5g/6g/8g arguments to use when
20 :: building the packages and commands.
22 :: GO_LDFLAGS: Additional 5l/6l/8l 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.
31 :: Keep environment variables within this script
32 :: unless invoked with --no-local.
33 if x%1==x--no-local goto nolocal
34 if x%2==x--no-local goto nolocal
40 if exist make.bat goto ok
41 echo Must run make.bat from Go src directory.
45 :: Clean old generated file that will cause problems in the build.
46 del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
48 :: Grab default GOROOT_FINAL and set GOROOT for build.
49 :: The expression %VAR:\=\\% means to take %VAR%
50 :: and apply the substitution \ = \\, escaping the
51 :: backslashes. Then we wrap that in quotes to create
56 if "x%GOROOT_FINAL%"=="x" set GOROOT_FINAL=%GOROOT%
57 set DEFGOROOT=-DGOROOT_FINAL="\"%GOROOT_FINAL:\=\\%\""
59 echo # Building C bootstrap tool.
61 if not exist ..\bin\tool mkdir ..\bin\tool
62 :: Windows has no glob expansion, so spell out cmd/dist/*.c.
63 gcc -O2 -Wall -Werror -o cmd/dist/dist.exe -Icmd/dist %DEFGOROOT% cmd/dist/buf.c cmd/dist/build.c cmd/dist/buildgc.c cmd/dist/buildruntime.c cmd/dist/goc2c.c cmd/dist/main.c cmd/dist/windows.c
64 if errorlevel 1 goto fail
65 .\cmd\dist\dist env -wp >env.bat
66 if errorlevel 1 goto fail
71 echo # Building compilers and Go bootstrap tool.
73 if x%1==x--no-clean set buildall=
74 .\cmd\dist\dist bootstrap %buildall% -v
75 if errorlevel 1 goto fail
76 :: Delay move of dist tool to now, because bootstrap cleared tool directory.
77 move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
78 "%GOTOOLDIR%\go_bootstrap" clean -i std
81 if not %GOHOSTARCH% == %GOARCH% goto localbuild
82 if not %GOHOSTOS% == %GOOS% goto localbuild
86 echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
89 set GOARCH=%GOHOSTARCH%
90 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -v std
92 if errorlevel 1 goto fail
96 echo # Building packages and commands.
97 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -a -v std
98 if errorlevel 1 goto fail
99 del "%GOTOOLDIR%\go_bootstrap.exe"
102 if x%1==x--no-banner goto nobanner
103 "%GOTOOLDIR%\dist" banner