Name: flex
Version: 2.6.4
Release: 2
Summary: A fast lexical analyzer generator
License: BSD and LGPLv2+
URL: https://github.com/westes/flex
Source0: https://github.com/westes/flex/releases/download/v%{version}/flex-%{version}.tar.gz

Patch0000: build-AC_USE_SYSTEM_EXTENSIONS-in-configure.ac.patch
Patch0001: filter-memory-leak-free-scanner-postprocessing.patch
Patch0002: scanner-c-i-j-should-preserve-case.patch
Patch0003: filter-Output-correct-line-value-for-current-file.patch
Patch0004: scanner-memory-leak-free-scanner-generator.patch
Patch0005: scanner-Ignore-comment-lines-in-skeleton-files.patch
Patch0006: mkskel.sh-fix-EOL-issue-for-CRLF-systems.patch
Patch0007: scanner-temporarily-protect-against-ccl-overflow-ove.patch
Patch0008: scanner-prevent-overflow-in-add_action.patch
Patch0009: 0001-scanner-fix-default-of-yy_top_state.patch
Patch0010: 0002-scanner-fix-default-of-yy_top_state.patch

BuildRequires: gcc gettext help2man m4 bison texinfo
Requires: m4
Requires(post): info
Requires(preun): info

%description
Flex is a tool for generating scanners: programs which recognize lexical
patterns in text.

%package devel
Summary: Libraries for flex scanner generator
Obsoletes: flex-static < 2.5.35-15
Provides: flex-static

%description devel
This package contains the library with default implementations of
`main' and `yywrap' functions that the client binary can choose to use
instead of implementing their own.

%package help
Summary:        Documents for %{name}
Buildarch:      noarch
Requires:	man info
Provides:       flex-doc
Obsoletes:      flex-doc

%description help
Man pages and other related documents for %{name}. 

%prep
%autosetup -n %{name}-%{version} -p1

%build
autoreconf
%configure
%make_build

%install
%make_install
rm -f $RPM_BUILD_ROOT/%{_infodir}/dir
find %{buildroot} \( -name '*.la' -or -name '*.so' \) -delete
find %{buildroot} \( -name '*.so.2' -or -name '*.so.2.0.0' \) -delete

cd ${RPM_BUILD_ROOT}
ln -sf flex .%{_bindir}/lex
ln -sf flex .%{_bindir}/flex++
ln -s flex.1 .%{_mandir}/man1/lex.1
ln -s flex.1 .%{_mandir}/man1/flex++.1
ln -s libfl.a .%{_libdir}/libl.a

%post
if [ -f %{_infodir}/flex.info.gz ]; then # for --excludedocs
   /sbin/install-info %{_infodir}/flex.info.gz --dir-file=%{_infodir}/dir ||:
fi

%preun
if [ $1 = 0 ]; then
    if [ -f %{_infodir}/flex.info.gz ]; then # for --excludedocs
	/sbin/install-info --delete %{_infodir}/%{name}.info.gz %{_infodir}/dir ||:
    fi
fi

%files
%{_datadir}/locale/*
%dir %{_pkgdocdir}
%license COPYING
%{_pkgdocdir}/NEWS
%{_pkgdocdir}/README.md
%{_bindir}/*
%{_includedir}/FlexLexer.h
%{_infodir}/flex.info*

%files devel
%dir %{_pkgdocdir}
%license COPYING
%{_libdir}/*.a

%files help
%{_pkgdocdir}
%{_mandir}/man1/*

%changelog
* Sun Jun 28 2020 openEuler liuchengaung<liuchenguang4@huawei.com> - 2.6.4-2
- quality enhancement synchronization github patch

* Mon May 11 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.6.4-1
- Type:requirement
- ID:NA
- SUG:NA
- DESC:update to 2.6.4

* Tue Jan 7 2020 chengquan<chengquan3@huawei.com> - 2.6.1-13
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:remove useless patches

* Fri Sep 27 2019 chengquan<chengquan3@huawei.com> - 2.6.1-12
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:add help package

* Mon Aug 19 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.6.1-11
- Package init

