# Note that this is NOT a relocatable package
%define ver      1.8.7
%define rel      6
%define prefix   %{_prefix}

Summary: An XML library.
Name: libxml
Version: %ver
Release: %rel
Copyright: LGPL
Group: System Environment/Libraries
Source: ftp://ftp.gnome.org/pub/GNOME/sources/libxml/libxml-%{ver}.tar.gz
BuildRoot: /var/tmp/libxml-%{PACKAGE_VERSION}-root
URL: http://www.gnome.org
Patch: libxml-%{ver}-aixlibs.patch
Prereq: /sbin/install-info
BuildRequires: libtool >= 1.3.5
Docdir: %{prefix}/doc

%ifarch ia64
  %define stdlib lib/ia64l32
  %define stdlib64 lib/ia64l64
  %define liblink ../../..
  %define PKG64 %{name}-%{version}-ia64l64
  %define DIRS . %{_builddir}/%{PKG64}/%{name}-%{version}
  %define DEFCCIA cc
  %define DEFCC %{DEFCCIA}
%else
  %define stdlib lib
  %define liblink ../..
  %define DIRS .
  %define DEFCC cc
%endif

%description
The libxml package contains an XML library, which allows you to
manipulate XML files. XML (eXtensible Markup Language) is a data
format for structured document interchange via the Web.

%package devel
Summary: Libraries, includes and other files to develop libxml applications.
Group: Development/Libraries
Requires: libxml = %{PACKAGE_VERSION}
Requires: zlib-devel

%description devel
The libxml-devel package contains the libraries, include and other
files you can use to develop libxml applications.

%prep
%ifarch ia64
%setup -q -c -n %{PKG64}
cd %{name}-%{version}
%patch -p2 -b .aixlibs
%endif
%setup -q
%patch -p2 -b .aixlibs

%build

# Use the default compiler for this platform - gcc otherwise
if [[ -z "$CC" ]]
then
    if test "X`type %{DEFCC} 2>/dev/null`" != 'X'; then
       export CC=%{DEFCC}
    else 
       export CC=gcc
    fi
fi
if [[ "$CC" != "gcc" ]]
then
%ifarch ia64
      if [[ "$CC" = "bcc" ]]
      then
          export CC="bcc -Nilp32"
          export CC64=bcc
      else
          export CC64="$CC -q64"
      fi
%endif
       export RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed 's:-fsigned-char::'`
       export CFLAGS="$RPM_OPT_FLAGS"
fi
for dir in %{DIRS}; do cd $dir; if [[ $dir != "." ]]; then export CC="$CC64"; fi
libtoolize --force
CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%prefix 
make
done

%install
rm -rf $RPM_BUILD_ROOT

# Potential loop if building 64-bit libraries for IA64
for dir in %{DIRS}; do cd $dir; 
if [[ $dir = "." ]]; then INSTDIR=%{_prefix}; else INSTDIR=/%{PKG64}%{_prefix};
fi
make prefix=$RPM_BUILD_ROOT$INSTDIR install
done

(cd $RPM_BUILD_ROOT
 for dir in bin include
 do
    mkdir -p usr/$dir
    cd usr/$dir
    ln -sf ../..%{prefix}/$dir/* .
    cd -
 done

 mkdir -p usr/%{stdlib}
 cd usr/%{stdlib}
 ln -sf %{liblink}%{prefix}/lib/* .
)

%ifarch ppc || %ifarch rs6000
( cd $RPM_BUILD_ROOT/%{prefix}/lib
  # Create a compatibility member to mitigate differences with Bull Freeware
  # offering
  COMPATMEMBER=shr.o
  for lib in *.a
  do
    /usr/bin/dump -Tv $lib |/usr/bin/awk 'match($4,"EXP|Exp") { print $NF }' > tmp.exp
    libbase=`print $lib | sed  -e 's/.a$//' -e 's/^lib//'`
    ld -L. -bI:tmp.exp -bE:tmp.exp -l$libbase -bM:SRE -bnoentry -o $COMPATMEMBER
    /usr/bin/strip -e $COMPATMEMBER   # Make shr.o a load-only module
    /usr/bin/ar -r $lib $COMPATMEMBER
    rm -f $COMPATMEMBER tmp.exp
  done
)
%endif

%ifarch ia64
# Add 64-bit libs to main install tree
mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{stdlib64}
mv ${RPM_BUILD_ROOT}/%{PKG64}%{_prefix}/lib/* $RPM_BUILD_ROOT%{_prefix}/%{stdlib64}

# Add system links
cd $RPM_BUILD_ROOT
mkdir -p usr/%{stdlib64}
cd usr/%{stdlib64}
ln -sf %{liblink}%{prefix}/%{stdlib64}/* .
%endif
%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-, root, root)

%doc AUTHORS ChangeLog NEWS README COPYING COPYING.LIB TODO
%doc doc/html

%ifarch ia64
%{prefix}/lib/lib*.so*
/usr/%{stdlib}/lib*.so*
%{_prefix}/%{stdlib64}/lib*
/usr/%{stdlib64}/lib*
%else
%{prefix}/lib/*a
/usr/%{stdlib}/*a
%endif

%files devel
%docdir %{prefix}/share/gnome-xml/html
%{prefix}/share/gnome-xml

%defattr(-, root, root)
%{prefix}/bin/xml-config
/usr/bin/xml-config

%{prefix}/lib/*.sh
%{prefix}/include/*
/usr/%{stdlib}/*.sh
/usr/include/*

%changelog
* Thu Mar 22 2001 Marc Stephenson <marc@austin.ibm.com>
- Build both 32- and 64-bit libraries

* Wed Mar 07 2001 Marc Stephenson <marc@austin.ibm.com>
- Add compatibility member for Bull freeware

* Wed Mar 07 2001 Marc Stephenson <marc@austin.ibm.com>
- Update to libtool 1.3.5a
- Add logic for default compiler

* Fri Feb 16 2001 aixtoolbox <aixtoollbox-l@austin.ibm.com>
- Account for different standard lib location in IA64 32-bit ABI

* Fri Oct 27 2000 pkgmgr <pkgmgr@austin.ibm.com>
- Modify for AIX Freeware distribution

* Fri Feb 04 2000 Elliot Lee <sopwith@redhat.com>
- Link the library to @Z_LIBS@

* Mon Jan 31 2000 Jeff Johnson <jbj@redhat.com>
- update to 1.8.6.
- don't provide libxml.so.0, as it's in the Red Hat libxml10 package.

* Mon Sep 20 1999 Elliot Lee <sopwith@redhat.com>
- version 1.6.2

* Thu Aug 12 1999 Jonathan Blandford <jrb@redhat.com>
- version 1.4.0

* Thu Mar 04 1999 Michael Fulbright <drmike@redhat.com>
- version 1.0.0

* Fri Feb 12 1999 Michael Fulbright <drmike@redhat.com>
- version 0.99.5 built against gnome-libs-0.99.8

* Wed Feb 03 1999 Michael Fulbright <drmike@redhat.com>
- version 0.99.5

* Wed Jan 06 1999 Michael Fulbright <drmike@redhat.com>
- made clean section work again

* Wed Dec 16 1998 Michael Fulbright <drmike@redhat.com>
- bumped to 0.99.0 for GNOME freeze

* Sun Oct  4 1998 Daniel Veillard <Daniel.Veillard@w3.org>
- Added xml-config to the package

* Thu Sep 24 1998 Michael Fulbright <msf@redhat.com>
- Built release 0.30
