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.

2079 lines
57KB

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