#!/bin/sh # # ctg # # David Adams # January 2005 # # Entry point for ctest_gnu, an implementation of CTEST # based on the GNU building tools, autoconf and automake. ######################################################################## # Main program ######################################################################## # Extract command line options and set corresponding flags ARGS="$*" HELP= UPDATE= GNUFILES= BUILD_DIR= MAKE_DIRS= CLEAN= ENVIR= TEST= BUILD= INSURE= ERROR=0 while getopts hugdbtice: OPT; do case $OPT in h) HELP=true;; u) UPDATE=true;; g) GNUFILES=true;; d) BUILD_DIR=true; MAKE_DIRS=true;; b) BUILD=true;; t) TEST=true;; i) INSTALL=true;; c) CLEAN=true;; *) exit 1;; esac done shift $(( OPTIND - 1 )) if [ -n "$HELP" ]; then echo "$0 OPTS FULLPKG" echo " -u CVS update or checkout" echo " -g package_name (generate shared GNU build files)" echo " -d package_name (generate GNU build directory)" echo " -b package_name (build)" echo " -t package_name (test)" echo " -i package_name (install at the head of CTG_INSPATH)" echo " -c package_name (clean)" exit 0 fi # Find the package directory. # PKGDIR is the top directory of the package. # PKG is the package name. NARG=$# if [ $NARG != 1 ]; then echo "CTG: Found $NARG package names" echo "CTG: $*" echo "CTG: Call with 1 package name" exit 1 fi FULLPKG=$1 LASTPKG=`cat $DEVDIR/ctgpkgs.dat 2>/dev/null | sed 's/:.*//'` DEVDIR=`ctg_devdir` PKGDIR=$DEVDIR/$FULLPKG CHECKOUT= # Check existence of package directory. if [ ! -d $PKGDIR ]; then if [ -z "$UPDATE" ]; then echo "CTG: Unable to find package directory:" echo "CTG: $PKGDIR" exit 2 fi else # Check existence of VERSION. if [ ! -r $PKGDIR/VERSION ]; then echo "CTG: Unable to find VERSION at" echo "CTG: $PKGDIR/VERSION" exit 3 fi fi PKG=`basename $PKGDIR` echo "CTG: Building package $FULLPKG for $CTG_PLATFORM at" echo "CTG: $PKGDIR" ######################################################################## # Clean. MAKEDIRS=`cat $PKGDIR/MAKEDIRS 2>/dev/null` BLDDIR=$PKGDIR/build/build-$CTG_PLATFORM LINSDIR=$PKGDIR/build/$CTG_PLATFORM if [ -n "$CLEAN" ]; then echo "CTG: Cleaning" echo "CTG: Removing build directories" rm -rf $BLDDIR rm -rf $LINSDIR rmdir $PKGDIR/build 1>/dev/null 2>&1 echo "CTG: Cleaning prebuild makes" if [ -n "$MAKEDIRS" ]; then for DIR in $MAKEDIRS; do cd $PKGDIR/$DIR for name in Makefile CompMakefile DepMakefile; do if [ -r $name ]; then echo "CTG: $DIR/$name" make -f $name clean S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi fi # Remove generated makefile. if [ -r Makefile -a -r Makefile.in ]; then rm Makefile fi done cd $PKGDIR done fi echo "CTG: Removing FULLDEPS" rm -f $PKGDIR/FULLDEPS echo "CTG: Removing gbuild" rm -rf $PKGDIR/gbuild fi ######################################################################## # Update (or check out) from CVS. if [ -n "$UPDATE" ]; then echo "CTG: CVS update or checkout" cd $DEVDIR if [ -d $PKGDIR ]; then echo "CTG: Update" cvs update $FULLPKG S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi else echo "CTG: Checkout" cvs checkout $FULLPKG S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi fi # We must update MAKEDIRS because update may have changed it. MAKEDIRS=`cat $PKGDIR/MAKEDIRS 2>/dev/null` fi ######################################################################## # Install the GNU build input files. GINDIR=$PKGDIR/gbuild ACFILE=$GINDIR/configure.ac AMFILE=$GINDIR/Makefile.am if [ -n "$GNUFILES" ]; then echo "CTG: Platform-independent configuration" if [ ! -d $GINDIR ]; then echo "CTG: Creating $GINDIR" echo "CTG: Add this to CVS" mkdir $GINDIR fi # Process dependency makefiles. echo "CTG: Generating dependencies" if [ -n "$MAKEDIRS" ]; then for DIR in $MAKEDIRS; do if [ -r $PKGDIR/$DIR/DepMakefile ]; then echo "CTG: Making in $DIR" cd $PKGDIR/$DIR make -f DepMakefile S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi cd $PKGDIR fi done fi # Expand dependencies. echo "CTG: Expanding dependencies" rm -f $PKGDIR/FULLDEPS if [ $FULLPKG = ctest/ctest_gnu ]; then echo ctest/ctest_gnu > $PKGDIR/FULLDEPS else depexpand LIBDEPS $FULLPKG `ctg_devdirs` > $PKGDIR/FULLDEPS fi S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi # Process component makefiles. echo "CTG: Generating component desciptions" if [ -n "$MAKEDIRS" ]; then for DIR in $MAKEDIRS; do if [ -r $PKGDIR/$DIR/CompMakefile ]; then echo "CTG: Making in $DIR" cd $PKGDIR/$DIR make -f CompMakefile S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi cd $PKGDIR fi done fi echo "CTG: Running ctg_make_acfile" # Create configuration file. ctg_make_acfile $PKGDIR > $ACFILE S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi # Create build make file. echo "CTG: Running ctg_make_amfile" ctg_make_amfile $PKGDIR > $AMFILE S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi fi ######################################################################## # Create the GNU build directory. if [ -n "$BUILD_DIR" ]; then echo "CTG: Platform-specific configuration" if [ ! -d $BLDDIR ]; then echo "CTG: $BLDDIR" mkdir -p $BLDDIR fi rm -rf $BLDDIR/* if [ ! -r $ACFILE ]; then echo "CTG: Unable to find $ACFILE" exit 21 fi if [ ! -r $AMFILE ]; then echo "CTG: Unable to find $AMFILE" exit 22 fi cp $ACFILE $BLDDIR cp $AMFILE $BLDDIR # Find the location of the libtool M4 macros. LTEXE=`which libtool` LTM4=`dirname $LTEXE` LTM4=`dirname $LTM4`/share/aclocal # GNU confguration. SAVEPWD=`pwd` cd $BLDDIR pwd touch NEWS README AUTHORS ChangeLog echo "CTG: Running libtoolize" libtoolize -f > libtoolize.log 2>&1 S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi echo "CTG: Running aclocal" aclocal -I $LTM4 > aclocal.log 2>&1 S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi echo "CTG: Running autoconf" autoconf > autoconf.log 2>&1 S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi echo "CTG: Running automake" automake -a > automake.log 2>&1 S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi echo "CTG: Running configure" configure --prefix=$LINSDIR > configure.log 2>&1 S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi cd $SAVEPWD echo "CTG: Checking makefile" if [ ! -r $BLDDIR/Makefile ]; then echo "CTG: GNU configuration failed" exit 23 fi fi ######################################################################## # Process prebuild makefiles. if [ -n "$MAKE_DIRS" ]; then echo "CTG: Processing prebuild makefiles" if [ -n "$MAKEDIRS" ]; then for DIR in $MAKEDIRS; do if [ -r $PKGDIR/$DIR/Makefile ]; then echo "CTG: Making in $DIR" cd $PKGDIR/$DIR make S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi cd $PKGDIR fi done fi fi ######################################################################## # Build library and binaries. if [ -n "$BUILD" ]; then echo "CTG: Building" if [ ! -d $BLDDIR ]; then echo "CTG: Unable to find build directory at" echo "CTG: $BLDDIR" echo "CTG: Use option -d to generate this directory" exit 31 fi SAVEPWD=`pwd` cd $BLDDIR # First execute external setup--this helped with linking # possibly conflicting libraries on RH73. echo " CTG: Making external setup script" make extsetup.sh . ./extsetup.sh echo " CTG: Making all" make S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi echo " CTG: Making (local) install" make install S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi fi ######################################################################## # Run tests CTEST=$TEST BTEST=$TEST if [ -n "$CTEST" ]; then echo "CTG: Testing" echo "CTG: Testing external setup script" ctg_test_setup $LINSDIR/bin/extsetup.sh S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi echo "CTG: Testing build setup script" ctg_test_setup $LINSDIR/bin/bldsetup.sh S=$?; if [ $S -ne 0 ]; then echo Error $S; exit $S; fi echo "CTG: Running component tests" NOTESTS=true if [ -r $PKGDIR/COMPONENTS ]; then CMPS=`cat $PKGDIR/COMPONENTS` if [ -n "$CMPS" ]; then NOTESTS=false for CMP in $CMPS; do echo "CTG: Testing $CMP" ctg_run_ctest $PKGDIR $CMP STAT=$? if [ $STAT -ne 0 ]; then exit 41 fi done echo "CTG: All component tests succeeded" fi fi if [ $NOTESTS = true ]; then echo "CTG: No component tests run--unable to read component list at" echo "CTG: $PKGDIR/COMPONENTS" fi fi if [ -n "$BTEST" ]; then echo "CTG: Running binary tests" NOTESTS=true if [ -r $PKGDIR/BINARIES ]; then CMPS=`cat $PKGDIR/BINARIES` if [ -n "$CMPS" ]; then NOTESTS=false for CMP in $CMPS; do echo "CTG: Testing $CMP" ctg_run_btest $PKGDIR $CMP STAT=$? if [ $STAT -ne 0 ]; then exit 41 fi done echo "CTG: All binary tests succeeded" fi fi if [ $NOTESTS = true ]; then echo "CTG: No binary tests run--unable to find binary list at" echo "CTG: $PKGDIR/BINARIES" fi echo "CTG: All tests succeeded" fi ######################################################################## # Install. GINSDIR=`ctg_insdir` if [ -n "$INSTALL" ]; then echo "CTG: Installing" if [ -z "$GINSDIR" ]; then echo "CTG: Installation path CTG_INSPATH is not defined" exit 51 fi if [ ! -d "$GINSDIR" ]; then mkdir -p $GINSDIR STAT=$? if [ $STAT != 0 ]; then echo "CTG: Unable to create installation directory at" echo "CTG: $GINSDIR" exit 52 fi fi echo "CTG: $GINSDIR" if [ "$PKG" = "$LASTPKG" ]; then # Create list of packages. echo "CTG: Creating package list" ctg_tags > $GINSDIR/ctgpkgs.dat STAT=$? if [ $STAT != 0 ]; then echo "CTG: ctg_tags failed with error $STAT" #exit 53 fi # Create list of external packages. echo "CTG: Creating external package list" ctg_externals > $GINSDIR/ctgexts.dat if [ $STAT != 0 ]; then echo "CTG: ctg_externals failed with error $STAT" exit 54 fi fi # headers HDRDIR=$PKGDIR/$PKG INCDIR=$GINSDIR/include if [ ! -d $INCDIR ]; then mkdir -p $INCDIR fi if [ -d $HDRDIR ]; then echo "CTG: Installing headers" rm -rf $INCDIR/$PKG mkdir $INCDIR/$PKG cp $HDRDIR/*.h $INCDIR/$PKG fi # library if [ ! -d $GINSDIR/lib ]; then mkdir -p $GINSDIR/lib fi LIB=$LINSDIR/lib/lib$PKG.so.*.*.* if [ -r $LIB ]; then echo "CTG: Installing library" BLIB=`basename $LIB` BLIB1=`echo $BLIB | awk -F . '{print $1"."$2}'` BLIB2=`echo $BLIB | awk -F . '{print $1"."$2"."$3}'` NEWLIB=$GINSDIR/lib/$BLIB LINK1=$GINSDIR/lib/$BLIB1 LINK2=$GINSDIR/lib/$BLIB2 rm -f $NEWLIB $LINK1 $LINK2 cp $LIB $NEWLIB SAVEDIR=`pwd` cd $GINSDIR/lib ln -s $BLIB $LINK1 ln -s $BLIB $LINK2 cd $SAVEDIR fi # binaries BINDIR=$LINSDIR/bin if [ ! -d $GINSDIR/bin ]; then mkdir -p $GINSDIR/bin fi if [ ! -d $GINSDIR/sbin ]; then mkdir -p $GINSDIR/sbin fi if [ -d $BINDIR ]; then echo "CTG: Installing binaries" FILES=`find $BINDIR/* 2>/dev/null` if [ -n "$FILES" ]; then for FILE in $FILES; do BASE=`basename $FILE` DESTFILE=$GINSDIR/bin/$BASE if [ $FILE = $BINDIR/extsetup.sh ]; then DESTFILE=$GINSDIR/sbin/extsetup_$PKG.sh else if [ $FILE = $BINDIR/bldsetup.sh ]; then continue; fi; fi echo "CTG: "$BASE cp $FILE $DESTFILE done fi fi # data DATAFILES=`cat $PKGDIR/DATA 2>/dev/null` DATADEST=$GINSDIR/data/$PKG if [ -n "$DATAFILES" ]; then if [ ! -d $DATADEST ]; then mkdir -p $DATADEST fi for FILE in $DATAFILES; do cp -r $PKGDIR/$FILE $GINSDIR/data/$PKG done # Strip CVS directories. CVSDIRS=`find $GINSDIR/data/$PKG -name CVS` rm -rf $CVSDIRS fi fi ######################################################################## echo "CTG: Success!" ########################################################################