Summary: Visualisation tools for the Performance Co-Pilot toolkit
Name: @pkg_name@
Version: @pkg_version@
Release: @pkg_release@
Distribution: @pkg_distribution@
BuildRoot: @build_root@ 
Conflicts: pcp-pro
Source: @pkg_name@-@pkg_version@.src.tar.gz
License: GPLv2
Vendor: Silicon Graphics, Inc.
URL: http://oss.sgi.com/projects/pcp
Group: Applications/System
Requires: pcp >= 3.5.0, pcp-libs-devel >= 3.5.0
BuildRequires: pcp >= 3.5.0, pcp-libs-devel >= 3.5.0
%if "%{_vendor}" == "suse"
Requires: qt >= 4.2
BuildRequires: qt-devel >= 4.2
%else
Requires: qt4 >= 4.2
BuildRequires: qt4-devel >= 4.2
%endif

%description
The PCP GUI package primarily includes visualisation tools for
monitoring systems using live and archived Performance Co-Pilot
(PCP) sources.
These tools have dependencies on graphics libraries which may or
may not be installed on server machines, so PCP GUI is delivered,
managed and maintained as a separate (source and binary) package
to the core PCP infrastructure.

#
# pcp-doc package
#
%package -n pcp-doc
License: GPLv2
BuildArch: noarch
Group: Documentation
Conflicts: pcp-gui <= 1.5.5
Summary: Performance Co-Pilot documentation and tutorials
Vendor: Silicon Graphics, Inc.
URL: http://oss.sgi.com/projects/pcp/

%description -n pcp-doc
The pcp-doc package provides useful information on using and
configuring the Performance Co-Pilot (PCP) toolkit for system
level performance management.  It includes tutorials, HOWTOs,
and other detailed documentation about the internals of core
PCP utilities and daemons, and the PCP graphical tools.

#
# pcp-gui-testsuite
#
%package testsuite
License: GPLv2
Group: Applications/System
Summary: Performance Co-Pilot (PCP) GUI test suite
URL: http://oss.sgi.com/projects/pcp/

Requires: pcp-gui = @pkg_version@
Requires: pcp-testsuite

%description testsuite
Quality assurance test suite for Performance Co-Pilot (PCP) GUI.

%prep
%setup -q
@make@ configure-pcp-gui

%clean
[ ! -z "$DIST_ROOT" ] && rm -rf $DIST_ROOT
rm -rf $RPM_BUILD_ROOT

%build
@make@ default-pcp-gui

%install
BACKDIR=`pwd`;
DIST_ROOT="$RPM_BUILD_ROOT"
DIST_MANIFEST=`pwd`/install.manifest
export DIST_ROOT DIST_MANIFEST
@make@ install-pcp-gui

# Patterns for files to be marked %config(noreplace).
cat >conf_files <<EOFEOF
pmsnap/control
pmsnap/crontab
EOFEOF

# Files for the pcp-doc and pcp-gui-testsuite subpackages.
awk '{print $NF}' $DIST_MANIFEST | egrep 'pcp-doc' >docs_files
awk '{print $NF}' $DIST_MANIFEST | egrep 'tutorials' >>docs_files
awk '{print $NF}' $DIST_MANIFEST | egrep 'testsuite' >testsuite_files

rm -f docs_files.rpm testsuite_files.rpm base_files.rpm
sort -u $DIST_MANIFEST | awk '
BEGIN {
    while( getline < "docs_files") doc[$0]=1;
    while( getline < "testsuite_files") testsuite[$0]=1;
    while( getline < "conf_files") conf[nconf++]=$0;
}
{
    if (doc[$NF]) f="docs_files.rpm";
    else if (testsuite[$NF]) f="testsuite_files.rpm";
    else f="base_files.rpm"
}
$1 == "d" { printf ("%%%%dir %%%%attr(%s,root,root) %s\n", $2, $5) >> f }
$1 == "f" {
            for (i=0; i < nconf; i++) {
                if ($6 ~ conf[i]) {
                    printf ("%%%%config(noreplace) ") >> f;
                    break;
                }
            }
            if (match ($6, "'$PKG_MAN_DIR'") || match ($6, "'$PKG_DOC_DIR'")) {
                printf ("%%%%doc ") >> f;
            }
            printf ("%%%%attr(%s,root,root) %s\n", $2, $6) >> f }
$1 == "l" { print "%attr(0777,root,root)", $3 >> f }'

set -x

%files -f base_files.rpm
%defattr(-,root,root)

%files -n pcp-doc -f docs_files.rpm
%defattr(-,root,root)

%files testsuite -f testsuite_files.rpm
%defattr(-,pcpqa,pcpqa)

