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