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.

485 lines
12KB

  1. #!/bin/sh
  2. #
  3. # ffmpeg configure script (c) 2000, 2001, 2002 Fabrice Bellard
  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. v4l="yes"
  42. audio_oss="yes"
  43. network="yes"
  44. zlib="yes"
  45. mp3lame="no"
  46. a52="yes"
  47. a52bin="no"
  48. win32="no"
  49. lshared="no"
  50. extralibs="-lm"
  51. simpleidct="yes"
  52. bigendian="no"
  53. vhook="no"
  54. mpegaudio_hp="yes"
  55. SHFLAGS=-shared
  56. # OS specific
  57. targetos=`uname -s`
  58. case $targetos in
  59. BeOS)
  60. prefix="/boot/home/config"
  61. # helps building libavcodec
  62. CFLAGS="-O3 -DPIC -fomit-frame-pointer"
  63. SHFLAGS=-nostart
  64. # disable linux things
  65. audio_oss="no"
  66. v4l="no"
  67. # no need for libm, but the inet stuff
  68. # Check for BONE
  69. if (echo $BEINCLUDES|grep 'headers/be/bone' >/dev/null); then
  70. extralibs="-lbind -lsocket"
  71. else
  72. echo "Not sure building for net_server will succeed... good luck."
  73. extralibs="-lsocket"
  74. fi ;;
  75. BSD/OS)
  76. v4l="no"
  77. audio_oss="yes"
  78. extralibs="-lpoll -lgnugetopt -lm"
  79. make="gmake"
  80. ;;
  81. *) ;;
  82. esac
  83. # find source path
  84. # XXX: we assume an absolute path is given when launching configure,
  85. # except in './configure' case.
  86. source_path=${0%configure}
  87. source_path=${source_path%/}
  88. source_path_used="yes"
  89. if test -z "$source_path" -o "$source_path" = "." ; then
  90. source_path=`pwd`
  91. source_path_used="no"
  92. fi
  93. cat > $TMPC << EOF
  94. #include <dlfcn.h>
  95. int main( void ) { return (int) dlopen("foo", 0); }
  96. EOF
  97. if $cc -o $TMPO $TMPC -ldl 2> /dev/null ; then
  98. : vhook=yes
  99. fi
  100. cat > $TMPC << EOF
  101. #include <X11/Xlib.h>
  102. #include <Imlib2.h>
  103. int main( void ) { return (int) imlib_load_font("foo"); }
  104. EOF
  105. imlib2=no
  106. if $cc -o $TMPO $TMPC -lImlib2 2> /dev/null ; then
  107. imlib2=yes
  108. fi
  109. for opt do
  110. case "$opt" in
  111. --prefix=*) prefix=`echo $opt | cut -d '=' -f 2`
  112. ;;
  113. --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
  114. ;;
  115. --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
  116. ;;
  117. --cc=*) cc=`echo $opt | cut -d '=' -f 2`
  118. ;;
  119. --make=*) make=`echo $opt | cut -d '=' -f 2`
  120. ;;
  121. --extra-cflags=*) CFLAGS="${opt#--extra-cflags=}"
  122. ;;
  123. --extra-ldflags=*) LDFLAGS=${opt#--extra-ldflags=}
  124. ;;
  125. --extra-libs=*) extralibs=${opt#--extra-libs=}
  126. ;;
  127. --cpu=*) cpu=`echo $opt | cut -d '=' -f 2`
  128. ;;
  129. --disable-mmx) mmx="no"
  130. ;;
  131. --enable-gprof) gprof="yes"
  132. ;;
  133. --disable-v4l) v4l="no"
  134. ;;
  135. --disable-audio-oss) audio_oss="no"
  136. ;;
  137. --disable-network) network="no"
  138. ;;
  139. --disable-zlib) zlib="no"
  140. ;;
  141. --disable-a52) a52="no"
  142. ;;
  143. --enable-a52bin) a52bin="yes" ; extralibs="-ldl $extralibs"
  144. ;;
  145. --enable-mp3lame) mp3lame="yes"
  146. ;;
  147. --disable-vhook) vhook="no"
  148. ;;
  149. --disable-simple_idct) simpleidct="no"
  150. ;;
  151. --enable-win32) win32="yes"
  152. ;;
  153. --enable-shared) lshared="yes"
  154. ;;
  155. --disable-mpegaudio-hp) mpegaudio_hp="no"
  156. ;;
  157. esac
  158. done
  159. # compute mmx state
  160. if test $mmx = "default"; then
  161. if test $cpu = "x86"; then
  162. mmx="yes"
  163. else
  164. mmx="no"
  165. fi
  166. fi
  167. # Checking for CFLAGS
  168. if test -z "$CFLAGS"; then
  169. CFLAGS="-O3"
  170. fi
  171. if test "$win32" = "yes" ; then
  172. cross_prefix="i386-mingw32msvc-"
  173. v4l="no"
  174. audio_oss="no"
  175. network="no"
  176. fi
  177. cc="${cross_prefix}${cc}"
  178. ar="${cross_prefix}${ar}"
  179. strip="${cross_prefix}${strip}"
  180. # ---
  181. # big/little endian test
  182. cat > $TMPC << EOF
  183. #include <inttypes.h>
  184. int main(int argc, char ** argv){
  185. volatile uint32_t i=0x01234567;
  186. return (*((uint8_t*)(&i))) == 0x67;
  187. }
  188. EOF
  189. if $cc -o $TMPO $TMPC 2>/dev/null ; then
  190. $TMPO && bigendian="yes"
  191. else
  192. echo big/little test failed
  193. fi
  194. # ---
  195. # check availability of some header files
  196. cat > $TMPC << EOF
  197. #include <malloc.h>
  198. int main( void ) { return 0; }
  199. EOF
  200. _memalign=no
  201. _malloc_h=no
  202. if $cc -o $TMPO $TMPC 2> /dev/null ; then
  203. _malloc_h=yes
  204. _memalign=yes
  205. # check for memalign - atmos
  206. cat > $TMPC << EOF
  207. #include <malloc.h>
  208. int main ( void ) {
  209. char *string = NULL;
  210. string = memalign(64, sizeof(char));
  211. return 0;
  212. }
  213. EOF
  214. $cc -o $TMPO $TMPC 2> /dev/null || _memalign=no
  215. fi
  216. cat > $TMPC << EOF
  217. #define _GNU_SOURCE
  218. #include <time.h>
  219. int main( void ) { return *strptime("", "", 0); }
  220. EOF
  221. strptime=no
  222. if $cc -o $TMPO $TMPC 2> /dev/null ; then
  223. strptime=yes
  224. fi
  225. if test "$zlib" = "yes"; then
  226. # check for zlib - mmu_man
  227. cat > $TMPC << EOF
  228. #include <zlib.h>
  229. int main ( void ) {
  230. if (zlibVersion() != ZLIB_VERSION)
  231. puts("zlib version differs !!!");
  232. return 1;
  233. return 0;
  234. }
  235. EOF
  236. $cc -o $TMPO $TMPC -lz 2> /dev/null || zlib="no"
  237. # $TMPO 2> /dev/null > /dev/null || zlib="no"
  238. # XXX: more tests needed - runtime test
  239. fi
  240. if test "$zlib" = "yes"; then
  241. extralibs="$extralibs -lz"
  242. fi
  243. _restrict=
  244. for restrict_keyword in restrict __restrict__ __restrict; do
  245. echo "void foo(char * $restrict_keyword p);" > $TMPC
  246. if $cc -c -o $TMPO $TMPC 2> /dev/null; then
  247. _restrict=$restrict_keyword
  248. break;
  249. fi
  250. done
  251. if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
  252. cat << EOF
  253. Usage: configure [options]
  254. Options: [defaults in brackets after descriptions]
  255. EOF
  256. echo "Standard options:"
  257. echo " --help print this message"
  258. echo " --prefix=PREFIX install in PREFIX [$prefix]"
  259. echo " --enable-mp3lame enable mp3 encoding via libmp3lame [default=no]"
  260. echo " --enable-win32 enable win32 cross compile"
  261. echo " --disable-a52 disable GPL'ed A52 support [default=no]"
  262. echo " --enable-a52bin open liba52.so.0 at runtime [default=no]"
  263. echo " --enable-shared build shared libraries [default=no]"
  264. echo ""
  265. echo "Advanced options (experts only):"
  266. echo " --source-path=PATH path of source code [$source_path]"
  267. echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
  268. echo " --cc=CC use C compiler CC [$cc]"
  269. echo " --make=MAKE use specified make [$make]"
  270. echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS [$CFLAGS]"
  271. echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS [$LDFLAGS]"
  272. echo " --extra-libs=ELIBS add ELIBS [$ELIBS]"
  273. echo " --cpu=CPU force cpu to CPU [$cpu]"
  274. echo " --disable-mmx disable mmx usage"
  275. echo " --disable-audio-oss disable OSS audio support [default=no]"
  276. echo " --disable-v4l disable video4linux grabbing [default=no]"
  277. echo " --disable-network disable network support [default=no]"
  278. echo " --disable-zlib disable zlib [default=no]"
  279. echo " --disable-simple_idct disable simple IDCT routines [default=no]"
  280. # echo " --disable-vhook disable video hooking support"
  281. echo " --enable-gprof enable profiling with gprof [$gprof]"
  282. echo " --disable-mpegaudio-hp faster (but less accurate)"
  283. echo " mpegaudio decoding [default=no]"
  284. echo ""
  285. echo "NOTE: The object files are build at the place where configure is launched"
  286. exit 1
  287. fi
  288. echo "Install prefix $prefix"
  289. echo "Source path $source_path"
  290. echo "C compiler $cc"
  291. echo "make $make"
  292. echo "CPU $cpu"
  293. echo "Big Endian $bigendian"
  294. echo "MMX enabled $mmx"
  295. echo "gprof enabled $gprof"
  296. echo "zlib enabled $zlib"
  297. echo "mp3lame enabled $mp3lame"
  298. echo "a52 support $a52"
  299. echo "a52 dlopened $a52bin"
  300. # echo "Video hooking $vhook"
  301. if test "$vhook" = "yes" ; then
  302. : echo "Imlib2 support $imlib2"
  303. fi
  304. echo "Creating config.mak and config.h"
  305. echo "# Automatically generated by configure - do not modify" > config.mak
  306. echo "/* Automatically generated by configure - do not modify */" > $TMPH
  307. echo "prefix=$prefix" >> config.mak
  308. echo "MAKE=$make" >> config.mak
  309. echo "CC=$cc" >> config.mak
  310. echo "AR=$ar" >> config.mak
  311. echo "STRIP=$strip" >> config.mak
  312. echo "OPTFLAGS=$CFLAGS" >> config.mak
  313. echo "LDFLAGS=$LDFLAGS" >> config.mak
  314. echo "SHFLAGS=$SHFLAGS" >> config.mak
  315. if test "$cpu" = "x86" ; then
  316. echo "TARGET_ARCH_X86=yes" >> config.mak
  317. echo "#define ARCH_X86 1" >> $TMPH
  318. elif test "$cpu" = "armv4l" ; then
  319. echo "TARGET_ARCH_ARMV4L=yes" >> config.mak
  320. echo "#define ARCH_ARMV4L 1" >> $TMPH
  321. elif test "$cpu" = "alpha" ; then
  322. echo "TARGET_ARCH_ALPHA=yes" >> config.mak
  323. echo "#define ARCH_ALPHA 1" >> $TMPH
  324. elif test "$cpu" = "powerpc" ; then
  325. echo "TARGET_ARCH_POWERPC=yes" >> config.mak
  326. echo "#define ARCH_POWERPC 1" >> $TMPH
  327. fi
  328. if test "$bigendian" = "yes" ; then
  329. echo "WORDS_BIGENDIAN=yes" >> config.mak
  330. echo "#define WORDS_BIGENDIAN 1" >> $TMPH
  331. fi
  332. if test "$mmx" = "yes" ; then
  333. echo "TARGET_MMX=yes" >> config.mak
  334. echo "#define HAVE_MMX 1" >> $TMPH
  335. fi
  336. if test "$gprof" = "yes" ; then
  337. echo "TARGET_GPROF=yes" >> config.mak
  338. echo "#define HAVE_GPROF 1" >> $TMPH
  339. fi
  340. if test "$strptime" = "yes" ; then
  341. echo "#define HAVE_STRPTIME 1" >> $TMPH
  342. else
  343. echo "BUILD_STRPTIME=yes" >> config.mak
  344. fi
  345. if test "$imlib2" = "yes" ; then
  346. echo "HAVE_IMLIB2=yes" >> config.mak
  347. fi
  348. if test "$vhook" = "yes" ; then
  349. echo "BUILD_VHOOK=yes" >> config.mak
  350. echo "#define HAVE_VHOOK 1" >> $TMPH
  351. extralibs="$extralibs -ldl"
  352. fi
  353. if test "$lshared" = "yes" ; then
  354. echo "BUILD_SHARED=yes" >> config.mak
  355. echo "PIC=-fPIC" >> config.mak
  356. fi
  357. echo "EXTRALIBS=$extralibs" >> config.mak
  358. echo -n "VERSION=" >>config.mak
  359. head $source_path/VERSION >>config.mak
  360. echo "" >>config.mak
  361. # if you do not want to use encoders, disable that.
  362. echo "#define CONFIG_ENCODERS 1" >> $TMPH
  363. echo "CONFIG_ENCODERS=yes" >> config.mak
  364. # if you do not want to use decoders, disable that.
  365. echo "#define CONFIG_DECODERS 1" >> $TMPH
  366. echo "CONFIG_DECODERS=yes" >> config.mak
  367. # AC3
  368. if test "$a52" = "yes" ; then
  369. echo "#define CONFIG_AC3 1" >> $TMPH
  370. echo "CONFIG_AC3=yes" >> config.mak
  371. if test "$a52bin" = "yes" ; then
  372. echo "#define CONFIG_A52BIN 1" >> $TMPH
  373. echo "CONFIG_A52BIN=yes" >> config.mak
  374. fi
  375. fi
  376. # mpeg audio high precision mode
  377. if test "$mpegaudio_hp" = "yes" ; then
  378. echo "#define CONFIG_MPEGAUDIO_HP 1" >> $TMPH
  379. fi
  380. if test "$v4l" = "yes" ; then
  381. echo "#define CONFIG_VIDEO4LINUX 1" >> $TMPH
  382. echo "CONFIG_VIDEO4LINUX=yes" >> config.mak
  383. fi
  384. if test "$audio_oss" = "yes" ; then
  385. echo "#define CONFIG_AUDIO_OSS 1" >> $TMPH
  386. echo "CONFIG_AUDIO_OSS=yes" >> config.mak
  387. fi
  388. if test "$network" = "yes" ; then
  389. echo "#define CONFIG_NETWORK 1" >> $TMPH
  390. echo "CONFIG_NETWORK=yes" >> config.mak
  391. fi
  392. if test "$zlib" = "yes" ; then
  393. echo "#define CONFIG_ZLIB 1" >> $TMPH
  394. echo "CONFIG_ZLIB=yes" >> config.mak
  395. fi
  396. if test "$mp3lame" = "yes" ; then
  397. echo "#define CONFIG_MP3LAME 1" >> $TMPH
  398. echo "CONFIG_MP3LAME=yes" >> config.mak
  399. fi
  400. if test "$win32" = "yes" ; then
  401. echo "#define CONFIG_WIN32 1" >> $TMPH
  402. echo "CONFIG_WIN32=yes" >> config.mak
  403. fi
  404. if test "$_malloc_h" = "yes" ; then
  405. echo "#define HAVE_MALLOC_H 1" >> $TMPH
  406. else
  407. echo "#undef HAVE_MALLOC_H" >> $TMPH
  408. fi
  409. if test "$_memalign" = "yes" ; then
  410. echo "#define HAVE_MEMALIGN 1" >> $TMPH
  411. else
  412. echo "#undef HAVE_MEMALIGN" >> $TMPH
  413. fi
  414. if test "$simpleidct" = "yes" ; then
  415. echo "#define SIMPLE_IDCT 1" >> $TMPH
  416. fi
  417. echo "#define restrict $_restrict" >> $TMPH
  418. # build tree in object directory if source path is different from current one
  419. if test "$source_path_used" = "yes" ; then
  420. DIRS="libav libavcodec libavcodec/alpha libavcodec/armv4l libavcodec/i386 \
  421. libavcodec/liba52 libavcodec/mlib tests"
  422. FILES="Makefile libav/Makefile libavcodec/Makefile tests/Makefile"
  423. for dir in $DIRS ; do
  424. mkdir -p $dir
  425. done
  426. for f in $FILES ; do
  427. ln -sf $source_path/$f $f
  428. done
  429. fi
  430. echo "SRC_PATH=$source_path" >> config.mak
  431. diff $TMPH config.h >/dev/null 2>&1
  432. if test $? -ne 0 ; then
  433. mv -f $TMPH config.h
  434. else
  435. echo "config.h is unchanged"
  436. fi
  437. rm -f $TMPO $TMPC $TMPS $TMPH