configure 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194
  1. #!/bin/sh
  2. #
  3. # FFmpeg configure script
  4. #
  5. # Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  6. # Copyright (c) 2005-2006 Diego Biurrun
  7. # Copyright (c) 2005-2006 Mans Rullgard
  8. #
  9. # make sure we are running under a compatible shell
  10. # try to make this part work with most shells
  11. try_exec(){
  12. echo "Trying shell $1"
  13. type "$1" >/dev/null 2>&1 && exec "$@"
  14. }
  15. unset foo
  16. (: ${foo%%bar}) 2>/dev/null
  17. E1="$?"
  18. (: ${foo?}) 2>/dev/null
  19. E2="$?"
  20. if test "$E1" != 0 || test "$E2" = 0; then
  21. echo "Broken shell detected. Trying alternatives."
  22. export FF_CONF_EXEC
  23. if test "0$FF_CONF_EXEC" -lt 1; then
  24. FF_CONF_EXEC=1
  25. try_exec bash "$0" "$@"
  26. fi
  27. if test "0$FF_CONF_EXEC" -lt 2; then
  28. FF_CONF_EXEC=2
  29. try_exec ksh "$0" "$@"
  30. fi
  31. if test "0$FF_CONF_EXEC" -lt 3; then
  32. FF_CONF_EXEC=3
  33. try_exec /usr/xpg4/bin/sh "$0" "$@"
  34. fi
  35. echo "No compatible shell script interpreter found."
  36. echo "This configure script requires a POSIX-compatible shell"
  37. echo "such as bash or ksh."
  38. echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
  39. echo "Instead, install a working POSIX-compatible shell."
  40. echo "Disabling this configure test will create a broken FFmpeg."
  41. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  42. echo "This bash version ($BASH_VERSION) is broken on your platform."
  43. echo "Upgrade to a later version if available."
  44. fi
  45. exit 1
  46. fi
  47. show_help(){
  48. echo "Usage: configure [options]"
  49. echo "Options: [defaults in brackets after descriptions]"
  50. echo
  51. echo "Standard options:"
  52. echo " --help print this message"
  53. echo " --logfile=FILE log tests and output to FILE [config.err]"
  54. echo " --disable-logging do not log configure debug information"
  55. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  56. echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
  57. echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
  58. echo " --incdir=DIR install includes in DIR [PREFIX/include]"
  59. echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
  60. echo " --enable-static build static libraries [default=yes]"
  61. echo " --disable-static do not build static libraries [default=no]"
  62. echo " --enable-shared build shared libraries [default=no]"
  63. echo " --disable-shared do not build shared libraries [default=yes]"
  64. echo " --enable-gpl allow use of GPL code, the resulting libav*"
  65. echo " and ffmpeg will be under GPL [default=no]"
  66. echo " --enable-nonfree allow use of nonfree code, the resulting libav*"
  67. echo " and ffmpeg will be unredistributable [default=no]"
  68. echo " --enable-postproc enable GPLed postprocessing support [default=no]"
  69. echo " --enable-swscale software scaler support [default=no]"
  70. echo " --enable-avfilter video filter support (replaces vhook) [default=no]"
  71. echo " --enable-avfilter-lavf video filters dependant on avformat [default=no]"
  72. echo " --enable-beosthreads use BeOS threads [default=no]"
  73. echo " --enable-os2threads use OS/2 threads [default=no]"
  74. echo " --enable-pthreads use pthreads [default=no]"
  75. echo " --enable-w32threads use Win32 threads [default=no]"
  76. echo " --enable-x11grab enable X11 grabbing [default=no]"
  77. echo
  78. echo "External library support:"
  79. echo " --enable-mlib use Sun medialib [default=no]"
  80. echo " --enable-liba52 enable GPLed liba52 support [default=no]"
  81. echo " --enable-liba52bin open liba52.so.0 at runtime [default=no]"
  82. echo " --enable-avisynth allow reading AVISynth script files [default=no]"
  83. echo " --enable-libamr-nb enable libamr-nb floating point audio codec"
  84. echo " --enable-libamr-wb enable libamr-wb floating point audio codec"
  85. echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
  86. echo " and libraw1394 [default=no]"
  87. echo " --enable-libfaac enable FAAC support via libfaac [default=no]"
  88. echo " --enable-libfaad enable FAAD support via libfaad [default=no]"
  89. echo " --enable-libfaadbin open libfaad.so.0 at runtime [default=no]"
  90. echo " --enable-libgsm enable GSM support via libgsm [default=no]"
  91. echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [default=no]"
  92. echo " --enable-libnut enable NUT (de)muxing via libnut,"
  93. echo " native demuxer exists [default=no]"
  94. echo " --enable-libtheora enable Theora encoding via libtheora [default=no]"
  95. echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
  96. echo " native implementation exists [default=no]"
  97. echo " --enable-libx264 enable H.264 encoding via x264 [default=no]"
  98. echo " --enable-libxvid enable Xvid encoding via xvidcore,"
  99. echo " native MPEG-4/Xvid encoder exists [default=no]"
  100. echo ""
  101. echo "Advanced options (experts only):"
  102. echo " --source-path=PATH path to source code [$source_path]"
  103. echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
  104. echo " --enable-cross-compile assume a cross-compiler is used"
  105. echo " --target-os=OS compiler targets OS [$target_os]"
  106. echo " --cc=CC use C compiler CC [$cc]"
  107. echo " --make=MAKE use specified make [$make]"
  108. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  109. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  110. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  111. echo " --build-suffix=SUFFIX suffix for application specific build []"
  112. echo " --arch=ARCH select architecture [$arch]"
  113. echo " --cpu=CPU selects the minimum cpu required (affects"
  114. echo " instruction selection, may crash on older CPUs)"
  115. echo " --enable-powerpc-perf enable performance report on PPC"
  116. echo " (requires enabling PMC)"
  117. echo " --disable-mmx disable MMX usage"
  118. echo " --disable-mmx2 disable MMX2 usage"
  119. echo " --disable-ssse3 disable SSSE3 usage"
  120. echo " --disable-armv5te disable armv5te usage"
  121. echo " --disable-armv6 disable armv6 usage"
  122. echo " --disable-iwmmxt disable iwmmxt usage"
  123. echo " --disable-altivec disable AltiVec usage"
  124. echo " --disable-network disable network support [default=no]"
  125. echo " --disable-ipv6 disable ipv6 support [default=no]"
  126. echo " --disable-zlib disable zlib [default=no]"
  127. echo " --disable-vhook disable video hooking support"
  128. echo " --disable-debug disable debugging symbols"
  129. echo " --disable-mpegaudio-hp faster (but less accurate)"
  130. echo " MPEG audio decoding [default=no]"
  131. echo " --enable-gray enable full grayscale support (slower color)"
  132. echo " --disable-ffmpeg disable ffmpeg build"
  133. echo " --disable-ffserver disable ffserver build"
  134. echo " --disable-ffplay disable ffplay build"
  135. echo " --enable-small optimize for size instead of speed"
  136. echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
  137. echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
  138. echo " --disable-encoder=NAME disables encoder NAME"
  139. echo " --enable-encoder=NAME enables encoder NAME"
  140. echo " --disable-decoder=NAME disables decoder NAME"
  141. echo " --enable-decoder=NAME enables decoder NAME"
  142. echo " --disable-encoders disables all encoders"
  143. echo " --disable-decoders disables all decoders"
  144. echo " --disable-muxer=NAME disables muxer NAME"
  145. echo " --enable-muxer=NAME enables muxer NAME"
  146. echo " --disable-muxers disables all muxers"
  147. echo " --disable-demuxer=NAME disables demuxer NAME"
  148. echo " --enable-demuxer=NAME enables demuxer NAME"
  149. echo " --disable-demuxers disables all demuxers"
  150. echo " --enable-parser=NAME enables parser NAME"
  151. echo " --disable-parser=NAME disables parser NAME"
  152. echo " --disable-parsers disables all parsers"
  153. echo " --enable-bsf=NAME enables bitstream filter NAME"
  154. echo " --disable-bsf=NAME disables bitstream filter NAME"
  155. echo " --disable-bsfs disables all bitstream filters"
  156. echo " --enable-protocol=NAME enables protocol NAME"
  157. echo " --disable-protocol=NAME disables protocol NAME"
  158. echo " --disable-protocols disables all protocols"
  159. echo " --disable-devices disables all devices"
  160. echo " --list-decoders show all available decoders"
  161. echo " --list-encoders show all available encoders"
  162. echo " --list-muxers show all available muxers"
  163. echo " --list-demuxers show all available demuxers"
  164. echo " --list-parsers show all available parsers"
  165. echo " --list-protocols show all available protocols"
  166. echo " --list-bsfs show all available bitstream filters"
  167. echo " --list-indevs show all available input devices"
  168. echo " --list-outdevs show all available output devices"
  169. echo
  170. echo "Developer options (useful when working on FFmpeg itself):"
  171. echo " --enable-gprof enable profiling with gprof [$gprof]"
  172. echo " --disable-optimizations disable compiler optimizations"
  173. echo " --enable-extra-warnings enable more compiler warnings"
  174. echo " --disable-stripping disable stripping of executables and shared libraries"
  175. echo ""
  176. echo "NOTE: Object files are built at the place where configure is launched."
  177. exit 1
  178. }
  179. log(){
  180. echo "$@" >>$logfile
  181. }
  182. log_file(){
  183. log BEGIN $1
  184. pr -n -t $1 >>$logfile
  185. log END $1
  186. }
  187. echolog(){
  188. log "$@"
  189. echo "$@"
  190. }
  191. die(){
  192. echolog "$@"
  193. cat <<EOF
  194. If you think configure made a mistake, make sure you are using the latest
  195. version from SVN. If the latest version fails, report the problem to the
  196. ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
  197. EOF
  198. if disabled logging; then
  199. cat <<EOF
  200. Rerun configure with logging enabled (do not use --disable-logging), and
  201. include the log this produces with your report.
  202. EOF
  203. else
  204. cat <<EOF
  205. Include the log file "$logfile" produced by configure as this will help
  206. solving the problem.
  207. EOF
  208. fi
  209. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  210. exit 1
  211. }
  212. # Avoid locale weirdness, besides we really just want to translate ASCII.
  213. toupper(){
  214. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  215. }
  216. tolower(){
  217. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  218. }
  219. set_all(){
  220. value=$1
  221. shift
  222. for var in $*; do
  223. eval $var=$value
  224. done
  225. }
  226. pushvar(){
  227. for var in $*; do
  228. eval level=\${${var}_level:=0}
  229. eval ${var}_${level}="\$$var"
  230. eval ${var}_level=$(($level+1))
  231. done
  232. }
  233. popvar(){
  234. for var in $*; do
  235. eval level=\${${var}_level:-0}
  236. test $level = 0 && continue
  237. eval level=$(($level-1))
  238. eval $var="\${${var}_${level}}"
  239. eval ${var}_level=$level
  240. eval unset ${var}_${level}
  241. done
  242. }
  243. enable(){
  244. set_all yes $*
  245. }
  246. disable(){
  247. set_all no $*
  248. }
  249. enabled(){
  250. eval test "x\$$1" = "xyes"
  251. }
  252. disabled(){
  253. eval test "x\$$1" = "xno"
  254. }
  255. enabled_all(){
  256. for opt; do
  257. enabled $opt || return 1
  258. done
  259. }
  260. disabled_all(){
  261. for opt; do
  262. disabled $opt || return 1
  263. done
  264. }
  265. enabled_any(){
  266. for opt; do
  267. enabled $opt && return 0
  268. done
  269. }
  270. disabled_any(){
  271. for opt; do
  272. disabled $opt && return 0
  273. done
  274. }
  275. is_in(){
  276. value=$1
  277. shift
  278. for var in $*; do
  279. [ $var = $value ] && return 0
  280. done
  281. return 1
  282. }
  283. check_deps(){
  284. for cfg; do
  285. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  286. disabled ${cfg}_checking && continue
  287. enable ${cfg}_checking
  288. eval dep_all="\$${cfg}_deps"
  289. eval dep_any="\$${cfg}_deps_any"
  290. pushvar cfg dep_all dep_any
  291. check_deps $dep_all $dep_any
  292. popvar cfg dep_all dep_any
  293. enabled_all $dep_all || disable $cfg
  294. enabled_any $dep_any || disable $cfg
  295. if enabled $cfg; then
  296. eval dep_extralibs="\$${cfg}_extralibs"
  297. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  298. fi
  299. disable ${cfg}_checking
  300. done
  301. }
  302. print_config(){
  303. pfx=$1
  304. header=$2
  305. makefile=$3
  306. shift 3
  307. for cfg; do
  308. ucname="`toupper $cfg`"
  309. if enabled $cfg; then
  310. echo "#define ${pfx}${ucname} 1" >> $header
  311. echo "#define ENABLE_${ucname} 1" >> $header
  312. echo "${pfx}${ucname}=yes" >> $makefile
  313. else
  314. echo "#define ENABLE_${ucname} 0" >> $header
  315. fi
  316. done
  317. }
  318. flags_saved(){
  319. (: ${SAVE_CFLAGS?}) 2>/dev/null
  320. }
  321. save_flags(){
  322. flags_saved && return
  323. SAVE_CFLAGS="$CFLAGS"
  324. SAVE_LDFLAGS="$LDFLAGS"
  325. SAVE_extralibs="$extralibs"
  326. }
  327. restore_flags(){
  328. flags_saved || return
  329. CFLAGS="$SAVE_CFLAGS"
  330. LDFLAGS="$SAVE_LDFLAGS"
  331. extralibs="$SAVE_extralibs"
  332. unset SAVE_CFLAGS
  333. unset SAVE_LDFLAGS
  334. unset SAVE_extralibs
  335. }
  336. temp_cflags(){
  337. save_flags
  338. CFLAGS="$CFLAGS $*"
  339. }
  340. temp_ldflags(){
  341. save_flags
  342. LDFLAGS="$LDFLAGS $*"
  343. }
  344. temp_extralibs(){
  345. save_flags
  346. extralibs="$extralibs $*"
  347. }
  348. append(){
  349. var=$1
  350. shift
  351. flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
  352. eval "$var=\"\$$var $*\""
  353. }
  354. add_cflags(){
  355. append CFLAGS "$@"
  356. }
  357. add_ldflags(){
  358. append LDFLAGS "$@"
  359. }
  360. add_extralibs(){
  361. append extralibs "$@"
  362. }
  363. check_cmd(){
  364. log "$@"
  365. "$@" >>$logfile 2>&1
  366. }
  367. check_cc(){
  368. log check_cc "$@"
  369. cat >$TMPC
  370. log_file $TMPC
  371. check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
  372. }
  373. check_cpp(){
  374. log check_cpp "$@"
  375. cat >$TMPC
  376. log_file $TMPC
  377. check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
  378. }
  379. check_asm(){
  380. log check_asm "$@"
  381. name="$1"
  382. asm="$2"
  383. shift 2
  384. check_cc "$@" <<EOF && enable $name || disable $name
  385. int foo(void){ asm volatile($asm); }
  386. EOF
  387. }
  388. check_ld(){
  389. log check_ld "$@"
  390. check_cc || return
  391. flags=''
  392. libs=''
  393. for f; do
  394. test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
  395. done
  396. check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
  397. }
  398. check_cflags(){
  399. log check_cflags "$@"
  400. check_cc "$@" <<EOF && add_cflags "$@"
  401. int x;
  402. EOF
  403. }
  404. check_ldflags(){
  405. log check_ldflags "$@"
  406. check_ld "$@" <<EOF && add_ldflags "$@"
  407. int main(void){ return 0; }
  408. EOF
  409. }
  410. check_header(){
  411. log check_header "$@"
  412. header=$1
  413. shift
  414. var=`echo $header | sed 's/[^A-Za-z0-9_]/_/g'`
  415. disable $var
  416. check_cpp "$@" <<EOF && enable $var
  417. #include <$header>
  418. int x;
  419. EOF
  420. }
  421. check_func(){
  422. log check_func "$@"
  423. func=$1
  424. shift
  425. disable $func
  426. check_ld "$@" <<EOF && enable $func
  427. extern int $func();
  428. int main(void){ $func(); }
  429. EOF
  430. }
  431. check_func2(){
  432. log check_func2 "$@"
  433. headers=$1
  434. func=$2
  435. shift 2
  436. disable $func
  437. incs=""
  438. for hdr in $headers; do
  439. incs="$incs
  440. #include <$hdr>"
  441. done
  442. check_ld "$@" <<EOF && enable $func
  443. $incs
  444. int main(int argc, char **argv){
  445. (void) $func;
  446. return 0;
  447. }
  448. EOF
  449. }
  450. check_lib(){
  451. log check_lib "$@"
  452. header="$1"
  453. func="$2"
  454. shift 2
  455. temp_extralibs "$@"
  456. check_header $header && check_func $func && add_extralibs "$@"
  457. err=$?
  458. restore_flags
  459. return $err
  460. }
  461. check_lib2(){
  462. log check_lib2 "$@"
  463. headers="$1"
  464. func="$2"
  465. shift 2
  466. temp_extralibs "$@"
  467. check_func2 "$headers" $func && add_extralibs "$@"
  468. err=$?
  469. restore_flags
  470. return $err
  471. }
  472. check_exec(){
  473. check_ld "$@" && { enabled cross_compile || $TMPE >>$logfile 2>&1; }
  474. }
  475. check_exec_crash(){
  476. code=`cat`
  477. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  478. # are safe but may not be available everywhere. Thus we use
  479. # raise(SIGTERM) instead. The check is run in a subshell so we
  480. # can redirect the "Terminated" message from the shell. SIGBUS
  481. # is not defined by standard C so it is used conditionally.
  482. (check_exec "$@") >>$logfile 2>&1 <<EOF
  483. #include <signal.h>
  484. static void sighandler(int sig){
  485. raise(SIGTERM);
  486. }
  487. int main(void){
  488. signal(SIGILL, sighandler);
  489. signal(SIGFPE, sighandler);
  490. signal(SIGSEGV, sighandler);
  491. #ifdef SIGBUS
  492. signal(SIGBUS, sighandler);
  493. #endif
  494. { $code }
  495. }
  496. EOF
  497. }
  498. check_type(){
  499. log check_type "$@"
  500. headers=$1
  501. type=$2
  502. shift 2
  503. disable $type
  504. incs=""
  505. for hdr in $headers; do
  506. incs="$incs
  507. #include <$hdr>"
  508. done
  509. check_cc "$@" <<EOF && enable $type
  510. $incs
  511. $type v;
  512. EOF
  513. }
  514. require(){
  515. name="$1"
  516. header="$2"
  517. func="$3"
  518. shift 3
  519. check_lib $header $func "$@" || die "ERROR: $name not found"
  520. }
  521. require2(){
  522. name="$1"
  523. headers="$2"
  524. func="$3"
  525. shift 3
  526. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  527. }
  528. check_foo_config(){
  529. cfg=$1
  530. pkg=$2
  531. header=$3
  532. func=$4
  533. shift 4
  534. disable $cfg
  535. check_cmd ${pkg}-config --version
  536. err=$?
  537. if test "$err" = 0; then
  538. temp_cflags `${pkg}-config --cflags`
  539. temp_extralibs `${pkg}-config --libs`
  540. check_lib "$@" $header $func && enable $cfg
  541. fi
  542. return $err
  543. }
  544. apply(){
  545. file=$1
  546. shift
  547. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  548. }
  549. COMPONENT_LIST="
  550. bsfs
  551. decoders
  552. demuxers
  553. encoders
  554. filters
  555. indevs
  556. muxers
  557. outdevs
  558. parsers
  559. protocols
  560. "
  561. CONFIG_LIST="
  562. $COMPONENT_LIST
  563. avfilter
  564. avfilter_lavf
  565. avisynth
  566. beos_netserver
  567. ffmpeg
  568. ffplay
  569. ffserver
  570. gpl
  571. gprof
  572. gray
  573. hardcoded_tables
  574. ipv6
  575. liba52
  576. liba52bin
  577. libamr_nb
  578. libamr_wb
  579. libdc1394
  580. libfaac
  581. libfaad
  582. libfaadbin
  583. libgsm
  584. libmp3lame
  585. libnut
  586. libtheora
  587. libvorbis
  588. libx264
  589. libxvid
  590. memalign_hack
  591. mlib
  592. mpegaudio_hp
  593. network
  594. nonfree
  595. postproc
  596. powerpc_perf
  597. small
  598. swscale
  599. vhook
  600. x11grab
  601. zlib
  602. "
  603. THREADS_LIST='
  604. beosthreads
  605. os2threads
  606. pthreads
  607. w32threads
  608. '
  609. ARCH_LIST='
  610. alpha
  611. armv4l
  612. bfin
  613. ia64
  614. m68k
  615. mips
  616. parisc
  617. powerpc
  618. s390
  619. sh4
  620. sparc
  621. sparc64
  622. x86
  623. x86_32
  624. x86_64
  625. '
  626. ARCH_EXT_LIST='
  627. altivec
  628. armv5te
  629. armv6
  630. iwmmxt
  631. mmi
  632. mmx
  633. mmx2
  634. ssse3
  635. vis
  636. '
  637. HAVE_LIST="
  638. $ARCH_EXT_LIST
  639. $THREADS_LIST
  640. altivec_h
  641. arpa_inet_h
  642. bswap
  643. byteswap_h
  644. closesocket
  645. cmov
  646. conio_h
  647. dcbzl
  648. dev_bktr_ioctl_bt848_h
  649. dev_bktr_ioctl_meteor_h
  650. dev_ic_bt8xx_h
  651. dev_video_meteor_ioctl_meteor_h
  652. dev_video_bktr_ioctl_bt848_h
  653. dlfcn_h
  654. dlopen
  655. ebp_available
  656. ebx_available
  657. fast_64bit
  658. fast_cmov
  659. fast_unaligned
  660. fork
  661. freetype2
  662. gethrtime
  663. GetProcessTimes
  664. getrusage
  665. imlib2
  666. inet_aton
  667. inline_asm
  668. libdc1394_1
  669. libdc1394_2
  670. llrint
  671. lrint
  672. lrintf
  673. machine_ioctl_bt848_h
  674. machine_ioctl_meteor_h
  675. malloc_h
  676. memalign
  677. mkstemp
  678. pld
  679. ppc64
  680. round
  681. roundf
  682. sdl
  683. sdl_video_size
  684. socklen_t
  685. soundcard_h
  686. poll_h
  687. sys_mman_h
  688. sys_select_h
  689. sys_soundcard_h
  690. termios_h
  691. threads
  692. winsock2_h
  693. "
  694. CMDLINE_SELECT="
  695. $ARCH_EXT_LIST
  696. $CONFIG_LIST
  697. $THREADS_LIST
  698. cross_compile
  699. debug
  700. extra_warnings
  701. logging
  702. optimizations
  703. shared
  704. static
  705. stripping
  706. "
  707. CMDLINE_SET='
  708. arch
  709. build_suffix
  710. cc
  711. cpu
  712. cross_prefix
  713. incdir
  714. libdir
  715. logfile
  716. make
  717. mandir
  718. prefix
  719. shlibdir
  720. source_path
  721. target_os
  722. '
  723. # code dependency declarations
  724. # architecture extensions
  725. altivec_deps="powerpc"
  726. armv5te_deps="armv4l"
  727. armv6_deps="armv4l"
  728. iwmmxt_deps="armv4l"
  729. mmi_deps="mips"
  730. mmx_deps="x86"
  731. mmx2_deps="x86 mmx"
  732. ssse3_deps="x86"
  733. vis_deps="sparc"
  734. # decoders / encoders
  735. ac3_decoder_deps="gpl"
  736. dxa_decoder_deps="zlib"
  737. flashsv_decoder_deps="zlib"
  738. flashsv_encoder_deps="zlib"
  739. mpeg_xvmc_decoder_deps="xvmc"
  740. png_decoder_deps="zlib"
  741. png_encoder_deps="zlib"
  742. zmbv_decoder_deps="zlib"
  743. zmbv_encoder_deps="zlib"
  744. # external libraries
  745. liba52_decoder_deps="liba52"
  746. liba52bin_decoder_extralibs='$ldl'
  747. libamr_nb_decoder_deps="libamr_nb"
  748. libamr_nb_encoder_deps="libamr_nb"
  749. libamr_wb_decoder_deps="libamr_wb"
  750. libamr_wb_encoder_deps="libamr_wb"
  751. libfaac_encoder_deps="libfaac"
  752. libfaad_decoder_deps="libfaad"
  753. libfaadbin_decoder_extralibs='$ldl'
  754. libgsm_decoder_deps="libgsm"
  755. libgsm_encoder_deps="libgsm"
  756. libgsm_ms_decoder_deps="libgsm"
  757. libgsm_ms_encoder_deps="libgsm"
  758. libmp3lame_encoder_deps="libmp3lame"
  759. libtheora_encoder_deps="libtheora"
  760. libvorbis_encoder_deps="libvorbis"
  761. libx264_encoder_deps="libx264"
  762. libxvid_encoder_deps="libxvid"
  763. mpeg4aac_decoder_deps="libfaad"
  764. # demuxers / muxers
  765. ac3_demuxer_deps="ac3_parser"
  766. audio_beos_demuxer_deps="audio_beos"
  767. audio_beos_demuxer_extralibs="-lmedia -lbe"
  768. audio_beos_muxer_deps="audio_beos"
  769. audio_beos_muxer_extralibs="-lmedia -lbe"
  770. avisynth_demuxer_deps="avisynth"
  771. bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  772. dv1394_demuxer_deps="dv1394 dv_demuxer"
  773. libdc1394_demuxer_deps="libdc1394"
  774. libnut_demuxer_deps="libnut"
  775. libnut_muxer_deps="libnut"
  776. mp3_demuxer_deps="mpegaudio_parser"
  777. oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
  778. oss_muxer_deps_any="soundcard_h sys_soundcard_h"
  779. redir_demuxer_deps="network"
  780. rtp_muxer_deps="network rtp_protocol"
  781. rtsp_demuxer_deps="sdp_demuxer"
  782. sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
  783. v4l_demuxer_deps="linux_videodev_h"
  784. v4l2_demuxer_deps="linux_videodev2_h"
  785. vfwcap_demuxer_deps="capCreateCaptureWindow"
  786. vfwcap_demuxer_extralibs="-lvfw32"
  787. x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
  788. x11_grab_device_demuxer_extralibs="-lX11 -lXext"
  789. # protocols
  790. http_protocol_deps="network"
  791. rtp_protocol_deps="udp_protocol"
  792. tcp_protocol_deps="network"
  793. udp_protocol_deps="network"
  794. # filters
  795. movie_filter_deps="avfilter_lavf"
  796. # programs
  797. ffplay_deps="sdl"
  798. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  799. ffserver_extralibs='$ldl'
  800. vhook_extralibs='$ldl'
  801. # default parameters
  802. logfile="config.err"
  803. # installation paths
  804. prefix="/usr/local"
  805. libdir='$(PREFIX)/lib'
  806. shlibdir="$libdir"
  807. incdir='$(PREFIX)/include'
  808. mandir='$(PREFIX)/share/man'
  809. bindir='$(PREFIX)/bin'
  810. # toolchain
  811. cc="gcc"
  812. ar="ar"
  813. nm="nm"
  814. ranlib="ranlib"
  815. make="make"
  816. strip="strip"
  817. asmalign_pot="unknown"
  818. ln_s="ln -sf"
  819. # machine
  820. arch=`uname -m`
  821. cpu="generic"
  822. # OS
  823. target_os=$(tolower $(uname -s))
  824. # libraries
  825. enable zlib
  826. # configurable options
  827. enable debug
  828. enable ffmpeg
  829. enable ffplay
  830. enable ffserver
  831. enable ipv6
  832. enable mpegaudio_hp
  833. enable network
  834. enable optimizations
  835. enable protocols
  836. enable static
  837. enable stripping
  838. vhook="default"
  839. # build settings
  840. SHFLAGS='-shared -Wl,-soname,$(SLIBNAME_WITH_MAJOR)'
  841. VHOOKSHFLAGS='$(SHFLAGS)'
  842. LDLATEFLAGS='-Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
  843. FFSERVERLDFLAGS=-Wl,-E
  844. LIBPREF="lib"
  845. LIBSUF=".a"
  846. FULLNAME='$(NAME)$(BUILDSUF)'
  847. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  848. SLIBPREF="lib"
  849. SLIBSUF=".so"
  850. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  851. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  852. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  853. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  854. # gcc stupidly only outputs the basename of targets with -MM
  855. DEPEND_CMD='$(CC) -MM $(CFLAGS) $(filter-out %.h,$^) | sed "s,[0-9a-z._-]*: \($(SRC_DIR)/\)*\([a-z0-9]*/\)[^/]* ,\\2&,"'
  856. VHOOK_DEPEND_CMD='$(CC) -MM $(VHOOKCFLAGS) $(filter-out %.h,$^) | sed "s,^\([a-z]\),vhook/\\1,"'
  857. # find source path
  858. source_path="`dirname \"$0\"`"
  859. enable source_path_used
  860. if test -z "$source_path" -o "$source_path" = "." ; then
  861. source_path="`pwd`"
  862. disable source_path_used
  863. else
  864. source_path="`cd \"$source_path\"; pwd`"
  865. echo "$source_path" | grep -q '[[:blank:]]' &&
  866. die "Out of tree builds are impossible with whitespace in source path."
  867. fi
  868. FFMPEG_CONFIGURATION="$@"
  869. find_things(){
  870. thing=$1
  871. pattern=$2
  872. file=$source_path/$3
  873. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  874. }
  875. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  876. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  877. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  878. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  879. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  880. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  881. OUTDEV_LIST=$(find_things muxer _MUX libavdevice/alldevices.c)
  882. INDEV_LIST=$(find_things demuxer DEMUX libavdevice/alldevices.c)
  883. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  884. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  885. enable $ARCH_EXT_LIST \
  886. $DECODER_LIST \
  887. $ENCODER_LIST \
  888. $PARSER_LIST \
  889. $BSF_LIST \
  890. $DEMUXER_LIST \
  891. $MUXER_LIST \
  892. $FILTER_LIST \
  893. $PROTOCOL_LIST \
  894. $INDEV_LIST \
  895. $OUTDEV_LIST \
  896. die_unknown(){
  897. echo "Unknown option \"$1\"."
  898. echo "See $0 --help for available options."
  899. exit 1
  900. }
  901. show_list() {
  902. suffix=_$1
  903. shift
  904. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  905. exit 0
  906. }
  907. for opt do
  908. optval="${opt#*=}"
  909. case "$opt" in
  910. --extra-cflags=*) add_cflags "$optval"
  911. ;;
  912. --extra-ldflags=*) add_ldflags "$optval"
  913. ;;
  914. --extra-libs=*) add_extralibs "$optval"
  915. ;;
  916. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  917. ;;
  918. --enable-debug=*) debuglevel="$optval"
  919. ;;
  920. --enable-*=*|--disable-*=*)
  921. eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
  922. case "$thing" in
  923. encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
  924. *) die_unknown "$opt" ;;
  925. esac
  926. ;;
  927. --enable-?*|--disable-?*)
  928. eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
  929. if is_in $option $COMPONENT_LIST; then
  930. eval $action \$$(toupper ${option%s})_LIST
  931. elif is_in $option $CMDLINE_SELECT; then
  932. $action $option
  933. else
  934. die_unknown $opt
  935. fi
  936. ;;
  937. --list-*)
  938. NAME="${opt#--list-}"
  939. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  940. NAME=${NAME%s}
  941. eval show_list $NAME \$$(toupper $NAME)_LIST
  942. ;;
  943. --help|-h) show_help
  944. ;;
  945. *)
  946. optname="${opt%=*}"
  947. optname="${optname#--}"
  948. optname=$(echo "$optname" | sed 's/-/_/g')
  949. is_in $optname $CMDLINE_SET || die_unknown $opt
  950. eval $optname='$optval'
  951. ;;
  952. esac
  953. done
  954. # OS specific
  955. case $target_os in
  956. beos|haiku|zeta)
  957. prefix="$HOME/config"
  958. # helps building libavcodec
  959. add_cflags "-DPIC -fomit-frame-pointer"
  960. # 3 gcc releases known for BeOS, each with ugly bugs
  961. gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
  962. case "$gcc_version" in
  963. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  964. disable mmx
  965. ;;
  966. *20010315*) echo "BeBits gcc"
  967. add_cflags "-fno-expensive-optimizations"
  968. ;;
  969. esac
  970. SHFLAGS=-nostart
  971. # enable BeOS things
  972. enable audio_beos
  973. # no need for libm, but the inet stuff
  974. # Check for BONE
  975. # XXX: actually should check for NOT net_server
  976. if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
  977. network_extralibs="-lbind -lsocket"
  978. else
  979. enable beos_netserver
  980. network_extralibs="-lnet"
  981. fi ;;
  982. sunos)
  983. FFSERVERLDFLAGS=""
  984. SHFLAGS='-shared -Wl,-h,$(SLIBNAME_WITH_MAJOR)'
  985. network_extralibs="-lsocket -lnsl"
  986. ;;
  987. netbsd)
  988. oss_demuxer_extralibs="-lossaudio"
  989. oss_muxer_extralibs="-lossaudio"
  990. ;;
  991. openbsd)
  992. disable need_memalign
  993. LIBOBJFLAGS='$(PIC)'
  994. SHFLAGS='-shared'
  995. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF).$(LIBVERSION)'
  996. SLIBNAME_WITH_VERSION='$(SLIBNAME)'
  997. SLIBNAME_WITH_MAJOR='$(SLIBNAME)'
  998. oss_demuxer_extralibs="-lossaudio"
  999. oss_muxer_extralibs="-lossaudio"
  1000. ;;
  1001. freebsd)
  1002. disable need_memalign
  1003. ;;
  1004. bsd/os)
  1005. osextralibs="-lpoll -lgnugetopt"
  1006. strip="strip -d"
  1007. ;;
  1008. darwin)
  1009. disable need_memalign
  1010. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  1011. VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$@'
  1012. strip="strip -x"
  1013. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1014. SLIBSUF=".dylib"
  1015. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1016. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1017. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1018. ;;
  1019. mingw32*)
  1020. target_os=mingw32
  1021. shlibdir="$bindir"
  1022. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1023. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1024. if enabled swscale; then
  1025. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1026. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1027. fi
  1028. disable ffserver
  1029. SLIBPREF=""
  1030. SLIBSUF=".dll"
  1031. EXESUF=".exe"
  1032. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1033. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1034. SLIB_EXTRA_CMD='-lib /machine:i386 /def:$(@:$(SLIBSUF)=.def)'
  1035. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1036. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1037. SHFLAGS='-shared -Wl,--output-def,$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  1038. ;;
  1039. cygwin*)
  1040. target_os=cygwin
  1041. shlibdir="$bindir"
  1042. VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
  1043. VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
  1044. if enabled swscale; then
  1045. VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
  1046. VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
  1047. fi
  1048. EXESUF=".exe"
  1049. SLIBPREF="cyg"
  1050. SLIBSUF=".dll"
  1051. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1052. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1053. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1054. ;;
  1055. *-dos|freedos|opendos)
  1056. disable ffplay ffserver vhook
  1057. disable $INDEV_LIST $OUTDEV_LIST
  1058. network_extralibs="-lsocket"
  1059. EXESUF=".exe"
  1060. ;;
  1061. linux)
  1062. LDLATEFLAGS="-Wl,--as-needed $LDLATEFLAGS"
  1063. enable dv1394
  1064. ;;
  1065. irix*)
  1066. target_os=irix
  1067. ranlib="echo ignoring ranlib"
  1068. ;;
  1069. os/2*)
  1070. strip="lxlite"
  1071. ln_s="cp -f"
  1072. EXESUF=".exe"
  1073. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1074. SHFLAGS='$(NAME).def -Zdll -Zomf'
  1075. FFSERVERLDFLAGS=""
  1076. LIBSUF="_s.a"
  1077. SLIBPREF=""
  1078. SLIBSUF=".dll"
  1079. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1080. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1081. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(NAME).def; \
  1082. echo PROTMODE >> $(NAME).def; \
  1083. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(NAME).def; \
  1084. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(NAME).def; \
  1085. echo EXPORTS >> $(NAME).def; \
  1086. emxexp -o $(OBJS) >> $(NAME).def'
  1087. SLIB_EXTRA_CMD='emximp -o $(LIBPREF)$(NAME)_dll.a $(NAME).def; \
  1088. emximp -o $(LIBPREF)$(NAME)_dll.lib $(NAME).def;'
  1089. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1090. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1091. disable vhook
  1092. ;;
  1093. interix)
  1094. disable vhook
  1095. ;;
  1096. *)
  1097. target_os="${target_os}-UNKNOWN"
  1098. ;;
  1099. esac
  1100. # set temporary file name
  1101. if test ! -z "$TMPDIR" ; then
  1102. TMPDIR1="${TMPDIR}"
  1103. elif test ! -z "$TEMPDIR" ; then
  1104. TMPDIR1="${TEMPDIR}"
  1105. else
  1106. TMPDIR1="/tmp"
  1107. fi
  1108. TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  1109. TMPE="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}${EXESUF}"
  1110. TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  1111. TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  1112. TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  1113. TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
  1114. add_extralibs $osextralibs
  1115. disabled logging && logfile=/dev/null
  1116. echo "# $0 $@" >$logfile
  1117. set >>$logfile
  1118. case "$arch" in
  1119. i386|i486|i586|i686|i86pc|BePC)
  1120. arch="x86_32"
  1121. enable fast_unaligned
  1122. ;;
  1123. x86_64|amd64)
  1124. arch="x86_32"
  1125. enable fast_unaligned
  1126. check_cc <<EOF && enable fast_64bit && arch="x86_64"
  1127. int test[sizeof(char*) - 7];
  1128. EOF
  1129. ;;
  1130. # armv4l is a subset of armv[567]*l
  1131. arm|armv[4567]*l)
  1132. arch="armv4l"
  1133. ;;
  1134. alpha)
  1135. arch="alpha"
  1136. enable fast_64bit
  1137. ;;
  1138. "Power Macintosh"|ppc|powerpc)
  1139. arch="powerpc"
  1140. ;;
  1141. ppc64)
  1142. arch="powerpc"
  1143. enable fast_64bit
  1144. ;;
  1145. mips|mipsel|IP*)
  1146. arch="mips"
  1147. ;;
  1148. sun4u|sparc64)
  1149. arch="sparc64"
  1150. enable fast_64bit
  1151. ;;
  1152. sparc)
  1153. arch="sparc"
  1154. ;;
  1155. sh4)
  1156. arch="sh4"
  1157. ;;
  1158. parisc)
  1159. arch="parisc"
  1160. ;;
  1161. parisc64)
  1162. arch="parisc"
  1163. enable fast_64bit
  1164. ;;
  1165. s390|s390x)
  1166. arch="s390"
  1167. ;;
  1168. m68k)
  1169. arch="m68k"
  1170. ;;
  1171. ia64)
  1172. arch="ia64"
  1173. enable fast_64bit
  1174. ;;
  1175. bfin)
  1176. arch="bfin"
  1177. ;;
  1178. *)
  1179. arch="unknown"
  1180. ;;
  1181. esac
  1182. enable $arch
  1183. enabled_any x86_32 x86_64 && enable x86
  1184. enabled sparc64 && enable sparc
  1185. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1186. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1187. test -n "$cross_prefix" && enable cross_compile
  1188. cc="${cross_prefix}${cc}"
  1189. ar="${cross_prefix}${ar}"
  1190. nm="${cross_prefix}${nm}"
  1191. ranlib="${cross_prefix}${ranlib}"
  1192. strip="${cross_prefix}${strip}"
  1193. # we need to build at least one lib type
  1194. if ! enabled_any static shared; then
  1195. cat <<EOF
  1196. At least one library type must be built.
  1197. Specify --enable-static to build the static libraries or --enable-shared to
  1198. build the shared libraries as well. To only build the shared libraries specify
  1199. --disable-static in addition to --enable-shared.
  1200. EOF
  1201. exit 1;
  1202. fi
  1203. disabled static && LIBNAME=""
  1204. if enabled_any libfaad libfaadbin ; then
  1205. if check_header faad.h; then
  1206. check_cc << EOF
  1207. #include <faad.h>
  1208. #ifndef FAAD2_VERSION
  1209. ok faad1
  1210. #endif
  1211. int main(void) { return 0; }
  1212. EOF
  1213. test $? = 0 && enable libfaad2
  1214. else
  1215. die "FAAD test failed."
  1216. fi
  1217. fi
  1218. if ! enabled gpl; then
  1219. die_gpl_disabled(){
  1220. name=$1
  1221. shift
  1222. enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
  1223. }
  1224. die_gpl_disabled "The Postprocessing code" postproc
  1225. die_gpl_disabled "liba52" liba52
  1226. die_gpl_disabled "libx264" libx264
  1227. die_gpl_disabled "libxvidcore" libxvid
  1228. die_gpl_disabled "FAAD2" libfaad2
  1229. die_gpl_disabled "The X11 grabber" x11grab
  1230. die_gpl_disabled "The software scaler" swscale
  1231. fi
  1232. if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
  1233. die "libamr is nonfree and --enable-nonfree is not specified."
  1234. fi
  1235. check_deps $ARCH_EXT_LIST
  1236. test -z "$need_memalign" && need_memalign="$mmx"
  1237. #Darwin CC versions
  1238. if test $target_os = darwin; then
  1239. if $cc -v 2>&1 | grep -q xlc; then
  1240. add_cflags "-qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto"
  1241. else
  1242. add_cflags "-pipe"
  1243. check_cflags "-force_cpusubtype_ALL"
  1244. check_cflags "-Wno-sign-compare"
  1245. enabled shared || add_cflags -mdynamic-no-pic
  1246. fi
  1247. fi
  1248. disabled optimizations || add_cflags -fomit-frame-pointer
  1249. # Add processor-specific flags
  1250. if test $cpu != "generic"; then
  1251. warn_altivec(){
  1252. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1253. }
  1254. case $cpu in
  1255. 601|ppc601|PowerPC601)
  1256. add_cflags "-mcpu=601"
  1257. warn_altivec enabled PPC601
  1258. ;;
  1259. 603*|ppc603*|PowerPC603*)
  1260. add_cflags "-mcpu=603"
  1261. warn_altivec enabled PPC603
  1262. ;;
  1263. 604*|ppc604*|PowerPC604*)
  1264. add_cflags "-mcpu=604"
  1265. warn_altivec enabled PPC604
  1266. ;;
  1267. G3|g3|75*|ppc75*|PowerPC75*)
  1268. add_cflags "-mcpu=750 -mpowerpc-gfxopt"
  1269. warn_altivec enabled PPC75x
  1270. ;;
  1271. G4|g4|745*|ppc745*|PowerPC745*)
  1272. add_cflags "-mcpu=7450 -mpowerpc-gfxopt"
  1273. warn_altivec disabled PPC745x
  1274. ;;
  1275. 74*|ppc74*|PowerPC74*)
  1276. add_cflags "-mcpu=7400 -mpowerpc-gfxopt"
  1277. warn_altivec disabled PPC74xx
  1278. ;;
  1279. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1280. add_cflags "-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  1281. warn_altivec disabled PPC970
  1282. enable ppc64
  1283. ;;
  1284. Cell|CELL|cell)
  1285. add_cflags "-mcpu=cell"
  1286. warn_altivec disabled Cell
  1287. enable ppc64
  1288. ;;
  1289. # targets that do NOT support conditional mov (cmov)
  1290. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1291. add_cflags "-march=$cpu"
  1292. disable cmov
  1293. ;;
  1294. # targets that do support conditional mov (cmov)
  1295. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1296. add_cflags "-march=$cpu"
  1297. enable cmov
  1298. enable fast_cmov
  1299. ;;
  1300. # targets that do support conditional mov but on which it's slow
  1301. pentium4|pentium4m|prescott|nocona)
  1302. add_cflags "-march=$cpu"
  1303. enable cmov
  1304. disable fast_cmov
  1305. ;;
  1306. sparc64)
  1307. add_cflags "-mcpu=v9"
  1308. ;;
  1309. arm*)
  1310. add_cflags "-mcpu=$cpu"
  1311. ;;
  1312. *)
  1313. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1314. ;;
  1315. esac
  1316. fi
  1317. gnu_make(){
  1318. $1 --version 2>&1 | grep -q GNU
  1319. }
  1320. if ! gnu_make $make; then
  1321. gnu_make gmake && make=gmake || die "GNU make not found."
  1322. fi
  1323. # make sure we can execute files in $TMPDIR
  1324. cat >$TMPSH 2>>$logfile <<EOF
  1325. #! /bin/sh
  1326. EOF
  1327. chmod +x $TMPSH >>$logfile 2>&1
  1328. if ! $TMPSH >>$logfile 2>&1; then
  1329. cat <<EOF
  1330. Unable to create and execute files in $TMPDIR1. Set the TMPDIR environment
  1331. variable to another directory and make sure that $TMPDIR1 is not mounted
  1332. noexec.
  1333. EOF
  1334. die "Sanity test failed."
  1335. fi
  1336. rm $TMPSH
  1337. # compiler sanity check
  1338. check_exec <<EOF
  1339. int main(void){ return 0; }
  1340. EOF
  1341. if test "$?" != 0; then
  1342. echo "$cc is unable to create an executable file."
  1343. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1344. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1345. echo "Only do this if you know what cross compiling means."
  1346. fi
  1347. die "C compiler test failed."
  1348. fi
  1349. check_cc <<EOF || die "Symbol mangling check failed."
  1350. int ff_extern;
  1351. EOF
  1352. sym=$($nm -P -g $TMPO)
  1353. extern_prefix=${sym%%ff_extern*}
  1354. check_asm inline_asm '""'
  1355. if enabled x86; then
  1356. # check whether EBP is available on x86
  1357. # As 'i' is stored on the stack, this program will crash
  1358. # if the base pointer is used to access it because the
  1359. # base pointer is cleared in the inline assembly code.
  1360. check_exec_crash <<EOF && enable ebp_available
  1361. volatile int i=0;
  1362. asm volatile (
  1363. "xorl %%ebp, %%ebp"
  1364. ::: "%ebp");
  1365. return i;
  1366. EOF
  1367. # check wether EBX is available on x86
  1368. check_asm ebx_available '"":::"%ebx"'
  1369. # check whether binutils is new enough to compile SSSE3/MMX2
  1370. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1371. enabled mmx2 && check_asm mmx2 '"movss %xmm0, %xmm0"'
  1372. check_asm bswap '"bswap %%eax" ::: "%eax"'
  1373. fi
  1374. # check for assembler specific support
  1375. if test $arch = "powerpc"; then
  1376. check_cc <<EOF && enable dcbzl
  1377. int main(void) {
  1378. register long zero = 0;
  1379. char data[1024];
  1380. asm volatile("dcbzl %0, %1" : : "b" (data), "r" (zero));
  1381. return 0;
  1382. }
  1383. EOF
  1384. fi
  1385. # check for SIMD availability
  1386. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1387. if enabled altivec; then
  1388. check_cflags -maltivec -mabi=altivec &&
  1389. check_header altivec.h ||
  1390. check_cflags -faltivec
  1391. # check if our compiler supports Motorola AltiVec C API
  1392. enabled altivec_h &&
  1393. inc_altivec_h="#include <altivec.h>" ||
  1394. inc_altivec_h=
  1395. check_cc <<EOF || disable altivec
  1396. $inc_altivec_h
  1397. int main(void) {
  1398. vector signed int v1, v2, v3;
  1399. v1 = vec_add(v2,v3);
  1400. return 0;
  1401. }
  1402. EOF
  1403. fi
  1404. # We have to check if pld is a nop and disable it.
  1405. enabled armv4l && check_asm pld '"pld [r0]"'
  1406. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1407. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1408. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1409. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1410. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1411. enabled vis && add_cflags "-mcpu=ultrasparc -mtune=ultrasparc"
  1412. # ---
  1413. # big/little-endian test
  1414. check_cc <<EOF || die "endian test failed"
  1415. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1416. EOF
  1417. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1418. # ---
  1419. # check availability of some header files
  1420. if check_func dlopen; then
  1421. ldl=
  1422. elif check_func dlopen -ldl; then
  1423. ldl=-ldl
  1424. fi
  1425. check_func fork
  1426. check_func gethrtime
  1427. check_func getrusage
  1428. check_func inet_aton $network_extralibs
  1429. check_func memalign
  1430. check_func mkstemp
  1431. check_func2 windows.h GetProcessTimes
  1432. check_header byteswap.h
  1433. check_header conio.h
  1434. check_header dlfcn.h
  1435. check_header malloc.h
  1436. check_header sys/mman.h
  1437. check_header termios.h
  1438. if ! enabled_any memalign memalign_hack && enabled need_memalign ; then
  1439. die "Error, no memalign() but SSE enabled, disable it or use --enable-memalign-hack."
  1440. fi
  1441. enabled zlib && check_lib zlib.h zlibVersion -lz || disable zlib
  1442. # ffserver uses poll(),
  1443. # if it's not found we can emulate it using select().
  1444. if enabled ffserver; then
  1445. check_header poll.h
  1446. check_header sys/select.h
  1447. fi
  1448. # check for some common methods of building with pthread support
  1449. # do this before the optional library checks as some of them require pthreads
  1450. if enabled pthreads; then
  1451. if check_func pthread_create; then
  1452. :
  1453. elif check_func pthread_create -pthread; then
  1454. add_cflags -pthread
  1455. add_extralibs -pthread
  1456. elif check_func pthread_create -pthreads; then
  1457. add_cflags -pthreads
  1458. add_extralibs -pthreads
  1459. elif ! check_lib pthread.h pthread_create -lpthread; then
  1460. die "ERROR: can't find pthreads library"
  1461. fi
  1462. fi
  1463. for thread in $THREADS_LIST; do
  1464. if enabled $thread; then
  1465. test -n "$thread_type" &&
  1466. die "ERROR: Only one thread type must be selected." ||
  1467. thread_type="$thread"
  1468. fi
  1469. done
  1470. check_lib math.h sin -lm
  1471. # test for C99 functions in math.h
  1472. for func in llrint lrint lrintf round roundf; do
  1473. check_exec <<EOF && enable $func || disable $func
  1474. #define _ISOC9X_SOURCE 1
  1475. #include <math.h>
  1476. int main(void) { return ($func(3.999f) > 0)?0:1; }
  1477. EOF
  1478. done
  1479. # these are off by default, so fail if requested and not available
  1480. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1481. enabled liba52 && require liba52 a52dec/a52.h a52_init -la52
  1482. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
  1483. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1484. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1485. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1486. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1487. enabled libmp3lame && require LAME lame/lame.h lame_init -lmp3lame -lm
  1488. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1489. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1490. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  1491. enabled libx264 && require x264 x264.h x264_encoder_open -lx264 -lm
  1492. enabled libxvid && require Xvid xvid.h xvid_global -lxvidcore
  1493. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1494. # disable the native AC-3 decoder if liba52 is enabled
  1495. enabled liba52 && disable ac3_decoder
  1496. # libdc1394 check
  1497. if enabled libdc1394; then
  1498. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  1499. enable libdc1394_2; } ||
  1500. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  1501. enable libdc1394_1; } ||
  1502. die "ERROR: No version of libdc1394 found "
  1503. fi
  1504. _restrict=
  1505. for restrict_keyword in restrict __restrict__ __restrict; do
  1506. check_cc <<EOF && _restrict=$restrict_keyword && break
  1507. void foo(char * $restrict_keyword p);
  1508. EOF
  1509. done
  1510. test "$vhook" = "default" && vhook="$dlopen"
  1511. if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
  1512. disable vhook
  1513. echo
  1514. echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
  1515. echo "Patches welcome."
  1516. echo
  1517. fi
  1518. if enabled vhook; then
  1519. check_ldflags -rdynamic
  1520. check_ldflags -export-dynamic
  1521. fi
  1522. check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
  1523. check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
  1524. ##########################################
  1525. # SDL check
  1526. disable sdl_too_old
  1527. disable sdl
  1528. SDL_CONFIG="${cross_prefix}sdl-config"
  1529. if "${SDL_CONFIG}" --version >/dev/null 2>&1; then
  1530. sdl_cflags=`"${SDL_CONFIG}" --cflags`
  1531. temp_cflags $sdl_cflags
  1532. temp_extralibs `"${SDL_CONFIG}" --libs`
  1533. if check_lib2 SDL.h SDL_Init; then
  1534. _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
  1535. if test "$_sdlversion" -lt 121 ; then
  1536. enable sdl_too_old
  1537. else
  1538. enable sdl
  1539. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1540. #include <SDL.h>
  1541. int main(int argc, char **argv){
  1542. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1543. int w = vi->current_w;
  1544. return 0;
  1545. }
  1546. EOF
  1547. fi
  1548. fi
  1549. restore_flags
  1550. fi
  1551. texi2html -version >/dev/null 2>&1 && enable texi2html || disable texi2html
  1552. check_type sys/socket.h socklen_t
  1553. ##########################################
  1554. # Network check
  1555. if enabled network; then
  1556. # Prefer arpa/inet.h over winsock2
  1557. if check_header arpa/inet.h ; then
  1558. check_func closesocket
  1559. elif check_header winsock2.h ; then
  1560. network_extralibs="-lws2_32"
  1561. check_type ws2tcpip.h socklen_t
  1562. check_func2 winsock2.h closesocket
  1563. fi
  1564. fi
  1565. ##########################################
  1566. # IPv6 check
  1567. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1568. #include <sys/types.h>
  1569. #include <sys/socket.h>
  1570. #include <netinet/in.h>
  1571. #include <netdb.h>
  1572. int main(void) {
  1573. struct sockaddr_storage saddr;
  1574. struct ipv6_mreq mreq6;
  1575. getaddrinfo(0,0,0,0);
  1576. getnameinfo(0,0,0,0,0,0,0);
  1577. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1578. }
  1579. EOF
  1580. check_header linux/videodev.h
  1581. check_header linux/videodev2.h
  1582. check_func2 "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  1583. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1584. { check_header dev/bktr/ioctl_meteor.h &&
  1585. check_header dev/bktr/ioctl_bt848.h; } ||
  1586. { check_header machine/ioctl_meteor.h &&
  1587. check_header machine/ioctl_bt848.h; } ||
  1588. { check_header dev/video/meteor/ioctl_meteor.h &&
  1589. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1590. check_header dev/ic/bt8xx.h
  1591. check_header sys/soundcard.h
  1592. check_header soundcard.h
  1593. # deal with the X11 frame grabber
  1594. enabled x11grab &&
  1595. check_header X11/Xlib.h &&
  1596. check_header X11/extensions/XShm.h &&
  1597. check_func XOpenDisplay -lX11 &&
  1598. check_func XShmCreateImage -lX11 -lXext
  1599. enabled debug && add_cflags -g"$debuglevel"
  1600. # add some useful compiler flags if supported
  1601. check_cflags -Wdeclaration-after-statement
  1602. check_cflags -Wall
  1603. check_cflags -Wno-switch
  1604. check_cflags -Wdisabled-optimization
  1605. check_cflags -Wpointer-arith
  1606. check_cflags -Wredundant-decls
  1607. check_cflags -Wno-pointer-sign
  1608. check_cflags -Wcast-qual
  1609. check_cflags -Wwrite-strings
  1610. check_cflags -Wtype-limits
  1611. enabled extra_warnings && check_cflags -Winline
  1612. # add some linker flags
  1613. check_ldflags -Wl,--warn-common
  1614. check_ldflags $LDLATEFLAGS
  1615. check_ldflags -Wl,-Bsymbolic
  1616. if enabled small; then
  1617. check_cflags -Os # not all compilers support -Os
  1618. optimizations="small"
  1619. elif enabled optimizations; then
  1620. if $cc -v 2>&1 | grep -q xlc; then
  1621. add_cflags "-O5"
  1622. add_ldflags "-O5"
  1623. else
  1624. add_cflags "-O3"
  1625. fi
  1626. fi
  1627. check_cflags -fno-math-errno
  1628. check_cflags -fno-signed-zeros
  1629. # PIC flags for shared library objects where they are needed
  1630. if enabled shared; then
  1631. # LIBOBJFLAGS may have already been set in the OS configuration
  1632. if test -z "$LIBOBJFLAGS" ; then
  1633. case "$arch" in
  1634. x86_64|ia64|alpha|sparc*|power*) LIBOBJFLAGS='$(PIC)' ;;
  1635. esac
  1636. fi
  1637. fi
  1638. if enabled gprof; then
  1639. add_cflags "-p"
  1640. add_ldflags "-p"
  1641. fi
  1642. VHOOKCFLAGS="-fPIC"
  1643. # Find out if the .align argument is a power of two or not.
  1644. if test $asmalign_pot = "unknown"; then
  1645. disable asmalign_pot
  1646. echo 'asm (".align 3");' | check_cc && enable asmalign_pot
  1647. fi
  1648. enabled_any $DECODER_LIST && enable decoders
  1649. enabled_any $ENCODER_LIST && enable encoders
  1650. enabled_any $BSF_LIST && enable bsfs
  1651. enabled_any $DEMUXER_LIST && enable demuxers
  1652. enabled_any $MUXER_LIST && enable muxers
  1653. enabled_any $FILTER_LIST && enable filters
  1654. enabled_any $INDEV_LIST && enable demuxers
  1655. enabled_any $OUTDEV_LIST && enable muxers
  1656. enabled_any $PROTOCOL_LIST && enable protocols
  1657. enabled_any $THREADS_LIST && enable threads
  1658. check_deps $CONFIG_LIST \
  1659. $HAVE_LIST \
  1660. $DECODER_LIST \
  1661. $ENCODER_LIST \
  1662. $PARSER_LIST \
  1663. $BSF_LIST \
  1664. $DEMUXER_LIST \
  1665. $MUXER_LIST \
  1666. $FILTER_LIST \
  1667. $INDEV_LIST \
  1668. $OUTDEV_LIST \
  1669. $PROTOCOL_LIST \
  1670. enabled libdc1394 && append pkg_requires "libraw1394"
  1671. enabled libtheora && append pkg_requires "theora"
  1672. enabled libvorbis && append pkg_requires "vorbisenc"
  1673. echo "install prefix $prefix"
  1674. echo "source path $source_path"
  1675. echo "C compiler $cc"
  1676. echo "make $make"
  1677. echo ".align is power-of-two $asmalign_pot"
  1678. echo "ARCH $arch ($cpu)"
  1679. if test "$build_suffix" != ""; then
  1680. echo "build suffix $build_suffix"
  1681. fi
  1682. echo "big-endian ${bigendian-no}"
  1683. if test $arch = "x86_32" -o $arch = "x86_64"; then
  1684. echo "MMX enabled ${mmx-no}"
  1685. echo "CMOV enabled ${cmov-no}"
  1686. echo "CMOV is fast ${fast_cmov-no}"
  1687. echo "EBX available ${ebx_available-no}"
  1688. echo "EBP available ${ebp_available-no}"
  1689. fi
  1690. if test $arch = "armv4l"; then
  1691. echo "ARMv5TE enabled ${armv5te-no}"
  1692. echo "ARMv6 enabled ${armv6-no}"
  1693. echo "IWMMXT enabled ${iwmmxt-no}"
  1694. fi
  1695. if test $arch = "mips"; then
  1696. echo "MMI enabled ${mmi-no}"
  1697. fi
  1698. if test $arch = "powerpc"; then
  1699. echo "AltiVec enabled ${altivec-no}"
  1700. echo "dcbzl available ${dcbzl-no}"
  1701. fi
  1702. echo "gprof enabled ${gprof-no}"
  1703. echo "debug symbols ${debug-no}"
  1704. echo "strip symbols ${stripping-no}"
  1705. echo "optimizations ${optimizations-no}"
  1706. echo "static ${static-no}"
  1707. echo "shared ${shared-no}"
  1708. echo "postprocessing support ${postproc-no}"
  1709. echo "software scaler enabled ${swscale-no}"
  1710. echo "new filter support ${avfilter-no}"
  1711. echo "filters using lavformat ${avfilter_lavf-no}"
  1712. echo "video hooking ${vhook-no}"
  1713. if enabled vhook; then
  1714. echo "Imlib2 support ${imlib2-no}"
  1715. echo "FreeType support ${freetype2-no}"
  1716. fi
  1717. echo "network support ${network-no}"
  1718. if enabled network; then
  1719. echo "IPv6 support ${ipv6-no}"
  1720. fi
  1721. echo "threading support ${thread_type-no}"
  1722. echo "SDL support ${sdl-no}"
  1723. if enabled sdl_too_old; then
  1724. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  1725. fi
  1726. echo "Sun medialib support ${mlib-no}"
  1727. echo "AVISynth enabled ${avisynth-no}"
  1728. echo "liba52 support ${liba52-no}"
  1729. echo "liba52 dlopened ${liba52bin-no}"
  1730. echo "libamr-nb support ${libamr_nb-no}"
  1731. echo "libamr-wb support ${libamr_wb-no}"
  1732. echo "libdc1394 support ${libdc1394-no}"
  1733. echo "libfaac enabled ${libfaac-no}"
  1734. echo "libfaad enabled ${libfaad-no}"
  1735. echo "libfaad dlopened ${libfaadbin-no}"
  1736. echo "libgsm enabled ${libgsm-no}"
  1737. echo "libmp3lame enabled ${libmp3lame-no}"
  1738. echo "libnut enabled ${libnut-no}"
  1739. echo "libtheora enabled ${libtheora-no}"
  1740. echo "libvorbis enabled ${libvorbis-no}"
  1741. echo "x264 enabled ${libx264-no}"
  1742. echo "XviD enabled ${libxvid-no}"
  1743. echo "zlib enabled ${zlib-no}"
  1744. echo
  1745. for type in decoder encoder parser demuxer muxer protocol filter bsf indev outdev; do
  1746. echo "Enabled ${type}s:"
  1747. eval list=\$$(toupper $type)_LIST
  1748. for part in $list; do
  1749. enabled $part && echo ${part%_*}
  1750. done | sort | pr -3 -t
  1751. echo
  1752. done
  1753. enabled nonfree &&
  1754. echo "License: unredistributable" ||
  1755. (enabled gpl &&
  1756. echo "License: GPL" ||
  1757. echo "License: LGPL")
  1758. echo "Creating config.mak and config.h..."
  1759. echo "# Automatically generated by configure - do not modify!" > config.mak
  1760. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  1761. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  1762. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  1763. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  1764. echo "PREFIX=$prefix" >> config.mak
  1765. echo "prefix=\$(DESTDIR)\$(PREFIX)" >> config.mak
  1766. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  1767. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  1768. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  1769. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  1770. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  1771. echo "MAKE=$make" >> config.mak
  1772. echo "CC=$cc" >> config.mak
  1773. echo "AR=$ar" >> config.mak
  1774. echo "RANLIB=$ranlib" >> config.mak
  1775. echo "LN_S=$ln_s" >> config.mak
  1776. enabled stripping &&
  1777. echo "STRIP=$strip" >> config.mak ||
  1778. echo "STRIP=echo ignoring strip" >> config.mak
  1779. echo "OPTFLAGS=$CFLAGS" >> config.mak
  1780. echo "VHOOKCFLAGS=$VHOOKCFLAGS">>config.mak
  1781. echo "LDFLAGS=$LDFLAGS" >> config.mak
  1782. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  1783. echo "SHFLAGS=$SHFLAGS" >> config.mak
  1784. echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
  1785. echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
  1786. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  1787. echo "BUILD_STATIC=$static" >> config.mak
  1788. echo "BUILDSUF=$build_suffix" >> config.mak
  1789. echo "FULLNAME=$FULLNAME" >> config.mak
  1790. echo "LIBPREF=$LIBPREF" >> config.mak
  1791. echo "LIBSUF=$LIBSUF" >> config.mak
  1792. echo "LIBNAME=$LIBNAME" >> config.mak
  1793. echo "SLIBPREF=$SLIBPREF" >> config.mak
  1794. echo "SLIBSUF=$SLIBSUF" >> config.mak
  1795. echo "EXESUF=$EXESUF" >> config.mak
  1796. echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
  1797. echo "VHOOK_DEPEND_CMD=$VHOOK_DEPEND_CMD" >> config.mak
  1798. if enabled bigendian; then
  1799. echo "WORDS_BIGENDIAN=yes" >> config.mak
  1800. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  1801. fi
  1802. if enabled sdl; then
  1803. echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
  1804. echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
  1805. fi
  1806. if enabled texi2html; then
  1807. echo "BUILD_DOC=yes" >> config.mak
  1808. fi
  1809. get_version(){
  1810. name=$1
  1811. file=$source_path/$2
  1812. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  1813. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  1814. lcname=$(tolower $name)
  1815. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  1816. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  1817. }
  1818. get_version LIBSWSCALE libswscale/swscale.h
  1819. get_version LIBPOSTPROC libpostproc/postprocess.h
  1820. get_version LIBAVCODEC libavcodec/avcodec.h
  1821. get_version LIBAVDEVICE libavdevice/avdevice.h
  1822. get_version LIBAVFORMAT libavformat/avformat.h
  1823. get_version LIBAVUTIL libavutil/avutil.h
  1824. get_version LIBAVFILTER libavfilter/avfilter.h
  1825. if enabled shared; then
  1826. echo "BUILD_SHARED=yes" >> config.mak
  1827. echo "PIC=-fPIC -DPIC" >> config.mak
  1828. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  1829. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  1830. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  1831. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  1832. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  1833. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  1834. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  1835. fi
  1836. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  1837. echo "EXTRALIBS=$extralibs" >> config.mak
  1838. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  1839. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  1840. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  1841. $DECODER_LIST \
  1842. $ENCODER_LIST \
  1843. $PARSER_LIST \
  1844. $BSF_LIST \
  1845. $DEMUXER_LIST \
  1846. $MUXER_LIST \
  1847. $FILTER_LIST \
  1848. $PROTOCOL_LIST \
  1849. $INDEV_LIST \
  1850. $OUTDEV_LIST \
  1851. echo "#define restrict $_restrict" >> $TMPH
  1852. if enabled small; then
  1853. echo "#define av_always_inline" >> $TMPH
  1854. fi
  1855. echo "SRC_PATH=\"$source_path\"" >> config.mak
  1856. echo "SRC_PATH_BARE=$source_path" >> config.mak
  1857. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  1858. # Apparently it's not possible to portably echo a backslash.
  1859. enabled asmalign_pot &&
  1860. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  1861. printf '#define ASMALIGN(ZEROBITS) ".align 1<<" #ZEROBITS "\\n\\t"\n' >> $TMPH
  1862. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  1863. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  1864. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  1865. cmp -s $TMPH config.h &&
  1866. echo "config.h is unchanged" ||
  1867. mv -f $TMPH config.h
  1868. rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
  1869. # build tree in object directory if source path is different from current one
  1870. if enabled source_path_used; then
  1871. DIRS="\
  1872. doc \
  1873. libavcodec \
  1874. libavcodec/alpha \
  1875. libavcodec/armv4l \
  1876. libavcodec/bfin \
  1877. libavcodec/i386 \
  1878. libavcodec/mlib \
  1879. libavcodec/ppc \
  1880. libavcodec/sh4 \
  1881. libavcodec/sparc \
  1882. libavdevice \
  1883. libavfilter \
  1884. libavformat \
  1885. libavutil \
  1886. libpostproc \
  1887. libswscale \
  1888. tests \
  1889. tools \
  1890. vhook \
  1891. "
  1892. FILES="\
  1893. Makefile \
  1894. common.mak \
  1895. doc/texi2pod.pl \
  1896. libavcodec/Makefile \
  1897. libavdevice/Makefile \
  1898. libavfilter/Makefile \
  1899. libavformat/Makefile \
  1900. libavutil/Makefile \
  1901. libpostproc/Makefile \
  1902. libswscale/Makefile \
  1903. "
  1904. for dir in $DIRS ; do
  1905. mkdir -p $dir
  1906. done
  1907. for f in $FILES ; do
  1908. $ln_s "$source_path/$f" $f
  1909. done
  1910. fi
  1911. # build pkg-config files
  1912. # FIXME: libdir and includedir are hardcoded and may differ from the real path.
  1913. pkgconfig_generate(){
  1914. name=$1
  1915. comment=$2
  1916. version=$3
  1917. libs=$4
  1918. requires=$5
  1919. cat <<EOF >$name.pc
  1920. prefix=$prefix
  1921. exec_prefix=\${prefix}
  1922. libdir=\${exec_prefix}/lib
  1923. includedir=\${prefix}/include
  1924. Name: $name
  1925. Description: $comment
  1926. Version: $version
  1927. Requires: $requires
  1928. Conflicts:
  1929. Libs: -L\${libdir} $libs
  1930. Cflags: -I\${includedir}
  1931. EOF
  1932. }
  1933. pkgconfig_generate_uninstalled(){
  1934. name=$1
  1935. shortname=${name#lib}
  1936. comment=$2
  1937. version=$3
  1938. libs=$4
  1939. requires=$5
  1940. cat <<EOF >$name-uninstalled.pc
  1941. prefix=
  1942. exec_prefix=
  1943. libdir=\${pcfiledir}/$name
  1944. includedir=\${pcfiledir}
  1945. Name: $name
  1946. Description: $comment
  1947. Version: $version
  1948. Requires: $requires
  1949. Conflicts:
  1950. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  1951. Cflags: -I\${includedir}
  1952. EOF
  1953. }
  1954. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" -lavutil ""
  1955. pkgconfig_generate_uninstalled libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  1956. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "-lavcodec $extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  1957. pkgconfig_generate_uninstalled libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  1958. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "-lavformat $extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  1959. pkgconfig_generate_uninstalled libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  1960. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "-lavdevice $extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
  1961. pkgconfig_generate_uninstalled libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "$pkg_requires libavformat = $LIBAVFORMAT_VERSION"
  1962. if enabled postproc; then
  1963. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION" -lpostproc ""
  1964. pkgconfig_generate_uninstalled libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  1965. fi
  1966. if enabled swscale; then
  1967. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" -lswscale "libavutil = $LIBAVUTIL_VERSION"
  1968. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  1969. else
  1970. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  1971. pkgconfig_generate_uninstalled libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "$pkg_requires libavcodec = $LIBAVCODEC_VERSION"
  1972. apply libswscale.pc sed s/^Libs:.*$/Libs:/
  1973. apply libswscale-uninstalled.pc sed s/^Libs:.*$/Libs:/
  1974. fi
  1975. if enabled avfilter; then
  1976. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "-lavfilter $extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION" ffmpeg
  1977. pkgconfig_generate_uninstalled libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "$pkg_requires libavutil = $LIBAVUTIL_VERSION"
  1978. fi