summaryrefslogtreecommitdiff
path: root/community/go/PKGBUILD
blob: f484fbe1e839ae80e7092143538befac631789b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# $Id: PKGBUILD 108291 2014-03-26 09:53:48Z arodseth $
# Maintainer: Vesa Kaihlavirta <vegai@iki.fi>
# Maintainer: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Rémy Oudompheng  <remy@archlinux.org>
# Contributor: Andres Perera <andres87p gmail>
# Contributor: Matthew Bauer <mjbauer95@gmail.com>
# Contributor: Christian Himpel <chressie@gmail.com>
# Contributor: Mike Rosset <mike.rosset@gmail.com>
# Contributor: Daniel YC Lin <dlin.tw@gmail.com>
# Contributor: John Luebs <jkluebs@gmail.com>

pkgname=go
epoch=2
pkgver=1.2.1
pkgrel=4
pkgdesc='Compiler and tools for the Go programming language from Google'
arch=('x86_64' 'i686')
url='http://golang.org/'
license=('custom')
depends=('perl' 'gawk')
makedepends=('inetutils' 'mercurial')
options=('!strip' 'staticlibs')
optdepends=('mercurial: for fetching sources from mercurial repositories'
            'git: for fetching sources from git repositories'
            'bzr: for fetching sources from bazaar repositories'
            'svn: for fetching sources from subversion repositories')
install="$pkgname.install"
source=("$pkgname-$pkgver::hg+https://code.google.com/p/$pkgname#branch=release-branch.$pkgname${pkgver/.1}")
md5sums=('SKIP')

build() {
  export GOROOT="$srcdir/$pkgname-$pkgver"
  cd "$GOROOT/src"

  export GOPATH="$srcdir/"
  export GOROOT_FINAL=/usr/lib/go

  #
  # Arch Linux doesn't support SSE2 for i686 (to support older CPUs)
  # The SSE2 version is _a lot_ faster for i686.
  # This line disables it.
  #
  export GO386=387

  # Enable ARM crosscompilation for linux
  export GOOS=linux
  export GOARCH=arm

  bash make.bash

  # Crosscompilation for various platforms (including linux)
  for os in linux; do # darwin freebsd windows; do
    for arch in amd64 386; do
      export GOOS="$os"
      export GOARCH="$arch"
      bash make.bash --no-clean
    done
  done

  GOOS=linux
  case "$CARCH" in
    x86_64) GOARCH=amd64 ;;
    i686) GOARCH=386 ;;
  esac

  $GOROOT/bin/go get -d code.google.com/p/go.tools/cmd/godoc
  $GOROOT/bin/go build -o $srcdir/godoc code.google.com/p/go.tools/cmd/godoc
  for tool in vet cover; do
    $GOROOT/bin/go get -d code.google.com/p/go.tools/cmd/${tool}
    $GOROOT/bin/go build -o $GOROOT/pkg/tool/${GOOS}_${GOARCH}/${tool} code.google.com/p/go.tools/cmd/${tool}
  done
}

check() {
  cd "$pkgname-$pkgver"

  export GO386=387

  export GOOS=linux
  if [ "$CARCH" == 'x86_64' ]; then
    export GOARCH=amd64
  elif [ "$CARCH" == 'i686' ]; then
    export GOARCH=386
  fi

  export GOROOT="$srcdir/$pkgname-$pkgver"
  export PATH="$srcdir/$pkgname-$pkgver/bin:$PATH"

  # TestSimpleMulticastListener will fail in standard chroot
  cd src && bash run.bash --no-rebuild || true
}

package() {
  cd "$pkgname-$pkgver"
  export GOROOT="$srcdir/$pkgname-$pkgver"

  install -Dm755 $srcdir/godoc $pkgdir/usr/bin/godoc

  install -Dm644 LICENSE \
    "$pkgdir/usr/share/licenses/go/LICENSE"
  install -Dm644 misc/bash/go \
    "$pkgdir/usr/share/bash-completion/completions/go"
  install -Dm644 misc/emacs/go-mode-load.el \
    "$pkgdir/usr/share/emacs/site-lisp/go-mode-load.el"
  install -Dm644 misc/emacs/go-mode.el \
    "$pkgdir/usr/share/emacs/site-lisp/go-mode.el"
  install -Dm644 misc/zsh/go \
    "$pkgdir/usr/share/zsh/site-functions/_go"

  for f in ftdetect/gofiletype.vim autoload/go/complete.vim indent/go.vim \
    ftplugin/go/fmt.vim ftplugin/go/import.vim syntax/go.vim syntax/godoc.vim \
    plugin/godoc.vim;
  do
    install -Dm644 "misc/vim/$f" "$pkgdir/usr/share/vim/vimfiles/$f"
  done

  mkdir -p \
    "$pkgdir/"{etc/profile.d,usr/{share/go,lib/go,lib/go/src,lib/go/site/src}}

  cp -r doc misc -t "$pkgdir/usr/share/go"
  ln -s /usr/share/go/doc "$pkgdir/usr/lib/go/doc"
  cp -a bin "$pkgdir/usr"
  cp -a pkg "$pkgdir/usr/lib/go"
  cp -a "$GOROOT/src/pkg" "$pkgdir/usr/lib/go/src/"
  cp -a "$GOROOT/src/cmd" "$pkgdir/usr/lib/go/src/cmd"
  cp -a "$GOROOT/src/lib9" "$pkgdir/usr/lib/go/src/"
  cp -a "$GOROOT/lib" "$pkgdir/usr/lib/go/"
  cp -a "$GOROOT/include" "$pkgdir/usr/lib/go/"

  install -Dm644 src/Make.* "$pkgdir/usr/lib/go/src"

  # Remove object files from target src dir
  find "$pkgdir/usr/lib/go/src/" -type f -name '*.[ao]' -delete

  # Fix for FS#32813
  find "$pkgdir" -type f -name sql.go -exec chmod -x {} \;
  
  # Remove all executable source files
  find "$pkgdir/usr/lib/go/src/pkg" -type f -executable -delete

  # Headers for C modules
  install -Dm644 src/pkg/runtime/runtime.h \
    "$pkgdir/usr/lib/go/src/pkg/runtime/runtime.h"
  install -Dm644 src/pkg/runtime/cgocall.h \
    "$pkgdir/usr/lib/go/src/pkg/runtime/cgocall.h"

  # This is to make go get code.google.com/p/go-tour/gotour and
  # then running the gotour executable work out of the box.
  ln -sf /usr/bin "$pkgdir/usr/lib/go/bin"

  # For godoc
  install -Dm644 favicon.ico "$pkgdir/usr/lib/go/favicon.ico"

  rm -f "$pkgdir/usr/share/go/doc/articles/wiki/get.bin"

  install -Dm644 VERSION "$pkgdir/usr/lib/go/VERSION"

  find "$pkgdir/usr/"{lib/go/pkg,bin} -type f -exec touch '{}' +
}

# vim:set ts=2 sw=2 et: