Summary:	http request/response parser for c 
Name:		http-parser
Version:	2.4.2
Release:	1%{?_dist_release}
License:	MIT
Group:		System Environment/Libraries 
URL:		https://github.com/joyent/http-parser

# https://github.com/joyent/%{name}/archive/v%{version}.tar.gz
Source0:	%{name}-%{version}.tar.gz

# based on fedora
Patch0:		http-parser-gyp-sharedlib.patch

BuildRequires: gyp

BuildRoot:	%{_tmppath}/%{name}-%{version}-root

Vendor:		Project Vine
Distribution:	Vine Linux
Packager:	Takemikaduchi

%description
This is a parser for HTTP messages written in C. It parses both
requests and responses. The parser is designed to be used in
performance HTTP applications. It does not make any syscalls nor
allocations, it does not buffer data, it can be interrupted at
anytime. Depending on your architecture, it only requires about
40 bytes of data per message stream
(in a web server that is per connection).

%package        devel
Summary:        Development tools for %{name}
Summary(ja):    %{name} の開発環境
Group:          Development/Libraries
Requires:       %{name} = %{version}-%{release}
Requires:       pkgconfig

%description    devel
Header files and libraries for building a extension library for the %{name}.


%prep
%setup -q
%patch0 -p1


%build
export CFLAGS='%{optflags} -fPIC'
gyp -f make --depth=`pwd` http_parser.gyp
make %{?_smp_mflags} BUILDTYPE=Release 


%install
rm -rf ${RPM_BUILD_ROOT}

mkdir -p ${RPM_BUILD_ROOT}/%{_libdir}
mkdir -p ${RPM_BUILD_ROOT}/%{_includedir}

mv out/Release/lib.target/libhttp_parser.so.2 libhttp_parser.so.%{version}
install -m 0755 libhttp_parser.so.%{version} ${RPM_BUILD_ROOT}%{_libdir}/libhttp_parser.so.%{version}
ln -sf libhttp_parser.so.%{version} ${RPM_BUILD_ROOT}%{_libdir}/libhttp_parser.so.2
install libhttp_parser.so.%{version} ${RPM_BUILD_ROOT}%{_libdir}/libhttp_parser.so
install -m 0644 http_parser.h ${RPM_BUILD_ROOT}%{_includedir}/


%clean
%{__rm} -rf ${RPM_BUILD_ROOT}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


%files
%defattr(-,root,root,-)
%doc LICENSE-MIT README.md
%{_libdir}/libhttp_parser.so.*

%files devel
%defattr(-,root,root,-)
%{_includedir}/http_parser.h
%{_libdir}/libhttp_parser.so


%changelog
* Sun Apr 05 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.4.2-1
- initial build based on fedora