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.

518 lines
12KB

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