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.

258 lines
5.8KB

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