From edb434873238876790f6a17bb65490cc29a1d176 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 17 Dec 2016 20:01:07 +0100 Subject: [PATCH 1/2] build: Store library version numbers in .version files This moves work from the configure to the Make stage where it can be parallelized and ensures that shared libraries are built with the right version number in the filename. --- Makefile | 2 +- avbuild/common.mak | 2 +- avbuild/library.mak | 5 +++++ avbuild/libversion.sh | 15 +++++++++++++++ configure | 13 ------------- 5 files changed, 22 insertions(+), 15 deletions(-) create mode 100755 avbuild/libversion.sh diff --git a/Makefile b/Makefile index c9fa162d8d..6036e447db 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC) %.h.c: $(Q)echo '#include "$*.h"' >$@ -%.c %.h %.ver: TAG = GEN +%.c %.h %.ver %.version: TAG = GEN AVPROGS-$(CONFIG_AVCONV) += avconv AVPROGS-$(CONFIG_AVPLAY) += avplay diff --git a/avbuild/common.mak b/avbuild/common.mak index 96762949cc..236380effc 100644 --- a/avbuild/common.mak +++ b/avbuild/common.mak @@ -49,7 +49,7 @@ $(TOOLOBJS): | tools OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(TESTOBJS)) -CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver +CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.version DISTCLEANSUFFIXES = *.pc LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a diff --git a/avbuild/library.mak b/avbuild/library.mak index 9215a93a2c..45152bebe8 100644 --- a/avbuild/library.mak +++ b/avbuild/library.mak @@ -1,5 +1,7 @@ include $(SRC_PATH)/avbuild/common.mak +-include $(SUBDIR)lib$(NAME).version + LIBVERSION := $(lib$(NAME)_VERSION) LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR) LIBMINOR := $(lib$(NAME)_VERSION_MINOR) @@ -30,6 +32,9 @@ $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME) $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS) +$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h | $(SUBDIR) + $$(M) $$(SRC_PATH)/avbuild/libversion.sh $(NAME) $$< > $$@ + $(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ diff --git a/avbuild/libversion.sh b/avbuild/libversion.sh new file mode 100755 index 0000000000..30046b1d25 --- /dev/null +++ b/avbuild/libversion.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +toupper(){ + echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ +} + +name=lib$1 +ucname=$(toupper ${name}) +file=$2 + +eval $(awk "/#define ${ucname}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file") +eval ${ucname}_VERSION=\$${ucname}_VERSION_MAJOR.\$${ucname}_VERSION_MINOR.\$${ucname}_VERSION_MICRO +eval echo "${name}_VERSION=\$${ucname}_VERSION" +eval echo "${name}_VERSION_MAJOR=\$${ucname}_VERSION_MAJOR" +eval echo "${name}_VERSION_MINOR=\$${ucname}_VERSION_MINOR" diff --git a/configure b/configure index bcc5f6ec72..2671b5a02b 100755 --- a/configure +++ b/configure @@ -5318,19 +5318,6 @@ VERSION_SCRIPT_POSTPROCESS_CMD=${VERSION_SCRIPT_POSTPROCESS_CMD} SAMPLES:=${samples:-\$(LIBAV_SAMPLES)} EOF -get_version(){ - lcname=lib${1} - name=$(toupper $lcname) - file=$source_path/$lcname/version.h - eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file") - eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO - eval echo "${lcname}_VERSION=\$${name}_VERSION" >> avbuild/config.mak - eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> avbuild/config.mak - eval echo "${lcname}_VERSION_MINOR=\$${name}_VERSION_MINOR" >> avbuild/config.mak -} - -map 'get_version $v' $LIBRARY_LIST - map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> avbuild/config.mak' $LIBRARY_LIST print_program_extralibs(){ From 92db5083077a8b0f8e1050507671b456fd155125 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 20 Dec 2016 14:27:19 +0100 Subject: [PATCH 2/2] build: Generate pkg-config files from Make and not from configure This moves work from the configure to the Make stage where it can be parallelized and ensures that pkgconfig files are updated when library versions change. Bug-Id: 449 --- Makefile | 3 +- avbuild/.gitignore | 1 + avbuild/library.mak | 7 ++-- avbuild/pkgconfig_generate.sh | 50 +++++++++++++++++++++++++++ configure | 65 +++++++++++------------------------ libavcodec/Makefile | 1 + libavdevice/Makefile | 1 + libavfilter/Makefile | 1 + libavformat/Makefile | 1 + libavresample/Makefile | 1 + libavutil/Makefile | 1 + libswscale/Makefile | 1 + 12 files changed, 85 insertions(+), 48 deletions(-) create mode 100755 avbuild/pkgconfig_generate.sh diff --git a/Makefile b/Makefile index 6036e447db..a9f5f9a8e9 100644 --- a/Makefile +++ b/Makefile @@ -67,7 +67,7 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC) %.h.c: $(Q)echo '#include "$*.h"' >$@ -%.c %.h %.ver %.version: TAG = GEN +%.c %.h %.pc %.ver %.version: TAG = GEN AVPROGS-$(CONFIG_AVCONV) += avconv AVPROGS-$(CONFIG_AVPLAY) += avplay @@ -125,7 +125,6 @@ tools/cws2fws$(EXESUF): ELIBS = $(ZLIB) CONFIGURABLE_COMPONENTS = \ $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \ - $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/version.h)) \ $(SRC_PATH)/libavcodec/bitstream_filters.c \ $(SRC_PATH)/libavformat/protocols.c \ diff --git a/avbuild/.gitignore b/avbuild/.gitignore index 693b7aa0d3..38ed170752 100644 --- a/avbuild/.gitignore +++ b/avbuild/.gitignore @@ -2,3 +2,4 @@ /config.fate /config.log /config.mak +/config.sh diff --git a/avbuild/library.mak b/avbuild/library.mak index 45152bebe8..e5f6d7d288 100644 --- a/avbuild/library.mak +++ b/avbuild/library.mak @@ -9,8 +9,8 @@ INCINSTDIR := $(INCDIR)/lib$(NAME) INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%) -all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) -all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) +all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(NAME).pc +all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(NAME).pc LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS) $(LIBOBJS) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H @@ -35,6 +35,9 @@ $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h | $(SUBDIR) $$(M) $$(SRC_PATH)/avbuild/libversion.sh $(NAME) $$< > $$@ +$(SUBDIR)lib$(NAME).pc: $(SUBDIR)version.h | $(SUBDIR) + $$(M) $$(SRC_PATH)/avbuild/pkgconfig_generate.sh $(NAME) "$(DESC)" + $(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ diff --git a/avbuild/pkgconfig_generate.sh b/avbuild/pkgconfig_generate.sh new file mode 100755 index 0000000000..33e188f5ea --- /dev/null +++ b/avbuild/pkgconfig_generate.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +. avbuild/config.sh + +if test "$shared" = "yes"; then + shared=true +else + shared=false +fi + +shortname=$1 +name=lib${shortname} +comment=$2 +libs=$(eval echo \$extralibs_${shortname}) +requires=$(eval echo \$requires_${shortname}) +requires=${requires%, } + +version=$(grep ${name}_VERSION= $name/${name}.version | cut -d= -f2) + +cat < $name/$name.pc +prefix=$prefix +exec_prefix=\${prefix} +libdir=$libdir +includedir=$incdir + +Name: $name +Description: $comment +Version: $version +Requires: $($shared || echo $requires) +Requires.private: $($shared && echo $requires) +Conflicts: +Libs: -L\${libdir} -l${shortname} $($shared || echo $libs) +Libs.private: $($shared && echo $libs) +Cflags: -I\${includedir} +EOF + +cat < $name/$name-uninstalled.pc +prefix= +exec_prefix= +libdir=\${pcfiledir} +includedir=${source_path} + +Name: $name +Description: $comment +Version: $version +Requires: $requires +Conflicts: +Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs +Cflags: -I\${includedir} +EOF diff --git a/configure b/configure index 2671b5a02b..8e402383d8 100755 --- a/configure +++ b/configure @@ -5402,52 +5402,29 @@ lib_version(){ eval printf "\"lib${1} >= \$LIB$(toupper ${1})_VERSION, \"" } -pkgconfig_generate(){ - name=$1 - shortname=${name#lib} - comment=$2 - version=$3 - libs=$4 - requires=$(map 'lib_version $v' $(eval echo \$${name#lib}_deps)) - requires=${requires%, } - enabled ${name#lib} || return 0 - mkdir -p $name - cat < $name/$name.pc +cat > avbuild/config.sh < $name/$name-uninstalled.pc -prefix= -exec_prefix= -libdir=\${pcfiledir} -includedir=${source_path} - -Name: $name -Description: $comment -Version: $version -Requires: $requires -Conflicts: -Libs: \${libdir}/${LIBPREF}${shortname}${LIBSUF} $libs -Cflags: -I\${includedir} -EOF -} - -pkgconfig_generate libavutil "Libav utility library" "$LIBAVUTIL_VERSION" "$LIBRT $LIBM" -pkgconfig_generate libavcodec "Libav codec library" "$LIBAVCODEC_VERSION" "$extralibs" -pkgconfig_generate libavformat "Libav container format library" "$LIBAVFORMAT_VERSION" "$extralibs" -pkgconfig_generate libavdevice "Libav device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" -pkgconfig_generate libavfilter "Libav video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" -pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$LIBM" -pkgconfig_generate libswscale "Libav image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 239a4c0f0a..b3cee1d0ca 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1,4 +1,5 @@ NAME = avcodec +DESC = Libav codec library HEADERS = avcodec.h \ avfft.h \ diff --git a/libavdevice/Makefile b/libavdevice/Makefile index 664fa0f9ff..ab8931c639 100644 --- a/libavdevice/Makefile +++ b/libavdevice/Makefile @@ -1,4 +1,5 @@ NAME = avdevice +DESC = Libav device handling library HEADERS = avdevice.h \ version.h \ diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 646a5b5a26..c8d1515d2c 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -1,4 +1,5 @@ NAME = avfilter +DESC = Libav video filtering library HEADERS = avfilter.h \ avfiltergraph.h \ diff --git a/libavformat/Makefile b/libavformat/Makefile index 6146cbe12a..f363955e0e 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -1,4 +1,5 @@ NAME = avformat +DESC = Libav container format library HEADERS = avformat.h \ avio.h \ diff --git a/libavresample/Makefile b/libavresample/Makefile index b9ca491194..928b721cc2 100644 --- a/libavresample/Makefile +++ b/libavresample/Makefile @@ -1,4 +1,5 @@ NAME = avresample +DESC = Libav audio resampling library HEADERS = avresample.h \ version.h \ diff --git a/libavutil/Makefile b/libavutil/Makefile index f34c79950e..60e180c79d 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -1,4 +1,5 @@ NAME = avutil +DESC = Libav utility library HEADERS = adler32.h \ aes.h \ diff --git a/libswscale/Makefile b/libswscale/Makefile index c9b2fc9c46..a9502f6f29 100644 --- a/libswscale/Makefile +++ b/libswscale/Makefile @@ -1,4 +1,5 @@ NAME = swscale +DESC = Libav image rescaling library HEADERS = swscale.h \ version.h \