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