File debian.rules of Package linphone

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

export LinphoneCoreVersion = 5.2.97

# Uncomment this to turn on verbose mode.
export DH_VERBOSE = 1
export DIR_WHERE_FIRST_CMAKELISTS_DOT_TEXT_IS = buildstartshere

# Get some information about the machine we are building on:
export ARCHITECTURE=$(shell uname -m)
export numberOfProcessorsOnMachine=$(shell nproc)
export wantedJobs=$(shell echo "1.25*$(numberOfProcessorsOnMachine)" | bc -l)
export jobsIget=$(shell echo $(wantedJobs) | awk '{print int($$1+0.5)}')
export TOTAL_DISK = $(shell df -h --total | awk 'END{print $$2}')
export FREEMEM = $(shell free --mega)
export TOTAL_MEM = $(shell free --total --mega | xargs | awk '{print $$19"MB"}')
export TOTAL_RAM = $(shell free --total --mega | xargs | awk '{print $$8"MB"}')
export TOTAL_SWAP = $(shell free --total --mega | xargs | awk '{print $$15"MB"}')

export PRETTY_NAME=$(shell cat /etc/*-release | egrep "PRETTY_NAME" | cut -d = -f 2)

#ifeq ($(PRETTY_NAME),Raspbian)
#    export PLATFORM=Raspbian
#    export BUILDDIR=obj-arm-linux-gnueabihf
#    export LIBDIR=arm-linux-gnueabihf
#endif

ifeq ($(findstring Raspbian,$(PRETTY_NAME)),Raspbian)
    # Found
    export PLATFORM=Raspbian
    export BUILDDIR=obj-arm-linux-gnueabihf
    export LIBDIR=arm-linux-gnueabihf
else
    # Not found
    export PLATFORM=DebianOrUbuntu
    export BUILDDIR=obj-x86_64-linux-gnu
    export LIBDIR=x86_64-linux-gnu
endif



%:
	echo
	echo "----- Entering section % -----"
	echo
	# Template:    
	# dh $@ --buildsystem=cmake --builddirectory=$(DIR_WHERE_FIRST_CMAKELISTS_DOT_TEXT_IS) --parallel --max-parallel=$(jobsIget)
	dh $@ --buildsystem=cmake --parallel --max-parallel=$(jobsIget)
	echo
	echo "----- Exiting section % -----"
	echo
    


override_dh_update_autotools_config:
	echo
	echo "--- Start override_dh_update_autotools_config: ---"
	echo
	echo "Skipping running override_dh_update_autotools_config"
	echo
	echo "--- End override_dh_update_autotools_config: ---"
	echo
    


override_dh_autoreconf:
	echo
	echo "--- Start override_dh_autoreconf: ---"
	echo
	echo "Skipping running dh_autoreconf"
	echo
	echo "--- End override_dh_autoreconf: ---"
	echo
    


override_dh_auto_configure:
	echo
	echo "--- Start override_dh_auto_configure: ---"
	echo
	echo "--- Machine data we are building on ---"
	echo "ARCHITECTURE: $$ARCHITECTURE"
	echo "Total disk: $$TOTAL_DISK"
	echo "Output of free -h:"
	echo "$$FREEMEM" 
	echo "Total memory: $$TOTAL_MEM"
	echo "Total RAM: $$TOTAL_RAM"
	echo "Total SWAP: $$TOTAL_SWAP"
	echo "numberOfProcessorsOnMachine=$$numberOfProcessorsOnMachine"
	echo "wantedJobs=$$wantedJobs"
	echo "jobsIget=$$jobsIget"
	echo "--- End machine data we are building on ---"
	echo
	echo "--- List files ---"
	ls /usr/lib
	find /usr/src/packages
	echo "--- End list files ---"
	echo
	echo "Current directory:" #/usr/src/packages/BUILD
	echo "    $(shell pwd)"
	echo
	echo PRETTY_NAME=$(PRETTY_NAME)
	echo PLATFORM=$(PLATFORM)
	echo BUILDDIR=$(BUILDDIR)
	echo LIBDIR=$(LIBDIR)
	echo
	# To avoid error, we have to create directory Debian/Ubuntu:
	# /usr/src/packages/BUILD/obj-x86_64-linux-gnu
	# On Raspbian we have to create directory:
	# /usr/src/packages/BUILD/obj-arm-linux-gnueabihf
	mkdir -v $(BUILDDIR)
	#
	# patch LinphoneCore version
	sed -i "s|project(linphone VERSION 5.2.[0-9]* LANGUAGES C CXX)|project(linphone VERSION $(LinphoneCoreVersion) LANGUAGES C CXX)|g" CMakeLists.txt
	cat 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/src/FlexiAPIClient.cc; \
	#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
	# cmake -S /path/to/source-dir -B /path/to/build-dir -DCMAKE_VARIABLES_HERE=something
	# CMAKE Options for reference when not used:
	#  -DENABLE_QRCODE=ON
	#  -DENABLE_FLEXIAPI=ON # This is needed by linphoneqt
	cmake -S /usr/src/packages/BUILD/ -B /usr/src/packages/BUILD/$(BUILDDIR) \
	  -DCMAKE_BUILD_PARALLEL_LEVEL=$(jobsIget) \
	  -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_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
	echo
	echo "--- End override_dh_auto_configure: ---"
	echo
    


override_dh_auto_test:
	echo
	echo "--- Start override_dh_auto_test: ---"
	echo
	echo "Skipping running dh_auto_test"
	echo
	echo "--- End override_dh_auto_test: ---"
	echo



override_after_dh_auto_install:
	echo
	echo "--- Start override_after_dh_auto_install: ---"
	echo
	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 "--- End override_after_dh_auto_install: ---"
	echo



override_dh_shlibdeps:
	dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info
openSUSE Build Service is sponsored by