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.

270 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. # OS specific
  54. targetos=`uname -s`
  55. case $targetos in
  56. BeOS)
  57. prefix="/boot/home/config"
  58. # helps building libavcodec
  59. grab="no"
  60. CFLAGS="-O2 -DPIC"
  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. *) ;;
  70. esac
  71. if test "$1" = "-h" -o "$1" = "--help" ; then
  72. cat << EOF
  73. Usage: configure [options]
  74. Options: [defaults in brackets after descriptions]
  75. --help print this message
  76. EOF
  77. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  78. echo " --cc=CC use C compiler CC [$cc]"
  79. echo " --cpu=CPU force cpu to CPU [$cpu]"
  80. echo " --disable-mmx disable mmx usage"
  81. echo " --enable-gprof enable profiling with gprof [$gprof]"
  82. echo " --disable-grab disable audio/video grabbing code"
  83. echo " --enable-simple_idct use simple IDCT routines [default=no]"
  84. echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
  85. echo " --enable-win32 enable win32 cross compile"
  86. echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
  87. echo " --enable-shared build shared libraries [default=no]"
  88. exit 1
  89. fi
  90. lshared=no
  91. for opt do
  92. case "$opt" in
  93. --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
  94. ;;
  95. --cc=*) cc=`echo $opt | cut -d '=' -f 2`
  96. ;;
  97. --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  98. ;;
  99. --disable-mmx) mmx="no"
  100. ;;
  101. --enable-gprof) gprof="yes"
  102. ;;
  103. --disable-grab) grab="no"
  104. ;;
  105. --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
  106. ;;
  107. --enable-mp3lame) mp3lame="yes"
  108. ;;
  109. --enable-simple_idct) simpleidct="yes"
  110. ;;
  111. --enable-win32) win32="yes"
  112. ;;
  113. --enable-shared=*) lshared=`echo $opt | cut -d '=' -f 2`
  114. ;;
  115. esac
  116. done
  117. # Checking for CFLAGS
  118. if test -z "$CFLAGS"; then
  119. CFLAGS="-O2"
  120. fi
  121. if test "$win32" = "yes" ; then
  122. cross_prefix="i386-mingw32msvc-"
  123. cc="${cross_prefix}gcc"
  124. ar="${cross_prefix}ar"
  125. grab="no"
  126. fi
  127. # ---
  128. # check availability of some header files
  129. cat > $TMPC << EOF
  130. #include <malloc.h>
  131. int main( void ) { return 0; }
  132. EOF
  133. _memalign=no
  134. _malloc_h=no
  135. if $cc -o $TMPO $TMPC 2> /dev/null ; then
  136. _malloc_h=yes
  137. _memalign=yes
  138. # check for memalign - atmos
  139. cat > $TMPC << EOF
  140. #include <malloc.h>
  141. int main ( void ) {
  142. char *string = NULL;
  143. string = memalign(64, sizeof(char));
  144. return 0;
  145. }
  146. EOF
  147. $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
  148. fi
  149. echo "Install prefix $prefix"
  150. echo "C compiler $cc"
  151. echo "CPU $cpu"
  152. echo "MMX enabled $mmx"
  153. echo "gprof enabled $gprof"
  154. echo "grab enabled $grab"
  155. echo "mp3lame enabled $mp3lame"
  156. echo "a52 dlopened $a52bin"
  157. echo "Creating config.mak and config.h"
  158. echo "# Automatically generated by configure - do not modify" > config.mak
  159. echo "/* Automatically generated by configure - do not modify */" > $TMPH
  160. echo "prefix=$prefix" >> config.mak
  161. echo "MAKE=make" >> config.mak
  162. echo "CC=$cc" >> config.mak
  163. echo "AR=$ar" >> config.mak
  164. echo "OPTFLAGS=$CFLAGS" >> config.mak
  165. if test "$cpu" = "x86" ; then
  166. echo "TARGET_ARCH_X86=yes" >> config.mak
  167. echo "#define ARCH_X86 1" >> $TMPH
  168. fi
  169. if test "$cpu" = "armv4l" ; then
  170. echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
  171. echo "#define ARCH_ARMV4L 1" >> $TMPH
  172. fi
  173. if test "$cpu" = "alpha" ; then
  174. echo "TARGET_ARCH_ALPHA=yes" >> config.mak
  175. echo "#define ARCH_ALPHA 1" >> $TMPH
  176. fi
  177. if test "$mmx" = "yes" ; then
  178. echo "TARGET_MMX=yes" >> config.mak
  179. echo "#define HAVE_MMX 1" >> $TMPH
  180. fi
  181. if test "$gprof" = "yes" ; then
  182. echo "TARGET_GPROF=yes" >> config.mak
  183. echo "#define HAVE_GPROF 1" >> $TMPH
  184. fi
  185. if test "$lshared" = "yes" ; then
  186. echo "BUILD_SHARED=yes" >> config.mak
  187. else
  188. echo "BUILD_SHARED=no" >> config.mak
  189. fi
  190. echo "EXTRALIBS=$extralibs" >> config.mak
  191. echo -n "VERSION=" >>config.mak
  192. head VERSION >>config.mak
  193. echo "" >>config.mak
  194. # if you do not want to use encoders, disable that.
  195. echo "#define CONFIG_ENCODERS 1" >> $TMPH
  196. echo "CONFIG_ENCODERS=yes" >> config.mak
  197. # if you do not want to use decoders, disable that.
  198. echo "#define CONFIG_DECODERS 1" >> $TMPH
  199. echo "CONFIG_DECODERS=yes" >> config.mak
  200. # special AC3 stuff in case you already have it
  201. # without libavcodec.
  202. echo "#define CONFIG_AC3 1" >> $TMPH
  203. echo "CONFIG_AC3=yes" >> config.mak
  204. if test "$a52bin" = "yes" ; then
  205. echo "#define CONFIG_A52BIN 1" >> $TMPH
  206. echo "CONFIG_A52BIN=yes" >> config.mak
  207. else
  208. echo "CONFIG_A52BIN=no" >> config.mak
  209. fi
  210. if test "$grab" = "yes" ; then
  211. echo "#define CONFIG_GRAB 1" >> $TMPH
  212. echo "CONFIG_GRAB=yes" >> config.mak
  213. fi
  214. if test "$mp3lame" = "yes" ; then
  215. echo "#define CONFIG_MP3LAME 1" >> $TMPH
  216. echo "CONFIG_MP3LAME=yes" >> config.mak
  217. fi
  218. if test "$win32" = "yes" ; then
  219. echo "#define CONFIG_WIN32 1" >> $TMPH
  220. echo "CONFIG_WIN32=yes" >> config.mak
  221. fi
  222. if test "$_malloc_h" = "yes" ; then
  223. echo "#define HAVE_MALLOC_H 1" >> $TMPH
  224. else
  225. echo "#undef HAVE_MALLOC_H" >> $TMPH
  226. fi
  227. if test "$_memalign" = "yes" ; then
  228. echo "#define HAVE_MEMALIGN 1" >> $TMPH
  229. else
  230. echo "#undef HAVE_MEMALIGN" >> $TMPH
  231. fi
  232. if test "$simpleidct" = "yes" ; then
  233. echo "#define SIMPLE_IDCT 1" >> $TMPH
  234. fi
  235. diff $TMPH config.h >/dev/null 2>&1
  236. if test $? -ne 0 ; then
  237. mv -f $TMPH config.h
  238. else
  239. echo "config.h is unchanged"
  240. fi
  241. rm -f $TMPO $TMPC $TMPS $TMPH