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