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.

2494 lines
72KB

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