pkg/kamailio/deb/precise/rules
90379ff3
 #!/usr/bin/make -f
 # Sample debian/rules that uses debhelper.
 # GNU copyright 1997 to 1999 by Joey Hess.
 
806489af
 DEBVERSION:=$(shell head -n 1 debian/changelog \
                     | sed -e 's/^[^(]*(\([^)]*\)).*/\1/')
 UPVERSION:=$(shell dpkg-parsechangelog | sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
 
 FILENAME := kamailio_$(UPVERSION).orig.tar.gz
 URL := http://www.kamailio.org/pub/kamailio/$(UPVERSION)/src/kamailio-$(UPVERSION)_src.tar.gz
 
 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 DPKG_EXPORT_BUILDFLAGS = 1
 include /usr/share/dpkg/buildflags.mk
90379ff3
 
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
 
8d7d72ad
 export JAVA_HOME=/usr/lib/jvm/java-gcj
90379ff3
 
 # modules not in the "main" kamailio package
806489af
 EXCLUDED_MODULES=
90379ff3
 
 # extra modules to skip, because they are not compilable now
 # - regardless if they go to the main kamailio package or to some module package,
 # they will be excluded from compile and install of all
e5d8c17d
 EXTRA_EXCLUDED_MODULES=bdb dbtext oracle pa iptrtpproxy mi_xmlrpc dnssec kazoo cnxcc systemd rabbitmq geoip2 phonenum mongodb ruby python3 mqtt
90379ff3
 
 # module groups that are packaged in seperate packages
 # (with the name kamailio-$(group_name)-modules)
 # Note: the order is important (should be in dependency order, the one
 # on which other depend first)
 PACKAGE_GROUPS=mysql postgres berkeley unixodbc radius presence \
806489af
 			   ldap xml perl utils lua memcached \
f4f2b7b2
 			   snmpstats carrierroute xmpp cpl redis python geoip \
127b3280
 			   sqlite json mono ims sctp java \
09d97d9e
 			   tls outbound websocket autheph \
e5d8c17d
 			   erlang 
90379ff3
 
a1de51c5
 # module groups to be packaged onto kamailio-extra-modules
72daa184
 EXTRA_GROUPS=gzcompress uuid ev jansson http_async
a1de51c5
 
90379ff3
 # name of libdir in the path for libraries (e.g., lib for 32b, lib64 for 64b)
86c4168d
 export LIBDIR ?= lib/$(DEB_HOST_MULTIARCH)
90379ff3
 
 # directories with possible duplicate libraries (that should be deleted
 # from current module* packages)
 DUP_LIBS_DIRS=$(CURDIR)/debian/kamailio/usr/$(LIBDIR)/kamailio \
 			$(CURDIR)/debian/kamailio-db-modules/usr/$(LIBDIR)/kamailio
 
 # "function" to get package short name out of a dir/module_name
 # it also transforms db_foo into foo
 mod_name=$(subst db_,,$(lastword $(subst /, ,$(1))))
 
 define PACKAGE_GRP_BUILD_template
 	# package all the modules in PACKAGE_GROUPS in separate packages
2115943f
 	$(foreach grp,$(PACKAGE_GROUPS),\
9ccc072c
 		$(MAKE) every-module group_include="k$(grp)" quiet=verbose
90379ff3
 	)
 endef
 
 define PACKAGE_GRP_INSTALL_template
 	$(foreach grp,$(PACKAGE_GROUPS),\
806489af
 		$(MAKE) install-modules-all LIBDIR=$(LIBDIR) group_include="k$(grp)" \
bf39780f
 		BASEDIR=$(CURDIR)/debian/kamailio-$(grp)-modules \
90379ff3
 		cfg_prefix=$(CURDIR)/debian/kamailio-$(grp)-modules \
9ccc072c
 		doc-dir=share/doc/kamailio-$(grp)-modules quiet=verbose
90379ff3
 		# eliminate duplicate libs
 		-for d in $(DUP_LIBS_DIRS); do \
 			test "$$d" != "$(CURDIR)/debian/kamailio-$(grp)-modules/usr/$(LIBDIR)/kamailio" &&\
806489af
 			for r in `find $$d -name 'lib*'|xargs`; do \
 				echo "removing $(grp) lib `basename $$r` present also in $$d";\
 				rm -f $(CURDIR)/debian/kamailio-$(grp)-modules/usr/$(LIBDIR)/kamailio/`basename "$$r"` ; \
90379ff3
 			done ; \
 		done
806489af
 		find $(CURDIR)/debian/kamailio-$(grp)-modules -depth -empty -type d -exec rmdir {} \;
90379ff3
 	)
 endef
 
2115943f
 define PACKAGE_EXTRA_BUILD_template
 	# package all the modules in EXTRA_GROUPS in separate packages
 	$(foreach grp,$(EXTRA_GROUPS),\
9ccc072c
 		$(MAKE) every-module group_include="k$(grp)" quiet=verbose
2115943f
 	)
 endef
 
a1de51c5
 define PACKAGE_EXTRA_INSTALL_template
 	$(foreach grp,$(EXTRA_GROUPS),\
 		$(MAKE) install-modules-all LIBDIR=$(LIBDIR) group_include="k$(grp)" \
bf39780f
 		BASEDIR=$(CURDIR)/debian/kamailio-extra-modules \
a1de51c5
 		cfg_prefix=$(CURDIR)/debian/kamailio-extra-modules \
9ccc072c
 		doc-dir=share/doc/kamailio-extra-modules quiet=verbose
a1de51c5
 	)
 	# eliminate duplicate libs
 	-for d in $(DUP_LIBS_DIRS); do \
 		test "$$d" != "$(CURDIR)/debian/kamailio-extra-modules/usr/$(LIBDIR)/kamailio" &&\
 		for r in `find $$d -name 'lib*'|xargs`; do \
 			echo "removing extra lib `basename $$r` present also in $$d";\
 			rm -f $(CURDIR)/debian/kamailio-extra-modules/usr/$(LIBDIR)/kamailio/`basename "$$r"` ; \
 		done ; \
 	done
 	find $(CURDIR)/debian/kamailio-extra-modules -depth -empty -type d -exec rmdir {} \;
 endef
90379ff3
 
806489af
 # CFLAGS + CPPFLAGS -> CC_EXTRA_OPTS
a5b3c636
 CC_EXTRA_OPTS := $(shell dpkg-buildflags --get CPPFLAGS)
6ba9900f
 CC_EXTRA_OPTS += $(shell DEB_CFLAGS_MAINT_STRIP=-O2 dpkg-buildflags --get CFLAGS)
 CXXFLAGS := $(shell DEB_CXXFLAGS_MAINT_STRIP=-O2 dpkg-buildflags --get CXXFLAGS)
806489af
 # LDFLAGS -> LD_EXTRA_OPTS
a5b3c636
 LD_EXTRA_OPTS := $(shell dpkg-buildflags --get LDFLAGS)
806489af
 
15ab2ed2
 # https://wiki.debian.org/ReproducibleBuilds/
 CC_EXTRA_OPTS += -DVERSION_NODATE
 
90379ff3
 configure: configure-stamp
 configure-stamp:
 	dh_testdir
 	# Add here commands to configure the package.
 	$(MAKE) FLAVOUR=kamailio cfg prefix=/usr cfg_prefix=$(CURDIR)/debian/kamailio \
 			cfg_target=/etc/kamailio/ \
bf39780f
 			BASEDIR=$(CURDIR)/debian/kamailio \
90379ff3
 			skip_modules="$(EXCLUDED_MODULES) $(EXTRA_EXCLUDED_MODULES)" \
a5b3c636
 			CC_EXTRA_OPTS="$(CC_EXTRA_OPTS)" \
 			LD_EXTRA_OPTS="$(LD_EXTRA_OPTS)" \
9ccc072c
 			group_include="kstandard" quiet=verbose
90379ff3
 
 	touch configure-stamp
 
 
 build: build-stamp
806489af
 build-arch: build-stamp
 build-indep: build-stamp
 build-stamp: configure-stamp
90379ff3
 	dh_testdir
 	# Add here commands to compile the package.
9ccc072c
 	$(MAKE) all quiet=verbose
90379ff3
 	# make groups
 	$(call PACKAGE_GRP_BUILD_template)
2115943f
 	$(call PACKAGE_EXTRA_BUILD_template)
90379ff3
 	touch build-stamp
 
 clean:
 	dh_testdir
 	dh_testroot
 	rm -f build-stamp configure-stamp
 	# Add here commands to clean up after the build process.
806489af
 	$(MAKE) maintainer-clean
90379ff3
 	dh_clean
 
 install: build
 	dh_testdir
 	dh_testroot
806489af
 	dh_prep
90379ff3
 	dh_installdirs
 	# Add here commands to install the package into debian/kamailio
86c4168d
 	$(MAKE) install group_include="kstandard"
90379ff3
 	# make group packages
 	$(call PACKAGE_GRP_INSTALL_template)
a1de51c5
 	$(call PACKAGE_EXTRA_INSTALL_template)
806489af
 	mv $(CURDIR)/debian/kamailio-berkeley-modules/usr/sbin/kambdb_recover \
 		$(CURDIR)/debian/kamailio-berkeley-bin/usr/sbin/kambdb_recover
90379ff3
 	# install /etc/default/kamailio file
 	mkdir -p $(CURDIR)/debian/kamailio/etc/default
 	cp -f debian/kamailio.default $(CURDIR)/debian/kamailio/etc/default/kamailio
cbf9f0dd
 	# delete /run/kamailio dir
bf39780f
 	rm -rf $(CURDIR)/debian/kamailio/usr/local
90379ff3
 
 
 # This single target is used to build all the packages, all at once, or
 # one at a time. So keep in mind: any options passed to commands here will
 # affect _all_ packages. Anything you want to only affect one package
 # should be put in another target, such as the install target.
806489af
 binary-common:
90379ff3
 	dh_testdir
 	dh_testroot
806489af
 	dh_installdebconf
90379ff3
 	dh_installdocs
1950e38d
 	dh_installexamples -Xobsoleted -Xsr
90379ff3
 	dh_installmenu
806489af
 	dh_installinit -pkamailio -- defaults 23
90379ff3
 	dh_installcron
 	dh_installman
 	dh_installinfo
34720cbb
 	dh_lintian
806489af
 	dh_installchangelogs ChangeLog
90379ff3
 	dh_link
 	dh_strip --dbg-package=kamailio-dbg
806489af
 	dh_compress
90379ff3
 	dh_fixperms
 	dh_makeshlibs
 	dh_installdeb
 	dh_shlibdeps
 	dh_gencontrol
 	dh_md5sums
 	dh_builddeb
 
 # Build architecture-independent packages using the common target
 binary-indep: build install
 # (Uncomment this next line if you have such packages.)
 #        $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
 # We have nothing to do by default.
 
 
 # Build architecture-dependent packages using the common target
 binary-arch: build install
 	$(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
 
 # Any other binary targets build just one binary package at a time.
 binary-%: build install
 	$(MAKE) -f debian/rules binary-common DH_OPTIONS=-p$*
 
806489af
 print-version:
 	@@echo "Debian version:          $(DEBVERSION)"
 	@@echo "Upstream version:        $(UPVERSION)"
 
 get-orig-source:
 	@@dh_testdir
 	@@[ -d ../tarballs/. ]||mkdir -p ../tarballs
 	@@echo Downloading $(FILENAME) from $(URL) ...
 	@@wget -nv -T10 -t3 -O ../tarballs/$(FILENAME) $(URL)
 
90379ff3
 binary: binary-indep binary-arch
 .PHONY: build clean binary-indep binary-arch binary install configure