#
# spec file for package libyajl
#
# Copyright (c) 2019 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 https://bugs.opensuse.org/
#


%define sover 2
Name:           libyajl
Version:        2.1.0
Release:        5.12
Summary:        Yet Another JSON Library
License:        ISC
Group:          System/Libraries
Url:            http://lloyd.github.com/yajl/
Source0:        https://github.com/lloyd/yajl/archive/%{version}.tar.gz
Source1:        baselibs.conf
Source2:        json_reformat.1
Source3:        json_verify.1
Source99:       %{name}-rpmlintrc
Patch1:         libyajl-optflags.patch
Patch2:         libyajl-lib_suffix.patch
Patch3:         libyajl-pkgconfig.patch
BuildRequires:  bison
BuildRequires:  cmake
BuildRequires:  doxygen
BuildRequires:  flex
BuildRequires:  gcc-c++
BuildRequires:  pkgconf-pkg-config
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
YAJL is a small event-driven (SAX-style) JSON parser written in ANSI C, and a
small validating JSON generator.

%package -n %{name}%{sover}
Summary:        Yet Another JSON Library
Group:          System/Libraries

%description -n %{name}%{sover}
YAJL is a small event-driven (SAX-style) JSON parser written in ANSI C, and a
small validating JSON generator.

%package -n %{name}-devel
Summary:        Yet Another JSON Library (Development Environment)
Group:          Development/Libraries/C and C++
Requires:       %{name}%{sover} = %{version}

%description -n %{name}-devel
YAJL is a small event-driven (SAX-style) JSON parser written in ANSI C, and a
small validating JSON generator.

This package provides the necessary environment for compiling and linking
against %{name}.

%package -n %{name}-devel-static
Summary:        Yet Another JSON Library (Static Library)
Group:          Development/Libraries/C and C++
Requires:       %{name}-devel = %{version}

%description -n %{name}-devel-static
YAJL is a small event-driven (SAX-style) JSON parser written in ANSI C, and a
small validating JSON generator.

This package provides the necessary environment for linking statically
against %{name}.

%package -n yajl
Summary:        Yet Another JSON Library Tools
Group:          Productivity/Text/Utilities
Requires:       %{name}%{sover} = %{version}

%description -n yajl
YAJL is a small event-driven (SAX-style) JSON parser written in ANSI C, and a
small validating JSON generator.

This package provides a few command-line utilities for processing JSON files.

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

%build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects
%cmake
%cmake_build

%install
%cmake_install
install -d -m 0755 %{buildroot}%{_mandir}/man1
install -m644 %{SOURCE2} %{SOURCE3} %{buildroot}/%{_mandir}/man1

%check
make %{?_smp_mflags} test

%post   -n %{name}%{sover} -p /sbin/ldconfig

%postun -n %{name}%{sover} -p /sbin/ldconfig

%files -n %{name}%{sover}
%defattr(-,root,root)
%license COPYING
%{_libdir}/libyajl.so.%{sover}
%{_libdir}/libyajl.so.%{sover}.*

%files -n %{name}-devel
%defattr(-,root,root)
%doc README TODO
%{_includedir}/yajl
%{_libdir}/libyajl.so
%{_libdir}/pkgconfig/yajl.pc

%files -n %{name}-devel-static
%defattr(-,root,root)
%{_libdir}/libyajl_s.a

%files -n yajl
%defattr(-,root,root)
%{_mandir}/man1/json_reformat.1*
%{_mandir}/man1/json_verify.1*
%{_bindir}/json_reformat
%{_bindir}/json_verify

