aboutsummaryrefslogtreecommitdiffstats
path: root/community/emacs/APKBUILD
blob: 13212bd30d25bba065e843a6a1acf3f61d919ea2 (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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# Maintainer: stef <l0ls0fo2i@ctrlc.hu>
# Contributor: Timo Teräs <timo.teras@iki.fi>
pkgname=emacs
pkgver=27.1
pkgrel=2
pkgdesc="The extensible, customizable, self-documenting real-time display editor"
arch="all"
depends="emacs-nox"
url="https://www.gnu.org/software/emacs/emacs.html"
license="GPL-3.0-or-later"
makedepends="autoconf automake linux-headers gawk ncurses-dev
	ncurses-libs gnutls-dev gmp-dev jansson-dev harfbuzz-dev"
subpackages="$pkgname-doc $pkgname-nox"
source="https://ftp.gnu.org/gnu/emacs/emacs-$pkgver.tar.xz
	no-git-repo.patch"

case $CARCH in
	mips64|s390x)
		# limited by librsvg (rust)
		_docdir="nox"
		;;
	*)
		makedepends="$makedepends glib-dev fontconfig-dev libpng-dev
			librsvg-dev giflib-dev libxpm-dev gtk+2.0-dev gtk+3.0-dev
			alsa-lib-dev libxml2-dev pango-dev tiff-dev libjpeg-turbo-dev
			libxaw-dev"
		subpackages="$subpackages $pkgname-x11 $pkgname-gtk2 $pkgname-gtk3"
		_docdir="gtk2"
		;;
esac

prepare() {
	cd "$builddir/$1"
	default_prepare
	./autogen.sh
}

_build_variant() {
	cd "$builddir/$1"
	shift
	CFLAGS=-fno-pie \
	LDFLAGS=-no-pie \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--libexecdir=/usr/lib \
		--localstatedir=/var \
		--without-makeinfo \
		--with-gameuser=:games \
		--with-gpm \
		--with-harfbuzz \
		--with-json \
		"${@}"
	make
}

_build_x11() {
	_build_variant x11 \
		--with-x-toolkit=athena \
		--without-toolkit-scroll-bars \
		--without-dbus \
		--with-xft \
		--with-jpeg=yes \
		--with-tiff=yes
}

_build_gtk2() {
	 _build_variant gtk2 \
		--with-x-toolkit=gtk2 \
		--with-xft \
		--with-jpeg=yes \
		--with-tiff=no
}

_build_gtk3() {
	 _build_variant gtk3 \
		--with-x-toolkit=gtk3 \
		--with-xft \
		--with-jpeg=yes \
		--with-tiff=no
}

_build_nox() {
	_build_variant nox \
		--without-sound \
		--without-x \
		--without-file-notification
}

build() {
	mkdir -p nox
	mv ./* nox || true

	case "$CARCH" in
	mips64|s390x)
		# limited by librsvg (rust)
		_build_nox
		;;
	*)
		cp -a nox x11
		cp -a nox gtk2
		cp -a nox gtk3
		_build_nox
		_build_x11
		_build_gtk2
		_build_gtk3
		;;
	esac
}

package() {
	mkdir -p "$pkgdir"
}

doc() {
	depends=""
	mkdir -p "$subpkgdir"
	cd "$builddir"/"$_docdir"
	make DESTDIR="$subpkgdir" install
	# remove conflict with ctags package
	mv "$subpkgdir"/usr/share/man/man1/ctags.1.gz "$subpkgdir"/usr/share/man/man1/ctags.emacs.1.gz
	# only keep info and man directories, all other is in the specific package
	rm -rf "${subpkgdir:?}"/usr/bin \
		"$subpkgdir"/usr/lib \
		"$subpkgdir"/usr/share/appdata \
		"$subpkgdir"/usr/share/applications \
		"$subpkgdir"/usr/share/emacs \
		"$subpkgdir"/usr/share/icons \
		"${subpkgdir:?}"/var \
		"$subpkgdir"/usr/lib/systemd
}

_subpackage() {
	cd "$builddir/$1"
	make DESTDIR="$subpkgdir" install

	# remove conflict with ctags package
	mv "$subpkgdir"/usr/bin/ctags "$subpkgdir"/usr/bin/ctags.emacs
	rm -rf "$subpkgdir"/usr/share/info \
		"$subpkgdir"/usr/share/man

	# fix user/root permissions on usr/share files
	find "$subpkgdir"/usr/share/emacs/ -exec chown root:root {} \;
	find "$subpkgdir"/usr/lib -perm -g+s,g+x ! -type d -exec chmod g-s {} \;
	# fix perms on /var/games
	chmod 775 "$subpkgdir"/var/games
	chmod 775 "$subpkgdir"/var/games/emacs
	chmod 664 "$subpkgdir"/var/games/emacs/*
	chown -R root:games "$subpkgdir"/var/games
}

nox() {
	pkgdesc="$pkgdesc - without X11"
	depends="!emacs-x11 !emacs-gtk2 !emacs-gtk3"
	_subpackage nox
}

x11() {
	pkgdesc="$pkgdesc - with X11"
	depends="!emacs-nox !emacs-gtk2 !emacs-gtk3 hicolor-icon-theme desktop-file-utils"
	_subpackage x11
}

gtk2() {
	pkgdesc="$pkgdesc - with GTK2"
	depends="!emacs-nox !emacs-x11 !emacs-gtk3 hicolor-icon-theme desktop-file-utils"
	_subpackage gtk2
}

gtk3() {
	pkgdesc="$pkgdesc - with GTK3"
	depends="!emacs-nox !emacs-x11 !emacs-gtk2 hicolor-icon-theme desktop-file-utils"
	_subpackage gtk3
}

sha512sums="dfb26531d2c19cf9fb56505f03d799654b45e5f9528e777900e8280ed2c1d21e04c52f510528e31e015977c471ae63164cedee6174b7439ebcf479a21fc18064  emacs-27.1.tar.xz
5a2d1d10d66fd335b16d9f2d6d1e45e093067db87f8ef2d14a8c921cc94b3e226310c7cc691d19eb91eaf16de9ae4f20ff8be3596a4906b0514fa5f098328d97  no-git-repo.patch"