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.

2131 lines
61KB

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