xref: /titanic_50/usr/src/tools/quick/make-smbsrv (revision d235eb05fe584753047218e3a6dd344d0154d19b)
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 2013 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  libidmap \
105  libpam \
106  libsec \
107  libscf \
108  libshare \
109  libsmbfs \
110  libsqlite \
111  libuutil \
112  passwdutil \
113  smbsrv
114do
115  (cd $SRC/lib/$lib && $make $targ)
116done
117}
118
119################################################################
120
121do_kern() {
122  case $1 in
123  lint) targ=modlintlib ;;
124  *) targ=$1 ;;
125  esac
126  ( unset SOURCEDEBUG ;
127  (cd $SRC/uts/$x/nsmb && $make $targ) ;
128  (cd $SRC/uts/$x/smbfs && $make $targ) ;
129  (cd $SRC/uts/$x/smbsrv && $make $targ) )
130}
131
132################################################################
133
134do_libs() {
135
136for lib in \
137  libavl \
138  libcmdutils \
139  libsmbfs \
140  libsqlite \
141  libuutil
142do
143  (cd $SRC/lib/$lib && $make $1)
144done
145
146(cd $SRC/lib/libshare && $make $1 PLUGINS=smb)
147(cd $SRC/lib/smbsrv && $make $1)
148(cd $SRC/lib/passwdutil && $make $1)
149(cd $SRC/lib/pam_modules/smb && $make $1)
150
151}
152
153################################################################
154
155do_cmds() {
156
157case $1 in
158install)
159  # mount programs need fslib.o
160  (cd $SRC/cmd/fs.d && $make fslib.o)
161  (cd $SRC/cmd/fs.d/smbclnt && $make $1 catalog)
162  ;;
163clean|clobber)
164  (cd $SRC/cmd/fs.d/smbclnt && $make $1)
165  (cd $SRC/cmd/fs.d && $make ${1}_local)
166  ;;
167esac
168
169(cd $SRC/cmd/devfsadm && $make $1)
170(cd $SRC/cmd/smbsrv && $make $1)
171
172# Build the MDB modules, WITH the linktest
173(cd $SRC/cmd/mdb/tools && $make $1)
174for a in $mdb_arch
175do
176  case $1 in
177  install|lint)
178    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
179	$make kmdb_modlinktest.o )
180    ;;
181  clean|clobber)
182    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
183	$make -k $1 )
184    ;;
185  esac
186
187  (cd $SRC/cmd/mdb/$x/$a/nsmb &&
188	$make $1 KMDB_LINKTEST_ENABLE= )
189  (cd $SRC/cmd/mdb/$x/$a/smbfs &&
190	$make $1 KMDB_LINKTEST_ENABLE= )
191  (cd $SRC/cmd/mdb/$x/$a/smbsrv &&
192	$make $1 KMDB_LINKTEST_ENABLE= )
193done
194
195(cd $SRC/cmd/Adm/sun && $make $1)
196
197# Deal with mode 0400 file annoyance...
198# See usr/src/cmd/Adm/sun/Makefile
199if [ $1 = install ]; then
200  chmod a+r $ROOT/var/smb/smbpasswd
201fi
202}
203
204
205################################################################
206# This builds $SRC/TAGS (and cscope.files) in a helpful order.
207
208do_tags() {
209	(cd $SRC ;
210	find uts/common/sys -name '*.[ch]' -print |sort
211	find uts/common/net -name '*.[ch]' -print |sort
212	find uts/common/netinet -name '*.[ch]' -print |sort
213	find uts/common/smb -name '*.[ch]' -print |sort
214	find uts/common/smbsrv -name '*.ndl' -print |sort
215	find uts/common/smbsrv -name '*.[ch]' -print |sort
216	find uts/common/fs/smbsrv -name '*.[ch]' -print |sort
217	find lib/libsmbfs -name '*.[ch]' -print |sort
218	find lib/smbsrv -name '*.[ch]' -print |sort
219	find cmd/smbsrv -name '*.[ch]' -print |sort
220	find common/smbsrv -name '*.[ch]' -print |sort
221	) > $SRC/cscope.files
222
223	(cd $SRC ;
224	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
225	cscope -b )
226}
227
228################################################################
229# This creates a tarfile one can use to update a test machine.
230
231do_tar() {
232	files="
233usr/kernel/drv/$arch64/smbsrv
234usr/kernel/drv/smbsrv
235usr/kernel/kmdb/$arch64/smbsrv
236usr/kernel/kmdb/smbsrv
237usr/lib/fs/smb/$arch64/libshare_smb.so.1
238usr/lib/fs/smb/libshare_smb.so.1
239usr/lib/libsmbfs.so.1
240usr/lib/mdb/kvm/$arch64/smbsrv.so
241usr/lib/mdb/kvm/smbsrv.so
242usr/lib/reparse/libreparse_smb.so.1
243usr/lib/security/pam_smb_passwd.so.1
244usr/lib/smbsrv/libmlrpc.so.1
245usr/lib/smbsrv/libmlsvc.so.1
246usr/lib/smbsrv/libsmb.so.1
247usr/lib/smbsrv/libsmbns.so.1
248usr/lib/smbsrv/smbd
249usr/sbin/devfsadm
250usr/sbin/smbadm
251usr/sbin/smbstat
252"
253
254	(cd $ROOT && tar cfj ../../smbsrv.tar.bz2 $files)
255}
256
257################################################################
258
259if [ "$1" = "" ]; then
260  set '?' # force usage
261fi
262
263set -x
264
265for arg
266do
267  case "$arg" in
268  build|install)
269    arg=install
270    build_tools
271    set -e
272    do_hdrs $arg
273    do_kern $arg
274    do_libs $arg
275    do_cmds $arg
276    ;;
277  lint)
278    do_kern $arg
279    do_libs $arg
280    do_cmds $arg
281    ;;
282  clean)
283    do_cmds $arg
284    do_libs $arg
285    do_kern $arg
286    ;;
287  clobber)
288    do_cmds $arg
289    do_libs $arg
290    do_kern $arg
291    do_hdrs $arg
292    clobber_tools
293    ;;
294  tags)
295    do_tags
296    ;;
297  tar)
298    do_tar
299    ;;
300  *)
301    echo "Usage: $0 {build|lint|clean|clobber|tags|tar}";
302    exit 1;
303    ;;
304  esac
305done
306