#
# spec file for package libconfig
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


%define docbuild 0
%define _soversion 9
Name:           libconfig
Version:        1.5
Release:        1.3
Summary:        A simple library for manipulating structured configuration files
License:        LGPL-2.1+
Group:          Development/Libraries/C and C++
Url:            http://www.hyperrealm.com/libconfig
Source0:        http://www.hyperrealm.com/libconfig/libconfig-%{version}.tar.gz
Source1:        baselibs.conf
BuildRequires:  bison
BuildRequires:  fdupes
BuildRequires:  flex
BuildRequires:  gcc-c++
BuildRequires:  pkg-config
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if 0%{?docbuild} == 1
BuildRequires:  texinfo
BuildRequires:  texlive
BuildRequires:  texlive-latex
Requires(pre):  info
%endif

%description
Libconfig is a simple library for manipulating structured
configuration files, like this one: test.cfg. This file format
is more compact and more readable than XML. And unlike XML, it
is type-aware, so it is not necessary to do string parsing in
application code.

Libconfig is very compact — just 38K for the stripped C shared
library (less than one-fourth the size of the expat XML parser
library) and 66K for the stripped C++ shared library. This makes
it well-suited for memory-constrained systems like handheld
devices.

The library includes bindings for both the C and C++ languages.
It works on POSIX-compliant UNIX systems (GNU/Linux, Mac OS X,
Solaris, FreeBSD) and Windows (2000, XP and later).

%package -n libconfig%{_soversion}
Summary:        Shared libraries for libconfig
Group:          System/Libraries

%description -n libconfig%{_soversion}
Libconfig is a simple library for manipulating structured
configuration files, like this one: test.cfg. This file format
is more compact and more readable than XML. And unlike XML, it
is type-aware, so it is not necessary to do string parsing in
application code.

This package contains the shared libraries for libconfig.

%package devel
Summary:        C-Bindings development files for libconfig
Group:          Development/Languages/C and C++
Requires:       libconfig%{_soversion} = %{version}
Recommends:     libconfig-doc = %{version}

%description devel
Libconfig is a simple library for manipulating structured
configuration files, like this one: test.cfg. This file format
is more compact and more readable than XML. And unlike XML, it
is type-aware, so it is not necessary to do string parsing in
application code.

This package contains the C-bindings development files.

%package -n libconfig++%{_soversion}
Summary:        Shared libraries for libconfig
Group:          System/Libraries

%description -n libconfig++%{_soversion}
Libconfig is a simple library for manipulating structured
configuration files, like this one: test.cfg. This file format
is more compact and more readable than XML. And unlike XML, it
is type-aware, so it is not necessary to do string parsing in
application code.

This package contains the shared libraries for libconfig.

%package -n libconfig++-devel
Summary:        C++-Bindings development files for libconfig
Group:          Development/Languages/C and C++
Requires:       libconfig++%{_soversion} = %{version}
Requires:       libconfig-devel = %{version}
Recommends:     libconfig-doc = %{version}

%description -n libconfig++-devel
Libconfig is a simple library for manipulating structured
configuration files, like this one: test.cfg. This file format
is more compact and more readable than XML. And unlike XML, it
is type-aware, so it is not necessary to do string parsing in
application code.

This package contains the C++-bindings development files.

%if 0%{?docbuild} == 1
%package doc
Summary:        Documentation files for libconfig
Group:          Documentation/Other
%if 0%{?suse_version} >= 1130
BuildArch:      noarch
%endif

%description doc
Documentation files for package libconfig.
%endif

%prep
%setup -q

%build
%configure
make %{?_smp_mflags}
%if 0%{?docbuild} == 1
make %{?_smp_mflags} html
make %{?_smp_mflags} pdf
%endif

%install
%make_install
# clean up
pushd examples
    make clean
    find . -name '*.vcproj' -o -name '.deps' -exec rm -Rf '{}' '+'
