File FreeCAD.spec of Package FreeCAD

# spec file for package FreeCAD
# Copyright (c) 2012 SUSE LINUX Products 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

%define x_prefix %{_libdir}/%{name}

Name:           FreeCAD
Version:        0.16
Release:        0
License:        LGPL-2.0+ and GPL-2.0+
Summary:        General Purpose 3D CAD Modeler
Group:          Productivity/Graphics/CAD
Source0:        %{name}-%version.tar.xz
Source2:        FreeCAD_shared_mimeinfo
BuildRequires:  Coin-devel
BuildRequires:  oce-devel
BuildRequires:  SoQt-devel
%if 0%{?suse_version} == 1315 && 0%{?is_opensuse} == 1
# Leap has it's own special boost-devel
BuildRequires:  boost_1_58_0-devel
BuildRequires:  boost-devel >= 1.55
BuildRequires:  cmake
BuildRequires:  doxygen
BuildRequires:  f2c
BuildRequires:  fdupes
BuildRequires:  freeglut-devel
BuildRequires:  gcc-fortran
BuildRequires:  pkg-config
BuildRequires:  pkgconfig(QtWebKit)
BuildRequires:  libXerces-c-devel
%if 0%{?suse_version} > 0
BuildRequires:  libeigen3-devel
BuildRequires:  python-xml
%if 0%{?fedora} > 18
BuildRequires:  eigen3-devel
BuildRequires:  libqt4-devel
BuildRequires:  libspnav-devel
BuildRequires:  opencv-devel
BuildRequires:  python-CXX-devel
BuildRequires:  python-devel
BuildRequires:  python-matplotlib
BuildRequires:  swig
%if 0%{?suse_version}
BuildRequires:  update-desktop-files
BuildRequires:  zlib-devel
# Used because of "no-return-in-nonvoid-function" and "stringcompare" rpm post build check errors
#BuildRequires:	-post-build-checks
BuildRequires:  unzip
BuildRequires:	libshiboken-devel
BuildRequires:	python-pyside
BuildRequires:	python-pyside-devel
BuildRequires:	python-pyside-tools
BuildRequires:	git
BuildRequires:	make
BuildRequires:  dos2unix
BuildRequires:  hdf5-devel
Requires:       python-cxx
Requires(post): shared-mime-info
Requires(postun): shared-mime-info
Recommends:     python-pivy
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

Note: This package contains the current development version and thus might
be unstable!

FreeCAD is a general purpose 3D CAD modeler. The development will be completely
Open Source. As with many modern 3D CAD modelers it will have a 2D component in
order to extract design detail from the 3D model to create 2D production
drawings, although 2D (e.g. AutoCAD LT) is not the focus, neither are animation
and organic shapes (e.g. Maya, 3D StudioMAX and Cinema 4D).

%package devel
Summary:        Development Files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
This package contains the files needed for development with FreeCAD.

%setup -q

# Fix "wrong-file-end-of-line-encoding" rpmlint warning
sed -i 's/\r$//' ChangeLog.txt
sed -i 's/\r$//' copying.lib

# Fix "wrong-script-end-of-line-encoding" rpmlint warning
sed -i 's/\r$//' src/Mod/PartDesign/Scripts/
sed -i 's/\r$//' src/Mod/Robot/

# Remove 3rd party libs
rm src/3rdparty/Pivy -fr
rm src/3rdparty/Pivy-0.5 -fr

mkdir build && cd build
# cmake macro would set standard libdir
# it needs an older specific zipios version  -DFREECAD_USE_EXTERNAL_ZIPIOS=TRUE 
cmake \
  -DCMAKE_INSTALL_PREFIX=%{_libdir}/%{name} \
  -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
  -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
  -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir}/%{name} \
  -DOCC_INCLUDE_DIR=%{_includedir}/oce \
  -DRESOURCEDIR=%{_datadir}/%{name} \
%if %{with netgen}

make VERBOSE=1 %{?_smp_mflags} all

# # Build documentation last, somehow
# # this triggers a rebuild
# mkdir build_doc
# pushd build_doc
# cmake \
#   -DCMAKE_INSTALL_PREFIX=%{_prefix} \
#   -DLIB_SUFFIX=%{_lib} \
#   -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
#   -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
#   -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir}/%{name} \
#   -DCMAKE_BUILD_TYPE=Release \
#   ../
#   # Needs an updated opencascade
#   #-DOCE_DIR=/opt/OpenCASCADE/%{_lib}
# nice make VERBOSE=1 DevDoc
# popd

pushd build
nice make VERBOSE=1 %{?_smp_mflags} install DESTDIR=%{buildroot}

# pushd build_doc
# nice make VERBOSE=1 %{?_smp_mflags} install DESTDIR=%{buildroot}
# popd

# Install the Qt plugin
#install -Dpm 0755 src/Tools/plugins/widget/ %{buildroot}/usr/%{_lib}/qt4/plugins/designer/

# Fix "non-executable-script" rpmlint warning
chmod 755 %{buildroot}%{x_prefix}/Mod/Robot/

# Move desktop icon in the correct location
mkdir -p %{buildroot}/usr/share/pixmaps
mv %{buildroot}%{_datadir}/%{name}/freecad.xpm %{buildroot}/usr/share/pixmaps/freecad.xpm

# Install additional documentation files
install -pm 0644 ChangeLog.txt copying.lib %{buildroot}%{_docdir}/%{name}/

%if 0%{?suse_version}
%suse_update_desktop_file -c %{name} "%{name}" "3D CAD Modeler" %{name} "freecad" Education Engineering

# Install mime type
install -Dpm 0644 %{SOURCE2} %{buildroot}/usr/share/mime/packages/%{name}.xml

# Remove unneeded files
find %{buildroot} -name '*.la' -exec rm -f {} ';'

# Fix rpmlint warning "doc-file-dependency"
rm -f html/installdox

# Install development documentation manually in order to fix rpmlint warning "files-duplicate"
mkdir -p %{buildroot}%{_docdir}/%{name}-devel
#cp -a html/ %{buildroot}%{_docdir}/%{name}-devel/

# Correct line endings
dos2unix %{buildroot}%{x_prefix}/Mod/PartDesign/Scripts/
dos2unix %{buildroot}%{x_prefix}/Mod/PartDesign/Scripts/
dos2unix %{buildroot}%{x_prefix}/Mod/Test/
dos2unix %{buildroot}%{x_prefix}/Mod/Part/

# Link binaries
mkdir -p %{buildroot}/usr/bin
ln -s -t %{buildroot}/usr/bin %{x_prefix}/bin/FreeCAD
ln -s -t %{buildroot}/usr/bin %{x_prefix}/bin/FreeCADCmd

%fdupes -s %{buildroot}

/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

/usr/bin/update-mime-database %{_datadir}/mime &> /dev/null || :

%doc %{_docdir}/%{name}/
%if 0%{?suse_version} > 0