buildVLCKit.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. #!/bin/sh
  2. # Copyright (C) Pierre d'Herbemont, 2010
  3. # Copyright (C) Felix Paul Kühne, 2012-2016
  4. set -e
  5. SDK=`xcrun --sdk macosx --show-sdk-version`
  6. SDK_MIN=10.9
  7. VERBOSE=no
  8. CONFIGURATION="Release"
  9. NONETWORK=no
  10. SKIPLIBVLCCOMPILATION=no
  11. SCARY=yes
  12. DEBUG="no"
  13. if [ -z "$MAKE_JOBS" ]; then
  14. CORE_COUNT=`sysctl -n machdep.cpu.core_count`
  15. let MAKE_JOBS=$CORE_COUNT+1
  16. fi
  17. usage()
  18. {
  19. cat << EOF
  20. usage: $0 [-s] [-v] [-k sdk]
  21. OPTIONS
  22. -k Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
  23. -v Be more verbose
  24. -d Enable Debug
  25. -n Skip script steps requiring network interaction
  26. -l Skip libvlc compilation
  27. -w Build a limited stack of non-scary libraries only
  28. EOF
  29. }
  30. spushd()
  31. {
  32. pushd "$1" 2>&1> /dev/null
  33. }
  34. spopd()
  35. {
  36. popd 2>&1> /dev/null
  37. }
  38. info()
  39. {
  40. local green="\033[1;32m"
  41. local normal="\033[0m"
  42. echo "[${green}info${normal}] $1"
  43. }
  44. buildxcodeproj()
  45. {
  46. local target="$2"
  47. local PLATFORM="$3"
  48. info "Building $1 ($target, ${CONFIGURATION}, $PLATFORM)"
  49. local architectures="x86_64"
  50. local defs="$GCC_PREPROCESSOR_DEFINITIONS"
  51. if [ "$SCARY" = "no" ]; then
  52. defs="$defs NOSCARYCODECS"
  53. fi
  54. xcodebuild -project "$1.xcodeproj" \
  55. -target "$target" \
  56. -sdk $PLATFORM$SDK \
  57. -configuration ${CONFIGURATION} \
  58. ARCHS="${architectures}" \
  59. MACOSX_DEPLOYMENT_TARGET=${SDK_MIN} \
  60. GCC_PREPROCESSOR_DEFINITIONS="$defs" \
  61. > ${out}
  62. }
  63. while getopts "hvwsfbdntlk:" OPTION
  64. do
  65. case $OPTION in
  66. h)
  67. usage
  68. exit 1
  69. ;;
  70. v)
  71. VERBOSE=yes
  72. ;;
  73. d) CONFIGURATION="Debug"
  74. DEBUG="yes"
  75. ;;
  76. w) SCARY="no"
  77. ;;
  78. n)
  79. NONETWORK=yes
  80. ;;
  81. l)
  82. SKIPLIBVLCCOMPILATION=yes
  83. ;;
  84. k)
  85. SDK=$OPTARG
  86. ;;
  87. ?)
  88. usage
  89. exit 1
  90. ;;
  91. esac
  92. done
  93. shift $(($OPTIND - 1))
  94. out="/dev/null"
  95. if [ "$VERBOSE" = "yes" ]; then
  96. out="/dev/stdout"
  97. fi
  98. if [ "x$1" != "x" ]; then
  99. usage
  100. exit 1
  101. fi
  102. # Get root dir
  103. spushd .
  104. aspen_root_dir=`pwd`
  105. spopd
  106. info "Preparing build dirs"
  107. mkdir -p libvlc
  108. spushd libvlc
  109. if [ "$NONETWORK" != "yes" ]; then
  110. if ! [ -e vlc ]; then
  111. git clone git://git.videolan.org/vlc.git vlc
  112. else
  113. cd vlc
  114. git pull --rebase
  115. cd ..
  116. fi
  117. fi
  118. spopd
  119. #
  120. # Build time
  121. #
  122. buildLibVLC() {
  123. export CC=`xcrun -f clang`
  124. export CXX=`xcrun -f clang++`
  125. export OBJC=`xcrun -f clang`
  126. args=""
  127. if [ "$VERBOSE" = "yes" ]; then
  128. args="${args} V=1"
  129. fi
  130. spushd libvlc
  131. spushd vlc
  132. VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
  133. PREFIX="${VLCROOT}/install-macos"
  134. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  135. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/x86_64-apple-darwin15/bin:$PATH"
  136. info "Building tools"
  137. spushd extras/tools
  138. ./bootstrap
  139. make -j$MAKE_JOBS ${args}
  140. spopd # extras/tools
  141. # export CFLAGS="-Werror=partial-availability"
  142. SDK_VERSION=`xcrun --sdk macosx --show-sdk-version`
  143. SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SDK_VERSION}.sdk
  144. ARCH=x86_64
  145. TARGET=${ARCH}-apple-darwin15
  146. if [ ! -d "${SDKROOT}" ]
  147. then
  148. echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
  149. exit 1
  150. fi
  151. if [ "$DEBUG" = "yes" ]; then
  152. OPTIM="-O0 -g"
  153. else
  154. OPTIM="-O3 -g"
  155. fi
  156. # clean the environment
  157. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
  158. info "Building contrib"
  159. spushd contrib
  160. mkdir -p vlckitbuild
  161. spushd vlckitbuild
  162. export USE_FFMPEG=1
  163. ../bootstrap --build=${TARGET} --disable-bluray --disable-growl --disable-sparkle --disable-SDL --disable-SDL_image --disable-microdns --disable-fontconfig --disable-bghudappkit --disable-protobuf
  164. make -j$MAKE_JOBS fetch ${args}
  165. make -j$MAKE_JOBS .gettext ${args}
  166. make -j$MAKE_JOBS ${args}
  167. spopd # vlckitbuild
  168. spopd # contrib
  169. info "Bootstraping vlc"
  170. info "VLCROOT = ${VLCROOT}"
  171. if ! [ -e ${VLCROOT}/configure ]; then
  172. ${VLCROOT}/bootstrap
  173. fi
  174. mkdir -p vlckitbuild
  175. spushd vlckitbuild
  176. ../configure --build=${TARGET} --prefix="${PREFIX}" \
  177. --disable-macosx \
  178. --enable-merge-ffmpeg \
  179. --disable-sparkle \
  180. --enable-osx-notifications \
  181. --enable-faad \
  182. --enable-flac \
  183. --enable-theora \
  184. --enable-shout \
  185. --enable-ncurses \
  186. --enable-twolame \
  187. --enable-realrtsp \
  188. --enable-libass \
  189. --enable-macosx-qtkit \
  190. --enable-macosx-avfoundation \
  191. --disable-skins2 \
  192. --disable-chromecast \
  193. --disable-qt \
  194. --disable-xcb \
  195. --disable-caca \
  196. --disable-pulse \
  197. --disable-gnutls \
  198. --disable-vnc
  199. make -j$MAKE_JOBS ${args}
  200. make install $(args)
  201. spopd #vlckitbuild
  202. fi
  203. spopd #vlc
  204. spopd #libvlc
  205. }
  206. buildLibVLC
  207. info "libvlc compilation done"
  208. info "Building VLCKit.framework"
  209. buildxcodeproj VLCKit "VLCKit" macosx
  210. info "Build of VLCKit.framework completed"