%changelog
* Fri Aug  2 2019 Martin Liška <mliska@suse.cz>
- Use FAT LTO objects in order to provide proper static library.
* Mon Mar 25 2019 olaf@aepfle.de
- Install pkgconfig into libdir instead of datadir with libyajl-pkgconfig.patch
- Use autosetup and cmake_build macro
- Rename macro soname to sover
* Tue Mar 27 2018 kukuk@suse.de
- Use %%license instead of %%doc [bsc#1082318]
- Move other docu to -devel package where it better fits
* Sun Apr 26 2015 mpluskal@suse.com
- Use correct url for download
- Add dependency on doxygen for doc generation
- Cleanup spec file with spec-clener
* Wed Nov  5 2014 ku.b@gmx.de
- update to 2.1.0
- 2.1.0
  - @nonodename, @patperry - fixed some compiler warnings
  - @yep, @emaste - documentation improvements
  - @sgravrock - build fix for NetBSD (and whenever sh != bash)
  - @rotty, @brimstone3, @lloyd - allow client to reset generator
  - @sgravrock - remove bash dependencies
  - @lloyd - add api tests
  - @rflynn - remove ruby dependency
  - @cloderic - nmake install works on windows
  - @shahbag - build fix for qnx
  - @breese - debugging improvements
  - @lloyd - json_verify supports -s flag for stream processing
  - @lloyd - json_reformat supports -s flag for stream processing
- 2.0.4
  - @jcekstrom - additional checking in integer parsing
  - @jcekstrom - fix a bug in yajl_tree that would cause valid json integersto fail to parse
  - @plaguemorin - fix a memory leak in yajl_tree (error strings were being leaked)
  - @7AC - reset errno
  - @ConradIrwin - include flags to reformatter to allow toggling of escape solidus option
- 2.0.3
  - John Stamp generation of a pkgconfig file at build time.
  - @robzuber bugfix in yajl_tree_get()
  - @lloyd - fix for compilation on 64 bit windows
- 2.0.2
  - lth fix typos in yajl_tree.h macros YAJL_IS_INTEGER and YAJL_IS_DOUBLE,
    contributed by Artem S Vybornov.
  - lth add #ifdef __cplusplus wrappers to yajl_tree to allow proper
    usage from many populer C++ compilers.
- fix array access
* Sun Jan 29 2012 jengelh@medozas.de
- Remove redundant tags/sections per specfile guideline suggestions
* Fri Sep 16 2011 jengelh@medozas.de
- Add libyajl-devel to baselibs
* Tue Aug 16 2011 mrueckert@suse.de
- bump baselibs.conf
* Fri Aug 12 2011 mrueckert@suse.de
- update to 2.0.1
  - lth generator flag to allow client to specify they want escaped
    solidi '/'.  issue #28
  - lth crash fix when yajl_parse() is never called. issue #27
- additional changes from 2.0.0
  - lth YAJL is now ISC licensed:
    http://en.wikipedia.org/wiki/ISC_license
  - lth 20-35%% (osx and linux respectively) parsing performance
    improvement attained by tweaking string scanning (idea:
    @michaelrhanson).
  - Florian Forster & lth - yajl_tree interface introduced as a
    higher level interface to the parser (eats JSON, poops a memory
    representation)
  - lth require a C99 compiler
  - lth integers are now represented with long long (64bit+) on all
    platforms.
  - lth size_t now used throughout to represent buffer lengths, so
    you can safely manage buffers greater than 4GB.
  - gno semantic improvements to yajl's API regarding partial value
    parsing and trailing garbage
  - lth new configuration mechanism for yajl, see yajl_config() and
    yajl_gen_config()
  - gno more allocation checking in more places
  - gno remove usage of strtol, replace with custom implementation
    that cares not about your locale.
  - lth yajl_parse_complete renamed to yajl_complete_parse.
  - lth add a switch to validate utf8 strings as they are
    generated.
  - lth tests are a lot quieter in their output.
  - lth addition of a little in tree performance benchmark,
    `perftest` in perf/perftest.c
- additional changes from 1.0.12
  - Conrad Irwin - Parse null bytes correctly
  - Mirek Rusin - fix LLVM warnings
  - gno - Don't generate numbers for keys. closes #13
  - lth - various win32 fixes, including build documentation
    improvements
  - John Stamp - Don't export private symbols.
  - John Stamp - Install yajl_version.h, not the template.
  - John Stamp - Don't use -fPIC for static lib.  Cmake will
    automatically add it for the shared.
  - lth 0 fix paths embedded in dylib upon installation on osx.
    closes #11
- refreshed optflags patch
* Thu Jun  2 2011 jfehlig@novell.com
- Add man pages for json_{reformat,verify}
* Wed Apr 13 2011 jfehlig@novell.com
- Add filters to rpmlintrc
- spec file: Document githash usage in tarbal name
* Wed Apr 13 2011 jfehlig@novell.com
- Add filters to rpmlintrc
- spec file: Document githash usage in tarbal name
* Fri Apr  8 2011 coolo@novell.com
- add baselibs.conf for 32bit library support
* Wed Feb  9 2011 pascal.bleser@opensuse.org
- revert last change, it is BSD3c indeed, and totally unrelated to
  bnc#670525
* Wed Feb  9 2011 pascal.bleser@opensuse.org
- fix license, changed from erroneous BSD3c to MIT, as stated on
  http://pyyaml.org/wiki/LibYAML, sort of fixes bnc#670525
* Tue Dec 21 2010 pascal.bleser@opensuse.org
- merge yajl package from darix:
  * lib -> LIBDIR patch
  * -devel-static subpackage
* Wed Dec  1 2010 pascal.bleser@opensuse.org
- update to 1.0.11: no user-visible changes
- changes from 1.0.10:
  * yajl version number now programatically accessible
* Mon Jul 12 2010 pascal.bleser@opensuse.org
- initial package (1.0.9)