#!/bin/sh
#
# $Id: build.me,v 1.11 2014/05/16 20:38:39 ucko Exp $
#
# W A R N I N G ! ! !
# That script is intended for internal use in NCBI only
#
#

#check that we're running within NCBI
MYDOMAIN=`grep '^domain' /etc/resolv.conf |awk '{print $2}'`
test -z "$MYDOMAIN"  &&  \
    MYDOMAIN="`hostname | grep '\.'  ||  hostname --fqdn 2>/dev/null`"
test -z "$MYDOMAIN"  &&  MYDOMAIN="`domainname`"
if [ `echo "$MYDOMAIN" | grep -c 'nlm[.]nih[.]gov$'` != 1 ] ; then
    echo That script is intended for internal use in NCBI only
    exit 1
fi

SCRIPTDIR=/am/ncbiapdata/scripts/build
CWD=`pwd`
UPDIR=`dirname $CWD`
MYDIR=`basename $CWD`
if [ "$MYDIR" != "ncbi" ] ; then
	echo that script should be located in \"ncbi\" directory
	exit 1;
fi

echo "Rebuilding ASNs..."
#first rebuild the asn
$SCRIPTDIR/rebuild_asn $CWD
if [ "$?" != 0 ] ; then
	echo rebuild_asn failed, bye...
	exit 1
fi

#now make needed directories if they're absent
mkdir -p include bin lib build altlib shlib >/dev/null 2>&1

#now start the build
cd .. && time $SCRIPTDIR/makedis.csh 2>&1 | tee $CWD/out.makedis.csh

exit 0
