build.sh revision 1.171 1 #! /usr/bin/env sh
2 # $NetBSD: build.sh,v 1.171 2007/06/26 12:59:38 apb Exp $
3 #
4 # Copyright (c) 2001-2005 The NetBSD Foundation, Inc.
5 # All rights reserved.
6 #
7 # This code is derived from software contributed to The NetBSD Foundation
8 # by Todd Vierling and Luke Mewburn.
9 #
10 # Redistribution and use in source and binary forms, with or without
11 # modification, are permitted provided that the following conditions
12 # are met:
13 # 1. Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # 2. Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in the
17 # documentation and/or other materials provided with the distribution.
18 # 3. All advertising materials mentioning features or use of this software
19 # must display the following acknowledgement:
20 # This product includes software developed by the NetBSD
21 # Foundation, Inc. and its contributors.
22 # 4. Neither the name of The NetBSD Foundation nor the names of its
23 # contributors may be used to endorse or promote products derived
24 # from this software without specific prior written permission.
25 #
26 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 # POSSIBILITY OF SUCH DAMAGE.
37 #
38 #
39 # Top level build wrapper, for a system containing no tools.
40 #
41 # This script should run on any POSIX-compliant shell. If the
42 # first "sh" found in the PATH is a POSIX-compliant shell, then
43 # you should not need to take any special action. Otherwise, you
44 # should set the environment variable HOST_SH to a POSIX-compliant
45 # shell, and invoke build.sh with that shell. (Depending on your
46 # system, one of /bin/ksh, /usr/local/bin/bash, or /usr/xpg4/bin/sh
47 # might be a suitable shell.)
48 #
49
50 progname=${0##*/}
51 toppid=$$
52 results=/dev/null
53 trap "exit 1" 1 2 3 15
54
55 bomb()
56 {
57 cat >&2 <<ERRORMESSAGE
58
59 ERROR: $@
60 *** BUILD ABORTED ***
61 ERRORMESSAGE
62 kill ${toppid} # in case we were invoked from a subshell
63 exit 1
64 }
65
66
67 statusmsg()
68 {
69 ${runcmd} echo "===> $@" | tee -a "${results}"
70 }
71
72 warning()
73 {
74 statusmsg "Warning: $@"
75 }
76
77 # Find a program in the PATH, and print the result. If not found,
78 # print a default. If $2 is defined (even if it is an empty string),
79 # then that is the default; otherwise, $1 is used as the default.
80 find_in_PATH()
81 {
82 local prog="$1"
83 local result="${2-"$1"}"
84 local oldIFS="${IFS}"
85 local dir
86 IFS=":"
87 for dir in ${PATH}; do
88 if [ -x "${dir}/${prog}" ]; then
89 result="${dir}/${prog}"
90 break
91 fi
92 done
93 IFS="${oldIFS}"
94 echo "${result}"
95 }
96
97 # Try to find a working POSIX shell, and set HOST_SH to refer to it.
98 # Assumes that uname_s, uname_m, and PWD have been set.
99 set_HOST_SH()
100 {
101 # Even if ${HOST_SH} is already defined, we still do the
102 # sanity checks at the end.
103
104 # Solaris has /usr/xpg4/bin/sh.
105 #
106 [ -z "${HOST_SH}" ] && [ x"${uname_s}" = x"SunOS" ] && \
107 [ -x /usr/xpg4/bin/sh ] && HOST_SH="/usr/xpg4/bin/sh"
108
109 # Try to get the name of the shell that's running this script,
110 # by parsing the output from "ps". We assume that, if the host
111 # system's ps command supports -o comm at all, it will do so
112 # in the usual way: a one-line header followed by a one-line
113 # result, possibly including trailing white space. And if the
114 # host system's ps command doesn't support -o comm, we assume
115 # that we'll get an error message on stderr and nothing on
116 # stdout. (We don't try to use ps -o 'comm=' to suppress the
117 # header line, because that is less widely supported.)
118 #
119 # If we get the wrong result here, the user can override it by
120 # specifying HOST_SH in the environment.
121 #
122 [ -z "${HOST_SH}" ] && HOST_SH="$(
123 (ps -p $$ -o comm | sed -ne '2s/[ \t]*$//p') 2>/dev/null )"
124
125 # If nothing above worked, use "sh". We will later find the
126 # first directory in the PATH that has a "sh" program.
127 #
128 [ -z "${HOST_SH}" ] && HOST_SH="sh"
129
130 # If the result so far is not an absolute path, try to prepend
131 # PWD or search the PATH.
132 #
133 case "${HOST_SH}" in
134 /*) :
135 ;;
136 */*) HOST_SH="${PWD}/${HOST_SH}"
137 ;;
138 *) HOST_SH="$(find_in_PATH "${HOST_SH}")"
139 ;;
140 esac
141
142 # If we don't have an absolute path by now, bomb.
143 #
144 case "${HOST_SH}" in
145 /*) :
146 ;;
147 *) bomb "HOST_SH=\"${HOST_SH}\" is not an absolute path."
148 ;;
149 esac
150
151 # If HOST_SH is not executable, bomb.
152 #
153 [ -x "${HOST_SH}" ] ||
154 bomb "HOST_SH=\"${HOST_SH}\" is not executable."
155 }
156
157 initdefaults()
158 {
159 makeenv=
160 makewrapper=
161 makewrappermachine=
162 runcmd=
163 operations=
164 removedirs=
165
166 [ -d usr.bin/make ] || cd "$(dirname $0)"
167 [ -d usr.bin/make ] ||
168 bomb "build.sh must be run from the top source level"
169 [ -f share/mk/bsd.own.mk ] ||
170 bomb "src/share/mk is missing; please re-fetch the source tree"
171
172 # Find information about the build platform. Note that "uname -p"
173 # is not part of POSIX, but NetBSD's uname -p prints MACHINE_ARCH,
174 # while uname -m prints MACHINE.
175 #
176 uname_s=$(uname -s 2>/dev/null)
177 uname_r=$(uname -r 2>/dev/null)
178 uname_m=$(uname -m 2>/dev/null)
179 uname_p=$(uname -p 2>/dev/null || uname -m 2>/dev/null)
180
181 # If $PWD is a valid name of the current directory, POSIX mandates
182 # that pwd return it by default which causes problems in the
183 # presence of symlinks. Unsetting PWD is simpler than changing
184 # every occurrence of pwd to use -P.
185 #
186 # XXX Except that doesn't work on Solaris. Or many Linuces.
187 #
188 unset PWD
189 TOP=$(/bin/pwd -P 2>/dev/null || /bin/pwd 2>/dev/null)
190
191 # The user can set HOST_SH in the environment, or we try to
192 # guess an appropriate value. Then we set several other
193 # variables from HOST_SH.
194 #
195 set_HOST_SH
196 setmakeenv HOST_SH "${HOST_SH}"
197 setmakeenv BSHELL "${HOST_SH}"
198 setmakeenv CONFIG_SHELL "${HOST_SH}"
199
200 # Set defaults.
201 #
202 toolprefix=nb
203
204 # Some systems have a small ARG_MAX. -X prevents make(1) from
205 # exporting variables in the environment redundantly.
206 #
207 case "${uname_s}" in
208 Darwin | FreeBSD | CYGWIN*)
209 MAKEFLAGS=-X
210 ;;
211 *)
212 MAKEFLAGS=
213 ;;
214 esac
215
216 # do_{operation}=true if given operation is requested.
217 #
218 do_expertmode=false
219 do_rebuildmake=false
220 do_removedirs=false
221 do_tools=false
222 do_obj=false
223 do_build=false
224 do_distribution=false
225 do_release=false
226 do_kernel=false
227 do_releasekernel=false
228 do_install=false
229 do_sets=false
230 do_sourcesets=false
231 do_syspkgs=false
232 do_iso_image=false
233 do_params=false
234
235 # Create scratch directory
236 #
237 tmpdir="${TMPDIR-/tmp}/nbbuild$$"
238 mkdir "${tmpdir}" || bomb "Cannot mkdir: ${tmpdir}"
239 trap "cd /; rm -r -f \"${tmpdir}\"" 0
240 results="${tmpdir}/build.sh.results"
241
242 # Set source directories
243 #
244 setmakeenv NETBSDSRCDIR "${TOP}"
245
246 # Find the version of NetBSD
247 #
248 DISTRIBVER="$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh)"
249
250 # Set various environment variables to known defaults,
251 # to minimize (cross-)build problems observed "in the field".
252 #
253 unsetmakeenv INFODIR
254 unsetmakeenv LESSCHARSET
255 setmakeenv LC_ALL C
256 }
257
258 getarch()
259 {
260 # Translate some MACHINE name aliases (known only to build.sh)
261 # into proper MACHINE and MACHINE_ARCH names. Save the alias
262 # name in makewrappermachine.
263 #
264 case "${MACHINE}" in
265
266 evbarm-e[bl])
267 makewrappermachine=${MACHINE}
268 # MACHINE_ARCH is "arm" or "armeb", not "armel"
269 MACHINE_ARCH=arm${MACHINE##*-}
270 MACHINE_ARCH=${MACHINE_ARCH%el}
271 MACHINE=${MACHINE%-e[bl]}
272 ;;
273
274 evbmips-e[bl]|sbmips-e[bl])
275 makewrappermachine=${MACHINE}
276 MACHINE_ARCH=mips${MACHINE##*-}
277 MACHINE=${MACHINE%-e[bl]}
278 ;;
279
280 evbmips64-e[bl]|sbmips64-e[bl])
281 makewrappermachine=${MACHINE}
282 MACHINE_ARCH=mips64${MACHINE##*-}
283 MACHINE=${MACHINE%64-e[bl]}
284 ;;
285
286 evbsh3-e[bl])
287 makewrappermachine=${MACHINE}
288 MACHINE_ARCH=sh3${MACHINE##*-}
289 MACHINE=${MACHINE%-e[bl]}
290 ;;
291
292 esac
293
294 # Translate a MACHINE into a default MACHINE_ARCH.
295 #
296 case "${MACHINE}" in
297
298 acorn26|acorn32|cats|hpcarm|iyonix|netwinder|shark|zaurus)
299 MACHINE_ARCH=arm
300 ;;
301
302 evbarm) # unspecified MACHINE_ARCH gets LE
303 MACHINE_ARCH=${MACHINE_ARCH:=arm}
304 ;;
305
306 hp700)
307 MACHINE_ARCH=hppa
308 ;;
309
310 sun2)
311 MACHINE_ARCH=m68000
312 ;;
313
314 amiga|atari|cesfic|hp300|luna68k|mac68k|mvme68k|news68k|next68k|sun3|x68k)
315 MACHINE_ARCH=m68k
316 ;;
317
318 evbmips|sbmips) # no default MACHINE_ARCH
319 ;;
320
321 ews4800mips|mipsco|newsmips|sgimips)
322 MACHINE_ARCH=mipseb
323 ;;
324
325 algor|arc|cobalt|hpcmips|playstation2|pmax)
326 MACHINE_ARCH=mipsel
327 ;;
328
329 pc532)
330 MACHINE_ARCH=ns32k
331 ;;
332
333 evbppc64|macppc64)
334 makewrappermachine=${MACHINE}
335 MACHINE=${MACHINE%64}
336 MACHINE_ARCH=powerpc64
337 ;;
338
339 amigappc|bebox|evbppc|ibmnws|macppc|mvmeppc|ofppc|pmppc|prep|sandpoint)
340 MACHINE_ARCH=powerpc
341 ;;
342
343 evbsh3) # no default MACHINE_ARCH
344 ;;
345
346 mmeye)
347 MACHINE_ARCH=sh3eb
348 ;;
349
350 dreamcast|hpcsh|landisk)
351 MACHINE_ARCH=sh3el
352 ;;
353
354 amd64)
355 MACHINE_ARCH=x86_64
356 ;;
357
358 alpha|i386|sparc|sparc64|vax|ia64)
359 MACHINE_ARCH=${MACHINE}
360 ;;
361
362 *)
363 bomb "Unknown target MACHINE: ${MACHINE}"
364 ;;
365
366 esac
367 }
368
369 validatearch()
370 {
371 # Ensure that the MACHINE_ARCH exists (and is supported by build.sh).
372 #
373 case "${MACHINE_ARCH}" in
374
375 alpha|arm|armeb|hppa|i386|m68000|m68k|mipse[bl]|mips64e[bl]|ns32k|powerpc|powerpc64|sh[35]e[bl]|sparc|sparc64|vax|x86_64|ia64)
376 ;;
377
378 "")
379 bomb "No MACHINE_ARCH provided"
380 ;;
381
382 *)
383 bomb "Unknown target MACHINE_ARCH: ${MACHINE_ARCH}"
384 ;;
385
386 esac
387
388 # Determine valid MACHINE_ARCHs for MACHINE
389 #
390 case "${MACHINE}" in
391
392 evbarm)
393 arches="arm armeb"
394 ;;
395
396 evbmips|sbmips)
397 arches="mipseb mipsel mips64eb mips64el"
398 ;;
399
400 sgimips)
401 arches="mipseb mips64eb"
402 ;;
403
404 evbsh3)
405 arches="sh3eb sh3el"
406 ;;
407
408 macppc|evbppc)
409 arches="powerpc powerpc64"
410 ;;
411 *)
412 oma="${MACHINE_ARCH}"
413 getarch
414 arches="${MACHINE_ARCH}"
415 MACHINE_ARCH="${oma}"
416 ;;
417
418 esac
419
420 # Ensure that MACHINE_ARCH supports MACHINE
421 #
422 archok=false
423 for a in ${arches}; do
424 if [ "${a}" = "${MACHINE_ARCH}" ]; then
425 archok=true
426 break
427 fi
428 done
429 ${archok} ||
430 bomb "MACHINE_ARCH '${MACHINE_ARCH}' does not support MACHINE '${MACHINE}'"
431 }
432
433 nobomb_getmakevar()
434 {
435 [ -x "${make}" ] || return 1
436 "${make}" -m ${TOP}/share/mk -s -B -f- _x_ <<EOF || return 1
437 _x_:
438 echo \${$1}
439 .include <bsd.prog.mk>
440 .include <bsd.kernobj.mk>
441 EOF
442 }
443
444 raw_getmakevar()
445 {
446 [ -x "${make}" ] || bomb "raw_getmakevar $1: ${make} is not executable"
447 nobomb_getmakevar "$1" || bomb "raw_getmakevar $1: ${make} failed"
448 }
449
450 getmakevar()
451 {
452 # raw_getmakevar() doesn't work properly if $make hasn't yet been
453 # built, which can happen when running with the "-n" option.
454 # getmakevar() deals with this by emitting a literal '$'
455 # followed by the variable name, instead of trying to find the
456 # variable's value.
457 #
458 if [ -x "${make}" ]; then
459 raw_getmakevar "$1"
460 else
461 echo "\$$1"
462 fi
463 }
464
465 setmakeenv()
466 {
467 eval "$1='$2'; export $1"
468 makeenv="${makeenv} $1"
469 }
470
471 unsetmakeenv()
472 {
473 eval "unset $1"
474 makeenv="${makeenv} $1"
475 }
476
477 # Convert possibly-relative path to absolute path by prepending
478 # ${TOP} if necessary. Also delete trailing "/", if any.
479 resolvepath()
480 {
481 case "${OPTARG}" in
482 /)
483 ;;
484 /*)
485 OPTARG="${OPTARG%/}"
486 ;;
487 *)
488 OPTARG="${TOP}/${OPTARG%/}"
489 ;;
490 esac
491 }
492
493 usage()
494 {
495 if [ -n "$*" ]; then
496 echo ""
497 echo "${progname}: $*"
498 fi
499 cat <<_usage_
500
501 Usage: ${progname} [-EnorUux] [-a arch] [-B buildid] [-D dest] [-j njob]
502 [-M obj] [-m mach] [-N noisy] [-O obj] [-R release] [-T tools]
503 [-V var=[value]] [-w wrapper] [-X x11src] [-Z var]
504 operation [...]
505
506 Build operations (all imply "obj" and "tools"):
507 build Run "make build".
508 distribution Run "make distribution" (includes DESTDIR/etc/ files).
509 release Run "make release" (includes kernels & distrib media).
510
511 Other operations:
512 help Show this message and exit.
513 makewrapper Create ${toolprefix}make-\${MACHINE} wrapper and ${toolprefix}make.
514 Always performed.
515 obj Run "make obj". [Default unless -o is used]
516 tools Build and install tools.
517 install=idir Run "make installworld" to \`idir' to install all sets
518 except \`etc'. Useful after "distribution" or "release"
519 kernel=conf Build kernel with config file \`conf'
520 releasekernel=conf Install kernel built by kernel=conf to RELEASEDIR.
521 sets Create binary sets in RELEASEDIR/MACHINE/binary/sets.
522 DESTDIR should be populated beforehand.
523 sourcesets Create source sets in RELEASEDIR/source/sets.
524 syspkgs Create syspkgs in RELEASEDIR/MACHINE/binary/syspkgs.
525 iso-image Create CD-ROM image in RELEASEDIR/MACHINE/installation.
526 params Display various make(1) parameters.
527
528 Options:
529 -a arch Set MACHINE_ARCH to arch. [Default: deduced from MACHINE]
530 -B buildId Set BUILDID to buildId.
531 -D dest Set DESTDIR to dest. [Default: destdir.MACHINE]
532 -E Set "expert" mode; disables various safety checks.
533 Should not be used without expert knowledge of the build system.
534 -h Print this help message.
535 -j njob Run up to njob jobs in parallel; see make(1) -j.
536 -M obj Set obj root directory to obj; sets MAKEOBJDIRPREFIX.
537 Unsets MAKEOBJDIR.
538 -m mach Set MACHINE to mach; not required if NetBSD native.
539 -N noisy Set the noisyness (MAKEVERBOSE) level of the build:
540 0 Quiet
541 1 Operations are described, commands are suppressed
542 2 Full output
543 [Default: 2]
544 -n Show commands that would be executed, but do not execute them.
545 -O obj Set obj root directory to obj; sets a MAKEOBJDIR pattern.
546 Unsets MAKEOBJDIRPREFIX.
547 -o Set MKOBJDIRS=no; do not create objdirs at start of build.
548 -R release Set RELEASEDIR to release. [Default: releasedir]
549 -r Remove contents of TOOLDIR and DESTDIR before building.
550 -T tools Set TOOLDIR to tools. If unset, and TOOLDIR is not set in
551 the environment, ${toolprefix}make will be (re)built unconditionally.
552 -U Set MKUNPRIVED=yes; build without requiring root privileges,
553 install from an UNPRIVED build with proper file permissions.
554 -u Set MKUPDATE=yes; do not run "make clean" first.
555 Without this, everything is rebuilt, including the tools.
556 -V v=[val] Set variable \`v' to \`val'.
557 -w wrapper Create ${toolprefix}make script as wrapper.
558 [Default: \${TOOLDIR}/bin/${toolprefix}make-\${MACHINE}]
559 -X x11src Set X11SRCDIR to x11src. [Default: /usr/xsrc]
560 -x Set MKX11=yes; build X11R6 from X11SRCDIR
561 -Z v Unset ("zap") variable \`v'.
562
563 _usage_
564 exit 1
565 }
566
567 parseoptions()
568 {
569 opts='a:B:bD:dEhi:j:k:M:m:N:nO:oR:rT:tUuV:w:xX:Z:'
570 opt_a=no
571
572 if type getopts >/dev/null 2>&1; then
573 # Use POSIX getopts.
574 #
575 getoptcmd='getopts ${opts} opt && opt=-${opt}'
576 optargcmd=':'
577 optremcmd='shift $((${OPTIND} -1))'
578 else
579 type getopt >/dev/null 2>&1 ||
580 bomb "/bin/sh shell is too old; try ksh or bash"
581
582 # Use old-style getopt(1) (doesn't handle whitespace in args).
583 #
584 args="$(getopt ${opts} $*)"
585 [ $? = 0 ] || usage
586 set -- ${args}
587
588 getoptcmd='[ $# -gt 0 ] && opt="$1" && shift'
589 optargcmd='OPTARG="$1"; shift'
590 optremcmd=':'
591 fi
592
593 # Parse command line options.
594 #
595 while eval ${getoptcmd}; do
596 case ${opt} in
597
598 -a)
599 eval ${optargcmd}
600 MACHINE_ARCH=${OPTARG}
601 opt_a=yes
602 ;;
603
604 -B)
605 eval ${optargcmd}
606 BUILDID=${OPTARG}
607 ;;
608
609 -b)
610 usage "'-b' has been replaced by 'makewrapper'"
611 ;;
612
613 -D)
614 eval ${optargcmd}; resolvepath
615 setmakeenv DESTDIR "${OPTARG}"
616 ;;
617
618 -d)
619 usage "'-d' has been replaced by 'distribution'"
620 ;;
621
622 -E)
623 do_expertmode=true
624 ;;
625
626 -i)
627 usage "'-i idir' has been replaced by 'install=idir'"
628 ;;
629
630 -j)
631 eval ${optargcmd}
632 parallel="-j ${OPTARG}"
633 ;;
634
635 -k)
636 usage "'-k conf' has been replaced by 'kernel=conf'"
637 ;;
638
639 -M)
640 eval ${optargcmd}; resolvepath
641 makeobjdir="${OPTARG}"
642 unsetmakeenv MAKEOBJDIR
643 setmakeenv MAKEOBJDIRPREFIX "${OPTARG}"
644 ;;
645
646 # -m overrides MACHINE_ARCH unless "-a" is specified
647 -m)
648 eval ${optargcmd}
649 MACHINE="${OPTARG}"
650 [ "${opt_a}" != "yes" ] && getarch
651 ;;
652
653 -N)
654 eval ${optargcmd}
655 case "${OPTARG}" in
656 0|1|2)
657 setmakeenv MAKEVERBOSE "${OPTARG}"
658 ;;
659 *)
660 usage "'${OPTARG}' is not a valid value for -N"
661 ;;
662 esac
663 ;;
664
665 -n)
666 runcmd=echo
667 ;;
668
669 -O)
670 eval ${optargcmd}; resolvepath
671 makeobjdir="${OPTARG}"
672 unsetmakeenv MAKEOBJDIRPREFIX
673 setmakeenv MAKEOBJDIR "\${.CURDIR:C,^$TOP,$OPTARG,}"
674 ;;
675
676 -o)
677 MKOBJDIRS=no
678 ;;
679
680 -R)
681 eval ${optargcmd}; resolvepath
682 setmakeenv RELEASEDIR "${OPTARG}"
683 ;;
684
685 -r)
686 do_removedirs=true
687 do_rebuildmake=true
688 ;;
689
690 -T)
691 eval ${optargcmd}; resolvepath
692 TOOLDIR="${OPTARG}"
693 export TOOLDIR
694 ;;
695
696 -t)
697 usage "'-t' has been replaced by 'tools'"
698 ;;
699
700 -U)
701 setmakeenv MKUNPRIVED yes
702 ;;
703
704 -u)
705 setmakeenv MKUPDATE yes
706 ;;
707
708 -V)
709 eval ${optargcmd}
710 case "${OPTARG}" in
711 # XXX: consider restricting which variables can be changed?
712 [a-zA-Z_][a-zA-Z_0-9]*=*)
713 setmakeenv "${OPTARG%%=*}" "${OPTARG#*=}"
714 ;;
715 *)
716 usage "-V argument must be of the form 'var=[value]'"
717 ;;
718 esac
719 ;;
720
721 -w)
722 eval ${optargcmd}; resolvepath
723 makewrapper="${OPTARG}"
724 ;;
725
726 -X)
727 eval ${optargcmd}; resolvepath
728 setmakeenv X11SRCDIR "${OPTARG}"
729 ;;
730
731 -x)
732 setmakeenv MKX11 yes
733 ;;
734
735 -Z)
736 eval ${optargcmd}
737 # XXX: consider restricting which variables can be unset?
738 unsetmakeenv "${OPTARG}"
739 ;;
740
741 --)
742 break
743 ;;
744
745 -'?'|-h)
746 usage
747 ;;
748
749 esac
750 done
751
752 # Validate operations.
753 #
754 eval ${optremcmd}
755 while [ $# -gt 0 ]; do
756 op=$1; shift
757 operations="${operations} ${op}"
758
759 case "${op}" in
760
761 help)
762 usage
763 ;;
764
765 makewrapper|obj|tools|build|distribution|release|sets|sourcesets|syspkgs|params)
766 ;;
767
768 iso-image)
769 op=iso_image # used as part of a variable name
770 ;;
771
772 kernel=*|releasekernel=*)
773 arg=${op#*=}
774 op=${op%%=*}
775 [ -n "${arg}" ] ||
776 bomb "Must supply a kernel name with \`${op}=...'"
777 ;;
778
779 install=*)
780 arg=${op#*=}
781 op=${op%%=*}
782 [ -n "${arg}" ] ||
783 bomb "Must supply a directory with \`install=...'"
784 ;;
785
786 *)
787 usage "Unknown operation \`${op}'"
788 ;;
789
790 esac
791 eval do_${op}=true
792 done
793 [ -n "${operations}" ] || usage "Missing operation to perform."
794
795 # Set up MACHINE*. On a NetBSD host, these are allowed to be unset.
796 #
797 if [ -z "${MACHINE}" ]; then
798 [ "${uname_s}" = "NetBSD" ] ||
799 bomb "MACHINE must be set, or -m must be used, for cross builds."
800 MACHINE=${uname_m}
801 fi
802 [ -n "${MACHINE_ARCH}" ] || getarch
803 validatearch
804
805 # Set up default make(1) environment.
806 #
807 makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS"
808 [ -z "${BUILDID}" ] || makeenv="${makeenv} BUILDID"
809 MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS} MKOBJDIRS=${MKOBJDIRS-yes}"
810 export MAKEFLAGS MACHINE MACHINE_ARCH
811 }
812
813 sanitycheck()
814 {
815 # If the PATH contains any non-absolute components (including,
816 # but not limited to, "." or ""), then complain. As an exception,
817 # allow "" or "." as the last component of the PATH. This is fatal
818 # if expert mode is not in effect.
819 #
820 local path="${PATH}"
821 path="${path%:}" # delete trailing ":"
822 path="${path%:.}" # delete trailing ":."
823 case ":${path}:/" in
824 *:[!/]*)
825 if ${do_expertmode}; then
826 warning "PATH contains non-absolute components"
827 else
828 bomb "PATH environment variable must not" \
829 "contain non-absolute components"
830 fi
831 ;;
832 esac
833 }
834
835 # Try to set a value for TOOLDIR. This is difficult because of a cyclic
836 # dependency: TOOLDIR may be affected by settings in /etc/mk.conf, so
837 # we would like to use getmakevar to get the value of TOOLDIR, but we
838 # can't use getmakevar before we have an up to date version of nbmake;
839 # we might already have an up to date version of nbmake in TOOLDIR, but
840 # we don't yet know where TOOLDIR is.
841 #
842 # In principle, we could break the cycle by building a copy of nbmake
843 # in a temporary directory. However, people who use the default value
844 # of TOOLDIR do not like to have nbmake rebuilt every time they run
845 # build.sh.
846 #
847 # We try to please everybody as follows:
848 #
849 # * If TOOLDIR was set in the environment or on the command line, use
850 # that value.
851 # * Otherwise try to guess what TOOLDIR would be if not overridden by
852 # /etc/mk.conf, and check whether the resulting directory contains
853 # a copy of ${toolprefix}make (this should work for everybody who
854 # doesn't override TOOLDIR via /etc/mk.conf);
855 # * Failing that, search for ${toolprefix}make, nbmake, bmake, or make,
856 # in the PATH (this might accidentally find a non-NetBSD version of
857 # make, which will lead to failure in the next step);
858 # * If a copy of make was found above, try to use it with
859 # nobomb_getmakevar to find the correct value for TOOLDIR;
860 # * If all else fails, leave TOOLDIR unset. Our caller is expected to
861 # be able to cope with this.
862 #
863 try_set_TOOLDIR()
864 {
865 [ -n "${TOOLDIR}" ] && return
866
867 # Set guess_TOOLDIR, in the same way that <bsd.own.mk> would set
868 # TOOLDIR if /etc/mk.conf sisn't interfere.
869 local topobjdir="${TOP}"
870 [ -n "${makeobjdir}" ] && topobjdir="${topobjdir}/${makeobjdir}"
871 local host_ostype="${uname_s}-$(
872 echo "${uname_r}" | sed -e 's/([^)]*)//g' -e 's/ /_/g'
873 )$(
874 echo "${uname_p}" | sed -e 's/([^)]*)//g' -e 's/ /_/g'
875 )"
876 local guess_TOOLDIR="${topobjdir}/tooldir.${host_ostype}"
877
878 # Look for a suitable ${toolprefix}make, nbmake, bmake, or make.
879 guess_make="${guess_TOOLDIR}/bin/${toolprefix}make"
880 [ -x "${guess_make}" ] || guess_make=""
881 : ${guess_make:=$(find_in_PATH ${toolprefix}make '')}
882 : ${guess_make:=$(find_in_PATH nbmake '')}
883 : ${guess_make:=$(find_in_PATH bmake '')}
884 : ${guess_make:=$(find_in_PATH make '')}
885
886 # Use ${guess_make} with nobomb_getmakevar
887 if [ -x "${guess_make}" ]; then
888 TOOLDIR=$(make="${guess_make}" nobomb_getmakevar TOOLDIR)
889 [ -n "${TOOLDIR}" ] || unset TOOLDIR
890 fi
891 }
892
893 rebuildmake()
894 {
895 # Test make source file timestamps against installed ${toolprefix}make
896 # binary, if TOOLDIR is pre-set or if try_set_TOOLDIR can set it.
897 #
898 try_set_TOOLDIR
899 make="${TOOLDIR-nonexistent}/bin/${toolprefix}make"
900 if [ -x "${make}" ]; then
901 for f in usr.bin/make/*.[ch] usr.bin/make/lst.lib/*.[ch]; do
902 if [ "${f}" -nt "${make}" ]; then
903 statusmsg "${make} outdated (older than ${f}), needs building."
904 do_rebuildmake=true
905 break
906 fi
907 done
908 else
909 statusmsg "No ${make}, needs building."
910 do_rebuildmake=true
911 fi
912
913 # Build bootstrap ${toolprefix}make if needed.
914 if ${do_rebuildmake}; then
915 statusmsg "Bootstrapping ${toolprefix}make"
916 ${runcmd} cd "${tmpdir}"
917 ${runcmd} env CC="${HOST_CC-cc}" CPPFLAGS="${HOST_CPPFLAGS}" \
918 CFLAGS="${HOST_CFLAGS--O}" LDFLAGS="${HOST_LDFLAGS}" \
919 ${HOST_SH} "${TOP}/tools/make/configure" ||
920 bomb "Configure of ${toolprefix}make failed"
921 ${runcmd} ${HOST_SH} buildmake.sh ||
922 bomb "Build of ${toolprefix}make failed"
923 make="${tmpdir}/${toolprefix}make"
924 ${runcmd} cd "${TOP}"
925 ${runcmd} rm -f usr.bin/make/*.o usr.bin/make/lst.lib/*.o
926 fi
927 }
928
929 validatemakeparams()
930 {
931 if [ "${runcmd}" = "echo" ]; then
932 TOOLCHAIN_MISSING=no
933 EXTERNAL_TOOLCHAIN=""
934 else
935 TOOLCHAIN_MISSING=$(raw_getmakevar TOOLCHAIN_MISSING)
936 EXTERNAL_TOOLCHAIN=$(raw_getmakevar EXTERNAL_TOOLCHAIN)
937 fi
938 if [ "${TOOLCHAIN_MISSING}" = "yes" ] && \
939 [ -z "${EXTERNAL_TOOLCHAIN}" ]; then
940 ${runcmd} echo "ERROR: build.sh (in-tree cross-toolchain) is not yet available for"
941 ${runcmd} echo " MACHINE: ${MACHINE}"
942 ${runcmd} echo " MACHINE_ARCH: ${MACHINE_ARCH}"
943 ${runcmd} echo ""
944 ${runcmd} echo "All builds for this platform should be done via a traditional make"
945 ${runcmd} echo "If you wish to use an external cross-toolchain, set"
946 ${runcmd} echo " EXTERNAL_TOOLCHAIN=<path to toolchain root>"
947 ${runcmd} echo "in either the environment or mk.conf and rerun"
948 ${runcmd} echo " ${progname} $*"
949 exit 1
950 fi
951
952 # Normalise MKOBJDIRS, MKUNPRIVED, and MKUPDATE
953 # These may be set as build.sh options or in "mk.conf".
954 # Don't export them as they're only used for tests in build.sh.
955 #
956 MKOBJDIRS=$(getmakevar MKOBJDIRS)
957 MKUNPRIVED=$(getmakevar MKUNPRIVED)
958 MKUPDATE=$(getmakevar MKUPDATE)
959
960 if [ "${MKOBJDIRS}" != "no" ]; then
961 # If setting -M or -O to the root of an obj dir, make sure
962 # the base directory is made before continuing as <bsd.own.mk>
963 # will need this to pick up _SRC_TOP_OBJ_
964 #
965 if [ ! -z "${makeobjdir}" ]; then
966 ${runcmd} mkdir -p "${makeobjdir}"
967 fi
968
969 # make obj in tools to ensure that the objdir for the top-level
970 # of the source tree and for "tools" is available, in case the
971 # default TOOLDIR setting from <bsd.own.mk> is used, or the
972 # build.sh default DESTDIR and RELEASEDIR is to be used.
973 #
974 ${runcmd} cd tools
975 ${runcmd} "${make}" -m ${TOP}/share/mk obj NOSUBDIR= ||
976 bomb "Failed to make obj in tools"
977 ${runcmd} cd "${TOP}"
978 fi
979
980 # Find TOOLDIR, DESTDIR, and RELEASEDIR.
981 #
982 TOOLDIR=$(getmakevar TOOLDIR)
983 statusmsg "TOOLDIR path: ${TOOLDIR}"
984 DESTDIR=$(getmakevar DESTDIR)
985 RELEASEDIR=$(getmakevar RELEASEDIR)
986 if ! $do_expertmode; then
987 _SRC_TOP_OBJ_=$(getmakevar _SRC_TOP_OBJ_)
988 : ${DESTDIR:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}}
989 : ${RELEASEDIR:=${_SRC_TOP_OBJ_}/releasedir}
990 makeenv="${makeenv} DESTDIR RELEASEDIR"
991 fi
992 export TOOLDIR DESTDIR RELEASEDIR
993 statusmsg "DESTDIR path: ${DESTDIR}"
994 statusmsg "RELEASEDIR path: ${RELEASEDIR}"
995
996 # Check validity of TOOLDIR and DESTDIR.
997 #
998 if [ -z "${TOOLDIR}" ] || [ "${TOOLDIR}" = "/" ]; then
999 bomb "TOOLDIR '${TOOLDIR}' invalid"
1000 fi
1001 removedirs="${TOOLDIR}"
1002
1003 if [ -z "${DESTDIR}" ] || [ "${DESTDIR}" = "/" ]; then
1004 if ${do_build} || ${do_distribution} || ${do_release}; then
1005 if ! ${do_build} || \
1006 [ "${uname_s}" != "NetBSD" ] || \
1007 [ "${uname_m}" != "${MACHINE}" ]; then
1008 bomb "DESTDIR must != / for cross builds, or ${progname} 'distribution' or 'release'."
1009 fi
1010 if ! ${do_expertmode}; then
1011 bomb "DESTDIR must != / for non -E (expert) builds"
1012 fi
1013 statusmsg "WARNING: Building to /, in expert mode."
1014 statusmsg " This may cause your system to break! Reasons include:"
1015 statusmsg " - your kernel is not up to date"
1016 statusmsg " - the libraries or toolchain have changed"
1017 statusmsg " YOU HAVE BEEN WARNED!"
1018 fi
1019 else
1020 removedirs="${removedirs} ${DESTDIR}"
1021 fi
1022 if ${do_build} || ${do_distribution} || ${do_release}; then
1023 if ! ${do_expertmode} && \
1024 [ "$(id -u 2>/dev/null)" -ne 0 ] && \
1025 [ "${MKUNPRIVED}" = "no" ] ; then
1026 bomb "-U or -E must be set for build as an unprivileged user."
1027 fi
1028 fi
1029 if ${do_releasekernel} && [ -z "${RELEASEDIR}" ]; then
1030 bomb "Must set RELEASEDIR with \`releasekernel=...'"
1031 fi
1032 }
1033
1034
1035 createmakewrapper()
1036 {
1037 # Remove the target directories.
1038 #
1039 if ${do_removedirs}; then
1040 for f in ${removedirs}; do
1041 statusmsg "Removing ${f}"
1042 ${runcmd} rm -r -f "${f}"
1043 done
1044 fi
1045
1046 # Recreate $TOOLDIR.
1047 #
1048 ${runcmd} mkdir -p "${TOOLDIR}/bin" ||
1049 bomb "mkdir of '${TOOLDIR}/bin' failed"
1050
1051 # Install ${toolprefix}make if it was built.
1052 #
1053 if ${do_rebuildmake}; then
1054 ${runcmd} rm -f "${TOOLDIR}/bin/${toolprefix}make"
1055 ${runcmd} cp "${make}" "${TOOLDIR}/bin/${toolprefix}make" ||
1056 bomb "Failed to install \$TOOLDIR/bin/${toolprefix}make"
1057 make="${TOOLDIR}/bin/${toolprefix}make"
1058 statusmsg "Created ${make}"
1059 fi
1060
1061 # Build a ${toolprefix}make wrapper script, usable by hand as
1062 # well as by build.sh.
1063 #
1064 if [ -z "${makewrapper}" ]; then
1065 makewrapper="${TOOLDIR}/bin/${toolprefix}make-${makewrappermachine:-${MACHINE}}"
1066 [ -z "${BUILDID}" ] || makewrapper="${makewrapper}-${BUILDID}"
1067 fi
1068
1069 ${runcmd} rm -f "${makewrapper}"
1070 if [ "${runcmd}" = "echo" ]; then
1071 echo 'cat <<EOF >'${makewrapper}
1072 makewrapout=
1073 else
1074 makewrapout=">>\${makewrapper}"
1075 fi
1076
1077 case "${KSH_VERSION:-${SH_VERSION}}" in
1078 *PD\ KSH*|*MIRBSD\ KSH*)
1079 set +o braceexpand
1080 ;;
1081 esac
1082
1083 eval cat <<EOF ${makewrapout}
1084 #! ${HOST_SH}
1085 # Set proper variables to allow easy "make" building of a NetBSD subtree.
1086 # Generated from: \$NetBSD: build.sh,v 1.171 2007/06/26 12:59:38 apb Exp $
1087 # with these arguments: ${_args}
1088 #
1089 EOF
1090 for f in ${makeenv}; do
1091 if eval "[ -z \"\${$f}\" -a \"\${${f}-X}\" = \"X\" ]"; then
1092 eval echo "unset ${f}" ${makewrapout}
1093 else
1094 eval echo "${f}=\'\$$(echo ${f})\'\;\ export\ ${f}" ${makewrapout}
1095 fi
1096 done
1097
1098 eval cat <<EOF ${makewrapout}
1099 MAKEWRAPPERMACHINE=${makewrappermachine:-${MACHINE}}; export MAKEWRAPPERMACHINE
1100 USETOOLS=yes; export USETOOLS
1101
1102 exec "\${TOOLDIR}/bin/${toolprefix}make" \${1+"\$@"}
1103 EOF
1104 [ "${runcmd}" = "echo" ] && echo EOF
1105 ${runcmd} chmod +x "${makewrapper}"
1106 statusmsg "makewrapper: ${makewrapper}"
1107 statusmsg "Updated ${makewrapper}"
1108 }
1109
1110 buildtools()
1111 {
1112 if [ "${MKOBJDIRS}" != "no" ]; then
1113 ${runcmd} "${makewrapper}" ${parallel} obj-tools ||
1114 bomb "Failed to make obj-tools"
1115 fi
1116 ${runcmd} cd tools
1117 if [ "${MKUPDATE}" = "no" ]; then
1118 ${runcmd} "${makewrapper}" ${parallel} cleandir ||
1119 bomb "Failed to make cleandir tools"
1120 fi
1121 ${runcmd} "${makewrapper}" ${parallel} dependall ||
1122 bomb "Failed to make dependall tools"
1123 ${runcmd} "${makewrapper}" ${parallel} install ||
1124 bomb "Failed to make install tools"
1125 statusmsg "Tools built to ${TOOLDIR}"
1126 ${runcmd} cd "${TOP}"
1127 }
1128
1129 getkernelconf()
1130 {
1131 kernelconf="$1"
1132 if [ "${MKOBJDIRS}" != "no" ]; then
1133 # The correct value of KERNOBJDIR might
1134 # depend on a prior "make obj" in
1135 # ${KERNSRCDIR}/${KERNARCHDIR}/compile.
1136 #
1137 KERNSRCDIR="$(getmakevar KERNSRCDIR)"
1138 KERNARCHDIR="$(getmakevar KERNARCHDIR)"
1139 ${runcmd} cd "${KERNSRCDIR}/${KERNARCHDIR}/compile"
1140 ${runcmd} "${makewrapper}" ${parallel} obj ||
1141 bomb "Failed to make obj in ${KERNSRCDIR}/${KERNARCHDIR}/compile"
1142 ${runcmd} cd "${TOP}"
1143 fi
1144 KERNCONFDIR="$(getmakevar KERNCONFDIR)"
1145 KERNOBJDIR="$(getmakevar KERNOBJDIR)"
1146 case "${kernelconf}" in
1147 */*)
1148 kernelconfpath="${kernelconf}"
1149 kernelconfname="${kernelconf##*/}"
1150 ;;
1151 *)
1152 kernelconfpath="${KERNCONFDIR}/${kernelconf}"
1153 kernelconfname="${kernelconf}"
1154 ;;
1155 esac
1156 kernelbuildpath="${KERNOBJDIR}/${kernelconfname}"
1157 }
1158
1159 buildkernel()
1160 {
1161 if ! ${do_tools} && ! ${buildkernelwarned:-false}; then
1162 # Building tools every time we build a kernel is clearly
1163 # unnecessary. We could try to figure out whether rebuilding
1164 # the tools is necessary this time, but it doesn't seem worth
1165 # the trouble. Instead, we say it's the user's responsibility
1166 # to rebuild the tools if necessary.
1167 #
1168 statusmsg "Building kernel without building new tools"
1169 buildkernelwarned=true
1170 fi
1171 getkernelconf $1
1172 statusmsg "Building kernel: ${kernelconf}"
1173 statusmsg "Build directory: ${kernelbuildpath}"
1174 ${runcmd} mkdir -p "${kernelbuildpath}" ||
1175 bomb "Cannot mkdir: ${kernelbuildpath}"
1176 if [ "${MKUPDATE}" = "no" ]; then
1177 ${runcmd} cd "${kernelbuildpath}"
1178 ${runcmd} "${makewrapper}" ${parallel} cleandir ||
1179 bomb "Failed to make cleandir in ${kernelbuildpath}"
1180 ${runcmd} cd "${TOP}"
1181 fi
1182 [ -x "${TOOLDIR}/bin/${toolprefix}config" ] \
1183 || bomb "${TOOLDIR}/bin/${toolprefix}config does not exist. You need to \"$0 tools\" first."
1184 ${runcmd} "${TOOLDIR}/bin/${toolprefix}config" -b "${kernelbuildpath}" \
1185 -s "${TOP}/sys" "${kernelconfpath}" ||
1186 bomb "${toolprefix}config failed for ${kernelconf}"
1187 ${runcmd} cd "${kernelbuildpath}"
1188 ${runcmd} "${makewrapper}" ${parallel} depend ||
1189 bomb "Failed to make depend in ${kernelbuildpath}"
1190 ${runcmd} "${makewrapper}" ${parallel} all ||
1191 bomb "Failed to make all in ${kernelbuildpath}"
1192 ${runcmd} cd "${TOP}"
1193
1194 if [ "${runcmd}" != "echo" ]; then
1195 statusmsg "Kernels built from ${kernelconf}:"
1196 kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
1197 for kern in ${kernlist:-netbsd}; do
1198 [ -f "${kernelbuildpath}/${kern}" ] && \
1199 echo " ${kernelbuildpath}/${kern}"
1200 done | tee -a "${results}"
1201 fi
1202 }
1203
1204 releasekernel()
1205 {
1206 getkernelconf $1
1207 kernelreldir="${RELEASEDIR}/${MACHINE}/binary/kernel"
1208 ${runcmd} mkdir -p "${kernelreldir}"
1209 kernlist=$(awk '$1 == "config" { print $2 }' ${kernelconfpath})
1210 for kern in ${kernlist:-netbsd}; do
1211 builtkern="${kernelbuildpath}/${kern}"
1212 [ -f "${builtkern}" ] || continue
1213 releasekern="${kernelreldir}/${kern}-${kernelconfname}.gz"
1214 statusmsg "Kernel copy: ${releasekern}"
1215 ${runcmd} gzip -c -9 < "${builtkern}" > "${releasekern}"
1216 done
1217 }
1218
1219 installworld()
1220 {
1221 dir="$1"
1222 ${runcmd} "${makewrapper}" INSTALLWORLDDIR="${dir}" installworld ||
1223 bomb "Failed to make installworld to ${dir}"
1224 statusmsg "Successful installworld to ${dir}"
1225 }
1226
1227
1228 main()
1229 {
1230 initdefaults
1231 _args=$@
1232 parseoptions "$@"
1233
1234 sanitycheck
1235
1236 build_start=$(date)
1237 statusmsg "${progname} command: $0 $@"
1238 statusmsg "${progname} started: ${build_start}"
1239 statusmsg "NetBSD version: ${DISTRIBVER}"
1240 statusmsg "MACHINE: ${MACHINE}"
1241 statusmsg "MACHINE_ARCH: ${MACHINE_ARCH}"
1242 statusmsg "Build platform: ${uname_s} ${uname_r} ${uname_m}"
1243 statusmsg "HOST_SH: ${HOST_SH}"
1244
1245 rebuildmake
1246 validatemakeparams
1247 createmakewrapper
1248
1249 # Perform the operations.
1250 #
1251 for op in ${operations}; do
1252 case "${op}" in
1253
1254 makewrapper)
1255 # no-op
1256 ;;
1257
1258 tools)
1259 buildtools
1260 ;;
1261
1262 sets)
1263 statusmsg "Building sets from pre-populated ${DESTDIR}"
1264 ${runcmd} "${makewrapper}" ${parallel} ${op} ||
1265 bomb "Failed to make ${op}"
1266 statusmsg "Successful make ${op}"
1267 ;;
1268
1269 obj|build|distribution|iso-image|release|sourcesets|syspkgs|params)
1270 ${runcmd} "${makewrapper}" ${parallel} ${op} ||
1271 bomb "Failed to make ${op}"
1272 statusmsg "Successful make ${op}"
1273 ;;
1274
1275 kernel=*)
1276 arg=${op#*=}
1277 buildkernel "${arg}"
1278 ;;
1279
1280 releasekernel=*)
1281 arg=${op#*=}
1282 releasekernel "${arg}"
1283 ;;
1284
1285 install=*)
1286 arg=${op#*=}
1287 if [ "${arg}" = "/" ] && \
1288 ( [ "${uname_s}" != "NetBSD" ] || \
1289 [ "${uname_m}" != "${MACHINE}" ] ); then
1290 bomb "'${op}' must != / for cross builds."
1291 fi
1292 installworld "${arg}"
1293 ;;
1294
1295 *)
1296 bomb "Unknown operation \`${op}'"
1297 ;;
1298
1299 esac
1300 done
1301
1302 statusmsg "${progname} ended: $(date)"
1303 if [ -s "${results}" ]; then
1304 echo "===> Summary of results:"
1305 sed -e 's/^===>//;s/^/ /' "${results}"
1306 echo "===> ."
1307 fi
1308 }
1309
1310 main "$@"
1311