#!/usr/bin/make -f
# SPDX-License-Identifier: GPL-2.0-only

# This rules file is a adjusted version of the upstream template file
# The original can be found in scripts/package/debian/

include debian/rules.vars

srctree ?= .

build: build-arch build-indep
build-indep:
build-arch:
	$(MAKE) \
	-f $(srctree)/Makefile \
	ARCH=$(ARCH) \
	KERNELRELEASE=${version} \
	KBUILD_BUILD_USER=$(USER_OVERRIDE) \
	KBUILD_BUILD_HOST=$(HOST_OVERRIDE) \
	defconfig ti_arm64_prune.config balluff.config ti_rt.config

	$(MAKE) \
	-f $(srctree)/Makefile \
	-j $(shell nproc) \
	ARCH=$(ARCH) \
	CROSS_COMPILE=$(CC) \
	KERNELRELEASE=$(KERNELRELEASE)-$(LOCALVERSION) \
	KBUILD_BUILD_USER=$(USER_OVERRIDE) \
	KBUILD_BUILD_HOST=$(HOST_OVERRIDE) \
	all

binary: binary-arch binary-indep
binary-indep: build-indep
binary-arch: build-arch
	$(MAKE) \
	-f $(srctree)/Makefile \
	ARCH=$(ARCH) \
	CROSS_COMPILE=$(CC) \
	KERNELRELEASE=$(KERNELRELEASE)-$(LOCALVERSION) \
	KBUILD_BUILD_USER=$(USER_OVERRIDE) \
	KBUILD_BUILD_HOST=$(HOST_OVERRIDE) \
	KDEB_COMPRESS=$(BINARY_COMPRESS) \
	KBUILD_RUN_COMMAND=+$(srctree)/scripts/package/builddeb \
	run-command

clean:
	rm -rf debian/files debian/linux-*

	$(MAKE) \
	-f $(srctree)/Makefile \
	ARCH=$(ARCH) \
	clean

