aboutsummaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 33c1119e0284ba0f095d67bbef59f97781980ab9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/make -f
#
# Generally nothing needs to be modified below this line
#
SHELL    := sh -e
DEB_HOST_ARCH  := $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
SOURCE   := $(shell dpkg-parsechangelog | sed -ne 's,^Source: *\(.*\)$$,\1,p')
VERSION  := $(shell dpkg-parsechangelog | sed -ne 's,^Version: *\(.*\)-[^-]*$$,\1,p')

include debian/rules.defs

source: debian/control $(STAMPS_DIR)/source-base
$(STAMPS_DIR)/source-base: $(BUILD_DIR) $(STAMPS_DIR)
	dh_testdir
	$(MAKE) -f debian/rules.gen source-$(DEB_HOST_ARCH)
	touch $@

source-all: debian/control $(BUILD_DIR) $(STAMPS_DIR)
	dh_testdir
	$(MAKE) -f debian/rules.gen source

setup: debian/control $(STAMPS_DIR)/setup-base
$(STAMPS_DIR)/setup-base: $(STAMPS_DIR)/source-base
	dh_testdir
	$(MAKE) -f debian/rules.gen setup-$(DEB_HOST_ARCH)
	touch $@

build: debian/control $(STAMPS_DIR)/build-base
$(STAMPS_DIR)/build-base: $(STAMPS_DIR)/setup-base
	dh_testdir
	$(MAKE) -f debian/rules.gen build-$(DEB_HOST_ARCH)
	touch $@

$(BUILD_DIR) $(STAMPS_DIR):
	@[ -d $@ ] || mkdir $@

DIR_ORIG = ../orig/$(SOURCE)-$(VERSION)
TAR_ORIG = ../$(SOURCE)_$(VERSION).orig.tar.gz

orig: $(DIR_ORIG)
	rsync --delete --exclude debian --exclude .svn --link-dest=$(DIR_ORIG)/ -a $(DIR_ORIG)/ .

$(DIR_ORIG):
	if [ -f $(TAR_ORIG) ]; then \
		mkdir -p ../orig; \
		tar -C ../orig -xzf $(TAR_ORIG); \
	else \
		echo "Can't find orig tarball." >&2; \
		exit 1; \
	fi

maintainerclean:
	rm -f debian/control debian/control.md5sum debian/rules.gen debian/bin/patch.* debian/linux-*
	rm -rf $(filter-out debian .svn, $(wildcard * .[^.]*))

clean: debian/control
	dh_testdir
	rm -rf $(BUILD_DIR) $(STAMPS_DIR) debian/lib/python/debian_linux/*.pyc
	dh_clean

binary-indep: $(STAMPS_DIR)/source-base
	dh_testdir
	$(MAKE) -f debian/rules.gen binary-indep

binary-arch: $(STAMPS_DIR)/build-base
	dh_testdir
	$(MAKE) -f debian/rules.gen binary-arch-$(DEB_HOST_ARCH)

binary:	binary-indep binary-arch

#
# Makes the master debian/control file by substituting
# variable values into the template.
#
CONTROL_FILES = debian/changelog $(wildcard debian/templates/*) 
CONTROL_FILES += debian/arch/defines $(wildcard debian/arch/*/defines) $(wildcard debian/arch/*/*/defines)
debian/control debian/rules.gen: debian/bin/gencontrol.py $(CONTROL_FILES)
	if [ -f debian/control.md5sum ]; then \
		if md5sum $^ | diff - debian/control.md5sum > /dev/null; then true; else \
			$(MAKE) -f debian/rules debian/control-real; \
		fi \
	else \
		$(MAKE) -f debian/rules debian/control-real; \
	fi

debian/control-real: debian/bin/gencontrol.py $(CONTROL_FILES)
	chmod +x $<
	$<
	md5sum $^ > debian/control.md5sum
	@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
	exit 1

#
# Rule to check all configs snipplets in debian/arch
#

CheckConfs_DIR := $(BUILD_DIR)/check

$(CheckConfs_DIR) source-configs: debian/control $(BUILD_DIR) $(STAMPS_DIR)
	$(MAKE) -f debian/rules.gen setup-$(DEB_HOST_ARCH)-real
	rm -rf '$(CheckConfs_DIR)'
	cp -al $(BUILD_DIR)/source $(CheckConfs_DIR)

check-configs: $(CheckConfs_DIR)
	@echo "Checking all configuration files"
	ocaml debian/bin/kconfig.ml -c -b "debian/arch"

clean-configs:
	rm -rf '$(CheckConfs_DIR)'

.PHONY: clean build setup binary-indep binary-arch binary