[x264-devel] Improve build system capabilities

Nikoli git at videolan.org
Thu May 12 08:39:12 CEST 2011


x264 | branch: master | Nikoli <nikoli at lavabit.com> | Fri Apr 29 14:19:22 2011 +0400| [c1e60b9032196d204db8dce77051360e403a1d2f] | committer: Jason Garrett-Glaser

Improve build system capabilities
Make static lib and CLI optional.
Support linking CLI to system libx264.
Don't strip by default, to match GNU packaging guidelines.

> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=c1e60b9032196d204db8dce77051360e403a1d2f
---

 Makefile  |   24 +++++++++++++-----
 configure |   77 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 83 insertions(+), 18 deletions(-)

diff --git a/Makefile b/Makefile
index 67301fc..5831091 100644
--- a/Makefile
+++ b/Makefile
@@ -135,9 +135,13 @@ OBJCLI = $(SRCCLI:%.c=%.o)
 OBJSO = $(SRCSO:%.c=%.o)
 DEP  = depend
 
-.PHONY: all default fprofiled clean distclean install uninstall dox test testclean
+.PHONY: all default fprofiled clean distclean install uninstall dox test testclean lib-static lib-shared cli install-lib-dev install-lib-static install-lib-shared install-cli
 
-default: $(DEP) x264$(EXE)
+default: $(DEP)
+
+cli: x264$(EXE)
+lib-static: $(LIBX264)
+lib-shared: $(SONAME)
 
 $(LIBX264): .depend $(OBJS) $(OBJASM)
 	$(AR)$@ $(OBJS) $(OBJASM)
@@ -146,8 +150,8 @@ $(LIBX264): .depend $(OBJS) $(OBJASM)
 $(SONAME): .depend $(OBJS) $(OBJASM) $(OBJSO)
 	$(LD)$@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
 
-x264$(EXE): $(OBJCLI) $(LIBX264)
-	$(LD)$@ $+ $(LDFLAGSCLI) $(LDFLAGS)
+x264$(EXE): .depend $(OBJCLI) $(CLI_LIBX264)
+	$(LD)$@ $(OBJCLI) $(CLI_LIBX264) $(LDFLAGSCLI) $(LDFLAGS)
 
 checkasm: tools/checkasm.o $(LIBX264)
 	$(LD)$@ $+ $(LDFLAGS)
@@ -207,17 +211,23 @@ distclean: clean
 	rm -f config.mak x264_config.h config.h config.log x264.pc x264.def
 	rm -rf test/
 
-install: x264$(EXE) $(SONAME)
+install-cli: cli
 	install -d $(DESTDIR)$(bindir)
+	install x264$(EXE) $(DESTDIR)$(bindir)
+
+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 x264_config.h $(DESTDIR)$(includedir)
-	install -m 644 $(LIBX264) $(DESTDIR)$(libdir)
 	install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
-	install x264$(EXE) $(DESTDIR)$(bindir)
+
+install-lib-static: lib-static install-lib-dev
+	install -m 644 $(LIBX264) $(DESTDIR)$(libdir)
 	$(if $(RANLIB), $(RANLIB) $(DESTDIR)$(libdir)/$(LIBX264))
+
+install-lib-shared: lib-shared install-lib-dev
 ifeq ($(SYS),WINDOWS)
 	$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(bindir))
 else
diff --git a/configure b/configure
index d5a93e7..d164414 100755
--- a/configure
+++ b/configure
@@ -7,6 +7,10 @@ Usage: ./configure [options]
 available options:
 
   --help                   print this message
+  --disable-cli            disables cli
+  --system-libx264         use system libx264 instead of internal
+  --enable-shared          build shared library
+  --enable-static          build static library
   --disable-avs            disables avisynth support (windows only)
   --disable-lavf           disables libavformat support
   --disable-ffms           disables ffmpegsource support
@@ -17,11 +21,11 @@ available options:
   --disable-swscale        disables swscale support
   --disable-asm            disables platform-specific assembly optimizations
   --disable-interlaced     disables interlaced encoding support
-  --enable-debug           adds -g, doesn't strip
-  --enable-gprof           adds -pg, doesn't strip
+  --enable-debug           adds -g
+  --enable-gprof           adds -pg
+  --enable-strip           adds -s
   --enable-visualize       enables visualization (X11 only)
   --enable-pic             build position-independent code
-  --enable-shared          build shared library
   --bit-depth=BIT_DEPTH    sets output bit depth (8-10), default 8
   --extra-asflags=EASFLAGS add EASFLAGS to ASFLAGS
   --extra-cflags=ECFLAGS   add ECFLAGS to CFLAGS
@@ -198,6 +202,10 @@ libdir='${exec_prefix}/lib'
 includedir='${prefix}/include'
 DEVNULL='/dev/null'
 
+cli="yes"
+cli_libx264="internal"
+shared="no"
+static="no"
 avs="auto"
 lavf="auto"
 ffms="auto"
