%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\([^.]*\\.pl\\)
Name: groff
Version: 1.22.4
Release: 6
Summary: A typesetting system
License: GPLv3+ and GFDL and BSD and MIT
URL: http://www.gnu.org/software/groff/
Source: http://ftp.gnu.org/gnu/groff/groff-%{version}.tar.gz

BuildRequires: gcc, gcc-c++ texinfo
BuildRequires: git, netpbm-progs, perl-generators, psutils, ghostscript
BuildRequires: libXaw-devel, libXmu-devel
BuildRequires: jbig2dec-libs gdb
Requires:      coreutils

Obsoletes:    %{name}-base < %{version}-%{release}
Obsoletes:    %{name}-perl < %{version}-%{release}
Obsoletes:    %{name}-x11 < %{version}-%{release}
Obsoletes:    %{name}-gxditview < 1.20.1
Provides:     %{name}-base
Provides:     %{name}-perl
Provides:     %{name}-x11
Provides:     groff-gxditview = %{version}-%{release}
Provides:     nroff-i18n = %{version}-%{release}

%description
Groff (GNU troff) is a typesetting system that reads plain text mixed
with formatting commands and produces formatted output. Output may be
PostScript or PDF, html, or ASCII/UTF8 for display at the terminal.
Formatting commands may be either low-level typesetting requests
(“primitives”) or macros from a supplied set. Users may also write
their own macros. All three may be combined.

%package        help
Summary:        Documents for %{name}
Buildarch:      noarch
Requires:       man info
Requires:       groff = %{version}-%{release}

Obsoletes:      %{name}-doc < %{version}-%{release}
Provides:       %{name}-doc

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

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

for file in NEWS src/devices/grolbp/grolbp.1.man doc/webpage.ms \
                contrib/mm/*.man contrib/mom/examples/{README.txt,*.mom,mom.vim}; do
    iconv -f iso-8859-1 -t utf-8 < "$file" > "${file}_"
    mv "${file}_" "$file"
done

%build
%configure \
    --docdir=%{_docdir}/%{name}-%{version} \
    --with-appresdir=%{_datadir}/X11/app-defaults \
    --with-grofferdir=%{_datadir}/%{name}/%{version}/groffer
%make_build

%install
%make_install

# some binaries need alias with 'g' or 'z' prefix
for file in g{nroff,troff,tbl,pic,eqn,neqn,refer,lookbib,indxbib,soelim} zsoelim; do
    ln -s ${file#?} %{buildroot}%{_bindir}/${file}
    ln -s ${file#?}.1.gz %{buildroot}%{_mandir}/man1/${file}.1.gz
done

# fix absolute symlink to relative symlink
rm -f %{buildroot}%{_docdir}/%{name}-%{version}/pdf/mom-pdf.pdf
ln -s ../examples/mom/mom-pdf.pdf %{buildroot}%{_docdir}/%{name}-%{version}/pdf/mom-pdf.pdf

# rename groff downloadable postscript fonts(bz #477394)
for file in $(find %{buildroot}%{_datadir}/%{name}/%{version}/font/devps -name "*.pfa"); do
    mv ${file} ${file}_
done
sed --in-place 's/\.pfa$/.pfa_/' %{buildroot}%{_datadir}/%{name}/%{version}/font/devps/download

# remove unnecessary files
rm -f %{buildroot}%{_infodir}/dir

# fix privileges
chmod 755 %{buildroot}%{_datadir}/groff/%{version}/groffer/version.sh
chmod 755 %{buildroot}%{_datadir}/groff/%{version}/font/devlj4/generate/special.awk

# remove CreationDate
pushd %{buildroot}%{_docdir}/%{name}-%{version}
    find -name "*.html" | xargs sed -i "/^<!-- CreationDate: /d"
    find -name "*.ps"   | xargs sed -i "/^%%%%CreationDate: /d"
popd

# /bin/sed moved to /usr/bin/sed
sed --in-place 's|#! /bin/sed -f|#! /usr/bin/sed -f|' %{buildroot}%{_datadir}/groff/%{version}/font/devps/generate/symbol.sed

%check
make check

%pre

%preun

%post

%postun

%files
%defattr(-,root,root)
%license COPYING FDL LICENSES
%{_datadir}/%{name}/
%{_datadir}/X11/app-defaults/GXditview
%{_datadir}/X11/app-defaults/GXditview-color
%{_bindir}/gxditview
%{_bindir}/addftinfo
%{_bindir}/eqn2graph
%{_bindir}/gdiffmk
%{_bindir}/grap2graph
%{_bindir}/grn
%{_bindir}/grodvi
%{_bindir}/grolbp
%{_bindir}/grolj4
%{_bindir}/hpftodit
%{_bindir}/indxbib
%{_bindir}/lkbib
%{_bindir}/lookbib
%{_bindir}/pdfroff
%{_bindir}/pfbtops
%{_bindir}/pic2graph
%{_bindir}/refer
%{_bindir}/tfmtodit
%{_bindir}/grefer
%{_bindir}/glookbib
%{_bindir}/gindxbib
%{_bindir}/afmtodit
%{_bindir}/chem
%{_bindir}/gperl
%{_bindir}/gpinyin
%{_bindir}/glilypond
%{_bindir}/groffer
%{_bindir}/grog
%{_bindir}/gropdf
%{_bindir}/mmroff
%{_bindir}/pdfmom
%{_bindir}/roff2dvi
%{_bindir}/roff2html
%{_bindir}/roff2pdf
%{_bindir}/roff2ps
%{_bindir}/roff2text
%{_bindir}/roff2x
%{_bindir}/xtotroff
%{_bindir}/eqn
%{_bindir}/groff
%{_bindir}/grops
%{_bindir}/grotty
%{_bindir}/neqn
%{_bindir}/nroff
%{_bindir}/pic
%{_bindir}/post-grohtml
%{_bindir}/pre-grohtml
%{_bindir}/preconv
%{_bindir}/soelim
%{_bindir}/tbl
%{_bindir}/troff
%{_bindir}/gnroff
%{_bindir}/gtroff
%{_bindir}/gtbl
%{_bindir}/gpic
%{_bindir}/geqn
%{_bindir}/gneqn
%{_bindir}/gsoelim
%{_bindir}/zsoelim

%{_libdir}/groff/

%files help
%defattr(-,root,root)
%{_mandir}/man1/
%{_mandir}/man5/
%{_mandir}/man7/
%doc %{_docdir}/%{name}-%{version}/
%doc BUG-REPORT MORE.STUFF NEWS PROBLEMS
%{_infodir}/groff.info*

%changelog
* Wed Feb 10 2020 chenjialong<chenjialong@huawei.com> - 1.22.4-6
- Type:NA
- ID:NA
- SUG:NA
- DESC:rebuild.

* Sat Mar 14 2020 openEuler Buildteam <buildteam@openeuler.org> - 1.22.4-4
- fixbug in self-building

* Wed Jan  8 2020 JeanLeo <liujianliu.liu@huawei.com> - 1.22.4-3
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:update software package

* Fri Oct 25 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.22.4-2
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:add the need buildrequires

* Fri Sep 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.22.4-1
- Package init
