xref: /linux/scripts/package/debian/rules (revision cc3df32c9f3a99f715c551f76b040fcf2e5050a5)
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
14# When KBUILD_VERBOSE is undefined (presumably you are directly working with
15# the debianized tree), show verbose logs unless DEB_BUILD_OPTION=terse is set.
16ifeq ($(origin KBUILD_VERBOSE),undefined)
17    ifeq (,$(filter terse,$(DEB_BUILD_OPTIONS)))
18        export KBUILD_VERBOSE := 1
19    endif
20endif
21
22revision = $(lastword $(subst -, ,$(shell dpkg-parsechangelog -S Version)))
23CROSS_COMPILE ?= $(filter-out $(DEB_BUILD_GNU_TYPE)-, $(DEB_HOST_GNU_TYPE)-)
24make-opts = ARCH=$(ARCH) KERNELRELEASE=$(KERNELRELEASE) KBUILD_BUILD_VERSION=$(revision) $(addprefix CROSS_COMPILE=,$(CROSS_COMPILE))
25
26.PHONY: binary binary-indep binary-arch
27binary: binary-arch binary-indep
28binary-indep: build-indep
29binary-arch: build-arch
30	$(MAKE) $(make-opts) \
31	run-command KBUILD_RUN_COMMAND='+$$(srctree)/scripts/package/builddeb'
32
33.PHONY: build build-indep build-arch
34build: build-arch build-indep
35build-indep:
36build-arch:
37	$(MAKE) $(make-opts) olddefconfig
38	$(MAKE) $(make-opts) $(if $(filter um,$(ARCH)),,headers) all
39
40.PHONY: clean
41clean:
42	rm -rf debian/files debian/linux-* debian/deb-env.vars*
43	$(MAKE) ARCH=$(ARCH) clean
44
45# If DEB_HOST_ARCH is empty, it is likely that debian/rules was executed
46# directly. Run 'dpkg-architecture --print-set --print-format=make' to
47# generate a makefile construct that exports all DEB_* variables.
48ifndef DEB_HOST_ARCH
49include debian/deb-env.vars
50
51debian/deb-env.vars:
52	dpkg-architecture -a$$(cat debian/arch) --print-set --print-format=make > $@.tmp
53	mv $@.tmp $@
54endif
55