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-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!"
114 --disable-avis-input)
120 --disable-mp4-output)
124 ASFLAGS
="$ASFLAGS ${opt#--extra-asflags=}"
127 CFLAGS
="$CFLAGS ${opt#--extra-cflags=}"
130 LDFLAGS
="$LDFLAGS ${opt#--extra-ldflags=}"
133 pthread
="auto" # can't skip detection, since it differs by OS
143 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"
187 if [ "$pic" = "no" ]; then
188 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"
216 CFLAGS
="$CFLAGS -mno-cygwin"
217 LDFLAGS
="$LDFLAGS -mno-cygwin"
228 CFLAGS
="$CFLAGS -DHAVE_MALLOC_H"
229 LDFLAGS
="$LDFLAGS -lm"
233 echo "Unknown system $host, edit the configure"
242 if [ "$SYS" = MACOSX
]; then
243 ASFLAGS
="$ASFLAGS -f macho -DPREFIX"
244 elif [ "$SYS" = MINGW
]; then
245 ASFLAGS
="$ASFLAGS -f win32 -DPREFIX"
247 ASFLAGS
="$ASFLAGS -f elf"
252 if [ "$SYS" = MACOSX
];then
253 ASFLAGS
="-f macho64 -m amd64 -DPIC -DPREFIX"
254 CFLAGS
="$CFLAGS -arch x86_64"
255 LDFLAGS
="$LDFLAGS -arch x86_64"
257 ASFLAGS
="-f elf -m amd64"
264 ALTIVECFLAGS
="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
266 ALTIVECFLAGS
="$ALTIVECFLAGS -maltivec -mabi=altivec"
270 if test "$(uname -m)" = "sun4u"; then
272 CFLAGS
="$CFLAGS -mcpu=ultrasparc"
273 LDFLAGS
="$LDFLAGS -mcpu=ultrasparc"
275 ASFLAGS
="-xarch=v8plusa"
280 mips|mipsel|mips64|mips64el
)
293 ARCH
="$(echo $host_cpu | tr a-z A-Z)"
299 if [ $shared = yes -a \
( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" \
) ] ; then
303 if [ $asm = yes -a \
( $ARCH = X86
-o $ARCH = X86_64 \
) ] ; then
304 if as_check
"pinsrd xmm0, [esp], 0" ; then
305 CFLAGS
="$CFLAGS -DHAVE_MMX"
307 VER
=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
309 echo "Minimum version is yasm-0.6.1"
310 echo "If you really want to compile without asm, configure with --disable-asm."
317 CFLAGS
="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
319 echo "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';" > conftest.c
320 $CC $CFLAGS conftest.c
-c -o conftest.o
2>$DEVNULL || die
"endian test failed"
321 grep -q BIGE conftest.o
&& CFLAGS
="$CFLAGS -DWORDS_BIGENDIAN"
323 # autodetect options that weren't forced nor disabled
326 if test "$pthread" = "auto" ; then
333 if cc_check pthread.h
-lpthread "pthread_create(0,0,0,0);" ; then
335 libpthread
="-lpthread"
336 elif cc_check pthread.h
-lpthreadGC2 "pthread_create(0,0,0,0);" ; then
338 libpthread
="-lpthreadGC2"
339 elif cc_check pthread.h
"-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
341 libpthread
="-lpthreadGC2 -lwsock32"
342 CFLAGS
="$CFLAGS -DPTW32_STATIC_LIB"
346 cc_check pthread.h
-lpthread && pthread
="yes" && libpthread
="-lpthread"
350 if test "$pthread" = "yes" ; then
351 CFLAGS
="$CFLAGS -DHAVE_PTHREAD"
352 LDFLAGS
="$LDFLAGS $libpthread"
355 MP4_LDFLAGS
="-lgpac_static"
356 if [ $SYS = MINGW
]; then
357 MP4_LDFLAGS
="$MP4_LDFLAGS -lwinmm"
359 if [ "$mp4_output" = "auto" ] ; then
361 cc_check gpac
/isomedia.h
"$MP4_LDFLAGS" && mp4_output
="yes"
363 if [ "$mp4_output" = "yes" ] ; then
364 echo "#define MP4_OUTPUT" >> config.h
365 LDFLAGS
="$LDFLAGS $MP4_LDFLAGS"
368 if [ "$avis_input" = "auto" ] ; then
369 if [ $SYS = MINGW
]; then
375 if [ "$avis_input" = "yes" ] ; then
376 echo "#define AVIS_INPUT" >> config.h
377 LDFLAGS
="$LDFLAGS -lvfw32"
380 if [ "$pic" = "yes" ] ; then
381 CFLAGS
="$CFLAGS -fPIC"
382 ASFLAGS
="$ASFLAGS -DPIC"
383 # resolve textrels in the x86 asm
384 cc_check stdio.h
-Wl,-Bsymbolic && LDFLAGS
="$LDFLAGS -Wl,-Bsymbolic"
387 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
388 CFLAGS
="$CFLAGS -s -fomit-frame-pointer"
389 LDFLAGS
="$LDFLAGS -s"
392 if [ "$debug" = "yes" ]; then
393 CFLAGS
="-O1 -g $CFLAGS"
395 CFLAGS
="-O4 -ffast-math $CFLAGS"
398 if cc_check
"stdio.h" "" "fseeko(stdin,0,0);" ; then
399 echo "#define fseek fseeko" >> config.h
400 echo "#define ftell ftello" >> config.h
401 elif cc_check
"stdio.h" "" "fseeko64(stdin,0,0);" ; then
402 echo "#define fseek fseeko64" >> config.h
403 echo "#define ftell ftello64" >> config.h
408 # generate config files
410 cat > config.mak
<< EOF
412 exec_prefix=$exec_prefix
415 includedir=$includedir
420 ALTIVECFLAGS=$ALTIVECFLAGS
426 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
431 $ECHON 'CONFIGURE_ARGS=' >> config.mak
433 $ECHON " '$A'" >> config.mak
435 echo '' >> config.mak
437 if [ "$shared" = "yes" ]; then
438 API
=$
(grep '#define X264_BUILD' < x264.h | cut
-f 3 -d ' ')
439 if [ "$SYS" = "MINGW" ]; then
440 echo "SONAME=libx264-$API.dll" >> config.mak
441 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
442 echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
443 elif [ "$SYS" = "MACOSX" ]; then
444 echo "SOSUFFIX=dylib" >> config.mak
445 echo "SONAME=libx264.$API.dylib" >> config.mak
446 echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
448 echo "SOSUFFIX=so" >> config.mak
449 echo "SONAME=libx264.so.$API" >> config.mak
450 echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
452 echo 'default: $(SONAME)' >> config.mak
457 pclibs
="-L$libdir -lx264 $libpthread"
461 exec_prefix=$exec_prefix
463 includedir=$includedir
466 Description: H.264 (MPEG4 AVC) encoder library
467 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
469 Cflags: -I$includedir
473 echo "Platform: $ARCH"
476 echo "avis input: $avis_input"
477 echo "mp4 output: $mp4_output"
478 echo "pthread: $pthread"
482 echo "shared: $shared"
483 echo "visualize: $vis"
485 echo "You can run 'make' or 'make fprofiled' now."