5917 User-mode SMB server
[unleashed.git] / usr / src / tools / quick / make-smbsrv
blob3eca17ff831e468279f95e64fa8db4db5db06f75
1 #!/bin/ksh
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.
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.
14 # Copyright 2014 Nexenta Systems, Inc. All rights reserved.
17 # Use distributed make (dmake) by default.
18 make=${MAKE:-dmake}
20 CLOSED_IS_PRESENT=no
21 export CLOSED_IS_PRESENT
23 export SOURCEDEBUG=yes
25 [ -n "$SRC" ] || {
26 echo "SRC not set. Run 'ws' or 'bldenv' first."
27 exit 1
30 cpu=`uname -p`
31 case $cpu in
32 i386)
33 x=intel
34 mdb_arch="ia32 amd64"
35 arch64=amd64
37 sparc)
38 x=sparc
39 mdb_arch=v9
40 arch64=sparcv9
42 *) echo "Huh?" ; exit 1;;
43 esac
45 ################################################################
47 build_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)
53 clobber_tools() {
54 (cd $SRC/tools && $make clobber)
55 (cd $SRC/common/mapfiles; $make clobber)
58 ################################################################
60 do_hdrs() {
62 targ=$1
63 if [ "$targ" = clobber ]
64 then
65 (cd $SRC/uts && $make -k clobber_h)
66 (cd $SRC/head && $make clobber)
69 if [ "$targ" = install ]
70 then
71 targ=install_h
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)
79 test -f $SRC/head/rpcsvc/nispasswd.h ||
80 (cd $SRC/head && $make -k install_h)
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)
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)
98 # Need some library headers too...
99 for 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
116 (cd $SRC/lib/$lib && $make $targ)
117 done
120 ################################################################
122 do_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) )
133 ################################################################
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)
139 do_lib1() {
141 for lib in \
142 libavl \
143 libcmdutils \
144 libsqlite \
145 libuutil
147 (cd $SRC/lib/$lib && $make $1)
148 done
151 # lib2 builds stuff we include in the tar file,
152 # or that we don't mind rebuilding after clean.
154 do_lib2() {
156 for lib in \
157 libfakekernel \
158 libsmbfs
160 (cd $SRC/lib/$lib && $make $1)
161 done
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)
170 ################################################################
172 do_cmds() {
174 case $1 in
175 install)
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)
180 clean|clobber)
181 (cd $SRC/cmd/fs.d/smbclnt && $make $1)
182 (cd $SRC/cmd/fs.d && $make ${1}_local)
184 esac
186 (cd $SRC/cmd/devfsadm && $make $1)
187 (cd $SRC/cmd/smbsrv && $make $1)
189 # Build the MDB modules, WITH the linktest
190 (cd $SRC/cmd/mdb/tools && $make $1)
191 for a in $mdb_arch
193 case $1 in
194 install|lint)
195 (cd $SRC/cmd/mdb/$x/$a/kmdb &&
196 $make kmdb_modlinktest.o )
198 clean|clobber)
199 (cd $SRC/cmd/mdb/$x/$a/kmdb &&
200 $make -k $1 )
202 esac
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= )
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 )
220 done
222 (cd $SRC/cmd/Adm/sun && $make $1)
224 # Deal with mode 0400 file annoyance...
225 # See usr/src/cmd/Adm/sun/Makefile
226 if [ $1 = install ]; then
227 chmod a+r $ROOT/var/smb/smbpasswd
232 ################################################################
233 # This builds $SRC/TAGS (and cscope.files) in a helpful order.
235 do_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
250 (cd $SRC ;
251 exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
252 cscope -b )
255 ################################################################
256 # This creates a tarfile one can use to update a test machine.
258 do_tar() {
259 files="
260 usr/kernel/drv/$arch64/smbsrv
261 usr/kernel/drv/smbsrv
262 usr/kernel/kmdb/$arch64/smbsrv
263 usr/kernel/kmdb/smbsrv
264 usr/lib/fs/smb/$arch64/libshare_smb.so.1
265 usr/lib/fs/smb/libshare_smb.so.1
266 usr/lib/libsmbfs.so.1
267 usr/lib/mdb/kvm/$arch64/smbsrv.so
268 usr/lib/mdb/kvm/smbsrv.so
269 usr/lib/reparse/libreparse_smb.so.1
270 usr/lib/security/pam_smb_passwd.so.1
271 usr/lib/smbsrv/libmlrpc.so.1
272 usr/lib/smbsrv/libmlsvc.so.1
273 usr/lib/smbsrv/libsmb.so.1
274 usr/lib/smbsrv/libsmbns.so.1
275 usr/lib/smbsrv/smbd
276 usr/sbin/devfsadm
277 usr/sbin/smbadm
278 usr/sbin/smbstat
281 (cd $ROOT && tar cfj ../../smbsrv.tar.bz2 $files)
284 ################################################################
286 if [ "$1" = "" ]; then
287 set '?' # force usage
290 set -x
292 for arg
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
304 lint)
305 do_kern $arg
306 do_lib1 $arg
307 do_lib2 $arg
308 do_cmds $arg
310 clean)
311 # intentionally skip: lib1, hdrs, tools
312 do_cmds $arg
313 do_lib2 $arg
314 do_kern $arg
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
324 tags)
325 do_tags
327 tar)
328 do_tar
331 echo "Usage: $0 {install|lint|clean|clobber|tags|tar}";
332 exit 1;
334 esac
335 done