xref: /titanic_52/usr/src/tools/quick/make-smbsrv (revision 7a5aac98bc37534537d4896efd4efd30627d221e)
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
23# Do this if you want to use dbx or gdb
24# export SOURCEDEBUG=yes
25
26[ -n "$SRC" ] || {
27  echo "SRC not set.  Run 'ws' or 'bldenv' first."
28  exit 1
29}
30
31cpu=`uname -p`
32case $cpu in
33i386)
34	x=intel
35	mdb_arch="ia32 amd64"
36	arch64=amd64
37	;;
38sparc)
39	x=sparc
40	mdb_arch=v9
41	arch64=sparcv9
42	;;
43*)  echo "Huh?" ; exit 1;;
44esac
45
46################################################################
47
48build_tools() {
49  test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets ||
50    (cd $SRC/tools && $make install)
51  (cd $SRC/common/mapfiles; $make install)
52}
53
54clobber_tools() {
55  (cd $SRC/tools && $make clobber)
56  (cd $SRC/common/mapfiles; $make clobber)
57}
58
59################################################################
60
61do_hdrs() {
62
63targ=$1
64if [ "$targ" = clobber ]
65then
66  (cd $SRC/uts && $make -k clobber_h)
67  (cd $SRC/head && $make clobber)
68fi
69
70if [ "$targ" = install ]
71then
72  targ=install_h
73
74  # Just the parts of "make sgs" we need, and
75  # skip them if they appear to be done.
76  # ... stuff under $SRC
77  test -f $SRC/uts/common/sys/priv_names.h ||
78    (cd $SRC/uts && $make -k all_h)
79
80  test -f $SRC/head/rpcsvc/nispasswd.h ||
81    (cd $SRC/head && $make -k install_h)
82
83  # ... stuff under $ROOT (proto area)
84  test -d $ROOT/usr/include/sys ||
85    (cd $SRC && $make rootdirs)
86  test -f $ROOT/usr/include/sys/types.h ||
87    (cd $SRC/uts && $make -k install_h)
88  test -f $ROOT/usr/include/rpcsvc/daemon_utils.h ||
89    (cd $SRC/head && $make install_h)
90
91  # always update the smbsrv headers to be safe
92  (cd $SRC/uts/common/gssapi && $make -k install_h)
93  (cd $SRC/uts/common/sys && $make -k install_h)
94  (cd $SRC/uts/common/smb && $make -k install_h)
95  (cd $SRC/uts/common/smbsrv && $make -k install_h)
96
97fi
98
99# Need some library headers too...
100for lib in \
101  libads \
102  libbsm \
103  libcmdutils \
104  libcryptoutil \
105  libdevid \
106  libfakekernel	\
107  libgss \
108  libkrb5 \
109  libidmap \
110  libpam \
111  libsec \
112  libscf \
113  libshare \
114  libsmbfs \
115  libsqlite \
116  libuutil \
117  passwdutil \
118  smbsrv
119do
120  (cd $SRC/lib/$lib && $make $targ)
121done
122}
123
124################################################################
125
126do_kern() {
127  case $1 in
128  lint) targ=modlintlib ;;
129  *) targ=$1 ;;
130  esac
131  ( unset SOURCEDEBUG ;
132  (cd $SRC/uts/$x/nsmb && $make $targ) ;
133  (cd $SRC/uts/$x/smbfs && $make $targ) ;
134  (cd $SRC/uts/$x/smbsrv && $make $targ) )
135}
136
137################################################################
138
139# Note lib1 builds prerequisite libraries not delivered by the
140# tar file we create below.  To accelerate clean/install, we
141# skip these on clean (but still nuke them for clobber)
142
143do_lib1() {
144
145for lib in \
146  libavl \
147  libgss \
148  libkrb5 \
149  libcmdutils \
150  libsqlite \
151  libuutil
152do
153  (cd $SRC/lib/$lib && $make $1)
154done
155}
156
157# lib2 builds stuff we include in the tar file,
158# or that we don't mind rebuilding after clean.
159
160do_lib2() {
161
162for lib in \
163  libfakekernel \
164  libads \
165  libsmbfs
166do
167  (cd $SRC/lib/$lib && $make $1)
168done
169
170(cd $SRC/lib/libshare && $make $1 PLUGINS=smb)
171(cd $SRC/lib/smbsrv && $make $1)
172(cd $SRC/lib/passwdutil && $make $1)
173(cd $SRC/lib/pam_modules/smb && $make $1)
174
175}
176
177################################################################
178
179do_cmds() {
180
181case $1 in
182install)
183  # mount programs need fslib.o
184  (cd $SRC/cmd/fs.d && $make fslib.o)
185  (cd $SRC/cmd/fs.d/smbclnt && $make $1 catalog)
186  ;;
187clean|clobber)
188  (cd $SRC/cmd/fs.d/smbclnt && $make $1)
189  (cd $SRC/cmd/fs.d && $make ${1}_local)
190  ;;
191esac
192
193(cd $SRC/cmd/devfsadm && $make $1)
194(cd $SRC/cmd/smbsrv && $make $1)
195
196# Build the MDB modules, WITH the linktest
197(cd $SRC/cmd/mdb/tools && $make $1)
198for a in $mdb_arch
199do
200  case $1 in
201  install|lint)
202    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
203	$make kmdb_modlinktest.o )
204    ;;
205  clean|clobber)
206    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
207	$make -k $1 )
208    ;;
209  esac
210
211  (cd $SRC/cmd/mdb/$x/$a/nsmb &&
212	$make $1 KMDB_LINKTEST_ENABLE= )
213  (cd $SRC/cmd/mdb/$x/$a/smbfs &&
214	$make $1 KMDB_LINKTEST_ENABLE= )
215  (cd $SRC/cmd/mdb/$x/$a/smbsrv &&
216	$make $1 KMDB_LINKTEST_ENABLE= )
217  (cd $SRC/cmd/mdb/$x/$a/libfksmbsrv &&
218	$make $1 KMDB_LINKTEST_ENABLE= )
219
220# We build these libraries (to the proto area), so we need to
221# build the mdb modules too so mdb will load them.
222  (cd $SRC/cmd/mdb/$x/$a/libcmdutils &&
223	$make $1 )
224  (cd $SRC/cmd/mdb/$x/$a/libavl &&
225	$make $1 )
226
227done
228
229(cd $SRC/cmd/Adm/sun && $make $1)
230
231# Deal with mode 0400 file annoyance...
232# See usr/src/cmd/Adm/sun/Makefile
233if [ $1 = install ]; then
234  chmod a+r $ROOT/var/smb/smbpasswd
235fi
236}
237
238
239################################################################
240# This builds $SRC/TAGS (and cscope.files) in a helpful order.
241
242do_tags() {
243	(cd $SRC ;
244	find uts/common/sys -name '*.[ch]' -print |sort
245	find uts/common/net -name '*.[ch]' -print |sort
246	find uts/common/netinet -name '*.[ch]' -print |sort
247	find uts/common/smb -name '*.[ch]' -print |sort
248	find uts/common/smbsrv -name '*.ndl' -print |sort
249	find uts/common/smbsrv -name '*.[ch]' -print |sort
250	find uts/common/fs/smbsrv -name '*.[ch]' -print |sort
251	find uts/common/gssapi -name '*.[ch]' -print |sort
252	find head -name '*.h' -print |sort
253	find lib/smbsrv -name '*.[ch]' -print |sort
254	find lib/libsmbfs -name '*.[ch]' -print |sort
255	find lib/libads -name '*.[ch]' -print |sort
256	find lib/libgss -name '*.[ch]' -print |sort
257	find cmd/smbsrv -name '*.[ch]' -print |sort
258	find common/smbsrv -name '*.[ch]' -print |sort
259	) > $SRC/cscope.files
260
261	(cd $SRC ;
262	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
263	cscope -b )
264}
265
266################################################################
267# This creates a tarfile one can use to update a test machine.
268
269do_tar() {
270	git_rev=`git rev-parse --short=8 HEAD`
271	files="
272lib/svc/manifest/network/smb/server.xml
273usr/kernel/drv/$arch64/smbsrv
274usr/kernel/drv/smbsrv
275usr/kernel/kmdb/$arch64/smbsrv
276usr/kernel/kmdb/smbsrv
277usr/lib/fs/smb/$arch64/libshare_smb.so.1
278usr/lib/fs/smb/libshare_smb.so.1
279usr/lib/libsmbfs.so.1
280usr/lib/mdb/kvm/$arch64/smbsrv.so
281usr/lib/mdb/kvm/smbsrv.so
282usr/lib/reparse/libreparse_smb.so.1
283usr/lib/security/pam_smb_passwd.so.1
284usr/lib/smbsrv/dtrace
285usr/lib/smbsrv/libmlrpc.so.1
286usr/lib/smbsrv/libmlsvc.so.1
287usr/lib/smbsrv/libsmb.so.1
288usr/lib/smbsrv/libsmbns.so.1
289usr/lib/smbsrv/smbd
290usr/sbin/devfsadm
291usr/sbin/smbadm
292usr/sbin/smbstat
293"
294
295	(cd $ROOT && tar cfj ../../smbsrv-${git_rev}.tar.bz2 $files)
296}
297
298################################################################
299
300if [ "$1" = "" ]; then
301  set '?' # force usage
302fi
303
304set -x
305
306for arg
307do
308  case "$arg" in
309  install)
310    build_tools
311    set -e
312    do_hdrs $arg
313    do_kern $arg
314    do_lib1 $arg
315    do_lib2 $arg
316    do_cmds $arg
317    ;;
318  lint)
319    do_kern $arg
320    do_lib1 $arg
321    do_lib2 $arg
322    do_cmds $arg
323    ;;
324  clean)
325    # intentionally skip: lib1, hdrs, tools
326    do_cmds $arg
327    do_lib2 $arg
328    do_kern $arg
329    ;;
330  clobber)
331    do_cmds $arg
332    do_lib2 $arg
333    do_lib1 $arg
334    do_kern $arg
335    do_hdrs $arg
336    clobber_tools
337    ;;
338  tags)
339    do_tags
340    ;;
341  tar)
342    do_tar
343    ;;
344  *)
345    echo "Usage: $0 {install|lint|clean|clobber|tags|tar}";
346    exit 1;
347    ;;
348  esac
349done
350