%define name    ser
%define ver     2.1.0
%define rel     dev23b

%define EXCLUDED_MODULES	mysql jabber auth_radius group_radius uri_radius postgres snmp cpl cpl-c extcmd ldap
%define MYSQL_MODULES		mysql
%define JABBER_MODULES		jabber
%define RADIUS_MODULES		auth_radius group_radius uri_radius
%define RADIUS_MOD_PATH		modules/auth_radius modules/group_radius modules/uri_radius

Summary:      SIP Express Router, very fast and flexible SIP Proxy
Name:         %name
Version:      %ver
Release:      %rel
Packager:     Jan Janak <jan@iptel.org>
Copyright:    GPL
Group:        System Environment/Daemons
Source:       http://ftp.iptel.org/pub/ser/%{ver}/src/%{name}-%{ver}-%{rel}_src.tar.gz
Source2:      ser.init
URL:          http://iptel.org/ser
Vendor:       FhG FOKUS
BuildRoot:    /var/tmp/%{name}-%{ver}-root
Conflicts:    ser-mysql < %ver, ser-jabber < %ver, ser-radius < %ver
BuildPrereq:  make flex bison


%description
Ser or SIP Express Router is a very fast and flexible SIP (RFC3621)
proxy server. Written entirely in C, ser can handle thousands calls
per second even on low-budget hardware. A C Shell like scripting language
provides full control over the server's behaviour. It's modular
architecture allows only required functionality to be loaded.
Currently the following modules are available: digest authentication,
CPL scripts, instant messaging, MySQL support, a presence agent, radius
authentication, record routing, an SMS gateway, a jabber gateway, a 
transaction module, registrar and user location.

%package  mysql
Summary:  MySQL connectivity for the SIP Express Router.
Group:    System Environment/Daemons
Requires: ser = %ver
BuildPrereq:  mysql-devel zlib-devel

%description mysql
The ser-mysql package contains MySQL database connectivity that you
need to use digest authentication module or persistent user location
entries.

%package  jabber
Summary:  sip jabber message translation support for the SIP Express Router.
Group:    System Environment/Daemons
Requires: ser = %ver
BuildPrereq:  expat-devel

%description jabber
The ser-jabber package contains a sip to jabber message translator.

#%package  radius
#Summary:  ser radius authentication, group and uri check modules.
#Group:    System Environment/Daemons
#Requires: ser = %ver
#BuildPrereq:  radiusclient-devel

#%description radius
#The ser-radius package contains modules for radius authentication, group
# membership and uri checking.

%prep
%setup -n %{name}-%{ver}-%{rel}

%build
make all include_modules="tls" skip_modules="%EXCLUDED_MODULES"      cfg-target=/%{_sysconfdir}/ser/
make modules modules="modules/%MYSQL_MODULES"  cfg-target=/%{_sysconfdir}/ser/
make modules modules="modules/%JABBER_MODULES" cfg-target=/%{_sysconfdir}/ser/
make modules modules="%RADIUS_MOD_PATH"        cfg-target=/%{_sysconfdir}/ser/


%install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"

make install include_modules="tls" skip_modules="%EXCLUDED_MODULES" \
		basedir=$RPM_BUILD_ROOT \
		prefix=/usr \
		cfg-prefix=$RPM_BUILD_ROOT \
		cfg-target=/%{_sysconfdir}/ser/ 
make install-modules modules="modules/%MYSQL_MODULES" \
		basedir=$RPM_BUILD_ROOT \
		prefix=/usr \
		cfg-prefix=$RPM_BUILD_ROOT \
		cfg-target=/%{_sysconfdir}/ser/ 
make install-modules modules="modules/%JABBER_MODULES" \
		basedir=$RPM_BUILD_ROOT \
		prefix=/usr \
		cfg-prefix=$RPM_BUILD_ROOT \
		cfg-target=/%{_sysconfdir}/ser/ 
make install-doc modules="modules/%JABBER_MODULES" \
		basedir=$RPM_BUILD_ROOT \
		prefix=/usr \
		cfg-prefix=$RPM_BUILD_ROOT \
		cfg-target=/%{_sysconfdir}/ser/ 
#make install-modules modules="%RADIUS_MOD_PATH" \
#		basedir=$RPM_BUILD_ROOT \
#		prefix=/usr \
#		cfg-prefix=$RPM_BUILD_ROOT \
#		cfg-target=/%{_sysconfdir}/ser/ 
#make install-doc modules="%RADIUS_MOD_PATH" \
#		basedir=$RPM_BUILD_ROOT \
#		prefix=/usr \
#		cfg-prefix=$RPM_BUILD_ROOT \
#		cfg-target=/%{_sysconfdir}/ser/ 

mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d
install -m755 $RPM_SOURCE_DIR/ser.init \
              $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/ser




%clean
rm -rf "$RPM_BUILD_ROOT"

%post
/sbin/chkconfig --add ser

%preun
if [ $1 = 0 ]; then
    /sbin/service ser stop > /dev/null 2>&1
    /sbin/chkconfig --del ser
fi


%files
%defattr(-,root,root)
%dir %{_docdir}/ser
%doc %{_docdir}/ser/AUTHORS
%doc %{_docdir}/ser/NEWS
%doc %{_docdir}/ser/INSTALL
%doc %{_docdir}/ser/README
%doc %{_docdir}/ser/README-MODULES
%doc %{_docdir}/ser/README.acc_syslog
%doc %{_docdir}/ser/README.auth
%doc %{_docdir}/ser/README.auth_db
%doc %{_docdir}/ser/README.avp
%doc %{_docdir}/ser/README.avp_db
%doc %{_docdir}/ser/README.cfg_db
%doc %{_docdir}/ser/README.db_ops
%doc %{_docdir}/ser/README.dispatcher
%doc %{_docdir}/ser/README.diversion
%doc %{_docdir}/ser/README.domain
%doc %{_docdir}/ser/README.enum
%doc %{_docdir}/ser/README.eval
%doc %{_docdir}/ser/README.exec
%doc %{_docdir}/ser/README.flatstore
%doc %{_docdir}/ser/README.gflags
%doc %{_docdir}/ser/README.lcr
%doc %{_docdir}/ser/README.maxfwd
%doc %{_docdir}/ser/README.msilo
%doc %{_docdir}/ser/README.nathelper
%doc %{_docdir}/ser/README.options
%doc %{_docdir}/ser/README.pdt
%doc %{_docdir}/ser/README.permissions
%doc %{_docdir}/ser/README.pike
%doc %{_docdir}/ser/README.prefix_route
%doc %{_docdir}/ser/README.print
%doc %{_docdir}/ser/README.ratelimit
%doc %{_docdir}/ser/README.registrar
%doc %{_docdir}/ser/README.rr
%doc %{_docdir}/ser/README.sanity
%doc %{_docdir}/ser/README.sl
%doc %{_docdir}/ser/README.sms
%doc %{_docdir}/ser/README.speeddial
%doc %{_docdir}/ser/README.textops
%doc %{_docdir}/ser/README.timer
%doc %{_docdir}/ser/README.tls
%doc %{_docdir}/ser/README.tm
%doc %{_docdir}/ser/README.uac
%doc %{_docdir}/ser/README.uri
%doc %{_docdir}/ser/README.uri_db
%doc %{_docdir}/ser/README.usrloc
%doc %{_docdir}/ser/README.xlog

