# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm/configs/htcleo_defconfig

pkgname=linux-htc-leo
pkgver=3.0.4
pkgrel=3
pkgdesc="HTC HD2 kernel fork"
arch="armv7"
_carch="arm"
_flavor="htc-leo"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="bash bc bison devicepkg-dev flex openssl-dev perl gcc4"

# Compiler: GCC4. Doesn't boot with newer versions of GCC
if [ "${CC:0:5}" != "gcc4-" ]; then
	CC="gcc4-$CC"
	HOSTCC="gcc4-gcc"
	CROSS_COMPILE="gcc4-$CROSS_COMPILE"
fi

# Source
#_repository="android_kernel_htc_qsd8k"
#_commit="917cc470bb9c5ef1655ecb49357db4917eaa8957"
_repository="android_kernel_htc_htcleo"
_commit="fb2ba086ea96647f38539664ebf0aa6eca61d7bb"
_config="config-$_flavor.$arch"
source="
	$pkgname-$_commit.tar.gz::https://github.com/qsd8k-legacy/$_repository/archive/$_commit.tar.gz
	$_config
	01-fix-compiler-path.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"

prepare() {
	default_prepare
	. downstreamkernel_prepare
}

build() {
	unset LDFLAGS
	make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}

package() {
	downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
}
sha512sums="5f324b69ff30284c0aabf16f9580726470eb54ce7edf6066e22d41d92e8be05085f9fb38fddeceee9cec4fb30cd68dda51585ff73ffbd4d52b154956aa81603e  linux-htc-leo-fb2ba086ea96647f38539664ebf0aa6eca61d7bb.tar.gz
06171936e4018f0d932aeb385256d5d773231573f77a9695951173bbc0d9f7a7e6ce4f1d388c3aba5bad10f07a44baf9434c8a18b72ea2668f8357a38ebb45d7  config-htc-leo.armv7
4166bdd725a00577c1319f1103ad802fc4699da3b5aae247c77b035880d21925d16c4faece72e93f59c933774dd912fc08082b07af03a90b664b7fa2865a61bc  01-fix-compiler-path.patch"
