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.

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