add a way to configure code coverage
[citadel.git] / citadel / debian / rules
1 #!/usr/bin/make -f
2
3 # Uncomment this to turn on verbose mode.
4 #export DH_VERBOSE=1
5
6 # This has to be exported to make some magic below work.
7 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
8 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
9
10 export DH_OPTIONS
11
12 DEB_DESTDIR = $(CURDIR)/debian/tmp
13
14 CFLAGS = -Wall -g
15
16
17 EXTRA_ARGS=
18 PROFILE_ARGS=
19 #to enable debugging: export DEB_BUILD_OPTIONS="debug profiling threadoff rss gcov"
20 ifneq (,$(findstring profiling,$(DEB_BUILD_OPTIONS)))
21         PROFILE_ARGS= --with-gprof
22 endif
23 ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
24         CFLAGS += -O0 -ggdb -rdynamic -D_GNU_SOURCE -MD -MP -D TECH_PREVIEW
25         LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed
26         EXTRA_ARGS = --with-backtrace
27 else
28         LDFLAGS+=-Wl,--no-undefined -Wl,--as-needed
29         CFLAGS += -O2
30 endif
31
32 ifneq (,$(findstring threadoff,$(DEB_BUILD_OPTIONS)))
33         THREAD_ARGS=--without-threaded-client
34         CFLAGS += -D WITH_THREADLOG
35 else
36         THREAD_ARGS=
37 endif
38
39
40 ifneq (,$(findstring rss,$(DEB_BUILD_OPTIONS)))
41         CFLAGS += -D DEBUG_RSS
42 endif
43
44 ifneq (,$(findstring iodbg,$(DEB_BUILD_OPTIONS)))
45         CFLAGS += -D BIGBAD_IODBG
46 endif
47
48 ifneq (,$(findstring gcov,$(DEB_BUILD_OPTIONS)))
49         CFLAGS += -fprofile-arcs -ftest-coverage
50         LDFLAGS += -fprofile-arcs -ftest-coverage
51 endif
52
53 configure: configure-stamp
54 configure-stamp:
55         dh_testdir
56
57         LDFLAGS="$(LDFLAGS)"; CFLAGS="$(CFLAGS)" ./configure \
58                 --prefix=/var/lib/citadel/ \
59                 --with-datadir=/var/lib/citadel/ \
60                 --with-helpdir=/usr/share/citadel-server/ \
61                 --with-staticdatadir=/etc/citadel/ \
62                 --with-spooldir=/var/spool/citadel/ \
63                 --with-sysconfdir=/etc/citadel/ \
64                 --with-rundir=/var/run/citadel/ \
65                 --with-docdir=/usr/share/doc/citadel-doc/ \
66                 --with-ssldir=/etc/ssl/citadel/ \
67                 --with-utility-bindir=/usr/lib/citadel-server/ \
68                 --with-autosysconfdir=/var/lib/citadel/data/ \
69                 --with-localedir=/usr/share/ \
70                 --with-pam \
71                 --with-db \
72                 --enable-debug $(EXTRA_ARGS) $(PROFILE_ARGS) $(THREAD_ARGS)
73
74         touch configure-stamp
75
76 #Architecture 
77 build: build-arch build-indep
78
79 build-arch: build-arch-stamp
80 build-arch-stamp: configure-stamp
81
82         $(MAKE)
83         touch $@
84
85 build-indep: build-indep-stamp
86 build-indep-stamp: configure-stamp
87
88         touch $@
89
90 clean:
91         dh_testdir
92         dh_testroot
93         rm -f build-arch-stamp build-indep-stamp configure-stamp
94
95
96         dh_clean 
97         rm -f config.status config.log
98 #[ ! -f Makefile ] || $(MAKE) distclean
99
100 install: install-indep install-arch
101 install-indep: build-indep
102         dh_testdir
103         dh_testroot
104         dh_clean -k -i 
105         dh_installdirs -i
106
107         $(MAKE) DESTDIR=$(DEB_DESTDIR) install-doc-new
108
109         dh_install -i --sourcedir=debian/tmp
110
111 install-arch: build-arch
112         dh_testdir
113         dh_testroot
114         dh_clean -k -s 
115         dh_installdirs -s
116
117         $(MAKE) install-locale DESTDIR=$(DEB_DESTDIR)
118         $(MAKE) DESTDIR=$(DEB_DESTDIR) install-exec-new install-data-new
119
120         install -D -p -m0755 database_cleanup.sh \
121                 $(DEB_DESTDIR)/usr/share/doc/citadel-server/examples/database_cleanup.sh
122
123         install -D -p -m0644 docs/welcomemail.html \
124                 $(DEB_DESTDIR)/usr/share/doc/citadel-server/welcomemail.html
125
126         install -D -p -m0644 docs/welcomemail.txt \
127                 $(DEB_DESTDIR)/usr/share/doc/citadel-server/welcomemail.txt
128
129         dh_install -s --sourcedir=debian/tmp
130
131 binary-common:
132         dh_testdir
133         dh_testroot
134         dh_installchangelogs
135         dh_installdocs
136         dh_installdebconf       
137         dh_installinit --name=citadel
138         dh_installman
139         dh_strip --dbg-package=citadel-dbg
140         dh_link
141         dh_compress 
142         dh_fixperms
143         dh_makeshlibs
144         dh_installdeb
145         dh_shlibdeps
146         dh_gencontrol
147         dh_md5sums
148         dh_builddeb
149
150 # Build architecture independant packages using the common target.
151 binary-indep: build-indep install-indep
152         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
153
154 # Build architecture dependant packages using the common target.
155 binary-arch: build-arch install-arch
156         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
157
158 binary: binary-arch binary-indep
159 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure