#include <$1>
int main () { $3 return 0; }
EOF
- $CC $CFLAGS $LDFLAGS $2 conftest.c -o conftest 2>$DEVNULL
+ $CC conftest.c $CFLAGS $LDFLAGS $2 -o conftest 2>$DEVNULL
TMP="$?"
- rm -f conftest.c conftest*
+ rm -f conftest*
return $TMP
}
shared="no"
CC="${CC-gcc}"
-CFLAGS="-Wall -I. -D__X264__"
-LDFLAGS=""
+CFLAGS="$CFLAGS -Wall -I. -D__X264__"
+LDFLAGS="$LDFLAGS"
HAVE_GETOPT_LONG=1
AS="nasm"
EXE=""
+# check whether 'echo -n' works as expected, otherwise try printf
+if [ "x`echo -n houba`" = xhouba ]
+then
+ ECHON="echo -n"
+elif [ "x`printf houba`" = xhouba ]
+then
+ ECHON="printf"
+else
+ echo "Neither 'echo -n' nor 'printf' are working with your shell!"
+ exit 1
+fi
+
MACHINE="$(./config.guess)"
case "${MACHINE#*-*-}" in
;;
esac
+# check requirements
+
+if [ $SYS = MACOSX -a $ARCH = X86 ]
+then
+ # we want Apple's nasm from Xcode 2.4.1 or later
+ NASM_BUILD_REQUIRED=11
+ NASM_BUILD=`nasm -v|grep "Apple Computer"|sed 's/.*build \([0-9]*\).*/\1/'`
+ if [ $NASM_BUILD -lt $NASM_BUILD_REQUIRED ]
+ then
+ echo "Your version of 'nasm' is too old."
+ echo "Please install Xcode 2.4.1 or later."
+ exit 1
+ fi
+fi
+
CFLAGS="$CFLAGS -DARCH_$ARCH -DSYS_$SYS"
# parse options
LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}"
;;
--enable-pthread)
- pthread="yes"
+ pthread="auto" # can't skip detection, since it differs by OS
;;
--disable-pthread)
pthread="no"
# autodetect options that weren't forced nor disabled
+libpthread=""
if test "$pthread" = "auto" ; then
+ pthread="no"
case $SYS in
- MINGW|CYGWIN|BEOS)
+ BEOS)
pthread="yes"
;;
+ MINGW|CYGWIN)
+ if cc_check pthread.h -lpthread "pthread_create(0,0,0,0);" ; then
+ pthread="yes"
+ libpthread="-lpthread"
+ elif cc_check pthread.h -lpthreadGC2 "pthread_create(0,0,0,0);" ; then
+ pthread="yes"
+ libpthread="-lpthreadGC2"
+ elif cc_check pthread.h "-lpthreadGC2 -lwsock32 -DPTW32_STATIC_LIB" "pthread_create(0,0,0,0);" ; then
+ pthread="yes"
+ libpthread="-lpthreadGC2 -lwsock32"\
+ CFLAGS="$CFLAGS -DPTW32_STATIC_LIB"
+ fi
+ ;;
*)
- pthread="no"
- cc_check pthread.h -lpthread && pthread="yes"
+ cc_check pthread.h -lpthread && pthread="yes" && libpthread="-lpthread"
;;
esac
fi
if test "$pthread" = "yes" ; then
CFLAGS="$CFLAGS -DHAVE_PTHREAD"
- case $SYS in
- MINGW|CYGWIN|BEOS)
- ;;
- *) LDFLAGS="$LDFLAGS -lpthread"
- ;;
- esac
+ LDFLAGS="$LDFLAGS $libpthread"
fi
MP4_LDFLAGS="-lgpac_static"
VIS=$vis
HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG
DEVNULL=$DEVNULL
+ECHON=$ECHON
EOF
-echo -n 'CONFIGURE_ARGS=' >> config.mak
+$ECHON 'CONFIGURE_ARGS=' >> config.mak
for A in "$@" ; do
- echo -n " '$A'" >> config.mak
+ $ECHON " '$A'" >> config.mak
done
echo '' >> config.mak
./version.sh
-pclibs="-L$libdir -lx264"
-if test "$pthread" = "yes" ; then
- case $SYS in
- MINGW|CYGWIN|BEOS)
- ;;
- *) pclibs="$pclibs -lpthread"
- ;;
- esac
-fi
+pclibs="-L$libdir -lx264 $libpthread"
cat > x264.pc << EOF
prefix=$prefix