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.

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