buildMobileVLCKit.sh 31 KB

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