3 if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
5 echo "Usage: ./configure [options]"
7 echo "available options:"
9 echo " --help print this message"
10 echo " --disable-avs-input disables avisynth input (win32 only)"
11 echo " --disable-mp4-output disables mp4 output (using gpac)"
12 echo " --disable-pthread disables multithreaded encoding"
13 echo " --disable-asm disables assembly optimizations on x86 and arm"
14 echo " --enable-debug adds -g, doesn't strip"
15 echo " --enable-gprof adds -pg, doesn't strip"
16 echo " --enable-visualize enables visualization (X11 only)"
17 echo " --enable-pic build position-independent code"
18 echo " --enable-shared build libx264.so"
19 echo " --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS"
20 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS"
21 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS"
22 echo " --host=HOST build programs to run on HOST"
23 echo " --cross-prefix=PREFIX use PREFIX for compilation tools"
30 [ -n "$1" ] && echo "#include <$1>" > conftest.c
31 echo "int main () { $3 return 0; }" >> conftest.c
32 $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
36 echo "$1" > conftest.asm
37 $AS conftest.asm $ASFLAGS $2 -o conftest.o 2>$DEVNULL
45 rm -f config.h config.mak x264.pc conftest*
48 exec_prefix='${prefix}'
49 bindir='${exec_prefix}/bin'
50 libdir='${exec_prefix}/lib'
51 includedir='${prefix}/include'
64 CFLAGS="$CFLAGS -Wall -I."
100 if [ "$avs_input" != "auto" -a "$avs_input" != "vfw" -a "$avs_input" != "avs" ] ; then
101 echo "unrecognized enable-avis-input option '$avs_input'"
102 echo "available options are 'auto', 'avs', or 'vfw'"
112 --disable-mp4-output)
116 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
119 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
122 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
125 pthread="auto" # can't skip detection, since it differs by OS
135 LDFLAGS="$LDFLAGS -pg"
145 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
146 CFLAGS="$CFLAGS -DVISUALIZE=1"
150 host="${opt#--host=}"
153 cross_prefix="${opt#--cross-prefix=}"
156 echo "Unknown option $opt, ignored"
161 CC="${CC-${cross_prefix}gcc}"
162 AR="${AR-${cross_prefix}ar}"
163 RANLIB="${RANLIB-${cross_prefix}ranlib}"
164 STRIP="${STRIP-${cross_prefix}strip}"
166 if [ "x$host" = x ]; then
167 host=`./config.guess`
169 # normalize a triplet into a quadruplet
170 host=`./config.sub $host`
173 host_cpu="${host%%-*}"
175 host_vendor="${host%%-*}"
181 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
185 CFLAGS="$CFLAGS -falign-loops=16"
186 LDFLAGS="$LDFLAGS -lm"
187 if [ "$pic" = "no" ]; then
188 cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic"
193 LDFLAGS="$LDFLAGS -lm"
197 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
198 LDFLAGS="$LDFLAGS -lm"
202 LDFLAGS="$LDFLAGS -lm"
206 CFLAGS="$CFLAGS -I/usr/X11R6/include"
207 LDFLAGS="$LDFLAGS -lm"
211 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
212 LDFLAGS="$LDFLAGS -lm"
218 if cc_check "" -mno-cygwin; then
219 CFLAGS="$CFLAGS -mno-cygwin"
220 LDFLAGS="$LDFLAGS -mno-cygwin"
230 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
231 LDFLAGS="$LDFLAGS -lm"
235 die "Unknown system $host, edit the configure"
243 ASFLAGS="$ASFLAGS -O2"
244 if [[ "$asm" == yes && "$CFLAGS" != *-march* ]]; then
245 CFLAGS="$CFLAGS -march=i686"
247 if [[ "$asm" == yes && "$CFLAGS" != *-mfpmath* ]]; then
248 CFLAGS="$CFLAGS -mfpmath=sse -msse"
250 if [ "$SYS" = MACOSX ]; then
251 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
252 elif [ "$SYS" = MINGW ]; then
253 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
255 ASFLAGS="$ASFLAGS -f elf"
261 if [ "$SYS" = MACOSX ];then
262 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
263 if cc_check '' "-arch x86_64"; then
264 CFLAGS="$CFLAGS -arch x86_64"
265 LDFLAGS="$LDFLAGS -arch x86_64"
267 elif [ "$SYS" = MINGW ]; then
268 ASFLAGS="$ASFLAGS -f win32 -m amd64 -DPREFIX"
270 ASFLAGS="$ASFLAGS -f elf -m amd64"
277 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
279 CFLAGS="$CFLAGS -maltivec -mabi=altivec -DHAVE_ALTIVEC_H"
283 if test "$(uname -m)" = "sun4u"; then
285 CFLAGS="$CFLAGS -mcpu=ultrasparc"
286 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
287 AS="${cross_prefix}as"
288 ASFLAGS="$ASFLAGS -xarch=v8plusa"
293 mips|mipsel|mips64|mips64el)
298 AS="${AS-${cross_prefix}gcc}"
307 ARCH="$(echo $host_cpu | tr a-z A-Z)"
313 cc_check || die "No working C compiler found."
315 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" \) ] ; then
319 if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
320 if ! as_check "lzcnt eax, eax" ; then
321 VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
323 echo "Minimum version is yasm-0.6.2"
324 echo "If you really want to compile without asm, configure with --disable-asm."
327 if ! cc_check '' '' 'asm("pabsw %xmm0, %xmm0");' ; then
328 VER=`(as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
330 echo "Minimum version is binutils-2.17"
331 echo "Your compiler can't handle inline SSSE3 asm."
332 echo "If you really want to compile without asm, configure with --disable-asm."
335 CFLAGS="$CFLAGS -DHAVE_MMX"
338 if [ $asm = yes -a $ARCH = ARM ] ; then
339 # set flags so neon is built by default
340 echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
342 if cc_check '' '' 'asm("rev ip, ip");' ; then CFLAGS="$CFLAGS -DHAVE_ARMV6"
343 cc_check '' '' 'asm("movt r0, #0");' && CFLAGS="$CFLAGS -DHAVE_ARMV6T2"
344 cc_check '' '' 'asm("vadd.i16 q0, q0, q0");' && CFLAGS="$CFLAGS -DHAVE_NEON"
345 ASFLAGS="$ASFLAGS $CFLAGS -c"
347 echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
348 echo "If you really want to run on such a CPU, configure with --disable-asm."
353 [ $asm = no ] && AS=""
354 [ "x$AS" = x ] && asm="no"
356 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
358 echo "int i = 0x42494745; double f = 0x1.0656e6469616ep+102;" > conftest.c
359 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
360 if grep -q BIGE conftest.o && grep -q FPendian conftest.o ; then
361 CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
362 elif !(grep -q EGIB conftest.o && grep -q naidnePF conftest.o) ; then
363 die "endian test failed"
366 # autodetect options that weren't forced nor disabled
369 if test "$pthread" = "auto" ; then
376 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
378 libpthread="-lpthread"
379 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
381 libpthread="-lpthreadGC2"
382 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
384 libpthread="-lpthreadGC2 -lwsock32"
385 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
386 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
388 libpthread="-lpthreadGC2 -lws2_32"
389 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
393 cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
396 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
400 if test "$pthread" = "yes" ; then
401 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
402 LDFLAGS="$LDFLAGS $libpthread"
405 MP4_LDFLAGS="-lgpac_static"
406 if [ $SYS = MINGW ]; then
407 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
409 if [ "$mp4_output" = "auto" ] ; then
411 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
413 if [ "$mp4_output" = "yes" ] ; then
414 echo "#define MP4_OUTPUT" >> config.h
415 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
418 if [ "$avs_input" = "auto" -o "$avs_input" = "avs" ] ; then
419 if [ $SYS = MINGW ] && cc_check avisynth_c.h ; then
421 echo "#define AVS_INPUT" >> config.h
422 echo "#define HAVE_AVISYNTH_C_H" >> config.h
423 elif [ $SYS = MINGW ] && cc_check extras/avisynth_c.h ; then
425 echo "#define AVS_INPUT" >> config.h
430 if [ "$avs_input" = "auto" -o "$avs_input" = "vfw" ] ; then
431 if [ $SYS = MINGW ] && cc_check "stdlib.h" -lvfw32 ; then
432 echo "#define VFW_INPUT" >> config.h
433 LDFLAGS="$LDFLAGS -lvfw32"
435 elif [ $SYS = MINGW ] && cc_check "stdlib.h" -lavifil32 ; then
436 echo "#define VFW_INPUT" >> config.h
437 LDFLAGS="$LDFLAGS -lavifil32"
444 if [ "$pic" = "yes" ] ; then
445 CFLAGS="$CFLAGS -fPIC"
446 ASFLAGS="$ASFLAGS -DPIC"
447 # resolve textrels in the x86 asm
448 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
451 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
452 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
453 LDFLAGS="$LDFLAGS -s"
456 if [ "$debug" = "yes" ]; then
457 CFLAGS="-O1 -g $CFLAGS"
458 elif [ $ARCH = ARM ]; then
459 # arm-gcc-4.2 produces incorrect output with -ffast-math
460 # and it doesn't save any speed anyway on 4.4, so disable it
461 CFLAGS="-O4 -fno-fast-math $CFLAGS"
463 CFLAGS="-O4 -ffast-math $CFLAGS"
466 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
467 echo "#define fseek fseeko" >> config.h
468 echo "#define ftell ftello" >> config.h
469 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
470 echo "#define fseek fseeko64" >> config.h
471 echo "#define ftell ftello64" >> config.h
476 # generate config files
478 cat > config.mak << EOF
480 exec_prefix=$exec_prefix
483 includedir=$includedir
496 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
500 if [ "$shared" = "yes" ]; then
501 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
502 if [ "$SYS" = "MINGW" ]; then
503 echo "SONAME=libx264-$API.dll" >> config.mak
504 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
505 echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
506 elif [ "$SYS" = "MACOSX" ]; then
507 echo "SOSUFFIX=dylib" >> config.mak
508 echo "SONAME=libx264.$API.dylib" >> config.mak
509 echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
510 elif [ "$SYS" = "SunOS" ]; then
511 echo "SOSUFFIX=so" >> config.mak
512 echo "SONAME=libx264.so.$API" >> config.mak
513 echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak
515 echo "SOSUFFIX=so" >> config.mak
516 echo "SONAME=libx264.so.$API" >> config.mak
517 echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
519 echo 'default: $(SONAME)' >> config.mak
524 pclibs="-L$libdir -lx264 $libpthread"
528 exec_prefix=$exec_prefix
530 includedir=$includedir
533 Description: H.264 (MPEG4 AVC) encoder library
534 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
536 Cflags: -I$includedir
540 echo "Platform: $ARCH"
543 echo "avs input: $avs_input"
544 echo "mp4 output: $mp4_output"
545 echo "pthread: $pthread"
549 echo "shared: $shared"
550 echo "visualize: $vis"
552 echo "You can run 'make' or 'make fprofiled' now."