%define _unpackaged_files_terminate_build 1

Summary:        Graph Visualization Tools
Summary(ja):	グラフ可視化ツール
Name:           graphviz
Version:        2.49.3
Release:        2%{?_dist_release}
Group:          graphics
Vendor:         Project Vine
Distribution:   Vine Linux
Packager:       daisuke

License:        EPL
URL:            https://www.graphviz.org/
Source0:        https://gitlab.com/graphviz/graphviz/-/archive/%{version}/%{name}-%{version}.tar.bz2

BuildRequires:  bison
BuildRequires:  cairo-devel
BuildRequires:  expat-devel
BuildRequires:  flex
BuildRequires:  fontconfig-devel
BuildRequires:  freetype2-devel
BuildRequires:  gd-devel
BuildRequires:  ghostscript
BuildRequires:  gmp-devel
BuildRequires:  gtk2-devel
BuildRequires:  guile-devel
BuildRequires:  libjpeg-turbo-devel
BuildRequires:  libpng-devel 
BuildRequires:  libSM-devel
BuildRequires:  libtool-ltdl-devel >= 2.2.6a
BuildRequires:	libXaw-devel
BuildRequires:  libXext-devel
BuildRequires:  librsvg2-devel
BuildRequires:  lua-devel
BuildRequires:  m4
BuildRequires:  perl
BuildRequires:  python3-devel
BuildRequires:  python3-rpm-macros
BuildRequires:  python3-setuptools
BuildRequires:  ruby-devel
BuildRequires:  swig
BuildRequires:  tcl-devel >= 8.4
BuildRequires:  tk-devel >= 8.4
BuildRequires:  zlib-devel
Requires:	urw-fonts

# only for this release
# BuildConflicts: graphviz-devel

%description
A collection of tools and tcl packages for the manipulation and layout
of graphs (as in nodes and edges, not as in barcharts).


%package devel
Summary:        Development tools for version %{version} of %{name}
Group:          programming
Requires:       %{name} = %{version}

%description devel
The %{name}-devel package contains the header files
and man3 pages necessary for developing programs
using version %{version} of the %{name} libraries.


%package doc
Summary: PDF and HTML documents for graphviz
Group:	 documentation

%description doc
Provides some additional PDF and HTML documentation for graphviz.


%package guile
Summary:	Guile extension for graphviz
Group:          programming
Requires:	%{name} = %{version}-%{release}, guile

%description guile
Guile extension for graphviz.


%package lua
Summary:	Lua extension for graphviz
Group:          programming
Requires:	%{name} = %{version}-%{release}, lua

%description lua
Lua extension for graphviz.


%package perl
Summary:  Perl extension for graphviz
Group:  programming
Requires: %{name} = %{version}-%{release}
Requires: perl >= 2:5.34.0

%description perl
Perl extension for graphviz.


%package -n python3-graphviz
Summary:  Python3 extension for graphviz
Group:          programming
Requires: %{name} = %{version}-%{release}
Requires: python3
Obsoletes: graphviz-python3 < 2.49.0
Provides: graphviz-python3 = %{version}-%{release}

%description -n python3-graphviz
Python3 extension for graphviz.


%package ruby
Summary:  Ruby extension for graphviz
Group:          programming
Requires: %{name} = %{version}-%{release}
Requires: ruby

%description ruby
Ruby extension for graphviz.


%package tcl
Summary:  Tcl extension & tools for graphviz
Group:          programming
Requires: tcl >= 8.4, tk >= 8.4
Requires: %{name} = %{version}

%description tcl
Various tcl packages (extensions) for the graphviz tools.


%debug_package


%prep
%setup -q -n graphviz-%{version}
# Attempt to fix rpmlint warnings about executable sources
find -type f -regex '.*\.\(c\|h\)$' -exec chmod a-x {} ';'


%build
./autogen.sh

# using archdir instead of sitearchdir for Vine
sed -i -e "s|sitearchdir|archdir|g" config/config_ruby.rb
# Rewrite config_ruby.rb to work with Ruby 2.1
sed -i 's|expand(|expand(RbConfig::|' config/config_ruby.rb
sed -i 's|sitearchdir|vendorarchdir|' config/config_ruby.rb

# get the path to search for ruby/config.h to CPPFLAGS, so that configure can find it
export CPPFLAGS=-I`ruby -e "puts File.join(RbConfig::CONFIG['includedir'], RbConfig::CONFIG['sitearch'])" || echo /dev/null`
# XXX ix86 only used to have -ffast-math, let's use everywhere
%{expand: %%define optflags %{optflags} -ffast-math}

