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