
# set to omit demos
%define _disable_all_vads   --disable-all-vads

Name:	 virtuoso-opensource
Version: 6.1.8
Release: 1%{?_dist_release}
Summary: A high-performance object-relational SQL database

Group:   Applications/Databases
# see LICENSE for exception details
License: GPLv2 with exceptions
URL:	 http://virtuoso.sourceforge.net/
Source0: http://downloads.sourceforge.net/virtuoso/virtuoso-opensource-%{version}.tar.gz
#Source0: ftp://download.openlinksw.com/support/vos/virtuoso-opensource-%{snap}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

## Upstreamable patches
# based on http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/virtuoso-opensource/current/SOURCES/virtuoso-opensource-6.1.0-extern-iodbc.patch
Patch51: virtuoso-opensource-6.1.0-external_iodbc.patch
Patch52: virtuoso-opensource-6.1.8-nodemos_buildfix.patch

BuildRequires: automake libtool
BuildRequires: bison
BuildRequires: flex
BuildRequires: gperf
#BuildRequires: htmldoc
## when/if we ever decide to ship .jar's
#BuildRequires: java-devel
BuildRequires: openldap-devel
BuildRequires: openssl-devel
BuildRequires: libiodbc-devel
BuildRequires: libxml2-devel
BuildRequires: zlib-devel

Provides: virtuoso = %{version}-%{release}

%if 0%{?_disable_all_vads:1}
Obsoletes: virtuoso-opensource-apps < 6.1.0
Obsoletes: virtuoso-opensource-conductor < 6.1.0
%endif


%description
Virtuoso is a scalable cross-platform server that combines SQL/RDF/XML
Data Management with Web Application Server and Web Services Platform
functionality.

%package apps
Summary: Applications
Group:   Applications/Databases
Requires: %{name} = %{version}-%{release}
%description apps 
%{summary}.

%package conductor
Summary: Server pages 
Group:   Applications/Databases
Requires: %{name} = %{version}-%{release}
%if 0%{?fedora} > 9
BuildArch: noarch
%endif
%description conductor 
%{summary}.

%package doc 
Summary: Documentation 
Group:   Documentation 
Requires: %{name} = %{version}-%{release}
%if 0%{?fedora} > 9
BuildArch: noarch
%endif
%description doc 
%{summary}.

%package utils
Summary: Utilities
Group:   Applications/Databases
Requires: %{name} = %{version}-%{release}
%description utils
%{summary}.


%prep
%setup -q -n virtuoso-opensource%{!?snap:-%{version}}%{?snap:-%{snap}}

%patch51 -p1 -b .external_iodbc
%patch52 -p1 -b .nodemos_buildfix

./autogen.sh


%build
# --with-debug avoids useless -debuginfo
%configure \
  --with-layout=redhat \
  --enable-shared --disable-static \
  --without-internal-zlib \
  --with-debug \
  --with-iodbc \
  --enable-openssl \
  --disable-imagemagick \
  %{?_disable_all_vads} 

make %{?_smp_mflags}


%install
rm -rf %{buildroot} 

make install DESTDIR=%{buildroot}

# silly that both binaries with internal vs. external libiodbc get built 
mv %{buildroot}%{_bindir}/virtuoso-iodbc-t %{buildroot}%{_bindir}/virtuoso-t
mv %{buildroot}%{_bindir}/isql-iodbc %{buildroot}%{_bindir}/isql
mv %{buildroot}%{_bindir}/isqlw-iodbc %{buildroot}%{_bindir}/isqlw
mv %{buildroot}%{_bindir}/odbc_mail %{buildroot}%{_bindir}/virt_mail

mkdir -p %{buildroot}%{_sysconfdir}/virtuoso
mv %{buildroot}%{_var}/lib/virtuoso/db/virtuoso.ini %{buildroot}%{_sysconfdir}/virtuoso/
ln -s ../../../..%{_sysconfdir}/virtuoso/virtuoso.ini %{buildroot}%{_var}/lib/virtuoso/db/virtuoso.ini

# generic'ish binaries, hide them away safely
mkdir -p %{buildroot}%{_libexecdir}/virtuoso/
mv %{buildroot}%{_bindir}/{inifile,isql,isqlw} \
   %{buildroot}%{_libexecdir}/virtuoso/

