#
# spec file for package xerces-j2-bootstrap (Version 2.8.1)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild

Name:           xerces-j2-bootstrap
Url:            http://xml.apache.org/xerces2-j/
BuildRequires:  fastjar java-1_4_2-gcj-compat-devel unzip xml-commons-apis-bootstrap xml-commons-resolver-bootstrap xml-commons-which-bootstrap zip
%if %{?!suse_version:1}0
%if %{?!mandriva_release:1}0
BuildRequires:  chkconfig
%endif
%else
BuildRequires:  update-alternatives
%endif
%define       xerces_version_cvs 2_8_1
%define       real_name xerces-j2
Summary:        Java XML parser
Group:          Development/Libraries/Java
Version:        2.8.1
Release:        155
Requires:       xml-commons-which-bootstrap
Requires:       xml-commons-apis-bootstrap
Requires:       xml-commons-resolver-bootstrap
License:        The Apache Software License
Group:          Development/Libraries/Java
AutoReqProv:    on
Source0:        Xerces-J-src.%{version}.tar.bz2
Patch0:         xerces-j2-gcj-switch-constants-bug.patch
Patch1:         xerces-build.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
#BuildArchitectures: noarch
#ExclusiveArch: %ix86
BuildArch:      noarch
Provides:       xerces-j2

%description
Welcome to the future! Xerces2 is the next generation of high
performance, fully compliant XML parsers in the Apache Xerces family.
This new version of Xerces introduces the Xerces Native Interface
(XNI), a complete framework for building parser components and
configurations that is extremely modular and easy to program.

The Apache Xerces2 parser is the reference implementation of XNI but
other parser components, configurations, and parsers can be written
using the Xerces Native Interface. For complete design and
implementation documents, refer to the XNI Manual.

Xerces 2 is a fully conforming XML Schema processor. For more
information, refer to the XML Schema page.

Xerces 2 also provides a partial implementation of Document Object
Model Level 3 Core, Load and Save and Abstract Schemas [deprecated]
Working Drafts. For more information, refer to the DOM Level 3
Implementation page.



%prep
#<<< package descriptions end
#>>> %prep
%setup -n xerces-%{xerces_version_cvs}
%patch0
%patch1
#<<<
#>>> %build 

%build 
#>>> some useful functions ... used throughout bootstrap packages
# variables:
TARGET_DIR=`pwd`
CLASSPATH_ORIG="$CLASSPATH"
LIB_GCJ="`ls %{_javadir}/libgcj-*.jar`"
#>>> delete binary file and files not needed
function delBinaryFiles() {
  set +x
  echo deleting binary files ...
  for file in `find . -name "*.class" -o -name "*.jar" -o -name "*DELETED-BY-PACKAGER*"` 
  do 
    rm -rf $file
  done
  set -x
}
#<<<
#>>> make a string with all jar files found in target folder that can be used for a classpath string
# string is saved in JAR_CLASSPATH
function mkTargetClasspath() {
  set +x
  JAR_CLASSPATH=""
  for file in `find %{_javadir} -name "*.jar"`
  do
    JAR_CLASSPATH=$file:$JAR_CLASSPATH
  done
  set -x
}
#<<<
#>>> compiles all *.java file in the current directory tree
# uses mkTargetClasspath for CLASSPATH  variable
# uses LIB_GCJ for CLASSPATH
function compileFiles() {
  mkTargetClasspath
  set +x
  COMPILE_CLASSPATH_PATH=.:${JAR_CLASSPATH}
  echo using: $COMPILER_COMMAND $$file
  echo with classpath: $COMPILE_CLASSPATH_PATH
  export CLASSPATH=$COMPILE_CLASSPATH_PATH
  for file in `find . -name "*.java"`
  do
    echo -e "$COMPILER_COMMAND $file ... \c"
    $COMPILER_COMMAND $file
    # check for errors
    if [ $? != 0 ]
    then
      echo ERROR
      exit 1;
    fi
    echo done
  done
  set -x
}
#<<<
#>>> make jar archive
# PARAM#1: name of jar archive (without .jar suffix)
# uses $TARGET_DIR to move created jar to
function mkJar() {
  find  -name "version.txt" -or -name "*.class" -or -name "*.properties" -or -name "*.rsc" -or -name "*manifest*" |\
    xargs /usr/bin/fastjar -m manifest.* -cf ${1}.jar ;
  mv ${1}.jar $TARGET_DIR
}
#<<<
COMPILER_COMMAND="javac -C "
#<<< end functions
delBinaryFiles
#>>> xerces-j2
pushd src
compileFiles
mkJar %{name}
delBinaryFiles
popd
#<<< xerces end
#<<<
#>>> %install

%install
#>>> ant
export NO_BRP_CHECK_BYTECODE_VERSION=true
mkdir -p $RPM_BUILD_ROOT%{_javadir}
cp %{name}.jar $RPM_BUILD_ROOT/%{_javadir}/
#<<<
#<<< install end

%clean
rm -rf $RPM_BUILD_ROOT 
#>>> files

%files
%defattr(-,root,root)   
#%dir %{_javadir}
%{_javadir}/%{name}.jar
#<<<
# vim:fdm=marker:foldmarker=#>>>,#<<<:foldcolumn=6:

%changelog
* Thu Jan 24 2008 skh@suse.de
- fix build with gcj
* Wed May 02 2007 dbornkessel@suse.de
- added unzip to BuildRequires
* Wed Nov 15 2006 dbornkessel@suse.de
- Changed
  PreReq: /usr/sbin/update-alternatives
  to
  PreReq: update-alternatives
* Fri Sep 22 2006 dbornkessel@suse.de
- first version