You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2648 lines
76KB

  1. #!/bin/sh
  2. #
  3. # FFmpeg configure script
  4. #
  5. # Copyright (c) 2000-2002 Fabrice Bellard
  6. # Copyright (c) 2005-2008 Diego Biurrun
  7. # Copyright (c) 2005-2008 Mans Rullgard
  8. #
  9. # Prevent locale nonsense from breaking basic text processing.
  10. LC_ALL=C
  11. export LC_ALL
  12. # make sure we are running under a compatible shell
  13. # try to make this part work with most shells
  14. try_exec(){
  15. echo "Trying shell $1"
  16. type "$1" > /dev/null 2>&1 && exec "$@"
  17. }
  18. unset foo
  19. (: ${foo%%bar}) 2> /dev/null
  20. E1="$?"
  21. (: ${foo?}) 2> /dev/null
  22. E2="$?"
  23. if test "$E1" != 0 || test "$E2" = 0; then
  24. echo "Broken shell detected. Trying alternatives."
  25. export FF_CONF_EXEC
  26. if test "0$FF_CONF_EXEC" -lt 1; then
  27. FF_CONF_EXEC=1
  28. try_exec bash "$0" "$@"
  29. fi
  30. if test "0$FF_CONF_EXEC" -lt 2; then
  31. FF_CONF_EXEC=2
  32. try_exec ksh "$0" "$@"
  33. fi
  34. if test "0$FF_CONF_EXEC" -lt 3; then
  35. FF_CONF_EXEC=3
  36. try_exec /usr/xpg4/bin/sh "$0" "$@"
  37. fi
  38. echo "No compatible shell script interpreter found."
  39. echo "This configure script requires a POSIX-compatible shell"
  40. echo "such as bash or ksh."
  41. echo "THIS IS NOT A BUG IN FFMPEG, DO NOT REPORT IT AS SUCH."
  42. echo "Instead, install a working POSIX-compatible shell."
  43. echo "Disabling this configure test will create a broken FFmpeg."
  44. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  45. echo "This bash version ($BASH_VERSION) is broken on your platform."
  46. echo "Upgrade to a later version if available."
  47. fi
  48. exit 1
  49. fi
  50. show_help(){
  51. echo "Usage: configure [options]"
  52. echo "Options: [defaults in brackets after descriptions]"
  53. echo
  54. echo "Standard options:"
  55. echo " --help print this message"
  56. echo " --logfile=FILE log tests and output to FILE [config.err]"
  57. echo " --disable-logging do not log configure debug information"
  58. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  59. echo " --bindir=DIR install binaries in DIR [PREFIX/bin]"
  60. echo " --datadir=DIR install data files in DIR [PREFIX/share/ffmpeg]"
  61. echo " --libdir=DIR install libs in DIR [PREFIX/lib]"
  62. echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]"
  63. echo " --incdir=DIR install includes in DIR [PREFIX/include]"
  64. echo " --mandir=DIR install man page in DIR [PREFIX/share/man]"
  65. echo
  66. echo "Configuration options:"
  67. echo " --disable-static do not build static libraries [no]"
  68. echo " --enable-shared build shared libraries [no]"
  69. echo " --enable-gpl allow use of GPL code, the resulting libs"
  70. echo " and binaries will be under GPL [no]"
  71. echo " --enable-version3 upgrade (L)GPL to version 3 [no]"
  72. echo " --enable-nonfree allow use of nonfree code, the resulting libs"
  73. echo " and binaries will be unredistributable [no]"
  74. echo " --disable-ffmpeg disable ffmpeg build"
  75. echo " --disable-ffplay disable ffplay build"
  76. echo " --disable-ffserver disable ffserver build"
  77. echo " --enable-postproc enable GPLed postprocessing support [no]"
  78. echo " --enable-avfilter video filter support [no]"
  79. echo " --enable-avfilter-lavf video filters dependent on avformat [no]"
  80. echo " --enable-beosthreads use BeOS threads [no]"
  81. echo " --enable-os2threads use OS/2 threads [no]"
  82. echo " --enable-pthreads use pthreads [no]"
  83. echo " --enable-w32threads use Win32 threads [no]"
  84. echo " --enable-x11grab enable X11 grabbing [no]"
  85. echo " --disable-network disable network support [no]"
  86. echo " --disable-ipv6 disable IPv6 support [no]"
  87. echo " --disable-mpegaudio-hp faster (but less accurate) MPEG audio decoding [no]"
  88. echo " --enable-gray enable full grayscale support (slower color)"
  89. echo " --disable-swscale-alpha disable alpha channel support in swscale"
  90. echo " --disable-fastdiv disable table-based division"
  91. echo " --enable-small optimize for size instead of speed"
  92. echo " --disable-aandct disable AAN DCT code"
  93. echo " --disable-fft disable FFT code"
  94. echo " --disable-golomb disable Golomb code"
  95. echo " --disable-mdct disable MDCT code"
  96. echo " --disable-rdft disable RDFT code"
  97. echo " --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)"
  98. echo " --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
  99. echo " --enable-memalign-hack emulate memalign, interferes with memory debuggers"
  100. echo " --enable-beos-netserver enable BeOS netserver"
  101. echo " --disable-encoder=NAME disable encoder NAME"
  102. echo " --enable-encoder=NAME enable encoder NAME"
  103. echo " --disable-encoders disable all encoders"
  104. echo " --disable-decoder=NAME disable decoder NAME"
  105. echo " --enable-decoder=NAME enable decoder NAME"
  106. echo " --disable-decoders disable all decoders"
  107. echo " --disable-hwaccel=NAME disable hwaccel NAME"
  108. echo " --enable-hwaccel=NAME enable hwaccel NAME"
  109. echo " --disable-hwaccels disable all hwaccels"
  110. echo " --disable-muxer=NAME disable muxer NAME"
  111. echo " --enable-muxer=NAME enable muxer NAME"
  112. echo " --disable-muxers disable all muxers"
  113. echo " --disable-demuxer=NAME disable demuxer NAME"
  114. echo " --enable-demuxer=NAME enable demuxer NAME"
  115. echo " --disable-demuxers disable all demuxers"
  116. echo " --enable-parser=NAME enable parser NAME"
  117. echo " --disable-parser=NAME disable parser NAME"
  118. echo " --disable-parsers disable all parsers"
  119. echo " --enable-bsf=NAME enable bitstream filter NAME"
  120. echo " --disable-bsf=NAME disable bitstream filter NAME"
  121. echo " --disable-bsfs disable all bitstream filters"
  122. echo " --enable-protocol=NAME enable protocol NAME"
  123. echo " --disable-protocol=NAME disable protocol NAME"
  124. echo " --disable-protocols disable all protocols"
  125. echo " --disable-indevs disable input devices"
  126. echo " --disable-outdevs disable output devices"
  127. echo " --disable-devices disable all devices"
  128. echo " --enable-filter=NAME enable filter NAME"
  129. echo " --disable-filter=NAME disable filter NAME"
  130. echo " --disable-filters disable all filters"
  131. echo " --list-decoders show all available decoders"
  132. echo " --list-encoders show all available encoders"
  133. echo " --list-hwaccels show all available hardware accelerators"
  134. echo " --list-muxers show all available muxers"
  135. echo " --list-demuxers show all available demuxers"
  136. echo " --list-parsers show all available parsers"
  137. echo " --list-protocols show all available protocols"
  138. echo " --list-bsfs show all available bitstream filters"
  139. echo " --list-indevs show all available input devices"
  140. echo " --list-outdevs show all available output devices"
  141. echo " --list-filters show all available filters"
  142. echo
  143. echo "External library support:"
  144. echo " --enable-avisynth enable reading of AVISynth script files [no]"
  145. echo " --enable-bzlib enable bzlib [autodetect]"
  146. echo " --enable-libamr-nb enable libamr-nb floating point audio codec [no]"
  147. echo " --enable-libamr-wb enable libamr-wb floating point audio codec [no]"
  148. echo " --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394"
  149. echo " and libraw1394 [no]"
  150. echo " --enable-libdirac enable Dirac support via libdirac [no]"
  151. echo " --enable-libfaac enable FAAC support via libfaac [no]"
  152. echo " --enable-libfaad enable FAAD support via libfaad [no]"
  153. echo " --enable-libfaadbin open libfaad.so.0 at runtime [no]"
  154. echo " --enable-libgsm enable GSM support via libgsm [no]"
  155. echo " --enable-libmp3lame enable MP3 encoding via libmp3lame [no]"
  156. echo " --enable-libnut enable NUT (de)muxing via libnut,"
  157. echo " native (de)muxer exists [no]"
  158. echo " --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]"
  159. echo " --enable-libschroedinger enable Dirac support via libschroedinger [no]"
  160. echo " --enable-libspeex enable Speex decoding via libspeex [no]"
  161. echo " --enable-libtheora enable Theora encoding via libtheora [no]"
  162. echo " --enable-libvorbis enable Vorbis encoding via libvorbis,"
  163. echo " native implementation exists [no]"
  164. echo " --enable-libx264 enable H.264 encoding via x264 [no]"
  165. echo " --enable-libxvid enable Xvid encoding via xvidcore,"
  166. echo " native MPEG-4/Xvid encoder exists [no]"
  167. echo " --enable-mlib enable Sun medialib [no]"
  168. echo " --enable-zlib enable zlib [autodetect]"
  169. echo ""
  170. echo "Advanced options (experts only):"
  171. echo " --source-path=PATH path to source code [$source_path]"
  172. echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
  173. echo " --enable-cross-compile assume a cross-compiler is used"
  174. echo " --sysroot=PATH root of cross-build tree"
  175. echo " --sysinclude=PATH location of cross-build system headers"
  176. echo " --target-os=OS compiler targets OS [$target_os]"
  177. echo " --target-exec=CMD command to run executables on target"
  178. echo " --target-path=DIR path to view of build directory on target"
  179. echo " --nm=NM use nm tool"
  180. echo " --as=AS use assembler AS [$as_default]"
  181. echo " --cc=CC use C compiler CC [$cc_default]"
  182. echo " --host-cc=HOSTCC use host C compiler HOSTCC"
  183. echo " --host-cflags=HCFLAGS use HCFLAGS when compiling for host"
  184. echo " --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host"
  185. echo " --host-libs=HLIBS use libs HLIBS when linking for host"
  186. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  187. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  188. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  189. echo " --extra-version=STRING version string suffix []"
  190. echo " --build-suffix=SUFFIX library name suffix []"
  191. echo " --arch=ARCH select architecture [$arch]"
  192. echo " --cpu=CPU select the minimum required CPU (affects"
  193. echo " instruction selection, may crash on older CPUs)"
  194. echo " --enable-powerpc-perf enable performance report on PPC"
  195. echo " (requires enabling PMC)"
  196. echo " --disable-altivec disable AltiVec optimizations"
  197. echo " --disable-amd3dnow disable 3DNow! optimizations"
  198. echo " --disable-amd3dnowext disable 3DNow! extended optimizations"
  199. echo " --disable-mmx disable MMX optimizations"
  200. echo " --disable-mmx2 disable MMX2 optimizations"
  201. echo " --disable-sse disable SSE optimizations"
  202. echo " --disable-ssse3 disable SSSE3 optimizations"
  203. echo " --disable-armv5te disable armv5te optimizations"
  204. echo " --disable-armv6 disable armv6 optimizations"
  205. echo " --disable-armv6t2 disable armv6t2 optimizations"
  206. echo " --disable-armvfp disable ARM VFP optimizations"
  207. echo " --disable-iwmmxt disable iwmmxt optimizations"
  208. echo " --disable-mmi disable MMI optimizations"
  209. echo " --disable-neon disable neon optimizations"
  210. echo " --disable-vis disable VIS optimizations"
  211. echo " --disable-yasm disable use of yasm assembler"
  212. echo
  213. echo "Developer options (useful when working on FFmpeg itself):"
  214. echo " --disable-debug disable debugging symbols"
  215. echo " --enable-debug=LEVEL set the debug level [$debuglevel]"
  216. echo " --enable-gprof enable profiling with gprof [$gprof]"
  217. echo " --disable-optimizations disable compiler optimizations"
  218. echo " --enable-extra-warnings enable more compiler warnings"
  219. echo " --disable-stripping disable stripping of executables and shared libraries"
  220. echo ""
  221. echo "NOTE: Object files are built at the place where configure is launched."
  222. exit 0
  223. }
  224. log(){
  225. echo "$@" >> $logfile
  226. }
  227. log_file(){
  228. log BEGIN $1
  229. pr -n -t $1 >> $logfile
  230. log END $1
  231. }
  232. echolog(){
  233. log "$@"
  234. echo "$@"
  235. }
  236. die(){
  237. echolog "$@"
  238. cat <<EOF
  239. If you think configure made a mistake, make sure you are using the latest
  240. version from SVN. If the latest version fails, report the problem to the
  241. ffmpeg-user@mplayerhq.hu mailing list or IRC #ffmpeg on irc.freenode.net.
  242. EOF
  243. if disabled logging; then
  244. cat <<EOF
  245. Rerun configure with logging enabled (do not use --disable-logging), and
  246. include the log this produces with your report.
  247. EOF
  248. else
  249. cat <<EOF
  250. Include the log file "$logfile" produced by configure as this will help
  251. solving the problem.
  252. EOF
  253. fi
  254. exit 1
  255. }
  256. # Avoid locale weirdness, besides we really just want to translate ASCII.
  257. toupper(){
  258. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  259. }
  260. tolower(){
  261. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  262. }
  263. c_escape(){
  264. echo "$*" | sed 's/["\\]/\\\0/g'
  265. }
  266. set_all(){
  267. value=$1
  268. shift
  269. for var in $*; do
  270. eval $var=$value
  271. done
  272. }
  273. set_weak(){
  274. value=$1
  275. shift
  276. for var; do
  277. eval : \${$var:=$value}
  278. done
  279. }
  280. pushvar(){
  281. for var in $*; do
  282. eval level=\${${var}_level:=0}
  283. eval ${var}_${level}="\$$var"
  284. eval ${var}_level=$(($level+1))
  285. done
  286. }
  287. popvar(){
  288. for var in $*; do
  289. eval level=\${${var}_level:-0}
  290. test $level = 0 && continue
  291. eval level=$(($level-1))
  292. eval $var="\${${var}_${level}}"
  293. eval ${var}_level=$level
  294. eval unset ${var}_${level}
  295. done
  296. }
  297. enable(){
  298. set_all yes $*
  299. }
  300. disable(){
  301. set_all no $*
  302. }
  303. enable_weak(){
  304. set_weak yes $*
  305. }
  306. disable_weak(){
  307. set_weak no $*
  308. }
  309. enable_safe(){
  310. enable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
  311. }
  312. disable_safe(){
  313. disable $(echo "$*" | sed 's/[^A-Za-z0-9_ ]/_/g')
  314. }
  315. do_enable_deep(){
  316. for var; do
  317. enabled $var && continue
  318. eval sel="\$${var}_select"
  319. eval sgs="\$${var}_suggest"
  320. pushvar var sgs
  321. enable_deep $sel
  322. popvar sgs
  323. enable_deep_weak $sgs
  324. popvar var
  325. done
  326. }
  327. enable_deep(){
  328. do_enable_deep $*
  329. enable $*
  330. }
  331. enable_deep_weak(){
  332. do_enable_deep $*
  333. enable_weak $*
  334. }
  335. enabled(){
  336. test "${1#!}" = "$1" && op== || op=!=
  337. eval test "x\$${1#!}" $op "xyes"
  338. }
  339. disabled(){
  340. test "${1#!}" = "$1" && op== || op=!=
  341. eval test "x\$${1#!}" $op "xno"
  342. }
  343. enabled_all(){
  344. for opt; do
  345. enabled $opt || return 1
  346. done
  347. }
  348. disabled_all(){
  349. for opt; do
  350. disabled $opt || return 1
  351. done
  352. }
  353. enabled_any(){
  354. for opt; do
  355. enabled $opt && return 0
  356. done
  357. }
  358. disabled_any(){
  359. for opt; do
  360. disabled $opt && return 0
  361. done
  362. return 1
  363. }
  364. set_default(){
  365. for opt; do
  366. eval : \${$opt:=\$${opt}_default}
  367. done
  368. }
  369. is_in(){
  370. value=$1
  371. shift
  372. for var in $*; do
  373. [ $var = $value ] && return 0
  374. done
  375. return 1
  376. }
  377. check_deps(){
  378. for cfg; do
  379. cfg="${cfg#!}"
  380. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  381. disabled ${cfg}_checking && continue
  382. enable ${cfg}_checking
  383. eval dep_all="\$${cfg}_deps"
  384. eval dep_any="\$${cfg}_deps_any"
  385. eval dep_sel="\$${cfg}_select"
  386. eval dep_sgs="\$${cfg}_suggest"
  387. pushvar cfg dep_all dep_any dep_sel dep_sgs
  388. check_deps $dep_all $dep_any $dep_sel $dep_sgs
  389. popvar cfg dep_all dep_any dep_sel dep_sgs
  390. enabled_all $dep_all || disable $cfg
  391. enabled_any $dep_any || disable $cfg
  392. disabled_any $dep_sel && disable $cfg
  393. if enabled $cfg; then
  394. eval dep_extralibs="\$${cfg}_extralibs"
  395. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  396. enable_deep $dep_sel
  397. enable_deep_weak $dep_sgs
  398. fi
  399. disable ${cfg}_checking
  400. done
  401. }
  402. print_config(){
  403. pfx=$1
  404. header=$2
  405. makefile=$3
  406. shift 3
  407. for cfg; do
  408. ucname="$(toupper $cfg)"
  409. if enabled $cfg; then
  410. echo "#define ${pfx}${ucname} 1" >> $header
  411. echo "${pfx}${ucname}=yes" >> $makefile
  412. else
  413. echo "#define ${pfx}${ucname} 0" >> $header
  414. fi
  415. done
  416. }
  417. flags_saved(){
  418. (: ${SAVE_CFLAGS?}) 2> /dev/null
  419. }
  420. save_flags(){
  421. flags_saved && return
  422. SAVE_CFLAGS="$CFLAGS"
  423. SAVE_LDFLAGS="$LDFLAGS"
  424. SAVE_extralibs="$extralibs"
  425. }
  426. restore_flags(){
  427. flags_saved || return
  428. CFLAGS="$SAVE_CFLAGS"
  429. LDFLAGS="$SAVE_LDFLAGS"
  430. extralibs="$SAVE_extralibs"
  431. unset SAVE_CFLAGS
  432. unset SAVE_LDFLAGS
  433. unset SAVE_extralibs
  434. }
  435. temp_cflags(){
  436. save_flags
  437. CFLAGS="$CFLAGS $*"
  438. }
  439. temp_ldflags(){
  440. save_flags
  441. LDFLAGS="$LDFLAGS $*"
  442. }
  443. temp_extralibs(){
  444. save_flags
  445. extralibs="$extralibs $*"
  446. }
  447. append(){
  448. var=$1
  449. shift
  450. flags_saved && eval "SAVE_$var=\"\$SAVE_$var $*\""
  451. eval "$var=\"\$$var $*\""
  452. }
  453. add_cflags(){
  454. append CFLAGS "$@"
  455. }
  456. add_ldflags(){
  457. append LDFLAGS "$@"
  458. }
  459. add_extralibs(){
  460. append extralibs "$@"
  461. }
  462. check_cmd(){
  463. log "$@"
  464. "$@" >> $logfile 2>&1
  465. }
  466. check_cc(){
  467. log check_cc "$@"
  468. cat > $TMPC
  469. log_file $TMPC
  470. check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
  471. }
  472. check_cpp(){
  473. log check_cpp "$@"
  474. cat > $TMPC
  475. log_file $TMPC
  476. check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
  477. }
  478. check_as(){
  479. log check_as "$@"
  480. cat > $TMPC
  481. log_file $TMPC
  482. check_cmd $as $CFLAGS "$@" -c -o $TMPO $TMPC
  483. }
  484. check_asm(){
  485. log check_asm "$@"
  486. name="$1"
  487. asm="$2"
  488. shift 2
  489. check_as "$@" <<EOF && enable $name || disable $name
  490. void foo(void){ __asm__ volatile($asm); }
  491. EOF
  492. }
  493. check_yasm(){
  494. log check_yasm "$@"
  495. echo "$1" > $TMPS
  496. log_file $TMPS
  497. shift 1
  498. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  499. }
  500. check_ld(){
  501. log check_ld "$@"
  502. check_cc || return
  503. flags=''
  504. libs=''
  505. for f; do
  506. test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
  507. done
  508. check_cmd $cc $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
  509. }
  510. check_cflags(){
  511. log check_cflags "$@"
  512. check_cc "$@" <<EOF && add_cflags "$@"
  513. int x;
  514. EOF
  515. }
  516. check_ldflags(){
  517. log check_ldflags "$@"
  518. check_ld "$@" <<EOF && add_ldflags "$@"
  519. int main(void){ return 0; }
  520. EOF
  521. }
  522. check_header(){
  523. log check_header "$@"
  524. header=$1
  525. shift
  526. disable_safe $header
  527. check_cpp "$@" <<EOF && enable_safe $header
  528. #include <$header>
  529. int x;
  530. EOF
  531. }
  532. check_func(){
  533. log check_func "$@"
  534. func=$1
  535. shift
  536. disable $func
  537. check_ld "$@" <<EOF && enable $func
  538. extern int $func();
  539. int main(void){ $func(); }
  540. EOF
  541. }
  542. check_func_headers(){
  543. log check_func_headers "$@"
  544. headers=$1
  545. func=$2
  546. shift 2
  547. disable $func
  548. incs=""
  549. for hdr in $headers; do
  550. incs="$incs
  551. #include <$hdr>"
  552. done
  553. check_ld "$@" <<EOF && enable $func && enable_safe $headers
  554. $incs
  555. int main(int argc, char **argv){
  556. (void) $func;
  557. return 0;
  558. }
  559. EOF
  560. }
  561. check_cpp_condition(){
  562. log check_cpp_condition "$@"
  563. header=$1
  564. condition=$2
  565. check_cpp <<EOF
  566. #include <$header>
  567. #if !($condition)
  568. #error "unsatisfied condition: $condition"
  569. #endif
  570. EOF
  571. }
  572. check_lib(){
  573. log check_lib "$@"
  574. header="$1"
  575. func="$2"
  576. shift 2
  577. temp_extralibs "$@"
  578. check_header $header && check_func $func && add_extralibs "$@"
  579. err=$?
  580. restore_flags
  581. return $err
  582. }
  583. check_lib2(){
  584. log check_lib2 "$@"
  585. headers="$1"
  586. func="$2"
  587. shift 2
  588. temp_extralibs "$@"
  589. check_func_headers "$headers" $func && add_extralibs "$@"
  590. err=$?
  591. restore_flags
  592. return $err
  593. }
  594. check_exec(){
  595. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  596. }
  597. check_exec_crash(){
  598. code=$(cat)
  599. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  600. # are safe but may not be available everywhere. Thus we use
  601. # raise(SIGTERM) instead. The check is run in a subshell so we
  602. # can redirect the "Terminated" message from the shell. SIGBUS
  603. # is not defined by standard C so it is used conditionally.
  604. (check_exec "$@") >> $logfile 2>&1 <<EOF
  605. #include <signal.h>
  606. static void sighandler(int sig){
  607. raise(SIGTERM);
  608. }
  609. int main(void){
  610. signal(SIGILL, sighandler);
  611. signal(SIGFPE, sighandler);
  612. signal(SIGSEGV, sighandler);
  613. #ifdef SIGBUS
  614. signal(SIGBUS, sighandler);
  615. #endif
  616. { $code }
  617. }
  618. EOF
  619. }
  620. check_type(){
  621. log check_type "$@"
  622. headers=$1
  623. type=$2
  624. shift 2
  625. disable $type
  626. incs=""
  627. for hdr in $headers; do
  628. incs="$incs
  629. #include <$hdr>"
  630. done
  631. check_cc "$@" <<EOF && enable $type
  632. $incs
  633. $type v;
  634. EOF
  635. }
  636. require(){
  637. name="$1"
  638. header="$2"
  639. func="$3"
  640. shift 3
  641. check_lib $header $func "$@" || die "ERROR: $name not found"
  642. }
  643. require2(){
  644. name="$1"
  645. headers="$2"
  646. func="$3"
  647. shift 3
  648. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  649. }
  650. check_foo_config(){
  651. cfg=$1
  652. pkg=$2
  653. header=$3
  654. func=$4
  655. shift 4
  656. disable $cfg
  657. check_cmd ${pkg}-config --version
  658. err=$?
  659. if test "$err" = 0; then
  660. temp_cflags $(${pkg}-config --cflags)
  661. temp_extralibs $(${pkg}-config --libs)
  662. check_lib "$@" $header $func && enable $cfg
  663. fi
  664. return $err
  665. }
  666. apply(){
  667. file=$1
  668. shift
  669. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  670. }
  671. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  672. # system-dependent things.
  673. COMPONENT_LIST="
  674. bsfs
  675. decoders
  676. demuxers
  677. encoders
  678. filters
  679. hwaccels
  680. indevs
  681. muxers
  682. outdevs
  683. parsers
  684. protocols
  685. "
  686. CONFIG_LIST="
  687. $COMPONENT_LIST
  688. aandct
  689. avfilter
  690. avfilter_lavf
  691. avisynth
  692. beos_netserver
  693. bzlib
  694. fastdiv
  695. ffmpeg
  696. ffplay
  697. ffserver
  698. fft
  699. golomb
  700. gpl
  701. gprof
  702. gray
  703. hardcoded_tables
  704. ipv6
  705. libamr_nb
  706. libamr_wb
  707. libdc1394
  708. libdirac
  709. libfaac
  710. libfaad
  711. libfaadbin
  712. libgsm
  713. libmp3lame
  714. libnut
  715. libopenjpeg
  716. libschroedinger
  717. libspeex
  718. libtheora
  719. libvorbis
  720. libx264
  721. libxvid
  722. mdct
  723. memalign_hack
  724. mlib
  725. mpegaudio_hp
  726. network
  727. nonfree
  728. postproc
  729. powerpc_perf
  730. rdft
  731. runtime_cpudetect
  732. shared
  733. small
  734. static
  735. swscale_alpha
  736. version3
  737. x11grab
  738. zlib
  739. "
  740. THREADS_LIST='
  741. beosthreads
  742. os2threads
  743. pthreads
  744. w32threads
  745. '
  746. ARCH_LIST='
  747. alpha
  748. arm
  749. bfin
  750. ia64
  751. m68k
  752. mips
  753. mips64
  754. parisc
  755. ppc
  756. ppc64
  757. s390
  758. sh4
  759. sparc
  760. sparc64
  761. x86
  762. x86_32
  763. x86_64
  764. '
  765. ARCH_EXT_LIST='
  766. altivec
  767. amd3dnow
  768. amd3dnowext
  769. armv5te
  770. armv6
  771. armv6t2
  772. armvfp
  773. iwmmxt
  774. mmi
  775. mmx
  776. mmx2
  777. neon
  778. ppc4xx
  779. sse
  780. ssse3
  781. vis
  782. '
  783. HAVE_LIST="
  784. $ARCH_EXT_LIST
  785. $THREADS_LIST
  786. alsa_asoundlib_h
  787. altivec_h
  788. arpa_inet_h
  789. bigendian
  790. bswap
  791. closesocket
  792. cmov
  793. conio_h
  794. dcbzl
  795. dev_bktr_ioctl_bt848_h
  796. dev_bktr_ioctl_meteor_h
  797. dev_ic_bt8xx_h
  798. dev_video_meteor_ioctl_meteor_h
  799. dev_video_bktr_ioctl_bt848_h
  800. dlfcn_h
  801. dlopen
  802. dos_paths
  803. ebp_available
  804. ebx_available
  805. fast_64bit
  806. fast_cmov
  807. fast_unaligned
  808. fork
  809. gethrtime
  810. GetProcessTimes
  811. getrusage
  812. inet_aton
  813. inline_asm
  814. ldbrx
  815. libdc1394_1
  816. libdc1394_2
  817. llrint
  818. loongson
  819. lrint
  820. lrintf
  821. lzo1x_999_compress
  822. machine_ioctl_bt848_h
  823. machine_ioctl_meteor_h
  824. malloc_h
  825. memalign
  826. mkstemp
  827. pld
  828. posix_memalign
  829. round
  830. roundf
  831. sdl
  832. sdl_video_size
  833. setmode
  834. socklen_t
  835. soundcard_h
  836. poll_h
  837. sys_mman_h
  838. sys_resource_h
  839. sys_select_h
  840. sys_soundcard_h
  841. sys_videoio_h
  842. ten_operands
  843. termios_h
  844. threads
  845. truncf
  846. VirtualAlloc
  847. winsock2_h
  848. xform_asm
  849. yasm
  850. "
  851. # options emitted with CONFIG_ prefix but not available on command line
  852. CONFIG_EXTRA="
  853. gplv3
  854. lgplv3
  855. "
  856. CMDLINE_SELECT="
  857. $ARCH_EXT_LIST
  858. $CONFIG_LIST
  859. $THREADS_LIST
  860. cross_compile
  861. debug
  862. extra_warnings
  863. logging
  864. optimizations
  865. stripping
  866. yasm
  867. "
  868. PATHS_LIST='
  869. bindir
  870. datadir
  871. incdir
  872. libdir
  873. mandir
  874. prefix
  875. shlibdir
  876. '
  877. CMDLINE_SET="
  878. $PATHS_LIST
  879. arch
  880. as
  881. build_suffix
  882. cc
  883. cpu
  884. cross_prefix
  885. extra_version
  886. host_cc
  887. host_cflags
  888. host_ldflags
  889. host_libs
  890. host_os
  891. logfile
  892. nm
  893. source_path
  894. sysinclude
  895. sysroot
  896. target_exec
  897. target_os
  898. target_path
  899. "
  900. # code dependency declarations
  901. # architecture extensions
  902. altivec_deps="ppc"
  903. amd3dnow_deps="mmx"
  904. amd3dnowext_deps="amd3dnow"
  905. armv5te_deps="arm"
  906. armv6_deps="arm"
  907. armv6t2_deps="arm"
  908. armvfp_deps="arm"
  909. iwmmxt_deps="arm"
  910. mmi_deps="mips"
  911. mmx_deps="x86"
  912. mmx2_deps="mmx"
  913. neon_deps="arm"
  914. ppc4xx_deps="ppc"
  915. sse_deps="mmx"
  916. ssse3_deps="sse"
  917. vis_deps="sparc"
  918. # decoders / encoders / hardware accelerators
  919. aac_decoder_select="fft mdct"
  920. ac3_decoder_select="fft mdct"
  921. atrac3_decoder_select="fft mdct"
  922. cavs_decoder_select="golomb"
  923. cook_decoder_select="fft mdct"
  924. cscd_decoder_suggest="zlib"
  925. dca_decoder_select="fft mdct"
  926. dnxhd_encoder_select="aandct"
  927. dxa_decoder_select="zlib"
  928. eac3_decoder_select="fft mdct"
  929. eatgq_decoder_select="aandct"
  930. eatqi_decoder_select="aandct"
  931. ffv1_decoder_select="golomb"
  932. flac_decoder_select="golomb"
  933. flac_encoder_select="golomb"
  934. flashsv_decoder_select="zlib"
  935. flashsv_encoder_select="zlib"
  936. flv_encoder_select="aandct"
  937. h261_encoder_select="aandct"
  938. h263_encoder_select="aandct"
  939. h263_vaapi_hwaccel_deps="va_va_h"
  940. h263p_encoder_select="aandct"
  941. h264_decoder_select="golomb"
  942. h264_vaapi_hwaccel_deps="va_va_h"
  943. h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  944. imc_decoder_select="fft mdct"
  945. jpegls_decoder_select="golomb"
  946. jpegls_encoder_select="golomb"
  947. ljpeg_encoder_select="aandct"
  948. loco_decoder_select="golomb"
  949. mjpeg_encoder_select="aandct"
  950. mpeg1video_encoder_select="aandct"
  951. mpeg2video_encoder_select="aandct"
  952. mpeg4_encoder_select="aandct"
  953. mpeg_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  954. mpeg1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  955. mpeg2_vaapi_hwaccel_deps="va_va_h"
  956. mpeg4_vaapi_hwaccel_deps="va_va_h"
  957. mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  958. msmpeg4v1_encoder_select="aandct"
  959. msmpeg4v2_encoder_select="aandct"
  960. msmpeg4v3_encoder_select="aandct"
  961. nellymoser_decoder_select="fft mdct"
  962. nellymoser_encoder_select="fft mdct"
  963. png_decoder_select="zlib"
  964. png_encoder_select="zlib"
  965. qdm2_decoder_select="fft mdct rdft"
  966. rv10_encoder_select="aandct"
  967. rv20_encoder_select="aandct"
  968. rv30_decoder_select="golomb"
  969. rv40_decoder_select="golomb"
  970. shorten_decoder_select="golomb"
  971. sonic_decoder_select="golomb"
  972. sonic_encoder_select="golomb"
  973. sonic_ls_encoder_select="golomb"
  974. svq3_decoder_select="golomb"
  975. svq3_decoder_suggest="zlib"
  976. tiff_decoder_suggest="zlib"
  977. tiff_encoder_suggest="zlib"
  978. tscc_decoder_select="zlib"
  979. vc1_vaapi_hwaccel_deps="va_va_h"
  980. vc1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  981. vorbis_decoder_select="fft mdct"
  982. vorbis_encoder_select="fft mdct"
  983. wmav1_decoder_select="fft mdct"
  984. wmav1_encoder_select="fft mdct"
  985. wmav2_decoder_select="fft mdct"
  986. wmav2_encoder_select="fft mdct"
  987. wmv1_encoder_select="aandct"
  988. wmv2_encoder_select="aandct"
  989. wmv3_vaapi_hwaccel_deps="va_va_h"
  990. wmv3_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  991. zlib_decoder_select="zlib"
  992. zlib_encoder_select="zlib"
  993. zmbv_decoder_select="zlib"
  994. zmbv_encoder_select="zlib"
  995. # external libraries
  996. libamr_nb_decoder_deps="libamr_nb"
  997. libamr_nb_encoder_deps="libamr_nb"
  998. libamr_wb_decoder_deps="libamr_wb"
  999. libamr_wb_encoder_deps="libamr_wb"
  1000. libdirac_decoder_deps="libdirac !libschroedinger"
  1001. libdirac_encoder_deps="libdirac"
  1002. libfaac_encoder_deps="libfaac"
  1003. libfaad_decoder_deps="libfaad"
  1004. libfaadbin_decoder_extralibs='$ldl'
  1005. libgsm_decoder_deps="libgsm"
  1006. libgsm_encoder_deps="libgsm"
  1007. libgsm_ms_decoder_deps="libgsm"
  1008. libgsm_ms_encoder_deps="libgsm"
  1009. libmp3lame_encoder_deps="libmp3lame"
  1010. libopenjpeg_decoder_deps="libopenjpeg"
  1011. libschroedinger_decoder_deps="libschroedinger"
  1012. libschroedinger_encoder_deps="libschroedinger"
  1013. libspeex_decoder_deps="libspeex"
  1014. libtheora_encoder_deps="libtheora"
  1015. libvorbis_encoder_deps="libvorbis"
  1016. libx264_encoder_deps="libx264"
  1017. libxvid_encoder_deps="libxvid"
  1018. # demuxers / muxers
  1019. ac3_demuxer_deps="ac3_parser"
  1020. alsa_demuxer_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1021. alsa_demuxer_extralibs="-lasound"
  1022. alsa_muxer_deps="alsa_asoundlib_h"
  1023. alsa_muxer_extralibs="-lasound"
  1024. audio_beos_demuxer_deps="audio_beos"
  1025. audio_beos_demuxer_extralibs="-lmedia -lbe"
  1026. audio_beos_muxer_deps="audio_beos"
  1027. audio_beos_muxer_extralibs="-lmedia -lbe"
  1028. avisynth_demuxer_deps="avisynth"
  1029. bktr_demuxer_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1030. dirac_demuxer_deps="dirac_parser"
  1031. dv1394_demuxer_deps="dv1394 dv_demuxer"
  1032. jack_demuxer_deps="jack_jack_h"
  1033. jack_demuxer_extralibs="-ljack"
  1034. libdc1394_demuxer_deps="libdc1394"
  1035. libnut_demuxer_deps="libnut"
  1036. libnut_muxer_deps="libnut"
  1037. matroska_demuxer_suggest="zlib bzlib"
  1038. mov_demuxer_suggest="zlib"
  1039. mp3_demuxer_deps="mpegaudio_parser"
  1040. oss_demuxer_deps_any="soundcard_h sys_soundcard_h"
  1041. oss_muxer_deps_any="soundcard_h sys_soundcard_h"
  1042. redir_demuxer_deps="network"
  1043. rtp_muxer_deps="network rtp_protocol"
  1044. rtsp_demuxer_deps="sdp_demuxer"
  1045. sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
  1046. v4l_demuxer_deps="linux_videodev_h"
  1047. v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
  1048. vfwcap_demuxer_deps="capCreateCaptureWindow"
  1049. vfwcap_demuxer_extralibs="-lvfw32"
  1050. x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
  1051. x11_grab_device_demuxer_extralibs="-lX11 -lXext"
  1052. # protocols
  1053. gopher_protocol_deps="network"
  1054. http_protocol_deps="network"
  1055. rtp_protocol_deps="udp_protocol"
  1056. tcp_protocol_deps="network"
  1057. udp_protocol_deps="network"
  1058. # filters
  1059. movie_filter_deps="avfilter_lavf"
  1060. # programs
  1061. ffplay_deps="sdl"
  1062. ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
  1063. ffserver_extralibs='$ldl'
  1064. # default parameters
  1065. logfile="config.err"
  1066. # installation paths
  1067. prefix_default="/usr/local"
  1068. bindir_default='${prefix}/bin'
  1069. datadir_default='${prefix}/share/ffmpeg'
  1070. incdir_default='${prefix}/include'
  1071. libdir_default='${prefix}/lib'
  1072. mandir_default='${prefix}/share/man'
  1073. shlibdir_default="$libdir_default"
  1074. # toolchain
  1075. ar="ar"
  1076. cc_default="gcc"
  1077. host_cc_default="gcc"
  1078. ln_s="ln -sf"
  1079. nm_default="nm"
  1080. objformat="elf"
  1081. ranlib="ranlib"
  1082. strip="strip"
  1083. yasmexe="yasm"
  1084. # machine
  1085. arch=$(uname -m)
  1086. cpu="generic"
  1087. # OS
  1088. target_os=$(tolower $(uname -s))
  1089. host_os=$target_os
  1090. # configurable options
  1091. enable debug
  1092. enable fastdiv
  1093. enable ffmpeg
  1094. enable ffplay
  1095. enable ffserver
  1096. enable ipv6
  1097. enable mpegaudio_hp
  1098. enable network
  1099. enable optimizations
  1100. enable protocols
  1101. enable static
  1102. enable stripping
  1103. enable swscale_alpha
  1104. # build settings
  1105. add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
  1106. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1107. FFSERVERLDFLAGS=-Wl,-E
  1108. LIBPREF="lib"
  1109. LIBSUF=".a"
  1110. FULLNAME='$(NAME)$(BUILDSUF)'
  1111. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1112. SLIBPREF="lib"
  1113. SLIBSUF=".so"
  1114. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1115. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1116. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1117. LIB_INSTALL_EXTRA_CMD='$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1118. host_cflags='-O3 -g -Wall'
  1119. host_libs='-lm'
  1120. target_path='.'
  1121. # gcc stupidly only outputs the basename of targets with -MM, but we need the
  1122. # full relative path for objects in subdirectories for non-recursive Make.
  1123. DEPEND_CMD='$(CC) $(CFLAGS) -MM $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
  1124. # find source path
  1125. source_path="$(dirname "$0")"
  1126. enable source_path_used
  1127. if test -z "$source_path" -o "$source_path" = "." ; then
  1128. source_path="$(pwd)"
  1129. disable source_path_used
  1130. else
  1131. source_path="$(cd "$source_path"; pwd)"
  1132. echo "$source_path" | grep -q '[[:blank:]]' &&
  1133. die "Out of tree builds are impossible with whitespace in source path."
  1134. test -e "$source_path/config.h" &&
  1135. die "Out of tree builds are impossible with config.h in source dir."
  1136. fi
  1137. for v in "$@"; do
  1138. r="${v#*=}"
  1139. l="${v%$r}"
  1140. test "$r" = "${r#* }" || r="'$r'"
  1141. FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
  1142. done
  1143. find_things(){
  1144. thing=$1
  1145. pattern=$2
  1146. file=$source_path/$3
  1147. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1148. }
  1149. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1150. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1151. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1152. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1153. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1154. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1155. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1156. OUTDEV_LIST=$(find_things muxer _MUX libavdevice/alldevices.c)
  1157. INDEV_LIST=$(find_things demuxer DEMUX libavdevice/alldevices.c)
  1158. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1159. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1160. enable $ARCH_EXT_LIST \
  1161. $DECODER_LIST \
  1162. $ENCODER_LIST \
  1163. $HWACCEL_LIST \
  1164. $PARSER_LIST \
  1165. $BSF_LIST \
  1166. $DEMUXER_LIST \
  1167. $MUXER_LIST \
  1168. $FILTER_LIST \
  1169. $PROTOCOL_LIST \
  1170. $INDEV_LIST \
  1171. $OUTDEV_LIST \
  1172. die_unknown(){
  1173. echo "Unknown option \"$1\"."
  1174. echo "See $0 --help for available options."
  1175. exit 1
  1176. }
  1177. show_list() {
  1178. suffix=_$1
  1179. shift
  1180. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort
  1181. exit 0
  1182. }
  1183. for opt do
  1184. optval="${opt#*=}"
  1185. case "$opt" in
  1186. --extra-cflags=*) add_cflags $optval
  1187. ;;
  1188. --extra-ldflags=*) add_ldflags $optval
  1189. ;;
  1190. --extra-libs=*) add_extralibs $optval
  1191. ;;
  1192. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1193. ;;
  1194. --enable-debug=*) debuglevel="$optval"
  1195. ;;
  1196. --enable-*=*|--disable-*=*)
  1197. eval $(echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/')
  1198. case "$thing" in
  1199. encoder|decoder|hwaccel|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
  1200. *) die_unknown "$opt" ;;
  1201. esac
  1202. ;;
  1203. --enable-?*|--disable-?*)
  1204. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1205. if is_in $option $COMPONENT_LIST; then
  1206. eval $action \$$(toupper ${option%s})_LIST
  1207. elif is_in $option $CMDLINE_SELECT; then
  1208. $action $option
  1209. else
  1210. die_unknown $opt
  1211. fi
  1212. ;;
  1213. --list-*)
  1214. NAME="${opt#--list-}"
  1215. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1216. NAME=${NAME%s}
  1217. eval show_list $NAME \$$(toupper $NAME)_LIST
  1218. ;;
  1219. --help|-h) show_help
  1220. ;;
  1221. *)
  1222. optname="${opt%%=*}"
  1223. optname="${optname#--}"
  1224. optname=$(echo "$optname" | sed 's/-/_/g')
  1225. is_in $optname $CMDLINE_SET || die_unknown $opt
  1226. eval $optname='$optval'
  1227. ;;
  1228. esac
  1229. done
  1230. disabled logging && logfile=/dev/null
  1231. echo "# $0 $FFMPEG_CONFIGURATION" > $logfile
  1232. set >> $logfile
  1233. test -n "$cross_prefix" && enable cross_compile
  1234. ar="${cross_prefix}${ar}"
  1235. cc_default="${cross_prefix}${cc_default}"
  1236. nm_default="${cross_prefix}${nm_default}"
  1237. ranlib="${cross_prefix}${ranlib}"
  1238. strip="${cross_prefix}${strip}"
  1239. sysinclude_default="${sysroot}/usr/include"
  1240. set_default cc nm sysinclude
  1241. as_default=$cc
  1242. enabled cross_compile || host_cc_default=$cc
  1243. set_default host_cc
  1244. exesuf() {
  1245. case $1 in
  1246. mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
  1247. esac
  1248. }
  1249. EXESUF=$(exesuf $target_os)
  1250. HOSTEXESUF=$(exesuf $host_os)
  1251. # set temporary file name
  1252. : ${TMPDIR:=$TEMPDIR}
  1253. : ${TMPDIR:=$TMP}
  1254. : ${TMPDIR:=/tmp}
  1255. if ! check_cmd type mktemp; then
  1256. # simple replacement for missing mktemp
  1257. # NOT SAFE FOR GENERAL USE
  1258. mktemp(){
  1259. echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
  1260. }
  1261. fi
  1262. tmpfile(){
  1263. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1264. (set -C; exec > $tmp) 2>/dev/null ||
  1265. die "Unable to create temoporary file in $TMPDIR."
  1266. append TMPFILES $tmp
  1267. eval $1=$tmp
  1268. }
  1269. trap 'rm -f -- $TMPFILES' EXIT
  1270. trap exit HUP INT TERM
  1271. tmpfile TMPC .c
  1272. tmpfile TMPE $EXESUF
  1273. tmpfile TMPH .h
  1274. tmpfile TMPO .o
  1275. tmpfile TMPS .S
  1276. tmpfile TMPSH .sh
  1277. unset -f mktemp
  1278. # make sure we can execute files in $TMPDIR
  1279. cat > $TMPSH 2>> $logfile <<EOF
  1280. #! /bin/sh
  1281. EOF
  1282. chmod +x $TMPSH >> $logfile 2>&1
  1283. if ! $TMPSH >> $logfile 2>&1; then
  1284. cat <<EOF
  1285. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1286. variable to another directory and make sure that it is not mounted noexec.
  1287. EOF
  1288. die "Sanity test failed."
  1289. fi
  1290. if $cc --version 2>/dev/null | grep -qi gcc; then
  1291. cc_type=gcc
  1292. elif $cc --version 2>/dev/null | grep -q Intel; then
  1293. cc_type=icc
  1294. elif $cc -v 2>&1 | grep -q xlc; then
  1295. cc_type=xlc
  1296. elif $cc -V 2>/dev/null | grep -q Compaq; then
  1297. cc_type=ccc
  1298. DEPEND_CMD='$(CC) $(CFLAGS) -M $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
  1299. debuglevel=3
  1300. add_ldflags -Wl,-z,now # calls to libots crash without this
  1301. elif $cc --vsn 2>/dev/null | grep -q RVCT; then
  1302. test -d "$sysroot" || die "No valid sysroot specified."
  1303. cc_type=armcc
  1304. armcc_conf="$PWD/armcc.conf"
  1305. $cc --arm_linux_configure \
  1306. --arm_linux_config_file="$armcc_conf" \
  1307. --configure_sysroot="$sysroot" \
  1308. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  1309. die "Error creating armcc configuration file."
  1310. cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
  1311. as_default="${cross_prefix}gcc"
  1312. fi
  1313. test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
  1314. set_default as
  1315. if test -n "$sysroot"; then
  1316. case "$cc_type" in
  1317. gcc)
  1318. add_cflags --sysroot="$sysroot"
  1319. add_ldflags --sysroot="$sysroot"
  1320. ;;
  1321. esac
  1322. fi
  1323. # compiler sanity check
  1324. check_exec <<EOF
  1325. int main(void){ return 0; }
  1326. EOF
  1327. if test "$?" != 0; then
  1328. echo "$cc is unable to create an executable file."
  1329. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  1330. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  1331. echo "Only do this if you know what cross compiling means."
  1332. fi
  1333. die "C compiler test failed."
  1334. fi
  1335. check_cflags -std=c99
  1336. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cflags -D_FILE_OFFSET_BITS=64
  1337. #include <stdlib.h>
  1338. EOF
  1339. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cflags -D_LARGEFILE_SOURCE
  1340. #include <stdlib.h>
  1341. EOF
  1342. case "$arch" in
  1343. alpha)
  1344. arch="alpha"
  1345. enable fast_64bit
  1346. check_cflags -mieee
  1347. ;;
  1348. arm|armv[4567]*l)
  1349. arch="arm"
  1350. ;;
  1351. avr32)
  1352. ;;
  1353. bfin)
  1354. arch="bfin"
  1355. ;;
  1356. ia64)
  1357. arch="ia64"
  1358. enable fast_64bit
  1359. ;;
  1360. m68k)
  1361. arch="m68k"
  1362. ;;
  1363. mips|mipsel|IP*)
  1364. arch="mips"
  1365. ;;
  1366. mips64)
  1367. arch="mips"
  1368. subarch="mips64"
  1369. enable fast_64bit
  1370. ;;
  1371. parisc|hppa)
  1372. arch="parisc"
  1373. ;;
  1374. parisc64|hppa64)
  1375. arch="parisc"
  1376. enable fast_64bit
  1377. ;;
  1378. "Power Macintosh"|ppc|powerpc)
  1379. arch="ppc"
  1380. enable fast_unaligned
  1381. ;;
  1382. ppc64)
  1383. arch="ppc"
  1384. subarch="ppc64"
  1385. enable fast_64bit
  1386. enable fast_unaligned
  1387. ;;
  1388. s390|s390x)
  1389. arch="s390"
  1390. ;;
  1391. sh4|sh)
  1392. arch="sh4"
  1393. ;;
  1394. sparc)
  1395. arch="sparc"
  1396. ;;
  1397. sun4u|sparc64)
  1398. arch="sparc"
  1399. subarch="sparc64"
  1400. enable fast_64bit
  1401. ;;
  1402. i386|i486|i586|i686|i86pc|BePC)
  1403. arch="x86"
  1404. subarch="x86_32"
  1405. enable fast_unaligned
  1406. ;;
  1407. x86_64|amd64)
  1408. arch="x86"
  1409. subarch="x86_32"
  1410. enable cmov
  1411. enable fast_cmov
  1412. enable fast_unaligned
  1413. check_cc <<EOF && enable fast_64bit && subarch="x86_64"
  1414. int test[sizeof(char*) - 7];
  1415. EOF
  1416. ;;
  1417. *)
  1418. arch="unknown"
  1419. ;;
  1420. esac
  1421. enable $arch $subarch
  1422. # OS specific
  1423. case $target_os in
  1424. beos|haiku|zeta)
  1425. prefix_default="$HOME/config"
  1426. # helps building libavcodec
  1427. add_cflags -DPIC -fomit-frame-pointer
  1428. # 3 gcc releases known for BeOS, each with ugly bugs
  1429. gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
  1430. case "$gcc_version" in
  1431. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  1432. disable mmx
  1433. ;;
  1434. *20010315*) echo "BeBits gcc"
  1435. add_cflags -fno-expensive-optimizations
  1436. ;;
  1437. esac
  1438. SHFLAGS=-nostart
  1439. # enable BeOS things
  1440. enable audio_beos
  1441. # no need for libm, but the inet stuff
  1442. # Check for BONE
  1443. # XXX: actually should check for NOT net_server
  1444. if echo $BEINCLUDES | grep -q 'headers/be/bone'; then
  1445. network_extralibs="-lbind -lsocket"
  1446. else
  1447. enable beos_netserver
  1448. network_extralibs="-lnet"
  1449. fi ;;
  1450. sunos)
  1451. FFSERVERLDFLAGS=""
  1452. SHFLAGS='-shared -Wl,-h,$$(@F)'
  1453. network_extralibs="-lsocket -lnsl"
  1454. add_cflags -D__EXTENSIONS__
  1455. ;;
  1456. netbsd)
  1457. oss_demuxer_extralibs="-lossaudio"
  1458. oss_muxer_extralibs="-lossaudio"
  1459. ;;
  1460. openbsd)
  1461. disable need_memalign
  1462. LIBOBJFLAGS='$(PIC)'
  1463. SHFLAGS='-shared'
  1464. oss_demuxer_extralibs="-lossaudio"
  1465. oss_muxer_extralibs="-lossaudio"
  1466. ;;
  1467. freebsd)
  1468. disable need_memalign
  1469. ;;
  1470. bsd/os)
  1471. osextralibs="-lpoll -lgnugetopt"
  1472. strip="strip -d"
  1473. ;;
  1474. darwin)
  1475. disable need_memalign
  1476. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
  1477. strip="strip -x"
  1478. FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
  1479. SLIBSUF=".dylib"
  1480. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  1481. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  1482. FFSERVERLDFLAGS=-Wl,-bind_at_load
  1483. objformat="macho"
  1484. enabled x86_64 && objformat="macho64"
  1485. ;;
  1486. mingw32*)
  1487. target_os=mingw32
  1488. LIBTARGET=i386
  1489. if enabled x86_64; then
  1490. disable need_memalign
  1491. LIBTARGET=x64
  1492. fi
  1493. shlibdir_default="$bindir_default"
  1494. disable ffserver
  1495. SLIBPREF=""
  1496. SLIBSUF=".dll"
  1497. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1498. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1499. SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
  1500. SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
  1501. install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
  1502. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
  1503. SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  1504. objformat="win32"
  1505. enable dos_paths
  1506. check_cflags -fno-common
  1507. if ! enabled x86_64; then
  1508. check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  1509. die "ERROR: MinGW runtime version must be >= 3.15."
  1510. enabled_any avisynth vfwcap_demuxer &&
  1511. { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
  1512. die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
  1513. fi
  1514. ;;
  1515. cygwin*)
  1516. target_os=cygwin
  1517. shlibdir_default="$bindir_default"
  1518. SLIBPREF="cyg"
  1519. SLIBSUF=".dll"
  1520. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  1521. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  1522. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  1523. objformat="win32"
  1524. enable dos_paths
  1525. check_cflags -fno-common
  1526. ;;
  1527. *-dos|freedos|opendos)
  1528. disable ffplay ffserver
  1529. disable $INDEV_LIST $OUTDEV_LIST
  1530. network_extralibs="-lsocket"
  1531. objformat="coff"
  1532. enable dos_paths
  1533. ;;
  1534. linux)
  1535. enable dv1394
  1536. ;;
  1537. irix*)
  1538. target_os=irix
  1539. ranlib="echo ignoring ranlib"
  1540. ;;
  1541. os/2*)
  1542. strip="lxlite"
  1543. ln_s="cp -f"
  1544. FFLDFLAGS="-Zomf -Zbin-files -Zargs-wild -Zmap"
  1545. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  1546. FFSERVERLDFLAGS=""
  1547. LIBSUF="_s.a"
  1548. SLIBPREF=""
  1549. SLIBSUF=".dll"
  1550. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  1551. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  1552. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  1553. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  1554. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  1555. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  1556. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  1557. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  1558. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  1559. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  1560. SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
  1561. SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
  1562. enable dos_paths
  1563. ;;
  1564. gnu/kfreebsd)
  1565. ;;
  1566. gnu)
  1567. ;;
  1568. *)
  1569. die "Unknown OS '$target_os'."
  1570. ;;
  1571. esac
  1572. set_default $PATHS_LIST
  1573. add_extralibs $osextralibs
  1574. # Combine FFLDFLAGS and the LDFLAGS environment variable.
  1575. LDFLAGS="$FFLDFLAGS $LDFLAGS"
  1576. # we need to build at least one lib type
  1577. if ! enabled_any static shared; then
  1578. cat <<EOF
  1579. At least one library type must be built.
  1580. Specify --enable-static to build the static libraries or --enable-shared to
  1581. build the shared libraries as well. To only build the shared libraries specify
  1582. --disable-static in addition to --enable-shared.
  1583. EOF
  1584. exit 1;
  1585. fi
  1586. disabled static && LIBNAME=""
  1587. if enabled_any libfaad libfaadbin ; then
  1588. if check_header faad.h; then
  1589. check_cc <<EOF
  1590. #include <faad.h>
  1591. #ifndef FAAD2_VERSION
  1592. ok faad1
  1593. #endif
  1594. int main(void) { return 0; }
  1595. EOF
  1596. test $? = 0 && enable libfaad2
  1597. else
  1598. die "FAAD test failed."
  1599. fi
  1600. fi
  1601. die_license_disabled() {
  1602. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  1603. }
  1604. die_license_disabled gpl libfaad2
  1605. die_license_disabled gpl libx264
  1606. die_license_disabled gpl libxvid
  1607. die_license_disabled gpl postproc
  1608. die_license_disabled gpl x11grab
  1609. die_license_disabled nonfree libamr_nb
  1610. die_license_disabled nonfree libamr_wb
  1611. die_license_disabled nonfree libfaac
  1612. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  1613. check_deps $ARCH_EXT_LIST
  1614. test -z "$need_memalign" && need_memalign="$mmx"
  1615. #Darwin CC versions
  1616. if test $target_os = darwin; then
  1617. if enabled xlc; then
  1618. add_cflags -qpdf2 -qlanglvl=extc99 -qmaxmem=-1 -qarch=auto -qtune=auto
  1619. else
  1620. add_cflags -pipe
  1621. check_cflags -force_cpusubtype_ALL
  1622. check_cflags -Wno-sign-compare
  1623. enabled shared || check_cflags -mdynamic-no-pic
  1624. fi
  1625. fi
  1626. disabled optimizations || check_cflags -fomit-frame-pointer
  1627. # Add processor-specific flags
  1628. if test $cpu != "generic"; then
  1629. warn_altivec(){
  1630. $1 altivec && echo "WARNING: Tuning for $2 but AltiVec $1.";
  1631. }
  1632. case $cpu in
  1633. 601|ppc601|PowerPC601)
  1634. add_cflags -mcpu=601
  1635. warn_altivec enabled PPC601
  1636. ;;
  1637. 603*|ppc603*|PowerPC603*)
  1638. add_cflags -mcpu=603
  1639. warn_altivec enabled PPC603
  1640. ;;
  1641. 604*|ppc604*|PowerPC604*)
  1642. add_cflags -mcpu=604
  1643. warn_altivec enabled PPC604
  1644. ;;
  1645. G3|g3|75*|ppc75*|PowerPC75*)
  1646. add_cflags -mcpu=750 -mpowerpc-gfxopt
  1647. warn_altivec enabled PPC75x
  1648. ;;
  1649. G4|g4|745*|ppc745*|PowerPC745*)
  1650. add_cflags -mcpu=7450 -mpowerpc-gfxopt
  1651. warn_altivec disabled PPC745x
  1652. ;;
  1653. 74*|ppc74*|PowerPC74*)
  1654. add_cflags -mcpu=7400 -mpowerpc-gfxopt
  1655. warn_altivec disabled PPC74xx
  1656. ;;
  1657. G5|g5|970|ppc970|PowerPC970|power4*|Power4*)
  1658. add_cflags -mcpu=970 -mpowerpc-gfxopt -mpowerpc64
  1659. warn_altivec disabled PPC970
  1660. ;;
  1661. Cell|CELL|cell)
  1662. add_cflags -mcpu=cell
  1663. warn_altivec disabled Cell
  1664. enable ldbrx
  1665. ;;
  1666. # targets that do NOT support conditional mov (cmov)
  1667. i[345]86|pentium|pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  1668. add_cflags -march=$cpu
  1669. disable cmov
  1670. ;;
  1671. # targets that do support conditional mov (cmov)
  1672. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64|k8|opteron|athlon-fx|core2)
  1673. add_cflags -march=$cpu
  1674. enable cmov
  1675. enable fast_cmov
  1676. ;;
  1677. # targets that do support conditional mov but on which it's slow
  1678. pentium4|pentium4m|prescott|nocona)
  1679. add_cflags -march=$cpu
  1680. enable cmov
  1681. disable fast_cmov
  1682. ;;
  1683. sparc64)
  1684. add_cflags -mcpu=v9
  1685. ;;
  1686. arm11*|cortex*)
  1687. add_cflags -mcpu=$cpu
  1688. enable fast_unaligned
  1689. ;;
  1690. armv*)
  1691. add_cflags -march=$cpu
  1692. ;;
  1693. arm*)
  1694. add_cflags -mcpu=$cpu
  1695. ;;
  1696. ev4|ev45|ev5|ev56|pca56|ev6|ev67)
  1697. enabled ccc && add_cflags -arch $cpu || add_cflags -mcpu=$cpu
  1698. ;;
  1699. bf*)
  1700. add_cflags -mcpu=$cpu
  1701. ;;
  1702. mips*|[45]k*|[237]4k*|m4k|r*000|loongson2[ef])
  1703. add_cflags -march=$cpu
  1704. ;;
  1705. *)
  1706. echo "WARNING: Unknown CPU \"$cpu\", ignored."
  1707. ;;
  1708. esac
  1709. fi
  1710. check_cc <<EOF || die "Symbol mangling check failed."
  1711. int ff_extern;
  1712. EOF
  1713. sym=$($nm -P -g $TMPO | grep ff_extern)
  1714. extern_prefix=${sym%%ff_extern*}
  1715. check_cc <<EOF && enable inline_asm
  1716. void foo(void) { __asm__ volatile ("" ::); }
  1717. EOF
  1718. if enabled x86; then
  1719. # check whether EBP is available on x86
  1720. # As 'i' is stored on the stack, this program will crash
  1721. # if the base pointer is used to access it because the
  1722. # base pointer is cleared in the inline assembly code.
  1723. check_exec_crash <<EOF && enable ebp_available
  1724. volatile int i=0;
  1725. __asm__ volatile (
  1726. "xorl %%ebp, %%ebp"
  1727. ::: "%ebp");
  1728. return i;
  1729. EOF
  1730. # check wether EBX is available on x86
  1731. check_asm ebx_available '"":::"%ebx"'
  1732. # check whether more than 10 operands are supported
  1733. check_cc <<EOF && enable ten_operands
  1734. int main(void) {
  1735. int x=0;
  1736. __asm__ volatile(
  1737. ""
  1738. :"+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x), "+&rm"(x)
  1739. );
  1740. return 0;
  1741. }
  1742. EOF
  1743. # check whether binutils is new enough to compile SSSE3/MMX2
  1744. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  1745. enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
  1746. check_asm bswap '"bswap %%eax" ::: "%eax"'
  1747. YASMFLAGS="-f $objformat -DARCH_$(toupper $subarch)"
  1748. enabled x86_64 && append YASMFLAGS "-m amd64"
  1749. enabled_all x86_64 shared && append YASMFLAGS "-DPIC"
  1750. case "$objformat" in
  1751. elf) enabled debug && append YASMFLAGS "-g dwarf2" ;;
  1752. macho64) append YASMFLAGS "-DPIC -DPREFIX" ;;
  1753. *) append YASMFLAGS "-DPREFIX" ;;
  1754. esac
  1755. disabled yasm || { check_yasm "pabsw xmm0, xmm0" && enable yasm; }
  1756. fi
  1757. # check for assembler specific support
  1758. enabled mips && check_asm loongson '"dmult.g $1, $2, $3"'
  1759. enabled ppc && check_asm dcbzl '"dcbzl 0, 1"'
  1760. enabled ppc && check_asm ppc4xx '"maclhw r10, r11, r12"'
  1761. enabled ppc && check_asm xform_asm '"lwzx 0, %y0" :: "Z"(*(int*)0)'
  1762. # check for SIMD availability
  1763. # AltiVec flags: The FSF version of GCC differs from the Apple version
  1764. if enabled altivec; then
  1765. check_cflags -maltivec -mabi=altivec &&
  1766. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  1767. check_cflags -faltivec
  1768. # check if our compiler supports Motorola AltiVec C API
  1769. check_cc <<EOF || disable altivec
  1770. $inc_altivec_h
  1771. int main(void) {
  1772. vector signed int v1, v2, v3;
  1773. v1 = vec_add(v2,v3);
  1774. return 0;
  1775. }
  1776. EOF
  1777. # check if our compiler supports braces for vector declarations
  1778. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  1779. $inc_altivec_h
  1780. int main (void) { (vector int) {1}; return 0; }
  1781. EOF
  1782. fi
  1783. # We have to check if pld is a nop and disable it.
  1784. enabled arm && check_asm pld '"pld [r0]"'
  1785. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  1786. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  1787. enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
  1788. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  1789. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  1790. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  1791. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  1792. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc
  1793. enabled vis && add_cflags -mcpu=ultrasparc -mtune=ultrasparc
  1794. # ---
  1795. # big/little-endian test
  1796. check_cc <<EOF || die "endian test failed"
  1797. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  1798. EOF
  1799. od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  1800. # ---
  1801. # check availability of some header files
  1802. if check_func dlopen; then
  1803. ldl=
  1804. elif check_func dlopen -ldl; then
  1805. ldl=-ldl
  1806. fi
  1807. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  1808. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  1809. check_func fork
  1810. check_func gethrtime
  1811. check_func getrusage
  1812. check_func inet_aton $network_extralibs
  1813. check_func memalign
  1814. check_func mkstemp
  1815. check_func posix_memalign
  1816. check_func_headers io.h setmode
  1817. check_func_headers lzo/lzo1x.h lzo1x_999_compress
  1818. check_func_headers windows.h GetProcessTimes
  1819. check_func_headers windows.h VirtualAlloc
  1820. check_header conio.h
  1821. check_header dlfcn.h
  1822. check_header malloc.h
  1823. check_header poll.h
  1824. check_header sys/mman.h
  1825. check_header sys/resource.h
  1826. check_header sys/select.h
  1827. check_header termios.h
  1828. check_header vdpau/vdpau.h
  1829. check_header vdpau/vdpau_x11.h
  1830. check_header X11/extensions/XvMClib.h
  1831. if ! enabled_any memalign memalign_hack posix_memalign && enabled need_memalign ; then
  1832. die "Error, no aligned memory allocator but SSE enabled, disable it or use --enable-memalign-hack."
  1833. fi
  1834. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  1835. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  1836. # check for some common methods of building with pthread support
  1837. # do this before the optional library checks as some of them require pthreads
  1838. if enabled pthreads; then
  1839. if check_func pthread_create; then
  1840. :
  1841. elif check_func pthread_create -pthread; then
  1842. add_cflags -pthread
  1843. add_extralibs -pthread
  1844. elif check_func pthread_create -pthreads; then
  1845. add_cflags -pthreads
  1846. add_extralibs -pthreads
  1847. elif check_func pthread_create -lpthreadGC2; then
  1848. add_extralibs -lpthreadGC2
  1849. elif ! check_lib pthread.h pthread_create -lpthread; then
  1850. die "ERROR: can't find pthreads library"
  1851. fi
  1852. fi
  1853. for thread in $THREADS_LIST; do
  1854. if enabled $thread; then
  1855. test -n "$thread_type" &&
  1856. die "ERROR: Only one thread type must be selected." ||
  1857. thread_type="$thread"
  1858. fi
  1859. done
  1860. check_lib math.h sin -lm
  1861. check_lib va/va.h vaInitialize -lva
  1862. # test for C99 functions in math.h
  1863. for func in llrint lrint lrintf round roundf truncf; do
  1864. check_exec <<EOF && enable $func || disable $func
  1865. #include <math.h>
  1866. int main(void) { return ($func(3.999f) > 0)?0:1; }
  1867. EOF
  1868. done
  1869. # these are off by default, so fail if requested and not available
  1870. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
  1871. enabled libamr_nb && require libamrnb amrnb/interf_dec.h Decoder_Interface_init -lamrnb -lm
  1872. enabled libamr_wb && require libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
  1873. enabled libdirac && add_cflags $(pkg-config --cflags dirac) &&
  1874. require libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init -ldirac_decoder &&
  1875. require libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init -ldirac_encoder
  1876. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  1877. enabled libfaad && require2 libfaad faad.h faacDecOpen -lfaad
  1878. enabled libgsm && require libgsm gsm.h gsm_create -lgsm
  1879. enabled libmp3lame && require libmp3lame lame/lame.h lame_init -lmp3lame -lm
  1880. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  1881. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  1882. enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
  1883. require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
  1884. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  1885. enabled libtheora && require libtheora theora/theora.h theora_info_init -ltheora -logg
  1886. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  1887. enabled libx264 && require libx264 x264.h x264_encoder_open -lx264 -lm &&
  1888. { check_cpp_condition x264.h "X264_BUILD >= 65" ||
  1889. die "ERROR: libx264 version must be >= 0.65."; }
  1890. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  1891. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  1892. # libdc1394 check
  1893. if enabled libdc1394; then
  1894. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  1895. enable libdc1394_2; } ||
  1896. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  1897. enable libdc1394_1; } ||
  1898. die "ERROR: No version of libdc1394 found "
  1899. fi
  1900. _restrict=
  1901. for restrict_keyword in restrict __restrict__ __restrict; do
  1902. check_cc <<EOF && _restrict=$restrict_keyword && break
  1903. void foo(char * $restrict_keyword p);
  1904. EOF
  1905. done
  1906. ##########################################
  1907. # SDL check
  1908. disable sdl_too_old
  1909. disable sdl
  1910. SDL_CONFIG="${cross_prefix}sdl-config"
  1911. if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
  1912. sdl_cflags=$("${SDL_CONFIG}" --cflags)
  1913. temp_cflags $sdl_cflags
  1914. temp_extralibs $("${SDL_CONFIG}" --libs)
  1915. if check_lib2 SDL.h SDL_Init; then
  1916. _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
  1917. if test "$_sdlversion" -lt 121 ; then
  1918. enable sdl_too_old
  1919. else
  1920. enable sdl
  1921. check_cc $sdl_cflags <<EOF && enable sdl_video_size
  1922. #include <SDL.h>
  1923. int main(int argc, char **argv){
  1924. const SDL_VideoInfo *vi = SDL_GetVideoInfo();
  1925. int w = vi->current_w;
  1926. return 0;
  1927. }
  1928. EOF
  1929. fi
  1930. fi
  1931. restore_flags
  1932. fi
  1933. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  1934. ##########################################
  1935. # Network check
  1936. if enabled network; then
  1937. check_type "sys/types.h sys/socket.h" socklen_t
  1938. # Prefer arpa/inet.h over winsock2
  1939. if check_header arpa/inet.h ; then
  1940. check_func closesocket
  1941. elif check_header winsock2.h ; then
  1942. network_extralibs="-lws2_32"
  1943. check_type ws2tcpip.h socklen_t
  1944. check_func_headers winsock2.h closesocket
  1945. fi
  1946. fi
  1947. ##########################################
  1948. # IPv6 check
  1949. enabled network && enabled ipv6 && check_ld <<EOF && enable ipv6 || disable ipv6
  1950. #include <sys/types.h>
  1951. #include <sys/socket.h>
  1952. #include <netinet/in.h>
  1953. #include <netdb.h>
  1954. int main(void) {
  1955. struct sockaddr_storage saddr;
  1956. struct ipv6_mreq mreq6;
  1957. getaddrinfo(0,0,0,0);
  1958. getnameinfo(0,0,0,0,0,0,0);
  1959. IN6_IS_ADDR_MULTICAST((const struct in6_addr *)0);
  1960. }
  1961. EOF
  1962. check_header linux/videodev.h
  1963. check_header linux/videodev2.h
  1964. check_header sys/videoio.h
  1965. check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
  1966. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  1967. { check_header dev/bktr/ioctl_meteor.h &&
  1968. check_header dev/bktr/ioctl_bt848.h; } ||
  1969. { check_header machine/ioctl_meteor.h &&
  1970. check_header machine/ioctl_bt848.h; } ||
  1971. { check_header dev/video/meteor/ioctl_meteor.h &&
  1972. check_header dev/video/bktr/ioctl_bt848.h; } ||
  1973. check_header dev/ic/bt8xx.h
  1974. check_header sys/soundcard.h
  1975. check_header soundcard.h
  1976. check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  1977. check_lib2 jack/jack.h jack_client_open -ljack
  1978. # deal with the X11 frame grabber
  1979. enabled x11grab &&
  1980. check_header X11/Xlib.h &&
  1981. check_header X11/extensions/XShm.h &&
  1982. check_func XOpenDisplay -lX11 &&
  1983. check_func XShmCreateImage -lX11 -lXext
  1984. enabled debug && add_cflags -g"$debuglevel"
  1985. # add some useful compiler flags if supported
  1986. check_cflags -Wdeclaration-after-statement
  1987. check_cflags -Wall
  1988. check_cflags -Wno-switch
  1989. check_cflags -Wdisabled-optimization
  1990. check_cflags -Wpointer-arith
  1991. check_cflags -Wredundant-decls
  1992. check_cflags -Wno-pointer-sign
  1993. check_cflags -Wcast-qual
  1994. check_cflags -Wwrite-strings
  1995. check_cflags -Wtype-limits
  1996. check_cflags -Wundef
  1997. enabled extra_warnings && check_cflags -Winline
  1998. # add some linker flags
  1999. check_ldflags -Wl,--warn-common
  2000. check_ldflags -Wl,--as-needed
  2001. check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
  2002. check_ldflags -Wl,-Bsymbolic
  2003. if enabled small; then
  2004. check_cflags -Os # not all compilers support -Os
  2005. optimizations="small"
  2006. elif enabled optimizations; then
  2007. if enabled xlc; then
  2008. add_cflags -O5
  2009. add_ldflags -O5
  2010. elif enabled ccc; then
  2011. add_cflags -fast
  2012. else
  2013. add_cflags -O3
  2014. fi
  2015. fi
  2016. check_cflags -fno-math-errno
  2017. check_cflags -fno-signed-zeros
  2018. # add some flags for Intel C Compiler
  2019. if enabled icc; then
  2020. # Just warnings, no remarks
  2021. check_cflags -w1
  2022. # -wd: Disable following warnings
  2023. # 144, 167, 556: -Wno-pointer-sign
  2024. # 10006: ignoring unknown option -fno-signed-zeros
  2025. # 10156: ignoring option '-W'; no argument required
  2026. check_cflags -wd144,167,556,10006,10156
  2027. # 11030: Warning unknown option --as-needed
  2028. # 10156: ignoring option '-export'; no argument required
  2029. check_ldflags -wd10156,11030
  2030. # Allow to compile with optimizations
  2031. check_ldflags -march=$cpu
  2032. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  2033. enable ebp_available
  2034. elif enabled ccc; then
  2035. # disable some annoying warnings
  2036. add_cflags -msg_disable cvtu32to64
  2037. add_cflags -msg_disable embedcomment
  2038. add_cflags -msg_disable needconstext
  2039. add_cflags -msg_disable nomainieee
  2040. add_cflags -msg_disable ptrmismatch1
  2041. add_cflags -msg_disable unreachcode
  2042. fi
  2043. # PIC flags for shared library objects where they are needed
  2044. if enabled shared; then
  2045. # LIBOBJFLAGS may have already been set in the OS configuration
  2046. if test -z "$LIBOBJFLAGS" ; then
  2047. case "${subarch-$arch}" in
  2048. x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
  2049. esac
  2050. fi
  2051. fi
  2052. if enabled gprof; then
  2053. add_cflags -p
  2054. add_ldflags -p
  2055. fi
  2056. # Find out if the .align argument is a power of two or not.
  2057. check_asm asmalign_pot '".align 3"'
  2058. enabled_any $DECODER_LIST && enable decoders
  2059. enabled_any $ENCODER_LIST && enable encoders
  2060. enabled_any $HWACCEL_LIST && enable hwaccels
  2061. enabled_any $BSF_LIST && enable bsfs
  2062. enabled_any $DEMUXER_LIST && enable demuxers
  2063. enabled_any $MUXER_LIST && enable muxers
  2064. enabled_any $FILTER_LIST && enable filters
  2065. enabled_any $INDEV_LIST && enable demuxers
  2066. enabled_any $OUTDEV_LIST && enable muxers
  2067. enabled_any $PROTOCOL_LIST && enable protocols
  2068. enabled_any $THREADS_LIST && enable threads
  2069. check_deps $CONFIG_LIST \
  2070. $CONFIG_EXTRA \
  2071. $HAVE_LIST \
  2072. $DECODER_LIST \
  2073. $ENCODER_LIST \
  2074. $HWACCEL_LIST \
  2075. $PARSER_LIST \
  2076. $BSF_LIST \
  2077. $DEMUXER_LIST \
  2078. $MUXER_LIST \
  2079. $FILTER_LIST \
  2080. $INDEV_LIST \
  2081. $OUTDEV_LIST \
  2082. $PROTOCOL_LIST \
  2083. echo "install prefix $prefix"
  2084. echo "source path $source_path"
  2085. echo "C compiler $cc"
  2086. echo ".align is power-of-two $asmalign_pot"
  2087. echo "ARCH $arch ($cpu)"
  2088. if test "$build_suffix" != ""; then
  2089. echo "build suffix $build_suffix"
  2090. fi
  2091. if test "$extra_version" != ""; then
  2092. echo "version string suffix $extra_version"
  2093. fi
  2094. echo "big-endian ${bigendian-no}"
  2095. echo "runtime cpu detection ${runtime_cpudetect-no}"
  2096. if enabled x86; then
  2097. echo "yasm ${yasm-no}"
  2098. echo "MMX enabled ${mmx-no}"
  2099. echo "MMX2 enabled ${mmx2-no}"
  2100. echo "3DNow! enabled ${amd3dnow-no}"
  2101. echo "3DNow! extended enabled ${amd3dnowext-no}"
  2102. echo "SSE enabled ${sse-no}"
  2103. echo "SSSE3 enabled ${ssse3-no}"
  2104. echo "CMOV enabled ${cmov-no}"
  2105. echo "CMOV is fast ${fast_cmov-no}"
  2106. echo "EBX available ${ebx_available-no}"
  2107. echo "EBP available ${ebp_available-no}"
  2108. echo "10 operands supported ${ten_operands-no}"
  2109. fi
  2110. if enabled arm; then
  2111. echo "ARMv5TE enabled ${armv5te-no}"
  2112. echo "ARMv6 enabled ${armv6-no}"
  2113. echo "ARMv6T2 enabled ${armv6t2-no}"
  2114. echo "ARM VFP enabled ${armvfp-no}"
  2115. echo "IWMMXT enabled ${iwmmxt-no}"
  2116. echo "NEON enabled ${neon-no}"
  2117. fi
  2118. if enabled mips; then
  2119. echo "MMI enabled ${mmi-no}"
  2120. fi
  2121. if enabled ppc; then
  2122. echo "AltiVec enabled ${altivec-no}"
  2123. echo "PPC 4xx optimizations ${ppc4xx-no}"
  2124. echo "dcbzl available ${dcbzl-no}"
  2125. echo "performance report ${powerpc_perf-no}"
  2126. fi
  2127. if enabled sparc; then
  2128. echo "VIS enabled ${vis-no}"
  2129. fi
  2130. echo "gprof enabled ${gprof-no}"
  2131. echo "debug symbols ${debug-no}"
  2132. echo "strip symbols ${stripping-no}"
  2133. echo "optimizations ${optimizations-no}"
  2134. echo "static ${static-no}"
  2135. echo "shared ${shared-no}"
  2136. echo "postprocessing support ${postproc-no}"
  2137. echo "new filter support ${avfilter-no}"
  2138. echo "filters using lavformat ${avfilter_lavf-no}"
  2139. echo "network support ${network-no}"
  2140. if enabled network; then
  2141. echo "IPv6 support ${ipv6-no}"
  2142. fi
  2143. echo "threading support ${thread_type-no}"
  2144. echo "SDL support ${sdl-no}"
  2145. if enabled sdl_too_old; then
  2146. echo "-> Your SDL version is too old - please upgrade to have FFplay/SDL support."
  2147. fi
  2148. echo "Sun medialib support ${mlib-no}"
  2149. echo "AVISynth enabled ${avisynth-no}"
  2150. echo "libamr-nb support ${libamr_nb-no}"
  2151. echo "libamr-wb support ${libamr_wb-no}"
  2152. echo "libdc1394 support ${libdc1394-no}"
  2153. echo "libdirac enabled ${libdirac-no}"
  2154. echo "libfaac enabled ${libfaac-no}"
  2155. echo "libfaad enabled ${libfaad-no}"
  2156. echo "libfaad dlopened ${libfaadbin-no}"
  2157. echo "libgsm enabled ${libgsm-no}"
  2158. echo "libmp3lame enabled ${libmp3lame-no}"
  2159. echo "libnut enabled ${libnut-no}"
  2160. echo "libopenjpeg enabled ${libopenjpeg-no}"
  2161. echo "libschroedinger enabled ${libschroedinger-no}"
  2162. echo "libspeex enabled ${libspeex-no}"
  2163. echo "libtheora enabled ${libtheora-no}"
  2164. echo "libvorbis enabled ${libvorbis-no}"
  2165. echo "libx264 enabled ${libx264-no}"
  2166. echo "libxvid enabled ${libxvid-no}"
  2167. echo "zlib enabled ${zlib-no}"
  2168. echo "bzlib enabled ${bzlib-no}"
  2169. echo
  2170. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  2171. echo "Enabled ${type}s:"
  2172. eval list=\$$(toupper $type)_LIST
  2173. for part in $list; do
  2174. enabled $part && echo ${part%_*}
  2175. done | sort | pr -3 -t
  2176. echo
  2177. done
  2178. license="LGPL version 2.1 or later"
  2179. if enabled nonfree; then
  2180. license="nonfree and unredistributable"
  2181. elif enabled gplv3; then
  2182. license="GPL version 3 or later"
  2183. elif enabled lgplv3; then
  2184. license="LGPL version 3 or later"
  2185. elif enabled gpl; then
  2186. license="GPL version 2 or later"
  2187. fi
  2188. echo "License: $license"
  2189. echo "Creating config.mak and config.h..."
  2190. echo "# Automatically generated by configure - do not modify!" > config.mak
  2191. echo "/* Automatically generated by configure - do not modify! */" > $TMPH
  2192. echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
  2193. echo "#define FFMPEG_CONFIG_H" >> $TMPH
  2194. echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
  2195. echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
  2196. echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
  2197. echo "prefix=$prefix" >> config.mak
  2198. echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
  2199. echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
  2200. echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
  2201. echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
  2202. echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
  2203. echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
  2204. echo "SRC_PATH=\"$source_path\"" >> config.mak
  2205. echo "SRC_PATH_BARE=$source_path" >> config.mak
  2206. echo "BUILD_ROOT=\"$PWD\"" >> config.mak
  2207. echo "CC=$cc" >> config.mak
  2208. echo "AS=$as" >> config.mak
  2209. echo "YASM=$yasmexe" >> config.mak
  2210. echo "AR=$ar" >> config.mak
  2211. echo "RANLIB=$ranlib" >> config.mak
  2212. echo "LN_S=$ln_s" >> config.mak
  2213. enabled stripping &&
  2214. echo "STRIP=$strip" >> config.mak ||
  2215. echo "STRIP=echo ignoring strip" >> config.mak
  2216. echo "OPTFLAGS=$CFLAGS" >> config.mak
  2217. echo "LDFLAGS=$LDFLAGS" >> config.mak
  2218. echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
  2219. echo "SHFLAGS=$SHFLAGS" >> config.mak
  2220. echo "YASMFLAGS=$YASMFLAGS" >> config.mak
  2221. echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
  2222. echo "BUILD_STATIC=$static" >> config.mak
  2223. echo "BUILDSUF=$build_suffix" >> config.mak
  2224. echo "FULLNAME=$FULLNAME" >> config.mak
  2225. echo "LIBPREF=$LIBPREF" >> config.mak
  2226. echo "LIBSUF=$LIBSUF" >> config.mak
  2227. echo "LIBNAME=$LIBNAME" >> config.mak
  2228. echo "SLIBPREF=$SLIBPREF" >> config.mak
  2229. echo "SLIBSUF=$SLIBSUF" >> config.mak
  2230. echo "EXESUF=$EXESUF" >> config.mak
  2231. echo "EXTRA_VERSION=$extra_version" >> config.mak
  2232. echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
  2233. echo "HOSTCC=$host_cc" >> config.mak
  2234. echo "HOSTCFLAGS=$host_cflags" >> config.mak
  2235. echo "HOSTEXESUF=$HOSTEXESUF" >> config.mak
  2236. echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
  2237. echo "HOSTLIBS=$host_libs" >> config.mak
  2238. echo "TARGET_EXEC=$target_exec" >> config.mak
  2239. echo "TARGET_PATH=$target_path" >> config.mak
  2240. if enabled bigendian; then
  2241. echo "WORDS_BIGENDIAN=yes" >> config.mak
  2242. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  2243. fi
  2244. if enabled sdl; then
  2245. echo "SDL_LIBS=$("${SDL_CONFIG}" --libs)" >> config.mak
  2246. echo "SDL_CFLAGS=$("${SDL_CONFIG}" --cflags)" >> config.mak
  2247. fi
  2248. if enabled texi2html; then
  2249. echo "BUILD_DOC=yes" >> config.mak
  2250. fi
  2251. get_version(){
  2252. name=$1
  2253. file=$source_path/$2
  2254. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  2255. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  2256. lcname=$(tolower $name)
  2257. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  2258. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  2259. }
  2260. get_version LIBSWSCALE libswscale/swscale.h
  2261. get_version LIBPOSTPROC libpostproc/postprocess.h
  2262. get_version LIBAVCODEC libavcodec/avcodec.h
  2263. get_version LIBAVDEVICE libavdevice/avdevice.h
  2264. get_version LIBAVFORMAT libavformat/avformat.h
  2265. get_version LIBAVUTIL libavutil/avutil.h
  2266. get_version LIBAVFILTER libavfilter/avfilter.h
  2267. if enabled shared; then
  2268. echo "BUILD_SHARED=yes" >> config.mak
  2269. echo "PIC=-fPIC -DPIC" >> config.mak
  2270. echo "LIBTARGET=${LIBTARGET}" >> config.mak
  2271. echo "SLIBNAME=${SLIBNAME}" >> config.mak
  2272. echo "SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}" >> config.mak
  2273. echo "SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}" >> config.mak
  2274. echo "SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}" >> config.mak
  2275. echo "SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}" >> config.mak
  2276. echo "SLIB_INSTALL_EXTRA_CMD=${SLIB_INSTALL_EXTRA_CMD}" >> config.mak
  2277. echo "SLIB_UNINSTALL_EXTRA_CMD=${SLIB_UNINSTALL_EXTRA_CMD}" >> config.mak
  2278. fi
  2279. echo "LIB_INSTALL_EXTRA_CMD=${LIB_INSTALL_EXTRA_CMD}" >> config.mak
  2280. echo "EXTRALIBS=$extralibs" >> config.mak
  2281. echo "ARCH=$arch" >> config.mak
  2282. print_config ARCH_ $TMPH config.mak $ARCH_LIST
  2283. print_config HAVE_ $TMPH config.mak $HAVE_LIST
  2284. print_config CONFIG_ $TMPH config.mak $CONFIG_LIST \
  2285. $CONFIG_EXTRA \
  2286. $DECODER_LIST \
  2287. $ENCODER_LIST \
  2288. $HWACCEL_LIST \
  2289. $PARSER_LIST \
  2290. $BSF_LIST \
  2291. $DEMUXER_LIST \
  2292. $MUXER_LIST \
  2293. $FILTER_LIST \
  2294. $PROTOCOL_LIST \
  2295. $INDEV_LIST \
  2296. $OUTDEV_LIST \
  2297. echo "#define restrict $_restrict" >> $TMPH
  2298. if enabled small; then
  2299. echo "#define av_always_inline" >> $TMPH
  2300. fi
  2301. # Apparently it's not possible to portably echo a backslash.
  2302. enabled asmalign_pot &&
  2303. printf '#define ASMALIGN(ZEROBITS) ".align " #ZEROBITS "\\n\\t"\n' >> $TMPH ||
  2304. printf '#define ASMALIGN(ZEROBITS) ".align 1 << " #ZEROBITS "\\n\\t"\n' >> $TMPH
  2305. echo "#define EXTERN_PREFIX \"${extern_prefix}\"" >> $TMPH
  2306. echo "#endif /* FFMPEG_CONFIG_H */" >> $TMPH
  2307. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  2308. cmp -s $TMPH config.h &&
  2309. echo "config.h is unchanged" ||
  2310. mv -f $TMPH config.h
  2311. # build tree in object directory if source path is different from current one
  2312. if enabled source_path_used; then
  2313. DIRS="\
  2314. doc \
  2315. libavcodec \
  2316. libavcodec/alpha \
  2317. libavcodec/arm \
  2318. libavcodec/bfin \
  2319. libavcodec/mlib \
  2320. libavcodec/ppc \
  2321. libavcodec/sh4 \
  2322. libavcodec/sparc \
  2323. libavcodec/x86 \
  2324. libavdevice \
  2325. libavfilter \
  2326. libavformat \
  2327. libavutil \
  2328. libpostproc \
  2329. libswscale \
  2330. libswscale/bfin \
  2331. libswscale/mlib \
  2332. libswscale/ppc \
  2333. libswscale/sparc \
  2334. libswscale/x86 \
  2335. tests \
  2336. tools \
  2337. "
  2338. FILES="\
  2339. Makefile \
  2340. common.mak \
  2341. subdir.mak \
  2342. doc/texi2pod.pl \
  2343. libavcodec/Makefile \
  2344. libavdevice/Makefile \
  2345. libavfilter/Makefile \
  2346. libavformat/Makefile \
  2347. libavutil/Makefile \
  2348. libpostproc/Makefile \
  2349. libswscale/Makefile \
  2350. "
  2351. for dir in $DIRS ; do
  2352. mkdir -p $dir
  2353. done
  2354. for f in $FILES ; do
  2355. $ln_s "$source_path/$f" $f
  2356. done
  2357. fi
  2358. # build pkg-config files
  2359. pkgconfig_generate(){
  2360. name=$1
  2361. shortname=${name#lib}${build_suffix}
  2362. comment=$2
  2363. version=$3
  2364. libs=$4
  2365. requires=$5
  2366. cat <<EOF > $name/$name.pc
  2367. prefix=$prefix
  2368. exec_prefix=\${prefix}
  2369. libdir=$libdir
  2370. includedir=$incdir
  2371. Name: $name
  2372. Description: $comment
  2373. Version: $version
  2374. Requires: $(disabled shared && echo $requires)
  2375. Requires.private: $(enabled shared && echo $requires)
  2376. Conflicts:
  2377. Libs: -L\${libdir} -l${shortname} $(disabled shared && echo $libs)
  2378. Libs.private: $(enabled shared && echo $libs)
  2379. Cflags: -I\${includedir}
  2380. EOF
  2381. cat <<EOF > $name/$name-uninstalled.pc
  2382. prefix=
  2383. exec_prefix=
  2384. libdir=\${pcfiledir}
  2385. includedir=${source_path}
  2386. Name: $name
  2387. Description: $comment
  2388. Version: $version
  2389. Requires: $requires
  2390. Conflicts:
  2391. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  2392. Cflags: -I\${includedir}
  2393. EOF
  2394. }
  2395. pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION"
  2396. pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2397. pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  2398. pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  2399. enabled avfilter &&
  2400. pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  2401. enabled postproc &&
  2402. pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
  2403. pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"