summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0a5dc1a46178f82863ecc76ac8016d3db521a797 (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
# Maintainer:  dreieck (https://aur.archlinux.org/account/dreieck)
# Contributor: Chris Severance

set -u
_pkgname='fdpp'
_gitname='dosemu2'
pkgname="${_pkgname}-git"
epoch=0
pkgver=1.8+4.r1607.20241115.1006a27
pkgrel=1
pkgdesc='64 bit FreeDOS++ for dosemu2. Latest git checkout.'
arch=(
  'x86_64'
  'aarch64'
)
url="https://github.com/${_gitname}/${_pkgname}"
license=(
  'GPL3'
)
depends=(
  'gcc-libs'
  'glibc'
  'libelf'
)
optdepends=(
  'dosemu2: To use this software.'
  'comcom32: For command.com interpreter.'
  'comcom64: For command.com interpreter.'
  'freecom: For command.com interpreter.'
  'COMMAND.COM: For command.com interpreter.'
)
makedepends=(
  'bash'
  'binutils'
  'clang'
  'git'
  'nasm-segelf' # See https://github.com/dosemu2/fdpp/issues/233#issuecomment-1788601563
  'thunk_gen'
)
if [ "${CARCH}" == "x86_64" ]; then
  export CROSS_LD='ld'
else
  makedepends+=("x86_64-elf-binutils")
  export CROSS_LD='x86_64-elf-ld'
fi
provides=(
  "${_pkgname}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
)
options=('!strip')
source=(
  "${_pkgname}::git+${url}.git"
)
sha256sums=(
  'SKIP'
)

prepare() {
  set -u
  cd "${srcdir}/${_pkgname}"

  git log > git.log

  sed -e '/^PREFIX / s:/usr/local:/usr:g' -i 'fdpp/defs.mak'
  set +u
}

pkgver() {
  set -u
  cd "${srcdir}/${_pkgname}"

  # _ver="$(grep -E -m1 '^[[:space:]]*fdpp[[:space:]]*\(' debian/changelog | sed -E -e 's|^[^\(]*\(([^\)]*)\).*$|\1|' -e 's|-.*$||')"
  # _ver="$(git describe --tags | sed -E -e 's|^[vV]||' -e 's|-g[0-9a-f]+$||' | tr '-' '+')" # git describe --tags give unpredictable result; sometimes it is like '1.6', sometimes like 'API31'. `git describe` seems to work.
  _ver="$(git describe | sed -E -e 's|^[vV]||' -e 's|-g[0-9a-f]+$||' | tr '-' '+')"
  _rev="$(git rev-list --count HEAD)"
  _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Version could not be determined."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

build() {
  set -u
  cd "${srcdir}/${_pkgname}"
  bash -e -u configure
  make -j "$(nproc)"
  set +u
}

package() {
  set -u
  cd "${srcdir}/${_pkgname}"
  make -j1 DESTDIR="${pkgdir}" install

  for _docfile in 'git.log' 'NEWS.md' 'README.md'; do
    install -Dvm644 "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/${_docfile}"
  done
  for _licensefile in LICENSE; do
    install -Dvm644 "${_licensefile}" "${pkgdir}/usr/share/licenses/${pkgname}/${_licensefile}"
    ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/${_licensefile}" "${pkgdir}/usr/share/doc/${_pkgname}/${_licensefile}"
  done

  set +u
}
set +u