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"
29 cat > conftest.c << EOF
31 int main () { $3 return 0; }
33 $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
41 echo "$1" > conftest.asm
42 $AS conftest.asm $ASFLAGS $2 -o conftest.o 2>$DEVNULL
48 rm -f config.h config.mak x264.pc
51 exec_prefix='${prefix}'
52 bindir='${exec_prefix}/bin'
53 libdir='${exec_prefix}/lib'
54 includedir='${prefix}/include'
68 CFLAGS="$CFLAGS -Wall -I."
77 # check whether 'echo -n' works as expected, otherwise try printf
78 if [ "x`echo -n houba`" = xhouba ]
81 elif [ "x`printf houba`" = xhouba ]
85 echo "Neither 'echo -n' nor 'printf' are working with your shell!"
112 --disable-avis-input)
118 --disable-mp4-output)
122 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
125 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
128 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
131 pthread="auto" # can't skip detection, since it differs by OS
141 LDFLAGS="$LDFLAGS -pg"
157 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
158 CFLAGS="$CFLAGS -DVISUALIZE=1"
162 host="${opt#--host=}"
165 echo "Unknown option $opt, ignored"
170 if [ "x$host" = x ]; then
171 host=`./config.guess`
173 # normalize a triplet into a quadruplet
174 host=`./config.sub $host`
177 host_cpu="${host%%-*}"
179 host_vendor="${host%%-*}"
185 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
189 CFLAGS="$CFLAGS -falign-loops=16"
190 LDFLAGS="$LDFLAGS -lm -lmx"
194 LDFLAGS="$LDFLAGS -lm"
198 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
199 LDFLAGS="$LDFLAGS -lm"
203 LDFLAGS="$LDFLAGS -lm"
207 CFLAGS="$CFLAGS -I/usr/X11R6/include"
208 LDFLAGS="$LDFLAGS -lm"
212 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
213 LDFLAGS="$LDFLAGS -lm"
217 CFLAGS="$CFLAGS -mno-cygwin"
218 LDFLAGS="$LDFLAGS -mno-cygwin"
229 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
230 LDFLAGS="$LDFLAGS -lm"
234 echo "Unknown system $host, edit the configure"
244 if [ "$SYS" = MACOSX ]; then
245 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
246 elif [ "$SYS" = CYGWIN -o "$SYS" = MINGW ]; then
247 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
248 elif [ "$SYS" = NETBSD ]; then
249 ASFLAGS="$ASFLAGS -f aoutb"
251 ASFLAGS="$ASFLAGS -f elf"
253 as_check || AS="nasm"
258 if [ "$SYS" = MACOSX ];then
259 ASFLAGS="-f macho64 -m amd64 -D__PIC__ -DPREFIX"
260 CFLAGS="$CFLAGS -arch x86_64"
261 LDFLAGS="$LDFLAGS -arch x86_64"
263 ASFLAGS="-f elf -m amd64"
270 ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
272 ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec"
276 if test "$(uname -m)" = "sun4u"; then
278 CFLAGS="$CFLAGS -mcpu=ultrasparc"
279 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
281 ASFLAGS="-xarch=v8plusa"
286 mips|mipsel|mips64|mips64el)
299 ARCH="$(echo $host_cpu | tr a-z A-Z)"
305 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" \) ] ; then
309 if [ $SYS = MACOSX -a $ARCH = X86 ]
311 # we want Apple's nasm from Xcode 2.4.1 or later
312 NASM_BUILD_REQUIRED=11
313 NASM_BUILD=`nasm -v|grep "Apple Computer"|sed 's/.*build \([0-9]*\).*/\1/'`
314 if [ $NASM_BUILD -lt $NASM_BUILD_REQUIRED ]
316 echo "Your version of 'nasm' is too old."
317 echo "Please install Xcode 2.4.1 or later."
322 if [ $ARCH = X86 -o $ARCH = X86_64 ] ; then
324 CFLAGS="$CFLAGS -DHAVE_MMX"
325 if as_check "pabsw xmm0, xmm0" ; then
326 ASFLAGS="$ASFLAGS -DHAVE_SSE3"
327 CFLAGS="$CFLAGS -DHAVE_SSE3"
330 echo "No suitable assembler found. x264 will be several times slower."
331 echo "Please install 'yasm' to get MMX/SSE optimized code."
336 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
338 # autodetect options that weren't forced nor disabled
341 if test "$pthread" = "auto" ; then
348 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
350 libpthread="-lpthread"
351 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
353 libpthread="-lpthreadGC2"
354 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
356 libpthread="-lpthreadGC2 -lwsock32"
357 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
361 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
365 if test "$pthread" = "yes" ; then
366 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
367 LDFLAGS="$LDFLAGS $libpthread"
370 MP4_LDFLAGS="-lgpac_static"
371 if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
372 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
374 if [ "$mp4_output" = "auto" ] ; then
376 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
378 if [ "$mp4_output" = "yes" ] ; then
379 echo "#define MP4_OUTPUT" >> config.h
380 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
383 if [ "$avis_input" = "auto" ] ; then
384 if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
390 if [ "$avis_input" = "yes" ] ; then
391 echo "#define AVIS_INPUT" >> config.h
392 LDFLAGS="$LDFLAGS -lvfw32"
395 if [ "$pic" = "yes" ] ; then
396 CFLAGS="$CFLAGS -fPIC"
397 ASFLAGS="$ASFLAGS -D__PIC__"
400 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
401 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
402 LDFLAGS="$LDFLAGS -s"
405 if [ "$debug" = "yes" ]; then
406 CFLAGS="-O1 -g $CFLAGS"
408 CFLAGS="-O4 -ffast-math $CFLAGS"
411 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
412 echo "#define fseek fseeko" >> config.h
413 echo "#define ftell ftello" >> config.h
414 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
415 echo "#define fseek fseeko64" >> config.h
416 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 echo "SONAME=libx264.so.$API" >> config.mak
454 echo 'default: $(SONAME)' >> config.mak
455 if [ "$gtk" = "yes" ]; then
456 echo "SONAMEGTK=libx264gtk.so.$API" >> gtk/config.mak
460 if [ "$gtk" = "yes" ]; then
461 echo 'default: libx264gtk.a' >> config.mak
462 echo 'install: install-gtk' >> config.mak
467 pclibs="-L$libdir -lx264 $libpthread"
471 exec_prefix=$exec_prefix
473 includedir=$includedir
476 Description: H.264 (MPEG4 AVC) encoder library
477 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
479 Cflags: -I$includedir
483 echo "Platform: $ARCH"
485 echo "avis input: $avis_input"
486 echo "mp4 output: $mp4_output"
487 echo "pthread: $pthread"
492 echo "shared: $shared"
493 echo "visualize: $vis"
495 echo "You can run 'make' or 'make fprofiled' now."