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.

387 lines
9.7KB

  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="-O3 -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="-O3"
  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. _restrict=
  181. for restrict_keyword in restrict __restrict__ __restrict; do
  182. echo "void foo(char * $restrict_keyword p);" > $TMPC
  183. if $cc -c -o $TMPO $TMPC 2> /dev/null; then
  184. _restrict=$restrict_keyword
  185. break;
  186. fi
  187. done
  188. if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  189. cat << EOF
  190. Usage: configure [options]
  191. Options: [defaults in brackets after descriptions]
  192. EOF
  193. echo "Standard options:"
  194. echo " --help print this message"
  195. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  196. echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
  197. echo " --enable-win32 enable win32 cross compile"
  198. echo " --disable-a52 disable GPL'ed A52 support [default=no]"
  199. echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
  200. echo " --enable-shared build shared libraries [default=no]"
  201. echo ""
  202. echo "Advanced options (experts only):"
  203. echo " --source-path=PATH path of source code [$source_path]"
  204. echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
  205. echo " --cc=CC use C compiler CC [$cc]"
  206. echo " --make=MAKE use specified make [$make]"
  207. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  208. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  209. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  210. echo " --cpu=CPU force cpu to CPU [$cpu]"
  211. echo " --disable-mmx disable mmx usage"
  212. echo " --disable-audio-oss disable OSS audio support [default=no]"
  213. echo " --disable-v4l disable video4linux grabbing [default=no]"
  214. echo " --disable-network disable network support [default=no]"
  215. echo " --disable-simple_idct disable simple IDCT routines [default=no]"
  216. echo " --enable-gprof enable profiling with gprof [$gprof]"
  217. echo " --disable-mpegaudio-hp faster (but less accurate)"
  218. echo " mpegaudio decoding [default=no]"
  219. echo ""
  220. echo "NOTE: The object files are build at the place where configure is launched"
  221. exit 1
  222. fi
  223. echo "Install prefix $prefix"
  224. echo "Source path $source_path"
  225. echo "C compiler $cc"
  226. echo "make $make"
  227. echo "CPU $cpu"
  228. echo "Big Endian $bigendian"
  229. echo "MMX enabled $mmx"
  230. echo "gprof enabled $gprof"
  231. echo "mp3lame enabled $mp3lame"
  232. echo "a52 support $a52"
  233. echo "a52 dlopened $a52bin"
  234. echo "Creating config.mak and config.h"
  235. echo "# Automatically generated by configure - do not modify" > config.mak
  236. echo "/* Automatically generated by configure - do not modify */" > $TMPH
  237. echo "prefix=$prefix" >> config.mak
  238. echo "MAKE=$make" >> config.mak
  239. echo "CC=$cc" >> config.mak
  240. echo "AR=$ar" >> config.mak
  241. echo "STRIP=$strip" >> config.mak
  242. echo "OPTFLAGS=$CFLAGS" >> config.mak
  243. echo "LDFLAGS=$LDFLAGS" >> config.mak
  244. if test "$cpu" = "x86" ; then
  245. echo "TARGET_ARCH_X86=yes" >> config.mak
  246. echo "#define ARCH_X86 1" >> $TMPH
  247. elif test "$cpu" = "armv4l" ; then
  248. echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
  249. echo "#define ARCH_ARMV4L 1" >> $TMPH
  250. elif test "$cpu" = "alpha" ; then
  251. echo "TARGET_ARCH_ALPHA=yes" >> config.mak
  252. echo "#define ARCH_ALPHA 1" >> $TMPH
  253. elif test "$cpu" = "powerpc" ; then
  254. echo "TARGET_ARCH_POWERPC=yes" >> config.mak
  255. echo "#define ARCH_POWERPC 1" >> $TMPH
  256. fi
  257. if test "$bigendian" = "yes" ; then
  258. echo "WORDS_BIGENDIAN=yes" >> config.mak
  259. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  260. fi
  261. if test "$mmx" = "yes" ; then
  262. echo "TARGET_MMX=yes" >> config.mak
  263. echo "#define HAVE_MMX 1" >> $TMPH
  264. fi
  265. if test "$gprof" = "yes" ; then
  266. echo "TARGET_GPROF=yes" >> config.mak
  267. echo "#define HAVE_GPROF 1" >> $TMPH
  268. fi
  269. if test "$lshared" = "yes" ; then
  270. echo "BUILD_SHARED=yes" >> config.mak
  271. echo "PIC=-fPIC" >> config.mak
  272. fi
  273. echo "EXTRALIBS=$extralibs" >> config.mak
  274. echo -n "VERSION=" >>config.mak
  275. head $source_path/VERSION >>config.mak
  276. echo "" >>config.mak
  277. # if you do not want to use encoders, disable that.
  278. echo "#define CONFIG_ENCODERS 1" >> $TMPH
  279. echo "CONFIG_ENCODERS=yes" >> config.mak
  280. # if you do not want to use decoders, disable that.
  281. echo "#define CONFIG_DECODERS 1" >> $TMPH
  282. echo "CONFIG_DECODERS=yes" >> config.mak
  283. # AC3
  284. if test "$a52" = "yes" ; then
  285. echo "#define CONFIG_AC3 1" >> $TMPH
  286. echo "CONFIG_AC3=yes" >> config.mak
  287. if test "$a52bin" = "yes" ; then
  288. echo "#define CONFIG_A52BIN 1" >> $TMPH
  289. echo "CONFIG_A52BIN=yes" >> config.mak
  290. fi
  291. fi
  292. # mpeg audio high precision mode
  293. if test "$mpegaudio_hp" = "yes" ; then
  294. echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
  295. fi
  296. if test "$v4l" = "yes" ; then
  297. echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
  298. echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
  299. fi
  300. if test "$audio_oss" = "yes" ; then
  301. echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
  302. echo "CONFIG_AUDIO_OSS=yes" >> config.mak
  303. fi
  304. if test "$network" = "yes" ; then
  305. echo "#define CONFIG_NETWORK 1" >> $TMPH
  306. echo "CONFIG_NETWORK=yes" >> config.mak
  307. fi
  308. if test "$mp3lame" = "yes" ; then
  309. echo "#define CONFIG_MP3LAME 1" >> $TMPH
  310. echo "CONFIG_MP3LAME=yes" >> config.mak
  311. fi
  312. if test "$win32" = "yes" ; then
  313. echo "#define CONFIG_WIN32 1" >> $TMPH
  314. echo "CONFIG_WIN32=yes" >> config.mak
  315. fi
  316. if test "$_malloc_h" = "yes" ; then
  317. echo "#define HAVE_MALLOC_H 1" >> $TMPH
  318. else
  319. echo "#undef HAVE_MALLOC_H" >> $TMPH
  320. fi
  321. if test "$_memalign" = "yes" ; then
  322. echo "#define HAVE_MEMALIGN 1" >> $TMPH
  323. else
  324. echo "#undef HAVE_MEMALIGN" >> $TMPH
  325. fi
  326. if test "$simpleidct" = "yes" ; then
  327. echo "#define SIMPLE_IDCT 1" >> $TMPH
  328. fi
  329. echo "#define restrict $_restrict" >> $TMPH
  330. # build tree in object directory if source path is different from current one
  331. if test "$source_path_used" = "yes" ; then
  332. DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
  333. libavcodec/liba52 libavcodec/mlib tests"
  334. FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
  335. for dir in $DIRS ; do
  336. mkdir -p $dir
  337. done
  338. for f in $FILES ; do
  339. ln -sf $source_path/$f $f
  340. done
  341. fi
  342. echo "SRC_PATH=$source_path" >> config.mak
  343. diff $TMPH config.h >/dev/null 2>&1
  344. if test $? -ne 0 ; then
  345. mv -f $TMPH config.h
  346. else
  347. echo "config.h is unchanged"
  348. fi
  349. rm -f $TMPO $TMPC $TMPS $TMPH