Name:           libmicrohttpd
Version:        0.9.75
Release:        2
Epoch:          1
Summary:        Lightweight library for embedding a webserver in applications
License:        LGPLv2+
URL:            http://www.gnu.org/software/libmicrohttpd/
Source0:        https://ftp.gnu.org/gnu/libmicrohttpd/%{name}-%{version}.tar.gz
Patch0001:      0001-gnutls-utilize-system-crypto-policy.patch
Patch0002:      fix-libmicrohttpd-tutorial-info.patch
Patch0003:      fixed-missing-websocket.inc-in-dist-files.patch

BuildRequires:  autoconf automake libtool gettext-devel texinfo gnutls-devel doxygen graphviz
Requires(post): info
Requires(preun):info

%description
GNU libmicrohttpd is a small C library that is supposed to make it
easy to run an HTTP server as part of another application.

%package devel
Summary:        Development files for libmicrohttpd
Requires:       %{name} = %{epoch}:%{version}-%{release}

%description devel
Development files for libmicrohttpd

%package help
Summary:        This help package for libmicrohttpd
Requires:       %{name} = %{epoch}:%{version}-%{release}
BuildArch:      noarch
Provides:       %{name}-doc = %{epoch}:%{version}-%{release}
Obsoletes:      %{name}-doc < %{epoch}:%{version}-%{release}

%description help
The help package contains manual pages and doc files for libmicrohttpd

%prep
%autosetup -p1

%build
%configure --disable-static --with-gnutls --enable-https=yes
%make_build
make -C doc/doxygen full

%check
make check

%install
%make_install

mkdir examples
cp  src/examples/*.c examples
cp doc/examples/*.c examples
chmod 644 examples/*.c
cp -R doc/doxygen/html html
%post help
install-info %{_infodir}/libmicrohttpd.info.gz %{_infodir}/dir || :
install-info %{_infodir}/libmicrohttpd-tutorial.info.gz %{_infodir}/dir || :

%preun help
if [ $1 = 0 ] ; then
install-info --delete %{_infodir}/libmicrohttpd.info.gz %{_infodir}/dir || :
install-info --delete %{_infodir}/libmicrohttpd-tutorial.info.gz %{_infodir}/dir || :
fi

%post
/sbin/ldconfig
%postun
/sbin/ldconfig

%files
%license COPYING
%{_libdir}/libmicrohttpd.so.*

%files devel
%{_includedir}/microhttpd.h
%{_libdir}/libmicrohttpd.so
%{_libdir}/pkgconfig/libmicrohttpd.pc
%exclude %{_libdir}/libmicrohttpd.la
%exclude %{_infodir}/dir
%exclude %{_bindir}/demo

%files help
%doc AUTHORS ChangeLog examples html README
%{_mandir}/man3/libmicrohttpd.3.gz
%{_infodir}/libmicrohttpd.info.gz
%{_infodir}/libmicrohttpd-tutorial.info.gz
%{_infodir}/libmicrohttpd_performance_data.png.gz

%changelog
* Fri Aug 5 2022 liyanan <liyanan32@h-partners.com> - 1:0.9.75-2
- Fixed missing websocket.inc in dist files

* Fri Jan 14 2022 xigaoxinyan<xigaoxinyan@huawei.com> - 0.9.75-1
- update to 0.9.75
* Thu Aug 05 2021 caodongxia<caodongxia@huawei.com> - 0.9.59-5
- Fix libmicrohttpd-tutorial info

* Thu Nov 21 2019 wangye<wangye54@huawei.com> - 0.9.59-4
- Package init
