import HEAD into svn+ssh://svn.samba.org/home/svn/samba/trunk
[metze/old/v3-2-winbind-ndr.git] / packaging / Debian / debian / 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
23 export DEB_HOST_GNU_TYPE
24 export DEB_BUILD_GNU_TYPE
25
26
27 # Support the DEB_BUILD_OPTIONS variable
28 CFLAGS = -gstabs -Wall
29 INSTALL = install
30
31 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
32   CFLAGS += -O0
33 else
34   CFLAGS += -O2
35 endif
36
37 ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
38   INSTALL += -s
39 endif
40
41
42 DESTDIR=`pwd`/debian/tmp
43 SWATDIR=`pwd`/debian/swat
44
45 IVARS = BASEDIR=$(DESTDIR)/usr \
46                 prefix=$(DESTDIR)/usr \
47                 BINDIR=$(DESTDIR)/usr/bin \
48                 SBINDIR=$(DESTDIR)/usr/sbin \
49                 MANDIR=$(DESTDIR)/usr/share/man \
50                 LIBDIR=$(DESTDIR)/usr/lib/samba \
51                 VARDIR=$(DESTDIR)/var \
52                 INCLUDEDIR=$(DESTDIR)/usr/include \
53                 SWATDIR=$(SWATDIR)/usr/share/samba/swat \
54                 CODEPAGEDIR=$(DESTDIR)/usr/share/samba/ \
55                 PRIVATEDIR=$(DESTDIR)/etc/samba \
56                 CONFIGDIR=$(DESTDIR)/etc/samba
57
58 patch: patch-stamp
59 patch-stamp:
60         dh_testdir
61         if [ ! -f patch-stamp ]; then /bin/sh debian/scripts/patch-source; fi
62         touch patch-stamp
63
64 unpatch:
65         dh_testdir
66         if [ -f patch-stamp ]; then /bin/sh debian/scripts/unpatch-source; fi
67         rm -f patch-stamp
68
69 configure: patch-stamp configure-stamp
70 configure-stamp:
71         dh_testdir
72
73         if [ -f debian/config.cache ]; then \
74                 cp -f debian/config.cache source/config.cache; \
75         fi
76
77         [ -f source/Makefile ] || (cd source && CFLAGS="$(CFLAGS)" ./configure \
78                 --host=$(DEB_HOST_GNU_TYPE) \
79                 --build=$(DEB_BUILD_GNU_TYPE) \
80                 --cache-file=./config.cache \
81                 --with-fhs \
82                 --enable-shared \
83                 --enable-static \
84                 --prefix=/usr \
85                 --sysconfdir=/etc \
86                 --libdir=/etc/samba \
87                 --with-privatedir=/etc/samba \
88                 --localstatedir=/var \
89                 --with-netatalk \
90                 --with-smbmount \
91                 --with-pam \
92                 --with-syslog \
93                 --with-utmp \
94                 --with-readline \
95                 --with-pam_smbpass \
96                 --with-libsmbclient \
97                 --with-winbind \
98                 --with-msdfs \
99                 --with-automount \
100                 --with-acl-support \
101                 --with-tdbsam \
102                 --with-ldap \
103                 --with-python=python2.3)
104
105         touch configure-stamp
106
107 build: patch-stamp configure-stamp build-stamp
108 build-stamp:
109         dh_testdir
110
111         $(MAKE) -C source headers
112         $(MAKE) -C source all nsswitch/libnss_wins.so python_ext
113
114         touch build-stamp
115
116 clean: unpatch
117         dh_testdir
118         dh_testroot
119         rm -f build-stamp configure-stamp
120
121         # Clean first the Samba package
122 #       -$(MAKE) -C source realclean
123 #       -$(MAKE) -C source clean
124         -$(MAKE) -C source python_clean distclean
125
126         # Delete stuff left after a build that is not deleted by 'make clean'
127         rm -f source/bin/wbinfo source/bin/winbindd source/bin/debug2html \
128                 source/bin/libsmbclient.a source/include/stamp-h
129
130         dh_clean
131
132 install: DH_OPTIONS=
133 install: build
134         dh_testdir
135         dh_testroot
136         dh_clean -k
137         dh_installdirs
138
139         mkdir -p $(DESTDIR)/usr/share/man $(DESTDIR)/usr/lib \
140                  $(DESTDIR)/lib/security $(DESTDIR)/sbin \
141                  $(DESTDIR)/usr/lib/cups/backend $(DESTDIR)/usr/share/samba \
142                  $(DESTDIR)/etc/pam.d $(DESTDIR)/etc/dhcp3/dhclient-enter-hooks.d \
143                  $(DESTDIR)/usr/lib/python2.3/site-packages
144
145         # Add here commands to install the package into debian/tmp.
146         $(MAKE) -C source install $(IVARS)
147
148         # libsmbclient files are not installed by the standard
149         #       'make install' - do it manually.
150         $(MAKE) -C source installclientlib $(IVARS)
151         mv $(DESTDIR)/usr/lib/libsmbclient.so $(DESTDIR)/usr/lib/libsmbclient.so.0.1
152         ln -s libsmbclient.so.0.1 $(DESTDIR)/usr/lib/libsmbclient.so.0
153         ln -s libsmbclient.so.0.1 $(DESTDIR)/usr/lib/libsmbclient.so
154
155         # Install other stuff not installed by "make install"
156         install -m 0755 debian/mksmbpasswd.awk $(DESTDIR)/usr/sbin/mksmbpasswd
157
158         # Install winbind stuff not installed by 'make install'
159         install -m 0644 source/nsswitch/libnss_winbind.so \
160                 $(DESTDIR)/lib/libnss_winbind.so.2
161         install -m 0644 source/nsswitch/pam_winbind.so \
162                 $(DESTDIR)/lib/security/
163
164         # Install libnss_wins.so, which is not installed by 'make install' either.
165         install -m 0644 source/nsswitch/libnss_wins.so \
166                 $(DESTDIR)/lib/libnss_wins.so.2
167
168         # pam_smbpass.so isn't being installed by 'make install'.
169         #       We'll move it here to $(DESTDIR)/lib/security/ and then
170         #       libpam-smbpass.files will make dh_movefiles move it to the
171         #       right location in the libpam-smbpass package.
172         install -m 0644 source/bin/pam_smbpass.so $(DESTDIR)/lib/security/
173
174         # Create the symlink that will allow us to do "mount -t smbfs ...".
175         #       Create also a symlink that will allow "mount -t smb ..." to
176         #       work too. The symlink is created in $(DESTDIR)/sbin/ but 
177         #       will be moved by dh_movefiles to the smbfs package later on.
178         ln -s /usr/bin/smbmount $(DESTDIR)/sbin/mount.smbfs
179         ln -s /usr/bin/smbmount $(DESTDIR)/sbin/mount.smb
180         ln -s smbmount.8 $(DESTDIR)/usr/share/man/man8/mount.smb.8
181         ln -s smbmount.8 $(DESTDIR)/usr/share/man/man8/mount.smbfs.8
182
183         # For CUPS to support printing to samba printers, it's necessary
184         #       to make the following symlink (according to
185         #       Erich Schubert <debian@vitavonni.de> in #109509):
186         ln -s ../../../bin/smbspool $(DESTDIR)/usr/lib/cups/backend/smb
187
188         # Install man pages for files without man pages in the upstream sources
189         install -m 0644 debian/mksmbpasswd.8 $(DESTDIR)/usr/share/man/man8/mksmbpasswd.8
190
191         # Delete unwanted stuff leftover from "make install"
192
193         # The smbwrapper package is not being generated anymore, so we must
194         #       delete the related man pages.
195         rm $(DESTDIR)/usr/share/man/man1/smbsh.1
196
197         # We're not providing findsmb (should we?) so let's remove the man
198         #       pages.
199         find debian/ -name 'findsmb*' -exec rm -f {} \;
200
201         # Install samba-common's conffiles - they'll get moved later to their
202         #       correct place by dh_movefiles.
203         cp debian/smb.conf $(DESTDIR)/usr/share/samba/
204         install -m755 debian/panic-action $(DESTDIR)/usr/share/samba/
205         cp debian/gdbcommands $(DESTDIR)/etc/samba/
206         cp debian/samba.pamd $(DESTDIR)/etc/pam.d/samba
207         install -m755 debian/samba-common.dhcp $(DESTDIR)/etc/dhcp3/dhclient-enter-hooks.d/samba
208
209         # Install the Python modules
210         #
211         # Hmmm... need to figure this out. We have lib.linux-i686-2.2
212         # and lib.linux-i686-2.3 directories. Using only the stuff from
213         # the 2.3 directory for now. peloy.-
214         #cp source/build/lib.*/samba/*.so $(DESTDIR)/usr/lib/python2.3/site-packages/
215         cp source/build/lib.linux-*-2.3/samba/*.so $(DESTDIR)/usr/lib/python2.3/site-packages/
216
217         dh_movefiles
218
219 # Build architecture-independent files here.
220 # Pass -i to all debhelper commands in this target to reduce clutter.
221 binary-indep: DH_OPTIONS=-i
222 binary-indep: build install
223         dh_testdir
224         dh_testroot
225         dh_installdebconf
226         dh_installdocs -A debian/README.build
227         # dh_installexamples is not available in Debian Potato...
228         [ -x /usr/bin/dh_installexamples ] && DH_OPTIONS= dh_installexamples -v -psamba-doc examples/*
229 #       dh_installmenu
230 #       dh_installemacsen
231 #       dh_installpam
232 #       dh_installinit
233 #       dh_installcron
234 #       dh_installmanpages
235 #       dh_installinfo
236 #       dh_undocumented
237         dh_installchangelogs
238         dh_link
239         dh_compress
240         dh_fixperms
241
242         # Get rid of those pesky .cvsignore files to make lintian happy
243         find debian/ -name .cvsignore -exec rm -f {} \;
244
245         dh_installdeb
246 #       dh_perl
247         dh_gencontrol
248         dh_md5sums
249         dh_builddeb
250
251 # Build architecture-dependent files here.
252 # Pass -a to all debhelper commands in this target to reduce clutter.
253 binary-arch: DH_OPTIONS=-a
254 binary-arch: build install
255         dh_testdir
256         dh_testroot
257         dh_installdebconf
258         dh_installdocs -A debian/README.build
259         # dh_installexamples is not available in Debian Potato...
260         [ -x /usr/bin/dh_installexamples ] && DH_OPTIONS= dh_installexamples -v -ppython2.3-samba source/python/examples/*
261 #       dh_installmenu
262         # dh_installlogrotate is not available in Debian Potato...
263         if [ -x /usr/bin/dh_installlogrotate ]; then \
264                 dh_installlogrotate; \
265         else \
266                 mkdir -p debian/samba/etc/logrotate.d; \
267                 cp debian/samba.logrotate debian/samba/etc/logrotate.d/samba; \
268                 mkdir -p debian/winbind/etc/logrotate.d; \
269                 cp debian/winbind.logrotate debian/winbind/etc/logrotate.d/winbind; \
270         fi
271 #       dh_installemacsen
272 #       dh_installpam
273         DH_OPTIONS= dh_installinit -psamba -- "defaults 20 19"
274         DH_OPTIONS= dh_installinit -pwinbind
275         dh_installcron 
276 #       dh_installmanpages
277 #       dh_installinfo
278         cp debian/winbind.lintian debian/winbind/usr/share/lintian/overrides/winbind
279 #       dh_undocumented
280         dh_installchangelogs -Nlibpam-smbpass
281         DH_OPTIONS= dh_installchangelogs -plibpam-smbpass source/pam_smbpass/CHANGELOG
282         dh_strip
283         dh_link
284         dh_compress
285         dh_fixperms
286
287         # Why this is executable, I have NO idea...
288         chmod a-x debian/libsmbclient-dev/usr/include/libsmbclient.h
289
290         # You may want to make some executables suid here.
291         # The smbmnt and smbumount binaries should be setuid-root. This
292         #       has security implications because these programs haven't had
293         #       a thorough security audit. smbmount _does not_ have to have
294         #       the setuid bit set. In fact, it is a security hole.
295         chmod u+s debian/smbfs/usr/bin/smbmnt
296         chmod u+s debian/smbfs/usr/bin/smbumount
297
298         # Set some reasonable default perms for the samba logdir.
299         chmod 0750 debian/samba/var/log/samba/
300         chown root.adm debian/samba/var/log/samba/
301
302         # Get rid of those pesky .cvsignore files to make lintian happy
303         # (maybe we only need the "find ... -exec rm -f {} ;" we have
304         # in the binary-indep target?) peloy.-
305         find debian/ -name .cvsignore -exec rm -f {} \;
306
307         dh_installdeb
308 #       dh_makeshlibs
309 #       dh_perl
310         dh_shlibdeps
311         dh_gencontrol
312         dh_md5sums
313         dh_builddeb
314
315 binary: binary-indep binary-arch
316 .PHONY: build clean binary-indep binary-arch binary install configure