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"
23 echo " --cross-prefix=PREFIX use PREFIX for compilation tools"
29 cat > conftest.c << EOF
31 int main () { $3 return 0; }
33 $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
37 echo "$1" > conftest.asm
38 $AS conftest.asm $ASFLAGS $2 -o conftest.o 2>$DEVNULL
41 rm -f config.h config.mak x264.pc conftest*
44 exec_prefix='${prefix}'
45 bindir='${exec_prefix}/bin'
46 libdir='${exec_prefix}/lib'
47 includedir='${prefix}/include'
60 CFLAGS="$CFLAGS -Wall -I."
103 --disable-mp4-output)
107 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
110 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
113 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
116 pthread="auto" # can't skip detection, since it differs by OS
126 LDFLAGS="$LDFLAGS -pg"
136 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
137 CFLAGS="$CFLAGS -DVISUALIZE=1"
141 host="${opt#--host=}"
144 cross_prefix="${opt#--cross-prefix=}"
147 echo "Unknown option $opt, ignored"
152 CC="${CC-${cross_prefix}gcc}"
153 AR="${AR-${cross_prefix}ar}"
154 RANLIB="${RANLIB-${cross_prefix}ranlib}"
155 STRIP="${STRIP-${cross_prefix}strip}"
158 if [ "x$host" = x ]; then
159 host=`./config.guess`
161 # normalize a triplet into a quadruplet
162 host=`./config.sub $host`
165 host_cpu="${host%%-*}"
167 host_vendor="${host%%-*}"
173 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
177 CFLAGS="$CFLAGS -falign-loops=16"
178 LDFLAGS="$LDFLAGS -lm -lmx"
179 if [ "$pic" = "no" ]; then
180 CFLAGS="$CFLAGS -mdynamic-no-pic"
185 LDFLAGS="$LDFLAGS -lm"
189 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
190 LDFLAGS="$LDFLAGS -lm"
194 LDFLAGS="$LDFLAGS -lm"
198 CFLAGS="$CFLAGS -I/usr/X11R6/include"
199 LDFLAGS="$LDFLAGS -lm"
203 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
204 LDFLAGS="$LDFLAGS -lm"
208 CFLAGS="$CFLAGS -mno-cygwin"
209 LDFLAGS="$LDFLAGS -mno-cygwin"
220 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
221 LDFLAGS="$LDFLAGS -lm"
225 echo "Unknown system $host, edit the configure"
234 ASFLAGS="$ASFLAGS -O2"
235 if [[ "$asm" == yes && "$CFLAGS" != *-march* ]]; then
236 CFLAGS="$CFLAGS -march=i686"
238 if [ "$SYS" = MACOSX ]; then
239 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
240 elif [ "$SYS" = MINGW ]; then
241 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
243 ASFLAGS="$ASFLAGS -f elf"
249 if [ "$SYS" = MACOSX ];then
250 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
251 CFLAGS="$CFLAGS -arch x86_64"
252 LDFLAGS="$LDFLAGS -arch x86_64"
253 elif [ "$SYS" = MINGW ]; then
254 ASFLAGS="$ASFLAGS -f win32 -m amd64 -DPREFIX"
256 ASFLAGS="$ASFLAGS -f elf -m amd64"
263 ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
265 ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec -DHAVE_ALTIVEC_H"
269 if test "$(uname -m)" = "sun4u"; then
271 CFLAGS="$CFLAGS -mcpu=ultrasparc"
272 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
273 AS="${cross_prefix}as"
274 ASFLAGS="$ASFLAGS -xarch=v8plusa"
279 mips|mipsel|mips64|mips64el)
292 ARCH="$(echo $host_cpu | tr a-z A-Z)"
298 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" \) ] ; then
302 if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
303 if as_check "pinsrd xmm0, [esp], 0" ; then
304 CFLAGS="$CFLAGS -DHAVE_MMX"
306 VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
308 echo "Minimum version is yasm-0.6.1"
309 echo "If you really want to compile without asm, configure with --disable-asm."
313 [ $asm = no ] && AS=""
314 [ "x$AS" = x ] && asm="no"
316 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
318 echo "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';" > conftest.c
319 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
320 grep -q BIGE conftest.o && CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
322 # autodetect options that weren't forced nor disabled
325 if test "$pthread" = "auto" ; then
332 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
334 libpthread="-lpthread"
335 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
337 libpthread="-lpthreadGC2"
338 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
340 libpthread="-lpthreadGC2 -lwsock32"
341 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
342 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
344 libpthread="-lpthreadGC2 -lws2_32"
345 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
349 cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
352 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
356 if test "$pthread" = "yes" ; then
357 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
358 LDFLAGS="$LDFLAGS $libpthread"
361 MP4_LDFLAGS="-lgpac_static"
362 if [ $SYS = MINGW ]; then
363 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
365 if [ "$mp4_output" = "auto" ] ; then
367 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
369 if [ "$mp4_output" = "yes" ] ; then
370 echo "#define MP4_OUTPUT" >> config.h
371 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
374 if [ "$avis_input" = "auto" ] ; then
375 if [ $SYS = MINGW ]; then
381 if [ "$avis_input" = "yes" ] ; then
382 if cc_check "stdlib.h" -lvfw32 ; then
383 echo "#define AVIS_INPUT" >> config.h
384 LDFLAGS="$LDFLAGS -lvfw32"
385 elif cc_check "stdlib.h" -lavifil32 ; then
386 echo "#define AVIS_INPUT" >> config.h
387 LDFLAGS="$LDFLAGS -lavifil32"
393 if [ "$pic" = "yes" ] ; then
394 CFLAGS="$CFLAGS -fPIC"
395 ASFLAGS="$ASFLAGS -DPIC"
396 # resolve textrels in the x86 asm
397 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
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
421 # generate config files
423 cat > config.mak << EOF
425 exec_prefix=$exec_prefix
428 includedir=$includedir
433 ALTIVECFLAGS=$ALTIVECFLAGS
442 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
446 if [ "$shared" = "yes" ]; then
447 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
448 if [ "$SYS" = "MINGW" ]; then
449 echo "SONAME=libx264-$API.dll" >> config.mak
450 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
451 echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
452 elif [ "$SYS" = "MACOSX" ]; then
453 echo "SOSUFFIX=dylib" >> config.mak
454 echo "SONAME=libx264.$API.dylib" >> config.mak
455 echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
456 elif [ "$SYS" = "SunOS" ]; then
457 echo "SOSUFFIX=so" >> config.mak
458 echo "SONAME=libx264.so.$API" >> config.mak
459 echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak
461 echo "SOSUFFIX=so" >> config.mak
462 echo "SONAME=libx264.so.$API" >> config.mak
463 echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
465 echo 'default: $(SONAME)' >> config.mak
470 pclibs="-L$libdir -lx264 $libpthread"
474 exec_prefix=$exec_prefix
476 includedir=$includedir
479 Description: H.264 (MPEG4 AVC) encoder library
480 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
482 Cflags: -I$includedir
486 echo "Platform: $ARCH"
489 echo "avis input: $avis_input"
490 echo "mp4 output: $mp4_output"
491 echo "pthread: $pthread"
495 echo "shared: $shared"
496 echo "visualize: $vis"
498 echo "You can run 'make' or 'make fprofiled' now."