echo " --enable-debug adds -g, doesn't strip"
echo " --enable-gprof adds -pg, doesn't strip"
echo " --enable-visualize enables visualization (X11 only)"
+echo " --enable-pic build position-independent code"
+echo " --enable-shared build libx264.so"
echo " --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS"
echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS"
echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS"
exit 1
fi
+cc_check() {
+ rm -f conftest*
+ cat > conftest.c << EOF
+#include <$1>
+int main () { $3 return 0; }
+EOF
+ $CC $CFLAGS $LDFLAGS $2 conftest.c -o conftest 2>$DEVNULL
+ TMP="$?"
+ rm -f conftest.c conftest*
+ return $TMP
+}
+
+rm -f config.h config.mak x264.pc
+
prefix='/usr/local'
exec_prefix='${prefix}'
bindir='${exec_prefix}/bin'
libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
+DEVNULL='/dev/null'
-avis_input="no"
-mp4_output="no"
-pthread="no"
+avis_input="auto"
+mp4_output="auto"
+pthread="auto"
debug="no"
gprof="no"
+pic="no"
vfw="no"
vis="no"
+shared="no"
CC="gcc"
CFLAGS="-Wall -I. -O4 -ffast-math -D__X264__"
HAVE_GETOPT_LONG=1
AS="nasm"
-ASFLAGS="-f elf"
+ASFLAGS=""
EXE=""
SYS="CYGWIN"
CFLAGS="$CFLAGS -mno-cygwin"
LDFLAGS="$LDFLAGS -mno-cygwin"
- ASFLAGS="-f win32 -DPREFIX"
EXE=".exe"
+ DEVNULL="NUL"
;;
MINGW*)
SYS="MINGW"
- ASFLAGS="-f win32 -DPREFIX"
EXE=".exe"
+ DEVNULL="NUL"
;;
SunOS)
SYS="SunOS"
i386|i486|i586|i686|BePC)
ARCH="X86"
CFLAGS="$CFLAGS -DHAVE_MMXEXT -DHAVE_SSE2"
+ AS="nasm"
+ ASFLAGS="-O2"
+ if [ "$SYS" = MACOSX ]; then
+ ASFLAGS="$ASFLAGS -f macho -DPREFIX"
+ elif [ "$SYS" = CYGWIN -o "$SYS" = MINGW ]; then
+ ASFLAGS="$ASFLAGS -f win32 -DPREFIX"
+ elif [ "$SYS" = NETBSD ]; then
+ ASFLAGS="$ASFLAGS -f aoutb"
+ else
+ ASFLAGS="$ASFLAGS -f elf"
+ fi
;;
x86_64)
ARCH="X86_64"
m68k)
ARCH="M68K"
;;
- arm)
+ arm|armv5tel)
ARCH="ARM"
;;
s390|s390x)
includedir="$optarg"
;;
--enable-avis-input)
- if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
- CFLAGS="$CFLAGS -DAVIS_INPUT"
- LDFLAGS="$LDFLAGS -lvfw32"
- avis_input="yes"
- fi
+ avis_input="yes"
+ ;;
+ --disable-avis-input)
+ avis_input="no"
;;
--enable-mp4-output)
- CFLAGS="$CFLAGS -DMP4_OUTPUT"
- LDFLAGS="$LDFLAGS -lgpac_static"
- if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
- LDFLAGS="$LDFLAGS -lwinmm"
- fi
mp4_output="yes"
;;
+ --disable-mp4-output)
+ mp4_output="no"
+ ;;
--extra-asflags=*)
ASFLAGS="$ASFLAGS ${opt#--extra-asflags=}"
;;
VFW_LDFLAGS="${opt#--extra-ldflags=}"
;;
--enable-pthread)
- CFLAGS="$CFLAGS -DHAVE_PTHREAD=1"
pthread="yes"
- case $SYS in
- MINGW|CYGWIN|BEOS)
- ;;
- *)
- LDFLAGS="$LDFLAGS -lpthread"
- ;;
- esac
+ ;;
+ --disable-pthread)
+ pthread="no"
;;
--enable-debug)
CFLAGS="$CFLAGS -g"
LDFLAGS="$LDFLAGS -pg"
gprof="yes"
;;
+ --enable-pic)
+ pic="yes"
+ ;;
--enable-vfw)
vfw="yes"
;;
+ --disable-vfw)
+ vfw="no"
+ ;;
+ --enable-shared)
+ shared="yes"
+ if [ $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" ] ; then
+ pic="yes"
+ fi
+ ;;
--enable-visualize)
LDFLAGS="$LDFLAGS -L/usr/X11R6/lib -lX11"
CFLAGS="$CFLAGS -DVISUALIZE=1"
esac
done
-VFWFLAGS=
+# autodetect options that weren't forced nor disabled
+
+if test "$pthread" = "auto" ; then
+ case $SYS in
+ MINGW|CYGWIN|BEOS)
+ pthread="yes"
+ ;;
+ *)
+ pthread="no"
+ cc_check pthread.h -lpthread && pthread="yes"
+ ;;
+ esac
+fi
+if test "$pthread" = "yes" ; then
+ CFLAGS="$CFLAGS -DHAVE_PTHREAD"
+ case $SYS in
+ MINGW|CYGWIN|BEOS)
+ ;;
+ *) LDFLAGS="$LDFLAGS -lpthread"
+ ;;
+ esac
+fi
+
+MP4_LDFLAGS="-lgpac_static"
+if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
+ MP4_LDFLAGS="$MP4_LDFLAGS -lwinmm"
+fi
+if [ "$mp4_output" = "auto" ] ; then
+ mp4_output="no"
+ cc_check gpac/isomedia.h "$MP4_LDFLAGS" && mp4_output="yes"
+fi
+if [ "$mp4_output" = "yes" ] ; then
+ echo "#define MP4_OUTPUT" >> config.h
+ LDFLAGS="$LDFLAGS $MP4_LDFLAGS"
+fi
+
+if [ "$avis_input" = "auto" ] ; then
+ if [ $SYS = CYGWIN -o $SYS = MINGW ]; then
+ avis_input="yes"
+ else
+ avis_input="no";
+ fi
+fi
+if [ "$avis_input" = "yes" ] ; then
+ echo "#define AVIS_INPUT" >> config.h
+ LDFLAGS="$LDFLAGS -lvfw32"
+fi
+
+if [ "$pic" = "yes" ] ; then
+ CFLAGS="$CFLAGS -fPIC"
+ ASFLAGS="$ASFLAGS -D__PIC__"
+fi
+
if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
CFLAGS="$CFLAGS -s -fomit-frame-pointer"
LDFLAGS="$LDFLAGS -s"
VFW_LDFLAGS="$VFW_LDFLAGS -s"
fi
-rm -f config.mak
+if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
+ echo "#define fseek fseeko" >> config.h
+ echo "#define ftell ftello" >> config.h
+elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
+ echo "#define fseek fseeko64" >> config.h
+ echo "#define ftell ftello64" >> config.h
+fi
+
+# generate config files
+
cat > config.mak << EOF
prefix=$prefix
exec_prefix=$exec_prefix
EXE=$EXE
VIS=$vis
HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
+DEVNULL=$DEVNULL
+CONFIGURE_ARGS=$@
EOF
if [ "$vfw" = "yes" ]; then
echo "default: x264vfw.dll" >> config.mak
fi
-# x264.pc file creation
-rm -f x264.pc
+if [ "$shared" = "yes" ]; then
+ API=`grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' '`
+ echo "SONAME=libx264.so.$API" >> config.mak
+ echo 'default: $(SONAME)' >> config.mak
+fi
+
+./version.sh
+
cat > x264.pc << EOF
prefix=$prefix
exec_prefix=$exec_prefix
Name: x264
Description: H.264 (MPEG4 AVC) encoder library
-Version:
+Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//')
Libs: -L$libdir -lx264
Cflags: -I$includedir
EOF
echo "vfw: $vfw"
echo "debug: $debug"
echo "gprof: $gprof"
+echo "PIC: $pic"
+echo "shared: $shared"
echo "visualize: $vis"
echo
-echo "You can run 'make' now."
+echo "You can run 'make' or 'make fprofiled' now."