MakeSwigWithExtras.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. if ! type -P swig &>/dev/null
  2. then
  3. echo "Swig is not installed want this script to download,make, and install it? ( y/n )"
  4. read answer
  5. if [ "$answer" = "n" ] || [ "$answer" = "N" ]
  6. then
  7. echo "Aborting"
  8. exit
  9. fi
  10. if [ ! -d "swig-2.0.0" ]
  11. then
  12. wget http://prdownloads.sourceforge.net/swig/swig-2.0.0.tar.gz
  13. tar xzf swig-2.0.0.tar.gz
  14. cd swig-2.0.0
  15. ./configure
  16. make
  17. echo "Switching to root, enter root password"
  18. su root -c "make install" #Automatically switches back after this command
  19. echo "Exited root"
  20. cd ../
  21. else
  22. cd swig-2.0.0
  23. ./configure
  24. make
  25. echo "Switching to root, enter root password"
  26. su root -c "make install" #Automatically switches back after this command
  27. echo "Exited root"
  28. cd ../
  29. fi
  30. fi
  31. if [ "$1" == "" ] || [ "$2" == "" ] || [ "$3" == "" ]
  32. then
  33. echo "Invalid number of parameters, Usage: MakeSwigWithExtras.sh PATH_TO_RAKNETSOURCE PATH_TO_DEPENDENTEXTENSIONS OPTION1"
  34. else
  35. echo "Performing Swig build"
  36. rm -f ./SwigOutput/SwigCSharpOutput/*
  37. if [ "$3" == "MYSQL_AUTOPATCHER" ]
  38. then
  39. echo "AutoPatcher MySql option added"
  40. swig -c++ -csharp -namespace RakNet -I"$1" -I"SwigInterfaceFiles" -I"$2" -DSWIG_ADDITIONAL_AUTOPATCHER_MYSQL -outdir SwigOutput/SwigCSharpOutput -o SwigOutput/CplusDLLIncludes/RakNet_wrap.cxx SwigInterfaceFiles/RakNet.i
  41. swigReturn=$?
  42. else
  43. echo "Invalid option"
  44. swigReturn=1
  45. fi
  46. if [ $swigReturn == 0 ]
  47. then
  48. echo "Swig build complete"
  49. echo "Removing and replacing the sample cs files with fresh ones"
  50. mv ./SwigLinuxCSharpSample/TestMain.cs ./SwigLinuxCSharpSample/TestMain.txt
  51. rm ./SwigLinuxCSharpSample/*.cs
  52. mv ./SwigLinuxCSharpSample/TestMain.txt ./SwigLinuxCSharpSample/TestMain.cs
  53. cp ./SwigOutput/SwigCSharpOutput/*.cs ./SwigLinuxCSharpSample/
  54. echo "Building the Swig Dynamic Link"
  55. savedDir=`pwd`
  56. cd $1
  57. if [ "$3" == "MYSQL_AUTOPATCHER" ]
  58. then
  59. echo "Building with AutoPatcher MySql"
  60. gcc -c $2/bzip2-1.0.3/blocksort.c $2/bzip2-1.0.3/bzip2.c $2/bzip2-1.0.3/bzlib.c $2/bzip2-1.0.3/compress.c $2/bzip2-1.0.3/crctable.c $2/bzip2-1.0.3/decompress.c $2/bzip2-1.0.3/dlltest.c $2/bzip2-1.0.3/huffman.c $2/bzip2-1.0.3/randtable.c
  61. g++ *.cpp ../DependentExtensions/Swig/SwigOutput/CplusDLLIncludes/RakNet_wrap.cxx blocksort.o bzip2.o bzlib.o compress.o crctable.o decompress.o dlltest.o huffman.o randtable.o $2/Autopatcher/ApplyPatch.cpp $2/Autopatcher/AutopatcherClient.cpp $2/Autopatcher/AutopatcherMySQLRepository/AutopatcherMySQLRepository.cpp $2/Autopatcher/AutopatcherServer.cpp $2/Autopatcher/CreatePatch.cpp $2/Autopatcher/MemoryCompressor.cpp $2/MySQLInterface/MySQLInterface.cpp -l pthread -lmysqlclient -I/usr/include/mysql/ -I./ -I$2/Autopatcher/AutopatcherMySQLRepository -I$2/Autopatcher -I$2/bzip2-1.0.3 -I$2/MySQLInterface -shared -o RakNet
  62. gccReturn=$?
  63. else
  64. echo "Invalid option"
  65. gccReturn=1
  66. fi
  67. if [ $gccReturn == 0 ]
  68. then
  69. echo "Copying to /usr/lib/ will need root password"
  70. if su root -c "cp ./RakNet /usr/lib" #Automatically switches back after this command
  71. then
  72. echo "RakNet lib copied"
  73. else
  74. echo "RakNet lib copy failed"
  75. fi
  76. echo "Exited root"
  77. else
  78. echo "There was an error durion the DLL build"
  79. fi
  80. cd $savedDir
  81. else
  82. echo "Swig had an error during build"
  83. fi
  84. fi
粤ICP备19079148号