## unpackaged files 
# iodbc-ized version of virt_mail, meh.
rm -vf %{buildroot}%{_bindir}/odbc_mail
rm -vf %{buildroot}%{_libdir}/*.{la,a}
rm -vf %{buildroot}%{_libdir}/virtuoso/hosting/*.la
rm -vf %{buildroot}%{_libdir}/hibernate/virt_dialect.jar
rm -vf %{buildroot}%{_libdir}/jena2/virt_jena2.jar
rm -vf %{buildroot}%{_libdir}/{jdbc-?.?,jena,sesame}/*.jar
rm -vf %{buildroot}%{_libdir}/sesame/create-virtuoso.xsl
rm -vf %{buildroot}%{_libdir}/sesame/create.xsl

## make directory
mkdir -p %{buildroot}%{_datadir}/virtuoso/
mkdir -p %{buildroot}%{_datadir}/virtuoso/vad/
mkdir -p %{buildroot}%{_libdir}/virtuoso/

%check
## these take a very long time
#make check


%clean
rm -rf %{buildroot} 


%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING LICENSE
%dir %{_sysconfdir}/virtuoso/
%config(noreplace) %{_sysconfdir}/virtuoso/virtuoso.ini
%{_bindir}/virtuoso-t
%{_libdir}/virt*.so
%dir %{_datadir}/virtuoso/
%dir %{_datadir}/virtuoso/vad/
%dir %{_libdir}/virtuoso/
%dir %{_libexecdir}/virtuoso/
%dir %{_var}/lib/virtuoso
%{_var}/lib/virtuoso/db/

%if ! 0%{?_disable_all_vads:1}
%files apps
%defattr(-,root,root,-)
%{_libdir}/virtuoso/hosting/
%{_datadir}/virtuoso/vad/*.vad
%exclude %{_datadir}/virtuoso/vad/conductor_dav.vad

%files conductor
%defattr(-,root,root,-)
%{_datadir}/virtuoso/vad/conductor_dav.vad
%{_var}/lib/virtuoso/vsp/
%endif

%files doc
%defattr(-,root,root,-)
%{_docdir}/virtuoso/

%files utils
%defattr(-,root,root,-)
%{_bindir}/virt_mail
%{_libexecdir}/virtuoso/*


%changelog
* Sun Aug 24 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 6.1.8-1
- update to 6.1.8
- remove Patch50 (virtuoso-opensource-5.0.11-openssl.patch)
- update Patch52 (virtuoso-opensource-6.1.8-nodemos_buildfix.patch)

* Sat Jan 29 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 6.1.0-4
- rebuild with openssl-1.0.0c

* Thu Feb 11 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 6.1.0-3
- initial build for Vine Linux

* Tue Feb 09 2010 Rex Dieter <rdieter@fedoraproject.org> 6.1.0-2
- fix Obsoletes: -apps,-conductor

* Thu Feb 04 2010 Rex Dieter <rdieter@fedoraproject.org> 6.1.0-1
- virtuoso-opensource-6.1.0
- build only what we need for nepomuk, Obsoletes: -apps,-conductor

* Sat Jan 09 2010 Rex Dieter <rdieter@fedoraproject.org> 6.0.0-1
- virtuoso-opensource-6.0.0

* Tue Oct 20 2009 Rex Dieter <rdieter@fedoraproject.org> 5.0.12-1
- virtuoso-opensource-5.0.12

* Sun Oct 11 2009 Rex Dieter <rdieter@fedoraproject.rog> 5.0.12-0.1.rc9.20090916
- virtuoso-opensource-20090916 (5.0.12-rc9)

* Wed Aug 26 2009 Tomas Mraz <tmraz@redhat.com> - 5.0.11-4
- rebuilt with new openssl

* Fri Jul 24 2009 Rex Dieter <rdieter@fedoraproject.org> 5.0.11-3
- BR: htmldoc
- -doc subpkg

* Sun Jun 07 2009 Rex Dieter <rdieter@fedoraproject.org> 5.0.11-2
- omit remaining .la files
- fix %%changelog
- fix virtuoso.ini dangling symlink

* Fri May 22 2009 Rex Dieter <rdieter@fedoraproject.org> 5.0.11-1
- virtuoso-opensource-5.0.11

