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.

561 lines
13KB

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