rules 3.75 KB
Newer Older
1
#!/usr/bin/make -f
Bastian Blank's avatar
Bastian Blank committed
2

3
SHELL    := sh -e
Bastian Blank's avatar
Bastian Blank committed
4
DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
5 6
SOURCE := $(shell dpkg-parsechangelog -SSource)
VERSION := $(shell dpkg-parsechangelog -SVersion)
Bastian Blank's avatar
Bastian Blank committed
7
VERSION_UPSTREAM := $(shell echo "$(VERSION)" | sed -e 's,-[^-]*$$,,')
8
VERSION_BINNMU := $(shell echo "$(VERSION)" | sed -rne 's,.*\+b([0-9]+)$$,\1,p')
9

10
include debian/rules.defs
11

12 13 14 15 16 17
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
  DEBIAN_KERNEL_JOBS := $(subst parallel=,,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
endif
ifdef DEBIAN_KERNEL_JOBS
  MAKEFLAGS += -j$(DEBIAN_KERNEL_JOBS)
endif
18
BUILD_STAGE1 := $(filter stage1,$(DEB_BUILD_PROFILES))
19 20 21
ifneq (,$(filter pkg.linux.notools,$(DEB_BUILD_PROFILES)))
  MAKEFLAGS += DO_TOOLS=False
endif
22

23 24
.NOTPARALLEL:

25
source: debian/control
26 27 28
	dh_testdir
	$(MAKE) -f debian/rules.gen source

29
setup: debian/control
30
	dh_testdir
31
	$(MAKE) -f debian/rules.gen setup_$(DEB_HOST_ARCH)
32

33 34
build: build-arch build-indep

35
build-arch: debian/control
36
	dh_testdir
37
ifndef BUILD_STAGE1
38
	$(MAKE) -f debian/rules.gen build-arch_$(DEB_HOST_ARCH)
39
endif
40

41
build-indep: debian/control
42
	dh_testdir
43
ifndef BUILD_STAGE1
44
	$(MAKE) -f debian/rules.gen build-indep
45
endif
46

47 48
binary:	binary-indep binary-arch

49
binary-arch: build-arch
50
	dh_testdir
51 52 53
ifdef BUILD_STAGE1
	$(MAKE) -f debian/rules.gen binary-libc-dev_$(DEB_HOST_ARCH)
else
54
	$(MAKE) -f debian/rules.gen binary-arch_$(DEB_HOST_ARCH)
55
endif
56

57
binary-indep: build-indep
58
	dh_testdir
59
ifndef BUILD_STAGE1
60
	$(MAKE) -f debian/rules.gen binary-indep
61
endif
62

Bastian Blank's avatar
Bastian Blank committed
63
DIR_ORIG = ../orig/$(SOURCE)-$(VERSION_UPSTREAM)
64
TAR_ORIG_NAME = $(SOURCE)_$(VERSION_UPSTREAM).orig.tar.xz
65
TAR_ORIG = $(firstword $(wildcard ../$(TAR_ORIG_NAME)) $(wildcard ../orig/$(TAR_ORIG_NAME)))
66

67
orig: $(DIR_ORIG)
68
	rsync --delete --exclude /debian --exclude .svk --exclude .svn --exclude .git --link-dest=$(DIR_ORIG)/ -a $(DIR_ORIG)/ .
69
	QUILT_PATCHES='$(CURDIR)/debian/patches' QUILT_PC=.pc quilt push --quiltrc - -a -q --fuzz=0
70 71

$(DIR_ORIG):
72 73 74
ifeq ($(TAR_ORIG),)
	$(error Cannot find orig tarball $(TAR_ORIG_NAME))
else
Bastian Blank's avatar
Bastian Blank committed
75
	mkdir -p ../orig
76
	tar -C ../orig -xaf $(TAR_ORIG)
77
endif
78

Bastian Blank's avatar
Bastian Blank committed
79
maintainerclean:
80
	rm -f debian/config.defines.dump debian/control debian/control.md5sum debian/linux-headers-* debian/linux-image-* debian/rules.gen
81
	rm -rf $(filter-out debian .svk .svn .git, $(wildcard * .[^.]*))
Bastian Blank's avatar
Bastian Blank committed
82

Bastian Blank's avatar
Bastian Blank committed
83
clean: debian/control
84
	dh_testdir
85
	rm -rf $(BUILD_DIR) $(STAMPS_DIR) debian/lib/python/debian_linux/*.pyc debian/lib/python/debian_linux/__pycache__ $$(find debian -maxdepth 1 -type d -name 'linux-*') debian/*-modules-*-di* debian/kernel-image-*-di* debian/xen-linux-system-* debian/*-tmp
86
	dh_clean
87

88
CONTROL_FILES = debian/changelog $(wildcard debian/templates/*.in)
89
CONTROL_FILES += debian/config/defines $(wildcard debian/config/*/defines) $(wildcard debian/config/*/*/defines)
90
CONTROL_FILES += $(wildcard debian/installer/*/kernel-versions) $(wildcard debian/installer/*/package-list) debian/installer/package-list
91
debian/control debian/rules.gen: debian/bin/gencontrol.py $(CONTROL_FILES)
92 93
ifeq ($(wildcard debian/control.md5sum),)
	$(MAKE) -f debian/rules debian/control-real
Bastian Blank's avatar
Bastian Blank committed
94
else ifeq ($(VERSION_BINNMU),)
95 96 97 98 99 100
	md5sum --check debian/control.md5sum --status || \
		$(MAKE) -f debian/rules debian/control-real
else
	grep -v debian/changelog debian/control.md5sum | md5sum --check - --status || \
		$(MAKE) -f debian/rules debian/control-real
endif
101

102
debian/control-real: debian/bin/gencontrol.py $(CONTROL_FILES)
103 104
# Hash randomisation makes the pickled config unreproducible
	PYTHONHASHSEED=0 $<
105
	md5sum $^ > debian/control.md5sum
106 107 108 109 110 111
	@echo
	@echo This target is made to fail intentionally, to make sure
	@echo that it is NEVER run during the automated build. Please
	@echo ignore the following error, the debian/control file has
	@echo been generated SUCCESSFULLY.
	@echo
112
	exit 1
113

Bastian Blank's avatar
Bastian Blank committed
114
.PHONY: clean build setup binary-indep binary-arch binary