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