1abb0f93cSkardel#! /bin/sh 2abb0f93cSkardel 3abb0f93cSkardelLOGF=make.log 4abb0f93cSkardelIAM=`hostname || uname -n` 5abb0f93cSkardelMYNAME=`IFS=. ; set $IAM ; echo $1` 6abb0f93cSkardelSIG= 7abb0f93cSkardel 8abb0f93cSkardelcase "$1" in 9abb0f93cSkardel 0.*) 10abb0f93cSkardel SIG=$1 11abb0f93cSkardel shift 12abb0f93cSkardel CONFIG_ARGS="$@" 13abb0f93cSkardel KEY=`sed -e q < .buildkey-$MYNAME` 14abb0f93cSkardel case "$SIG" in 15abb0f93cSkardel $KEY) ;; 16abb0f93cSkardel *) 17abb0f93cSkardel echo "Wrong directory for build on host $IAM" 18abb0f93cSkardel echo "This is <`pwd`>" 19abb0f93cSkardel echo "SIG is <$SIG>" 20abb0f93cSkardel echo "KEY is <$KEY>" 21abb0f93cSkardel exit 1 22abb0f93cSkardel ;; 23abb0f93cSkardel esac 24abb0f93cSkardel ;; 25abb0f93cSkardel *) 26abb0f93cSkardel CONFIG_ARGS="$@" 27abb0f93cSkardel ;; 28abb0f93cSkardelesac 29abb0f93cSkardel 30abb0f93cSkardel#set -e 31abb0f93cSkardel#set -x 32abb0f93cSkardel 338585484eSchristosif [ ! -r sntp/libevent/build-aux/config.guess ] ; then 348585484eSchristos echo "Error: bootstrap required." 1>&2 && exit 1 358585484eSchristosfi 36abb0f93cSkardel 378585484eSchristos# sntp/scripts/cvo.sh invokes config.guess, and we want it to use the copy 388585484eSchristos# in the build-aux directory if there's not another config.guess earlier 398585484eSchristos# on the path, so we invoke it using env to append to the PATH. 408585484eSchristos 418585484eSchristosCVO=`env PATH="$PATH:./sntp/libevent/build-aux" sntp/scripts/cvo.sh @cvo@` 42abb0f93cSkardelcase "$CVO" in 438585484eSchristos *-*-*-*) echo "sntp/scripts/cvo.sh returned <$CVO>, which makes no sense to me." 44abb0f93cSkardel exit 1 45abb0f93cSkardel ;; 46abb0f93cSkardel *-*-*) ;; 478585484eSchristos *) echo "sntp/scripts/cvo.sh returned <$CVO>, which makes no sense to me." 48abb0f93cSkardel exit 1 49abb0f93cSkardel ;; 50abb0f93cSkardelesac 51abb0f93cSkardel 52f003fb54Skardelcase "$NTP_BDIR" in 53f003fb54Skardel '') 54abb0f93cSkardel case "$IAM" in 55*067f5680Schristos *.ntp.org | *.ntfo.org) 56f003fb54Skardel NTP_BDIR=host 57f003fb54Skardel ;; 58abb0f93cSkardel *.udel.edu) 59f003fb54Skardel NTP_BDIR=host 60f003fb54Skardel # HMS: --enable-local-libopts is the default now... 61f003fb54Skardel #CONFIG_ARGS="$CONFIG_ARGS --enable-local-libopts" 62abb0f93cSkardel case "$CVO" in 63abb0f93cSkardel *-*-ultrix*) 64abb0f93cSkardel CONFIG_ARGS="$CONFIG_ARGS --with-libregex=/usr/local" 65abb0f93cSkardel ;; 66abb0f93cSkardel esac 67abb0f93cSkardel ;; 68abb0f93cSkardel *) 69f003fb54Skardel NTP_BDIR=cvo 70f003fb54Skardel ;; 71f003fb54Skardel esac 72f003fb54Skardel ;; 73f003fb54Skardelesac 74f003fb54Skardel 75f003fb54Skardelcase "$NTP_BDIR" in 76f003fb54Skardel host) 77f003fb54Skardel BASEDIR=A.$MYNAME 78f003fb54Skardel ;; 79f003fb54Skardel cvo) 80abb0f93cSkardel BASEDIR=A.$CVO 81abb0f93cSkardel ;; 82f003fb54Skardel *) 83f003fb54Skardel echo "build: NTP_BDIR must be either 'cvo' or 'host'!" 1>&2 84f003fb54Skardel exit 1 85f003fb54Skardel ;; 86abb0f93cSkardelesac 87abb0f93cSkardel 88abb0f93cSkardelKEYSUF="" 89abb0f93cSkardel 90abb0f93cSkardelcase "$CONFIG_ARGS" in 91abb0f93cSkardel *--with-crypto=autokey*) 92abb0f93cSkardel KEYSUF="-autokey" 93abb0f93cSkardel ;; 94abb0f93cSkardel *--without-crypto*) 95abb0f93cSkardel KEYSUF="-noopenssl" 96abb0f93cSkardel ;; 97abb0f93cSkardelesac 98abb0f93cSkardel 99abb0f93cSkardelcase "$CONFIG_ARGS" in 100abb0f93cSkardel *--disable-all-clocks*) 101abb0f93cSkardel KEYSUF="$KEYSUF-no-refclocks" 102abb0f93cSkardel ;; 103abb0f93cSkardelesac 104abb0f93cSkardel 105abb0f93cSkardelcase "$CONFIG_ARGS" in 106abb0f93cSkardel *--disable-debugging*) 107abb0f93cSkardel KEYSUF="$KEYSUF-nodebug" 108abb0f93cSkardel ;; 109abb0f93cSkardelesac 110abb0f93cSkardel 111abb0f93cSkardelcase "$CC" in 112f003fb54Skardel '') 113f003fb54Skardel CCSUF="" 114f003fb54Skardel ;; 115f003fb54Skardel *) 116f003fb54Skardel CCSUF="-`echo $CC | sed -e 's: :_:g' -e's:/:+:g'`" 117abb0f93cSkardel ;; 118abb0f93cSkardelesac 119abb0f93cSkardel 120abb0f93cSkardelBDIR="$BASEDIR$KEYSUF$CCSUF" 121abb0f93cSkardel 122abb0f93cSkardel[ -d "$BDIR" ] || mkdir $BDIR 123abb0f93cSkardel[ -f "$BDIR/.buildcvo" ] || echo $CVO > $BDIR/.buildcvo 124abb0f93cSkardel[ -f "$BDIR/.buildhost" ] || echo $IAM > $BDIR/.buildhost 125abb0f93cSkardel 126abb0f93cSkardel 127abb0f93cSkardelcd $BDIR 128abb0f93cSkardel 129abb0f93cSkardel# 130abb0f93cSkardel# Make sure we have a nice that works. 131f003fb54Skardel# To disable use of nice, setenv NO_NICE_BUILD=1 132abb0f93cSkardel# 133f003fb54SkardelNICEB= 134f003fb54Skardel[ "$NO_NICE_BUILD" != "1" ] && nice true && NICEB=nice 135f003fb54Skardel[ -z "$NICEB" ] && { 136f003fb54Skardel NICEB="./.nicebuild-$MYNAME-$SIG" 137f003fb54Skardel cat > $NICEB <<-HEREDOC 138abb0f93cSkardel #! /bin/sh 139abb0f93cSkardel shift 140abb0f93cSkardel \$* 141abb0f93cSkardelHEREDOC 142f003fb54Skardel chmod +x $NICEB 143abb0f93cSkardel} 144abb0f93cSkardel 145f003fb54Skardel# 146f003fb54Skardel# Find a test which supports -nt, unlike Solaris /bin/sh builtin. 147f003fb54Skardel# 148f003fb54SkardelTEST="${TEST-}" 149f003fb54Skardelif [ -z "$TEST" ] ; then 150f003fb54Skardel for try in test /bin/test /usr/bin/test ; do 151f003fb54Skardel case `$try config.status -nt ../configure 2>&1` in 152f003fb54Skardel '') 153f003fb54Skardel TEST="$try" 154f003fb54Skardel # echo "Using $TEST" 155f003fb54Skardel break 156abb0f93cSkardel ;; 157abb0f93cSkardel esac 158f003fb54Skardel done 159f003fb54Skardel if [ -z "$TEST" ] ; then 160f003fb54Skardel echo "build: need help finding test binary" 1>&2 161f003fb54Skardel exit 1 162f003fb54Skardel fi 163f003fb54Skardelfi 164f003fb54Skardel 165b5bbe2e3SchristosCONFIGURE="../configure" 166b5bbe2e3Schristos# We need KEYSUF because of RAND_ and others, and -noopenssl" 167b5bbe2e3Schristos#CONFIGURE="$CONFIGURE --cache-file=../config.cache-$IAM$KEYSUF$CCSUF" 168b5bbe2e3SchristosCONFIGURE="$CONFIGURE $CONFIG_ARGS" 169b5bbe2e3Schristos 170f003fb54Skardel 171f003fb54Skardel( # This sequence of commands is logged to make.log. 172f003fb54Skardel # If config.status is newer than ../configure, and the same 173f003fb54Skardel # is true for sntp, we do not need to re-run configure. 1748585484eSchristos # For libevent, the twist is we may not be configuring the 1758585484eSchristos # tearoff, so only act if its config.status exists. 176f003fb54Skardel # Solaris /bin/sh doesn't grok -nt. 177f003fb54Skardel 178f003fb54Skardel ( "$TEST" config.status -nt ../configure && 1798585484eSchristos "$TEST" sntp/config.status -nt ../sntp/configure && 1808585484eSchristos ( "$TEST" '!' -f sntp/libevent/config.status || 1818585484eSchristos "$TEST" sntp/libevent/config.status -nt ../sntp/libevent/configure ) ) || 182f003fb54Skardel "$NICEB" -7 $CONFIGURE 1838585484eSchristos "$TEST" Makefile -nt config.status || 1848585484eSchristos "$NICEB" -5 ./config.status 1858585484eSchristos "$TEST" sntp/Makefile -nt sntp/config.status || 1868585484eSchristos ( cd sntp && "$NICEB" -5 ./config.status ) 1878585484eSchristos "$TEST" '!' -f sntp/libevent/Makefile || 1888585484eSchristos "$TEST" sntp/libevent/Makefile -nt sntp/libevent/config.status || 1898585484eSchristos ( cd sntp/libevent && "$NICEB" -5 ./config.status ) 1908585484eSchristos "$NICEB" -14 ${MAKE-make} && "$NICEB" -11 ${MAKE-make} check 191abb0f93cSkardel) > $LOGF 2>&1 192abb0f93cSkardel 193f003fb54SkardelEXITCODE=$? 194abb0f93cSkardel 195abb0f93cSkardel# clean up if we made a dummy nice script 196f003fb54Skardelcase "$NICEB" in 197f003fb54Skardel nice) 198f003fb54Skardel ;; 199f003fb54Skardel *) 200f003fb54Skardel rm "$NICEB" 201f003fb54Skardel ;; 202f003fb54Skardelesac 203f003fb54Skardel 204f003fb54Skardelexit $EXITCODE 205