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.

616 lines
14KB

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