File OpenCASCADE.spec of Package OpenCascade

#
# spec file for package OpenCASCADE
#
# 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.

%define _prefix /opt/OpenCASCADE
%define pkgname opencascade

Name:           OpenCASCADE
Version:        6.9.0
Release:        0
License:        LGPL-2.1 with additional exception
Summary:        CAD/CAM/CAE Platform
Url:            http://www.opencascade.org/
Group:          Productivity/Graphics/CAD
Source0:        %{pkgname}-%{version}.tar.bz2
Source1:        %{name}.conf
Source2:        DRAWEXE.1
Source3:        occ-icon.xpm
Source4:        occ-icon-32.xpm
Source5:        occ-icon-48.xpm
Source6:        opencascade-draw.desktop
Source7:        opencascade-draw.menu
Patch1:        %{name}-%{version}-destdir.patch
Patch2:        %{name}-%{version}-vtk-libraries-version.patch
# PATCH-FIX-OPENSUSE OpenCASCADE-6.9.0-vtk-type.patch build fix - could go upstream, too
Patch3:         OpenCASCADE-6.9.0-vtk-type.patch
BuildRequires:  autoconf
BuildRequires:  automake
BuildRequires:  bison
%ifarch i586
BuildRequires:  compat
%else
BuildRequires:  compat-32bit
%endif
BuildRequires:  fdupes
BuildRequires:  flex
BuildRequires:  freetype2-devel
BuildRequires:  ftgl-devel
BuildRequires:  gcc-c++
BuildRequires:  libqt4-devel
BuildRequires:  libtool
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xext)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(xt)
BuildRequires:  tcl-devel
BuildRequires:  tk-devel
BuildRequires:  update-desktop-files
BuildRequires:  vtk-devel >= 6.1.0
%if 0%{suse_version} >= 1315
BuildRequires:  java-1_8_0-openjdk-devel
%endif
BuildRequires:  libhdf4
# Used because of "implicit-fortify-decl" and "no-return-in-nonvoid-function" rpm post build check errors
BuildRequires:	-post-build-checks
Requires:       tcsh
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
OpenCASCADE is a suite for 3D surface and solid modeling, visualization, data
exchange and rapid application development. It is an excellent platform for
development of numerical simulation software including CAD/CAM/CAE, AEC and
GIS, as well as PDM applications.

%package devel
Summary:        Development files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}
Requires:       freetype2-devel
Requires:       ftgl-devel
Requires:       libqt4-devel
Requires:       pkgconfig(gl)
Requires:       pkgconfig(glu)
Requires:       pkgconfig(x11)
Requires:       pkgconfig(xext)
Requires:       pkgconfig(xmu)
Requires:       pkgconfig(xt)
Requires:       tcl-devel
Requires:       tk-devel

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

%prep
%setup -q -n %{pkgname}-%{version}
%patch1 -p1
%patch2 -p1
%patch3

