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.

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