File debian.rules of Package linphone

#!/usr/bin/make -f
# -*- makefile -*-

# Uncomment this to turn on verbose mode.
export DH_VERBOSE=1
# Set debhelper options
DEB_BUILD_OPTIONS=nocheck
export pkgname=bcunit
export _topdir=/usr/src/packages
export _builddir=$(_topdir)/BUILD
export _sourcedir=$(_topdir)/SOURCES
export uploaddir=/usr/src/packages/SOURCES
export srcdir=/usr/src/packages/SOURCES
export pkgdir_head=/usr/src/packages/BUILD/debian
#export pkgdir=$(pkgdir_head)/$(pkgname)
export pkgdir=$(pkgdir_head)/tmp
export buildroot=/usr/src/packages/BUILD/debian/tmp
#export buildroot=/usr/src/packages/BUILD/debian/$(pkgname)
# Add support for different Debian based distributions
export VERSION_CODENAME = $(shell cat /etc/os-release | grep VERSION_CODENAME | awk -F= '{print $$2}')
export VERSION_ID = $(shell cat /etc/os-release | grep VERSION_ID | awk -F= '{print $$2}')
export PRETTY_NAME=$(shell cat /etc/*-release | egrep "PRETTY_NAME" | cut -d = -f 2)
export ARCHITECTURE=$(shell dpkg --print-architecture)
export MY_DEB_BUILD_ARCH=$(shell dpkg-architecture -q DEB_BUILD_ARCH)
ifeq ($(findstring arm64,$(ARCHITECTURE)),arm64)
    export ARCHTYPE=aarch64
    export BUILDDIR=obj-$(ARCHTYPE)-linux-gnu
    export LIBDIR=$(ARCHTYPE)-linux-gnu
endif
ifeq ($(findstring amd64,$(ARCHITECTURE)),amd64)
    export ARCHTYPE=x86_64
    export BUILDDIR=obj-$(ARCHTYPE)-linux-gnu
    export LIBDIR=$(ARCHTYPE)-linux-gnu
endif
ifeq ($(findstring armhf,$(ARCHITECTURE)),armhf)
    export ARCHTYPE=arm
    export BUILDDIR=obj-$(ARCHTYPE)-linux-gnueabihf
    export LIBDIR=$(ARCHTYPE)-linux-gnueabihf
endif
ifeq ($(findstring Raspbian,$(PRETTY_NAME)),Raspbian)
    # Found
    export PLATFORM=Raspbian
endif
ifeq ($(findstring Debian,$(PRETTY_NAME)),Debian)
    # Not found
    export PLATFORM=DebianOrUbuntu
endif
ifeq ($(findstring Ubuntu,$(PRETTY_NAME)),Ubuntu)
    # Not found
    export PLATFORM=DebianOrUbuntu
endif
export SOURCES_ARE_HERE=/usr/src/packages/BUILD/
export BUILD_IT_HERE=/usr/src/packages/BUILD/$(BUILDDIR)/


# Obsolete when using set_current_version.patch
# export LinphoneCoreVersion = 5.2.98
#export PRETTY_NAME=$(shell cat /etc/*-release | egrep "PRETTY_NAME" | cut -d = -f 2)
#export pkgname=liblinphone
#export uploaddir=/usr/src/packages/SOURCES
#export pkgdir_head=/usr/src/packages/BUILD/debian
#export pkgdir=$(pkgdir_head)/$(pkgname)
#export pkgdir=$(pkgdir_head)/tmp
#export buildroot=/usr/src/packages/BUILD/debian/tmp
#export buildroot=/usr/src/packages/BUILD/debian/$(pkgname)

%:
	dh $@ --buildsystem=cmake

override_dh_update_autotools_config:

override_dh_autoreconf:

override_dh_auto_configure:
	echo "Different Debian based distros need different patches and adjustments."
	echo PRETTY_NAME=$(PRETTY_NAME)
	echo ARCHITECTURE=$(ARCHITECTURE)
	echo DEB_BUILD_ARCH=$(DEB_BUILD_ARCH)
	echo MY_DEB_BUILD_ARCH=$(MY_DEB_BUILD_ARCH)
	echo PLATFORM=$(PLATFORM)
	echo BUILDDIR=$(BUILDDIR)
	echo LIBDIR=$(LIBDIR)
	echo
	echo pwd=$(shell pwd)
	echo
	echo "Installs $(pkgname)"
	echo _topdir=$(_topdir)
	echo _builddir=$(_builddir)
	echo _sourcedir=$(_sourcedir)
	echo uploaddir=$(uploaddir)
	echo srcdir=$(srcdir)
	echo pkgdir_head=$(pkgdir_head)
	echo pkgdir=$(pkgdir)
	echo buildroot=$(buildroot)
	echo "----------------------------------------"
	#mkdir -pv $(BUILDDIR)
	mkdir -pv $(BUILD_IT_HERE)
	# Adjust Linphone core version shown in About box (or use set_current_version.patch)
	# sed -i "s|project(linphone VERSION 5.2.[0-9]* LANGUAGES C CXX)|project(linphone VERSION $(LinphoneCoreVersion) LANGUAGES C CXX)|g" CMakeLists.txt
	# Fix the include path to <json/json.h> to <jsoncpp/json/json.h> :
	#MODIFY_FILE=/usr/src/packages/BUILD/include/linphone/FlexiAPIClient.hh; \
	#sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $$MODIFY_FILE
	#MODIFY_FILE=/usr/src/packages/BUILD/src/FlexiAPIClient.hh; \
	#sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $$MODIFY_FILE
	MODIFY_FILE=/usr/src/packages/BUILD/include/linphone/flexi-api-client.h; \
	sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $$MODIFY_FILE
	#MODIFY_FILE=/usr/src/packages/BUILD/src/FlexiAPIClient.cc; \
	#sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $$MODIFY_FILE
	MODIFY_FILE=/usr/src/packages/BUILD/src/account_creator/flexi-api-client.cpp; \
	sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $$MODIFY_FILE
	#MODIFY_FILE=/usr/src/packages/BUILD/tester/remote-provisioning-tester.cpp; \
	#sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $$MODIFY_FILE
	#MODIFY_FILE=/usr/src/packages/BUILD/tester/flexiapiclient-tester.cpp; \
	#sed -i 's/#include <json\/json\.h>/#include <jsoncpp\/json\/json.h>/g' $$MODIFY_FILE
	#if $(DEB_BUILD_ARCH) aarch64
	#  usr/lib/x86_64-linux-gnu/liblinphone ; \
	#  usr/lib/x86_64-linux-gnu/liblinphone/plugins ;
	#  /usr/lib/aarch64-linux-gnu/liblinphone/plugins
	find .
	if [ "$(DEB_BUILD_ARCH)" = "arm64" ]; then \
	  sed -i 's/x86_64/aarch64/g' debian/liblinphone-dev.dirs ; \
	  cat debian/liblinphone-dev.dirs ; \
	elif [ "$(DEB_BUILD_ARCH)" = "armhf" ]; then \
	  sed -i 's/x86_64-linux-gnu/arm-linux-gnueabihf/g' debian/liblinphone-dev.dirs ; \
	  cat debian/liblinphone-dev.dirs ; \
	fi
	# CMAKE Options for reference when not used:
	#  -DENABLE_QRCODE=ON
	#  -DENABLE_FLEXIAPI=ON # This is needed by linphoneqt
	#  -DCMAKE_EXE_LINKER_FLAGS="-Wl,--start-group -ljsoncpp -Wl,--end-group" \
	#cmake -S /usr/src/packages/BUILD/ -B /usr/src/packages/BUILD/$(BUILDDIR) \
	cmake -S $(SOURCES_ARE_HERE) -B $(BUILD_IT_HERE) \
	  -DCMAKE_INSTALL_LIBDIR=lib/$(LIBDIR) \
	  -DCMAKE_INSTALL_PREFIX=/usr \
	  -DCMAKE_PREFIX_PATH="$$CMAKE_PREFIX_PATH;/usr/include/jsoncpp" \
	  -DCMAKE_LIBRARY_PATH="$$CMAKE_LIBRARY_PATH;/usr/lib/$(LIBDIR)/" \
	  -DJSONCPP_INCLUDE_DIRS=/usr/include/jsoncpp \
	  -DCMAKE_EXE_LINKER_FLAGS="-Wl,--start-group -ljsoncpp" \
	  -DCMAKE_VERBOSE_MAKEFILE=ON \
	  -DCMAKE_BUILD_TYPE=Debug \
	  -DENABLE_STRICT=OFF \
	  -DBUILD_SHARED_LIBS=YES \
	  -DENABLE_STATIC=OFF \
	  -DENABLE_UNIT_TESTS=OFF \
	  -DENABLE_QRCODE=OFF \
	  -DENABLE_DOC=OFF

override_dh_auto_test:

execute_before_dh_auto_install:
	echo "--- Start execute_before_dh_auto_install ---"
	echo "--- End execute_before_dh_auto_install ---"

execute_after_dh_auto_install:
	echo "--- Start execute_after_dh_auto_install ---"
	echo "Different Debian based distros need different patches and adjustments."
	echo PRETTY_NAME=$(PRETTY_NAME)
	echo ARCHITECTURE=$(ARCHITECTURE)
	echo DEB_BUILD_ARCH=$(DEB_BUILD_ARCH)
	echo MY_DEB_BUILD_ARCH=$(MY_DEB_BUILD_ARCH)
	echo PLATFORM=$(PLATFORM)
	echo BUILDDIR=$(BUILDDIR)
	echo LIBDIR=$(LIBDIR)
	echo
	echo pwd=$(shell pwd)
	echo
	echo "Installs $(pkgname)"
	echo _topdir=$(_topdir)
	echo _builddir=$(_builddir)
	echo _sourcedir=$(_sourcedir)
	echo uploaddir=$(uploaddir)
	echo srcdir=$(srcdir)
	echo pkgdir_head=$(pkgdir_head)
	echo pkgdir=$(pkgdir)
	echo buildroot=$(buildroot)
	echo "----------------------------------------"
	echo
	# Exchange static camera picture
	#mkdir -pv $(buildroot)/usr/share/linphone/images
	#cp -v /usr/src/packages/SOURCES/nowebcamCIF.jpg $(buildroot)/usr/share/linphone/images/nowebcamCIF.jpg
	#echo "Find and remove file: rootca.pem"
	#echo "--------------------------------"    
	#echo "rm -f /usr/src/packages/BUILD/debian/tmp/usr/share/linphone/rootca.pem"
	#echo "or"   
	#echo "find . -type f -name rootca.pem -exec rm {} \;"
	#find . -type f -name rootca.pem -exec rm {} \;
	echo
	echo pkgdir=${pkgdir}
	echo "--- Files that will be packaged ---"
	find $(buildroot) | sed "s|${pkgdir}||g" | sort
	echo "--- End files that will be packaged ---"
	echo "--- End execute_after_dh_auto_install ---"

override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

openSUSE Build Service is sponsored by