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.

2178 lines
58KB

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