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.

2302 lines
66KB

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