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.

2515 lines
73KB

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