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.

3473 lines
103KB

  1. #!/bin/sh
  2. #
  3. # Libav configure script
  4. #
  5. # Copyright (c) 2000-2002 Fabrice Bellard
  6. # Copyright (c) 2005-2008 Diego Biurrun
  7. # Copyright (c) 2005-2008 Mans Rullgard
  8. #
  9. # Prevent locale nonsense from breaking basic text processing.
  10. LC_ALL=C
  11. export LC_ALL
  12. # make sure we are running under a compatible shell
  13. # try to make this part work with most shells
  14. try_exec(){
  15. echo "Trying shell $1"
  16. type "$1" > /dev/null 2>&1 && exec "$@"
  17. }
  18. unset foo
  19. (: ${foo%%bar}) 2> /dev/null
  20. E1="$?"
  21. (: ${foo?}) 2> /dev/null
  22. E2="$?"
  23. if test "$E1" != 0 || test "$E2" = 0; then
  24. echo "Broken shell detected. Trying alternatives."
  25. export FF_CONF_EXEC
  26. if test "0$FF_CONF_EXEC" -lt 1; then
  27. FF_CONF_EXEC=1
  28. try_exec bash "$0" "$@"
  29. fi
  30. if test "0$FF_CONF_EXEC" -lt 2; then
  31. FF_CONF_EXEC=2
  32. try_exec ksh "$0" "$@"
  33. fi
  34. if test "0$FF_CONF_EXEC" -lt 3; then
  35. FF_CONF_EXEC=3
  36. try_exec /usr/xpg4/bin/sh "$0" "$@"
  37. fi
  38. echo "No compatible shell script interpreter found."
  39. echo "This configure script requires a POSIX-compatible shell"
  40. echo "such as bash or ksh."
  41. echo "THIS IS NOT A BUG IN LIBAV, DO NOT REPORT IT AS SUCH."
  42. echo "Instead, install a working POSIX-compatible shell."
  43. echo "Disabling this configure test will create a broken Libav."
  44. if test "$BASH_VERSION" = '2.04.0(1)-release'; then
  45. echo "This bash version ($BASH_VERSION) is broken on your platform."
  46. echo "Upgrade to a later version if available."
  47. fi
  48. exit 1
  49. fi
  50. show_help(){
  51. cat <<EOF
  52. Usage: configure [options]
  53. Options: [defaults in brackets after descriptions]
  54. Standard options:
  55. --help print this message
  56. --logfile=FILE log tests and output to FILE [config.log]
  57. --disable-logging do not log configure debug information
  58. --prefix=PREFIX install in PREFIX [$prefix]
  59. --bindir=DIR install binaries in DIR [PREFIX/bin]
  60. --datadir=DIR install data files in DIR [PREFIX/share/avconv]
  61. --libdir=DIR install libs in DIR [PREFIX/lib]
  62. --shlibdir=DIR install shared libs in DIR [PREFIX/lib]
  63. --incdir=DIR install includes in DIR [PREFIX/include]
  64. --mandir=DIR install man page in DIR [PREFIX/share/man]
  65. Configuration options:
  66. --disable-static do not build static libraries [no]
  67. --enable-shared build shared libraries [no]
  68. --enable-gpl allow use of GPL code, the resulting libs
  69. and binaries will be under GPL [no]
  70. --enable-version3 upgrade (L)GPL to version 3 [no]
  71. --enable-nonfree allow use of nonfree code, the resulting libs
  72. and binaries will be unredistributable [no]
  73. --disable-doc do not build documentation
  74. --disable-ffmpeg disable ffmpeg build
  75. --disable-avconv disable avconv build
  76. --disable-avplay disable avplay build
  77. --disable-avprobe disable avprobe build
  78. --disable-avserver disable avserver build
  79. --disable-avdevice disable libavdevice build
  80. --disable-avcodec disable libavcodec build
  81. --disable-avformat disable libavformat build
  82. --disable-swscale disable libswscale build
  83. --disable-postproc disable libpostproc build
  84. --disable-avfilter disable video filter support [no]
  85. --disable-pthreads disable pthreads [auto]
  86. --disable-w32threads disable Win32 threads [auto]
  87. --enable-x11grab enable X11 grabbing [no]
  88. --disable-network disable network support [no]
  89. --enable-gray enable full grayscale support (slower color)
  90. --disable-swscale-alpha disable alpha channel support in swscale
  91. --disable-fastdiv disable table-based division
  92. --enable-small optimize for size instead of speed
  93. --disable-aandct disable AAN DCT code
  94. --disable-dct disable DCT code
  95. --disable-fft disable FFT code
  96. --disable-golomb disable Golomb code
  97. --disable-huffman disable Huffman code
  98. --disable-lpc disable LPC code
  99. --disable-mdct disable MDCT code
  100. --disable-rdft disable RDFT code
  101. --enable-vaapi enable VAAPI code
  102. --enable-vda enable VDA code
  103. --enable-vdpau enable VDPAU code
  104. --disable-dxva2 disable DXVA2 code
  105. --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)
  106. --enable-hardcoded-tables use hardcoded tables instead of runtime generation
  107. --enable-memalign-hack emulate memalign, interferes with memory debuggers
  108. --disable-everything disable all components listed below
  109. --disable-encoder=NAME disable encoder NAME
  110. --enable-encoder=NAME enable encoder NAME
  111. --disable-encoders disable all encoders
  112. --disable-decoder=NAME disable decoder NAME
  113. --enable-decoder=NAME enable decoder NAME
  114. --disable-decoders disable all decoders
  115. --disable-hwaccel=NAME disable hwaccel NAME
  116. --enable-hwaccel=NAME enable hwaccel NAME
  117. --disable-hwaccels disable all hwaccels
  118. --disable-muxer=NAME disable muxer NAME
  119. --enable-muxer=NAME enable muxer NAME
  120. --disable-muxers disable all muxers
  121. --disable-demuxer=NAME disable demuxer NAME
  122. --enable-demuxer=NAME enable demuxer NAME
  123. --disable-demuxers disable all demuxers
  124. --enable-parser=NAME enable parser NAME
  125. --disable-parser=NAME disable parser NAME
  126. --disable-parsers disable all parsers
  127. --enable-bsf=NAME enable bitstream filter NAME
  128. --disable-bsf=NAME disable bitstream filter NAME
  129. --disable-bsfs disable all bitstream filters
  130. --enable-protocol=NAME enable protocol NAME
  131. --disable-protocol=NAME disable protocol NAME
  132. --disable-protocols disable all protocols
  133. --disable-indev=NAME disable input device NAME
  134. --disable-outdev=NAME disable output device NAME
  135. --disable-indevs disable input devices
  136. --disable-outdevs disable output devices
  137. --disable-devices disable all devices
  138. --enable-filter=NAME enable filter NAME
  139. --disable-filter=NAME disable filter NAME
  140. --disable-filters disable all filters
  141. --list-decoders show all available decoders
  142. --list-encoders show all available encoders
  143. --list-hwaccels show all available hardware accelerators
  144. --list-muxers show all available muxers
  145. --list-demuxers show all available demuxers
  146. --list-parsers show all available parsers
  147. --list-protocols show all available protocols
  148. --list-bsfs show all available bitstream filters
  149. --list-indevs show all available input devices
  150. --list-outdevs show all available output devices
  151. --list-filters show all available filters
  152. External library support:
  153. --enable-avisynth enable reading of AVISynth script files [no]
  154. --enable-bzlib enable bzlib [autodetect]
  155. --enable-frei0r enable frei0r video filtering
  156. --enable-gnutls enable gnutls [no]
  157. --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]
  158. --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]
  159. --enable-libopencv enable video filtering via libopencv [no]
  160. --enable-libcdio enable audio CD grabbing with libcdio
  161. --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394
  162. and libraw1394 [no]
  163. --enable-libdirac enable Dirac support via libdirac [no]
  164. --enable-libfaac enable FAAC support via libfaac [no]
  165. --enable-libfreetype enable libfreetype [no]
  166. --enable-libgsm enable GSM support via libgsm [no]
  167. --enable-libmp3lame enable MP3 encoding via libmp3lame [no]
  168. --enable-libnut enable NUT (de)muxing via libnut,
  169. native (de)muxer exists [no]
  170. --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no]
  171. --enable-librtmp enable RTMP[E] support via librtmp [no]
  172. --enable-libschroedinger enable Dirac support via libschroedinger [no]
  173. --enable-libspeex enable Speex support via libspeex [no]
  174. --enable-libtheora enable Theora encoding via libtheora [no]
  175. --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no]
  176. --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no]
  177. --enable-libvorbis enable Vorbis encoding via libvorbis,
  178. native implementation exists [no]
  179. --enable-libvpx enable VP8 support via libvpx [no]
  180. --enable-libx264 enable H.264 encoding via x264 [no]
  181. --enable-libxavs enable AVS encoding via xavs [no]
  182. --enable-libxvid enable Xvid encoding via xvidcore,
  183. native MPEG-4/Xvid encoder exists [no]
  184. --enable-mlib enable Sun medialib [no]
  185. --enable-openssl enable openssl [no]
  186. --enable-zlib enable zlib [autodetect]
  187. Advanced options (experts only):
  188. --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
  189. --enable-cross-compile assume a cross-compiler is used
  190. --sysroot=PATH root of cross-build tree
  191. --sysinclude=PATH location of cross-build system headers
  192. --target-os=OS compiler targets OS [$target_os]
  193. --target-exec=CMD command to run executables on target
  194. --target-path=DIR path to view of build directory on target
  195. --nm=NM use nm tool
  196. --ar=AR use archive tool AR [$ar_default]
  197. --as=AS use assembler AS [$as_default]
  198. --cc=CC use C compiler CC [$cc_default]
  199. --ld=LD use linker LD
  200. --host-cc=HOSTCC use host C compiler HOSTCC
  201. --host-cflags=HCFLAGS use HCFLAGS when compiling for host
  202. --host-ldflags=HLDFLAGS use HLDFLAGS when linking for host
  203. --host-libs=HLIBS use libs HLIBS when linking for host
  204. --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]
  205. --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]
  206. --extra-libs=ELIBS add ELIBS [$ELIBS]
  207. --extra-version=STRING version string suffix []
  208. --build-suffix=SUFFIX library name suffix []
  209. --arch=ARCH select architecture [$arch]
  210. --cpu=CPU select the minimum required CPU (affects
  211. instruction selection, may crash on older CPUs)
  212. --disable-asm disable all assembler optimizations
  213. --disable-altivec disable AltiVec optimizations
  214. --disable-amd3dnow disable 3DNow! optimizations
  215. --disable-amd3dnowext disable 3DNow! extended optimizations
  216. --disable-mmx disable MMX optimizations
  217. --disable-mmx2 disable MMX2 optimizations
  218. --disable-sse disable SSE optimizations
  219. --disable-ssse3 disable SSSE3 optimizations
  220. --disable-avx disable AVX optimizations
  221. --disable-armv5te disable armv5te optimizations
  222. --disable-armv6 disable armv6 optimizations
  223. --disable-armv6t2 disable armv6t2 optimizations
  224. --disable-armvfp disable ARM VFP optimizations
  225. --disable-iwmmxt disable iwmmxt optimizations
  226. --disable-mmi disable MMI optimizations
  227. --disable-neon disable neon optimizations
  228. --disable-vis disable VIS optimizations
  229. --disable-yasm disable use of yasm assembler
  230. --enable-pic build position-independent code
  231. --malloc-prefix=PFX prefix malloc and related names with PFX
  232. --enable-sram allow use of on-chip SRAM
  233. --disable-symver disable symbol versioning
  234. --optflags override optimization-related compiler flags
  235. Developer options (useful when working on Libav itself):
  236. --disable-debug disable debugging symbols
  237. --enable-debug=LEVEL set the debug level [$debuglevel]
  238. --disable-optimizations disable compiler optimizations
  239. --enable-extra-warnings enable more compiler warnings
  240. --samples=PATH location of test samples for FATE, if not set use
  241. \$FATE_SAMPLES at make invocation time.
  242. NOTE: Object files are built at the place where configure is launched.
  243. EOF
  244. exit 0
  245. }
  246. quotes='""'
  247. log(){
  248. echo "$@" >> $logfile
  249. }
  250. log_file(){
  251. log BEGIN $1
  252. pr -n -t $1 >> $logfile
  253. log END $1
  254. }
  255. echolog(){
  256. log "$@"
  257. echo "$@"
  258. }
  259. warn(){
  260. log "WARNING: $*"
  261. WARNINGS="${WARNINGS}WARNING: $*\n"
  262. }
  263. die(){
  264. echolog "$@"
  265. cat <<EOF
  266. If you think configure made a mistake, make sure you are using the latest
  267. version from Git. If the latest version fails, report the problem to the
  268. libav-user@libav.org mailing list or IRC #libav on irc.freenode.net.
  269. EOF
  270. if disabled logging; then
  271. cat <<EOF
  272. Rerun configure with logging enabled (do not use --disable-logging), and
  273. include the log this produces with your report.
  274. EOF
  275. else
  276. cat <<EOF
  277. Include the log file "$logfile" produced by configure as this will help
  278. solving the problem.
  279. EOF
  280. fi
  281. exit 1
  282. }
  283. # Avoid locale weirdness, besides we really just want to translate ASCII.
  284. toupper(){
  285. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  286. }
  287. tolower(){
  288. echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
  289. }
  290. c_escape(){
  291. echo "$*" | sed 's/["\\]/\\\0/g'
  292. }
  293. sh_quote(){
  294. v=$(echo "$1" | sed "s/'/'\\\\''/g")
  295. test "x$v" = "x${v#*[!A-Za-z0-9_/.+-]}" || v="'$v'"
  296. echo "$v"
  297. }
  298. cleanws(){
  299. echo "$@" | sed 's/^ *//;s/ */ /g;s/ *$//'
  300. }
  301. filter(){
  302. pat=$1
  303. shift
  304. for v; do
  305. eval "case $v in $pat) echo $v ;; esac"
  306. done
  307. }
  308. filter_out(){
  309. pat=$1
  310. shift
  311. for v; do
  312. eval "case $v in $pat) ;; *) echo $v ;; esac"
  313. done
  314. }
  315. map(){
  316. m=$1
  317. shift
  318. for v; do eval $m; done
  319. }
  320. set_all(){
  321. value=$1
  322. shift
  323. for var in $*; do
  324. eval $var=$value
  325. done
  326. }
  327. set_weak(){
  328. value=$1
  329. shift
  330. for var; do
  331. eval : \${$var:=$value}
  332. done
  333. }
  334. set_safe(){
  335. var=$1
  336. shift
  337. eval $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')='$*'
  338. }
  339. get_safe(){
  340. eval echo \$$(echo "$1" | sed 's/[^A-Za-z0-9_]/_/g')
  341. }
  342. pushvar(){
  343. for var in $*; do
  344. eval level=\${${var}_level:=0}
  345. eval ${var}_${level}="\$$var"
  346. eval ${var}_level=$(($level+1))
  347. done
  348. }
  349. popvar(){
  350. for var in $*; do
  351. eval level=\${${var}_level:-0}
  352. test $level = 0 && continue
  353. eval level=$(($level-1))
  354. eval $var="\${${var}_${level}}"
  355. eval ${var}_level=$level
  356. eval unset ${var}_${level}
  357. done
  358. }
  359. enable(){
  360. set_all yes $*
  361. }
  362. disable(){
  363. set_all no $*
  364. }
  365. enable_weak(){
  366. set_weak yes $*
  367. }
  368. disable_weak(){
  369. set_weak no $*
  370. }
  371. enable_safe(){
  372. for var; do
  373. enable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  374. done
  375. }
  376. disable_safe(){
  377. for var; do
  378. disable $(echo "$var" | sed 's/[^A-Za-z0-9_]/_/g')
  379. done
  380. }
  381. do_enable_deep(){
  382. for var; do
  383. enabled $var && continue
  384. eval sel="\$${var}_select"
  385. eval sgs="\$${var}_suggest"
  386. pushvar var sgs
  387. enable_deep $sel
  388. popvar sgs
  389. enable_deep_weak $sgs
  390. popvar var
  391. done
  392. }
  393. enable_deep(){
  394. do_enable_deep $*
  395. enable $*
  396. }
  397. enable_deep_weak(){
  398. do_enable_deep $*
  399. enable_weak $*
  400. }
  401. enabled(){
  402. test "${1#!}" = "$1" && op== || op=!=
  403. eval test "x\$${1#!}" $op "xyes"
  404. }
  405. disabled(){
  406. test "${1#!}" = "$1" && op== || op=!=
  407. eval test "x\$${1#!}" $op "xno"
  408. }
  409. enabled_all(){
  410. for opt; do
  411. enabled $opt || return 1
  412. done
  413. }
  414. disabled_all(){
  415. for opt; do
  416. disabled $opt || return 1
  417. done
  418. }
  419. enabled_any(){
  420. for opt; do
  421. enabled $opt && return 0
  422. done
  423. }
  424. disabled_any(){
  425. for opt; do
  426. disabled $opt && return 0
  427. done
  428. return 1
  429. }
  430. set_default(){
  431. for opt; do
  432. eval : \${$opt:=\$${opt}_default}
  433. done
  434. }
  435. is_in(){
  436. value=$1
  437. shift
  438. for var in $*; do
  439. [ $var = $value ] && return 0
  440. done
  441. return 1
  442. }
  443. check_deps(){
  444. for cfg; do
  445. cfg="${cfg#!}"
  446. enabled ${cfg}_checking && die "Circular dependency for $cfg."
  447. disabled ${cfg}_checking && continue
  448. enable ${cfg}_checking
  449. eval dep_all="\$${cfg}_deps"
  450. eval dep_any="\$${cfg}_deps_any"
  451. eval dep_sel="\$${cfg}_select"
  452. eval dep_sgs="\$${cfg}_suggest"
  453. eval dep_ifa="\$${cfg}_if"
  454. eval dep_ifn="\$${cfg}_if_any"
  455. pushvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  456. check_deps $dep_all $dep_any $dep_sel $dep_sgs $dep_ifa $dep_ifn
  457. popvar cfg dep_all dep_any dep_sel dep_sgs dep_ifa dep_ifn
  458. [ -n "$dep_ifa" ] && { enabled_all $dep_ifa && enable_weak $cfg; }
  459. [ -n "$dep_ifn" ] && { enabled_any $dep_ifn && enable_weak $cfg; }
  460. enabled_all $dep_all || disable $cfg
  461. enabled_any $dep_any || disable $cfg
  462. disabled_any $dep_sel && disable $cfg
  463. if enabled $cfg; then
  464. eval dep_extralibs="\$${cfg}_extralibs"
  465. test -n "$dep_extralibs" && add_extralibs $dep_extralibs
  466. enable_deep $dep_sel
  467. enable_deep_weak $dep_sgs
  468. fi
  469. disable ${cfg}_checking
  470. done
  471. }
  472. print_config_h(){
  473. enabled $1 && v=1 || v=0
  474. echo "#define $2 $v"
  475. }
  476. print_config_mak(){
  477. enabled $1 && v= || v=!
  478. echo "$v$2=yes"
  479. }
  480. print_config_asm(){
  481. enabled $1 && echo "%define $2"
  482. }
  483. print_config(){
  484. pfx=$1
  485. files=$2
  486. shift 2
  487. for cfg; do
  488. ucname="$(toupper $cfg)"
  489. for f in $files; do
  490. "print_config_${f##*.}" $cfg ${pfx}${ucname} >>$f
  491. done
  492. done
  493. }
  494. print_enabled(){
  495. test "$1" = -n && end=" " && shift || end="\n"
  496. suf=$1
  497. shift
  498. for v; do
  499. enabled $v && printf "%s$end" ${v%$suf};
  500. done
  501. }
  502. append(){
  503. var=$1
  504. shift
  505. eval "$var=\"\$$var $*\""
  506. }
  507. prepend(){
  508. var=$1
  509. shift
  510. eval "$var=\"$* \$$var\""
  511. }
  512. add_cppflags(){
  513. append CPPFLAGS $($filter_cppflags "$@")
  514. }
  515. add_cflags(){
  516. append CFLAGS $($filter_cflags "$@")
  517. }
  518. add_asflags(){
  519. append ASFLAGS $($filter_asflags "$@")
  520. }
  521. add_ldflags(){
  522. append LDFLAGS "$@"
  523. }
  524. add_extralibs(){
  525. prepend extralibs "$@"
  526. }
  527. check_cmd(){
  528. log "$@"
  529. "$@" >> $logfile 2>&1
  530. }
  531. check_cc(){
  532. log check_cc "$@"
  533. cat > $TMPC
  534. log_file $TMPC
  535. check_cmd $cc $CPPFLAGS $CFLAGS "$@" -c -o $TMPO $TMPC
  536. }
  537. check_cpp(){
  538. log check_cpp "$@"
  539. cat > $TMPC
  540. log_file $TMPC
  541. check_cmd $cc $CPPFLAGS $CFLAGS "$@" -E -o $TMPO $TMPC
  542. }
  543. check_as(){
  544. log check_as "$@"
  545. cat > $TMPC
  546. log_file $TMPC
  547. check_cmd $as $CPPFLAGS $ASFLAGS "$@" -c -o $TMPO $TMPC
  548. }
  549. check_asm(){
  550. log check_asm "$@"
  551. name="$1"
  552. code="$2"
  553. shift 2
  554. disable $name
  555. check_as "$@" <<EOF && enable $name
  556. void foo(void){ __asm__ volatile($code); }
  557. EOF
  558. }
  559. check_yasm(){
  560. log check_yasm "$@"
  561. echo "$1" > $TMPS
  562. log_file $TMPS
  563. shift 1
  564. check_cmd $yasmexe $YASMFLAGS "$@" -o $TMPO $TMPS
  565. }
  566. check_ld(){
  567. log check_ld "$@"
  568. flags=''
  569. libs=''
  570. for f; do
  571. test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
  572. done
  573. check_cc $($filter_cflags $flags) || return
  574. check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $libs $extralibs
  575. }
  576. check_cppflags(){
  577. log check_cppflags "$@"
  578. set -- $($filter_cppflags "$@")
  579. check_cc "$@" <<EOF && append CPPFLAGS "$@"
  580. int x;
  581. EOF
  582. }
  583. check_cflags(){
  584. log check_cflags "$@"
  585. set -- $($filter_cflags "$@")
  586. check_cc "$@" <<EOF && append CFLAGS "$@"
  587. int x;
  588. EOF
  589. }
  590. test_ldflags(){
  591. log test_ldflags "$@"
  592. check_ld "$@" <<EOF
  593. int main(void){ return 0; }
  594. EOF
  595. }
  596. check_ldflags(){
  597. log check_ldflags "$@"
  598. test_ldflags "$@" && add_ldflags "$@"
  599. }
  600. check_header(){
  601. log check_header "$@"
  602. header=$1
  603. shift
  604. disable_safe $header
  605. check_cpp "$@" <<EOF && enable_safe $header
  606. #include <$header>
  607. int x;
  608. EOF
  609. }
  610. check_func(){
  611. log check_func "$@"
  612. func=$1
  613. shift
  614. disable $func
  615. check_ld "$@" <<EOF && enable $func
  616. extern int $func();
  617. int main(void){ $func(); }
  618. EOF
  619. }
  620. check_mathfunc(){
  621. log check_mathfunc "$@"
  622. func=$1
  623. shift
  624. disable $func
  625. check_ld "$@" <<EOF && enable $func
  626. #include <math.h>
  627. float foo(float f) { return $func(f); }
  628. int main(void){ return 0; }
  629. EOF
  630. }
  631. check_func_headers(){
  632. log check_func_headers "$@"
  633. headers=$1
  634. funcs=$2
  635. shift 2
  636. {
  637. for hdr in $headers; do
  638. echo "#include <$hdr>"
  639. done
  640. for func in $funcs; do
  641. echo "long check_$func(void) { return (long) $func; }"
  642. done
  643. echo "int main(void) { return 0; }"
  644. } | check_ld "$@" && enable $funcs && enable_safe $headers
  645. }
  646. check_cpp_condition(){
  647. log check_cpp_condition "$@"
  648. header=$1
  649. condition=$2
  650. shift 2
  651. check_cpp $($filter_cppflags "$@") <<EOF
  652. #include <$header>
  653. #if !($condition)
  654. #error "unsatisfied condition: $condition"
  655. #endif
  656. EOF
  657. }
  658. check_lib(){
  659. log check_lib "$@"
  660. header="$1"
  661. func="$2"
  662. shift 2
  663. check_header $header && check_func $func "$@" && add_extralibs "$@"
  664. }
  665. check_lib2(){
  666. log check_lib2 "$@"
  667. headers="$1"
  668. funcs="$2"
  669. shift 2
  670. check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
  671. }
  672. check_pkg_config(){
  673. log check_pkg_config "$@"
  674. pkg="$1"
  675. headers="$2"
  676. funcs="$3"
  677. shift 3
  678. $pkg_config --exists $pkg || return
  679. pkg_cflags=$($pkg_config --cflags $pkg)
  680. pkg_libs=$($pkg_config --libs $pkg)
  681. check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
  682. set_safe ${pkg}_cflags $pkg_cflags &&
  683. set_safe ${pkg}_libs $pkg_libs
  684. }
  685. check_exec(){
  686. check_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
  687. }
  688. check_exec_crash(){
  689. code=$(cat)
  690. # exit() is not async signal safe. _Exit (C99) and _exit (POSIX)
  691. # are safe but may not be available everywhere. Thus we use
  692. # raise(SIGTERM) instead. The check is run in a subshell so we
  693. # can redirect the "Terminated" message from the shell. SIGBUS
  694. # is not defined by standard C so it is used conditionally.
  695. (check_exec "$@") >> $logfile 2>&1 <<EOF
  696. #include <signal.h>
  697. static void sighandler(int sig){
  698. raise(SIGTERM);
  699. }
  700. int main(void){
  701. signal(SIGILL, sighandler);
  702. signal(SIGFPE, sighandler);
  703. signal(SIGSEGV, sighandler);
  704. #ifdef SIGBUS
  705. signal(SIGBUS, sighandler);
  706. #endif
  707. { $code }
  708. }
  709. EOF
  710. }
  711. check_type(){
  712. log check_type "$@"
  713. headers=$1
  714. type=$2
  715. shift 2
  716. disable_safe "$type"
  717. incs=""
  718. for hdr in $headers; do
  719. incs="$incs
  720. #include <$hdr>"
  721. done
  722. check_cc "$@" <<EOF && enable_safe "$type"
  723. $incs
  724. $type v;
  725. EOF
  726. }
  727. check_struct(){
  728. log check_type "$@"
  729. headers=$1
  730. struct=$2
  731. member=$3
  732. shift 3
  733. disable_safe "${struct}_${member}"
  734. incs=""
  735. for hdr in $headers; do
  736. incs="$incs
  737. #include <$hdr>"
  738. done
  739. check_cc "$@" <<EOF && enable_safe "${struct}_${member}"
  740. $incs
  741. const void *p = &(($struct *)0)->$member;
  742. EOF
  743. }
  744. require(){
  745. name="$1"
  746. header="$2"
  747. func="$3"
  748. shift 3
  749. check_lib $header $func "$@" || die "ERROR: $name not found"
  750. }
  751. require2(){
  752. name="$1"
  753. headers="$2"
  754. func="$3"
  755. shift 3
  756. check_lib2 "$headers" $func "$@" || die "ERROR: $name not found"
  757. }
  758. require_pkg_config(){
  759. pkg="$1"
  760. check_pkg_config "$@" || die "ERROR: $pkg not found"
  761. add_cflags $(get_safe ${pkg}_cflags)
  762. add_extralibs $(get_safe ${pkg}_libs)
  763. }
  764. check_host_cc(){
  765. log check_host_cc "$@"
  766. cat > $TMPC
  767. log_file $TMPC
  768. check_cmd $host_cc $host_cflags "$@" -c -o $TMPO $TMPC
  769. }
  770. check_host_cflags(){
  771. log check_host_cflags "$@"
  772. check_host_cc "$@" <<EOF && append host_cflags "$@"
  773. int x;
  774. EOF
  775. }
  776. apply(){
  777. file=$1
  778. shift
  779. "$@" < "$file" > "$file.tmp" && mv "$file.tmp" "$file" || rm "$file.tmp"
  780. }
  781. cp_if_changed(){
  782. cmp -s "$1" "$2" && echo "$2 is unchanged" && return
  783. mkdir -p "$(dirname $2)"
  784. cp -f "$1" "$2"
  785. }
  786. # CONFIG_LIST contains configurable options, while HAVE_LIST is for
  787. # system-dependent things.
  788. COMPONENT_LIST="
  789. bsfs
  790. decoders
  791. demuxers
  792. encoders
  793. filters
  794. hwaccels
  795. indevs
  796. muxers
  797. outdevs
  798. parsers
  799. protocols
  800. "
  801. CONFIG_LIST="
  802. $COMPONENT_LIST
  803. aandct
  804. ac3dsp
  805. avcodec
  806. avdevice
  807. avfilter
  808. avformat
  809. avisynth
  810. bzlib
  811. dct
  812. doc
  813. dwt
  814. dxva2
  815. fastdiv
  816. ffmpeg
  817. avconv
  818. avplay
  819. avprobe
  820. avserver
  821. fft
  822. frei0r
  823. gnutls
  824. golomb
  825. gpl
  826. gray
  827. h264dsp
  828. h264pred
  829. hardcoded_tables
  830. huffman
  831. libcdio
  832. libdc1394
  833. libdirac
  834. libfaac
  835. libfreetype
  836. libgsm
  837. libmp3lame
  838. libnut
  839. libopencore_amrnb
  840. libopencore_amrwb
  841. libopencv
  842. libopenjpeg
  843. libpulse
  844. librtmp
  845. libschroedinger
  846. libspeex
  847. libtheora
  848. libvo_aacenc
  849. libvo_amrwbenc
  850. libvorbis
  851. libvpx
  852. libx264
  853. libxavs
  854. libxvid
  855. lpc
  856. lsp
  857. mdct
  858. memalign_hack
  859. mlib
  860. mpegaudiodsp
  861. network
  862. nonfree
  863. openssl
  864. pic
  865. postproc
  866. rdft
  867. rtpdec
  868. runtime_cpudetect
  869. shared
  870. sinewin
  871. small
  872. sram
  873. static
  874. swscale
  875. swscale_alpha
  876. thumb
  877. vaapi
  878. vda
  879. vdpau
  880. version3
  881. x11grab
  882. zlib
  883. "
  884. THREADS_LIST='
  885. pthreads
  886. w32threads
  887. '
  888. ARCH_LIST='
  889. alpha
  890. arm
  891. avr32
  892. avr32_ap
  893. avr32_uc
  894. bfin
  895. ia64
  896. m68k
  897. mips
  898. mips64
  899. parisc
  900. ppc
  901. ppc64
  902. s390
  903. sh4
  904. sparc
  905. sparc64
  906. tomi
  907. x86
  908. x86_32
  909. x86_64
  910. '
  911. ARCH_EXT_LIST='
  912. altivec
  913. amd3dnow
  914. amd3dnowext
  915. armv5te
  916. armv6
  917. armv6t2
  918. armvfp
  919. avx
  920. iwmmxt
  921. mmi
  922. mmx
  923. mmx2
  924. neon
  925. ppc4xx
  926. sse
  927. ssse3
  928. vfpv3
  929. vis
  930. '
  931. HAVE_LIST_PUB='
  932. bigendian
  933. fast_unaligned
  934. '
  935. HAVE_LIST="
  936. $ARCH_EXT_LIST
  937. $HAVE_LIST_PUB
  938. $THREADS_LIST
  939. aligned_stack
  940. alsa_asoundlib_h
  941. altivec_h
  942. arpa_inet_h
  943. asm_mod_y
  944. attribute_may_alias
  945. attribute_packed
  946. bswap
  947. closesocket
  948. cmov
  949. dcbzl
  950. dev_bktr_ioctl_bt848_h
  951. dev_bktr_ioctl_meteor_h
  952. dev_ic_bt8xx_h
  953. dev_video_meteor_ioctl_meteor_h
  954. dev_video_bktr_ioctl_bt848_h
  955. dlfcn_h
  956. dlopen
  957. dos_paths
  958. ebp_available
  959. ebx_available
  960. exp2
  961. exp2f
  962. fast_64bit
  963. fast_clz
  964. fast_cmov
  965. fcntl
  966. fork
  967. getaddrinfo
  968. gethrtime
  969. GetProcessMemoryInfo
  970. GetProcessTimes
  971. getrusage
  972. gnu_as
  973. struct_rusage_ru_maxrss
  974. ibm_asm
  975. inet_aton
  976. inline_asm
  977. isatty
  978. ldbrx
  979. libdc1394_1
  980. libdc1394_2
  981. llrint
  982. llrintf
  983. local_aligned_16
  984. local_aligned_8
  985. localtime_r
  986. log2
  987. log2f
  988. loongson
  989. lrint
  990. lrintf
  991. lzo1x_999_compress
  992. machine_ioctl_bt848_h
  993. machine_ioctl_meteor_h
  994. malloc_h
  995. MapViewOfFile
  996. memalign
  997. mkstemp
  998. mmap
  999. posix_memalign
  1000. round
  1001. roundf
  1002. sdl
  1003. sdl_video_size
  1004. setmode
  1005. sndio_h
  1006. socklen_t
  1007. soundcard_h
  1008. poll_h
  1009. setrlimit
  1010. strerror_r
  1011. strptime
  1012. strtok_r
  1013. struct_addrinfo
  1014. struct_ipv6_mreq
  1015. struct_sockaddr_in6
  1016. struct_sockaddr_sa_len
  1017. struct_sockaddr_storage
  1018. symver
  1019. symver_gnu_asm
  1020. symver_asm_label
  1021. sys_mman_h
  1022. sys_resource_h
  1023. sys_select_h
  1024. sys_soundcard_h
  1025. sys_videoio_h
  1026. threads
  1027. trunc
  1028. truncf
  1029. vfp_args
  1030. VirtualAlloc
  1031. winsock2_h
  1032. xform_asm
  1033. xmm_clobbers
  1034. yasm
  1035. "
  1036. # options emitted with CONFIG_ prefix but not available on command line
  1037. CONFIG_EXTRA="
  1038. avutil
  1039. gplv3
  1040. lgplv3
  1041. "
  1042. CMDLINE_SELECT="
  1043. $ARCH_EXT_LIST
  1044. $CONFIG_LIST
  1045. $THREADS_LIST
  1046. asm
  1047. cross_compile
  1048. debug
  1049. extra_warnings
  1050. logging
  1051. optimizations
  1052. symver
  1053. yasm
  1054. "
  1055. PATHS_LIST='
  1056. bindir
  1057. datadir
  1058. incdir
  1059. libdir
  1060. mandir
  1061. prefix
  1062. shlibdir
  1063. '
  1064. CMDLINE_SET="
  1065. $PATHS_LIST
  1066. ar
  1067. arch
  1068. as
  1069. build_suffix
  1070. cc
  1071. cpu
  1072. cross_prefix
  1073. dep_cc
  1074. extra_version
  1075. host_cc
  1076. host_cflags
  1077. host_ldflags
  1078. host_libs
  1079. host_os
  1080. ld
  1081. logfile
  1082. malloc_prefix
  1083. nm
  1084. optflags
  1085. pkg_config
  1086. samples
  1087. sysinclude
  1088. sysroot
  1089. target_exec
  1090. target_os
  1091. target_path
  1092. "
  1093. CMDLINE_APPEND="
  1094. extra_cflags
  1095. "
  1096. # code dependency declarations
  1097. # architecture extensions
  1098. armv5te_deps="arm"
  1099. armv6_deps="arm"
  1100. armv6t2_deps="arm"
  1101. armvfp_deps="arm"
  1102. iwmmxt_deps="arm"
  1103. neon_deps="arm"
  1104. vfpv3_deps="armvfp"
  1105. mmi_deps="mips"
  1106. altivec_deps="ppc"
  1107. ppc4xx_deps="ppc"
  1108. vis_deps="sparc"
  1109. x86_64_suggest="cmov fast_cmov"
  1110. amd3dnow_deps="mmx"
  1111. amd3dnowext_deps="amd3dnow"
  1112. mmx_deps="x86"
  1113. mmx2_deps="mmx"
  1114. sse_deps="mmx"
  1115. ssse3_deps="sse"
  1116. avx_deps="ssse3"
  1117. aligned_stack_if_any="ppc x86"
  1118. fast_64bit_if_any="alpha ia64 mips64 parisc64 ppc64 sparc64 x86_64"
  1119. fast_clz_if_any="alpha armv5te avr32 mips ppc x86"
  1120. fast_unaligned_if_any="armv6 ppc x86"
  1121. need_memalign="altivec neon sse"
  1122. inline_asm_deps="!tms470"
  1123. symver_if_any="symver_asm_label symver_gnu_asm"
  1124. # subsystems
  1125. dct_select="rdft"
  1126. mdct_select="fft"
  1127. rdft_select="fft"
  1128. mpegaudiodsp_select="dct"
  1129. # decoders / encoders / hardware accelerators
  1130. aac_decoder_select="mdct sinewin"
  1131. aac_encoder_select="mdct sinewin"
  1132. aac_latm_decoder_select="aac_decoder aac_latm_parser"
  1133. ac3_decoder_select="mdct ac3dsp ac3_parser"
  1134. ac3_encoder_select="mdct ac3dsp"
  1135. ac3_fixed_encoder_select="mdct ac3dsp"
  1136. alac_encoder_select="lpc"
  1137. amrnb_decoder_select="lsp"
  1138. amrwb_decoder_select="lsp"
  1139. atrac1_decoder_select="mdct sinewin"
  1140. atrac3_decoder_select="mdct"
  1141. binkaudio_dct_decoder_select="mdct rdft dct sinewin"
  1142. binkaudio_rdft_decoder_select="mdct rdft sinewin"
  1143. cavs_decoder_select="golomb"
  1144. cook_decoder_select="mdct sinewin"
  1145. cscd_decoder_suggest="zlib"
  1146. dca_decoder_select="mdct"
  1147. dnxhd_encoder_select="aandct"
  1148. dxa_decoder_select="zlib"
  1149. eac3_decoder_select="ac3_decoder"
  1150. eac3_encoder_select="mdct ac3dsp"
  1151. eamad_decoder_select="aandct"
  1152. eatgq_decoder_select="aandct"
  1153. eatqi_decoder_select="aandct"
  1154. ffv1_decoder_select="golomb"
  1155. flac_decoder_select="golomb"
  1156. flac_encoder_select="golomb lpc"
  1157. flashsv_decoder_select="zlib"
  1158. flashsv_encoder_select="zlib"
  1159. flashsv2_decoder_select="zlib"
  1160. flv_decoder_select="h263_decoder"
  1161. flv_encoder_select="h263_encoder"
  1162. fraps_decoder_select="huffman"
  1163. h261_encoder_select="aandct"
  1164. h263_decoder_select="h263_parser"
  1165. h263_encoder_select="aandct"
  1166. h263_vaapi_hwaccel_select="vaapi h263_decoder"
  1167. h263i_decoder_select="h263_decoder"
  1168. h263p_encoder_select="h263_encoder"
  1169. h264_decoder_select="golomb h264dsp h264pred"
  1170. h264_dxva2_hwaccel_deps="dxva2api_h"
  1171. h264_dxva2_hwaccel_select="dxva2 h264_decoder"
  1172. h264_vaapi_hwaccel_select="vaapi h264_decoder"
  1173. h264_vda_hwaccel_select="vda h264_decoder"
  1174. h264_vdpau_decoder_select="vdpau h264_decoder"
  1175. imc_decoder_select="fft mdct sinewin"
  1176. jpegls_decoder_select="golomb"
  1177. jpegls_encoder_select="golomb"
  1178. ljpeg_encoder_select="aandct"
  1179. loco_decoder_select="golomb"
  1180. mjpeg_encoder_select="aandct"
  1181. mlp_decoder_select="mlp_parser"
  1182. mp1_decoder_select="mpegaudiodsp"
  1183. mp2_decoder_select="mpegaudiodsp"
  1184. mp3adu_decoder_select="mpegaudiodsp"
  1185. mp3_decoder_select="mpegaudiodsp"
  1186. mp3on4_decoder_select="mpegaudiodsp"
  1187. mp1float_decoder_select="mpegaudiodsp"
  1188. mp2float_decoder_select="mpegaudiodsp"
  1189. mp3adufloat_decoder_select="mpegaudiodsp"
  1190. mp3float_decoder_select="mpegaudiodsp"
  1191. mp3on4float_decoder_select="mpegaudiodsp"
  1192. mpeg1video_encoder_select="aandct"
  1193. mpeg2video_encoder_select="aandct"
  1194. mpeg4_decoder_select="h263_decoder mpeg4video_parser"
  1195. mpeg4_encoder_select="h263_encoder"
  1196. mpeg_vdpau_decoder_select="vdpau mpegvideo_decoder"
  1197. mpeg1_vdpau_decoder_select="vdpau mpeg1video_decoder"
  1198. mpeg2_dxva2_hwaccel_deps="dxva2api_h"
  1199. mpeg2_dxva2_hwaccel_select="dxva2 mpeg2video_decoder"
  1200. mpeg2_vaapi_hwaccel_select="vaapi mpeg2video_decoder"
  1201. mpeg4_vaapi_hwaccel_select="vaapi mpeg4_decoder"
  1202. mpeg4_vdpau_decoder_select="vdpau mpeg4_decoder"
  1203. mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
  1204. mpeg_xvmc_decoder_select="mpegvideo_decoder"
  1205. msmpeg4v1_decoder_select="h263_decoder"
  1206. msmpeg4v1_encoder_select="h263_encoder"
  1207. msmpeg4v2_decoder_select="h263_decoder"
  1208. msmpeg4v2_encoder_select="h263_encoder"
  1209. msmpeg4v3_decoder_select="h263_decoder"
  1210. msmpeg4v3_encoder_select="h263_encoder"
  1211. nellymoser_decoder_select="mdct sinewin"
  1212. nellymoser_encoder_select="mdct sinewin"
  1213. png_decoder_select="zlib"
  1214. png_encoder_select="zlib"
  1215. qcelp_decoder_select="lsp"
  1216. qdm2_decoder_select="mdct rdft mpegaudiodsp"
  1217. ra_144_encoder_select="lpc"
  1218. rv10_decoder_select="h263_decoder"
  1219. rv10_encoder_select="h263_encoder"
  1220. rv20_decoder_select="h263_decoder"
  1221. rv20_encoder_select="h263_encoder"
  1222. rv30_decoder_select="golomb h264pred"
  1223. rv40_decoder_select="golomb h264pred"
  1224. shorten_decoder_select="golomb"
  1225. sipr_decoder_select="lsp"
  1226. snow_decoder_select="dwt"
  1227. snow_encoder_select="aandct dwt"
  1228. svq1_encoder_select="aandct"
  1229. svq3_decoder_select="golomb h264dsp h264pred"
  1230. svq3_decoder_suggest="zlib"
  1231. theora_decoder_select="vp3_decoder"
  1232. tiff_decoder_suggest="zlib"
  1233. tiff_encoder_suggest="zlib"
  1234. truehd_decoder_select="mlp_decoder"
  1235. tscc_decoder_select="zlib"
  1236. twinvq_decoder_select="mdct lsp sinewin"
  1237. vc1_decoder_select="h263_decoder"
  1238. vc1_dxva2_hwaccel_deps="dxva2api_h DXVA_PictureParameters_wDecodedPictureIndex"
  1239. vc1_dxva2_hwaccel_select="dxva2 vc1_decoder"
  1240. vc1_vaapi_hwaccel_select="vaapi vc1_decoder"
  1241. vc1_vdpau_decoder_select="vdpau vc1_decoder"
  1242. vc1image_decoder_select="vc1_decoder"
  1243. vorbis_decoder_select="mdct"
  1244. vorbis_encoder_select="mdct"
  1245. vp6_decoder_select="huffman"
  1246. vp6a_decoder_select="vp6_decoder"
  1247. vp6f_decoder_select="vp6_decoder"
  1248. vp8_decoder_select="h264pred"
  1249. wmapro_decoder_select="mdct sinewin"
  1250. wmav1_decoder_select="mdct sinewin"
  1251. wmav1_encoder_select="mdct sinewin"
  1252. wmav2_decoder_select="mdct sinewin"
  1253. wmav2_encoder_select="mdct sinewin"
  1254. wmavoice_decoder_select="lsp rdft dct mdct sinewin"
  1255. wmv1_decoder_select="h263_decoder"
  1256. wmv1_encoder_select="h263_encoder"
  1257. wmv2_decoder_select="h263_decoder"
  1258. wmv2_encoder_select="h263_encoder"
  1259. wmv3_decoder_select="vc1_decoder"
  1260. wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel"
  1261. wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel"
  1262. wmv3_vdpau_decoder_select="vc1_vdpau_decoder"
  1263. wmv3image_decoder_select="wmv3_decoder"
  1264. zlib_decoder_select="zlib"
  1265. zlib_encoder_select="zlib"
  1266. zmbv_decoder_select="zlib"
  1267. zmbv_encoder_select="zlib"
  1268. vaapi_deps="va_va_h"
  1269. vda_deps="VideoDecodeAcceleration_VDADecoder_h pthreads"
  1270. vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
  1271. # parsers
  1272. h264_parser_select="golomb h264dsp h264pred"
  1273. # external libraries
  1274. libdirac_decoder_deps="libdirac !libschroedinger"
  1275. libdirac_encoder_deps="libdirac"
  1276. libfaac_encoder_deps="libfaac"
  1277. libgsm_decoder_deps="libgsm"
  1278. libgsm_encoder_deps="libgsm"
  1279. libgsm_ms_decoder_deps="libgsm"
  1280. libgsm_ms_encoder_deps="libgsm"
  1281. libmp3lame_encoder_deps="libmp3lame"
  1282. libopencore_amrnb_decoder_deps="libopencore_amrnb"
  1283. libopencore_amrnb_encoder_deps="libopencore_amrnb"
  1284. libopencore_amrwb_decoder_deps="libopencore_amrwb"
  1285. libopenjpeg_decoder_deps="libopenjpeg"
  1286. libschroedinger_decoder_deps="libschroedinger"
  1287. libschroedinger_encoder_deps="libschroedinger"
  1288. libspeex_decoder_deps="libspeex"
  1289. libspeex_encoder_deps="libspeex"
  1290. libtheora_encoder_deps="libtheora"
  1291. libvo_aacenc_encoder_deps="libvo_aacenc"
  1292. libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
  1293. libvorbis_encoder_deps="libvorbis"
  1294. libvpx_decoder_deps="libvpx"
  1295. libvpx_encoder_deps="libvpx"
  1296. libx264_encoder_deps="libx264"
  1297. libxavs_encoder_deps="libxavs"
  1298. libxvid_encoder_deps="libxvid"
  1299. # demuxers / muxers
  1300. ac3_demuxer_select="ac3_parser"
  1301. asf_stream_muxer_select="asf_muxer"
  1302. avisynth_demuxer_deps="avisynth"
  1303. dirac_demuxer_select="dirac_parser"
  1304. eac3_demuxer_select="ac3_parser"
  1305. flac_demuxer_select="flac_parser"
  1306. ipod_muxer_select="mov_muxer"
  1307. libnut_demuxer_deps="libnut"
  1308. libnut_muxer_deps="libnut"
  1309. matroska_audio_muxer_select="matroska_muxer"
  1310. matroska_demuxer_suggest="zlib bzlib"
  1311. mov_demuxer_suggest="zlib"
  1312. mp3_demuxer_select="mpegaudio_parser"
  1313. mp4_muxer_select="mov_muxer"
  1314. mpegtsraw_demuxer_select="mpegts_demuxer"
  1315. mxf_d10_muxer_select="mxf_muxer"
  1316. ogg_demuxer_select="golomb"
  1317. psp_muxer_select="mov_muxer"
  1318. rtp_demuxer_select="sdp_demuxer"
  1319. rtpdec_select="asf_demuxer rm_demuxer rtp_protocol mpegts_demuxer mov_demuxer"
  1320. rtsp_demuxer_select="http_protocol rtpdec"
  1321. rtsp_muxer_select="rtp_muxer http_protocol rtp_protocol"
  1322. sap_demuxer_select="sdp_demuxer"
  1323. sap_muxer_select="rtp_muxer rtp_protocol"
  1324. sdp_demuxer_select="rtpdec"
  1325. spdif_muxer_select="aac_parser"
  1326. tg2_muxer_select="mov_muxer"
  1327. tgp_muxer_select="mov_muxer"
  1328. w64_demuxer_deps="wav_demuxer"
  1329. # indevs / outdevs
  1330. alsa_indev_deps="alsa_asoundlib_h snd_pcm_htimestamp"
  1331. alsa_outdev_deps="alsa_asoundlib_h"
  1332. bktr_indev_deps_any="dev_bktr_ioctl_bt848_h machine_ioctl_bt848_h dev_video_bktr_ioctl_bt848_h dev_ic_bt8xx_h"
  1333. dv1394_indev_deps="dv1394 dv_demuxer"
  1334. fbdev_indev_deps="linux_fb_h"
  1335. jack_indev_deps="jack_jack_h"
  1336. libcdio_indev_deps="libcdio"
  1337. libdc1394_indev_deps="libdc1394"
  1338. oss_indev_deps_any="soundcard_h sys_soundcard_h"
  1339. oss_outdev_deps_any="soundcard_h sys_soundcard_h"
  1340. pulse_indev_deps="libpulse"
  1341. sndio_indev_deps="sndio_h"
  1342. sndio_outdev_deps="sndio_h"
  1343. v4l_indev_deps="linux_videodev_h"
  1344. v4l2_indev_deps_any="linux_videodev2_h sys_videoio_h"
  1345. vfwcap_indev_deps="capCreateCaptureWindow vfwcap_defines"
  1346. vfwcap_indev_extralibs="-lavicap32"
  1347. x11_grab_device_indev_deps="x11grab XShmCreateImage"
  1348. x11_grab_device_indev_extralibs="-lX11 -lXext -lXfixes"
  1349. # protocols
  1350. gopher_protocol_deps="network"
  1351. http_protocol_deps="network"
  1352. http_protocol_select="tcp_protocol"
  1353. https_protocol_select="tls_protocol"
  1354. mmsh_protocol_select="http_protocol"
  1355. mmst_protocol_deps="network"
  1356. rtmp_protocol_select="tcp_protocol"
  1357. rtp_protocol_select="udp_protocol"
  1358. tcp_protocol_deps="network"
  1359. tls_protocol_deps_any="openssl gnutls"
  1360. tls_protocol_select="tcp_protocol"
  1361. udp_protocol_deps="network"
  1362. # filters
  1363. blackframe_filter_deps="gpl"
  1364. boxblur_filter_deps="gpl"
  1365. cropdetect_filter_deps="gpl"
  1366. delogo_filter_deps="gpl"
  1367. drawtext_filter_deps="libfreetype"
  1368. frei0r_filter_deps="frei0r dlopen strtok_r"
  1369. frei0r_src_filter_deps="frei0r dlopen strtok_r"
  1370. hqdn3d_filter_deps="gpl"
  1371. ocv_filter_deps="libopencv"
  1372. scale_filter_deps="swscale"
  1373. yadif_filter_deps="gpl"
  1374. # libraries
  1375. avdevice_deps="avcodec avformat"
  1376. avformat_deps="avcodec"
  1377. postproc_deps="gpl"
  1378. # programs
  1379. ffmpeg_deps="avcodec avformat swscale"
  1380. ffmpeg_select="buffer_filter"
  1381. avconv_deps="avcodec avformat swscale"
  1382. avconv_select="buffer_filter"
  1383. avplay_deps="avcodec avformat swscale sdl"
  1384. avplay_select="rdft"
  1385. avprobe_deps="avcodec avformat"
  1386. avserver_deps="avformat ffm_muxer fork rtp_protocol rtsp_demuxer"
  1387. avserver_extralibs='$ldl'
  1388. doc_deps="texi2html"
  1389. # tests
  1390. test_deps(){
  1391. suf1=$1
  1392. suf2=$2
  1393. shift 2
  1394. for v; do
  1395. dep=${v%=*}
  1396. tests=${v#*=}
  1397. for name in ${tests}; do
  1398. append ${name}_test_deps ${dep}$suf1 ${dep}$suf2
  1399. done
  1400. done
  1401. }
  1402. mxf_d10_test_deps="avfilter"
  1403. seek_lavf_mxf_d10_test_deps="mxf_d10_test"
  1404. test_deps _encoder _decoder \
  1405. adpcm_g726=g726 \
  1406. adpcm_ima_qt \
  1407. adpcm_ima_wav \
  1408. adpcm_ms \
  1409. adpcm_swf \
  1410. adpcm_yamaha=adpcm_yam \
  1411. alac \
  1412. asv1 \
  1413. asv2 \
  1414. bmp \
  1415. dnxhd="dnxhd_1080i dnxhd_720p dnxhd_720p_rd" \
  1416. dvvideo="dv dv50" \
  1417. ffv1 \
  1418. flac \
  1419. flashsv \
  1420. flv \
  1421. gif \
  1422. h261 \
  1423. h263="h263 h263p" \
  1424. huffyuv \
  1425. jpegls \
  1426. mjpeg="jpg mjpeg ljpeg" \
  1427. mp2 \
  1428. mpeg1video="mpeg mpeg1b" \
  1429. mpeg2video="mpeg2 mpeg2thread" \
  1430. mpeg4="mpeg4 mpeg4adv mpeg4nr mpeg4thread error rc" \
  1431. msmpeg4v3=msmpeg4 \
  1432. msmpeg4v2 \
  1433. pbm=pbmpipe \
  1434. pcx \
  1435. pgm="pgm pgmpipe" \
  1436. png \
  1437. ppm="ppm ppmpipe" \
  1438. rawvideo="rgb yuv" \
  1439. roq \
  1440. rv10 \
  1441. rv20 \
  1442. sgi \
  1443. snow="snow snowll" \
  1444. svq1 \
  1445. targa=tga \
  1446. tiff \
  1447. wmav1 \
  1448. wmav2 \
  1449. wmv1 \
  1450. wmv2 \
  1451. test_deps _muxer _demuxer \
  1452. aiff \
  1453. pcm_alaw=alaw \
  1454. asf \
  1455. au \
  1456. avi \
  1457. dv=dv_fmt \
  1458. ffm \
  1459. flv=flv_fmt \
  1460. gxf \
  1461. matroska=mkv \
  1462. mmf \
  1463. mov \
  1464. pcm_mulaw=mulaw \
  1465. mxf="mxf mxf_d10" \
  1466. nut \
  1467. ogg \
  1468. rawvideo=pixfmt \
  1469. rm \
  1470. swf \
  1471. mpegts=ts \
  1472. voc \
  1473. wav \
  1474. yuv4mpegpipe=yuv4mpeg \
  1475. ac3_fixed_test_deps="ac3_fixed_encoder ac3_decoder rm_muxer rm_demuxer"
  1476. mpg_test_deps="mpeg1system_muxer mpegps_demuxer"
  1477. # default parameters
  1478. logfile="config.log"
  1479. # installation paths
  1480. prefix_default="/usr/local"
  1481. bindir_default='${prefix}/bin'
  1482. datadir_default='${prefix}/share/avconv'
  1483. incdir_default='${prefix}/include'
  1484. libdir_default='${prefix}/lib'
  1485. mandir_default='${prefix}/share/man'
  1486. shlibdir_default="$libdir_default"
  1487. # toolchain
  1488. ar_default="ar"
  1489. cc_default="gcc"
  1490. cc_version=\"unknown\"
  1491. host_cc_default="gcc"
  1492. ln_s="ln -sf"
  1493. nm_default="nm"
  1494. objformat="elf"
  1495. pkg_config_default=pkg-config
  1496. ranlib="ranlib"
  1497. yasmexe="yasm"
  1498. nogas=":"
  1499. nm_opts='-g'
  1500. # machine
  1501. arch_default=$(uname -m)
  1502. cpu="generic"
  1503. # OS
  1504. target_os_default=$(tolower $(uname -s))
  1505. host_os=$target_os_default
  1506. # configurable options
  1507. enable avcodec
  1508. enable avdevice
  1509. enable avfilter
  1510. enable avformat
  1511. enable avutil
  1512. enable asm
  1513. enable debug
  1514. enable doc
  1515. enable fastdiv
  1516. enable ffmpeg
  1517. enable avconv
  1518. enable avplay
  1519. enable avprobe
  1520. enable avserver
  1521. enable network
  1522. enable optimizations
  1523. enable postproc
  1524. enable protocols
  1525. enable static
  1526. enable swscale
  1527. enable swscale_alpha
  1528. # build settings
  1529. SHFLAGS='-shared -Wl,-soname,$$(@F)'
  1530. AVSERVERLDFLAGS=-Wl,-E
  1531. LIBPREF="lib"
  1532. LIBSUF=".a"
  1533. FULLNAME='$(NAME)$(BUILDSUF)'
  1534. LIBNAME='$(LIBPREF)$(FULLNAME)$(LIBSUF)'
  1535. SLIBPREF="lib"
  1536. SLIBSUF=".so"
  1537. SLIBNAME='$(SLIBPREF)$(FULLNAME)$(SLIBSUF)'
  1538. SLIBNAME_WITH_VERSION='$(SLIBNAME).$(LIBVERSION)'
  1539. SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
  1540. LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
  1541. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
  1542. SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
  1543. AS_O='-o $@'
  1544. CC_O='-o $@'
  1545. host_cflags='-D_ISOC99_SOURCE -O3 -g'
  1546. host_libs='-lm'
  1547. target_path='$(CURDIR)'
  1548. # since the object filename is not given with the -MM flag, the compiler
  1549. # is only able to print the basename, and we must add the path ourselves
  1550. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o," > $(@:.o=.d)'
  1551. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -MM'
  1552. # find source path
  1553. if test -f configure; then
  1554. source_path=.
  1555. else
  1556. source_path=$(cd $(dirname "$0"); pwd)
  1557. echo "$source_path" | grep -q '[[:blank:]]' &&
  1558. die "Out of tree builds are impossible with whitespace in source path."
  1559. test -e "$source_path/config.h" &&
  1560. die "Out of tree builds are impossible with config.h in source dir."
  1561. fi
  1562. for v in "$@"; do
  1563. r=${v#*=}
  1564. l=${v%"$r"}
  1565. r=$(sh_quote "$r")
  1566. LIBAV_CONFIGURATION="${LIBAV_CONFIGURATION# } ${l}${r}"
  1567. done
  1568. find_things(){
  1569. thing=$1
  1570. pattern=$2
  1571. file=$source_path/$3
  1572. sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
  1573. }
  1574. ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c)
  1575. DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c)
  1576. HWACCEL_LIST=$(find_things hwaccel HWACCEL libavcodec/allcodecs.c)
  1577. PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c)
  1578. BSF_LIST=$(find_things bsf BSF libavcodec/allcodecs.c)
  1579. MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c)
  1580. DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c)
  1581. OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
  1582. INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
  1583. PROTOCOL_LIST=$(find_things protocol PROTOCOL libavformat/allformats.c)
  1584. FILTER_LIST=$(find_things filter FILTER libavfilter/allfilters.c)
  1585. find_tests(){
  1586. map "echo ${2}\${v}_test" $(ls "$source_path"/tests/ref/$1 | grep -v '[^-a-z0-9_]')
  1587. }
  1588. ACODEC_TESTS=$(find_tests acodec)
  1589. VCODEC_TESTS=$(find_tests vsynth1)
  1590. LAVF_TESTS=$(find_tests lavf)
  1591. LAVFI_TESTS=$(find_tests lavfi)
  1592. SEEK_TESTS=$(find_tests seek seek_)
  1593. pcm_test_deps=$(map 'echo ${v%_*}_decoder $v' $(filter pcm_* $ENCODER_LIST))
  1594. for n in $COMPONENT_LIST; do
  1595. v=$(toupper ${n%s})_LIST
  1596. eval enable \$$v
  1597. eval ${n}_if_any="\$$v"
  1598. done
  1599. enable $ARCH_EXT_LIST $ACODEC_TESTS $VCODEC_TESTS $LAVF_TESTS $LAVFI_TESTS $SEEK_TESTS
  1600. die_unknown(){
  1601. echo "Unknown option \"$1\"."
  1602. echo "See $0 --help for available options."
  1603. exit 1
  1604. }
  1605. show_list() {
  1606. suffix=_$1
  1607. shift
  1608. echo $* | sed s/$suffix//g | tr ' ' '\n' | sort | pr -3 -t
  1609. exit 0
  1610. }
  1611. for opt do
  1612. optval="${opt#*=}"
  1613. case "$opt" in
  1614. --extra-ldflags=*) add_ldflags $optval
  1615. ;;
  1616. --extra-libs=*) add_extralibs $optval
  1617. ;;
  1618. --disable-devices) disable $INDEV_LIST $OUTDEV_LIST
  1619. ;;
  1620. --enable-debug=*) debuglevel="$optval"
  1621. ;;
  1622. --disable-everything)
  1623. map 'eval unset \${$(toupper ${v%s})_LIST}' $COMPONENT_LIST
  1624. ;;
  1625. --enable-*=*|--disable-*=*)
  1626. eval $(echo "${opt%%=*}" | sed 's/--/action=/;s/-/ thing=/')
  1627. is_in "${thing}s" $COMPONENT_LIST || die_unknown "$opt"
  1628. eval list=\$$(toupper $thing)_LIST
  1629. name=$(echo "${optval}" | sed "s/,/_${thing}|/g")_${thing}
  1630. $action $(filter "$name" $list)
  1631. ;;
  1632. --enable-?*|--disable-?*)
  1633. eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
  1634. if is_in $option $COMPONENT_LIST; then
  1635. test $action = disable && action=unset
  1636. eval $action \$$(toupper ${option%s})_LIST
  1637. elif is_in $option $CMDLINE_SELECT; then
  1638. $action $option
  1639. else
  1640. die_unknown $opt
  1641. fi
  1642. ;;
  1643. --list-*)
  1644. NAME="${opt#--list-}"
  1645. is_in $NAME $COMPONENT_LIST || die_unknown $opt
  1646. NAME=${NAME%s}
  1647. eval show_list $NAME \$$(toupper $NAME)_LIST
  1648. ;;
  1649. --help|-h) show_help
  1650. ;;
  1651. *)
  1652. optname="${opt%%=*}"
  1653. optname="${optname#--}"
  1654. optname=$(echo "$optname" | sed 's/-/_/g')
  1655. if is_in $optname $CMDLINE_SET; then
  1656. eval $optname='$optval'
  1657. elif is_in $optname $CMDLINE_APPEND; then
  1658. append $optname "$optval"
  1659. else
  1660. die_unknown $opt
  1661. fi
  1662. ;;
  1663. esac
  1664. done
  1665. disabled logging && logfile=/dev/null
  1666. echo "# $0 $LIBAV_CONFIGURATION" > $logfile
  1667. set >> $logfile
  1668. test -n "$cross_prefix" && enable cross_compile
  1669. if enabled cross_compile; then
  1670. test -n "$arch" && test -n "$target_os" ||
  1671. die "Must specify target arch and OS when cross-compiling"
  1672. fi
  1673. set_default arch target_os
  1674. ar_default="${cross_prefix}${ar_default}"
  1675. cc_default="${cross_prefix}${cc_default}"
  1676. nm_default="${cross_prefix}${nm_default}"
  1677. pkg_config_default="${cross_prefix}${pkg_config_default}"
  1678. ranlib="${cross_prefix}${ranlib}"
  1679. sysinclude_default="${sysroot}/usr/include"
  1680. set_default cc nm pkg_config sysinclude
  1681. enabled cross_compile || host_cc_default=$cc
  1682. set_default host_cc
  1683. if ! $pkg_config --version >/dev/null 2>&1; then
  1684. warn "$pkg_config not found, library detection may fail."
  1685. pkg_config=false
  1686. fi
  1687. exesuf() {
  1688. case $1 in
  1689. mingw32*|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
  1690. esac
  1691. }
  1692. EXESUF=$(exesuf $target_os)
  1693. HOSTEXESUF=$(exesuf $host_os)
  1694. # set temporary file name
  1695. : ${TMPDIR:=$TEMPDIR}
  1696. : ${TMPDIR:=$TMP}
  1697. : ${TMPDIR:=/tmp}
  1698. if ! check_cmd mktemp -u XXXXXX; then
  1699. # simple replacement for missing mktemp
  1700. # NOT SAFE FOR GENERAL USE
  1701. mktemp(){
  1702. echo "${2%%XXX*}.${HOSTNAME}.${UID}.$$"
  1703. }
  1704. fi
  1705. tmpfile(){
  1706. tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
  1707. (set -C; exec > $tmp) 2>/dev/null ||
  1708. die "Unable to create temporary file in $TMPDIR."
  1709. append TMPFILES $tmp
  1710. eval $1=$tmp
  1711. }
  1712. trap 'rm -f -- $TMPFILES' EXIT
  1713. tmpfile TMPC .c
  1714. tmpfile TMPE $EXESUF
  1715. tmpfile TMPH .h
  1716. tmpfile TMPO .o
  1717. tmpfile TMPS .S
  1718. tmpfile TMPV .ver
  1719. tmpfile TMPSH .sh
  1720. tmpfile TMPASM .asm
  1721. unset -f mktemp
  1722. chmod +x $TMPE
  1723. # make sure we can execute files in $TMPDIR
  1724. cat > $TMPSH 2>> $logfile <<EOF
  1725. #! /bin/sh
  1726. EOF
  1727. chmod +x $TMPSH >> $logfile 2>&1
  1728. if ! $TMPSH >> $logfile 2>&1; then
  1729. cat <<EOF
  1730. Unable to create and execute files in $TMPDIR. Set the TMPDIR environment
  1731. variable to another directory and make sure that it is not mounted noexec.
  1732. EOF
  1733. die "Sanity test failed."
  1734. fi
  1735. filter_cflags=echo
  1736. filter_cppflags=echo
  1737. filter_asflags=echo
  1738. if $cc -v 2>&1 | grep -q '^gcc.*LLVM'; then
  1739. cc_type=llvm_gcc
  1740. cc_version=__VERSION__
  1741. gcc_extra_ver=$(expr "$($cc --version | head -n1)" : '.*\((.*)\)')
  1742. cc_ident="llvm-gcc $($cc -dumpversion) $gcc_extra_ver"
  1743. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1744. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1745. speed_cflags='-O3'
  1746. size_cflags='-Os'
  1747. elif $cc -v 2>&1 | grep -qi ^gcc; then
  1748. cc_type=gcc
  1749. cc_version=__VERSION__
  1750. gcc_version=$($cc --version | head -n1)
  1751. gcc_basever=$($cc -dumpversion)
  1752. gcc_pkg_ver=$(expr "$gcc_version" : '[^ ]* \(([^)]*)\)')
  1753. gcc_ext_ver=$(expr "$gcc_version" : ".*$gcc_pkg_ver $gcc_basever \\(.*\\)")
  1754. cc_ident=$(cleanws "gcc $gcc_basever $gcc_pkg_ver $gcc_ext_ver")
  1755. if ! $cc -dumpversion | grep -q '^2\.'; then
  1756. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1757. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1758. fi
  1759. speed_cflags='-O3'
  1760. size_cflags='-Os'
  1761. elif $cc --version 2>/dev/null | grep -q Intel; then
  1762. cc_type=icc
  1763. cc_version="AV_STRINGIFY(__INTEL_COMPILER)"
  1764. cc_ident=$($cc --version | head -n1)
  1765. icc_version=$($cc -dumpversion)
  1766. CC_DEPFLAGS='-MMD'
  1767. AS_DEPFLAGS='-MMD'
  1768. speed_cflags='-O3'
  1769. size_cflags='-Os'
  1770. noopt_cflags='-O1'
  1771. elif $cc -v 2>&1 | grep -q xlc; then
  1772. cc_type=xlc
  1773. cc_version="AV_STRINGIFY(__IBMC__)"
  1774. cc_ident=$($cc -qversion 2>/dev/null | head -n1)
  1775. speed_cflags='-O5'
  1776. size_cflags='-O5 -qcompact'
  1777. elif $cc -V 2>/dev/null | grep -q Compaq; then
  1778. cc_type=ccc
  1779. cc_version="AV_STRINGIFY(__DECC_VER)"
  1780. cc_ident=$($cc -V | head -n1 | cut -d' ' -f1-3)
  1781. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -M'
  1782. debuglevel=3
  1783. add_ldflags -Wl,-z,now # calls to libots crash without this
  1784. speed_cflags='-fast'
  1785. size_cflags='-O1'
  1786. elif $cc --vsn 2>/dev/null | grep -q "ARM C/C++ Compiler"; then
  1787. test -d "$sysroot" || die "No valid sysroot specified."
  1788. cc_type=armcc
  1789. cc_version="AV_STRINGIFY(__ARMCC_VERSION)"
  1790. cc_ident=$($cc --vsn | head -n1)
  1791. armcc_conf="$PWD/armcc.conf"
  1792. $cc --arm_linux_configure \
  1793. --arm_linux_config_file="$armcc_conf" \
  1794. --configure_sysroot="$sysroot" \
  1795. --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
  1796. die "Error creating armcc configuration file."
  1797. $cc --vsn | grep -q RVCT && armcc_opt=rvct || armcc_opt=armcc
  1798. cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
  1799. as_default="${cross_prefix}gcc"
  1800. CC_DEPFLAGS='-MMD'
  1801. AS_DEPFLAGS='-MMD'
  1802. speed_cflags='-O3'
  1803. size_cflags='-Os'
  1804. filter_asflags="filter_out -W${armcc_opt}*"
  1805. elif $cc -version 2>/dev/null | grep -q TMS470; then
  1806. cc_type=tms470
  1807. cc_version="AV_STRINGIFY(__TI_COMPILER_VERSION__)"
  1808. cc_ident=$($cc -version | head -n1 | tr -s ' ')
  1809. cc="$cc --gcc --abi=eabi -eo=.o -mc -me"
  1810. CC_O='-fr=$(@D)'
  1811. as_default="${cross_prefix}gcc"
  1812. ld_default="${cross_prefix}gcc"
  1813. TMPO=$(basename $TMPC .c).o
  1814. append TMPFILES $TMPO
  1815. add_cflags -D__gnuc_va_list=va_list -D__USER_LABEL_PREFIX__=
  1816. CC_DEPFLAGS='-ppa -ppd=$(@:.o=.d)'
  1817. AS_DEPFLAGS='-MMD'
  1818. speed_cflags='-O3 -mf=5'
  1819. size_cflags='-O3 -mf=2'
  1820. filter_cflags=tms470_flags
  1821. tms470_flags(){
  1822. for flag; do
  1823. case $flag in
  1824. -march=*|-mcpu=*)
  1825. case "${flag#*=}" in
  1826. armv7-a|cortex-a*) echo -mv=7a8 ;;
  1827. armv7-r|cortex-r*) echo -mv=7r4 ;;
  1828. armv7-m|cortex-m*) echo -mv=7m3 ;;
  1829. armv6*|arm11*) echo -mv=6 ;;
  1830. armv5*e|arm[79]*e*|arm9[24]6*|arm96*|arm102[26])
  1831. echo -mv=5e ;;
  1832. armv4*|arm7*|arm9[24]*) echo -mv=4 ;;
  1833. esac
  1834. ;;
  1835. -mfpu=neon) echo --float_support=vfpv3 --neon ;;
  1836. -mfpu=vfp) echo --float_support=vfpv2 ;;
  1837. -mfpu=vfpv3) echo --float_support=vfpv3 ;;
  1838. -msoft-float) echo --float_support=vfplib ;;
  1839. -O[0-3]|-mf=*) echo $flag ;;
  1840. -g) echo -g -mn ;;
  1841. -pds=*) echo $flag ;;
  1842. esac
  1843. done
  1844. }
  1845. elif $cc -v 2>&1 | grep -q clang; then
  1846. cc_type=clang
  1847. $cc -dM -E $TMPC | grep -q __clang_version__ &&
  1848. cc_version=__clang_version__ || cc_version=__VERSION__
  1849. cc_ident=$($cc --version | head -n1)
  1850. CC_DEPFLAGS='-MMD'
  1851. AS_DEPFLAGS='-MMD'
  1852. speed_cflags='-O3'
  1853. size_cflags='-Os'
  1854. elif $cc -V 2>&1 | grep -q Sun; then
  1855. cc_type=suncc
  1856. cc_version="AV_STRINGIFY(__SUNPRO_C)"
  1857. cc_ident=$($cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
  1858. DEPEND_CMD='$(DEPCC) $(DEPFLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
  1859. DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -xM1'
  1860. add_ldflags -xc99
  1861. speed_cflags='-O5'
  1862. size_cflags='-O5 -xspace'
  1863. filter_cflags=suncc_flags
  1864. suncc_flags(){
  1865. for flag; do
  1866. case $flag in
  1867. -march=*|-mcpu=*)
  1868. case "${flag#*=}" in
  1869. native) echo -xtarget=native ;;
  1870. v9|niagara) echo -xarch=sparc ;;
  1871. ultrasparc) echo -xarch=sparcvis ;;
  1872. ultrasparc3|niagara2) echo -xarch=sparcvis2 ;;
  1873. i586|pentium) echo -xchip=pentium ;;
  1874. i686|pentiumpro|pentium2) echo -xtarget=pentium_pro ;;
  1875. pentium3*|c3-2) echo -xtarget=pentium3 ;;
  1876. pentium-m) echo -xarch=sse2 -xchip=pentium3 ;;
  1877. pentium4*) echo -xtarget=pentium4 ;;
  1878. prescott|nocona) echo -xarch=sse3 -xchip=pentium4 ;;
  1879. *-sse3) echo -xarch=sse3 ;;
  1880. core2) echo -xarch=ssse3 -xchip=core2 ;;
  1881. amdfam10|barcelona) echo -xarch=sse4_1 ;;
  1882. athlon-4|athlon-[mx]p) echo -xarch=ssea ;;
  1883. k8|opteron|athlon64|athlon-fx)
  1884. echo -xarch=sse2a ;;
  1885. athlon*) echo -xarch=pentium_proa ;;
  1886. esac
  1887. ;;
  1888. -std=c99) echo -xc99 ;;
  1889. -fomit-frame-pointer) echo -xregs=frameptr ;;
  1890. -fPIC) echo -KPIC -xcode=pic32 ;;
  1891. -W*,*) echo $flag ;;
  1892. -f*-*|-W*) ;;
  1893. *) echo $flag ;;
  1894. esac
  1895. done
  1896. }
  1897. elif $cc -v 2>&1 | grep -q 'PathScale\|Path64'; then
  1898. cc_type=pathscale
  1899. cc_version=__PATHSCALE__
  1900. cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
  1901. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1902. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1903. speed_cflags='-O2'
  1904. size_cflags='-Os'
  1905. filter_cflags='filter_out -Wdisabled-optimization'
  1906. elif $cc -v 2>&1 | grep -q Open64; then
  1907. cc_type=open64
  1908. cc_version=__OPEN64__
  1909. cc_ident=$($cc -v 2>&1 | head -n1 | tr -d :)
  1910. CC_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1911. AS_DEPFLAGS='-MMD -MF $(@:.o=.d) -MT $@'
  1912. speed_cflags='-O2'
  1913. size_cflags='-Os'
  1914. filter_cflags='filter_out -Wdisabled-optimization|-Wtype-limits|-fno-signed-zeros'
  1915. fi
  1916. test -n "$cc_type" && enable $cc_type ||
  1917. warn "Unknown C compiler $cc, unable to select optimal CFLAGS"
  1918. : ${as_default:=$cc}
  1919. : ${dep_cc_default:=$cc}
  1920. : ${ld_default:=$cc}
  1921. set_default ar as dep_cc ld
  1922. test -n "$CC_DEPFLAGS" || CCDEP=$DEPEND_CMD
  1923. test -n "$AS_DEPFLAGS" || ASDEP=$DEPEND_CMD
  1924. add_cflags $extra_cflags
  1925. add_asflags $extra_cflags
  1926. if test -n "$sysroot"; then
  1927. case "$cc_type" in
  1928. gcc|llvm_gcc|clang)
  1929. add_cppflags --sysroot="$sysroot"
  1930. add_ldflags --sysroot="$sysroot"
  1931. ;;
  1932. tms470)
  1933. add_cppflags -I"$sysinclude"
  1934. add_ldflags --sysroot="$sysroot"
  1935. ;;
  1936. esac
  1937. fi
  1938. if test "$cpu" = host; then
  1939. enabled cross_compile && die "--cpu=host makes no sense when cross-compiling."
  1940. case "$cc_type" in
  1941. gcc|llvm_gcc)
  1942. check_native(){
  1943. $cc $1=native -v -c -o $TMPO $TMPC >$TMPE 2>&1 || return
  1944. sed -n "/cc1.*$1=/{
  1945. s/.*$1=\\([^ ]*\\).*/\\1/
  1946. p
  1947. q
  1948. }" $TMPE
  1949. }
  1950. cpu=$(check_native -march || check_native -mcpu)
  1951. ;;
  1952. esac
  1953. test "${cpu:-host}" = host && die "--cpu=host not supported with compiler $cc"
  1954. fi
  1955. # Deal with common $arch aliases
  1956. case "$arch" in
  1957. arm*)
  1958. arch="arm"
  1959. ;;
  1960. mips|mipsel|IP*)
  1961. arch="mips"
  1962. ;;
  1963. mips64*)
  1964. arch="mips"
  1965. subarch="mips64"
  1966. ;;
  1967. parisc|hppa)
  1968. arch="parisc"
  1969. ;;
  1970. parisc64|hppa64)
  1971. arch="parisc"
  1972. subarch="parisc64"
  1973. ;;
  1974. "Power Macintosh"|ppc|powerpc)
  1975. arch="ppc"
  1976. ;;
  1977. ppc64|powerpc64)
  1978. arch="ppc"
  1979. subarch="ppc64"
  1980. ;;
  1981. s390|s390x)
  1982. arch="s390"
  1983. ;;
  1984. sh4|sh)
  1985. arch="sh4"
  1986. ;;
  1987. sun4u|sparc64)
  1988. arch="sparc"
  1989. subarch="sparc64"
  1990. ;;
  1991. i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64)
  1992. arch="x86"
  1993. ;;
  1994. esac
  1995. is_in $arch $ARCH_LIST || warn "unknown architecture $arch"
  1996. enable $arch
  1997. # Add processor-specific flags
  1998. if test "$cpu" = generic; then
  1999. : do nothing
  2000. elif enabled ppc; then
  2001. case $(tolower $cpu) in
  2002. 601|ppc601|powerpc601)
  2003. cpuflags="-mcpu=601"
  2004. disable altivec
  2005. ;;
  2006. 603*|ppc603*|powerpc603*)
  2007. cpuflags="-mcpu=603"
  2008. disable altivec
  2009. ;;
  2010. 604*|ppc604*|powerpc604*)
  2011. cpuflags="-mcpu=604"
  2012. disable altivec
  2013. ;;
  2014. g3|75*|ppc75*|powerpc75*)
  2015. cpuflags="-mcpu=750 -mpowerpc-gfxopt"
  2016. disable altivec
  2017. ;;
  2018. g4|745*|ppc745*|powerpc745*)
  2019. cpuflags="-mcpu=7450 -mpowerpc-gfxopt"
  2020. ;;
  2021. 74*|ppc74*|powerpc74*)
  2022. cpuflags="-mcpu=7400 -mpowerpc-gfxopt"
  2023. ;;
  2024. g5|970|ppc970|powerpc970|power4*)
  2025. cpuflags="-mcpu=970 -mpowerpc-gfxopt -mpowerpc64"
  2026. ;;
  2027. cell)
  2028. cpuflags="-mcpu=cell"
  2029. enable ldbrx
  2030. ;;
  2031. e500v2)
  2032. cpuflags="-mcpu=8548 -mhard-float -mfloat-gprs=double"
  2033. disable altivec
  2034. ;;
  2035. e500)
  2036. cpuflags="-mcpu=8540 -mhard-float"
  2037. disable altivec
  2038. ;;
  2039. esac
  2040. elif enabled x86; then
  2041. case $cpu in
  2042. i[345]86|pentium)
  2043. cpuflags="-march=$cpu"
  2044. disable mmx
  2045. ;;
  2046. # targets that do NOT support conditional mov (cmov)
  2047. pentium-mmx|k6|k6-[23]|winchip-c6|winchip2|c3)
  2048. cpuflags="-march=$cpu"
  2049. disable cmov
  2050. ;;
  2051. # targets that do support conditional mov (cmov)
  2052. i686|pentiumpro|pentium[23]|pentium-m|athlon|athlon-tbird|athlon-4|athlon-[mx]p|athlon64*|k8*|opteron*|athlon-fx|core2|amdfam10|barcelona|atom)
  2053. cpuflags="-march=$cpu"
  2054. enable cmov
  2055. enable fast_cmov
  2056. ;;
  2057. # targets that do support conditional mov but on which it's slow
  2058. pentium4|pentium4m|prescott|nocona)
  2059. cpuflags="-march=$cpu"
  2060. enable cmov
  2061. disable fast_cmov
  2062. ;;
  2063. esac
  2064. elif enabled sparc; then
  2065. case $cpu in
  2066. niagara)
  2067. cpuflags="-mcpu=$cpu"
  2068. disable vis
  2069. ;;
  2070. sparc64)
  2071. cpuflags="-mcpu=v9"
  2072. ;;
  2073. esac
  2074. elif enabled arm; then
  2075. case $cpu in
  2076. armv*)
  2077. cpuflags="-march=$cpu"
  2078. subarch=$(echo $cpu | sed 's/[^a-z0-9]//g')
  2079. ;;
  2080. *)
  2081. cpuflags="-mcpu=$cpu"
  2082. case $cpu in
  2083. cortex-a*) subarch=armv7a ;;
  2084. cortex-r*) subarch=armv7r ;;
  2085. cortex-m*) enable thumb; subarch=armv7m ;;
  2086. arm11*) subarch=armv6 ;;
  2087. arm[79]*e*|arm9[24]6*|arm96*|arm102[26]) subarch=armv5te ;;
  2088. armv4*|arm7*|arm9[24]*) subarch=armv4 ;;
  2089. esac
  2090. ;;
  2091. esac
  2092. elif enabled alpha; then
  2093. enabled ccc && cpuflags="-arch $cpu" || cpuflags="-mcpu=$cpu"
  2094. elif enabled bfin; then
  2095. cpuflags="-mcpu=$cpu"
  2096. elif enabled mips; then
  2097. cpuflags="-march=$cpu"
  2098. elif enabled avr32; then
  2099. case $cpu in
  2100. ap7[02]0[0-2])
  2101. subarch="avr32_ap"
  2102. cpuflags="-mpart=$cpu"
  2103. ;;
  2104. ap)
  2105. subarch="avr32_ap"
  2106. cpuflags="-march=$cpu"
  2107. ;;
  2108. uc3[ab]*)
  2109. subarch="avr32_uc"
  2110. cpuflags="-mcpu=$cpu"
  2111. ;;
  2112. uc)
  2113. subarch="avr32_uc"
  2114. cpuflags="-march=$cpu"
  2115. ;;
  2116. esac
  2117. fi
  2118. add_cflags $cpuflags
  2119. add_asflags $cpuflags
  2120. # compiler sanity check
  2121. check_exec <<EOF
  2122. int main(void){ return 0; }
  2123. EOF
  2124. if test "$?" != 0; then
  2125. echo "$cc is unable to create an executable file."
  2126. if test -z "$cross_prefix" && ! enabled cross_compile ; then
  2127. echo "If $cc is a cross-compiler, use the --enable-cross-compile option."
  2128. echo "Only do this if you know what cross compiling means."
  2129. fi
  2130. die "C compiler test failed."
  2131. fi
  2132. add_cppflags -D_ISOC99_SOURCE
  2133. check_cflags -std=c99
  2134. check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
  2135. #include <stdlib.h>
  2136. EOF
  2137. check_cc -D_LARGEFILE_SOURCE <<EOF && add_cppflags -D_LARGEFILE_SOURCE
  2138. #include <stdlib.h>
  2139. EOF
  2140. check_host_cflags -std=c99
  2141. check_host_cflags -Wall
  2142. case "$arch" in
  2143. alpha|ia64|mips|parisc|sparc)
  2144. spic=$shared
  2145. ;;
  2146. x86)
  2147. subarch="x86_32"
  2148. check_cc <<EOF && subarch="x86_64"
  2149. int test[(int)sizeof(char*) - 7];
  2150. EOF
  2151. if test "$subarch" = "x86_64"; then
  2152. spic=$shared
  2153. fi
  2154. ;;
  2155. esac
  2156. enable $subarch
  2157. enabled spic && enable pic
  2158. # OS specific
  2159. case $target_os in
  2160. haiku)
  2161. prefix_default="/boot/common"
  2162. network_extralibs="-lnetwork"
  2163. host_libs=
  2164. ;;
  2165. sunos)
  2166. AVSERVERLDFLAGS=""
  2167. SHFLAGS='-shared -Wl,-h,$$(@F)'
  2168. enabled x86 && SHFLAGS="-mimpure-text $SHFLAGS"
  2169. network_extralibs="-lsocket -lnsl"
  2170. add_cppflags -D__EXTENSIONS__
  2171. # When using suncc to build, the Solaris linker will mark
  2172. # an executable with each instruction set encountered by
  2173. # the Solaris assembler. As our libraries contain their own
  2174. # guards for processor-specific code, instead suppress
  2175. # generation of the HWCAPS ELF section on Solaris x86 only.
  2176. enabled_all suncc x86 && echo "hwcap_1 = OVERRIDE;" > mapfile && add_ldflags -Wl,-M,mapfile
  2177. nm_opts='-P -g'
  2178. ;;
  2179. netbsd)
  2180. disable symver
  2181. oss_indev_extralibs="-lossaudio"
  2182. oss_outdev_extralibs="-lossaudio"
  2183. ;;
  2184. openbsd)
  2185. enable malloc_aligned
  2186. # On OpenBSD 4.5. the compiler does not use PIC unless
  2187. # explicitly using -fPIC. Libav builds fine without PIC,
  2188. # however the generated executable will not do anything
  2189. # (simply quits with exit-code 1, no crash, no output).
  2190. # Thus explicitly enable PIC here.
  2191. enable pic
  2192. disable symver
  2193. SHFLAGS='-shared'
  2194. oss_indev_extralibs="-lossaudio"
  2195. oss_outdev_extralibs="-lossaudio"
  2196. ;;
  2197. dragonfly)
  2198. enable malloc_aligned
  2199. disable symver
  2200. ;;
  2201. freebsd)
  2202. enable malloc_aligned
  2203. ;;
  2204. bsd/os)
  2205. add_extralibs -lpoll -lgnugetopt
  2206. ;;
  2207. darwin)
  2208. enable malloc_aligned
  2209. gas="gas-preprocessor.pl $cc"
  2210. enabled ppc && add_asflags -force_cpusubtype_ALL
  2211. SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR)'
  2212. enabled x86_32 && append SHFLAGS -Wl,-read_only_relocs,suppress
  2213. add_ldflags -Wl,-dynamic,-search_paths_first
  2214. SLIBSUF=".dylib"
  2215. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME).$(LIBVERSION)$(SLIBSUF)'
  2216. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME).$(LIBMAJOR)$(SLIBSUF)'
  2217. AVSERVERLDFLAGS=-Wl,-bind_at_load
  2218. objformat="macho"
  2219. enabled x86_64 && objformat="macho64"
  2220. enabled_any pic shared ||
  2221. { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
  2222. ;;
  2223. mingw32*)
  2224. if test $target_os = "mingw32ce"; then
  2225. disable network
  2226. else
  2227. target_os=mingw32
  2228. fi
  2229. LIBTARGET=i386
  2230. if enabled x86_64; then
  2231. enable malloc_aligned
  2232. LIBTARGET="i386:x86-64"
  2233. elif enabled arm; then
  2234. LIBTARGET=arm-wince
  2235. fi
  2236. shlibdir_default="$bindir_default"
  2237. SLIBPREF=""
  2238. SLIBSUF=".dll"
  2239. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2240. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2241. SLIB_EXTRA_CMD=-'$(DLLTOOL) -m $(LIBTARGET) -d $$(@:$(SLIBSUF)=.def) -l $(SUBDIR)$(SLIBNAME:$(SLIBSUF)=.lib) -D $(SLIBNAME_WITH_MAJOR)'
  2242. SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
  2243. SLIB_INSTALL_LINKS=
  2244. SLIB_INSTALL_EXTRA_SHLIB='$(SLIBNAME:$(SLIBSUF)=.lib)'
  2245. SLIB_INSTALL_EXTRA_LIB='lib$(SLIBNAME:$(SLIBSUF)=.dll.a) $(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.def)'
  2246. SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--out-implib,$(SUBDIR)lib$(SLIBNAME:$(SLIBSUF)=.dll.a) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
  2247. objformat="win32"
  2248. dlltool="${cross_prefix}dlltool"
  2249. enable dos_paths
  2250. check_cflags -fno-common
  2251. check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
  2252. || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
  2253. die "ERROR: MinGW runtime version must be >= 3.15."
  2254. add_cppflags -U__STRICT_ANSI__
  2255. ;;
  2256. cygwin*)
  2257. target_os=cygwin
  2258. shlibdir_default="$bindir_default"
  2259. SLIBPREF="cyg"
  2260. SLIBSUF=".dll"
  2261. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
  2262. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
  2263. SHFLAGS='-shared -Wl,--enable-auto-image-base'
  2264. objformat="win32"
  2265. enable dos_paths
  2266. check_cflags -fno-common
  2267. add_cppflags -U__STRICT_ANSI__
  2268. ;;
  2269. *-dos|freedos|opendos)
  2270. network_extralibs="-lsocket"
  2271. objformat="coff"
  2272. enable dos_paths
  2273. add_cppflags -U__STRICT_ANSI__
  2274. ;;
  2275. linux)
  2276. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
  2277. enable dv1394
  2278. ;;
  2279. irix*)
  2280. target_os=irix
  2281. ranlib="echo ignoring ranlib"
  2282. ;;
  2283. os/2*)
  2284. ln_s="cp -f"
  2285. objformat="aout"
  2286. add_cppflags -D_GNU_SOURCE
  2287. add_ldflags -Zomf -Zbin-files -Zargs-wild -Zmap
  2288. SHFLAGS='$(SUBDIR)$(NAME).def -Zdll -Zomf'
  2289. AVSERVERLDFLAGS=""
  2290. LIBSUF="_s.a"
  2291. SLIBPREF=""
  2292. SLIBSUF=".dll"
  2293. SLIBNAME_WITH_VERSION='$(SLIBPREF)$(NAME)-$(LIBVERSION)$(SLIBSUF)'
  2294. SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(shell echo $(NAME) | cut -c1-6)$(LIBMAJOR)$(SLIBSUF)'
  2295. SLIB_CREATE_DEF_CMD='echo LIBRARY $(SLIBNAME_WITH_MAJOR) INITINSTANCE TERMINSTANCE > $(SUBDIR)$(NAME).def; \
  2296. echo PROTMODE >> $(SUBDIR)$(NAME).def; \
  2297. echo CODE PRELOAD MOVEABLE DISCARDABLE >> $(SUBDIR)$(NAME).def; \
  2298. echo DATA PRELOAD MOVEABLE MULTIPLE NONSHARED >> $(SUBDIR)$(NAME).def; \
  2299. echo EXPORTS >> $(SUBDIR)$(NAME).def; \
  2300. emxexp -o $(OBJS) >> $(SUBDIR)$(NAME).def'
  2301. SLIB_EXTRA_CMD='emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(NAME).def; \
  2302. emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
  2303. SLIB_INSTALL_EXTRA_LIB='$(LIBPREF)$(NAME)_dll.a $(LIBPREF)$(NAME)_dll.lib'
  2304. enable dos_paths
  2305. ;;
  2306. gnu/kfreebsd)
  2307. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
  2308. ;;
  2309. gnu)
  2310. add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
  2311. ;;
  2312. qnx)
  2313. add_cppflags -D_QNX_SOURCE
  2314. network_extralibs="-lsocket"
  2315. ;;
  2316. symbian)
  2317. SLIBSUF=".dll"
  2318. enable dos_paths
  2319. add_cflags --include=$sysinclude/gcce/gcce.h -fvisibility=default
  2320. add_cppflags -D__GCCE__ -D__SYMBIAN32__ -DSYMBIAN_OE_POSIX_SIGNALS
  2321. add_ldflags -Wl,--target1-abs,--no-undefined \
  2322. -Wl,-Ttext,0x80000,-Tdata,0x1000000 -shared \
  2323. -Wl,--entry=_E32Startup -Wl,-u,_E32Startup
  2324. add_extralibs -l:eexe.lib -l:usrt2_2.lib -l:dfpaeabi.dso \
  2325. -l:drtaeabi.dso -l:scppnwdl.dso -lsupc++ -lgcc \
  2326. -l:libc.dso -l:libm.dso -l:euser.dso -l:libcrt0.lib
  2327. ;;
  2328. none)
  2329. ;;
  2330. *)
  2331. die "Unknown OS '$target_os'."
  2332. ;;
  2333. esac
  2334. echo "config:$arch:$subarch:$cpu:$target_os:$cc_ident:$LIBAV_CONFIGURATION" >config.fate
  2335. check_cpp_condition stdlib.h "defined(__PIC__) || defined(__pic__) || defined(PIC)" && enable pic
  2336. set_default $PATHS_LIST
  2337. # we need to build at least one lib type
  2338. if ! enabled_any static shared; then
  2339. cat <<EOF
  2340. At least one library type must be built.
  2341. Specify --enable-static to build the static libraries or --enable-shared to
  2342. build the shared libraries as well. To only build the shared libraries specify
  2343. --disable-static in addition to --enable-shared.
  2344. EOF
  2345. exit 1;
  2346. fi
  2347. die_license_disabled() {
  2348. enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
  2349. }
  2350. die_license_disabled gpl libcdio
  2351. die_license_disabled gpl libx264
  2352. die_license_disabled gpl libxavs
  2353. die_license_disabled gpl libxvid
  2354. die_license_disabled gpl x11grab
  2355. die_license_disabled nonfree libfaac
  2356. die_license_disabled nonfree openssl
  2357. die_license_disabled version3 libopencore_amrnb
  2358. die_license_disabled version3 libopencore_amrwb
  2359. die_license_disabled version3 libvo_aacenc
  2360. die_license_disabled version3 libvo_amrwbenc
  2361. enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
  2362. disabled optimizations || check_cflags -fomit-frame-pointer
  2363. enable_pic() {
  2364. enable pic
  2365. add_cppflags -DPIC
  2366. add_cflags -fPIC
  2367. add_asflags -fPIC
  2368. }
  2369. enabled pic && enable_pic
  2370. check_cc <<EOF || die "Symbol mangling check failed."
  2371. int ff_extern;
  2372. EOF
  2373. sym=$($nm $nm_opts $TMPO | awk '/ff_extern/{ print substr($0, match($0, /[^ \t]*ff_extern/)) }')
  2374. extern_prefix=${sym%%ff_extern*}
  2375. check_cc <<EOF && enable inline_asm
  2376. void foo(void) { __asm__ volatile ("" ::); }
  2377. EOF
  2378. _restrict=
  2379. for restrict_keyword in restrict __restrict__ __restrict; do
  2380. check_cc <<EOF && _restrict=$restrict_keyword && break
  2381. void foo(char * $restrict_keyword p);
  2382. EOF
  2383. done
  2384. check_cc <<EOF && enable attribute_packed
  2385. struct { int x; } __attribute__((packed)) x;
  2386. EOF
  2387. check_cc <<EOF && enable attribute_may_alias
  2388. union { int x; } __attribute__((may_alias)) x;
  2389. EOF
  2390. check_cc <<EOF || die "endian test failed"
  2391. unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
  2392. EOF
  2393. od -t x1 $TMPO | grep -q '42 *49 *47 *45' && enable bigendian
  2394. if enabled alpha; then
  2395. check_cflags -mieee
  2396. elif enabled arm; then
  2397. enabled thumb && check_cflags -mthumb || check_cflags -marm
  2398. nogas=die
  2399. if check_cpp_condition stddef.h "defined __ARM_PCS_VFP"; then
  2400. enable vfp_args
  2401. elif ! check_cpp_condition stddef.h "defined __ARM_PCS || defined __SOFTFP__"; then
  2402. case "${cross_prefix:-$cc}" in
  2403. *hardfloat*) enable vfp_args; fpabi=vfp ;;
  2404. *) check_ld <<EOF && enable vfp_args && fpabi=vfp || fpabi=soft ;;
  2405. __asm__ (".eabi_attribute 28, 1");
  2406. int main(void) { return 0; }
  2407. EOF
  2408. esac
  2409. warn "Compiler does not indicate floating-point ABI, guessing $fpabi."
  2410. fi
  2411. enabled armv5te && check_asm armv5te '"qadd r0, r0, r0"'
  2412. enabled armv6 && check_asm armv6 '"sadd16 r0, r0, r0"'
  2413. enabled armv6t2 && check_asm armv6t2 '"movt r0, #0"'
  2414. enabled armvfp && check_asm armvfp '"fadds s0, s0, s0"'
  2415. enabled iwmmxt && check_asm iwmmxt '"wunpckelub wr6, wr4"'
  2416. enabled neon && check_asm neon '"vadd.i16 q0, q0, q0"'
  2417. enabled vfpv3 && check_asm vfpv3 '"vmov.f32 s0, #1.0"'
  2418. check_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
  2419. enabled_all armv6t2 shared !pic && enable_pic
  2420. elif enabled mips; then
  2421. check_asm loongson '"dmult.g $1, $2, $3"'
  2422. enabled mmi && check_asm mmi '"lq $2, 0($2)"'
  2423. elif enabled ppc; then
  2424. enable local_aligned_8 local_aligned_16
  2425. check_asm dcbzl '"dcbzl 0, %0" :: "r"(0)'
  2426. check_asm ibm_asm '"add 0, 0, 0"'
  2427. check_asm ppc4xx '"maclhw r10, r11, r12"'
  2428. check_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)'
  2429. # AltiVec flags: The FSF version of GCC differs from the Apple version
  2430. if enabled altivec; then
  2431. nogas=warn
  2432. check_cflags -maltivec -mabi=altivec &&
  2433. { check_header altivec.h && inc_altivec_h="#include <altivec.h>" ; } ||
  2434. check_cflags -faltivec
  2435. # check if our compiler supports Motorola AltiVec C API
  2436. check_cc <<EOF || disable altivec
  2437. $inc_altivec_h
  2438. int main(void) {
  2439. vector signed int v1, v2, v3;
  2440. v1 = vec_add(v2,v3);
  2441. return 0;
  2442. }
  2443. EOF
  2444. # check if our compiler supports braces for vector declarations
  2445. check_cc <<EOF || die "You need a compiler that supports {} in AltiVec vector declarations."
  2446. $inc_altivec_h
  2447. int main (void) { (vector int) {1}; return 0; }
  2448. EOF
  2449. fi
  2450. elif enabled sparc; then
  2451. enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
  2452. add_cflags -mcpu=ultrasparc -mtune=ultrasparc
  2453. elif enabled x86; then
  2454. enable local_aligned_8 local_aligned_16
  2455. # check whether EBP is available on x86
  2456. # As 'i' is stored on the stack, this program will crash
  2457. # if the base pointer is used to access it because the
  2458. # base pointer is cleared in the inline assembly code.
  2459. check_exec_crash <<EOF && enable ebp_available
  2460. volatile int i=0;
  2461. __asm__ volatile (
  2462. "xorl %%ebp, %%ebp"
  2463. ::: "%ebp");
  2464. return i;
  2465. EOF
  2466. # check whether EBX is available on x86
  2467. check_asm ebx_available '""::"b"(0)' &&
  2468. check_asm ebx_available '"":::"%ebx"'
  2469. # check whether xmm clobbers are supported
  2470. check_asm xmm_clobbers '"":::"%xmm0"'
  2471. # check whether binutils is new enough to compile SSSE3/MMX2
  2472. enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
  2473. enabled mmx2 && check_asm mmx2 '"pmaxub %mm0, %mm1"'
  2474. check_asm bswap '"bswap %%eax" ::: "%eax"'
  2475. if ! disabled_any asm mmx yasm; then
  2476. if check_cmd $yasmexe --version; then
  2477. enabled x86_64 && yasm_extra="-m amd64"
  2478. yasm_debug="-g dwarf2"
  2479. elif check_cmd nasm -v; then
  2480. yasmexe=nasm
  2481. yasm_debug="-g -F dwarf"
  2482. enabled x86_64 && test "$objformat" = elf && objformat=elf64
  2483. fi
  2484. YASMFLAGS="-f $objformat $yasm_extra"
  2485. enabled pic && append YASMFLAGS "-DPIC"
  2486. test -n "$extern_prefix" && append YASMFLAGS "-DPREFIX"
  2487. case "$objformat" in
  2488. elf*) enabled debug && append YASMFLAGS $yasm_debug ;;
  2489. esac
  2490. check_yasm "pextrd [eax], xmm0, 1" && enable yasm ||
  2491. die "yasm not found, use --disable-yasm for a crippled build"
  2492. check_yasm "vextractf128 xmm0, ymm0, 0" || disable avx
  2493. fi
  2494. case "$cpu" in
  2495. athlon*|opteron*|k8*|pentium|pentium-mmx|prescott|nocona|atom|geode)
  2496. disable fast_clz
  2497. ;;
  2498. esac
  2499. fi
  2500. if enabled asm; then
  2501. as=${gas:=$as}
  2502. check_asm gnu_as '".macro m n\n\\n:.int 0\n.endm\nm x"' ||
  2503. $nogas "GNU assembler not found, install gas-preprocessor"
  2504. fi
  2505. check_ldflags -Wl,--as-needed
  2506. if check_func dlopen; then
  2507. ldl=
  2508. elif check_func dlopen -ldl; then
  2509. ldl=-ldl
  2510. fi
  2511. if enabled network; then
  2512. check_type "sys/types.h sys/socket.h" socklen_t
  2513. check_type netdb.h "struct addrinfo"
  2514. check_type netinet/in.h "struct ipv6_mreq" -D_DARWIN_C_SOURCE
  2515. check_type netinet/in.h "struct sockaddr_in6"
  2516. check_type "sys/types.h sys/socket.h" "struct sockaddr_storage"
  2517. check_struct "sys/types.h sys/socket.h" "struct sockaddr" sa_len
  2518. # Prefer arpa/inet.h over winsock2
  2519. if check_header arpa/inet.h ; then
  2520. check_func closesocket
  2521. elif check_header winsock2.h ; then
  2522. check_func_headers winsock2.h closesocket -lws2 && \
  2523. network_extralibs="-lws2" || \
  2524. { check_func_headers winsock2.h closesocket -lws2_32 && \
  2525. network_extralibs="-lws2_32"; }
  2526. check_type ws2tcpip.h socklen_t
  2527. check_type ws2tcpip.h "struct addrinfo"
  2528. check_type ws2tcpip.h "struct ipv6_mreq"
  2529. check_type ws2tcpip.h "struct sockaddr_in6"
  2530. check_type ws2tcpip.h "struct sockaddr_storage"
  2531. check_struct winsock2.h "struct sockaddr" sa_len
  2532. else
  2533. disable network
  2534. fi
  2535. fi
  2536. # Solaris has nanosleep in -lrt, OpenSolaris no longer needs that
  2537. check_func nanosleep || { check_func nanosleep -lrt && add_extralibs -lrt; }
  2538. check_func fcntl
  2539. check_func fork
  2540. check_func getaddrinfo $network_extralibs
  2541. check_func gethrtime
  2542. check_func getrusage
  2543. check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
  2544. check_func inet_aton $network_extralibs
  2545. check_func isatty
  2546. check_func localtime_r
  2547. check_func ${malloc_prefix}memalign && enable memalign
  2548. check_func mkstemp
  2549. check_func mmap
  2550. check_func ${malloc_prefix}posix_memalign && enable posix_memalign
  2551. check_func setrlimit
  2552. check_func strerror_r
  2553. check_func strptime
  2554. check_func strtok_r
  2555. check_func_headers io.h setmode
  2556. check_func_headers lzo/lzo1x.h lzo1x_999_compress
  2557. check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
  2558. check_func_headers windows.h GetProcessTimes
  2559. check_func_headers windows.h MapViewOfFile
  2560. check_func_headers windows.h VirtualAlloc
  2561. check_header dlfcn.h
  2562. check_header dxva2api.h
  2563. check_header malloc.h
  2564. check_header poll.h
  2565. check_header sys/mman.h
  2566. check_header sys/resource.h
  2567. check_header sys/select.h
  2568. check_header vdpau/vdpau.h
  2569. check_header vdpau/vdpau_x11.h
  2570. check_header X11/extensions/XvMClib.h
  2571. check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
  2572. disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
  2573. disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
  2574. if ! disabled w32threads && ! enabled pthreads; then
  2575. check_func _beginthreadex && enable w32threads
  2576. fi
  2577. # check for some common methods of building with pthread support
  2578. # do this before the optional library checks as some of them require pthreads
  2579. if ! disabled pthreads && ! enabled w32threads; then
  2580. enable pthreads
  2581. if check_func pthread_create; then
  2582. :
  2583. elif check_func pthread_create -pthread; then
  2584. add_cflags -pthread
  2585. add_extralibs -pthread
  2586. elif check_func pthread_create -pthreads; then
  2587. add_cflags -pthreads
  2588. add_extralibs -pthreads
  2589. elif check_func pthread_create -lpthreadGC2; then
  2590. add_extralibs -lpthreadGC2
  2591. elif ! check_lib pthread.h pthread_create -lpthread; then
  2592. disable pthreads
  2593. fi
  2594. fi
  2595. for thread in $THREADS_LIST; do
  2596. if enabled $thread; then
  2597. test -n "$thread_type" &&
  2598. die "ERROR: Only one thread type must be selected." ||
  2599. thread_type="$thread"
  2600. fi
  2601. done
  2602. check_lib math.h sin -lm && LIBM="-lm"
  2603. enabled vaapi && require vaapi va/va.h vaInitialize -lva
  2604. check_mathfunc exp2
  2605. check_mathfunc exp2f
  2606. check_mathfunc llrint
  2607. check_mathfunc llrintf
  2608. check_mathfunc log2
  2609. check_mathfunc log2f
  2610. check_mathfunc lrint
  2611. check_mathfunc lrintf
  2612. check_mathfunc round
  2613. check_mathfunc roundf
  2614. check_mathfunc trunc
  2615. check_mathfunc truncf
  2616. # these are off by default, so fail if requested and not available
  2617. enabled avisynth && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
  2618. enabled frei0r && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
  2619. enabled gnutls && require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init
  2620. enabled libdirac && require_pkg_config dirac \
  2621. "libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h" \
  2622. "dirac_decoder_init dirac_encoder_init"
  2623. enabled libfaac && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
  2624. enabled libfreetype && require_pkg_config freetype2 "ft2build.h freetype/freetype.h" FT_Init_FreeType
  2625. enabled libgsm && require libgsm gsm/gsm.h gsm_create -lgsm
  2626. enabled libmp3lame && require "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
  2627. enabled libnut && require libnut libnut.h nut_demuxer_init -lnut
  2628. enabled libopencore_amrnb && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
  2629. enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
  2630. enabled libopencv && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
  2631. enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
  2632. enabled libpulse && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
  2633. enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
  2634. enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
  2635. enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex
  2636. enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
  2637. enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc
  2638. enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc
  2639. enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
  2640. enabled libvpx && {
  2641. enabled libvpx_decoder && { check_lib2 "vpx/vpx_decoder.h vpx/vp8dx.h" vpx_codec_dec_init_ver -lvpx ||
  2642. die "ERROR: libvpx decoder version must be >=0.9.1"; }
  2643. enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx ||
  2644. die "ERROR: libvpx encoder version must be >=0.9.1"; } }
  2645. enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 &&
  2646. { check_cpp_condition x264.h "X264_BUILD >= 118" ||
  2647. die "ERROR: libx264 version must be >= 0.118."; }
  2648. enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs
  2649. enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore
  2650. enabled mlib && require mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
  2651. enabled openssl && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
  2652. check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
  2653. check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
  2654. die "ERROR: openssl not found"; }
  2655. # libdc1394 check
  2656. if enabled libdc1394; then
  2657. { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
  2658. enable libdc1394_2; } ||
  2659. { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
  2660. enable libdc1394_1; } ||
  2661. die "ERROR: No version of libdc1394 found "
  2662. fi
  2663. if check_pkg_config sdl SDL_version.h SDL_Linked_Version; then
  2664. check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
  2665. enable sdl &&
  2666. check_struct SDL.h SDL_VideoInfo current_w $sdl_cflags && enable sdl_video_size
  2667. fi
  2668. texi2html -version > /dev/null 2>&1 && enable texi2html || disable texi2html
  2669. check_header linux/fb.h
  2670. check_header linux/videodev.h
  2671. check_header linux/videodev2.h
  2672. check_header sys/videoio.h
  2673. check_func_headers "windows.h vfw.h" capCreateCaptureWindow "$vfwcap_indev_extralibs"
  2674. # check that WM_CAP_DRIVER_CONNECT is defined to the proper value
  2675. # w32api 3.12 had it defined wrong
  2676. check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
  2677. # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
  2678. { check_header dev/bktr/ioctl_meteor.h &&
  2679. check_header dev/bktr/ioctl_bt848.h; } ||
  2680. { check_header machine/ioctl_meteor.h &&
  2681. check_header machine/ioctl_bt848.h; } ||
  2682. { check_header dev/video/meteor/ioctl_meteor.h &&
  2683. check_header dev/video/bktr/ioctl_bt848.h; } ||
  2684. check_header dev/ic/bt8xx.h
  2685. check_header sndio.h
  2686. check_header sys/soundcard.h
  2687. check_header soundcard.h
  2688. enabled_any alsa_indev alsa_outdev && check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
  2689. enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack
  2690. enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
  2691. enabled libcdio &&
  2692. check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open "-lcdio_paranoia -lcdio_cdda -lcdio"
  2693. enabled x11grab &&
  2694. check_header X11/Xlib.h &&
  2695. check_header X11/extensions/XShm.h &&
  2696. check_header X11/extensions/Xfixes.h &&
  2697. check_func XOpenDisplay -lX11 &&
  2698. check_func XShmCreateImage -lX11 -lXext &&
  2699. check_func XFixesGetCursorImage -lX11 -lXext -lXfixes
  2700. # check for VDA header
  2701. if ! disabled vda && check_header VideoDecodeAcceleration/VDADecoder.h; then
  2702. enable vda && add_ldflags -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore
  2703. fi
  2704. if ! disabled vdpau && enabled vdpau_vdpau_h; then
  2705. check_cpp_condition \
  2706. vdpau/vdpau.h "defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP" ||
  2707. { echolog "Please upgrade to libvdpau >= 0.2 if you would like vdpau support." &&
  2708. disable vdpau; }
  2709. fi
  2710. enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
  2711. # add some useful compiler flags if supported
  2712. check_cflags -Wdeclaration-after-statement
  2713. check_cflags -Wall
  2714. check_cflags -Wno-parentheses
  2715. check_cflags -Wno-switch
  2716. check_cflags -Wno-format-zero-length
  2717. check_cflags -Wdisabled-optimization
  2718. check_cflags -Wpointer-arith
  2719. check_cflags -Wredundant-decls
  2720. check_cflags -Wno-pointer-sign
  2721. check_cflags -Wcast-qual
  2722. check_cflags -Wwrite-strings
  2723. check_cflags -Wtype-limits
  2724. check_cflags -Wundef
  2725. check_cflags -Wmissing-prototypes
  2726. check_cflags -Wstrict-prototypes
  2727. enabled extra_warnings && check_cflags -Winline
  2728. # add some linker flags
  2729. check_ldflags -Wl,--warn-common
  2730. check_ldflags -Wl,-rpath-link=libpostproc:libswscale:libavfilter:libavdevice:libavformat:libavcodec:libavutil
  2731. test_ldflags -Wl,-Bsymbolic && append SHFLAGS -Wl,-Bsymbolic
  2732. echo "X{};" > $TMPV
  2733. if test_ldflags -Wl,--version-script,$TMPV; then
  2734. append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
  2735. check_cc <<EOF && enable symver_asm_label
  2736. void ff_foo(void) __asm__ ("av_foo@VERSION");
  2737. void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
  2738. EOF
  2739. check_cc <<EOF && enable symver_gnu_asm
  2740. __asm__(".symver ff_foo,av_foo@VERSION");
  2741. void ff_foo(void) {}
  2742. EOF
  2743. fi
  2744. if [ -n "$optflags" ]; then
  2745. add_cflags $optflags
  2746. elif enabled small; then
  2747. add_cflags $size_cflags
  2748. elif enabled optimizations; then
  2749. add_cflags $speed_cflags
  2750. else
  2751. add_cflags $noopt_cflags
  2752. fi
  2753. check_cflags -fno-math-errno
  2754. check_cflags -fno-signed-zeros
  2755. if enabled icc; then
  2756. # Just warnings, no remarks
  2757. check_cflags -w1
  2758. # -wd: Disable following warnings
  2759. # 144, 167, 556: -Wno-pointer-sign
  2760. # 1292: attribute "foo" ignored
  2761. # 10006: ignoring unknown option -fno-signed-zeros
  2762. # 10148: ignoring unknown option -Wno-parentheses
  2763. # 10156: ignoring option '-W'; no argument required
  2764. check_cflags -wd144,167,556,1292,10006,10148,10156
  2765. # 11030: Warning unknown option --as-needed
  2766. # 10156: ignoring option '-export'; no argument required
  2767. check_ldflags -wd10156,11030
  2768. # Allow to compile with optimizations
  2769. check_ldflags -march=$cpu
  2770. # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
  2771. enable ebp_available
  2772. if enabled x86_32; then
  2773. test ${icc_version%%.*} -ge 11 && \
  2774. check_cflags -falign-stack=maintain-16-byte || \
  2775. disable aligned_stack
  2776. fi
  2777. elif enabled ccc; then
  2778. # disable some annoying warnings
  2779. add_cflags -msg_disable cvtu32to64
  2780. add_cflags -msg_disable embedcomment
  2781. add_cflags -msg_disable needconstext
  2782. add_cflags -msg_disable nomainieee
  2783. add_cflags -msg_disable ptrmismatch1
  2784. add_cflags -msg_disable unreachcode
  2785. elif enabled gcc; then
  2786. check_cflags -fno-tree-vectorize
  2787. check_cflags -Werror=implicit-function-declaration
  2788. check_cflags -Werror=missing-prototypes
  2789. elif enabled llvm_gcc; then
  2790. check_cflags -mllvm -stack-alignment=16
  2791. elif enabled clang; then
  2792. check_cflags -mllvm -stack-alignment=16
  2793. check_cflags -Qunused-arguments
  2794. elif enabled armcc; then
  2795. # 2523: use of inline assembler is deprecated
  2796. add_cflags -W${armcc_opt},--diag_suppress=2523
  2797. add_cflags -W${armcc_opt},--diag_suppress=1207
  2798. add_cflags -W${armcc_opt},--diag_suppress=1293 # assignment in condition
  2799. add_cflags -W${armcc_opt},--diag_suppress=3343 # hardfp compat
  2800. add_cflags -W${armcc_opt},--diag_suppress=167 # pointer sign
  2801. add_cflags -W${armcc_opt},--diag_suppress=513 # pointer sign
  2802. elif enabled tms470; then
  2803. add_cflags -pds=824 -pds=837
  2804. elif enabled pathscale; then
  2805. add_cflags -fstrict-overflow -OPT:wrap_around_unsafe_opt=OFF
  2806. fi
  2807. enabled_any $THREADS_LIST && enable threads
  2808. check_deps $CONFIG_LIST \
  2809. $CONFIG_EXTRA \
  2810. $HAVE_LIST \
  2811. $DECODER_LIST \
  2812. $ENCODER_LIST \
  2813. $HWACCEL_LIST \
  2814. $PARSER_LIST \
  2815. $BSF_LIST \
  2816. $DEMUXER_LIST \
  2817. $MUXER_LIST \
  2818. $FILTER_LIST \
  2819. $INDEV_LIST \
  2820. $OUTDEV_LIST \
  2821. $PROTOCOL_LIST \
  2822. $ACODEC_TESTS \
  2823. $VCODEC_TESTS \
  2824. $LAVF_TESTS \
  2825. $LAVFI_TESTS \
  2826. $SEEK_TESTS \
  2827. enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; }
  2828. ! enabled_any memalign posix_memalign malloc_aligned &&
  2829. enabled_any $need_memalign && enable memalign_hack
  2830. echo "install prefix $prefix"
  2831. echo "source path $source_path"
  2832. echo "C compiler $cc"
  2833. echo "ARCH $arch ($cpu)"
  2834. if test "$build_suffix" != ""; then
  2835. echo "build suffix $build_suffix"
  2836. fi
  2837. if test "$extra_version" != ""; then
  2838. echo "version string suffix $extra_version"
  2839. fi
  2840. echo "big-endian ${bigendian-no}"
  2841. echo "runtime cpu detection ${runtime_cpudetect-no}"
  2842. if enabled x86; then
  2843. echo "${yasmexe} ${yasm-no}"
  2844. echo "MMX enabled ${mmx-no}"
  2845. echo "MMX2 enabled ${mmx2-no}"
  2846. echo "3DNow! enabled ${amd3dnow-no}"
  2847. echo "3DNow! extended enabled ${amd3dnowext-no}"
  2848. echo "SSE enabled ${sse-no}"
  2849. echo "SSSE3 enabled ${ssse3-no}"
  2850. echo "AVX enabled ${avx-no}"
  2851. echo "CMOV enabled ${cmov-no}"
  2852. echo "CMOV is fast ${fast_cmov-no}"
  2853. echo "EBX available ${ebx_available-no}"
  2854. echo "EBP available ${ebp_available-no}"
  2855. fi
  2856. if enabled arm; then
  2857. echo "ARMv5TE enabled ${armv5te-no}"
  2858. echo "ARMv6 enabled ${armv6-no}"
  2859. echo "ARMv6T2 enabled ${armv6t2-no}"
  2860. echo "ARM VFP enabled ${armvfp-no}"
  2861. echo "IWMMXT enabled ${iwmmxt-no}"
  2862. echo "NEON enabled ${neon-no}"
  2863. fi
  2864. if enabled mips; then
  2865. echo "MMI enabled ${mmi-no}"
  2866. fi
  2867. if enabled ppc; then
  2868. echo "AltiVec enabled ${altivec-no}"
  2869. echo "PPC 4xx optimizations ${ppc4xx-no}"
  2870. echo "dcbzl available ${dcbzl-no}"
  2871. fi
  2872. if enabled sparc; then
  2873. echo "VIS enabled ${vis-no}"
  2874. fi
  2875. echo "debug symbols ${debug-no}"
  2876. echo "optimize for size ${small-no}"
  2877. echo "optimizations ${optimizations-no}"
  2878. echo "static ${static-no}"
  2879. echo "shared ${shared-no}"
  2880. echo "postprocessing support ${postproc-no}"
  2881. echo "new filter support ${avfilter-no}"
  2882. echo "network support ${network-no}"
  2883. echo "threading support ${thread_type-no}"
  2884. echo "SDL support ${sdl-no}"
  2885. echo "Sun medialib support ${mlib-no}"
  2886. echo "libdxva2 enabled ${dxva2-no}"
  2887. echo "libva enabled ${vaapi-no}"
  2888. echo "libvdpau enabled ${vdpau-no}"
  2889. echo "AVISynth enabled ${avisynth-no}"
  2890. echo "frei0r enabled ${frei0r-no}"
  2891. echo "gnutls enabled ${gnutls-no}"
  2892. echo "libcdio support ${libcdio-no}"
  2893. echo "libdc1394 support ${libdc1394-no}"
  2894. echo "libdirac enabled ${libdirac-no}"
  2895. echo "libfaac enabled ${libfaac-no}"
  2896. echo "libgsm enabled ${libgsm-no}"
  2897. echo "libmp3lame enabled ${libmp3lame-no}"
  2898. echo "libnut enabled ${libnut-no}"
  2899. echo "libopencore-amrnb support ${libopencore_amrnb-no}"
  2900. echo "libopencore-amrwb support ${libopencore_amrwb-no}"
  2901. echo "libopencv support ${libopencv-no}"
  2902. echo "libopenjpeg enabled ${libopenjpeg-no}"
  2903. echo "libpulse enabled ${libpulse-no}"
  2904. echo "librtmp enabled ${librtmp-no}"
  2905. echo "libschroedinger enabled ${libschroedinger-no}"
  2906. echo "libspeex enabled ${libspeex-no}"
  2907. echo "libtheora enabled ${libtheora-no}"
  2908. echo "libvo-aacenc support ${libvo_aacenc-no}"
  2909. echo "libvo-amrwbenc support ${libvo_amrwbenc-no}"
  2910. echo "libvorbis enabled ${libvorbis-no}"
  2911. echo "libvpx enabled ${libvpx-no}"
  2912. echo "libx264 enabled ${libx264-no}"
  2913. echo "libxavs enabled ${libxavs-no}"
  2914. echo "libxvid enabled ${libxvid-no}"
  2915. echo "openssl enabled ${openssl-no}"
  2916. echo "zlib enabled ${zlib-no}"
  2917. echo "bzlib enabled ${bzlib-no}"
  2918. echo
  2919. for type in decoder encoder hwaccel parser demuxer muxer protocol filter bsf indev outdev; do
  2920. echo "Enabled ${type}s:"
  2921. eval list=\$$(toupper $type)_LIST
  2922. print_enabled '_*' $list | sort | pr -r -3 -t
  2923. echo
  2924. done
  2925. license="LGPL version 2.1 or later"
  2926. if enabled nonfree; then
  2927. license="nonfree and unredistributable"
  2928. elif enabled gplv3; then
  2929. license="GPL version 3 or later"
  2930. elif enabled lgplv3; then
  2931. license="LGPL version 3 or later"
  2932. elif enabled gpl; then
  2933. license="GPL version 2 or later"
  2934. fi
  2935. echo "License: $license"
  2936. echo "Creating config.mak and config.h..."
  2937. test -e Makefile || $ln_s "$source_path/Makefile" .
  2938. config_files="$TMPH config.mak"
  2939. cat > config.mak <<EOF
  2940. # Automatically generated by configure - do not modify!
  2941. LIBAV_CONFIGURATION=$LIBAV_CONFIGURATION
  2942. prefix=$prefix
  2943. LIBDIR=\$(DESTDIR)$libdir
  2944. SHLIBDIR=\$(DESTDIR)$shlibdir
  2945. INCDIR=\$(DESTDIR)$incdir
  2946. BINDIR=\$(DESTDIR)$bindir
  2947. DATADIR=\$(DESTDIR)$datadir
  2948. MANDIR=\$(DESTDIR)$mandir
  2949. SRC_PATH=$source_path
  2950. CC_IDENT=$cc_ident
  2951. ARCH=$arch
  2952. CC=$cc
  2953. AS=$as
  2954. LD=$ld
  2955. DEPCC=$dep_cc
  2956. YASM=$yasmexe
  2957. YASMDEP=$yasmexe
  2958. AR=$ar
  2959. RANLIB=$ranlib
  2960. LN_S=$ln_s
  2961. CPPFLAGS=$CPPFLAGS
  2962. CFLAGS=$CFLAGS
  2963. ASFLAGS=$ASFLAGS
  2964. AS_O=$CC_O
  2965. CC_O=$CC_O
  2966. DLLTOOL=$dlltool
  2967. LDFLAGS=$LDFLAGS
  2968. AVSERVERLDFLAGS=$AVSERVERLDFLAGS
  2969. SHFLAGS=$SHFLAGS
  2970. YASMFLAGS=$YASMFLAGS
  2971. BUILDSUF=$build_suffix
  2972. FULLNAME=$FULLNAME
  2973. LIBPREF=$LIBPREF
  2974. LIBSUF=$LIBSUF
  2975. LIBNAME=$LIBNAME
  2976. SLIBPREF=$SLIBPREF
  2977. SLIBSUF=$SLIBSUF
  2978. EXESUF=$EXESUF
  2979. EXTRA_VERSION=$extra_version
  2980. DEPFLAGS=$DEPFLAGS
  2981. CCDEP=$CCDEP
  2982. ASDEP=$ASDEP
  2983. CC_DEPFLAGS=$CC_DEPFLAGS
  2984. AS_DEPFLAGS=$AS_DEPFLAGS
  2985. HOSTCC=$host_cc
  2986. HOSTCFLAGS=$host_cflags
  2987. HOSTEXESUF=$HOSTEXESUF
  2988. HOSTLDFLAGS=$host_ldflags
  2989. HOSTLIBS=$host_libs
  2990. TARGET_EXEC=$target_exec
  2991. TARGET_PATH=$target_path
  2992. SDL_LIBS=$sdl_libs
  2993. SDL_CFLAGS=$sdl_cflags
  2994. LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
  2995. EXTRALIBS=$extralibs
  2996. INSTALL=install
  2997. LIBTARGET=${LIBTARGET}
  2998. SLIBNAME=${SLIBNAME}
  2999. SLIBNAME_WITH_VERSION=${SLIBNAME_WITH_VERSION}
  3000. SLIBNAME_WITH_MAJOR=${SLIBNAME_WITH_MAJOR}
  3001. SLIB_CREATE_DEF_CMD=${SLIB_CREATE_DEF_CMD}
  3002. SLIB_EXTRA_CMD=${SLIB_EXTRA_CMD}
  3003. SLIB_INSTALL_NAME=${SLIB_INSTALL_NAME}
  3004. SLIB_INSTALL_LINKS=${SLIB_INSTALL_LINKS}
  3005. SLIB_INSTALL_EXTRA_LIB=${SLIB_INSTALL_EXTRA_LIB}
  3006. SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB}
  3007. SAMPLES:=${samples:-\$(FATE_SAMPLES)}
  3008. EOF
  3009. get_version(){
  3010. name=$1
  3011. file=$source_path/$2
  3012. eval $(grep "#define ${name}_VERSION_M" "$file" | awk '{ print $2"="$3 }')
  3013. eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
  3014. lcname=$(tolower $name)
  3015. eval echo "${lcname}_VERSION=\$${name}_VERSION" >> config.mak
  3016. eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> config.mak
  3017. }
  3018. get_version LIBSWSCALE libswscale/swscale.h
  3019. get_version LIBPOSTPROC libpostproc/postprocess.h
  3020. get_version LIBAVCODEC libavcodec/version.h
  3021. get_version LIBAVDEVICE libavdevice/avdevice.h
  3022. get_version LIBAVFORMAT libavformat/version.h
  3023. get_version LIBAVUTIL libavutil/avutil.h
  3024. get_version LIBAVFILTER libavfilter/avfilter.h
  3025. cat > $TMPH <<EOF
  3026. /* Automatically generated by configure - do not modify! */
  3027. #ifndef LIBAV_CONFIG_H
  3028. #define LIBAV_CONFIG_H
  3029. #define LIBAV_CONFIGURATION "$(c_escape $LIBAV_CONFIGURATION)"
  3030. #define LIBAV_LICENSE "$(c_escape $license)"
  3031. #define AVCONV_DATADIR "$(eval c_escape $datadir)"
  3032. #define CC_TYPE "$cc_type"
  3033. #define CC_VERSION $cc_version
  3034. #define restrict $_restrict
  3035. #define EXTERN_PREFIX "${extern_prefix}"
  3036. #define EXTERN_ASM ${extern_prefix}
  3037. #define SLIBSUF "$SLIBSUF"
  3038. EOF
  3039. test -n "$malloc_prefix" &&
  3040. echo "#define MALLOC_PREFIX $malloc_prefix" >>$TMPH
  3041. if enabled small || disabled optimizations; then
  3042. echo "#undef av_always_inline" >> $TMPH
  3043. if enabled small; then
  3044. echo "#define av_always_inline inline" >> $TMPH
  3045. else
  3046. echo "#define av_always_inline av_unused" >> $TMPH
  3047. fi
  3048. fi
  3049. if enabled yasm; then
  3050. append config_files $TMPASM
  3051. printf '' >$TMPASM
  3052. fi
  3053. print_config ARCH_ "$config_files" $ARCH_LIST
  3054. print_config HAVE_ "$config_files" $HAVE_LIST
  3055. print_config CONFIG_ "$config_files" $CONFIG_LIST \
  3056. $CONFIG_EXTRA \
  3057. $DECODER_LIST \
  3058. $ENCODER_LIST \
  3059. $HWACCEL_LIST \
  3060. $PARSER_LIST \
  3061. $BSF_LIST \
  3062. $DEMUXER_LIST \
  3063. $MUXER_LIST \
  3064. $FILTER_LIST \
  3065. $PROTOCOL_LIST \
  3066. $INDEV_LIST \
  3067. $OUTDEV_LIST \
  3068. cat >>config.mak <<EOF
  3069. ACODEC_TESTS=$(print_enabled -n _test $ACODEC_TESTS)
  3070. VCODEC_TESTS=$(print_enabled -n _test $VCODEC_TESTS)
  3071. LAVF_TESTS=$(print_enabled -n _test $LAVF_TESTS)
  3072. LAVFI_TESTS=$(print_enabled -n _test $LAVFI_TESTS)
  3073. SEEK_TESTS=$(print_enabled -n _test $SEEK_TESTS)
  3074. EOF
  3075. echo "#endif /* LIBAV_CONFIG_H */" >> $TMPH
  3076. # Do not overwrite an unchanged config.h to avoid superfluous rebuilds.
  3077. cp_if_changed $TMPH config.h
  3078. touch .config
  3079. enabled yasm && cp_if_changed $TMPASM config.asm
  3080. cat > $TMPH <<EOF
  3081. /* Generated by ffconf */
  3082. #ifndef AVUTIL_AVCONFIG_H
  3083. #define AVUTIL_AVCONFIG_H
  3084. EOF
  3085. print_config AV_HAVE_ $TMPH $HAVE_LIST_PUB
  3086. echo "#endif /* AVUTIL_AVCONFIG_H */" >> $TMPH
  3087. cp_if_changed $TMPH libavutil/avconfig.h
  3088. test -n "$WARNINGS" && printf "\n$WARNINGS"
  3089. # build pkg-config files
  3090. pkgconfig_generate(){
  3091. name=$1
  3092. shortname=${name#lib}${build_suffix}
  3093. comment=$2
  3094. version=$3
  3095. libs=$4
  3096. requires=$5
  3097. enabled ${name#lib} || return 0
  3098. mkdir -p $name
  3099. cat <<EOF > $name/$name.pc
  3100. prefix=$prefix
  3101. exec_prefix=\${prefix}
  3102. libdir=$libdir
  3103. includedir=$incdir
  3104. Name: $name
  3105. Description: $comment
  3106. Version: $version
  3107. Requires: $(enabled shared || echo $requires)
  3108. Requires.private: $(enabled shared && echo $requires)
  3109. Conflicts:
  3110. Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
  3111. Libs.private: $(enabled shared && echo $libs)
  3112. Cflags: -I\${includedir}
  3113. EOF
  3114. cat <<EOF > $name/$name-uninstalled.pc
  3115. prefix=
  3116. exec_prefix=
  3117. libdir=\${pcfiledir}
  3118. includedir=${source_path}
  3119. Name: $name
  3120. Description: $comment
  3121. Version: $version
  3122. Requires: $requires
  3123. Conflicts:
  3124. Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs
  3125. Cflags: -I\${includedir}
  3126. EOF
  3127. }
  3128. pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" "$LIBM"
  3129. pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
  3130. pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" "libavcodec = $LIBAVCODEC_VERSION"
  3131. pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" "libavformat = $LIBAVFORMAT_VERSION"
  3132. pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
  3133. pkgconfig_generate libpostproc "Libav postprocessing library" "$LIBPOSTPROC_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
  3134. pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" "libavutil = $LIBAVUTIL_VERSION"