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 " --enable-avis-input enables avisynth input (win32 only)"
11 echo " --enable-mp4-output enables mp4 output (using gpac)"
12 echo " --enable-gtk build GTK+ interface"
13 echo " --enable-pthread enables multithreaded encoding"
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"
28 cat > conftest.c << EOF
30 int main () { $3 return 0; }
32 $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
38 echo "$1" > conftest.asm
39 $AS conftest.asm $ASFLAGS $2 -o conftest.o 2>$DEVNULL
44 rm -f config.h config.mak x264.pc conftest*
47 exec_prefix='${prefix}'
48 bindir='${exec_prefix}/bin'
49 libdir='${exec_prefix}/lib'
50 includedir='${prefix}/include'
64 CFLAGS="$CFLAGS -Wall -I."
73 # check whether 'echo -n' works as expected, otherwise try printf
74 if [ "x`echo -n houba`" = xhouba ]
77 elif [ "x`printf houba`" = xhouba ]
81 echo "Neither 'echo -n' nor 'printf' are working with your shell!"
108 --disable-avis-input)
114 --disable-mp4-output)
118 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
121 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
124 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
127 pthread="auto" # can't skip detection, since it differs by OS
137 LDFLAGS="$LDFLAGS -pg"
153 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
154 CFLAGS="$CFLAGS -DVISUALIZE=1"
158 host="${opt#--host=}"
161 echo "Unknown option $opt, ignored"
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 -lmx"
190 LDFLAGS="$LDFLAGS -lm"
194 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
195 LDFLAGS="$LDFLAGS -lm"
199 LDFLAGS="$LDFLAGS -lm"
203 CFLAGS="$CFLAGS -I/usr/X11R6/include"
204 LDFLAGS="$LDFLAGS -lm"
208 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
209 LDFLAGS="$LDFLAGS -lm"
213 CFLAGS="$CFLAGS -mno-cygwin"
214 LDFLAGS="$LDFLAGS -mno-cygwin"
225 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
226 LDFLAGS="$LDFLAGS -lm"
230 echo "Unknown system $host, edit the configure"
240 if [ "$SYS" = MACOSX ]; then
241 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
242 elif [ "$SYS" = MINGW ]; then
243 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
244 elif [ "$SYS" = NETBSD ]; then
245 ASFLAGS="$ASFLAGS -f aoutb"
247 ASFLAGS="$ASFLAGS -f elf"
249 as_check || AS="nasm"
254 if [ "$SYS" = MACOSX ];then
255 ASFLAGS="-f macho64 -m amd64 -D__PIC__ -DPREFIX"
256 CFLAGS="$CFLAGS -arch x86_64"
257 LDFLAGS="$LDFLAGS -arch x86_64"
259 ASFLAGS="-f elf -m amd64"
266 ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
268 ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec"
272 if test "$(uname -m)" = "sun4u"; then
274 CFLAGS="$CFLAGS -mcpu=ultrasparc"
275 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
277 ASFLAGS="-xarch=v8plusa"
282 mips|mipsel|mips64|mips64el)
295 ARCH="$(echo $host_cpu | tr a-z A-Z)"
301 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" \) ] ; then
305 if [ $SYS = MACOSX -a $ARCH = X86 ]
307 # we want Apple's nasm from Xcode 2.4.1 or later
308 NASM_BUILD_REQUIRED=11
309 NASM_BUILD=`nasm -v|grep "Apple Computer"|sed 's/.*build \([0-9]*\).*/\1/'`
310 if [ $NASM_BUILD -lt $NASM_BUILD_REQUIRED ]
312 echo "Your version of 'nasm' is too old."
313 echo "Please install Xcode 2.4.1 or later."
318 if [ $ARCH = X86 -o $ARCH = X86_64 ] ; then
319 if [ $ARCH = X86 -a $pic = yes -a x$AS = xyasm -a\
320 "`yasm --version | head -n 1`" "<" "yasm 0.6.2" ] ; then
321 echo "yasm prior to 0.6.2 miscompiles PIC. trying nasm instead..."
325 CFLAGS="$CFLAGS -DHAVE_MMX"
326 if as_check "pabsw xmm0, xmm0" ; then
327 ASFLAGS="$ASFLAGS -DHAVE_SSE3"
328 CFLAGS="$CFLAGS -DHAVE_SSE3"
331 echo "No suitable assembler found. x264 will be several times slower."
332 echo "Please install 'yasm' to get MMX/SSE optimized code."
337 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
339 echo "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';" > conftest.c
340 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
341 grep -q BIGE conftest.o && CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
343 # autodetect options that weren't forced nor disabled
346 if test "$pthread" = "auto" ; then
353 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
355 libpthread="-lpthread"
356 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
358 libpthread="-lpthreadGC2"
359 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
361 libpthread="-lpthreadGC2 -lwsock32"
362 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
366 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
370 if test "$pthread" = "yes" ; then
371 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
372 LDFLAGS="$LDFLAGS $libpthread"
375 MP4_LDFLAGS="-lgpac_static"
376 if [ $SYS = MINGW ]; then
377 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
379 if [ "$mp4_output" = "auto" ] ; then
381 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
383 if [ "$mp4_output" = "yes" ] ; then
384 echo "#define MP4_OUTPUT" >> config.h
385 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
388 if [ "$avis_input" = "auto" ] ; then
389 if [ $SYS = MINGW ]; then
395 if [ "$avis_input" = "yes" ] ; then
396 echo "#define AVIS_INPUT" >> config.h
397 LDFLAGS="$LDFLAGS -lvfw32"
400 if [ "$pic" = "yes" ] ; then
401 CFLAGS="$CFLAGS -fPIC"
402 ASFLAGS="$ASFLAGS -D__PIC__"
403 # resolve textrels in the x86 asm
404 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
407 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
408 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
409 LDFLAGS="$LDFLAGS -s"
412 if [ "$debug" = "yes" ]; then
413 CFLAGS="-O1 -g $CFLAGS"
415 CFLAGS="-O4 -ffast-math $CFLAGS"
418 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
419 echo "#define fseek fseeko" >> config.h
420 echo "#define ftell ftello" >> config.h
421 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
422 echo "#define fseek fseeko64" >> config.h
423 echo "#define ftell ftello64" >> config.h
428 # generate config files
430 cat > config.mak << EOF
432 exec_prefix=$exec_prefix
435 includedir=$includedir
440 ALTIVECFLAGS=$ALTIVECFLAGS
447 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
452 $ECHON 'CONFIGURE_ARGS=' >> config.mak
454 $ECHON " '$A'" >> config.mak
456 echo '' >> config.mak
458 cp config.mak gtk/config.mak
460 if [ "$shared" = "yes" ]; then
461 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
462 if [ "$SYS" = "MINGW" ]; then
463 echo "SONAME=libx264-$API.dll" >> config.mak
464 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
465 echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
467 echo "SONAME=libx264.so.$API" >> config.mak
468 echo 'SOFLAGS=-Wl,soname,$(SONAME)' >> config.mak
470 echo 'default: $(SONAME)' >> config.mak
471 if [ "$gtk" = "yes" ]; then
472 echo "SONAMEGTK=libx264gtk.so.$API" >> gtk/config.mak
476 if [ "$gtk" = "yes" ]; then
477 echo 'default: libx264gtk.a' >> config.mak
478 echo 'install: install-gtk' >> config.mak
483 pclibs="-L$libdir -lx264 $libpthread"
487 exec_prefix=$exec_prefix
489 includedir=$includedir
492 Description: H.264 (MPEG4 AVC) encoder library
493 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
495 Cflags: -I$includedir
499 echo "Platform: $ARCH"
501 echo "avis input: $avis_input"
502 echo "mp4 output: $mp4_output"
503 echo "pthread: $pthread"
508 echo "shared: $shared"
509 echo "visualize: $vis"
511 echo "You can run 'make' or 'make fprofiled' now."