github.com/bgentry/go@v0.0.0-20150121062915-6cf5a733d54d/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 5g/6g/8g arguments to use when
    23  # building the packages and commands.
    24  #
    25  # GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
    26  # building the commands.
    27  #
    28  # GO_CCFLAGS: Additional 5c/6c/8c arguments to use when
    29  # building.
    30  #
    31  # CGO_ENABLED: Controls cgo usage during the build. Set it to 1
    32  # to include all cgo related files, .c and .go file with "cgo"
    33  # build directive, in the build. Set it to 0 to ignore them.
    34  
    35  rfork e
    36  if(! test -f run.rc){
    37  	echo 'make.rc must be run from $GOROOT/src' >[1=2]
    38  	exit wrongdir
    39  }
    40  
    41  # Generate libc_plan9.h.
    42  ../include/plan9/mklibc.rc > ../include/plan9/libc_plan9.h
    43  
    44  # Clean old generated file that will cause problems in the build.
    45  rm -f ./runtime/runtime_defs.go
    46  
    47  # Determine the host compiler toolchain.
    48  eval `{grep '^(CC|LD|O)=' /$objtype/mkfile}
    49  
    50  echo '# Building Go bootstrap tool.'
    51  echo cmd/dist
    52  GOROOT = `{cd .. && pwd}
    53  if(! ~ $#GOROOT_BOOTSTRAP 1)
    54  	GOROOT_BOOTSTRAP = $home/go1.4
    55  if(! test -x $GOROOT_BOOTSTRAP/bin/go){
    56  	echo 'ERROR: Cannot find '$GOROOT_BOOTSTRAP'/bin/go.' >[1=2]
    57  	echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.' >[1=2]
    58  	exit bootstrap
    59  }
    60  rm -f cmd/dist/dist
    61  GOROOT=$GOROOT_BOOTSTRAP GOOS='' GOARCH='' $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist
    62  
    63  eval `{./cmd/dist/dist env -9}
    64  echo
    65  
    66  if(~ $1 --dist-tool){
    67  	# Stop after building dist tool.
    68  	mkdir -p $GOTOOLDIR
    69  	if(! ~ $2 '')
    70  		cp cmd/dist/dist $2
    71  	mv cmd/dist/dist $GOTOOLDIR/dist
    72  	exit
    73  }
    74  
    75  echo '# Building compilers and Go bootstrap tool for host,' $GOHOSTOS/$GOHOSTARCH^.
    76  buildall = -a
    77  if(~ $1 --no-clean)
    78  	buildall = ()
    79  ./cmd/dist/dist bootstrap $buildall -v # builds go_bootstrap
    80  # Delay move of dist tool to now, because bootstrap may clear tool directory.
    81  mv cmd/dist/dist $GOTOOLDIR/dist
    82  $GOTOOLDIR/go_bootstrap clean -i std
    83  echo
    84  
    85  # Run only one process at a time on 9vx.
    86  if(~ $sysname vx32)
    87  	pflag = (-p 1)
    88  
    89  if(! ~ $GOHOSTARCH $GOARCH || ! ~ $GOHOSTOS $GOOS){
    90  	echo '# Building packages and commands for host,' $GOHOSTOS/$GOHOSTARCH^.
    91  	GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
    92  		$GOTOOLDIR/go_bootstrap install -ccflags $"GO_CCFLAGS -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std
    93  	echo
    94  }
    95  
    96  echo '# Building packages and commands for' $GOOS/$GOARCH^.
    97  $GOTOOLDIR/go_bootstrap install -ccflags $"GO_CCFLAGS -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std
    98  echo
    99  
   100  rm -f $GOTOOLDIR/go_bootstrap
   101  
   102  if(! ~ $1 --no-banner)
   103  	$GOTOOLDIR/dist banner
   104  
   105  status=''