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

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
# License file was removed due to GPL-3.0+ code
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 -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
%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
BuildRequires:  boost-devel >= 1.56
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

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.

%setup -q -n kicad-%{version}
%patch1 -p0
%patch2 -p1
# 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
%patch5 -p0

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

export CFLAGS="%{optflags} -fPIE"
%cmake \
    -DKICAD_REPO_NAME=stable \
    -DKICAD_BUILD_VERSION=%{version} \
    -DCMAKE_EXE_LINKER_FLAGS="-Wl,--as-needed -Wl,--no-undefined -Wl,-z,now -pie"

make %{?_smp_mflags}


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/ %{buildroot}%{_bindir}/

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



%exclude %{_bindir}/
%dir %{_datadir}/mimelnk/
%dir %{_datadir}/mimelnk/application/

%files library-install

openSUSE Build Service is sponsored by