File kicad.spec of Package kicad

#
# spec file for package kicad
#
# Copyright (c) 2017 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/
#


Name:           kicad
Version:        4.0.7
Release:        0
Summary:        EDA software suite for the creation of schematics and PCB
License:        GPL-2.0+ and GPL-3.0+
Group:          Productivity/Scientific/Electronics
Url:            http://kicad-pcb.org
Source:         https://launchpad.net/kicad/4.0/%{version}/+download/kicad-%{version}.tar.xz
# License file was removed due to GPL-3.0+ code
# https://github.com/KiCad/kicad-source-mirror/commit/681090b8ef3a362af75e8ca4417e18622747b63b
Source2:        COPYRIGHT.txt
# PATCH-FEATURE-OPENSUSE kicad-user-library.patch -- add user library path
Patch1:         kicad-user-library.patch
# PATCH-FEATURE-OPENSUSE kicad-library-repos-install.patch
Patch2:         kicad-library-repos-install.patch
# PATCH-FIX-OPENSUSE davejplater@gmail.com -kicad-suse-help-path.patch - kicad looks in /usr/share/doc/kicad for help files and doesn't find them.
# this patch adds packges/ befor kicad.
Patch3:         kicad-suse-help-path.patch
%if 0%{?suse_version} > 1320 || 0%{?suse_version} == 1315
# PATCH-FIX-UPSTREAM kicad-boost-1_61-boost-context-changes.patch -- Fix build with boost 1.61
Patch4:         kicad-boost-1_61-boost-context-changes.patch
# PATCH-OPENSUSE kicad-set-cxx-standard.diff -- use C++14 by default and decay to 11, required by boost 1.61 patch
Patch5:         kicad-set-cxx-version.patch
%endif
%if 0%{?suse_version} > 1325
BuildRequires:  libboost_context-devel
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_iostreams-devel
BuildRequires:  libboost_locale-devel
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_regex-devel
BuildRequires:  libboost_thread-devel
%else
BuildRequires:  boost-devel >= 1.56
%endif
BuildRequires:  cmake
BuildRequires:  doxygen
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libcurl-devel
BuildRequires:  pkg-config
BuildRequires:  python-devel
BuildRequires:  update-desktop-files
# Use direct version to avoid problems with wx 3.2
BuildRequires:  wxWidgets-3_0-devel >= 3
# Fix bug in old python-wxWidgets-3_0-devel
BuildRequires:  python-wxWidgets-3_0 >= 3
BuildRequires:  python-wxWidgets-3_0-devel >= 3
BuildRequires:  swig
BuildRequires:  pkgconfig(bzip2)
BuildRequires:  pkgconfig(cairo)
BuildRequires:  pkgconfig(glew)
BuildRequires:  pkgconfig(openssl)
BuildRequires:  pkgconfig(zlib)
# Fix directory owner
BuildRequires:  hicolor-icon-theme
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Requires:       python-wxWidgets-3_0 >= 3
# The help function doesn't work without the doc package
Requires:       %{name}-doc = %{version}
Recommends:     %{name}-library = %{version}
Recommends:     %{name}-library-install = %{version}
Recommends:     %{name}-footprints = %{version}
Obsoletes:      kicad = 20140120

%description
Kicad is an open source (GPL) software for the creation of electronic schematic
diagrams and printed circuit with up to 32 copper layers and additional techinical layers.

KiCad includes a project manager and four main independent software tools:
- Eeschema: schematic editor.
- Pcbnew: printed circuit board editor.
- Gerbview: GERBER file viewer (photoplotter documents).
- Cvpcb: footprint selector for components association.

%package        library-install
Summary:        Script for KiCad libraries downloading
Group:          Productivity/Scientific/Electronics
Requires:       %{name} = %{version}
Requires:       curl
Requires:       git-core
Requires:       sed

%description    library-install
Kicad is an open source (GPL) software for the creation of electronic schematic
diagrams and printed circuit with up to 32 copper layers and additional techinical layers.

This package contains script for KiCad libraries downloading.

%prep
%setup -q -n kicad-%{version}
%patch1 -p0
%patch2 -p1
%patch3
# patch requires C++11, CMAKE_CXX_STANDARD requires cmake 3.1 -> Leap 42.1 or TW
%if 0%{?suse_version} > 1320 || 0%{?suse_version} == 1315
%patch4
%patch5 -p0
%endif

cp %{SOURCE2} .

# Fix plugin directory
sed -i 's|KICAD_PLUGINS lib/kicad/plugins|KICAD_PLUGINS %{_lib}/kicad/plugins|' CMakeLists.txt
# Fix documentation directory
sed -i 's|KICAD_DOCS share/doc/kicad|KICAD_DOCS share/doc/packages/kicad|' CMakeLists.txt

%build
export CFLAGS="%{optflags} -fPIE"
export CXXFLAGS="$CFLAGS"
%cmake \
    -DKICAD_REPO_NAME=stable \
    -DKICAD_BUILD_VERSION=%{version} \
    -DKICAD_SKIP_BOOST=ON \
    -DBUILD_GITHUB_PLUGIN=ON \
    -DKICAD_SCRIPTING=ON \
    -DKICAD_SCRIPTING_MODULES=ON \
    -DKICAD_SCRIPTING_WXPYTHON=ON \
    -DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -pie"

make %{?_smp_mflags}

%install
%cmake_install

find %{buildroot}%{_datadir}/kicad/scripting/plugins -name "*.py" -exec chmod 0644 "{}" "+"
#Change permissions back for executable scripts
chmod -f 0755 `find %{buildroot}%{_datadir}/kicad/scripting/plugins -name "*.py" -perm 0644 -print0|xargs -0r grep -l '#!/usr'`

%suse_update_desktop_file -r bitmap2component "Education;Engineering"
%suse_update_desktop_file -r cvpcb "Education;Engineering"
%suse_update_desktop_file -r eeschema "Education;Engineering"
%suse_update_desktop_file -r gerbview "Education;Engineering"
%suse_update_desktop_file -r kicad "Education;Engineering"
%suse_update_desktop_file -r pcbcalculator "Education;Engineering"
%suse_update_desktop_file -r pcbnew "Education;Engineering"

install -D scripts/library-repos-install.sh %{buildroot}%{_bindir}/kicad-library-install.sh

%fdupes -s %{buildroot}%{_datadir}/kicad
%fdupes -s %{buildroot}%{_datadir}/icons/hicolor

%post
%desktop_database_post
%icon_theme_cache_post
%mime_database_post

%postun
%desktop_database_postun
%icon_theme_cache_postun
%mime_database_postun

%files
%defattr(-,root,root)
%doc CHANGELOG.txt COPYRIGHT.txt
%{_bindir}/*
%exclude %{_bindir}/kicad-library-install.sh
%{_libdir}/kicad/
%{_datadir}/kicad/
%{_datadir}/doc/packages/kicad/
%{python_sitelib}/*
%{_datadir}/applications/*.desktop
%{_datadir}/mime/packages/kicad.xml
%{_datadir}/mimelnk/application/x-kicad-*.desktop
%dir %{_datadir}/mimelnk/
%dir %{_datadir}/mimelnk/application/
%{_datadir}/icons/hicolor/*/mimetypes/application-x-*
%{_datadir}/icons/hicolor/*/apps/*.*

%files library-install
%defattr(-,root,root)
%{_bindir}/kicad-library-install.sh

%changelog
openSUSE Build Service is sponsored by