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"
30 [ -n "$1" ] && echo "#include <$1>" > conftest.c
31 echo "int main () { $3 return 0; }" >> conftest.c
32 $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
36 echo "$1" > conftest.asm
37 $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'
64 CFLAGS="$CFLAGS -Wall -I."
101 --disable-avis-input)
107 --disable-mp4-output)
111 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
114 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
117 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
120 pthread="auto" # can't skip detection, since it differs by OS
130 LDFLAGS="$LDFLAGS -pg"
140 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
141 CFLAGS="$CFLAGS -DVISUALIZE=1"
145 host="${opt#--host=}"
148 cross_prefix="${opt#--cross-prefix=}"
151 echo "Unknown option $opt, ignored"
156 CC="${CC-${cross_prefix}gcc}"
157 AR="${AR-${cross_prefix}ar}"
158 RANLIB="${RANLIB-${cross_prefix}ranlib}"
159 STRIP="${STRIP-${cross_prefix}strip}"
162 if [ "x$host" = x ]; then
163 host=`./config.guess`
165 # normalize a triplet into a quadruplet
166 host=`./config.sub $host`
169 host_cpu="${host%%-*}"
171 host_vendor="${host%%-*}"
177 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
181 CFLAGS="$CFLAGS -falign-loops=16"
182 LDFLAGS="$LDFLAGS -lm -lmx"
183 if [ "$pic" = "no" ]; then
184 CFLAGS="$CFLAGS -mdynamic-no-pic"
189 LDFLAGS="$LDFLAGS -lm"
193 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
194 LDFLAGS="$LDFLAGS -lm"
198 LDFLAGS="$LDFLAGS -lm"
202 CFLAGS="$CFLAGS -I/usr/X11R6/include"
203 LDFLAGS="$LDFLAGS -lm"
207 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
208 LDFLAGS="$LDFLAGS -lm"
214 if cc_check "" -mno-cygwin; then
215 CFLAGS="$CFLAGS -mno-cygwin"
216 LDFLAGS="$LDFLAGS -mno-cygwin"
226 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
227 LDFLAGS="$LDFLAGS -lm"
231 die "Unknown system $host, edit the configure"
239 ASFLAGS="$ASFLAGS -O2"
240 if [[ "$asm" == yes && "$CFLAGS" != *-march* ]]; then
241 CFLAGS="$CFLAGS -march=i686"
243 if [ "$SYS" = MACOSX ]; then
244 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
245 elif [ "$SYS" = MINGW ]; then
246 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
248 ASFLAGS="$ASFLAGS -f elf"
254 if [ "$SYS" = MACOSX ];then
255 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
256 CFLAGS="$CFLAGS -arch x86_64"
257 LDFLAGS="$LDFLAGS -arch x86_64"
258 elif [ "$SYS" = MINGW ]; then
259 ASFLAGS="$ASFLAGS -f win32 -m amd64 -DPREFIX"
261 ASFLAGS="$ASFLAGS -f elf -m amd64"
268 ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
270 ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec -DHAVE_ALTIVEC_H"
274 if test "$(uname -m)" = "sun4u"; then
276 CFLAGS="$CFLAGS -mcpu=ultrasparc"
277 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
278 AS="${cross_prefix}as"
279 ASFLAGS="$ASFLAGS -xarch=v8plusa"
284 mips|mipsel|mips64|mips64el)
297 ARCH="$(echo $host_cpu | tr a-z A-Z)"
303 cc_check || die "No working C compiler found."
305 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" \) ] ; then
309 if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
310 if ! as_check "pinsrd xmm0, [esp], 0" ; then
311 VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
313 echo "Minimum version is yasm-0.6.1"
314 echo "If you really want to compile without asm, configure with --disable-asm."
317 if ! cc_check '' '' 'asm("pabsw %xmm0, %xmm0");' ; then
318 VER=`(as --version || echo no gnu as) 2>$DEVNULL | head -n 1`
320 echo "Minimum version is binutils-2.17"
321 echo "Your compiler can't handle inline SSSE3 asm."
322 echo "If you really want to compile without asm, configure with --disable-asm."
325 CFLAGS="$CFLAGS -DHAVE_MMX"
327 [ $asm = no ] && AS=""
328 [ "x$AS" = x ] && asm="no"
330 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
332 echo "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';" > conftest.c
333 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
334 grep -q BIGE conftest.o && CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
336 # autodetect options that weren't forced nor disabled
339 if test "$pthread" = "auto" ; then
346 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
348 libpthread="-lpthread"
349 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
351 libpthread="-lpthreadGC2"
352 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
354 libpthread="-lpthreadGC2 -lwsock32"
355 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
356 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
358 libpthread="-lpthreadGC2 -lws2_32"
359 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
363 cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
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 if cc_check "stdlib.h" -lvfw32 ; then
397 echo "#define AVIS_INPUT" >> config.h
398 LDFLAGS="$LDFLAGS -lvfw32"
399 elif cc_check "stdlib.h" -lavifil32 ; then
400 echo "#define AVIS_INPUT" >> config.h
401 LDFLAGS="$LDFLAGS -lavifil32"
407 if [ "$pic" = "yes" ] ; then
408 CFLAGS="$CFLAGS -fPIC"
409 ASFLAGS="$ASFLAGS -DPIC"
410 # resolve textrels in the x86 asm
411 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
414 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
415 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
416 LDFLAGS="$LDFLAGS -s"
419 if [ "$debug" = "yes" ]; then
420 CFLAGS="-O1 -g $CFLAGS"
422 CFLAGS="-O4 -ffast-math $CFLAGS"
425 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
426 echo "#define fseek fseeko" >> config.h
427 echo "#define ftell ftello" >> config.h
428 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
429 echo "#define fseek fseeko64" >> config.h
430 echo "#define ftell ftello64" >> config.h
435 # generate config files
437 cat > config.mak << EOF
439 exec_prefix=$exec_prefix
442 includedir=$includedir
447 ALTIVECFLAGS=$ALTIVECFLAGS
456 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
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
466 elif [ "$SYS" = "MACOSX" ]; then
467 echo "SOSUFFIX=dylib" >> config.mak
468 echo "SONAME=libx264.$API.dylib" >> config.mak
469 echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
470 elif [ "$SYS" = "SunOS" ]; then
471 echo "SOSUFFIX=so" >> config.mak
472 echo "SONAME=libx264.so.$API" >> config.mak
473 echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak
475 echo "SOSUFFIX=so" >> config.mak
476 echo "SONAME=libx264.so.$API" >> config.mak
477 echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
479 echo 'default: $(SONAME)' >> config.mak
484 pclibs="-L$libdir -lx264 $libpthread"
488 exec_prefix=$exec_prefix
490 includedir=$includedir
493 Description: H.264 (MPEG4 AVC) encoder library
494 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
496 Cflags: -I$includedir
500 echo "Platform: $ARCH"
503 echo "avis input: $avis_input"
504 echo "mp4 output: $mp4_output"
505 echo "pthread: $pthread"
509 echo "shared: $shared"
510 echo "visualize: $vis"
512 echo "You can run 'make' or 'make fprofiled' now."