#!/bin/csh
# $1 = -c : clean
#    = -h help

unset C
if( "$1" == '-h' ) then
  echo "usage comp_all [-c]"
  echo "    -c : Clean"
  echo "ex:   time ./comp_all    |& tee -a comp.log_${SOPHYACXX}_`uname`"
  echo "ex:   time ./comp_all -c |& tee    comp.log_${SOPHYACXX}_`uname`"
  exit -1
else
  while( $#argv>0 )
    if( "$1" == "-c") set C
    shift
  end
endif
 
set HERE = `pwd`
echo vous etes dans: $HERE
if ( ! $?SOPHYABASEREP ) then
  echo variable SOPHYABASEREP non definie
  exit -1
endif
echo variable SOPHYABASEREP = $SOPHYABASEREP
echo variable SOPHYACXX = $SOPHYACXX
set diru = $SOPHYABASEREP/`uname`-$SOPHYACXX
echo repertoire pour les obj/lib/exe DPC: ${diru}
echo DEBUT DE COMPILATION `date`
echo "----"; echo "----"; echo "----"; echo "----"; echo "----";
echo "----"; echo "----"; echo "----"; echo "----"; echo "----";
echo "----"; echo "----"; echo "----"; echo "----"; echo "----";
echo "----"; echo "----"; echo "----"; echo "----"; echo "----";

echo =========== preparation des makefiles speciales

ln -sf ./Mgr/Makefile .

### Sur OSF, pour avoir "-blas" a la place de "-dxml" changer dans GNUmakefile
###          et dans MakefileUser.h
set sopmakefile = GNUmakefile
#set sopmakefile = Makefile
 
echo =========== clean
if( $?C ) then
  make clean
  rm -f ${diru}/Objs/*
  rm -f ${diru}/Libs/*
  rm -f ${diru}/ShLibs/*
  rm -f ${diru}/Exec/*
  ls -R ${diru}/.
endif

if( 0 ) then
echo =========== CodeMinuit
cd $HERE/CodeMinuit
make cleanall
make
make install
make cleanall
endif

echo =========== MinuitAdapt
cd $HERE/MinuitAdapt
if( $?C ) make clean
make
make install

if( 0 ) then
echo =========== XephemAstroLib
cd $HERE/XephemAstroLib
make clean
make
make install
make clean
endif

echo =========== XAstroPack
cd $HERE/XAstroPack
if( $?C ) make clean
make

if( 0 ) then
echo =========== SlaLib
cd $HERE/SlaLib
make clean
make
make install
make clean
endif

echo =========== libs
cd $HERE/.
make -f $sopmakefile libs

echo =========== slb
make -f $sopmakefile slb

echo =========== extlibs
# A installer pour les librairies exterieures:
# (cf procedure dans loglinux.help)
# - fftw version 2...
# - lapack
# - cfitsio
make -f $sopmakefile extlibs

echo =========== slbext
make -f $sopmakefile slbext

echo =========== PI
make -f $sopmakefile PI

echo =========== slbpi
make -f $sopmakefile slbpi

echo =========== ProgPI
cd $HERE/ProgPI
make -f Makefile

echo =========== PrgUtil
cd $HERE/PrgUtil
make -f Makefile

echo =========== PrgMap
cd $HERE/PrgMap
make -f Makefile

echo =========== Tests
cd $HERE/Tests
#set fexe = ( `ls -1 *.cc | awk -F"." '{print $1}'` )
set fexe = ( arrt carrt lpk obj_fits sphg0 tdcr tfft thash timg tobjio tobjio2 tspm tspm2 tstndblk tsttmat tsttminv tsttvec tcxxcmpldynl ppftswap)
make -f Makefile $fexe

echo =========== PI/Tests
cd $HERE/PI/Tests/.;
if( $?C ) make clean
set fexe = ( midasitt pilinetst pitcons pitgr xp0 xp1 xp2 xp3 pit0 )
#set fexe = ( $fexe pit1 pitst )
time make -f Makefile $fexe

#echo =========== JThreadsC++
#cd $HERE/JThreadsC++/JTCSrc
#make clean
#make all
#if( $?JTCBASEREP ) then
#  make install
#endif
#make clean

#echo =========== Speed
#cd $HERE/Eval/Speed
#make -f makefile

echo =========== CmvTests
cd $HERE/CmvTests
if( $?C ) make clean
make
make allprog

cd $HERE/CmvTests/FitsUtil
if( $?C ) make clean
make

echo FIN DE COMPILATION `date`
exit 0
