#!/bin/csh
# $Id: mkmfPI,v 1.1 1996-03-01 16:53:25 eros Exp $

set libf='$(LIB)libPI.a'
set slbf='$(SLB)libPI.so'

rm -f Makefile

echo "CC := gcc" >> Makefile
echo "CXX := g++" >> Makefile

cat ../Mgr/Makefile.h >> Makefile

echo " " >> Makefile
echo 'all:' $libf $slbf >> Makefile 

set files = `ls -1 *.cc | grep -v mac | grep -v pipp | grep -v attach | grep -v app.cc`
echo $files
#  Ca ne marche pas - Reza 1/3/96  10H00
# echo $libf ':' \
#  `echo $files | sed -e 's/\.cc/.o/g' | sed -e 's/^/$(OBJ)/'` >> Makefile
# echo $files | sed -e 's/\.cc/.o/g' | sed -e 's/^/$(OBJ)/' 
set lstlo =   ( $libf ':' )
foreach f ($files)
  set lstlo = ( $lstlo \$\(OBJ\)$f:r.o )
end
echo $lstlo  >> Makefile
echo '	ar -rs $@ $?' >> Makefile


echo " " >> Makefile
echo $slbf ':' $libf >> Makefile
echo '	ld -S -shared -o '$slbf' -all -L$(LIB) '$libf' 2>/dev/null'>> Makefile 

set inc = $EROSBASEREP/Include
set incxx = $inc/CxxInc

foreach f ( $files )
  gcc -MM -I$inc -I$incxx $f  \
       | sed -e 's/.*\.o/\$(OBJ)&/'  \
       | sed -e 's?'$incxx/'?$(CXI)?g' \
       | sed -e 's?'$inc/'?$(INC)?g' >> Makefile
end

foreach f ( *app.cc )
  gcc -MM -I$inc -I$incxx $f  \
       | sed -e 's/.*\.o/\$(OBJ)&/'  \
       | sed -e 's?'$incxx/'?$(CXI)?g' \
       | sed -e 's?'$inc/'?$(INC)?g' >> Makefile  

  echo $f:r : '$(EXE)'$f:r >> Makefile
  echo '	' >> Makefile

  echo '$(EXE)'$f:r ' : $(OBJ)'$f:r.o >> Makefile
  echo '	g++ -o $(EXE)'$f:r' $(OBJ)'$f:r'.o -L$(LIB) -lPI -lImages -lOutils -lmath -lXm -lXt -lX11 -lm' >> Makefile
end






