mirror of https://github.com/sipwise/rtpengine.git
These are potentially computed from inside each subdir, and in addition due to what appears to be a regression in GNU make 4.4, where it is reevaluating variables that contain $(shell) functions, many times (in the order of thousands, this was slowing down the build, were on the Debian amd64 build daemons it went from 5m with GNU make 4.3 to 2h40m with GNU make 4.4. Although the bulk of the slow down has been fixed with previous commits, the remaining optimizations are only to avoid this potentially happening again in the future, and to reduce useless duplicate work. Instead of trying to cache the values from within make itself, where programming this there is extremely painful, and does not seem to be able to greatly reduce the number of calls, because the build system is going to be called multiple times for different targets. Simply externalize the generation into several shell scripts, that we call to generate a make fragment that then we include from the various Makefiles. For a Debian build with GNU make 4.3, this reduces the amount of total pkg-config calls from around ~1600 to 128, for dpkg-buildflags from ~1100 down to 6, and for dpkg-parsechangelog from ~56 to 17, but the slow down is not as significant there anyway. For a Debian build with GNU make 4.4, this reduces the amount of total pkg-config calls from around ~2600 to 128, for dpkg-buildflags from ~2800 down to 6, and for dpkg-parsechangelog from ~350 to 21. For a Debian build with GNU make 4.4, this reduces the build time on this system from 2m10s to ~ 1m30s. Change-Id: I427d0ea5106dc6ed1ff9e664ccdba2fa0725b7d0pull/1910/head
parent
bb2bf3a702
commit
7dbe24e4e5
@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -z "${M}" ]; then
|
||||
M=$(pwd)
|
||||
fi
|
||||
|
||||
if [ -z "${RTPENGINE_VERSION}" ]; then
|
||||
have_dpkg_parsechangelog=no
|
||||
if command -v dpkg-parsechangelog >/dev/null; then
|
||||
have_dpkg_parsechangelog=yes
|
||||
fi
|
||||
if [ -f "${M}/../debian/changelog" ]; then
|
||||
deb_changelog="${M}/../debian/changelog"
|
||||
else
|
||||
deb_changelog="${M}/debian/changelog"
|
||||
fi
|
||||
if [ "${have_dpkg_parsechangelog}" = yes ]; then
|
||||
deb_version="$(dpkg-parsechangelog -l${deb_changelog} | awk '/^Version: / {print $$2}')"
|
||||
fi
|
||||
git_br_commit="git-$(cd ${M} && git rev-parse --abbrev-ref --symbolic-full-name HEAD 2> /dev/null)-$(cd ${M} && git rev-parse --short HEAD 2> /dev/null)"
|
||||
|
||||
if [ "${have_dpkg_parsechangelog}" = yes ]; then
|
||||
RTPENGINE_VERSION+=" ${deb_version}"
|
||||
fi
|
||||
if [ "${git_br_commit}" != "git--" ]; then
|
||||
RTPENGINE_VERSION+=" ${git_br_commit}"
|
||||
fi
|
||||
|
||||
if [ -z "${RTPENGINE_VERSION}" ]; then
|
||||
RTPENGINE_VERSION="undefined"
|
||||
fi
|
||||
echo "RTPENGINE_VERSION := ${RTPENGINE_VERSION}"
|
||||
fi
|
@ -1,7 +0,0 @@
|
||||
ifneq (,$(filter pkg.ngcp-rtpengine.codec-chain,${DEB_BUILD_PROFILES}))
|
||||
ifneq (,$(wildcard $(CODEC_CHAIN_HOME)/usr/include/codec-chain/client.h))
|
||||
CFLAGS+= -DHAVE_CODEC_CHAIN -I$(CODEC_CHAIN_HOME)/usr/include
|
||||
else ifneq (,$(wildcard /usr/include/codec-chain/client.h))
|
||||
CFLAGS+= -DHAVE_CODEC_CHAIN
|
||||
endif
|
||||
endif
|
@ -0,0 +1,12 @@
|
||||
# Define build flags for used dependencies.
|
||||
|
||||
$(top_srcdir)/config.mk:
|
||||
$(top_srcdir)/utils/gen-common-flags >$@
|
||||
ifeq (,$(filter pkg.ngcp-rtpengine.nobcg729,${DEB_BUILD_PROFILES}))
|
||||
$(top_srcdir)/utils/gen-bcg729-flags >>$@
|
||||
endif
|
||||
ifneq (,$(filter pkg.ngcp-rtpengine.codec-chain,${DEB_BUILD_PROFILES}))
|
||||
$(top_srcdir)/utils/gen-codec-chain-flags >>$@
|
||||
endif
|
||||
|
||||
include $(top_srcdir)/config.mk
|
@ -1,58 +0,0 @@
|
||||
ifeq (,$(filter pkg.ngcp-rtpengine.nobcg729,${DEB_BUILD_PROFILES}))
|
||||
# look for bcg729
|
||||
# system pkg-config
|
||||
have_bcg729 := $(shell pkg-config --exists libbcg729 && echo yes)
|
||||
ifeq ($(have_bcg729),yes)
|
||||
bcg729_inc := $(shell pkg-config --cflags libbcg729)
|
||||
bcg729_lib := $(shell pkg-config --libs libbcg729)
|
||||
else
|
||||
# system generic
|
||||
ifneq (,$(wildcard /usr/include/bcg729/decoder.h))
|
||||
have_bcg729 := yes
|
||||
bcg729_lib := -lbcg729
|
||||
else
|
||||
# /usr/src
|
||||
ifneq (,$(wildcard /usr/src/bcg729/include/bcg729/decoder.h))
|
||||
have_bcg729 := yes
|
||||
bcg729_inc := -I/usr/src/bcg729/include/
|
||||
bcg729_lib := -L/usr/src/bcg729/src/ -lbcg729
|
||||
else
|
||||
# rfuchs dev
|
||||
ifneq (,$(wildcard $(HOME)/src/bcg729/include/bcg729/decoder.h))
|
||||
have_bcg729 := yes
|
||||
bcg729_inc := -I$(HOME)/src/bcg729/include/
|
||||
bcg729_lib := -L$(HOME)/src/bcg729/src/ -lbcg729
|
||||
else
|
||||
# home directory
|
||||
ifneq (,$(wildcard $(HOME)/bcg729/include/bcg729/decoder.h))
|
||||
have_bcg729 := yes
|
||||
bcg729_inc := -I$(HOME)/bcg729/include/
|
||||
bcg729_lib := -L$(HOME)/bcg729/src/ -lbcg729
|
||||
else
|
||||
# included toplevel
|
||||
ifneq (,$(wildcard ../bcg729/include/bcg729/decoder.h))
|
||||
have_bcg729 := yes
|
||||
bcg729_inc := -I../bcg729/include/
|
||||
bcg729_lib := -L../bcg729/src/ -lbcg729
|
||||
else
|
||||
# /usr/local/include when installing from git
|
||||
ifneq (,$(wildcard /usr/local/include/bcg729/decoder.h))
|
||||
have_bcg729 := yes
|
||||
bcg729_inc := -I/usr/local/include/
|
||||
bcg729_lib := -L/usr/local/lib64/ -lbcg729
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(have_bcg729),yes)
|
||||
CFLAGS+= -DHAVE_BCG729
|
||||
CFLAGS+= $(bcg729_inc)
|
||||
endif
|
||||
ifeq ($(have_bcg729),yes)
|
||||
LDLIBS+= $(bcg729_lib)
|
||||
endif
|
@ -1,10 +0,0 @@
|
||||
have_mqtt := $(shell pkg-config --exists libmosquitto && echo yes)
|
||||
ifeq ($(have_mqtt),yes)
|
||||
mqtt_inc := $(shell pkg-config --cflags libmosquitto)
|
||||
mqtt_lib := $(shell pkg-config --libs libmosquitto)
|
||||
CFLAGS+= -DHAVE_MQTT
|
||||
CFLAGS+= $(mqtt_inc)
|
||||
endif
|
||||
ifeq ($(have_mqtt),yes)
|
||||
LDLIBS+= $(mqtt_lib)
|
||||
endif
|
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
have_bcg729="no"
|
||||
|
||||
# look for bcg729
|
||||
if pkg-config --exists libbcg729; then
|
||||
# system pkg-config
|
||||
have_bcg729="yes"
|
||||
|
||||
bcg729_inc="$(pkg-config --cflags libbcg729)"
|
||||
bcg729_lib="$(pkg-config --libs libbcg729)"
|
||||
elif [ -e /usr/include/bcg729/decoder.h ]; then
|
||||
# system generic
|
||||
have_bcg729="yes"
|
||||
bcg729_lib="-lbcg729"
|
||||
elif [ -e /usr/src/bcg729/include/bcg729/decoder.h ]; then
|
||||
# /usr/src
|
||||
have_bcg729=yes
|
||||
bcg729_inc="-I/usr/src/bcg729/include/"
|
||||
bcg729_lib="-L/usr/src/bcg729/src/ -lbcg729"
|
||||
elif [ -e "${HOME}/src/bcg729/include/bcg729/decoder.h" ]; then
|
||||
# rfuchs dev
|
||||
have_bcg729="yes"
|
||||
bcg729_inc="-I${HOME}/src/bcg729/include/"
|
||||
bcg729_lib="-L${HOME}/src/bcg729/src/ -lbcg729"
|
||||
elif [ -e "${HOME}/bcg729/include/bcg729/decoder.h" ]; then
|
||||
# home directory
|
||||
have_bcg729="yes"
|
||||
bcg729_inc="-I$(HOME)/bcg729/include/"
|
||||
bcg729_lib="-L$(HOME)/bcg729/src/ -lbcg729"
|
||||
elif [ -e "../bcg729/include/bcg729/decoder.h" ]; then
|
||||
# included toplevel
|
||||
have_bcg729="yes"
|
||||
bcg729_inc="-I../bcg729/include/"
|
||||
bcg729_lib="-L../bcg729/src/ -lbcg729"
|
||||
elif [ -e /usr/local/include/bcg729/decoder.h ]; then
|
||||
# /usr/local/include when installing from git
|
||||
have_bcg729="yes"
|
||||
bcg729_inc="-I/usr/local/include/"
|
||||
bcg729_lib="-L/usr/local/lib64/ -lbcg729"
|
||||
fi
|
||||
|
||||
if [ "${have_bcg729}" = "yes" ]; then
|
||||
echo "CFLAGS_BCG729 := -DHAVE_BCG729"
|
||||
echo "CFLAGS_BCG729 += ${bcg729_inc}"
|
||||
echo "LDLIBS_BCG729 := ${bcg729_lib}"
|
||||
fi
|
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ -e "${CODEC_CHAIN_HOME}/usr/include/codec-chain/client.h" ]; then
|
||||
echo "CFLAGS_CODEC_CHAIN := -DHAVE_CODEC_CHAIN -I${CODEC_CHAIN_HOME}/usr/include"
|
||||
elif [ -e /usr/include/codec-chain/client.h ]; then
|
||||
echo "CFLAGS_CODEC_CHAIN := -DHAVE_CODEC_CHAIN"
|
||||
fi
|
@ -0,0 +1,119 @@
|
||||
#!/bin/bash
|
||||
|
||||
gen-pkgconf-flags()
|
||||
{
|
||||
local var="$1"
|
||||
local pc="$2"
|
||||
|
||||
echo "export CFLAGS_${var} LDLIBS_${var}"
|
||||
echo "CFLAGS_${var} := $(pkg-config --cflags "${pc}")"
|
||||
echo "LDLIBS_${var} := $(pkg-config --libs "${pc}")"
|
||||
}
|
||||
|
||||
if [ -z "${top_srcdir}" ]; then
|
||||
top_srcdir=.
|
||||
fi
|
||||
|
||||
have_dpkg_parsechangelog=no
|
||||
if command -v dpkg-parsechangelog >/dev/null; then
|
||||
have_dpkg_parsechangelog=yes
|
||||
fi
|
||||
|
||||
if [ -z "${RELEASE_DATE}" ]; then
|
||||
if [ "${have_dpkg_parsechangelog}" = yes ]; then
|
||||
RELEASE_DATE="$(date -u -d "@$(dpkg-parsechangelog -l${top_srcdir}/debian/changelog -STimestamp)" '+%F')"
|
||||
fi
|
||||
if [ -z "${RELEASE_DATE}" ]; then
|
||||
RELEASE_DATE="undefined"
|
||||
fi
|
||||
fi
|
||||
echo "RELEASE_DATE = ${RELEASE_DATE}"
|
||||
|
||||
if [ -z "${RTPENGINE_VERSION}" ]; then
|
||||
if [ "${have_dpkg_parsechangelog}" = yes ]; then
|
||||
deb_version="$(dpkg-parsechangelog -l${top_srcdir}/debian/changelog | awk '/^Version: / { print $2 }')"
|
||||
fi
|
||||
git_br_commit="git-$(git rev-parse --abbrev-ref --symbolic-full-name HEAD 2> /dev/null)-$(git rev-parse --short HEAD 2> /dev/null)"
|
||||
|
||||
if [ "${have_dpkg_parsechangelog}" = yes ]; then
|
||||
RTPENGINE_VERSION+=" ${deb_version}"
|
||||
fi
|
||||
if [ "${git_br_commit}" != "git--" ]; then
|
||||
RTPENGINE_VERSION+=" ${git_br_commit}"
|
||||
fi
|
||||
|
||||
if [ -z "${RTPENGINE_VERSION}" ]; then
|
||||
RTPENGINE_VERSION=" undefined"
|
||||
fi
|
||||
fi
|
||||
echo "RTPENGINE_VERSION := ${RTPENGINE_VERSION}"
|
||||
|
||||
CFLAGS_DEFAULT=
|
||||
CPPFLAGS_DEFAULT=
|
||||
LDFLAGS_DEFAULT=
|
||||
LDLIBS_DEFAULT=
|
||||
if command -v dpkg-buildflags >/dev/null; then
|
||||
# support http://wiki.debian.org/Hardening for >=wheezy
|
||||
CFLAGS_DEFAULT=$(dpkg-buildflags --get CFLAGS)
|
||||
CPPFLAGS_DEFAULT=$(dpkg-buildflags --get CPPFLAGS)
|
||||
LDFLAGS=$(dpkg-buildflags --get LDFLAGS)
|
||||
fi
|
||||
CFLAGS_DEFAULT+=" -O3 -flto=auto -ffat-lto-objects"
|
||||
LDFLAGS_DEFAULT+=" -flto=auto"
|
||||
|
||||
echo "export CFLAGS_DEFAULT := ${CFLAGS_DEFAULT}"
|
||||
echo "export CPPFLAGS_DEFAULT := ${CPPFLAGS_DEFAULT}"
|
||||
echo "export LDFLAGS_DEFAULT := ${LDFLAGS_DEFAULT}"
|
||||
|
||||
gen-pkgconf-flags GLIB glib-2.0
|
||||
gen-pkgconf-flags GTHREAD gthread-2.0
|
||||
gen-pkgconf-flags JSON_GLIB json-glib-1.0
|
||||
gen-pkgconf-flags LIBAVCODEC libavcodec
|
||||
gen-pkgconf-flags LIBAVFILTER libavfilter
|
||||
gen-pkgconf-flags LIBAVFORMAT libavformat
|
||||
gen-pkgconf-flags LIBAVUTIL libavutil
|
||||
gen-pkgconf-flags LIBCURL libcurl
|
||||
gen-pkgconf-flags LIBCRYPTO libcrypto
|
||||
gen-pkgconf-flags LIBEVENT libevent_pthreads
|
||||
gen-pkgconf-flags LIBIPTC libiptc
|
||||
gen-pkgconf-flags LIBMNL libmnl
|
||||
gen-pkgconf-flags LIBNFTNL libnftnl
|
||||
gen-pkgconf-flags LIBPCRE libpcre2-8
|
||||
echo "CFLAGS_LIBPCRE += -DPCRE2_CODE_UNIT_WIDTH=8"
|
||||
gen-pkgconf-flags LIBSWRESAMPLE libswresample
|
||||
gen-pkgconf-flags LIBWEBSOCKETS libwebsockets
|
||||
gen-pkgconf-flags LIBZ zlib
|
||||
gen-pkgconf-flags NCURSESW ncursesw
|
||||
gen-pkgconf-flags OPENSSL openssl
|
||||
gen-pkgconf-flags OPUS opus
|
||||
gen-pkgconf-flags SPANDSP spandsp
|
||||
|
||||
echo "export CFLAGS_XMLRPC := $(pkg-config xmlrpc_client --cflags 2> /dev/null || xmlrpc-c-config client --cflags)"
|
||||
echo "CFLAGS_XMLRPC += $(pkg-config xmlrpc --cflags 2> /dev/null)"
|
||||
echo "CFLAGS_XMLRPC += $(pkg-config xmlrpc_util --cflags 2> /dev/null)"
|
||||
echo "export LDLIBS_XMLRPC := $(pkg-config xmlrpc_client --libs 2> /dev/null || xmlrpc-c-config client --libs)"
|
||||
echo "LDLIBS_XMLRPC += $(pkg-config xmlrpc --libs 2> /dev/null)"
|
||||
echo "LDLIBS_XMLRPC += $(pkg-config xmlrpc_util --libs 2> /dev/null)"
|
||||
|
||||
echo "export CFLAGS_MYSQL := $(mysql_config --cflags)"
|
||||
echo "export LDLIBS_MYSQL := $(mysql_config --libs)"
|
||||
|
||||
echo "export LDLIBS_LIBHIREDIS := -lhiredis"
|
||||
echo "export LDLIBS_LIBPCAP := -lpcap"
|
||||
|
||||
if pkg-config --exists libmosquitto; then
|
||||
gen-pkgconf-flags MQTT libmosquitto
|
||||
echo "CFLAGS_MQTT += -DHAVE_MQTT"
|
||||
fi
|
||||
|
||||
# look for libsystemd
|
||||
if pkg-config --exists libsystemd; then
|
||||
gen-pkgconf-flags LIBSYSTEMD libsystemd
|
||||
echo "CFLAGS_LIBSYSTEMD += -DHAVE_LIBSYSTEMD"
|
||||
fi
|
||||
|
||||
# look for liburing
|
||||
if pkg-config --atleast-version=2.3 liburing; then
|
||||
gen-pkgconf-flags LIBURING liburing
|
||||
echo "CFLAGS_LIBURING += -DHAVE_LIBURING"
|
||||
fi
|
Loading…
Reference in new issue