File erlang-toke.spec of Package erlang-toke

# norootforbuild

%define pkg_version 0
%define hg_version 20100714

Name:           erlang-toke
Version:        %{pkg_version}.hg%{hg_version}
Release:        1
Summary:        Erlang linked-in driver for Tokyo Cabinet
License:        MPL-1.1
Group:          Development/Libraries/Other
URL:            http://hg.opensource.lshift.net/toke/
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source0:        toke-%{version}.tar.bz2
Patch0:         ld.patch
Patch1:         missing_sys_types.diff
Patch2:         add_debug_info.diff
Requires:       erlang >= R13B01
BuildRequires:  erlang >= R13B01
BuildRequires:  gcc-c++ zlib-devel

###########################################################################################
# SuSE, openSUSE
###########################################################################################
%if 0%{?suse_version}
%define erl_dir %{_libdir}/erlang
%define erl_libdir %{erl_dir}/lib
%define erl_includedir %{erl_dir}/usr/include

Requires:       libtokyocabinet >= 1.3.1
BuildRequires:  libtokyocabinet-devel >= 1.3.1
BuildRequires:  erlang-src
%endif

##########################################################################################  
## Fedora, RHEL or CentOS  
########################################################################################## 
%if 0%{?fedora_version} || 0%{?rhel_version} || 0%{?centos_version}
%define erl_dir %{_libdir}/erlang
%define erl_libdir %{erl_dir}/lib
%define erl_includedir %{erl_dir}/usr/include

Requires:       tokyocabinet >= 1.3.1
BuildRequires:  tokyocabinet-devel >= 1.3.1
%endif 

##########################################################################################  
## Mandrake, Mandriva  
##########################################################################################  
%if 0%{?mandriva_version} || 0%{?mdkversion}
%define erl_dir %{_libdir}/erlang
%define erl_libdir %{erl_dir}/lib
%define erl_includedir %{erl_dir}/usr/include
%if 0%{?mandriva_version} >= 2009 || 0%{?mdkversion} >= 200900
BuildRequires:  erlang-stack >= R13B01
Requires:       erlang-stack >= R13B01
%else
#BuildRequires:  classpathx-jaf
%endif

Requires:       libtokyocabinet >= 1.3.1
BuildRequires:  tokyocabinet-devel >= 1.3.1
BuildRequires:  erlang-devel
%endif

%define toke_dir %{erl_libdir}/toke-%{version}

%description
Toke is a very minimal Erlang driver for Tokyo Cabinet. It only wraps
the hash API (tchdb*) and doesn't even implement all of that.

All keys and values must be binaries.


%prep
%setup -q -n toke
%patch0 -p1
%patch1 -p1
%patch2 -p1


%build
export CFLAGS="$RPM_OPT_FLAGS -I%{erl_includedir}"
export CXXFLAGS=$CFLAGS

%__make

%install
%__install -d -m 755 %{buildroot}%{toke_dir}
# %%__install -d -m 755 %%{buildroot}%%{toke_dir}/c_src
%__install -d -m 755 %{buildroot}%{toke_dir}/ebin
%__install -d -m 755 %{buildroot}%{toke_dir}/priv
%__install -d -m 755 %{buildroot}%{toke_dir}/src

# %%__install -m 644 c_src/toke.c %%{buildroot}%%{toke_dir}/c_src/toke.c
# %%__install -m 644 c_src/toke.h %%{buildroot}%%{toke_dir}/c_src/toke.h

%__install -m 644 ebin/toke_drv.beam %{buildroot}%{toke_dir}/ebin/toke_drv.beam
%__install -m 644 ebin/toke_test.beam %{buildroot}%{toke_dir}/ebin/toke_test.beam

%__install -m 755 priv/libtoke.so %{buildroot}%{toke_dir}/priv/libtoke.so

%__install -m 644 src/toke_drv.erl %{buildroot}%{toke_dir}/src/toke_drv.erl
%__install -m 644 src/toke_test.erl %{buildroot}%{toke_dir}/src/toke_test.erl


%files
%defattr(-,root,root,-)
%doc LICENSE LICENSE-MPL-Toke README
%dir %{toke_dir}
# %%dir %%{toke_dir}/c_src
# %%{toke_dir}/c_src/toke.c
# %%{toke_dir}/c_src/toke.h
%dir %{toke_dir}/ebin
%{toke_dir}/ebin/toke_drv.beam
%{toke_dir}/ebin/toke_test.beam
%dir %{toke_dir}/priv
%{toke_dir}/priv/libtoke.so
%dir %{toke_dir}/src
%{toke_dir}/src/toke_drv.erl
%{toke_dir}/src/toke_test.erl


%changelog
openSUSE Build Service is sponsored by