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.

333 lines
8.3KB

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