Sun Aug 12 08:46:41 2018 UTC ()
On Chrome OS, build nbsed too.

Both sed and awk in the Chrome OS base are permanently put into sandbox
mode, which makes them unsuitable for pkgsrc use. We were already building
nbawk; also add nbsed.


(bsiegert)
diff -r1.248 -r1.249 pkgsrc/bootstrap/bootstrap

cvs diff -r1.248 -r1.249 pkgsrc/bootstrap/bootstrap (switch to unified diff)

--- pkgsrc/bootstrap/bootstrap 2018/03/07 07:34:07 1.248
+++ pkgsrc/bootstrap/bootstrap 2018/08/12 08:46:41 1.249
@@ -1,1396 +1,1397 @@ @@ -1,1396 +1,1397 @@
1#! /bin/sh 1#! /bin/sh
2 2
3# $NetBSD: bootstrap,v 1.248 2018/03/07 07:34:07 rillig Exp $ 3# $NetBSD: bootstrap,v 1.249 2018/08/12 08:46:41 bsiegert Exp $
4# 4#
5# Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org> 5# Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org>
6# All rights reserved. 6# All rights reserved.
7# 7#
8# Redistribution and use in source and binary forms, with or without 8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions 9# modification, are permitted provided that the following conditions
10# are met: 10# are met:
11# 1. Redistributions of source code must retain the above copyright 11# 1. Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer. 12# notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright 13# 2. Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the 14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution. 15# documentation and/or other materials provided with the distribution.
16# 16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27# 27#
28#set -x 28#set -x
29 29
30# the following environment variables are honored: 30# the following environment variables are honored:
31# compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS, LIBS 31# compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS, LIBS
32# tools: CP, GREP, ID, MKDIR, SH, TEST, TOUCH, XARGS 32# tools: CP, GREP, ID, MKDIR, SH, TEST, TOUCH, XARGS
33 33
34 34
35BOOTSTRAP_VERSION=20060721 35BOOTSTRAP_VERSION=20060721
36 36
37# Don't let the bootstrap program get confused by a pre-existing mk.conf 37# Don't let the bootstrap program get confused by a pre-existing mk.conf
38# file. 38# file.
39MAKECONF=/dev/null 39MAKECONF=/dev/null
40export MAKECONF 40export MAKECONF
41 41
42# No vulnerability checks since there might be an incompatible checker installed 42# No vulnerability checks since there might be an incompatible checker installed
43NO_PKGTOOLS_REQD_CHECK=yes 43NO_PKGTOOLS_REQD_CHECK=yes
44export NO_PKGTOOLS_REQD_CHECK 44export NO_PKGTOOLS_REQD_CHECK
45 45
46unprivileged=no 46unprivileged=no
47 47
48preserve_path=no 48preserve_path=no
49 49
50# where the building takes place 50# where the building takes place
51bootstrapdir=`dirname "$0"` 51bootstrapdir=`dirname "$0"`
52bootstrapdir=`cd "${bootstrapdir}" && pwd` 52bootstrapdir=`cd "${bootstrapdir}" && pwd`
53pkgsrcdir=`dirname "${bootstrapdir}"` 53pkgsrcdir=`dirname "${bootstrapdir}"`
54wrkdir="`pwd`/work" 54wrkdir="`pwd`/work"
55 55
56usage="Usage: $0 "' 56usage="Usage: $0 "'
57 [ --abi [32|64] ] 57 [ --abi [32|64] ]
58 [ --binary-kit <tarball> ] 58 [ --binary-kit <tarball> ]
59 [ --binary-macpkg <pkg> ] 59 [ --binary-macpkg <pkg> ]
60 [ --compiler <compiler> ] 60 [ --compiler <compiler> ]
61 [ --cwrappers <auto|yes|no> ] 61 [ --cwrappers <auto|yes|no> ]
62 [ --full ] 62 [ --full ]
63 [ --gzip-binary-kit <tarball> ] 63 [ --gzip-binary-kit <tarball> ]
64 [ --help ] 64 [ --help ]
65 [ --make-jobs <num> ] 65 [ --make-jobs <num> ]
66 [ --mk-fragment <mk.conf> ] 66 [ --mk-fragment <mk.conf> ]
67 [ --pkgdbdir <pkgdbdir> ] 67 [ --pkgdbdir <pkgdbdir> ]
68 [ --pkginfodir <pkginfodir> ] 68 [ --pkginfodir <pkginfodir> ]
69 [ --pkgmandir <pkgmandir> ] 69 [ --pkgmandir <pkgmandir> ]
70 [ --prefer-pkgsrc <list|yes|no> ] 70 [ --prefer-pkgsrc <list|yes|no> ]
71 [ --prefix <prefix> ] 71 [ --prefix <prefix> ]
72 [ --preserve-path ] 72 [ --preserve-path ]
73 [ --quiet ] 73 [ --quiet ]
74 [ --sysconfdir <sysconfdir> ] 74 [ --sysconfdir <sysconfdir> ]
75 [ --unprivileged | --ignore-user-check ] 75 [ --unprivileged | --ignore-user-check ]
76 [ --varbase <varbase> ] 76 [ --varbase <varbase> ]
77 [ --workdir <workdir> ] 77 [ --workdir <workdir> ]
78' 78'
79 79
80# strip / for BSD/OS, strip - for HP-UX 80# strip / for BSD/OS, strip - for HP-UX
81opsys=`uname -s | tr -d /-` 81opsys=`uname -s | tr -d /-`
82 82
83mkbinarykit_macpkg() 83mkbinarykit_macpkg()
84{ 84{
85 local macdestdir 85 local macdestdir
86 macdestdir=${wrkdir}/macpkg-destdir 86 macdestdir=${wrkdir}/macpkg-destdir
87 rm -rf ${macdestdir} || die "cleanup destdir" 87 rm -rf ${macdestdir} || die "cleanup destdir"
88 88
89 mkdir -p ${macdestdir}${prefix} || die "mkdir destprefix" 89 mkdir -p ${macdestdir}${prefix} || die "mkdir destprefix"
90 rmdir ${macdestdir}${prefix} || die "rmdir destprefix" 90 rmdir ${macdestdir}${prefix} || die "rmdir destprefix"
91 cp -Rp ${prefix} ${macdestdir}${prefix} || die "copy prefix" 91 cp -Rp ${prefix} ${macdestdir}${prefix} || die "copy prefix"
92 92
93 if [ ! -d ${macdestdir}${pkgdbdir} ]; then 93 if [ ! -d ${macdestdir}${pkgdbdir} ]; then
94 mkdir -p ${macdestdir}${pkgdbdir} || die "mkdir destdbdir" 94 mkdir -p ${macdestdir}${pkgdbdir} || die "mkdir destdbdir"
95 rmdir ${macdestdir}${pkgdbdir} || die "rmdir destdbdir" 95 rmdir ${macdestdir}${pkgdbdir} || die "rmdir destdbdir"
96 cp -Rp ${pkgdbdir} ${macdestdir}${pkgdbdir} || die "copy dbdir" 96 cp -Rp ${pkgdbdir} ${macdestdir}${pkgdbdir} || die "copy dbdir"
97 fi 97 fi
98 98
99 ${sedprog} -e "s|%WRKDIR%|${wrkdir}|g" \ 99 ${sedprog} -e "s|%WRKDIR%|${wrkdir}|g" \
100 -e "s|%TARGETDIR%|${targetdir}|g" -e "s|%DATE%|${date}|g" \ 100 -e "s|%TARGETDIR%|${targetdir}|g" -e "s|%DATE%|${date}|g" \
101 < macpkg.pmproj.in > ${wrkdir}/macpkg.pmproj 101 < macpkg.pmproj.in > ${wrkdir}/macpkg.pmproj
102 ${packagemaker} -build -proj ${wrkdir}/macpkg.pmproj -p "${binary_macpkg}" 102 ${packagemaker} -build -proj ${wrkdir}/macpkg.pmproj -p "${binary_macpkg}"
103} 103}
104 104
105mkbinarykit_tar() 105mkbinarykit_tar()
106{ 106{
107 # in case tar was built by bootstrap 107 # in case tar was built by bootstrap
108 PATH="$prefix/bin:$PATH"; export PATH 108 PATH="$prefix/bin:$PATH"; export PATH
109 cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir .$etc_mk_conf 109 cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir .$etc_mk_conf
110} 110}
111 111
112mkbinarykit_tgz() 112mkbinarykit_tgz()
113{ 113{
114 # in case tar was built by bootstrap 114 # in case tar was built by bootstrap
115 PATH="$prefix/bin:$PATH"; export PATH 115 PATH="$prefix/bin:$PATH"; export PATH
116 cd / && tar -hcf - .$prefix .$pkgdbdir .$etc_mk_conf | gzip > "${binary_gzip_kit}" 116 cd / && tar -hcf - .$prefix .$pkgdbdir .$etc_mk_conf | gzip > "${binary_gzip_kit}"
117} 117}
118 118
119die() 119die()
120{ 120{
121 echo >&2 "$@" 121 echo >&2 "$@"
122 exit 1 122 exit 1
123} 123}
124 124
125echo_msg() 125echo_msg()
126{ 126{
127 echo "===> $@" 127 echo "===> $@"
128} 128}
129 129
130# see if we're using gcc. If so, set $compiler_is_gnu to '1'. 130# see if we're using gcc. If so, set $compiler_is_gnu to '1'.
131get_compiler() 131get_compiler()
132{ 132{
133 testcc="${CC}" 133 testcc="${CC}"
134 # normally, we'd just use 'cc', but certain configure tools look 134 # normally, we'd just use 'cc', but certain configure tools look
135 # for gcc specifically, so we have to see if that comes first 135 # for gcc specifically, so we have to see if that comes first
136 if [ -z "${testcc}" ]; then 136 if [ -z "${testcc}" ]; then
137 save_IFS="${IFS}" 137 save_IFS="${IFS}"
138 IFS=':' 138 IFS=':'
139 for dir in ${PATH}; do 139 for dir in ${PATH}; do
140 test -z "$dir" && dir=. 140 test -z "$dir" && dir=.
141 if [ -x "$dir/gcc" ]; then 141 if [ -x "$dir/gcc" ]; then
142 testcc="$dir/gcc" 142 testcc="$dir/gcc"
143 break 143 break
144 fi 144 fi
145 done 145 done
146 IFS="${save_IFS}" 146 IFS="${save_IFS}"
147 fi 147 fi
148 148
149 # Clang compiler pretends to be GCC, so we have to check that 149 # Clang compiler pretends to be GCC, so we have to check that
150 cat >${wrkdir}/$$.c <<EOF 150 cat >${wrkdir}/$$.c <<EOF
151#ifdef __clang__ 151#ifdef __clang__
152indeed 152indeed
153#endif 153#endif
154EOF 154EOF
155 compiler_is_clang=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed` 155 compiler_is_clang=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
156 rm -f ${wrkdir}/$$.c 156 rm -f ${wrkdir}/$$.c
157 157
158 cat >${wrkdir}/$$.c <<EOF 158 cat >${wrkdir}/$$.c <<EOF
159#ifdef __GNUC__ 159#ifdef __GNUC__
160#ifndef __clang__ 160#ifndef __clang__
161indeed 161indeed
162#endif 162#endif
163#endif 163#endif
164EOF 164EOF
165 compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed` 165 compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
166 rm -f ${wrkdir}/$$.c 166 rm -f ${wrkdir}/$$.c
167 167
168} 168}
169get_abi() 169get_abi()
170{ 170{
171 abi_opsys=$@ 171 abi_opsys=$@
172 172
173 if [ -n "$abi" ]; then 173 if [ -n "$abi" ]; then
174 case "$abi_opsys" in 174 case "$abi_opsys" in
175 IRIX) 175 IRIX)
176 die "ERROR: $abi_opsys has special ABI handling, --abi not supported (yet)." 176 die "ERROR: $abi_opsys has special ABI handling, --abi not supported (yet)."
177 ;; 177 ;;
178 esac 178 esac
179 fi 179 fi
180 180
181 case "$abi_opsys" in 181 case "$abi_opsys" in
182 IRIX) 182 IRIX)
183 if [ `uname -r` -ge 6 ]; then 183 if [ `uname -r` -ge 6 ]; then
184 abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults` 184 abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults`
185 isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults` 185 isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults`
186 case "$abi" in 186 case "$abi" in
187 o32) 187 o32)
188 imakeopts="-DBuildO32 -DSgiISAo32=$isa" 188 imakeopts="-DBuildO32 -DSgiISAo32=$isa"
189 abi="" 189 abi=""
190 ;; 190 ;;
191 n32) imakeopts="-DBuildN32 -DSgiISA32=$isa" 191 n32) imakeopts="-DBuildN32 -DSgiISA32=$isa"
192 abi="32" 192 abi="32"
193 ;; 193 ;;
194 64 | n64) 194 64 | n64)
195 imakeopts="-DBuild64bit -DSgiISA64=$isa" 195 imakeopts="-DBuild64bit -DSgiISA64=$isa"
196 abi="64" 196 abi="64"
197 ;; 197 ;;
198 esac 198 esac
199 else # IRIX before 6 199 else # IRIX before 6
200 abi=32 200 abi=32
201 fi 201 fi
202 ;; 202 ;;
203 esac 203 esac
204} 204}
205 205
206get_machine_arch_aix() 206get_machine_arch_aix()
207{ 207{
208 _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 208 _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
209 if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then 209 if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then
210 echo rs6000 210 echo rs6000
211 else 211 else
212 echo powerpc 212 echo powerpc
213 fi 213 fi
214} 214}
215 215
216get_machine_arch_darwin() 216get_machine_arch_darwin()
217{ 217{
218 case `uname -p` in 218 case `uname -p` in
219 i386) 219 i386)
220 # Returns "i386" or "x86_64" depending on CPU 220 # Returns "i386" or "x86_64" depending on CPU
221 echo `uname -m` 221 echo `uname -m`
222 ;; 222 ;;
223 powerpc) 223 powerpc)
224 # sysctl mib exists on 64-bit hardware 224 # sysctl mib exists on 64-bit hardware
225 if [ -n "`sysctl -n hw.optional.64bitops 2>/dev/null`" ]; then 225 if [ -n "`sysctl -n hw.optional.64bitops 2>/dev/null`" ]; then
226 echo "powerpc64" 226 echo "powerpc64"
227 else 227 else
228 echo "powerpc" 228 echo "powerpc"
229 fi 229 fi
230 ;; 230 ;;
231 esac 231 esac
232} 232}
233 233
234check_prog() 234check_prog()
235{ 235{
236 _var="$1"; _name="$2" 236 _var="$1"; _name="$2"
237 237
238 eval _tmp=\"\$$_var\" 238 eval _tmp=\"\$$_var\"
239 if [ "x$_tmp" != "x" ]; then 239 if [ "x$_tmp" != "x" ]; then
240 # Variable is already set (by the user, for example) 240 # Variable is already set (by the user, for example)
241 return 0 241 return 0
242 fi 242 fi
243 243
244 for _d in `echo $PATH | tr ':' ' '`; do 244 for _d in `echo $PATH | tr ':' ' '`; do
245 if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then 245 if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then
246 # Program found 246 # Program found
247 eval $_var=\""$_d/$_name"\" 247 eval $_var=\""$_d/$_name"\"
248 return 1 248 return 1
249 fi 249 fi
250 done 250 done
251 251
252 die "$_name not found in path." 252 die "$_name not found in path."
253} 253}
254 254
255opsys_finish() 255opsys_finish()
256{ 256{
257 case "$opsys" in 257 case "$opsys" in
258 IRIX) 258 IRIX)
259 if [ -n "$imakeopts" ]; then 259 if [ -n "$imakeopts" ]; then
260 echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF} 260 echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF}
261 fi 261 fi
262 if [ `uname -r` -lt 6 ]; then 262 if [ `uname -r` -lt 6 ]; then
263 echo_msg "Installing fake ldd script" 263 echo_msg "Installing fake ldd script"
264 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin" 264 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin"
265 need_extras=yes 265 need_extras=yes
266 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF} 266 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
267 fi 267 fi
268 ;; 268 ;;
269 Haiku) 269 Haiku)
270 need_extras=yes 270 need_extras=yes
271 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF} 271 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
272 ;; 272 ;;
273 esac 273 esac
274} 274}
275 275
276is_root() 276is_root()
277{ 277{
278 if [ `uname -s` = "IRIX" ]; then 278 if [ `uname -s` = "IRIX" ]; then
279 if [ `uname -r` -lt 6 -a -z "$ID" ]; then 279 if [ `uname -r` -lt 6 -a -z "$ID" ]; then
280 # older version of IRIX have an id command with limited features 280 # older version of IRIX have an id command with limited features
281 if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then 281 if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
282 return 1 282 return 1
283 fi 283 fi
284 return 0 284 return 0
285 fi 285 fi
286 fi 286 fi
287 if [ `$idprog -u` != 0 ]; then 287 if [ `$idprog -u` != 0 ]; then
288 return 1 288 return 1
289 fi 289 fi
290 return 0 290 return 0
291} 291}
292 292
293# run a command, abort if it fails 293# run a command, abort if it fails
294run_cmd() 294run_cmd()
295{ 295{
296 echo_msg "running: $@" 296 echo_msg "running: $@"
297 eval "$@" 297 eval "$@"
298 ret=$? 298 ret=$?
299 if [ $ret -ne 0 ]; then 299 if [ $ret -ne 0 ]; then
300 echo_msg "exited with status $ret" 300 echo_msg "exited with status $ret"
301 die "aborted." 301 die "aborted."
302 fi 302 fi
303} 303}
304 304
305# Some versions of mkdir (notably SunOS) bail out too easily, so use the 305# Some versions of mkdir (notably SunOS) bail out too easily, so use the
306# install-sh wrapper instead. 306# install-sh wrapper instead.
307mkdir_p() 307mkdir_p()
308{ 308{
309 for dir in $@; do 309 for dir in $@; do
310 run_cmd "$install_sh -d -o $user -g $group $dir" 310 run_cmd "$install_sh -d -o $user -g $group $dir"
311 done 311 done
312} 312}
313 313
314mkdir_p_early() 314mkdir_p_early()
315{ 315{
316 [ -d "$1" ] && return 0 316 [ -d "$1" ] && return 0
317 mkdir -p "$1" 2> /dev/null && return 0 317 mkdir -p "$1" 2> /dev/null && return 0
318 parent=`dirname "$1"` 318 parent=`dirname "$1"`
319 mkdir_p_early "$parent" 319 mkdir_p_early "$parent"
320 if [ ! -d "$1" ] && mkdir "$1"; then 320 if [ ! -d "$1" ] && mkdir "$1"; then
321 echo_msg "mkdir $1 exited with status $?" 321 echo_msg "mkdir $1 exited with status $?"
322 die "aborted." 322 die "aborted."
323 fi 323 fi
324 return 0 324 return 0
325} 325}
326 326
327copy_src() 327copy_src()
328{ 328{
329 _src="$1"; _dst="$2" 329 _src="$1"; _dst="$2"
330 if [ ! -d $wrkdir/$_dst ]; then 330 if [ ! -d $wrkdir/$_dst ]; then
331 mkdir_p $wrkdir/$_dst 331 mkdir_p $wrkdir/$_dst
332 fi 332 fi
333 $cpprog -r $_src/* $wrkdir/$_dst 333 $cpprog -r $_src/* $wrkdir/$_dst
334 if [ -f $wrkdir/$_dst/config.guess ]; then 334 if [ -f $wrkdir/$_dst/config.guess ]; then
335 $cpprog $pkgsrcdir/mk/gnu-config/config.guess $wrkdir/$_dst/ 335 $cpprog $pkgsrcdir/mk/gnu-config/config.guess $wrkdir/$_dst/
336 fi 336 fi
337 if [ -f $wrkdir/$_dst/config.sub ]; then 337 if [ -f $wrkdir/$_dst/config.sub ]; then
338 $cpprog $pkgsrcdir/mk/gnu-config/config.sub $wrkdir/$_dst/ 338 $cpprog $pkgsrcdir/mk/gnu-config/config.sub $wrkdir/$_dst/
339 fi 339 fi
340} 340}
341 341
342get_optarg() 342get_optarg()
343{ 343{
344 expr "x$1" : "x[^=]*=\\(.*\\)" 344 expr "x$1" : "x[^=]*=\\(.*\\)"
345} 345}
346 346
347checkarg_sane_absolute_path() { 347checkarg_sane_absolute_path() {
348 case "$1" in 348 case "$1" in
349 "") ;; # the default value will be used. 349 "") ;; # the default value will be used.
350 *[!-A-Za-z0-9_./]*) 350 *[!-A-Za-z0-9_./]*)
351 die "ERROR: Invalid characters in path $1 (from $2)." ;; 351 die "ERROR: Invalid characters in path $1 (from $2)." ;;
352 */) die "ERROR: The argument to $2 must not end in /." ;; 352 */) die "ERROR: The argument to $2 must not end in /." ;;
353 /*) ;; 353 /*) ;;
354 *) die "ERROR: The argument to $2 must be an absolute path." ;; 354 *) die "ERROR: The argument to $2 must be an absolute path." ;;
355 esac 355 esac
356} 356}
357 357
358checkarg_sane_relative_path() { 358checkarg_sane_relative_path() {
359 case "$1" in 359 case "$1" in
360 "") ;; # the default value will be used. 360 "") ;; # the default value will be used.
361 *[!-A-Za-z0-9_./]*) 361 *[!-A-Za-z0-9_./]*)
362 die "ERROR: Invalid characters in path $1 (from $2)." ;; 362 die "ERROR: Invalid characters in path $1 (from $2)." ;;
363 /*) die "ERROR: The argument to $2 must be a relative path." ;; 363 /*) die "ERROR: The argument to $2 must be a relative path." ;;
364 *) ;; 364 *) ;;
365 esac 365 esac
366} 366}
367 367
368bootstrap_sh=${SH-/bin/sh} 368bootstrap_sh=${SH-/bin/sh}
369bootstrap_sh_set=${SH+set} 369bootstrap_sh_set=${SH+set}
370 370
371case "$bootstrap_sh" in 371case "$bootstrap_sh" in
372/*) 372/*)
373 ;; 373 ;;
374*) 374*)
375 die "ERROR: The variable SH must contain an absolute path" 375 die "ERROR: The variable SH must contain an absolute path"
376 ;; 376 ;;
377esac 377esac
378 378
379# On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash, 379# On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash,
380# whose echo(1) is not BSD-compatible. 380# whose echo(1) is not BSD-compatible.
381# On all Debian GNU/kFreeBSD 7.0, /bin/sh is a symlink to /bin/dash, and 381# On all Debian GNU/kFreeBSD 7.0, /bin/sh is a symlink to /bin/dash, and
382# use /bin/bash. bootstrap forces /bin/bash is used. 382# use /bin/bash. bootstrap forces /bin/bash is used.
383dash_echo_test=`$bootstrap_sh -c 'echo "\\100"'` 383dash_echo_test=`$bootstrap_sh -c 'echo "\\100"'`
384if [ "$opsys" != "GNUkFreeBSD" ] && [ "$dash_echo_test" = "@" ]; then 384if [ "$opsys" != "GNUkFreeBSD" ] && [ "$dash_echo_test" = "@" ]; then
385 { echo "ERROR: Your shell's echo command is not BSD-compatible." 385 { echo "ERROR: Your shell's echo command is not BSD-compatible."
386 echo "ERROR: Please select another shell by setting the environment" 386 echo "ERROR: Please select another shell by setting the environment"
387 echo "ERROR: variable SH." 387 echo "ERROR: variable SH."
388 } 1>&2 388 } 1>&2
389 exit 1; 389 exit 1;
390fi 390fi
391 391
392if [ -n "$PKG_PATH" ]; then 392if [ -n "$PKG_PATH" ]; then
393 die "ERROR: Please unset PKG_PATH before running bootstrap." 393 die "ERROR: Please unset PKG_PATH before running bootstrap."
394fi 394fi
395 395
396build_start=`date` 396build_start=`date`
397echo_msg "bootstrap command: $0 $@" 397echo_msg "bootstrap command: $0 $@"
398echo_msg "bootstrap started: $build_start" 398echo_msg "bootstrap started: $build_start"
399 399
400# ensure system locations are empty; we will set them later when we know 400# ensure system locations are empty; we will set them later when we know
401# whether they will be system wide or user specific 401# whether they will be system wide or user specific
402prefix= 402prefix=
403pkgdbdir= 403pkgdbdir=
404pkginfodir= 404pkginfodir=
405pkgmandir= 405pkgmandir=
406sysconfdir= 406sysconfdir=
407varbase= 407varbase=
408 408
409compiler="" 409compiler=""
410cwrappers=auto 410cwrappers=auto
411full=no 411full=no
412make_jobs=1 412make_jobs=1
413mk_fragment= 413mk_fragment=
414quiet=no 414quiet=no
415 415
416while [ $# -gt 0 ]; do 416while [ $# -gt 0 ]; do
417 case $1 in 417 case $1 in
418 --workdir=*) wrkdir=`get_optarg "$1"` ;; 418 --workdir=*) wrkdir=`get_optarg "$1"` ;;
419 --workdir) wrkdir="$2"; shift ;; 419 --workdir) wrkdir="$2"; shift ;;
420 --prefix=*) prefix=`get_optarg "$1"` ;; 420 --prefix=*) prefix=`get_optarg "$1"` ;;
421 --prefix) prefix="$2"; shift ;; 421 --prefix) prefix="$2"; shift ;;
422 --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;; 422 --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;;
423 --pkgdbdir) pkgdbdir="$2"; shift ;; 423 --pkgdbdir) pkgdbdir="$2"; shift ;;
424 --pkginfodir=*) pkginfodir=`get_optarg "$1"` ;; 424 --pkginfodir=*) pkginfodir=`get_optarg "$1"` ;;
425 --pkginfodir) pkginfodir="$2"; shift ;; 425 --pkginfodir) pkginfodir="$2"; shift ;;
426 --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;; 426 --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;;
427 --pkgmandir) pkgmandir="$2"; shift ;; 427 --pkgmandir) pkgmandir="$2"; shift ;;
428 --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;; 428 --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
429 --sysconfdir) sysconfdir="$2"; shift ;; 429 --sysconfdir) sysconfdir="$2"; shift ;;
430 --varbase=*) varbase=`get_optarg "$1"` ;; 430 --varbase=*) varbase=`get_optarg "$1"` ;;
431 --varbase) varbase="$2"; shift ;; 431 --varbase) varbase="$2"; shift ;;
432 --compiler=*) compiler=`get_optarg "$1"` ;; 432 --compiler=*) compiler=`get_optarg "$1"` ;;
433 --compiler) compiler="$2"; shift ;; 433 --compiler) compiler="$2"; shift ;;
434 --abi=*) abi=`get_optarg "$1"` ;; 434 --abi=*) abi=`get_optarg "$1"` ;;
435 --abi) abi="$2"; shift ;; 435 --abi) abi="$2"; shift ;;
436 --cwrappers=*) cwrappers=`get_optarg "$1"` ;; 436 --cwrappers=*) cwrappers=`get_optarg "$1"` ;;
437 --cwrappers) cwrappers="$2"; shift ;; 437 --cwrappers) cwrappers="$2"; shift ;;
438 --unprivileged | --ignore-user-check) unprivileged=yes ;; 438 --unprivileged | --ignore-user-check) unprivileged=yes ;;
439 --prefer-pkgsrc=*) 439 --prefer-pkgsrc=*)
440 prefer_pkgsrc=`get_optarg "$1"` ;; 440 prefer_pkgsrc=`get_optarg "$1"` ;;
441 --prefer-pkgsrc) 441 --prefer-pkgsrc)
442 prefer_pkgsrc="$2"; shift ;; 442 prefer_pkgsrc="$2"; shift ;;
443 --preserve-path) preserve_path=yes ;; 443 --preserve-path) preserve_path=yes ;;
444 --mk-fragment=*) 444 --mk-fragment=*)
445 mk_fragment=`get_optarg "$1"` ;; 445 mk_fragment=`get_optarg "$1"` ;;
446 --mk-fragment) 446 --mk-fragment)
447 mk_fragment="$2"; shift ;; 447 mk_fragment="$2"; shift ;;
448 --binary-kit=*) 448 --binary-kit=*)
449 binary_kit=`get_optarg "$1"` ;; 449 binary_kit=`get_optarg "$1"` ;;
450 --binary-kit) 450 --binary-kit)
451 binary_kit="$2"; shift ;; 451 binary_kit="$2"; shift ;;
452 --gzip-binary-kit=*) 452 --gzip-binary-kit=*)
453 binary_gzip_kit=`get_optarg "$1"` ;; 453 binary_gzip_kit=`get_optarg "$1"` ;;
454 --gzip-binary-kit) 454 --gzip-binary-kit)
455 binary_gzip_kit="$2"; shift ;; 455 binary_gzip_kit="$2"; shift ;;
456 --binary-macpkg=*) 456 --binary-macpkg=*)
457 binary_macpkg=`get_optarg "$1"` ;; 457 binary_macpkg=`get_optarg "$1"` ;;
458 --binary-macpkg) 458 --binary-macpkg)
459 binary_macpkg="$2"; shift ;; 459 binary_macpkg="$2"; shift ;;
460 --make-jobs=*) make_jobs=`get_optarg "$1"` ;; 460 --make-jobs=*) make_jobs=`get_optarg "$1"` ;;
461 --make-jobs) make_jobs="$2"; shift ;; 461 --make-jobs) make_jobs="$2"; shift ;;
462 --full) full=yes ;; 462 --full) full=yes ;;
463 --quiet) quiet=yes ;; 463 --quiet) quiet=yes ;;
464 --help) echo "$usage"; exit ;; 464 --help) echo "$usage"; exit ;;
465 -h) echo "$usage"; exit ;; 465 -h) echo "$usage"; exit ;;
466 --*) echo "$usage"; exit 1 ;; 466 --*) echo "$usage"; exit 1 ;;
467 esac 467 esac
468 shift 468 shift
469done 469done
470 470
471checkarg_sane_absolute_path "$wrkdir" "--workdir" 471checkarg_sane_absolute_path "$wrkdir" "--workdir"
472checkarg_sane_absolute_path "$prefix" "--prefix" 472checkarg_sane_absolute_path "$prefix" "--prefix"
473checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir" 473checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir"
474checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir" 474checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir"
475checkarg_sane_absolute_path "$varbase" "--varbase" 475checkarg_sane_absolute_path "$varbase" "--varbase"
476checkarg_sane_relative_path "$pkginfodir" "--pkginfodir" 476checkarg_sane_relative_path "$pkginfodir" "--pkginfodir"
477checkarg_sane_relative_path "$pkgmandir" "--pkgmandir" 477checkarg_sane_relative_path "$pkgmandir" "--pkgmandir"
478 478
479# set defaults for system locations if not already set by the user 479# set defaults for system locations if not already set by the user
480wrkobjdir=${wrkdir}/pkgsrc 480wrkobjdir=${wrkdir}/pkgsrc
481if [ "$unprivileged" = "yes" ]; then 481if [ "$unprivileged" = "yes" ]; then
482 [ -z "$prefix" ] && prefix=${HOME}/pkg 482 [ -z "$prefix" ] && prefix=${HOME}/pkg
483elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then 483elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then
484 prefix=/usr/pkg 484 prefix=/usr/pkg
485 [ -z "$varbase" ] && varbase=/var 485 [ -z "$varbase" ] && varbase=/var
486fi 486fi
487 487
488[ -z "$varbase" ] && varbase=${prefix}/var 488[ -z "$varbase" ] && varbase=${prefix}/var
489[ -z "$pkgdbdir" ] && pkgdbdir=${prefix}/pkgdb 489[ -z "$pkgdbdir" ] && pkgdbdir=${prefix}/pkgdb
490 490
491if [ "$prefix" = "/usr" ]; then 491if [ "$prefix" = "/usr" ]; then
492 [ -z "$pkginfodir" ] && pkginfodir=share/info 492 [ -z "$pkginfodir" ] && pkginfodir=share/info
493 [ -z "$pkgmandir" ] && pkgmandir=share/man 493 [ -z "$pkgmandir" ] && pkgmandir=share/man
494else 494else
495 [ -z "$pkginfodir" ] && pkginfodir=info 495 [ -z "$pkginfodir" ] && pkginfodir=info
496 [ -z "$pkgmandir" ] && pkgmandir=man 496 [ -z "$pkgmandir" ] && pkgmandir=man
497fi 497fi
498infodir=${prefix}/${pkginfodir} 498infodir=${prefix}/${pkginfodir}
499mandir=${prefix}/${pkgmandir} 499mandir=${prefix}/${pkgmandir}
500[ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc 500[ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc
501 501
502if [ "x$preserve_path" != "xyes" ]; then 502if [ "x$preserve_path" != "xyes" ]; then
503 PATH="$PATH:/sbin:/usr/sbin" 503 PATH="$PATH:/sbin:/usr/sbin"
504fi 504fi
505 505
506overpath="" 506overpath=""
507root_user=root 507root_user=root
508bmakexargs= 508bmakexargs=
509need_extras=no 509need_extras=no
510use_bsdinstall= 510use_bsdinstall=
511case "$opsys" in 511case "$opsys" in
512AIX) 512AIX)
513 root_group=system 513 root_group=system
514 need_bsd_install=yes 514 need_bsd_install=yes
515 need_awk=yes 515 need_awk=yes
516 need_sed=yes 516 need_sed=yes
517 need_ksh=yes 517 need_ksh=yes
518 need_fixed_strip=yes 518 need_fixed_strip=yes
519 set_opsys=no 519 set_opsys=no
520 machine_arch=`get_machine_arch_aix` 520 machine_arch=`get_machine_arch_aix`
521 ;; 521 ;;
522Bitrig) 522Bitrig)
523 root_group=wheel 523 root_group=wheel
524 need_bsd_install=no 524 need_bsd_install=no
525 need_awk=no 525 need_awk=no
526 need_sed=no 526 need_sed=no
527 set_opsys=no 527 set_opsys=no
528 machine_arch=`arch -s` 528 machine_arch=`arch -s`
529 check_compiler=yes 529 check_compiler=yes
530 ;; 530 ;;
531CYGWIN_*) 531CYGWIN_*)
532 is_root () { 532 is_root () {
533 if id -nG | grep -q 'Administrators'; then 533 if id -nG | grep -q 'Administrators'; then
534 return 0 534 return 0
535 fi 535 fi
536 return 1 536 return 1
537 } 537 }
538 root_user=Administrators 538 root_user=Administrators
539 root_group=Administrators 539 root_group=Administrators
540 need_bsd_install=no 540 need_bsd_install=no
541 opsys=`uname -o` 541 opsys=`uname -o`
542 need_awk=no 542 need_awk=no
543 need_sed=no 543 need_sed=no
544 need_xargs=no 544 need_xargs=no
545 machine_arch=`uname -m` 545 machine_arch=`uname -m`
546 # only used for unprivileged builds. 546 # only used for unprivileged builds.
547 whoamiprog='id -u' 547 whoamiprog='id -u'
548 groupsprog='id -g' 548 groupsprog='id -g'
549 ;; 549 ;;
550 550
551Darwin) 551Darwin)
552 root_group=wheel 552 root_group=wheel
553 need_bsd_install=no 553 need_bsd_install=no
554 need_awk=no 554 need_awk=no
555 need_sed=no 555 need_sed=no
556 set_opsys=no 556 set_opsys=no
557 machine_arch=`get_machine_arch_darwin` 557 machine_arch=`get_machine_arch_darwin`
558 CC=${CC:-"cc -isystem /usr/include"}; export CC 558 CC=${CC:-"cc -isystem /usr/include"}; export CC
559 check_compiler=yes 559 check_compiler=yes
560 osrev=`uname -r` 560 osrev=`uname -r`
561 macosx_version=`echo $osrev | awk -F . '{ print "10."$1-4; }'` 561 macosx_version=`echo $osrev | awk -F . '{ print "10."$1-4; }'`
562 case "$macosx_version" in 562 case "$macosx_version" in
563 10.[7-9]) 563 10.[7-9])
564 packagemaker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker 564 packagemaker=/Applications/PackageMaker.app/Contents/MacOS/PackageMaker
565 ;; 565 ;;
566 10.[0-4]) 566 10.[0-4])
567 packagemaker=/Developer/Tools/packagemaker 567 packagemaker=/Developer/Tools/packagemaker
568 ;; 568 ;;
569 *) 569 *)
570 packagemaker=/Developer/usr/bin/packagemaker 570 packagemaker=/Developer/usr/bin/packagemaker
571 ;; 571 ;;
572 esac 572 esac
573 case "$macosx_version" in 573 case "$macosx_version" in
574 10.[8-9]|10.1[0123]) 574 10.[8-9]|10.1[0123])
575 need_awk=yes 575 need_awk=yes
576 need_sed=yes 576 need_sed=yes
577 ;; 577 ;;
578 esac 578 esac
579 unset osrev macosx_version 579 unset osrev macosx_version
580 ;; 580 ;;
581DragonFly) 581DragonFly)
582 root_group=wheel 582 root_group=wheel
583 need_bsd_install=no 583 need_bsd_install=no
584 need_awk=no 584 need_awk=no
585 need_sed=no 585 need_sed=no
586 set_opsys=no 586 set_opsys=no
587 check_prog tarprog tar 587 check_prog tarprog tar
588 machine_arch=`uname -p` 588 machine_arch=`uname -p`
589 ;; 589 ;;
590FreeBSD) 590FreeBSD)
591 root_group=wheel 591 root_group=wheel
592 need_bsd_install=no 592 need_bsd_install=no
593 need_awk=no 593 need_awk=no
594 need_sed=no 594 need_sed=no
595 set_opsys=no 595 set_opsys=no
596 machine_arch=`uname -p` 596 machine_arch=`uname -p`
597 check_compiler=yes 597 check_compiler=yes
598 ;; 598 ;;
599FreeMiNT) 599FreeMiNT)
600 root_group=root 600 root_group=root
601 need_bsd_install=no 601 need_bsd_install=no
602 need_awk=no 602 need_awk=no
603 need_sed=no 603 need_sed=no
604 set_opsys=no 604 set_opsys=no
605 machine_arch=m68k 605 machine_arch=m68k
606 ;; 606 ;;
607GNUkFreeBSD) 607GNUkFreeBSD)
608 root_group=root 608 root_group=root
609 need_bsd_install=no 609 need_bsd_install=no
610 need_awk=yes 610 need_awk=yes
611 need_sed=no 611 need_sed=no
612 set_opsys=no 612 set_opsys=no
613 machine_arch=`uname -m` 613 machine_arch=`uname -m`
614 ;; 614 ;;
615Haiku) 615Haiku)
616 root_user=`id -un` 616 root_user=`id -un`
617 root_group=root 617 root_group=root
618 need_bsd_install=no 618 need_bsd_install=no
619 need_awk=no 619 need_awk=no
620 need_sed=no 620 need_sed=no
621 set_opsys=no 621 set_opsys=no
622 case `uname -m` in 622 case `uname -m` in
623 BeMac) 623 BeMac)
624 machine_arch=powerpc 624 machine_arch=powerpc
625 ;; 625 ;;
626 BePC) 626 BePC)
627 machine_arch=i386 627 machine_arch=i386
628 ;; 628 ;;
629 *) 629 *)
630 machine_arch=`uname -p` 630 machine_arch=`uname -p`
631 ;; 631 ;;
632 esac 632 esac
633 ;; 633 ;;
634HPUX) 634HPUX)
635 root_group=sys 635 root_group=sys
636 need_bsd_install=yes 636 need_bsd_install=yes
637 need_awk=yes 637 need_awk=yes
638 need_sed=yes 638 need_sed=yes
639 set_opsys=no 639 set_opsys=no
640 machine_arch=`uname -m | sed 's/^9000.*$/hppa/'` 640 machine_arch=`uname -m | sed 's/^9000.*$/hppa/'`
641 ;; 641 ;;
642Interix) 642Interix)
643 is_root () { 643 is_root () {
644 if id -G | grep -q 131616; then 644 if id -G | grep -q 131616; then
645 return 0 645 return 0
646 fi 646 fi
647 return 1 647 return 1
648 } 648 }
649 mkdir_p () { 649 mkdir_p () {
650 mkdir -p "$@" # allows umask to take effect 650 mkdir -p "$@" # allows umask to take effect
651 } 651 }
652 default_install_mode=0775 652 default_install_mode=0775
653 root_user=`id -un` 653 root_user=`id -un`
654 root_group=+Administrators 654 root_group=+Administrators
655 case `uname -r` in 655 case `uname -r` in
656 3.* | 5.*) 656 3.* | 5.*)
657 need_bsd_install=yes 657 need_bsd_install=yes
658 need_awk=yes 658 need_awk=yes
659 need_sed=yes 659 need_sed=yes
660 set_opsys=no 660 set_opsys=no
661 need_xargs=yes 661 need_xargs=yes
662 ;; 662 ;;
663 *) 663 *)
664 need_bsd_install=no 664 need_bsd_install=no
665 need_awk=no 665 need_awk=no
666 need_sed=no 666 need_sed=no
667 set_opsys=no 667 set_opsys=no
668 need_xargs=no 668 need_xargs=no
669 ;; 669 ;;
670 esac 670 esac
671 # only used for unprivileged builds 671 # only used for unprivileged builds
672 groupsprog="id -gn" 672 groupsprog="id -gn"
673 # for bootstrap only; pkgsrc uses CPPFLAGS 673 # for bootstrap only; pkgsrc uses CPPFLAGS
674 CC="gcc -D_ALL_SOURCE"; export CC 674 CC="gcc -D_ALL_SOURCE"; export CC
675 ac_cv_header_poll_h=no; export ac_cv_header_poll_h 675 ac_cv_header_poll_h=no; export ac_cv_header_poll_h
676 ac_cv_func_poll=no; export ac_cv_func_poll 676 ac_cv_func_poll=no; export ac_cv_func_poll
677 ;; 677 ;;
678IRIX*) 678IRIX*)
679 if [ -d "/usr/freeware/bin" ]; then 679 if [ -d "/usr/freeware/bin" ]; then
680 overpath="/usr/freeware/bin:$overpath" 680 overpath="/usr/freeware/bin:$overpath"
681 fi 681 fi
682 if [ -d "/usr/bsd" ]; then 682 if [ -d "/usr/bsd" ]; then
683 overpath="/usr/bsd:$overpath" 683 overpath="/usr/bsd:$overpath"
684 fi 684 fi
685 if [ -d "/usr/bsd/bin" ]; then 685 if [ -d "/usr/bsd/bin" ]; then
686 overpath="/usr/bsd/bin:$overpath" 686 overpath="/usr/bsd/bin:$overpath"
687 fi 687 fi
688 root_group=sys 688 root_group=sys
689 need_bsd_install=yes 689 need_bsd_install=yes
690 get_abi "IRIX" 690 get_abi "IRIX"
691 opsys=IRIX 691 opsys=IRIX
692 need_awk=yes 692 need_awk=yes
693 need_sed=yes 693 need_sed=yes
694 set_opsys=yes 694 set_opsys=yes
695 machine_arch=mipseb 695 machine_arch=mipseb
696 check_compiler=yes 696 check_compiler=yes
697 if [ `uname -r` -lt 6 ]; then 697 if [ `uname -r` -lt 6 ]; then
698# IRIX 5's mkdir bails out with an error when trying to create with the -p 698# IRIX 5's mkdir bails out with an error when trying to create with the -p
699# option an already existing directory 699# option an already existing directory
700 need_mkdir=yes 700 need_mkdir=yes
701 fi 701 fi
702 ;; 702 ;;
703Linux) 703Linux)
704 if [ -f /etc/ssdlinux_version ]; then 704 if [ -f /etc/ssdlinux_version ]; then
705 root_group=wheel 705 root_group=wheel
706 else 706 else
707 root_group=root 707 root_group=root
708 fi 708 fi
709 need_bsd_install=no 709 need_bsd_install=no
710 # Debian/Ubuntu's awk is mawk, and mawk does not understand 710 # Debian/Ubuntu's awk is mawk, and mawk does not understand
711 # some regexp used in pkgsrc/mk. 711 # some regexp used in pkgsrc/mk.
712 if [ -f /etc/debian_version ]; then 712 if [ -f /etc/debian_version ]; then
713 need_awk=yes 713 need_awk=yes
714 elif grep -sq '^CHROMEOS_RELEASE_NAME' /etc/lsb-release; then 714 elif grep -sq '^CHROMEOS_RELEASE_NAME' /etc/lsb-release; then
715 need_awk=yes 715 need_awk=yes
 716 need_sed=yes
716 else 717 else
717 need_awk=no 718 need_awk=no
 719 need_sed=no
718 fi 720 fi
719 need_sed=no 
720 set_opsys=no 721 set_opsys=no
721 machine_arch=`uname -m` 722 machine_arch=`uname -m`
722 # Override machine_arch where required. 723 # Override machine_arch where required.
723 case "$machine_arch" in 724 case "$machine_arch" in
724 i?86) machine_arch=i386 ;; 725 i?86) machine_arch=i386 ;;
725 ppc64le) machine_arch=powerpc64le ;; 726 ppc64le) machine_arch=powerpc64le ;;
726 esac 727 esac
727 ;; 728 ;;
728Minix) 729Minix)
729 root_group=operator 730 root_group=operator
730 need_bsd_install=yes 731 need_bsd_install=yes
731 need_awk=no 732 need_awk=no
732 need_sed=no 733 need_sed=no
733 set_opsys=no 734 set_opsys=no
734 machine_arch=`uname -p` 735 machine_arch=`uname -p`
735 LDFLAGS="-lcompat_minix -lminlib" 736 LDFLAGS="-lcompat_minix -lminlib"
736 ;;  737 ;;
737MirBSD) 738MirBSD)
738 root_group=wheel 739 root_group=wheel
739 need_pax=yes 740 need_pax=yes
740 need_mtree=no 741 need_mtree=no
741 need_bsd_install=no 742 need_bsd_install=no
742 need_awk=no 743 need_awk=no
743 need_sed=no 744 need_sed=no
744 set_opsys=no 745 set_opsys=no
745 check_prog mtreeprog mtree 746 check_prog mtreeprog mtree
746 machine_arch=`arch -s` 747 machine_arch=`arch -s`
747 # there is no /usr/bin/cc, so use mgcc if unset 748 # there is no /usr/bin/cc, so use mgcc if unset
748 test -n "$CC" || { CC=mgcc; export CC; } 749 test -n "$CC" || { CC=mgcc; export CC; }
749 # get some variables from the native make if unset 750 # get some variables from the native make if unset
750 for var in CFLAGS CPPFLAGS LDFLAGS; do 751 for var in CFLAGS CPPFLAGS LDFLAGS; do
751 # check if variable is already set 752 # check if variable is already set
752 eval _tmp=\"\$$var\" 753 eval _tmp=\"\$$var\"
753 [ "x$_tmp" != x ] && continue 754 [ "x$_tmp" != x ] && continue
754 # ask the native make (EXPERIMENTAL = don't add -Werror) 755 # ask the native make (EXPERIMENTAL = don't add -Werror)
755 # the -I${.CURDIR} dance is to prevent junk in CPPFLAGS 756 # the -I${.CURDIR} dance is to prevent junk in CPPFLAGS
756 _tmp=`printf '%s\nall:\n\t@%s %%s %s=${%s:M*:Q:Q}\n%s\n%s\n' \ 757 _tmp=`printf '%s\nall:\n\t@%s %%s %s=${%s:M*:Q:Q}\n%s\n%s\n' \
757 $var'+=-I${.CURDIR}' printf $var $var':S/-I${.CURDIR}//' \ 758 $var'+=-I${.CURDIR}' printf $var $var':S/-I${.CURDIR}//' \
758 EXPERIMENTAL=yes '.include <bsd.prog.mk>' | \ 759 EXPERIMENTAL=yes '.include <bsd.prog.mk>' | \
759 (unset MAKECONF; /usr/bin/make -f - all 2>/dev/null) | \ 760 (unset MAKECONF; /usr/bin/make -f - all 2>/dev/null) | \
760 sed 's/^x//'` 761 sed 's/^x//'`
761 eval $_tmp 762 eval $_tmp
762 eval export $var 763 eval export $var
763 done 764 done
764 ;; 765 ;;
765NetBSD) 766NetBSD)
766 root_group=wheel 767 root_group=wheel
767 need_bsd_install=no 768 need_bsd_install=no
768 need_awk=no 769 need_awk=no
769 need_sed=no 770 need_sed=no
770 set_opsys=no 771 set_opsys=no
771 machine_arch=`uname -p` 772 machine_arch=`uname -p`
772 ;; 773 ;;
773OpenBSD) 774OpenBSD)
774 root_group=wheel 775 root_group=wheel
775 need_bsd_install=no 776 need_bsd_install=no
776 need_awk=no 777 need_awk=no
777 need_sed=no 778 need_sed=no
778 set_opsys=no 779 set_opsys=no
779 machine_arch=`arch -s` 780 machine_arch=`arch -s`
780 ;; 781 ;;
781OSF1) 782OSF1)
782 root_group=system 783 root_group=system
783 need_bsd_install=yes 784 need_bsd_install=yes
784 need_awk=yes 785 need_awk=yes
785 need_sed=yes 786 need_sed=yes
786 need_ksh=yes 787 need_ksh=yes
787 set_opsys=no 788 set_opsys=no
788 machine_arch=`uname -p` 789 machine_arch=`uname -p`
789 ;; 790 ;;
790QNX) 791QNX)
791 root_group=root 792 root_group=root
792 need_bsd_install=yes 793 need_bsd_install=yes
793 need_awk=yes 794 need_awk=yes
794 need_sed=yes 795 need_sed=yes
795 set_opsys=no 796 set_opsys=no
796 groupsprog="id -gn" 797 groupsprog="id -gn"
797 whoamiprog="id -un" 798 whoamiprog="id -un"
798 machine_arch=`uname -p | sed -e 's/x86/i386/'` 799 machine_arch=`uname -p | sed -e 's/x86/i386/'`
799 ;; 800 ;;
800SCO_SV) 801SCO_SV)
801 root_group=root 802 root_group=root
802 need_awk=yes 803 need_awk=yes
803 need_bsd_install=yes 804 need_bsd_install=yes
804 need_sed=yes 805 need_sed=yes
805 set_opsys=no 806 set_opsys=no
806 whoamiprog='id -u' 807 whoamiprog='id -u'
807 groupsprog='id -g' 808 groupsprog='id -g'
808 # /bin/sh under OpenServer 5.0.7/3.2 breaks bmake tests. 809 # /bin/sh under OpenServer 5.0.7/3.2 breaks bmake tests.
809 #bmakexargs="$bmakexargs --with-defshell=/bin/ksh" 810 #bmakexargs="$bmakexargs --with-defshell=/bin/ksh"
810 ;; 811 ;;
811SunOS) 812SunOS)
812 root_group=root 813 root_group=root
813 need_bsd_install=yes 814 need_bsd_install=yes
814 use_bsdinstall=yes 815 use_bsdinstall=yes
815 if [ -x "/usr/gnu/bin/awk" ]; then 816 if [ -x "/usr/gnu/bin/awk" ]; then
816 need_awk=no 817 need_awk=no
817 else 818 else
818 need_awk=yes 819 need_awk=yes
819 fi 820 fi
820 if [ -x "/usr/gnu/bin/sed" ]; then 821 if [ -x "/usr/gnu/bin/sed" ]; then
821 need_sed=no 822 need_sed=no
822 else 823 else
823 need_sed=yes 824 need_sed=yes
824 fi 825 fi
825 if [ -x "/usr/bin/bash" ]; then 826 if [ -x "/usr/bin/bash" ]; then
826 bootstrap_sh=${SH:-/usr/bin/bash} 827 bootstrap_sh=${SH:-/usr/bin/bash}
827 bootstrap_sh_set=set 828 bootstrap_sh_set=set
828 else 829 else
829 need_ksh=yes 830 need_ksh=yes
830 fi 831 fi
831 set_opsys=no 832 set_opsys=no
832 idprog="/usr/xpg4/bin/id" 833 idprog="/usr/xpg4/bin/id"
833 groupsprog="${idprog} -gn" 834 groupsprog="${idprog} -gn"
834 whoamiprog="${idprog} -un" 835 whoamiprog="${idprog} -un"
835 machine_arch=`uname -p | sed -e 's/i86pc/i386/'` 836 machine_arch=`uname -p | sed -e 's/i86pc/i386/'`
836 check_compiler=yes 837 check_compiler=yes
837 ;; 838 ;;
838UnixWare) 839UnixWare)
839 root_group=sys 840 root_group=sys
840 need_bsd_install=no 841 need_bsd_install=no
841 BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV" 842 BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV"
842 need_mkdir=yes 843 need_mkdir=yes
843 need_awk=yes 844 need_awk=yes
844 need_sed=yes 845 need_sed=yes
845 whoamiprog=/usr/ucb/whoami 846 whoamiprog=/usr/ucb/whoami
846 set_opsys=no 847 set_opsys=no
847 CC="gcc -DUNIXWARE"; export CC 848 CC="gcc -DUNIXWARE"; export CC
848 ;; 849 ;;
849*) 850*)
850 echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc" 851 echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
851 root_group=wheel 852 root_group=wheel
852 need_bsd_install=yes 853 need_bsd_install=yes
853 need_awk=yes 854 need_awk=yes
854 need_sed=yes 855 need_sed=yes
855 set_opsys=no 856 set_opsys=no
856 ;; 857 ;;
857esac 858esac
858 859
859# Fixup MACHINE_ARCH to use canonical pkgsrc variants, and support multiarch 860# Fixup MACHINE_ARCH to use canonical pkgsrc variants, and support multiarch
860# systems via --abi, setting a default $abi based on MACHINE_ARCH if not set. 861# systems via --abi, setting a default $abi based on MACHINE_ARCH if not set.
861# 862#
862case "$machine_arch/$abi" in 863case "$machine_arch/$abi" in
863# "amd64" translates to "x86_64", defaults to 64-bit 864# "amd64" translates to "x86_64", defaults to 64-bit
864amd64/32) abi=32 machine_arch=i386 ;; 865amd64/32) abi=32 machine_arch=i386 ;;
865amd64/*) abi=64 machine_arch=x86_64 ;; 866amd64/*) abi=64 machine_arch=x86_64 ;;
866# XXX: hppa untested 867# XXX: hppa untested
867hppa/64) abi=64 machine_arch=hppa64 ;; 868hppa/64) abi=64 machine_arch=hppa64 ;;
868hppa/*) abi=32 machine_arch=hppa ;; 869hppa/*) abi=32 machine_arch=hppa ;;
869hppa64/32) abi=32 machine_arch=hppa ;; 870hppa64/32) abi=32 machine_arch=hppa ;;
870hppa64/*) abi=64 machine_arch=hppa64 ;; 871hppa64/*) abi=64 machine_arch=hppa64 ;;
871# "i386" can support 64-bit, e.g. SunOS, defaults to 32-bit. 872# "i386" can support 64-bit, e.g. SunOS, defaults to 32-bit.
872i386/64) abi=64 machine_arch=x86_64 ;; 873i386/64) abi=64 machine_arch=x86_64 ;;
873i386/*) abi=32 machine_arch=i386 ;; 874i386/*) abi=32 machine_arch=i386 ;;
874# XXX: powerpc untested 875# XXX: powerpc untested
875powerpc/64) abi=64 machine_arch=powerpc64 ;; 876powerpc/64) abi=64 machine_arch=powerpc64 ;;
876powerpc/*) abi=32 machine_arch=powerpc ;; 877powerpc/*) abi=32 machine_arch=powerpc ;;
877powerpc64/32) abi=32 machine_arch=powerpc ;; 878powerpc64/32) abi=32 machine_arch=powerpc ;;
878powerpc64/*) abi=64 machine_arch=powerpc64 ;; 879powerpc64/*) abi=64 machine_arch=powerpc64 ;;
879powerpc64le/*) abi=64 machine_arch=powerpc64le;; 880powerpc64le/*) abi=64 machine_arch=powerpc64le;;
880# "sparc" can support 64-bit, e.g. SunOS, defaults to 32-bit. 881# "sparc" can support 64-bit, e.g. SunOS, defaults to 32-bit.
881sparc/64) abi=64 machine_arch=sparc64 ;; 882sparc/64) abi=64 machine_arch=sparc64 ;;
882sparc/*) abi=32 machine_arch=sparc ;; 883sparc/*) abi=32 machine_arch=sparc ;;
883# x86_64 supports 32-bit/64-bit, defaults to 64-bit. 884# x86_64 supports 32-bit/64-bit, defaults to 64-bit.
884x86_64/32) abi=32 machine_arch=i386 ;; 885x86_64/32) abi=32 machine_arch=i386 ;;
885x86_64/*) abi=64 machine_arch=x86_64 ;; 886x86_64/*) abi=64 machine_arch=x86_64 ;;
886esac 887esac
887 888
888# If "--full" is specified, then install all of the platform-independent 889# If "--full" is specified, then install all of the platform-independent
889# bootstrap software. 890# bootstrap software.
890# 891#
891case "$full" in 892case "$full" in
892yes) 893yes)
893 need_bsd_install=yes 894 need_bsd_install=yes
894 need_awk=yes 895 need_awk=yes
895 need_sed=yes 896 need_sed=yes
896 need_ksh=yes 897 need_ksh=yes
897 ;; 898 ;;
898esac 899esac
899 900
900case "$quiet" in 901case "$quiet" in
901yes) 902yes)
902 configure_quiet_flags="--quiet" 903 configure_quiet_flags="--quiet"
903 make_quiet_flags="-s" 904 make_quiet_flags="-s"
904 ;; 905 ;;
905no) 906no)
906 configure_quiet_flags="" 907 configure_quiet_flags=""
907 make_quiet_flags="" 908 make_quiet_flags=""
908esac 909esac
909 910
910test ${make_jobs} -gt 0 2>/dev/null 911test ${make_jobs} -gt 0 2>/dev/null
911if [ $? -ne 0 ]; then 912if [ $? -ne 0 ]; then
912 die "ERROR: --make-jobs must be a positive integer argument" 913 die "ERROR: --make-jobs must be a positive integer argument"
913fi 914fi
914 915
915# export MACHINE_ARCH and OPSYS for bmake and pkg_install. 916# export MACHINE_ARCH and OPSYS for bmake and pkg_install.
916MACHINE_ARCH=${machine_arch}; export MACHINE_ARCH 917MACHINE_ARCH=${machine_arch}; export MACHINE_ARCH
917OPSYS=${opsys}; export OPSYS 918OPSYS=${opsys}; export OPSYS
918 919
919if [ "x$preserve_path" != "xyes" ]; then 920if [ "x$preserve_path" != "xyes" ]; then
920 PATH="$overpath:$PATH" 921 PATH="$overpath:$PATH"
921fi 922fi
922 923
923check_prog awkprog awk 924check_prog awkprog awk
924check_prog chmodprog chmod 925check_prog chmodprog chmod
925if [ -n "$CP" ]; then 926if [ -n "$CP" ]; then
926 cpprog="$CP" 927 cpprog="$CP"
927else 928else
928 check_prog cpprog cp 929 check_prog cpprog cp
929fi 930fi
930if [ -n "$ID" ]; then 931if [ -n "$ID" ]; then
931 idprog="$ID" 932 idprog="$ID"
932else 933else
933 check_prog idprog id 934 check_prog idprog id
934fi 935fi
935check_prog groupsprog groups 936check_prog groupsprog groups
936check_prog lnprog ln 937check_prog lnprog ln
937check_prog lsprog ls 938check_prog lsprog ls
938check_prog rmdirprog rmdir 939check_prog rmdirprog rmdir
939check_prog sedprog sed 940check_prog sedprog sed
940check_prog shprog sh 941check_prog shprog sh
941check_prog whoamiprog whoami 942check_prog whoamiprog whoami
942 943
943if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then 944if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then
944 die "\"${wrkdir}\" already exists, please remove it or use --workdir" 945 die "\"${wrkdir}\" already exists, please remove it or use --workdir"
945fi 946fi
946 947
947if [ -f "${prefix}/share/mk/sys.mk" ]; then 948if [ -f "${prefix}/share/mk/sys.mk" ]; then
948 die "\"${prefix}\" already in use, remove it or use a different --prefix" 949 die "\"${prefix}\" already in use, remove it or use a different --prefix"
949fi 950fi
950 951
951if [ -d "${pkgdbdir}/bootstrap-mk-files-"* ]; then 952if [ -d "${pkgdbdir}/bootstrap-mk-files-"* ]; then
952 die "\"${pkgdbdir}\" already in use, remove it or use a different --pkgdbdir" 953 die "\"${pkgdbdir}\" already in use, remove it or use a different --pkgdbdir"
953fi 954fi
954 955
955mkdir_p_early ${wrkdir} 956mkdir_p_early ${wrkdir}
956if touch ${wrkdir}/.writeable; then 957if touch ${wrkdir}/.writeable; then
957 : 958 :
958else 959else
959 die "\"${wrkdir}\" is not writeable. Try $0 -h" 960 die "\"${wrkdir}\" is not writeable. Try $0 -h"
960fi 961fi
961echo "Working directory is: ${wrkdir}" 962echo "Working directory is: ${wrkdir}"
962 963
963if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then 964if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then
964 get_compiler 965 get_compiler
965 # Clang pretends to be GCC, so we have to check it first. 966 # Clang pretends to be GCC, so we have to check it first.
966 if [ $compiler_is_clang -gt 0 ]; then 967 if [ $compiler_is_clang -gt 0 ]; then
967 compiler="clang" 968 compiler="clang"
968 elif [ $compiler_is_gnu -gt 0 ]; then 969 elif [ $compiler_is_gnu -gt 0 ]; then
969 compiler="gcc" 970 compiler="gcc"
970 else 971 else
971 case "$opsys" in 972 case "$opsys" in
972 IRIX) 973 IRIX)
973 if [ `uname -r` -ge 6 ]; then 974 if [ `uname -r` -ge 6 ]; then
974 compiler="mipspro" 975 compiler="mipspro"
975 else 976 else
976 compiler="ido" 977 compiler="ido"
977 fi 978 fi
978 test -n "$CC" || CC=cc 979 test -n "$CC" || CC=cc
979 ;; 980 ;;
980 SunOS) compiler="sunpro" 981 SunOS) compiler="sunpro"
981 test -n "$CC" || CC=cc 982 test -n "$CC" || CC=cc
982 ;; 983 ;;
983 esac 984 esac
984 fi 985 fi
985fi 986fi
986 987
987mkdir_p_early ${wrkdir}/bin 988mkdir_p_early ${wrkdir}/bin
988 989
989# build install-sh 990# build install-sh
990run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/bin/install-sh" 991run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/bin/install-sh"
991run_cmd "$chmodprog +x $wrkdir/bin/install-sh" 992run_cmd "$chmodprog +x $wrkdir/bin/install-sh"
992install_sh="$shprog $wrkdir/bin/install-sh" 993install_sh="$shprog $wrkdir/bin/install-sh"
993 994
994if [ $unprivileged = "yes" ]; then 995if [ $unprivileged = "yes" ]; then
995 user=`$whoamiprog` 996 user=`$whoamiprog`
996 group=`$groupsprog | $awkprog '{print $1}'` 997 group=`$groupsprog | $awkprog '{print $1}'`
997 echo_msg "building as unprivileged user $user/$group" 998 echo_msg "building as unprivileged user $user/$group"
998 999
999 # force bmake install target to use $user and $group 1000 # force bmake install target to use $user and $group
1000 echo "BINOWN=$user 1001 echo "BINOWN=$user
1001BINGRP=$group 1002BINGRP=$group
1002LIBOWN=$user 1003LIBOWN=$user
1003LIBGRP=$group 1004LIBGRP=$group
1004MANOWN=$user 1005MANOWN=$user
1005MANGRP=$group" > ${wrkdir}/Makefile.inc 1006MANGRP=$group" > ${wrkdir}/Makefile.inc
1006elif is_root; then 1007elif is_root; then
1007 user=$root_user 1008 user=$root_user
1008 group=$root_group 1009 group=$root_group
1009else 1010else
1010 die "You must be either root to install bootstrap-pkgsrc or use the --unprivileged option." 1011 die "You must be either root to install bootstrap-pkgsrc or use the --unprivileged option."
1011fi 1012fi
1012 1013
1013# export the proper environment 1014# export the proper environment
1014PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH 1015PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH
1015if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then 1016if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then
1016 PATH=${PATH}:/usr/ccs/bin; export PATH 1017 PATH=${PATH}:/usr/ccs/bin; export PATH
1017fi 1018fi
1018PKG_DBDIR=$pkgdbdir; export PKG_DBDIR 1019PKG_DBDIR=$pkgdbdir; export PKG_DBDIR
1019LOCALBASE=$prefix; export LOCALBASE 1020LOCALBASE=$prefix; export LOCALBASE
1020VARBASE=$varbase; export VARBASE 1021VARBASE=$varbase; export VARBASE
1021 1022
1022# set up an example mk.conf file 1023# set up an example mk.conf file
1023TARGET_MKCONF=${wrkdir}/mk.conf.example 1024TARGET_MKCONF=${wrkdir}/mk.conf.example
1024echo_msg "Creating default mk.conf in ${wrkdir}" 1025echo_msg "Creating default mk.conf in ${wrkdir}"
1025echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${TARGET_MKCONF} 1026echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${TARGET_MKCONF}
1026echo "# `date`" >> ${TARGET_MKCONF} 1027echo "# `date`" >> ${TARGET_MKCONF}
1027echo "" >> ${TARGET_MKCONF} 1028echo "" >> ${TARGET_MKCONF}
1028echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${TARGET_MKCONF} 1029echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${TARGET_MKCONF}
1029echo "" >> ${TARGET_MKCONF} 1030echo "" >> ${TARGET_MKCONF}
1030 1031
1031# IRIX64 needs to be set to IRIX, for example 1032# IRIX64 needs to be set to IRIX, for example
1032if [ "$set_opsys" = "yes" ]; then 1033if [ "$set_opsys" = "yes" ]; then
1033 echo "OPSYS= $opsys" >> ${TARGET_MKCONF} 1034 echo "OPSYS= $opsys" >> ${TARGET_MKCONF}
1034fi 1035fi
1035 1036
1036if [ -n "$abi" ]; then 1037if [ -n "$abi" ]; then
1037 echo "ABI= $abi" >> ${TARGET_MKCONF} 1038 echo "ABI= $abi" >> ${TARGET_MKCONF}
1038fi 1039fi
1039if [ "$compiler" != "" ]; then 1040if [ "$compiler" != "" ]; then
1040 echo "PKGSRC_COMPILER= $compiler" >> ${TARGET_MKCONF} 1041 echo "PKGSRC_COMPILER= $compiler" >> ${TARGET_MKCONF}
1041fi 1042fi
1042case "$compiler" in 1043case "$compiler" in
1043sunpro) 1044sunpro)
1044 echo "CC= cc" >> ${TARGET_MKCONF} 1045 echo "CC= cc" >> ${TARGET_MKCONF}
1045 echo "CXX= CC" >> ${TARGET_MKCONF} 1046 echo "CXX= CC" >> ${TARGET_MKCONF}
1046 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF} 1047 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF}
1047 ;; 1048 ;;
1048clang) 1049clang)
1049 echo "CC= clang" >> ${TARGET_MKCONF} 1050 echo "CC= clang" >> ${TARGET_MKCONF}
1050 echo "CXX= clang++" >> ${TARGET_MKCONF} 1051 echo "CXX= clang++" >> ${TARGET_MKCONF}
1051 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF} 1052 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF}
1052 if [ -z "$CLANGBASE" -a -f "/usr/bin/clang" ]; then 1053 if [ -z "$CLANGBASE" -a -f "/usr/bin/clang" ]; then
1053 CLANGBASE="/usr" 1054 CLANGBASE="/usr"
1054 fi 1055 fi
1055 if [ -n "$CLANGBASE" -o -f "/bin/clang" ]; then 1056 if [ -n "$CLANGBASE" -o -f "/bin/clang" ]; then
1056 echo "CLANGBASE= $CLANGBASE" >> ${TARGET_MKCONF} 1057 echo "CLANGBASE= $CLANGBASE" >> ${TARGET_MKCONF}
1057 fi 1058 fi
1058 ;; 1059 ;;
1059esac 1060esac
1060if [ -n "$GCCBASE" ]; then 1061if [ -n "$GCCBASE" ]; then
1061 echo "GCCBASE= $GCCBASE" >> ${TARGET_MKCONF} 1062 echo "GCCBASE= $GCCBASE" >> ${TARGET_MKCONF}
1062fi 1063fi
1063if [ -n "$SUNWSPROBASE" ]; then 1064if [ -n "$SUNWSPROBASE" ]; then
1064 echo "SUNWSPROBASE= $SUNWSPROBASE" >> ${TARGET_MKCONF} 1065 echo "SUNWSPROBASE= $SUNWSPROBASE" >> ${TARGET_MKCONF}
1065fi 1066fi
1066echo "" >> ${TARGET_MKCONF} 1067echo "" >> ${TARGET_MKCONF}
1067 1068
1068# enable unprivileged builds if not root 1069# enable unprivileged builds if not root
1069if [ "$unprivileged" = "yes" ]; then 1070if [ "$unprivileged" = "yes" ]; then
1070 echo "UNPRIVILEGED= yes" >> ${TARGET_MKCONF} 1071 echo "UNPRIVILEGED= yes" >> ${TARGET_MKCONF}
1071fi 1072fi
1072 1073
1073# save environment in example mk.conf 1074# save environment in example mk.conf
1074echo "PKG_DBDIR= $pkgdbdir" >> ${TARGET_MKCONF} 1075echo "PKG_DBDIR= $pkgdbdir" >> ${TARGET_MKCONF}
1075echo "LOCALBASE= $prefix" >> ${TARGET_MKCONF} 1076echo "LOCALBASE= $prefix" >> ${TARGET_MKCONF}
1076echo "VARBASE= $varbase" >> ${TARGET_MKCONF} 1077echo "VARBASE= $varbase" >> ${TARGET_MKCONF}
1077if [ "${sysconfdir}" != "${prefix}/etc" ]; then 1078if [ "${sysconfdir}" != "${prefix}/etc" ]; then
1078 echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF} 1079 echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF}
1079fi 1080fi
1080echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF} 1081echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF}
1081echo "PKGINFODIR= $pkginfodir" >> ${TARGET_MKCONF} 1082echo "PKGINFODIR= $pkginfodir" >> ${TARGET_MKCONF}
1082echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF} 1083echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF}
1083echo "" >> ${TARGET_MKCONF} 1084echo "" >> ${TARGET_MKCONF}
1084 1085
1085if [ -n "$prefer_pkgsrc" ]; then 1086if [ -n "$prefer_pkgsrc" ]; then
1086 echo "PREFER_PKGSRC= $prefer_pkgsrc" >> ${TARGET_MKCONF} 1087 echo "PREFER_PKGSRC= $prefer_pkgsrc" >> ${TARGET_MKCONF}
1087 echo "" >> ${TARGET_MKCONF} 1088 echo "" >> ${TARGET_MKCONF}
1088fi 1089fi
1089 1090
1090BOOTSTRAP_MKCONF=${wrkdir}/mk.conf 1091BOOTSTRAP_MKCONF=${wrkdir}/mk.conf
1091cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF} 1092cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF}
1092 1093
1093case "$cwrappers" in 1094case "$cwrappers" in
1094yes|no) 1095yes|no)
1095 echo "USE_CWRAPPERS= $cwrappers" >> ${TARGET_MKCONF} 1096 echo "USE_CWRAPPERS= $cwrappers" >> ${TARGET_MKCONF}
1096 echo "USE_CWRAPPERS= $cwrappers" >> ${BOOTSTRAP_MKCONF} 1097 echo "USE_CWRAPPERS= $cwrappers" >> ${BOOTSTRAP_MKCONF}
1097 echo "" >> ${TARGET_MKCONF} 1098 echo "" >> ${TARGET_MKCONF}
1098 ;; 1099 ;;
1099esac 1100esac
1100 1101
1101# On all Debian GNU/kFreeBSD 7, /bin/sh is a symlink to /bin/dash, and 1102# On all Debian GNU/kFreeBSD 7, /bin/sh is a symlink to /bin/dash, and
1102# use /bin/bash. 1103# use /bin/bash.
1103if [ "$opsys" = "GNUkFreeBSD" -a "$bootstrap_sh_set" != "set" ]; then 1104if [ "$opsys" = "GNUkFreeBSD" -a "$bootstrap_sh_set" != "set" ]; then
1104 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${TARGET_MKCONF} 1105 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${TARGET_MKCONF}
1105 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${BOOTSTRAP_MKCONF} 1106 echo "TOOLS_PLATFORM.sh?= /bin/bash # instead of /bin/sh" >> ${BOOTSTRAP_MKCONF}
1106 echo $opsys 1107 echo $opsys
1107fi 1108fi
1108 1109
1109# sbin is used by pkg_install, share/mk by bootstrap-mk-files 1110# sbin is used by pkg_install, share/mk by bootstrap-mk-files
1110mkdir_p $wrkdir/sbin $wrkdir/share/mk 1111mkdir_p $wrkdir/sbin $wrkdir/share/mk
1111mkdir_p_early ${wrkdir} 1112mkdir_p_early ${wrkdir}
1112 1113
1113if [ "$need_bsd_install" = "yes" ]; then 1114if [ "$need_bsd_install" = "yes" ]; then
1114 BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV" 1115 BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV"
1115 if [ "$use_bsdinstall" = "yes" ]; then 1116 if [ "$use_bsdinstall" = "yes" ]; then
1116 echo "TOOLS_PLATFORM.install?= $prefix/bin/bsdinstall" >> ${TARGET_MKCONF} 1117 echo "TOOLS_PLATFORM.install?= $prefix/bin/bsdinstall" >> ${TARGET_MKCONF}
1117 else 1118 else
1118 echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF} 1119 echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF}
1119 fi 1120 fi
1120 echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF} 1121 echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF}
1121fi 1122fi
1122 1123
1123if [ "$need_fixed_strip" = "yes" ] ; then 1124if [ "$need_fixed_strip" = "yes" ] ; then
1124 echo_msg "Installing fixed strip script" 1125 echo_msg "Installing fixed strip script"
1125 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip" 1126 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip"
1126 echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF} 1127 echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF}
1127 echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF} 1128 echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF}
1128 need_extras=yes 1129 need_extras=yes
1129fi 1130fi
1130 1131
1131if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then 1132if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then
1132 echo_msg "Installing fixed mkdir script \"mkdir-sh\"" 1133 echo_msg "Installing fixed mkdir script \"mkdir-sh\""
1133 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh" 1134 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh"
1134 echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF} 1135 echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF}
1135 echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF} 1136 echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF}
1136 need_extras=yes 1137 need_extras=yes
1137fi 1138fi
1138 1139
1139if [ "$need_xargs" = "yes" ]; then 1140if [ "$need_xargs" = "yes" ]; then
1140 echo_msg "Installing fixed xargs script" 1141 echo_msg "Installing fixed xargs script"
1141 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs" 1142 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs"
1142 echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF} 1143 echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF}
1143 echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF} 1144 echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF}
1144 need_extras=yes 1145 need_extras=yes
1145fi 1146fi
1146 1147
1147echo_msg "Bootstrapping mk-files" 1148echo_msg "Bootstrapping mk-files"
1148run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \ 1149run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \
1149 OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \ 1150 OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \
1150ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \ 1151ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \
1151$shprog ./bootstrap.sh)" 1152$shprog ./bootstrap.sh)"
1152 1153
1153bootstrap_bmake() { 1154bootstrap_bmake() {
1154 echo_msg "Bootstrapping bmake" 1155 echo_msg "Bootstrapping bmake"
1155 copy_src $pkgsrcdir/devel/bmake/files bmake 1156 copy_src $pkgsrcdir/devel/bmake/files bmake
1156 run_cmd "(cd $wrkdir/bmake && $shprog configure $configure_quiet_flags --prefix=$wrkdir --with-default-sys-path=$wrkdir/share/mk --with-machine-arch=${machine_arch} $bmakexargs)" 1157 run_cmd "(cd $wrkdir/bmake && $shprog configure $configure_quiet_flags --prefix=$wrkdir --with-default-sys-path=$wrkdir/share/mk --with-machine-arch=${machine_arch} $bmakexargs)"
1157 run_cmd "(cd $wrkdir/bmake && $shprog make-bootstrap.sh)" 1158 run_cmd "(cd $wrkdir/bmake && $shprog make-bootstrap.sh)"
1158 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/bmake $wrkdir/bin/bmake" 1159 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/bmake $wrkdir/bin/bmake"
1159} 1160}
1160bootstrap_bmake 1161bootstrap_bmake
1161 1162
1162bmake="$wrkdir/bin/bmake" 1163bmake="$wrkdir/bin/bmake"
1163 1164
1164# build libnbcompat 1165# build libnbcompat
1165echo_msg "Building libnbcompat" 1166echo_msg "Building libnbcompat"
1166copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat 1167copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat
1167run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --enable-bsd-getopt --enable-db && $bmake $make_quiet_flags -j$make_jobs)" 1168run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --enable-bsd-getopt --enable-db && $bmake $make_quiet_flags -j$make_jobs)"
1168 1169
1169# bootstrap ksh if necessary 1170# bootstrap ksh if necessary
1170case "$need_ksh" in 1171case "$need_ksh" in
1171yes) echo_msg "Bootstrapping ksh" 1172yes) echo_msg "Bootstrapping ksh"
1172 copy_src $pkgsrcdir/shells/pdksh/files ksh 1173 copy_src $pkgsrcdir/shells/pdksh/files ksh
1173 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified 1174 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
1174 run_cmd "(cd $wrkdir/ksh && env $BSTRAP_ENV $shprog ./configure $configure_quiet_flags --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir && $bmake $make_quiet_flags -j$make_jobs)" 1175 run_cmd "(cd $wrkdir/ksh && env $BSTRAP_ENV $shprog ./configure $configure_quiet_flags --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir && $bmake $make_quiet_flags -j$make_jobs)"
1175 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh" 1176 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh"
1176 echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF} 1177 echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
1177 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF} 1178 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1178 echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF} 1179 echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
1179 echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF} 1180 echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
1180# Now rebootstrap bmake for ksh 1181# Now rebootstrap bmake for ksh
1181 echo_msg "Rebootstrapping bmake for ksh" 1182 echo_msg "Rebootstrapping bmake for ksh"
1182 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh" 1183 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh"
1183 bootstrap_bmake 1184 bootstrap_bmake
1184 ;; 1185 ;;
1185esac 1186esac
1186 1187
1187# bootstrap awk if necessary 1188# bootstrap awk if necessary
1188case "$need_awk" in 1189case "$need_awk" in
1189yes) echo_msg "Bootstrapping awk" 1190yes) echo_msg "Bootstrapping awk"
1190 copy_src $pkgsrcdir/lang/nawk/files awk 1191 copy_src $pkgsrcdir/lang/nawk/files awk
1191 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified 1192 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
1192 run_cmd "(cd $wrkdir/awk && $bmake $make_quiet_flags -j$make_jobs -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")" 1193 run_cmd "(cd $wrkdir/awk && $bmake $make_quiet_flags -j$make_jobs -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")"
1193 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk" 1194 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk"
1194 echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF} 1195 echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF}
1195 echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF} 1196 echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF}
1196 ;; 1197 ;;
1197esac 1198esac
1198 1199
1199# bootstrap sed if necessary 1200# bootstrap sed if necessary
1200case "$need_sed" in 1201case "$need_sed" in
1201yes) echo_msg "Bootstrapping sed" 1202yes) echo_msg "Bootstrapping sed"
1202 copy_src $pkgsrcdir/textproc/nbsed/files sed 1203 copy_src $pkgsrcdir/textproc/nbsed/files sed
1203 run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake $make_quiet_flags -j$make_jobs)" 1204 run_cmd "(cd $wrkdir/sed; env $BSTRAP_ENV CPPFLAGS='$CPPFLAGS -I../libnbcompat' LDFLAGS='$LDFLAGS -L../libnbcompat' LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --infodir=$infodir --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake $make_quiet_flags -j$make_jobs)"
1204 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed" 1205 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed"
1205 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF} 1206 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF}
1206 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF} 1207 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF}
1207 ;; 1208 ;;
1208esac 1209esac
1209 1210
1210# bootstrap pkg_install 1211# bootstrap pkg_install
1211echo_msg "Bootstrapping pkgtools" 1212echo_msg "Bootstrapping pkgtools"
1212copy_src $pkgsrcdir/archivers/libarchive/files libarchive 1213copy_src $pkgsrcdir/archivers/libarchive/files libarchive
1213run_cmd "(cd $wrkdir/libarchive; env $BSTRAP_ENV \ 1214run_cmd "(cd $wrkdir/libarchive; env $BSTRAP_ENV \
1214$shprog ./configure $configure_quiet_flags --enable-static --disable-shared \ 1215$shprog ./configure $configure_quiet_flags --enable-static --disable-shared \
1215--disable-bsdtar --disable-bsdcpio --disable-posix-regex-lib --disable-xattr \ 1216--disable-bsdtar --disable-bsdcpio --disable-posix-regex-lib --disable-xattr \
1216--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib \ 1217--disable-maintainer-mode --disable-acl --without-zlib --without-bz2lib \
1217--without-lzmadec --without-iconv --without-lzma --without-lzo2 --without-lz4 \ 1218--without-lzmadec --without-iconv --without-lzma --without-lzo2 --without-lz4 \
1218--without-nettle --without-openssl --without-xml2 --without-expat \ 1219--without-nettle --without-openssl --without-xml2 --without-expat \
1219MAKE=$bmake && $bmake $make_quiet_flags -j$make_jobs)" 1220MAKE=$bmake && $bmake $make_quiet_flags -j$make_jobs)"
1220copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install 1221copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
1221run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \ 1222run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \
1222CPPFLAGS='$CPPFLAGS -I${wrkdir}/libnbcompat -I${wrkdir}/libarchive/libarchive' \ 1223CPPFLAGS='$CPPFLAGS -I${wrkdir}/libnbcompat -I${wrkdir}/libarchive/libarchive' \
1223LDFLAGS='$LDFLAGS -L${wrkdir}/libnbcompat' \ 1224LDFLAGS='$LDFLAGS -L${wrkdir}/libnbcompat' \
1224LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \ 1225LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \
1225--enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \ 1226--enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \
1226--with-pkgdbdir=$pkgdbdir --infodir=$infodir \ 1227--with-pkgdbdir=$pkgdbdir --infodir=$infodir \
1227--mandir=$mandir $pkg_install_args && \ 1228--mandir=$mandir $pkg_install_args && \
1228STATIC_LIBARCHIVE=$wrkdir/libarchive/.libs/libarchive.a \ 1229STATIC_LIBARCHIVE=$wrkdir/libarchive/.libs/libarchive.a \
1229PKGSRC_MACHINE_ARCH="$machine_arch" $bmake $make_quiet_flags -j$make_jobs)" 1230PKGSRC_MACHINE_ARCH="$machine_arch" $bmake $make_quiet_flags -j$make_jobs)"
1230run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/add/pkg_add $wrkdir/sbin/pkg_add" 1231run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/add/pkg_add $wrkdir/sbin/pkg_add"
1231run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin" 1232run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin"
1232run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create" 1233run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create"
1233run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info" 1234run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info"
1234echo "PKG_ADD_CMD?= $wrkdir/sbin/pkg_add" >> ${BOOTSTRAP_MKCONF} 1235echo "PKG_ADD_CMD?= $wrkdir/sbin/pkg_add" >> ${BOOTSTRAP_MKCONF}
1235echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF} 1236echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF}
1236echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF} 1237echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF}
1237echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF} 1238echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF}
1238 1239
1239MAKECONF=$wrkdir/mk.conf 1240MAKECONF=$wrkdir/mk.conf
1240export MAKECONF 1241export MAKECONF
1241 1242
1242if [ "$bootstrap_sh_set" = "set" ]; then 1243if [ "$bootstrap_sh_set" = "set" ]; then
1243 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF} 1244 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF}
1244 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF} 1245 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF}
1245fi 1246fi
1246 1247
1247# preserve compiler and tool environment variables settings 1248# preserve compiler and tool environment variables settings
1248if test -n "$CP"; then 1249if test -n "$CP"; then
1249 echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF} 1250 echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF}
1250 echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF} 1251 echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF}
1251fi 1252fi
1252if test -n "$GREP"; then 1253if test -n "$GREP"; then
1253 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF} 1254 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF}
1254 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF} 1255 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF}
1255fi 1256fi
1256if test -n "$ID"; then 1257if test -n "$ID"; then
1257 echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF} 1258 echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF}
1258 echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF} 1259 echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF}
1259fi 1260fi
1260if test -n "$MKDIR"; then 1261if test -n "$MKDIR"; then
1261 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF} 1262 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF}
1262 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF} 1263 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF}
1263fi 1264fi
1264if test -n "$TEST"; then 1265if test -n "$TEST"; then
1265 echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF} 1266 echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF}
1266 echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF} 1267 echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF}
1267fi 1268fi
1268if test -n "$TOUCH"; then 1269if test -n "$TOUCH"; then
1269 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF} 1270 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF}
1270 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF} 1271 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF}
1271fi 1272fi
1272if test -n "$XARGS"; then 1273if test -n "$XARGS"; then
1273 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF} 1274 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF}
1274 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF} 1275 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF}
1275fi 1276fi
1276if test -n "$CFLAGS"; then 1277if test -n "$CFLAGS"; then
1277 echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF} 1278 echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF}
1278 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF} 1279 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF}
1279 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF} 1280 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF}
1280fi 1281fi
1281if test -n "$CPPFLAGS"; then 1282if test -n "$CPPFLAGS"; then
1282 echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF} 1283 echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF}
1283fi 1284fi
1284if test -n "$LDFLAGS"; then 1285if test -n "$LDFLAGS"; then
1285 echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF} 1286 echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF}
1286fi 1287fi
1287if test -n "$LIBS"; then 1288if test -n "$LIBS"; then
1288 echo "LIBS+= $LIBS" >> ${TARGET_MKCONF} 1289 echo "LIBS+= $LIBS" >> ${TARGET_MKCONF}
1289fi 1290fi
1290 1291
1291# opsys specific fiddling 1292# opsys specific fiddling
1292opsys_finish 1293opsys_finish
1293 1294
1294echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF} 1295echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF}
1295 1296
1296echo "" >> ${TARGET_MKCONF} 1297echo "" >> ${TARGET_MKCONF}
1297echo "" >> ${BOOTSTRAP_MKCONF} 1298echo "" >> ${BOOTSTRAP_MKCONF}
1298if test -n "${mk_fragment}"; then 1299if test -n "${mk_fragment}"; then
1299 cat "${mk_fragment}" >> ${TARGET_MKCONF} 1300 cat "${mk_fragment}" >> ${TARGET_MKCONF}
1300 echo "" >> ${TARGET_MKCONF} 1301 echo "" >> ${TARGET_MKCONF}
1301fi 1302fi
1302echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF} 1303echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF}
1303echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF} 1304echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF}
1304 1305
1305# build and register packages 1306# build and register packages
1306# usage: build_package <packagedirectory> 1307# usage: build_package <packagedirectory>
1307build_package() { 1308build_package() {
1308 run_cmd "(cd $pkgsrcdir/$1 && $bmake $make_quiet_flags MAKE_JOBS=${make_jobs} PKG_COMPRESSION=none -DPKG_PRESERVE MAKECONF=${BOOTSTRAP_MKCONF} install)" 1309 run_cmd "(cd $pkgsrcdir/$1 && $bmake $make_quiet_flags MAKE_JOBS=${make_jobs} PKG_COMPRESSION=none -DPKG_PRESERVE MAKECONF=${BOOTSTRAP_MKCONF} install)"
1309} 1310}
1310build_package_nopreserve() { 1311build_package_nopreserve() {
1311 run_cmd "(cd $pkgsrcdir/$1 && $bmake $make_quiet_flags MAKE_JOBS=${make_jobs} PKG_COMPRESSION=none MAKECONF=${BOOTSTRAP_MKCONF} install)" 1312 run_cmd "(cd $pkgsrcdir/$1 && $bmake $make_quiet_flags MAKE_JOBS=${make_jobs} PKG_COMPRESSION=none MAKECONF=${BOOTSTRAP_MKCONF} install)"
1312} 1313}
1313 1314
1314# 1315#
1315# cwrappers is special, we don't want to set it as a BOOTSTRAP_PKG but must 1316# cwrappers is special, we don't want to set it as a BOOTSTRAP_PKG but must
1316# build it (if required) without -DPKG_PRESERVE set so that it can be deleted. 1317# build it (if required) without -DPKG_PRESERVE set so that it can be deleted.
1317# 1318#
1318use_cwrappers=`(cd $pkgsrcdir/devel/bmake && $bmake show-var VARNAME=_USE_CWRAPPERS)` 1319use_cwrappers=`(cd $pkgsrcdir/devel/bmake && $bmake show-var VARNAME=_USE_CWRAPPERS)`
1319case "$use_cwrappers" in 1320case "$use_cwrappers" in
1320yes) 1321yes)
1321 build_package_nopreserve "pkgtools/cwrappers" 1322 build_package_nopreserve "pkgtools/cwrappers"
1322 ;; 1323 ;;
1323esac 1324esac
1324 1325
1325# 1326#
1326# Please make sure that the following packages and 1327# Please make sure that the following packages and
1327# only the following packages set BOOTSTRAP_PKG=yes. 1328# only the following packages set BOOTSTRAP_PKG=yes.
1328# 1329#
1329echo_msg "Installing packages" 1330echo_msg "Installing packages"
1330build_package "pkgtools/bootstrap-mk-files" 1331build_package "pkgtools/bootstrap-mk-files"
1331case "$need_bsd_install" in 1332case "$need_bsd_install" in
1332yes) 1333yes)
1333 if [ "$use_bsdinstall" = "yes" ]; then 1334 if [ "$use_bsdinstall" = "yes" ]; then
1334 build_package "sysutils/bsdinstall" 1335 build_package "sysutils/bsdinstall"
1335 else 1336 else
1336 build_package "sysutils/install-sh" 1337 build_package "sysutils/install-sh"
1337 fi 1338 fi
1338 ;; 1339 ;;
1339esac 1340esac
1340case "$need_ksh" in 1341case "$need_ksh" in
1341yes) build_package "shells/pdksh";; 1342yes) build_package "shells/pdksh";;
1342esac 1343esac
1343build_package "devel/bmake" 1344build_package "devel/bmake"
1344case "$need_awk" in 1345case "$need_awk" in
1345yes) build_package "lang/nawk";; 1346yes) build_package "lang/nawk";;
1346esac 1347esac
1347case "$need_sed" in 1348case "$need_sed" in
1348yes) build_package "textproc/nbsed";; 1349yes) build_package "textproc/nbsed";;
1349esac 1350esac
1350case "$need_extras" in 1351case "$need_extras" in
1351yes) build_package "pkgtools/bootstrap-extras";; 1352yes) build_package "pkgtools/bootstrap-extras";;
1352esac 1353esac
1353build_package "pkgtools/pkg_install" 1354build_package "pkgtools/pkg_install"
1354 1355
1355etc_mk_conf="$sysconfdir/mk.conf" 1356etc_mk_conf="$sysconfdir/mk.conf"
1356 1357
1357# Install the example mk.conf so that it is used, but only if it doesn't 1358# Install the example mk.conf so that it is used, but only if it doesn't
1358# exist yet. This can happen with non-default sysconfdir settings. 1359# exist yet. This can happen with non-default sysconfdir settings.
1359mkdir_p "$sysconfdir" 1360mkdir_p "$sysconfdir"
1360if [ ! -f "$etc_mk_conf" ]; then 1361if [ ! -f "$etc_mk_conf" ]; then
1361 cp "$TARGET_MKCONF" "$etc_mk_conf" 1362 cp "$TARGET_MKCONF" "$etc_mk_conf"
1362 TARGET_MKCONF="$etc_mk_conf" 1363 TARGET_MKCONF="$etc_mk_conf"
1363fi 1364fi
1364 1365
1365hline="===========================================================================" 1366hline="==========================================================================="
1366echo "" 1367echo ""
1367echo "$hline" 1368echo "$hline"
1368echo "" 1369echo ""
1369echo "Please remember to add $prefix/bin to your PATH environment variable" 1370echo "Please remember to add $prefix/bin to your PATH environment variable"
1370echo "and $mandir to your MANPATH environment variable, if necessary." 1371echo "and $mandir to your MANPATH environment variable, if necessary."
1371echo "" 1372echo ""
1372echo "An example mk.conf file with the settings you provided to \"bootstrap\"" 1373echo "An example mk.conf file with the settings you provided to \"bootstrap\""
1373echo "has been created for you. It can be found in:" 1374echo "has been created for you. It can be found in:"
1374echo "" 1375echo ""
1375echo " ${TARGET_MKCONF}" 1376echo " ${TARGET_MKCONF}"
1376echo "" 1377echo ""
1377if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then 1378if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then
1378 echo "Please copy it to $etc_mk_conf to use it." 1379 echo "Please copy it to $etc_mk_conf to use it."
1379 echo "" 1380 echo ""
1380fi 1381fi
1381echo "You can find extensive documentation of the NetBSD Packages Collection" 1382echo "You can find extensive documentation of the NetBSD Packages Collection"
1382echo "in $pkgsrcdir/doc/pkgsrc.txt." 1383echo "in $pkgsrcdir/doc/pkgsrc.txt."
1383echo "" 1384echo ""
1384echo "Thank you for using pkgsrc!" 1385echo "Thank you for using pkgsrc!"
1385echo "" 1386echo ""
1386echo "$hline" 1387echo "$hline"
1387echo "" 1388echo ""
1388 1389
1389[ -n "${binary_kit}" ] && mkbinarykit_tar 1390[ -n "${binary_kit}" ] && mkbinarykit_tar
1390[ -n "${binary_gzip_kit}" ] && mkbinarykit_tgz 1391[ -n "${binary_gzip_kit}" ] && mkbinarykit_tgz
1391[ -n "${binary_macpkg}" ] && mkbinarykit_macpkg 1392[ -n "${binary_macpkg}" ] && mkbinarykit_macpkg
1392 1393
1393echo_msg "bootstrap started: $build_start" 1394echo_msg "bootstrap started: $build_start"
1394echo_msg "bootstrap ended: `date`" 1395echo_msg "bootstrap ended: `date`"
1395 1396
1396exit 0 1397exit 0