summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a8eb2fdb467099888ffe8b8c2e41fd68a6d20c4d (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
# Contributor: 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>
# Maintainer: Stefan Husmann <stefan-husmann@t-online.de>

pkgname=nim-legacy
_pkgname=Nim
_csourcesver=0.20.0
pkgver=1.0.6
pkgrel=2
pkgdesc='Imperative, multi-paradigm, compiled programming language'
url='https://nim-lang.org/'
arch=('x86_64')
license=('MIT')
depends=('python' 'bash')
options=('!emptydirs')
conflicts=('nim')
provides=('nim')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/nim-lang/Nim/archive/v${pkgver}.tar.gz
        csources-${_csourcesver}.tar.gz::https://github.com/nim-lang/csources/archive/v${_csourcesver}.tar.gz)
sha256sums=('f5826ee7a00059243f00898a47e910fd89484f7aa8ad8c91e2b914a013b83ed0'
            '5e6fd15d90df1a8cb7614c4ffc70aa8c4198cd854d7742016202b96dd0228d3c')
sha512sums=('ce5f97f2c6b84781647889646dc3d58c640f73d1b734ce32198526fa8fbe4a118a40c1c86610c990b30921ecc800087ac98ca3c22d479727b6a0096ca241fbd0'
            '4da00678cb92cfd3b2425e4698cbbef8111c711f9457ba969367638437b5fad7928ca0a91fd24f53dcd9d341cfc420e87ec85d245767531bc57ccafd6feba258')

prepare() {
  cd ${_pkgname}-${pkgver}
  [[ -d csources ]] || mv ../csources-${_csourcesver} csources
  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}"

  msg2 "Building nim"
  (cd csources
    sh build.sh
  )
  msg2 "Building koch"
  nim c -d:release koch
  ./koch boot -d:release -d:nativeStacktrace -d:useGnuReadline

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

  msg2 "Building tools"
  ./koch tools
  (cd tools
    nim c -d:release nimgrep.nim
  )
  msg2 "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 compiler.nimble "${pkgdir}/usr/lib/nim/compiler"
  install -m 755 lib/libnimrtl.so "${pkgdir}/usr/lib/libnimrtl.so"

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

  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"

  install -d "${pkgdir}/usr/share/nim/doc"
  cp -a examples doc/* "${pkgdir}/usr/share/nim/doc"

  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/nimble"
}