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"
14 echo " --enable-gtk build GTK+ interface"
15 echo " --enable-debug adds -g, doesn't strip"
16 echo " --enable-gprof adds -pg, doesn't strip"
17 echo " --enable-visualize enables visualization (X11 only)"
18 echo " --enable-pic build position-independent code"
19 echo " --enable-shared build libx264.so"
20 echo " --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS"
21 echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS"
22 echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS"
23 echo " --host=HOST build programs to run on HOST"
29 cat > conftest.c << EOF
31 int main () { $3 return 0; }
33 $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
39 echo "$1" > conftest.asm
40 $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'
66 CFLAGS="$CFLAGS -Wall -I."
75 # check whether 'echo -n' works as expected, otherwise try printf
76 if [ "x`echo -n houba`" = xhouba ]
79 elif [ "x`printf houba`" = xhouba ]
83 echo "Neither 'echo -n' nor 'printf' are working with your shell!"
116 --disable-avis-input)
122 --disable-mp4-output)
126 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
129 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
132 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
135 pthread="auto" # can't skip detection, since it differs by OS
145 LDFLAGS="$LDFLAGS -pg"
161 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
162 CFLAGS="$CFLAGS -DVISUALIZE=1"
166 host="${opt#--host=}"
169 echo "Unknown option $opt, ignored"
174 if [ "x$host" = x ]; then
175 host=`./config.guess`
177 # normalize a triplet into a quadruplet
178 host=`./config.sub $host`
181 host_cpu="${host%%-*}"
183 host_vendor="${host%%-*}"
189 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
193 CFLAGS="$CFLAGS -falign-loops=16"
194 LDFLAGS="$LDFLAGS -lm -lmx"
198 LDFLAGS="$LDFLAGS -lm"
202 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
203 LDFLAGS="$LDFLAGS -lm"
207 LDFLAGS="$LDFLAGS -lm"
211 CFLAGS="$CFLAGS -I/usr/X11R6/include"
212 LDFLAGS="$LDFLAGS -lm"
216 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
217 LDFLAGS="$LDFLAGS -lm"
221 CFLAGS="$CFLAGS -mno-cygwin"
222 LDFLAGS="$LDFLAGS -mno-cygwin"
233 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
234 LDFLAGS="$LDFLAGS -lm"
238 echo "Unknown system $host, edit the configure"
248 if [ "$SYS" = MACOSX ]; then
249 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
250 elif [ "$SYS" = MINGW ]; then
251 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
253 ASFLAGS="$ASFLAGS -f elf"
255 as_check || AS="nasm"
260 if [ "$SYS" = MACOSX ];then
261 ASFLAGS="-f macho64 -m amd64 -D__PIC__ -DPREFIX"
262 CFLAGS="$CFLAGS -arch x86_64"
263 LDFLAGS="$LDFLAGS -arch x86_64"
265 ASFLAGS="-f elf -m amd64"
272 ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
274 ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec"
278 if test "$(uname -m)" = "sun4u"; then
280 CFLAGS="$CFLAGS -mcpu=ultrasparc"
281 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
283 ASFLAGS="-xarch=v8plusa"
288 mips|mipsel|mips64|mips64el)
301 ARCH="$(echo $host_cpu | tr a-z A-Z)"
307 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" \) ] ; then
311 if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
312 if [ $ARCH = X86 -a $pic = yes -a x$AS = xyasm -a\
313 "`yasm --version 2>$DEVNULL | head -n 1`" "<" "yasm 0.6.2" ] ; then
314 echo "yasm prior to 0.6.2 miscompiles PIC. trying nasm instead..."
317 if as_check "pabsw xmm0, xmm0" ; then
318 CFLAGS="$CFLAGS -DHAVE_MMX"
320 echo "No suitable assembler found. Install 'yasm' to get MMX/SSE optimized code."
321 echo "If you really want to compile without asm, configure with --disable-asm."
328 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
330 echo "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';" > conftest.c
331 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
332 grep -q BIGE conftest.o && CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
334 # autodetect options that weren't forced nor disabled
337 if test "$pthread" = "auto" ; then
344 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
346 libpthread="-lpthread"
347 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
349 libpthread="-lpthreadGC2"
350 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
352 libpthread="-lpthreadGC2 -lwsock32"
353 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
357 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
361 if test "$pthread" = "yes" ; then
362 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
363 LDFLAGS="$LDFLAGS $libpthread"
366 MP4_LDFLAGS="-lgpac_static"
367 if [ $SYS = MINGW ]; then
368 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
370 if [ "$mp4_output" = "auto" ] ; then
372 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
374 if [ "$mp4_output" = "yes" ] ; then
375 echo "#define MP4_OUTPUT" >> config.h
376 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
379 if [ "$avis_input" = "auto" ] ; then
380 if [ $SYS = MINGW ]; then
386 if [ "$avis_input" = "yes" ] ; then
387 echo "#define AVIS_INPUT" >> config.h
388 LDFLAGS="$LDFLAGS -lvfw32"
391 if [ "$pic" = "yes" ] ; then
392 CFLAGS="$CFLAGS -fPIC"
393 ASFLAGS="$ASFLAGS -D__PIC__"
394 # resolve textrels in the x86 asm
395 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
398 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
399 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
400 LDFLAGS="$LDFLAGS -s"
403 if [ "$debug" = "yes" ]; then
404 CFLAGS="-O1 -g $CFLAGS"
406 CFLAGS="-O4 -ffast-math $CFLAGS"
409 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
410 echo "#define fseek fseeko" >> config.h
411 echo "#define ftell ftello" >> config.h
412 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
413 echo "#define fseek fseeko64" >> config.h
414 echo "#define ftell ftello64" >> config.h
419 # generate config files
421 cat > config.mak << EOF
423 exec_prefix=$exec_prefix
426 includedir=$includedir
431 ALTIVECFLAGS=$ALTIVECFLAGS
438 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
443 $ECHON 'CONFIGURE_ARGS=' >> config.mak
445 $ECHON " '$A'" >> config.mak
447 echo '' >> config.mak
449 cp config.mak gtk/config.mak
451 if [ "$shared" = "yes" ]; then
452 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
453 if [ "$SYS" = "MINGW" ]; then
454 echo "SONAME=libx264-$API.dll" >> config.mak
455 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
456 echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
457 elif [ "$SYS" = "MACOSX" ]; then
458 echo "SONAME=libx264.$API.dylib" >> config.mak
459 echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress' >> config.mak
461 echo "SONAME=libx264.so.$API" >> config.mak
462 echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
464 echo 'default: $(SONAME)' >> config.mak
465 if [ "$gtk" = "yes" ]; then
466 echo "SONAMEGTK=libx264gtk.so.$API" >> gtk/config.mak
470 if [ "$gtk" = "yes" ]; then
471 echo 'default: libx264gtk.a' >> config.mak
472 echo 'install: install-gtk' >> config.mak
477 pclibs="-L$libdir -lx264 $libpthread"
481 exec_prefix=$exec_prefix
483 includedir=$includedir
486 Description: H.264 (MPEG4 AVC) encoder library
487 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
489 Cflags: -I$includedir
493 echo "Platform: $ARCH"
496 echo "avis input: $avis_input"
497 echo "mp4 output: $mp4_output"
498 echo "pthread: $pthread"
503 echo "shared: $shared"
504 echo "visualize: $vis"
506 echo "You can run 'make' or 'make fprofiled' now."