%define prefix	%{_prefix}
%define ver 	0.19
%define rel	1

Summary: The G App library.
Name: gal
Version: %ver
Release: %rel
Copyright: LGPL
Group: System Environment/Libraries
Source: ftp://ftp.gnome.org/pub/GNOME/unstable/sources/gal/gal-%{version}.tar.gz
Patch0: gal-%{ver}-aix.patch
BuildRoot: /var/tmp/gal-%{PACKAGE_VERSION}-root

%description
Reuseable GNOME library functions.  Mainly used for Evolution and
Gnumeric

%package devel
Summary: Libraries and include files for the G App library.
Group: Development/Libraries

%description devel
The gal-devel package includes the static libraries and header files for the
gal package.

Install gal-devel if you want to develop programs which will use gal.

%changelog
* Tue Jul 16 2002 Chris Tysor <entysor@austin.ibm.com>
- Get 0.19 to build correctly.

* Mon Jan 14 2002 Dan Nguyen <dnn@austin.ibm.com>
- Update to 0.19

* Thu Dec 06 2001 Dan Nguyen <dnn@austin.ibm.com>
- Add a e_strftime which does modifications for AIX

* Mon Nov 26 2001 Dan Nguyen <dnn@austin.ibm.com>
- Upgrade to 0.18.1 

* Mon Nov 12 2001 Dan Nguyen <dnn@austin.ibm.com>
- Upgrade to 0.18 for evolution

* Mon Oct 22 2001 Dan Nguyen <dnn@austin.ibm.com>
- Initial AIX packaging

* Thu Mar 15 2001 Matthew Wilson <msw@redhat.com>
- the -devel package must own the /usr/include/gal directory and all
  its contents

* Fri Oct 10 2000 John Gotts <jgotts@linuxsavvy.com>
- Created spec file.

%define DEFCC cc

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

%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
	export RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed 's:-fsigned-char::'`
	export RPM_OPT_FLAGS="$RPM_OPT_FLAGS -ma"
	if test "X$CC" = "Xxlc"
	then
		export RPM_OPT_FLAGS="$RPM_OPT_FLAGS -qlanglvl=extended"
	fi
fi
export CFLAGS=$RPM_OPT_FLAGS

libtoolize --force
CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="-Wl,-brtl" \
	./configure --prefix=%{prefix}

# hack -- force use of the current libtool version;
# configure above doesn't correctly install the current libtool
cp /usr/bin/libtool ./libtool
make 

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{prefix}

make install DESTDIR=$RPM_BUILD_ROOT
install -c ./gal/.libs/libgal.so.19 $RPM_BUILD_ROOT%{prefix}/lib/libgal.so.19

( 
cd $RPM_BUILD_ROOT%{prefix}/lib
ln -s libgal.so.19 libgal.so
cd $RPM_BUILD_ROOT
for dir in include lib
do
	mkdir -p usr/$dir
	cd usr/$dir
	ln -sf ../..%{prefix}/$dir/* .
	cd -
done
)


%clean
rm -rf $RPM_BUILD_ROOT

%files
%doc README AUTHORS COPYING ChangeLog NEWS
##%{prefix}/share/etable/%{version}/glade/*.glade
%{prefix}/share
%{prefix}/lib/libgal.so
%{prefix}/lib/libgal.so.*
%{prefix}/lib/galConf.sh
/usr/lib/libgal.so
/usr/lib/libgal.so.*
/usr/lib/galConf.sh

%files devel
%defattr(-, root, root)
##%{prefix}/lib/libgal.a
%{prefix}/lib/libgal.la
%{prefix}/include/gal
/usr/lib/libgal.la
/usr/include/gal
