media-suite_compile.sh 133 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156
  1. #!/bin/bash
  2. # shellcheck disable=SC2034,SC1090,SC1117,SC1091,SC2119
  3. shopt -s extglob
  4. if [[ -z $LOCALBUILDDIR ]]; then
  5. printf '%s\n' \
  6. "Something went wrong." \
  7. "MSYSTEM: $MSYSTEM" \
  8. "pwd: $(cygpath -w "$(pwd)")" \
  9. "fstab: " \
  10. "$(cat /etc/fstab)" \
  11. "Create a new issue and upload all logs you can find, especially compile.log"
  12. read -r -p "Enter to continue" ret
  13. exit 1
  14. fi
  15. FFMPEG_BASE_OPTS=("--pkg-config=pkgconf" --pkg-config-flags="--keep-system-libs --keep-system-cflags --static" "--cc=$CC" "--cxx=$CXX" "--ld=$CXX" "--extra-cxxflags=-fpermissive" "--extra-cflags=-Wno-int-conversion")
  16. printf '\nBuild start: %(%F %T %z)T\n' -1 >> "$LOCALBUILDDIR/newchangelog"
  17. printf '#!/bin/bash\nbash %s %s\n' "$LOCALBUILDDIR/media-suite_compile.sh" "$*" > "$LOCALBUILDDIR/last_run"
  18. while true; do
  19. case $1 in
  20. --cpuCount=* ) cpuCount=${1#*=} && shift ;;
  21. --build32=* ) build32=${1#*=} && shift ;;
  22. --build64=* ) build64=${1#*=} && shift ;;
  23. --mp4box=* ) mp4box=${1#*=} && shift ;;
  24. --rtmpdump=* ) rtmpdump=${1#*=} && shift ;;
  25. --vpx=* ) vpx=${1#*=} && shift ;;
  26. --x264=* ) x264=${1#*=} && shift ;;
  27. --x265=* ) x265=${1#*=} && shift ;;
  28. --other265=* ) other265=${1#*=} && shift ;;
  29. --flac=* ) flac=${1#*=} && shift ;;
  30. --fdkaac=* ) fdkaac=${1#*=} && shift ;;
  31. --mediainfo=* ) mediainfo=${1#*=} && shift ;;
  32. --sox=* ) sox=${1#*=} && shift ;;
  33. --ffmpeg=* ) ffmpeg=${1#*=} && shift ;;
  34. --ffmpegUpdate=* ) ffmpegUpdate=${1#*=} && shift ;;
  35. --ffmpegPath=* ) ffmpegPath="${1#*=}"; shift ;;
  36. --ffmpegChoice=* ) ffmpegChoice=${1#*=} && shift ;;
  37. --mplayer=* ) mplayer=${1#*=} && shift ;;
  38. --mpv=* ) mpv=${1#*=} && shift ;;
  39. --deleteSource=* ) deleteSource=${1#*=} && shift ;;
  40. --license=* ) license=${1#*=} && shift ;;
  41. --standalone=* ) standalone=${1#*=} && shift ;;
  42. --stripping* ) stripping=${1#*=} && shift ;;
  43. --packing* ) packing=${1#*=} && shift ;;
  44. --logging=* ) logging=${1#*=} && shift ;;
  45. --bmx=* ) bmx=${1#*=} && shift ;;
  46. --aom=* ) aom=${1#*=} && shift ;;
  47. --faac=* ) faac=${1#*=} && shift ;;
  48. --exhale=* ) exhale=${1#*=} && shift ;;
  49. --ffmbc=* ) ffmbc=${1#*=} && shift ;;
  50. --curl=* ) curl=${1#*=} && shift ;;
  51. --cyanrip=* ) cyanrip=${1#*=} && shift ;;
  52. --ripgrep=* ) ripgrep=${1#*=} && shift ;;
  53. --rav1e=* ) rav1e=${1#*=} && shift ;;
  54. --dav1d=* ) dav1d=${1#*=} && shift ;;
  55. --libavif=* ) libavif=${1#*=} && shift ;;
  56. --jpegxl=* ) jpegxl=${1#*=} && shift ;;
  57. --av1an=* ) av1an=${1#*=} && shift ;;
  58. --vvc=* ) vvc=${1#*=} && shift ;;
  59. --uvg266=* ) uvg266=${1#*=} && shift ;;
  60. --vvenc=* ) vvenc=${1#*=} && shift ;;
  61. --vvdec=* ) vvdec=${1#*=} && shift ;;
  62. --jq=* ) jq=${1#*=} && shift ;;
  63. --jo=* ) jo=${1#*=} && shift ;;
  64. --dssim=* ) dssim=${1#*=} && shift ;;
  65. --avs2=* ) avs2=${1#*=} && shift ;;
  66. --dovitool=* ) dovitool=${1#*=} && shift ;;
  67. --hdr10plustool=* ) hdr10plustool=${1#*=} && shift ;;
  68. --timeStamp=* ) timeStamp=${1#*=} && shift ;;
  69. --noMintty=* ) noMintty=${1#*=} && shift ;;
  70. --ccache=* ) ccache=${1#*=} && shift ;;
  71. --svthevc=* ) svthevc=${1#*=} && shift ;;
  72. --svtav1=* ) svtav1=${1#*=} && shift ;;
  73. --svtvp9=* ) svtvp9=${1#*=} && shift ;;
  74. --xvc=* ) xvc=${1#*=} && shift ;;
  75. --vlc=* ) vlc=${1#*=} && shift ;;
  76. --exitearly=* ) exitearly=${1#*=} && shift ;;
  77. # --autouploadlogs=* ) autouploadlogs=${1#*=} && shift ;;
  78. -- ) shift && break ;;
  79. -* ) echo "Error, unknown option: '$1'." && exit 1 ;;
  80. * ) break ;;
  81. esac
  82. done
  83. [[ $ccache != y ]] && export CCACHE_DISABLE=1
  84. # shellcheck source=media-suite_deps.sh
  85. source "$LOCALBUILDDIR"/media-suite_deps.sh
  86. # shellcheck source=media-suite_helper.sh
  87. source "$LOCALBUILDDIR"/media-suite_helper.sh
  88. if [[ $exitearly = EE1 ]]; then
  89. do_simple_print -p '\n\t'"${orange}Exit due to env var MABS_EXIT_EARLY set to EE1"
  90. exit 0
  91. fi
  92. do_simple_print -p "${orange}Warning: We will not accept any issues lacking any form of logs or logs.zip!$reset"
  93. buildProcess() {
  94. set_title
  95. do_simple_print -p '\n\t'"${orange}Starting $bits compilation of all tools$reset"
  96. [[ -f $HOME/custom_build_options ]] &&
  97. echo "Imported custom build options (unsupported)" &&
  98. source "$HOME"/custom_build_options
  99. cd_safe "$LOCALBUILDDIR"
  100. do_getFFmpegConfig "$license"
  101. do_getMpvConfig
  102. # in case the root was moved, this fixes windows abspaths
  103. mkdir -p "$LOCALDESTDIR/lib/pkgconfig"
  104. # pkgconfig keys to find the wrong abspaths from
  105. local _keys="(prefix|exec_prefix|libdir|includedir)"
  106. # current abspath root
  107. local _root
  108. _root=$(cygpath -m "$LOCALDESTDIR")
  109. # find .pc files with Windows abspaths
  110. grep -ElZR "${_keys}=[^/$].*" "$LOCALDESTDIR"/lib/pkgconfig | \
  111. # find those with a different abspath than the current
  112. xargs -0r grep -LZ "$_root" | \
  113. # replace with current abspath
  114. xargs -0r sed -ri "s;${_keys}=.*$LOCALDESTDIR;\1=$_root;g"
  115. unset _keys _root
  116. _clean_old_builds=(j{config,error,morecfg,peglib}.h
  117. lib{jpeg,nettle,gnurx,regex}.{,l}a
  118. lib{opencore-amr{nb,wb},twolame,theora{,enc,dec},caca,magic,uchardet}.{l,}a
  119. libSDL{,main}.{l,}a libopen{jpwl,mj2,jp2}.{a,pc}
  120. include/{nettle,opencore-amr{nb,wb},theora,cdio,SDL,openjpeg-2.{1,2},luajit-2.0,uchardet,wels}
  121. regex.h magic.h
  122. {nettle,vo-aacenc,sdl,uchardet}.pc
  123. {opencore-amr{nb,wb},twolame,theora{,enc,dec},caca,dcadec,libEGL,openh264}.pc
  124. libcdio_{cdda,paranoia}.{{l,}a,pc}
  125. twolame.h bin-audio/{twolame,cd-paranoia}.exe
  126. bin-global/{{file,uchardet}.exe,sdl-config,luajit-2.0.4.exe}
  127. libebur128.a ebur128.h
  128. libopenh264.a
  129. liburiparser.{{,l}a,pc}
  130. libchromaprint.{a,pc} chromaprint.h
  131. bin-global/libgcrypt-config libgcrypt.a gcrypt.h
  132. lib/libgcrypt.def bin-global/{dumpsexp,hmac256,mpicalc}.exe
  133. crossc.{h,pc} libcrossc.a
  134. include/onig{uruma,gnu,posix}.h libonig.a oniguruma.pc
  135. )
  136. do_uninstall q all "${_clean_old_builds[@]}"
  137. unset _clean_old_builds
  138. # In case a build was interrupted before reversing hide_conflicting_libs
  139. [[ -d $LOCALDESTDIR/opt/cyanffmpeg ]] &&
  140. hide_conflicting_libs -R "$LOCALDESTDIR/opt/cyanffmpeg"
  141. hide_conflicting_libs -R
  142. do_hide_all_sharedlibs
  143. create_ab_pkgconfig
  144. create_cmake_toolchain
  145. create_ab_ccache
  146. pacman -S --noconfirm "$MINGW_PACKAGE_PREFIX-cmake" > /dev/null 2>&1
  147. # Global header fixups
  148. grep_and_sed '__declspec(__dllimport__)' "$MINGW_PREFIX"/include/gmp.h \
  149. 's|__declspec\(__dllimport__\)||g' "$MINGW_PREFIX"/include/gmp.h
  150. $CC -E -P -include pthread.h - < /dev/null | grep -q MemoryBarrier ||
  151. grep_and_sed MemoryBarrier "$MINGW_PREFIX/include/pthread.h" 's/MemoryBarrier/__sync_synchronize/g'
  152. set_title "compiling global tools"
  153. do_simple_print -p '\n\t'"${orange}Starting $bits compilation of global tools${reset}"
  154. if [[ $bits = 32bit && $av1an != n ]]; then
  155. do_simple_print "${orange}Av1an cannot be compiled due to Vapoursynth being broken on 32-bit and will be disabled"'!'"${reset}"
  156. _reenable_av1an=$av1an # so that av1an can be built if both 32 bit and 64 bit targets are enabled
  157. av1an=n
  158. fi
  159. if [[ ! -z $_reenable_av1an ]] && [[ $bits = 64bit ]]; then
  160. av1an=$_reenable_av1an
  161. unset _reenable_av1an
  162. fi
  163. if [[ $packing = y &&
  164. ! "$(/opt/bin/upx -V 2> /dev/null | head -1)" = "upx 4.2.4" ]] &&
  165. do_wget -h 2e90ebda45b29217126d8e8ee4d0863bd9705a13adcca3ce07b7d19df55ca355 \
  166. "https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-win32.zip"; then
  167. do_install upx.exe /opt/bin/upx.exe
  168. fi
  169. if [[ "$ripgrep|$rav1e|$dssim|$libavif|$dovitool|$hdr10plustool" = *y* ]] ||
  170. [[ $av1an != n ]] || enabled librav1e; then
  171. do_pacman_install rust
  172. [[ $CC =~ clang ]] && rust_target_suffix="llvm"
  173. fi
  174. _check=(bin-global/rg.exe)
  175. if [[ $ripgrep = y ]] &&
  176. do_vcs "https://github.com/BurntSushi/ripgrep.git"; then
  177. do_uninstall "${_check[@]}"
  178. do_rust
  179. do_install "target/$CARCH-pc-windows-gnu$rust_target_suffix/release/rg.exe" bin-global/
  180. do_checkIfExist
  181. fi
  182. _check=(bin-global/jo.exe)
  183. if [[ $jo = y ]] &&
  184. do_vcs "https://github.com/jpmens/jo.git"; then
  185. do_mesoninstall global
  186. do_checkIfExist
  187. fi
  188. _deps=("$MINGW_PREFIX"/lib/pkgconfig/oniguruma.pc)
  189. _check=(bin-global/jq.exe)
  190. if [[ $jq = y ]] &&
  191. do_vcs "https://github.com/jqlang/jq.git"; then
  192. do_pacman_install oniguruma
  193. do_uninstall "${_check[@]}"
  194. do_autoreconf
  195. CFLAGS+=' -D_POSIX_C_SOURCE' YFLAGS='--warnings=no-yacc' \
  196. do_separate_conf global --enable-{all-static,pthread-tls,maintainer-mode} --disable-docs
  197. do_make && do_install jq.exe bin-global/
  198. do_checkIfExist
  199. fi
  200. _check=(bin-global/dssim.exe)
  201. if [[ $dssim = y ]] &&
  202. do_vcs "https://github.com/kornelski/dssim.git"; then
  203. do_uninstall "${_check[@]}"
  204. CFLAGS+=" -fno-PIC" do_rust
  205. do_install "target/$CARCH-pc-windows-gnu$rust_target_suffix/release/dssim.exe" bin-global/
  206. do_checkIfExist
  207. fi
  208. _check=(libxml2.a libxml2/libxml/xmlIO.h libxml-2.0.pc)
  209. if { enabled_any libxml2 libbluray || [[ $cyanrip = y ]] || ! mpv_disabled libbluray; } &&
  210. do_vcs "$SOURCE_REPO_LIBXML2"; then
  211. do_uninstall include/libxml2/libxml "${_check[@]}"
  212. extracommands=("-DLIBXML2_WITH_PYTHON=OFF" "-DLIBXML2_WITH_TESTS=OFF")
  213. [[ $standalone = y ]] || extracommands+=("-DLIBXML2_WITH_PROGRAMS=OFF")
  214. do_cmakeinstall "${extracommands[@]}"
  215. do_checkIfExist
  216. fi
  217. # Fixes an issue with ordering with libbluray libxml2 and libz and liblzma
  218. # Probably caused by https://gitlab.gnome.org/GNOME/libxml2/-/commit/93e8bb2a402012858500b608b4146cd5c756e34d
  219. grep_or_sed Requires.private "$LOCALDESTDIR/lib/pkgconfig/libxml-2.0.pc" 's/Requires:/Requires.private:/'
  220. if [[ $ffmpeg != no ]] && enabled libaribb24; then
  221. _check=(libpng.{pc,{,l}a} libpng16.{pc,{,l}a} libpng16/png.h)
  222. if do_vcs "$SOURCE_REPO_LIBPNG"; then
  223. do_uninstall include/libpng16 "${_check[@]}"
  224. do_autoupdate
  225. do_separate_confmakeinstall --with-pic
  226. do_checkIfExist
  227. fi
  228. _deps=(libpng.{pc,a} libpng16.{pc,a})
  229. _check=(aribb24.pc libaribb24.{,l}a)
  230. if do_vcs "$SOURCE_REPO_ARRIB24"; then
  231. do_patch "https://raw.githubusercontent.com/BtbN/FFmpeg-Builds/master/patches/aribb24/12.patch"
  232. do_patch "https://raw.githubusercontent.com/BtbN/FFmpeg-Builds/master/patches/aribb24/13.patch"
  233. do_patch "https://raw.githubusercontent.com/BtbN/FFmpeg-Builds/master/patches/aribb24/17.patch"
  234. do_uninstall include/aribb24 "${_check[@]}"
  235. do_autoreconf
  236. do_separate_confmakeinstall --with-pic
  237. do_checkIfExist
  238. fi
  239. fi
  240. if [[ $mplayer = y || $mpv = y ]] ||
  241. { [[ $ffmpeg != no ]] && enabled_any libass libfreetype {lib,}fontconfig libfribidi; }; then
  242. do_pacman_remove freetype fontconfig harfbuzz fribidi
  243. _check=(libfreetype.a freetype2.pc)
  244. [[ $ffmpeg = sharedlibs ]] && _check+=(bin-video/libfreetype-6.dll libfreetype.dll.a)
  245. if do_vcs "$SOURCE_REPO_FREETYPE"; then
  246. do_uninstall include/freetype2 bin-global/freetype-config \
  247. bin{,-video}/libfreetype-6.dll libfreetype.dll.a "${_check[@]}"
  248. extracommands=(-D{harfbuzz,png,bzip2,brotli,zlib,tests}"=disabled")
  249. [[ $ffmpeg = sharedlibs ]] && extracommands+=(--default-library=both)
  250. do_mesoninstall global "${extracommands[@]}"
  251. [[ $ffmpeg = sharedlibs ]] && do_install "$LOCALDESTDIR"/bin/libfreetype-6.dll bin-video/
  252. do_checkIfExist
  253. fi
  254. _deps=(libfreetype.a)
  255. _check=(libfontconfig.a fontconfig.pc)
  256. [[ $ffmpeg = sharedlibs ]] && enabled_any {lib,}fontconfig &&
  257. do_removeOption "--enable-(lib|)fontconfig"
  258. if enabled_any {lib,}fontconfig &&
  259. do_vcs "$SOURCE_REPO_FONTCONFIG"; then
  260. do_uninstall include/fontconfig "${_check[@]}"
  261. do_pacman_install gperf
  262. extracommands=()
  263. [[ $standalone = y ]] || extracommands+=(-Dtools=disabled)
  264. do_mesoninstall global -Ddoc=disabled -Dtests=disabled "${extracommands[@]}"
  265. do_checkIfExist
  266. fi
  267. _deps=(libfreetype.a)
  268. _check=(libharfbuzz.a harfbuzz.pc)
  269. [[ $ffmpeg = sharedlibs ]] && _check+=(libharfbuzz.dll.a bin-video/libharfbuzz-{subset-,}0.dll)
  270. if do_vcs "$SOURCE_REPO_HARFBUZZ"; then
  271. do_pacman_install ragel
  272. do_uninstall include/harfbuzz "${_check[@]}" libharfbuzz{-subset,}.la
  273. extracommands=(-D{glib,gobject,cairo,icu,tests,introspection,docs,benchmark}"=disabled")
  274. [[ $ffmpeg = sharedlibs ]] && extracommands+=(--default-library=both)
  275. do_mesoninstall global "${extracommands[@]}"
  276. # directwrite shaper doesn't work with mingw headers, maybe too old
  277. [[ $ffmpeg = sharedlibs ]] && do_install "$LOCALDESTDIR"/bin-global/libharfbuzz-{subset-,}0.dll bin-video/
  278. do_checkIfExist
  279. fi
  280. _check=(libfribidi.a fribidi.pc)
  281. [[ $standalone = y ]] && _check+=(bin-video/fribidi.exe)
  282. [[ $ffmpeg = sharedlibs ]] && _check+=(bin-video/libfribidi-0.dll libfribidi.dll.a)
  283. if do_vcs "$SOURCE_REPO_FRIBIDI"; then
  284. extracommands=("-Ddocs=false" "-Dtests=false")
  285. [[ $standalone = n ]] && extracommands+=("-Dbin=false")
  286. [[ $ffmpeg = sharedlibs ]] && extracommands+=(--default-library=both)
  287. do_mesoninstall video "${extracommands[@]}"
  288. do_checkIfExist
  289. fi
  290. _check=(ass/ass{,_types}.h libass.{{,l}a,pc})
  291. _deps=(lib{freetype,fontconfig,harfbuzz,fribidi}.a)
  292. [[ $ffmpeg = sharedlibs ]] && _check+=(bin-video/libass-9.dll libass.dll.a)
  293. if do_vcs "$SOURCE_REPO_LIBASS"; then
  294. do_autoreconf
  295. do_uninstall bin{,-video}/libass-9.dll libass.dll.a include/ass "${_check[@]}"
  296. extracommands=()
  297. enabled_any {lib,}fontconfig || extracommands+=(--disable-fontconfig)
  298. [[ $ffmpeg = sharedlibs ]] && extracommands+=(--disable-fontconfig --enable-shared)
  299. do_separate_confmakeinstall video "${extracommands[@]}"
  300. do_checkIfExist
  301. fi
  302. if [[ $ffmpeg != sharedlibs && $ffmpeg != shared ]]; then
  303. _libs=(lib{freetype,harfbuzz{-subset,},fribidi,ass}.dll.a
  304. libav{codec,device,filter,format,util,resample}.dll.a
  305. lib{sw{scale,resample},postproc}.dll.a)
  306. for _lib in "${_libs[@]}"; do
  307. rm -f "$LOCALDESTDIR/lib/$_lib"
  308. done
  309. unset _lib _libs
  310. fi
  311. fi
  312. [[ $ffmpeg != no ]] && enabled gcrypt && do_pacman_install libgcrypt
  313. if [[ $curl = y ]]; then
  314. enabled libtls && curl=libressl
  315. enabled openssl && curl=openssl
  316. enabled gnutls && curl=gnutls
  317. enabled mbedtls && curl=mbedtls
  318. [[ $curl = y ]] && curl=schannel
  319. fi
  320. if enabled_any gnutls librtmp || [[ $rtmpdump = y || $curl = gnutls ]]; then
  321. do_pacman_install nettle
  322. _check=(libgnutls.{,l}a gnutls.pc)
  323. _gnutls_ver=3.8.8
  324. _gnutls_hash=ac4f020e583880b51380ed226e59033244bc536cad2623f2e26f5afa2939d8fb
  325. if do_pkgConfig "gnutls = $_gnutls_ver" && do_wget -h $_gnutls_hash \
  326. "https://www.gnupg.org/ftp/gcrypt/gnutls/v${_gnutls_ver%.*}/gnutls-${_gnutls_ver}.tar.xz"; then
  327. do_uninstall include/gnutls "${_check[@]}"
  328. grep_or_sed crypt32 lib/gnutls.pc.in 's/Libs.private.*/& -lcrypt32/'
  329. CFLAGS="-Wno-int-conversion" \
  330. do_separate_confmakeinstall \
  331. --disable-{cxx,doc,tools,tests,nls,rpath,libdane,guile,gcc-warnings} \
  332. --without-{p11-kit,idn,tpm} --enable-local-libopts \
  333. --with-included-unistring --disable-code-coverage \
  334. LDFLAGS="$LDFLAGS -L${LOCALDESTDIR}/lib -L${MINGW_PREFIX}/lib"
  335. do_checkIfExist
  336. fi
  337. fi
  338. if [[ $curl = openssl ]] || { [[ $ffmpeg != no ]] && enabled openssl; }; then
  339. do_pacman_install openssl
  340. fi
  341. hide_libressl -R
  342. if [[ $curl = libressl ]] || { [[ $ffmpeg != no ]] && enabled libtls; }; then
  343. _check=(tls.h lib{crypto,ssl,tls}.{pc,{,l}a} openssl.pc)
  344. [[ $standalone = y ]] && _check+=(bin-global/openssl.exe)
  345. if do_vcs "$SOURCE_REPO_LIBRESSL" libressl; then
  346. do_uninstall etc/ssl include/openssl "${_check[@]}"
  347. _sed="man"
  348. [[ $standalone = y ]] || _sed="apps tests $_sed"
  349. sed -ri "s;(^SUBDIRS .*) $_sed;\1;" Makefile.am
  350. do_autogen
  351. do_separate_confmakeinstall global
  352. do_checkIfExist
  353. unset _sed
  354. fi
  355. fi
  356. { enabled mbedtls || [[ $curl = mbedtls ]]; } && do_pacman_install mbedtls
  357. if [[ $mediainfo = y || $bmx = y || $curl != n ]]; then
  358. do_pacman_install libunistring
  359. grep_and_sed dllimport "$MINGW_PREFIX"/include/unistring/woe32dll.h \
  360. 's|__declspec \(dllimport\)||g' "$MINGW_PREFIX"/include/unistring/woe32dll.h
  361. _deps=("$MINGW_PREFIX/lib/libunistring.a")
  362. _check=(libidn2.{{,l}a,pc} idn2.h)
  363. [[ $standalone == y ]] && _check+=(bin-global/idn2.exe)
  364. if do_pkgConfig "libidn2 = 2.3.7" &&
  365. do_wget -h 4c21a791b610b9519b9d0e12b8097bf2f359b12f8dd92647611a929e6bfd7d64 \
  366. "https://ftp.gnu.org/gnu/libidn/libidn2-2.3.7.tar.gz"; then
  367. do_uninstall "${_check[@]}"
  368. do_pacman_install gtk-doc
  369. [[ $standalone == y ]] || sed -ri 's|(bin_PROGRAMS = ).*|\1|g' src/Makefile.am
  370. # unistring also depends on iconv
  371. grep_or_sed '@LTLIBUNISTRING@ @LTLIBICONV@' libidn2.pc.in \
  372. 's|(@LTLIBICONV@) (@LTLIBUNISTRING@)|\2 \1|'
  373. AUTOPOINT=true do_autoreconf
  374. do_separate_confmakeinstall global --disable-{doc,rpath,nls}
  375. do_checkIfExist
  376. fi
  377. _deps=(libidn2.a)
  378. _check=(libpsl.{{,l}a,h,pc})
  379. [[ $standalone == y ]] && _check+=(bin-global/psl.exe)
  380. if do_pkgConfig "libpsl = 0.21.5" &&
  381. do_wget -h 1dcc9ceae8b128f3c0b3f654decd0e1e891afc6ff81098f227ef260449dae208 \
  382. "https://github.com/rockdaboot/libpsl/releases/download/0.21.5/libpsl-0.21.5.tar.gz"; then
  383. do_uninstall "${_check[@]}"
  384. [[ $standalone == y ]] || sed -ri 's|(bin_PROGRAMS = ).*|\1|g' tools/Makefile.in
  385. grep_or_sed "Requires.private" libpsl.pc.in "/Libs:/ i\Requires.private: libidn2"
  386. CFLAGS+=" -DPSL_STATIC" do_separate_confmakeinstall global --disable-{nls,rpath,gtk-doc-html,man,runtime}
  387. do_checkIfExist
  388. fi
  389. fi
  390. if [[ $mediainfo = y || $bmx = y || $curl != n || $cyanrip = y ]]; then
  391. do_pacman_install brotli nghttp2
  392. _check=(curl/curl.h libcurl.{{,l}a,pc})
  393. case $curl in
  394. libressl) _deps=(libssl.a) ;;
  395. openssl) _deps=("$MINGW_PREFIX/lib/libssl.a") ;;
  396. gnutls) _deps=(libgnutls.a) ;;
  397. mbedtls) _deps=("$MINGW_PREFIX/lib/libmbedtls.a") ;;
  398. *) _deps=() ;;
  399. esac
  400. [[ $standalone = y || $curl != n ]] && _check+=(bin-global/curl.exe)
  401. if do_vcs "$SOURCE_REPO_CURL"; then
  402. do_uninstall include/curl bin-global/curl-config "${_check[@]}"
  403. [[ $standalone = y || $curl != n ]] ||
  404. sed -ri "s;(^SUBDIRS = lib) src (include) scripts;\1 \2;" Makefile.in
  405. extra_opts=()
  406. case $curl in
  407. libressl|openssl)
  408. extra_opts+=(--with-{nghttp2,openssl} --without-{gnutls,mbedtls})
  409. ;;
  410. mbedtls) extra_opts+=(--with-{mbedtls,nghttp2} --without-openssl) ;;
  411. gnutls) extra_opts+=(--with-gnutls --without-{nghttp2,mbedtls,openssl}) ;;
  412. *) extra_opts+=(--with-{schannel,winidn,nghttp2} --without-{gnutls,mbedtls,openssl});;
  413. esac
  414. [[ ! -f configure || configure.ac -nt configure ]] &&
  415. do_autoreconf
  416. [[ $curl = openssl ]] && hide_libressl
  417. hide_conflicting_libs
  418. CPPFLAGS+=" -DGNUTLS_INTERNAL_BUILD -DNGHTTP2_STATICLIB -DPSL_STATIC" \
  419. do_separate_confmakeinstall global "${extra_opts[@]}" \
  420. --without-{libssh2,random,ca-bundle,ca-path,librtmp} \
  421. --with-brotli --enable-sspi --disable-debug
  422. hide_conflicting_libs -R
  423. [[ $curl = openssl ]] && hide_libressl -R
  424. if [[ $curl != schannel ]]; then
  425. _notrequired=true
  426. cd_safe "build-$bits"
  427. PATH=/usr/bin log ca-bundle make ca-bundle
  428. unset _notrequired
  429. [[ -f lib/ca-bundle.crt ]] &&
  430. cp -f lib/ca-bundle.crt "$LOCALDESTDIR"/bin-global/curl-ca-bundle.crt
  431. cd_safe ..
  432. fi
  433. do_checkIfExist
  434. fi
  435. fi
  436. if [[ $exitearly = EE2 ]]; then
  437. do_simple_print -p '\n\t'"${orange}Exit due to env var MABS_EXIT_EARLY set to EE2"
  438. return
  439. fi
  440. if { { [[ $ffmpeg != no || $standalone = y ]] && enabled libtesseract; } ||
  441. { [[ $standalone = y ]] && enabled libwebp; }; }; then
  442. _check=(libglut.a glut.pc)
  443. if do_vcs "$SOURCE_REPO_LIBGLUT" freeglut; then
  444. do_uninstall lib/cmake/FreeGLUT include/GL "${_check[@]}"
  445. do_cmakeinstall -D{UNIX,FREEGLUT_BUILD_DEMOS,FREEGLUT_BUILD_SHARED_LIBS}=OFF -DFREEGLUT_REPLACE_GLUT=ON
  446. do_checkIfExist
  447. fi
  448. do_pacman_install libjpeg-turbo xz zlib zstd libdeflate
  449. _deps=(libglut.a)
  450. _check=(libtiff{.a,-4.pc})
  451. [[ $standalone = y ]] && _check+=(bin-global/tiff{cp,dump,info,set,split}.exe)
  452. if do_vcs "$SOURCE_REPO_LIBTIFF"; then
  453. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/libtiff/0001-tiffgt-Link-winmm-if-windows.patch" am
  454. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/libtiff/0002-tiffgt-link-gl-after-glut.patch" am
  455. do_uninstall lib/cmake/tiff "${_check[@]}"
  456. extracommands=("-Dtiff-tests=OFF" "-Dtiff-docs=OFF")
  457. if [[ $standalone = y ]]; then
  458. extracommands+=("-Dtiff-tools=ON")
  459. else
  460. extracommands+=("-Dtiff-tools=OFF")
  461. fi
  462. grep_or_sed 'Requires.private' libtiff-4.pc.in \
  463. '/Libs:/ a\Requires.private: libjpeg liblzma zlib libzstd glut'
  464. CFLAGS+=" -DFREEGLUT_STATIC" \
  465. do_cmakeinstall global -D{webp,jbig,lerc}=OFF "${extracommands[@]}"
  466. do_checkIfExist
  467. fi
  468. fi
  469. file_installed -s libtiff-4.pc &&
  470. grep_or_sed '-ldeflate' "$(file_installed libtiff-4.pc)" \
  471. 's/Libs.private:.*/& -ldeflate/'
  472. if [[ $ffmpeg != no || $standalone = y ]] && enabled libwebp; then
  473. do_pacman_install giflib
  474. _check=(libwebp{,mux}.{a,pc})
  475. [[ $standalone = y ]] && _check+=(libwebp{demux,decoder}.{a,pc}
  476. bin-global/{{c,d}webp,webpmux,img2webp}.exe)
  477. if do_vcs "$SOURCE_REPO_LIBWEBP"; then
  478. do_uninstall include/webp bin-global/gif2webp.exe "${_check[@]}"
  479. extracommands=("-DWEBP_BUILD_EXTRAS=OFF" "-DWEBP_BUILD_VWEBP=OFF")
  480. if [[ $standalone = y ]]; then
  481. extracommands+=(-DWEBP_BUILD_{{C,D,GIF2,IMG2}WEBP,ANIM_UTILS,WEBPMUX}"=ON")
  482. else
  483. extracommands+=(-DWEBP_BUILD_{{C,D,GIF2,IMG2,V}WEBP,ANIM_UTILS,WEBPMUX}"=OFF")
  484. fi
  485. CFLAGS+=" -DFREEGLUT_STATIC" \
  486. do_cmakeinstall global -DWEBP_ENABLE_SWAP_16BIT_CSP=ON "${extracommands[@]}"
  487. do_checkIfExist
  488. fi
  489. fi
  490. if [[ $jpegxl = y ]] || { [[ $ffmpeg != no ]] && enabled libjxl; }; then
  491. _check=(bin/gflags_completions.sh gflags.pc gflags/gflags.h libgflags{,_nothreads}.a)
  492. if do_vcs "$SOURCE_REPO_GFLAGS"; then
  493. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/gflags/0001-cmake-chop-off-.lib-extension-from-shlwapi.patch" am
  494. do_uninstall "${_check[@]}" lib/cmake/gflags include/gflags
  495. do_cmakeinstall -D{BUILD,INSTALL}_STATIC_LIBS=ON -DBUILD_gflags_LIB=ON -DINSTALL_HEADERS=ON \
  496. -DREGISTER_{BUILD_DIR,INSTALL_PREFIX}=OFF
  497. do_checkIfExist
  498. fi
  499. do_pacman_install brotli lcms2
  500. _deps=(libgflags.a)
  501. _check=(libjxl{{,_threads}.a,.pc} jxl/decode.h)
  502. [[ $jpegxl = y ]] && _check+=(bin-global/{{c,d}jxl,cjpegli,jxlinfo}.exe)
  503. if do_vcs "$SOURCE_REPO_LIBJXL"; then
  504. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/libjxl/0001-brotli-link-enc-before-common.patch" am
  505. do_uninstall "${_check[@]}" include/jxl
  506. do_pacman_install asciidoc
  507. extracommands=()
  508. log -q "git.submodule" git submodule update --init --recursive
  509. [[ $jpegxl = y ]] || extracommands=("-DJPEGXL_ENABLE_TOOLS=OFF")
  510. CXXFLAGS+=" -DJXL_CMS_STATIC_DEFINE -DJXL_STATIC_DEFINE -DJXL_THREADS_STATIC_DEFINE" \
  511. do_cmakeinstall global -D{BUILD_TESTING,JPEGXL_ENABLE_{BENCHMARK,DOXYGEN,MANPAGES,OPENEXR,SKCMS,EXAMPLES}}=OFF \
  512. -DJPEGXL_{FORCE_SYSTEM_{BROTLI,LCMS2},STATIC}=ON "${extracommands[@]}"
  513. do_checkIfExist
  514. unset extracommands
  515. fi
  516. fi
  517. if files_exist bin-video/OpenCL.dll; then
  518. opencldll=$LOCALDESTDIR/bin-video/OpenCL.dll
  519. else
  520. syspath=$(cygpath -S)
  521. [[ $bits = 32bit && -d $syspath/../SysWOW64 ]] && syspath+=/../SysWOW64
  522. opencldll=$syspath/OpenCL.dll
  523. unset syspath
  524. fi
  525. if [[ $ffmpeg != no && -f $opencldll ]] && enabled opencl; then
  526. do_simple_print "${orange}FFmpeg and related apps will depend on OpenCL.dll$reset"
  527. do_pacman_remove opencl-headers
  528. _check=(CL/cl.h)
  529. if do_vcs "$SOURCE_REPO_OPENCLHEADERS"; then
  530. do_uninstall include/CL
  531. do_install CL/*.h include/CL/
  532. do_checkIfExist
  533. fi
  534. _check=(libOpenCL.a)
  535. if test_newer installed "$opencldll" "${_check[@]}"; then
  536. cd_safe "$LOCALBUILDDIR"
  537. [[ -d opencl ]] && rm -rf opencl
  538. mkdir -p opencl && cd_safe opencl
  539. create_build_dir
  540. gendef "$opencldll" >/dev/null 2>&1
  541. [[ -f OpenCL.def ]] && do_dlltool libOpenCL.a OpenCL.def
  542. [[ -f libOpenCL.a ]] && do_install libOpenCL.a
  543. do_checkIfExist
  544. fi
  545. else
  546. do_removeOption --enable-opencl
  547. fi
  548. unset opencldll
  549. if [[ $ffmpeg != no || $standalone = y ]] && enabled libtesseract; then
  550. do_pacman_remove tesseract-ocr
  551. _check=(libleptonica.{,l}a lept.pc)
  552. if do_vcs "$SOURCE_REPO_LEPT"; then
  553. do_uninstall include/leptonica "${_check[@]}"
  554. [[ -f configure ]] || do_autogen
  555. do_separate_confmakeinstall --disable-programs --without-{lib{openjpeg,webp},giflib}
  556. do_checkIfExist
  557. fi
  558. do_pacman_install libarchive pango asciidoc
  559. _check=(libtesseract.{,l}a tesseract.pc)
  560. if do_vcs "$SOURCE_REPO_TESSERACT"; then
  561. do_pacman_install docbook-xsl omp
  562. # Reverts a commit that breaks the pkgconfig file
  563. {
  564. git revert --no-edit b4a4f5c || git revert --abort
  565. } > /dev/null 2>&1
  566. do_autogen
  567. _check+=(bin-global/tesseract.exe)
  568. do_uninstall include/tesseract "${_check[@]}"
  569. sed -i 's|Requires.private.*|& libarchive iconv libtiff-4|' tesseract.pc.in
  570. grep_or_sed ws2_32 "$MINGW_PREFIX/lib/pkgconfig/libarchive.pc" 's;Libs.private:.*;& -lws2_32;g'
  571. case $CC in
  572. *gcc) sed -i -e 's|Libs.private.*|& -fopenmp -lgomp|' tesseract.pc.in ;;
  573. *clang) sed -i -e 's|Libs.private.*|& -fopenmp=libomp|' tesseract.pc.in ;;
  574. esac
  575. do_separate_confmakeinstall global --disable-{graphics,tessdata-prefix} \
  576. --without-curl \
  577. LIBLEPT_HEADERSDIR="$LOCALDESTDIR/include" \
  578. LIBS="$($PKG_CONFIG --libs iconv lept libtiff-4)" --datadir="$LOCALDESTDIR/bin-global"
  579. if [[ ! -f $LOCALDESTDIR/bin-global/tessdata/eng.traineddata ]]; then
  580. do_pacman_install tesseract-data-eng
  581. mkdir -p "$LOCALDESTDIR"/bin-global/tessdata
  582. do_install "$MINGW_PREFIX/share/tessdata/eng.traineddata" bin-global/tessdata/
  583. printf '%s\n' \
  584. "You can get more language data here:" \
  585. "https://github.com/tesseract-ocr/tessdata" \
  586. "Just download <lang you want>.traineddata and copy it to this directory." \
  587. > "$LOCALDESTDIR"/bin-global/tessdata/need_more_languages.txt
  588. fi
  589. do_checkIfExist
  590. fi
  591. fi
  592. _check=(librubberband.a rubberband.pc rubberband/{rubberband-c,RubberBandStretcher}.h)
  593. if { { [[ $ffmpeg != no ]] && enabled librubberband; } ||
  594. ! mpv_disabled rubberband; } &&
  595. do_vcs "$SOURCE_REPO_RUBBERBAND"; then
  596. do_uninstall "${_check[@]}"
  597. log "distclean" make distclean
  598. do_make PREFIX="$LOCALDESTDIR" install-static
  599. do_checkIfExist
  600. fi
  601. _check=(zimg{.h,++.hpp} libzimg.{,l}a zimg.pc)
  602. if [[ $ffmpeg != no ]] && enabled libzimg &&
  603. do_vcs "$SOURCE_REPO_ZIMG"; then
  604. log -q "git.submodule" git submodule update --init --recursive
  605. do_uninstall "${_check[@]}"
  606. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/zimg/0001-libm_wrapper-define-__CRT__NO_INLINE-before-math.h.patch" am
  607. do_autoreconf
  608. do_separate_confmakeinstall
  609. do_checkIfExist
  610. fi
  611. if [[ $exitearly = EE3 ]]; then
  612. do_simple_print -p '\n\t'"${orange}Exit due to env var MABS_EXIT_EARLY set to EE3"
  613. return
  614. fi
  615. set_title "compiling audio tools"
  616. do_simple_print -p '\n\t'"${orange}Starting $bits compilation of audio tools${reset}"
  617. if [[ $ffmpeg != no || $sox = y ]]; then
  618. do_pacman_install wavpack
  619. enabled_any libopencore-amr{wb,nb} && do_pacman_install opencore-amr
  620. if enabled libtwolame; then
  621. do_pacman_install twolame
  622. do_addOption --extra-cflags=-DLIBTWOLAME_STATIC
  623. fi
  624. enabled libmp3lame && do_pacman_install lame
  625. fi
  626. _check=(ilbc.h libilbc.{a,pc})
  627. if [[ $ffmpeg != no ]] && enabled libilbc &&
  628. do_vcs "$SOURCE_REPO_LIBILBC"; then
  629. do_uninstall "${_check[@]}"
  630. log -q "git.submodule" git submodule update --init --recursive
  631. do_cmakeinstall -DUNIX=OFF
  632. do_checkIfExist
  633. fi
  634. _check=(libogg.{l,}a ogg/ogg.h ogg.pc)
  635. if { [[ $flac = y ]] || enabled libvorbis; } &&
  636. do_vcs "$SOURCE_REPO_LIBOGG"; then
  637. do_uninstall include/ogg "${_check[@]}"
  638. do_autogen
  639. do_separate_confmakeinstall audio
  640. do_checkIfExist
  641. fi
  642. _check=(libvorbis{,enc,file}.{,l}a vorbis{,enc,file}.pc vorbis/vorbisenc.h)
  643. if enabled libvorbis && do_vcs "$SOURCE_REPO_LIBVORBIS"; then
  644. do_uninstall include/vorbis "${_check[@]}"
  645. do_autogen
  646. do_separate_confmakeinstall audio --disable-docs
  647. do_checkIfExist
  648. fi
  649. _check=(libspeex.{l,}a speex.pc speex/speex.h)
  650. [[ $standalone = y ]] && _check+=(bin-audio/speex{enc,dec}.exe)
  651. if enabled libspeex && do_vcs "$SOURCE_REPO_SPEEX"; then
  652. do_pacman_remove speex
  653. do_uninstall include/speex "${_check[@]}"
  654. do_autogen
  655. extracommands=()
  656. [[ $standalone = y ]] || extracommands+=(--disable-binaries)
  657. do_separate_confmakeinstall audio --enable-vorbis-psy "${extracommands[@]}"
  658. do_checkIfExist
  659. fi
  660. _check=(libFLAC{,++}.a flac{,++}.pc)
  661. [[ $standalone = y ]] && _check+=(bin-audio/flac.exe)
  662. if [[ $flac = y ]]; then
  663. if do_vcs "$SOURCE_REPO_FLAC"; then
  664. if [[ $standalone = y ]]; then
  665. _check+=(bin-audio/metaflac.exe)
  666. fi
  667. do_uninstall include/FLAC{,++} share/aclocal/libFLAC{,++}.m4 "${_check[@]}"
  668. do_cmakeinstall audio -DBUILD_{DOCS,DOXYGEN,EXAMPLES,TESTING}=OFF -DINSTALL_MANPAGES=OFF
  669. do_checkIfExist
  670. fi
  671. elif [[ $sox = y ]] || { [[ $standalone = y ]] && enabled_any libvorbis libopus; }; then
  672. do_pacman_install flac
  673. grep_and_sed dllimport "$MINGW_PREFIX"/include/FLAC++/export.h \
  674. 's|__declspec\(dllimport\)||g' "$MINGW_PREFIX"/include/FLAC{,++}/export.h
  675. fi
  676. grep_and_sed dllimport "$LOCALDESTDIR"/include/FLAC++/export.h \
  677. 's|__declspec\(dllimport\)||g' "$LOCALDESTDIR"/include/FLAC{,++}/export.h
  678. grep_or_sed pthread "$LOCALDESTDIR/lib/pkgconfig/flac.pc" 's/Libs.private: /&-pthread /;s/Cflags: .*/& -pthread/'
  679. _check=(libvo-amrwbenc.{l,}a vo-amrwbenc.pc)
  680. if [[ $ffmpeg != no ]] && enabled libvo-amrwbenc &&
  681. do_pkgConfig "vo-amrwbenc = 0.1.3" &&
  682. do_wget_sf -h f63bb92bde0b1583cb3cb344c12922e0 \
  683. "opencore-amr/vo-amrwbenc/vo-amrwbenc-0.1.3.tar.gz"; then
  684. do_uninstall include/vo-amrwbenc "${_check[@]}"
  685. do_separate_confmakeinstall
  686. do_checkIfExist
  687. fi
  688. if { [[ $ffmpeg != no ]] && enabled libfdk-aac; } || [[ $fdkaac = y ]]; then
  689. _check=(libfdk-aac.{l,}a fdk-aac.pc)
  690. if do_vcs "$SOURCE_REPO_FDKAAC"; then
  691. do_autoreconf
  692. do_uninstall include/fdk-aac "${_check[@]}"
  693. CXXFLAGS+=" -fno-exceptions -fno-rtti" do_separate_confmakeinstall
  694. do_checkIfExist
  695. fi
  696. _check=(bin-audio/fdkaac.exe)
  697. _deps=(libfdk-aac.a)
  698. if [[ $standalone = y ]] &&
  699. do_vcs "$SOURCE_REPO_FDKAACEXE" bin-fdk-aac; then
  700. do_autoreconf
  701. do_uninstall "${_check[@]}"
  702. CFLAGS+=" $($PKG_CONFIG --cflags fdk-aac)" \
  703. LDFLAGS+=" $($PKG_CONFIG --cflags --libs fdk-aac)" \
  704. do_separate_confmakeinstall audio
  705. do_checkIfExist
  706. fi
  707. fi
  708. if [[ $faac = y ]]; then
  709. _check=(bin-audio/faac.exe)
  710. if [[ $standalone = y ]]; then
  711. do_pacman_install faac
  712. elif do_vcs "$SOURCE_REPO_FAAC"; then
  713. do_pacman_remove faac
  714. do_uninstall libfaac.a faac{,cfg}.h "${_check[@]}"
  715. log bootstrap ./bootstrap
  716. do_separate_confmakeinstall audio
  717. do_checkIfExist
  718. fi
  719. fi
  720. _check=(bin-audio/exhale.exe)
  721. if [[ $exhale = y ]] &&
  722. do_vcs "$SOURCE_REPO_EXHALE"; then
  723. do_uninstall "${_check[@]}"
  724. _notrequired=true
  725. do_cmakeinstall audio
  726. do_checkIfExist
  727. unset _notrequired
  728. fi
  729. _check=(bin-audio/ogg{enc,dec}.exe)
  730. _deps=(ogg.pc vorbis.pc)
  731. if [[ $standalone = y ]] && enabled libvorbis &&
  732. do_vcs "$SOURCE_REPO_VORBIS_TOOLS"; then
  733. do_patch "https://github.com/xiph/vorbis-tools/pull/39.patch" am
  734. do_autoreconf
  735. do_uninstall "${_check[@]}"
  736. extracommands=()
  737. enabled libspeex || extracommands+=(--without-speex)
  738. do_separate_conf --disable-{ogg123,vorbiscomment,vcut,ogginfo} \
  739. --with-lib{iconv,intl}-prefix="$MINGW_PREFIX" "${extracommands[@]}"
  740. do_make
  741. do_install oggenc/oggenc.exe oggdec/oggdec.exe bin-audio/
  742. do_checkIfExist
  743. fi
  744. _check=(libopus.{,l}a opus.pc opus/opus.h)
  745. if enabled libopus && do_vcs "$SOURCE_REPO_OPUS"; then
  746. do_pacman_remove opus
  747. do_uninstall include/opus "${_check[@]}"
  748. (
  749. sha=$(grep dnn/download_model.sh autogen.sh | awk -F'"' '{print $2}')
  750. model=opus_data-${sha}.tar.gz
  751. pushd . > /dev/null
  752. [ -f "/build/$model" ] || do_wget -r -q -n "https://media.xiph.org/opus/models/$model"
  753. popd > /dev/null || return 1
  754. ln -s "$LOCALBUILDDIR/$model" .
  755. )
  756. do_autogen
  757. do_separate_confmakeinstall --disable-{stack-protector,doc,extra-programs}
  758. do_checkIfExist
  759. fi
  760. if [[ $standalone = y ]] && enabled libopus; then
  761. do_pacman_install openssl
  762. hide_libressl
  763. do_pacman_remove opusfile
  764. _check=(opus/opusfile.h libopus{file,url}.{,l}a opus{file,url}.pc)
  765. _deps=(ogg.pc opus.pc "$MINGW_PREFIX"/lib/pkgconfig/libssl.pc)
  766. if do_vcs "$SOURCE_REPO_OPUSFILE"; then
  767. do_uninstall "${_check[@]}"
  768. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/opusfile/0001-Disable-cert-store-integration-if-OPENSSL_VERSION_NU.patch" am
  769. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/opusfile/0002-configure-Only-add-std-c89-if-not-mingw-because-of-c.patch" am
  770. do_autogen
  771. do_separate_confmakeinstall --disable-{examples,doc}
  772. do_checkIfExist
  773. fi
  774. _check=(opus/opusenc.h libopusenc.{pc,{,l}a})
  775. _deps=(opus.pc)
  776. if do_vcs "$SOURCE_REPO_LIBOPUSENC"; then
  777. do_uninstall "${_check[@]}"
  778. do_autogen
  779. do_separate_confmakeinstall --disable-{examples,doc}
  780. do_checkIfExist
  781. fi
  782. _check=(bin-audio/opusenc.exe)
  783. _deps=(opusfile.pc libopusenc.pc)
  784. if do_vcs "$SOURCE_REPO_OPUSEXE"; then
  785. _check+=(bin-audio/opus{dec,info}.exe)
  786. do_uninstall "${_check[@]}"
  787. do_autogen
  788. do_separate_confmakeinstall audio
  789. do_checkIfExist
  790. fi
  791. hide_libressl -R
  792. fi
  793. _check=(soxr.h libsoxr.a)
  794. if [[ $ffmpeg != no ]] && enabled libsoxr &&
  795. do_vcs "$SOURCE_REPO_LIBSOXR"; then
  796. do_uninstall "${_check[@]}"
  797. do_cmakeinstall -D{WITH_LSR_BINDINGS,BUILD_TESTS,WITH_OPENMP}=off
  798. do_checkIfExist
  799. fi
  800. _check=(libcodec2.a codec2.pc codec2/codec2.h)
  801. if [[ $ffmpeg != no ]] && enabled libcodec2; then
  802. if do_vcs "$SOURCE_REPO_CODEC2"; then
  803. do_uninstall all include/codec2 "${_check[@]}"
  804. sed -i 's|if(WIN32)|if(FALSE)|g' CMakeLists.txt
  805. if enabled libspeex; then
  806. # rename same-named symbols copied from speex
  807. grep -ERl "\b(lsp|lpc)_to_(lpc|lsp)" --include="*.[ch]" | \
  808. xargs -r sed -ri "s;((lsp|lpc)_to_(lpc|lsp));c2_\1;g"
  809. fi
  810. do_cmakeinstall -D{UNITTEST,INSTALL_EXAMPLES}=off \
  811. -DCMAKE_INSTALL_BINDIR="$(pwd)/build-$bits/_bin"
  812. do_checkIfExist
  813. fi
  814. fi
  815. if [[ $standalone = y ]] && enabled libmp3lame; then
  816. _check=(bin-audio/lame.exe)
  817. if files_exist "${_check[@]}" &&
  818. grep -q "3.100" "$LOCALDESTDIR/bin-audio/lame.exe"; then
  819. do_print_status "lame 3.100" "$green" "Up-to-date"
  820. elif do_wget_sf \
  821. -h ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e \
  822. "lame/lame/3.100/lame-3.100.tar.gz"; then
  823. do_uninstall include/lame libmp3lame.{l,}a "${_check[@]}"
  824. _mingw_patches_lame="https://raw.githubusercontent.com/Alexpux/MINGW-packages/master/mingw-w64-lame"
  825. do_patch "$_mingw_patches_lame/0005-no-gtk.all.patch"
  826. do_patch "$_mingw_patches_lame/0006-dont-use-outdated-symbol-list.patch"
  827. do_patch "$_mingw_patches_lame/0007-revert-posix-code.patch"
  828. do_patch "$_mingw_patches_lame/0008-skip-termcap.patch"
  829. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/lame/0001-libmp3lame-vector-Makefile.am-Add-msse-to-fix-i686-c.patch"
  830. do_autoreconf
  831. do_separate_conf --enable-nasm
  832. do_make
  833. do_install frontend/lame.exe bin-audio/
  834. do_checkIfExist
  835. unset _mingw_patches_lame
  836. fi
  837. fi
  838. _check=(libgme.{a,pc})
  839. if [[ $ffmpeg != no ]] && enabled libgme && do_pkgConfig "libgme = 0.6.3" &&
  840. do_wget -h aba34e53ef0ec6a34b58b84e28bf8cfbccee6585cebca25333604c35db3e051d \
  841. "https://bitbucket.org/mpyne/game-music-emu/downloads/game-music-emu-0.6.3.tar.xz"; then
  842. do_uninstall include/gme "${_check[@]}"
  843. do_cmakeinstall -DENABLE_UBSAN=OFF
  844. do_checkIfExist
  845. fi
  846. _check=(libbs2b.{{l,}a,pc})
  847. if [[ $ffmpeg != no ]] && enabled libbs2b && do_pkgConfig "libbs2b = 3.1.0" &&
  848. do_wget_sf -h c1486531d9e23cf34a1892ec8d8bfc06 "bs2b/libbs2b/3.1.0/libbs2b-3.1.0.tar.bz2"; then
  849. do_uninstall include/bs2b "${_check[@]}"
  850. # sndfile check is disabled since we don't compile binaries anyway
  851. /usr/bin/grep -q sndfile configure && sed -i '20119,20133d' configure
  852. sed -i "s|bin_PROGRAMS = .*||" src/Makefile.in
  853. do_separate_confmakeinstall
  854. do_checkIfExist
  855. fi
  856. _check=(libsndfile.a sndfile.{h,pc})
  857. if [[ $sox = y ]] && do_vcs "$SOURCE_REPO_SNDFILE" sndfile; then
  858. do_uninstall include/sndfile.hh "${_check[@]}"
  859. do_cmakeinstall -DBUILD_EXAMPLES=off -DBUILD_TESTING=off -DBUILD_PROGRAMS=OFF
  860. do_checkIfExist
  861. fi
  862. _check=(bin-audio/sox.exe sox.pc)
  863. _deps=(libsndfile.a opus.pc "$MINGW_PREFIX"/lib/libmp3lame.a)
  864. if [[ $sox = y ]]; then
  865. do_pacman_install libmad
  866. extracommands=()
  867. if enabled libopus; then
  868. [[ $standalone = y ]] || do_pacman_install opusfile
  869. else
  870. extracommands+=(--without-opus)
  871. fi
  872. if do_vcs "$SOURCE_REPO_SOX" sox; then
  873. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/sox/0001-sox_version-fold-function-into-sox_version_info.patch" am
  874. do_patch "https://raw.githubusercontent.com/msys2/MINGW-packages/master/mingw-w64-sox/0001-ucrt-no-rewind-pipe.patch"
  875. do_uninstall sox.{pc,h} bin-audio/{soxi,play,rec}.exe libsox.{l,}a "${_check[@]}"
  876. do_autoreconf
  877. extralibs=(-lshlwapi -lz)
  878. enabled libmp3lame || extracommands+=(--without-lame)
  879. enabled_any libopencore-amr{wb,nb} &&
  880. extralibs+=(-lvo-amrwbenc) ||
  881. extracommands+=(--without-amr{wb,nb})
  882. enabled libtwolame &&
  883. extracommands+=(CFLAGS="$CFLAGS -DLIBTWOLAME_STATIC") ||
  884. extracommands+=(--without-twolame)
  885. enabled libvorbis || extracommands+=(--without-oggvorbis)
  886. hide_conflicting_libs
  887. sed -i 's|found_libgsm=yes|found_libgsm=no|g' configure
  888. do_separate_conf --disable-symlinks LIBS="-L$LOCALDESTDIR/lib ${extralibs[*]}" "${extracommands[@]}"
  889. do_make
  890. do_install src/sox.exe bin-audio/
  891. do_install sox.pc
  892. hide_conflicting_libs -R
  893. do_checkIfExist
  894. unset extralibs
  895. fi
  896. unset extracommands
  897. fi
  898. unset _deps
  899. _check=(libopenmpt.{a,pc})
  900. if [[ $ffmpeg != no ]] && enabled libopenmpt &&
  901. do_vcs "$SOURCE_REPO_LIBOPENMPT"; then
  902. do_uninstall include/libopenmpt "${_check[@]}"
  903. mkdir bin 2> /dev/null
  904. extracommands=("CONFIG=mingw64-win${bits%bit}" "AR=ar" "STATIC_LIB=1" "EXAMPLES=0" "OPENMPT123=0"
  905. "TEST=0" "OS=" "CC=$CC" "CXX=$CXX" "MINGW_COMPILER=${CC##* }")
  906. log clean make clean "${extracommands[@]}"
  907. do_makeinstall PREFIX="$LOCALDESTDIR" "${extracommands[@]}"
  908. sed -i 's/Libs.private.*/& -lrpcrt4/' "$LOCALDESTDIR/lib/pkgconfig/libopenmpt.pc"
  909. do_checkIfExist
  910. fi
  911. _check=(libmysofa.{a,pc} mysofa.h)
  912. if [[ $ffmpeg != no ]] && enabled libmysofa &&
  913. do_vcs "$SOURCE_REPO_LIBMYSOFA"; then
  914. do_uninstall "${_check[@]}"
  915. do_cmakeinstall -DBUILD_TESTS=no -DCODE_COVERAGE=OFF
  916. do_checkIfExist
  917. fi
  918. _check=(libflite.a flite/flite.h)
  919. if enabled libflite && do_vcs "$SOURCE_REPO_FLITE"; then
  920. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/flite/0001-tools-find_sts_main.c-Include-windows.h-before-defin.patch" am
  921. do_uninstall libflite_cmu_{grapheme,indic}_{lang,lex}.a \
  922. libflite_cmu_us_{awb,kal,kal16,rms,slt}.a \
  923. libflite_{cmulex,usenglish,cmu_time_awb}.a "${_check[@]}" include/flite
  924. log clean make clean
  925. do_configure --bindir="$LOCALDESTDIR"/bin-audio --disable-shared \
  926. --with-audio=none
  927. do_make && do_makeinstall
  928. do_checkIfExist
  929. fi
  930. _check=(shine/layer3.h libshine.{,l}a shine.pc)
  931. [[ $standalone = y ]] && _check+=(bin-audio/shineenc.exe)
  932. if enabled libshine && do_pkgConfig "shine = 3.1.1" &&
  933. do_wget -h 58e61e70128cf73f88635db495bfc17f0dde3ce9c9ac070d505a0cd75b93d384 \
  934. "https://github.com/toots/shine/releases/download/3.1.1/shine-3.1.1.tar.gz"; then
  935. do_uninstall "${_check[@]}"
  936. [[ $standalone = n ]] && sed -i '/bin_PROGRAMS/,+4d' Makefile.am
  937. # fix out-of-root build
  938. # shellcheck disable=SC2016
  939. sed -ri -e 's;(libshine.sym)$;$(srcdir)/\1;' \
  940. -e '/libshine_la_HEADERS/{s;(src/lib);$(srcdir)/\1;}' \
  941. -e '/shineenc_CFLAGS/{s;(src/lib);$(srcdir)/\1;}' Makefile.am
  942. rm configure
  943. do_autoreconf
  944. do_separate_confmakeinstall audio
  945. do_checkIfExist
  946. fi
  947. _check=(openal.pc libopenal.a)
  948. if { { [[ $ffmpeg != no ]] &&
  949. enabled openal; } || mpv_enabled openal; } &&
  950. do_vcs "$SOURCE_REPO_OPENAL"; then
  951. do_uninstall "${_check[@]}"
  952. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/openal-soft/0001-CMake-Fix-issues-for-mingw-w64.patch" am
  953. do_cmakeinstall -DLIBTYPE=STATIC -DALSOFT_UTILS=OFF -DALSOFT_EXAMPLES=OFF
  954. sed -i 's/Libs.private.*/& -luuid -lole32/' "$LOCALDESTDIR/lib/pkgconfig/openal.pc" # uuid is for FOLDERID_* stuff
  955. do_checkIfExist
  956. unset _mingw_patches
  957. fi
  958. _check=(liblc3.a lc3.pc)
  959. if [[ $ffmpeg != no ]] && enabled liblc3 &&
  960. do_vcs "$SOURCE_REPO_LIBLC3"; then
  961. do_uninstall "${_check[@]}"
  962. if [[ $standalone = y ]]; then
  963. _check+=(bin-audio/{d,e}lc3.exe)
  964. LDFLAGS+=" -lpthread" do_mesoninstall audio -Dtools=true
  965. else
  966. do_mesoninstall audio
  967. fi
  968. do_checkIfExist
  969. fi
  970. if [[ $exitearly = EE4 ]]; then
  971. do_simple_print -p '\n\t'"${orange}Exit due to env var MABS_EXIT_EARLY set to EE4"
  972. return
  973. fi
  974. set_title "compiling video tools"
  975. do_simple_print -p '\n\t'"${orange}Starting $bits compilation of video tools${reset}"
  976. _deps=(gnutls.pc)
  977. _check=(librtmp.{a,pc})
  978. [[ $rtmpdump = y || $standalone = y ]] && _check+=(bin-video/rtmpdump.exe)
  979. if { [[ $rtmpdump = y ]] ||
  980. { [[ $ffmpeg != no ]] && enabled librtmp; }; } &&
  981. do_vcs "$SOURCE_REPO_LIBRTMP" librtmp; then
  982. [[ $rtmpdump = y || $standalone = y ]] && _check+=(bin-video/rtmp{suck,srv,gw}.exe)
  983. do_uninstall include/librtmp "${_check[@]}"
  984. [[ -f librtmp/librtmp.a ]] && log "clean" make clean
  985. _rtmp_pkgver() {
  986. printf '%s-%s-%s_%s-%s-static' \
  987. "$(/usr/bin/grep -oP "(?<=^VERSION=).+" Makefile)" \
  988. "$(git log -1 --format=format:%cd-g%h --date=format:%Y%m%d)" \
  989. "GnuTLS" \
  990. "$($PKG_CONFIG --modversion gnutls)" \
  991. "$CARCH"
  992. }
  993. do_makeinstall XCFLAGS="$CFLAGS -I$MINGW_PREFIX/include" XLDFLAGS="$LDFLAGS" SHARED= \
  994. SYS=mingw prefix="$LOCALDESTDIR" bindir="$LOCALDESTDIR"/bin-video \
  995. sbindir="$LOCALDESTDIR"/bin-video mandir="$LOCALDESTDIR"/share/man \
  996. CRYPTO=GNUTLS LIB_GNUTLS="$($PKG_CONFIG --libs gnutls) -lz" \
  997. VERSION="$(_rtmp_pkgver)"
  998. do_checkIfExist
  999. unset _rtmp_pkgver
  1000. fi
  1001. _check=(libvpx.a vpx.pc)
  1002. [[ $standalone = y || $av1an != n ]] && _check+=(bin-video/vpxenc.exe)
  1003. if { enabled libvpx || [[ $vpx = y ]]; } && do_vcs "$SOURCE_REPO_VPX" vpx; then
  1004. extracommands=()
  1005. [[ -f config.mk ]] && log "distclean" make distclean
  1006. [[ $standalone = y || $av1an != n ]] && _check+=(bin-video/vpxdec.exe) ||
  1007. extracommands+=(--disable-{examples,webm-io,libyuv,postproc})
  1008. do_uninstall include/vpx "${_check[@]}"
  1009. create_build_dir
  1010. [[ $bits = 32bit ]] && arch=x86 || arch=x86_64
  1011. [[ $ffmpeg = sharedlibs ]] || extracommands+=(--enable-{vp9-postproc,vp9-highbitdepth})
  1012. get_external_opts extracommands
  1013. config_path=.. do_configure --target="${arch}-win${bits%bit}-gcc" \
  1014. --disable-{shared,unit-tests,docs,install-bins} \
  1015. "${extracommands[@]}"
  1016. sed -i 's;HAVE_GNU_STRIP=yes;HAVE_GNU_STRIP=no;' -- ./*.mk
  1017. do_make
  1018. do_makeinstall
  1019. [[ $standalone = y || $av1an != n ]] && do_install vpx{enc,dec}.exe bin-video/
  1020. do_checkIfExist
  1021. unset extracommands
  1022. else
  1023. pc_exists vpx || do_removeOption --enable-libvpx
  1024. fi
  1025. _check=(libvmaf.{a,pc} libvmaf/libvmaf.h)
  1026. if [[ $ffmpeg != no ]] && enabled libvmaf &&
  1027. do_vcs "$SOURCE_REPO_LIBVMAF"; then
  1028. do_uninstall share/model "${_check[@]}"
  1029. do_pacman_install -m vim # for built_in_models
  1030. cd_safe libvmaf
  1031. CFLAGS="-msse2 -mfpmath=sse -mstackrealign $CFLAGS" do_mesoninstall video \
  1032. -Denable_float=true -Dbuilt_in_models=true -Denable_tests=false
  1033. do_checkIfExist
  1034. fi
  1035. file_installed -s libvmaf.dll.a && rm "$(file_installed libvmaf.dll.a)"
  1036. _check=(libaom.a aom.pc)
  1037. if [[ $aom = y || $standalone = y || $av1an != n ]]; then
  1038. _aom_bins=true
  1039. _check+=(bin-video/aomenc.exe)
  1040. else
  1041. _aom_bins=false
  1042. fi
  1043. if { [[ $aom = y ]] || [[ $libavif = y ]] || { [[ $ffmpeg != no ]] && enabled libaom; }; } &&
  1044. do_vcs "$SOURCE_REPO_LIBAOM"; then
  1045. extracommands=()
  1046. if $_aom_bins; then
  1047. _check+=(bin-video/aomdec.exe)
  1048. # fix google's shit
  1049. sed -ri 's;_PREFIX.+CMAKE_INSTALL_BINDIR;_FULL_BINDIR;' \
  1050. build/cmake/aom_install.cmake
  1051. else
  1052. extracommands+=("-DENABLE_EXAMPLES=off")
  1053. fi
  1054. do_uninstall include/aom "${_check[@]}"
  1055. get_external_opts extracommands
  1056. do_cmakeinstall video -DENABLE_{DOCS,TOOLS,TEST{S,DATA}}=off \
  1057. -DENABLE_NASM=on -DFORCE_HIGHBITDEPTH_DECODING=0 "${extracommands[@]}"
  1058. do_checkIfExist
  1059. unset extracommands
  1060. fi
  1061. unset _aom_bins
  1062. _check=(dav1d/dav1d.h dav1d.pc libdav1d.a)
  1063. [[ $standalone = y ]] && _check+=(bin-video/dav1d.exe)
  1064. if { [[ $dav1d = y ]] || [[ $libavif = y ]] || { [[ $ffmpeg != no ]] && enabled libdav1d; }; } &&
  1065. do_vcs "$SOURCE_REPO_DAV1D"; then
  1066. do_uninstall include/dav1d "${_check[@]}"
  1067. extracommands=()
  1068. [[ $standalone = y ]] || extracommands=("-Denable_tools=false")
  1069. do_mesoninstall video -Denable_{tests,examples}=false "${extracommands[@]}"
  1070. do_checkIfExist
  1071. fi
  1072. { enabled librav1e || [[ $libavif = y ]] || [[ $dovitool = y ]]; } && do_pacman_install cargo-c
  1073. _check=()
  1074. { [[ $rav1e = y ]] || [[ $av1an != n ]] ||
  1075. { enabled librav1e && [[ $standalone = y ]]; } } &&
  1076. _check+=(bin-video/rav1e.exe)
  1077. { enabled librav1e || [[ $libavif = y ]]; } && _check+=(librav1e.a rav1e.pc rav1e/rav1e.h)
  1078. if { [[ $rav1e = y ]] || [[ $libavif = y ]] || enabled librav1e; } &&
  1079. do_vcs "$SOURCE_REPO_LIBRAV1E"; then
  1080. do_uninstall "${_check[@]}" include/rav1e
  1081. # We want to hide libgit2 unless we have a static library
  1082. _libgit2_pc="$MINGW_PREFIX/lib/pkgconfig/libgit2.pc"
  1083. if ! [[ -f $MINGW_PREFIX/lib/libgit2.a ]]; then
  1084. if [[ -f $_libgit2_pc ]]; then
  1085. mv -f "$_libgit2_pc"{,.dyn}
  1086. fi
  1087. else
  1088. if ! [[ -f $_libgit2_pc ]]; then
  1089. cp -f "$_libgit2_pc"{.dyn,}
  1090. fi
  1091. fi
  1092. unset _libgit2_pc
  1093. # standalone binary
  1094. if [[ $rav1e = y || $standalone = y || $av1an != n ]]; then
  1095. do_rust --profile release-no-lto
  1096. find "target/$CARCH-pc-windows-gnu$rust_target_suffix" -name "rav1e.exe" | while read -r f; do
  1097. do_install "$f" bin-video/
  1098. done
  1099. fi
  1100. # C lib
  1101. if [[ $libavif = y ]] || enabled librav1e; then
  1102. rm -f "$CARGO_HOME/config" 2> /dev/null
  1103. PKG_CONFIG="$LOCALDESTDIR/bin/ab-pkg-config-static.bat" \
  1104. log "install-rav1e-c" cargo capi install \
  1105. --release --jobs "$cpuCount" --prefix="$LOCALDESTDIR" \
  1106. --destdir="$PWD/install-$bits"
  1107. # do_install "install-$bits/bin/rav1e.dll" bin-video/
  1108. # do_install "install-$bits/lib/librav1e.dll.a" lib/
  1109. do_install "$(find "install-$bits/" -name "librav1e.a")" lib/
  1110. do_install "$(find "install-$bits/" -name "rav1e.pc")" lib/pkgconfig/
  1111. sed -i 's/\\/\//g' "$LOCALDESTDIR/lib/pkgconfig/rav1e.pc" >/dev/null 2>&1
  1112. do_install "$(find "install-$bits/" -name "rav1e")"/*.h include/rav1e/
  1113. fi
  1114. do_checkIfExist
  1115. fi
  1116. # add allow-multiple-definition to the .pc file to fix linking with other rust libraries
  1117. sed -i 's/Libs.private:.*/& -Wl,--allow-multiple-definition/' "$LOCALDESTDIR/lib/pkgconfig/rav1e.pc" >/dev/null 2>&1
  1118. _check=(bin-video/SvtAv1EncApp.exe
  1119. libSvtAv1Enc.a SvtAv1Enc.pc)
  1120. if [[ $bits = 32bit ]]; then
  1121. do_removeOption --enable-libsvtav1
  1122. elif { [[ $svtav1 = y ]] || enabled libsvtav1; } &&
  1123. do_vcs "$SOURCE_REPO_SVTAV1"; then
  1124. do_uninstall include/svt-av1 "${_check[@]}" include/svt-av1
  1125. do_cmakeinstall video -DUNIX=OFF -DENABLE_AVX512=ON
  1126. do_checkIfExist
  1127. fi
  1128. if [[ $libavif = y ]]; then
  1129. do_pacman_install libjpeg-turbo libyuv
  1130. _check=(libavif.{a,pc} avif/avif.h)
  1131. [[ $standalone = y ]] && _check+=(bin-video/avif{enc,dec}.exe)
  1132. if { pc_exists "aom" || pc_exists "dav1d" || pc_exists "rav1e" || pc_exists "SvtAv1Enc"; } &&
  1133. do_vcs "$SOURCE_REPO_LIBAVIF"; then
  1134. # chop off any .lib suffixes that is attached to a library name
  1135. grep_and_sed '\.lib' CMakeLists.txt 's|(\w)\.lib\b|\1|g'
  1136. do_uninstall "${_check[@]}"
  1137. extracommands=()
  1138. pc_exists "dav1d" && extracommands+=("-DAVIF_CODEC_DAV1D=ON")
  1139. pc_exists "rav1e" && extracommands+=("-DAVIF_CODEC_RAV1E=ON")
  1140. pc_exists "aom" && extracommands+=("-DAVIF_CODEC_AOM=ON")
  1141. pc_exists "SvtAv1Enc" && extracommands+=("-DAVIF_CODEC_SVT=ON")
  1142. case $standalone in
  1143. y) extracommands+=("-DAVIF_BUILD_APPS=ON") ;;
  1144. *) extracommands+=("-DAVIF_BUILD_APPS=OFF") ;;
  1145. esac
  1146. do_cmakeinstall video -DAVIF_ENABLE_WERROR=OFF "${extracommands[@]}"
  1147. do_checkIfExist
  1148. fi
  1149. fi
  1150. _check=(libkvazaar.{,l}a kvazaar.pc kvazaar.h)
  1151. [[ $standalone = y ]] && _check+=(bin-video/kvazaar.exe)
  1152. if { [[ $other265 = y ]] || { [[ $ffmpeg != no ]] && enabled libkvazaar; }; } &&
  1153. do_vcs "$SOURCE_REPO_LIBKVAZAAR"; then
  1154. do_patch "https://github.com/m-ab-s/mabs-patches/raw/master/kvazaar/0001-Mingw-w64-Re-enable-avx2.patch" am
  1155. do_uninstall kvazaar_version.h "${_check[@]}"
  1156. do_autogen
  1157. [[ $standalone = y || $other265 = y ]] ||
  1158. sed -i "s|bin_PROGRAMS = .*||" src/Makefile.in
  1159. CFLAGS+=" -fno-asynchronous-unwind-tables -DKVZ_BIT_DEPTH=10" \
  1160. do_separate_confmakeinstall video
  1161. do_checkIfExist
  1162. fi
  1163. _check=(libSDL2{,_test,main}.a sdl2.pc SDL2/SDL.h)
  1164. if { { [[ $ffmpeg != no ]] &&
  1165. { enabled sdl2 || ! disabled_any sdl2 autodetect; }; } ||
  1166. mpv_enabled sdl2; } &&
  1167. do_vcs "$SOURCE_REPO_SDL2"; then
  1168. do_uninstall include/SDL2 lib/cmake/SDL2 bin/sdl2-config "${_check[@]}"
  1169. do_autogen
  1170. sed -i 's|__declspec(dllexport)||g' include/{begin_code,SDL_opengl}.h
  1171. do_separate_confmakeinstall
  1172. do_checkIfExist
  1173. fi
  1174. _check=(libdvdread.{l,}a dvdread.pc)
  1175. if { { [[ $ffmpeg != no ]] && enabled_any libdvdread libdvdnav; } ||
  1176. [[ $mplayer = y ]] || mpv_enabled dvdnav; } &&
  1177. do_vcs "$SOURCE_REPO_LIBDVDREAD" dvdread; then
  1178. do_autoreconf
  1179. do_uninstall include/dvdread "${_check[@]}"
  1180. do_separate_confmakeinstall
  1181. do_checkIfExist
  1182. fi
  1183. [[ -f $LOCALDESTDIR/lib/pkgconfig/dvdread.pc ]] &&
  1184. grep_or_sed "Libs.private" "$LOCALDESTDIR"/lib/pkgconfig/dvdread.pc \
  1185. "/Libs:/ a\Libs.private: -ldl -lpsapi"
  1186. _check=(libdvdnav.{l,}a dvdnav.pc)
  1187. _deps=(libdvdread.a)
  1188. if { { [[ $ffmpeg != no ]] && enabled libdvdnav; } ||
  1189. [[ $mplayer = y ]] || mpv_enabled dvdnav; } &&
  1190. do_vcs "$SOURCE_REPO_LIBDVDNAV" dvdnav; then
  1191. do_autoreconf
  1192. do_uninstall include/dvdnav "${_check[@]}"
  1193. do_separate_confmakeinstall
  1194. do_checkIfExist
  1195. fi
  1196. unset _deps
  1197. if { [[ $ffmpeg != no ]] && enabled_any gcrypt libbluray; } ||
  1198. ! mpv_disabled libbluray; then
  1199. do_pacman_install libgcrypt
  1200. grep_or_sed ws2_32 "$MINGW_PREFIX/bin/libgcrypt-config" 's;-lgpg-error;& -lws2_32;'
  1201. grep_or_sed ws2_32 "$MINGW_PREFIX/bin/gpg-error-config" 's;-lgpg-error;& -lws2_32;'
  1202. fi
  1203. if { [[ $ffmpeg != no ]] && enabled libbluray; } || ! mpv_disabled libbluray; then
  1204. _check=(bin-video/libaacs.dll libaacs.{{,l}a,pc} libaacs/aacs.h)
  1205. if do_vcs "$SOURCE_REPO_LIBAACS"; then
  1206. sed -ri 's;bin_PROGRAMS.*;bin_PROGRAMS = ;' Makefile.am
  1207. do_autoreconf
  1208. do_uninstall "${_check[@]}" include/libaacs
  1209. do_separate_confmakeinstall video --enable-shared --with-libgcrypt-prefix="$MINGW_PREFIX"
  1210. mv -f "$LOCALDESTDIR/bin/libaacs-0.dll" "$LOCALDESTDIR/bin-video/libaacs.dll"
  1211. rm -f "$LOCALDESTDIR/bin-video/${MINGW_CHOST}-aacs_info.exe"
  1212. do_checkIfExist
  1213. fi
  1214. _check=(bin-video/libbdplus.dll libbdplus.{{,l}a,pc} libbdplus/bdplus.h)
  1215. if do_vcs "$SOURCE_REPO_LIBBDPLUS"; then
  1216. sed -ri 's;noinst_PROGRAMS.*;noinst_PROGRAMS = ;' Makefile.am
  1217. do_autoreconf
  1218. do_uninstall "${_check[@]}" include/libbdplus
  1219. do_separate_confmakeinstall video --enable-shared
  1220. mv -f "$LOCALDESTDIR/bin/libbdplus-0.dll" "$LOCALDESTDIR/bin-video/libbdplus.dll"
  1221. do_checkIfExist
  1222. fi
  1223. fi
  1224. _check=(libbluray.{{l,}a,pc})
  1225. if { { [[ $ffmpeg != no ]] && enabled libbluray; } || ! mpv_disabled libbluray; } &&
  1226. do_vcs "$SOURCE_REPO_LIBBLURAY"; then
  1227. [[ -f contrib/libudfread/.git ]] || log git.submodule git submodule update --init
  1228. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/libbluray/0001-dec-prefix-with-libbluray-for-now.patch" am
  1229. do_autoreconf
  1230. do_uninstall include/libbluray share/java "${_check[@]}"
  1231. sed -i 's|__declspec(dllexport)||g' jni/win32/jni_md.h
  1232. extracommands=()
  1233. log javahome get_java_home
  1234. OLD_PATH=$PATH
  1235. if [[ -n $JAVA_HOME ]]; then
  1236. if [[ ! -f /opt/apache-ant/bin/ant ]] ; then
  1237. apache_ant_ver=$(clean_html_index "https://www.apache.org/dist/ant/binaries/")
  1238. apache_ant_ver=$(get_last_version "$apache_ant_ver" "apache-ant" "1\.\d+\.\d+")
  1239. if do_wget -r -c \
  1240. "https://www.apache.org/dist/ant/binaries/apache-ant-${apache_ant_ver:-1.10.6}-bin.zip" \
  1241. apache-ant.zip; then
  1242. rm -rf /opt/apache-ant
  1243. mv apache-ant /opt/apache-ant
  1244. fi
  1245. fi
  1246. PATH=/opt/apache-ant/bin:$JAVA_HOME/bin:$PATH
  1247. log ant-diagnostics ant -diagnostics
  1248. export JDK_HOME=''
  1249. export JAVA_HOME
  1250. else
  1251. extracommands+=(--disable-bdjava-jar)
  1252. fi
  1253. if enabled libxml2; then
  1254. sed -ri 's;(Cflags.*);\1 -DLIBXML_STATIC;' src/libbluray.pc.in
  1255. else
  1256. extracommands+=(--without-libxml2)
  1257. fi
  1258. CFLAGS+=" $(enabled libxml2 && echo "-DLIBXML_STATIC")" \
  1259. do_separate_confmakeinstall --disable-{examples,doxygen-doc} \
  1260. --without-{fontconfig,freetype} "${extracommands[@]}"
  1261. do_checkIfExist
  1262. PATH=$OLD_PATH
  1263. unset extracommands JDK_HOME JAVA_HOME OLD_PATH
  1264. fi
  1265. _check=(libxavs.a xavs.{h,pc})
  1266. if [[ $ffmpeg != no ]] && enabled libxavs && do_pkgConfig "xavs = 0.1." "0.1" &&
  1267. do_vcs "$SOURCE_REPO_XAVS"; then
  1268. do_patch "https://github.com/Distrotech/xavs/pull/1.patch" am
  1269. [[ -f libxavs.a ]] && log "distclean" make distclean
  1270. do_uninstall "${_check[@]}"
  1271. sed -i 's|"NUL"|"/dev/null"|g' configure
  1272. do_configure
  1273. do_make libxavs.a
  1274. for _file in xavs.h libxavs.a xavs.pc; do do_install "$_file"; done
  1275. do_checkIfExist
  1276. unset _file
  1277. fi
  1278. _check=(libxavs2.a xavs2_config.h xavs2.{h,pc})
  1279. [[ $standalone = y ]] && _check+=(bin-video/xavs2.exe)
  1280. if [[ $bits = 32bit ]]; then
  1281. do_removeOption --enable-libxavs2
  1282. elif { [[ $avs2 = y ]] || { [[ $ffmpeg != no ]] && enabled libxavs2; }; } &&
  1283. do_vcs "$SOURCE_REPO_XAVS2"; then
  1284. do_patch "https://github.com/pkuvcl/xavs2/compare/master...1480c1:xavs2:gcc14/pointerconversion.patch" am
  1285. cd_safe build/linux
  1286. [[ -f config.mak ]] && log "distclean" make distclean
  1287. do_uninstall all "${_check[@]}"
  1288. do_configure --bindir="$LOCALDESTDIR"/bin-video --enable-static --enable-strip
  1289. do_makeinstall
  1290. do_checkIfExist
  1291. fi
  1292. _check=(libdavs2.a davs2_config.h davs2.{h,pc})
  1293. [[ $standalone = y ]] && _check+=(bin-video/davs2.exe)
  1294. if [[ $bits = 32bit ]]; then
  1295. do_removeOption --enable-libdavs2
  1296. elif { [[ $avs2 = y ]] || { [[ $ffmpeg != no ]] && enabled libdavs2; }; } &&
  1297. do_vcs "$SOURCE_REPO_DAVS"; then
  1298. cd_safe build/linux
  1299. [[ -f config.mak ]] && log "distclean" make distclean
  1300. do_uninstall all "${_check[@]}"
  1301. do_configure --bindir="$LOCALDESTDIR"/bin-video --enable-strip
  1302. do_makeinstall
  1303. do_checkIfExist
  1304. fi
  1305. _check=(libuavs3d.a uavs3d.{h,pc})
  1306. [[ $standalone = y ]] && _check+=(bin-video/uavs3dec.exe)
  1307. if [[ $ffmpeg != no ]] && enabled libuavs3d &&
  1308. do_vcs "$SOURCE_REPO_UAVS3D"; then
  1309. do_cmakeinstall
  1310. [[ $standalone = y ]] && do_install uavs3dec.exe bin-video/
  1311. do_checkIfExist
  1312. fi
  1313. _check=(libdovi.a libdovi/rpu_parser.h dovi.pc bin-video/dovi_tool.exe)
  1314. if [[ $dovitool = y ]] &&
  1315. do_vcs "$SOURCE_REPO_DOVI_TOOL"; then
  1316. do_uninstall "${_check[@]}" include/libdovi bin-video/dovi.dll dovi.def dovi.dll.a
  1317. do_rust
  1318. do_install "target/$CARCH-pc-windows-gnu$rust_target_suffix/release/dovi_tool.exe" bin-video/
  1319. cd dolby_vision
  1320. do_rustcinstall --bindir="$LOCALDESTDIR"/bin-video/ --library-type=staticlib
  1321. do_checkIfExist
  1322. fi
  1323. _check=(bin-video/hdr10plus_tool.exe)
  1324. if [[ $hdr10plustool = y ]] &&
  1325. do_vcs "$SOURCE_REPO_HDR10PLUS_TOOL"; then
  1326. do_uninstall "${_check[@]}"
  1327. do_rust
  1328. do_install "target/$CARCH-pc-windows-gnu$rust_target_suffix/release/hdr10plus_tool.exe" bin-video/
  1329. do_checkIfExist
  1330. fi
  1331. if [[ $mediainfo = y ]]; then
  1332. [[ $curl = openssl ]] && hide_libressl
  1333. _check=(libzen.{a,pc})
  1334. if do_vcs "$SOURCE_REPO_LIBZEN" libzen; then
  1335. do_uninstall include/ZenLib bin-global/libzen-config \
  1336. "${_check[@]}" libzen.la lib/cmake/zenlib
  1337. do_cmakeinstall Project/CMake
  1338. do_checkIfExist
  1339. fi
  1340. fix_cmake_crap_exports "$LOCALDESTDIR/lib/cmake/zenlib"
  1341. sed -i 's;message(FATAL_ERROR "The imported target;message(WARNING "The imported target;' \
  1342. "$MINGW_PREFIX"/lib/cmake/CURL/CURLTargets.cmake
  1343. _check=(libmediainfo.{a,pc})
  1344. _deps=(lib{zen,curl}.a)
  1345. if do_vcs "$SOURCE_REPO_LIBMEDIAINFO" libmediainfo; then
  1346. do_uninstall include/MediaInfo{,DLL} bin-global/libmediainfo-config \
  1347. "${_check[@]}" libmediainfo.la lib/cmake/mediainfolib
  1348. CFLAGS+=" $($PKG_CONFIG --cflags libzen)" \
  1349. LDFLAGS+=" $($PKG_CONFIG --cflags --libs libzen)" \
  1350. do_cmakeinstall Project/CMake -DBUILD_ZLIB=off -DBUILD_ZENLIB=off
  1351. do_checkIfExist
  1352. fi
  1353. fix_cmake_crap_exports "$LOCALDESTDIR/lib/cmake/mediainfolib"
  1354. _check=(bin-video/mediainfo.exe)
  1355. _deps=(libmediainfo.a)
  1356. if do_vcs "$SOURCE_REPO_MEDIAINFO" mediainfo; then
  1357. cd_safe Project/GNU/CLI
  1358. do_autogen
  1359. do_uninstall "${_check[@]}"
  1360. [[ -f Makefile ]] && log distclean make distclean
  1361. do_configure --disable-shared --bindir="$LOCALDESTDIR/bin-video" \
  1362. --enable-staticlibs
  1363. do_makeinstall
  1364. do_checkIfExist
  1365. fi
  1366. [[ $curl = openssl ]] && hide_libressl -R
  1367. fi
  1368. if [[ $ffmpeg != no ]] && enabled libvidstab; then
  1369. do_pacman_install omp
  1370. _check=(libvidstab.a vidstab.pc)
  1371. if do_vcs "$SOURCE_REPO_VIDSTAB" vidstab; then
  1372. do_uninstall include/vid.stab "${_check[@]}"
  1373. do_cmakeinstall
  1374. do_checkIfExist
  1375. fi
  1376. fi
  1377. _check=(libzvbi.{h,{l,}a} zvbi-0.2.pc)
  1378. if [[ $ffmpeg != no ]] && enabled libzvbi &&
  1379. do_vcs "$SOURCE_REPO_ZVBI"; then
  1380. do_uninstall "${_check[@]}" zvbi-0.2.pc
  1381. do_autoreconf
  1382. do_separate_conf --disable-{dvb,bktr,examples,nls,proxy,tests} --without-doxygen
  1383. cd_safe src
  1384. do_makeinstall
  1385. cd_safe ..
  1386. log pkgconfig make SUBDIRS=. install
  1387. do_checkIfExist
  1388. unset _vlc_zvbi_patches
  1389. fi
  1390. if [[ $ffmpeg != no ]] && enabled_any frei0r ladspa; then
  1391. _check=(libdl.a dlfcn.h)
  1392. if do_vcs "$SOURCE_REPO_DLFCN"; then
  1393. do_uninstall "${_check[@]}"
  1394. do_cmakeinstall
  1395. do_checkIfExist
  1396. fi
  1397. _check=(frei0r.{h,pc})
  1398. if do_vcs "$SOURCE_REPO_FREI0R"; then
  1399. sed -i 's/find_package (Cairo)//' "CMakeLists.txt"
  1400. do_uninstall lib/frei0r-1 "${_check[@]}"
  1401. do_pacman_install gavl
  1402. do_cmakeinstall -DWITHOUT_OPENCV=on
  1403. do_checkIfExist
  1404. fi
  1405. fi
  1406. _check=(DeckLinkAPI.h DeckLinkAPIVersion.h DeckLinkAPI_i.c)
  1407. if [[ $ffmpeg != no ]] && enabled decklink &&
  1408. do_vcs "$SOURCE_REPO_DECKLINK"; then
  1409. do_makeinstall PREFIX="$LOCALDESTDIR"
  1410. do_checkIfExist
  1411. fi
  1412. _check=(libvpl.a vpl.pc)
  1413. if [[ $ffmpeg != no ]] && enabled libvpl; then
  1414. if enabled libmfx; then
  1415. do_removeOption --enable-libmfx
  1416. fi
  1417. if do_vcs "$SOURCE_REPO_LIBVPL" libvpl; then
  1418. if [[ $bits = 32bit ]]; then
  1419. do_patch https://raw.githubusercontent.com/msys2/MINGW-packages/master/mingw-w64-libvpl/0003-cmake-fix-32bit-install.patch
  1420. fi
  1421. do_uninstall include/vpl "${_check[@]}"
  1422. do_cmakeinstall -DUNIX=OFF
  1423. do_checkIfExist
  1424. fi
  1425. fi
  1426. _check=(libmfx.{{l,}a,pc})
  1427. if [[ $ffmpeg != no ]] && enabled libmfx &&
  1428. do_vcs "$SOURCE_REPO_LIBMFX" libmfx; then
  1429. do_autoreconf
  1430. do_uninstall include/mfx "${_check[@]}"
  1431. do_separate_confmakeinstall
  1432. do_checkIfExist
  1433. fi
  1434. _check=(AMF/core/Version.h)
  1435. if [[ $ffmpeg != no ]] && { enabled amf || ! disabled_any autodetect amf; } &&
  1436. do_vcs "$SOURCE_REPO_AMF"; then
  1437. do_uninstall include/AMF
  1438. cd_safe amf/public/include
  1439. install -D -p -t "$LOCALDESTDIR/include/AMF/core" core/*.h
  1440. install -D -p -t "$LOCALDESTDIR/include/AMF/components" components/*.h
  1441. do_checkIfExist
  1442. fi
  1443. _check=(libgpac_static.a bin-video/{MP4Box,gpac}.exe)
  1444. if [[ $mp4box = y ]] && do_vcs "$SOURCE_REPO_GPAC"; then
  1445. do_uninstall include/gpac "${_check[@]}"
  1446. git grep -PIl "\xC2\xA0" | xargs -r sed -i 's/\xC2\xA0/ /g'
  1447. # Disable passing rpath to the linker, as it's a no-op with ld, but an error with lld
  1448. find . -name "Makefile" -exec grep -q rpath {} \; -exec sed -i '/^LINKFLAGS.*-rpath/s/^/#/' {} +
  1449. LIBRARY_PATH="$(cygpath -pm "$LOCALDESTDIR/lib:$MINGW_PREFIX/lib")" \
  1450. do_separate_conf --static-bin --static-build --static-modules
  1451. do_make
  1452. log "install" make install-lib
  1453. do_install bin/gcc/MP4Box.exe bin/gcc/gpac.exe bin-video/
  1454. do_checkIfExist
  1455. fi
  1456. _check=(SvtHevcEnc.pc libSvtHevcEnc.a svt-hevc/EbApi.h
  1457. bin-video/SvtHevcEncApp.exe)
  1458. if [[ $bits = 32bit ]]; then
  1459. do_removeOption --enable-libsvthevc
  1460. elif { [[ $svthevc = y ]] || enabled libsvthevc; } &&
  1461. do_vcs "$SOURCE_REPO_SVTHEVC"; then
  1462. do_uninstall "${_check[@]}" include/svt-hevc
  1463. do_cmakeinstall video -DUNIX=OFF
  1464. do_checkIfExist
  1465. fi
  1466. _check=(bin-video/SvtVp9EncApp.exe
  1467. libSvtVp9Enc.a SvtVp9Enc.pc)
  1468. if [[ $bits = 32bit ]]; then
  1469. do_removeOption --enable-libsvtvp9
  1470. elif { [[ $svtvp9 = y ]] || enabled libsvtvp9; } &&
  1471. do_vcs "$SOURCE_REPO_SVTVP9"; then
  1472. do_uninstall include/svt-vp9 "${_check[@]}" include/svt-vp9
  1473. do_cmakeinstall video -DUNIX=OFF
  1474. do_checkIfExist
  1475. fi
  1476. _check=(xvc.pc xvc{enc,dec}.h libxvc{enc,dec}.a bin-video/xvc{enc,dec}.exe)
  1477. if [[ $xvc == y ]] &&
  1478. do_vcs "$SOURCE_REPO_XVC"; then
  1479. do_uninstall "${_check[@]}"
  1480. do_cmakeinstall video -DBUILD_TESTS=OFF -DENABLE_ASSERTIONS=OFF
  1481. do_checkIfExist
  1482. fi
  1483. if [[ $x264 != no ]] ||
  1484. { [[ $ffmpeg != no ]] && enabled libx264; }; then
  1485. _check=(x264{,_config}.h libx264.a x264.pc)
  1486. [[ $standalone = y || $av1an != n ]] && _check+=(bin-video/x264.exe)
  1487. _bitdepth=$(get_api_version x264_config.h BIT_DEPTH)
  1488. if do_vcs "$SOURCE_REPO_X264" ||
  1489. [[ $x264 = o8 && $_bitdepth =~ (0|10) ]] ||
  1490. [[ $x264 = high && $_bitdepth =~ (0|8) ]] ||
  1491. [[ $x264 =~ (yes|full|shared|fullv) && "$_bitdepth" != 0 ]]; then
  1492. extracommands=("--host=$MINGW_CHOST" "--prefix=$LOCALDESTDIR"
  1493. "--bindir=$LOCALDESTDIR/bin-video")
  1494. # light ffmpeg build
  1495. old_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
  1496. PKG_CONFIG_PATH=$LOCALDESTDIR/opt/lightffmpeg/lib/pkgconfig:$MINGW_PREFIX/lib/pkgconfig
  1497. unset_extra_script
  1498. if [[ $standalone = y || $av1an != n ]] && [[ $x264 =~ (full|fullv) ]]; then
  1499. _check=("$LOCALDESTDIR"/opt/lightffmpeg/lib/pkgconfig/libav{codec,format}.pc)
  1500. do_vcs "$ffmpegPath"
  1501. do_uninstall "$LOCALDESTDIR"/opt/lightffmpeg
  1502. [[ -f config.mak ]] && log "distclean" make distclean
  1503. create_build_dir light
  1504. if [[ $x264 = fullv ]]; then
  1505. mapfile -t audio_codecs < <(
  1506. sed -n '/audio codecs/,/external libraries/p' ../libavcodec/allcodecs.c |
  1507. sed -n 's/^[^#]*extern.* *ff_\([^ ]*\)_decoder;/\1/p')
  1508. config_path=.. LDFLAGS+=" -L$MINGW_PREFIX/lib" \
  1509. do_configure "${FFMPEG_BASE_OPTS[@]}" \
  1510. --prefix="$LOCALDESTDIR/opt/lightffmpeg" \
  1511. --disable-{programs,devices,filters,encoders,muxers,debug,sdl2,network,protocols,doc} \
  1512. --enable-protocol=file,pipe \
  1513. --disable-decoder="$(IFS=, ; echo "${audio_codecs[*]}")" --enable-gpl \
  1514. --disable-bsf=aac_adtstoasc,text2movsub,noise,dca_core,mov2textsub,mp3_header_decompress \
  1515. --disable-autodetect --enable-{lzma,bzlib,zlib}
  1516. unset audio_codecs
  1517. else
  1518. config_path=.. LDFLAGS+=" -L$MINGW_PREFIX/lib" \
  1519. do_configure "${FFMPEG_BASE_OPTS[@]}" \
  1520. --prefix="$LOCALDESTDIR/opt/lightffmpeg" \
  1521. --disable-{programs,devices,filters,encoders,muxers,debug,sdl2,doc} --enable-gpl
  1522. fi
  1523. do_makeinstall
  1524. files_exist "${_check[@]}" && touch "build_successful${bits}_light"
  1525. unset_extra_script
  1526. _check=("$LOCALDESTDIR"/opt/lightffmpeg/lib/pkgconfig/ffms2.pc bin-video/ffmsindex.exe)
  1527. if do_vcs "$SOURCE_REPO_FFMS2"; then
  1528. do_uninstall "${_check[@]}"
  1529. sed -i 's/Cflags.*/& -DFFMS_STATIC/' ffms2.pc.in
  1530. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/ffms2/0001-ffmsindex-fix-linking-issues.patch" am
  1531. mkdir -p src/config
  1532. do_autoreconf
  1533. do_separate_confmakeinstall video --prefix="$LOCALDESTDIR/opt/lightffmpeg"
  1534. do_checkIfExist
  1535. fi
  1536. cd_safe "$LOCALBUILDDIR"/x264-git
  1537. else
  1538. extracommands+=(--disable-lavf --disable-ffms)
  1539. fi
  1540. if [[ $standalone = y || $av1an != n ]]; then
  1541. _check=("$LOCALDESTDIR/opt/lightffmpeg/lib/pkgconfig/liblsmash.pc")
  1542. if do_vcs "$SOURCE_REPO_LIBLSMASH" liblsmash; then
  1543. [[ -f config.mak ]] && log "distclean" make distclean
  1544. do_uninstall "${_check[@]}"
  1545. create_build_dir
  1546. log configure ../configure --prefix="$LOCALDESTDIR/opt/lightffmpeg"
  1547. do_make install-lib
  1548. do_checkIfExist
  1549. fi
  1550. cd_safe "$LOCALBUILDDIR"/x264-git
  1551. else
  1552. extracommands+=(--disable-cli)
  1553. fi
  1554. _check=(x264{,_config}.h x264.pc)
  1555. [[ $standalone = y || $av1an != n ]] && _check+=(bin-video/x264.exe)
  1556. [[ -f config.h ]] && log "distclean" make distclean
  1557. x264_build=$(grep ' X264_BUILD ' x264.h | cut -d' ' -f3)
  1558. if [[ $x264 = shared ]]; then
  1559. extracommands+=(--enable-shared)
  1560. _check+=(libx264.dll.a bin-video/libx264-"${x264_build}".dll)
  1561. else
  1562. extracommands+=(--enable-static)
  1563. _check+=(libx264.a)
  1564. fi
  1565. case $x264 in
  1566. high) extracommands+=("--bit-depth=10") ;;
  1567. o8) extracommands+=("--bit-depth=8") ;;
  1568. *) extracommands+=("--bit-depth=all") ;;
  1569. esac
  1570. do_uninstall "${_check[@]}"
  1571. check_custom_patches
  1572. create_build_dir
  1573. extra_script pre configure
  1574. PKGCONFIG="$PKG_CONFIG" CFLAGS="${CFLAGS// -O2 / }" \
  1575. log configure ../configure "${extracommands[@]}"
  1576. extra_script post configure
  1577. do_make
  1578. do_makeinstall
  1579. do_checkIfExist
  1580. PKG_CONFIG_PATH=$old_PKG_CONFIG_PATH
  1581. unset extracommands x264_build old_PKG_CONFIG_PATH
  1582. fi
  1583. unset _bitdepth
  1584. else
  1585. pc_exists x264 || do_removeOption --enable-libx264
  1586. fi
  1587. _check=(x265{,_config}.h libx265.a x265.pc)
  1588. [[ $standalone = y || $av1an != n ]] && _check+=(bin-video/x265.exe)
  1589. if [[ ! $x265 = n ]] && do_vcs "$SOURCE_REPO_X265"; then
  1590. grep_and_sed CMAKE_CXX_IMPLICIT_LINK_LIBRARIES source/CMakeLists.txt 's|\$\{CMAKE_CXX_IMPLICIT_LINK_LIBRARIES\}||g'
  1591. do_uninstall libx265{_main10,_main12}.a bin-video/libx265_main{10,12}.dll "${_check[@]}"
  1592. [[ $bits = 32bit ]] && assembly=-DENABLE_ASSEMBLY=OFF
  1593. [[ $x265 = d ]] && xpsupport=-DWINXP_SUPPORT=ON
  1594. build_x265() {
  1595. create_build_dir
  1596. local build_root=$PWD
  1597. mkdir -p {8,10,12}bit
  1598. do_x265_cmake() {
  1599. do_print_progress "Building $1" && shift 1
  1600. extra_script pre cmake
  1601. log "cmake" cmake "$(get_first_subdir -f)/source" -G Ninja \
  1602. -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" -DBIN_INSTALL_DIR="$LOCALDESTDIR/bin-video" \
  1603. -DENABLE_SHARED=OFF -DENABLE_CLI=OFF -DHIGH_BIT_DEPTH=ON \
  1604. -DENABLE_HDR10_PLUS=ON $xpsupport -DCMAKE_CXX_COMPILER="$LOCALDESTDIR/bin/${CXX#ccache }.bat" \
  1605. -DCMAKE_TOOLCHAIN_FILE="$LOCALDESTDIR/etc/toolchain.cmake" "$@"
  1606. extra_script post cmake
  1607. do_ninja
  1608. }
  1609. [[ $standalone = y || $av1an != n ]] && cli=-DENABLE_CLI=ON
  1610. if [[ $x265 =~ (o12|s|d|y) ]]; then
  1611. cd_safe "$build_root/12bit"
  1612. if [[ $x265 = s ]]; then
  1613. do_x265_cmake "shared 12-bit lib" $assembly -DENABLE_SHARED=ON -DMAIN12=ON
  1614. do_install libx265.dll bin-video/libx265_main12.dll
  1615. _check+=(bin-video/libx265_main12.dll)
  1616. elif [[ $x265 = o12 ]]; then
  1617. do_x265_cmake "12-bit lib/bin" $assembly $cli -DMAIN12=ON
  1618. else
  1619. do_x265_cmake "12-bit lib for multilib" $assembly -DEXPORT_C_API=OFF -DMAIN12=ON
  1620. cp libx265.a ../8bit/libx265_main12.a
  1621. fi
  1622. fi
  1623. if [[ $x265 =~ (o10|s|d|y) ]]; then
  1624. cd_safe "$build_root/10bit"
  1625. if [[ $x265 = s ]]; then
  1626. do_x265_cmake "shared 10-bit lib" $assembly -DENABLE_SHARED=ON
  1627. do_install libx265.dll bin-video/libx265_main10.dll
  1628. _check+=(bin-video/libx265_main10.dll)
  1629. elif [[ $x265 = o10 ]]; then
  1630. do_x265_cmake "10-bit lib/bin" $assembly $cli
  1631. else
  1632. do_x265_cmake "10-bit lib for multilib" $assembly -DEXPORT_C_API=OFF
  1633. cp libx265.a ../8bit/libx265_main10.a
  1634. fi
  1635. fi
  1636. if [[ $x265 =~ (o8|s|d|y) ]]; then
  1637. cd_safe "$build_root/8bit"
  1638. if [[ $x265 = s || $x265 = o8 ]]; then
  1639. do_x265_cmake "8-bit lib/bin" $cli -DHIGH_BIT_DEPTH=OFF
  1640. else
  1641. do_x265_cmake "multilib lib/bin" -DEXTRA_LIB="x265_main10.a;x265_main12.a" \
  1642. -DEXTRA_LINK_FLAGS=-L. $cli -DHIGH_BIT_DEPTH=OFF -DLINKED_{10,12}BIT=ON
  1643. mv libx265.a libx265_main.a
  1644. ar -M <<EOF
  1645. CREATE libx265.a
  1646. ADDLIB libx265_main.a
  1647. ADDLIB libx265_main10.a
  1648. ADDLIB libx265_main12.a
  1649. SAVE
  1650. END
  1651. EOF
  1652. fi
  1653. fi
  1654. }
  1655. build_x265
  1656. cpuCount=1 log "install" ninja install
  1657. if [[ $standalone = y || $av1an != n ]] && [[ $x265 = d ]]; then
  1658. cd_safe "$(get_first_subdir -f)"
  1659. do_uninstall bin-video/x265-numa.exe
  1660. do_print_progress "Building NUMA version of binary"
  1661. xpsupport="" build_x265
  1662. do_install x265.exe bin-video/x265-numa.exe
  1663. _check+=(bin-video/x265-numa.exe)
  1664. fi
  1665. do_checkIfExist
  1666. unset xpsupport assembly cli
  1667. else
  1668. pc_exists x265 || do_removeOption "--enable-libx265"
  1669. fi
  1670. pc_exists x265 && sed -i 's|-lmingwex||g' "$(file_installed x265.pc)"
  1671. _check=(xvid.h libxvidcore.a bin-video/xvid_encraw.exe)
  1672. if enabled libxvid && [[ $standalone = y ]] &&
  1673. do_vcs "$SOURCE_REPO_XVID"; then
  1674. do_patch "https://github.com/m-ab-s/xvid/compare/lighde.patch" am
  1675. do_pacman_remove xvidcore
  1676. do_uninstall "${_check[@]}"
  1677. cd_safe xvidcore/build/generic
  1678. log "bootstrap" ./bootstrap.sh
  1679. do_configure
  1680. do_make
  1681. do_install ../../src/xvid.h include/
  1682. do_install '=build/libxvidcore.a' libxvidcore.a
  1683. do_install '=build/libxvidcore.dll' bin-video/
  1684. cd_safe ../../examples
  1685. do_make xvid_encraw
  1686. do_install xvid_encraw.exe bin-video/
  1687. do_checkIfExist
  1688. fi
  1689. _check=(ffnvcodec/nvEncodeAPI.h ffnvcodec.pc)
  1690. if [[ $ffmpeg != no ]] && { enabled ffnvcodec ||
  1691. ! disabled_any ffnvcodec autodetect || ! mpv_disabled cuda-hwaccel; } &&
  1692. do_vcs "$SOURCE_REPO_FFNVCODEC" ffnvcodec; then
  1693. do_makeinstall PREFIX="$LOCALDESTDIR"
  1694. do_checkIfExist
  1695. fi
  1696. if enabled libsrt; then
  1697. do_pacman_install openssl
  1698. _check=(libsrt.a srt.pc srt/srt.h)
  1699. [[ $standalone = y ]] && _check+=(bin-video/srt-live-transmit.exe)
  1700. if do_vcs "$SOURCE_REPO_SRT"; then
  1701. hide_libressl
  1702. do_cmakeinstall video -DENABLE_SHARED=off -DENABLE_SUFLIP=off \
  1703. -DENABLE_EXAMPLES=off -DUSE_OPENSSL_PC=on -DUSE_STATIC_LIBSTDCXX=ON
  1704. hide_libressl -R
  1705. do_checkIfExist
  1706. fi
  1707. fi
  1708. if enabled librist; then
  1709. do_pacman_install cjson
  1710. _check=(librist.{a,pc} librist/librist.h)
  1711. [[ $standalone = y ]] && _check+=(bin-global/rist{sender,receiver,2rist,srppasswd}.exe)
  1712. if do_vcs "$SOURCE_REPO_LIBRIST"; then
  1713. do_uninstall include/librist "${_check[@]}"
  1714. extracommands=("-Dbuiltin_cjson=false")
  1715. [[ $standalone = y ]] || extracommands+=("-Dbuilt_tools=false")
  1716. do_mesoninstall global -Dhave_mingw_pthreads=true -Dtest=false "${extracommands[@]}"
  1717. do_checkIfExist
  1718. fi
  1719. fi
  1720. _vapoursynth_install() {
  1721. if [[ $bits = 32bit ]]; then
  1722. do_simple_print "${orange}Vapoursynth is known to be broken on 32-bit and will be disabled"'!'"${reset}"
  1723. return 1
  1724. fi
  1725. _python_ver=3.12.7
  1726. _python_lib=python312
  1727. _vsver=70
  1728. _check=("lib$_python_lib.a")
  1729. if files_exist "${_check[@]}"; then
  1730. do_print_status "python $_python_ver" "$green" "Up-to-date"
  1731. elif do_wget "https://www.python.org/ftp/python/$_python_ver/python-$_python_ver-embed-amd64.zip"; then
  1732. gendef "$_python_lib.dll" >/dev/null 2>&1
  1733. do_dlltool "lib$_python_lib.a" "$_python_lib.def"
  1734. [[ -f lib$_python_lib.a ]] && do_install "lib$_python_lib.a"
  1735. do_checkIfExist
  1736. fi
  1737. _check=(lib{vapoursynth,vsscript}.a vapoursynth{,-script}.pc vapoursynth/{VS{Helper,Script},VapourSynth}.h)
  1738. if pc_exists "vapoursynth = $_vsver" && files_exist "${_check[@]}"; then
  1739. do_print_status "vapoursynth R$_vsver" "$green" "Up-to-date"
  1740. elif do_wget "https://github.com/vapoursynth/vapoursynth/releases/download/R$_vsver/VapourSynth${bits%bit}-Portable-R$_vsver.zip"; then
  1741. do_uninstall {vapoursynth,vsscript}.lib include/vapoursynth "${_check[@]}"
  1742. do_install sdk/include/vapoursynth/*.h include/vapoursynth/
  1743. # Extract the .dll from the pip wheel
  1744. log "7z" 7z e -y -aoa wheel/VapourSynth-$_vsver-cp${_python_lib:6:3}-cp${_python_lib:6:3}-win_amd64.whl \
  1745. VapourSynth-$_vsver.data/data/Lib/site-packages/vapoursynth.dll
  1746. create_build_dir
  1747. declare -A _pc_vars=(
  1748. [vapoursynth-name]=vapoursynth
  1749. [vapoursynth-description]='A frameserver for the 21st century'
  1750. [vapoursynth-cflags]="-DVS_CORE_EXPORTS"
  1751. [vsscript-name]=vapoursynth-script
  1752. [vsscript-description]='Library for interfacing VapourSynth with Python'
  1753. [vsscript-private]="-l$_python_lib"
  1754. )
  1755. for _file in vapoursynth vsscript; do
  1756. gendef - "../$_file.dll" 2>/dev/null |
  1757. sed -E 's|^_||;s|@[1-9]+$||' > "${_file}.def"
  1758. do_dlltool "lib${_file}.a" "${_file}.def"
  1759. [[ -f lib${_file}.a ]] && do_install "lib${_file}.a"
  1760. # shellcheck disable=SC2016
  1761. printf '%s\n' \
  1762. "prefix=$LOCALDESTDIR" \
  1763. 'exec_prefix=${prefix}' \
  1764. 'libdir=${exec_prefix}/lib' \
  1765. 'includedir=${prefix}/include/vapoursynth' \
  1766. "Name: ${_pc_vars[${_file}-name]}" \
  1767. "Description: ${_pc_vars[${_file}-description]}" \
  1768. "Version: $_vsver" \
  1769. "Libs: -L\${libdir} -l${_file}" \
  1770. "Libs.private: ${_pc_vars[${_file}-private]}" \
  1771. "Cflags: -I\${includedir} ${_pc_vars[${_file}-cflags]}" \
  1772. > "${_pc_vars[${_file}-name]}.pc"
  1773. done
  1774. do_install vapoursynth{,-script}.pc lib/pkgconfig/
  1775. do_checkIfExist
  1776. fi
  1777. unset _file _python_lib _python_ver _vsver _pc_vars
  1778. return 0
  1779. }
  1780. if ! { { ! mpv_disabled vapoursynth || enabled vapoursynth || [[ $av1an != n ]]; } && _vapoursynth_install; }; then
  1781. mpv_disable vapoursynth
  1782. do_removeOption --enable-vapoursynth
  1783. fi
  1784. if [[ $av1an != n ]]; then
  1785. local av1an_bindir="bin-video"
  1786. local av1an_ffmpeg_prefix="opt/av1anffmpeg"
  1787. [[ $av1an = shared ]] && av1an_bindir="bin-video/av1an/bin" && av1an_ffmpeg_prefix="bin-video/av1an"
  1788. _check=("$LOCALDESTDIR"/"$av1an_ffmpeg_prefix"/lib/pkgconfig/lib{av{codec,device,filter,format,util},swscale}.pc)
  1789. if flavor=av1an do_vcs "$ffmpegPath"; then
  1790. do_uninstall "$LOCALDESTDIR"/"$av1an_ffmpeg_prefix"
  1791. [[ -f config.mak ]] && log "distclean" make distclean
  1792. local av1an_ffmpeg_opts=("--enable-static" "--disable-shared")
  1793. [[ $av1an = shared ]] && av1an_ffmpeg_opts=("--disable-static" "--enable-shared")
  1794. # compile ffmpeg executable if ffmpeg is disabled so av1an can function
  1795. if [[ $ffmpeg != no ]]; then
  1796. av1an_ffmpeg_opts+=("--disable-programs")
  1797. else
  1798. # enable filters too so they can be used with av1an
  1799. av1an_ffmpeg_opts+=("--disable-ffprobe" "--disable-ffplay" "--enable-filters")
  1800. fi
  1801. create_build_dir av1an
  1802. config_path=.. do_configure "${FFMPEG_BASE_OPTS[@]}" \
  1803. --prefix="$LOCALDESTDIR/$av1an_ffmpeg_prefix" \
  1804. --disable-autodetect --disable-everything \
  1805. --disable-{debug,doc,postproc,network} \
  1806. --enable-{decoders,demuxers,protocols} \
  1807. "${av1an_ffmpeg_opts[@]}"
  1808. do_make && do_makeinstall
  1809. # move static ffmpeg to a reasonable location if ffmpeg is disabled
  1810. [[ $av1an != shared ]] && [[ $ffmpeg = no ]] && [[ ! -f "$LOCALDESTDIR"/bin-video/ffmpeg.exe ]] &&
  1811. mv -f "$LOCALDESTDIR"/{"$av1an_ffmpeg_prefix"/bin,bin-video}/ffmpeg.exe
  1812. files_exist "${_check[@]}" && touch ../"build_successful${bits}_av1an"
  1813. unset av1an_ffmpeg_opts
  1814. fi
  1815. old_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
  1816. PKG_CONFIG_PATH=$LOCALDESTDIR/$av1an_ffmpeg_prefix/lib/pkgconfig:$PKG_CONFIG_PATH
  1817. _check=("$av1an_bindir"/av1an.exe)
  1818. if do_vcs "$SOURCE_REPO_AV1AN"; then
  1819. do_uninstall "${_check[@]}"
  1820. do_pacman_install clang
  1821. PKG_CONFIG="$LOCALDESTDIR/bin/ab-pkg-config-static.bat" \
  1822. VAPOURSYNTH_LIB_DIR="$LOCALDESTDIR/lib" do_rust
  1823. do_install "target/$CARCH-pc-windows-gnu$rust_target_suffix/release/av1an.exe" $av1an_bindir/
  1824. do_checkIfExist
  1825. fi
  1826. PKG_CONFIG_PATH=$old_PKG_CONFIG_PATH
  1827. unset old_PKG_CONFIG_PATH av1an_{bindir,ffmpeg_prefix}
  1828. fi
  1829. if [[ $ffmpeg != no ]] && enabled liblensfun; then
  1830. do_pacman_install glib2
  1831. grep_or_sed liconv "$MINGW_PREFIX/lib/pkgconfig/glib-2.0.pc" 's;-lintl;& -liconv;g'
  1832. _check=(liblensfun.a lensfun.pc lensfun/lensfun.h)
  1833. if do_vcs "$SOURCE_REPO_LENSFUN"; then
  1834. do_patch "https://github.com/m-ab-s/mabs-patches/raw/master/lensfun/0001-CMake-exclude-mingw-w64-from-some-msvc-exclusive-thi.patch" am
  1835. do_patch "https://github.com/m-ab-s/mabs-patches/raw/master/lensfun/0002-CMake-don-t-add-glib2-s-includes-as-SYSTEM-dirs.patch" am
  1836. do_uninstall "bin-video/lensfun" "${_check[@]}"
  1837. CFLAGS+=" -DGLIB_STATIC_COMPILATION" CXXFLAGS+=" -DGLIB_STATIC_COMPILATION" \
  1838. do_cmakeinstall -DBUILD_STATIC=on -DBUILD_{TESTS,LENSTOOL,DOC}=off \
  1839. -DINSTALL_HELPER_SCRIPTS=off -DCMAKE_INSTALL_DATAROOTDIR="$LOCALDESTDIR/bin-video" \
  1840. -DINSTALL_PYTHON_MODULE=OFF
  1841. do_checkIfExist
  1842. fi
  1843. fi
  1844. _check=(bin-video/vvc/{Encoder,Decoder}App.exe)
  1845. if [[ $bits = 64bit && $vvc = y ]] &&
  1846. do_vcs "$SOURCE_REPO_VVC" vvc; then
  1847. do_uninstall bin-video/vvc
  1848. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/VVCSoftware_VTM/0001-BBuildEnc.cmake-Remove-Werror-for-gcc-and-clang.patch" am
  1849. # patch for easier install of apps
  1850. # probably not of upstream's interest because of how experimental the codec is
  1851. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/VVCSoftware_VTM/0002-cmake-allow-installing-apps.patch" am
  1852. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/VVCSoftware_VTM/0003-CMake-add-USE_CCACHE-variable-to-disable-using-found.patch" am
  1853. _notrequired=true
  1854. # install to own dir because the binaries' names are too generic
  1855. do_cmakeinstall -DCMAKE_INSTALL_BINDIR="$LOCALDESTDIR"/bin-video/vvc \
  1856. -DBUILD_STATIC=on -DSET_ENABLE_SPLIT_PARALLELISM=ON -DENABLE_SPLIT_PARALLELISM=OFF \
  1857. -DUSE_CCACHE=OFF
  1858. do_checkIfExist
  1859. unset _notrequired
  1860. fi
  1861. _check=(bin-video/uvg266.exe libuvg266.a uvg266.pc uvg266.h)
  1862. if [[ $bits = 64bit && $uvg266 = y ]] &&
  1863. do_vcs "$SOURCE_REPO_UVG266"; then
  1864. do_uninstall version.h "${_check[@]}"
  1865. do_cmakeinstall video -DBUILD_TESTING=OFF
  1866. do_checkIfExist
  1867. fi
  1868. _check=(bin-video/vvenc{,FF}app.exe
  1869. vvenc/vvenc.h
  1870. libvvenc.{a,pc}
  1871. lib/cmake/vvenc/vvencConfig.cmake)
  1872. if [[ $bits = 64bit && $vvenc = y ]] ||
  1873. { [[ $ffmpeg != no && $bits = 64bit ]] && enabled libvvenc; } &&
  1874. do_vcs "$SOURCE_REPO_LIBVVENC"; then
  1875. do_uninstall include/vvenc lib/cmake/vvenc "${_check[@]}"
  1876. do_cmakeinstall video -DVVENC_ENABLE_LINK_TIME_OPT=OFF -DVVENC_INSTALL_FULLFEATURE_APP=ON
  1877. do_checkIfExist
  1878. else
  1879. pc_exists libvvenc || do_removeOption "--enable-libvvenc"
  1880. fi
  1881. _check=(bin-video/vvdecapp.exe
  1882. vvdec/vvdec.h
  1883. libvvdec.{a,pc}
  1884. lib/cmake/vvdec/vvdecConfig.cmake)
  1885. if [[ $bits = 64bit && $vvdec = y ]] ||
  1886. { [[ $ffmpeg != no && $bits = 64bit ]] && enabled libvvdec; } &&
  1887. do_vcs "$SOURCE_REPO_LIBVVDEC"; then
  1888. do_uninstall include/vvdec lib/cmake/vvdec "${_check[@]}"
  1889. do_cmakeinstall video -DVVDEC_ENABLE_LINK_TIME_OPT=OFF -DVVDEC_INSTALL_VVDECAPP=ON
  1890. do_checkIfExist
  1891. else
  1892. pc_exists libvvdec || do_removeOption "--enable-libvvdec"
  1893. fi
  1894. _check=(bin-video/xeve_app.exe xeve/xeve{,_exports}.h libxeve.a xeve.pc)
  1895. if [[ $ffmpeg != no ]] && enabled libxeve &&
  1896. do_vcs "$SOURCE_REPO_XEVE"; then
  1897. do_uninstall bin-video/libxeve.dll lib/libxeve.dll.a.dyn "${_check[@]}"
  1898. sed -i 's/-Werror //' CMakeLists.txt
  1899. do_cmakeinstall video
  1900. # no way to disable shared lib building in cmake
  1901. mv -f "$LOCALDESTDIR"/lib/xeve/libxeve.a "$LOCALDESTDIR"/lib/libxeve.a
  1902. mv -f "$LOCALDESTDIR"/lib/libxeve.dll.a "$LOCALDESTDIR"/lib/libxeve.dll.a.dyn
  1903. do_checkIfExist
  1904. fi
  1905. _check=(bin-video/xevd_app.exe xevd/xevd{,_exports}.h libxevd.a xevd.pc)
  1906. if [[ $ffmpeg != no ]] && enabled libxevd &&
  1907. do_vcs "$SOURCE_REPO_XEVD"; then
  1908. do_uninstall bin-video/libxevd.dll lib/libxevd.dll.a.dyn "${_check[@]}"
  1909. sed -i 's/-Werror //' CMakeLists.txt
  1910. do_cmakeinstall video
  1911. # no way to disable shared lib building in cmake
  1912. mv -f "$LOCALDESTDIR"/lib/xevd/libxevd.a "$LOCALDESTDIR"/lib/libxevd.a
  1913. mv -f "$LOCALDESTDIR"/lib/libxevd.dll.a "$LOCALDESTDIR"/lib/libxevd.dll.a.dyn
  1914. do_checkIfExist
  1915. fi
  1916. _check=(avisynth/avisynth{,_c}.h
  1917. avisynth/avs/{alignment,arch,capi,config,cpuid,minmax,posix,types,win,version}.h)
  1918. if [[ $ffmpeg != no ]] && enabled avisynth &&
  1919. do_vcs "$SOURCE_REPO_AVISYNTH"; then
  1920. do_uninstall "${_check[@]}"
  1921. do_cmake -DHEADERS_ONLY=ON
  1922. do_ninja VersionGen
  1923. do_ninjainstall
  1924. do_checkIfExist
  1925. fi
  1926. _check=(libvulkan.a vulkan.pc vulkan/vulkan.h d3d{kmthk,ukmdt}.h)
  1927. if { { [[ $ffmpeg != no ]] && enabled_any vulkan libplacebo; } ||
  1928. { [[ $mpv != n ]] && ! mpv_disabled_any vulkan libplacebo; } } &&
  1929. do_vcs "$SOURCE_REPO_VULKANLOADER" vulkan-loader; then
  1930. _wine_mirror=https://raw.githubusercontent.com/wine-mirror/wine/master/include
  1931. _mabs=https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/vulkan-loader
  1932. do_pacman_install uasm
  1933. do_uninstall "${_check[@]}"
  1934. do_patch "$_mabs/0001-pc-remove-CMAKE_CXX_IMPLICIT_LINK_LIBRARIES.patch" am
  1935. do_patch "$_mabs/0002-loader-CMake-related-static-hacks.patch" am
  1936. do_patch "$_mabs/0003-loader-Re-add-private-libs-to-pc-file.patch" am
  1937. do_patch "$_mabs/0004-loader-Static-library-name-related-hacks.patch" am
  1938. grep_and_sed VULKAN_LIB_SUFFIX loader/vulkan.pc.in \
  1939. 's/@VULKAN_LIB_SUFFIX@//'
  1940. create_build_dir
  1941. log dependencies /usr/bin/python3 ../scripts/update_deps.py --no-build
  1942. cd_safe Vulkan-Headers
  1943. do_print_progress "Installing Vulkan-Headers"
  1944. do_uninstall include/vulkan
  1945. # disable module header because clang-scan-deps can't understand `ccache clang++` as the "compiler."
  1946. do_cmakeinstall -DVULKAN_HEADERS_ENABLE_MODULE=OFF
  1947. do_wget -c -r -q "$_wine_mirror/ddk/d3dkmthk.h"
  1948. do_wget -c -r -q "$_wine_mirror/d3dukmdt.h"
  1949. do_install d3d{kmthk,ukmdt}.h include/
  1950. cd_safe "$(get_first_subdir -f)"
  1951. do_print_progress "Building Vulkan-Loader"
  1952. CC="${CC##ccache }" CXX="${CXX##ccache }" \
  1953. CFLAGS+=" -DSTRSAFE_NO_DEPRECATE" \
  1954. do_cmakeinstall -DBUILD_TESTS=OFF \
  1955. -DVULKAN_HEADERS_INSTALL_DIR="$LOCALDESTDIR" \
  1956. -DBUILD_STATIC_LOADER=ON -DUNIX=OFF
  1957. do_checkIfExist
  1958. unset _wine_mirror _mabs
  1959. fi
  1960. if [[ $exitearly = EE5 ]]; then
  1961. do_simple_print -p '\n\t'"${orange}Exit due to env var MABS_EXIT_EARLY set to EE5"
  1962. return
  1963. fi
  1964. _check=(spirv_cross/spirv_cross_c.h spirv-cross.pc libspirv-cross.a)
  1965. if { { [[ $mpv != n ]] && ! mpv_disabled libplacebo; } ||
  1966. { [[ $mpv != n ]] && ! mpv_disabled spirv-cross; } ||
  1967. { [[ $ffmpeg != no ]] && enabled libplacebo; } } &&
  1968. do_vcs "$SOURCE_REPO_SPIRV_CROSS"; then
  1969. do_uninstall include/spirv_cross "${_check[@]}" spirv-cross-c-shared.pc libspirv-cross-c-shared.a
  1970. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/SPIRV-Cross/0001-add-a-basic-Meson-build-system-for-use-as-a-subproje.patch" am
  1971. sed -i 's/0.13.0/0.48.0/' meson.build
  1972. do_mesoninstall
  1973. do_checkIfExist
  1974. fi
  1975. _check=(lib{glslang,OSDependent,SPVRemapper}.a
  1976. libSPIRV{,-Tools{,-opt,-link,-reduce}}.a glslang/SPIRV/GlslangToSpv.h)
  1977. if { { [[ $mpv != n ]] && ! mpv_disabled libplacebo; } ||
  1978. { [[ $ffmpeg != no ]] && enabled_any libplacebo libglslang; } } &&
  1979. do_vcs "$SOURCE_REPO_GLSLANG"; then
  1980. do_pacman_install python
  1981. do_uninstall libHLSL.a "${_check[@]}"
  1982. log dependencies /usr/bin/python ./update_glslang_sources.py
  1983. # Python3_EXECUTABLE set to prevent CMake from finding the newer (but specific to the msys subsystem) python 3.11
  1984. # (current mingw-w64 versions are 3.10)
  1985. do_cmakeinstall -DUNIX=OFF -DPython3_EXECUTABLE="${MINGW_PREFIX}/bin/python.exe"
  1986. do_checkIfExist
  1987. fi
  1988. _check=(shaderc/shaderc.h libshaderc_combined.a)
  1989. if { { [[ $mpv != n ]] && ! mpv_disabled libplacebo; } ||
  1990. { [[ $ffmpeg != no ]] && enabled libplacebo; } } ||
  1991. ! mpv_disabled shaderc &&
  1992. do_vcs "$SOURCE_REPO_SHADERC"; then
  1993. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/shaderc/0001-third_party-set-INSTALL-variables-as-cache.patch" am
  1994. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/shaderc/0002-shaderc_util-add-install.patch" am
  1995. do_uninstall "${_check[@]}" include/shaderc include/libshaderc_util
  1996. grep_and_sed d0e67c58134377f065a509845ca6b7d463f5b487 DEPS 's/d0e67c58134377f065a509845ca6b7d463f5b487/76cc41d26f6902de543773023611e40fbcdde58b/g'
  1997. log dependencies /usr/bin/python ./utils/git-sync-deps
  1998. # fix python indentation errors from non-existant code review
  1999. grep -ZRlP --include="*.py" '\t' third_party/spirv-tools/ | xargs -r -0 -n1 sed -i 's;\t; ;g'
  2000. do_cmakeinstall -GNinja -DSHADERC_SKIP_{TESTS,EXAMPLES}=ON -DSHADERC_ENABLE_WERROR_COMPILE=OFF -DSKIP_{GLSLANG,GOOGLETEST}_INSTALL=ON -DSPIRV_HEADERS_SKIP_{INSTALL,EXAMPLES}=ON
  2001. do_checkIfExist
  2002. unset add_third_party
  2003. fi
  2004. file_installed -s shaderc_static.pc &&
  2005. mv "$(file_installed shaderc_static.pc)" "$(file_installed shaderc.pc)"
  2006. _check=(libplacebo.{a,pc})
  2007. _deps=(lib{vulkan,shaderc_combined}.a spirv-cross.pc shaderc/shaderc.h)
  2008. if { { [[ $mpv != n ]] && ! mpv_disabled libplacebo; } ||
  2009. { [[ $ffmpeg != no ]] && enabled libplacebo; } } &&
  2010. do_vcs "$SOURCE_REPO_LIBPLACEBO"; then
  2011. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/libplacebo/0001-meson-use-shaderc_combined.patch" am
  2012. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/libplacebo/0002-spirv-cross-use-spirv-cross-instead-of-c-shared.patch" am
  2013. do_pacman_install python-{mako,setuptools}
  2014. do_uninstall "${_check[@]}"
  2015. log -q "git.submodule" git submodule update --init --recursive
  2016. do_mesoninstall -Dvulkan-registry="$LOCALDESTDIR/share/vulkan/registry/vk.xml" -Ddemos=false -Dd3d11=enabled
  2017. do_checkIfExist
  2018. fi
  2019. if [[ $exitearly = EE6 ]]; then
  2020. do_simple_print -p '\n\t'"${orange}Exit due to env var MABS_EXIT_EARLY set to EE6"
  2021. return
  2022. fi
  2023. enabled openssl && hide_libressl
  2024. if [[ $ffmpeg != no ]]; then
  2025. enabled libgsm && do_pacman_install gsm
  2026. enabled libsnappy && do_pacman_install snappy
  2027. if enabled libxvid && [[ $standalone = n ]]; then
  2028. do_pacman_install xvidcore
  2029. [[ -f $MINGW_PREFIX/lib/xvidcore.a ]] && mv -f "$MINGW_PREFIX"/lib/{,lib}xvidcore.a
  2030. [[ -f $MINGW_PREFIX/lib/xvidcore.dll.a ]] && mv -f "$MINGW_PREFIX"/lib/xvidcore.dll.a{,.dyn}
  2031. fi
  2032. if enabled libssh; then
  2033. do_pacman_install libssh
  2034. do_addOption --extra-cflags=-DLIBSSH_STATIC "--extra-ldflags=-Wl,--allow-multiple-definition"
  2035. grep_or_sed "Requires.private" "$MINGW_PREFIX"/lib/pkgconfig/libssh.pc \
  2036. "/Libs:/ i\Requires.private: zlib libssl"
  2037. fi
  2038. enabled libtheora && do_pacman_install libtheora
  2039. if enabled libcdio; then
  2040. do_pacman_install libcdio-paranoia
  2041. grep -ZlER -- "-R/mingw\S+" "$MINGW_PREFIX"/lib/pkgconfig/* | xargs -r -0 sed -ri 's;-R/mingw\S+;;g'
  2042. fi
  2043. enabled libcaca && do_addOption --extra-cflags=-DCACA_STATIC && do_pacman_install libcaca
  2044. enabled libmodplug && do_addOption --extra-cflags=-DMODPLUG_STATIC && do_pacman_install libmodplug
  2045. enabled libopenjpeg && do_pacman_install openjpeg2
  2046. if enabled libopenh264; then
  2047. # We use msys2's package for the header and import library so we don't build it, for licensing reasons
  2048. do_pacman_install openh264
  2049. if [[ -f $MINGW_PREFIX/lib/libopenh264.dll.a.dyn ]]; then
  2050. # backup the static library
  2051. mv -f "$MINGW_PREFIX"/lib/libopenh264.a{,.bak}
  2052. # use the import library as a phony static library, as mpv doesn't look for .dll.a
  2053. mv -f "$MINGW_PREFIX"/lib/libopenh264.{dll.a.dyn,a}
  2054. fi
  2055. [[ -f $MINGW_PREFIX/lib/libopenh264.dll.a ]] && mv -f "$MINGW_PREFIX"/lib/libopenh264.{dll.,}a
  2056. _openh264_ver=2.5.0
  2057. _pacman_openh264_ver=$(pacman -Q "${MINGW_PACKAGE_PREFIX}-openh264" | awk '{print $2}')
  2058. if [[ $(vercmp.exe $_openh264_ver "$_pacman_openh264_ver") -ne 0 ]]; then
  2059. do_simple_print "${orange}Openh264 version differs from msys2's, current: $_openh264_ver, msys2: $_pacman_openh264_ver${reset}"
  2060. do_simple_print "${orange}Check if this is the latest suite and update if possible, else open an issue${reset}"
  2061. fi
  2062. if test_newer "$MINGW_PREFIX"/lib/libopenh264.dll.a "$LOCALDESTDIR/bin-video/libopenh264-7.dll" ||
  2063. ! get_dll_version "$LOCALDESTDIR/bin-video/libopenh264-7.dll" | grep -q "$_openh264_ver"; then
  2064. pushd "$LOCALDESTDIR/bin-video" >/dev/null || do_exit_prompt "Did you delete the bin-video folder?"
  2065. if [[ $bits = 64bit ]]; then
  2066. _sha256=1879afe8429fc9b064cfbdeb91a19d9e0594116d06702d8e0c821150d6150972
  2067. else
  2068. _sha256=004c3cf7cd8633067d33acb19e3c945396b011f6ef64545780b061d6eaae540f
  2069. fi
  2070. do_wget -c -r -q -h $_sha256 \
  2071. "http://ciscobinary.openh264.org/openh264-${_openh264_ver}-win${bits%bit}.dll.bz2" \
  2072. libopenh264.dll.bz2
  2073. [[ -f libopenh264.dll.bz2 ]] && bunzip2 -f libopenh264.dll.bz2
  2074. mv -f libopenh264.dll libopenh264-7.dll
  2075. popd >/dev/null || do_exit_prompt "Did you delete the previous folder?"
  2076. fi
  2077. unset _sha256 _openh264_ver
  2078. fi
  2079. enabled chromaprint && do_addOption --extra-cflags=-DCHROMAPRINT_NODLL &&
  2080. { do_pacman_remove fftw; do_pacman_install chromaprint; }
  2081. if enabled libzmq; then
  2082. if [[ $bits = 64bit ]]; then
  2083. do_pacman_install zeromq
  2084. grep_or_sed ws2_32 "$MINGW_PREFIX"/lib/pkgconfig/libzmq.pc \
  2085. 's/-lpthread/& -lws2_32/'
  2086. do_addOption --extra-cflags=-DZMQ_STATIC
  2087. else
  2088. do_removeOption --enable-libzmq
  2089. do_simple_print "${orange}libzmq is not available for 32-bit, disabling${reset}"
  2090. fi
  2091. fi
  2092. enabled frei0r && do_addOption --extra-libs=-lpsapi
  2093. enabled libxml2 && do_addOption --extra-cflags=-DLIBXML_STATIC
  2094. enabled ladspa && do_pacman_install ladspa-sdk
  2095. if enabled vapoursynth && pc_exists "vapoursynth-script >= 42"; then
  2096. _ver=$($PKG_CONFIG --modversion vapoursynth-script)
  2097. do_simple_print "${green}Compiling FFmpeg with Vapoursynth R${_ver}${reset}"
  2098. do_simple_print "${orange}FFmpeg will need vapoursynth.dll and vsscript.dll to run using vapoursynth demuxers"'!'"${reset}"
  2099. unset _ver
  2100. elif enabled vapoursynth; then
  2101. do_removeOption --enable-vapoursynth
  2102. do_simple_print "${red}Update to at least Vapoursynth R42 to use with FFmpeg${reset}"
  2103. fi
  2104. disabled autodetect && enabled iconv && do_addOption --extra-libs=-liconv
  2105. do_hide_all_sharedlibs
  2106. _check=(libavutil.pc)
  2107. disabled_any avfilter ffmpeg || _check+=(bin-video/ffmpeg.exe)
  2108. if [[ $ffmpeg =~ shared ]]; then
  2109. _check+=(libavutil.dll.a)
  2110. else
  2111. _check+=(libavutil.a)
  2112. [[ $ffmpeg =~ both ]] && _check+=(bin-video/ffmpegSHARED)
  2113. fi
  2114. # todo: make this more easily customizable
  2115. [[ $ffmpegUpdate = y ]] && enabled_any lib{aom,tesseract,vmaf,x265,vpx} &&
  2116. _deps=(lib{aom,tesseract,vmaf,x265,vpx}.a)
  2117. if do_vcs "$ffmpegPath"; then
  2118. do_changeFFmpegConfig "$license"
  2119. [[ -f ffmpeg_extra.sh ]] && source ffmpeg_extra.sh
  2120. if enabled libvvdec; then
  2121. do_patch "https://raw.githubusercontent.com/wiki/fraunhoferhhi/vvdec/data/patch/v6-0001-avcodec-add-external-dec-libvvdec-for-H266-VVC.patch" am ||
  2122. do_removeOptions --enable-libvvdec
  2123. fi
  2124. if enabled libsvthevc; then
  2125. do_patch "https://raw.githubusercontent.com/OpenVisualCloud/SVT-HEVC/master/ffmpeg_plugin/master-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch" am ||
  2126. do_removeOption --enable-libsvthevc
  2127. fi
  2128. if enabled libsvtvp9; then
  2129. do_patch "https://raw.githubusercontent.com/OpenVisualCloud/SVT-VP9/master/ffmpeg_plugin/master-0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch" am ||
  2130. do_removeOption --enable-libsvtvp9
  2131. fi
  2132. enabled libsvthevc || do_removeOption FFMPEG_OPTS_SHARED "--enable-libsvthevc"
  2133. enabled libsvtav1 || do_removeOption FFMPEG_OPTS_SHARED "--enable-libsvtav1"
  2134. enabled libsvtvp9 || do_removeOption FFMPEG_OPTS_SHARED "--enable-libsvtvp9"
  2135. if enabled openal &&
  2136. pc_exists "openal"; then
  2137. OPENAL_LIBS=$($PKG_CONFIG --libs openal)
  2138. export OPENAL_LIBS
  2139. do_addOption "--extra-cflags=-DAL_LIBTYPE_STATIC"
  2140. do_addOption FFMPEG_OPTS_SHARED "--extra-cflags=-DAL_LIBTYPE_STATIC"
  2141. for _openal_flag in $($PKG_CONFIG --cflags openal); do
  2142. do_addOption "--extra-cflags=$_openal_flag"
  2143. done
  2144. unset _openal_flag
  2145. fi
  2146. if [[ ${#FFMPEG_OPTS[@]} -gt 35 ]]; then
  2147. # remove redundant -L and -l flags from extralibs
  2148. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/ffmpeg/0001-configure-deduplicate-linking-flags.patch" am
  2149. fi
  2150. _patches=$(git rev-list origin/master.. --count)
  2151. [[ $_patches -gt 0 ]] &&
  2152. do_addOption "--extra-version=g$(git rev-parse --short origin/master)+$_patches"
  2153. _uninstall=(include/libav{codec,device,filter,format,util,resample}
  2154. include/lib{sw{scale,resample},postproc}
  2155. libav{codec,device,filter,format,util,resample}.{dll.a,a,pc}
  2156. lib{sw{scale,resample},postproc}.{dll.a,a,pc}
  2157. "$LOCALDESTDIR"/lib/av{codec,device,filter,format,util}-*.def
  2158. "$LOCALDESTDIR"/lib/{sw{scale,resample},postproc}-*.def
  2159. "$LOCALDESTDIR"/bin-video/av{codec,device,filter,format,util}-*.dll
  2160. "$LOCALDESTDIR"/bin-video/{sw{scale,resample},postproc}-*.dll
  2161. "$LOCALDESTDIR"/bin-video/av{codec,device,filter,format,util}.lib
  2162. "$LOCALDESTDIR"/bin-video/{sw{scale,resample},postproc}.lib
  2163. )
  2164. _check=()
  2165. sedflags="prefix|bindir|extra-version|pkg-config-flags"
  2166. # --build-suffix handling
  2167. opt_exists FFMPEG_OPTS "^--build-suffix=[a-zA-Z0-9-]+$" &&
  2168. build_suffix=$(printf '%s\n' "${FFMPEG_OPTS[@]}" |
  2169. sed -rn '/build-suffix=/{s;.+=(.+);\1;p}') ||
  2170. build_suffix=""
  2171. if [[ $ffmpeg =~ both ]]; then
  2172. _check+=(bin-video/ffmpegSHARED/lib/"libavutil${build_suffix}.dll.a")
  2173. FFMPEG_OPTS_SHARED+=("--prefix=$LOCALDESTDIR/bin-video/ffmpegSHARED")
  2174. elif [[ $ffmpeg =~ shared ]]; then
  2175. _check+=("libavutil${build_suffix}".{dll.a,pc})
  2176. FFMPEG_OPTS_SHARED+=("--prefix=$LOCALDESTDIR"
  2177. "--bindir=$LOCALDESTDIR/bin-video"
  2178. "--shlibdir=$LOCALDESTDIR/bin-video")
  2179. fi
  2180. ! disabled_any debug "debug=gdb" &&
  2181. ffmpeg_cflags=$(sed -r 's/ (-O[1-3]|-mtune=\S+)//g' <<< "$CFLAGS")
  2182. # shared
  2183. if [[ $ffmpeg != static ]] && [[ ! -f build_successful${bits}_shared ]]; then
  2184. do_print_progress "Compiling ${bold}shared${reset} FFmpeg"
  2185. do_uninstall bin-video/ffmpegSHARED "${_uninstall[@]}"
  2186. [[ -f config.mak ]] && log "distclean" make distclean
  2187. create_build_dir shared
  2188. config_path=.. CFLAGS="${ffmpeg_cflags:-$CFLAGS}" \
  2189. LDFLAGS+=" -L$LOCALDESTDIR/lib -L$MINGW_PREFIX/lib" \
  2190. do_configure \
  2191. --disable-static --enable-shared "${FFMPEG_OPTS_SHARED[@]}"
  2192. # cosmetics
  2193. sed -ri "s/ ?--($sedflags)=(\S+[^\" ]|'[^']+')//g" config.h
  2194. do_make && do_makeinstall
  2195. cd_safe ..
  2196. files_exist "${_check[@]}" && touch "build_successful${bits}_shared"
  2197. fi
  2198. # static
  2199. if [[ ! $ffmpeg =~ shared ]] && _check=(libavutil.{a,pc}); then
  2200. do_print_progress "Compiling ${bold}static${reset} FFmpeg"
  2201. [[ -f config.mak ]] && log "distclean" make distclean
  2202. if ! disabled_any programs avcodec avformat; then
  2203. if ! disabled swresample; then
  2204. disabled_any avfilter ffmpeg || _check+=(bin-video/ffmpeg.exe)
  2205. if { disabled autodetect && enabled_any sdl2 ffplay; } ||
  2206. { ! disabled autodetect && ! disabled_any sdl2 ffplay; }; then
  2207. _check+=(bin-video/ffplay.exe)
  2208. fi
  2209. fi
  2210. disabled ffprobe || _check+=(bin-video/ffprobe.exe)
  2211. fi
  2212. do_uninstall bin-video/ff{mpeg,play,probe}.exe{,.debug} "${_uninstall[@]}"
  2213. create_build_dir static
  2214. config_path=.. CFLAGS="${ffmpeg_cflags:-$CFLAGS}" \
  2215. cc=$CC cxx=$CXX LDFLAGS+=" -L$LOCALDESTDIR/lib -L$MINGW_PREFIX/lib" \
  2216. do_configure \
  2217. --bindir="$LOCALDESTDIR/bin-video" "${FFMPEG_OPTS[@]}"
  2218. # cosmetics
  2219. sed -ri "s/ ?--($sedflags)=(\S+[^\" ]|'[^']+')//g" config.h
  2220. do_make && do_makeinstall
  2221. ! disabled_any debug "debug=gdb" &&
  2222. create_debug_link "$LOCALDESTDIR"/bin-video/ff{mpeg,probe,play}.exe
  2223. cd_safe ..
  2224. fi
  2225. do_checkIfExist
  2226. [[ -f $LOCALDESTDIR/bin-video/ffmpeg.exe ]] &&
  2227. create_winpty_exe ffmpeg "$LOCALDESTDIR"/bin-video/
  2228. unset ffmpeg_cflags build_suffix
  2229. fi
  2230. fi
  2231. # static do_vcs just for svn
  2232. check_mplayer_updates() {
  2233. cd_safe "$LOCALBUILDDIR"
  2234. if [[ ! -d mplayer-svn/.svn ]]; then
  2235. rm -rf mplayer-svn
  2236. do_print_progress " Running svn clone for mplayer"
  2237. svn_clone() (
  2238. set -x
  2239. svn --non-interactive checkout -r HEAD svn://svn.mplayerhq.hu/mplayer/trunk mplayer-svn &&
  2240. [[ -d mplayer-svn/.svn ]]
  2241. )
  2242. if svn --non-interactive ls svn://svn.mplayerhq.hu/mplayer/trunk > /dev/null 2>&1 &&
  2243. log -q "svn.clone" svn_clone; then
  2244. touch mplayer-svn/recently_{updated,checked}
  2245. else
  2246. echo "mplayer svn seems to be down"
  2247. echo "Try again later or <Enter> to continue"
  2248. do_prompt "if you're sure nothing depends on it."
  2249. return
  2250. fi
  2251. unset svn_clone
  2252. fi
  2253. cd_safe mplayer-svn
  2254. oldHead=$(svn info --show-item last-changed-revision .)
  2255. log -q "svn.reset" svn revert --recursive .
  2256. if ! [[ -f recently_checked && recently_checked -nt $LOCALBUILDDIR/last_run ]]; then
  2257. do_print_progress " Running svn update for mplayer"
  2258. log -q "svn.update" svn update -r HEAD
  2259. newHead=$(svn info --show-item last-changed-revision .)
  2260. touch recently_checked
  2261. else
  2262. newHead="$oldHead"
  2263. fi
  2264. rm -f custom_updated
  2265. check_custom_patches
  2266. if [[ $oldHead != "$newHead" || -f custom_updated ]]; then
  2267. touch recently_updated
  2268. rm -f ./build_successful{32,64}bit{,_*}
  2269. if [[ $build32$build64$bits == yesyes64bit ]]; then
  2270. new_updates="yes"
  2271. new_updates_packages="$new_updates_packages [mplayer]"
  2272. fi
  2273. printf 'mplayer\n' >> "$LOCALBUILDDIR"/newchangelog
  2274. do_print_status "┌ mplayer svn" "$orange" "Updates found"
  2275. elif [[ -f recently_updated && ! -f build_successful$bits ]]; then
  2276. do_print_status "┌ mplayer svn" "$orange" "Recently updated"
  2277. elif ! files_exist "${_check[@]}"; then
  2278. do_print_status "┌ mplayer svn" "$orange" "Files missing"
  2279. else
  2280. do_print_status "mplayer svn" "$green" "Up-to-date"
  2281. [[ ! -f recompile ]] &&
  2282. return 1
  2283. do_print_status "┌ mplayer svn" "$orange" "Forcing recompile"
  2284. do_print_status prefix "$bold├$reset " "Found recompile flag" "$orange" "Recompiling"
  2285. fi
  2286. return 0
  2287. }
  2288. _check=(bin-video/m{player,encoder}.exe)
  2289. if [[ $mplayer = y ]] && check_mplayer_updates; then
  2290. [[ $license != nonfree || $faac == n ]] && faac_opts=(--disable-faac)
  2291. do_uninstall "${_check[@]}"
  2292. [[ -f config.mak ]] && log "distclean" make distclean
  2293. if [[ ! -d ffmpeg ]] &&
  2294. ! { [[ -d $LOCALBUILDDIR/ffmpeg-git ]] &&
  2295. git clone -q "$LOCALBUILDDIR/ffmpeg-git" ffmpeg; } &&
  2296. ! git clone "$ffmpegPath" ffmpeg; then
  2297. rm -rf ffmpeg
  2298. printf '%s\n' \
  2299. "Failed to get a FFmpeg checkout" \
  2300. "Please try again or put FFmpeg source code copy into ffmpeg/ manually." \
  2301. "Nightly snapshot: http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2" \
  2302. "Either re-run the script or extract above to inside /build/mplayer-svn."
  2303. do_prompt "<Enter> to continue or <Ctrl+c> to exit the script"
  2304. fi
  2305. [[ ! -d ffmpeg ]] && compilation_fail "Finding valid ffmpeg dir"
  2306. [[ -d ffmpeg/.git ]] && {
  2307. git -C ffmpeg fetch -q origin
  2308. git -C ffmpeg checkout -qf --no-track -B master origin/HEAD
  2309. }
  2310. grep_or_sed windows libmpcodecs/ad_spdif.c '/#include "mp_msg.h/ a\#include <windows.h>'
  2311. grep_or_sed gnu11 configure 's/c11/gnu11/g'
  2312. # shellcheck disable=SC2016
  2313. sed -i '/%\$(EXESUF):/{n; s/\$(CC)/\$(CXX)/g};/mencoder$(EXESUF)/{n; s/\$(CC)/\$(CXX)/g}' Makefile
  2314. _notrequired=true
  2315. do_configure --bindir="$LOCALDESTDIR"/bin-video \
  2316. --extra-cflags='-fpermissive -DPTW32_STATIC_LIB -O3 -DMODPLUG_STATIC -Wno-int-conversion' \
  2317. --extra-libs="-llzma -liconv -lws2_32 -lpthread -lwinpthread -lpng -lwinmm $($PKG_CONFIG --libs libilbc) \
  2318. $(enabled vapoursynth && $PKG_CONFIG --libs vapoursynth-script)" \
  2319. --extra-ldflags='-Wl,--allow-multiple-definition' --enable-{static,runtime-cpudetection} \
  2320. --disable-{gif,cddb} "${faac_opts[@]}" --with-dvdread-config="$PKG_CONFIG dvdread" \
  2321. --with-freetype-config="$PKG_CONFIG freetype2" --with-dvdnav-config="$PKG_CONFIG dvdnav" &&
  2322. do_makeinstall CXX="$CXX" && do_checkIfExist
  2323. unset _notrequired faac_opts
  2324. fi
  2325. if [[ $mpv != n ]] && pc_exists libavcodec libavformat libswscale libavfilter; then
  2326. if ! mpv_disabled lua && opt_exists MPV_OPTS "--lua=5.1"; then
  2327. do_pacman_install lua51
  2328. elif ! mpv_disabled lua &&
  2329. _check=(bin-global/luajit.exe libluajit-5.1.a luajit.pc luajit-2.1/lua.h) &&
  2330. do_vcs "$SOURCE_REPO_LUAJIT" luajit; then
  2331. do_pacman_remove luajit lua51
  2332. do_uninstall include/luajit-2.1 lib/lua "${_check[@]}"
  2333. [[ -f src/luajit.exe ]] && log "clean" make clean
  2334. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/LuaJIT/0001-Add-win32-UTF-8-filesystem-functions.patch" am
  2335. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/LuaJIT/0002-win32-UTF-8-Remove-va-arg-and-.-and-unused-functions.patch" am
  2336. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/LuaJIT/0003-make-don-t-override-user-provided-CC.patch" am
  2337. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/LuaJIT/0004-pkgconfig-fix-pkg-config-file-for-mingw64.patch" am
  2338. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/LuaJIT/0005-revert-rolling-release-parts-in-Makefile.patch" am
  2339. sed -i "s|export PREFIX= /usr/local|export PREFIX=${LOCALDESTDIR}|g" Makefile
  2340. sed -i "s|^prefix=.*|prefix=$LOCALDESTDIR|" etc/luajit.pc
  2341. _luajit_args=("PREFIX=$LOCALDESTDIR" "INSTALL_BIN=$LOCALDESTDIR/bin-global" "INSTALL_TNAME=luajit.exe")
  2342. do_make amalg HOST_CC="$CC" BUILDMODE=static \
  2343. CFLAGS='-D_WIN32_WINNT=0x0602 -DUNICODE' \
  2344. XCFLAGS="-DLUAJIT_ENABLE_LUA52COMPAT$([[ $bits = 64bit ]] && echo " -DLUAJIT_ENABLE_GC64")" \
  2345. "${_luajit_args[@]}"
  2346. do_makeinstall "${_luajit_args[@]}"
  2347. do_checkIfExist
  2348. unset _luajit_args
  2349. fi
  2350. do_pacman_remove uchardet-git
  2351. ! mpv_disabled uchardet && do_pacman_install uchardet
  2352. ! mpv_disabled libarchive && do_pacman_install libarchive
  2353. ! mpv_disabled lcms2 && do_pacman_install lcms2
  2354. do_pacman_remove angleproject-git
  2355. _check=(EGL/egl.h)
  2356. if mpv_enabled egl-angle && do_vcs "$SOURCE_REPO_ANGLE"; then
  2357. do_simple_print "${orange}mpv will need libGLESv2.dll and libEGL.dll to use gpu-context=angle"'!'
  2358. do_simple_print "You can find these in your browser's installation directory, usually."
  2359. do_uninstall include/{EGL,GLES{2,3},KHR,platform} angle_gl.h \
  2360. lib{GLESv2,EGL}.a "${_check[@]}"
  2361. cp -rf include/{EGL,KHR} "$LOCALDESTDIR/include/"
  2362. do_checkIfExist
  2363. elif ! mpv_disabled egl-angle && ! files_exist "${_check[@]}"; then
  2364. mpv_disable egl-angle
  2365. fi
  2366. if ! mpv_disabled vapoursynth && pc_exists "vapoursynth-script >= 24"; then
  2367. _ver=$($PKG_CONFIG --modversion vapoursynth-script)
  2368. do_simple_print "${green}Compiling mpv with Vapoursynth R${_ver}${reset}"
  2369. do_simple_print "${orange}mpv will need vapoursynth.dll and vsscript.dll to use vapoursynth filter"'!'"${reset}"
  2370. unset _ver
  2371. elif ! mpv_disabled vapoursynth; then
  2372. mpv_disable vapoursynth
  2373. do_simple_print "${red}Update to at least Vapoursynth R24 to use with mpv${reset}"
  2374. fi
  2375. _check=(mujs.{h,pc} libmujs.a)
  2376. if ! mpv_disabled javascript &&
  2377. do_vcs "$SOURCE_REPO_MUJS"; then
  2378. do_uninstall bin-global/mujs.exe "${_check[@]}"
  2379. log clean env -i PATH="$PATH" "$(command -v make)" clean
  2380. mujs_targets=(build/release/{mujs.pc,libmujs.a})
  2381. if [[ $standalone != n ]]; then
  2382. mujs_targets+=(build/release/mujs)
  2383. _check+=(bin-global/mujs.exe)
  2384. sed -i "s;-lreadline;$($PKG_CONFIG --libs readline);g" Makefile
  2385. fi
  2386. extra_script pre make
  2387. TEMP="${TEMP:-/tmp}" CPATH="${CPATH:-}" log "make" "$(command -v make)" \
  2388. "${mujs_targets[@]}" prefix="$LOCALDESTDIR" bindir="$LOCALDESTDIR/bin-global"
  2389. extra_script post make
  2390. extra_script pre install
  2391. [[ $standalone != n ]] && do_install build/release/mujs "$LOCALDESTDIR/bin-global"
  2392. do_install build/release/mujs.pc lib/pkgconfig/
  2393. do_install build/release/libmujs.a lib/
  2394. do_install mujs.h include/
  2395. extra_script post install
  2396. grep_or_sed "Requires.private:" "$LOCALDESTDIR/lib/pkgconfig/mujs.pc" \
  2397. 's;Version:.*;&\nRequires.private: readline;'
  2398. unset mujs_targets
  2399. do_checkIfExist
  2400. fi
  2401. _check=()
  2402. ! mpv_disabled cplayer && _check+=(bin-video/mpv.{exe,com})
  2403. mpv_enabled libmpv-shared && _check+=(bin-video/mpv-2.dll)
  2404. mpv_enabled libmpv-static && _check+=(libmpv.a)
  2405. _deps=(lib{ass,avcodec,vapoursynth,shaderc_combined,spirv-cross,placebo}.a "$MINGW_PREFIX"/lib/libuchardet.a)
  2406. if do_vcs "$SOURCE_REPO_MPV"; then
  2407. do_pacman_install -m python-setuptools
  2408. do_patch "https://github.com/mpv-player/mpv/commit/78447c4b91634aa91dcace1cc6a9805fb93b9252.patch" am
  2409. do_patch "https://github.com/mpv-player/mpv/commit/414ddbd628724df3afc1e15f5e415dbb2c76a0b5.patch" am
  2410. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/mpv/0001-ao_wasapi_utils-include-mmreg.h-for-WAVE_FORMAT.patch" am
  2411. hide_conflicting_libs
  2412. create_ab_pkgconfig
  2413. log bootstrap /usr/bin/python bootstrap.py
  2414. if [[ -d build ]]; then
  2415. WAF_NO_PREFORK=1 /usr/bin/python waf distclean >/dev/null 2>&1
  2416. do_uninstall bin-video/mpv{.exe,-2.dll}.debug "${_check[@]}"
  2417. fi
  2418. mpv_ldflags=("-L$LOCALDESTDIR/lib" "-L$MINGW_PREFIX/lib")
  2419. if [[ $bits = 64bit ]]; then
  2420. mpv_ldflags+=("-Wl,--image-base,0x140000000,--high-entropy-va")
  2421. if enabled libnpp && [[ -n "$CUDA_PATH" ]]; then
  2422. mpv_cflags=("-I$(cygpath -sm "$CUDA_PATH")/include")
  2423. mpv_ldflags+=("-L$(cygpath -sm "$CUDA_PATH")/lib/x64")
  2424. fi
  2425. fi
  2426. enabled libvidstab && {
  2427. mapfile -d ' ' -t -O "${#mpv_cflags[@]}" mpv_cflags < <($PKG_CONFIG --libs vidstab)
  2428. mapfile -d ' ' -t -O "${#mpv_ldflags[@]}" mpv_ldflags < <($PKG_CONFIG --libs vidstab)
  2429. }
  2430. enabled_any libssh libxavs2 && mpv_ldflags+=("-Wl,--allow-multiple-definition")
  2431. if ! mpv_disabled manpage-build || mpv_enabled html-build; then
  2432. do_pacman_install python-docutils
  2433. fi
  2434. # do_pacman_remove python3-rst2pdf
  2435. # mpv_enabled pdf-build && do_pacman_install python2-rst2pdf
  2436. # rst2pdf is broken
  2437. mpv_disable pdf-build
  2438. [[ -f mpv_extra.sh ]] && source mpv_extra.sh
  2439. # The mruby branch cannot (currently) be built with Meson, and hasn't seen
  2440. # any activity in over 5 years; for now it's statically disabled.
  2441. # https://github.com/mpv-player/mpv/issues/11078
  2442. if mpv_enabled mruby; then
  2443. do_removeOption MPV_OPTS "--enable-mruby";
  2444. do_simple_print "${orange}mruby in mpv is no longer supported!${reset}"
  2445. fi
  2446. if files_exist libavutil.a; then
  2447. MPV_OPTS+=(--enable-static-build)
  2448. else
  2449. # force pkg-config lookup to look for static requirements
  2450. export PKGCONF_STATIC=yes
  2451. # hacky way of ignoring ffmpeg libs own shared dependencies
  2452. for _avpc in avcodec avdevice avfilter avformat avutil swresample swscale; do
  2453. if [[ -f $LOCALDESTDIR/lib/pkgconfig/lib$_avpc.pc ]]; then
  2454. sed -i 's;^Requires.private;# &;g' "$LOCALDESTDIR/lib/pkgconfig/lib${_avpc}.pc"
  2455. fi
  2456. done
  2457. fi
  2458. if [[ $CC == *clang* ]]; then
  2459. mpv_cflags+=("-Wno-incompatible-function-pointer-types")
  2460. mpv_ldflags+=("-lc++")
  2461. fi
  2462. extra_script pre configure
  2463. # -Wno-incompatible-pointer-types there until we can move to a newer version of mpv and fix it properly.
  2464. CFLAGS+=" ${mpv_cflags[*]} -Wno-int-conversion -Wno-incompatible-pointer-types" LDFLAGS+=" ${mpv_ldflags[*]}" \
  2465. RST2MAN="${MINGW_PREFIX}/bin/rst2man" \
  2466. RST2HTML="${MINGW_PREFIX}/bin/rst2html" \
  2467. RST2PDF="${MINGW_PREFIX}/bin/rst2pdf2" \
  2468. PKG_CONFIG="$LOCALDESTDIR/bin/ab-pkg-config" \
  2469. WAF_NO_PREFORK=1 \
  2470. log configure /usr/bin/python waf configure \
  2471. "--prefix=$LOCALDESTDIR" "--bindir=$LOCALDESTDIR/bin-video" \
  2472. "${MPV_OPTS[@]}"
  2473. extra_script post configure
  2474. replace="LIBPATH_lib\1 = ['${LOCALDESTDIR}/lib','${MINGW_PREFIX}/lib']"
  2475. sed -r -i "s:LIBPATH_lib(ass|av(|device|filter)) = .*:$replace:g" ./build/c4che/_cache.py
  2476. extra_script pre build
  2477. WAF_NO_PREFORK=1 \
  2478. log build /usr/bin/python waf -j "${cpuCount:-1}"
  2479. extra_script post build
  2480. extra_script pre install
  2481. WAF_NO_PREFORK=1 \
  2482. log install /usr/bin/python waf -j1 install ||
  2483. log install /usr/bin/python waf -j1 install
  2484. extra_script post install
  2485. if ! files_exist libavutil.a; then
  2486. # revert hack
  2487. for _avpc in avcodec avdevice avfilter avformat avutil swresample swscale; do
  2488. if [[ -f $LOCALDESTDIR/lib/pkgconfig/lib$_avpc.pc ]]; then
  2489. sed -ri 's;#.*(Requires.private);\1;g' "$LOCALDESTDIR/lib/pkgconfig/lib${_avpc}.pc"
  2490. fi
  2491. done
  2492. fi
  2493. unset mpv_ldflags replace PKGCONF_STATIC
  2494. hide_conflicting_libs -R
  2495. files_exist share/man/man1/mpv.1 && dos2unix -q "$LOCALDESTDIR"/share/man/man1/mpv.1
  2496. ! mpv_disabled debug-build &&
  2497. create_debug_link "$LOCALDESTDIR"/bin-video/mpv{.exe,-2.dll}
  2498. create_winpty_exe mpv "$LOCALDESTDIR"/bin-video/ "export _started_from_console=yes"
  2499. do_checkIfExist
  2500. fi
  2501. fi
  2502. if [[ $bmx = y ]]; then
  2503. _check=(bin-global/uriparse.exe liburiparser.a liburiparser.pc uriparser/Uri.h)
  2504. do_pacman_remove uriparser
  2505. if do_vcs "$SOURCE_REPO_URIPARSER"; then
  2506. do_uninstall include/uriparser "${_check[@]}"
  2507. do_cmakeinstall global -DURIPARSER_BUILD_{DOCS,TESTS}=OFF
  2508. do_checkIfExist
  2509. fi
  2510. # libMXF and libMXF++ were moved into bmx.
  2511. _check=(bin-video/{bmxtranswrap,{h264,mov,vc2}dump,mxf2raw,raw2bmx}.exe)
  2512. _deps=(liburiparser.a)
  2513. if do_vcs "$SOURCE_REPO_LIBBMX"; then
  2514. (
  2515. pushd deps/libMXF >/dev/null
  2516. do_patch "https://github.com/bbc/libMXF/commit/0a9d2129f2a883d600369b031e1ee29dc808a193.patch" am
  2517. popd >/dev/null
  2518. ) || do_exit_prompt "Did you delete the libMXF folder?"
  2519. do_uninstall libbmx-0.1.{{,l}a,pc} bin-video/bmxparse.exe \
  2520. include/bmx-0.1 "${_check[@]}"
  2521. do_cmakeinstall video -DUNIX=OFF -DBMX_BUILD_TESTING=OFF -DBMX_BUILD_WITH_LIBCURL=OFF -DLIBMXF_BUILD_TOOLS=OFF -DLIBMXF_BUILD_MXFDUMP=OFF
  2522. do_checkIfExist
  2523. fi
  2524. fi
  2525. enabled openssl && hide_libressl -R
  2526. if [[ $cyanrip = y ]]; then
  2527. do_pacman_install libcdio-paranoia jansson
  2528. sed -ri 's;-R[^ ]*;;g' "$MINGW_PREFIX/lib/pkgconfig/libcdio.pc"
  2529. _check=(neon/ne_utils.h libneon.a neon.pc)
  2530. if do_vcs "$SOURCE_REPO_NEON"; then
  2531. do_patch "https://github.com/notroj/neon/pull/69.patch" am
  2532. do_uninstall include/neon "${_check[@]}"
  2533. do_autogen
  2534. do_separate_confmakeinstall --disable-{nls,debug,webdav}
  2535. do_checkIfExist
  2536. fi
  2537. _deps=(libneon.a libxml2.a)
  2538. _check=(musicbrainz5/mb5_c.h libmusicbrainz5{,cc}.{a,pc})
  2539. if do_vcs "$SOURCE_REPO_LIBMUSICBRAINZ"; then
  2540. do_patch "https://github.com/metabrainz/libmusicbrainz/compare/master...wiiaboo:libmusicbrainz:master.patch" am
  2541. do_uninstall "${_check[@]}" include/musicbrainz5
  2542. CXXFLAGS+=" $($PKG_CONFIG --cflags libxml-2.0)" \
  2543. LDFLAGS+=" $($PKG_CONFIG --libs libxml-2.0)" \
  2544. do_cmakeinstall
  2545. do_checkIfExist
  2546. fi
  2547. _deps=(libmusicbrainz5.a libcurl.a)
  2548. _check=(bin-audio/cyanrip.exe)
  2549. if do_vcs "$SOURCE_REPO_CYANRIP"; then
  2550. old_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
  2551. _check=("$LOCALDESTDIR"/opt/cyanffmpeg/lib/pkgconfig/libav{codec,format}.pc)
  2552. if flavor=cyan do_vcs "$ffmpegPath"; then
  2553. do_uninstall "$LOCALDESTDIR"/opt/cyanffmpeg
  2554. [[ -f config.mak ]] && log "distclean" make distclean
  2555. mapfile -t cyan_ffmpeg_opts < <(
  2556. enabled libmp3lame &&
  2557. printf '%s\n' "--enable-libmp3lame" "--enable-encoder=libmp3lame"
  2558. if enabled libvorbis; then
  2559. printf '%s\n' "--enable-libvorbis" "--enable-encoder=libvorbis"
  2560. else
  2561. echo "--enable-encoder=vorbis"
  2562. fi
  2563. if enabled libopus; then
  2564. printf '%s\n' "--enable-libopus" "--enable-encoder=libopus"
  2565. else
  2566. echo "--enable-encoder=opus"
  2567. fi
  2568. )
  2569. create_build_dir cyan
  2570. config_path=.. do_configure "${FFMPEG_BASE_OPTS[@]}" \
  2571. --prefix="$LOCALDESTDIR/opt/cyanffmpeg" \
  2572. --disable-{programs,devices,filters,decoders,hwaccels,encoders,muxers} \
  2573. --disable-{debug,protocols,demuxers,parsers,doc,swscale,postproc,network} \
  2574. --disable-{avdevice,autodetect} \
  2575. --disable-bsfs --enable-protocol=file,data \
  2576. --enable-encoder=flac,tta,aac,wavpack,alac,pcm_s16le,pcm_s32le \
  2577. --enable-muxer=flac,tta,ipod,wv,mp3,opus,ogg,wav,pcm_s16le,pcm_s32le,image2,singlejpeg \
  2578. --enable-parser=png,mjpeg --enable-decoder=mjpeg,png \
  2579. --enable-demuxer=image2,singlejpeg \
  2580. --enable-{bzlib,zlib,lzma,iconv} \
  2581. --enable-filter=hdcd \
  2582. "${cyan_ffmpeg_opts[@]}"
  2583. do_makeinstall
  2584. files_exist "${_check[@]}" && touch ../"build_successful${bits}_cyan"
  2585. fi
  2586. unset cyan_ffmpeg_opts
  2587. PKG_CONFIG_PATH=$LOCALDESTDIR/opt/cyanffmpeg/lib/pkgconfig:$PKG_CONFIG_PATH
  2588. cd_safe "$LOCALBUILDDIR"/cyanrip-git
  2589. _check=(bin-audio/cyanrip.exe)
  2590. _extra_cflags=("$(cygpath -m "$LOCALDESTDIR/opt/cyanffmpeg/include")"
  2591. "$(cygpath -m "$LOCALDESTDIR/include")")
  2592. _extra_ldflags=("$(cygpath -m "$LOCALDESTDIR/opt/cyanffmpeg/lib")"
  2593. "$(cygpath -m "$LOCALDESTDIR/lib")")
  2594. hide_conflicting_libs "$LOCALDESTDIR/opt/cyanffmpeg"
  2595. CFLAGS+=" -DLIBXML_STATIC $(printf ' -I%s' "${_extra_cflags[@]}")" \
  2596. LDFLAGS+="$(printf ' -L%s' "${_extra_ldflags[@]}")" \
  2597. do_mesoninstall audio
  2598. hide_conflicting_libs -R "$LOCALDESTDIR/opt/cyanffmpeg"
  2599. do_checkIfExist
  2600. PKG_CONFIG_PATH=$old_PKG_CONFIG_PATH
  2601. unset old_PKG_CONFIG_PATH _extra_ldflags _extra_cflags
  2602. fi
  2603. fi
  2604. if [[ $vlc == y ]]; then
  2605. do_pacman_install lib{cddb,nfs,shout,samplerate,microdns,secret} \
  2606. a52dec taglib gtk3 lua perl
  2607. # Remove useless shell scripts file that causes errors when stdout is not a tty.
  2608. find "$MINGW_PREFIX/bin/" -name "luac" -delete
  2609. _check=("$DXSDK_DIR/fxc2.exe" "$DXSDK_DIR/d3dcompiler_47.dll")
  2610. if do_vcs "https://github.com/mozilla/fxc2.git"; then
  2611. do_uninstall "${_check[@]}"
  2612. do_patch "https://code.videolan.org/videolan/vlc/-/raw/master/contrib/src/fxc2/0001-make-Vn-argument-as-optional-and-provide-default-var.patch" am
  2613. do_patch "https://code.videolan.org/videolan/vlc/-/raw/master/contrib/src/fxc2/0002-accept-windows-style-flags-and-splitted-argument-val.patch" am
  2614. do_patch "https://code.videolan.org/videolan/vlc/-/raw/master/contrib/src/fxc2/0004-Revert-Fix-narrowing-conversion-from-int-to-BYTE.patch" am
  2615. $CXX $CFLAGS -static -static-libgcc -static-libstdc++ -o "$DXSDK_DIR/fxc2.exe" fxc2.cpp -ld3dcompiler $LDFLAGS
  2616. case $bits in
  2617. 32*) cp -f "dll/d3dcompiler_47_32.dll" "$DXSDK_DIR/d3dcompiler_47.dll" ;;
  2618. *) cp -f "dll/d3dcompiler_47.dll" "$DXSDK_DIR/d3dcompiler_47.dll" ;;
  2619. esac
  2620. do_checkIfExist
  2621. fi
  2622. # Taken from https://code.videolan.org/videolan/vlc/blob/master/contrib/src/qt/AddStaticLink.sh
  2623. _add_static_link() {
  2624. local PRL_SOURCE=$LOCALDESTDIR/$2/lib$3.prl LIBS
  2625. [[ -f $PRL_SOURCE ]] || PRL_SOURCE=$LOCALDESTDIR/$2/$3.prl
  2626. [[ ! -f $PRL_SOURCE ]] && return 1
  2627. LIBS=$(sed -e "
  2628. /QMAKE_PRL_LIBS =/ {
  2629. s@QMAKE_PRL_LIBS =@@
  2630. s@$LOCALDESTDIR/lib@\${libdir}@g
  2631. s@\$\$\[QT_INSTALL_LIBS\]@\${libdir}@g
  2632. p
  2633. }
  2634. d" "$PRL_SOURCE" | grep -v QMAKE_PRL_LIBS_FOR_CMAKE)
  2635. sed -i.bak "
  2636. s# -l$1# -l$3 -l$1#
  2637. s#Libs.private:.*#& $LIBS -L\${prefix}/$2#
  2638. " "$LOCALDESTDIR/lib/pkgconfig/$1.pc"
  2639. }
  2640. _qt_version=5.15 # Version that vlc uses
  2641. # $PKG_CONFIG --exists Qt5{Core,Widgets,Gui,Quick{,Widgets,Controls2},Svg}
  2642. # Qt compilation takes ages.
  2643. export QMAKE_CXX=$CXX QMAKE_CC=$CC
  2644. export MSYS2_ARG_CONV_EXCL="--foreign-types="
  2645. _check=(bin/qmake.exe Qt5Core.pc Qt5Gui.pc Qt5Widgets.pc)
  2646. if do_vcs "https://github.com/qt/qtbase.git#branch=${_qt_version:=5.15}"; then
  2647. do_uninstall include/QtCore share/mkspecs "${_check[@]}"
  2648. # Enable ccache on !unix and use cygpath to fix certain issues
  2649. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/qtbase/0001-qtbase-mabs.patch" am
  2650. do_patch "https://code.videolan.org/videolan/vlc/-/raw/master/contrib/src/qt/0003-allow-cross-compilation-of-angle-with-wine.patch" am
  2651. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/qtbase/0003-Remove-wine-prefix-before-fxc2.patch" am
  2652. do_patch "https://code.videolan.org/videolan/vlc/-/raw/master/contrib/src/qt/0006-ANGLE-don-t-use-msvc-intrinsics-when-crosscompiling-.patch" am
  2653. do_patch "https://code.videolan.org/videolan/vlc/-/raw/master/contrib/src/qt/0009-Add-KHRONOS_STATIC-to-allow-static-linking-on-Windows.patch" am
  2654. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/qtbase/0006-qt_module.prf-don-t-create-libtool-if-not-unix.patch" am
  2655. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/qtbase/0007-qmake-Patch-win32-g-for-static-builds.patch" am
  2656. cp -f src/3rdparty/angle/src/libANGLE/{,libANGLE}Debug.cpp
  2657. grep_and_sed "src/libANGLE/Debug.cpp" src/angle/src/common/gles_common.pri \
  2658. "s#src/libANGLE/Debug.cpp#src/libANGLE/libANGLEDebug.cpp#g"
  2659. QT5Base_config=(
  2660. -prefix "$LOCALDESTDIR"
  2661. -datadir "$LOCALDESTDIR"
  2662. -archdatadir "$LOCALDESTDIR"
  2663. -opensource
  2664. -confirm-license
  2665. -release
  2666. -static
  2667. -platform "$(
  2668. case $CC in
  2669. *clang) echo win32-clang-g++ ;;
  2670. *) echo win32-g++ ;;
  2671. esac
  2672. )"
  2673. -make-tool make
  2674. -qt-{libjpeg,freetype,zlib}
  2675. -angle
  2676. -no-{shared,fontconfig,pkg-config,sql-sqlite,gif,openssl,dbus,vulkan,sql-odbc,pch,compile-examples,glib,direct2d,feature-testlib}
  2677. -skip qtsql
  2678. -nomake examples
  2679. -nomake tests
  2680. )
  2681. if [[ $strip == y ]]; then
  2682. QT5Base_config+=(-strip)
  2683. fi
  2684. if [[ $ccache == y ]]; then
  2685. QT5Base_config+=(-ccache)
  2686. fi
  2687. # can't use regular do_configure since their configure doesn't follow
  2688. # standard and uses single dash args
  2689. log "configure" ./configure "${QT5Base_config[@]}"
  2690. do_make
  2691. do_makeinstall
  2692. _add_static_link Qt5Gui plugins/imageformats qjpeg
  2693. grep_or_sed "QtGui/$(qmake -query QT_VERSION)/QtGui" "$LOCALDESTDIR/lib/pkgconfig/Qt5Gui.pc" \
  2694. "s;Cflags:.*;& -I\${includedir}/QtGui/$(qmake -query QT_VERSION)/QtGui;"
  2695. _add_static_link Qt5Gui plugins/platforms qwindows
  2696. _add_static_link Qt5Widgets plugins/styles qwindowsvistastyle
  2697. cat >> "$LOCALDESTDIR/mkspecs/win32-g++/qmake.conf" <<'EOF'
  2698. CONFIG += static
  2699. EOF
  2700. do_checkIfExist
  2701. fi
  2702. _deps=(Qt5Core.pc)
  2703. _check=(Qt5Quick.pc Qt5Qml.pc)
  2704. if do_vcs "https://github.com/qt/qtdeclarative.git#branch=$_qt_version"; then
  2705. do_uninstall "${_check[@]}"
  2706. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/qtdeclarative/0001-features-hlsl_bytecode_header.prf-Use-DXSDK_DIR-for-.patch" am
  2707. git cherry-pick 0b9fcb829313d0eaf2b496bf3ad44e5628fa43b2 > /dev/null 2>&1 ||
  2708. git cherry-pick --abort
  2709. do_qmake
  2710. do_makeinstall
  2711. _add_static_link Qt5Quick qml/QtQuick.2 qtquick2plugin
  2712. _add_static_link Qt5Quick qml/QtQuick/Layouts qquicklayoutsplugin
  2713. _add_static_link Qt5Quick qml/QtQuick/Window.2 windowplugin
  2714. _add_static_link Qt5Qml qml/QtQml/Models.2 modelsplugin
  2715. do_checkIfExist
  2716. fi
  2717. _deps=(Qt5Core.pc)
  2718. _check=(Qt5Svg.pc)
  2719. if do_vcs "https://github.com/qt/qtsvg.git#branch=$_qt_version"; then
  2720. do_uninstall "${_check[@]}"
  2721. do_qmake
  2722. do_makeinstall
  2723. _add_static_link Qt5Svg plugins/iconengines qsvgicon
  2724. _add_static_link Qt5Svg plugins/imageformats qsvg
  2725. do_checkIfExist
  2726. fi
  2727. _deps=(Qt5Core.pc Qt5Quick.pc Qt5Qml.pc)
  2728. _check=("$LOCALDESTDIR/qml/QtGraphicalEffects/libqtgraphicaleffectsplugin.a")
  2729. if do_vcs "https://github.com/qt/qtgraphicaleffects.git#branch=$_qt_version"; then
  2730. do_uninstall "${_check[@]}"
  2731. do_qmake
  2732. do_makeinstall
  2733. _add_static_link Qt5QuickWidgets qml/QtGraphicalEffects qtgraphicaleffectsplugin
  2734. _add_static_link Qt5QuickWidgets qml/QtGraphicalEffects/private qtgraphicaleffectsprivate
  2735. do_checkIfExist
  2736. fi
  2737. _deps=(Qt5Core.pc Qt5Quick.pc Qt5Qml.pc)
  2738. _check=(Qt5QuickControls2.pc)
  2739. if do_vcs "https://github.com/qt/qtquickcontrols2.git#branch=$_qt_version"; then
  2740. do_uninstall "${_check[@]}"
  2741. do_qmake
  2742. do_makeinstall
  2743. _add_static_link Qt5QuickControls2 qml/QtQuick/Controls.2 qtquickcontrols2plugin
  2744. _add_static_link Qt5QuickControls2 qml/QtQuick/Templates.2 qtquicktemplates2plugin
  2745. do_checkIfExist
  2746. fi
  2747. _check=(libspatialaudio.a spatialaudio/Ambisonics.h spatialaudio.pc)
  2748. if do_vcs "https://github.com/videolabs/libspatialaudio.git"; then
  2749. do_uninstall include/spatialaudio "${_check[@]}"
  2750. do_cmakeinstall
  2751. do_checkIfExist
  2752. fi
  2753. _check=(libshout.{,l}a shout.pc shout/shout.h)
  2754. if do_vcs "https://gitlab.xiph.org/xiph/icecast-libshout.git" libshout; then
  2755. do_uninstall "${_check[@]}"
  2756. log -q "git.submodule" git submodule update --init
  2757. do_autoreconf
  2758. CFLAGS+=" -include ws2tcpip.h" do_separate_confmakeinstall --disable-examples LIBS="$($PKG_CONFIG --libs openssl)"
  2759. do_checkIfExist
  2760. fi
  2761. _check=(bin/protoc.exe libprotobuf-lite.{,l}a libprotobuf.{,l}a protobuf{,-lite}.pc)
  2762. if do_vcs "https://github.com/protocolbuffers/protobuf.git"; then
  2763. do_uninstall include/google/protobuf "${_check[@]}"
  2764. do_autogen
  2765. do_separate_confmakeinstall
  2766. do_checkIfExist
  2767. fi
  2768. _check=(pixman-1.pc libpixman-1.a pixman-1/pixman.h)
  2769. if do_vcs "https://gitlab.freedesktop.org/pixman/pixman.git"; then
  2770. do_uninstall include/pixman-1 "${_check[@]}"
  2771. do_patch "https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/pixman/0001-pixman-pixman-mmx-fix-redefinition-of-_mm_mulhi_pu16.patch" am
  2772. NOCONFIGURE=y do_autogen
  2773. CFLAGS="-msse2 -mfpmath=sse -mstackrealign $CFLAGS" \
  2774. do_separate_confmakeinstall
  2775. do_checkIfExist
  2776. fi
  2777. _check=(libmedialibrary.a medialibrary.pc medialibrary/IAlbum.h)
  2778. if do_vcs "https://code.videolan.org/videolan/medialibrary.git"; then
  2779. do_uninstall include/medialibrary "${_check[@]}"
  2780. do_mesoninstall -Dtests=disabled -Dlibvlc=disabled
  2781. do_checkIfExist
  2782. fi
  2783. _check=(libthai.pc libthai.{,l}a thai/thailib.h)
  2784. if do_vcs "https://github.com/tlwg/libthai.git"; then
  2785. do_uninstall include/thai "${_check[@]}"
  2786. do_autogen
  2787. do_separate_confmakeinstall
  2788. do_checkIfExist
  2789. fi
  2790. _check=(libebml.a ebml/ebml_export.h libebml.pc lib/cmake/EBML/EBMLTargets.cmake)
  2791. if do_vcs "https://github.com/Matroska-Org/libebml.git"; then
  2792. do_uninstall include/ebml lib/cmake/EBML "${_check[@]}"
  2793. do_cmakeinstall
  2794. do_checkIfExist
  2795. fi
  2796. _check=(libmatroska.a libmatroska.pc matroska/KaxTypes.h lib/cmake/Matroska/MatroskaTargets.cmake)
  2797. if do_vcs "https://github.com/Matroska-Org/libmatroska.git"; then
  2798. do_uninstall include/matroska lib/cmake/Matroska "${_check[@]}"
  2799. do_cmakeinstall
  2800. do_checkIfExist
  2801. fi
  2802. _check=("$LOCALDESTDIR"/vlc/bin/{{c,r}vlc,vlc.exe,libvlc.dll}
  2803. "$LOCALDESTDIR"/vlc/libexec/vlc/vlc-cache-gen.exe
  2804. "$LOCALDESTDIR"/vlc/lib/pkgconfig/libvlc.pc
  2805. "$LOCALDESTDIR"/vlc/include/vlc/libvlc_version.h)
  2806. if do_vcs "https://code.videolan.org/videolan/vlc.git"; then
  2807. do_uninstall bin/plugins lib/vlc "${_check[@]}"
  2808. _mabs_vlc=https://raw.githubusercontent.com/m-ab-s/mabs-patches/master/vlc
  2809. do_patch "https://code.videolan.org/videolan/vlc/-/merge_requests/155.patch" am
  2810. do_patch "$_mabs_vlc/0001-modules-access-srt-Use-srt_create_socket-instead-of-.patch" am
  2811. do_patch "$_mabs_vlc/0002-modules-codec-libass-Use-ass_set_pixel_aspect-instea.patch" am
  2812. do_patch "$_mabs_vlc/0003-Use-libdir-for-plugins-on-msys2.patch" am
  2813. do_patch "$_mabs_vlc/0004-include-vlc_fixups.h-fix-iovec-is-redefined-errors.patch" am
  2814. do_patch "$_mabs_vlc/0005-include-vlc_common.h-fix-snprintf-and-vsnprintf-rede.patch" am
  2815. do_patch "$_mabs_vlc/0006-configure.ac-check-if-_WIN32_IE-is-already-defined.patch" am
  2816. do_patch "$_mabs_vlc/0007-modules-stream_out-rtp-don-t-redefine-E-defines.patch" am
  2817. do_patch "$_mabs_vlc/0008-include-vlc_codecs.h-don-t-redefine-WAVE_FORMAT_PCM.patch" am
  2818. do_patch "$_mabs_vlc/0009-modules-audio_filter-channel_mixer-spatialaudio-add-.patch" am
  2819. do_patch "$_mabs_vlc/0010-modules-access_output-don-t-put-lgpg-error-for-liveh.patch" am
  2820. do_autoreconf
  2821. # All of the disabled are because of multiple issues both on the installed libs and on vlc's side.
  2822. # Maybe set up vlc_options.txt
  2823. # Can't disable shared since vlc will error out. I don't think enabling static will really do anything for us other than breaking builds.
  2824. create_build_dir
  2825. config_path=".." do_configure \
  2826. --prefix="$LOCALDESTDIR/vlc" \
  2827. --sysconfdir="$LOCALDESTDIR/vlc/etc" \
  2828. --{build,host,target}="$MINGW_CHOST" \
  2829. --enable-{shared,avcodec,merge-ffmpeg,qt,nls} \
  2830. --disable-{static,dbus,fluidsynth,svgdec,aom,mod,ncurses,mpg123,notify,svg,secret,telx,ssp,lua,gst-decode,nvdec} \
  2831. --with-binary-version="MABS" BUILDCC="$CC" \
  2832. CFLAGS="$CFLAGS -DGLIB_STATIC_COMPILATION -DQT_STATIC -DGNUTLS_INTERNAL_BUILD -DLIBXML_STATIC -DLIBXML_CATALOG_ENABLED" \
  2833. LIBS="$($PKG_CONFIG --libs libcddb regex iconv) -lwsock32 -lws2_32 -lpthread -liphlpapi"
  2834. do_makeinstall
  2835. do_checkIfExist
  2836. PATH="$LOCALDESTDIR/vlc/bin:$PATH" "$LOCALDESTDIR/vlc/libexec/vlc/vlc-cache-gen" "$LOCALDESTDIR/vlc/lib/plugins"
  2837. fi
  2838. fi
  2839. _check=(bin-video/ffmbc.exe)
  2840. if [[ $ffmbc = y ]] && do_vcs "https://github.com/bcoudurier/FFmbc.git#branch=ffmbc"; then # no other branch
  2841. _notrequired=true
  2842. create_build_dir
  2843. log configure ../configure --target-os=mingw32 --enable-gpl \
  2844. --disable-{dxva2,ffprobe} --extra-cflags=-DNO_DSHOW_STRSAFE \
  2845. --cc="$CC" --ld="$CXX"
  2846. do_make
  2847. do_install ffmbc.exe bin-video/
  2848. do_checkIfExist
  2849. unset _notrequired
  2850. fi
  2851. do_simple_print -p "${orange}Finished $bits compilation of all tools${reset}"
  2852. }
  2853. run_builds() {
  2854. new_updates=no
  2855. new_updates_packages=""
  2856. if [[ $build32 = yes ]]; then
  2857. source /local32/etc/profile2.local
  2858. buildProcess
  2859. fi
  2860. if [[ $build64 = yes ]]; then
  2861. source /local64/etc/profile2.local
  2862. buildProcess
  2863. fi
  2864. }
  2865. cd_safe "$LOCALBUILDDIR"
  2866. run_builds
  2867. if [[ $exitearly = EE2 || $exitearly = EE3 || $exitearly = EE4 || $exitearly = EE5 || $exitearly = EE6 ]]; then
  2868. exit 0
  2869. fi
  2870. while [[ $new_updates = yes ]]; do
  2871. ret=no
  2872. printf '%s\n' \
  2873. "-------------------------------------------------------------------------------" \
  2874. "There were new updates while compiling." \
  2875. "Updated:$new_updates_packages" \
  2876. "Would you like to run compilation again to get those updates? Default: no"
  2877. do_prompt "y/[n] "
  2878. echo "-------------------------------------------------------------------------------"
  2879. if [[ $ret = y || $ret = Y || $ret = yes ]]; then
  2880. run_builds
  2881. else
  2882. break
  2883. fi
  2884. done
  2885. clean_suite
  2886. if [[ -f $LOCALBUILDDIR/post_suite.sh ]]; then
  2887. do_simple_print -p "${green}Executing post_suite.sh${reset}"
  2888. source "$LOCALBUILDDIR"/post_suite.sh || true
  2889. fi
  2890. do_simple_print -p "${green}Compilation successful.${reset}"
  2891. do_simple_print -p "${green}This window will close automatically in 5 seconds.${reset}"
  2892. sleep 5