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.

626 lines
15KB

  1. #!/bin/sh
  2. #
  3. # ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
  4. #
  5. # set temporary file name
  6. if test ! -z "$TMPDIR" ; then
  7. TMPDIR1="${TMPDIR}"
  8. elif test ! -z "$TEMPDIR" ; then
  9. TMPDIR1="${TEMPDIR}"
  10. else
  11. TMPDIR1="/tmp"
  12. fi
  13. TMPC="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  14. TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  15. TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  16. TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  17. # default parameters
  18. prefix="/usr/local"
  19. cross_prefix=""
  20. cc="gcc"
  21. ar="ar"
  22. ranlib="ranlib"
  23. make="make"
  24. strip="strip"
  25. cpu=`uname -m`
  26. mmx="default"
  27. altivec="default"
  28. mmi="default"
  29. case "$cpu" in
  30. i386|i486|i586|i686|i86pc|BePC)
  31. cpu="x86"
  32. ;;
  33. armv4l)
  34. cpu="armv4l"
  35. ;;
  36. alpha)
  37. cpu="alpha"
  38. ;;
  39. "Power Macintosh"|ppc)
  40. cpu="powerpc"
  41. ;;
  42. mips)
  43. cpu="mips"
  44. ;;
  45. *)
  46. cpu="unknown"
  47. ;;
  48. esac
  49. gprof="no"
  50. v4l="yes"
  51. audio_oss="yes"
  52. network="yes"
  53. zlib="yes"
  54. mp3lame="no"
  55. vorbis="no"
  56. a52="yes"
  57. a52bin="no"
  58. win32="no"
  59. cygwin="no"
  60. lshared="no"
  61. extralibs="-lm"
  62. simpleidct="yes"
  63. bigendian="no"
  64. vhook="no"
  65. mpegaudio_hp="yes"
  66. SHFLAGS=-shared
  67. netserver="no"
  68. # OS specific
  69. targetos=`uname -s`
  70. case $targetos in
  71. BeOS)
  72. prefix="/boot/home/config"
  73. # helps building libavcodec
  74. CFLAGS="-O3 -DPIC -fomit-frame-pointer"
  75. # 3 gcc releases known for BeOS, each with ugly bugs
  76. gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
  77. case "$gcc_version" in
  78. 2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
  79. mmx="no"
  80. ;;
  81. *20010315*) echo "BeBits gcc"
  82. CFLAGS="$CFLAGS -fno-expensive-optimizations"
  83. ;;
  84. esac
  85. SHFLAGS=-nostart
  86. # disable linux things
  87. audio_oss="no"
  88. v4l="no"
  89. # no need for libm, but the inet stuff
  90. # Check for BONE
  91. if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
  92. extralibs="-lbind -lsocket"
  93. else
  94. netserver="yes"
  95. extralibs="-lnet"
  96. fi ;;
  97. BSD/OS)
  98. v4l="no"
  99. audio_oss="yes"
  100. extralibs="-lpoll -lgnugetopt -lm"
  101. make="gmake"
  102. ;;
  103. Darwin)
  104. cc="cc"
  105. v4l="no"
  106. audio_oss="no"
  107. CFLAGS="-no-cpp-precomp -pipe -O3 -fomit-frame-pointer -mdynamic-no-pic"
  108. SHFLAGS="-dynamiclib"
  109. extralibs=""
  110. darwin="yes"
  111. ;;
  112. CYGWIN*)
  113. v4l="no"
  114. audio_oss="yes"
  115. extralibs=""
  116. cygwin="yes"
  117. test -f /usr/include/inttypes.h || \
  118. test -f /usr/local/include/inttypes.h || \
  119. echo "Missing inttypes.h, please copy cygwin_inttypes.h to" \
  120. "/usr/include/inttypes.h !!!"
  121. ;;
  122. *) ;;
  123. esac
  124. # find source path
  125. # XXX: we assume an absolute path is given when launching configure,
  126. # except in './configure' case.
  127. source_path=${0%configure}
  128. source_path=${source_path%/}
  129. source_path_used="yes"
  130. if test -z "$source_path" -o "$source_path" = "." ; then
  131. source_path=`pwd`
  132. source_path_used="no"
  133. fi
  134. cat > $TMPC << EOF
  135. #include <dlfcn.h>
  136. int main( void ) { return (int) dlopen("foo", 0); }
  137. EOF
  138. if $cc -o $TMPO $TMPC -ldl 2> /dev/null ; then
  139. : vhook=yes
  140. fi
  141. cat > $TMPC << EOF
  142. #include <X11/Xlib.h>
  143. #include <Imlib2.h>
  144. int main( void ) { return (int) imlib_load_font("foo"); }
  145. EOF
  146. imlib2=no
  147. if $cc -o $TMPO $TMPC -lImlib2 2> /dev/null ; then
  148. imlib2=yes
  149. fi
  150. for opt do
  151. case "$opt" in
  152. --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
  153. ;;
  154. --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
  155. ;;
  156. --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
  157. ;;
  158. --cc=*) cc=`echo $opt | cut -d '=' -f 2`
  159. ;;
  160. --make=*) make=`echo $opt | cut -d '=' -f 2`
  161. ;;
  162. --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
  163. ;;
  164. --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
  165. ;;
  166. --extra-libs=*) extralibs=${opt#--extra-libs=}
  167. ;;
  168. --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  169. ;;
  170. --disable-mmx) mmx="no"
  171. ;;
  172. --disable-altivec) altivec="no"
  173. ;;
  174. --enable-gprof) gprof="yes"
  175. ;;
  176. --disable-v4l) v4l="no"
  177. ;;
  178. --disable-audio-oss) audio_oss="no"
  179. ;;
  180. --disable-network) network="no"
  181. ;;
  182. --disable-zlib) zlib="no"
  183. ;;
  184. --disable-a52) a52="no"
  185. ;;
  186. --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
  187. ;;
  188. --enable-mp3lame) mp3lame="yes"
  189. ;;
  190. --enable-vorbis) vorbis="yes"
  191. ;;
  192. --disable-vhook) vhook="no"
  193. ;;
  194. --disable-simple_idct) simpleidct="no"
  195. ;;
  196. --enable-win32) win32="yes"
  197. ;;
  198. --enable-shared) lshared="yes"
  199. ;;
  200. --disable-mpegaudio-hp) mpegaudio_hp="no"
  201. ;;
  202. esac
  203. done
  204. # compute mmx state
  205. if test $mmx = "default"; then
  206. if test $cpu = "x86"; then
  207. mmx="yes"
  208. else
  209. mmx="no"
  210. fi
  211. fi
  212. # Can only do AltiVec on PowerPC
  213. if test $altivec = "default"; then
  214. if test $cpu = "powerpc"; then
  215. altivec="yes"
  216. else
  217. altivec="no"
  218. fi
  219. fi
  220. # See does our compiler support Motorola AltiVec C API
  221. if test $altivec = "yes"; then
  222. cat > $TMPC << EOF
  223. int main(void) {
  224. vector signed int v1, v2, v3;
  225. v1 = vec_add(v2,v3);
  226. return 0;
  227. }
  228. EOF
  229. $cc -o $TMPO $TMPC -faltivec 2> /dev/null || altivec="no"
  230. fi
  231. # Can only do mmi on mips
  232. if test $mmi = "default"; then
  233. if test $cpu = "mips"; then
  234. mmi="yes"
  235. else
  236. mmi="no"
  237. fi
  238. fi
  239. # See does our compiler support mmi
  240. if test $mmi = "yes"; then
  241. cat > $TMPC << EOF
  242. int main(void) {
  243. __asm__ ("lq \$2, 0(\$2)");
  244. return 0;
  245. }
  246. EOF
  247. $cc -o $TMPO $TMPC 2> /dev/null || mmi="no"
  248. fi
  249. # Checking for CFLAGS
  250. if test -z "$CFLAGS"; then
  251. CFLAGS="-O3"
  252. fi
  253. if test "$win32" = "yes" ; then
  254. cross_prefix="i386-mingw32msvc-"
  255. v4l="no"
  256. audio_oss="no"
  257. network="no"
  258. fi
  259. cc="${cross_prefix}${cc}"
  260. ar="${cross_prefix}${ar}"
  261. ranlib="${cross_prefix}${ranlib}"
  262. strip="${cross_prefix}${strip}"
  263. if test -z "$cross_prefix" ; then
  264. # ---
  265. # big/little endian test
  266. cat > $TMPC << EOF
  267. #include <inttypes.h>
  268. int main(int argc, char ** argv){
  269. volatile uint32_t i=0x01234567;
  270. return (*((uint8_t*)(&i))) == 0x67;
  271. }
  272. EOF
  273. if $cc -o $TMPO $TMPC 2>/dev/null ; then
  274. $TMPO && bigendian="yes"
  275. else
  276. echo big/little test failed
  277. fi
  278. else
  279. # if cross compiling, cannot launch a program, so make a static guess
  280. if test "$cpu" = "powerpc" -o "$cpu" = "mips" ; then
  281. bigendian="yes"
  282. fi
  283. fi
  284. # ---
  285. # check availability of some header files
  286. cat > $TMPC << EOF
  287. #include <malloc.h>
  288. int main( void ) { return 0; }
  289. EOF
  290. _memalign=no
  291. _malloc_h=no
  292. if $cc -o $TMPO $TMPC 2> /dev/null ; then
  293. _malloc_h=yes
  294. _memalign=yes
  295. # check for memalign - atmos
  296. cat > $TMPC << EOF
  297. #include <malloc.h>
  298. int main ( void ) {
  299. char *string = NULL;
  300. string = memalign(64, sizeof(char));
  301. return 0;
  302. }
  303. EOF
  304. $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
  305. fi
  306. cat > $TMPC << EOF
  307. #define _GNU_SOURCE
  308. #include <time.h>
  309. int main( void ) { return *strptime("", "", 0); }
  310. EOF
  311. strptime=no
  312. if $cc -o $TMPO $TMPC 2> /dev/null ; then
  313. strptime=yes
  314. fi
  315. if test "$zlib" = "yes"; then
  316. # check for zlib - mmu_man
  317. cat > $TMPC << EOF
  318. #include <zlib.h>
  319. int main ( void ) {
  320. if (zlibVersion() != ZLIB_VERSION)
  321. puts("zlib version differs !!!");
  322. return 1;
  323. return 0;
  324. }
  325. EOF
  326. $cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
  327. # $TMPO 2> /dev/null > /dev/null || zlib="no"
  328. # XXX: more tests needed - runtime test
  329. fi
  330. if test "$zlib" = "yes"; then
  331. extralibs="$extralibs -lz"
  332. fi
  333. _restrict=
  334. for restrict_keyword in restrict __restrict__ __restrict; do
  335. echo "void foo(char * $restrict_keyword p);" > $TMPC
  336. if $cc -c -o $TMPO $TMPC 2> /dev/null; then
  337. _restrict=$restrict_keyword
  338. break;
  339. fi
  340. done
  341. if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  342. cat << EOF
  343. Usage: configure [options]
  344. Options: [defaults in brackets after descriptions]
  345. EOF
  346. echo "Standard options:"
  347. echo " --help print this message"
  348. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  349. echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
  350. echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
  351. echo " --enable-win32 enable win32 cross compile"
  352. echo " --disable-a52 disable GPL'ed A52 support [default=no]"
  353. echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
  354. echo " --enable-shared build shared libraries [default=no]"
  355. echo ""
  356. echo "Advanced options (experts only):"
  357. echo " --source-path=PATH path of source code [$source_path]"
  358. echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
  359. echo " --cc=CC use C compiler CC [$cc]"
  360. echo " --make=MAKE use specified make [$make]"
  361. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  362. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  363. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  364. echo " --cpu=CPU force cpu to CPU [$cpu]"
  365. echo " --disable-mmx disable mmx usage"
  366. echo " --disable-altivec disable AltiVec usage"
  367. echo " --disable-audio-oss disable OSS audio support [default=no]"
  368. echo " --disable-v4l disable video4linux grabbing [default=no]"
  369. echo " --disable-network disable network support [default=no]"
  370. echo " --disable-zlib disable zlib [default=no]"
  371. echo " --disable-simple_idct disable simple IDCT routines [default=no]"
  372. # echo " --disable-vhook disable video hooking support"
  373. echo " --enable-gprof enable profiling with gprof [$gprof]"
  374. echo " --disable-mpegaudio-hp faster (but less accurate)"
  375. echo " mpegaudio decoding [default=no]"
  376. echo ""
  377. echo "NOTE: The object files are build at the place where configure is launched"
  378. exit 1
  379. fi
  380. echo "Install prefix $prefix"
  381. echo "Source path $source_path"
  382. echo "C compiler $cc"
  383. echo "make $make"
  384. echo "CPU $cpu"
  385. echo "Big Endian $bigendian"
  386. if test $cpu = "x86"; then
  387. echo "MMX enabled $mmx"
  388. fi
  389. if test $cpu = "mips"; then
  390. echo "MMI enabled $mmi"
  391. fi
  392. if test $cpu = "powerpc"; then
  393. echo "AltiVec enabled $altivec"
  394. fi
  395. echo "gprof enabled $gprof"
  396. echo "zlib enabled $zlib"
  397. echo "mp3lame enabled $mp3lame"
  398. echo "vorbis enabled $vorbis"
  399. echo "a52 support $a52"
  400. echo "a52 dlopened $a52bin"
  401. # echo "Video hooking $vhook"
  402. if test "$vhook" = "yes" ; then
  403. : echo "Imlib2 support $imlib2"
  404. fi
  405. echo "Creating config.mak and config.h"
  406. echo "# Automatically generated by configure - do not modify" > config.mak
  407. echo "/* Automatically generated by configure - do not modify */" > $TMPH
  408. echo "prefix=$prefix" >> config.mak
  409. echo "MAKE=$make" >> config.mak
  410. echo "CC=$cc" >> config.mak
  411. echo "AR=$ar" >> config.mak
  412. echo "RANLIB=$ranlib" >> config.mak
  413. echo "STRIP=$strip" >> config.mak
  414. echo "OPTFLAGS=$CFLAGS" >> config.mak
  415. echo "LDFLAGS=$LDFLAGS" >> config.mak
  416. echo "SHFLAGS=$SHFLAGS" >> config.mak
  417. if test "$cpu" = "x86" ; then
  418. echo "TARGET_ARCH_X86=yes" >> config.mak
  419. echo "#define ARCH_X86 1" >> $TMPH
  420. elif test "$cpu" = "armv4l" ; then
  421. echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
  422. echo "#define ARCH_ARMV4L 1" >> $TMPH
  423. elif test "$cpu" = "alpha" ; then
  424. echo "TARGET_ARCH_ALPHA=yes" >> config.mak
  425. echo "#define ARCH_ALPHA 1" >> $TMPH
  426. elif test "$cpu" = "powerpc" ; then
  427. echo "TARGET_ARCH_POWERPC=yes" >> config.mak
  428. echo "#define ARCH_POWERPC 1" >> $TMPH
  429. elif test "$cpu" = "mips" ; then
  430. echo "TARGET_ARCH_MIPS=yes" >> config.mak
  431. echo "#define ARCH_MIPS 1" >> $TMPH
  432. fi
  433. if test "$bigendian" = "yes" ; then
  434. echo "WORDS_BIGENDIAN=yes" >> config.mak
  435. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  436. fi
  437. if test "$mmx" = "yes" ; then
  438. echo "TARGET_MMX=yes" >> config.mak
  439. echo "#define HAVE_MMX 1" >> $TMPH
  440. fi
  441. if test "$mmi" = "yes" ; then
  442. echo "TARGET_MMI=yes" >> config.mak
  443. echo "#define HAVE_MMI 1" >> $TMPH
  444. fi
  445. if test "$altivec" = "yes" ; then
  446. echo "TARGET_ALTIVEC=yes" >> config.mak
  447. echo "#define HAVE_ALTIVEC 1" >> $TMPH
  448. fi
  449. if test "$gprof" = "yes" ; then
  450. echo "TARGET_GPROF=yes" >> config.mak
  451. echo "#define HAVE_GPROF 1" >> $TMPH
  452. fi
  453. if test "$strptime" = "yes" ; then
  454. echo "#define HAVE_STRPTIME 1" >> $TMPH
  455. else
  456. echo "BUILD_STRPTIME=yes" >> config.mak
  457. fi
  458. if test "$imlib2" = "yes" ; then
  459. echo "HAVE_IMLIB2=yes" >> config.mak
  460. fi
  461. if test "$vhook" = "yes" ; then
  462. echo "BUILD_VHOOK=yes" >> config.mak
  463. echo "#define HAVE_VHOOK 1" >> $TMPH
  464. extralibs="$extralibs -ldl"
  465. fi
  466. if test "$lshared" = "yes" ; then
  467. echo "BUILD_SHARED=yes" >> config.mak
  468. echo "PIC=-fPIC" >> config.mak
  469. fi
  470. echo "EXTRALIBS=$extralibs" >> config.mak
  471. echo -n "VERSION=" >>config.mak
  472. head $source_path/VERSION >>config.mak
  473. echo "" >>config.mak
  474. # if you do not want to use encoders, disable that.
  475. echo "#define CONFIG_ENCODERS 1" >> $TMPH
  476. echo "CONFIG_ENCODERS=yes" >> config.mak
  477. # if you do not want to use decoders, disable that.
  478. echo "#define CONFIG_DECODERS 1" >> $TMPH
  479. echo "CONFIG_DECODERS=yes" >> config.mak
  480. # AC3
  481. if test "$a52" = "yes" ; then
  482. echo "#define CONFIG_AC3 1" >> $TMPH
  483. echo "CONFIG_AC3=yes" >> config.mak
  484. if test "$a52bin" = "yes" ; then
  485. echo "#define CONFIG_A52BIN 1" >> $TMPH
  486. echo "CONFIG_A52BIN=yes" >> config.mak
  487. fi
  488. fi
  489. # mpeg audio high precision mode
  490. if test "$mpegaudio_hp" = "yes" ; then
  491. echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
  492. fi
  493. if test "$v4l" = "yes" ; then
  494. echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
  495. echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
  496. fi
  497. if test "$audio_oss" = "yes" ; then
  498. echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
  499. echo "CONFIG_AUDIO_OSS=yes" >> config.mak
  500. fi
  501. if test "$network" = "yes" ; then
  502. echo "#define CONFIG_NETWORK 1" >> $TMPH
  503. echo "CONFIG_NETWORK=yes" >> config.mak
  504. fi
  505. if test "$zlib" = "yes" ; then
  506. echo "#define CONFIG_ZLIB 1" >> $TMPH
  507. echo "CONFIG_ZLIB=yes" >> config.mak
  508. fi
  509. if test "$mp3lame" = "yes" ; then
  510. echo "#define CONFIG_MP3LAME 1" >> $TMPH
  511. echo "CONFIG_MP3LAME=yes" >> config.mak
  512. fi
  513. if test "$vorbis" = "yes" ; then
  514. echo "#define CONFIG_VORBIS 1" >> $TMPH
  515. echo "CONFIG_VORBIS=yes" >> config.mak
  516. fi
  517. if test "$win32" = "yes" ; then
  518. echo "#define CONFIG_WIN32 1" >> $TMPH
  519. echo "CONFIG_WIN32=yes" >> config.mak
  520. fi
  521. if test "$cygwin" = "yes" ; then
  522. # setup correct exesuffix
  523. echo "CONFIG_WIN32=yes" >> config.mak
  524. fi
  525. if test "$darwin" = "yes"; then
  526. echo "#define CONFIG_DARWIN 1" >> $TMPH
  527. echo "CONFIG_DARWIN=yes" >> config.mak
  528. fi
  529. if test "$_malloc_h" = "yes" ; then
  530. echo "#define HAVE_MALLOC_H 1" >> $TMPH
  531. else
  532. echo "#undef HAVE_MALLOC_H" >> $TMPH
  533. fi
  534. if test "$_memalign" = "yes" ; then
  535. echo "#define HAVE_MEMALIGN 1" >> $TMPH
  536. else
  537. echo "#undef HAVE_MEMALIGN" >> $TMPH
  538. fi
  539. if test "$netserver" = "yes" ; then
  540. echo "#define CONFIG_BEOS_NETSERVER 1" >> $TMPH
  541. echo "CONFIG_BEOS_NETSERVER=yes" >> config.mak
  542. fi
  543. if test "$simpleidct" = "yes" ; then
  544. echo "#define SIMPLE_IDCT 1" >> $TMPH
  545. fi
  546. echo "#define restrict $_restrict" >> $TMPH
  547. # build tree in object directory if source path is different from current one
  548. if test "$source_path_used" = "yes" ; then
  549. DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
  550. libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests"
  551. FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
  552. for dir in $DIRS ; do
  553. mkdir -p $dir
  554. done
  555. for f in $FILES ; do
  556. ln -sf $source_path/$f $f
  557. done
  558. fi
  559. echo "SRC_PATH=$source_path" >> config.mak
  560. diff $TMPH config.h >/dev/null 2>&1
  561. if test $? -ne 0 ; then
  562. mv -f $TMPH config.h
  563. else
  564. echo "config.h is unchanged"
  565. fi
  566. rm -f $TMPO $TMPC $TMPS $TMPH