xref: /linux/scripts/package/debian/rules (revision ea518afc992032f7570c0a89ac9240b387dc0faf)
1#!/usr/bin/make -f
2# SPDX-License-Identifier: GPL-2.0-only
3
4# in case debian/rules is executed directly
5export DEB_RULES_REQUIRES_ROOT := no
6
7include debian/rules.vars
8
9ifneq (,$(filter-out parallel=1,$(filter parallel=%,$(DEB_BUILD_OPTIONS))))
10    NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
11    MAKEFLAGS += -j$(NUMJOBS)
12endif
13
14revision = $(lastword $(subst -, ,$(shell dpkg-parsechangelog -S Version)))
15CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-)
16make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE))
17
18.PHONY: binary binary-indep binary-arch
19binary: binary-arch binary-indep
20binary-indep: build-indep
21binary-arch: build-arch
22	$(MAKE) $(make-opts) \
23	run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb'
24
25.PHONY: build build-indep build-arch
26build: build-arch build-indep
27build-indep:
28build-arch:
29	$(MAKE) $(make-opts) olddefconfig
30	$(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all
31
32.PHONY: clean
33clean:
34	rm -rf debian/files debian/linux-* debian/deb-env.vars*
35	$(MAKE) ARCH=$(ARCH) clean
36
37# If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed
38# directly. Run 'dpkg-architecture --print-set --print-format=make' to
39# generate a makefile construct that exports all DEB_* variables.
40ifndef DEB_HOST_ARCH
41include debian/deb-env.vars
42
43debian/deb-env.vars:
44	dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@.tmp
45	mv $@.tmp $@
46endif
47