'Network User' is now 'Normal User'
[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 -Werror=format-security 
15
16 COMPILER=
17 EXTRA_ARGS=
18 PROFILE_ARGS=
19 #to enable debugging: export DEB_BUILD_OPTIONS="debug profiling threadoff rss gcov clang cares"
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 -Wcast-align
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 cares,$(DEB_BUILD_OPTIONS)))
58         CFLAGS += -D DEBUG_CARES
59 endif
60
61 ifneq (,$(findstring iodbg,$(DEB_BUILD_OPTIONS)))
62         CFLAGS += -D BIGBAD_IODBG -D LDAP_INITIALIZE
63 endif
64
65 ifneq (,$(findstring gcov,$(DEB_BUILD_OPTIONS)))
66         CFLAGS += -fprofile-arcs -ftest-coverage
67         LDFLAGS += -fprofile-arcs -ftest-coverage
68 endif
69
70 configure: configure-stamp
71 configure-stamp:
72         dh_testdir
73
74         export CC=$(COMPILER); export LDFLAGS="$(LDFLAGS)"; export CFLAGS="$(CFLAGS)"; ./configure \
75                 --prefix=/var/lib/citadel/ \
76                 --with-datadir=/var/lib/citadel/ \
77                 --with-helpdir=/usr/share/citadel-server/ \
78                 --with-staticdatadir=/etc/citadel/ \
79                 --with-spooldir=/var/spool/citadel/ \
80                 --with-sysconfdir=/etc/citadel/ \
81                 --with-rundir=/var/run/citadel/ \
82                 --with-docdir=/usr/share/doc/citadel-doc/ \
83                 --with-ssldir=/etc/ssl/citadel/ \
84                 --with-utility-bindir=/usr/lib/citadel-server/ \
85                 --with-autosysconfdir=/var/lib/citadel/data/ \
86                 --with-localedir=/usr/share/ \
87                 --with-pam \
88                 --with-db \
89                 --enable-debug $(EXTRA_ARGS) $(PROFILE_ARGS) $(THREAD_ARGS)
90
91         touch configure-stamp
92
93 #Architecture 
94 build: build-arch build-indep
95
96 build-arch: build-arch-stamp
97 build-arch-stamp: configure-stamp
98
99         $(MAKE)
100         touch $@
101
102 build-indep: build-indep-stamp
103 build-indep-stamp: configure-stamp
104
105         touch $@
106
107 clean:
108         dh_testdir
109         dh_testroot
110         rm -f build-arch-stamp build-indep-stamp configure-stamp
111
112
113         dh_clean 
114         rm -f config.status config.log
115 #[ ! -f Makefile ] || $(MAKE) distclean
116
117 install: install-indep install-arch
118 install-indep: build-indep
119         dh_testdir
120         dh_testroot
121         dh_clean -k -i 
122         dh_installdirs -i
123
124         $(MAKE) DESTDIR=$(DEB_DESTDIR) install-doc-new
125
126         dh_install -i --sourcedir=debian/tmp
127
128 install-arch: build-arch
129         dh_testdir
130         dh_testroot
131         dh_clean -k -s 
132         dh_installdirs -s
133
134         $(MAKE) install-locale DESTDIR=$(DEB_DESTDIR)
135         $(MAKE) DESTDIR=$(DEB_DESTDIR) install-exec-new install-data-new
136
137         install -D -p -m0755 database_cleanup.sh \
138                 $(DEB_DESTDIR)/usr/share/doc/citadel-server/examples/database_cleanup.sh
139
140         install -D -p -m0644 docs/welcomemail.html \
141                 $(DEB_DESTDIR)/usr/share/doc/citadel-server/welcomemail.html
142
143         install -D -p -m0644 docs/welcomemail.txt \
144                 $(DEB_DESTDIR)/usr/share/doc/citadel-server/welcomemail.txt
145
146         dh_install -s --sourcedir=debian/tmp
147
148 binary-common:
149         dh_testdir
150         dh_testroot
151         dh_installchangelogs
152         dh_installdocs
153         dh_installdebconf       
154         dh_installinit --name=citadel
155         dh_installman
156         dh_strip --dbg-package=citadel-dbg
157         dh_link
158         dh_compress 
159         dh_fixperms
160         dh_makeshlibs
161         dh_installdeb
162         dh_shlibdeps
163         dh_gencontrol
164         dh_md5sums
165         dh_builddeb
166
167 # Build architecture independant packages using the common target.
168 binary-indep: build-indep install-indep
169         $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
170
171 # Build architecture dependant packages using the common target.
172 binary-arch: build-arch install-arch
173         $(MAKE) -f debian/rules DH_OPTIONS=-s binary-common
174
175 binary: binary-arch binary-indep
176 .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch configure