##
##  xalan-c.spec -- OpenPKG RPM Specification
##  Copyright (c) 2000-2003 Cable & Wireless Deutschland GmbH
##  Copyright (c) 2000-2003 The OpenPKG Project <http://www.openpkg.org/>
##  Copyright (c) 2000-2003 Ralf S. Engelschall <rse@engelschall.com>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_opkg    1.4
%define       V_dist    1_4

#   package information
Name:         xalan-c
Summary:      XSLT processor
URL:          http://xml.apache.org/xalan-c/
Vendor:       Apache Software Foundation
Packager:     The OpenPKG Project
Distribution: OpenPKG [EVAL]
Group:        Web
License:      Apache Software License 1.1
Version:      %{V_opkg}
Release:      20030103

#   package options
%option       with_threads  no

#   list of sources
Source0:      http://xml.apache.org/dist/xalan-c/Xalan-C_%{V_dist}-src.tar.gz
Patch0:       xalan-c.patch

#   build information
Prefix:       %{l_prefix}
BuildRoot:    %{l_buildroot}
BuildPreReq:  OpenPKG, openpkg >= 20030103, autoconf, gcc, make, xerces-c >= 2.1.0
PreReq:       OpenPKG, openpkg >= 20030103, xerces-c >= 2.1.0
AutoReq:      no
AutoReqProv:  no

%description
    Xalan is an XSLT processor for transforming XML documents into HTML,
    text, or other XML document types.

%prep
    %setup -q -n xml-xalan
    %patch0 -p0

%build
    rm -rf $RPM_BUILD_ROOT
    ( XALANCROOT=`pwd` ;
      XERCESCROOT=%{l_prefix} ;
      export XALANCROOT XERCESCROOT ;
      cd c/src ;
      %{l_shtool} subst \
          -e 's;@l_ar@;%{l_libtool} --mode=link c++ -static -o;' \
          Makefile.in ;
      pf=LINUX;
      cf="";
      lf="";
%if "%{with_threads}" == "yes"
      case "%{l_target}" in
        *-freebsd*)     pf=LINUX
                        cf="-pthread"
                        lf=""
                        ;;
        *-linux*)       pf=LINUX
                        cf="-pthread"
                        lf=""
                        ;;
        *-hpux*)        pf=LINUX
                        cf="-pthread"
                        lf=""
                        ;;
        *-solaris*)     pf=LINUX
                        cf=""
                        lf="-lpthread -lsocket -lnsl"
                        ;;
        *-aix*)         pf=AIX;
                        cf="-pthread"
                        lf=""
                        ;;
      esac ;
%else
      case "%{l_target}" in
        *-freebsd*)     pf=LINUX
                        cf=""
                        lf=""
                        ;;
        *-linux*)       pf=LINUX
                        cf=""
                        lf=""
                        ;;
        *-hpux*)        pf=LINUX
                        cf=""
                        lf=""
                        ;;
        *-solaris*)     pf=LINUX
                        cf=""
                        lf="-lsocket -lnsl"
                        ;;
        *-aix*)         pf=AIX;
                        cf=""
                        lf=""
                        ;;
      esac ;
%endif
      CC="%{l_cc} $cf" \
      CXX="%{l_cxx} $cf" \
      CFLAGS="%{l_cflags -O}" \
      LDFLAGS="%{l_ldflags} $lf" \
      ./configure \
        --prefix=%{l_prefix} ; \
      %{l_make} %{l_mflags} PLATFORM="$pf"
    )

%install
    %{l_shtool} mkdir -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/bin
    %{l_shtool} install -c -s -m 755 \
        bin/Xalan $RPM_BUILD_ROOT%{l_prefix}/bin
    %{l_shtool} mkdir -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/lib
    %{l_shtool} install -c -m 644 \
        lib/libxalan-c.a $RPM_BUILD_ROOT%{l_prefix}/lib
    %{l_shtool} mkdir -p -m 755 $RPM_BUILD_ROOT%{l_prefix}/share/xalan-c
    ( cd c
      for f in `find samples xdocs -type d \( -name CVS -prune -o -print \)`; do
          %{l_shtool} mkdir -m 755 $RPM_BUILD_ROOT%{l_prefix}/share/xalan-c/$f
      done
      for f in `find samples xdocs -type d -name CVS -prune -o -type f -print`; do
          %{l_shtool} install -c -m 644 \
              $f $RPM_BUILD_ROOT%{l_prefix}/share/xalan-c/
      done
      cd src
      for f in */*.hpp ; do
          %{l_shtool} mkdir -p -m 755 \
              $RPM_BUILD_ROOT%{l_prefix}/include/xalan/`dirname $f`
          %{l_shtool} install -c -m 644 \
              $f $RPM_BUILD_ROOT%{l_prefix}/include/xalan/
      done
    )
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean
    rm -rf $RPM_BUILD_ROOT

