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.

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