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-avis-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."
101 --disable-avis-input)
107 --disable-mp4-output)
111 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
114 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
117 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
120 pthread="auto" # can't skip detection, since it differs by OS
130 LDFLAGS="$LDFLAGS -pg"
140 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
141 CFLAGS="$CFLAGS -DVISUALIZE=1"
145 host="${opt#--host=}"
148 cross_prefix="${opt#--cross-prefix=}"
151 echo "Unknown option $opt, ignored"
156 CC="${CC-${cross_prefix}gcc}"
157 AR="${AR-${cross_prefix}ar}"
158 RANLIB="${RANLIB-${cross_prefix}ranlib}"
159 STRIP="${STRIP-${cross_prefix}strip}"
161 if [ "x$host" = x ]; then
162 host=`./config.guess`
164 # normalize a triplet into a quadruplet
165 host=`./config.sub $host`
168 host_cpu="${host%%-*}"
170 host_vendor="${host%%-*}"
176 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
180 CFLAGS="$CFLAGS -falign-loops=16"
181 LDFLAGS="$LDFLAGS -lm"
182 if [ "$pic" = "no" ]; then
183 CFLAGS="$CFLAGS -mdynamic-no-pic"
188 LDFLAGS="$LDFLAGS -lm"
192 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
193 LDFLAGS="$LDFLAGS -lm"
197 LDFLAGS="$LDFLAGS -lm"
201 CFLAGS="$CFLAGS -I/usr/X11R6/include"
202 LDFLAGS="$LDFLAGS -lm"
206 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
207 LDFLAGS="$LDFLAGS -lm"
213 if cc_check "" -mno-cygwin; then
214 CFLAGS="$CFLAGS -mno-cygwin"
215 LDFLAGS="$LDFLAGS -mno-cygwin"
225 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
226 LDFLAGS="$LDFLAGS -lm"
230 die "Unknown system $host, edit the configure"
238 ASFLAGS="$ASFLAGS -O2"
239 if [[ "$asm" == yes && "$CFLAGS" != *-march* ]]; then
240 CFLAGS="$CFLAGS -march=i686"
242 if [[ "$asm" == yes && "$CFLAGS" != *-mfpmath* ]]; then
243 CFLAGS="$CFLAGS -mfpmath=sse -msse"
245 if [ "$SYS" = MACOSX ]; then
246 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
247 elif [ "$SYS" = MINGW ]; then
248 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
250 ASFLAGS="$ASFLAGS -f elf"
256 if [ "$SYS" = MACOSX ];then
257 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
258 CFLAGS="$CFLAGS -arch x86_64"
259 LDFLAGS="$LDFLAGS -arch x86_64"
260 elif [ "$SYS" = MINGW ]; then
261 ASFLAGS="$ASFLAGS -f win32 -m amd64 -DPREFIX"
263 ASFLAGS="$ASFLAGS -f elf -m amd64"
270 ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
272 ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec -DHAVE_ALTIVEC_H"
276 if test "$(uname -m)" = "sun4u"; then
278 CFLAGS="$CFLAGS -mcpu=ultrasparc"
279 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
280 AS="${cross_prefix}as"
281 ASFLAGS="$ASFLAGS -xarch=v8plusa"
286 mips|mipsel|mips64|mips64el)
291 AS="${AS-${cross_prefix}gcc}"
300 ARCH="$(echo $host_cpu | tr a-z A-Z)"
306 cc_check || die "No working C compiler found."
308 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" \) ] ; then
312 if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
313 if ! as_check "lzcnt eax, eax" ; then
314 VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
316 echo "Minimum version is yasm-0.6.2"
317 echo "If you really want to compile without asm, configure with --disable-asm."
320 if ! cc_check '' '' 'asm("pabsw %xmm0, %xmm0");' ; then
321 VER=`(as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
323 echo "Minimum version is binutils-2.17"
324 echo "Your compiler can't handle inline SSSE3 asm."
325 echo "If you really want to compile without asm, configure with --disable-asm."
328 CFLAGS="$CFLAGS -DHAVE_MMX"
331 if [ $asm = yes -a $ARCH = ARM ] ; then
332 # set flags so neon is built by default
333 echo $CFLAGS | grep -Eq '(-mcpu|-march|-mfpu|-mfloat-abi)' || CFLAGS="$CFLAGS -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
335 if cc_check '' '' 'asm("rev ip, ip");' ; then CFLAGS="$CFLAGS -DHAVE_ARMV6"
336 cc_check '' '' 'asm("movt r0, #0");' && CFLAGS="$CFLAGS -DHAVE_ARMV6T2"
337 cc_check '' '' 'asm("vadd.i16 q0, q0, q0");' && CFLAGS="$CFLAGS -DHAVE_NEON"
338 ASFLAGS="$ASFLAGS $CFLAGS -c"
340 echo "You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS."
341 echo "If you really want to run on such a CPU, configure with --disable-asm."
346 [ $asm = no ] && AS=""
347 [ "x$AS" = x ] && asm="no"
349 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
351 echo "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';" > conftest.c
352 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
353 grep -q BIGE conftest.o && CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
355 # autodetect options that weren't forced nor disabled
358 if test "$pthread" = "auto" ; then
365 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
367 libpthread="-lpthread"
368 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
370 libpthread="-lpthreadGC2"
371 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
373 libpthread="-lpthreadGC2 -lwsock32"
374 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
375 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
377 libpthread="-lpthreadGC2 -lws2_32"
378 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
382 cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
385 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
389 if test "$pthread" = "yes" ; then
390 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
391 LDFLAGS="$LDFLAGS $libpthread"
394 MP4_LDFLAGS="-lgpac_static"
395 if [ $SYS = MINGW ]; then
396 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
398 if [ "$mp4_output" = "auto" ] ; then
400 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
402 if [ "$mp4_output" = "yes" ] ; then
403 echo "#define MP4_OUTPUT" >> config.h
404 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
407 if [ "$avis_input" = "auto" ] ; then
408 if [ $SYS = MINGW ]; then
414 if [ "$avis_input" = "yes" ] ; then
415 if cc_check "stdlib.h" -lvfw32 ; then
416 echo "#define AVIS_INPUT" >> config.h
417 LDFLAGS="$LDFLAGS -lvfw32"
418 elif cc_check "stdlib.h" -lavifil32 ; then
419 echo "#define AVIS_INPUT" >> config.h
420 LDFLAGS="$LDFLAGS -lavifil32"
426 if [ "$pic" = "yes" ] ; then
427 CFLAGS="$CFLAGS -fPIC"
428 ASFLAGS="$ASFLAGS -DPIC"
429 # resolve textrels in the x86 asm
430 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
433 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
434 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
435 LDFLAGS="$LDFLAGS -s"
438 if [ "$debug" = "yes" ]; then
439 CFLAGS="-O1 -g $CFLAGS"
440 elif [ $ARCH = ARM ]; then
441 # arm-gcc-4.2 produces incorrect output with -ffast-math
442 # and it doesn't save any speed anyway on 4.4, so disable it
443 CFLAGS="-O4 -fno-fast-math $CFLAGS"
445 CFLAGS="-O4 -ffast-math $CFLAGS"
448 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
449 echo "#define fseek fseeko" >> config.h
450 echo "#define ftell ftello" >> config.h
451 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
452 echo "#define fseek fseeko64" >> config.h
453 echo "#define ftell ftello64" >> config.h
458 # generate config files
460 cat > config.mak << EOF
462 exec_prefix=$exec_prefix
465 includedir=$includedir
470 ALTIVECFLAGS=$ALTIVECFLAGS
479 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
483 if [ "$shared" = "yes" ]; then
484 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
485 if [ "$SYS" = "MINGW" ]; then
486 echo "SONAME=libx264-$API.dll" >> config.mak
487 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
488 echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
489 elif [ "$SYS" = "MACOSX" ]; then
490 echo "SOSUFFIX=dylib" >> config.mak
491 echo "SONAME=libx264.$API.dylib" >> config.mak
492 echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
493 elif [ "$SYS" = "SunOS" ]; then
494 echo "SOSUFFIX=so" >> config.mak
495 echo "SONAME=libx264.so.$API" >> config.mak
496 echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak
498 echo "SOSUFFIX=so" >> config.mak
499 echo "SONAME=libx264.so.$API" >> config.mak
500 echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
502 echo 'default: $(SONAME)' >> config.mak
507 pclibs="-L$libdir -lx264 $libpthread"
511 exec_prefix=$exec_prefix
513 includedir=$includedir
516 Description: H.264 (MPEG4 AVC) encoder library
517 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
519 Cflags: -I$includedir
523 echo "Platform: $ARCH"
526 echo "avis input: $avis_input"
527 echo "mp4 output: $mp4_output"
528 echo "pthread: $pthread"
532 echo "shared: $shared"
533 echo "visualize: $vis"
535 echo "You can run 'make' or 'make fprofiled' now."