build-package-deps-osx.sh 4.2 KB

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