%build
# cd ros
%ifarch x86_64 ppc64
export CFLAGS="%{optflags} -D_OCC64 -fno-strict-aliasing"
export CXXFLAGS="%{optflags} -D_OCC64 -fno-strict-aliasing"
%else
export CFLAGS="%{optflags} -fno-strict-aliasing"
export CXXFLAGS="%{optflags} -fno-strict-aliasing"
%endif
%define vtk_ver %(rpm -q --qf %%\{version\} vtk-devel | awk -F. \'\{ print $1 "." $2 \}\' )
autoreconf -fi
LDFLAGS=-lpthread %configure \
	--with-freetype=/usr \
	--with-ftgl=/usr \
	--with-tcl=/usr/%{_lib} \
	--with-tk=/usr/%{_lib} \
        --with-vtk-include=/usr/include/vtk-%{vtk_ver} \
        --with-vtk-library=/usr/%{_lib}/vtk \
        --disable-debug \
        --enable-production \
        --enable-shared \
        --disable-dependency-tracking \
        --disable-maintainer-mode \
        --enable-openmp \
        --with-qt=/usr/%{_lib} \
	--with-x

make %{?_smp_mflags}
# cd ..

%install
# cd ros
%makeinstall
# cd ..

# Fix rpmlint error "spurious-executable-perm" and warning "script-without-shebang"
`for i in $(find %{buildroot}%{_prefix}/inc/ -name '*.h'); do chmod -x $i; done`
`for i in $(find %{buildroot}%{_prefix}/inc/ -name '*.hxx'); do chmod -x $i; done`
`for i in $(find %{buildroot}%{_prefix}/inc/ -name '*.lxx'); do chmod -x $i; done`
`for i in $(find %{buildroot}%{_prefix}/inc/ -name '*.gxx'); do chmod -x $i; done`

# Fix rpmlint error "spurious-executable-perm"
chmod -x %{buildroot}%{_prefix}/src/UnitsAPI/UnitsAPI.cxx
#chmod -x %{buildroot}%{_prefix}/src/DrawResources/Filtre.c
#chmod -x %{buildroot}%{_prefix}/src/DrawResources/TestDraw.cxx
#chmod -x %{buildroot}%{_prefix}/src/DrawResources/DIFF.c

# Fix rpmlint warning "script-without-shebang"
chmod -x %{buildroot}%{_prefix}/src/UnitsAPI/Lexi_Expr.dat
chmod -x %{buildroot}%{_prefix}/src/UnitsAPI/Units.dat

# Remove unneeded files
rm -f %{buildroot}%{_libdir}/*.la
rm -f %{buildroot}%{_libdir}/opencas/*.la
rm -f %{buildroot}%{_prefix}/config.h
rm -f %{buildroot}%{_prefix}/inc/config.h

# Install additional files
mv data %{buildroot}%{_prefix}/
mv doc %{buildroot}%{_prefix}/
install -pm 0644 LICENSE_LGPL_21.txt %{buildroot}%{_prefix}/doc/
mv samples %{buildroot}%{_prefix}/

# Fix rpmlint warning "wrong-script-end-of-line-encoding"
find %{buildroot}%{_prefix}/data -type f -print0 |xargs -0 chmod a-x
# Fix rpmlint warnings "wrong-script-end-of-line-encoding" and "script-without-shebang"
find %{buildroot}%{_prefix}/doc -type f -print0 |xargs -0 chmod a-x
# Remove unneeded file (fix also rpmlint warning "non-executable-script")
rm -f  %{buildroot}%{_prefix}/doc/ReferenceDocumentation/html/installdox
# Fix rpmlint error "spurious-executable-perm" and warnings "wrong-script-end-of-line-encoding", "script-without-shebang"
find %{buildroot}%{_prefix}/samples -type f -print0 |xargs -0 chmod a-x
# Fix rpmlint error "suse-filelist-forbidden-backup-file"
rm -f %{buildroot}%{_prefix}/samples/mfc/04_Viewer3d/src/TexturesExt_Presentation.cpp.bak
rm -f %{buildroot}%{_prefix}/samples/mfc/09_Animation/src/AnimationView3D.cpp.bak

%ifarch x86_64
ln -s %{_libdir} %{buildroot}/%{_prefix}/Linux/lib
#ln -s %{_libdir} %{buildroot}/%{_prefix}/lin/lib
%endif

# Add synlinks for compatibility resons
mkdir -p %{buildroot}/usr/share/opencascade/
mkdir -p %{buildroot}/usr/include/
mkdir -p %{buildroot}/usr/share/doc/packages/
mkdir -p %{buildroot}/usr/%{_lib}/
mkdir -p %{buildroot}/usr/bin/

ln -s %{_bindir}/DRAWEXE %{buildroot}/usr/bin/DRAWEXE
ln -s %{_prefix} %{buildroot}/usr/share/opencascade/%{version}
ln -s %{_prefix}/inc %{buildroot}/usr/include/opencascade
ln -s %{_prefix}/doc %{buildroot}/usr/share/doc/packages/%{name}
`for i in $(ls %{buildroot}/%{_libdir}); do ln -s %{_libdir}/$i %{buildroot}/usr/%{_lib}/$i; done`

#
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d/
cp -a %{SOURCE1} %{buildroot}%{_sysconfdir}/ld.so.conf.d/

# Install man page and other sources
mkdir -p %{buildroot}/usr/share/man/man1
mkdir -p %{buildroot}/usr/share/pixmaps
mkdir -p %{buildroot}/usr/share/applications
mkdir -p %{buildroot}%{_sysconfdir}/xdg/menus

cp -a %{SOURCE2} %{buildroot}/usr/share/man/man1/
cp -a %{SOURCE3} %{SOURCE4} %{SOURCE5} %{buildroot}/usr/share/pixmaps/
cp -a %{SOURCE6} %{buildroot}/usr/share/applications
cp -a %{SOURCE7} %{buildroot}%{_sysconfdir}/xdg/menus

%suse_update_desktop_file opencascade-draw Education Science 

%fdupes -s %{buildroot}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%dir %{_prefix}
%dir %{_bindir}
# %dir %{_prefix}/lin
%dir %{_prefix}/Linux
%dir %{_prefix}/data
%dir %{_prefix}/doc
%dir %{_prefix}/src/UnitsAPI
%dir %{_prefix}/src
%dir %{_libdir}
%dir /usr/share/opencascade
%dir %{_sysconfdir}/xdg/menus
%{_bindir}/DRAWEXE
# %{_prefix}/lin/bin
# %{_prefix}/lin/lib
%{_prefix}/Linux/bin
%{_prefix}/Linux/lib
%{_prefix}/data/*
%{_prefix}/doc/*
%{_prefix}/src/UnitsAPI/*.dat
%{_prefix}/*.sh
%{_libdir}/*.so.*
# %{_libdir}/opencas
/usr/bin/DRAWEXE
/usr/%{_lib}/*.so.*
# /usr/%{_lib}/opencas
/usr/share/opencascade/%{version}
%doc /usr/share/doc/packages/%{name}
%doc /usr/share/man/man1/DRAWEXE.1%{ext_man}
/usr/share/pixmaps/*.xpm
/usr/share/applications/*.desktop
%config %{_sysconfdir}/xdg/menus/opencascade-draw.menu
%config %{_sysconfdir}/ld.so.conf.d/%{name}.conf

%files devel
%defattr(-,root,root,-)
%dir %{_prefix}/%{_lib}
%{_prefix}/%{_lib}/*.so
%dir %{_prefix}/src
%{_prefix}/src/*
%dir %{_prefix}/inc
%{_prefix}/inc/*
%dir %{_prefix}/samples
%{_prefix}/samples/*
/usr/include/opencascade
/usr/%{_lib}/*.so
%exclude %{_prefix}/src/UnitsAPI/*.dat

%changelog