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.

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