# Tanım: GO Programlama dili
# URL: http://golang.org/
# Paketçi: milisarge
# Gerekler: git go18 
# Grup: geliştirme

isim=go110
surum=1.10.3
devir=1
kaynak=(https://storage.googleapis.com/golang/go$surum.src.tar.gz
		default-buildmode-pie.patch)

derle() {
export GOOS=linux
case "$CARCH" in
  x86_64) export GOARCH=amd64 ;;
esac
export GOROOT_FINAL=/usr/lib/go
export GOROOT_BOOTSTRAP=/usr/lib/go
export GOCACHE=off
  cp -r go go-pie
  cd go-pie
  patch -p1 -i "$SRC"/default-buildmode-pie.patch
  export GOPATH="$SRC/"
  for _isim in `echo "go go-pie"`; do
    export GOROOT="$SRC/$_isim"
    export GOBIN="$GOROOT/bin"
    cd "$SRC/$_isim/src"
    ./make.bash --no-clean -v
    PATH="$GOBIN:$PATH" go install -v -buildmode=shared std
    PATH="$GOBIN:$PATH" go install -v -race std
  done
  
  cd $SRC/go
  install -d "$PKG/usr/bin" "$PKG/usr/lib/go-$surum" 
  cp -a bin pkg src lib misc api "$PKG/usr/lib/go-$surum"
  #cp -r doc/* "$PKG/usr/share/doc/go"
  ln -sf /usr/lib/go-$surum/bin/go "$PKG/usr/bin/go-$surum"
  ln -sf /usr/lib/go-$surum/bin/gofmt "$PKG/usr/bin/gofmt-$surum"
  install -Dm644 LICENSE "$PKG/usr/share/licenses/go/LICENSE"
  install -Dm644 VERSION "$PKG/usr/lib/go-$surum/VERSION"
  rm -rf "$PKG/usr/lib/go-$surum/pkg/bootstrap"
  rm -rf "$PKG/usr/lib/go-$surum/pkg/tool/*/api"
}
