xref: /titanic_41/usr/src/tools/quick/make-idmap (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 and smbsrv headers (we need to build libsmb)
92*4f4cb30bSGordon Ross  (cd $SRC/uts/common/sys && $make -k install_h)
93*4f4cb30bSGordon Ross  (cd $SRC/uts/common/smb && $make -k install_h)
94*4f4cb30bSGordon Ross  (cd $SRC/uts/common/smbsrv && $make -k install_h)
95*4f4cb30bSGordon Ross
96*4f4cb30bSGordon Rossfi
97*4f4cb30bSGordon Ross
98*4f4cb30bSGordon Ross# Need some library headers too...
99*4f4cb30bSGordon Rossfor lib in \
100*4f4cb30bSGordon Ross  libbsm \
101*4f4cb30bSGordon Ross  libcmdutils \
102*4f4cb30bSGordon Ross  libcryptoutil \
103*4f4cb30bSGordon Ross  libdevid \
104*4f4cb30bSGordon Ross  libgss \
105*4f4cb30bSGordon Ross  libkrb5 \
106*4f4cb30bSGordon Ross  libldap5 \
107*4f4cb30bSGordon Ross  libidmap \
108*4f4cb30bSGordon Ross  libsmbfs \
109*4f4cb30bSGordon Ross  libsqlite \
110*4f4cb30bSGordon Ross  libuutil
111*4f4cb30bSGordon Rossdo
112*4f4cb30bSGordon Ross  (cd $SRC/lib/$lib && $make $targ)
113*4f4cb30bSGordon Rossdone
114*4f4cb30bSGordon Ross}
115*4f4cb30bSGordon Ross
116*4f4cb30bSGordon Ross################################################################
117*4f4cb30bSGordon Ross
118*4f4cb30bSGordon Rossdo_kern() {
119*4f4cb30bSGordon Ross  case $1 in
120*4f4cb30bSGordon Ross  lint) targ=modlintlib ;;
121*4f4cb30bSGordon Ross  *) targ=$1 ;;
122*4f4cb30bSGordon Ross  esac
123*4f4cb30bSGordon Ross  ( unset SOURCEDEBUG ;
124*4f4cb30bSGordon Ross  (cd $SRC/uts/$x/idmap && $make $targ) )
125*4f4cb30bSGordon Ross}
126*4f4cb30bSGordon Ross
127*4f4cb30bSGordon Ross################################################################
128*4f4cb30bSGordon Ross
129*4f4cb30bSGordon Rossdo_libs() {
130*4f4cb30bSGordon Ross
131*4f4cb30bSGordon Rossfor lib in \
132*4f4cb30bSGordon Ross  libavl \
133*4f4cb30bSGordon Ross  libcmdutils \
134*4f4cb30bSGordon Ross  libldap5 \
135*4f4cb30bSGordon Ross  libadutils \
136*4f4cb30bSGordon Ross  libuutil \
137*4f4cb30bSGordon Ross  libidmap \
138*4f4cb30bSGordon Ross  libsmbfs \
139*4f4cb30bSGordon Ross  libsqlite \
140*4f4cb30bSGordon Ross  nsswitch/ad
141*4f4cb30bSGordon Rossdo
142*4f4cb30bSGordon Ross  (cd $SRC/lib/$lib && $make $1)
143*4f4cb30bSGordon Rossdone
144*4f4cb30bSGordon Ross
145*4f4cb30bSGordon Ross# need libsmb for cmd/idmap/idmapd (and libsmbfs for libsmb)
146*4f4cb30bSGordon Ross(cd $SRC/lib/smbsrv/libsmb && $make $1)
147*4f4cb30bSGordon Ross
148*4f4cb30bSGordon Ross}
149*4f4cb30bSGordon Ross
150*4f4cb30bSGordon Ross################################################################
151*4f4cb30bSGordon Ross
152*4f4cb30bSGordon Rossdo_cmds() {
153*4f4cb30bSGordon Ross
154*4f4cb30bSGordon Ross(cd $SRC/cmd/idmap && $make $1)
155*4f4cb30bSGordon Ross
156*4f4cb30bSGordon Ross}
157*4f4cb30bSGordon Ross
158*4f4cb30bSGordon Ross
159*4f4cb30bSGordon Ross################################################################
160*4f4cb30bSGordon Ross# This builds $SRC/TAGS (and cscope.files) in a helpful order.
161*4f4cb30bSGordon Ross
162*4f4cb30bSGordon Rossdo_tags() {
163*4f4cb30bSGordon Ross	(cd $SRC ;
164*4f4cb30bSGordon Ross	find uts/common/sys -name '*.[ch]' -print |sort
165*4f4cb30bSGordon Ross	find uts/common/net -name '*.[ch]' -print |sort
166*4f4cb30bSGordon Ross	find uts/common/netinet -name '*.[ch]' -print |sort
167*4f4cb30bSGordon Ross	find uts/common/rpcsvc -name '*.[ch]' -print |sort
168*4f4cb30bSGordon Ross	find uts/common/idmap -name '*.[ch]' -print |sort
169*4f4cb30bSGordon Ross	find head -name '*.h' -print |sort
170*4f4cb30bSGordon Ross	find lib/libidmap -name '*.[ch]' -print |sort
171*4f4cb30bSGordon Ross	find lib/libadutils -name '*.[ch]' -print |sort
172*4f4cb30bSGordon Ross	find lib/libldap5 -name '*.[ch]' -print |sort
173*4f4cb30bSGordon Ross	find cmd/idmap -name '*.[ch]' -print |sort
174*4f4cb30bSGordon Ross	) > $SRC/cscope.files
175*4f4cb30bSGordon Ross
176*4f4cb30bSGordon Ross	(cd $SRC ;
177*4f4cb30bSGordon Ross	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
178*4f4cb30bSGordon Ross	cscope -b )
179*4f4cb30bSGordon Ross}
180*4f4cb30bSGordon Ross
181*4f4cb30bSGordon Ross################################################################
182*4f4cb30bSGordon Ross# This creates a tarfile one can use to update a test machine.
183*4f4cb30bSGordon Ross
184*4f4cb30bSGordon Rossdo_tar() {
185*4f4cb30bSGordon Ross	git_rev=`git rev-parse --short=8 HEAD`
186*4f4cb30bSGordon Ross	files="
187*4f4cb30bSGordon Rosslib/svc/manifest/system/idmap.xml
188*4f4cb30bSGordon Rossusr/lib/idmapd
189*4f4cb30bSGordon Rossusr/lib/libadutils.so.1
190*4f4cb30bSGordon Rossusr/lib/$arch64/libadutils.so.1
191*4f4cb30bSGordon Rossusr/lib/libidmap.so.1
192*4f4cb30bSGordon Rossusr/lib/$arch64/libidmap.so.1
193*4f4cb30bSGordon Rossusr/lib/libldap.so.5
194*4f4cb30bSGordon Rossusr/lib/$arch64/libldap.so.5
195*4f4cb30bSGordon Rossusr/lib/nss_ad.so.1
196*4f4cb30bSGordon Rossusr/lib/$arch64/nss_ad.so.1
197*4f4cb30bSGordon Rossusr/bin/test-getdc
198*4f4cb30bSGordon Rossusr/sbin/idmap
199*4f4cb30bSGordon Rossusr/sbin/nltest
200*4f4cb30bSGordon Ross"
201*4f4cb30bSGordon Ross
202*4f4cb30bSGordon Ross	(cd $ROOT && tar cfj ../../idmap-${git_rev}.tar.bz2 $files)
203*4f4cb30bSGordon Ross}
204*4f4cb30bSGordon Ross
205*4f4cb30bSGordon Ross################################################################
206*4f4cb30bSGordon Ross
207*4f4cb30bSGordon Rossif [ "$1" = "" ]; then
208*4f4cb30bSGordon Ross  set '?' # force usage
209*4f4cb30bSGordon Rossfi
210*4f4cb30bSGordon Ross
211*4f4cb30bSGordon Rossset -x
212*4f4cb30bSGordon Ross
213*4f4cb30bSGordon Rossfor arg
214*4f4cb30bSGordon Rossdo
215*4f4cb30bSGordon Ross  case "$arg" in
216*4f4cb30bSGordon Ross  build|install)
217*4f4cb30bSGordon Ross    arg=install
218*4f4cb30bSGordon Ross    build_tools
219*4f4cb30bSGordon Ross    set -e
220*4f4cb30bSGordon Ross    do_hdrs $arg
221*4f4cb30bSGordon Ross    do_kern $arg
222*4f4cb30bSGordon Ross    do_libs $arg
223*4f4cb30bSGordon Ross    do_cmds $arg
224*4f4cb30bSGordon Ross    ;;
225*4f4cb30bSGordon Ross  lint)
226*4f4cb30bSGordon Ross    do_kern $arg
227*4f4cb30bSGordon Ross    do_libs $arg
228*4f4cb30bSGordon Ross    do_cmds $arg
229*4f4cb30bSGordon Ross    ;;
230*4f4cb30bSGordon Ross  clean)
231*4f4cb30bSGordon Ross    do_cmds $arg
232*4f4cb30bSGordon Ross    do_libs $arg
233*4f4cb30bSGordon Ross    do_kern $arg
234*4f4cb30bSGordon Ross    ;;
235*4f4cb30bSGordon Ross  clobber)
236*4f4cb30bSGordon Ross    do_cmds $arg
237*4f4cb30bSGordon Ross    do_libs $arg
238*4f4cb30bSGordon Ross    do_kern $arg
239*4f4cb30bSGordon Ross    do_hdrs $arg
240*4f4cb30bSGordon Ross    clobber_tools
241*4f4cb30bSGordon Ross    ;;
242*4f4cb30bSGordon Ross  tags)
243*4f4cb30bSGordon Ross    do_tags
244*4f4cb30bSGordon Ross    ;;
245*4f4cb30bSGordon Ross  tar)
246*4f4cb30bSGordon Ross    do_tar
247*4f4cb30bSGordon Ross    ;;
248*4f4cb30bSGordon Ross  *)
249*4f4cb30bSGordon Ross    echo "Usage: $0 {build|lint|clean|clobber|tags|tar}";
250*4f4cb30bSGordon Ross    exit 1;
251*4f4cb30bSGordon Ross    ;;
252*4f4cb30bSGordon Ross  esac
253*4f4cb30bSGordon Rossdone
254