popd
rm %{buildroot}%{_libdir}/*.la
%fdupes -s examples %{buildroot}%{_docdir}

%post -n libconfig%{_soversion} -p /sbin/ldconfig

%postun -n libconfig%{_soversion} -p /sbin/ldconfig

%post -n libconfig++%{_soversion} -p /sbin/ldconfig

%postun -n libconfig++%{_soversion} -p /sbin/ldconfig

%if 0%{?docbuild} == 1
%files doc
%defattr(-,root,root)
%doc doc/*.html doc/*.pdf examples
%endif

%files -n libconfig%{_soversion}
%defattr(-,root,root)
%doc AUTHORS COPYING* README
%{_libdir}/libconfig.so.*

%files -n libconfig++%{_soversion}
%defattr(-,root,root)
%doc AUTHORS COPYING* README
%{_libdir}/libconfig++.so.*

%files devel
%defattr(-,root,root)
%doc ChangeLog TODO
%{_includedir}/libconfig.h
%{_libdir}/libconfig.so
%{_libdir}/libconfig*.a
%{_libdir}/pkgconfig/libconfig.pc

%post -n libconfig++-devel
%install_info --info-dir=%{_infodir} %{_infodir}/libconfig.info.gz

%postun -n libconfig++-devel
%install_info_delete --info-dir=%{_infodir} %{_infodir}/libconfig.info.gz

%files -n libconfig++-devel
%defattr(-,root,root)
%doc ChangeLog TODO
%{_includedir}/libconfig.h++
%{_libdir}/libconfig++.so
%{_libdir}/pkgconfig/libconfig++.pc
%{_infodir}/libconfig.info.gz

%changelog
* Sun Jun  7 2015 i@marguerite.su
- update version 1.5.0
  * lib/libconfig.c - Don't fclose() a null pointer.
  * lib/libconfig.c, lib/wincompat.h - check if file being
    opened is a directory
  * lib/libconfig.c, lib/libconfig.h, lib/libconfig.h++,
    doc/libconfig.texi - added config_set_options(),
    config_get_options(), setOptions(), getOptions().
  * lib/libconfig.c++, lib/libconfig.h++ - added patches
    from Matt Renaud (added iterators, removed throws()
    specifications); added Setting.lookup(); code cleanup;
    added patch from Yuri Dyachenko (made exception
    constructors public)
  * lib/libconfig.c, lib/libconfig.h - renamed
    config_setting_lookup_from() to config_setting_lookup()
    and documented it; patch from Alexander Klauer (floating
    point precision loss)
  * doc/libconfig.texi - documented new APIs, bumped version
  * lib/scanner.c, lib/scanner.h, lib/scanner.l, libconfig.c -
    scanner code cleanup; and regenerated with flex 2.5.39
  * lib/grammar.c, lib/grammar.h, lib/grammar.y - parser code
    cleanup; and regenerated with bison 3.0.2
  * lib/libconfig.c - bugfix; capture root filename
  * tests/Makefile.am - fix for out-of-source builds
  * ac_config.h.in, aclocal.m4 - updated to newer autotools
* Sun Oct  5 2014 jengelh@inai.de
- Make doc subpackage noarch; improve on RPM group classification
* Sat Dec 29 2012 p.drouand@gmail.com
- Update to 1.4.9 version:
  * lib/libconfigcpp.c++ - Fixed compiler warnings in constructor
    initializers
  * tinytest/tiytest.c, tinytest/tinytest.h - added tt_file_exists();
    added alternate implementations of some test macros since MSVC does
    not support C99 fully; added comparators for text files (ignoring
    line endings)
  * tests/tests.c - use tt_file_exists() rather than access(); alias
    snprintf to _snprintf for MSVC; compare files as text files rather
    than as binary files
  * lib/scanner.l - fixed parsing issue when backslash in string is
    followed by invalid escape character; reported by Jimmy Scott
  * lib/scanner.c - regenerated
  * lib/libconfig.h, lib/libconfig.h++, lib/Makefile.am,
    doc/libconfig.texi, configure.ac - bump version numbers
  * aclocal.m4, ac_config.h - regenerated
  * m4/*, aux-build/*, libtool - updated to newer
* Sat May 19 2012 davejplater@gmail.com
- Added baselibs.conf for 32 bit ffado
- Disabled pdf and html docs, moved info to devel package
* Wed Mar 14 2012 saschpe@suse.de
- Fix typo, it's %%{_smp_mflags}
- Remove unwanted description paragraphs
* Mon Mar 12 2012 saschpe@suse.de
- Fixed changes file markup
* Mon Feb 27 2012 saschpe@suse.de
- Spec file cleanup:
  * Use original tarball
  * Move COPYING, README into lib packages (legal requirement)
  * Move CHANGELOG and TODO into devel packages (not needed by users)
  * Move examples into doc package, and recommend it for both devel packages
  * Ran spec cleaner and removed unneeded rpmlintrc
* Sat Feb 25 2012 davejplater@gmail.com
- Renamed package to libconfig and updated to 1.4.8
- Upstream changes:
  * tests/Makefile.am - marked 'libconfig_tests' as non-installable
  * lib/scanner.l, lib/grammar.y - grammar changes to make trailing
    semicolons optional (and to allow commas as an alternative)
  * lib/libconfig.c - bugfixes for lack of auto-conversion handling in
    the config_lookup*() functions (reported by Feng Yu), and some
    fixes for compiler warnings
  * lib/Makefile.am - bump .so version
  * configure.ac - bump version, add '-Wno-unused-parameter' compiler
    switch to disable "unused parameter" warnings
  * doc/libconfig.texi - documentation updates; added a chapter that
    calls attention to the bundled example programs
  * lib/libconfig.h, lib/libconfig.h++ - bump versions
  * doc/libconfig.texi - fixed typo; updated docs
  * TODO - updated list
  * lib/libconfig.c, lib/libconfig.h, lib/libconfigcpp.c++,
    lib/libconfig.h++ - added config{get,set}_default_format(),
    Config::{get,set}DefaultFormat()
  * lib/libconfig.c - fixed memory leak when encountering a parse error
    in an @include'd file
  * lib/libconfig.h, lib/libconfig.h++, lib/Makefile.am, configure.ac,
    doc/libconfig.texi - bump versions
  * doc/libconfig.texi - documentation updates
  * lib/libconfig.c, lib/libconfigcpp.c++, lib/libconfig.h,
    lib/libconfig.h++, lib/wincompat.h, lib/scanctx.c - added support
    for specifying an include directory
  * m4/* - added local m4 directory
  * contrib/* - added user-contributed files
- See /usr/share/doc/packages/libconfig/ChangeLog for more.
* Fri Oct  1 2010 davejplater@gmail.com
- Created libconfig++ from the pacman source rpm and adapted the spec
  file to openSUSE also transfered the changes to a changes file
* Wed May  5 2010 toni@links2linux.de
- update to 1.4.5
- This release includes a bugfix and some code cleanup to eliminate compiler warnings.
* Tue Apr 13 2010 toni@links2linux.de
- update to 1.4.4
- new SO-name ==> libconfig9 and libconfig++9
- This release fixes several build issues.
* Mon Feb 15 2010 toni@links2linux.de
- update to 1.4.3
- This release fixes a problem with parsing indented '@include' directives.
* Fri Jan 29 2010 toni@links2linux.de
- update to 1.4.2
- new SO-name ==> libconfig8 and libconfig++8 (!!!)
- removed static libs
- This release fixes some problems with the ParseException class.
* Fri Jan  1 2010 toni@links2linux.de
- update to 1.4.1
- This release fixes a crash when reading a configuration from a string,
  and includes a few minor build improvements.
* Fri Nov 13 2009 toni@links2linux.de
- update to 1.4
- new SO-name ==> libconfig9 and libconfig++9
- This release includes some minor bugfixes
* Sat Feb 21 2009 toni@links2linux.de
- Initial release 1.3.2