summaryrefslogtreecommitdiff
path: root/debian/rules
blob: 1ef40f83886e105e9090d3ef3c42c756282a47f6 (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
#!/usr/bin/make -f
# by Gergely Nagy <8@free.bsd.hu>
# patch and unpatch based on debian/rules.d/patch.mk in glibc-2.1.95-1

export DH_COMPAT=2
CFLAGS	= -O2
ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
	CFLAGS += -g
endif

configure: patch configure-stamp
configure-stamp:
	dh_testdir
	CFLAGS="$(CFLAGS)" ./configure --prefix=/usr \
				       --infodir=/usr/share/info \
				       --mandir=/usr/share/man
	touch configure-stamp

patch: patch-stamp
patch-stamp:
	test -d debian/patched || install -d debian/patched
	@echo "Patches applied in the Debian version of ratpoison:" > $@T
	@for patch in `cat debian/patches/00list`; do \
		stamp=debian/patched/$$patch.dpatch; \
		patch=debian/patches/$$patch.dpatch; \
		test -x $$patch || chmod +x $$patch; \
		if test -f $$stamp; then \
			echo "$$patch already applied."; \
			echo -e "\n$$patch:" >> $@T; \
			sed -n 's/^# *DP: */  /p' $$patch >> $@T; \
		else \
			echo "trying to apply patch $$patch..."; \
			if $$patch -patch >$$stamp.new 2>&1; then \
				mv $$stamp.new $$stamp; \
				touch $$stamp; \
				echo -e "\n$$patch:" >> $@T; \
				sed -n 's/^# *DP: */  /p' $$patch >> $@T; \
			else \
				echo "error in applying $$patch patch."; \
				exit 1; \
			fi; \
		fi; \
	done
	mv -f $@T $@

unpatch:
	@for patch in `tac debian/patches/00list`; do \
		stamp=debian/patched/$$patch.dpatch; \
		patch=debian/patches/$$patch.dpatch; \
		test -x $$patch || chmod +x $$patch; \
		if test -f $$stamp; then \
			echo "trying to revert patch $$patch..."; \
			if $$patch -unpatch; then \
				echo "reverted $$patch patch."; \
				rm -f $$stamp; \
			else \
				echo "error in reverting $$patch patch."; \
				exit 1; \
			fi; \
		fi; \
	done
	rm -f patch-stamp

build: configure build-stamp
build-stamp:
	dh_testdir
	$(MAKE)
	touch build-stamp

clean: clean1 unpatch
clean1:
	dh_testdir
	dh_testroot
	rm -f build-stamp configure-stamp patch-stamp
	-$(MAKE) distclean
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs
	$(MAKE) install prefix=`pwd`/debian/`dh_listpackages`/usr

binary-indep: build install

binary-arch: build install
	dh_testversion 2.0.89
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installexamples
	dh_installmenu
	dh_installmanpages
	dh_installinfo
	dh_installchangelogs src/ChangeLog
	dh_installwm
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install unpatch \
	clean1 patch configure