buildVLCKit.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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. export CFLAGS=""
  159. export CPPFLAGS=""
  160. export CXXFLAGS=""
  161. export OBJCFLAGS=""
  162. export LDFLAGS=""
  163. CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} ${OPTIM} -mmacosx-version-min=${SDK_MIN} -march=core2 -mtune=core2"
  164. LDFLAGS="-isysroot ${SDKROOT} -L${SDKROOT}/usr/lib -arch ${ARCH} -Wl,-macosx_version_min,${SDK_MIN}"
  165. export CFLAGS="${CFLAGS}"
  166. export CXXFLAGS="${CFLAGS}"
  167. export CPPFLAGS="${CFLAGS}"
  168. export OBJCFLAGS="${CFLAGS}"
  169. export LDFLAGS="${LDFLAGS}"
  170. info "Building contrib"
  171. spushd contrib
  172. mkdir -p vlckitbuild
  173. spushd vlckitbuild
  174. ../bootstrap --build=${TARGET} --disable-bluray --disable-growl --disable-sparkle --disable-SDL --disable-SDL_image --disable-microdns --disable-fontconfig --disable-bghudappkit --disable-protobuf
  175. echo "EXTRA_CFLAGS += ${CFLAGS}" >> config.mak
  176. echo "EXTRA_LDFLAGS += ${LDFLAGS}" >> config.mak
  177. make -j$MAKE_JOBS fetch ${args}
  178. make -j$MAKE_JOBS .gettext ${args}
  179. make -j$MAKE_JOBS ${args}
  180. spopd # vlckitbuild
  181. spopd # contrib
  182. info "Bootstraping vlc"
  183. info "VLCROOT = ${VLCROOT}"
  184. if ! [ -e ${VLCROOT}/configure ]; then
  185. ${VLCROOT}/bootstrap
  186. fi
  187. mkdir -p vlckitbuild
  188. spushd vlckitbuild
  189. ../configure --build=${TARGET} --prefix="${PREFIX}" \
  190. --disable-macosx \
  191. --enable-merge-ffmpeg \
  192. --disable-sparkle \
  193. --enable-osx-notifications \
  194. --enable-faad \
  195. --enable-flac \
  196. --enable-theora \
  197. --enable-shout \
  198. --enable-ncurses \
  199. --enable-twolame \
  200. --enable-realrtsp \
  201. --enable-libass \
  202. --enable-macosx-qtkit \
  203. --enable-macosx-avfoundation \
  204. --disable-skins2 \
  205. --disable-chromecast \
  206. --disable-qt \
  207. --disable-xcb \
  208. --disable-caca \
  209. --disable-pulse \
  210. --disable-gnutls \
  211. --disable-vnc
  212. make -j$MAKE_JOBS ${args}
  213. make install $(args)
  214. spopd #vlckitbuild
  215. fi
  216. spopd #vlc
  217. spopd #libvlc
  218. }
  219. buildLibVLC
  220. info "libvlc compilation done"
  221. info "Building VLCKit.framework"
  222. buildxcodeproj VLCKit "VLCKit" macosx
  223. info "Build of VLCKit.framework completed"