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.

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