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
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'
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"
212 CFLAGS="$CFLAGS -mno-cygwin"
213 LDFLAGS="$LDFLAGS -mno-cygwin"
224 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
225 LDFLAGS="$LDFLAGS -lm"
229 echo "Unknown system $host, edit the configure"
238 ASFLAGS="$ASFLAGS -O2"
239 if [ "$SYS" = MACOSX ]; then
240 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
241 elif [ "$SYS" = MINGW ]; then
242 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
244 ASFLAGS="$ASFLAGS -f elf"
250 if [ "$SYS" = MACOSX ];then
251 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
252 CFLAGS="$CFLAGS -arch x86_64"
253 LDFLAGS="$LDFLAGS -arch x86_64"
254 elif [ "$SYS" = MINGW ]; then
255 ASFLAGS="$ASFLAGS -f win32 -m amd64 -DPREFIX"
257 ASFLAGS="$ASFLAGS -f elf -m amd64"
264 ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
266 ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec -DHAVE_ALTIVEC_H"
270 if test "$(uname -m)" = "sun4u"; then
272 CFLAGS="$CFLAGS -mcpu=ultrasparc"
273 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
274 AS="${cross_prefix}as"
275 ASFLAGS="$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."
314 [ $asm = no ] && AS=""
315 [ "x$AS" = x ] && asm="no"
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"
343 elif cc_check pthread.h "-lpthreadGC2 -lws2_32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
345 libpthread="-lpthreadGC2 -lws2_32"
346 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
350 cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
353 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
357 if test "$pthread" = "yes" ; then
358 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
359 LDFLAGS="$LDFLAGS $libpthread"
362 MP4_LDFLAGS="-lgpac_static"
363 if [ $SYS = MINGW ]; then
364 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
366 if [ "$mp4_output" = "auto" ] ; then
368 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
370 if [ "$mp4_output" = "yes" ] ; then
371 echo "#define MP4_OUTPUT" >> config.h
372 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
375 if [ "$avis_input" = "auto" ] ; then
376 if [ $SYS = MINGW ]; then
382 if [ "$avis_input" = "yes" ] ; then
383 if cc_check "stdlib.h" -lvfw32 ; then
384 echo "#define AVIS_INPUT" >> config.h
385 LDFLAGS="$LDFLAGS -lvfw32"
386 elif cc_check "stdlib.h" -lavifil32 ; then
387 echo "#define AVIS_INPUT" >> config.h
388 LDFLAGS="$LDFLAGS -lavifil32"
394 if [ "$pic" = "yes" ] ; then
395 CFLAGS="$CFLAGS -fPIC"
396 ASFLAGS="$ASFLAGS -DPIC"
397 # resolve textrels in the x86 asm
398 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
401 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
402 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
403 LDFLAGS="$LDFLAGS -s"
406 if [ "$debug" = "yes" ]; then
407 CFLAGS="-O1 -g $CFLAGS"
409 CFLAGS="-O4 -ffast-math $CFLAGS"
412 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
413 echo "#define fseek fseeko" >> config.h
414 echo "#define ftell ftello" >> config.h
415 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
416 echo "#define fseek fseeko64" >> config.h
417 echo "#define ftell ftello64" >> config.h
422 # generate config files
424 cat > config.mak << EOF
426 exec_prefix=$exec_prefix
429 includedir=$includedir
434 ALTIVECFLAGS=$ALTIVECFLAGS
443 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
447 if [ "$shared" = "yes" ]; then
448 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
449 if [ "$SYS" = "MINGW" ]; then
450 echo "SONAME=libx264-$API.dll" >> config.mak
451 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
452 echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
453 elif [ "$SYS" = "MACOSX" ]; then
454 echo "SOSUFFIX=dylib" >> config.mak
455 echo "SONAME=libx264.$API.dylib" >> config.mak
456 echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
457 elif [ "$SYS" = "SunOS" ]; then
458 echo "SOSUFFIX=so" >> config.mak
459 echo "SONAME=libx264.so.$API" >> config.mak
460 echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak
462 echo "SOSUFFIX=so" >> config.mak
463 echo "SONAME=libx264.so.$API" >> config.mak
464 echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
466 echo 'default: $(SONAME)' >> config.mak
471 pclibs="-L$libdir -lx264 $libpthread"
475 exec_prefix=$exec_prefix
477 includedir=$includedir
480 Description: H.264 (MPEG4 AVC) encoder library
481 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
483 Cflags: -I$includedir
487 echo "Platform: $ARCH"
490 echo "avis input: $avis_input"
491 echo "mp4 output: $mp4_output"
492 echo "pthread: $pthread"
496 echo "shared: $shared"
497 echo "visualize: $vis"
499 echo "You can run 'make' or 'make fprofiled' now."