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