3 # $NetBSD: bootstrap,v 1.156 2010/02/06 10:28:54 obache Exp $
6 # Copyright (c) 2001-2002 Alistair G. Crooks. All rights reserved.
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # 3. All advertising materials mentioning features or use of this software
17 # must display the following acknowledgement:
18 # This product includes software developed by Alistair G. Crooks
19 # for the NetBSD project.
20 # 4. The name of the author may not be used to endorse or promote
21 # products derived from this software without specific prior written
24 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
25 # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
28 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
30 # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 # the following environment variables are honored:
39 # compiler/linker flags: CFLAGS, CPPFLAGS, LDFLAGS, LIBS
40 # tools: CP, GREP, ID, MKDIR, SH, TEST, TOUCH, XARGS
43 BOOTSTRAP_VERSION=20060721
45 # Don't let the bootstrap program get confused by a pre-existing mk.conf
55 # where the building takes place
56 bootstrapdir=`dirname "$0"`
57 bootstrapdir=`cd "${bootstrapdir}" && pwd`
58 pkgsrcdir=`dirname "${bootstrapdir}"`
62 [ --workdir <workdir> ]
64 [ --pkgdbdir <pkgdbdir> ]
65 [ --pkgmandir <pkgmandir> ]
66 [ --sysconfdir <sysconfdir> ]
67 [ --varbase <varbase> ]
68 [ --fetch-cmd <ftp command> ]
69 [ --ignore-case-check ]
70 [ --unprivileged | --ignore-user-check ]
72 [ --compiler <compiler> ]
74 [ --mk-fragment <mk.conf> ]
75 [ --binary-kit <tarball> ]
76 [ --gzip-binary-kit <tarball> ]
77 [ --binary-macpkg <pkg> ]
82 # this replicates some of the logic in bsd.prefs.mk. until
83 # bootstrap-pkgsrc is merged into pkgsrc, we need to determine the
84 # right value for OPSYS and MACHINE_ARCH.
86 # strip / for BSD/OS, strip - for HP-UX
87 opsys=`uname -s | tr -d /-`
92 macdestdir=${wrkdir}/macpkg-destdir
93 rm -rf ${macdestdir} || die "cleanup destdir"
95 mkdir -p ${macdestdir}${prefix} || die "mkdir destprefix"
96 rmdir ${macdestdir}${prefix} || die "rmdir destprefix"
97 cp -Rp ${prefix} ${macdestdir}${prefix} || die "copy prefix"
99 if [ ! -d ${macdestdir}${pkgdbdir} ]; then
100 mkdir -p ${macdestdir}${pkgdbdir} || die "mkdir destdbdir"
101 rmdir ${macdestdir}${pkgdbdir} || die "rmdir destdbdir"
102 cp -Rp ${pkgdbdir} ${macdestdir}${pkgdbdir} || die "copy dbdir"
105 ${sedprog} -e "s|%WRKDIR%|${wrkdir}|g" \
106 -e "s|%TARGETDIR%|${targetdir}|g" -e "s|%DATE%|${date}|g" \
107 < macpkg.pmproj.in > ${wrkdir}/macpkg.pmproj
108 ${packagemaker} -build -proj ${wrkdir}/macpkg.pmproj -p "${binary_macpkg}"
113 # in case tar was built by bootstrap
114 PATH="$prefix/bin:$PATH"; export PATH
115 cd / && tar -hcf "${binary_kit}" .$prefix .$pkgdbdir .$etc_mk_conf
120 # in case tar was built by bootstrap
121 PATH="$prefix/bin:$PATH"; export PATH
122 cd / && tar -hzcf "${binary_gzip_kit}" .$prefix .$pkgdbdir .$etc_mk_conf
136 # see if we're using gcc. If so, set $compiler_is_gnu to '1'.
140 # normally, we'd just use 'cc', but certain configure tools look
141 # for gcc specifically, so we have to see if that comes first
142 if [ -z "${testcc}" ]; then
145 for dir in ${PATH}; do
146 test -z "$dir" && dir=.
147 if [ -x "$dir/gcc" ]; then
155 cat >${wrkdir}/$$.c <<EOF
160 compiler_is_gnu=`${testcc:-cc} -E ${wrkdir}/$$.c 2>/dev/null | grep -c indeed`
168 if [ -n "$abi" ]; then
169 die "ERROR: $abi_opsys has special ABI handling, --abi not supported (yet)."
174 if [ `uname -r` -ge 6 ]; then
175 abi=`sed -e 's/.*\(abi=\)\([on]*[36][24]\).*/\2/' /etc/compiler.defaults`
176 isa=`sed -e 's/.*\(isa=mips\)\([1234]\).*/\2/' /etc/compiler.defaults`
179 imakeopts="-DBuildO32 -DSgiISAo32=$isa"
182 n32) imakeopts="-DBuildN32 -DSgiISA32=$isa"
186 imakeopts="-DBuild64bit -DSgiISA64=$isa"
197 get_machine_arch_aix()
199 _cpuid=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
200 if /usr/sbin/lsattr -El $_cpuid | grep ' POWER' >/dev/null 2>&1; then
209 _var="$1"; _name="$2"
211 eval _tmp=\"\$$_var\"
212 if [ "x$_tmp" != "x" ]; then
213 # Variable is already set (by the user, for example)
217 for _d in `echo $PATH | tr ':' ' '`; do
218 if [ -f "$_d/$_name" ] && [ -x "$_d/$_name" ]; then
220 eval $_var=\""$_d/$_name"\"
225 die "$_name not found in path."
232 if [ ! -z "$imakeopts" ]; then
233 echo "IMAKEOPTS+= $imakeopts" >> ${TARGET_MKCONF}
235 if [ `uname -r` -lt 6 ]; then
236 echo_msg "Installing fake ldd script"
237 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/fakeldd $prefix/sbin"
239 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
244 echo "LDD= $prefix/sbin/fakeldd" >> ${TARGET_MKCONF}
251 if [ `uname -s` = "IRIX" ]; then
252 if [ `uname -r` -lt 6 -a -z "$ID" ]; then
253 # older version of IRIX have an id command with limited features
254 if [ "`$idprog`" != "uid=0(root) gid=0(sys)" ]; then
260 if [ `$idprog -u` != 0 ]; then
266 # run a command, abort if it fails
269 echo_msg "running: $@"
272 if [ $ret -ne 0 ]; then
273 echo_msg "exited with status $ret"
278 # Some versions of mkdir (notably SunOS) bail out too easily, so use the
279 # install-sh wrapper instead.
283 run_cmd "$install_sh -d -o $user -g $group $dir"
289 [ -d "$1" ] && return 0
290 mkdir -p "$1" 2> /dev/null && return 0
291 parent=`dirname "$1"`
292 mkdir_p_early "$parent"
293 if [ ! -d "$1" ] && mkdir "$1"; then
294 echo_msg "mkdir $1 exited with status $?"
303 if [ ! -d $wrkdir/$_dst ]; then
304 mkdir_p $wrkdir/$_dst
306 $cpprog -r $_src/* $wrkdir/$_dst
311 expr "x$1" : "x[^=]*=\\(.*\\)"
314 checkarg_sane_absolute_path() {
316 "") ;; # the default value will be used.
318 die "ERROR: Invalid characters in path $1 (from $2)." ;;
320 *) die "ERROR: The argument to $2 must be an absolute path." ;;
324 checkarg_sane_relative_path() {
326 "") ;; # the default value will be used.
328 die "ERROR: Invalid characters in path $1 (from $2)." ;;
329 /*) die "ERROR: The argument to $2 must be a relative path." ;;
334 bootstrap_sh=${SH-/bin/sh}
335 bootstrap_sh_set=${SH+set}
337 # On some newer Ubuntu installations, /bin/sh is a symlink to /bin/dash,
338 # whose echo(1) is not BSD-compatible.
339 dash_echo_test=`$bootstrap_sh -c 'echo "\\100"'`
340 if [ "$dash_echo_test" = "@" ]; then
341 { echo "ERROR: Your shell's echo command is not BSD-compatible."
342 echo "ERROR: Please select another shell by setting the environment"
343 echo "ERROR: variable SH."
348 if [ -n "$PKG_PATH" ]; then
349 echo "ERROR: Please unset PKG_PATH before running bootstrap." 1>&2
354 echo_msg "bootstrap command: $0 $@"
355 echo_msg "bootstrap started: $build_start"
357 # ensure system locations are empty; we will set them later when we know
358 # whether they will be system wide or user specific
370 while [ $# -gt 0 ]; do
372 --workdir=*) wrkdir=`get_optarg "$1"` ;;
373 --workdir) wrkdir="$2"; shift ;;
374 --prefix=*) prefix=`get_optarg "$1"` ;;
375 --prefix) prefix="$2"; shift ;;
376 --pkgdbdir=*) pkgdbdir=`get_optarg "$1"` ;;
377 --pkgdbdir) pkgdbdir="$2"; shift ;;
378 --pkgmandir=*) pkgmandir=`get_optarg "$1"` ;;
379 --pkgmandir) pkgmandir="$2"; shift ;;
380 --sysconfdir=*) sysconfdir=`get_optarg "$1"` ;;
381 --sysconfdir) sysconfdir="$2"; shift ;;
382 --varbase=*) varbase=`get_optarg "$1"` ;;
383 --varbase) varbase="$2"; shift ;;
384 --fetch-cmd=*) fetch_cmd=`get_optarg "$1"` ;;
385 --fetch-cmd) fetch_cmd="$2"; shift ;;
386 --compiler=*) compiler=`get_optarg "$1"` ;;
387 --compiler) compiler="$2"; shift ;;
388 --abi=*) abi=`get_optarg "$1"` ;;
389 --abi) abi="$2"; shift ;;
390 --ignore-case-check) ignorecasecheck=yes ;;
391 --unprivileged | --ignore-user-check) unprivileged=yes ;;
392 --preserve-path) preserve_path=yes ;;
394 mk_fragment=`get_optarg "$1"` ;;
396 mk_fragment="$2"; shift ;;
399 binary_kit=`get_optarg "$1"` ;;
401 binary_kit="$2"; shift ;;
403 binary_gzip_kit=`get_optarg "$1"` ;;
405 binary_gzip_kit="$2"; shift ;;
407 binary_macpkg=`get_optarg "$1"` ;;
409 binary_macpkg="$2"; shift ;;
411 --quiet) quiet=yes ;;
412 --help) echo "$usage"; exit ;;
413 -h) echo "$usage"; exit ;;
414 --*) echo "$usage"; exit 1 ;;
419 checkarg_sane_absolute_path "$wrkdir" "--workdir"
420 checkarg_sane_absolute_path "$prefix" "--prefix"
421 checkarg_sane_absolute_path "$pkgdbdir" "--pkgdbdir"
422 checkarg_sane_absolute_path "$sysconfdir" "--sysconfdir"
423 checkarg_sane_absolute_path "$varbase" "--varbase"
424 checkarg_sane_relative_path "$pkgmandir" "--pkgmandir"
426 # set defaults for system locations if not already set by the user
427 wrkobjdir=${wrkdir}/pkgsrc
428 if [ "$unprivileged" = "yes" ]; then
429 [ -z "$prefix" ] && prefix=${HOME}/pkg
430 elif [ -z "$prefix" -o "$prefix" = "/usr/pkg" ]; then
432 [ -z "$varbase" ] && varbase=/var
435 [ -z "$varbase" ] && varbase=${prefix}/var
436 [ -z "$pkgdbdir" ] && pkgdbdir=${varbase}/db/pkg
438 if [ "$prefix" = "/usr" ]; then
439 [ -z "$pkgmandir" ] && pkgmandir=share/man
441 [ -z "$pkgmandir" ] && pkgmandir=man
443 mandir=${prefix}/${pkgmandir}
444 [ -z "$sysconfdir" ] && sysconfdir=${prefix}/etc
446 if [ "x$preserve_path" != "xyes" ]; then
447 PATH="$PATH:/sbin:/usr/sbin"
463 machine_arch=`get_machine_arch_aix`
471 [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
472 machine_arch=`uname -p`
473 CC="gcc -isystem /usr/include"; export CC
475 macosx_version=`echo $osrev | awk -F . '{ print "10."$1-4; }'`
476 case "$macosx_version" in
478 packagemaker=/Developer/Tools/packagemaker
481 packagemaker=/Developer/usr/bin/packagemaker
484 unset osrev macosx_version
492 check_prog tarprog tar
493 machine_arch=`uname -p`
496 [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
498 1.0* | 1.1 | 1.2.* | 1.3.*)
501 [ -z "$fetch_cmd" ] && fetch_cmd="/usr/bin/ftp"
511 machine_arch=`uname -p`
528 machine_arch=`uname -p`
538 machine_arch=`uname -m | sed 's/^9000.*$/hppa/'`
542 if id -G | grep -q 131616; then
548 mkdir -p "$@" # allows umask to take effect
550 default_install_mode=0775
569 # only used for unprivileged builds
571 # for bootstrap only; pkgsrc uses CPPFLAGS
572 CC="gcc -D_ALL_SOURCE"; export CC
573 ac_cv_header_poll_h=no; export ac_cv_header_poll_h
574 ac_cv_func_poll=no; export ac_cv_func_poll
577 if [ -d "/usr/freeware/bin" ]; then
578 overpath="/usr/freeware/bin:$overpath"
580 if [ -d "/usr/bsd" ]; then
581 overpath="/usr/bsd:$overpath"
583 if [ -d "/usr/bsd/bin" ]; then
584 overpath="/usr/bsd/bin:$overpath"
594 bmakexargs="MACHINE_ARCH=$machine_arch"
595 bmakexenv="MAKE=pmake"
597 if [ `uname -r` -lt 6 ]; then
598 # IRIX 5's mkdir bails out with an error when trying to create with the -p
599 # option an already existing directory
604 if [ -f /etc/ssdlinux_version ]; then
613 machine_arch=`uname -m | sed -e 's/i.86/i386/'`
621 machine_arch=`uname -p`
629 machine_arch=`uname -m`
647 fetch_cmd="/usr/bin/ftp"
648 machine_arch=`uname -p | sed -e 's/x86/i386/'`
651 if [ -d "/usr/xpg4/bin" ]; then
652 overpath="/usr/xpg4/bin:$overpath"
660 groupsprog="/usr/xpg4/bin/id -gn"
661 whoamiprog="/usr/xpg4/bin/id -un"
662 machine_arch=`uname -p | sed -e 's/i86pc/i386/'`
668 BSTRAP_ENV="INSTALL=/usr/ucb/install $BSTRAP_ENV"
672 whoamiprog=/usr/ucb/whoami
674 CC="gcc -DUNIXWARE"; export CC
677 echo "This platform ($opsys) is untried - good luck, and thanks for using pkgsrc"
686 # If "--full" is specified, then install all of the platform-independent
687 # bootstrap software.
700 configure_quiet_flags="--quiet"
701 make_quiet_flags="-s"
704 configure_quiet_flags=""
708 # export OPSYS and MACHINE_ARCH for pkg_install. we only set
709 # MACHINE_ARCH on platforms where we override bmake's value.
712 if [ "${machine_arch}" != "" ]; then
713 MACHINE_ARCH=${machine_arch}
717 if [ "x$preserve_path" != "xyes" ]; then
718 PATH="$overpath:$PATH"
721 check_prog awkprog awk
722 check_prog chmodprog chmod
723 if [ -n "$CP" ]; then
728 if [ -n "$ID" ]; then
733 check_prog groupsprog groups
736 check_prog rmdirprog rmdir
737 check_prog sedprog sed
739 check_prog whoamiprog whoami
741 if [ -d "${wrkdir}" ] || [ -f "${wrkdir}" ]; then
742 echo "\"${wrkdir}\" already exists, please remove it or use --workdir.";
746 mkdir_p_early ${wrkdir}
747 if touch ${wrkdir}/.writeable; then
750 echo "\"${wrkdir}\" is not writeable. Try $0 -h.";
753 echo "Working directory is: ${wrkdir}"
755 if [ "$compiler" = "" ] && [ x"$check_compiler" = x"yes" ]; then
757 if [ $compiler_is_gnu -gt 0 ]; then
762 if [ `uname -r` -ge 6 ]; then
767 test -n "$CC" || CC=cc
769 SunOS) compiler="sunpro"
770 test -n "$CC" || CC=cc
776 mkdir_p_early ${wrkdir}/bin
779 run_cmd "$sedprog -e 's|@DEFAULT_INSTALL_MODE@|'${default_install_mode-0755}'|' $pkgsrcdir/sysutils/install-sh/files/install-sh.in > $wrkdir/bin/install-sh"
780 run_cmd "$chmodprog +x $wrkdir/bin/install-sh"
781 install_sh="$shprog $wrkdir/bin/install-sh"
788 if [ $unprivileged = "no" ]; then
789 die "You must be either root to install bootstrap-pkgsrc or use the --unprivileged option."
793 group=`$groupsprog | $awkprog '{print $1}'`
794 echo_msg "building as unprivileged user $user/$group"
796 # force bmake install target to use $user and $group
802 MANGRP=$group" > ${wrkdir}/Makefile.inc
805 # make sure we're using a case-sensitive file system
806 if [ $ignorecasecheck = "no" ]; then
809 echo_msg "Testing file system case sensitivity"
810 for fs in "$prefix"; do
811 testdir="pkgsrc-REQUIRES-case-SENSITIVE-filesystem"
812 testdir_mangled="PKGSRC-requires-CASE-sensitive-FILESYSTEM"
813 mkdir_p "$fs/$testdir" || die "can't verify filesystem ($fs) case-sensitivity"
814 if [ -d "$fs/$testdir_mangled" ]; then
815 $rmdirprog "$fs/$testdir"
816 die "\"$fs\" needs to be on a case-sensitive filesystem (see README.$opsys)"
818 $rmdirprog "$fs/$testdir"
824 # export the proper environment
825 PATH=$prefix/bin:$prefix/sbin:${PATH}; export PATH
826 if [ -d /usr/ccs/bin -a -x /usr/ccs/bin/make ]; then
827 PATH=${PATH}:/usr/ccs/bin; export PATH
829 PKG_DBDIR=$pkgdbdir; export PKG_DBDIR
830 LOCALBASE=$prefix; export LOCALBASE
831 VARBASE=$varbase; export VARBASE
833 # set up an example mk.conf file
834 TARGET_MKCONF=${wrkdir}/mk.conf.example
835 echo_msg "Creating default mk.conf in ${wrkdir}"
836 echo "# Example ${sysconfdir}/mk.conf file produced by bootstrap-pkgsrc" > ${TARGET_MKCONF}
837 echo "# `date`" >> ${TARGET_MKCONF}
838 echo "" >> ${TARGET_MKCONF}
839 echo ".ifdef BSD_PKG_MK # begin pkgsrc settings" >> ${TARGET_MKCONF}
840 echo "" >> ${TARGET_MKCONF}
842 # IRIX64 needs to be set to IRIX, for example
843 if [ "$set_opsys" = "yes" ]; then
844 echo "OPSYS= $opsys" >> ${TARGET_MKCONF}
847 if [ ! -z "$abi" ]; then
848 echo "ABI= $abi" >> ${TARGET_MKCONF}
850 if [ "$compiler" != "" ]; then
851 echo "PKGSRC_COMPILER= $compiler" >> ${TARGET_MKCONF}
855 echo "CC= cc" >> ${TARGET_MKCONF}
856 echo "CXX= CC" >> ${TARGET_MKCONF}
857 echo "CPP= \${CC} -E" >> ${TARGET_MKCONF}
860 if [ -n "$SUNWSPROBASE" ]; then
861 echo "SUNWSPROBASE= $SUNWSPROBASE" >> ${TARGET_MKCONF}
863 echo "" >> ${TARGET_MKCONF}
865 # enable unprivileged builds if not root
866 if [ "$unprivileged" = "yes" ]; then
867 echo "UNPRIVILEGED= yes" >> ${TARGET_MKCONF}
870 # save environment in example mk.conf
871 echo "PKG_DBDIR= $pkgdbdir" >> ${TARGET_MKCONF}
872 echo "LOCALBASE= $prefix" >> ${TARGET_MKCONF}
873 echo "VARBASE= $varbase" >> ${TARGET_MKCONF}
874 if [ "${sysconfdir}" != "${prefix}/etc" ]; then
875 echo "PKG_SYSCONFBASE= $sysconfdir" >> ${TARGET_MKCONF}
877 echo "PKG_TOOLS_BIN= $prefix/sbin" >> ${TARGET_MKCONF}
878 echo "PKGMANDIR= $pkgmandir" >> ${TARGET_MKCONF}
879 echo "" >> ${TARGET_MKCONF}
881 BOOTSTRAP_MKCONF=${wrkdir}/mk.conf
882 cp ${TARGET_MKCONF} ${BOOTSTRAP_MKCONF}
884 # sbin is used by pkg_install, share/mk by bootstrap-mk-files
885 mkdir_p $wrkdir/sbin $wrkdir/share/mk
886 mkdir_p_early ${wrkdir}
888 if [ "$need_bsd_install" = "yes" ]; then
889 BSTRAP_ENV="INSTALL='$prefix/bin/install-sh -c' $BSTRAP_ENV"
890 echo "TOOLS_PLATFORM.install?= $prefix/bin/install-sh" >> ${TARGET_MKCONF}
891 echo "TOOLS_PLATFORM.install?= $wrkdir/bin/install-sh" >> ${BOOTSTRAP_MKCONF}
894 if [ "$need_fixed_strip" = "yes" ] ; then
895 echo_msg "Installing fixed strip script"
896 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/strip-sh $wrkdir/bin/strip"
897 echo "TOOLS_PLATFORM.strip?= $prefix/bin/strip" >> ${TARGET_MKCONF}
898 echo "TOOLS_PLATFORM.strip?= $wrkdir/bin/strip" >> ${BOOTSTRAP_MKCONF}
902 if [ "$need_mkdir" = "yes" -a -z "$MKDIR" ]; then
903 echo_msg "Installing fixed mkdir script \"mkdir-sh\""
904 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/mkdir-sh $wrkdir/bin/mkdir-sh"
905 echo "TOOLS_PLATFORM.mkdir?= $prefix/bin/mkdir-sh -p" >> ${TARGET_MKCONF}
906 echo "TOOLS_PLATFORM.mkdir?= $wrkdir/bin/mkdir-sh -p" >> ${BOOTSTRAP_MKCONF}
910 if [ "$need_xargs" = "yes" ]; then
911 echo_msg "Installing fixed xargs script"
912 run_cmd "$install_sh -c -o $user -g $group -m 755 $pkgsrcdir/pkgtools/bootstrap-extras/files/xargs-sh $wrkdir/bin/xargs"
913 echo "TOOLS_PLATFORM.xargs?= $prefix/bin/xargs" >> ${TARGET_MKCONF}
914 echo "TOOLS_PLATFORM.xargs?= $wrkdir/bin/xargs" >> ${BOOTSTRAP_MKCONF}
918 echo_msg "Bootstrapping mk-files"
919 run_cmd "(cd ${pkgsrcdir}/pkgtools/bootstrap-mk-files/files && env CP=${cpprog} \
920 OPSYS=${opsys} MK_DST=${wrkdir}/share/mk ROOT_GROUP=${root_group} \
921 ROOT_USER=${root_user} SED=${sedprog} SYSCONFDIR=${sysconfdir} \
922 $shprog ./bootstrap.sh)"
925 echo_msg "Bootstrapping bmake"
926 copy_src $pkgsrcdir/devel/bmake/files bmake
927 run_cmd "(cd $wrkdir/bmake && env $bmakexenv $shprog ./boot-strap $configure_quiet_flags -q -o $opsys --prefix=$wrkdir --sysconfdir=$wrkdir --mksrc none --with-default-sys-path="$wrkdir/share/mk" $bmakexargs)"
928 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/bmake/$opsys/bmake $wrkdir/bin/bmake"
932 bmake="$wrkdir/bin/bmake $make_quiet_flags"
935 echo_msg "Building libnbcompat"
936 copy_src $pkgsrcdir/pkgtools/libnbcompat/files libnbcompat
937 run_cmd "(cd $wrkdir/libnbcompat; $shprog ./configure $configure_quiet_flags -C --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir --enable-bsd-getopt --enable-db && $bmake $make_quiet_flags)"
939 # bootstrap ksh if necessary
941 yes) echo_msg "Bootstrapping ksh"
942 copy_src $pkgsrcdir/shells/pdksh/files ksh
943 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
944 run_cmd "(cd $wrkdir/ksh && env $BSTRAP_ENV $shprog ./configure $configure_quiet_flags --prefix=$prefix --mandir=$mandir --sysconfdir=$sysconfdir && $bmake)"
945 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/ksh/ksh $wrkdir/bin/pdksh"
946 echo "TOOLS_PLATFORM.sh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
947 echo "TOOLS_PLATFORM.sh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
948 echo "TOOLS_PLATFORM.ksh?= $prefix/bin/pdksh" >> ${TARGET_MKCONF}
949 echo "TOOLS_PLATFORM.ksh?= $wrkdir/bin/pdksh" >> ${BOOTSTRAP_MKCONF}
950 # Now rebootstrap bmake for ksh
951 echo_msg "Rebootstrapping bmake for ksh"
952 bmakexargs="$bmakexargs --with-defshell=$wrkdir/bin/pdksh"
957 # bootstrap awk if necessary
959 yes) echo_msg "Bootstrapping awk"
960 copy_src $pkgsrcdir/lang/nawk/files awk
961 test -n "$CC" || CC=gcc # default to gcc if no compiler is specified
962 run_cmd "(cd $wrkdir/awk && $bmake -f Makefile CC=\"${CC}\" CFLAGS=\"${CFLAGS}\")"
963 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/awk/a.out $wrkdir/bin/nawk"
964 echo "TOOLS_PLATFORM.awk?= $prefix/bin/nawk" >> ${TARGET_MKCONF}
965 echo "TOOLS_PLATFORM.awk?= $wrkdir/bin/nawk" >> ${BOOTSTRAP_MKCONF}
969 # bootstrap sed if necessary
971 yes) echo_msg "Bootstrapping sed"
972 copy_src $pkgsrcdir/textproc/nbsed/files sed
973 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 --mandir=$mandir --sysconfdir=$sysconfdir --program-transform-name='s,sed,nbsed,' && $bmake)"
974 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/sed/sed $wrkdir/bin/sed"
975 echo "TOOLS_PLATFORM.sed?= $prefix/bin/nbsed" >> ${TARGET_MKCONF}
976 echo "TOOLS_PLATFORM.sed?= $wrkdir/bin/sed" >> ${BOOTSTRAP_MKCONF}
980 # bootstrap pkg_install
981 echo_msg "Bootstrapping pkgtools"
982 copy_src $pkgsrcdir/pkgtools/pkg_install/files pkg_install
983 run_cmd "(cd $wrkdir/pkg_install; env $BSTRAP_ENV \
984 CPPFLAGS='$CPPFLAGS -I../libnbcompat -I../../libnbcompat' \
985 LDFLAGS='$LDFLAGS -L../libnbcompat -L../../libnbcompat' \
986 LIBS='$LIBS -lnbcompat' $shprog ./configure $configure_quiet_flags -C \
987 --enable-bootstrap --prefix=$prefix --sysconfdir=$sysconfdir \
988 --with-pkgdbdir=$pkgdbdir --mandir=$mandir $pkg_install_args && $bmake)"
989 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/admin/pkg_admin $wrkdir/sbin/pkg_admin"
990 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/create/pkg_create $wrkdir/sbin/pkg_create"
991 run_cmd "$install_sh -c -o $user -g $group -m 755 $wrkdir/pkg_install/info/pkg_info $wrkdir/sbin/pkg_info"
992 echo "PKG_ADMIN_CMD?= $wrkdir/sbin/pkg_admin" >> ${BOOTSTRAP_MKCONF}
993 echo "PKG_CREATE_CMD?= $wrkdir/sbin/pkg_create" >> ${BOOTSTRAP_MKCONF}
994 echo "PKG_INFO_CMD?= $wrkdir/sbin/pkg_info" >> ${BOOTSTRAP_MKCONF}
996 if [ -n "${fetch_cmd}" ]; then
997 echo "FETCH_CMD= $fetch_cmd" >> ${TARGET_MKCONF}
1000 MAKECONF=$wrkdir/mk.conf
1003 if [ "$bootstrap_sh_set" = "set" ]; then
1004 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${TARGET_MKCONF}
1005 echo "TOOLS_PLATFORM.sh?= ${bootstrap_sh}" >> ${BOOTSTRAP_MKCONF}
1008 # preserve compiler and tool environment variables settings
1009 if test -n "$CP"; then
1010 echo "TOOLS_PLATFORM.cp?= $CP" >> ${TARGET_MKCONF}
1011 echo "TOOLS_PLATFORM.cp?= $CP" >> ${BOOTSTRAP_MKCONF}
1013 if test -n "$GREP"; then
1014 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${TARGET_MKCONF}
1015 echo "TOOLS_PLATFORM.grep?= $GREP" >> ${BOOTSTRAP_MKCONF}
1017 if test -n "$ID"; then
1018 echo "TOOLS_PLATFORM.id?= $ID" >> ${TARGET_MKCONF}
1019 echo "TOOLS_PLATFORM.id?= $ID" >> ${BOOTSTRAP_MKCONF}
1021 if test -n "$MKDIR"; then
1022 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${TARGET_MKCONF}
1023 echo "TOOLS_PLATFORM.mkdir?= $MKDIR" >> ${BOOTSTRAP_MKCONF}
1025 if test -n "$TEST"; then
1026 echo "TOOLS_PLATFORM.test?= $TEST" >> ${TARGET_MKCONF}
1027 echo "TOOLS_PLATFORM.test?= $TEST" >> ${BOOTSTRAP_MKCONF}
1029 if test -n "$TOUCH"; then
1030 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${TARGET_MKCONF}
1031 echo "TOOLS_PLATFORM.touch?= $TOUCH" >> ${BOOTSTRAP_MKCONF}
1033 if test -n "$XARGS"; then
1034 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${TARGET_MKCONF}
1035 echo "TOOLS_PLATFORM.xargs?= $XARGS" >> ${BOOTSTRAP_MKCONF}
1037 if test -n "$CFLAGS"; then
1038 echo "CFLAGS+= $CFLAGS" >> ${TARGET_MKCONF}
1039 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${TARGET_MKCONF}
1040 echo "DBG= # prevent DBG from adding default optimizer flags" >> ${BOOTSTRAP_MKCONF}
1042 if test -n "$CPPFLAGS"; then
1043 echo "CPPFLAGS+= $CPPFLAGS" >> ${TARGET_MKCONF}
1045 if test -n "$LDFLAGS"; then
1046 echo "LDFLAGS+= $LDFLAGS" >> ${TARGET_MKCONF}
1048 if test -n "$LIBS"; then
1049 echo "LIBS+= $LIBS" >> ${TARGET_MKCONF}
1052 # opsys specific fiddling
1055 echo "WRKOBJDIR= ${wrkdir}/wrk" >> ${BOOTSTRAP_MKCONF}
1057 echo "" >> ${TARGET_MKCONF}
1058 echo "" >> ${BOOTSTRAP_MKCONF}
1059 if test -n "${mk_fragment}"; then
1060 cat "${mk_fragment}" >> ${TARGET_MKCONF}
1061 echo "" >> ${TARGET_MKCONF}
1063 echo ".endif # end pkgsrc settings" >> ${TARGET_MKCONF}
1064 echo ".endif # end pkgsrc settings" >> ${BOOTSTRAP_MKCONF}
1067 # usage: register_package <packagedirectory> [additional arguments]
1069 run_cmd "(cd $pkgsrcdir/$1 && $bmake -DPKG_PRESERVE MAKECONF=${BOOTSTRAP_MKCONF} install)"
1073 # Please make sure that the following packages and
1074 # only the following packages set BOOTSTRAP_PKG=yes.
1076 echo_msg "Installing packages"
1077 build_package "pkgtools/bootstrap-mk-files"
1078 case "$need_bsd_install" in
1079 yes) build_package "sysutils/install-sh";;
1082 yes) build_package "shells/pdksh";;
1084 build_package "devel/bmake"
1086 yes) build_package "lang/nawk";;
1089 yes) build_package "textproc/nbsed";;
1091 case "$need_extras" in
1092 yes) build_package "pkgtools/bootstrap-extras";;
1094 build_package "pkgtools/pkg_install"
1096 etc_mk_conf="$sysconfdir/mk.conf"
1098 # Install the example mk.conf so that it is used, but only if it doesn't
1099 # exist yet. This can happen with non-default sysconfdir settings.
1100 mkdir_p "$sysconfdir"
1101 if [ ! -f "$etc_mk_conf" ]; then
1102 cp "$TARGET_MKCONF" "$etc_mk_conf"
1103 TARGET_MKCONF="$etc_mk_conf"
1106 hline="==========================================================================="
1110 echo "Please remember to add $prefix/bin to your PATH environment variable"
1111 echo "and $mandir to your MANPATH environment variable, if necessary."
1113 echo "An example mk.conf file with the settings you provided to \"bootstrap\""
1114 echo "has been created for you. It can be found in:"
1116 echo " ${TARGET_MKCONF}"
1118 if [ "$TARGET_MKCONF" != "$etc_mk_conf" ]; then
1119 echo "Please copy it to $etc_mk_conf to use it."
1122 echo "You can find extensive documentation of the NetBSD Packages Collection"
1123 echo "in $pkgsrcdir/doc/pkgsrc.txt."
1125 echo "Hopefully everything is now complete."
1131 [ ! -z "${binary_kit}" ] && mkbinarykit_tar
1132 [ ! -z "${binary_gzip_kit}" ] && mkbinarykit_tgz
1133 [ ! -z "${binary_macpkg}" ] && mkbinarykit_macpkg
1135 echo_msg "bootstrap started: $build_start"
1136 echo_msg "bootstrap ended: `date`"