#!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) ALL_PACKAGES = openser openser-mysql-module openser-postgres-module \ openser-jabber-module openser-cpl-module openser-radius-modules \ openser-unixodbc-module openser-presence-modules openser-xmlrpc-module \ openser-perl-module openser-snmpstats-module openser-xmpp-module DEBVERSION:=$(shell head -n 1 debian/changelog \ | sed -e 's/^[^(]*(\([^)]*\)).*/\1/') UPVERSION:=$(shell echo $(DEBVERSION) | sed -e 's/^.*://' -e 's/-[0-9.]*$$//' -e 's/.dfsg$$//') FILENAME := openser_$(UPVERSION).orig.tar.gz UPFILENAME := openser-$(UPVERSION)-tls_src.tar.gz URL := http://openser.org/pub/openser/$(UPVERSION)/src/openser-$(UPVERSION)-tls_src.tar.gz # Uncomment this to turn on verbose mode. # export DH_VERBOSE=1 # Include dpatch rules include /usr/share/dpatch/dpatch.make # Do we want the TLS version ? # Disabled by default due to license issues, set to non-void to enable TLS= # modules depending on mysql MYSQL_MODULES = mysql # modules depending on postgres POSTGRES_MODULES = postgres # modules depending on unixODBC UNIXODBC_MODULES=unixodbc # jabber module JABBER_MODULES = jabber # cpl related modules CPL_MODULES = cpl-c # module depending on radiusclient RADIUS_MODULES = avp_radius auth_radius group_radius uri_radius # presence related modules PRESENCE_MODULES = presence pua pua_mi pua_usrloc # XMLRPC module XMLRPC_MODULES = mi_xmlrpc # Perl module PERL_MODULES = perl # SNMPstats module SNMPSTATS_MODULES = snmpstats # XMPP module XMPP_MODULES = xmpp ALL_MODULES = $(MYSQL_MODULES) $(POSTGRES_MODULES) $(UNIXODBC_MODULES) $(JABBER_MODULES) $(CPL_MODULES) $(RADIUS_MODULES) $(PRESENCE_MODULES) $(XMLRPC_MODULES) $(PERL_MODULES) $(SNMPSTATS_MODULES) $(XMPP_MODULES) # modules not in the "main" package or unstable modules EXCLUDED_MODULES = $(ALL_MODULES) pa osp # the same but with path prepended (needed for modules="...") MYSQL_MOD_PATH=$(addprefix modules/, $(MYSQL_MODULES)) POSTGRES_MOD_PATH=$(addprefix modules/, $(POSTGRES_MODULES)) UNIXODBC_MOD_PATH=$(addprefix modules/, $(UNIXODBC_MODULES)) JABBER_MOD_PATH=$(addprefix modules/, $(JABBER_MODULES)) CPL_MOD_PATH=$(addprefix modules/, $(CPL_MODULES)) RADIUS_MOD_PATH=$(addprefix modules/, $(RADIUS_MODULES)) PRESENCE_MOD_PATH=$(addprefix modules/, $(PRESENCE_MODULES)) XMLRPC_MOD_PATH=$(addprefix modules/, $(XMLRPC_MODULES)) PERL_MOD_PATH=$(addprefix modules/, $(PERL_MODULES)) SNMPSTATS_MOD_PATH=$(addprefix modules/, $(SNMPSTATS_MODULES)) XMPP_MOD_PATH=$(addprefix modules/, $(XMPP_MODULES)) ifeq (cc, $(CC)) CC = gcc endif CFLAGS = -Wall -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif configure: configure-stamp configure-stamp: dh_testdir # Add here commands to configure the package. touch configure-stamp build: build-stamp build-stamp: patch-stamp configure-stamp dh_testdir # Add here commands to compile the package. CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) all skip_modules="$(EXCLUDED_MODULES)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(MYSQL_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(POSTGRES_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(UNIXODBC_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(JABBER_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(CPL_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(RADIUS_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(PRESENCE_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(XMLRPC_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(PERL_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(SNMPSTATS_MOD_PATH)" cfg-target=/etc/openser/ CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) modules modules="$(XMPP_MOD_PATH)" cfg-target=/etc/openser/ touch build-stamp clean: real-clean unpatch real-clean: dh_testdir dh_testroot rm -f build-stamp configure-stamp # Add here commands to clean up after the build process. -$(MAKE) TLS=$(TLS) include_modules="$(ALL_MODULES)" proper rm -f cfg.tab.h rm -f utils/openserunix/openserunix.o utils/openserunix/openserunix dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs # Add here commands to install the package into debian/openser # openser base package CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install skip_modules="$(EXCLUDED_MODULES)" \ basedir=$(CURDIR)/debian/openser \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser \ cfg-target=/etc/openser/ find $(CURDIR)/debian/openser/etc/openser -type f -exec chmod -x {} \; sed -i -e "s/^PATH.*//" $(CURDIR)/debian/openser/usr/sbin/openserctl # install only the mysql module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(MYSQL_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-mysql-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-mysql-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-mysql-module mv $(CURDIR)/debian/openser-mysql-module/usr/sbin/openser_mysql.sh $(CURDIR)/debian/openser-mysql-module/usr/sbin/openser_mysql sed -i -e "s/^PATH.*//" $(CURDIR)/debian/openser-mysql-module/usr/sbin/openser_mysql chmod +x $(CURDIR)/debian/openser-mysql-module/usr/sbin/openser_mysql # install only the postgres module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(POSTGRES_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-postgres-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-postgres-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-postgres-module mv $(CURDIR)/debian/openser-postgres-module/usr/sbin/openser_postgresql.sh $(CURDIR)/debian/openser-postgres-module/usr/sbin/openser_postgresql sed -i -e "s/^PATH.*//" $(CURDIR)/debian/openser-postgres-module/usr/sbin/openser_postgresql chmod +x $(CURDIR)/debian/openser-postgres-module/usr/sbin/openser_postgresql # install only the unixodbc module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(UNIXODBC_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-unixodbc-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-unixodbc-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-unixodbc-module # install only the jabber module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(JABBER_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-jabber-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-jabber-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-jabber-module # install only the cpl module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(CPL_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-cpl-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-cpl-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-cpl-module # install only the radius modules CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(RADIUS_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-radius-modules \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-radius-modules \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-radius-modules mkdir -p $(CURDIR)/debian/openser-radius-modules/etc/openser/ mv $(CURDIR)/debian/openser/etc/openser/dictionary.radius $(CURDIR)/debian/openser-radius-modules/etc/openser/ # install only the presence modules CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(PRESENCE_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-presence-modules \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-presence-modules \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-presence-modules # install only the xmlrpc module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(XMLRPC_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-xmlrpc-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-xmlrpc-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-xmlrpc-module # install only the perl module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(PERL_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-perl-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-perl-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-perl-module # install only the snmpstats module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(SNMPSTATS_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-snmpstats-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-snmpstats-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-snmpstats-module # install only the xmpp module CC="$(CC)" CFLAGS="$(CFLAGS)" TLS=$(TLS) $(MAKE) install-modules-all modules="$(XMPP_MOD_PATH)" \ basedir=$(CURDIR)/debian/openser-xmpp-module \ prefix=/usr \ cfg-prefix=$(CURDIR)/debian/openser-xmpp-module \ cfg-target=/etc/openser/ \ doc-dir=share/doc/openser-xmpp-module # the modules packages all ship an empty /usr/sbin directory, let's clean that up for p in $(ALL_PACKAGES); \ do rmdir --ignore-fail-on-non-empty $(CURDIR)/debian/$$p/usr/sbin; done # 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. binary-arch: build install dh_testdir dh_testroot dh_installdocs dh_installexamples --exclude=".svn" # dh_installlogrotate dh_installinit -popenser -- defaults 23 dh_installcron dh_installman dh_installinfo dh_installchangelogs dh_link dh_strip --dbg-package=openser-dbg dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb # Build architecture-independent packages using the common target binary-indep: build install # We have nothing to do by default. binary: binary-indep binary-arch 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 -N -nv -T10 -t3 -O ../tarballs/$(FILENAME) $(URL) .PHONY: build clean binary-indep binary-arch binary install configure patch unpatch real-clean