buildVLCKit.sh 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. CORE_COUNT=`sysctl -n machdep.cpu.core_count`
  14. let MAKE_JOBS=$CORE_COUNT+1
  15. usage()
  16. {
  17. cat << EOF
  18. usage: $0 [-s] [-v] [-k sdk]
  19. OPTIONS
  20. -k Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
  21. -v Be more verbose
  22. -d Enable Debug
  23. -n Skip script steps requiring network interaction
  24. -l Skip libvlc compilation
  25. -w Build a limited stack of non-scary libraries only
  26. EOF
  27. }
  28. spushd()
  29. {
  30. pushd "$1" 2>&1> /dev/null
  31. }
  32. spopd()
  33. {
  34. popd 2>&1> /dev/null
  35. }
  36. info()
  37. {
  38. local green="\033[1;32m"
  39. local normal="\033[0m"
  40. echo "[${green}info${normal}] $1"
  41. }
  42. buildxcodeproj()
  43. {
  44. local target="$2"
  45. local PLATFORM="$3"
  46. info "Building $1 ($target, ${CONFIGURATION}, $PLATFORM)"
  47. local architectures="x86_64"
  48. local defs="$GCC_PREPROCESSOR_DEFINITIONS"
  49. if [ "$SCARY" = "no" ]; then
  50. defs="$defs NOSCARYCODECS"
  51. fi
  52. xcodebuild -project "$1.xcodeproj" \
  53. -target "$target" \
  54. -sdk $PLATFORM$SDK \
  55. -configuration ${CONFIGURATION} \
  56. ARCHS="${architectures}" \
  57. MACOSX_DEPLOYMENT_TARGET=${SDK_MIN} \
  58. GCC_PREPROCESSOR_DEFINITIONS="$defs" \
  59. > ${out}
  60. }
  61. while getopts "hvwsfbdntlk:" OPTION
  62. do
  63. case $OPTION in
  64. h)
  65. usage
  66. exit 1
  67. ;;
  68. v)
  69. VERBOSE=yes
  70. MAKE_JOBS=1
  71. ;;
  72. d) CONFIGURATION="Debug"
  73. DEBUG="yes"
  74. ;;
  75. w) SCARY="no"
  76. ;;
  77. n)
  78. NONETWORK=yes
  79. ;;
  80. l)
  81. SKIPLIBVLCCOMPILATION=yes
  82. ;;
  83. k)
  84. SDK=$OPTARG
  85. ;;
  86. ?)
  87. usage
  88. exit 1
  89. ;;
  90. esac
  91. done
  92. shift $(($OPTIND - 1))
  93. out="/dev/null"
  94. if [ "$VERBOSE" = "yes" ]; then
  95. out="/dev/stdout"
  96. fi
  97. if [ "x$1" != "x" ]; then
  98. usage
  99. exit 1
  100. fi
  101. # Get root dir
  102. spushd .
  103. aspen_root_dir=`pwd`
  104. spopd
  105. info "Preparing build dirs"
  106. mkdir -p libvlc
  107. spushd libvlc
  108. if [ "$NONETWORK" != "yes" ]; then
  109. if ! [ -e vlc ]; then
  110. git clone git://git.videolan.org/vlc.git vlc
  111. else
  112. cd vlc
  113. git pull --rebase
  114. cd ..
  115. fi
  116. fi
  117. spopd
  118. #
  119. # Build time
  120. #
  121. buildLibVLC() {
  122. args=""
  123. if [ "$VERBOSE" = "yes" ]; then
  124. args="${args} V=1"
  125. fi
  126. spushd libvlc
  127. spushd vlc
  128. VLCROOT=`pwd` # Let's make sure VLCROOT is an absolute path
  129. PREFIX="${VLCROOT}/install-macos"
  130. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  131. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/x86_64-apple-darwin15/bin:$PATH"
  132. info "Building tools"
  133. spushd extras/tools
  134. ./bootstrap
  135. make -j$MAKE_JOBS ${args}
  136. spopd # extras/tools
  137. # export CFLAGS="-Werror=partial-availability"
  138. SDK_VERSION=`xcrun --sdk macosx --show-sdk-version`
  139. SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${SDK_VERSION}.sdk
  140. ARCH=x86_64
  141. TARGET=${ARCH}-apple-darwin15
  142. if [ ! -d "${SDKROOT}" ]
  143. then
  144. echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
  145. exit 1
  146. fi
  147. if [ "$DEBUG" = "yes" ]; then
  148. OPTIM="-O0 -g"
  149. else
  150. OPTIM="-O3 -g"
  151. fi
  152. # clean the environment
  153. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
  154. export CFLAGS=""
  155. export CPPFLAGS=""
  156. export CXXFLAGS=""
  157. export OBJCFLAGS=""
  158. export LDFLAGS=""
  159. CFLAGS="-isysroot ${SDKROOT} -arch ${ARCH} ${OPTIM} -mmacosx-version-min=${SDK_MIN} -march=core2 -mtune=core2"
  160. LDFLAGS="-isysroot ${SDKROOT} -L${SDKROOT}/usr/lib -arch ${ARCH} -Wl,-macosx_version_min,${SDK_MIN}"
  161. export CFLAGS="${CFLAGS}"
  162. export CXXFLAGS="${CFLAGS}"
  163. export CPPFLAGS="${CFLAGS}"
  164. export OBJCFLAGS="${CFLAGS}"
  165. export LDFLAGS="${LDFLAGS}"
  166. info "Building contrib"
  167. spushd contrib
  168. mkdir -p vlckitbuild
  169. spushd vlckitbuild
  170. ../bootstrap --build=${TARGET} --disable-bluray --disable-growl --disable-sparkle --disable-SDL --disable-SDL_image --disable-microdns --disable-fontconfig --disable-bghudappkit --disable-protobuf
  171. echo "EXTRA_CFLAGS += ${CFLAGS}" >> config.mak
  172. echo "EXTRA_LDFLAGS += ${LDFLAGS}" >> config.mak
  173. make -j$MAKE_JOBS fetch ${args}
  174. make .gettext ${args}
  175. make -j$MAKE_JOBS ${args}
  176. spopd # vlckitbuild
  177. spopd # contrib
  178. info "Bootstraping vlc"
  179. info "VLCROOT = ${VLCROOT}"
  180. if ! [ -e ${VLCROOT}/configure ]; then
  181. ${VLCROOT}/bootstrap
  182. fi
  183. mkdir -p vlckitbuild
  184. spushd vlckitbuild
  185. export CC="xcrun clang"
  186. export CXX="xcrun clang++"
  187. export OBJC="xcrun clang"
  188. ../configure --build=${TARGET} --prefix="${PREFIX}" \
  189. --disable-macosx-vlc-app \
  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-sdl \
  211. --disable-gnutls \
  212. --disable-vnc
  213. make -j$MAKE_JOBS ${args}
  214. make install $(args)
  215. spopd #vlckitbuild
  216. fi
  217. spopd #vlc
  218. spopd #libvlc
  219. }
  220. buildLibVLC
  221. info "libvlc compilation done"
  222. info "Building VLCKit.framework"
  223. buildxcodeproj VLCKit "VLCKit" macosx
  224. info "Build of VLCKit.framework completed"