File gnu-cobol.spec of Package gnu-cobol

#
# spec file for package gnu-cobol
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%define         _lto_cflags      %{nil}
%define sover   4
%define _mver   3.2
Name:           gnu-cobol
Version:        3.2
Release:        0
Summary:        A COBOL compiler
License:        GPL-3.0-or-later AND LGPL-3.0-or-later
Group:          Development/Languages/Other
URL:            https://savannah.gnu.org/projects/gnucobol
Source0:        https://sourceforge.net/projects/open-cobol/files/gnu-cobol/%{_mver}/gnucobol-%{version}.tar.xz
Source1:        https://sourceforge.net/projects/open-cobol/files/gnu-cobol/%{_mver}/gnucobol-%{version}.tar.xz.sig

# https://sourceforge.net/p/gnucobol/bugs/941/
Patch0:         xml-parser.patch
BuildRequires:  autoconf
BuildRequires:  db-devel
BuildRequires:  dos2unix
BuildRequires:  gcc
BuildRequires:  gmp-devel
BuildRequires:  help2man
BuildRequires:  libxml2-devel
BuildRequires:  libjson-c-devel
BuildRequires:  libdbi-devel  
BuildRequires:  makeinfo
BuildRequires:  pkgconfig(json-c) >= 0.12
BuildRequires:  pkgconfig(libxml-2.0)
BuildRequires:  pkgconfig(ncurses) >= 5.4
Requires(post): %{install_info_prereq}
Requires(preun): %{install_info_prereq}
Provides:       libcob-devel = %{version}
Provides:       opencobol = %{version}
Obsoletes:      libcob-devel <= 3.1.2

%description
GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler.
cobc translates COBOL to executable using intermediate C sources,
providing full access to nearly all C libraries.

%package -n libcob%{sover}
Summary:        GnuCOBOL shared library
License:        LGPL-3.0-or-later
Group:          Development/Languages/Other

%description -n libcob%{sover}
GnuCOBOL (formerly OpenCOBOL) is a COBOL compiler.
cobc translates COBOL to executable using intermediate C sources,
providing full access to nearly all C libraries.

%package esql
Summary:        ESQL for GnuCOBOL
License:        LGPL-3.0-or-later

%description esql
Embedded SQL (ESQL) compiler for GnuCOBOL

%prep
%autosetup -p0 -n gnucobol-%{version}

%build
export CFLAGS="$CFLAGS \
%if 0%{?suse_version} > 1600
              -std=gnu17 \
%endif
              -O3"
%global optflags %{optflags}
%configure \
        --enable-hardening \
        --enable-static=no \
        --with-xml2 \
        --with-db \
        --with-curses=ncursesw  \
        --with-json=json-c
%make_build

%install
%make_install
%find_lang gnucobol
find %{buildroot} -type f -name "*.la" -delete -print

%check
%make_build check

%post
%install_info --info-dir=%{_infodir} %{_infodir}/gnucobol.info.gz

%preun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/gnucobol.info.gz

%post -n libcob%{sover} -p /sbin/ldconfig
%postun -n libcob%{sover} -p /sbin/ldconfig

%files -f gnucobol.lang
%license COPYING COPYING.DOC
%doc ABOUT-NLS AUTHORS ChangeLog NEWS README THANKS TODO
%{_bindir}/cob-config
%{_bindir}/cobc
%{_bindir}/cobcrun
%{_datadir}/gnucobol
%{_infodir}/gnucobol.info%{?ext_info}
%{_libdir}/gnucobol
%{_libdir}/libcob.so
%{_includedir}/*
%{_mandir}/man1/cob-config.1%{ext_info}
%{_mandir}/man1/cobc.1%{ext_info}
%{_mandir}/man1/cobcrun.1%{ext_info}

%files -n libcob%{sover}
%license COPYING.LESSER
%{_libdir}/libcob.so.%{sover}*
%{_libdir}/gnucobol/CBL_OC_DUMP.so

%files esql
%{_bindir}/esqlOC
%{_libdir}/libocsql.so*

%changelog
openSUSE Build Service is sponsored by