buildMobileVLCKit.sh 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  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="9f88cd6" # 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:${VLC_PATH}:/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. --enable-soxr \
  449. ${CUSTOMOSOPTIONS} \
  450. --enable-taglib > ${out}
  451. echo "EXTRA_CFLAGS += ${EXTRA_CFLAGS}" >> config.mak
  452. echo "EXTRA_LDFLAGS += ${EXTRA_LDFLAGS}" >> config.mak
  453. make fetch -j$MAKE_JOBS
  454. make -j$MAKE_JOBS > ${out}
  455. spopd # ${VLCROOT}/contrib
  456. if ! [ -e ${VLCROOT}/configure ]; then
  457. info "Bootstraping vlc"
  458. ${VLCROOT}/bootstrap > ${out}
  459. fi
  460. mkdir -p ${BUILDDIR}
  461. spushd ${BUILDDIR}
  462. if [ "$DEBUG" = "yes" ]; then
  463. DEBUGFLAG="--enable-debug"
  464. else
  465. export CFLAGS="${CFLAGS} -DNDEBUG"
  466. fi
  467. if [ "$SCARY" = "yes" ]; then
  468. SCARYFLAG="--enable-dvbpsi --enable-avcodec --disable-vpx"
  469. else
  470. SCARYFLAG="--disable-dca --disable-dvbpsi --disable-avcodec --disable-avformat --disable-zvbi --enable-vpx"
  471. fi
  472. if [ "$TVOS" != "yes" -a \( "$ARCH" = "armv7" -o "$ARCH" = "armv7s" \) ];then
  473. export ac_cv_arm_neon=yes
  474. else
  475. export ac_cv_arm_neon=no
  476. fi
  477. # Available but not authorized
  478. export ac_cv_func_daemon=no
  479. export ac_cv_func_fork=no
  480. if [ "${VLCROOT}/configure" -nt config.log -o \
  481. "${THIS_SCRIPT_PATH}" -nt config.log ]; then
  482. info "Configuring vlc"
  483. ${VLCROOT}/configure \
  484. --prefix="${PREFIX}" \
  485. --host="${TARGET}" \
  486. --with-contrib="${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" \
  487. --enable-static \
  488. ${DEBUGFLAG} \
  489. ${SCARYFLAG} \
  490. --disable-macosx \
  491. --disable-macosx-qtkit \
  492. --disable-macosx-avfoundation \
  493. --disable-shared \
  494. --enable-opus \
  495. --disable-faad \
  496. --disable-lua \
  497. --disable-a52 \
  498. --enable-fribidi \
  499. --disable-qt --disable-skins2 \
  500. --disable-vcd \
  501. --disable-vlc \
  502. --disable-vlm \
  503. --disable-httpd \
  504. --disable-nls \
  505. --disable-sse \
  506. --disable-notify \
  507. --enable-live555 \
  508. --enable-realrtsp \
  509. --enable-swscale \
  510. --disable-projectm \
  511. --enable-libass \
  512. --enable-libxml2 \
  513. --disable-goom \
  514. --disable-dvdread \
  515. --disable-dvdnav \
  516. --disable-bluray \
  517. --disable-linsys \
  518. --disable-libva \
  519. --disable-gme \
  520. --disable-tremor \
  521. --enable-vorbis \
  522. --disable-fluidsynth \
  523. --disable-jack \
  524. --disable-pulse \
  525. --disable-mtp \
  526. --enable-ogg \
  527. --enable-speex \
  528. --enable-theora \
  529. --enable-flac \
  530. --disable-screen \
  531. --enable-freetype \
  532. --enable-taglib \
  533. --disable-mmx \
  534. --disable-sparkle \
  535. --disable-addonmanagermodules \
  536. --disable-mad > ${out}
  537. fi
  538. info "Building libvlc"
  539. make -j$MAKE_JOBS > ${out}
  540. info "Installing libvlc"
  541. make install > ${out}
  542. find ${PREFIX}/lib/vlc/plugins -name *.a -type f -exec cp '{}' ${PREFIX}/lib/vlc/plugins \;
  543. rm -rf "${PREFIX}/contribs"
  544. cp -R "${VLCROOT}/contrib/${OSSTYLE}-${TARGET}-${ARCH}" "${PREFIX}/contribs"
  545. info "Removing unneeded modules"
  546. blacklist="
  547. stats
  548. access_bd
  549. shm
  550. access_imem
  551. oldrc
  552. real
  553. hotkeys
  554. gestures
  555. dynamicoverlay
  556. rss
  557. ball
  558. marq
  559. magnify
  560. audiobargraph_
  561. clone
  562. mosaic
  563. osdmenu
  564. puzzle
  565. mediadirs
  566. t140
  567. ripple
  568. motion
  569. sharpen
  570. grain
  571. posterize
  572. mirror
  573. wall
  574. scene
  575. blendbench
  576. psychedelic
  577. alphamask
  578. netsync
  579. audioscrobbler
  580. motiondetect
  581. motionblur
  582. export
  583. smf
  584. podcast
  585. bluescreen
  586. erase
  587. stream_filter_record
  588. speex_resampler
  589. remoteosd
  590. magnify
  591. gradient
  592. logger
  593. visual
  594. fb
  595. aout_file
  596. dummy
  597. invert
  598. sepia
  599. wave
  600. hqdn3d
  601. headphone_channel_mixer
  602. gaussianblur
  603. gradfun
  604. extract
  605. colorthres
  606. antiflicker
  607. anaglyph
  608. remap
  609. oldmovie
  610. vhs
  611. demuxdump
  612. fingerprinter
  613. output_udp
  614. output_http
  615. output_livehttp
  616. libmux
  617. stream_out
  618. "
  619. if [ "$SCARY" = "no" ]; then
  620. blacklist="${blacklist}
  621. dts
  622. dvbsub
  623. svcd
  624. hevc
  625. packetizer_mlp
  626. a52
  627. vc1
  628. uleaddvaudio
  629. librar
  630. libvoc
  631. avio
  632. chorus_flanger
  633. smooth
  634. cvdsub
  635. libmod
  636. libdash
  637. libmpgv
  638. dolby_surround
  639. mpegaudio"
  640. fi
  641. echo ${blacklist}
  642. for i in ${blacklist}
  643. do
  644. find ${PREFIX}/lib/vlc/plugins -name *$i* -type f -exec rm '{}' \;
  645. done
  646. spopd
  647. }
  648. buildMobileKit() {
  649. PLATFORM="$1"
  650. if [ "$SKIPLIBVLCCOMPILATION" != "yes" ]; then
  651. if [ "$TVOS" = "yes" ]; then
  652. # this variable is read by libvlc's contrib build script
  653. # to create the required build environment
  654. # for historical raisons, tvOS is a special flavor of iOS
  655. # so we need to export both variables
  656. export BUILDFORIOS="yes"
  657. export BUILDFORTVOS="yes"
  658. info "Building libvlc for tvOS"
  659. fi
  660. if [ "$MACOS" = "yes" ]; then
  661. # macOS is the default build environment for libvlc's contrib
  662. # build scripts, so we don't need to export anything
  663. info "Building libvlc for macOS"
  664. fi
  665. if [ "$IOS" = "yes" ]; then
  666. # this variable is read by libvlc's contrib build script
  667. # to create the required build environment
  668. export BUILDFORIOS="yes"
  669. info "Building libvlc for iOS"
  670. fi
  671. export AR=`xcrun -f ar`
  672. export RANLIB=`xcrun -f ranlib`
  673. export CC=`xcrun -f clang`
  674. export OBJC=`xcrun -f clang`
  675. export CXX=`xcrun -f clang++`
  676. export LD=`xcrun -f ld`
  677. export STRIP=`xcrun -f strip`
  678. export CPPFLAGS=-E
  679. export CXXCPPFLAGS=-E
  680. unset AS
  681. unset CCAS
  682. if [ "$FARCH" = "all" ];then
  683. if [ "$TVOS" = "yes" ]; then
  684. if [ "$PLATFORM" = "iphonesimulator" ]; then
  685. buildLibVLC "x86_64" "Simulator"
  686. else
  687. buildLibVLC "aarch64" "OS"
  688. fi
  689. fi
  690. if [ "$MACOS" = "yes" ]; then
  691. buildLibVLC "x86_64" "OS"
  692. fi
  693. if [ "$IOS" = "yes" ]; then
  694. if [ "$PLATFORM" = "iphonesimulator" ]; then
  695. buildLibVLC "i386" "Simulator"
  696. buildLibVLC "x86_64" "Simulator"
  697. else
  698. buildLibVLC "armv7" "OS"
  699. buildLibVLC "armv7s" "OS"
  700. buildLibVLC "aarch64" "OS"
  701. fi
  702. fi
  703. else
  704. if [ "$FARCH" != "x86_64" -a "$FARCH" != "aarch64" -a "$FARCH" != "i386" \
  705. -a "$FARCH" != "armv7" -a "$FARCH" != "armv7s" ];then
  706. echo "*** Framework ARCH: ${FARCH} is invalid ***"
  707. exit 1
  708. fi
  709. local buildPlatform=""
  710. if [ "$PLATFORM" = "iphonesimulator" ]; then
  711. if [ "$FARCH" == "x86_64" -o "$FARCH" == "i386" ];then
  712. buildPlatform="Simulator"
  713. fi
  714. else
  715. if [ "$FARCH" == "armv7" -o "$FARCH" == "armv7s" -o "$FARCH" == "aarch64" ];then
  716. buildPlatform="OS"
  717. fi
  718. fi
  719. if [ ! -z "$buildPlatform" ];then
  720. buildLibVLC $FARCH $buildPlatform
  721. fi
  722. fi
  723. fi
  724. }
  725. if [ "$BUILD_DEVICE" != "no" ]; then
  726. buildMobileKit iphoneos
  727. fi
  728. if [ "$BUILD_SIMULATOR" != "no" ]; then
  729. buildMobileKit iphonesimulator
  730. fi
  731. DEVICEARCHS=""
  732. SIMULATORARCHS=""
  733. doVLCLipo() {
  734. FILEPATH="$1"
  735. FILE="$2"
  736. PLUGIN="$3"
  737. OSSTYLE="$4"
  738. files=""
  739. info "...$FILEPATH$FILE"
  740. for i in $DEVICEARCHS
  741. do
  742. actual_arch=`get_actual_arch $i`
  743. files="install-"$OSSTYLE"OS/$actual_arch/lib/$FILEPATH$FILE $files"
  744. done
  745. for i in $SIMULATORARCHS
  746. do
  747. actual_arch=`get_actual_arch $i`
  748. files="install-"$OSSTYLE"Simulator/$actual_arch/lib/$FILEPATH$FILE $files"
  749. done
  750. if [ "$PLUGIN" != "no" ]; then
  751. lipo $files -create -output install-$OSSTYLE/plugins/$FILE
  752. else
  753. lipo $files -create -output install-$OSSTYLE/core/$FILE
  754. fi
  755. }
  756. doContribLipo() {
  757. LIBNAME="$1"
  758. OSSTYLE="$2"
  759. files=""
  760. info "...$LIBNAME"
  761. for i in $DEVICEARCHS $SIMULATORARCHS
  762. do
  763. files="contrib/$OSSTYLE-$i-apple-darwin14-$i/lib/$LIBNAME $files"
  764. done
  765. lipo $files -create -output install-$OSSTYLE/contrib/$LIBNAME
  766. }
  767. get_symbol()
  768. {
  769. echo "$1" | grep vlc_entry_$2|cut -d" " -f 3|sed 's/_vlc/vlc/'
  770. }
  771. build_universal_static_lib() {
  772. PROJECT_DIR=`pwd`
  773. OSSTYLE="$1"
  774. info "building universal static libs for OS style $OSSTYLE"
  775. # remove old module list
  776. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  777. rm -f $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  778. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  779. touch $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  780. if [ "$OSSTYLE" != "MacOSX" ]; then
  781. spushd libvlc/vlc
  782. rm -rf install-$OSSTYLE
  783. mkdir install-$OSSTYLE
  784. mkdir install-$OSSTYLE/core
  785. mkdir install-$OSSTYLE/contrib
  786. mkdir install-$OSSTYLE/plugins
  787. spopd # vlc
  788. else
  789. spushd libvlc/vlc/install-$OSSTYLE
  790. rm -rf core
  791. rm -rf contrib
  792. rm -rf plugins
  793. ln -s x86_64/lib core
  794. ln -s x86_64/contribs/lib contrib
  795. ln -s x86_64/lib/vlc/plugins plugins
  796. spopd # vlc
  797. fi
  798. VLCMODULES=""
  799. VLCNEONMODULES=""
  800. SIMULATORARCHS=""
  801. CONTRIBLIBS=""
  802. DEVICEARCHS=""
  803. # arm64 got the lowest number of modules
  804. arch="aarch64"
  805. if [ "$FARCH" != "all" ];then
  806. arch="$FARCH"
  807. fi
  808. actual_arch=`get_actual_arch $arch`
  809. if [ -d libvlc/vlc/install-"$OSSTYLE"OS ];then
  810. spushd libvlc/vlc/install-"$OSSTYLE"OS
  811. for i in `ls .`
  812. do
  813. local iarch="`get_arch $i`"
  814. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  815. DEVICEARCHS="$DEVICEARCHS $iarch"
  816. fi
  817. done
  818. if (! is_simulator_arch $arch);then
  819. echo "IPHONE OS: $arch"
  820. spushd $actual_arch/lib/vlc/plugins
  821. for i in `ls *.a`
  822. do
  823. VLCMODULES="$i $VLCMODULES"
  824. done
  825. spopd # $actual_arch/lib/vlc/plugins
  826. fi
  827. if [ "$OSSTYLE" != "AppleTV" -a \
  828. \( "$FARCH" = "all" -o "$FARCH" = "armv7" -o "$FARCH" = "armv7s" \) ]; then
  829. # collect ARMv7/s specific neon modules
  830. if [ "$FARCH" = "all" ];then
  831. spushd armv7/lib/vlc/plugins
  832. else
  833. spushd $FARCH/lib/vlc/plugins
  834. fi
  835. for i in `ls *.a | grep neon`
  836. do
  837. VLCNEONMODULES="$i $VLCNEONMODULES"
  838. done
  839. spopd # armv7/lib/vlc/plugins
  840. fi
  841. spopd # vlc-install-"$OSSTYLE"OS
  842. fi
  843. if [ -d libvlc/vlc/install-"$OSSTYLE"Simulator ];then
  844. spushd libvlc/vlc/install-"$OSSTYLE"Simulator
  845. if (is_simulator_arch $arch);then
  846. echo "SIMU OS: $arch"
  847. spushd $actual_arch/lib/vlc/plugins
  848. for i in `ls *.a`
  849. do
  850. VLCMODULES="$i $VLCMODULES"
  851. done
  852. spopd # $actual_arch/lib/vlc/plugins
  853. fi
  854. for i in `ls .`
  855. do
  856. local iarch="`get_arch $i`"
  857. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  858. SIMULATORARCHS="$SIMULATORARCHS $iarch"
  859. fi
  860. done
  861. spopd # vlc-install-"$OSSTYLE"Simulator
  862. fi
  863. if [ "$OSSTYLE" = "MacOSX" ]; then
  864. if [ -d libvlc/vlc/install-"$OSSTYLE" ];then
  865. spushd libvlc/vlc/install-"$OSSTYLE"
  866. echo `pwd`
  867. echo "macOS: $arch"
  868. spushd $arch/lib/vlc/plugins
  869. for i in `ls *.a`
  870. do
  871. VLCMODULES="$i $VLCMODULES"
  872. done
  873. spopd # $actual_arch/lib/vlc/plugins
  874. spopd # vlc-install-"$OSSTYLE"
  875. fi
  876. fi
  877. spushd libvlc/vlc
  878. # collect contrib libraries
  879. spushd contrib/$OSSTYLE-$arch-apple-darwin14-$arch/lib
  880. for i in `ls *.a`
  881. do
  882. CONTRIBLIBS="$i $CONTRIBLIBS"
  883. done
  884. spopd # contrib/$OSSTYLE-$arch-apple-darwin14-$arch/lib
  885. # lipo all the vlc libraries and its plugins
  886. if [ "$OSSTYLE" != "MacOSX" ]; then
  887. doVLCLipo "" "libvlc.a" "no" $OSSTYLE
  888. doVLCLipo "" "libvlccore.a" "no" $OSSTYLE
  889. doVLCLipo "vlc/" "libcompat.a" "no" $OSSTYLE
  890. for i in $VLCMODULES
  891. do
  892. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  893. done
  894. # lipo contrib libraries
  895. for i in $CONTRIBLIBS
  896. do
  897. doContribLipo $i $OSSTYLE
  898. done
  899. if [ "$OSSTYLE" != "AppleTV" ]; then
  900. # lipo the remaining NEON plugins
  901. DEVICEARCHS=""
  902. for i in armv7 armv7s; do
  903. local iarch="`get_arch $i`"
  904. if [ "$FARCH" == "all" -o "$FARCH" = "$iarch" ];then
  905. DEVICEARCHS="$DEVICEARCHS $iarch"
  906. fi
  907. done
  908. SIMULATORARCHS=""
  909. for i in $VLCNEONMODULES
  910. do
  911. doVLCLipo "vlc/plugins/" $i "yes" $OSSTYLE
  912. done
  913. fi
  914. fi
  915. # create module list
  916. info "creating module list"
  917. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  918. echo "// This file is autogenerated by $(basename $0)\n\n" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  919. # arm64 got the lowest number of modules
  920. BUILTINS="const void *vlc_static_modules[] = {\n"; \
  921. LDFLAGS=""
  922. DEFINITIONS=""
  923. # add contrib libraries to LDFLAGS
  924. for file in $CONTRIBLIBS
  925. do
  926. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/contrib/$file "
  927. done
  928. for file in $VLCMODULES
  929. do
  930. symbols=$(nm -g -arch $actual_arch install-$OSSTYLE/plugins/$file)
  931. entryname=$(get_symbol "$symbols" _)
  932. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  933. BUILTINS+=" $entryname,\n"
  934. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/plugins/$file "
  935. info "...$entryname"
  936. done;
  937. # we only have ARM NEON modules for 32bit so this is limited to iOS
  938. if [ "$OSSTYLE" = "iPhone" ]; then
  939. BUILTINS+="#ifdef __arm__\n"
  940. DEFINITIONS+="#ifdef __arm__\n"
  941. for file in $VLCNEONMODULES
  942. do
  943. symbols=$(nm -g -arch $actual_arch install-$OSSTYLE/plugins/$file)
  944. entryname=$(get_symbol "$symbols" _)
  945. DEFINITIONS+="int $entryname (int (*)(void *, void *, int, ...), void *);\n";
  946. BUILTINS+=" $entryname,\n"
  947. LDFLAGS+="\$(PROJECT_DIR)/libvlc/vlc/install-"$OSSTYLE"/plugins/$file "
  948. info "...$entryname"
  949. done;
  950. BUILTINS+="#endif\n"
  951. DEFINITIONS+="#endif\n"
  952. fi
  953. BUILTINS="$BUILTINS NULL\n};\n"
  954. echo "$DEFINITIONS\n$BUILTINS" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.h
  955. echo "VLC_PLUGINS_LDFLAGS=$LDFLAGS" > $PROJECT_DIR/Resources/MobileVLCKit/vlc-plugins-$OSSTYLE.xcconfig
  956. spopd # vlc
  957. }
  958. if [ "$TVOS" = "yes" ]; then
  959. build_universal_static_lib "AppleTV"
  960. fi
  961. if [ "$MACOS" = "yes" ]; then
  962. build_universal_static_lib "MacOSX"
  963. fi
  964. if [ "$IOS" = "yes" ]; then
  965. build_universal_static_lib "iPhone"
  966. fi
  967. info "all done"
  968. if [ "$BUILD_STATIC_FRAMEWORK" != "no" ]; then
  969. if [ "$TVOS" = "yes" ]; then
  970. info "Building static TVVLCKit.framework"
  971. lipo_libs=""
  972. platform=""
  973. if [ -d libvlc/vlc/install-AppleTVOS ];then
  974. platform="appletvos"
  975. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  976. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvos/libTVVLCKit.a"
  977. fi
  978. if [ -d libvlc/vlc/install-AppleTVSimulator ];then
  979. platform="appletvsimulator"
  980. buildxcodeproj MobileVLCKit "TVVLCKit" ${platform}
  981. lipo_libs="$lipo_libs ${CONFIGURATION}-appletvsimulator/libTVVLCKit.a"
  982. fi
  983. # Assumes both platforms were built currently
  984. spushd build
  985. rm -rf TVVLCKit.framework && \
  986. mkdir TVVLCKit.framework && \
  987. lipo -create ${lipo_libs} -o TVVLCKit.framework/TVVLCKit && \
  988. chmod a+x TVVLCKit.framework/TVVLCKit && \
  989. cp -pr ${CONFIGURATION}-${platform}/TVVLCKit TVVLCKit.framework/Headers
  990. spopd # build
  991. info "Build of static TVVLCKit.framework completed"
  992. fi
  993. if [ "$IOS" = "yes" ]; then
  994. info "Building static MobileVLCKit.framework"
  995. lipo_libs=""
  996. platform=""
  997. if [ "$FARCH" = "all" ] || (! is_simulator_arch $FARCH);then
  998. platform="iphoneos"
  999. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  1000. lipo_libs="$lipo_libs ${CONFIGURATION}-iphoneos/libMobileVLCKit.a"
  1001. fi
  1002. if [ "$FARCH" = "all" ] || (is_simulator_arch $arch);then
  1003. platform="iphonesimulator"
  1004. buildxcodeproj MobileVLCKit "MobileVLCKit" ${platform}
  1005. lipo_libs="$lipo_libs ${CONFIGURATION}-iphonesimulator/libMobileVLCKit.a"
  1006. fi
  1007. # Assumes both platforms were built currently
  1008. spushd build
  1009. rm -rf MobileVLCKit.framework && \
  1010. mkdir MobileVLCKit.framework && \
  1011. lipo -create ${lipo_libs} -o MobileVLCKit.framework/MobileVLCKit && \
  1012. chmod a+x MobileVLCKit.framework/MobileVLCKit && \
  1013. cp -pr ${CONFIGURATION}-${platform}/MobileVLCKit MobileVLCKit.framework/Headers
  1014. spopd # build
  1015. info "Build of static MobileVLCKit.framework completed"
  1016. fi
  1017. fi
  1018. if [ "$BUILD_DYNAMIC_FRAMEWORK" != "no" ]; then
  1019. if [ "$MACOS" = "yes" ]; then
  1020. info "Building VLCKit.framework"
  1021. buildxcodeproj VLCKit "VLCKit" "macosx"
  1022. # remove intermediate build result we don't need to keep
  1023. spushd build
  1024. rm ${CONFIGURATION}/libStaticLibVLC.a
  1025. spopd # build
  1026. info "Build of VLCKit.framework completed"
  1027. fi
  1028. fi