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."
102 --disable-avis-input)
108 --disable-mp4-output)
112 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
115 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
118 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
121 pthread="auto" # can't skip detection, since it differs by OS
131 LDFLAGS="$LDFLAGS -pg"
141 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
142 CFLAGS="$CFLAGS -DVISUALIZE=1"
146 host="${opt#--host=}"
149 echo "Unknown option $opt, ignored"
154 if [ "x$host" = x ]; then
155 host=`./config.guess`
157 # normalize a triplet into a quadruplet
158 host=`./config.sub $host`
161 host_cpu="${host%%-*}"
163 host_vendor="${host%%-*}"
169 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
173 CFLAGS="$CFLAGS -falign-loops=16"
174 LDFLAGS="$LDFLAGS -lm -lmx"
175 if [ "$pic" = "no" ]; then
176 CFLAGS="$CFLAGS -mdynamic-no-pic"
181 LDFLAGS="$LDFLAGS -lm"
185 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
186 LDFLAGS="$LDFLAGS -lm"
190 LDFLAGS="$LDFLAGS -lm"
194 CFLAGS="$CFLAGS -I/usr/X11R6/include"
195 LDFLAGS="$LDFLAGS -lm"
199 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
200 LDFLAGS="$LDFLAGS -lm"
204 CFLAGS="$CFLAGS -mno-cygwin"
205 LDFLAGS="$LDFLAGS -mno-cygwin"
216 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
217 LDFLAGS="$LDFLAGS -lm"
221 echo "Unknown system $host, edit the configure"
230 ASFLAGS="$ASFLAGS -O2"
231 if [ "$SYS" = MACOSX ]; then
232 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
233 elif [ "$SYS" = MINGW ]; then
234 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
236 ASFLAGS="$ASFLAGS -f elf"
242 if [ "$SYS" = MACOSX ];then
243 ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
244 CFLAGS="$CFLAGS -arch x86_64"
245 LDFLAGS="$LDFLAGS -arch x86_64"
247 ASFLAGS="-f elf -m amd64"
254 ALTIVECFLAGS="$ALTIVECFLAGS -faltivec -fastf -mcpu=G4"
256 ALTIVECFLAGS="$ALTIVECFLAGS -maltivec -mabi=altivec -DHAVE_ALTIVEC_H"
260 if test "$(uname -m)" = "sun4u"; then
262 CFLAGS="$CFLAGS -mcpu=ultrasparc"
263 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
265 ASFLAGS="$ASFLAGS -xarch=v8plusa"
270 mips|mipsel|mips64|mips64el)
283 ARCH="$(echo $host_cpu | tr a-z A-Z)"
289 if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" \) ] ; then
293 if [ $asm = yes -a \( $ARCH = X86 -o $ARCH = X86_64 \) ] ; then
294 if as_check "pinsrd xmm0, [esp], 0" ; then
295 CFLAGS="$CFLAGS -DHAVE_MMX"
297 VER=`($AS --version || echo no assembler) 2>$DEVNULL | head -n 1`
299 echo "Minimum version is yasm-0.6.1"
300 echo "If you really want to compile without asm, configure with --disable-asm."
304 [ $asm = no ] && AS=""
305 [ "x$AS" = x ] && asm="no"
307 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
309 echo "unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';" > conftest.c
310 $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed"
311 grep -q BIGE conftest.o && CFLAGS="$CFLAGS -DWORDS_BIGENDIAN"
313 # autodetect options that weren't forced nor disabled
316 if test "$pthread" = "auto" ; then
323 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
325 libpthread="-lpthread"
326 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
328 libpthread="-lpthreadGC2"
329 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
331 libpthread="-lpthreadGC2 -lwsock32"
332 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
336 cc_check pthread.h -pthread && pthread="yes" && libpthread="-pthread"
339 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
343 if test "$pthread" = "yes" ; then
344 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
345 LDFLAGS="$LDFLAGS $libpthread"
348 MP4_LDFLAGS="-lgpac_static"
349 if [ $SYS = MINGW ]; then
350 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
352 if [ "$mp4_output" = "auto" ] ; then
354 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
356 if [ "$mp4_output" = "yes" ] ; then
357 echo "#define MP4_OUTPUT" >> config.h
358 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
361 if [ "$avis_input" = "auto" ] ; then
362 if [ $SYS = MINGW ]; then
368 if [ "$avis_input" = "yes" ] ; then
369 echo "#define AVIS_INPUT" >> config.h
370 LDFLAGS="$LDFLAGS -lvfw32"
373 if [ "$pic" = "yes" ] ; then
374 CFLAGS="$CFLAGS -fPIC"
375 ASFLAGS="$ASFLAGS -DPIC"
376 # resolve textrels in the x86 asm
377 cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
380 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
381 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
382 LDFLAGS="$LDFLAGS -s"
385 if [ "$debug" = "yes" ]; then
386 CFLAGS="-O1 -g $CFLAGS"
388 CFLAGS="-O4 -ffast-math $CFLAGS"
391 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
392 echo "#define fseek fseeko" >> config.h
393 echo "#define ftell ftello" >> config.h
394 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
395 echo "#define fseek fseeko64" >> config.h
396 echo "#define ftell ftello64" >> config.h
401 # generate config files
403 cat > config.mak << EOF
405 exec_prefix=$exec_prefix
408 includedir=$includedir
413 ALTIVECFLAGS=$ALTIVECFLAGS
419 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
423 if [ "$shared" = "yes" ]; then
424 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
425 if [ "$SYS" = "MINGW" ]; then
426 echo "SONAME=libx264-$API.dll" >> config.mak
427 echo 'IMPLIBNAME=libx264.dll.a' >> config.mak
428 echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak
429 elif [ "$SYS" = "MACOSX" ]; then
430 echo "SOSUFFIX=dylib" >> config.mak
431 echo "SONAME=libx264.$API.dylib" >> config.mak
432 echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak
433 elif [ "$SYS" = "SunOS" ]; then
434 echo "SOSUFFIX=so" >> config.mak
435 echo "SONAME=libx264.so.$API" >> config.mak
436 echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak
438 echo "SOSUFFIX=so" >> config.mak
439 echo "SONAME=libx264.so.$API" >> config.mak
440 echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak
442 echo 'default: $(SONAME)' >> config.mak
447 pclibs="-L$libdir -lx264 $libpthread"
451 exec_prefix=$exec_prefix
453 includedir=$includedir
456 Description: H.264 (MPEG4 AVC) encoder library
457 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
459 Cflags: -I$includedir
463 echo "Platform: $ARCH"
466 echo "avis input: $avis_input"
467 echo "mp4 output: $mp4_output"
468 echo "pthread: $pthread"
472 echo "shared: $shared"
473 echo "visualize: $vis"
475 echo "You can run 'make' or 'make fprofiled' now."