xref: /titanic_50/usr/src/tools/quick/make-gss (revision 10d63b7db37a83b39c7f511cf9426c9d03ea0760)
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  # system headers
92  (cd $SRC/uts/common/sys && $make -k install_h)
93
94fi
95
96# Need some library headers too...
97for lib in \
98  libgss \
99  libkrb5
100do
101  (cd $SRC/lib/$lib && $make $targ)
102done
103}
104
105################################################################
106
107do_kern() {
108  case $1 in
109  lint) targ=modlintlib ;;
110  *) targ=$1 ;;
111  esac
112  ( unset SOURCEDEBUG ;
113  (cd $SRC/uts/$x/kgssapi && $make $targ) )
114}
115
116################################################################
117
118do_libs() {
119
120for lib in \
121  libgss
122do
123  (cd $SRC/lib/$lib && $make $1)
124done
125
126# For some reason, mech_krb5 does not build for debug.
127# It also takes forever to lint.  skip that.
128if [ "$1" != "lint" ]; then
129  (cd $SRC/lib/gss_mechs/mech_krb5 && unset SOURCEDEBUG && $make $1)
130  (cd $SRC/lib/gss_mechs/mech_spnego && $make $1)
131fi
132
133}
134
135################################################################
136
137do_cmds() {
138
139(cd $SRC/cmd/gss && $make $1)
140
141}
142
143
144################################################################
145# This builds $SRC/TAGS (and cscope.files) in a helpful order.
146
147do_tags() {
148	(cd $SRC ;
149	find uts/common/sys -name '*.[ch]' -print |sort
150	find uts/common/net -name '*.[ch]' -print |sort
151	find uts/common/netinet -name '*.[ch]' -print |sort
152	find uts/common/gssapi -name '*.[ch]' -print |sort
153	find head -name '*.h' -print |sort
154	find lib/gss_mechs -name '*.[ch]' -print |sort
155	find cmd/gss -name '*.[ch]' -print |sort
156	) > $SRC/cscope.files
157
158	(cd $SRC ;
159	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
160	cscope -b )
161}
162
163################################################################
164# This creates a tarfile one can use to update a test machine.
165
166do_tar() {
167	git_rev=`git rev-parse --short=8 HEAD`
168	files="
169usr/lib/gss/gssd
170usr/lib/gss/mech_krb5.so.1
171usr/lib/$arch64/gss/mech_krb5.so.1
172usr/lib/gss/mech_spnego.so.1
173usr/lib/$arch64/gss/mech_spnego.so.1
174usr/lib/libgss.so.1
175usr/lib/$arch64/libgss.so.1
176"
177
178	(cd $ROOT && tar cfj ../../gss-${git_rev}.tar.bz2 $files)
179}
180
181################################################################
182
183if [ "$1" = "" ]; then
184  set '?' # force usage
185fi
186
187set -x
188
189for arg
190do
191  case "$arg" in
192  build|install)
193    arg=install
194    build_tools
195    set -e
196    do_hdrs $arg
197    do_kern $arg
198    do_libs $arg
199    do_cmds $arg
200    ;;
201  lint)
202    do_kern $arg
203    do_libs $arg
204    do_cmds $arg
205    ;;
206  clean)
207    do_cmds $arg
208    do_libs $arg
209    do_kern $arg
210    ;;
211  clobber)
212    do_cmds $arg
213    do_libs $arg
214    do_kern $arg
215    do_hdrs $arg
216    clobber_tools
217    ;;
218  tags)
219    do_tags
220    ;;
221  tar)
222    do_tar
223    ;;
224  *)
225    echo "Usage: $0 {build|lint|clean|clobber|tags|tar}";
226    exit 1;
227    ;;
228  esac
229done
230