#!/bin/ksh # -------------------------------------------------------------------- # buildlib : generates source files and libraries from a Patchy # set of directives contained in a cradle # -------------------------------------------------------------------- cmd=`basename $0` usage="usage: $cmd [-ndph] CarFile " debug=0 pool=0 version='pro' allopt=$@ while getopts nhdp xopt ; do case $xopt in n) version='dev';; d) debug=1 ;; p) pool=1 ;; 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 echo 'It is possible to force the loading of the DEV version ' echo 'explicitely by specifying the "n" option switch. ' echo echo 'The fortran files are written in the "src" directory. ' echo 'The library file is written in the "lib" directory. ' echo echo 'The "CarFile" argument should be the file name only, ' echo 'excluding the directory path.' echo echo 'switches -optional:' echo '-h prints this help message' echo '-n use the "dev" path for CAR file search (default:pro)' echo '-d turns ON the debug compiler option' echo '-p turns ON the code for "daq pool" input' echo ------------------------------------------------------------------------ echo $usage exit 9;; \?) 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 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 f77_opt="-c " if [ $debug = 1 ] ; then f77_opt="-c -g " ; fi machineflag='PClinux' objdir='PClinux' fi if [ ${OPSYS} = 'OSF1' ] ; then f77_opt="-c " if [ $debug = 1 ] ; then f77_opt="-c -g " ; fi machineflag='Alpha' objdir='Alpha' fi USER=${USER:=`whoami`} log=`date`" $USER $cmd $allopt" echo $log echo " operating system: " $OPSYS # debugflag='nodebug' poolflag='nopool' if [ $debug = 1 ] ; then debugflag='debug' ; fi if [ $pool = 1 ] ; then poolflag='pool' ; fi echo "patchy flags= " $machineflag $debugflag $poolflag 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 mkdir ${srcdir} ; fi fdir=${srcdir}/${carfile}.fdir if [ -d ${fdir} ]; then rm -r $fdir; fi mkdir ${fdir}; 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 tty - - - - .go +exe. +use,type. +use,unix. +use,$debugflag. +use,$machineflag. +use,$poolflag. +use,*ariane. +pam,12,t=attach,t=cards. $carfile +quit ! # #------------------------------------------------------------------- # Preparing $carfile.fca for splitting the Fortran source. # cd ${srcdir} 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` f77 $f77_opt -o $name.o $i done for i in *.c do if [ -r $i ] ; then name=`basename $i .c` cc -c -o $name.o $i fi done #------------- move pool.o to lib directory if [ -f ${libdir}/pool.o.bak ] ; then rm ${libdir}/pool.o.bak fi if [ -f ${libdir}/pool.o ]; then mv ${libdir}/pool.o ${libdir}/pool.o.bak fi if [ -f pool.o ] ; then mv pool.o ${libdir} ; fi #------------------------------------------------------------------- # create archive library in directory ${wdir}/lib/${objdir}/ # if [ -f ${libdir}/${carfile}.a.bak ] ; then rm ${libdir}/${carfile}.a.bak fi if [ -f ${libdir}/${carfile}.a ]; then mv ${libdir}/${carfile}.a ${libdir}/${carfile}.a.bak fi ar -q ${libdir}/${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