* 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 8a34f3659371680ca523aecfd9098c28f0f809eb and
ee164727dd64c199b87118917e674b17c25e0da3 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>
... | ... |
@@ -87,7 +87,6 @@ tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS) |
87 | 87 |
|
88 | 88 |
CONFIGURABLE_COMPONENTS = \ |
89 | 89 |
$(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \ |
90 |
- $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/version.h)) \ |
|
91 | 90 |
$(SRC_PATH)/libavcodec/bitstream_filters.c \ |
92 | 91 |
$(SRC_PATH)/libavformat/protocols.c \ |
93 | 92 |
|
... | ... |
@@ -109,6 +108,12 @@ $(1) := |
109 | 109 |
$(1)-yes := |
110 | 110 |
endef |
111 | 111 |
|
112 |
+ifdef CONFIG_RAISE_MAJOR |
|
113 |
+RAISE_MAJOR = 100 |
|
114 |
+else |
|
115 |
+RAISE_MAJOR = 0 |
|
116 |
+endif |
|
117 |
+ |
|
112 | 118 |
define DOSUBDIR |
113 | 119 |
$(foreach V,$(SUBDIR_VARS),$(eval $(call RESET,$(V)))) |
114 | 120 |
SUBDIR := $(1)/ |
... | ... |
@@ -6756,20 +6756,6 @@ NOREDZONE_FLAGS=$noredzone_flags |
6756 | 6756 |
LIBFUZZER_PATH=$libfuzzer_path |
6757 | 6757 |
EOF |
6758 | 6758 |
|
6759 |
-get_version(){ |
|
6760 |
- lcname=lib${1} |
|
6761 |
- name=$(toupper $lcname) |
|
6762 |
- file=$source_path/$lcname/version.h |
|
6763 |
- eval $(awk "/#define ${name}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file") |
|
6764 |
- enabled raise_major && eval ${name}_VERSION_MAJOR=$((${name}_VERSION_MAJOR+100)) |
|
6765 |
- eval ${name}_VERSION=\$${name}_VERSION_MAJOR.\$${name}_VERSION_MINOR.\$${name}_VERSION_MICRO |
|
6766 |
- eval echo "${lcname}_VERSION=\$${name}_VERSION" >> ffbuild/config.mak |
|
6767 |
- eval echo "${lcname}_VERSION_MAJOR=\$${name}_VERSION_MAJOR" >> ffbuild/config.mak |
|
6768 |
- eval echo "${lcname}_VERSION_MINOR=\$${name}_VERSION_MINOR" >> ffbuild/config.mak |
|
6769 |
-} |
|
6770 |
- |
|
6771 |
-map 'get_version $v' $LIBRARY_LIST |
|
6772 |
- |
|
6773 | 6759 |
map 'eval echo "${v}_FFLIBS=\$${v}_deps" >> ffbuild/config.mak' $LIBRARY_LIST |
6774 | 6760 |
|
6775 | 6761 |
print_program_extralibs(){ |
... | ... |
@@ -6866,64 +6852,32 @@ if test -n "$WARNINGS"; then |
6866 | 6866 |
enabled fatal_warnings && exit 1 |
6867 | 6867 |
fi |
6868 | 6868 |
|
6869 |
-# build pkg-config files |
|
6869 |
+# Settings for pkg-config files |
|
6870 | 6870 |
|
6871 |
-lib_version(){ |
|
6872 |
- eval printf "\"lib${1}${build_suffix} >= \$LIB$(toupper ${1})_VERSION, \"" |
|
6873 |
-} |
|
6874 |
- |
|
6875 |
-pkgconfig_generate(){ |
|
6876 |
- name=$1 |
|
6877 |
- shortname=${name#lib}${build_suffix} |
|
6878 |
- comment=$2 |
|
6879 |
- version=$3 |
|
6880 |
- libs=$4 |
|
6881 |
- requires=$(map 'lib_version $v' $(eval echo \$${name#lib}_deps)) |
|
6882 |
- requires=${requires%, } |
|
6883 |
- enabled ${name#lib} || return 0 |
|
6884 |
- mkdir -p $name |
|
6885 |
- cat <<EOF > $name/$name${build_suffix}.pc |
|
6871 |
+cat > ffbuild/config.sh <<EOF |
|
6872 |
+# Automatically generated by configure - do not modify! |
|
6873 |
+shared=$shared |
|
6874 |
+build_suffix=$build_suffix |
|
6886 | 6875 |
prefix=$prefix |
6887 |
-exec_prefix=\${prefix} |
|
6888 | 6876 |
libdir=$libdir |
6889 |
-includedir=$incdir |
|
6890 |
- |
|
6891 |
-Name: $name |
|
6892 |
-Description: $comment |
|
6893 |
-Version: $version |
|
6894 |
-Requires: $(enabled shared || echo $requires) |
|
6895 |
-Requires.private: $(enabled shared && echo $requires) |
|
6896 |
-Conflicts: |
|
6897 |
-Libs: -L\${libdir} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs) |
|
6898 |
-Libs.private: $(enabled shared && echo $libs) |
|
6899 |
-Cflags: -I\${includedir} |
|
6877 |
+incdir=$incdir |
|
6878 |
+rpath=$(enabled rpath && echo "-Wl,-rpath,\${libdir}") |
|
6879 |
+source_path=${source_path} |
|
6880 |
+LIBPREF=${LIBPREF} |
|
6881 |
+LIBSUF=${LIBSUF} |
|
6882 |
+ |
|
6883 |
+extralibs_avutil="$LIBRT $LIBM" |
|
6884 |
+extralibs_avcodec="$extralibs" |
|
6885 |
+extralibs_avformat="$extralibs" |
|
6886 |
+extralibs_avdevice="$extralibs" |
|
6887 |
+extralibs_avfilter="$extralibs" |
|
6888 |
+extralibs_avresample="$LIBM" |
|
6889 |
+extralibs_postproc="" |
|
6890 |
+extralibs_swscale="$LIBM" |
|
6891 |
+extralibs_swresample="$LIBM $LIBSOXR" |
|
6900 | 6892 |
EOF |
6901 | 6893 |
|
6902 |
-mkdir -p doc/examples/pc-uninstalled |
|
6903 |
-includedir=${source_path} |
|
6904 |
-[ "$includedir" = . ] && includedir="\${pcfiledir}/../../.." |
|
6905 |
- cat <<EOF > doc/examples/pc-uninstalled/${name}-uninstalled.pc |
|
6906 |
-prefix= |
|
6907 |
-exec_prefix= |
|
6908 |
-libdir=\${pcfiledir}/../../../$name |
|
6909 |
-includedir=${includedir} |
|
6910 |
- |
|
6911 |
-Name: $name |
|
6912 |
-Description: $comment |
|
6913 |
-Version: $version |
|
6914 |
-Requires: $requires |
|
6915 |
-Conflicts: |
|
6916 |
-Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${shortname} $(enabled shared || echo $libs) |
|
6917 |
-Cflags: -I\${includedir} |
|
6918 |
-EOF |
|
6919 |
-} |
|
6920 |
- |
|
6921 |
-pkgconfig_generate libavutil "FFmpeg utility library" "$LIBAVUTIL_VERSION" "$LIBRT $LIBM" |
|
6922 |
-pkgconfig_generate libavcodec "FFmpeg codec library" "$LIBAVCODEC_VERSION" "$extralibs" |
|
6923 |
-pkgconfig_generate libavformat "FFmpeg container format library" "$LIBAVFORMAT_VERSION" "$extralibs" |
|
6924 |
-pkgconfig_generate libavdevice "FFmpeg device handling library" "$LIBAVDEVICE_VERSION" "$extralibs" |
|
6925 |
-pkgconfig_generate libavfilter "FFmpeg audio/video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" |
|
6926 |
-pkgconfig_generate libpostproc "FFmpeg postprocessing library" "$LIBPOSTPROC_VERSION" "" |
|
6927 |
-pkgconfig_generate libavresample "Libav audio resampling library" "$LIBAVRESAMPLE_VERSION" "$LIBM" |
|
6928 |
-pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "$LIBM" |
|
6929 |
-pkgconfig_generate libswresample "FFmpeg audio resampling library" "$LIBSWRESAMPLE_VERSION" "$LIBM $LIBSOXR" |
|
6894 |
+for lib in $LIBRARY_LIST; do |
|
6895 |
+ lib_deps="$(eval echo \$${lib}_deps)" |
|
6896 |
+ echo ${lib}_deps=\"$lib_deps\" >> ffbuild/config.sh |
|
6897 |
+done |
... | ... |
@@ -89,7 +89,7 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC) |
89 | 89 |
%.h.c: |
90 | 90 |
$(Q)echo '#include "$*.h"' >$@ |
91 | 91 |
|
92 |
-%.c %.h %.ver: TAG = GEN |
|
92 |
+%.c %.h %.pc %.ver %.version: TAG = GEN |
|
93 | 93 |
|
94 | 94 |
# Dummy rule to stop make trying to rebuild removed or renamed headers |
95 | 95 |
%.h: |
... | ... |
@@ -154,7 +154,7 @@ $(TOOLOBJS): | tools |
154 | 154 |
|
155 | 155 |
OBJDIRS := $(OBJDIRS) $(dir $(OBJS) $(HOBJS) $(HOSTOBJS) $(SLIBOBJS) $(TESTOBJS)) |
156 | 156 |
|
157 |
-CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.ho *$(DEFAULT_YASMD).asm |
|
157 |
+CLEANSUFFIXES = *.d *.o *~ *.h.c *.gcda *.gcno *.map *.ver *.version *.ho *$(DEFAULT_YASMD).asm |
|
158 | 158 |
DISTCLEANSUFFIXES = *.pc |
159 | 159 |
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a |
160 | 160 |
|
... | ... |
@@ -1,5 +1,7 @@ |
1 | 1 |
include $(SRC_PATH)/ffbuild/common.mak |
2 | 2 |
|
3 |
+-include $(SUBDIR)lib$(NAME).version |
|
4 |
+ |
|
3 | 5 |
LIBVERSION := $(lib$(NAME)_VERSION) |
4 | 6 |
LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR) |
5 | 7 |
LIBMINOR := $(lib$(NAME)_VERSION_MINOR) |
... | ... |
@@ -7,8 +9,8 @@ INCINSTDIR := $(INCDIR)/lib$(NAME) |
7 | 7 |
|
8 | 8 |
INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%) |
9 | 9 |
|
10 |
-all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) |
|
11 |
-all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) |
|
10 |
+all-$(CONFIG_STATIC): $(SUBDIR)$(LIBNAME) $(SUBDIR)lib$(NAME).pc |
|
11 |
+all-$(CONFIG_SHARED): $(SUBDIR)$(SLIBNAME) $(SUBDIR)lib$(NAME).pc |
|
12 | 12 |
|
13 | 13 |
LIBOBJS := $(OBJS) $(SUBDIR)%.h.o $(TESTOBJS) |
14 | 14 |
$(LIBOBJS) $(LIBOBJS:.o=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H |
... | ... |
@@ -31,6 +33,12 @@ $(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME) |
31 | 31 |
$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o |
32 | 32 |
$$(LD) $(LDFLAGS) $(LDEXEFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS) |
33 | 33 |
|
34 |
+$(SUBDIR)lib$(NAME).version: $(SUBDIR)version.h | $(SUBDIR) |
|
35 |
+ $$(M) $$(SRC_PATH)/ffbuild/libversion.sh $(NAME) $$< $(RAISE_MAJOR) > $$@ |
|
36 |
+ |
|
37 |
+$(SUBDIR)lib$(FULLNAME).pc: $(SUBDIR)version.h | $(SUBDIR) |
|
38 |
+ $$(M) $$(SRC_PATH)/ffbuild/pkgconfig_generate.sh $(NAME) "$(DESC)" |
|
39 |
+ |
|
34 | 40 |
$(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS) |
35 | 41 |
$$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@ |
36 | 42 |
|
37 | 43 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,15 @@ |
0 |
+toupper(){ |
|
1 |
+ echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ |
|
2 |
+} |
|
3 |
+ |
|
4 |
+name=lib$1 |
|
5 |
+ucname=$(toupper ${name}) |
|
6 |
+file=$2 |
|
7 |
+raise_major=$3 |
|
8 |
+ |
|
9 |
+eval $(awk "/#define ${ucname}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file") |
|
10 |
+eval ${ucname}_VERSION_MAJOR=$((${ucname}_VERSION_MAJOR+${raise_major})) |
|
11 |
+eval ${ucname}_VERSION=\$${ucname}_VERSION_MAJOR.\$${ucname}_VERSION_MINOR.\$${ucname}_VERSION_MICRO |
|
12 |
+eval echo "${name}_VERSION=\$${ucname}_VERSION" |
|
13 |
+eval echo "${name}_VERSION_MAJOR=\$${ucname}_VERSION_MAJOR" |
|
14 |
+eval echo "${name}_VERSION_MINOR=\$${ucname}_VERSION_MINOR" |
0 | 15 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,62 @@ |
0 |
+#!/bin/sh |
|
1 |
+ |
|
2 |
+. ffbuild/config.sh |
|
3 |
+ |
|
4 |
+if test "$shared" = "yes"; then |
|
5 |
+ shared=true |
|
6 |
+else |
|
7 |
+ shared=false |
|
8 |
+fi |
|
9 |
+ |
|
10 |
+shortname=$1 |
|
11 |
+name=lib${shortname} |
|
12 |
+fullname=${name}${build_suffix} |
|
13 |
+comment=$2 |
|
14 |
+libs=$(eval echo \$extralibs_${shortname}) |
|
15 |
+deps=$(eval echo \$${shortname}_deps) |
|
16 |
+ |
|
17 |
+for dep in $deps; do |
|
18 |
+ depname=lib${dep} |
|
19 |
+ fulldepname=${depname}${build_suffix} |
|
20 |
+ . ${depname}/${depname}.version |
|
21 |
+ depversion=$(eval echo \$${depname}_VERSION) |
|
22 |
+ requires="$requires ${fulldepname} >= ${depversion}, " |
|
23 |
+done |
|
24 |
+requires=${requires%, } |
|
25 |
+ |
|
26 |
+version=$(grep ${name}_VERSION= $name/${name}.version | cut -d= -f2) |
|
27 |
+ |
|
28 |
+cat <<EOF > $name/$fullname.pc |
|
29 |
+prefix=$prefix |
|
30 |
+exec_prefix=\${prefix} |
|
31 |
+libdir=$libdir |
|
32 |
+includedir=$incdir |
|
33 |
+ |
|
34 |
+Name: $fullname |
|
35 |
+Description: $comment |
|
36 |
+Version: $version |
|
37 |
+Requires: $($shared || echo $requires) |
|
38 |
+Requires.private: $($shared && echo $requires) |
|
39 |
+Conflicts: |
|
40 |
+Libs: -L\${libdir} $rpath -l${fullname#lib} $($shared || echo $libs) |
|
41 |
+Libs.private: $($shared && echo $libs) |
|
42 |
+Cflags: -I\${includedir} |
|
43 |
+EOF |
|
44 |
+ |
|
45 |
+mkdir -p doc/examples/pc-uninstalled |
|
46 |
+includedir=${source_path} |
|
47 |
+[ "$includedir" = . ] && includedir="\${pcfiledir}/../../.." |
|
48 |
+ cat <<EOF > doc/examples/pc-uninstalled/${name}-uninstalled.pc |
|
49 |
+prefix= |
|
50 |
+exec_prefix= |
|
51 |
+libdir=\${pcfiledir}/../../../$name |
|
52 |
+includedir=${source_path} |
|
53 |
+ |
|
54 |
+Name: $fullname |
|
55 |
+Description: $comment |
|
56 |
+Version: $version |
|
57 |
+Requires: $requires |
|
58 |
+Conflicts: |
|
59 |
+Libs: -L\${libdir} -Wl,-rpath,\${libdir} -l${fullname#lib} $($shared || echo $libs) |
|
60 |
+Cflags: -I\${includedir} |
|
61 |
+EOF |