xref: /titanic_41/usr/src/tools/quick/make-smbsrv (revision 7206bf49b1fe641544165ee97f63856da95e0868)
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 2014 Nexenta Systems, Inc.  All rights reserved.
15#
16
17# Use distributed make (dmake) by default.
18make=${MAKE:-dmake}
19
20CLOSED_IS_PRESENT=no
21export CLOSED_IS_PRESENT
22
23export SOURCEDEBUG=yes
24
25[ -n "$SRC" ] || {
26  echo "SRC not set.  Run 'ws' or 'bldenv' first."
27  exit 1
28}
29
30cpu=`uname -p`
31case $cpu in
32i386)
33	x=intel
34	mdb_arch="ia32 amd64"
35	arch64=amd64
36	;;
37sparc)
38	x=sparc
39	mdb_arch=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 smbsrv headers to be safe
91  # test -f $ROOT/usr/include/smbsrv/wintypes.h ||
92    (cd $SRC/uts/common/sys && $make -k install_h)
93    (cd $SRC/uts/common/smb && $make -k install_h)
94    (cd $SRC/uts/common/smbsrv && $make -k install_h)
95
96fi
97
98# Need some library headers too...
99for lib in \
100  libbsm \
101  libcmdutils \
102  libcryptoutil \
103  libdevid \
104  libfakekernel	\
105  libidmap \
106  libpam \
107  libsec \
108  libscf \
109  libshare \
110  libsmbfs \
111  libsqlite \
112  libuutil \
113  passwdutil \
114  smbsrv
115do
116  (cd $SRC/lib/$lib && $make $targ)
117done
118}
119
120################################################################
121
122do_kern() {
123  case $1 in
124  lint) targ=modlintlib ;;
125  *) targ=$1 ;;
126  esac
127  ( unset SOURCEDEBUG ;
128  (cd $SRC/uts/$x/nsmb && $make $targ) ;
129  (cd $SRC/uts/$x/smbfs && $make $targ) ;
130  (cd $SRC/uts/$x/smbsrv && $make $targ) )
131}
132
133################################################################
134
135# Note lib1 builds prerequisite libraries not delivered by the
136# tar file we create below.  To accelerate clean/install, we
137# skip these on clean (but still nuke them for clobber)
138
139do_lib1() {
140
141for lib in \
142  libavl \
143  libcmdutils \
144  libsqlite \
145  libuutil
146do
147  (cd $SRC/lib/$lib && $make $1)
148done
149}
150
151# lib2 builds stuff we include in the tar file,
152# or that we don't mind rebuilding after clean.
153
154do_lib2() {
155
156for lib in \
157  libfakekernel \
158  libsmbfs
159do
160  (cd $SRC/lib/$lib && $make $1)
161done
162
163(cd $SRC/lib/libshare && $make $1 PLUGINS=smb)
164(cd $SRC/lib/smbsrv && $make $1)
165(cd $SRC/lib/passwdutil && $make $1)
166(cd $SRC/lib/pam_modules/smb && $make $1)
167
168}
169
170################################################################
171
172do_cmds() {
173
174case $1 in
175install)
176  # mount programs need fslib.o
177  (cd $SRC/cmd/fs.d && $make fslib.o)
178  (cd $SRC/cmd/fs.d/smbclnt && $make $1 catalog)
179  ;;
180clean|clobber)
181  (cd $SRC/cmd/fs.d/smbclnt && $make $1)
182  (cd $SRC/cmd/fs.d && $make ${1}_local)
183  ;;
184esac
185
186(cd $SRC/cmd/devfsadm && $make $1)
187(cd $SRC/cmd/smbsrv && $make $1)
188
189# Build the MDB modules, WITH the linktest
190(cd $SRC/cmd/mdb/tools && $make $1)
191for a in $mdb_arch
192do
193  case $1 in
194  install|lint)
195    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
196	$make kmdb_modlinktest.o )
197    ;;
198  clean|clobber)
199    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
200	$make -k $1 )
201    ;;
202  esac
203
204  (cd $SRC/cmd/mdb/$x/$a/nsmb &&
205	$make $1 KMDB_LINKTEST_ENABLE= )
206  (cd $SRC/cmd/mdb/$x/$a/smbfs &&
207	$make $1 KMDB_LINKTEST_ENABLE= )
208  (cd $SRC/cmd/mdb/$x/$a/smbsrv &&
209	$make $1 KMDB_LINKTEST_ENABLE= )
210  (cd $SRC/cmd/mdb/$x/$a/libfksmbsrv &&
211	$make $1 KMDB_LINKTEST_ENABLE= )
212
213# We build these libraries (to the proto area), so we need to
214# build the mdb modules too so mdb will load them.
215  (cd $SRC/cmd/mdb/$x/$a/libcmdutils &&
216	$make $1 )
217  (cd $SRC/cmd/mdb/$x/$a/libavl &&
218	$make $1 )
219
220done
221
222(cd $SRC/cmd/Adm/sun && $make $1)
223
224# Deal with mode 0400 file annoyance...
225# See usr/src/cmd/Adm/sun/Makefile
226if [ $1 = install ]; then
227  chmod a+r $ROOT/var/smb/smbpasswd
228fi
229}
230
231
232################################################################
233# This builds $SRC/TAGS (and cscope.files) in a helpful order.
234
235do_tags() {
236	(cd $SRC ;
237	find uts/common/sys -name '*.[ch]' -print |sort
238	find uts/common/net -name '*.[ch]' -print |sort
239	find uts/common/netinet -name '*.[ch]' -print |sort
240	find uts/common/smb -name '*.[ch]' -print |sort
241	find uts/common/smbsrv -name '*.ndl' -print |sort
242	find uts/common/smbsrv -name '*.[ch]' -print |sort
243	find uts/common/fs/smbsrv -name '*.[ch]' -print |sort
244	find lib/libsmbfs -name '*.[ch]' -print |sort
245	find lib/smbsrv -name '*.[ch]' -print |sort
246	find cmd/smbsrv -name '*.[ch]' -print |sort
247	find common/smbsrv -name '*.[ch]' -print |sort
248	) > $SRC/cscope.files
249
250	(cd $SRC ;
251	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
252	cscope -b )
253}
254
255################################################################
256# This creates a tarfile one can use to update a test machine.
257
258do_tar() {
259	files="
260usr/kernel/drv/$arch64/smbsrv
261usr/kernel/drv/smbsrv
262usr/kernel/kmdb/$arch64/smbsrv
263usr/kernel/kmdb/smbsrv
264usr/lib/fs/smb/$arch64/libshare_smb.so.1
265usr/lib/fs/smb/libshare_smb.so.1
266usr/lib/libsmbfs.so.1
267usr/lib/mdb/kvm/$arch64/smbsrv.so
268usr/lib/mdb/kvm/smbsrv.so
269usr/lib/reparse/libreparse_smb.so.1
270usr/lib/security/pam_smb_passwd.so.1
271usr/lib/smbsrv/libmlrpc.so.1
272usr/lib/smbsrv/libmlsvc.so.1
273usr/lib/smbsrv/libsmb.so.1
274usr/lib/smbsrv/libsmbns.so.1
275usr/lib/smbsrv/smbd
276usr/sbin/devfsadm
277usr/sbin/smbadm
278usr/sbin/smbstat
279"
280
281	(cd $ROOT && tar cfj ../../smbsrv.tar.bz2 $files)
282}
283
284################################################################
285
286if [ "$1" = "" ]; then
287  set '?' # force usage
288fi
289
290set -x
291
292for arg
293do
294  case "$arg" in
295  install)
296    build_tools
297    set -e
298    do_hdrs $arg
299    do_kern $arg
300    do_lib1 $arg
301    do_lib2 $arg
302    do_cmds $arg
303    ;;
304  lint)
305    do_kern $arg
306    do_lib1 $arg
307    do_lib2 $arg
308    do_cmds $arg
309    ;;
310  clean)
311    # intentionally skip: lib1, hdrs, tools
312    do_cmds $arg
313    do_lib2 $arg
314    do_kern $arg
315    ;;
316  clobber)
317    do_cmds $arg
318    do_lib2 $arg
319    do_lib1 $arg
320    do_kern $arg
321    do_hdrs $arg
322    clobber_tools
323    ;;
324  tags)
325    do_tags
326    ;;
327  tar)
328    do_tar
329    ;;
330  *)
331    echo "Usage: $0 {install|lint|clean|clobber|tags|tar}";
332    exit 1;
333    ;;
334  esac
335done
336