blob: 331a41787ab1d49f81ab24e1128a7d7fd16b0be2 (
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
:
# NAME:
# boot-strap
#
# SYNOPSIS:
# boot-strap [--"configure_arg" ... ][-s "srcdir"][-m "mksrc"]\\
# ["prefix" ["bmakesrc" ["mksrc"]]]
#
# DESCRIPTION:
# This script is used to configure/build bmake it builds for
# each OS in a subdir to keep the src clean.
# On successful completion it echos commands to put the new
# bmake binary into the /configs tree (if it exists)
# (http://www.crufty.net/FreeWare/configs.html), $prefix/bin
# and a suitable ~/*bin directory.
#
# Options:
#
# -c "rc"
# Pick up settings from "rc".
# We look for '.bmake-boot-strap.rc' before processing
# options.
#
# -m "mksrc"
# Indicate where the mk files can be found.
# Default is ./mk or ../mk, set to 'none' to force
# building without "mksrc" but in that case a sys.mk
# needs to exist in the default syspath ($prefix/share/mk)
#
# Possibly useful configure_args:
#
# --with-machine="machine"
# set "machine" to override that determined by
# machine.sh
#
# --with-force-machine="machine"
# force "machine" even if uname(3) provides a value.
#
# --with-machine_arch="machine_arch"
# set "machine_arch" to override that determined by
# machine.sh
#
# --with-default-sys-path="syspath"
# set an explicit default "syspath" which is where bmake
# will look for sys.mk and friends.
#
# --with-prefix-sys-path="syspath"
# prefix the built in default syspath with "syspath"
#
# AUTHOR:
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
# $Id: boot-strap,v 1.3 2008/03/09 19:54:29 joerg Exp $
#
# @(#) Copyright (c) 2001 Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
Mydir=`dirname $0`
. $Mydir/os.sh
case $Mydir in
/*) ;;
*) Mydir=`cd $Mydir; /bin/pwd`;;
esac
Usage() {
[ "$1" ] && echo "ERROR: $@" >&2
echo "Usage:" >&2
echo "$0 [--<configure_arg> ...][-s <srcdir>][-m <mksrc>][<prefix> [[<srcdir>] [<mksrc>]]]" >&2
exit 1
}
Error() {
echo "ERROR: $@" >&2
exit 1
}
source_rc() {
rc=$1; shift
for d in ${*:-""}
do
r=${d:+$d/}$rc
[ -f $r -a -s $r ] || continue
echo "NOTE: reading $r"
. $r
break
done
}
CONFIGURE_ARGS=
# pick a useful default prefix (for me at least ;-)
for prefix in /opt/$HOST_TARGET $HOME/$HOST_TARGET /usr/pkg /usr/local ""
do
[ -d ${prefix:-.} ] && break
done
srcdir=
mksrc=
objdir=
quiet=:
source_rc .bmake-boot-strap.rc . $Mydir/.. $HOME
while :
do
case "$1" in
--) shift; break;;
--prefix) prefix=$2; shift 2;;
--prefix=*) prefix=`IFS="="; set -- $1; echo $2`; shift;;
--src=*) srcdir=`IFS="="; set -- $1; echo $2`; shift;;
--with-mksrc=*) mksrc=`IFS="="; set -- $1; echo $2`; shift;;
-s|--src) srcdir=$2; shift 2;;
-m|--mksrc) mksrc=$2; shift 2;;
-o|--objdir) objdir=$2; shift 2;;
-q) quiet=; shift;;
-c) source_rc $2; shift 2;;
--*) CONFIGURE_ARGS="$CONFIGURE_ARGS $1"; shift;;
*=*) eval "$1"; export `IFS="="; set -- $1; echo $1`; shift;;
*) break;;
esac
done
AddConfigure() {
case " $CONFIGURE_ARGS " in
*" $1"*) ;;
*) CONFIGURE_ARGS="$CONFIGURE_ARGS $1$2";;
esac
}
GetDir() {
match=$1
shift
for dir in $*
do
[ -d $dir ] || continue
case "/$dir/" in
*$match*) ;;
*) continue;;
esac
case "$dir/" in
*./*) cd $dir && /bin/pwd;;
/*) echo $dir;;
*) cd $dir && /bin/pwd;;
esac
break
done
}
srcdir=`GetDir /bmake $srcdir $2 $Mydir ./bmake* $Mydir/../bmake*`
[ -d ${srcdir:-/dev/null} ] || Usage
case "$mksrc" in
none|-) # we don't want it
mksrc=
;;
*) # guess we want mksrc...
mksrc=`GetDir /mk $mksrc $3 ./mk* $srcdir/mk* $srcdir/../mk*`
[ -d ${mksrc:-/dev/null} ] || Usage "Use '-m none' to build without mksrc"
;;
esac
# Ok, get to work...
objdir=${objdir:-$OS}
[ -d $objdir ] || mkdir -p $objdir
[ -d $objdir ] || mkdir $objdir
cd $objdir || exit 1
AddConfigure --prefix= $prefix
case "$CONFIGURE_ARGS" in
*--with-prefix-sys-path*) ;; # skip
*) AddConfigure --with-default-sys-path= $prefix/share/mk;;
esac
if [ "$mksrc" ]; then
AddConfigure --with-mksrc= $mksrc
# not all cc's support this
export CFLAGS_MF=
fi
$srcdir/configure $CONFIGURE_ARGS || exit 1
${MAKE:-make} -f makefile.boot clean
${MAKE:-make} -f makefile.boot bootstrap || exit 1
# If -q given, we don't want all the install instructions
$quiet exit 0
make_version=`./bmake -m ./mk -m /usr/share/mk -f ./Makefile -V MAKE_VERSION | ( read one two; echo $one )`
install_prefix() {
bindir=$1/bin
mandir=$1/share/man
mkdir=${2:-$1}/share/mk
echo
echo Commands to install into $1/
echo
echo mkdir -p $bindir
echo cp $objdir/bmake $bindir/$make_version
echo rm -f $bindir/bmake
echo ln -s $make_version $bindir/bmake
if [ -s bmake.cat1 ]; then
echo mkdir -p $mandir/man1
echo cp $srcdir/bmake.1 $mandir/man1
else
echo mkdir -p $mandir/cat1
echo cp $srcdir/bmake.cat1 $mandir/cat1/bmake.1
fi
[ "$mksrc" ] && echo $mksrc/install-mk $mkdir
}
case $prefix/ in
$HOME/*) ;;
*) CONFIGS=${CONFIGS:-/configs}
[ -d $CONFIGS ] &&
install_prefix $CONFIGS/$OS/$OSMAJOR.X/$MACHINE_ARCH$prefix
# I like to keep a copy here...
install_prefix $HOME/$HOST_TARGET
;;
esac
install_prefix $prefix
|