aboutsummaryrefslogtreecommitdiffstats
path: root/ffbuild
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-05-04 19:59:30 -0300
committerJames Almer <jamrial@gmail.com>2017-05-04 19:59:30 -0300
commit6fdd35a3126f6ecbe4ebab12bdf8867e4f544958 (patch)
tree7e0a89ba5a5e99377ec5461e9946ff1a0003a545 /ffbuild
parentc0f17a905f3588bf61ba6d86a83c6835d431ed3d (diff)
parent92db5083077a8b0f8e1050507671b456fd155125 (diff)
downloadffmpeg-6fdd35a3126f6ecbe4ebab12bdf8867e4f544958.tar.gz
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 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>
Diffstat (limited to 'ffbuild')
-rw-r--r--ffbuild/.gitignore1
-rw-r--r--ffbuild/common.mak4
-rw-r--r--ffbuild/library.mak12
-rwxr-xr-xffbuild/libversion.sh15
-rwxr-xr-xffbuild/pkgconfig_generate.sh62
5 files changed, 90 insertions, 4 deletions
diff --git a/ffbuild/.gitignore b/ffbuild/.gitignore
index 693b7aa0d3..38ed170752 100644
--- a/ffbuild/.gitignore
+++ b/ffbuild/.gitignore
@@ -2,3 +2,4 @@
/config.fate
/config.log
/config.mak
+/config.sh
diff --git a/ffbuild/common.mak b/ffbuild/common.mak
index 195737028a..e61f853ebb 100644
--- a/ffbuild/common.mak
+++ b/ffbuild/common.mak
@@ -89,7 +89,7 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
%.h.c:
$(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
%.h:
@@ -154,7 +154,7 @@ $(TOOLOBJS): | tools
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
LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
diff --git a/ffbuild/library.mak b/ffbuild/library.mak
index 5e576d18cd..addc945168 100644
--- a/ffbuild/library.mak
+++ b/ffbuild/library.mak
@@ -1,5 +1,7 @@
include $(SRC_PATH)/ffbuild/common.mak
+-include $(SUBDIR)lib$(NAME).version
+
LIBVERSION := $(lib$(NAME)_VERSION)
LIBMAJOR := $(lib$(NAME)_VERSION_MAJOR)
LIBMINOR := $(lib$(NAME)_VERSION_MINOR)
@@ -7,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=.s) $(LIBOBJS:.o=.i): CPPFLAGS += -DHAVE_AV_CONFIG_H
@@ -31,6 +33,12 @@ $(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)/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)
$$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@
diff --git a/ffbuild/libversion.sh b/ffbuild/libversion.sh
new file mode 100755
index 0000000000..687adf28bc
--- /dev/null
+++ b/ffbuild/libversion.sh
@@ -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"
diff --git a/ffbuild/pkgconfig_generate.sh b/ffbuild/pkgconfig_generate.sh
new file mode 100755
index 0000000000..e5de6716d2
--- /dev/null
+++ b/ffbuild/pkgconfig_generate.sh
@@ -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