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 " --enable-avis-input enables avisynth input (win32 only)"
11 echo " --enable-mp4-output enables mp4 output (using gpac)"
12 echo " --enable-gtk build GTK+ interface"
13 echo " --enable-pthread enables multithreaded encoding"
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"
28 cat > conftest.c << EOF
30 int main () { $3 return 0; }
32 $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
38 rm -f config.h config.mak x264.pc
41 exec_prefix='${prefix}'
42 bindir='${exec_prefix}/bin'
43 libdir='${exec_prefix}/lib'
44 includedir='${prefix}/include'
58 CFLAGS="-Wall -I. -D__X264__"
67 MACHINE="$(./config.guess)"
69 case "${MACHINE#*-*-}" in
72 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
76 CFLAGS="$CFLAGS -falign-loops=16"
77 LDFLAGS="$LDFLAGS -lm -lmx"
81 LDFLAGS="$LDFLAGS -lm"
85 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
86 LDFLAGS="$LDFLAGS -lm"
90 LDFLAGS="$LDFLAGS -lm"
94 CFLAGS="$CFLAGS -I/usr/X11R6/include"
95 LDFLAGS="$LDFLAGS -lm"
99 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
100 LDFLAGS="$LDFLAGS -lm"
104 CFLAGS="$CFLAGS -mno-cygwin"
105 LDFLAGS="$LDFLAGS -mno-cygwin"
116 CFLAGS="$CFLAGS -DHAVE_MALLOC_H"
117 LDFLAGS="$LDFLAGS -lm"
121 echo "Unknown system $MACHINE, edit the configure"
126 case "${MACHINE%%-*}" in
129 CFLAGS="$CFLAGS -DHAVE_MMXEXT -DHAVE_SSE2"
132 if [ "$SYS" = MACOSX ]; then
133 ASFLAGS="$ASFLAGS -f macho -DPREFIX"
134 elif [ "$SYS" = CYGWIN -o "$SYS" = MINGW ]; then
135 ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
136 elif [ "$SYS" = NETBSD ]; then
137 ASFLAGS="$ASFLAGS -f aoutb"
139 ASFLAGS="$ASFLAGS -f elf"
144 CFLAGS="$CFLAGS -DHAVE_MMXEXT -DHAVE_SSE2"
146 ASFLAGS="-f elf -m amd64"
152 CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4"
154 CFLAGS="$CFLAGS -maltivec -mabi=altivec"
158 if test "$(uname -m)" = "sun4u"; then
160 CFLAGS="$CFLAGS -mcpu=ultrasparc"
161 LDFLAGS="$LDFLAGS -mcpu=ultrasparc"
163 ASFLAGS="-xarch=v8plusa"
168 mips|mipsel|mips64|mips64el)
181 ARCH="$(echo ${MACHINE%%-*} | tr a-z A-Z)"
187 if [ $SYS = MACOSX -a $ARCH = X86 ]
189 # we want Apple's nasm from Xcode 2.4.1 or later
190 NASM_BUILD_REQUIRED=11
191 NASM_BUILD=`nasm -v|grep "Apple Computer"|sed 's/.*build \([0-9]*\).*/\1/'`
192 if [ $NASM_BUILD -lt $NASM_BUILD_REQUIRED ]
194 echo "Your version of 'nasm' is too old."
195 echo "Please install Xcode 2.4.1 or later."
200 CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
211 exec_prefix="$optarg"
225 --disable-avis-input)
231 --disable-mp4-output)
235 ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
238 CFLAGS="$CFLAGS ${opt#--extra-cflags=}"
241 LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
244 pthread="auto" # can't skip detection, since it differs by OS
254 LDFLAGS="$LDFLAGS -pg"
268 if [ $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" ] ; then
273 LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
274 CFLAGS="$CFLAGS -DVISUALIZE=1"
278 echo "Unknown option $opt, ignored"
283 # autodetect options that weren't forced nor disabled
286 if test "$pthread" = "auto" ; then
293 if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
295 libpthread="-lpthread"
296 elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
298 libpthread="-lpthreadGC2"
299 elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
301 libpthread="-lpthreadGC2 -lwsock32"\
302 CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
306 cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
310 if test "$pthread" = "yes" ; then
311 CFLAGS="$CFLAGS -DHAVE_PTHREAD"
312 LDFLAGS="$LDFLAGS $libpthread"
315 MP4_LDFLAGS="-lgpac_static"
316 if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
317 MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
319 if [ "$mp4_output" = "auto" ] ; then
321 cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
323 if [ "$mp4_output" = "yes" ] ; then
324 echo "#define MP4_OUTPUT" >> config.h
325 LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
328 if [ "$avis_input" = "auto" ] ; then
329 if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
335 if [ "$avis_input" = "yes" ] ; then
336 echo "#define AVIS_INPUT" >> config.h
337 LDFLAGS="$LDFLAGS -lvfw32"
340 if [ "$pic" = "yes" ] ; then
341 CFLAGS="$CFLAGS -fPIC"
342 ASFLAGS="$ASFLAGS -D__PIC__"
345 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
346 CFLAGS="$CFLAGS -s -fomit-frame-pointer"
347 LDFLAGS="$LDFLAGS -s"
350 if [ "$debug" = "yes" ]; then
351 CFLAGS="-O1 -g $CFLAGS"
353 CFLAGS="-O4 -ffast-math $CFLAGS"
356 if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
357 echo "#define fseek fseeko" >> config.h
358 echo "#define ftell ftello" >> config.h
359 elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
360 echo "#define fseek fseeko64" >> config.h
361 echo "#define ftell ftello64" >> config.h
364 # generate config files
366 cat > config.mak << EOF
368 exec_prefix=$exec_prefix
371 includedir=$includedir
382 HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
386 echo -n 'CONFIGURE_ARGS=' >> config.mak
388 echo -n " '$A'" >> config.mak
390 echo '' >> config.mak
392 cp config.mak gtk/config.mak
394 if [ "$shared" = "yes" ]; then
395 API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
396 echo "SONAME=libx264.so.$API" >> config.mak
397 echo 'default: $(SONAME)' >> config.mak
398 if [ "$gtk" = "yes" ]; then
399 echo "SONAMEGTK=libx264gtk.so.$API" >> gtk/config.mak
403 if [ "$gtk" = "yes" ]; then
404 echo 'default: libx264gtk.a' >> config.mak
405 echo 'install: install-gtk' >> config.mak
410 pclibs="-L$libdir -lx264 $libpthread"
414 exec_prefix=$exec_prefix
416 includedir=$includedir
419 Description: H.264 (MPEG4 AVC) encoder library
420 Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
422 Cflags: -I$includedir
426 echo "Platform: $ARCH"
428 echo "avis input: $avis_input"
429 echo "mp4 output: $mp4_output"
430 echo "pthread: $pthread"
435 echo "shared: $shared"
436 echo "visualize: $vis"
438 echo "You can run 'make' or 'make fprofiled' now."