1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit '92db5083077a8b0f8e1050507671b456fd155125'

* commit '92db5083077a8b0f8e1050507671b456fd155125':
  build: Generate pkg-config files from Make and not from configure
  build: Store library version numbers in .version files

Includes cherry-picked commits 8a34f36593 and
ee164727dd to fix issues.

Changes were also made to retain support for raise_major and build_suffix.

Reviewed-by: ubitux
Merged-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2017-05-04 19:59:30 -03:00
commit 6fdd35a312
16 changed files with 128 additions and 90 deletions

View File

@ -87,7 +87,6 @@ tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS)
CONFIGURABLE_COMPONENTS = \ CONFIGURABLE_COMPONENTS = \
$(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \ $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \
$(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/version.h)) \
$(SRC_PATH)/libavcodec/bitstream_filters.c \ $(SRC_PATH)/libavcodec/bitstream_filters.c \
$(SRC_PATH)/libavformat/protocols.c \ $(SRC_PATH)/libavformat/protocols.c \
@ -109,6 +108,12 @@ $(1) :=
$(1)-yes := $(1)-yes :=
endef endef
ifdef CONFIG_RAISE_MAJOR
RAISE_MAJOR = 100
else
RAISE_MAJOR = 0
endif
define DOSUBDIR define DOSUBDIR
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V)))) $(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V))))
SUBDIR := $(1)/ SUBDIR := $(1)/

92
configure vendored
View File

@ -6756,20 +6756,6 @@ NOREDZONE_FLAGS=$noredzone_flags
LIBFUZZER_PATH=$libfuzzer_path LIBFUZZER_PATH=$libfuzzer_path
EOF 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")
enabled raise_major && eval ${name}_VERSION_MAJOR=$((${name}_VERSION_MAJOR+100))
eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO
eval echo "${lcname}_VERSION=\$${name}_VERSION" >> ffbuild/config.mak
eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> ffbuild/config.mak
eval echo "${lcname}_VERSION_MINOR=\$${name}_VERSION_MINOR" >> ffbuild/config.mak
}
map 'get_version $v' $LIBRARY_LIST
map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> ffbuild/config.mak' $LIBRARY_LIST map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> ffbuild/config.mak' $LIBRARY_LIST
print_program_extralibs(){ print_program_extralibs(){
@ -6866,64 +6852,32 @@ if test -n "$WARNINGS"; then
enabled fatal_warnings && exit 1 enabled fatal_warnings && exit 1
fi fi
# build pkg-config files # Settings for pkg-config files
lib_version(){ cat > ffbuild/config.sh <<EOF
eval printf "\"lib${1}${build_suffix} >= \$LIB$(toupper ${1})_VERSION, \"" # Automatically generated by configure - do not modify!
} shared=$shared
build_suffix=$build_suffix
pkgconfig_generate(){
name=$1
shortname=${name#lib}${build_suffix}
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 <<EOF > $name/$name${build_suffix}.pc
prefix=$prefix prefix=$prefix
exec_prefix=\${prefix}
libdir=$libdir libdir=$libdir
includedir=$incdir incdir=$incdir
rpath=$(enabled rpath && echo "-Wl,-rpath,\${libdir}")
source_path=${source_path}
LIBPREF=${LIBPREF}
LIBSUF=${LIBSUF}
Name: $name extralibs_avutil="$LIBRT $LIBM"
Description: $comment extralibs_avcodec="$extralibs"
Version: $version extralibs_avformat="$extralibs"
Requires: $(enabled shared || echo $requires) extralibs_avdevice="$extralibs"
Requires.private: $(enabled shared && echo $requires) extralibs_avfilter="$extralibs"
Conflicts: extralibs_avresample="$LIBM"
Libs: -L\${libdir} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs) extralibs_postproc=""
Libs.private: $(enabled shared && echo $libs) extralibs_swscale="$LIBM"
Cflags: -I\${includedir} extralibs_swresample="$LIBM $LIBSOXR"
EOF EOF
mkdir -p doc/examples/pc-uninstalled for lib in $LIBRARY_LIST; do
includedir=${source_path} lib_deps="$(eval echo \$${lib}_deps)"
[ "$includedir" = . ] && includedir="\${pcfiledir}/../../.." echo ${lib}_deps=\"$lib_deps\" >> ffbuild/config.sh
cat <<EOF > doc/examples/pc-uninstalled/${name}-uninstalled.pc done
prefix=
exec_prefix=
libdir=\${pcfiledir}/../../../$name
includedir=${includedir}
Name: $name
Description: $comment
Version: $version
Requires: $requires
Conflicts:
Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${shortname} $(enabled shared || echo $libs)
Cflags: -I\${includedir}
EOF
}
pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBRT $LIBM"
pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs"
pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs"
pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs"
pkgconfig_generate libavfilter "FFmpeg audio/video filtering library" "$LIBAVFILTER_VERSION" "$extralibs"
pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" ""
pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$LIBM"
pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM"
pkgconfig_generate libswresample "FFmpeg audio resampling library" "$LIBSWRESAMPLE_VERSION" "$LIBM $LIBSOXR"

1
ffbuild/.gitignore vendored
View File

@ -2,3 +2,4 @@
/config.fate /config.fate
/config.log /config.log
/config.mak /config.mak
/config.sh

View File

@ -89,7 +89,7 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
%.h.c: %.h.c:
$(Q)echo '#include "$*.h"' >$@ $(Q)echo '#include "$*.h"' >$@
%.c %.h %.ver: TAG = GEN %.c %.h %.pc %.ver %.version: TAG = GEN
# Dummy rule to stop make trying to rebuild removed or renamed headers # Dummy rule to stop make trying to rebuild removed or renamed headers
%.h: %.h:
@ -154,7 +154,7 @@ $(TOOLOBJS): | tools
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS)) OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS))
CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.ho *$(DEFAULT_YASMD).asm CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.version *.ho *$(DEFAULT_YASMD).asm
DISTCLEANSUFFIXES = *.pc DISTCLEANSUFFIXES = *.pc
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a

