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.

2576 lines
74KB

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