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.

271 lines
6.2KB

  1. #!/bin/sh
  2. TMPC="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.c"
  3. TMPO="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
  4. TMPS="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
  5. TMPH="ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
  6. if test ! -z "$TMPDIR" ; then
  7. TMPC="${TMPDIR}/${TMPC}"
  8. TMPCPP="${TMPDIR}/${TMPCPP}"
  9. TMPO="${TMPDIR}/${TMPO}"
  10. TMPS="${TMPDIR}/${TMPS}"
  11. TMPH="${TMPDIR}/${TMPH}"
  12. elif test ! -z "$TEMPDIR" ; then
  13. TMPC="${TEMPDIR}/${TMPC}"
  14. TMPCPP="${TEMPDIR}/${TMPCPP}"
  15. TMPO="${TEMPDIR}/${TMPO}"
  16. TMPS="${TEMPDIR}/${TMPS}"
  17. TMPH="${TEMPDIR}/${TMPH}"
  18. else
  19. TMPC="/tmp/${TMPC}"
  20. TMPCPP="/tmp/${TMPCPP}"
  21. TMPO="/tmp/${TMPO}"
  22. TMPS="/tmp/${TMPS}"
  23. TMPH="/tmp/${TMPH}"
  24. fi
  25. # default parameters
  26. prefix="/usr/local"
  27. cc="gcc"
  28. ar="ar"
  29. cpu=`uname -m`
  30. case "$cpu" in
  31. i386|i486|i586|i686|i86pc|BePC)
  32. cpu="x86"
  33. mmx="yes"
  34. ;;
  35. armv4l)
  36. cpu="armv4l"
  37. mmx="no"
  38. ;;
  39. alpha)
  40. cpu="alpha"
  41. mmx="no"
  42. ;;
  43. *)
  44. mmx="no"
  45. ;;
  46. esac
  47. gprof="no"
  48. grab="yes"
  49. mp3lame="no"
  50. a52bin="no"
  51. win32="no"
  52. extralibs="-lm"
  53. simpleidct="yes"
  54. # OS specific
  55. targetos=`uname -s`
  56. case $targetos in
  57. BeOS)
  58. prefix="/boot/home/config"
  59. # helps building libavcodec
  60. grab="no"
  61. CFLAGS="-O2 -DPIC"
  62. # no need for libm, but the inet stuff
  63. # Check for BONE
  64. if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
  65. extralibs="-lbind -lsocket"
  66. else
  67. echo "Not sure building for net_server will succeed... good luck."
  68. extralibs="-lsocket"
  69. fi ;;
  70. *) ;;
  71. esac
  72. if test "$1" = "-h" -o "$1" = "--help" ; then
  73. cat << EOF
  74. Usage: configure [options]
  75. Options: [defaults in brackets after descriptions]
  76. --help print this message
  77. EOF
  78. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  79. echo " --cc=CC use C compiler CC [$cc]"
  80. echo " --cpu=CPU force cpu to CPU [$cpu]"
  81. echo " --disable-mmx disable mmx usage"
  82. echo " --enable-gprof enable profiling with gprof [$gprof]"
  83. echo " --disable-grab disable audio/video grabbing code"
  84. echo " --disable-simple_idct disable simple IDCT routines [default=no]"
  85. echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
  86. echo " --enable-win32 enable win32 cross compile"
  87. echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
  88. echo " --enable-shared build shared libraries [default=no]"
  89. exit 1
  90. fi
  91. lshared=no
  92. for opt do
  93. case "$opt" in
  94. --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
  95. ;;
  96. --cc=*) cc=`echo $opt | cut -d '=' -f 2`
  97. ;;
  98. --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  99. ;;
  100. --disable-mmx) mmx="no"
  101. ;;
  102. --enable-gprof) gprof="yes"
  103. ;;
  104. --disable-grab) grab="no"
  105. ;;
  106. --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
  107. ;;
  108. --enable-mp3lame) mp3lame="yes"
  109. ;;
  110. --disable-simple_idct) simpleidct="no"
  111. ;;
  112. --enable-win32) win32="yes"
  113. ;;
  114. --enable-shared=*) lshared=`echo $opt | cut -d '=' -f 2`
  115. ;;
  116. esac
  117. done
  118. # Checking for CFLAGS
  119. if test -z "$CFLAGS"; then
  120. CFLAGS="-O2"
  121. fi
  122. if test "$win32" = "yes" ; then
  123. cross_prefix="i386-mingw32msvc-"
  124. cc="${cross_prefix}gcc"
  125. ar="${cross_prefix}ar"
  126. grab="no"
  127. fi
  128. # ---
  129. # check availability of some header files
  130. cat > $TMPC << EOF
  131. #include <malloc.h>
  132. int main( void ) { return 0; }
  133. EOF
  134. _memalign=no
  135. _malloc_h=no
  136. if $cc -o $TMPO $TMPC 2> /dev/null ; then
  137. _malloc_h=yes
  138. _memalign=yes
  139. # check for memalign - atmos
  140. cat > $TMPC << EOF
  141. #include <malloc.h>
  142. int main ( void ) {
  143. char *string = NULL;
  144. string = memalign(64, sizeof(char));
  145. return 0;
  146. }
  147. EOF
  148. $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
  149. fi
  150. echo "Install prefix $prefix"
  151. echo "C compiler $cc"
  152. echo "CPU $cpu"
  153. echo "MMX enabled $mmx"
  154. echo "gprof enabled $gprof"
  155. echo "grab enabled $grab"
  156. echo "mp3lame enabled $mp3lame"
  157. echo "a52 dlopened $a52bin"
  158. echo "Creating config.mak and config.h"
  159. echo "# Automatically generated by configure - do not modify" > config.mak
  160. echo "/* Automatically generated by configure - do not modify */" > $TMPH
  161. echo "prefix=$prefix" >> config.mak
  162. echo "MAKE=make" >> config.mak
  163. echo "CC=$cc" >> config.mak
  164. echo "AR=$ar" >> config.mak
  165. echo "OPTFLAGS=$CFLAGS" >> config.mak
  166. if test "$cpu" = "x86" ; then
  167. echo "TARGET_ARCH_X86=yes" >> config.mak
  168. echo "#define ARCH_X86 1" >> $TMPH
  169. fi
  170. if test "$cpu" = "armv4l" ; then
  171. echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
  172. echo "#define ARCH_ARMV4L 1" >> $TMPH
  173. fi
  174. if test "$cpu" = "alpha" ; then
  175. echo "TARGET_ARCH_ALPHA=yes" >> config.mak
  176. echo "#define ARCH_ALPHA 1" >> $TMPH
  177. fi
  178. if test "$mmx" = "yes" ; then
  179. echo "TARGET_MMX=yes" >> config.mak
  180. echo "#define HAVE_MMX 1" >> $TMPH
  181. fi
  182. if test "$gprof" = "yes" ; then
  183. echo "TARGET_GPROF=yes" >> config.mak
  184. echo "#define HAVE_GPROF 1" >> $TMPH
  185. fi
  186. if test "$lshared" = "yes" ; then
  187. echo "BUILD_SHARED=yes" >> config.mak
  188. else
  189. echo "BUILD_SHARED=no" >> config.mak
  190. fi
  191. echo "EXTRALIBS=$extralibs" >> config.mak
  192. echo -n "VERSION=" >>config.mak
  193. head VERSION >>config.mak
  194. echo "" >>config.mak
  195. # if you do not want to use encoders, disable that.
  196. echo "#define CONFIG_ENCODERS 1" >> $TMPH
  197. echo "CONFIG_ENCODERS=yes" >> config.mak
  198. # if you do not want to use decoders, disable that.
  199. echo "#define CONFIG_DECODERS 1" >> $TMPH
  200. echo "CONFIG_DECODERS=yes" >> config.mak
  201. # special AC3 stuff in case you already have it
  202. # without libavcodec.
  203. echo "#define CONFIG_AC3 1" >> $TMPH
  204. echo "CONFIG_AC3=yes" >> config.mak
  205. if test "$a52bin" = "yes" ; then
  206. echo "#define CONFIG_A52BIN 1" >> $TMPH
  207. echo "CONFIG_A52BIN=yes" >> config.mak
  208. else
  209. echo "CONFIG_A52BIN=no" >> config.mak
  210. fi
  211. if test "$grab" = "yes" ; then
  212. echo "#define CONFIG_GRAB 1" >> $TMPH
  213. echo "CONFIG_GRAB=yes" >> config.mak
  214. fi
  215. if test "$mp3lame" = "yes" ; then
  216. echo "#define CONFIG_MP3LAME 1" >> $TMPH
  217. echo "CONFIG_MP3LAME=yes" >> config.mak
  218. fi
  219. if test "$win32" = "yes" ; then
  220. echo "#define CONFIG_WIN32 1" >> $TMPH
  221. echo "CONFIG_WIN32=yes" >> config.mak
  222. fi
  223. if test "$_malloc_h" = "yes" ; then
  224. echo "#define HAVE_MALLOC_H 1" >> $TMPH
  225. else
  226. echo "#undef HAVE_MALLOC_H" >> $TMPH
  227. fi
  228. if test "$_memalign" = "yes" ; then
  229. echo "#define HAVE_MEMALIGN 1" >> $TMPH
  230. else
  231. echo "#undef HAVE_MEMALIGN" >> $TMPH
  232. fi
  233. if test "$simpleidct" = "yes" ; then
  234. echo "#define SIMPLE_IDCT 1" >> $TMPH
  235. fi
  236. diff $TMPH config.h >/dev/null 2>&1
  237. if test $? -ne 0 ; then
  238. mv -f $TMPH config.h
  239. else
  240. echo "config.h is unchanged"
  241. fi
  242. rm -f $TMPO $TMPC $TMPS $TMPH