xref: /illumos-gate/usr/src/tools/quick/make-smbclnt (revision 698f4ab6008be205f4362675967638572eef4f21)
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="
242etc/security/exec_attr.d/SUNWsmbfs
243lib/svc/manifest/network/smb/client.xml
244lib/svc/method/smb-client
245usr/bin/smbutil
246usr/kernel/drv/$arch64/nsmb
247usr/kernel/fs/$arch64/smbfs
248usr/kernel/kmdb/$arch64/nsmb
249usr/kernel/kmdb/$arch64/smbfs
250usr/lib/$arch64/libsmbfs.so.1
251usr/lib/fs/smbfs/$arch64/libshare_smbfs.so.1
252usr/lib/fs/smbfs/chacl
253usr/lib/fs/smbfs/dfshares
254usr/lib/fs/smbfs/libshare_smbfs.so.1
255usr/lib/fs/smbfs/lsacl
256usr/lib/fs/smbfs/mount
257usr/lib/fs/smbfs/share
258usr/lib/fs/smbfs/umount
259usr/lib/fs/smbfs/unshare
260usr/lib/libmlrpc.so.2
261usr/lib/libsmbfs.so.1
262usr/lib/mdb/kvm/$arch64/nsmb.so
263usr/lib/mdb/kvm/$arch64/smbfs.so
264usr/lib/security/$arch64/pam_smbfs_login.so.1
265usr/lib/security/pam_smbfs_login.so.1
266usr/lib/smbfs/smbiod
267usr/lib/smbfs/smbiod-svc
268"
269
270	(cd $ROOT && tar cfj ../../smbclnt-${git_rev}.tar.bz2 $files)
271}
272
273################################################################
274
275if [ "$1" = "" ]; then
276  set '?' # force usage
277fi
278
279set -x
280
281for arg
282do
283  case "$arg" in
284  install)
285    build_tools
286    set -e
287    do_hdrs $arg
288    do_kern $arg
289    do_lib1 $arg
290    do_lib2 $arg
291    do_cmds $arg
292    ;;
293  lint)
294    do_kern $arg
295    do_lib1 $arg
296    do_lib2 $arg
297    do_cmds $arg
298    ;;
299  clean)
300    # intentionally skip: lib1, hdrs, tools
301    do_cmds $arg
302    do_lib2 $arg
303    do_kern $arg
304    ;;
305  clobber)
306    do_cmds $arg
307    do_lib2 $arg
308    do_lib1 $arg
309    do_kern $arg
310    do_hdrs $arg
311    clobber_tools
312    ;;
313  tags)
314    do_tags
315    ;;
316  tar)
317    do_tar
318    ;;
319  *)
320    echo "Usage: $0 {install|lint|clean|clobber|tags|tar}";
321    exit 1;
322    ;;
323  esac
324done
325