View File

@ -1,5 +1,7 @@
include $(SRC_PATH)/ffbuild/common.mak include $(SRC_PATH)/ffbuild/common.mak
-include $(SUBDIR)lib$(NAME).version
LIBVERSION := $(lib$(NAME)_VERSION) LIBVERSION := $(lib$(NAME)_VERSION)
LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR) LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
LIBMINOR := $(lib$(NAME)_VERSION_MINOR) LIBMINOR := $(lib$(NAME)_VERSION_MINOR)
@ -7,8 +9,8 @@ INCINSTDIR := $(INCDIR)/lib$(NAME)
INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%) INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(NAME).pc
all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(NAME).pc
LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS) LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS)
$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H $(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H
@ -31,6 +33,12 @@ $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
$$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS) $$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS)
$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h | $(SUBDIR)
$$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$< $(RAISE_MAJOR) > $$@
$(SUBDIR)lib$(FULLNAME).pc: $(SUBDIR)version.h | $(SUBDIR)
$$(M) $$(SRC_PATH)/ffbuild/pkgconfig_generate.sh $(NAME) "$(DESC)"
$(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) $(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS)
$$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ $$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@

15
ffbuild/libversion.sh Executable file
View File

@ -0,0 +1,15 @@
toupper(){
echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
}
name=lib$1
ucname=$(toupper ${name})
file=$2
raise_major=$3
eval $(awk "/#define ${ucname}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
eval ${ucname}_VERSION_MAJOR=$((${ucname}_VERSION_MAJOR+${raise_major}))
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"

62
ffbuild/pkgconfig_generate.sh Executable file
View File

@ -0,0 +1,62 @@
#!/bin/sh
. ffbuild/config.sh
if test "$shared" = "yes"; then
shared=true
else
shared=false
fi
shortname=$1
name=lib${shortname}
fullname=${name}${build_suffix}
comment=$2
libs=$(eval echo \$extralibs_${shortname})
deps=$(eval echo \$${shortname}_deps)
for dep in $deps; do
depname=lib${dep}
fulldepname=${depname}${build_suffix}
. ${depname}/${depname}.version
depversion=$(eval echo \$${depname}_VERSION)
requires="$requires ${fulldepname} >= ${depversion}, "
done
requires=${requires%, }
version=$(grep ${name}_VERSION= $name/${name}.version | cut -d= -f2)
cat <<EOF > $name/$fullname.pc
prefix=$prefix
exec_prefix=\${prefix}
libdir=$libdir
includedir=$incdir
Name: $fullname
Description: $comment
Version: $version
Requires: $($shared || echo $requires)
Requires.private: $($shared && echo $requires)
Conflicts:
Libs: -L\${libdir} $rpath -l${fullname#lib} $($shared || echo $libs)
Libs.private: $($shared && echo $libs)
Cflags: -I\${includedir}
EOF
mkdir -p doc/examples/pc-uninstalled
includedir=${source_path}
[ "$includedir" = . ] && includedir="\${pcfiledir}/../../.."
cat <<EOF > doc/examples/pc-uninstalled/${name}-uninstalled.pc
prefix=
exec_prefix=
libdir=\${pcfiledir}/../../../$name
includedir=${source_path}
Name: $fullname
Description: $comment
Version: $version
Requires: $requires
Conflicts:
Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${fullname#lib} $($shared || echo $libs)
Cflags: -I\${includedir}
EOF

View File

@ -1,6 +1,5 @@
include $(SUBDIR)../ffbuild/config.mak
NAME = avcodec NAME = avcodec
DESC = FFmpeg codec library
HEADERS = avcodec.h \ HEADERS = avcodec.h \
avdct.h \ avdct.h \

View File

@ -1,6 +1,5 @@
include $(SUBDIR)../ffbuild/config.mak
NAME = avdevice NAME = avdevice
DESC = FFmpeg device handling library
HEADERS = avdevice.h \ HEADERS = avdevice.h \
version.h \ version.h \

View File

@ -1,6 +1,5 @@
include $(SUBDIR)../ffbuild/config.mak
NAME = avfilter NAME = avfilter
DESC = FFmpeg audio/video filtering library
HEADERS = avfilter.h \ HEADERS = avfilter.h \
avfiltergraph.h \ avfiltergraph.h \

View File

@ -1,6 +1,5 @@
include $(SUBDIR)../ffbuild/config.mak
NAME = avformat NAME = avformat
DESC = FFmpeg container format library
HEADERS = avformat.h \ HEADERS = avformat.h \
avio.h \ avio.h \

View File

@ -1,4 +1,5 @@
NAME = avresample NAME = avresample
DESC = Libav audio resampling library
HEADERS = avresample.h \ HEADERS = avresample.h \
version.h \ version.h \

View File

@ -1,6 +1,5 @@
include $(SUBDIR)../ffbuild/config.mak
NAME = avutil NAME = avutil
DESC = FFmpeg utility library
HEADERS = adler32.h \ HEADERS = adler32.h \
aes.h \ aes.h \

View File

@ -1,6 +1,5 @@
include $(SUBDIR)../ffbuild/config.mak
NAME = postproc NAME = postproc
DESC = FFmpeg postprocessing library
FFLIBS = avutil FFLIBS = avutil
HEADERS = postprocess.h \ HEADERS = postprocess.h \

View File

@ -1,6 +1,5 @@
include $(SUBDIR)../ffbuild/config.mak
NAME = swresample NAME = swresample
DESC = FFmpeg audio resampling library
FFLIBS = avutil FFLIBS = avutil
HEADERS = swresample.h \ HEADERS = swresample.h \

View File

@ -1,6 +1,5 @@
include $(SUBDIR)../ffbuild/config.mak
NAME = swscale NAME = swscale
DESC = FFmpeg image rescaling library
HEADERS = swscale.h \ HEADERS = swscale.h \
version.h \ version.h \