aboutsummaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 7f2fc811d7d91149ddc68a47638ae844e5ee80e1 (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/make -f
#
# Finally switching to debhelper.
#
# Not using debhelper was an exercise suggested to me by my AM (Gergely
# Nagy). It was educating at the time but I finally decided that the
# exercise is over now.
#

# Include the bitlbee-libpurple variant and OTR plugin by default.
BITLBEE_LIBPURPLE ?= 1
BITLBEE_OTR ?= plugin
BITLBEE_CONFIGURE_FLAGS ?=
DEBUG ?= 0

ifndef BITLBEE_VERSION
# Want to use the full package version number instead of just the release.
BITLBEE_CONFIGURE_VERSION ?= BITLBEE_VERSION="$(shell dpkg-parsechangelog | awk '/^Version:/ {print $$2}')"
endif

ifneq ($(BITLBEE_LIBPURPLE),1)
DH_OPTIONS += -Nbitlbee-libpurple
endif

ifneq ($(BITLBEE_OTR),plugin)
DH_OPTIONS += -Nbitlbee-plugin-otr
endif

CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)

CONFIGURE_OVERRIDES:=CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"

HAS_DH_SYSTEMD:=$(shell dpkg-query -W -f='$${Status}' dh-systemd 2>/dev/null | grep -c "ok installed")

# No difference at the build stage so just call main build target.
# (Well indep could be docs-only but we prebuild them plus it's really
# not that much work.)
build-arch build-indep: build

build: build-stamp
build-stamp:
	dh_testdir

	mkdir -p debian/build-native
	ROOT=$$PWD; cd debian/build-native; $(BITLBEE_CONFIGURE_VERSION) $(CONFIGURE_OVERRIDES) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent --otr=$(BITLBEE_OTR) $(BITLBEE_CONFIGURE_FLAGS)
	$(MAKE) -C debian/build-native

ifeq ($(BITLBEE_LIBPURPLE),1)
	mkdir -p debian/build-libpurple
	ROOT=$$PWD; cd debian/build-libpurple; $(BITLBEE_CONFIGURE_VERSION) $(CONFIGURE_OVERRIDES) $$ROOT/configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --purple=1 $(BITLBEE_CONFIGURE_FLAGS)
	$(MAKE) -C debian/build-libpurple
endif

	$(MAKE) -C doc
	$(MAKE) -C doc/user-guide

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp

	rm -rf build-arch-stamp debian/build-* debian/bitlbee-libpurple.prerm
	$(MAKE) distclean

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	$(MAKE) -C debian/build-native install-bin DESTDIR=`pwd`/debian/bitlbee
	$(MAKE) -C debian/build-native install-etc install-doc DESTDIR=`pwd`/debian/bitlbee-common
	$(MAKE) -C debian/build-native install-dev DESTDIR=`pwd`/debian/bitlbee-dev
	$(MAKE) -C debian/build-native install-plugin-otr DESTDIR=`pwd`/debian/bitlbee-plugin-otr

ifeq ($(HAS_DH_SYSTEMD),1)
	$(MAKE) -C debian/build-native install-systemd DESTDIR=`pwd`/debian/bitlbee-common
endif

ifeq ($(BITLBEE_LIBPURPLE),1)
	$(MAKE) -C debian/build-libpurple install-bin DESTDIR=`pwd`/debian/bitlbee-libpurple
	ln -sf debian/bitlbee.prerm debian/bitlbee-libpurple.prerm
endif

	patch debian/bitlbee-common/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff
	chmod 640 debian/bitlbee-common/etc/bitlbee/bitlbee.conf

binary-common:
	dh_testdir
	dh_testroot

	dh_installchangelogs doc/CHANGES
	dh_installexamples
	dh_installdocs #--link-doc=bitlbee-common
	# TODO: Restore --link-doc up here and remove the hack below once
	# Hardy and Lenny are deprecated.
	for p in bitlbee bitlbee-libpurple bitlbee-dev bitlbee-plugin-otr; do rm -r debian/$$p/usr/share/doc/$$p && ln -s bitlbee-common debian/$$p/usr/share/doc/$$p || true; done
	dh_installdebconf
ifeq ($(HAS_DH_SYSTEMD),1)
	dh_systemd_enable -p bitlbee-common --no-enable bitlbee.socket
	dh_systemd_enable -p bitlbee-common bitlbee.service
	dh_installinit -p bitlbee-common --init-script=bitlbee
	dh_systemd_start -p bitlbee-common
else
	dh_installinit -p bitlbee-common --init-script=bitlbee
endif
	dh_installman
	dh_lintian
	dh_strip
	dh_link
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-indep: build install
	DH_OPTIONS=-i $(MAKE) -f debian/rules binary-common

binary-arch: build install
	DH_OPTIONS=-a $(MAKE) -f debian/rules binary-common

binary-%: build install
	DH_OPTIONS=-p$* $(MAKE) -f debian/rules binary-common

binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary-common binary install