Fri Sep 9 10:58:15 2022 UTC ()
bootstrap: Remove old -isystem hack on macOS.

This was introduced many years ago in PR#26143 to try and work around a
misconfiguration in how Apple's GCC was built at the time.  Newer compilers no
longer look in /usr/local/include, and this workaround can now be harmful when
trying to pick a specific SDK to build against.


(jperkin)
diff -r1.312 -r1.313 pkgsrc/bootstrap/bootstrap

cvs diff -r1.312 -r1.313 pkgsrc/bootstrap/bootstrap (switch to unified diff)

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