You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2178 lines
58KB

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