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.

343 lines
8.5KB

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