1d9287ea8SMasahiro Yamada#!/usr/bin/make -f 2d9287ea8SMasahiro Yamada# SPDX-License-Identifier: GPL-2.0-only 3d9287ea8SMasahiro Yamada 45e73758bSMasahiro Yamada# in case debian/rules is executed directly 55e73758bSMasahiro Yamadaexport DEB_RULES_REQUIRES_ROOT := no 65e73758bSMasahiro Yamada 7d9287ea8SMasahiro Yamadainclude debian/rules.vars 8d9287ea8SMasahiro Yamada 9ed79c34dSMasahiro Yamadaifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))) 10ed79c34dSMasahiro Yamada NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) 11ed79c34dSMasahiro Yamada MAKEFLAGS += -j$(NUMJOBS) 12ed79c34dSMasahiro Yamadaendif 13ed79c34dSMasahiro Yamada 14cc3df32cSMasahiro Yamada# When KBUILD_VERBOSE is undefined (presumably you are directly working with 15cc3df32cSMasahiro Yamada# the debianized tree), show verbose logs unless DEB_BUILD_OPTION=terse is set. 16cc3df32cSMasahiro Yamadaifeq ($(origin KBUILD_VERBOSE),undefined) 17cc3df32cSMasahiro Yamada ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS))) 18cc3df32cSMasahiro Yamada export KBUILD_VERBOSE := 1 19*caf400c8SMasahiro Yamada else 20*caf400c8SMasahiro Yamada Q := @ 21cc3df32cSMasahiro Yamada endif 22cc3df32cSMasahiro Yamadaendif 23cc3df32cSMasahiro Yamada 247d4f07d5SMasahiro Yamadarevision = $(lastword $(subst -, ,$(shell dpkg-parsechangelog -S Version))) 257d4f07d5SMasahiro YamadaCROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-) 267d4f07d5SMasahiro Yamadamake-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE)) 27466e6fc4SMasahiro Yamada 28d9287ea8SMasahiro Yamada.PHONY: binary binary-indep binary-arch 29d9287ea8SMasahiro Yamadabinary: binary-arch binary-indep 30d9287ea8SMasahiro Yamadabinary-indep: build-indep 31d9287ea8SMasahiro Yamadabinary-arch: build-arch 32*caf400c8SMasahiro Yamada $(Q)$(MAKE) $(make-opts) \ 33eaf80f7fSMasahiro Yamada run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb' 34d9287ea8SMasahiro Yamada 35d9287ea8SMasahiro Yamada.PHONY: build build-indep build-arch 36d9287ea8SMasahiro Yamadabuild: build-arch build-indep 37d9287ea8SMasahiro Yamadabuild-indep: 38d9287ea8SMasahiro Yamadabuild-arch: 39*caf400c8SMasahiro Yamada $(Q)$(MAKE) $(make-opts) olddefconfig 40*caf400c8SMasahiro Yamada $(Q)$(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all 41d9287ea8SMasahiro Yamada 42d9287ea8SMasahiro Yamada.PHONY: clean 43d9287ea8SMasahiro Yamadaclean: 44*caf400c8SMasahiro Yamada $(Q)rm -rf debian/files debian/linux-* debian/deb-env.vars* 45*caf400c8SMasahiro Yamada $(Q)$(MAKE) ARCH=$(ARCH) clean 46159956f3SMasahiro Yamada 47159956f3SMasahiro Yamada# If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed 48159956f3SMasahiro Yamada# directly. Run 'dpkg-architecture --print-set --print-format=make' to 49159956f3SMasahiro Yamada# generate a makefile construct that exports all DEB_* variables. 50159956f3SMasahiro Yamadaifndef DEB_HOST_ARCH 51159956f3SMasahiro Yamadainclude debian/deb-env.vars 52159956f3SMasahiro Yamada 53159956f3SMasahiro Yamadadebian/deb-env.vars: 54*caf400c8SMasahiro Yamada $(Q)dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@.tmp 55*caf400c8SMasahiro Yamada $(Q)mv $@.tmp $@ 56159956f3SMasahiro Yamadaendif 57