%define pkg_name    opensource-cobol
%define pkg_version 1.5.2J
%define pkg_release 1%{?_dist_release}

Summary: An open-source COBOL compiler
Name:    %{pkg_name}
Version: %{pkg_version}
Release: %{pkg_release}

License: GPLv2
Group:   Development/Languages
URL:     https://www.osscons.jp/
Source0: %{name}-%{version}-utf8.tar.gz

Buildroot: %{_tmppath}/%{name}-%{version}-root

%if %{?_dist_release} == "vl6"
BuildRequires: db4-devel
%else
BuildRequires: libdb-devel
%endif
BuildRequires: gmp-devel
BuildRequires: ncurses-devel

BuildRequires: texinfo
BuildRequires: texlive-common
%if %{?_dist_release} == "vl6"
BuildRequires: texlive-collection-texinfo
%endif
%if %{?_dist_release} >= "vl7"
BuildRequires: texlive-collection-plaingeneric
BuildRequires: texlive-collection-fontsrecommended
%endif

Requires: ncurses-devel
%if %{?_dist_release} == "vl6"
Requires: db4-devel
%else
Requires: libdb-devel
%endif

Vendor: Project Vine
Distribution: Vine Linux
Packager: ara_t


%description
"opensource COBOL" is open-source COBOL compiler,
an extension of the Japan-specific features.
"opensource COBOL" translates COBOL program to C code
and compiles it using GCC or CL.

It was forked from OpenCOBOL in 2012.
See also OpenCOBOL project.
    http://www.opencobol.org/
    http://sourceforge.net/projects/open-cobol/

%description -l ja
opensource COBOLは、オーペンソースのCOBOLコンパイラであり、
COBOLプログラムをC言語のコードに翻訳し、GCCあるいはCLを用いて
コンパイルします。

opensource COBOLは、オープンCOBOLソリューション部会によって
OpenCOBOLに日本特有のビジネス環境に即したカスタマイズ、
メンテナンスを加えたものです。


%prep
%{__rm} -rf ${RPM_BUILD_ROOT}
%setup -q -n %{name}-%{version}-utf8

%build
%{configure} \
 --enable-utf8 \
 --disable-static

%{__make} %{?_smp_mflags}
%{__make} pdf html

%check
%{__make} check

%install
%{make_install}
%{__rm} ${RPM_BUILD_ROOT}%{_libdir}/*.la
%{__rm} ${RPM_BUILD_ROOT}%{_infodir}/dir

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

%post
%{_syssbindir}/install-info %{_infodir}/open-cobol.info.gz \
 %{_infodir}/dir 2>/dev/null
%{_syssbindir}/ldconfig

%preun
if [ $1 = 0 ]; then
    %{_syssbindir}/install-info --delete %{_infodir}/open-cobol.info.gz \
     %{_infodir}/dir 2>/dev/null
fi

%postun -p %{_syssbindir}/ldconfig


%files
%defattr(-,root,root)
%doc AUTHORS ChangeLog COPYING* NEWS README THANKS TODO
%doc texi/open-cobol.pdf
%doc texi/open-cobol.html/
%{_bindir}/
%{_includedir}/libcob.h
%{_includedir}/libcob
%{_libdir}/libcob.so*
%{_datadir}/locale/
%{_datadir}/%{name}-%{version}
%{_infodir}/*.info.gz


%changelog
* Sun Apr 21 2019 Toshiaki Ara <ara_t@384.jp> 1.5.2J-1
- new upstream release
- change to BuildRequires: texlive-collection-plaingeneric

* Mon Dec 12 2016 Toshiaki Ara <ara_t@384.jp> 1.5.1J-1
- new upstream release

* Sun Nov 06 2016 Toshiaki Ara <ara_t@384.jp> 1.5.0J-3
- change Group to Development/Languages

* Fri Jul 29 2016 Toshiaki Ara <ara_t@384.jp> 1.5.0J-2
- change Requires: ncurses to ncurses-devel
- change Requires: db4/libdb to db4-devel/libdb-devel
- add export CFLAGS="%{optflags} -std=gnu89" for VineSeed (gcc-5)

* Sun Jun 19 2016 Toshiaki Ara <ara_t@384.jp> 1.5.0J-1
- update to 1.5.0J
- delete BuildRequires: texlive-collection-lang*

* Sat May 14 2016 Toshiaki Ara <ara_t@384.jp> 1.4.0J-2
- rebuild under texlive 2016 pretest
- add BuildRequires

* Fri May 13 2016 Toshiaki Ara <ara_t@384.jp> 1.4.0J-1
- new package

