[x264-devel] [PATCH] Add out-of-tree build support
Derek Buitenhuis
derek.buitenhuis at gmail.com
Thu Dec 29 23:56:03 CET 2011
From: Oka Motofumi <chikuzen.mo at gmail.com>
---
Makefile | 9 +++++++--
configure | 18 +++++++++++++-----
version.sh | 1 +
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index c9505d3..6d8e00b 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,11 @@
include config.mak
+vpath %.c $(SRCPATH)
+vpath %.h $(SRCPATH)
+vpath %.S $(SRCPATH)
+vpath %.asm $(SRCPATH)
+
all: default
SRCS = common/mc.c common/predict.c common/pixel.c common/macroblock.c \
@@ -86,7 +91,7 @@ ASFLAGS += -DARCH_X86_64
endif
ifdef ARCH_X86
-ASFLAGS += -Icommon/x86/
+ASFLAGS += -I$(SRCPATH)/common/x86/
SRCS += common/x86/mc-c.c common/x86/predict-c.c
OBJASM = $(ASMSRC:%.asm=%.o)
$(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
@@ -177,7 +182,7 @@ $(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK): .depend
.depend: config.mak
@rm -f .depend
- @$(foreach SRC, $(SRCS) $(SRCCLI) $(SRCSO), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:%.c=%.o) $(DEPMM) 1>> .depend;)
+ @$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
config.mak:
./configure
diff --git a/configure b/configure
index 4e474ec..1e6ff32 100755
--- a/configure
+++ b/configure
@@ -212,6 +212,10 @@ die() {
rm -f x264_config.h config.h config.mak config.log x264.pc x264.def conftest*
+SRCPATH="$(cd $(dirname $0); pwd)"
+[ "$SRCPATH" = "$(pwd)" ] && SRCPATH=.
+[ -n "$(echo $SRCPATH | grep ' ')" ] && die "Out of tree builds are impossible with whitespace in source path."
+
prefix='/usr/local'
exec_prefix='${prefix}'
bindir='${exec_prefix}/bin'
@@ -241,7 +245,7 @@ bit_depth="8"
chroma_format="all"
compiler="GNU"
-CFLAGS="$CFLAGS -Wall -I."
+CFLAGS="$CFLAGS -Wall -I. -I\$(SRCPATH)"
LDFLAGS="$LDFLAGS"
LDFLAGSCLI="$LDFLAGSCLI"
ASFLAGS="$ASFLAGS"
@@ -380,10 +384,10 @@ RANLIB="${RANLIB-${cross_prefix}ranlib}"
STRIP="${STRIP-${cross_prefix}strip}"
if [ "x$host" = x ]; then
- host=`./config.guess`
+ host=`${SRCPATH}/config.guess`
fi
# normalize a triplet into a quadruplet
-host=`./config.sub $host`
+host=`${SRCPATH}/config.sub $host`
# split $host
host_cpu="${host%%-*}"
@@ -997,6 +1001,7 @@ EOF
# generate config files
cat > config.mak << EOF
+SRCPATH=$SRCPATH
prefix=$prefix
exec_prefix=$exec_prefix
bindir=$bindir
@@ -1036,7 +1041,7 @@ if [ "$cli" = "yes" ]; then
fi
if [ "$shared" = "yes" ]; then
- API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
+ API=$(grep '#define X264_BUILD' < ${SRCPATH}/x264.h | cut -f 3 -d ' ')
if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
echo "SONAME=libx264-$API.dll" >> config.mak
if [ $compiler = ICL ]; then
@@ -1087,7 +1092,7 @@ fi
echo "LDFLAGSCLI = $LDFLAGSCLI" >> config.mak
echo "CLI_LIBX264 = $CLI_LIBX264" >> config.mak
-./version.sh >> x264_config.h
+${SRCPATH}/version.sh "${SRCPATH}" >> x264_config.h
pclibs="-L$libdir -lx264 $libpthread"
@@ -1139,6 +1144,9 @@ cat conftest.log >> config.log
cat conftest.log
rm conftest.log
+[ "$SRCPATH" != "." ] && ln -sf ${SRCPATH}/Makefile ./Makefile
+mkdir -p common/{arm,ppc,sparc,x86} encoder extras filters/video input output tools 2> $DEVNULL
+
echo
echo "You can run 'make' or 'make fprofiled' now."
diff --git a/version.sh b/version.sh
index 7f06c7c..9a415c6 100755
--- a/version.sh
+++ b/version.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+[ -n "$1" ] && cd $1
git rev-list HEAD | sort > config.git-hash
LOCALVER=`wc -l config.git-hash | awk '{print $1}'`
if [ $LOCALVER \> 1 ] ; then
--
1.7.7.3
More information about the x264-devel
mailing list