summaryrefslogtreecommitdiff
path: root/main/pjproject/APKBUILD
blob: 3d46f531410064dd0bb2b23ea1537c8148e802ef (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
113
114
115
116
117
118
119
120
121
# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=pjproject
pkgver=2.12.1
pkgrel=2
pkgdesc="Open source multimedia communication library"
url="https://www.pjsip.org/pjsua.htm"
arch="all"
license="GPL-2.0-or-later"
depends_dev="openssl-dev>3 alsa-lib-dev gsm-dev speex-dev speexdsp-dev
	portaudio-dev libsrtp-dev libsamplerate-dev"
makedepends="$depends_dev linux-headers python3-dev swig"
subpackages="$pkgname-dbg $pkgname-dev py3-pjsua:py3 pjsua"
source="https://github.com/pjsip/pjproject/archive/$pkgver/pjproject-$pkgver.tar.gz
	pjproject_no_third_party.patch
	execinfo.patch
	"

# secfixes:
#   2.12.1-r0:
#     - CVE-2022-24754
#     - CVE-2022-24763
#     - CVE-2022-24764
#     - CVE-2022-24786
#     - CVE-2022-24792
#     - CVE-2022-24793
#   2.12-r0:
#     - CVE-2021-37706
#     - CVE-2021-41141
#     - CVE-2021-43299
#     - CVE-2021-43300
#     - CVE-2021-43301
#     - CVE-2021-43302
#     - CVE-2021-43303
#     - CVE-2021-43804
#     - CVE-2021-43845
#     - CVE-2022-21722
#     - CVE-2022-21723
#     - CVE-2022-23608
#   2.11.1-r0:
#     - CVE-2021-32686
#   2.11-r0:
#     - CVE-2020-15260
#     - CVE-2021-21375

prepare() {
	default_prepare
	update_config_sub

	# Remove target name from lib names
	sed -i -e 's/-$(TARGET_NAME)//g' \
		-e 's/= $(TARGET_NAME).a/= .a/g' \
		-e 's/-$(LIB_SUFFIX)/$(LIB_SUFFIX)/g' \
		$(find . -name '*.mak*' -o -name Makefile)

	# Fix hardcoded prefix and flags
	sed -i \
		-e 's/poll@/poll@\nexport PREFIX := @prefix@\n/g' \
		-e 's!prefix = /usr/local!prefix = $(PREFIX)!' \
		-e '/PJLIB_CFLAGS/ s/(_CFLAGS)/(_CFLAGS) -fPIC/g' \
		-e '/PJLIB_UTIL_CFLAGS/ s/(_CFLAGS)/(_CFLAGS) -fPIC/g' \
		Makefile \
		build.mak.in

	# Use libsamplerate instead of bundled resample
	sed -i -e "s/resample//" third_party/build/Makefile
	sed -i -e "s#../../third_party/libsamplerate/src/samplerate.h#samplerate.h#" pjmedia/src/pjmedia/resample_libsamplerate.c
}

build() {
	export CFLAGS="-DNDEBUG $CFLAGS"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--enable-shared \
		--enable-libsamplerate \
		--with-external-speex \
		--with-external-gsm \
		--with-external-srtp \
		--with-external-pa \
		--disable-libwebrtc \
		--disable-static

	# TODO: make it build with only shared libs from system
	# rm -r third_party
	make dep
	make all

	cd pjsip-apps/src/swig/python
	make
}

package() {
	install -d "$pkgdir"/usr/lib
	make -j1 DESTDIR="$pkgdir" prefix=/usr install
	rm -f "$pkgdir"/usr/lib/*.a

	cd pjsip-apps/src/swig/python
	python3 setup.py install --prefix=/usr --root="$pkgdir"
}

pjsua() {
	pkgdesc="Open source command line SIP user agent (softphone)"
	cd "$builddir"/pjsip-apps/bin/
	install -D -m755 pjsua "$subpkgdir"/usr/bin/pjsua
}

py3() {
	pkgdesc="$pkgdesc (Python bindings)"
	amove usr/lib/python*
}

sha512sums="
9087456024b8886e56660cebc45c7093b3b91cd6b08a3926fa2c0de452989ac84ceb4e27413c0311bde95f271341ee44d9681f81f83602a4e16151f1831d773b  pjproject-2.12.1.tar.gz
fe53b4e8a654dc4025a4bf6350f405953609abc9e7ed967882cb9eb9e6a659e348a0c3c7496c8093562a0dcc4a40459896d8ee1da7275dd089244338111bccbb  pjproject_no_third_party.patch
59337a5ddf5f989b1cb5644cc644f4b7efc17f8f92ef595667813662eaeee4ad25494a3386385b1114c604fd028f9b22f150cf32879c03e9255d737dee20f436  execinfo.patch
"