windows-builds.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/bin/sh
  2. # A dirty script to create some windows binaries (shared, static, debug, ...) using the MSYS environment.
  3. # give build type as command line argument
  4. # x86 or x86_64-cross
  5. build_type=$1
  6. test -z "$build_type" && build_type=x86
  7. echo "build type: $build_type"
  8. case $build_type in
  9. x86)
  10. decoder=x86
  11. strip=strip
  12. hostopt=
  13. ;;
  14. x86_64-cross)
  15. decoder=x86-64
  16. strip=x86_64-w64-mingw32-strip
  17. hostopt="--host=x86_64-w64-mingw32 --build=`./build/config.guess`"
  18. ;;
  19. *)
  20. echo "Unknown build type!"
  21. exit 1
  22. ;;
  23. esac
  24. temp="$PWD/tmp"
  25. final="$PWD/releases"
  26. txt="README COPYING NEWS"
  27. # let's try with modules
  28. opts=""
  29. #opts="--with-audio=win32 --disable-modules"
  30. # Get the version for the build from configure.ac .
  31. version=`sed -n 's/^AC_INIT([^,]*, \[\([^,]*\)\], .*$/\1/p' < configure.ac`
  32. echo "Building binaries for version $version"
  33. prepare_dir()
  34. {
  35. test -e "$final" || mkdir "$final"
  36. }
  37. prepare_unix2dos()
  38. {
  39. echo "preparing unix2dos tool"
  40. # I'll include documentation in DOS-style, with the help of this little unix2dos variant.
  41. test -x "unix2dos" || echo "
  42. #include <unistd.h>
  43. #include <stdio.h>
  44. int main()
  45. {
  46. char buf[1000];
  47. ssize_t got;
  48. while((got=read(0, buf, 1000))>0)
  49. {
  50. ssize_t end=0;
  51. ssize_t pos=0;
  52. for(end=0;end<got;++end)
  53. {
  54. if(buf[end] == '\n')
  55. {
  56. write(1, buf+pos, end-pos);
  57. write(1, \"\r\n\", 2);
  58. pos=end+1;
  59. }
  60. }
  61. write(1, buf+pos, end-pos);
  62. }
  63. }" > unix2dos.c && gcc -O -o unix2dos unix2dos.c
  64. }
  65. mpg123_build()
  66. {
  67. cpu=$1
  68. stat=$2
  69. debug=$3
  70. myopts=$opts
  71. if test "$stat" = "y"; then
  72. echo "static build (stat=$stat)" &&
  73. name=mpg123-$version-static-$cpu
  74. myopts="$myopts --disable-shared"
  75. else
  76. echo "dynamic build (stat=$stat)" &&
  77. name=mpg123-$version-$cpu
  78. fi &&
  79. if test "$debug" = "y"; then
  80. echo "Debugging build!"
  81. name=$name-debug
  82. myopts="$myopts --enable-debug"
  83. fi &&
  84. tmp=$temp-$name &&
  85. echo "REMOVING $tmp!" &&
  86. sleep 5 &&
  87. if test -e Makefile; then make clean; fi &&
  88. rm -rvf $tmp &&
  89. ./configure $hostopt --prefix=$tmp --with-module-suffix=.dll $myopts --with-cpu=$cpu && make && make install &&
  90. rm -rf "$final/$name" &&
  91. mkdir "$final/$name" &&
  92. cp -v "$tmp/bin/mpg123.exe" "$final/$name" &&
  93. if test "$debug" = y; then
  94. echo "Not stripping the debug build..."
  95. else
  96. $strip --strip-unneeded "$final/$name/"*.exe
  97. fi &&
  98. if test "$stat" = "y"; then
  99. echo "No DLL there..."
  100. else
  101. cp -v "$tmp/bin/libmpg123"*.dll "$tmp/include/mpg123.h" "$final/$name" &&
  102. cp -v "src/libmpg123/.libs/libmpg123"*.dll.def "$final/$name" &&
  103. if test "$debug" = y; then
  104. echo "Not stripping the debug build..."
  105. else
  106. $strip --strip-unneeded "$final/$name/"*.dll || exit 1
  107. fi
  108. for i in $tmp/lib/mpg123/*.dll
  109. do
  110. if test -e "$i"; then
  111. plugdir="$final/$name/plugins"
  112. mkdir -p "$plugdir" &&
  113. cp -v "$i" "$plugdir"
  114. fi
  115. done
  116. fi &&
  117. for i in $txt
  118. do
  119. echo "text file $i -> $final/$name/$i.txt"
  120. ./unix2dos < "$i" > "$final/$name/$i.txt"
  121. done
  122. }
  123. prepare_dir &&
  124. prepare_unix2dos &&
  125. mpg123_build $decoder y n &&
  126. mpg123_build $decoder n n &&
  127. mpg123_build $decoder n y &&
  128. echo "Hurray! Note: Please do not forget to copy the libltdl DLL from MSYS to the dynamic build directories... " || echo "Bleh..."