summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 32b9467291e69f77db67b7ad14d335ae148f9083 (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
# Maintainer: Adrian Perez de Castro <aperez@igalia.com>
pkgname=cproc-git
pkgdesc='Small C11 compiler using QBE as backend'
pkgver=r592.9ae9aa6
pkgrel=1
url=https://git.sr.ht/~mcf/cproc
makedepends=(git)
arch=(x86_64)
depends=(gcc "qbe>=1.1")
license=(custom)
source=("${pkgname}::git+${url}")
b2sums=(SKIP)

pkgver ()
{
	cd "${pkgname}"
	(
		set -o pipefail
		git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
		printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
	)
}

build ()
{
	cd "${pkgname}"

	local ldso_option
	case ${CARCH} in
		x84_64) ldso_option='--with-ldso=/lib/ld-linux-x86-64.so.2' ;;
		i686)   ldso_option='--with-ldso=/lib/ld-linux.so.2' ;;
		*)      msg2 'Letting cproc choose the dynamic linker path' ;;
	esac

	make clean

	./configure \
		--prefix=/usr \
		--with-cpp=/usr/bin/cpp \
		--with-qbe=/usr/bin/qbe \
		--with-as=/usr/bin/as \
		--with-ld=/usr/bin/ld \
		${ldso_option}

	make
}

check ()
{
	make -C "${pkgname}" check
}

package ()
{
	cd "${pkgname}"
	make DESTDIR="${pkgdir}" install

	install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.cproc"

	for filename in README.md doc/*.md ; do
		install -Dm644 README.md \
			"${pkgdir}/usr/share/doc/${pkgname}/${filename##*/}"
	done
}