xref: /titanic_41/usr/src/tools/quick/make-gss (revision 4f4cb30ba3c6b5af6c9141b197634fbb900e60c3)
1*4f4cb30bSGordon Ross#!/bin/ksh
2*4f4cb30bSGordon Ross#
3*4f4cb30bSGordon Ross# This file and its contents are supplied under the terms of the
4*4f4cb30bSGordon Ross# Common Development and Distribution License ("CDDL"), version 1.0.
5*4f4cb30bSGordon Ross# You may only use this file in accordance with the terms of version
6*4f4cb30bSGordon Ross# 1.0 of the CDDL.
7*4f4cb30bSGordon Ross#
8*4f4cb30bSGordon Ross# A full copy of the text of the CDDL should have accompanied this
9*4f4cb30bSGordon Ross# source.  A copy of the CDDL is also available via the Internet at
10*4f4cb30bSGordon Ross# http://www.illumos.org/license/CDDL.
11*4f4cb30bSGordon Ross#
12*4f4cb30bSGordon Ross
13*4f4cb30bSGordon Ross#
14*4f4cb30bSGordon Ross# Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
15*4f4cb30bSGordon Ross#
16*4f4cb30bSGordon Ross
17*4f4cb30bSGordon Ross# Use distributed make (dmake) by default.
18*4f4cb30bSGordon Rossmake=${MAKE:-dmake}
19*4f4cb30bSGordon Ross
20*4f4cb30bSGordon RossCLOSED_IS_PRESENT=no
21*4f4cb30bSGordon Rossexport CLOSED_IS_PRESENT
22*4f4cb30bSGordon Ross
23*4f4cb30bSGordon Ross# Do this if you want to use dbx or gdb
24*4f4cb30bSGordon Ross# export SOURCEDEBUG=yes
25*4f4cb30bSGordon Ross
26*4f4cb30bSGordon Ross[ -n "$SRC" ] || {
27*4f4cb30bSGordon Ross  echo "SRC not set.  Run 'ws' or 'bldenv' first."
28*4f4cb30bSGordon Ross  exit 1
29*4f4cb30bSGordon Ross}
30*4f4cb30bSGordon Ross
31*4f4cb30bSGordon Rosscpu=`uname -p`
32*4f4cb30bSGordon Rosscase $cpu in
33*4f4cb30bSGordon Rossi386)
34*4f4cb30bSGordon Ross	x=intel
35*4f4cb30bSGordon Ross	mdb_arch="ia32 amd64"
36*4f4cb30bSGordon Ross	arch64=amd64
37*4f4cb30bSGordon Ross	;;
38*4f4cb30bSGordon Rosssparc)
39*4f4cb30bSGordon Ross	x=sparc
40*4f4cb30bSGordon Ross	mdb_arch=v9
41*4f4cb30bSGordon Ross	arch64=sparcv9
42*4f4cb30bSGordon Ross	;;
43*4f4cb30bSGordon Ross*)  echo "Huh?" ; exit 1;;
44*4f4cb30bSGordon Rossesac
45*4f4cb30bSGordon Ross
46*4f4cb30bSGordon Ross################################################################
47*4f4cb30bSGordon Ross
48*4f4cb30bSGordon Rossbuild_tools() {
49*4f4cb30bSGordon Ross  test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets ||
50*4f4cb30bSGordon Ross    (cd $SRC/tools && $make install)
51*4f4cb30bSGordon Ross  (cd $SRC/common/mapfiles; $make install)
52*4f4cb30bSGordon Ross}
53*4f4cb30bSGordon Ross
54*4f4cb30bSGordon Rossclobber_tools() {
55*4f4cb30bSGordon Ross  (cd $SRC/tools && $make clobber)
56*4f4cb30bSGordon Ross  (cd $SRC/common/mapfiles; $make clobber)
57*4f4cb30bSGordon Ross}
58*4f4cb30bSGordon Ross
59*4f4cb30bSGordon Ross################################################################
60*4f4cb30bSGordon Ross
61*4f4cb30bSGordon Rossdo_hdrs() {
62*4f4cb30bSGordon Ross
63*4f4cb30bSGordon Rosstarg=$1
64*4f4cb30bSGordon Rossif [ "$targ" = clobber ]
65*4f4cb30bSGordon Rossthen
66*4f4cb30bSGordon Ross  (cd $SRC/uts && $make -k clobber_h)
67*4f4cb30bSGordon Ross  (cd $SRC/head && $make clobber)
68*4f4cb30bSGordon Rossfi
69*4f4cb30bSGordon Ross
70*4f4cb30bSGordon Rossif [ "$targ" = install ]
71*4f4cb30bSGordon Rossthen
72*4f4cb30bSGordon Ross  targ=install_h
73*4f4cb30bSGordon Ross
74*4f4cb30bSGordon Ross  # Just the parts of "make sgs" we need, and
75*4f4cb30bSGordon Ross  # skip them if they appear to be done.
76*4f4cb30bSGordon Ross  # ... stuff under $SRC
77*4f4cb30bSGordon Ross  test -f $SRC/uts/common/sys/priv_names.h ||
78*4f4cb30bSGordon Ross    (cd $SRC/uts && $make -k all_h)
79*4f4cb30bSGordon Ross
80*4f4cb30bSGordon Ross  test -f $SRC/head/rpcsvc/nispasswd.h ||
81*4f4cb30bSGordon Ross    (cd $SRC/head && $make -k install_h)
82*4f4cb30bSGordon Ross
83*4f4cb30bSGordon Ross  # ... stuff under $ROOT (proto area)
84*4f4cb30bSGordon Ross  test -d $ROOT/usr/include/sys ||
85*4f4cb30bSGordon Ross    (cd $SRC && $make rootdirs)
86*4f4cb30bSGordon Ross  test -f $ROOT/usr/include/sys/types.h ||
87*4f4cb30bSGordon Ross    (cd $SRC/uts && $make -k install_h)
88*4f4cb30bSGordon Ross  test -f $ROOT/usr/include/rpcsvc/daemon_utils.h ||
89*4f4cb30bSGordon Ross    (cd $SRC/head && $make install_h)
90*4f4cb30bSGordon Ross
91*4f4cb30bSGordon Ross  # system headers
92*4f4cb30bSGordon Ross  (cd $SRC/uts/common/sys && $make -k install_h)
93*4f4cb30bSGordon Ross
94*4f4cb30bSGordon Rossfi
95*4f4cb30bSGordon Ross
96*4f4cb30bSGordon Ross# Need some library headers too...
97*4f4cb30bSGordon Rossfor lib in \
98*4f4cb30bSGordon Ross  libgss \
99*4f4cb30bSGordon Ross  libkrb5
100*4f4cb30bSGordon Rossdo
101*4f4cb30bSGordon Ross  (cd $SRC/lib/$lib && $make $targ)
102*4f4cb30bSGordon Rossdone
103*4f4cb30bSGordon Ross}
104*4f4cb30bSGordon Ross
105*4f4cb30bSGordon Ross################################################################
106*4f4cb30bSGordon Ross
107*4f4cb30bSGordon Rossdo_kern() {
108*4f4cb30bSGordon Ross  case $1 in
109*4f4cb30bSGordon Ross  lint) targ=modlintlib ;;
110*4f4cb30bSGordon Ross  *) targ=$1 ;;
111*4f4cb30bSGordon Ross  esac
112*4f4cb30bSGordon Ross  ( unset SOURCEDEBUG ;
113*4f4cb30bSGordon Ross  (cd $SRC/uts/$x/kgssapi && $make $targ) )
114*4f4cb30bSGordon Ross}
115*4f4cb30bSGordon Ross
116*4f4cb30bSGordon Ross################################################################
117*4f4cb30bSGordon Ross
118*4f4cb30bSGordon Rossdo_libs() {
119*4f4cb30bSGordon Ross
120*4f4cb30bSGordon Rossfor lib in \
121*4f4cb30bSGordon Ross  libgss
122*4f4cb30bSGordon Rossdo
123*4f4cb30bSGordon Ross  (cd $SRC/lib/$lib && $make $1)
124*4f4cb30bSGordon Rossdone
125*4f4cb30bSGordon Ross
126*4f4cb30bSGordon Ross# For some reason, mech_krb5 does not build for debug.
127*4f4cb30bSGordon Ross# It also takes forever to lint.  skip that.
128*4f4cb30bSGordon Rossif [ "$1" != "lint" ]; then
129*4f4cb30bSGordon Ross  (cd $SRC/lib/gss_mechs/mech_krb5 && unset SOURCEDEBUG && $make $1)
130*4f4cb30bSGordon Ross  (cd $SRC/lib/gss_mechs/mech_spnego && $make $1)
131*4f4cb30bSGordon Rossfi
132*4f4cb30bSGordon Ross
133*4f4cb30bSGordon Ross}
134*4f4cb30bSGordon Ross
135*4f4cb30bSGordon Ross################################################################
136*4f4cb30bSGordon Ross
137*4f4cb30bSGordon Rossdo_cmds() {
138*4f4cb30bSGordon Ross
139*4f4cb30bSGordon Ross(cd $SRC/cmd/gss && $make $1)
140*4f4cb30bSGordon Ross
141*4f4cb30bSGordon Ross}
142*4f4cb30bSGordon Ross
143*4f4cb30bSGordon Ross
144*4f4cb30bSGordon Ross################################################################
145*4f4cb30bSGordon Ross# This builds $SRC/TAGS (and cscope.files) in a helpful order.
146*4f4cb30bSGordon Ross
147*4f4cb30bSGordon Rossdo_tags() {
148*4f4cb30bSGordon Ross	(cd $SRC ;
149*4f4cb30bSGordon Ross	find uts/common/sys -name '*.[ch]' -print |sort
150*4f4cb30bSGordon Ross	find uts/common/net -name '*.[ch]' -print |sort
151*4f4cb30bSGordon Ross	find uts/common/netinet -name '*.[ch]' -print |sort
152*4f4cb30bSGordon Ross	find uts/common/gssapi -name '*.[ch]' -print |sort
153*4f4cb30bSGordon Ross	find head -name '*.h' -print |sort
154*4f4cb30bSGordon Ross	find lib/gss_mechs -name '*.[ch]' -print |sort
155*4f4cb30bSGordon Ross	find cmd/gss -name '*.[ch]' -print |sort
156*4f4cb30bSGordon Ross	) > $SRC/cscope.files
157*4f4cb30bSGordon Ross
158*4f4cb30bSGordon Ross	(cd $SRC ;
159*4f4cb30bSGordon Ross	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
160*4f4cb30bSGordon Ross	cscope -b )
161*4f4cb30bSGordon Ross}
162*4f4cb30bSGordon Ross
163*4f4cb30bSGordon Ross################################################################
164*4f4cb30bSGordon Ross# This creates a tarfile one can use to update a test machine.
165*4f4cb30bSGordon Ross
166*4f4cb30bSGordon Rossdo_tar() {
167*4f4cb30bSGordon Ross	git_rev=`git rev-parse --short=8 HEAD`
168*4f4cb30bSGordon Ross	files="
169*4f4cb30bSGordon Rossusr/lib/gss/gssd
170*4f4cb30bSGordon Rossusr/lib/gss/mech_krb5.so.1
171*4f4cb30bSGordon Rossusr/lib/$arch64/gss/mech_krb5.so.1
172*4f4cb30bSGordon Rossusr/lib/gss/mech_spnego.so.1
173*4f4cb30bSGordon Rossusr/lib/$arch64/gss/mech_spnego.so.1
174*4f4cb30bSGordon Rossusr/lib/libgss.so.1
175*4f4cb30bSGordon Rossusr/lib/$arch64/libgss.so.1
176*4f4cb30bSGordon Ross"
177*4f4cb30bSGordon Ross
178*4f4cb30bSGordon Ross	(cd $ROOT && tar cfj ../../gss-${git_rev}.tar.bz2 $files)
179*4f4cb30bSGordon Ross}
180*4f4cb30bSGordon Ross
181*4f4cb30bSGordon Ross################################################################
182*4f4cb30bSGordon Ross
183*4f4cb30bSGordon Rossif [ "$1" = "" ]; then
184*4f4cb30bSGordon Ross  set '?' # force usage
185*4f4cb30bSGordon Rossfi
186*4f4cb30bSGordon Ross
187*4f4cb30bSGordon Rossset -x
188*4f4cb30bSGordon Ross
189*4f4cb30bSGordon Rossfor arg
190*4f4cb30bSGordon Rossdo
191*4f4cb30bSGordon Ross  case "$arg" in
192*4f4cb30bSGordon Ross  build|install)
193*4f4cb30bSGordon Ross    arg=install
194*4f4cb30bSGordon Ross    build_tools
195*4f4cb30bSGordon Ross    set -e
196*4f4cb30bSGordon Ross    do_hdrs $arg
197*4f4cb30bSGordon Ross    do_kern $arg
198*4f4cb30bSGordon Ross    do_libs $arg
199*4f4cb30bSGordon Ross    do_cmds $arg
200*4f4cb30bSGordon Ross    ;;
201*4f4cb30bSGordon Ross  lint)
202*4f4cb30bSGordon Ross    do_kern $arg
203*4f4cb30bSGordon Ross    do_libs $arg
204*4f4cb30bSGordon Ross    do_cmds $arg
205*4f4cb30bSGordon Ross    ;;
206*4f4cb30bSGordon Ross  clean)
207*4f4cb30bSGordon Ross    do_cmds $arg
208*4f4cb30bSGordon Ross    do_libs $arg
209*4f4cb30bSGordon Ross    do_kern $arg
210*4f4cb30bSGordon Ross    ;;
211*4f4cb30bSGordon Ross  clobber)
212*4f4cb30bSGordon Ross    do_cmds $arg
213*4f4cb30bSGordon Ross    do_libs $arg
214*4f4cb30bSGordon Ross    do_kern $arg
215*4f4cb30bSGordon Ross    do_hdrs $arg
216*4f4cb30bSGordon Ross    clobber_tools
217*4f4cb30bSGordon Ross    ;;
218*4f4cb30bSGordon Ross  tags)
219*4f4cb30bSGordon Ross    do_tags
220*4f4cb30bSGordon Ross    ;;
221*4f4cb30bSGordon Ross  tar)
222*4f4cb30bSGordon Ross    do_tar
223*4f4cb30bSGordon Ross    ;;
224*4f4cb30bSGordon Ross  *)
225*4f4cb30bSGordon Ross    echo "Usage: $0 {build|lint|clean|clobber|tags|tar}";
226*4f4cb30bSGordon Ross    exit 1;
227*4f4cb30bSGordon Ross    ;;
228*4f4cb30bSGordon Ross  esac
229*4f4cb30bSGordon Rossdone
230