r11398: Keep s3 in sync with trunk
[samba.git] / packaging / Debian / debian-unstable / rules
1 #!/usr/bin/make -f
2
3 # Important modifications (introduction of a saved config.cache to
4 #       solve build problems) introduced in Samba 2.2.1a-5. These
5 #       modification were made by Steve Langasek <vorlon@netexpress.net>.
6 #
7 #
8
9 # Uncomment this to turn on verbose mode. 
10 #export DH_VERBOSE=1
11
12 # This is the debhelper compatability version to use.
13 export DH_COMPAT=4
14
15 # This has to be exported to make some magic below work.
16 export DH_OPTIONS
17
18 # Set the host and build architectures for use with config.cache loading,
19 # cross-building, etc.
20 DEB_HOST_GNU_TYPE       := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
21 DEB_BUILD_GNU_TYPE      := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
22 DEB_HOST_ARCH_OS        := $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
23
24 export DEB_HOST_GNU_TYPE
25 export DEB_BUILD_GNU_TYPE
26 export DEB_HOST_ARCH_OS
27
28 # Support the DEB_BUILD_OPTIONS variable
29 CFLAGS = -g -Wall
30 INSTALL = install
31
32 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
33   CFLAGS += -O0
34 else
35   CFLAGS += -O2
36 endif
37
38 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
39   INSTALL += -s
40 endif
41
42
43 DESTDIR=`pwd`/debian/tmp
44
45 conf_args = \
46                 --cache-file=./config.cache \
47                 --with-fhs \
48                 --enable-shared \
49                 --enable-static \
50                 --prefix=/usr \
51                 --sysconfdir=/etc \
52                 --libdir=/etc/samba \
53                 --with-privatedir=/etc/samba \
54                 --with-piddir=/var/run/samba \
55                 --localstatedir=/var \
56                 --with-netatalk \
57                 --with-pam \
58                 --with-syslog \
59                 --with-utmp \
60                 --with-readline \
61                 --with-pam_smbpass \
62                 --with-libsmbclient \
63                 --with-winbind \
64                 --with-msdfs \
65                 --with-automount \
66                 --with-tdbsam \
67                 --with-ldap \
68                 --with-python=python2.3
69
70 ifeq ($(DEB_HOST_ARCH_OS),linux)
71   conf_args += \
72                 --with-smbmount \
73                 --with-acl-support \
74                 --with-quotas
75   mount_cifs    = yes
76   smbfs         = yes
77 else
78   conf_args +=  --without-quotas
79   mount_cifs    = no
80   smbfs         = no
81 endif
82
83 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
84   conf_args += --build $(DEB_HOST_GNU_TYPE)
85 else
86   conf_args += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
87 endif
88
89 patch: patch-stamp
90 patch-stamp:
91         dh_testdir
92         if [ ! -f patch-stamp ]; then /bin/sh debian/scripts/patch-source; fi
93         touch patch-stamp
94
95 unpatch:
96         dh_testdir
97         if [ -f patch-stamp ]; then /bin/sh debian/scripts/unpatch-source; fi
98         rm -f patch-stamp
99
100 configure: patch-stamp configure-stamp
101 configure-stamp:
102         dh_testdir
103
104         if [ -f debian/config.cache ]; then \
105                 cp -f debian/config.cache source/config.cache; \
106         fi
107
108         [ -f source/Makefile ] || (cd source && CFLAGS="$(CFLAGS)" ./configure $(conf_args))
109
110         touch configure-stamp
111
112 build: patch-stamp configure-stamp build-stamp
113 build-stamp:
114         dh_testdir
115
116         $(MAKE) -C source headers
117         $(MAKE) -C source all nsswitch/libnss_wins.so python_ext
118 ifeq ($(mount_cifs),yes)
119         $(MAKE) -C source client/mount.cifs
120 endif
121
122         touch build-stamp
123
124 clean: unpatch
125         dh_testdir
126         dh_testroot
127         rm -f build-stamp configure-stamp
128
129         # Clean first the Samba package
130 #       -$(MAKE) -C source realclean
131 #       -$(MAKE) -C source clean
132         -$(MAKE) -C source python_clean distclean
133
134         # Delete stuff left after a build that is not deleted by 'make clean'
135         rm -f source/bin/wbinfo source/bin/winbindd source/bin/debug2html \
136                 source/bin/libsmbclient.a source/client/mount.cifs \
137                 source/include/stamp-h
138
139         sed -e "s/@libacl@/`type-handling any linux-gnu`/g" \
140                 < debian/control.in > debian/control
141
142         dh_clean
143
144 install: DH_OPTIONS=
145 install: build
146         dh_testdir
147         dh_testroot
148         dh_clean -k
149         dh_installdirs
150
151         mkdir -p $(DESTDIR)/usr/share/man $(DESTDIR)/usr/lib/samba \
152                  $(DESTDIR)/lib/security $(DESTDIR)/sbin \
153                  $(DESTDIR)/usr/lib/cups/backend $(DESTDIR)/usr/share/samba \
154                  $(DESTDIR)/etc/pam.d $(DESTDIR)/etc/dhcp3/dhclient-enter-hooks.d \
155                  $(DESTDIR)/usr/lib/python2.3/site-packages/samba
156
157         # Add here commands to install the package into debian/tmp.
158         $(MAKE) -C source install DESTDIR=$(DESTDIR)
159
160         # libsmbclient files are not installed by the standard
161         #       'make install' - do it manually.
162         $(MAKE) -C source installclientlib DESTDIR=$(DESTDIR)
163         mv $(DESTDIR)/usr/lib/samba/libsmbclient.so $(DESTDIR)/usr/lib/samba/libsmbclient.so.0.1
164         ln -s libsmbclient.so.0.1 $(DESTDIR)/usr/lib/samba/libsmbclient.so.0
165         ln -s libsmbclient.so.0.1 $(DESTDIR)/usr/lib/samba/libsmbclient.so
166
167         # Starting with Samba 3.0.6 libsmbclient.so is installed in
168         # /usr/lib/samba. We don't want it there since it is not in the
169         # default library path. Here we move it to /usr/lib/.
170         mv $(DESTDIR)/usr/lib/samba/libsmbclient* \
171                 $(DESTDIR)/usr/lib/
172
173         # Install other stuff not installed by "make install"
174         install -m 0755 debian/mksmbpasswd.awk $(DESTDIR)/usr/sbin/mksmbpasswd
175
176         # Install winbind stuff not installed by 'make install'
177         install -m 0644 source/nsswitch/libnss_winbind.so \
178                 $(DESTDIR)/lib/libnss_winbind.so.2
179         install -m 0644 source/nsswitch/pam_winbind.so \
180                 $(DESTDIR)/lib/security/
181
182         # Install libnss_wins.so, which is not installed by 'make install' either.
183         install -m 0644 source/nsswitch/libnss_wins.so \
184                 $(DESTDIR)/lib/libnss_wins.so.2
185
186         # pam_smbpass.so isn't being installed by 'make install'.
187         #       We'll move it here to $(DESTDIR)/lib/security/ and then
188         #       libpam-smbpass.files will make dh_movefiles move it to the
189         #       right location in the libpam-smbpass package.
190         install -m 0644 source/bin/pam_smbpass.so $(DESTDIR)/lib/security/
191
192 ifeq ($(smbfs),yes)
193         # Create the symlinks that will allow us to do "mount -t smbfs ..."
194         # and "mount -t smb ...". Note that the source/script/installbin.sh
195         # tries to create the first symlink, but we have commented
196         # that code out and do everything here. We also create
197         # symlinks for the man pages.
198         ln -s /usr/bin/smbmount $(DESTDIR)/sbin/mount.smbfs
199         ln -s /usr/bin/smbmount $(DESTDIR)/sbin/mount.smb
200         ln -s smbmount.8 $(DESTDIR)/usr/share/man/man8/mount.smb.8
201         ln -s smbmount.8 $(DESTDIR)/usr/share/man/man8/mount.smbfs.8
202 endif
203
204 ifeq ($(mount_cifs),yes)
205         # Install mount.cifs and its man page
206         install -m 04755 source/client/mount.cifs $(DESTDIR)/sbin/
207         install -m 0644 docs/manpages/mount.cifs.8 $(DESTDIR)/usr/share/man/man8/
208 endif
209
210         # For CUPS to support printing to samba printers, it's necessary
211         #       to make the following symlink (according to
212         #       Erich Schubert <debian@vitavonni.de> in #109509):
213         ln -s ../../../bin/smbspool $(DESTDIR)/usr/lib/cups/backend/smb
214
215         # Install man pages for files without man pages in the upstream sources
216         install -m 0644 debian/mksmbpasswd.8 $(DESTDIR)/usr/share/man/man8/mksmbpasswd.8
217
218         # We don't provide the "Using Samba" book in the swat package.
219         # It's provided in the samba-doc package so in the swat package
220         # we just provide a symlink to the real book.
221         ln -s ../../doc/samba-doc/htmldocs/using_samba \
222               $(DESTDIR)/usr/share/samba/swat/using_samba
223
224         # Delete unwanted stuff leftover from "make install"
225
226         # The smbwrapper package is not being generated anymore, so we must
227         #       delete the related man pages.
228         rm $(DESTDIR)/usr/share/man/man1/smbsh.1
229
230         # We're not providing findsmb (should we?) so let's remove the man
231         #       pages.
232         find debian/ -name 'findsmb*' -exec rm -f {} \;
233
234         # Install samba-common's conffiles - they'll get moved later to their
235         #       correct place by dh_movefiles.
236         cp debian/smb.conf $(DESTDIR)/usr/share/samba/
237         install -m755 debian/panic-action $(DESTDIR)/usr/share/samba/
238         cp debian/gdbcommands $(DESTDIR)/etc/samba/
239         cp debian/samba.pamd $(DESTDIR)/etc/pam.d/samba
240         install -m755 debian/samba-common.dhcp $(DESTDIR)/etc/dhcp3/dhclient-enter-hooks.d/samba
241
242         # Install the Python modules
243         #
244         # Hmmm... need to figure this out. We have lib.linux-i686-2.2
245         # and lib.linux-i686-2.3 directories. Using only the stuff from
246         # the 2.3 directory for now. peloy.-
247         #cp source/build/lib.*/samba/*.so $(DESTDIR)/usr/lib/python2.3/site-packages/
248         cp source/build/lib.*-*-2.3/samba/*.so $(DESTDIR)/usr/lib/python2.3/site-packages/samba/
249         cp source/python/samba/* $(DESTDIR)/usr/lib/python2.3/site-packages/samba/
250
251         dh_movefiles
252
253 # Build architecture-independent files here.
254 # Pass -i to all debhelper commands in this target to reduce clutter.
255 binary-indep: DH_OPTIONS=-i
256 binary-indep: build install
257         dh_testdir
258         dh_testroot
259         dh_installdebconf
260         dh_installdocs -A debian/README.build
261         # dh_installexamples is not available in Debian Potato...
262         [ -x /usr/bin/dh_installexamples ] && DH_OPTIONS= dh_installexamples -v -psamba-doc examples/*
263 #       dh_installmenu
264 #       dh_installemacsen
265 #       dh_installpam
266 #       dh_installinit
267 #       dh_installcron
268 #       dh_installmanpages
269 #       dh_installinfo
270 #       dh_undocumented
271         dh_installchangelogs
272         dh_link
273         dh_compress
274         dh_fixperms
275
276         # Get rid of those pesky .cvsignore files to make lintian happy
277         find debian/ -name .cvsignore -exec rm -f {} \;
278
279         dh_installdeb
280 #       dh_perl
281         dh_gencontrol
282         dh_md5sums
283         dh_builddeb
284
285 # Build architecture-dependent files here.
286 # Pass -a to all debhelper commands in this target to reduce clutter.
287 ifeq ($(smbfs),no)
288   DH_EXTRAS=-Nsmbfs
289 endif
290
291 binary-arch: DH_OPTIONS=-a $(DH_EXTRAS)
292 binary-arch: build install
293         dh_testdir
294         dh_testroot
295         dh_installdebconf
296         dh_installdocs -A debian/README.build
297         # dh_installexamples is not available in Debian Potato...
298         [ -x /usr/bin/dh_installexamples ] && DH_OPTIONS= dh_installexamples -v -ppython2.3-samba source/python/examples/*
299 #       dh_installmenu
300         # dh_installlogrotate is not available in Debian Potato...
301         if [ -x /usr/bin/dh_installlogrotate ]; then \
302                 dh_installlogrotate; \
303         else \
304                 mkdir -p debian/samba/etc/logrotate.d; \
305                 cp debian/samba.logrotate debian/samba/etc/logrotate.d/samba; \
306                 mkdir -p debian/winbind/etc/logrotate.d; \
307                 cp debian/winbind.logrotate debian/winbind/etc/logrotate.d/winbind; \
308         fi
309 #       dh_installemacsen
310 #       dh_installpam
311         DH_OPTIONS= dh_installinit -psamba -- "defaults 20 19"
312         DH_OPTIONS= dh_installinit -pwinbind
313         dh_installcron 
314 #       dh_installmanpages
315 #       dh_installinfo
316         cp debian/winbind.lintian debian/winbind/usr/share/lintian/overrides/winbind
317 #       dh_undocumented
318         dh_installchangelogs -Nlibpam-smbpass
319         DH_OPTIONS= dh_installchangelogs -plibpam-smbpass source/pam_smbpass/CHANGELOG
320         dh_strip --dbg-package=samba --dbg-package=smbclient
321         cp -a debian/smbclient-dbg/* debian/samba-dbg
322         rm -rf debian/smbclient-dbg
323         dh_link
324         dh_compress
325         dh_fixperms
326
327         # Why this is executable, I have NO idea...
328         chmod a-x debian/libsmbclient-dev/usr/include/libsmbclient.h
329
330 ifeq ($(smbfs),yes)
331         # You may want to make some executables suid here.
332         # The smbmnt and smbumount binaries should be setuid-root. This
333         #       has security implications because these programs haven't had
334         #       a thorough security audit. smbmount _does not_ have to have
335         #       the setuid bit set. In fact, it is a security hole.
336         chmod u+s debian/smbfs/usr/bin/smbmnt
337         chmod u+s debian/smbfs/usr/bin/smbumount
338 endif
339
340         # Set some reasonable default perms for the samba logdir.
341         chmod 0750 debian/samba/var/log/samba/
342         chown root.adm debian/samba/var/log/samba/
343
344         # Get rid of those pesky .cvsignore files to make lintian happy
345         # (maybe we only need the "find ... -exec rm -f {} ;" we have
346         # in the binary-indep target?) peloy.-
347         find debian/ -name .cvsignore -exec rm -f {} \;
348
349         dh_installdeb
350 #       dh_makeshlibs
351 #       dh_perl
352         dh_shlibdeps
353         dh_gencontrol
354         dh_md5sums
355         dh_builddeb
356
357 binary: binary-indep binary-arch
358 .PHONY: build clean binary-indep binary-arch binary install configure