1SUMMARY="A generic-purpose lossless compression algorithm"
2DESCRIPTION="A generic-purpose lossless compression algorithm that \
3compresses data using a combination of a modern variant of the LZ77 algorithm, \
4Huffman coding and 2nd order context modeling, with a compression ratio \
5comparable to the best currently available general-purpose compression \
6methods. It is similar in speed with deflate but offers more dense compression."
7HOMEPAGE="https://github.com/google/brotli"
8COPYRIGHT="2009, 2010, 2013-2023 Brotli Authors"
9LICENSE="MIT"
10REVISION="1"
11SOURCE_URI="https://github.com/google/brotli/archive/v$portVersion.tar.gz"
12CHECKSUM_SHA256="e720a6ca29428b803f4ad165371771f5398faba397edf6778837a18599ea13ff"
13SOURCE_FILENAME="brotli-$portVersion.tar.gz"
14
15ARCHITECTURES="all !x86_gcc2"
16SECONDARY_ARCHITECTURES="x86"
17
18# For now the library will follow $portVersion,
19# but upstream said that will change in the future.
20libVersion="$portVersion"
21libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
22
23PROVIDES="
24	brotli$secondaryArchSuffix = $portVersion
25	cmd:brotli$secondaryArchSuffix = $portVersion
26	lib:libbrotlicommon$secondaryArchSuffix = $libVersionCompat
27	lib:libbrotlidec$secondaryArchSuffix = $libVersionCompat
28	lib:libbrotlienc$secondaryArchSuffix = $libVersionCompat
29	"
30REQUIRES="
31	haiku$secondaryArchSuffix
32	"
33
34PROVIDES_devel="
35	brotli${secondaryArchSuffix}_devel = $portVersion
36	devel:libbrotlicommon$secondaryArchSuffix = $libVersionCompat
37	devel:libbrotlicommon_static$secondaryArchSuffix = $libVersion
38	devel:libbrotlidec$secondaryArchSuffix = $libVersionCompat
39	devel:libbrotlidec_static$secondaryArchSuffix = $libVersion
40	devel:libbrotlienc$secondaryArchSuffix = $libVersionCompat
41	devel:libbrotlienc_static$secondaryArchSuffix = $libVersion
42	"
43REQUIRES_devel="
44	brotli$secondaryArchSuffix == $portVersion base
45	"
46
47BUILD_REQUIRES="
48	haiku${secondaryArchSuffix}_devel
49	"
50BUILD_PREREQUIRES="
51	cmd:cmake
52	cmd:g++$secondaryArchSuffix
53	cmd:gcc$secondaryArchSuffix
54	cmd:make
55	"
56
57PYTHON_PACKAGES+=(python310)
58PYTHON_VERSIONS+=(3.10)
59for i in "${!PYTHON_PACKAGES[@]}"; do
60	pythonPackage=${PYTHON_PACKAGES[i]}
61	pythonVersion=${PYTHON_VERSIONS[$i]}
62
63	eval "PROVIDES_${pythonPackage}=\"
64		${portName}_$pythonPackage = $portVersion
65		\""
66	eval "REQUIRES_$pythonPackage=\"
67		haiku$secondaryArchSuffix
68		lib:libpython$pythonVersion$secondaryArchSuffix
69		\""
70	BUILD_REQUIRES+="
71		setuptools_$pythonPackage
72		"
73	BUILD_PREREQUIRES+="
74		cmd:python$pythonVersion
75		"
76done
77
78
79BUILD()
80{
81	cmake \
82		-B build -S . \
83		-DCMAKE_BUILD_TYPE=Release \
84		-DCMAKE_INSTALL_LIBDIR=$libDir \
85		-DCMAKE_INSTALL_BINDIR=$binDir \
86		-DCMAKE_INSTALL_INCLUDEDIR=$includeDir \
87		-DBROTLI_DISABLE_TESTS=OFF
88
89	make -C build $jobArgs
90}
91
92
93INSTALL()
94{
95	make -C build install
96
97	for i in "${!PYTHON_PACKAGES[@]}"; do
98		pythonPackage=${PYTHON_PACKAGES[i]}
99		pythonVersion=${PYTHON_VERSIONS[$i]}
100
101		python=python$pythonVersion
102		installLocation=$prefix/lib/$python/vendor-packages/
103		export PYTHONPATH=$installLocation:$PYTHONPATH
104
105		mkdir -p $installLocation
106		rm -rf build
107
108		$python setup.py build install \
109			--root=/ --prefix=$prefix
110
111		packageEntries $pythonPackage \
112			"$prefix"/lib/$python
113	done
114
115	install -d -m 755 "$manDir"/man{1,3}
116	install -t "$manDir/man1" docs/brotli.1
117	install -t "$manDir/man3" docs/*.3
118
119	prepareInstalledDevelLibs libbrotli{common,dec,enc}
120	fixPkgconfig
121
122	packageEntries devel \
123		"$manDir/man3" \
124		"$developDir"
125}
126
127
128TEST()
129{
130
131	for i in "${!PYTHON_PACKAGES[@]}"; do
132		pythonVersion=${PYTHON_VERSIONS[$i]}
133
134		python=python$pythonVersion
135		$python setup.py test
136	done
137}
138