buildMobileVLCKit.sh 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  1. #!/bin/sh
  2. # Copyright (C) Pierre d'Herbemont, 2010
  3. # Copyright (C) Felix Paul Kühne, 2012-2017
  4. set -e
  5. BUILD_DEVICE=yes
  6. BUILD_SIMULATOR=yes
  7. BUILD_STATIC_FRAMEWORK=no
  8. SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
  9. SDK_MIN=7.0
  10. VERBOSE=no
  11. DEBUG=no
  12. CONFIGURATION="Release"
  13. NONETWORK=no
  14. SKIPLIBVLCCOMPILATION=no
  15. SCARY=yes
  16. TVOS=no
  17. MACOS=no
  18. IOS=yes
  19. BITCODE=no
  20. OSVERSIONMINCFLAG=miphoneos-version-min
  21. OSVERSIONMINLDFLAG=ios_version_min
  22. ROOT_DIR=empty
  23. FARCH="all"
  24. TESTEDHASH=250e44f
  25. if [ -z "$MAKE_JOBS" ]; then
  26. CORE_COUNT=`sysctl -n machdep.cpu.core_count`
  27. let MAKE_JOBS=$CORE_COUNT+1
  28. fi
  29. usage()
  30. {
  31. cat << EOF
  32. usage: $0 [-s] [-v] [-k sdk]
  33. OPTIONS
  34. -k Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
  35. -v Be more verbose
  36. -s Build for simulator
  37. -f Build framework for device and simulator
  38. -d Enable Debug
  39. -n Skip script steps requiring network interaction
  40. -l Skip libvlc compilation
  41. -t Build for tvOS
  42. -x Build for macOS / Mac OS X
  43. -w Build a limited stack of non-scary libraries only
  44. -y Build universal static libraries
  45. -b Enable bitcode
  46. -a Build framework for specific arch (all|i386|x86_64|armv7|armv7s|aarch64)
  47. EOF
  48. }
  49. while getopts "hvwsfbdxntlk:a:" OPTION
  50. do
  51. case $OPTION in
  52. h)
  53. usage
  54. exit 1
  55. ;;
  56. v)
  57. VERBOSE=yes
  58. ;;
  59. s)
  60. BUILD_DEVICE=no
  61. BUILD_SIMULATOR=yes
  62. BUILD_STATIC_FRAMEWORK=no
  63. ;;
  64. f)
  65. BUILD_DEVICE=yes
  66. BUILD_SIMULATOR=yes
  67. BUILD_STATIC_FRAMEWORK=yes
  68. ;;
  69. d) CONFIGURATION="Debug"
  70. DEBUG=yes
  71. ;;
  72. w) SCARY="no"
  73. ;;
  74. n)
  75. NONETWORK=yes
  76. ;;
  77. l)
  78. SKIPLIBVLCCOMPILATION=yes
  79. ;;
  80. k)
  81. SDK=$OPTARG
  82. ;;
  83. a)
  84. BUILD_DEVICE=yes
  85. BUILD_SIMULATOR=yes
  86. BUILD_STATIC_FRAMEWORK=yes
  87. FARCH=$OPTARG
  88. ;;
  89. b)
  90. BITCODE=yes
  91. ;;
  92. t)
  93. TVOS=yes
  94. IOS=no
  95. BITCODE=yes
  96. SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
  97. SDK_MIN=9.0
  98. OSVERSIONMINCFLAG=mtvos-version-min
  99. OSVERSIONMINLDFLAG=tvos_version_min
  100. ;;
  101. x)
  102. MACOS=yes
  103. IOS=no
  104. BITCODE=no
  105. SDK_VERSION=`xcrun --sdk macosx --show-sdk-version`
  106. SDK_MIN=10.9
  107. OSVERSIONMINCFLAG=mmacosx-version-min
  108. OSVERSIONMINLDFLAG=macosx_version_min
  109. BUILD_DEVICE=yes
  110. FARCH=x86_64
  111. BUILD_STATIC_FRAMEWORK=no
  112. ;;
  113. ?)
  114. usage
  115. exit 1
  116. ;;
  117. esac
  118. done
  119. shift $(($OPTIND - 1))
  120. out="/dev/null"
  121. if [ "$VERBOSE" = "yes" ]; then
  122. out="/dev/stdout"
  123. fi
  124. if [ "x$1" != "x" ]; then
  125. usage
  126. exit 1
  127. fi
  128. get_actual_arch() {
  129. if [ "$1" = "aarch64" ]; then
  130. echo "arm64"
  131. else
  132. echo "$1"
  133. fi
  134. }
  135. get_arch() {
  136. if [ "$1" = "arm64" ]; then
  137. echo "aarch64"
  138. else
  139. echo "$1"
  140. fi
  141. }
  142. is_simulator_arch() {
  143. if [ "$1" = "i386" -o "$1" = "x86_64" ];then
  144. return 0
  145. else
  146. return 1
  147. fi
  148. }
  149. spushd()
  150. {
  151. pushd "$1" 2>&1> /dev/null
  152. }
  153. spopd()
  154. {
  155. popd 2>&1> /dev/null
  156. }
  157. info()
  158. {
  159. local green="\033[1;32m"
  160. local normal="\033[0m"
  161. echo "[${green}info${normal}] $1"
  162. }
  163. buildxcodeproj()
  164. {
  165. local target="$2"
  166. local PLATFORM="$3"
  167. info "Building $1 ($target, ${CONFIGURATION}, $PLATFORM)"
  168. local architectures=""
  169. if [ "$FARCH" = "all" ];then
  170. if [ "$TVOS" != "yes" ]; then
  171. if [ "$PLATFORM" = "iphonesimulator" ]; then
  172. architectures="i386 x86_64"
  173. else
  174. architectures="armv7 armv7s arm64"
  175. fi
  176. else
  177. if [ "$PLATFORM" = "appletvsimulator" ]; then
  178. architectures="x86_64"
  179. else
  180. architectures="arm64"
  181. fi
  182. fi
  183. else
  184. architectures=`get_actual_arch $FARCH`
  185. fi
  186. local bitcodeflag=""
  187. if [ "$BITCODE" = "yes" ]; then
  188. bitcodeflag="BITCODE_GENERATION_MODE=bitcode"
  189. fi
  190. local defs="$GCC_PREPROCESSOR_DEFINITIONS"
  191. if [ "$SCARY" = "no" ]; then
  192. defs="$defs NOSCARYCODECS"
  193. fi
  194. xcodebuild -project "$1.xcodeproj" \
  195. -target "$target" \
  196. -sdk $PLATFORM$SDK \
  197. -configuration ${CONFIGURATION} \
  198. ARCHS="${architectures}" \
  199. IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} \
  200. GCC_PREPROCESSOR_DEFINITIONS="$defs" \
  201. ${bitcodeflag} \
  202. > ${out}
  203. }
  204. # Get root dir
  205. spushd .
  206. ROOT_DIR=`pwd`
  207. spopd
  208. VLCROOT=${ROOT_DIR}/libvlc/vlc
  209. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin"
  210. info "Preparing build dirs"
  211. mkdir -p libvlc
  212. spushd libvlc
  213. echo `pwd`
  214. if [ "$NONETWORK" != "yes" ]; then
  215. if ! [ -e vlc ]; then
  216. git clone https://git.videolan.org/git/vlc.git vlc
  217. info "Applying patches to vlc.git"
  218. cd vlc
  219. git checkout -B localBranch ${TESTEDHASH}
  220. git branch --set-upstream-to=origin/master localBranch
  221. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  222. if [ $? -ne 0 ]; then
  223. git am --abort
  224. info "Applying the patches failed, aborting git-am"
  225. exit 1
  226. fi
  227. cd ..
  228. else
  229. cd vlc
  230. git reset --hard ${TESTEDHASH}
  231. git pull --rebase
  232. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  233. cd ..
  234. fi
  235. fi
  236. spopd
  237. #
  238. # Build time
  239. #
  240. out="/dev/null"
  241. if [ "$VERBOSE" = "yes" ]; then
  242. out="/dev/stdout"
  243. fi
  244. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  245. info "Building tools"
  246. spushd ${ROOT_DIR}/libvlc/vlc/extras/tools
  247. ./bootstrap
  248. make
  249. make .gas
  250. spopd #libvlc/vlc/extras/tools
  251. fi
  252. buildLibVLC() {
  253. VERBOSE="$1"
  254. DEBUG="$2"
  255. SCARY="$3"
  256. BITCODE="$4"
  257. ARCH="$5"
  258. PLATFORM="$6"
  259. OSSTYLE=iPhone
  260. if [ "$DEBUG" = "yes" ]; then
  261. OPTIM="-O0 -g"
  262. else
  263. OPTIM="-O3 -g"
  264. fi
  265. if [ "$TVOS" = "yes" ]; then
  266. OSSTYLE=AppleTV
  267. fi
  268. if [ "$MACOS" = "yes" ]; then
  269. OSSTYLE=MacOSX
  270. PLATFORM=
  271. fi
  272. ACTUAL_ARCH=`get_actual_arch $ARCH`
  273. info "Compiling ${ARCH} with SDK version ${SDK_VERSION}, platform ${PLATFORM}"
  274. SDKROOT=`xcode-select -print-path`/Platforms/${OSSTYLE}${PLATFORM}.platform/Developer/SDKs/${OSSTYLE}${PLATFORM}${SDK_VERSION}.sdk
  275. if [ ! -d "${SDKROOT}" ]
  276. then
  277. echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
  278. exit 1
  279. fi
  280. BUILDDIR="${VLCROOT}/build-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"
  281. PREFIX="${VLCROOT}/install-${OSSTYLE}${PLATFORM}/${ACTUAL_ARCH}"
  282. TARGET="${ARCH}-apple-darwin14"
  283. # clean the environment
  284. export CFLAGS=""
  285. export CPPFLAGS=""
  286. export CXXFLAGS=""
  287. export OBJCFLAGS=""
  288. export LDFLAGS=""
  289. export PLATFORM=$PLATFORM
  290. export SDK_VERSION=$SDK_VERSION
  291. export VLCSDKROOT=$SDKROOT
  292. CFLAGS="-isysroot ${SDKROOT} -arch ${ACTUAL_ARCH} ${OPTIM}"
  293. OBJCFLAGS="${OPTIM}"
  294. if [ "$PLATFORM" = "OS" ]; then
  295. if [ "$ARCH" != "aarch64" ]; then
  296. CFLAGS+=" -mcpu=cortex-a8 -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  297. else
  298. CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  299. fi
  300. else
  301. CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  302. fi
  303. if [ "$BITCODE" = "yes" ]; then
  304. CFLAGS+=" -fembed-bitcode"
  305. fi
  306. export CFLAGS="${CFLAGS}"
  307. export CXXFLAGS="${CFLAGS}"
  308. export CPPFLAGS="${CFLAGS}"
  309. export OBJCFLAGS="${OBJCFLAGS}"
  310. if [ "$PLATFORM" = "Simulator" ]; then
  311. # Use the new ABI on simulator, else we can't build
  312. export OBJCFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch ${OBJCFLAGS}"
  313. fi
  314. export LDFLAGS="-arch ${ACTUAL_ARCH}"
  315. if [ "$PLATFORM" = "OS" ]; then
  316. EXTRA_CFLAGS="-arch ${ACTUAL_ARCH}"
  317. EXTRA_LDFLAGS="-arch ${ACTUAL_ARCH}"
  318. if [ "$ARCH" != "aarch64" ]; then
  319. EXTRA_CFLAGS+=" -mcpu=cortex-a8"
  320. EXTRA_CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  321. EXTRA_LDFLAGS+=" -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  322. export LDFLAGS="${LDFLAGS} -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  323. else
  324. EXTRA_CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  325. EXTRA_LDFLAGS+=" -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  326. export LDFLAGS="${LDFLAGS} -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  327. fi
  328. else
  329. EXTRA_CFLAGS="-arch ${ARCH}"
  330. EXTRA_CFLAGS+=" -${OSVERSIONMINCFLAG}=${SDK_MIN}"
  331. EXTRA_LDFLAGS=" -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  332. export LDFLAGS="${LDFLAGS} -v -Wl,-${OSVERSIONMINLDFLAG},${SDK_MIN}"
  333. fi
  334. spushd ${VLCROOT}/contrib
  335. info "Compiling third-party libraries"
  336. mkdir -p "${VLCROOT}/contrib/${OSSTYLE}${PLATFORM}-${ARCH}"
  337. cd "${VLCROOT}/contrib/${OSSTYLE}${PLATFORM}-${ARCH}"
  338. if [ "$PLATFORM" = "OS" ]; then
  339. export AS="gas-preprocessor.pl ${CC}"
  340. export ASCPP="gas-preprocessor.pl ${CC}"
  341. export CCAS="gas-preprocessor.pl ${CC}"
  342. if [ "$ARCH" = "aarch64" ]; then
  343. export GASPP_FIX_XCODE5=1
  344. fi
  345. else
  346. export ASCPP="xcrun as"
  347. fi
  348. if [ "$TVOS" = "yes" ]; then
  349. CUSTOMOSOPTIONS="--disable-libarchive"
  350. fi
  351. if [ "$MACOS" = "yes" ]; then
  352. CUSTOMOSOPTIONS="--disable-fontconfig --disable-bghudappkit --disable-twolame --disable-microdns --disable-SDL --disable-SDL_image --disable-cddb --disable-bluray"
  353. fi
  354. if [ "$IOS" = "yes" ]; then
  355. CUSTOMOSOPTIONS=""
  356. fi
  357. if [ "${TARGET}" = "x86_64-apple-darwin14" ];then
  358. BUILD=""
  359. else
  360. BUILD="--build=x86_64-apple-darwin14"
  361. fi
  362. if [ "$MACOS" = "yes" ]; then
  363. # The following symbols do not exist on the minimal macOS version (10.7), so they are disabled
  364. # here. This allows compilation also with newer macOS SDKs.
  365. # Added symbols in 10.13
  366. export ac_cv_func_open_wmemstream=no
  367. export ac_cv_func_fmemopen=no
  368. export ac_cv_func_open_memstream=no
  369. export ac_cv_func_futimens=no
  370. export ac_cv_func_utimensat=no
  371. # Added symbols between 10.11 and 10.12
  372. export ac_cv_func_basename_r=no
  373. export ac_cv_func_clock_getres=no
  374. export ac_cv_func_clock_gettime=no
  375. export ac_cv_func_clock_settime=no
  376. export ac_cv_func_dirname_r=no
  377. export ac_cv_func_getentropy=no
  378. export ac_cv_func_mkostemp=no
  379. export ac_cv_func_mkostemps=no
  380. # Added symbols between 10.7 and 10.11
  381. export ac_cv_func_ffsll=no
  382. export ac_cv_func_flsll=no
  383. export ac_cv_func_fdopendir=no
  384. export ac_cv_func_openat=no
  385. export ac_cv_func_fstatat=no
  386. export ac_cv_func_readlinkat=no
  387. else
  388. # The following symbols do not exist on the minimal iOS version (7.0), so they are disabled
  389. # here. This allows compilation also with newer iOS SDKs
  390. # Added symbols between 7.x and 10.x
  391. export ac_cv_func_basename_r=no
  392. export ac_cv_func_clock_getres=no
  393. export ac_cv_func_clock_gettime=no
  394. export ac_cv_func_clock_settime=no
  395. export ac_cv_func_dirname_r=no
  396. export ac_cv_func_getentropy=no
  397. export ac_cv_func_mkostemp=no
  398. export ac_cv_func_mkostemps=no
  399. export ac_cv_func_open_memstream=no
  400. export ac_cv_func_futimens=no
  401. fi
  402. export USE_FFMPEG=1
  403. ../bootstrap ${BUILD} --host=${TARGET} --prefix=${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH} --disable-gpl \
  404. --enable-ad-clauses \
  405. --disable-disc --disable-sout \
  406. --disable-sdl \
  407. --disable-SDL_image \
  408. --disable-iconv \
  409. --enable-zvbi \
  410. --disable-kate \
  411. --disable-caca \
  412. --disable-gettext \
  413. --disable-mpcdec \
  414. --disable-upnp \
  415. --disable-gme \
  416. --disable-srt \
  417. --disable-tremor \
  418. --enable-vorbis \
  419. --disable-sidplay2 \
  420. --disable-samplerate \
  421. --disable-goom \
  422. --disable-vncserver \
  423. --disable-orc \
  424. --disable-schroedinger \
  425. --disable-libmpeg2 \
  426. --disable-chromaprint \
  427. --disable-mad \
  428. --enable-fribidi \
  429. --enable-libxml2 \
  430. --enable-freetype2 \
  431. --enable-ass \
  432. --disable-fontconfig \
  433. --disable-gpg-error \
  434. --disable-vncclient \
  435. --disable-gnutls \
  436. --disable-lua \
  437. --disable-luac \
  438. --disable-protobuf \
  439. --disable-aribb24 \
  440. --disable-aribb25 \
  441. --enable-vpx \
  442. --enable-libdsm \
  443. --enable-libplacebo \
  444. --disable-sparkle \
  445. --disable-growl \
  446. --disable-breakpad \
  447. --disable-ncurses \
  448. --disable-asdcplib \
  449. ${CUSTOMOSOPTIONS} \
  450. --enable-taglib > ${out}
  451. echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
  452. echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
  453. make fetch -j$MAKE_JOBS
  454. make -j$MAKE_JOBS > ${out}
  455. spopd # ${VLCROOT}/contrib
  456. if ! [ -e ${VLCROOT}/configure ]; then
  457. info "Bootstraping vlc"
  458. ${VLCROOT}/bootstrap > ${out}
  459. fi
  460. mkdir -p ${BUILDDIR}
  461. spushd ${BUILDDIR}
  462. if [ "$DEBUG" = "yes" ]; then
  463. DEBUGFLAG="--enable-debug"
  464. else
  465. export CFLAGS="${CFLAGS} -DNDEBUG"
  466. fi
  467. if [ "$SCARY" = "yes" ]; then
  468. SCARYFLAG="--enable-dvbpsi --enable-avcodec --disable-vpx"
  469. else
  470. SCARYFLAG="--disable-dca --disable-dvbpsi --disable-avcodec --disable-avformat --disable-zvbi --enable-vpx"
  471. fi
  472. if [ "$TVOS" != "yes" -a \( "$ARCH" = "armv7" -o "$ARCH" = "armv7s" \) ];then
  473. export ac_cv_arm_neon=yes
  474. else
  475. export ac_cv_arm_neon=no
  476. fi
  477. # Available but not authorized
  478. export ac_cv_func_daemon=no
  479. export ac_cv_func_fork=no
  480. if [ "${VLCROOT}/configure" -nt config.log -o \
  481. "${THIS_SCRIPT_PATH}" -nt config.log ]; then
  482. info "Configuring vlc"
  483. ${VLCROOT}/configure \
  484. --prefix="${PREFIX}" \
  485. --host="${TARGET}" \
  486. --with-contrib="${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" \
  487. --enable-static \
  488. ${DEBUGFLAG} \
  489. ${SCARYFLAG} \
  490. --disable-macosx \
  491. --disable-macosx-qtkit \
  492. --disable-macosx-avfoundation \
  493. --disable-shared \
  494. --enable-opus \
  495. --disable-faad \
  496. --disable-lua \
  497. --disable-a52 \
  498. --enable-fribidi \
  499. --disable-qt --disable-skins2 \
  500. --disable-vcd \
  501. --disable-vlc \
  502. --disable-vlm \
  503. --disable-httpd \
  504. --disable-nls \
  505. --disable-sse \
  506. --disable-notify \
  507. --enable-live555 \
  508. --enable-realrtsp \
  509. --enable-swscale \
  510. --disable-projectm \
  511. --enable-libass \
  512. --enable-libxml2 \
  513. --disable-goom \
  514. --disable-dvdread \
  515. --disable-dvdnav \
  516. --disable-bluray \
  517. --disable-linsys \
  518. --disable-libva \
  519. --disable-gme \
  520. --disable-tremor \
  521. --enable-vorbis \
  522. --disable-fluidsynth \
  523. --disable-jack \
  524. --disable-pulse \
  525. --disable-mtp \
  526. --enable-ogg \
  527. --enable-speex \
  528. --enable-theora \
  529. --enable-flac \
  530. --disable-screen \
  531. --enable-freetype \
  532. --enable-taglib \
  533. --disable-mmx \
  534. --disable-sparkle \
  535. --disable-addonmanagermodules \
  536. --disable-mad > ${out}
  537. fi
  538. info "Building libvlc"
  539. make -j$MAKE_JOBS > ${out}
  540. info "Installing libvlc"
  541. make install > ${out}
  542. find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
  543. rm -rf "${PREFIX}/contribs"
  544. cp -R "${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" "${PREFIX}/contribs"
  545. info "Removing unneeded modules"
  546. blacklist="
  547. stats
  548. access_bd
  549. shm
  550. access_imem
  551. oldrc
  552. real
  553. hotkeys
  554. gestures
  555. dynamicoverlay
  556. rss
  557. ball
  558. marq
  559. magnify
  560. audiobargraph_
  561. clone
  562. mosaic
  563. osdmenu
  564. puzzle
  565. mediadirs
  566. t140
  567. ripple
  568. motion
  569. sharpen
  570. grain
  571. posterize
  572. mirror
  573. wall
  574. scene
  575. blendbench
  576. psychedelic
  577. alphamask
  578. netsync
  579. audioscrobbler
  580. motiondetect
  581. motionblur
  582. export
  583. smf
  584. podcast
  585. bluescreen
  586. erase
  587. stream_filter_record
  588. speex_resampler
  589. remoteosd
  590. magnify
  591. gradient
  592. logger
  593. visual
  594. fb
  595. aout_file
  596. dummy
  597. invert
  598. sepia
  599. wave
  600. hqdn3d
  601. headphone_channel_mixer
  602. gaussianblur
  603. gradfun
  604. extract
  605. colorthres
  606. antiflicker
  607. anaglyph
  608. remap
  609. oldmovie
  610. vhs
  611. demuxdump
  612. fingerprinter
  613. output_udp
  614. output_http
  615. output_livehttp
  616. libmux
  617. stream_out
  618. "
  619. if [ "$SCARY" = "no" ]; then
  620. blacklist="${blacklist}
  621. dts
  622. dvbsub
  623. svcd
  624. hevc
  625. packetizer_mlp
  626. a52
  627. vc1
  628. uleaddvaudio
  629. librar
  630. libvoc
  631. avio
  632. chorus_flanger
  633. smooth
  634. cvdsub
  635. libmod
  636. libdash
  637. libmpgv
  638. dolby_surround
  639. mpegaudio"
  640. fi
  641. echo ${blacklist}
  642. for i in ${blacklist}
  643. do
  644. find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
  645. done
  646. spopd
  647. }
  648. buildMobileKit() {
  649. PLATFORM="$1"
  650. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  651. if [ "$TVOS" = "yes" ]; then
  652. # this variable is read by libvlc's contrib build script
  653. # to create the required build environment
  654. # for historical raisons, tvOS is a special flavor of iOS
  655. # so we need to export both variables
  656. export BUILDFORIOS="yes"
  657. export BUILDFORTVOS="yes"
  658. info "Building libvlc for tvOS"
  659. fi
  660. if [ "$MACOS" = "yes" ]; then
  661. # macOS is the default build environment for libvlc's contrib
  662. # build scripts, so we don't need to export anything
  663. info "Building libvlc for macOS"
  664. fi
  665. if [ "$IOS" = "yes" ]; then
  666. # this variable is read by libvlc's contrib build script
  667. # to create the required build environment
  668. export BUILDFORIOS="yes"
  669. info "Building libvlc for iOS"
  670. fi
  671. export AR=`xcrun -f ar`
  672. export RANLIB=`xcrun -f ranlib`
  673. export CC=`xcrun -f clang`
  674. export OBJC=`xcrun -f clang`
  675. export CXX=`xcrun -f clang++`
  676. export LD=`xcrun -f ld`
  677. export STRIP=`xcrun -f strip`
  678. export CPPFLAGS=-E
  679. export CXXCPPFLAGS=-E
  680. unset AS
  681. unset CCAS
  682. if [ "$FARCH" = "all" ];then
  683. if [ "$TVOS" = "yes" ]; then
  684. if [ "$PLATFORM" = "iphonesimulator" ]; then
  685. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" "Simulator"
  686. else
  687. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "aarch64" "OS"
  688. fi
  689. fi
  690. if [ "$MACOS" = "yes" ]; then
  691. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" "OS"
  692. fi
  693. if [ "$IOS" = "yes" ]; then
  694. if [ "$PLATFORM" = "iphonesimulator" ]; then
  695. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "i386" "Simulator"
  696. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" "Simulator"
  697. else
  698. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "armv7" "OS"
  699. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "armv7s" "OS"
  700. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "aarch64" "OS"
  701. fi
  702. fi
  703. else
  704. if [ "$FARCH" != "x86_64" -a "$FARCH" != "aarch64" -a "$FARCH" != "i386" \
  705. -a "$FARCH" != "armv7" -a "$FARCH" != "armv7s" ];then
  706. echo "*** Framework ARCH: ${FARCH} is invalid ***"
  707. exit 1
  708. fi
  709. local buildPlatform=""
  710. if [ "$PLATFORM" = "iphonesimulator" ]; then
  711. if [ "$FARCH" == "x86_64" -o "$FARCH" == "i386" ];then
  712. buildPlatform="Simulator"
  713. fi
  714. else
  715. if [ "$FARCH" == "armv7" -o "$FARCH" == "armv7s" -o "$FARCH" == "aarch64" ];then
  716. buildPlatform="OS"
  717. fi
  718. fi
  719. if [ ! -z "$buildPlatform" ];then
  720. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE $FARCH $buildPlatform
  721. fi
  722. fi
  723. fi
  724. }
  725. if [ "$BUILD_DEVICE" != "no" ]; then
  726. buildMobileKit iphoneos
  727. fi
  728. if [ "$BUILD_SIMULATOR" != "no" ]; then
  729. buildMobileKit iphonesimulator
  730. fi
  731. DEVICEARCHS=""
  732. SIMULATORARCHS=""
  733. doVLCLipo() {
  734. FILEPATH="$1"
  735. FILE="$2"
  736. PLUGIN="$3"
  737. OSSTYLE="$4"
  738. files=""
  739. info "...$FILEPATH$FILE"
  740. for i in $DEVICEARCHS
  741. do
  742. actual_arch=`get_actual_arch $i`
  743. files="install-"$OSSTYLE"OS/$actual_arch/lib/$FILEPATH$FILE $files"
  744. done
  745. for i in $SIMULATORARCHS
  746. do
  747. actual_arch=`get_actual_arch $i`
  748. files="install-"$OSSTYLE"Simulator/$actual_arch/lib/$FILEPATH$FILE $files"
  749. done
  750. if [ "$PLUGIN" != "no" ]; then
  751. lipo $files -create -output install-$OSSTYLE/plugins/$FILE
  752. else
  753. lipo $files -create -output install-$OSSTYLE/core/$FILE
  754. fi
  755. }
  756. doContribLipo() {
  757. LIBNAME="$1"
  758. OSSTYLE="$2"
  759. files=""
  760. info "...$LIBNAME"
  761. for i in $DEVICEARCHS $SIMULATORARCHS
  762. do
  763. files="contrib/$OSSTYLE-$i-apple-darwin14-$i/lib/$LIBNAME $files"
  764. done
  765. lipo $files -create -output install-$OSSTYLE/contrib/$LIBNAME
  766. }
  767. get_symbol()
  768. {
  769. echo "$1" | grep vlc_entry_$2|cut -d" " -f 3|sed 's/_vlc/vlc/'
  770. }
  771. build_universal_static_lib() {
  772. PROJECT_DIR=`pwd`
  773. OSSTYLE="$1"
  774. info "building universal static libs for OS style $OSSTYLE"
  775. # remove old module list
  776. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  777. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  778. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  779. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  780. if [ "$OSSTYLE" != "MacOSX" ]; then
  781. spushd libvlc/vlc
  782. rm -rf install-$OSSTYLE
  783. mkdir install-$OSSTYLE
  784. mkdir install-$OSSTYLE/core
  785. mkdir install-$OSSTYLE/contrib
  786. mkdir install-$OSSTYLE/plugins
  787. spopd # vlc
  788. else
  789. spushd libvlc/vlc/install-$OSSTYLE
  790. rm -rf core
  791. rm -rf contrib
  792. rm -rf plugins
  793. ln -s x86_64/lib core
  794. ln -s x86_64/contribs/lib contrib
  795. ln -s x86_64/lib/vlc/plugins plugins
  796. spopd # vlc
  797. fi
  798. VLCMODULES=""
  799. VLCNEONMODULES=""
  800. SIMULATORARCHS=""
  801. CONTRIBLIBS=""
  802. DEVICEARCHS=""
  803. # arm64 got the lowest number of modules
  804. arch="aarch64"
  805. if [ "$FARCH" != "all" ];then
  806. arch="$FARCH"
  807. fi
  808. actual_arch=`get_actual_arch $arch`
  809. if [ -d libvlc/vlc/install-"$OSSTYLE"OS ];then
  810. spushd libvlc/vlc/install-"$OSSTYLE"OS
  811. for i in `ls .`
  812. do
  813. local iarch="`get_arch $i`"
  814. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  815. DEVICEARCHS="$DEVICEARCHS $iarch"
  816. fi
  817. done
  818. if (! is_simulator_arch $arch);then
  819. echo "IPHONE OS: $arch"
  820. spushd $actual_arch/lib/vlc/plugins
  821. for i in `ls *.a`
  822. do
  823. VLCMODULES="$i $VLCMODULES"
  824. done
  825. spopd # $actual_arch/lib/vlc/plugins
  826. fi
  827. if [ "$OSSTYLE" != "AppleTV" -a \
  828. \( "$FARCH" = "all" -o "$FARCH" = "armv7" -o "$FARCH" = "armv7s" \) ]; then
  829. # collect ARMv7/s specific neon modules
  830. if [ "$FARCH" = "all" ];then
  831. spushd armv7/lib/vlc/plugins
  832. else
  833. spushd $FARCH/lib/vlc/plugins
  834. fi
  835. for i in `ls *.a | grep neon`
  836. do
  837. VLCNEONMODULES="$i $VLCNEONMODULES"
  838. done
  839. spopd # armv7/lib/vlc/plugins
  840. fi
  841. spopd # vlc-install-"$OSSTYLE"OS
  842. fi
  843. if [ -d libvlc/vlc/install-"$OSSTYLE"Simulator ];then
  844. spushd libvlc/vlc/install-"$OSSTYLE"Simulator
  845. if (is_simulator_arch $arch);then
  846. echo "SIMU OS: $arch"
  847. spushd $actual_arch/lib/vlc/plugins
  848. for i in `ls *.a`
  849. do
  850. VLCMODULES="$i $VLCMODULES"
  851. done
  852. spopd # $actual_arch/lib/vlc/plugins
  853. fi
  854. for i in `ls .`
  855. do
  856. local iarch="`get_arch $i`"
  857. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  858. SIMULATORARCHS="$SIMULATORARCHS $iarch"
  859. fi
  860. done
  861. spopd # vlc-install-"$OSSTYLE"Simulator
  862. fi
  863. if [ "$OSSTYLE" = "MacOSX" ]; then
  864. if [ -d libvlc/vlc/install-"$OSSTYLE" ];then
  865. spushd libvlc/vlc/install-"$OSSTYLE"
  866. echo `pwd`
  867. echo "macOS: $arch"
  868. spushd $arch/lib/vlc/plugins
  869. for i in `ls *.a`
  870. do
  871. VLCMODULES="$i $VLCMODULES"
  872. done
  873. spopd # $actual_arch/lib/vlc/plugins
  874. spopd # vlc-install-"$OSSTYLE"
  875. fi
  876. fi
  877. spushd libvlc/vlc
  878. # collect contrib libraries
  879. spushd contrib/$OSSTYLE-$arch-apple-darwin14-$arch/lib
  880. for i in `ls *.a`
  881. do
  882. CONTRIBLIBS="$i $CONTRIBLIBS"
  883. done
  884. spopd # contrib/$OSSTYLE-$arch-apple-darwin14-$arch/lib
  885. # lipo all the vlc libraries and its plugins
  886. if [ "$OSSTYLE" != "MacOSX" ]; then
  887. doVLCLipo "" "libvlc.a" "no" $OSSTYLE
  888. doVLCLipo "" "libvlccore.a" "no" $OSSTYLE
  889. doVLCLipo "vlc/" "libcompat.a" "no" $OSSTYLE
  890. for i in $VLCMODULES
  891. do
  892. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  893. done
  894. # lipo contrib libraries
  895. for i in $CONTRIBLIBS
  896. do
  897. doContribLipo $i $OSSTYLE
  898. done
  899. if [ "$OSSTYLE" != "AppleTV" ]; then
  900. # lipo the remaining NEON plugins
  901. DEVICEARCHS=""
  902. for i in armv7 armv7s; do
  903. local iarch="`get_arch $i`"
  904. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  905. DEVICEARCHS="$DEVICEARCHS $iarch"
  906. fi
  907. done
  908. SIMULATORARCHS=""
  909. for i in $VLCNEONMODULES
  910. do
  911. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  912. done
  913. fi
  914. fi
  915. # create module list
  916. info "creating module list"
  917. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  918. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  919. # arm64 got the lowest number of modules
  920. BUILTINS="const void *vlc_static_modules[] = {\n"; \
  921. LDFLAGS=""
  922. DEFINITIONS=""
  923. # add contrib libraries to LDFLAGS
  924. for file in $CONTRIBLIBS
  925. do
  926. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/contrib/$file "
  927. done
  928. for file in $VLCMODULES
  929. do
  930. symbols=$(nm -g -arch $actual_arch install-$OSSTYLE/plugins/$file)
  931. entryname=$(get_symbol "$symbols" _)
  932. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  933. BUILTINS+=" $entryname,\n"
  934. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/plugins/$file "
  935. info "...$entryname"
  936. done;
  937. # we only have ARM NEON modules for 32bit so this is limited to iOS
  938. if [ "$OSSTYLE" = "iPhone" ]; then
  939. BUILTINS+="#ifdef __arm__\n"
  940. DEFINITIONS+="#ifdef __arm__\n"
  941. for file in $VLCNEONMODULES
  942. do
  943. symbols=$(nm -g -arch $actual_arch install-$OSSTYLE/plugins/$file)
  944. entryname=$(get_symbol "$symbols" _)
  945. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  946. BUILTINS+=" $entryname,\n"
  947. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/plugins/$file "
  948. info "...$entryname"
  949. done;
  950. BUILTINS+="#endif\n"
  951. DEFINITIONS+="#endif\n"
  952. fi
  953. BUILTINS="$BUILTINS NULL\n};\n"
  954. echo "$DEFINITIONS\n$BUILTINS" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  955. echo "VLC_PLUGINS_LDFLAGS=$LDFLAGS" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  956. spopd # vlc
  957. }
  958. if [ "$TVOS" = "yes" ]; then
  959. build_universal_static_lib "AppleTV"
  960. fi
  961. if [ "$MACOS" = "yes" ]; then
  962. build_universal_static_lib "MacOSX"
  963. fi
  964. if [ "$IOS" = "yes" ]; then
  965. build_universal_static_lib "iPhone"
  966. fi
  967. info "all done"
  968. if [ "$BUILD_STATIC_FRAMEWORK" != "no" ]; then
  969. if [ "$TVOS" = "yes" ]; then
  970. info "Building static TVVLCKit.framework"
  971. lipo_libs=""
  972. platform=""
  973. if [ -d libvlc/vlc/install-AppleTVOS ];then
  974. platform="appletvos"
  975. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  976. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvos/libTVVLCKit.a"
  977. fi
  978. if [ -d libvlc/vlc/install-AppleTVSimulator ];then
  979. platform="appletvsimulator"
  980. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  981. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvsimulator/libTVVLCKit.a"
  982. fi
  983. # Assumes both platforms were built currently
  984. spushd build
  985. rm -rf TVVLCKit.framework && \
  986. mkdir TVVLCKit.framework && \
  987. lipo -create ${lipo_libs} -o TVVLCKit.framework/TVVLCKit && \
  988. chmod a+x TVVLCKit.framework/TVVLCKit && \
  989. cp -pr ${CONFIGURATION}-${platform}/TVVLCKit TVVLCKit.framework/Headers
  990. spopd # build
  991. info "Build of static TVVLCKit.framework completed"
  992. fi
  993. if [ "$IOS" = "yes" ]; then
  994. info "Building static MobileVLCKit.framework"
  995. lipo_libs=""
  996. platform=""
  997. if [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  998. platform="iphoneos"
  999. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  1000. lipo_libs="$lipo_libs ${CONFIGURATION}-iphoneos/libMobileVLCKit.a"
  1001. fi
  1002. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);then
  1003. platform="iphonesimulator"
  1004. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  1005. lipo_libs="$lipo_libs ${CONFIGURATION}-iphonesimulator/libMobileVLCKit.a"
  1006. fi
  1007. # Assumes both platforms were built currently
  1008. spushd build
  1009. rm -rf MobileVLCKit.framework && \
  1010. mkdir MobileVLCKit.framework && \
  1011. lipo -create ${lipo_libs} -o MobileVLCKit.framework/MobileVLCKit && \
  1012. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  1013. cp -pr ${CONFIGURATION}-${platform}/MobileVLCKit MobileVLCKit.framework/Headers
  1014. spopd # build
  1015. info "Build of static MobileVLCKit.framework completed"
  1016. fi
  1017. fi