# TODO
+# - rename -libs to -cpp, -devel to -cpp-devel, -static to -cpp-static?
+# - no SONAME ext in -libs, enforce some?
# - BR for java, ruby, perl, more general BR
-# - package -libs & ldconfig
# - Separate packages per each language
# - fix perl: missing vendordir on install
# - fix java: not installing to %{_javadir}
# - avoid downloading from net when build building java
# - Fix ruby install
-# - Fix PHP build
# - Add Mono
-# - libthriftnb.so lacks some libs when linking
+# - Fix parallel build make.
+#
+# TODO (2) - fix or disable
+# - java - br, build, files - icedtea7 ?
+# - erlang - build, files
+# - php_extension - br, build
+# - ruby - build, files, some gems required for build?
+# - haskell - build, files
+# - d - needs working dmd or gdm to build
+#
+# Conditional build:
+#
+# generic options
+%bcond_with tests # build with tests
+#
+# language options
+%bcond_without cpp # build the C++ library
+%bcond_with qt4 # build the Qt4 library
+%bcond_with qt5 # build the Qt5 library
+%bcond_without c_glib # build the C (GLib) library
+%bcond_with csharp # build the C# library
+%bcond_with java # build the Java library
+%bcond_with erlang # build the Erlang library
+%bcond_with nodejs # build nodejs library
+%bcond_with lua # build Lua library
+%bcond_without python # build the Python library
+%bcond_with perl # build the Perl library
+%bcond_with php # build the PHP library
+%bcond_with php_extension # build the PHP_EXTENSION library
+%bcond_with ruby # build the Ruby library
+%bcond_with haskell # build the Haskell library
+%bcond_with go # build the Go library
+%bcond_with d # build the D library
+
+%if %{with perl}
+%define pdir Thrift
+%endif
+
+%if 0%{!?php_name:1}
+%define php_name php55
+%endif
+
+%define php_min_version 5.3.0
+%include /usr/lib/rpm/macros.perl
Summary: Framework for scalable cross-language services development
Summary(pl.UTF-8): Szkielet budowania skalowalnych usług dla różnych języków programowania
Name: thrift
-Version: 0.5.0
-Release: 0.1
+Version: 0.9.3
+Release: 2.2
License: Apache v2.0
Group: Development/Libraries
-Source0: http://ftp.tpnet.pl/vol/d1/apache//incubator/thrift/%{version}-incubating/thrift-%{version}.tar.gz
-# Source0-md5: 14c97adefb4efc209285f63b4c7f51f2
+Source0: http://www.apache.org/dist/thrift/%{version}/%{name}-%{version}.tar.gz
+# Source0-md5: 88d667a8ae870d5adeca8cb7d6795442
Patch0: %{name}-Werror_strlcpy_fix.patch
-URL: http://incubator.apache.org/thrift/
-BuildRequires: bison
-BuildRequires: boost-devel >= 1.33.1
+Patch1: %{name}-cpp_link_fix.patch
+URL: http://thrift.apache.org/
+BuildRequires: autoconf
+BuildRequires: automake >= 1:1.13
+BuildRequires: bison >= 2.5
+BuildRequires: boost-devel >= 1.54.0
BuildRequires: flex
BuildRequires: libevent-devel
BuildRequires: pkgconfig
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.219
BuildRequires: zlib-devel >= 1.2.3
+%if %{with qt4}
+BuildRequires: QtNetwork-devel
+%endif
+%if %{with c_glib}
+BuildRequires: glib2-devel
+%endif
+%if %{with csharp}
+BuildRequires: mono-csharp
+BuildRequires: mono-devel
+%endif
+%if %{with java}
+BuildRequires: java-gcj-compat-devel
+BuildRequires: java-ivy
+%endif
+%if %{with lua}
+BuildRequires: lua51-devel
+%endif
+%if %{with nodejs}
+BuildRequires: nodejs
+BuildRequires: npm
+%endif
+%if %{with python}
+BuildRequires: python
+BuildRequires: python-TwistedCore
+%endif
+%if %{with perl}
+BuildRequires: perl-Bit-Vector
+BuildRequires: perl-Class-Accessor
+BuildRequires: perl-base
+%endif
+%if %{with php}
+BuildRequires: %{php_name}-cli
+BuildRequires: %{php_name}-devel
+BuildRequires: phpunit
+%endif
+%if %{with erlang}
+BuildRequires: erlang
+%endif
+%if %{with ruby}
+BuildRequires: ruby
+BuildRequires: ruby-bundler
+%endif
+%if %{with haskell}
+BuildRequires: ghc
+BuildRequires: ghc-haskell-platform
+%endif
+%if %{with go}
+BuildRequires: golang
+%endif
+%if %{with d}
+BuildRequires: dmd
+%endif
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+# library use symbols provided by the glib2 libraries
+%define skip_post_check_so libthrift_c_glib.so.*
+
%description
-Software framework for scalable cross-language services development.
-It combines a software stack with a code generation engine to build
-services that work efficiently and seamlessly between C++, Java,
-Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, Smalltalk, and
-OCaml.
+The Apache Thrift software framework, for scalable cross-language
+services development, combines a software stack with a code generation
+engine to build services that work efficiently and seamlessly between
+C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa,
+JavaScript, Node.js, Smalltalk, OCaml and Delphi and other languages.
%description -l pl.UTF-8
Programowy szkielet dla rozwoju skalowanych usług dla różnych języków
programowania. Zawiera oprogramowanie wraz silnikiem generowania kodu
do tworzenie usług które spawnie działają pomiędzy C++, Javą,
-Pythonem, PHP, Rybym, Erlangiem, Perlem, Heskellem, C#, Cocoa,
+Pythonem, PHP, Rybym, Erlangiem, Perlem, Haskellem, C#, Cocoa,
Smalltalikiem i Ocamlem.
%package devel
-Summary: Header files for thrift
-Summary(pl.UTF-8): Pliki nagłówkowe thrift
+Summary: C++ header files
+Summary(pl.UTF-8): Pliki nagłówkowe i bibliotek iterfejsu C++ thrift
Group: Development/Libraries
-Requires: %{name} = %{version}-%{release}
+Requires: %{name}-libs = %{version}-%{release}
%description devel
-Header files for thrift.
+Header and libarary files for C++ thrift inteface.
%description devel -l pl.UTF-8
-Pliki nagłówkowe thrift.
+Pliki nagłówkowe i bibliotek iterfejsu C++ thrift.
+
+%package static
+Summary: Thrift C++ static libraries
+Summary(pl.UTF-8): Biblioteki statyczne iterfejsu C++ thrift
+Group: Development/Libraries
+Requires: %{name}-devel = %{version}-%{release}
+
+%description static
+Static libarary files for C++ thrift inteface.
+
+%description static -l pl.UTF-8
+Statyczne biblioteki iterfejsu C++ thrift.
+
+%package libs
+Summary: C++ thrift interface libraries
+Summary(pl.UTF-8): Interfejs thrift dla C++
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description libs
+C++ thrift interface libraries
+
+%description libs -l pl.UTF-8
+Biblioteki interfejsu thrift dla C++.
+
+%package -n php-%{name}
+Summary: PHP Thrift interface
+Summary(pl.UTF-8): Interfejs Thrift dla PHP
+Group: Development/Languages/PHP
+Requires: %{name} = %{version}-%{release}
+Requires: php(core) >= %{php_min_version}
+
+%description -n php-%{name}
+PHP Thrift interface.
%package -n python-%{name}
Summary: Python thrift interface
%description -n python-%{name} -l pl.UTF-8
Interfejs thrift dla Pythona.
+%package -n perl-Thrift
+Summary: Perl thrift interface
+Summary(pl.UTF-8): Interfejs thrift dla Perla
+Group: Development/Languages/Perl
+Requires: %{name} = %{version}-%{release}
+
+%description -n perl-Thrift
+Perl thrift interface.
+
+%description -n perl-Thrift -l pl.UTF-8
+Interfejs thrift dla Perla.
+
%prep
%setup -q
-%patch0 -p1
+#%patch0 -p1
+#%patch1 -p1
%build
+%{__aclocal} -I aclocal
+%{__autoconf}
+%{__autoheader}
+%{__automake}
%configure \
- --without-ruby \
- --without-php \
- --without-java \
- --without-php_extension
-
-%{__make}
+ PHP_PREFIX=%{php_data_dir} \
+ PHP=%{__php} \
+ PERL_PREFIX=%{perl_vendorlib} \
+ %{__with_without cpp} \
+ %{__with_without qt4} \
+ %{__with_without qt5} \
+ %{__with_without c_glib} \
+ %{__with_without csharp} \
+ %{__with_without java} \
+ %{__with_without erlang} \
+ %{__with_without nodejs} \
+ %{__with_without python} \
+ %{__with_without lua} \
+ %{__with_without perl} \
+ %{__with_without php} \
+ %{__with_without php_extension} \
+ %{__with_without ruby} \
+ %{__with_without haskell} \
+ %{__with_without go} \
+ %{__with_without d} \
+ --enable-libs \
+ --with-boost \
+ --with-libevent \
+ --with-zlib \
+ --disable-tutorial \
+ --disable-tests \
+ %{__with_without tests}
+
+%{__make} -j1
%install
rm -rf $RPM_BUILD_ROOT
-
%{__make} install \
DESTDIR=$RPM_BUILD_ROOT
+%if %{with python}
%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
%py_comp $RPM_BUILD_ROOT%{py_sitedir}
%py_postclean
+%endif
+
+%if %{with perl}
+%{__mv} $RPM_BUILD_ROOT%{perl_vendorlib}/lib/perl5/Thrift{,.pm} $RPM_BUILD_ROOT%{perl_vendorlib}
+%endif
%clean
rm -rf $RPM_BUILD_ROOT
+%post libs -p /sbin/ldconfig
+%postun libs -p /sbin/ldconfig
+
%files
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/thrift
+%if %{with cpp}
+%files libs
+%defattr(644,root,root,755)
+%{_libdir}/libthrift-%{version}.so
+%{_libdir}/libthriftnb-%{version}.so
+%{_libdir}/libthriftz-%{version}.so
+%if %{with qt4}
+%{_libdir}/libthriftqt-%{version}.so
+%endif
+%if %{with qt5}
+%{_libdir}/libthriftqt5-%{version}.so
+%endif
+%if %{with c_glib}
+%{_libdir}/libthrift_c_glib.so.*
+%endif
+
%files devel
%defattr(644,root,root,755)
-%{_libdir}/libthrift.so
%{_libdir}/libthrift.la
-%{_libdir}/libthriftz.so
+%{_libdir}/libthriftnb.la
%{_libdir}/libthriftz.la
-%{_includedir}/%{name}
+%{_libdir}/libthrift.so
+%{_libdir}/libthriftnb.so
+%{_libdir}/libthriftz.so
+%{_includedir}/thrift
%{_pkgconfigdir}/thrift-nb.pc
%{_pkgconfigdir}/thrift-z.pc
%{_pkgconfigdir}/thrift.pc
+%if %{with qt4}
+%{_libdir}/libthriftqt.so
+%{_libdir}/libthriftqt.la
+%{_pkgconfigdir}/thrift-qt.pc
+%endif
+%if %{with qt5}
+%{_libdir}/libthriftqt5.so
+%{_libdir}/libthriftqt5.la
+%{_pkgconfigdir}/thrift-qt5.pc
+%endif
+%if %{with c_glib}
+%{_libdir}/libthrift_c_glib.so
+%{_libdir}/libthrift_c_glib.la
+%{_pkgconfigdir}/thrift_c_glib.pc
+%endif
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/libthrift.a
+%{_libdir}/libthriftnb.a
+%{_libdir}/libthriftz.a
+%if %{with qt4}
+%{_libdir}/libthriftqt.a
+%endif
+%if %{with qt5}
+%{_libdir}/libthriftqt5.a
+%endif
+%if %{with c_glib}
+%{_libdir}/libthrift_c_glib.a
+%endif
+%endif
+
+%if %{with php}
+%files -n php-%{name}
+%defattr(644,root,root,755)
+%{php_data_dir}/Thrift
+%endif
+
+%if %{with python}
%files -n python-%{name}
%defattr(644,root,root,755)
-%dir %{py_sitedir}
%dir %{py_sitedir}/%{name}
%dir %{py_sitedir}/%{name}/protocol
%{py_sitedir}/%{name}/protocol/*.py[co]
%{py_sitedir}/%{name}/transport/*.py[co]
%{py_sitedir}/%{name}/*.py[co]
%if "%{py_ver}" > "2.4"
-%{py_sitedir}/Thrift-*.egg-info
+%{py_sitedir}/thrift-%{version}-py*.egg-info
+%endif
+%endif
+
+%if %{with perl}
+%files -n perl-Thrift
+%defattr(644,root,root,755)
+%dir %{perl_vendorlib}/Thrift
+%{perl_vendorlib}/Thrift.pm
+%{perl_vendorlib}/Thrift/*.pm
%endif