buildMobileVLCKit.sh 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  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. BITCODE=no
  19. OSVERSIONMINCFLAG=miphoneos-version-min
  20. OSVERSIONMINLDFLAG=ios_version_min
  21. ROOT_DIR=empty
  22. FARCH="all"
  23. TESTEDHASH=250e44f
  24. if [ -z "$MAKE_JOBS" ]; then
  25. CORE_COUNT=`sysctl -n machdep.cpu.core_count`
  26. let MAKE_JOBS=$CORE_COUNT+1
  27. fi
  28. usage()
  29. {
  30. cat << EOF
  31. usage: $0 [-s] [-v] [-k sdk]
  32. OPTIONS
  33. -k Specify which sdk to use (see 'xcodebuild -showsdks', current: ${SDK})
  34. -v Be more verbose
  35. -s Build for simulator
  36. -f Build framework for device and simulator
  37. -d Enable Debug
  38. -n Skip script steps requiring network interaction
  39. -l Skip libvlc compilation
  40. -t Build for tvOS
  41. -x Build for macOS / Mac OS X
  42. -w Build a limited stack of non-scary libraries only
  43. -y Build universal static libraries
  44. -b Enable bitcode
  45. -a Build framework for specific arch (all|i386|x86_64|armv7|armv7s|aarch64)
  46. EOF
  47. }
  48. while getopts "hvwsfbdxntlk:a:" OPTION
  49. do
  50. case $OPTION in
  51. h)
  52. usage
  53. exit 1
  54. ;;
  55. v)
  56. VERBOSE=yes
  57. ;;
  58. s)
  59. BUILD_DEVICE=no
  60. BUILD_SIMULATOR=yes
  61. BUILD_STATIC_FRAMEWORK=no
  62. ;;
  63. f)
  64. BUILD_DEVICE=yes
  65. BUILD_SIMULATOR=yes
  66. BUILD_STATIC_FRAMEWORK=yes
  67. ;;
  68. d) CONFIGURATION="Debug"
  69. DEBUG=yes
  70. ;;
  71. w) SCARY="no"
  72. ;;
  73. n)
  74. NONETWORK=yes
  75. ;;
  76. l)
  77. SKIPLIBVLCCOMPILATION=yes
  78. ;;
  79. k)
  80. SDK=$OPTARG
  81. ;;
  82. a)
  83. BUILD_DEVICE=yes
  84. BUILD_SIMULATOR=yes
  85. BUILD_STATIC_FRAMEWORK=yes
  86. FARCH=$OPTARG
  87. ;;
  88. b)
  89. BITCODE=yes
  90. ;;
  91. t)
  92. TVOS=yes
  93. BITCODE=yes
  94. SDK_VERSION=`xcrun --sdk appletvos --show-sdk-version`
  95. SDK_MIN=9.0
  96. OSVERSIONMINCFLAG=mtvos-version-min
  97. OSVERSIONMINLDFLAG=tvos_version_min
  98. ;;
  99. x)
  100. MACOS=yes
  101. BITCODE=no
  102. SDK_VERSION=`xcrun --sdk macosx --show-sdk-version`
  103. SDK_MIN=10.9
  104. OSVERSIONMINCFLAG=mmacosx-version-min
  105. OSVERSIONMINLDFLAG=macosx_version_min
  106. BUILD_DEVICE=yes
  107. FARCH=x86_64
  108. BUILD_STATIC_FRAMEWORK=no
  109. ;;
  110. ?)
  111. usage
  112. exit 1
  113. ;;
  114. esac
  115. done
  116. shift $(($OPTIND - 1))
  117. out="/dev/null"
  118. if [ "$VERBOSE" = "yes" ]; then
  119. out="/dev/stdout"
  120. fi
  121. if [ "x$1" != "x" ]; then
  122. usage
  123. exit 1
  124. fi
  125. get_actual_arch() {
  126. if [ "$1" = "aarch64" ]; then
  127. echo "arm64"
  128. else
  129. echo "$1"
  130. fi
  131. }
  132. get_arch() {
  133. if [ "$1" = "arm64" ]; then
  134. echo "aarch64"
  135. else
  136. echo "$1"
  137. fi
  138. }
  139. is_simulator_arch() {
  140. if [ "$1" = "i386" -o "$1" = "x86_64" ];then
  141. return 0
  142. else
  143. return 1
  144. fi
  145. }
  146. spushd()
  147. {
  148. pushd "$1" 2>&1> /dev/null
  149. }
  150. spopd()
  151. {
  152. popd 2>&1> /dev/null
  153. }
  154. info()
  155. {
  156. local green="\033[1;32m"
  157. local normal="\033[0m"
  158. echo "[${green}info${normal}] $1"
  159. }
  160. buildxcodeproj()
  161. {
  162. local target="$2"
  163. local PLATFORM="$3"
  164. info "Building $1 ($target, ${CONFIGURATION}, $PLATFORM)"
  165. local architectures=""
  166. if [ "$FARCH" = "all" ];then
  167. if [ "$TVOS" != "yes" ]; then
  168. if [ "$PLATFORM" = "iphonesimulator" ]; then
  169. architectures="i386 x86_64"
  170. else
  171. architectures="armv7 armv7s arm64"
  172. fi
  173. else
  174. if [ "$PLATFORM" = "appletvsimulator" ]; then
  175. architectures="x86_64"
  176. else
  177. architectures="arm64"
  178. fi
  179. fi
  180. else
  181. architectures=`get_actual_arch $FARCH`
  182. fi
  183. local bitcodeflag=""
  184. if [ "$BITCODE" = "yes" ]; then
  185. bitcodeflag="BITCODE_GENERATION_MODE=bitcode"
  186. fi
  187. local defs="$GCC_PREPROCESSOR_DEFINITIONS"
  188. if [ "$SCARY" = "no" ]; then
  189. defs="$defs NOSCARYCODECS"
  190. fi
  191. xcodebuild -project "$1.xcodeproj" \
  192. -target "$target" \
  193. -sdk $PLATFORM$SDK \
  194. -configuration ${CONFIGURATION} \
  195. ARCHS="${architectures}" \
  196. IPHONEOS_DEPLOYMENT_TARGET=${SDK_MIN} \
  197. GCC_PREPROCESSOR_DEFINITIONS="$defs" \
  198. ${bitcodeflag} \
  199. > ${out}
  200. }
  201. # Get root dir
  202. spushd .
  203. ROOT_DIR=`pwd`
  204. spopd
  205. VLCROOT=${ROOT_DIR}/libvlc/vlc
  206. export PATH="${VLCROOT}/extras/tools/build/bin:${VLCROOT}/contrib/${TARGET}/bin:/usr/bin:/bin:/usr/sbin:/sbin"
  207. info "Preparing build dirs"
  208. mkdir -p libvlc
  209. spushd libvlc
  210. echo `pwd`
  211. if [ "$NONETWORK" != "yes" ]; then
  212. if ! [ -e vlc ]; then
  213. git clone https://git.videolan.org/git/vlc.git vlc
  214. info "Applying patches to vlc.git"
  215. cd vlc
  216. git checkout -B localBranch ${TESTEDHASH}
  217. git branch --set-upstream-to=origin/master localBranch
  218. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  219. if [ $? -ne 0 ]; then
  220. git am --abort
  221. info "Applying the patches failed, aborting git-am"
  222. exit 1
  223. fi
  224. cd ..
  225. else
  226. cd vlc
  227. git reset --hard ${TESTEDHASH}
  228. git pull --rebase
  229. git am ${ROOT_DIR}/Resources/MobileVLCKit/patches/*.patch
  230. cd ..
  231. fi
  232. fi
  233. spopd
  234. #
  235. # Build time
  236. #
  237. out="/dev/null"
  238. if [ "$VERBOSE" = "yes" ]; then
  239. out="/dev/stdout"
  240. fi
  241. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  242. info "Building tools"
  243. spushd ${ROOT_DIR}/libvlc/vlc/extras/tools
  244. ./bootstrap
  245. make
  246. make .gas
  247. spopd #libvlc/vlc/extras/tools
  248. fi
  249. buildLibVLC() {
  250. VERBOSE="$1"
  251. DEBUG="$2"
  252. SCARY="$3"
  253. BITCODE="$4"
  254. ARCH="$5"
  255. TVOS="$6"
  256. MACOS="$7"
  257. SDK_VERSION="$8"
  258. PLATFORM="$9"
  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. else
  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. else
  354. CUSTOMOSOPTIONS=""
  355. fi
  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. else
  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. else
  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. 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" $TVOS $MACOS $SDK_VERSION "Simulator"
  686. else
  687. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "aarch64" $TVOS $MACOS $SDK_VERSION "OS"
  688. fi
  689. else
  690. if [ "$MACOS" = "yes" ]; then
  691. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" $TVOS $MACOS $SDK_VERSION "OS"
  692. else
  693. if [ "$PLATFORM" = "iphonesimulator" ]; then
  694. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "i386" $TVOS $MACOS $SDK_VERSION "Simulator"
  695. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "x86_64" $TVOS $MACOS $SDK_VERSION "Simulator"
  696. else
  697. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "armv7" $TVOS $MACOS $SDK_VERSION "OS"
  698. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "armv7s" $TVOS $MACOS $SDK_VERSION "OS"
  699. buildLibVLC $VERBOSE $DEBUG $SCARY $BITCODE "aarch64" $TVOS $MACOS $SDK_VERSION "OS"
  700. fi
  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 $TVOS $MACOS $SDK_VERSION $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. if [ "$OSSTYLE" != "AppleTV" ]; 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. else
  960. if [ "$MACOS" = "yes" ]; then
  961. build_universal_static_lib "MacOSX"
  962. else
  963. build_universal_static_lib "iPhone"
  964. fi
  965. fi
  966. info "all done"
  967. if [ "$BUILD_STATIC_FRAMEWORK" != "no" ]; then
  968. if [ "$TVOS" != "yes" ]; then
  969. info "Building static MobileVLCKit.framework"
  970. lipo_libs=""
  971. platform=""
  972. if [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  973. platform="iphoneos"
  974. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  975. lipo_libs="$lipo_libs ${CONFIGURATION}-iphoneos/libMobileVLCKit.a"
  976. fi
  977. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);then
  978. platform="iphonesimulator"
  979. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  980. lipo_libs="$lipo_libs ${CONFIGURATION}-iphonesimulator/libMobileVLCKit.a"
  981. fi
  982. # Assumes both platforms were built currently
  983. spushd build
  984. rm -rf MobileVLCKit.framework && \
  985. mkdir MobileVLCKit.framework && \
  986. lipo -create ${lipo_libs} -o MobileVLCKit.framework/MobileVLCKit && \
  987. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  988. cp -pr ${CONFIGURATION}-${platform}/MobileVLCKit MobileVLCKit.framework/Headers
  989. spopd # build
  990. info "Build of static MobileVLCKit.framework completed"
  991. else
  992. info "Building static TVVLCKit.framework"
  993. lipo_libs=""
  994. platform=""
  995. if [ -d libvlc/vlc/install-AppleTVOS ];then
  996. platform="appletvos"
  997. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  998. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvos/libTVVLCKit.a"
  999. fi
  1000. if [ -d libvlc/vlc/install-AppleTVSimulator ];then
  1001. platform="appletvsimulator"
  1002. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  1003. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvsimulator/libTVVLCKit.a"
  1004. fi
  1005. # Assumes both platforms were built currently
  1006. spushd build
  1007. rm -rf TVVLCKit.framework && \
  1008. mkdir TVVLCKit.framework && \
  1009. lipo -create ${lipo_libs} -o TVVLCKit.framework/TVVLCKit && \
  1010. chmod a+x TVVLCKit.framework/TVVLCKit && \
  1011. cp -pr ${CONFIGURATION}-${platform}/TVVLCKit TVVLCKit.framework/Headers
  1012. spopd # build
  1013. info "Build of static TVVLCKit.framework completed"
  1014. fi
  1015. fi