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.

421 lines
10KB

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