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.

376 lines
9.4KB

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