# Set to bcond_without or use --with bootstrap if bootstrapping a new release
# or architecture
%bcond_with bootstrap
# Set to bcond_with or use --without gui to disable qt4 gui build
%bcond_without gui

Name: cmake
Summary: Cross-platform make system
Summary(ja): クロスプラットフォームな Make システム
Version: 2.8.6
Release: 2%{?_dist_release}

Group: Development/Tools
License: BSD
URL: http://www.cmake.org/

Source0: http://www.cmake.org/files/v2.8/%{name}-%{version}.tar.gz
Source1: macros.cmake

# Patch to find DCMTK in Fedora (bug #720140)
Patch0:         cmake-dcmtk.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: curl-devel
BuildRequires: expat-devel
BuildRequires: gcc-gfortran
BuildRequires: libarchive-devel
BuildRequires: libidn-devel
BuildRequires: ncurses-devel
BuildRequires: openssl-devel
BuildRequires: zlib-devel
%if %{with gui}
BuildRequires: qt4-devel, desktop-file-utils
%define qt_gui --qt-gui
%else
%define qt_gui --no-qt-gui
%endif

Vendor: Project Vine
Distribution: Vine Linux

%description
CMake is used to control the software compilation process using simple 
platform and compiler independent configuration files. CMake generates 
native makefiles and workspaces that can be used in the compiler 
environment of your choice. CMake is quite sophisticated: it is possible 
to support complex environments requiring system configuration, pre-processor 
generation, code generation, and template instantiation.

%package        gui
Summary:        Qt GUI for %{name}
Group:          Development/Tools
Requires:       %{name} = %{version}-%{release}
Requires(post): desktop-file-utils, shared-mime-info
Requires(postun): desktop-file-utils, shared-mime-info

%description    gui
The %{name}-gui package contains the Qt based GUI for CMake.


%prep
%setup -q
%patch0 -p1 -b .dcmtk

# Fixup permissions
#find -name \*.h -o -name \*.cxx -print0 | xargs -0 chmod -x

%build
./bootstrap \
    --prefix=%{_prefix} \
    --datadir=/share/%{name} \
    --mandir=/share/man \
    --%{?with_bootstrap:no-}system-libs \
    %{?qt_gui}

sed -i 's/-lcurses/-lcurses -ltinfo/' Source/CMakeFiles/ccmake.dir/link.txt
%if %{?_dist_release} == "vl5"
sed -i 's/HAVE_SYS_WAIT_H:INTERNAL=/HAVE_SYS_WAIT_H:INTERNAL=1/' CMakeCache.txt
%endif

make VERBOSE=1 %{?_smp_mflags}

%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT

find $RPM_BUILD_ROOT/%{_datadir}/%{name}/Modules -type f | xargs chmod -x
rm -rf $RPM_BUILD_ROOT/usr/doc

# RPM macros
install -p -m0644 -D %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.cmake
sed -i -e "s|@@CMAKE_VERSION@@|%{version}|" $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.cmake
touch -r %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/rpm/macros.cmake

%if %{with gui}
# Desktop file
desktop-file-install --delete-original \
  --dir=$RPM_BUILD_ROOT%{_datadir}/applications \
  $RPM_BUILD_ROOT/%{_datadir}/applications/CMake.desktop
%endif


%clean
rm -rf $RPM_BUILD_ROOT

%if %{with gui}
%post gui
update-desktop-database &> /dev/null || :
update-mime-database %{_datadir}/mime &> /dev/null || :

%postun gui
update-desktop-database &> /dev/null || :
update-mime-database %{_datadir}/mime &> /dev/null || :
%endif


%files
%defattr(-,root,root)
%doc CMakeLogo.gif ChangeLog.* Copyright.txt
%doc Docs/*
%doc Example/
%config(noreplace) %{_sysconfdir}/rpm/macros.cmake
%{_bindir}/ccmake
%{_bindir}/cmake
%{_bindir}/cpack
%{_bindir}/ctest
%{_datadir}/%{name}/
%{_datadir}/aclocal/cmake.m4
%{_mandir}/man1/*

%if %{with gui}
%files gui
%defattr(-,root,root,-)
%{_bindir}/cmake-gui
%{_datadir}/applications/CMake.desktop
%{_datadir}/mime/packages/cmakecache.xml
%{_datadir}/pixmaps/CMakeSetup32.png
%endif


%changelog
* Sun Jun 10 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.8.6-2
- rebuild with libarchive-3.0.4

* Sat Nov 19 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.8.6-1
- new upstream release
- forced to link with libtinfo.so (ccmake)
- used --system-libs again

* Sat Jan  8 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.8.3-1
- new upstream release
- used --no-system-libs, removed BR: curl-devel, expat-devel, zlib-devel

* Sun Sep  5 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.8.2-4
- fixed typo (not --with-system-libs, but --system-libs)
- added BR: curl-devel, expat-devel, zlib-devel

* Mon Aug 23 2010 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.8.2-3
- add BuildRequires: ncurses-devel

* Sun Aug 22 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.8.2-2
- generate gui package
- renamed module directory

* Sun Jul 25 2010 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.8.2-1
- new upstream release

* Fri Feb 05 2010 Shu KONNO <owa@bg.wakwak.com> 2.6.4-3
- rebuilt with new toolchain

* Sun Aug 30 2009 NAKAMURA Kenta <kenta@vinelinux.org> 2.6.4-2
- imported RPM macros from Fedora (cmake-2.6.4-3.fc12)

* Tue Aug 25 2009 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.6.4-1
- new upstream release
- added Vendor/Distribution tag

* Wed Mar 25 2009 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.6.3-1
- new upstream release

* Tue Oct 21 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.6.2-1
- new upstream release

* Sat Mar 29 2008 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.4.8-1
- new upstream release

* Wed Aug 15 2007 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.4.7-0vl1
- new upstream release

* Mon May 14 2007 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.4.6-0vl1
- new upstream release
- drop Patch100
- use bootstrap script instead of configure
- delete caches from %%doc

* Sat May 12 2007 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.4.3-0vl2
- rebuilt with new toolchain

* Tue Oct 31 2006 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.4.3-0vl1
- new upstream release
- delete duped docs

* Fri Oct 13 2006 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.2.3-0vl2
- added Patch100 (especially for ppc to solve ppc/powerpc issue)

* Mon Feb 06 2006 Seiya Nishizawa <seiya@kugi.kyoto-u.ac.jp> 2.2.3-0vl1
- source version up

* Sun Mar 20 2005 Seiya Nishizawa <seiya@kugi.kyoto-u.ac.jp> 2.0.5-0vl1
- initial build for Vine Linux