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