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.

2148 lines
57KB

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