compileAndBuildVLCKit.sh 31 KB

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