]> git.sesse.net Git - x264/commitdiff
Add out-of-tree build support
authorOka Motofumi <chikuzen.mo@gmail.com>
Thu, 5 Jan 2012 22:23:50 +0000 (14:23 -0800)
committerFiona Glaser <fiona@x264.com>
Thu, 12 Jan 2012 20:07:56 +0000 (12:07 -0800)
Makefile
configure
version.sh

index c9505d3ea7798319bc5ed52b25d581088c1f55ac..0858cc76aa94b6e36e64c06808f3d1fba781da9b 100644 (file)
--- 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
@@ -229,7 +234,7 @@ install-lib-dev:
        install -d $(DESTDIR)$(includedir)
        install -d $(DESTDIR)$(libdir)
        install -d $(DESTDIR)$(libdir)/pkgconfig
-       install -m 644 x264.h $(DESTDIR)$(includedir)
+       install -m 644 $(SRCPATH)/x264.h $(DESTDIR)$(includedir)
        install -m 644 x264_config.h $(DESTDIR)$(includedir)
        install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
 
index 4e474ecce1d70d6d0a9ffe984e420175a4a18bdb..43f363ad996b1ebc6f55c7e4c723d5a84a66701d 100755 (executable)
--- 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
+
 echo
 echo "You can run 'make' or 'make fprofiled' now."
 
index 7f06c7c5f4f7b3205b6460581d5723d23c7514d9..9a415c64a61469ee19f07c035b9edb1cefe01ef6 100755 (executable)
@@ -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