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