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.

593 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. # ---
  253. # big/little endian test
  254. cat > $TMPC << EOF
  255. #include <inttypes.h>
  256. int main(int argc, char ** argv){
  257. volatile uint32_t i=0x01234567;
  258. return (*((uint8_t*)(&i))) == 0x67;
  259. }
  260. EOF
  261. if $cc -o $TMPO $TMPC 2>/dev/null ; then
  262. $TMPO && bigendian="yes"
  263. else
  264. echo big/little test failed
  265. fi
  266. # ---
  267. # check availability of some header files
  268. cat > $TMPC << EOF
  269. #include <malloc.h>
  270. int main( void ) { return 0; }
  271. EOF
  272. _memalign=no
  273. _malloc_h=no
  274. if $cc -o $TMPO $TMPC 2> /dev/null ; then
  275. _malloc_h=yes
  276. _memalign=yes
  277. # check for memalign - atmos
  278. cat > $TMPC << EOF
  279. #include <malloc.h>
  280. int main ( void ) {
  281. char *string = NULL;
  282. string = memalign(64, sizeof(char));
  283. return 0;
  284. }
  285. EOF
  286. $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
  287. fi
  288. cat > $TMPC << EOF
  289. #define _GNU_SOURCE
  290. #include <time.h>
  291. int main( void ) { return *strptime("", "", 0); }
  292. EOF
  293. strptime=no
  294. if $cc -o $TMPO $TMPC 2> /dev/null ; then
  295. strptime=yes
  296. fi
  297. if test "$zlib" = "yes"; then
  298. # check for zlib - mmu_man
  299. cat > $TMPC << EOF
  300. #include <zlib.h>
  301. int main ( void ) {
  302. if (zlibVersion() != ZLIB_VERSION)
  303. puts("zlib version differs !!!");
  304. return 1;
  305. return 0;
  306. }
  307. EOF
  308. $cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
  309. # $TMPO 2> /dev/null > /dev/null || zlib="no"
  310. # XXX: more tests needed - runtime test
  311. fi
  312. if test "$zlib" = "yes"; then
  313. extralibs="$extralibs -lz"
  314. fi
  315. _restrict=
  316. for restrict_keyword in restrict __restrict__ __restrict; do
  317. echo "void foo(char * $restrict_keyword p);" > $TMPC
  318. if $cc -c -o $TMPO $TMPC 2> /dev/null; then
  319. _restrict=$restrict_keyword
  320. break;
  321. fi
  322. done
  323. if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  324. cat << EOF
  325. Usage: configure [options]
  326. Options: [defaults in brackets after descriptions]
  327. EOF
  328. echo "Standard options:"
  329. echo " --help print this message"
  330. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  331. echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
  332. echo " --enable-vorbis enable vorbis support via libvorbisenc [default=no]"
  333. echo " --enable-win32 enable win32 cross compile"
  334. echo " --disable-a52 disable GPL'ed A52 support [default=no]"
  335. echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
  336. echo " --enable-shared build shared libraries [default=no]"
  337. echo ""
  338. echo "Advanced options (experts only):"
  339. echo " --source-path=PATH path of source code [$source_path]"
  340. echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
  341. echo " --cc=CC use C compiler CC [$cc]"
  342. echo " --make=MAKE use specified make [$make]"
  343. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  344. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  345. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  346. echo " --cpu=CPU force cpu to CPU [$cpu]"
  347. echo " --disable-mmx disable mmx usage"
  348. echo " --disable-altivec disable AltiVec usage"
  349. echo " --disable-audio-oss disable OSS audio support [default=no]"
  350. echo " --disable-v4l disable video4linux grabbing [default=no]"
  351. echo " --disable-network disable network support [default=no]"
  352. echo " --disable-zlib disable zlib [default=no]"
  353. echo " --disable-simple_idct disable simple IDCT routines [default=no]"
  354. # echo " --disable-vhook disable video hooking support"
  355. echo " --enable-gprof enable profiling with gprof [$gprof]"
  356. echo " --disable-mpegaudio-hp faster (but less accurate)"
  357. echo " mpegaudio decoding [default=no]"
  358. echo ""
  359. echo "NOTE: The object files are build at the place where configure is launched"
  360. exit 1
  361. fi
  362. echo "Install prefix $prefix"
  363. echo "Source path $source_path"
  364. echo "C compiler $cc"
  365. echo "make $make"
  366. echo "CPU $cpu"
  367. echo "Big Endian $bigendian"
  368. echo "MMX enabled $mmx"
  369. echo "MMI enabled $mmi"
  370. echo "AltiVec enabled $altivec"
  371. echo "gprof enabled $gprof"
  372. echo "zlib enabled $zlib"
  373. echo "mp3lame enabled $mp3lame"
  374. echo "vorbis enabled $vorbis"
  375. echo "a52 support $a52"
  376. echo "a52 dlopened $a52bin"
  377. # echo "Video hooking $vhook"
  378. if test "$vhook" = "yes" ; then
  379. : echo "Imlib2 support $imlib2"
  380. fi
  381. echo "Creating config.mak and config.h"
  382. echo "# Automatically generated by configure - do not modify" > config.mak
  383. echo "/* Automatically generated by configure - do not modify */" > $TMPH
  384. echo "prefix=$prefix" >> config.mak
  385. echo "MAKE=$make" >> config.mak
  386. echo "CC=$cc" >> config.mak
  387. echo "AR=$ar" >> config.mak
  388. echo "RANLIB=$ranlib" >> config.mak
  389. echo "STRIP=$strip" >> config.mak
  390. echo "OPTFLAGS=$CFLAGS" >> config.mak
  391. echo "LDFLAGS=$LDFLAGS" >> config.mak
  392. echo "SHFLAGS=$SHFLAGS" >> config.mak
  393. if test "$cpu" = "x86" ; then
  394. echo "TARGET_ARCH_X86=yes" >> config.mak
  395. echo "#define ARCH_X86 1" >> $TMPH
  396. elif test "$cpu" = "armv4l" ; then
  397. echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
  398. echo "#define ARCH_ARMV4L 1" >> $TMPH
  399. elif test "$cpu" = "alpha" ; then
  400. echo "TARGET_ARCH_ALPHA=yes" >> config.mak
  401. echo "#define ARCH_ALPHA 1" >> $TMPH
  402. elif test "$cpu" = "powerpc" ; then
  403. echo "TARGET_ARCH_POWERPC=yes" >> config.mak
  404. echo "#define ARCH_POWERPC 1" >> $TMPH
  405. elif test "$cpu" = "mips" ; then
  406. echo "TARGET_ARCH_MIPS=yes" >> config.mak
  407. echo "#define ARCH_MIPS 1" >> $TMPH
  408. fi
  409. if test "$bigendian" = "yes" ; then
  410. echo "WORDS_BIGENDIAN=yes" >> config.mak
  411. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  412. fi
  413. if test "$mmx" = "yes" ; then
  414. echo "TARGET_MMX=yes" >> config.mak
  415. echo "#define HAVE_MMX 1" >> $TMPH
  416. fi
  417. if test "$mmi" = "yes" ; then
  418. echo "TARGET_MMI=yes" >> config.mak
  419. echo "#define HAVE_MMI 1" >> $TMPH
  420. fi
  421. if test "$altivec" = "yes" ; then
  422. echo "TARGET_ALTIVEC=yes" >> config.mak
  423. echo "#define HAVE_ALTIVEC 1" >> $TMPH
  424. fi
  425. if test "$gprof" = "yes" ; then
  426. echo "TARGET_GPROF=yes" >> config.mak
  427. echo "#define HAVE_GPROF 1" >> $TMPH
  428. fi
  429. if test "$strptime" = "yes" ; then
  430. echo "#define HAVE_STRPTIME 1" >> $TMPH
  431. else
  432. echo "BUILD_STRPTIME=yes" >> config.mak
  433. fi
  434. if test "$imlib2" = "yes" ; then
  435. echo "HAVE_IMLIB2=yes" >> config.mak
  436. fi
  437. if test "$vhook" = "yes" ; then
  438. echo "BUILD_VHOOK=yes" >> config.mak
  439. echo "#define HAVE_VHOOK 1" >> $TMPH
  440. extralibs="$extralibs -ldl"
  441. fi
  442. if test "$lshared" = "yes" ; then
  443. echo "BUILD_SHARED=yes" >> config.mak
  444. echo "PIC=-fPIC" >> config.mak
  445. fi
  446. echo "EXTRALIBS=$extralibs" >> config.mak
  447. echo -n "VERSION=" >>config.mak
  448. head $source_path/VERSION >>config.mak
  449. echo "" >>config.mak
  450. # if you do not want to use encoders, disable that.
  451. echo "#define CONFIG_ENCODERS 1" >> $TMPH
  452. echo "CONFIG_ENCODERS=yes" >> config.mak
  453. # if you do not want to use decoders, disable that.
  454. echo "#define CONFIG_DECODERS 1" >> $TMPH
  455. echo "CONFIG_DECODERS=yes" >> config.mak
  456. # AC3
  457. if test "$a52" = "yes" ; then
  458. echo "#define CONFIG_AC3 1" >> $TMPH
  459. echo "CONFIG_AC3=yes" >> config.mak
  460. if test "$a52bin" = "yes" ; then
  461. echo "#define CONFIG_A52BIN 1" >> $TMPH
  462. echo "CONFIG_A52BIN=yes" >> config.mak
  463. fi
  464. fi
  465. # mpeg audio high precision mode
  466. if test "$mpegaudio_hp" = "yes" ; then
  467. echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
  468. fi
  469. if test "$v4l" = "yes" ; then
  470. echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
  471. echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
  472. fi
  473. if test "$audio_oss" = "yes" ; then
  474. echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
  475. echo "CONFIG_AUDIO_OSS=yes" >> config.mak
  476. fi
  477. if test "$network" = "yes" ; then
  478. echo "#define CONFIG_NETWORK 1" >> $TMPH
  479. echo "CONFIG_NETWORK=yes" >> config.mak
  480. fi
  481. if test "$zlib" = "yes" ; then
  482. echo "#define CONFIG_ZLIB 1" >> $TMPH
  483. echo "CONFIG_ZLIB=yes" >> config.mak
  484. fi
  485. if test "$mp3lame" = "yes" ; then
  486. echo "#define CONFIG_MP3LAME 1" >> $TMPH
  487. echo "CONFIG_MP3LAME=yes" >> config.mak
  488. fi
  489. if test "$vorbis" = "yes" ; then
  490. echo "#define CONFIG_VORBIS 1" >> $TMPH
  491. echo "CONFIG_VORBIS=yes" >> config.mak
  492. fi
  493. if test "$win32" = "yes" ; then
  494. echo "#define CONFIG_WIN32 1" >> $TMPH
  495. echo "CONFIG_WIN32=yes" >> config.mak
  496. fi
  497. if test "$cygwin" = "yes" ; then
  498. # setup correct exesuffix
  499. echo "CONFIG_WIN32=yes" >> config.mak
  500. fi
  501. if test "$darwin" = "yes"; then
  502. echo "#define CONFIG_DARWIN 1" >> $TMPH
  503. echo "CONFIG_DARWIN=yes" >> config.mak
  504. fi
  505. if test "$_malloc_h" = "yes" ; then
  506. echo "#define HAVE_MALLOC_H 1" >> $TMPH
  507. else
  508. echo "#undef HAVE_MALLOC_H" >> $TMPH
  509. fi
  510. if test "$_memalign" = "yes" ; then
  511. echo "#define HAVE_MEMALIGN 1" >> $TMPH
  512. else
  513. echo "#undef HAVE_MEMALIGN" >> $TMPH
  514. fi
  515. if test "$simpleidct" = "yes" ; then
  516. echo "#define SIMPLE_IDCT 1" >> $TMPH
  517. fi
  518. echo "#define restrict $_restrict" >> $TMPH
  519. # build tree in object directory if source path is different from current one
  520. if test "$source_path_used" = "yes" ; then
  521. DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
  522. libavcodec/ppc libavcodec/liba52 libavcodec/mlib tests"
  523. FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
  524. for dir in $DIRS ; do
  525. mkdir -p $dir
  526. done
  527. for f in $FILES ; do
  528. ln -sf $source_path/$f $f
  529. done
  530. fi
  531. echo "SRC_PATH=$source_path" >> config.mak
  532. diff $TMPH config.h >/dev/null 2>&1
  533. if test $? -ne 0 ; then
  534. mv -f $TMPH config.h
  535. else
  536. echo "config.h is unchanged"
  537. fi
  538. rm -f $TMPO $TMPC $TMPS $TMPH