%configure \
    --with-x \
    --disable-static \
    --with-mylibgd \
    --with-ipsepcola \
    --with-pangocairo \
    --with-gdk-pixbuf \
    --without-mylibgd \
    --without-ming \
    --without-qt \
    --disable-sharp \
    --enable-guile \
    --disable-java \
    --enable-lua \
    --disable-ocaml \
    --enable-perl \
    --disable-php \
    --enable-python3 \
    --disable-r \
    --enable-ruby \
    --enable-swig \
    --enable-tcl \
    --with-visio

make %{?_smp_mflags} 


%install
rm -rf $RPM_BUILD_ROOT __doc
make DESTDIR=$RPM_BUILD_ROOT \
    docdir=$RPM_BUILD_ROOT%{_docdir}/%{name} \
    pkgconfigdir=%{_libdir}/pkgconfig \
    install

find ${RPM_BUILD_ROOT} -type f -name "*.la" -exec rm -f {} ';'
chmod -x $RPM_BUILD_ROOT%{_datadir}/%{name}/lefty/*
cp -a $RPM_BUILD_ROOT%{_datadir}/%{name}/doc __doc
rm -rf $RPM_BUILD_ROOT%{_datadir}/%{name}/doc

rm -rf %{buildroot}%{_libdir}/graphviz/python2


%clean
rm -rf $RPM_BUILD_ROOT


# run "dot -c" to generate plugin config in %{_libdir}/%{name}/config
%post
/sbin/ldconfig
%{_bindir}/dot -c

# if there is no dot after everything else is done, then remove config
%postun
if [ $1 -eq 0 ]; then
    rm -f %{_libdir}/graphviz/config || :
fi


%files
%defattr(-,root,root)
%license COPYING
%doc AUTHORS ChangeLog NEWS README
%{_bindir}/*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/gvpr
%{_datadir}/%{name}/lefty
%{_mandir}/man1/*
%{_mandir}/man7/*
%dir %{_libdir}/%{name}
%{_libdir}/*.so.*
%{_libdir}/%{name}/*.so.*
%exclude %{_libdir}/graphviz/*/*

%files devel
%defattr(-,root,root)
%{_includedir}/%{name}
%{_libdir}/*.so
%{_libdir}/%{name}/*.so
%{_libdir}/pkgconfig/*.pc
%{_datadir}/%{name}/graphs
%{_mandir}/man3/*.3.gz

%files doc
%defattr(-,root,root,-)
%doc __doc/*

%files guile
%defattr(-,root,root,-)
%{_libdir}/graphviz/guile/
%{_mandir}/man3/gv.3guile*

%files lua
%defattr(-,root,root,-)
%{_libdir}/graphviz/lua/
%{_libdir}/lua*/*
%{_mandir}/man3/gv.3lua*

%files perl
%defattr(-,root,root,-)
%{_libdir}/graphviz/perl/
%{perl_vendorarch}/*
%{_mandir}/man3/gv.3perl*

%files -n python3-graphviz
%defattr(-,root,root,-)
%{_libdir}/graphviz/python3/
%{_libdir}/python3*/*
%{_mandir}/man3/gv.3python*

%files ruby
%defattr(-,root,root,-)
%{_libdir}/graphviz/ruby/
%{_libdir}/*ruby*/*
%{_mandir}/man3/gv.3ruby*

