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.

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