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