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