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.

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