home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 5 / CD_Magazyn_EXEC_nr_5.iso / Programy / MorphOS / morphosdev-150201.lha / emulinclude / genstubs.sh < prev    next >
Encoding:
Text File  |  2001-02-14  |  1.7 KB  |  56 lines

  1. #! sh
  2. #
  3. # Usage: genstubs.sh fddir incdir destdir
  4. #
  5. # generates link libraries containing MorphOS stubs for all libraries
  6. # found in 'fddir'. 'incdir' should contain a matching
  7. # 'clib/???_protos.h' for all ???_lib.fd files.
  8. #
  9.  
  10. #---- configure this ------
  11.  
  12. CC="ppc-morphos-gcc -I/ade/morphos/emulinclude/includegcc"        #add -Isomepath/include if needed
  13. AWK=gawk
  14. AR=ar
  15. RANLIB=ranlib
  16. TMP=/t            # should be in ram:, or things get really slow
  17.  
  18. #--------------------------
  19.  
  20. FDDIR=$1
  21. INCDIR=$2
  22. DESTDIR=$3
  23. CWD=`pwd`
  24.  
  25. if [ -d $DESTDIR ]; then true; else mkdir $DESTDIR; fi
  26. if [ -d $TMP/genstubstmp ]; then rm -rf $TMP/genstubstmp; fi
  27. mkdir $TMP/genstubstmp
  28. TMP=$TMP/genstubstmp
  29.  
  30. for fd in $FDDIR/*.fd; do
  31.     rootname=`basename $fd _lib.fd`;
  32.     libname=$rootname
  33.     if test $libname = muimaster; then
  34.         libname=mui
  35.     fi
  36.     echo "making lib$libname.a";
  37.     ../emultools/fd2inline/fd2inline --stubs --morphos $fd $INCDIR/clib/${rootname}_protos.h -o $TMP/$rootname.h;
  38.     grep '#include' $INCDIR/clib/${rootname}_protos.h >$TMP/$rootname.c
  39.     grep 'typedef' $INCDIR/clib/${rootname}_protos.h >>$TMP/$rootname.c
  40. #        if [ -f $(srcdir)/../include/proto-src/$rootname.h ]; then
  41. #            grep '#include' $(srcdir)/../include/proto-src/$rootname.h
  42. #              | grep -v '#include.*<clib/' | grep -v '#include.*<inline/'
  43. #              | grep -v '#include.*<proto/' >>$TMP/$rootname.c;
  44. #        else true;
  45. #        fi
  46.     echo '#include "'$rootname'.h"' >>$TMP/$rootname.c
  47.     $CC -v -O2 -I$INCDIR -S -o $TMP/$rootname.asm $TMP/$rootname.c
  48.     $AWK -v dest=$TMP -f splitasm.awk $TMP/$rootname.asm
  49.     (cd $TMP; $CC -c *.s)
  50.     (cd $TMP; $AR r `echo $CWD/$DESTDIR/lib$libname.a | sed -e "s,.*//,/,"` *.o)
  51.     $RANLIB $DESTDIR/lib$libname.a
  52.     rm -f $TMP/*
  53. done
  54. rm -rf $TMP
  55.  
  56.