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.

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