build-package-deps-osx.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. #!/usr/bin/env bash
  2. set -e
  3. # This script builds a tar file that contains a bunch of deps that OBS needs for
  4. # advanced functionality on OSX. Currently this tar file is pulled down off of s3
  5. # and used in the CI build process on travis.
  6. # Mostly this sets build flags to compile with older SDKS and make sure that
  7. # the libs are portable.
  8. exists()
  9. {
  10. command -v "$1" >/dev/null 2>&1
  11. }
  12. if ! exists nasm; then
  13. echo "nasm not found. Try brew install nasm"
  14. exit
  15. fi
  16. CURDIR=$(pwd)
  17. # the temp directory
  18. WORK_DIR=`mktemp -d`
  19. # deletes the temp directory
  20. function cleanup {
  21. #rm -rf "$WORK_DIR"
  22. echo "Deleted temp working directory $WORK_DIR"
  23. }
  24. # register the cleanup function to be called on the EXIT signal
  25. trap cleanup EXIT
  26. cd $WORK_DIR
  27. DEPS_DEST=$WORK_DIR/obsdeps
  28. # make dest dirs
  29. mkdir $DEPS_DEST
  30. mkdir $DEPS_DEST/bin
  31. mkdir $DEPS_DEST/include
  32. mkdir $DEPS_DEST/lib
  33. # OSX COMPAT
  34. export MACOSX_DEPLOYMENT_TARGET=10.11
  35. # If you need an olders SDK and Xcode won't give it to you
  36. # https://github.com/phracker/MacOSX-SDKs
  37. # libopus
  38. curl -L -O https://ftp.osuosl.org/pub/xiph/releases/opus/opus-1.2.1.tar.gz
  39. tar -xf opus-1.2.1.tar.gz
  40. cd ./opus-1.2.1
  41. mkdir build
  42. cd ./build
  43. ../configure --disable-shared --enable-static --prefix="/tmp/obsdeps"
  44. make -j 12
  45. make install
  46. cd $WORK_DIR
  47. # libogg
  48. curl -L -O https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.3.tar.gz
  49. tar -xf libogg-1.3.3.tar.gz
  50. cd ./libogg-1.3.3
  51. mkdir build
  52. cd ./build
  53. ../configure --disable-shared --enable-static --prefix="/tmp/obsdeps"
  54. make -j 12
  55. make install
  56. cd $WORK_DIR
  57. # libvorbis
  58. curl -L -O https://ftp.osuosl.org/pub/xiph/releases/vorbis/libvorbis-1.3.6.tar.gz
  59. tar -xf libvorbis-1.3.6.tar.gz
  60. cd ./libvorbis-1.3.6
  61. mkdir build
  62. cd ./build
  63. ../configure --disable-shared --enable-static --prefix="/tmp/obsdeps"
  64. make -j 12
  65. make install
  66. cd $WORK_DIR
  67. # libvpx
  68. curl -L -O https://chromium.googlesource.com/webm/libvpx/+archive/v1.7.0.tar.gz
  69. mkdir -p ./libvpx-v1.7.0
  70. tar -xf v1.7.0.tar.gz -C $PWD/libvpx-v1.7.0
  71. cd ./libvpx-v1.7.0
  72. mkdir -p build
  73. cd ./build
  74. ../configure --disable-shared --prefix="/tmp/obsdeps" --libdir="/tmp/obsdeps/lib"
  75. make -j 12
  76. make install
  77. cd $WORK_DIR
  78. # x264
  79. git clone git://git.videolan.org/x264.git
  80. cd ./x264
  81. git checkout origin/stable
  82. mkdir build
  83. cd ./build
  84. ../configure --extra-ldflags="-mmacosx-version-min=10.11" --enable-static --prefix="/tmp/obsdeps"
  85. make -j 12
  86. make install
  87. ../configure --extra-ldflags="-mmacosx-version-min=10.11" --enable-shared --libdir="/tmp/obsdeps/bin" --prefix="/tmp/obsdeps"
  88. make -j 12
  89. ln -f -s libx264.*.dylib libx264.dylib
  90. find . -name \*.dylib -exec cp \{\} $DEPS_DEST/bin/ \;
  91. rsync -avh --include="*/" --include="*.h" --exclude="*" ../* $DEPS_DEST/include/
  92. rsync -avh --include="*/" --include="*.h" --exclude="*" ./* $DEPS_DEST/include/
  93. cd $WORK_DIR
  94. # janson
  95. curl -L -O http://www.digip.org/jansson/releases/jansson-2.11.tar.gz
  96. tar -xf jansson-2.11.tar.gz
  97. cd jansson-2.11
  98. mkdir build
  99. cd ./build
  100. ../configure --libdir="/tmp/obsdeps/bin" --enable-shared --disable-static
  101. make -j 12
  102. find . -name \*.dylib -exec cp \{\} $DEPS_DEST/bin/ \;
  103. rsync -avh --include="*/" --include="*.h" --exclude="*" ../* $DEPS_DEST/include/
  104. rsync -avh --include="*/" --include="*.h" --exclude="*" ./* $DEPS_DEST/include/
  105. cd $WORK_DIR
  106. export LDFLAGS="-L/tmp/obsdeps/lib"
  107. export CFLAGS="-I/tmp/obsdeps/include"
  108. # FFMPEG
  109. curl -L -O https://github.com/FFmpeg/FFmpeg/archive/n4.0.2.zip
  110. unzip ./n4.0.2.zip
  111. cd ./FFmpeg-n4.0.2
  112. mkdir build
  113. cd ./build
  114. ../configure --pkg-config-flags="--static" --extra-ldflags="-mmacosx-version-min=10.11" --enable-shared --disable-static --shlibdir="/tmp/obsdeps/bin" --enable-gpl --disable-doc --enable-libx264 --enable-libopus --enable-libvorbis --enable-libvpx --disable-outdev=sdl
  115. make -j 12
  116. find . -name \*.dylib -exec cp \{\} $DEPS_DEST/bin/ \;
  117. rsync -avh --include="*/" --include="*.h" --exclude="*" ../* $DEPS_DEST/include/
  118. rsync -avh --include="*/" --include="*.h" --exclude="*" ./* $DEPS_DEST/include/
  119. #luajit
  120. curl -L -O https://luajit.org/download/LuaJIT-2.0.5.tar.gz
  121. tar -xf LuaJIT-2.0.5.tar.gz
  122. cd LuaJIT-2.0.5
  123. make PREFIX=/tmp/obsdeps
  124. make PREFIX=/tmp/obsdeps install
  125. find /tmp/obsdeps/lib -name libluajit\*.dylib -exec cp \{\} $DEPS_DEST/lib/ \;
  126. rsync -avh --include="*/" --include="*.h" --exclude="*" src/* $DEPS_DEST/include/
  127. make PREFIX=/tmp/obsdeps uninstall
  128. cd $WORK_DIR
  129. tar -czf osx-deps.tar.gz obsdeps
  130. cp ./osx-deps.tar.gz $CURDIR