Commit 5a37283d authored by Nikoli's avatar Nikoli Committed by Fiona 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.
parent 6c54a135
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment