kamailio-5.x: update build setup

This switches the Makefile away from calling "make" manually to using
OpenWrt default build defines. This way PKG_BUILD_PARALLEL and
PKG_INSTALL can be used.

To achieve this the flags are added to MAKE_FLAGS. The flags are also
tidied up as per example from Alpine Linux. Like this the build is
cleaner, for instance this gets rid of the wrong share directory
("//share/kamailio" instead of "/usr/share/kamailio") and things like
multi-slashes in directory names (ex. "///usr/lib/kamailio/modules").

lib_target was removed after verifying that the correct RPATH
"/usr/lib/kamailio" is still in place without it.

CFLAGS is replaced by CC_EXTRA_OPTS (same is already done for LDFLAGS).
This way upstream source can add flags like "-Wall" to OpenWrt builds.

Extra flags LOCALBASE, SYSBASE and CROSS get removed as they aren't
needed anymore with the "Alpine Linux" flags.

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>
This commit is contained in:
Sebastian Kemper 2020-04-10 13:52:17 +02:00
parent 16a3e1c7a2
commit 60ea8ff676

View file

@ -21,8 +21,9 @@ PKG_LICENSE:=GPL-2.0+
PKG_LICENSE_FILES:=COPYING PKG_LICENSE_FILES:=COPYING
PKG_MAINTAINER:=Jiri Slachta <jiri@slachta.eu> PKG_MAINTAINER:=Jiri Slachta <jiri@slachta.eu>
# Defining PKG_BUILD_PARALLEL to 1 would be a noop due to the way we call make PKG_INSTALL:=1
#PKG_BUILD_PARALLEL:=1
PKG_BUILD_PARALLEL:=1
MODULES_AVAILABLE:= \ MODULES_AVAILABLE:= \
acc \ acc \
@ -388,9 +389,6 @@ endef
# "ims_diameter_server" -> libkamailio_ims # "ims_diameter_server" -> libkamailio_ims
# "carrierroute" -> libtrie # "carrierroute" -> libtrie
# "lib_target" is specified in order for the modules to get a proper
# RPATH, as otherwise they would not find the internal libraries.
EXTRA_MODULES:= \ EXTRA_MODULES:= \
$(if $(CONFIG_PACKAGE_kamailio5-mod-carrierroute),,carrierroute) \ $(if $(CONFIG_PACKAGE_kamailio5-mod-carrierroute),,carrierroute) \
$(if $(CONFIG_PACKAGE_kamailio5-mod-ims-diameter-server),,ims_diameter_server) \ $(if $(CONFIG_PACKAGE_kamailio5-mod-ims-diameter-server),,ims_diameter_server) \
@ -408,35 +406,26 @@ ifeq ($(call qstrip,$(CONFIG_ARCH)),mips)
CPU_MIPS2:=mips32 24kc 34kc 74kc CPU_MIPS2:=mips32 24kc 34kc 74kc
endif endif
PKG_MAKE_ARGS:= \ MAKE_FLAGS += \
prefix=/ \ $(if $(findstring $(call qstrip,$(CONFIG_CPU_TYPE)),$(CPU_MIPS2)),ARCH="mips2",ARCH="$(ARCH)") \
cfg_dir=/etc/kamailio/ \ CC_EXTRA_OPTS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
bin_dir=/usr/sbin/ \ LD="$(TARGET_CC)" \
data_dir=/usr/share/kamailio/ \ LD_EXTRA_OPTS="$(TARGET_LDFLAGS)" \
lib_dir=/usr/lib/kamailio/ \ LIBDIR=lib \
modules_dir=/usr/lib/kamailio/ \ PREFIX=/usr \
cfg_prefix="$(PKG_INSTALL_DIR)" \
cfg_target=/etc/kamailio \
group_include="standard" \ group_include="standard" \
include_modules="$$(INCL_MODULES) $(EXTRA_MODULES)" \ include_modules="$$(INCL_MODULES) $(EXTRA_MODULES)" \
cfg_target=/etc/kamailio/ \ quiet=verbose \
lib_target=/usr/lib/kamailio/ \ run_prefix=""
run_target=/var/run/kamailio/ \
CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
LD_EXTRA_OPTS="$(TARGET_LDFLAGS)" \
LOCALBASE="$(STAGING_DIR)/usr" \
SYSBASE="$(STAGING_DIR)/usr" \
CROSS_COMPILE=$(TARGET_CROSS) \
CC="$(TARGET_CC)" \
$(if $(findstring $(call qstrip,$(CONFIG_CPU_TYPE)),$(CPU_MIPS2)),ARCH="mips2",ARCH="$(ARCH)") \
DESTDIR=$(PKG_INSTALL_DIR) \
quiet=verbose
define Build/Configure define Build/Configure
endef endef
define Build/Compile define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) $(PKG_MAKE_ARGS) cfg $(call Build/Compile/Default,cfg)
$(MAKE) -C $(PKG_BUILD_DIR) quiet=verbose all $(call Build/Compile/Default,all)
$(MAKE) -C $(PKG_BUILD_DIR) quiet=verbose install
endef endef
$(eval $(call BuildPackage,kamailio5)) $(eval $(call BuildPackage,kamailio5))