build: Generate pkg-config files from Make and not from configure
authorDiego Biurrun <diego@biurrun.de>
Tue, 20 Dec 2016 13:27:19 +0000 (14:27 +0100)
committerDiego Biurrun <diego@biurrun.de>
Thu, 22 Dec 2016 11:30:54 +0000 (12:30 +0100)
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

12 files changed:
Makefile
avbuild/.gitignore
avbuild/library.mak
avbuild/pkgconfig_generate.sh [new file with mode: 0755]
configure
libavcodec/Makefile
libavdevice/Makefile
libavfilter/Makefile
libavformat/Makefile
libavresample/Makefile
libavutil/Makefile
libswscale/Makefile

index 6036e447db76029a3c8b1fc3ed1f401e4960c88d..a9f5f9a8e9c1c01872f28af926fbf7e79fe31ea7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -67,7 +67,7 @@ COMPILE_HOSTC = $(call COMPILE,HOSTCC)
 %.h.c:
        $(Q)echo '#include "$*.h"' >$@
 
 %.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
 
 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))                 \
 
 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                             \
 
     $(SRC_PATH)/libavcodec/bitstream_filters.c                      \
     $(SRC_PATH)/libavformat/protocols.c                             \
 
index 693b7aa0d3e77f57a540ab6a5980ed6e8eaac96b..38ed170752cc5b9ff37f338e9c523a379714806c 100644 (file)
@@ -2,3 +2,4 @@
 /config.fate
 /config.log
 /config.mak
 /config.fate
 /config.log
 /config.mak
+/config.sh
index 45152bebe87a1d27e847160c37addc17495552de..e5f6d7d288aa50fee9e996886d0b44ad33954fea 100644 (file)
@@ -9,8 +9,8 @@ INCINSTDIR := $(INCDIR)/lib$(NAME)
 
 INSTHEADERS := $(INSTHEADERS) $(HEADERS:%=$(SUBDIR)%)
 
 
 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
 
 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).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) > $$@
 
 $(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 (executable)
index 0000000..33e188f
--- /dev/null
@@ -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 <<EOF > $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 <<EOF > $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
index 2671b5a02b4c248f6b06d82dd05c13d28368987c..8e402383d82302fe9803298be4b79159a06ffec8 100755 (executable)
--- a/configure
+++ b/configure
@@ -5402,52 +5402,29 @@ lib_version(){
     eval printf "\"lib${1} >= \$LIB$(toupper ${1})_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 <<EOF > $name/$name.pc
+cat > avbuild/config.sh <<EOF
+# Automatically generated by configure - do not modify!
+shared=$shared
 prefix=$prefix
 prefix=$prefix
-exec_prefix=\${prefix}
 libdir=$libdir
 includedir=$incdir
 libdir=$libdir
 includedir=$incdir
-
-Name: $name
-Description: $comment
-Version: $version
-Requires: $(enabled shared || echo $requires)
-Requires.private: $(enabled shared && echo $requires)
-Conflicts:
-Libs: -L\${libdir} -l${shortname} $(enabled shared || echo $libs)
-Libs.private: $(enabled shared && echo $libs)
-Cflags: -I\${includedir}
+source_path=${source_path}
+LIBPREF=${LIBPREF}
+LIBSUF=${LIBSUF}
+
+requires_avutil="$(map 'lib_version $v' $(echo $avutil_deps))"
+requires_avcodec="$(map 'lib_version $v' $(echo $avcodec_deps))"
+requires_avformat="$(map 'lib_version $v' $(echo $avformat_deps))"
+requires_avdevice="$(map 'lib_version $v' $(echo $avdevice_deps))"
+requires_avfilter="$(map 'lib_version $v' $(echo $avfilter_deps))"
+requires_avresample="$(map 'lib_version $v' $(echo $avresample_deps))"
+requires_swscale="$(map 'lib_version $v' $(echo $swscale_deps))"
+
+extralibs_avutil="$LIBRT $LIBM"
+extralibs_avcodec="$extralibs"
+extralibs_avformat="$extralibs"
+extralibs_avdevice="$extralibs"
+extralibs_avfilter="$extralibs"
+extralibs_avresample="$LIBM"
+extralibs_swscale="$LIBM"
 EOF
 EOF
-    cat <<EOF > $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"
index 239a4c0f0a3fa22106782f2cc3177c8dc72074b9..b3cee1d0cacd3d602fa4e076339e3a1777c16e2c 100644 (file)
@@ -1,4 +1,5 @@
 NAME = avcodec
 NAME = avcodec
+DESC = Libav codec library
 
 HEADERS = avcodec.h                                                     \
           avfft.h                                                       \
 
 HEADERS = avcodec.h                                                     \
           avfft.h                                                       \
index 664fa0f9ffebbb3b46dc4ae9c741300f67ef60d0..ab8931c63901123b90ef8dc32ea23b6da2b65bb5 100644 (file)
@@ -1,4 +1,5 @@
 NAME    = avdevice
 NAME    = avdevice
+DESC    = Libav device handling library
 
 HEADERS = avdevice.h                                                    \
           version.h                                                     \
 
 HEADERS = avdevice.h                                                    \
           version.h                                                     \
index 646a5b5a26f520b0c74a47b1e4121c3a6b36b9ec..c8d1515d2c9e050a8182d6b5004c0932e15aa1b9 100644 (file)
@@ -1,4 +1,5 @@
 NAME = avfilter
 NAME = avfilter
+DESC = Libav video filtering library
 
 HEADERS = avfilter.h                                                    \
           avfiltergraph.h                                               \
 
 HEADERS = avfilter.h                                                    \
           avfiltergraph.h                                               \
index 6146cbe12a8d8b4005f43c0e2a36d1a58144f554..f363955e0e3a290a2e0fc2a23458285f6aef9304 100644 (file)
@@ -1,4 +1,5 @@
 NAME = avformat
 NAME = avformat
+DESC = Libav container format library
 
 HEADERS = avformat.h                                                    \
           avio.h                                                        \
 
 HEADERS = avformat.h                                                    \
           avio.h                                                        \
index b9ca49119409de5d3d1efcbdc598de02f5e589d3..928b721cc202c35f1fab6d76e844402d7793d5f9 100644 (file)
@@ -1,4 +1,5 @@
 NAME = avresample
 NAME = avresample
+DESC = Libav audio resampling library
 
 HEADERS = avresample.h                                                  \
           version.h                                                     \
 
 HEADERS = avresample.h                                                  \
           version.h                                                     \
index f34c79950ef2ba6ae5197ac747611f3dd519aaff..60e180c79d940f5a6feb5fd0be691accd2afe035 100644 (file)
@@ -1,4 +1,5 @@
 NAME = avutil
 NAME = avutil
+DESC = Libav utility library
 
 HEADERS = adler32.h                                                     \
           aes.h                                                         \
 
 HEADERS = adler32.h                                                     \
           aes.h                                                         \
index c9b2fc9c468a4639c9ef1b78a90f606044b18d78..a9502f6f2919f715066d51e291518402b6998411 100644 (file)
@@ -1,4 +1,5 @@
 NAME = swscale
 NAME = swscale
+DESC = Libav image rescaling library
 
 HEADERS = swscale.h                                                     \
           version.h                                                     \
 
 HEADERS = swscale.h                                                     \
           version.h                                                     \