xref: /illumos-gate/usr/src/tools/quick/make-smbclnt (revision 33c72b7598992897b94815b1f47b7b8077e53808)
1#!/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
15#
16
17# Use ordinary make (not dmake) by default.
18make=${MAKE:-make}
19
20# Do this if you want to use dbx or gdb
21# export SOURCEDEBUG=yes
22
23[ -n "$SRC" ] || {
24  echo "SRC not set.  Run 'ws' or 'bldenv' first."
25  exit 1
26}
27
28cpu=`uname -p`
29case $cpu in
30i386)
31	x=intel
32	kmdb_arch="amd64"
33	mdb_arch="ia32 amd64"
34	arch64=amd64
35	;;
36sparc)
37	x=sparc
38	kmdb_arch=v9
39	mdb_arch="v7 v9"
40	arch64=sparcv9
41	;;
42*)  echo "Huh?" ; exit 1;;
43esac
44
45################################################################
46
47build_tools() {
48  test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets ||
49    (cd $SRC/tools && $make install)
50  (cd $SRC/common/mapfiles; $make install)
51}
52
53clobber_tools() {
54  (cd $SRC/tools && $make clobber)
55  (cd $SRC/common/mapfiles; $make clobber)
56}
57
58################################################################
59
60do_hdrs() {
61
62targ=$1
63if [ "$targ" = clobber ]
64then
65  (cd $SRC/uts && $make -k clobber_h)
66  (cd $SRC/head && $make clobber)
67fi
68
69if [ "$targ" = install ]
70then
71  targ=install_h
72
73  # Just the parts of "make sgs" we need, and
74  # skip them if they appear to be done.
75  # ... stuff under $SRC
76  test -f $SRC/uts/common/sys/priv_names.h ||
77    (cd $SRC/uts && $make -k all_h)
78
79  test -f $SRC/head/rpcsvc/nispasswd.h ||
80    (cd $SRC/head && $make -k install_h)
81
82  # ... stuff under $ROOT (proto area)
83  test -d $ROOT/usr/include/sys ||
84    (cd $SRC && $make rootdirs)
85  test -f $ROOT/usr/include/sys/types.h ||
86    (cd $SRC/uts && $make -k install_h)
87  test -f $ROOT/usr/include/rpcsvc/daemon_utils.h ||
88    (cd $SRC/head && $make install_h)
89
90  # always update the smb headers to be safe
91  (cd $SRC/uts/common/smb && $make -k install_h)
92
93fi
94
95# Need some library headers too...
96for lib in \
97  libcmdutils \
98  libcryptoutil \
99  libfakekernel	\
100  libmlrpc \
101  libpam \
102  libsec \
103  libshare \
104  libsmbfs \
105  passwdutil
106do
107  (cd $SRC/lib/$lib && $make $targ)
108done
109}
110
111################################################################
112
113do_kern() {
114  case $1 in
115  lint) targ=modlintlib ;;
116  *) targ=$1 ;;
117  esac
118  ( unset SOURCEDEBUG ;
119  (cd $SRC/uts/$x/nsmb && $make $targ) ;
120  (cd $SRC/uts/$x/smbfs && $make $targ) )
121}
122
123################################################################
124
125# Note lib1 builds prerequisite libraries not delivered by the
126# tar file we create below.  To accelerate clean/install, we
127# skip these on clean (but still nuke them for clobber)
128
129do_lib1() {
130
131for lib in \
132  libavl \
133  libcmdutils
134do
135  (cd $SRC/lib/$lib && $make $1)
136done
137}
138
139# lib2 builds stuff we include in the tar file,
140# or that we don't mind rebuilding after clean.
141
142do_lib2() {
143
144(cd $SRC/lib/libsmbfs && $make $1)
145[ "$1" = install ] &&
146  (cd $SRC/lib/libsmbfs && $make _msg)
147
148for lib in \
149  libfakekernel \
150  libsmbfs \
151  libmlrpc \
152  smbclnt
153do
154  (cd $SRC/lib/$lib && $make $1)
155done
156
157(cd $SRC/lib/libshare && $make $1 PLUGINS=smbfs)
158(cd $SRC/lib/passwdutil && $make $1)
159(cd $SRC/lib/pam_modules/smbfs && $make $1)
160
161}
162
163################################################################
164
165do_cmds() {
166
167case $1 in
168install)
169  # mount programs need fslib.o
170  (cd $SRC/cmd/fs.d && $make fslib.o)
171  (cd $SRC/cmd/fs.d/smbclnt && $make $1 catalog)
172  ;;
173clean|clobber)
174  (cd $SRC/cmd/fs.d/smbclnt && $make $1)
175  (cd $SRC/cmd/fs.d && $make ${1}_local)
176  ;;
177esac
178
179# Build the MDB modules, WITH the linktest
180(cd $SRC/cmd/mdb/tools && $make $1)
181
182# kmdb_arch is 64-bit only
183for a in $kmdb_arch
184do
185  case $1 in
186  install|lint)
187    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
188	$make kmdb_modlinktest.o )
189    ;;
190  clean|clobber)
191    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
192	$make -k $1 )
193    ;;
194  esac
195
196  (cd $SRC/cmd/mdb/$x/$a/nsmb &&
197	$make $1 KMDB_LINKTEST_ENABLE= )
198  (cd $SRC/cmd/mdb/$x/$a/smbfs &&
199	$make $1 KMDB_LINKTEST_ENABLE= )
200done
201
202# mdb_arch is both 32-bit & 64-bit
203for a in $mdb_arch
204do
205  (cd $SRC/cmd/mdb/$x/$a/libfknsmb &&
206	$make $1 )
207  (cd $SRC/cmd/mdb/$x/$a/libfksmbfs &&
208	$make $1 )
209done
210}
211
212
213################################################################
214# This builds $SRC/TAGS (and cscope.files) in a helpful order.
215
216do_tags() {
217	(cd $SRC ;
218	find uts/common/sys -name '*.[ch]' -print |sort
219	find uts/common/net -name '*.[ch]' -print |sort
220	find uts/common/netinet -name '*.[ch]' -print |sort
221	find uts/common/smb -name '*.[ch]' -print |sort
222	find uts/common/netsmb -name '*.[ch]' -print |sort
223	find uts/common/fs/smbclnt -name '*.[ch]' -print |sort
224	find head -name '*.h' -print |sort
225	find lib/smbclnt  -name '*.[ch]' -print |sort
226	find lib/libsmbfs -name '*.[ch]' -print |sort
227	find cmd/fs.d/smbclnt -name '*.[ch]' -print |sort
228	find common/smbclnt -name '*.[ch]' -print |sort
229	) > $SRC/cscope.files
230
231	(cd $SRC ;
232	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
233	cscope -b )
234}
235
236################################################################
237# This creates a tarfile one can use to update a test machine.
238
239do_tar() {
240	git_rev=`git rev-parse --short=8 HEAD`
241	files="
242lib/svc/manifest/network/smb/client.xml
243lib/svc/method/smb-client
244usr/bin/smbutil
245usr/kernel/drv/$arch64/nsmb
246usr/kernel/fs/$arch64/smbfs
247usr/kernel/kmdb/$arch64/nsmb
248usr/kernel/kmdb/$arch64/smbfs
249usr/lib/$arch64/libsmbfs.so.1
250usr/lib/fs/smbfs/$arch64/libshare_smbfs.so.1
251usr/lib/fs/smbfs/chacl
252usr/lib/fs/smbfs/dfshares
253usr/lib/fs/smbfs/libshare_smbfs.so.1
254usr/lib/fs/smbfs/lsacl
255usr/lib/fs/smbfs/mount
256usr/lib/fs/smbfs/share
257usr/lib/fs/smbfs/umount
258usr/lib/fs/smbfs/unshare
259usr/lib/libmlrpc.so.2
260usr/lib/libsmbfs.so.1
261usr/lib/mdb/kvm/$arch64/nsmb.so
262usr/lib/mdb/kvm/$arch64/smbfs.so
263usr/lib/security/$arch64/pam_smbfs_login.so.1
264usr/lib/security/pam_smbfs_login.so.1
265usr/lib/smbfs/smbiod
266usr/lib/smbfs/smbiod-svc
267"
268
269	(cd $ROOT && tar cfj ../../smbclnt-${git_rev}.tar.bz2 $files)
270}
271
272################################################################
273
274if [ "$1" = "" ]; then
275  set '?' # force usage
276fi
277
278set -x
279
280for arg
281do
282  case "$arg" in
283  install)
284    build_tools
285    set -e
286    do_hdrs $arg
287    do_kern $arg
288    do_lib1 $arg
289    do_lib2 $arg
290    do_cmds $arg
291    ;;
292  lint)
293    do_kern $arg
294    do_lib1 $arg
295    do_lib2 $arg
296    do_cmds $arg
297    ;;
298  clean)
299    # intentionally skip: lib1, hdrs, tools
300    do_cmds $arg
301    do_lib2 $arg
302    do_kern $arg
303    ;;
304  clobber)
305    do_cmds $arg
306    do_lib2 $arg
307    do_lib1 $arg
308    do_kern $arg
309    do_hdrs $arg
310    clobber_tools
311    ;;
312  tags)
313    do_tags
314    ;;
315  tar)
316    do_tar
317    ;;
318  *)
319    echo "Usage: $0 {install|lint|clean|clobber|tags|tar}";
320    exit 1;
321    ;;
322  esac
323done
324