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