Summary:	http request/response parser for c 
Name:		http-parser
Version:	2.9.4
Release:	1%{?_dist_release}
Group:		System Environment/Libraries 
Vendor:		Project Vine
Distribution:	Vine Linux

License:	MIT
URL:		https://github.com/nodejs/http-parser
Source0:	https://github.com/nodejs/http-parser/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz

# based on fedora
Patch0:		0001-url-treat-empty-port-as-default.patch

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

%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}

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


%prep
%setup -q
%patch0 -p1

cat > meson.build << EOF
project('%{name}', 'c', version : '%{version}')
install_headers('http_parser.h')
foreach x : [['http_parser',        ['-DHTTP_PARSER_STRICT=0']],
             ['http_parser_strict', ['-DHTTP_PARSER_STRICT=1']]]
  lib = library(x.get(0), 'http_parser.c',
                c_args : x.get(1),
                version : '%{version}',
                install : true)
  test('test-@0@'.format(x.get(0)),
       executable('test-@0@'.format(x.get(0)), 'test.c',
                  c_args : x.get(1),
                  link_with : lib),
       timeout : 60)
endforeach
EOF


%build
%meson
%meson_build


%install
rm -rf ${RPM_BUILD_ROOT}
%meson_install


%check
%meson_test


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

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig


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

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


%changelog
* Tue May 05 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.9.4-1
- new upstream release.
- dropped Patch0.
- imported Patch0 from rawhide.

* Thu Sep 01 2016 Toshiaki Ara <ara_t@384.jp> - 2.4.2-2
- rebuild with gcc-5.4.0

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