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