Initial import
[samba] / 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 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 CFLAGS = -g -Wall
29
30 ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
31   CFLAGS += -O0
32 else
33   CFLAGS += -O2
34 endif
35
36 ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS)))
37   CFLAGS += -mthumb
38 endif
39
40 DESTDIR=`pwd`/debian/tmp
41
42 conf_args = \
43                 --cache-file=./config.cache \
44                 --with-fhs \
45                 --enable-shared \
46                 --enable-static \
47                 --disable-pie \
48                 --prefix=/usr \
49                 --sysconfdir=/etc \
50                 --libdir=/etc/samba \
51                 --with-privatedir=/etc/samba \
52                 --with-piddir=/var/run/samba \
53                 --localstatedir=/var \
54                 --without-netatalk \
55                 --without-pam \
56                 --with-syslog \
57                 --with-utmp \
58                 --without-readline \
59                 --without-pam_smbpass \
60                 --with-libsmbclient \
61                 --without-winbind \
62                 --with-shared-modules=idmap_rid,idmap_ad \
63                 --without-msdfs \
64                 --without-automount \
65                 --without-tdbsam \
66                 --without-ldap \
67                 --without-python
68
69 ifeq ($(DEB_HOST_ARCH_OS),linux)
70   conf_args += \
71                 --with-smbmount \
72                 --with-acl-support \
73                 --with-quotas
74   mount_cifs    = yes
75   smbfs         = yes
76 else
77   conf_args +=  --without-quotas
78   mount_cifs    = no
79   smbfs         = no
80 endif
81
82 ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
83   conf_args += --build $(DEB_HOST_GNU_TYPE)
84 else
85   conf_args += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
86 endif
87
88 configure: patch configure-stamp
89 configure-stamp:
90         dh_testdir
91
92         if [ -f debian/config.cache ]; then \
93                 cp -f debian/config.cache source/config.cache; \
94         fi
95
96         [ -f source/Makefile ] || (cd source && CFLAGS="$(CFLAGS)" ./configure $(conf_args))
97
98         touch configure-stamp
99
100 build: configure build-stamp
101 build-stamp:
102         dh_testdir
103
104         $(MAKE) -C source headers
105         $(MAKE) -C source all nsswitch/libnss_wins.so
106 ifeq ($(mount_cifs),yes)
107         $(MAKE) -C source client/mount.cifs client/umount.cifs
108 endif
109
110         touch build-stamp
111
112 clean:  clean-patched unpatch
113
114 clean-patched: 
115         dh_testdir
116         dh_testroot
117         rm -f build-stamp configure-stamp
118
119         # Clean first the Samba package
120         -$(MAKE) -C source distclean
121
122         # Delete stuff left after a build that is not deleted by 'make clean'
123         rm -f source/bin/wbinfo source/bin/debug2html \
124                 source/bin/libsmbclient.a \
125                 source/client/mount.cifs source/client/umount.cifs \
126                 source/include/stamp-h
127
128         # No type-handling in ubuntu main
129         #sed -e "s/@libacl@/`type-handling any linux-gnu`/g" \
130         #       < debian/control.in > debian/control
131
132         dh_clean
133
134 install: DH_OPTIONS=
135 install: build
136         dh_testdir
137         dh_testroot
138         dh_clean -k
139         dh_installdirs
140
141         mkdir -p $(DESTDIR)/usr/share/man $(DESTDIR)/usr/lib/samba \
142                  $(DESTDIR)/lib/security $(DESTDIR)/sbin \
143                  $(DESTDIR)/usr/lib/cups/backend $(DESTDIR)/usr/share/samba \
144                  $(DESTDIR)/etc/dhcp3/dhclient-enter-hooks.d
145 #                $(DESTDIR)/usr/lib/python2.4/site-packages/samba
146
147         # Add here commands to install the package into debian/tmp.
148         $(MAKE) -C source install DESTDIR=$(DESTDIR)
149
150         # libsmbclient files are not installed by the standard
151         #       'make install' - do it manually.
152         $(MAKE) -C source installclientlib DESTDIR=$(DESTDIR)
153         mv $(DESTDIR)/usr/lib/samba/libsmbclient.so $(DESTDIR)/usr/lib/samba/libsmbclient.so.0.1
154         ln -s libsmbclient.so.0.1 $(DESTDIR)/usr/lib/samba/libsmbclient.so.0
155         ln -s libsmbclient.so.0.1 $(DESTDIR)/usr/lib/samba/libsmbclient.so
156
157         # Starting with Samba 3.0.6 libsmbclient.so is installed in
158         # /usr/lib/samba. We don't want it there since it is not in the
159         # default library path. Here we move it to /usr/lib/.
160         mv $(DESTDIR)/usr/lib/samba/libsmbclient* \
161                 $(DESTDIR)/usr/lib/
162
163         # Install other stuff not installed by "make install"
164         install -m 0755 debian/mksmbpasswd.awk $(DESTDIR)/usr/sbin/mksmbpasswd
165
166         # Install libnss_wins.so, which is not installed by 'make install' either.
167         install -m 0644 source/nsswitch/libnss_wins.so \
168                 $(DESTDIR)/lib/libnss_wins.so.2
169
170 ifeq ($(smbfs),yes)
171         # Create the symlinks that will allow us to do "mount -t smbfs ..."
172         # and "mount -t smb ...". Note that the source/script/installbin.sh
173         # tries to create the first symlink, but we have commented
174         # that code out and do everything here. We also create
175         # symlinks for the man pages.
176         ln -sf /usr/bin/smbmount $(DESTDIR)/sbin/mount.smbfs
177         ln -sf /usr/bin/smbmount $(DESTDIR)/sbin/mount.smb
178         ln -sf smbmount.8 $(DESTDIR)/usr/share/man/man8/mount.smb.8
179         ln -sf smbmount.8 $(DESTDIR)/usr/share/man/man8/mount.smbfs.8
180 endif
181
182 ifeq ($(mount_cifs),yes)
183         install -m 0755 source/client/mount.cifs $(DESTDIR)/sbin/
184         install -m 0755 source/client/umount.cifs $(DESTDIR)/sbin/
185 endif
186
187         # For CUPS to support printing to samba printers, it's necessary
188         #       to make the following symlink (according to
189         #       Erich Schubert <debian@vitavonni.de> in #109509):
190         ln -s ../../../bin/smbspool $(DESTDIR)/usr/lib/cups/backend/smb
191
192         # Install man pages for files without man pages in the upstream sources
193         install -m 0644 debian/mksmbpasswd.8 $(DESTDIR)/usr/share/man/man8/mksmbpasswd.8
194
195         # Install samba-common's conffiles - they'll get moved later to their
196         #       correct place by dh_movefiles.
197         cp debian/smb.conf $(DESTDIR)/usr/share/samba/
198         install -m755 debian/panic-action $(DESTDIR)/usr/share/samba/
199         cp debian/gdbcommands $(DESTDIR)/etc/samba/
200         install -m755 debian/samba-common.dhcp $(DESTDIR)/etc/dhcp3/dhclient-enter-hooks.d/samba
201
202         # Install the Python modules
203         #
204         # Hmmm... need to figure this out. We have lib.linux-i686-2.2
205         # and lib.linux-i686-2.4 directories. Using only the stuff from
206         # the 2.4 directory for now. peloy.-
207         #cp source/build/lib.*/samba/*.so $(DESTDIR)/usr/lib/python2.4/site-packages/
208 #       cp source/build/lib.*-*-2.4/samba/*.so $(DESTDIR)/usr/lib/python2.4/site-packages/samba/
209 #       cp source/python/samba/* $(DESTDIR)/usr/lib/python2.4/site-packages/samba/
210
211         dh_movefiles
212
213 # Build architecture-independent files here.
214 # Pass -i to all debhelper commands in this target to reduce clutter.
215 binary-indep: DH_OPTIONS=-i
216 binary-indep: build install
217         dh_testdir
218         dh_testroot
219         dh_installdebconf
220         dh_installdocs -A debian/README.build
221         # Ignore COPYING. Otherwise, an extra copy of the GPL licence 
222         # in smbldap-tools example is included in samba-doc
223         dh_installexamples -Xsmbldap-tools-*
224 #       dh_installmenu
225 #       dh_installemacsen
226 #       dh_installpam
227 #       dh_installinit
228 #       dh_installcron
229 #       dh_installmanpages
230 #       dh_installinfo
231 #       dh_undocumented
232         dh_installchangelogs
233         dh_link
234         dh_compress
235         dh_fixperms
236         dh_installdeb
237 #       dh_perl
238         dh_gencontrol
239         dh_md5sums
240         dh_builddeb
241
242 # Build architecture-dependent files here.
243 # Pass -a to all debhelper commands in this target to reduce clutter.
244 ifeq ($(smbfs),no)
245   DH_EXTRAS=-Nsmbfs
246 endif
247
248 binary-arch: DH_OPTIONS=-a $(DH_EXTRAS)
249 binary-arch: build install
250         dh_testdir
251         dh_testroot
252         dh_installdebconf
253         dh_installdocs -A debian/README.build
254         dh_installexamples
255 #       dh_installmenu
256         dh_installlogrotate
257 #       dh_installemacsen
258 #       dh_installpam
259         DH_OPTIONS= dh_installinit -psamba -- "defaults 20 19"
260         dh_installcron 
261 #       dh_installmanpages
262 #       dh_installinfo
263         for pkg in samba smbfs; do \
264           install -m 0644 -D debian/$$pkg.lintian debian/$$pkg/usr/share/lintian/overrides/$$pkg || exit; \
265         done
266 #       dh_undocumented
267         dh_installchangelogs -Nlibpam-smbpass
268         dh_strip --dbg-package=samba --dbg-package=smbclient
269         cp -a debian/smbclient-dbg/* debian/samba-dbg
270         rm -rf debian/smbclient-dbg
271         dh_link
272         dh_compress
273         dh_fixperms
274
275         # Upstream makefile installs this using "install" without -m, so
276         # it becomes executable
277         chmod a-x debian/libsmbclient-dev/usr/include/libsmbclient.h
278
279         # You may want to make some executables suid here.
280 ifeq ($(smbfs),yes)
281         # The smbmnt and smbumount binaries should be setuid-root. This
282         #       has security implications because these programs haven't had
283         #       a thorough security audit. smbmount _does not_ have to have
284         #       the setuid bit set. In fact, it is a security hole.
285         #chmod u+s debian/smbfs/usr/bin/smbmnt
286         #chmod ug+s debian/smbfs/usr/bin/smbumount
287 endif
288 ifeq ($(mount_cifs),yes)
289         #chmod u+s debian/smbfs/sbin/mount.cifs
290         #chmod u+s debian/smbfs/sbin/umount.cifs
291 endif
292
293         # Set some reasonable default perms for the samba logdir.
294         chmod 0750 debian/samba/var/log/samba/
295         chown root.adm debian/samba/var/log/samba/
296
297         dh_installdeb
298 #       dh_makeshlibs
299 #       dh_perl
300         dh_shlibdeps
301         dh_gencontrol
302         dh_md5sums
303         dh_builddeb
304
305 binary: binary-indep binary-arch
306 .PHONY: build clean binary-indep binary-arch binary install configure patch unpatch