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.

2451 lines
71KB

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