154359Sroberto#! /bin/sh 254359Sroberto 354359SrobertoLOGF=make.log 482498SrobertoIAM=`hostname || uname -n` 5200576SrobertoMYNAME=`IFS=. ; set $IAM ; echo $1` 6200576SrobertoSIG= 754359Sroberto 882498Srobertocase "$1" in 982498Sroberto 0.*) 1082498Sroberto SIG=$1 1182498Sroberto shift 1282498Sroberto CONFIG_ARGS="$@" 13200576Sroberto KEY=`sed -e q < .buildkey-$MYNAME` 1482498Sroberto case "$SIG" in 1582498Sroberto $KEY) ;; 1682498Sroberto *) 1782498Sroberto echo "Wrong directory for build on host $IAM" 18132451Sroberto echo "This is <`pwd`>" 19132451Sroberto echo "SIG is <$SIG>" 20132451Sroberto echo "KEY is <$KEY>" 21290001Sglebius exit 1 22290001Sglebius ;; 2382498Sroberto esac 2482498Sroberto ;; 2582498Sroberto *) 2682498Sroberto CONFIG_ARGS="$@" 2782498Sroberto ;; 2882498Srobertoesac 2954359Sroberto 3054359Sroberto#set -e 3154359Sroberto#set -x 3254359Sroberto 33290001Sglebiusif [ ! -r sntp/libevent/build-aux/config.guess ] ; then 34290001Sglebius echo "Error: bootstrap required." 1>&2 && exit 1 35290001Sglebiusfi 36290001Sglebius 37290001Sglebius# sntp/scripts/cvo.sh invokes config.guess, and we want it to use the copy 38290001Sglebius# in the build-aux directory if there's not another config.guess earlier 39290001Sglebius# on the path, so we invoke it using env to append to the PATH. 40290001Sglebius 41290001SglebiusCVO=`env PATH="$PATH:./sntp/libevent/build-aux" sntp/scripts/cvo.sh @cvo@` 4254359Srobertocase "$CVO" in 43290001Sglebius *-*-*-*) echo "sntp/scripts/cvo.sh returned <$CVO>, which makes no sense to me." 44290001Sglebius exit 1 45290001Sglebius ;; 4654359Sroberto *-*-*) ;; 47290001Sglebius *) echo "sntp/scripts/cvo.sh returned <$CVO>, which makes no sense to me." 4854359Sroberto exit 1 4954359Sroberto ;; 5054359Srobertoesac 5154359Sroberto 52290001Sglebiuscase "$NTP_BDIR" in 53290001Sglebius '') 54290001Sglebius case "$IAM" in 55290001Sglebius *.ntp.org) 56290001Sglebius NTP_BDIR=host 57182007Sroberto ;; 58290001Sglebius *.udel.edu) 59290001Sglebius NTP_BDIR=host 60290001Sglebius # HMS: --enable-local-libopts is the default now... 61290001Sglebius #CONFIG_ARGS="$CONFIG_ARGS --enable-local-libopts" 62290001Sglebius case "$CVO" in 63290001Sglebius *-*-ultrix*) 64290001Sglebius CONFIG_ARGS="$CONFIG_ARGS --with-libregex=/usr/local" 65290001Sglebius ;; 66290001Sglebius esac 67290001Sglebius ;; 68290001Sglebius *) 69290001Sglebius NTP_BDIR=cvo 70290001Sglebius ;; 71290001Sglebius esac 72290001Sglebius ;; 73290001Sglebiusesac 74290001Sglebius 75290001Sglebiuscase "$NTP_BDIR" in 76290001Sglebius host) 77290001Sglebius BASEDIR=A.$MYNAME 7854359Sroberto ;; 79290001Sglebius cvo) 80290001Sglebius BASEDIR=A.$CVO 81290001Sglebius ;; 8254359Sroberto *) 83290001Sglebius echo "build: NTP_BDIR must be either 'cvo' or 'host'!" 1>&2 84290001Sglebius exit 1 8554359Sroberto ;; 8654359Srobertoesac 8754359Sroberto 8882498SrobertoKEYSUF="" 8982498Sroberto 9082498Srobertocase "$CONFIG_ARGS" in 9182498Sroberto *--with-crypto=autokey*) 9282498Sroberto KEYSUF="-autokey" 9382498Sroberto ;; 9482498Sroberto *--without-crypto*) 95132451Sroberto KEYSUF="-noopenssl" 9682498Sroberto ;; 9782498Srobertoesac 9882498Sroberto 99182007Srobertocase "$CONFIG_ARGS" in 100182007Sroberto *--disable-all-clocks*) 101182007Sroberto KEYSUF="$KEYSUF-no-refclocks" 102182007Sroberto ;; 103182007Srobertoesac 104182007Sroberto 105182007Srobertocase "$CONFIG_ARGS" in 106182007Sroberto *--disable-debugging*) 107182007Sroberto KEYSUF="$KEYSUF-nodebug" 108182007Sroberto ;; 109182007Srobertoesac 110182007Sroberto 11154359Srobertocase "$CC" in 112290001Sglebius '') 113290001Sglebius CCSUF="" 11454359Sroberto ;; 115290001Sglebius *) 116290001Sglebius CCSUF="-`echo $CC | sed -e 's: :_:g' -e's:/:+:g'`" 117290001Sglebius ;; 11854359Srobertoesac 11954359Sroberto 120290001SglebiusBDIR="$BASEDIR$KEYSUF$CCSUF" 12154359Sroberto 12254359Sroberto[ -d "$BDIR" ] || mkdir $BDIR 12354359Sroberto[ -f "$BDIR/.buildcvo" ] || echo $CVO > $BDIR/.buildcvo 12454359Sroberto[ -f "$BDIR/.buildhost" ] || echo $IAM > $BDIR/.buildhost 12554359Sroberto 126200576Sroberto 12754359Srobertocd $BDIR 12854359Sroberto 129200576Sroberto# 130290001Sglebius# Make sure we have a nice that works. 131290001Sglebius# To disable use of nice, setenv NO_NICE_BUILD=1 132200576Sroberto# 133290001SglebiusNICEB= 134290001Sglebius[ "$NO_NICE_BUILD" != "1" ] && nice true && NICEB=nice 135290001Sglebius[ -z "$NICEB" ] && { 136290001Sglebius NICEB="./.nicebuild-$MYNAME-$SIG" 137290001Sglebius cat > $NICEB <<-HEREDOC 138290001Sglebius #! /bin/sh 139290001Sglebius shift 140290001Sglebius \$* 141290001SglebiusHEREDOC 142290001Sglebius chmod +x $NICEB 143290001Sglebius} 144200576Sroberto 145290001Sglebius# 146290001Sglebius# Find a test which supports -nt, unlike Solaris /bin/sh builtin. 147290001Sglebius# 148290001SglebiusTEST="${TEST-}" 149290001Sglebiusif [ -z "$TEST" ] ; then 150290001Sglebius for try in test /bin/test /usr/bin/test ; do 151290001Sglebius case `$try config.status -nt ../configure 2>&1` in 152290001Sglebius '') 153290001Sglebius TEST="$try" 154290001Sglebius # echo "Using $TEST" 155290001Sglebius break 156290001Sglebius ;; 157290001Sglebius esac 158290001Sglebius done 159290001Sglebius if [ -z "$TEST" ] ; then 160290001Sglebius echo "build: need help finding test binary" 1>&2 161290001Sglebius exit 1 162290001Sglebius fi 163290001Sglebiusfi 164200576Sroberto 165290001SglebiusCONFIGURE="../configure" 166290001Sglebius# We need KEYSUF because of RAND_ and others, and -noopenssl" 167290001Sglebius#CONFIGURE="$CONFIGURE --cache-file=../config.cache-$IAM$KEYSUF$CCSUF" 168290001SglebiusCONFIGURE="$CONFIGURE $CONFIG_ARGS" 16954359Sroberto 17082498Sroberto 171290001Sglebius( # This sequence of commands is logged to make.log. 172290001Sglebius # If config.status is newer than ../configure, and the same 173290001Sglebius # is true for sntp, we do not need to re-run configure. 174290001Sglebius # For libevent, the twist is we may not be configuring the 175290001Sglebius # tearoff, so only act if its config.status exists. 176290001Sglebius # Solaris /bin/sh doesn't grok -nt. 177290001Sglebius 178290001Sglebius ( "$TEST" config.status -nt ../configure && 179290001Sglebius "$TEST" sntp/config.status -nt ../sntp/configure && 180290001Sglebius ( "$TEST" '!' -f sntp/libevent/config.status || 181290001Sglebius "$TEST" sntp/libevent/config.status -nt ../sntp/libevent/configure ) ) || 182290001Sglebius "$NICEB" -7 $CONFIGURE 183290001Sglebius "$TEST" Makefile -nt config.status || 184290001Sglebius "$NICEB" -5 ./config.status 185290001Sglebius "$TEST" sntp/Makefile -nt sntp/config.status || 186290001Sglebius ( cd sntp && "$NICEB" -5 ./config.status ) 187290001Sglebius "$TEST" '!' -f sntp/libevent/Makefile || 188290001Sglebius "$TEST" sntp/libevent/Makefile -nt sntp/libevent/config.status || 189290001Sglebius ( cd sntp/libevent && "$NICEB" -5 ./config.status ) 190290001Sglebius "$NICEB" -14 ${MAKE-make} && "$NICEB" -11 ${MAKE-make} check 191290001Sglebius) > $LOGF 2>&1 192290001Sglebius 193290001SglebiusEXITCODE=$? 194290001Sglebius 195290001Sglebius# clean up if we made a dummy nice script 196290001Sglebiuscase "$NICEB" in 197290001Sglebius nice) 198290001Sglebius ;; 199290001Sglebius *) 200290001Sglebius rm "$NICEB" 201290001Sglebius ;; 20254359Srobertoesac 203290001Sglebius 204290001Sglebiusexit $EXITCODE 205