download_externals.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/usr/bin/env bash
  2. # stop on error
  3. set -e
  4. # normalize current directory to project root
  5. cd build 2>&1 > /dev/null || true
  6. cd ..
  7. function download_and_unpack_tar () {
  8. set -e
  9. MPT_GET_DESTDIR="$1"
  10. MPT_GET_URL="$2"
  11. MPT_GET_FILE="$3"
  12. MPT_GET_SUBDIR="$4"
  13. if [ ! -f "$3" ]; then
  14. wget "$2" -O "$3"
  15. fi
  16. cd include
  17. if [ -d "$1" ]; then
  18. rm -rf "$1"
  19. fi
  20. if [ "$4" = "." ]; then
  21. mkdir "$1"
  22. cd "$1"
  23. tar xvaf "../../$3"
  24. cd ..
  25. else
  26. tar xvaf "../$3"
  27. if [ ! "$4" = "$1" ]; then
  28. mv "$4" "$1"
  29. fi
  30. fi
  31. cd ..
  32. return 0
  33. }
  34. function download_and_unpack_zip () {
  35. set -e
  36. MPT_GET_DESTDIR="$1"
  37. MPT_GET_URL="$2"
  38. MPT_GET_FILE="$3"
  39. MPT_GET_SUBDIR="$4"
  40. if [ ! -f "$3" ]; then
  41. wget "$2" -O "$3"
  42. fi
  43. cd include
  44. if [ -d "$1" ]; then
  45. rm -rf "$1"
  46. fi
  47. if [ "$4" = "." ]; then
  48. mkdir "$1"
  49. cd "$1"
  50. unzip "../../$3"
  51. cd ..
  52. else
  53. unzip "../$3"
  54. if [ ! "$4" = "$1" ]; then
  55. mv "$4" "$1"
  56. fi
  57. fi
  58. cd ..
  59. return 0
  60. }
  61. function download () {
  62. set -e
  63. MPT_GET_URL="$1"
  64. MPT_GET_FILE="$2"
  65. if [ ! -f "$2" ]; then
  66. wget "$1" -O "$2"
  67. fi
  68. return 0
  69. }
  70. if [ ! -d "build/externals" ]; then
  71. mkdir build/externals
  72. fi
  73. if [ ! -d "build/tools" ]; then
  74. mkdir build/tools
  75. fi
  76. download_and_unpack_zip "allegro42" "https://lib.openmpt.org/files/libopenmpt/contrib/allegro/allegro-4.2.3.1-hg.8+r8500.zip" "build/externals/allegro-4.2.3.1-hg.8+r8500.zip" "."
  77. download_and_unpack_zip "cwsdpmi" "https://lib.openmpt.org/files/libopenmpt/contrib/djgpp/cwsdpmi/csdpmi7b.zip" "build/externals/csdpmi7b.zip" "."
  78. download "https://lib.openmpt.org/files/libopenmpt/contrib/djgpp/cwsdpmi/csdpmi7s.zip" "build/externals/csdpmi7s.zip"
  79. #download_and_unpack_zip "cwsdpmi" "https://djgpp.mirror.garr.it/current/v2misc/csdpmi7b.zip" "build/externals/csdpmi7b.zip" "."
  80. #download "https://djgpp.mirror.garr.it/current/v2misc/csdpmi7s.zip" "build/externals/csdpmi7s.zip"