#!/bin/csh
# $Id: mkmflib_save,v 1.1.1.1 1999-11-26 16:37:08 ansari Exp $

cd ../$1
set libf='$(LIB)lib'$1'.a'

set hfcxxlibs = '-L$(LIB)' 
set i = 1
while ($i <= $#argv)
  set hfcxxlibs = "$hfcxxlibs -l$argv[$i]"
  @ i++
end


rm -f GNUmakefile

echo 'include ../Mgr/Makefile.h' >> GNUmakefile 

echo " " >> GNUmakefile
echo 'all:' $libf  >> GNUmakefile 

echo 'clean:' >> GNUmakefile
set toto='rm -f'
foreach f (*.cc *.c) 
  set toto= ( $toto '$(OBJ)'$f:r.o )
end
echo '	'$toto >> GNUmakefile
echo '	rm -f '$libf >> GNUmakefile

if ( ! -f exclude ) touch exclude
if ( ! $?TMPDIR ) set TMPDIR = /tmp
sort exclude >! $TMPDIR/exclude.sort

echo $libf ':' \
 `ls *.{c,cc} | comm -3 -1 $TMPDIR/exclude.sort - | sed -e 's/\.cc/.o/' | sed -e 's/\.c/.o/' | sed -e 's/^/$(OBJ)/'` >> GNUmakefile
echo '	$(AR) $(ARFLAGS) $@ $?' >> GNUmakefile
#  Pour faire compiler les instantiations automatique de cxx (DEC)
echo 'ifeq ($(CXX),cxx)' >> GNUmakefile
echo '	$(CXX) $? $(CPPFLAGS) $(CXXFLAGS)' $hfcxxlibs '-o $(OBJ)xx.x -Hf' >> GNUmakefile
echo 'endif ' >> GNUmakefile

rm -f $TMPDIR/exclude.sort

echo " " >> GNUmakefile

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

foreach f ( *.cc )
  grep -q '^'$f'$' exclude && continue
  gcc -MM -I$inc -I$incxx $f  \
       | sed -e 's/.*\.o/\$(OBJ)&/'  \
       | sed -e 's?'$incxx/'?$(CXI)?g' \
       | sed -e 's?'$inc/'?$(INC)?g' >> GNUmakefile
end

foreach f ( *.c )
  grep -q '^'$f'$' exclude && continue
  gcc -MM -I$inc -I$incxx $f  \
       | sed -e 's/.*\.o/\$(OBJ)&/'  \
       | sed -e 's?'$incxx/'?$(CXI)?g' \
       | sed -e 's?'$inc/'?$(INC)?g' >> GNUmakefile
end 




