utility.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. # Debug script; builds the library, uninstalls it and then installs it
  3. function ERROR
  4. {
  5. echo "{ ERROR }"
  6. echo "Expected ./utility [ACTION]"
  7. echo " statistics [generates statistics about Temelia]"
  8. # Shared object
  9. echo " so_build [builds libtemelia.so]"
  10. echo " so_clean [cleans object files and deletes libtemelia.so]"
  11. echo " so_install [copies headers in /usr/include/temelia and libtemelia.so in /usr/lib]"
  12. echo " so_uninstall [removes directory /usr/include/temelia and /usr/lib/libtemelia.so]"
  13. # DLL
  14. echo " dll_build [builds temelia.dll]"
  15. echo " dll_clean [cleans object files and deletes temelia.dll]"
  16. echo " dll_install [copies headers in /usr/include/temelia and temelia.dll in /usr/lib]"
  17. echo " dll_uninstall [removes directory /usr/include/temelia and /usr/lib/temelia.dll]"
  18. }
  19. TEMELIA="."
  20. TEMELIA_SAMPLES="../temelia_samples"
  21. TEMELIA_PERFORMANCE="../temelia_performance"
  22. TEMELIA_PERFORMANCE_GRAPHS="../temelia_performance_graphs"
  23. # WARNING - messing with these may kill your cat (and you system)
  24. SRCDIR="src"
  25. HDRDIR="$SRCDIR/include"
  26. HDRS="$HDRDIR/*.h"
  27. PRJNAME="temelia"
  28. LOCLIBDIR="/usr/lib"
  29. LOCINCDIR="/usr/include/$PRJNAME"
  30. C_SOURCE_FILES="src/*.c"
  31. C_HEADER_FILES="src/include/*.h"
  32. CPP_SOURCE_FILES="src/*.cpp"
  33. CPP_HEADER_FILES="src/include/*.hpp"
  34. JAVA_FILES="src/org/ceata/temelia/*.java"
  35. if [ $# -eq 0 ] ;
  36. then
  37. ERROR
  38. exit
  39. fi
  40. if [ $1 == "statistics" ] ;
  41. then
  42. total=0
  43. size=3
  44. query[0]=`wc -l $TEMELIA/$C_SOURCE_FILES $TEMELIA/$C_HEADER_FILES | grep total | cut -d " " -f 2`
  45. query[1]=`wc -l $TEMELIA_SAMPLES/$C_SOURCE_FILES $TEMELIA_SAMPLES/$C_HEADER_FILES | grep total | cut -d " " -f 3`
  46. query[2]=`wc -l $TEMELIA_PERFORMANCE/$CPP_SOURCE_FILES $TEMELIA_PERFORMANCE/$CPP_HEADER_FILES | grep total | cut -d " " -f 2`
  47. query[3]=`wc -l $TEMELIA_PERFORMANCE_GRAPHS/$JAVA_FILES | grep total | cut -d " " -f 2`
  48. echo "[temelia] "${query[0]}
  49. echo "[temelia samples] "${query[1]}
  50. echo "[temelia performance] "${query[2]}
  51. echo "[temelia performance graphs] "${query[3]}
  52. for i in `seq 0 $size`
  53. do
  54. total=`expr ${total} + ${query[$i]}`
  55. done
  56. echo "Temelia project: " $total
  57. elif [ $1 == "so_build" ];
  58. then
  59. make
  60. elif [ $1 == "so_install" ];
  61. then
  62. make install
  63. elif [ $1 == "so_uninstall" ];
  64. then
  65. make uninstall
  66. elif [ $1 == "so_clean" ];
  67. then
  68. make clean
  69. elif [ $1 == "dll_build" ];
  70. then
  71. make clean
  72. make CROSS_COMPILE=i586-mingw32msvc- dll
  73. elif [ $1 == "dll_install" ];
  74. then
  75. mkdir -p $LOCINCDIR
  76. cp $HDRS $LOCINCDIR
  77. cp temelia.dll $LOCLIBDIR
  78. elif [ $1 == "dll_uninstall" ];
  79. then
  80. rm -rf $LOCINCDIR
  81. rm -f $LOCLIBDIR/temelia.dll
  82. elif [ $1 == "dll_clean" ];
  83. then
  84. make dll_clean
  85. else
  86. ERROR
  87. fi