101e196c8SJohn Marino: 201e196c8SJohn Marino# NAME: 301e196c8SJohn Marino# boot-strap 401e196c8SJohn Marino# 501e196c8SJohn Marino# SYNOPSIS: 65f1e34d9SAlexandre Perrin# boot-strap ["options"] 75f1e34d9SAlexandre Perrin# boot-strap --prefix=/opt --install 85f1e34d9SAlexandre Perrin# boot-strap --prefix=$HOME --install-host-target -DWITH_PROG_VERSION 95f1e34d9SAlexandre Perrin# boot-strap ["options"] op=build 105f1e34d9SAlexandre Perrin# boot-strap ["options"] op=install 1101e196c8SJohn Marino# 1201e196c8SJohn Marino# DESCRIPTION: 1301e196c8SJohn Marino# This script is used to configure/build bmake it builds for 145f1e34d9SAlexandre Perrin# each host-target in a different subdir to keep the src clean. 155f1e34d9SAlexandre Perrin# There is no requirement for an existing make(1). 165f1e34d9SAlexandre Perrin# 175f1e34d9SAlexandre Perrin# On successful completion if no '--install' flag is given, 185f1e34d9SAlexandre Perrin# it echos a command to do installation. 195f1e34d9SAlexandre Perrin# 205f1e34d9SAlexandre Perrin# The variable "op" defaults to 'all', and is affected by 215f1e34d9SAlexandre Perrin# '--install' flag as above. 225f1e34d9SAlexandre Perrin# Other values include: 235f1e34d9SAlexandre Perrin# 245f1e34d9SAlexandre Perrin# configure 255f1e34d9SAlexandre Perrin# Just run 'configure' 265f1e34d9SAlexandre Perrin# 275f1e34d9SAlexandre Perrin# build 285f1e34d9SAlexandre Perrin# If 'configure' has not been done, do it, then 295f1e34d9SAlexandre Perrin# run the build script, and finally 'test'. 305f1e34d9SAlexandre Perrin# 315f1e34d9SAlexandre Perrin# install 325f1e34d9SAlexandre Perrin# If 'build' has not been done, do it, 'test' then 335f1e34d9SAlexandre Perrin# install. 345f1e34d9SAlexandre Perrin# 355f1e34d9SAlexandre Perrin# clean 365f1e34d9SAlexandre Perrin# attempt to clean up 375f1e34d9SAlexandre Perrin# 385f1e34d9SAlexandre Perrin# test 395f1e34d9SAlexandre Perrin# run the unit-tests. Done automatically after 'build' 405f1e34d9SAlexandre Perrin# and before 'install'. 415f1e34d9SAlexandre Perrin# 425f1e34d9SAlexandre Perrin# The above are leveraged by a trivial makefile for the benefit 435f1e34d9SAlexandre Perrin# of those that have './configure; make; make install' baked 445f1e34d9SAlexandre Perrin# into them. 4501e196c8SJohn Marino# 4601e196c8SJohn Marino# Options: 4701e196c8SJohn Marino# 4801e196c8SJohn Marino# -c "rc" 4901e196c8SJohn Marino# Pick up settings from "rc". 5001e196c8SJohn Marino# We look for '.bmake-boot-strap.rc' before processing 515f1e34d9SAlexandre Perrin# options (unless SKIP_RC is set in environment). 5201e196c8SJohn Marino# 5301e196c8SJohn Marino# --share "share_dir" 5401e196c8SJohn Marino# Where to put man pages and mk files. 5501e196c8SJohn Marino# If $prefix ends in $HOST_TARGET, and $prefix/../share 5601e196c8SJohn Marino# exits, the default will be that rather than $prefix/share. 5701e196c8SJohn Marino# 5801e196c8SJohn Marino# --mksrc "mksrc" 5901e196c8SJohn Marino# Indicate where the mk files can be found. 605f1e34d9SAlexandre Perrin# Default is $Mydir/mk 615f1e34d9SAlexandre Perrin# 625f1e34d9SAlexandre Perrin# --install 635f1e34d9SAlexandre Perrin# If build and test work, run bmake install. 645f1e34d9SAlexandre Perrin# BINDIR=$prefix/bin 655f1e34d9SAlexandre Perrin# SHAREDIR=$prefix/share 665f1e34d9SAlexandre Perrin# 675f1e34d9SAlexandre Perrin# --install-host-target 685f1e34d9SAlexandre Perrin# As for '--install' but BINDIR=$prefix/$HOST_TARGET/bin 695f1e34d9SAlexandre Perrin# This is useful when $prefix/ is shared by multiple 705f1e34d9SAlexandre Perrin# machines. 715f1e34d9SAlexandre Perrin# 725f1e34d9SAlexandre Perrin# Flags relevant when installing: 735f1e34d9SAlexandre Perrin# 745f1e34d9SAlexandre Perrin# -DWITHOUT_INSTALL_MK 755f1e34d9SAlexandre Perrin# Skip installing mk files. 765f1e34d9SAlexandre Perrin# By default they will be installed to $prefix/share/mk 775f1e34d9SAlexandre Perrin# 785f1e34d9SAlexandre Perrin# -DWITH_PROG_VERSION 795f1e34d9SAlexandre Perrin# Install 'bmake' as 'bmake-$MAKE_VERSION' 805f1e34d9SAlexandre Perrin# A symlink will be made as 'bmake' unless 815f1e34d9SAlexandre Perrin# -DWITHOUT_PROG_LINK is set. 8201e196c8SJohn Marino# 8301e196c8SJohn Marino# Possibly useful configure_args: 8401e196c8SJohn Marino# 8501e196c8SJohn Marino# --without-meta 8601e196c8SJohn Marino# disable use of meta mode. 8701e196c8SJohn Marino# 8801e196c8SJohn Marino# --without-filemon 8901e196c8SJohn Marino# disable use of filemon(9) which is currently only 9001e196c8SJohn Marino# available for NetBSD and FreeBSD. 9101e196c8SJohn Marino# 92ca58f742SDaniel Fojt# --with-filemon=ktrace 93ca58f742SDaniel Fojt# on NetBSD or others with fktrace(2), use ktrace 94ca58f742SDaniel Fojt# version of filemon. 95ca58f742SDaniel Fojt# 9601e196c8SJohn Marino# --with-filemon="path/to/filemon.h" 9701e196c8SJohn Marino# enables use of filemon(9) by meta mode. 9801e196c8SJohn Marino# 9901e196c8SJohn Marino# --with-machine="machine" 10001e196c8SJohn Marino# set "machine" to override that determined by 10101e196c8SJohn Marino# machine.sh 10201e196c8SJohn Marino# 10301e196c8SJohn Marino# --with-force-machine="machine" 10401e196c8SJohn Marino# force "machine" even if uname(3) provides a value. 10501e196c8SJohn Marino# 10601e196c8SJohn Marino# --with-machine_arch="machine_arch" 10701e196c8SJohn Marino# set "machine_arch" to override that determined by 10801e196c8SJohn Marino# machine.sh 10901e196c8SJohn Marino# 110a34d5fb1SAntonio Huete Jimenez# --with-force_machine_arch="machine_arch" 111a34d5fb1SAntonio Huete Jimenez# force "machine_arch" to override that determined by 112a34d5fb1SAntonio Huete Jimenez# machine.sh 113a34d5fb1SAntonio Huete Jimenez# 11401e196c8SJohn Marino# --with-default-sys-path="syspath" 11501e196c8SJohn Marino# set an explicit default "syspath" which is where bmake 11601e196c8SJohn Marino# will look for sys.mk and friends. 11701e196c8SJohn Marino# 11801e196c8SJohn Marino# AUTHOR: 11901e196c8SJohn Marino# Simon J. Gerraty <sjg@crufty.net> 12001e196c8SJohn Marino 12101e196c8SJohn Marino# RCSid: 122*6eef5f0cSAntonio Huete Jimenez# $Id: boot-strap,v 1.57 2021/10/22 20:32:21 sjg Exp $ 12301e196c8SJohn Marino# 12401e196c8SJohn Marino# @(#) Copyright (c) 2001 Simon J. Gerraty 12501e196c8SJohn Marino# 12601e196c8SJohn Marino# This file is provided in the hope that it will 12701e196c8SJohn Marino# be of use. There is absolutely NO WARRANTY. 12801e196c8SJohn Marino# Permission to copy, redistribute or otherwise 12901e196c8SJohn Marino# use this file is hereby granted provided that 13001e196c8SJohn Marino# the above copyright notice and this notice are 13101e196c8SJohn Marino# left intact. 13201e196c8SJohn Marino# 13301e196c8SJohn Marino# Please send copies of changes and bug-fixes to: 13401e196c8SJohn Marino# sjg@crufty.net 13501e196c8SJohn Marino# 13601e196c8SJohn Marino 13701e196c8SJohn MarinoMydir=`dirname $0` 13801e196c8SJohn Marino. "$Mydir/os.sh" 13901e196c8SJohn Marinocase "$Mydir" in 14001e196c8SJohn Marino/*) ;; 14101e196c8SJohn Marino*) Mydir=`cd "$Mydir" && 'pwd'`;; 14201e196c8SJohn Marinoesac 14301e196c8SJohn Marino 14401e196c8SJohn MarinoUsage() { 14501e196c8SJohn Marino [ "$1" ] && echo "ERROR: $@" >&2 14601e196c8SJohn Marino echo "Usage:" >&2 1475f1e34d9SAlexandre Perrin echo "$0 [--<configure_arg> ...][<prefix>][--install]" >&2 14801e196c8SJohn Marino exit 1 14901e196c8SJohn Marino} 15001e196c8SJohn Marino 15101e196c8SJohn MarinoError() { 15201e196c8SJohn Marino echo "ERROR: $@" >&2 15301e196c8SJohn Marino exit 1 15401e196c8SJohn Marino} 15501e196c8SJohn Marino 15601e196c8SJohn Marinosource_rc() { 15701e196c8SJohn Marino rc="$1"; shift 15801e196c8SJohn Marino for d in ${*:-""} 15901e196c8SJohn Marino do 16001e196c8SJohn Marino r="${d:+$d/}$rc" 16101e196c8SJohn Marino [ -f "$r" -a -s "$r" ] || continue 16201e196c8SJohn Marino echo "NOTE: reading $r" 16301e196c8SJohn Marino . "$r" 16401e196c8SJohn Marino break 16501e196c8SJohn Marino done 16601e196c8SJohn Marino} 16701e196c8SJohn Marino 1685f1e34d9SAlexandre Perrincmd_args="$@" 1695f1e34d9SAlexandre Perrin 1705f1e34d9SAlexandre Perrin# clear some things from the environment that we care about 1715f1e34d9SAlexandre Perrinunset MAKEOBJDIR MAKEOBJDIRPREFIX 172ca58f742SDaniel Fojt# or that might be incompatible 173ca58f742SDaniel Fojtunset MAKE MAKEFLAGS 1745f1e34d9SAlexandre Perrin 1755f1e34d9SAlexandre Perrin# --install[-host-target] will set this 1765f1e34d9SAlexandre PerrinINSTALL_PREFIX= 1775f1e34d9SAlexandre Perrin# other things we pass to install step 1785f1e34d9SAlexandre PerrinINSTALL_ARGS= 17901e196c8SJohn MarinoCONFIGURE_ARGS= 18001e196c8SJohn MarinoMAKESYSPATH= 18101e196c8SJohn Marino# pick a useful default prefix (for me at least ;-) 18201e196c8SJohn Marinofor prefix in /opt/$HOST_TARGET "$HOME/$HOST_TARGET" /usr/pkg /usr/local "" 18301e196c8SJohn Marinodo 1845f1e34d9SAlexandre Perrin [ -d "${prefix:-.}" ] || continue 1855f1e34d9SAlexandre Perrin case "$prefix" in 1865f1e34d9SAlexandre Perrin */$HOST_TARGET) 1875f1e34d9SAlexandre Perrin p=`dirname $prefix` 1885f1e34d9SAlexandre Perrin if [ -d $p/share ]; then 1895f1e34d9SAlexandre Perrin INSTALL_BIN=$HOST_TARGET/bin 1905f1e34d9SAlexandre Perrin prefix=$p 1915f1e34d9SAlexandre Perrin fi 1925f1e34d9SAlexandre Perrin ;; 1935f1e34d9SAlexandre Perrin esac 1945f1e34d9SAlexandre Perrin echo "NOTE: default prefix=$prefix ${INSTALL_BIN:+INSTALL_BIN=$INSTALL_BIN}" 1955f1e34d9SAlexandre Perrin break 19601e196c8SJohn Marinodone 1975f1e34d9SAlexandre Perrinsrcdir=$Mydir 1985f1e34d9SAlexandre Perrinmksrc=$Mydir/mk 19901e196c8SJohn Marinoobjdir= 20001e196c8SJohn Marinoquiet=: 20101e196c8SJohn Marino 2025f1e34d9SAlexandre Perrin${SKIP_RC:+:} source_rc .bmake-boot-strap.rc . "$Mydir/.." "$HOME" 20301e196c8SJohn Marino 20401e196c8SJohn Marinoget_optarg() { 20501e196c8SJohn Marino expr "x$1" : "x[^=]*=\\(.*\\)" 20601e196c8SJohn Marino} 20701e196c8SJohn Marino 2085f1e34d9SAlexandre Perrinhere=`'pwd'` 2095f1e34d9SAlexandre Perrinif [ $here = $Mydir ]; then 2106a91b982SJohn Marino # avoid pollution 2115f1e34d9SAlexandre Perrin OBJROOT=../ 2125f1e34d9SAlexandre Perrinfi 2135f1e34d9SAlexandre Perrin 2145f1e34d9SAlexandre Perrinop=all 2155f1e34d9SAlexandre PerrinBMAKE= 2165f1e34d9SAlexandre Perrin 21701e196c8SJohn Marinowhile : 21801e196c8SJohn Marinodo 21901e196c8SJohn Marino case "$1" in 22001e196c8SJohn Marino --) shift; break;; 2215f1e34d9SAlexandre Perrin --help) sed -n -e "1d;/RCSid/,\$d" -e '/^#\.[a-z]/d' -e '/^#/s,^# *,,p' $0; exit 0;; 22201e196c8SJohn Marino --prefix) prefix="$2"; shift;; 22301e196c8SJohn Marino --prefix=*) prefix=`get_optarg "$1"`;; 22401e196c8SJohn Marino --src=*) srcdir=`get_optarg "$1"`;; 22501e196c8SJohn Marino --with-mksrc=*|--mksrc=*) mksrc=`get_optarg "$1"`;; 22601e196c8SJohn Marino --share=*) share_dir=`get_optarg "$1"`;; 22701e196c8SJohn Marino --share) share_dir="$2"; shift;; 22801e196c8SJohn Marino --with-default-sys-path=*) 2296a91b982SJohn Marino CONFIGURE_ARGS="$1";; 23001e196c8SJohn Marino --with-default-sys-path) 2316a91b982SJohn Marino CONFIGURE_ARGS="$1 $2";; 2325f1e34d9SAlexandre Perrin --install) INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix};; 2335f1e34d9SAlexandre Perrin --install-host-target) 2345f1e34d9SAlexandre Perrin INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix} 2355f1e34d9SAlexandre Perrin INSTALL_BIN=$HOST_TARGET/bin;; 2365f1e34d9SAlexandre Perrin --install-destdir=*) INSTALL_DESTDIR=`get_optarg "$1"`;; 2375f1e34d9SAlexandre Perrin --install-prefix=*) INSTALL_PREFIX=`get_optarg "$1"`;; 2385f1e34d9SAlexandre Perrin -DWITH*) INSTALL_ARGS="$INSTALL_ARGS $1";; 23901e196c8SJohn Marino -s|--src) srcdir="$2"; shift;; 24001e196c8SJohn Marino -m|--mksrc) mksrc="$2"; shift;; 24101e196c8SJohn Marino -o|--objdir) objdir="$2"; shift;; 24201e196c8SJohn Marino -q) quiet=;; 24301e196c8SJohn Marino -c) source_rc "$2"; shift;; 24401e196c8SJohn Marino --*) CONFIGURE_ARGS="$CONFIGURE_ARGS $1";; 24501e196c8SJohn Marino *=*) eval "$1"; export `expr "x$1" : "x\\(.[^=]*\\)=.*"`;; 24601e196c8SJohn Marino *) break;; 24701e196c8SJohn Marino esac 24801e196c8SJohn Marino shift 24901e196c8SJohn Marinodone 25001e196c8SJohn Marino 25101e196c8SJohn MarinoAddConfigure() { 25201e196c8SJohn Marino case " $CONFIGURE_ARGS " in 25301e196c8SJohn Marino *" $1"*) ;; 25401e196c8SJohn Marino *) CONFIGURE_ARGS="$CONFIGURE_ARGS $1$2";; 25501e196c8SJohn Marino esac 25601e196c8SJohn Marino} 25701e196c8SJohn Marino 25801e196c8SJohn MarinoGetDir() { 25901e196c8SJohn Marino match="$1" 26001e196c8SJohn Marino shift 26101e196c8SJohn Marino fmatch="$1" 26201e196c8SJohn Marino shift 26301e196c8SJohn Marino for dir in $* 26401e196c8SJohn Marino do 26501e196c8SJohn Marino [ -d "$dir" ] || continue 26601e196c8SJohn Marino case "/$dir/" in 26701e196c8SJohn Marino *$match*) ;; 26801e196c8SJohn Marino *) continue;; 26901e196c8SJohn Marino esac 27001e196c8SJohn Marino case "$fmatch" in 27101e196c8SJohn Marino .) ;; 27201e196c8SJohn Marino *) [ -s $dir/$fmatch ] || continue;; 27301e196c8SJohn Marino esac 27401e196c8SJohn Marino case "$dir/" in 27501e196c8SJohn Marino *./*) cd "$dir" && 'pwd';; 27601e196c8SJohn Marino /*) echo $dir;; 27701e196c8SJohn Marino *) cd "$dir" && 'pwd';; 27801e196c8SJohn Marino esac 27901e196c8SJohn Marino break 28001e196c8SJohn Marino done 28101e196c8SJohn Marino} 28201e196c8SJohn Marino 28301e196c8SJohn MarinoFindHereOrAbove() { 28401e196c8SJohn Marino ( 28501e196c8SJohn Marino _t=-s 28601e196c8SJohn Marino while : 28701e196c8SJohn Marino do 28801e196c8SJohn Marino case "$1" in 28901e196c8SJohn Marino -C) cd "$2"; shift; shift;; 29001e196c8SJohn Marino -?) _t=$1; shift;; 29101e196c8SJohn Marino *) break;; 29201e196c8SJohn Marino esac 29301e196c8SJohn Marino done 29401e196c8SJohn Marino case "$1" in 29501e196c8SJohn Marino /*) # we shouldn't be here 29601e196c8SJohn Marino [ $_t "$1" ] && echo "$1" 29701e196c8SJohn Marino return 29801e196c8SJohn Marino ;; 29901e196c8SJohn Marino .../*) want=`echo "$1" | sed 's,^.../*,,'`;; 30001e196c8SJohn Marino *) want="$1";; 30101e196c8SJohn Marino esac 30201e196c8SJohn Marino here=`'pwd'` 30301e196c8SJohn Marino while : 30401e196c8SJohn Marino do 30501e196c8SJohn Marino if [ $_t "./$want" ]; then 30601e196c8SJohn Marino echo "$here/$want" 30701e196c8SJohn Marino return 30801e196c8SJohn Marino fi 30901e196c8SJohn Marino cd .. 31001e196c8SJohn Marino here=`'pwd'` 31101e196c8SJohn Marino case "$here" in 31201e196c8SJohn Marino /) return;; 31301e196c8SJohn Marino esac 31401e196c8SJohn Marino done 31501e196c8SJohn Marino ) 31601e196c8SJohn Marino} 31701e196c8SJohn Marino 31801e196c8SJohn Marino# is $1 missing from $2 (or PATH) ? 31901e196c8SJohn Marinono_path() { 32001e196c8SJohn Marino eval "__p=\$${2:-PATH}" 32101e196c8SJohn Marino case ":$__p:" in *:"$1":*) return 1;; *) return 0;; esac 32201e196c8SJohn Marino} 32301e196c8SJohn Marino 32401e196c8SJohn Marino# if $1 exists and is not in path, append it 32501e196c8SJohn Marinoadd_path () { 32601e196c8SJohn Marino case "$1" in 32701e196c8SJohn Marino -?) t=$1; shift;; 32801e196c8SJohn Marino *) t=-d;; 32901e196c8SJohn Marino esac 33001e196c8SJohn Marino case "$2,$1" in 33101e196c8SJohn Marino MAKESYSPATH,.../*) ;; 33201e196c8SJohn Marino *) [ $t ${1:-.} ] || return;; 33301e196c8SJohn Marino esac 33401e196c8SJohn Marino no_path $* && eval ${2:-PATH}="$__p${__p:+:}$1" 33501e196c8SJohn Marino} 33601e196c8SJohn Marino 33701e196c8SJohn Marino 33801e196c8SJohn Marinosrcdir=`GetDir /bmake make-bootstrap.sh.in "$srcdir" "$2" "$Mydir" ./bmake* "$Mydir"/../bmake*` 33901e196c8SJohn Marino[ -d "${srcdir:-/dev/null}" ] || Usage 34001e196c8SJohn Marinocase "$mksrc" in 3416a91b982SJohn Marinonone|-) # we ignore this now 3426a91b982SJohn Marino mksrc=$Mydir/mk 34301e196c8SJohn Marino ;; 34401e196c8SJohn Marino.../*) # find here or above 34501e196c8SJohn Marino mksrc=`FindHereOrAbove -C "$Mydir" -s "$mksrc/sys.mk"` 34601e196c8SJohn Marino # that found a file 34701e196c8SJohn Marino mksrc=`dirname $mksrc` 34801e196c8SJohn Marino ;; 34901e196c8SJohn Marino*) # guess we want mksrc... 35001e196c8SJohn Marino mksrc=`GetDir /mk sys.mk "$mksrc" "$3" ./mk* "$srcdir"/mk* "$srcdir"/../mk*` 35101e196c8SJohn Marino [ -d "${mksrc:-/dev/null}" ] || Usage "Use '-m none' to build without mksrc" 35201e196c8SJohn Marino ;; 35301e196c8SJohn Marinoesac 35401e196c8SJohn Marino 35501e196c8SJohn Marino# Ok, get to work... 3565f1e34d9SAlexandre Perrinobjdir="${objdir:-$OBJROOT$HOST_TARGET}" 35701e196c8SJohn Marino[ -d "$objdir" ] || mkdir -p "$objdir" 35801e196c8SJohn Marino[ -d "$objdir" ] || mkdir "$objdir" 35901e196c8SJohn Marinocd "$objdir" || exit 1 36001e196c8SJohn Marino# make it absolute 36101e196c8SJohn Marinoobjdir=`'pwd'` 36201e196c8SJohn Marino 36301e196c8SJohn MarinoShareDir() { 36401e196c8SJohn Marino case "/$1" in 36501e196c8SJohn Marino /) [ -d /share ] || return;; 36601e196c8SJohn Marino */$HOST_TARGET) 36701e196c8SJohn Marino if [ -d "$1/../share" ]; then 36801e196c8SJohn Marino echo `dirname "$1"`/share 36901e196c8SJohn Marino return 37001e196c8SJohn Marino fi 37101e196c8SJohn Marino ;; 37201e196c8SJohn Marino esac 37301e196c8SJohn Marino echo $1/share 37401e196c8SJohn Marino} 37501e196c8SJohn Marino 37601e196c8SJohn Marino# make it easy to force prefix to use $HOST_TARGET 37701e196c8SJohn Marino: looking at "$prefix" 37801e196c8SJohn Marinocase "$prefix" in 37901e196c8SJohn Marino*/host?target) prefix=`echo "$prefix" | sed "s,host.target,${HOST_TARGET},"`;; 38001e196c8SJohn Marinoesac 38101e196c8SJohn Marino 38201e196c8SJohn Marinoshare_dir="${share_dir:-`ShareDir $prefix`}" 38301e196c8SJohn Marino 38401e196c8SJohn MarinoAddConfigure --prefix= "$prefix" 38501e196c8SJohn Marinocase "$CONFIGURE_ARGS" in 38601e196c8SJohn Marino*--with-*-sys-path*) ;; # skip 38701e196c8SJohn Marino*) [ "$share_dir" ] && AddConfigure --with-default-sys-path= "$share_dir/mk";; 38801e196c8SJohn Marinoesac 38901e196c8SJohn Marinoif [ "$mksrc" ]; then 39001e196c8SJohn Marino AddConfigure --with-mksrc= "$mksrc" 39101e196c8SJohn Marino # not all cc's support this 39201e196c8SJohn Marino CFLAGS_MF= CFLAGS_MD= 39301e196c8SJohn Marino export CFLAGS_MF CFLAGS_MD 39401e196c8SJohn Marinofi 39501e196c8SJohn Marino 3965f1e34d9SAlexandre Perrin# this makes it easy to run the bmake we just built 3975f1e34d9SAlexandre Perrin# the :tA dance is needed because 'pwd' and even /bin/pwd 3985f1e34d9SAlexandre Perrin# may not give the same result as realpath(). 3995f1e34d9SAlexandre PerrinBmake() { 40001e196c8SJohn Marino ( 4015f1e34d9SAlexandre Perrin cd $Mydir && 4025f1e34d9SAlexandre Perrin MAKESYSPATH=$mksrc SRCTOP=$Mydir OBJTOP=$objdir \ 4035f1e34d9SAlexandre Perrin MAKEOBJDIR='${.CURDIR:S,${SRCTOP:tA},${OBJTOP:tA},}' \ 4045f1e34d9SAlexandre Perrin ${BMAKE:-$objdir/bmake} -f $Mydir/Makefile "$@" 40501e196c8SJohn Marino ) 40601e196c8SJohn Marino} 40701e196c8SJohn Marino 4085f1e34d9SAlexandre Perrinop_configure() { 4095f1e34d9SAlexandre Perrin $srcdir/configure $CONFIGURE_ARGS || exit 1 4105f1e34d9SAlexandre Perrin} 4115f1e34d9SAlexandre Perrin 4125f1e34d9SAlexandre Perrinop_build() { 4135f1e34d9SAlexandre Perrin [ -s make-bootstrap.sh ] || op_configure 4145f1e34d9SAlexandre Perrin chmod 755 make-bootstrap.sh || exit 1 4155f1e34d9SAlexandre Perrin ./make-bootstrap.sh || exit 1 4165f1e34d9SAlexandre Perrin case "$op" in 4175f1e34d9SAlexandre Perrin build) op_test;; 4185f1e34d9SAlexandre Perrin esac 4195f1e34d9SAlexandre Perrin} 4205f1e34d9SAlexandre Perrin 4215f1e34d9SAlexandre Perrinop_test() { 4225f1e34d9SAlexandre Perrin [ -x bmake ] || op_build 423*6eef5f0cSAntonio Huete Jimenez Bmake test "$@" || exit 1 4245f1e34d9SAlexandre Perrin} 4255f1e34d9SAlexandre Perrin 4265f1e34d9SAlexandre Perrinop_clean() { 4275f1e34d9SAlexandre Perrin if [ -x bmake ]; then 4285f1e34d9SAlexandre Perrin ln bmake bmake$$ 4295f1e34d9SAlexandre Perrin BMAKE=$objdir/bmake$$ Bmake clean 4305f1e34d9SAlexandre Perrin rm -f bmake$$ 4315f1e34d9SAlexandre Perrin elif [ $objdir != $srcdir ]; then 4325f1e34d9SAlexandre Perrin rm -rf * 4335f1e34d9SAlexandre Perrin fi 4345f1e34d9SAlexandre Perrin} 4355f1e34d9SAlexandre Perrin 4365f1e34d9SAlexandre Perrinop_install() { 4375f1e34d9SAlexandre Perrin op_test 4385f1e34d9SAlexandre Perrin case "$INSTALL_PREFIX,$INSTALL_BIN,$prefix" in 4395f1e34d9SAlexandre Perrin ,$HOST_TARGET/bin,*/$HOST_TARGET) 4405f1e34d9SAlexandre Perrin INSTALL_PREFIX=`dirname $prefix` 44101e196c8SJohn Marino ;; 44201e196c8SJohn Marino esac 4435f1e34d9SAlexandre Perrin INSTALL_PREFIX=${INSTALL_PREFIX:-$prefix} 4445f1e34d9SAlexandre Perrin Bmake install prefix=$INSTALL_PREFIX BINDIR=$INSTALL_PREFIX/${INSTALL_BIN:-bin} ${INSTALL_DESTDIR:+DESTDIR=$INSTALL_DESTDIR} $INSTALL_ARGS || exit 1 4455f1e34d9SAlexandre Perrin} 44601e196c8SJohn Marino 4475f1e34d9SAlexandre Perrinop_all() { 4485f1e34d9SAlexandre Perrin rm -f make-bootstrap.sh bmake *.o 4495f1e34d9SAlexandre Perrin if [ -n "$INSTALL_PREFIX" ]; then 4505f1e34d9SAlexandre Perrin op_install 4515f1e34d9SAlexandre Perrin else 4525f1e34d9SAlexandre Perrin op_test 453f445c897SJohn Marino MAKE_VERSION=`sed -n '/^_MAKE_VERSION/ { s,.*= *,,;p; }' $srcdir/Makefile` 454a34d5fb1SAntonio Huete Jimenez cat << EOM 455a34d5fb1SAntonio Huete JimenezYou can install by running: 456a34d5fb1SAntonio Huete Jimenez 457a34d5fb1SAntonio Huete Jimenez$0 $cmd_args op=install 458a34d5fb1SAntonio Huete Jimenez 459a34d5fb1SAntonio Huete JimenezUse --install-prefix=/something to install somewhere other than $prefix 460a34d5fb1SAntonio Huete JimenezUse --install-destdir=/somewhere to set DESTDIR during install 461a34d5fb1SAntonio Huete JimenezUse --install-host-target to use INSTALL_BIN=$HOST_TARGET/bin 462a34d5fb1SAntonio Huete JimenezUse -DWITH_PROG_VERSION to install as bmake-$MAKE_VERSION 463a34d5fb1SAntonio Huete JimenezUse -DWITHOUT_PROG_LINK to suppress bmake -> bmake-$MAKE_VERSION symlink 464a34d5fb1SAntonio Huete JimenezUse -DWITHOUT_INSTALL_MK to skip installing files to $prefix/share/mk 465a34d5fb1SAntonio Huete JimenezEOM 4665f1e34d9SAlexandre Perrin fi 467a34d5fb1SAntonio Huete Jimenez cat << EOM 468a34d5fb1SAntonio Huete Jimenez 469a34d5fb1SAntonio Huete JimenezNote: bmake.cat1 contains ANSI escape sequences. 470a34d5fb1SAntonio Huete JimenezYou may need the -r or -R option to more/less to view it correctly. 471a34d5fb1SAntonio Huete Jimenez 472a34d5fb1SAntonio Huete JimenezEOM 4735f1e34d9SAlexandre Perrin} 4745f1e34d9SAlexandre Perrin 475*6eef5f0cSAntonio Huete Jimenezop_$op "$@" 4765f1e34d9SAlexandre Perrinexit 0 477