%files tcl
%defattr(-,root,root)
%{_libdir}/%{name}/tcl/*
%{_libdir}/tcl*/*
%{_datadir}/%{name}/demo
# hack to include gv.3tcl only if available
#  always includes tcldot.3tcl, gdtclft.3tcl
%{_mandir}/man3/*.3tcl*


%changelog
* Mon Nov 22 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.49.3-2
- rebuilt with perl-5.34.0.

* Mon Nov 15 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.49.3-1
- new upstream release.
- built with ruby-3.0.2.

* Wed May 12 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.47.1-1
- new upstream release.

* Mon Aug 17 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.44.1-1
- new upstream release.

* Mon Mar 16 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.42.2-1
- built with ruby-2.6.5.
- added python3 support.
- dropped Patch0.
- imported Patch0-2 from rawhide.

* Tue Sep 10 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.40.1-2
- rebuilt with guile-2.2.

* Sat Jan 06 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.40.1-1
- updated to 2.40.1.
- dropped all patches.
- imported Patch0 from rawhide.

* Wed Jun 29 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.38.0-4
- rebuild with gcc-5.4.0

* Sat Sep 12 2015 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.38.0-3
- rebuild with ruby-2.2.3

* Sun Mar 15 2015 Ryoichi INAGAKI <ryo1@toki.waaseda.jp> 2.38.0-2
- added Patch0-5 from Fedora
- rebuilt with guile 2.0.11
- changed BR: tcl-devel, tk-devel instead of tcl, tk
- added lua subpackage

* Sat Jun 28 2014 Daisuke SUZUKI <daisuke@vinelinux.org> 2.38.0-1
- update to 2.38.0

* Wed Jan 15 2014 NAKAMURA Kenta <kenta@vinelinux.org> 2.36.0-1
- new upstream release

* Wed Oct 02 2013 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.30.1-2
- rebuilt with gd-2.1.0.

* Sun Mar 24 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.30.1-1
- new upstream release

* Mon Jan  7 2013 IWAI, Masaharu <iwai@alib.jp> 2.28.0-3
- build with Tcl/Tk 8.5.7-1
- stop running autoreconf
- add Vendor and Distribution tags

* Sun Nov 11 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 2.28.0-2
- re-enable ruby binding, which is accidentally disabled in 2.28.0-1
  - rewrite config_ruby.rb to build with ruby-1.9.3
  - add search path for ruby/config.h to CPPFLAGS for configure

* Sat Nov 10 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.28.0-1
- new upstream release
- remove Patch10 (graphviz-2.26.3_dont_regard_tiger_as_the_only_ppc.patch)
- add BuildRequires: librsvg2-devel

* Sun Oct 10 2010 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.26.3-2
- add Patch10 to avoid build failure on ppc

* Sat Oct  9 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.26.3-1
- new upstream release
- built with rpm-4.8.1
- split doc, guile, perl, python, ruby subpackage

* Thu Apr 16 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 2.20.3-3
- rebuild with libtool-2.2.6a

* Sun Nov 09 2008 Shu KONNO <owa@bg.wakwak.com> 2.20.3-1
- new upstream release

* Sun Nov 09 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.20.2-2
- rebuild with libXaw.so.7 (libXaw-1.0.5)

* Wed Jul 16 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.20.2-1
- new upstream release

* Wed Feb 20 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.16.1-0vl1
- new upstream release
- build with expat-2.0.1
- add man7

* Tue Oct 09 2007 Shu KONNO <owa@bg.wakwak.com> 2.12-0vl2
- rebuild with tcl/tk-8.4.16

* Sun May 13 2007 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.12-0vl1
- new upstream release
- add BuildPrereq: swig
- delete BuildPrereq: gd-progs gd-devel
- add --with-mylibgd and --disable-FEATURE to configure option
- update %%files

* Sun Jul 30 2006 NAKAMURA Kenta <kenta@vinelinux.org> 2.6-0vl2
- added BuildPrereq: ruby-devel

* Tue Oct 11 2005 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.6-0vl1
- new upstream release
- add BuildPrereq: libtool-ltdl-devel
- move pkgconfig files to %%{_libdir}/pkgconfig
- add --disable-rpath --disable-static to configure option
- add %%post to every package

* Mon Jan 24 2005 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.2-0vl1
- new upstream release
- BuildPrereq: tcl >= 8.4, tk >= 8.4
- add BuildPrereq: gd-progs gd-devel flex bison pkgconfig
- update %%files
- remove lines about Vine2.6
- change License to CPL

* Sun May 16 2004 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 1.12-0vl1
- source upgrade
- remove patch0 and commented lines

* Tue Dec 16 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 1.10-0vl2
- build for VineSeed

* Tue Dec 16 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 1.10-0vl1
- source upgrade
- change spec to build both VineSeed and Vine2.5/2.6
- add BuildPrereq: expat-devel and Requires: libexpat
- add patch0 to build against freetype2-2.1.7
- stop using autogen.sh script
- add BuildPrereq: tcl >= 8.3 tk >= 8.3 (VineSeed)
- add graphviz-tcl package (VineSeed)

* Thu Aug  7 2003 USAMI Kosuke <usami-k@yc5.so-net.ne.jp> - 1.9-0vl2
- rebuild for new Vine

* Wed Mar 05 2003 Kunio Murasawa <murasawa@fa2.so-net.ne.jp> 1.9-0vl1
- import from offical site (src.rpm)

