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