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