configure 62 KB

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