%define snap -SNAP-0910052249

Summary:        FastCGI development kit
Summary(ja):    FastCGI 開発キット
Name:           fcgi
Version:        2.4.1
Release:        1%{?_dist_release}

Group:          Development/Languages
License:        BSD
URL:            http://www.fastcgi.com/#TheDevKit
Source0:        http://fastcgi.com/dist/fcgi-%{version}%{?snap}.tar.gz
Source1:        fcgi-autogen.sh
Patch0:         fcgi-2.4.0-autotools.patch
# Patch0 created with Source1 after patching Patch1 and Patch2
#Patch1:         fcgi-2.4.0-configure.in.patch
#Patch2:         fcgi-2.4.0-Makefile.am-CPPFLAGS.patch
Patch3:         fcgi-2.4.0-gcc44_fixes.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

# for -perl
BuildRequires:  perl(ExtUtils::MakeMaker)

# don't "provide" private Perl libs
%global _use_internal_dependency_generator 0
%global provfind /bin/sh -c "grep -v '%perl_vendorarch.*\\.so$' | %__find_provides"
%global __find_provides %provfind

%description
FastCGI is a language independent, scalable, open extension to CGI that
provides high performance without the limitations of server specific APIs.


%package        devel
Summary:        Development files for %{name}
Summary(ja):    Development files for %{name}
Group:          Development/Libraries
Requires:       %{name} = %{version}-%{release}


%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%package perl
Summary:        Perl bindings for %{name}
Summary(ja):    Perl bindings for %{name}
Group:          Development/Libraries
Requires:       %{name} = %{version}-%{release}
Requires:  perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))


%description    perl
The %{name}-perl package contains the perl bindings for fcgi.


%prep
%setup -q -n "%{name}-%{version}%{snap}"
%patch3 -p1

# remove DOS End Of Line Encoding
sed -i 's/\r//' doc/fastcgi-prog-guide/ch2c.htm
# fix file permissions
chmod a-x include/fcgios.h libfcgi/os_unix.c


%build
%configure
# does not build with parallel make flags
make

%install
%{__rm} -rf %{buildroot}
%{__mkdir_p} %{buildroot}

make install DESTDIR=%{buildroot}
%{__rm} -fv %{buildroot}/%{_libdir}/libfcgi{++,}.{l,}a
install -p -m 0644 -D doc/cgi-fcgi.1 %{buildroot}/%{_mandir}/man1/cgi-fcgi.1
for manpage in doc/*.3
do
install -p -m 0644 -D $manpage %{buildroot}%{_mandir}/man3/$(basename $manpage)
done
%{__rm} -f -- doc/*.1
%{__rm} -f -- doc/*.3


%post
/sbin/ldconfig

%postun
/sbin/ldconfig


%clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%{_bindir}/cgi-fcgi
%{_libdir}/libfcgi.so.*
%{_libdir}/libfcgi++.so.*
%{_mandir}/man1/*
%defattr(0644,root,root,0755)
%doc LICENSE.TERMS README


%files devel
%defattr(-,root,root,-)
%{_includedir}/*
%{_libdir}/libfcgi.so
%{_libdir}/libfcgi++.so
%{_mandir}/man3/*
%defattr(0644,root,root,0755)
%doc doc/


%changelog
* Tue Jul  8 2014 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.1-1
- new upstream release.
- removed perl binding (not used).

* Sun Apr  3 2011 IWAI, Masaharu <iwai@alib.jp> 2.4.0-2vl6
- build with perl 5.12.3

* Sat Jul 25 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.0-1
- initial build for Vine Linux

* Sun Mar 01 2009 Chris Weyl <cweyl@alumni.drew.edu> - 2.4.0-9
- Stripping bad provides of private Perl extension libs

* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.4.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Sun Feb 15 2009 Till Maas <opensource@till.name> - 2.4.0-7
- Add missing #include <cstdio> to make it compile with gcc 4.4

* Tue Oct 14 2008 Chris Weyl <cweyl@alumni.drew.edu> - 2.4.0-6
- package up the perl bindings in their own subpackage

* Wed Feb 20 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 2.4.0-5
- Autorebuild for GCC 4.3

* Thu Aug 23 2007 Till Maas <opensource till name> - 2.4.0-4
- bump release for rebuild

* Wed Jul 11 2007 Till Maas <opensource till name> - 2.4.0-3
- remove parallel make flags

* Tue Apr 17 2007 Till Maas <opensource till name> - 2.4.0-2
- add some documentation
- add mkdir ${RPM_BUILD_ROOT} to %%install
- install man-pages

* Mon Mar 5 2007 Till Maas <opensource till name> - 2.4.0-1
- Initial spec for fedora