@@ -209,9 +217,9 @@ asm="auto"
 interlaced="yes"
 debug="no"
 gprof="no"
+strip="no"
 pic="no"
 vis="no"
-shared="no"
 bit_depth="8"
 compiler="GNU"
 
@@ -247,6 +255,18 @@ for opt do
         --includedir=*)
             includedir="$optarg"
             ;;
+        --disable-cli)
+            cli="no"
+            ;;
+        --system-libx264)
+            cli_libx264="system"
+            ;;
+        --enable-shared)
+            shared="yes"
+            ;;
+        --enable-static)
+            static="yes"
+            ;;
         --disable-asm)
             asm="no"
             ;;
@@ -294,12 +314,12 @@ for opt do
             LDFLAGS="$LDFLAGS -pg"
             gprof="yes"
             ;;
+        --enable-strip)
+            strip="yes"
+            ;;
         --enable-pic)
             pic="yes"
             ;;
-        --enable-shared)
-            shared="yes"
-            ;;
         --enable-visualize)
             vis="yes"
             ;;
@@ -327,6 +347,8 @@ for opt do
     esac
 done
 
+[ "$cli" = "no" -a "$shared" = "no" -a "$static" = "no" ] && die "Nothing to build. Enable cli, shared or static."
+
 CC="${CC-${cross_prefix}gcc}"
 AR="${AR-${cross_prefix}ar}"
 RANLIB="${RANLIB-${cross_prefix}ranlib}"
@@ -826,7 +848,11 @@ if [ "$pic" = "yes" ] ; then
 fi
 
 if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then
-    CFLAGS="$CFLAGS -s -fomit-frame-pointer"
+    CFLAGS="$CFLAGS -fomit-frame-pointer"
+fi
+
+if [ "$strip" = "yes" ]; then
+    CFLAGS="$CFLAGS -s"
     LDFLAGS="$LDFLAGS -s"
 fi
 
@@ -945,7 +971,6 @@ DEPMM=$DEPMM
 DEPMT=$DEPMT
 LD=$LD
 LDFLAGS=$LDFLAGS
-LDFLAGSCLI=$LDFLAGSCLI
 LIBX264=$LIBX264
 AR=$AR
 RANLIB=$RANLIB
@@ -966,6 +991,11 @@ if [ $compiler = ICL ]; then
     echo '	$(CC) $(CFLAGS) -c -Fo$@ $<' >> config.mak
 fi
 
+if [ "$cli" = "yes" ]; then
+    echo 'default: cli' >> config.mak
+    echo 'install: install-cli' >> config.mak
+fi
+
 if [ "$shared" = "yes" ]; then
     API=$(grep '#define X264_BUILD' < x264.h | cut -f 3 -d ' ')
     if [ "$SYS" = "WINDOWS" -o "$SYS" = "CYGWIN" ]; then
@@ -994,8 +1024,29 @@ if [ "$shared" = "yes" ]; then
         echo "SONAME=libx264.so.$API" >> config.mak
         echo 'SOFLAGS=-shared -Wl,-soname,$(SONAME)' >> config.mak
     fi
-    echo 'default: $(SONAME)' >> config.mak
+    echo 'default: lib-shared' >> config.mak
+    echo 'install: install-lib-shared' >> config.mak
+fi
+
+if [ "$static" = "yes" ]; then
+    echo 'default: lib-static' >> config.mak
+    echo 'install: install-lib-static' >> config.mak
+fi
+
+if [ "$cli_libx264" = "system" ] ; then
+    if [ "$shared" = "yes" ]; then
+        CLI_LIBX264='$(SONAME)'
+    elif ${cross_prefix}pkg-config --exists x264 2>/dev/null; then
+        LDFLAGSCLI="$LDFLAGSCLI $(${cross_prefix}pkg-config --libs x264)"
+        CLI_LIBX264=
+    else
+        die "Can not find system libx264"
+    fi
+else
+    CLI_LIBX264='$(LIBX264)'
 fi
+echo "LDFLAGSCLI = $LDFLAGSCLI" >> config.mak
+echo "CLI_LIBX264 = $CLI_LIBX264" >> config.mak
 
 ./version.sh >> config.h
 
@@ -1022,6 +1073,10 @@ gpl_filters=""
 cat > conftest.log <<EOF
 Platform:   $ARCH
 System:     $SYS
+cli:        $cli
+libx264:    $cli_libx264
+shared:     $shared
+static:     $static
 asm:        $asm
 interlaced: $interlaced
 avs:        $avs
@@ -1033,8 +1088,8 @@ thread:     $thread
 filters:    $filters
 debug:      $debug
 gprof:      $gprof
+strip:      $strip
 PIC:        $pic
-shared:     $shared
 visualize:  $vis
 bit depth:  $bit_depth
 EOF



More information about the x264-devel mailing list