summaryrefslogtreecommitdiffstats
path: root/nim-compat/PKGBUILD
blob: 3c42b26a2d95ff02c4c619468d4fe69c7b007940 (plain) (blame)
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
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Dominik Picheta <morfeusz8@gmail.com>
# Contributor: Sven-Hendrik Haase <sh@lutzhaase.com>
# Contributor: Jesus Alvarez <jeezusjr@gmail.com>

pkgname=nim
_pkgname=Nim
pkgver=2.0.8
_pkgver=2.2.6
_csourcesver=86742fb02c6606ab01a532a0085784effb2e753e
pkgrel=1
pkgdesc='Imperative, multi-paradigm, compiled programming language'
url='https://nim-lang.org/'
arch=(x86_64)
license=(MIT)
depends=(
  bash
  gcc
  gcc-libs
  glibc
)
makedepends=(
  git
)
provides=(nimble)
conflicts=(nimble)
replaces=(nimble)
options=('!emptydirs')
backup=(
  etc/nim/nim.cfg
  etc/nim/nimdoc.cfg
  etc/nim/nimdoc.tex.cfg
  etc/nim/rename.rules.cfg
)
source=(https://github.com/nim-lang/Nim/archive/v${_pkgver}/${pkgname}-${_pkgver}.tar.gz
        "git+https://github.com/nim-lang/csources_v2.git#commit=${_csourcesver}")
sha256sums=('4a691f3a5351540ca493ffe1f812cb3151cea9ab540d5001b54865d253229072'
            '130a6d21808f43da421057385a5a8fd0a6ebd0d211211d3edd645eefd4fc7087')
b2sums=('99981be22a332c65c75b86164eb857984de20116ffb84e74501ab90cf8aa7154dc19f87e8128c8f1f6d76750054953ec34ca15896960a7beb707a56a72e5f344'
        '2325bebb91b56f9373df83366efb308994fececc0f73acb2ad7b0822fc549d101026a5c1bf7c5ff7fd534e57f9e956f167bbfe00223fe3db0b487175cf0ca369')

prepare() {
  cd ${_pkgname}-${_pkgver}
  cp -r ../csources_v2/* .
  rm bin/empty.txt
  for nimcfg in {compiler,config}/nim.cfg; do
    echo "gcc.options.always %= \"\${gcc.options.always} ${CFLAGS:-} ${CPPFLAGS}\"" >> "${nimcfg}"
    echo "gcc.options.linker %= \"\${gcc.options.linker} ${LDFLAGS:-}\"" >> "${nimcfg}"
  done
}

build() {
  cd ${_pkgname}-${_pkgver}
  export PATH="${srcdir}/${_pkgname}-${_pkgver}/bin:${PATH}"

  echo "Building nim"
  sh build.sh

  echo "Building koch"
  nim c -d:release koch
  ./koch boot -d:release -d:nativeStacktrace -d:useGnuReadline

  echo "Building libs"
  (cd lib
    nim c --app:lib -d:createNimRtl -d:release nimrtl.nim
  )

  echo "Building tools"
  ./koch tools
  (cd tools
    nim c -d:release nimgrep.nim
  )

  echo "Building nimsuggest"
  nim c -d:release nimsuggest/nimsuggest.nim
}

package() {
  cd ${_pkgname}-${_pkgver}
  export PATH="${srcdir}/${_pkgname}-${_pkgver}/bin:${PATH}"

  ./koch install "${pkgdir}"

  install -d "${pkgdir}/usr/lib"
  cp -a lib "${pkgdir}/usr/lib/nim"
  cp -a compiler "${pkgdir}/usr/lib/nim"
  install -Dm 644 nim.nimble "${pkgdir}/usr/lib/nim/compiler"
  install -m 755 lib/libnimrtl.so "${pkgdir}/usr/lib/libnimrtl.so"

  install -Dm 644 config/* -t "${pkgdir}/etc/nim"
  install -Dm 755 bin/* -t "${pkgdir}/usr/bin"

  # Fix FS#50252, unusual placement of header files
  install -d "${pkgdir}/usr/include"
  cp -a "${pkgdir}/usr/lib/nim/"*.h "${pkgdir}/usr/include"

  # Fix FS#48118, related to the doc2 command
  ln -s /usr/share/nim/doc "${pkgdir}/usr/lib/nim/doc"
  install -d "${pkgdir}/usr/share/nim/doc"
  cp -a doc/* "${pkgdir}/usr/share/nim/doc"

  # Fix wrong path for system.nim https://github.com/nim-lang/Nim/issues/22369
  ln -s /usr/lib/nim "$pkgdir"/usr/lib/nim/lib

  install -Dm 644 copying.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"

  # completions
  for comp in tools/*.bash-completion; do
    install -Dm 644 "${comp}" "${pkgdir}/usr/share/bash-completion/completions/$(basename "${comp/.bash-completion}")"
  done
  for comp in tools/*.zsh-completion; do
    install -Dm 644 "${comp}" "${pkgdir}/usr/share/zsh/site-functions/_$(basename "${comp/.zsh-completion}")"
  done

  rm -r "${pkgdir}/nim"
  rm "${pkgdir}"/usr/bin/nim-gdb.bat
}

# vim: ts=2 sw=2 et: