#!/bin/ksh # -------------------------------------------------------------------- # buildgraf : generates graphics source files and libraries from a # Patchy set of directives contained in a cradle # -------------------------------------------------------------------- cmd=`basename $0` usage="usage: $cmd [-ndh] CarFile " debug=0 version='pro' allopt=$@ while getopts nhd xopt ; do case $xopt in n) version='dev';; h) # help message: echo $cmd script makes fortran files and library from the ".car" echo file given in the argument according to "CRADLE" instructions. echo 'The cradle, within this script, specifies the FLAGS and ' echo 'PATCHES for ypatchy execution.' echo 'It is possible to force the loading of the DEV version ' echo 'explicitely by specifying the "n" option switch. ' echo 'The fortran files are written in the "src" directory. ' echo 'The library file is written in the "lib" directory. ' echo 'The "CarFile" argument should be the file name only, ' echo 'excluding the directory path.' echo switches \(optional\): echo -h prints this help message echo -n use the "dev" path for CAR file search \(default: pro path\) echo -d turns ON the debug compiler option echo ------------------------------------------------------------------------ echo $usage exit 9;; d) debug=1 ;; \?) echo unknown option $xopt; echo $usage; exit 9;; esac done shift `expr $OPTIND - 1 ` if [ $# -le 0 ]; then echo file argument missing echo $usage exit 9 fi OPSYS=${OPSYS:=`uname`} # carfile=`basename $1 .car` # # set defaults to hpux fcomp='f77' ccomp='cc' objdir='hpux' machineflag='hpux' f77_opt="+es -c -O +ppu +e +T " if [ $debug = 1 ] ; then f77_opt="+es -c -O -K +ppu +e +T -g " ; fi if [ ${OPSYS} = 'AIX' ] ; then f77_opt="-c -qextname =qnosave -w " if [ $debug = 1 ] ; then f77_opt="-c -qextname -w -g " ; fi machineflag='aix' objdir='aix' fi if [ ${OPSYS} = 'Linux' ] ; then fcomp='g77' ccomp='gcc' f77_opt="-c -w " if [ $debug = 1 ] ; then f77_opt="-c -w -g " ; fi machineflag='PClinux' objdir='PClinux' fi USER=${USER:=`whoami`} log=`date`" $USER $cmd $allopt" echo $log echo " operating system: " $OPSYS # debugflag='nodebug' if [ $debug = 1 ] ; then debugflag='debug' ; fi echo "machineflag= " $machineflag $debugflag echo "compiler options: " $f77_opt #------------------------------------------------------------------- # Define needed directories wdir="/afs/cern.ch/user/d/diracww/public/offline/ariane/${version}" srcdir=${wdir}/src/${objdir} if [ -d ${srcdir} ]; then echo "DIR: ${srcdir} Exists " else echo "DIR: ${srcdir} will be created" mkdir ${srcdir}; fi fdir=${srcdir}/${carfile}.fdir if [ -d ${fdir} ]; then echo "DIR: ${fdir} Exists: clear it " rm -f ${fdir}/*fca rm -f ${fdir}/*.f rm -f ${fdir}/*.o else echo "DIR: ${fdir} will be created" mkdir ${fdir}; fi libdir=${wdir}/lib/${objdir} if [ -d ${libdir} ]; then echo "DIR: ${libdir} Exists " else echo "DIR: ${libdir} will be created" mkdir ${libdir}; fi echo directories echo $wdir echo $srcdir echo $fdir echo $libdir #------------------------------------------------------------------- # Run patchy cd ${wdir}/car nypatchy <<! - ${srcdir}/${carfile}.fca tty - - - - .go +exe. +use,type,unix. +use,cdes. +use,Trcdes. +use,Header. +use,$debugflag. +use,$machineflag. +use,graf. +pam,13,r=Header,t=cards,t=attach. ariane +pam,14 ,t=cards,t=attach. graf +quit. ! # #------------------------------------------------------------------- # Preparing $carfile.fca for splitting the Fortran source. # cd ${srcdir} if [ -f ${carfile}.fca.bak ]; then rm ${carfile}.fca.bak; fi mv ${carfile}.fca $fdir #------------------------------------------------------------------- # split source into one file per subroutine or function cd $fdir fcasplit ${carfile}.fca #------------------------------------------------------------------- # compile splitted source files # for i in *.f do name=`basename $i .f` $fcomp $f77_opt -o $name.o $i done if [ -f *.c ]; then for i in *.c do if [ -r $i ] ; then name=`basename $i .c` $ccomp -c -o $name.o $i fi done fi #------------------------------------------------------------------- # create archive library in directory ${wdir}/lib/${objdir}/ # ldir="${wdir}/lib/${objdir}" if [ -f ${ldir}/${carfile}.a.bak ]; then rm ${ldir}/${carfile}.a.bak fi if [ -f ${ldir}/${carfile}.a ]; then mv ${ldir}/${carfile}.a ${ldir}/${carfile}.a.bak fi ar -q ${ldir}/${carfile}.a *.o # #------------------------------------------------------------------- # remove object decks rm -f *.o # #------------------------------------------------------------------- # remove sources if debugging not requested cd $wdir if [ $debug != 1 ] ; then if [ -d $fdir ]; then rm -r $fdir; fi fi