%dir %{_sysconfdir}/ser
%config(noreplace) %{_sysconfdir}/ser/*
%config %{_sysconfdir}/rc.d/init.d/*

%dir %{_libdir}/ser
%{_libdir}/ser/libser_cds.so
%{_libdir}/ser/libser_cds.so.0
%{_libdir}/ser/libser_cds.so.0.1
%dir %{_libdir}/ser/modules
%{_libdir}/ser/modules/acc_db.so
%{_libdir}/ser/modules/acc_syslog.so
%{_libdir}/ser/modules/auth.so
%{_libdir}/ser/modules/auth_db.so
%{_libdir}/ser/modules/avp.so
%{_libdir}/ser/modules/avp_db.so
%{_libdir}/ser/modules/blst.so
%{_libdir}/ser/modules/cfg_db.so
%{_libdir}/ser/modules/cfg_rpc.so
%{_libdir}/ser/modules/ctl.so
%{_libdir}/ser/modules/db_ops.so
%{_libdir}/ser/modules/dispatcher.so
%{_libdir}/ser/modules/diversion.so
%{_libdir}/ser/modules/domain.so
%{_libdir}/ser/modules/enum.so
%{_libdir}/ser/modules/eval.so
%{_libdir}/ser/modules/exec.so
%{_libdir}/ser/modules/fifo.so
%{_libdir}/ser/modules/flatstore.so
%{_libdir}/ser/modules/gflags.so
%{_libdir}/ser/modules/lcr.so
%{_libdir}/ser/modules/maxfwd.so
%{_libdir}/ser/modules/mediaproxy.so
%{_libdir}/ser/modules/msilo.so
%{_libdir}/ser/modules/nathelper.so
%{_libdir}/ser/modules/options.so
%{_libdir}/ser/modules/pdt.so
%{_libdir}/ser/modules/permissions.so
%{_libdir}/ser/modules/pike.so
%{_libdir}/ser/modules/prefix_route.so
%{_libdir}/ser/modules/print.so
%{_libdir}/ser/modules/ratelimit.so
%{_libdir}/ser/modules/registrar.so
%{_libdir}/ser/modules/rr.so
%{_libdir}/ser/modules/sanity.so
%{_libdir}/ser/modules/sl.so
%{_libdir}/ser/modules/sms.so
%{_libdir}/ser/modules/speeddial.so
%{_libdir}/ser/modules/textops.so
%{_libdir}/ser/modules/timer.so
%{_libdir}/ser/modules/tls.so
%{_libdir}/ser/modules/tm.so
%{_libdir}/ser/modules/uac.so
%{_libdir}/ser/modules/uri.so
%{_libdir}/ser/modules/uri_db.so
%{_libdir}/ser/modules/usrloc.so
%{_libdir}/ser/modules/xlog.so

%{_sbindir}/ser
%{_sbindir}/sercmd

%{_sbindir}/gen_ha1

%{_mandir}/man5/*
%{_mandir}/man8/*


%files mysql
%defattr(-,root,root)

%{_libdir}/ser/modules/mysql.so
%{_sbindir}/ser_mysql.sh
/usr/share/ser/*.sql

%files jabber
%defattr(-,root,root)
%doc %{_docdir}/ser/README.jabber

%{_libdir}/ser/modules/jabber.so

#%files radius
#%defattr(-,root,root)
#%doc %{_docdir}/ser/README.auth_radius
#%doc %{_docdir}/ser/README.group_radius
#%doc %{_docdir}/ser/README.uri_radius

#%{_libdir}/ser/modules/auth_radius.so
#%{_libdir}/ser/modules/group_radius.so
#%{_libdir}/ser/modules/uri_radius.so


%changelog
* Thu Feb 22 2007 Alfred E. Heggestad <aeh@db.org>
- Updated for release 2.0.0

* Fri Jul 23 2004 Andrei Pelinescu - Onciul <pelinescu-onciul@fokus.fraunhofer.de>
- changed vesion to 0.8.14 (new upstream release)
- added ext to the modules list, removed the radius modules (they depend on radiusclient-ng now)

* Fri Nov 14 2003 Andrei Pelinescu - Onciul <pelinescu-onciul@fokus.fraunhofer.de>
- changed vesion to 0.8.12 (new upstream release)
- added auth_diameter, pdt & mangler to the modules list

* Wed Aug 27 2003 Andrei Pelinescu - Onciul <pelinescu-onciul@fokus.fraunhofer.de>
- changed vesion to 0.8.11
- gen_ha1 is now left in _sbindir
- removed harv_ser.sh
- added xlog to the modules list

* Fri Jun 6 2003 Andrei Pelinescu - Onciul <pelinescu-onciul@fokus.fraunhofer.de>
- added Conflicts:, changed vesion to 0.8.11pre30

* Mon Jun 2 2003 Daniel-Constantin Mierla <mierla@fokus.fraunhofer.de>
- added README files for ser-jabber and ser-radius packages
- spec file updated to work with rpm v4.1+

* Sun Jun 1 2003 Andrei Pelinescu - Onciul <pelinescu-onciul@fokus.fraunhofer.de>
- added a separate rpm for the radius modules
- updated to the new makefile variables (removed lots of unnecessary stuff)

* Thu Nov 14 2002 Jan Janak <J.Janak@sh.cvut.cz>
- Installing harv_ser.sh again
- quick hack to move gen_ha1 to bin directory instead of sbin (should
  be done from the Makefile next time)

* Tue Nov 12 2002 Andrei Pelinescu - Onciul <pelinescu-onciul@fokus.gmd.de>
- added a separate rpm for the jabber modules
- moved all the binaries to sbin
- removed obsolete installs (make install installs everything now)

* Fri Oct 25 2002 Jan Janak <J.Janak@sh.cvut.cz>
- Minor description fixes

* Fri Oct  4 2002 Jiri Kuthan <jiri@iptel.org>
- exec module introduced

* Wed Sep 25 2002 Andrei Pelinescu - Onciul  <pelinescu-onciul@fokus.gmd.de>
- modified make install & make: added cfg-target & modules-target

* Sun Sep 08 2002 Jan Janak <J.Janak@sh.cvut.cz>
- Created subpackage containing mysql connectivity support.

* Mon Sep 02 2002 Jan Janak <J.Janak@sh.cvut.cz>
- gen_ha1 utility added, scripts added.

* Tue Aug 28 2002 Jan Janak <J.Janak@sh.cvut.cz>
- Finished the first version of the spec file.

* Sun Aug 12 2002 Jan Janak <J.Janak@sh.cvut.cz>
- First version of the spec file.
