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.

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