summaryrefslogtreecommitdiff
path: root/quickbuild
blob: 1c4638e3879d16ceea7825569dcdba4d9867d8ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/ksh
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
#

# Use distributed make (dmake) by default.
make=${MAKE:-dmake}

# Do this if you want to use dbx or gdb
# export SOURCEDEBUG=yes

[ -n "$SRC" ] || {
  echo "SRC not set.  Run 'ws' or 'bldenv' first."
  exit 1
}

cpu=`uname -p`
case $cpu in
i386)
	x=intel
	mdb_arch="ia32 amd64"
	arch64=amd64
	;;
sparc)
	x=sparc
	mdb_arch=v9
	arch64=sparcv9
	;;
*)  echo "Huh?" ; exit 1;;
esac

################################################################

build_tools() {
  test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets ||
    (cd $SRC/tools && $make install)
  (cd $SRC/common/mapfiles/common; $make install)
}

clobber_tools() {
  (cd $SRC/tools && $make clobber)
  (cd $SRC/common/mapfiles/common; $make clobber)
}

################################################################

do_hdrs() {

case $1 in
clean|clobber)
  (cd $SRC/uts && $make -k clobber_h)
  (cd $SRC/head && $make clobber)
  ;;
install)
  (cd $SRC && $make sgs)
  ;;
*)
  ;;
esac

# Need some library headers too...
(cd $SRC/lib/libfoo && $make $targ)

}

################################################################

do_kern() {
  case $1 in
  lint) targ=modlintlib ;;
  *) targ=$1 ;;
  esac
  ( unset SOURCEDEBUG ;
   (cd $SRC/uts/$x/foo && $make $targ)
  )
}

################################################################

do_libs() {

  (cd $SRC/lib && $make $1)

}

################################################################

do_cmds() {

  (cd $SRC/cmd && $make $1)

}

################################################################

do_mans() {

  (cd $SRC/man && $make $1)
}


################################################################
# This builds $SRC/TAGS (and cscope.files) in a helpful order.

do_tags() {
	(cd $SRC ;
	find uts/common/sys -name '*.[ch]' -print |sort
	find lib/libfoo -name '*.[ch]' -print |sort
	find cmd/foo -name '*.[ch]' -print |sort
	) > $SRC/cscope.files

	(cd $SRC ;
	exctags -e -L - < cscope.files
	cscope -b )
}

################################################################
# This creates a tarfile one can use to update a test machine.

do_tar() {
	git_rev=`git rev-parse --short=8 HEAD`
	files="
kernel/drv/foo.conf
kernel/drv/$arch64/foo
kernel/drv/foo
usr/lib/libfoo.so.1
usr/lib/libfoo.so
usr/bin/foo
"

	(cd $ROOT && tar cfj ../../on-skel-${git_rev}.tar.bz2 $files)
}

################################################################

if [ "$1" = "" ]; then
  set '?' # force usage
fi

set -x

for arg
do
  case "$arg" in
  install)
    build_tools
    set -e
    do_hdrs $arg
    do_kern $arg
    do_libs $arg
    do_cmds $arg
    do_mans $arg
    ;;
  lint)
    do_kern $arg
    do_libs $arg
    do_cmds $arg
    ;;
  check)
    do_libs $arg
    do_cmds $arg
    do_mans $arg
    ;;
  clean)
    # intentionally skip: lib1, hdrs, tools
    do_mans $arg
    do_cmds $arg
    do_libs $arg
    do_kern $arg
    ;;
  clobber)
    do_mans $arg
    do_cmds $arg
    do_libs $arg
    do_kern $arg
    do_hdrs $arg
    clobber_tools
    ;;
  tags)
    do_tags
    ;;
  tar)
    do_tar
    ;;
  *)
    echo "Usage: $0 {install|lint|check|clean|clobber|tags|tar}";
    exit 1;
    ;;
  esac
done