Name: unixODBC
Version: 2.3.4
Release: 1%{?_dist_release}
Summary: A complete ODBC Driver Manager for Linux
Summary(ja): Linux 用 ODBC ドライバマネージャー

Group: System Environment/Libraries
# Programs are GPL, libraries are LGPL, except News Server library is GPL.
License: GPLv2+ and LGPLv2+
URL: http://www.unixODBC.org/

Source: http://www.unixODBC.org/%{name}-%{version}.tar.gz
Source1: odbcinst.ini
Source4: conffile.h
Source5: README.dist

Patch6: export-symbols.patch
Patch8: so-version-bump.patch
Patch9: keep-typedefs.patch

Conflicts: iodbc

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: automake autoconf libtool libtool-ltdl-devel bison flex
BuildRequires: readline-devel

Vendor: Project Vine
Distribution: Vine Linux

%description
Install unixODBC if you want to access databases through ODBC.
You will also need the mysql-connector-odbc package if you want to access
a MySQL database, and/or the postgresql-odbc package for PostgreSQL.

%package devel
Summary: Development files for programs which will use the unixODBC library.
Summary(ja): unixODBC ライブラリを用いるプログラムのための開発用ファイル
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}

%description devel
The unixODBC package can be used to access databases through ODBC
drivers. If you want to develop programs that will access data through
ODBC, you need to install this package.

%prep
%setup -q
%patch6 -p1
%patch8 -p1
%patch9 -p1

chmod 0644 Drivers/MiniSQL/*.c
chmod 0644 Drivers/nn/*.c
chmod 0644 Drivers/template/*.c
chmod 0644 doc/ProgrammerManual/Tutorial/*.html
chmod 0644 doc/lst/*
chmod 0644 include/odbcinst.h

# Blow away the embedded libtool and replace with build system's libtool.
# (We will use the installed libtool anyway, but this makes sure they match.)
rm -rf config.guess config.sub install-sh ltmain.sh libltdl
# this hack is so we can build with either libtool 2.2 or 1.5
libtoolize --install || libtoolize

%build
aclocal
automake --add-missing
autoconf

# unixODBC 2.2.14 is not aliasing-safe
CFLAGS="%{optflags} -fno-strict-aliasing"
CXXFLAGS="$CFLAGS"
export CFLAGS CXXFLAGS

%configure --with-gnu-ld=yes --enable-threads=yes \
        --enable-drivers=yes --enable-driverc=yes --enable-ltdllib

# Get rid of the rpaths
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

make all

%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}

# multilib header hacks
# we only apply this to known Red Hat multilib arches, per bug #181335
case `uname -i` in
  i386 | x86_64 | ia64 | ppc | ppc64 | s390 | s390x | sparc | sparc64 )
    mv $RPM_BUILD_ROOT%{_includedir}/unixodbc_conf.h $RPM_BUILD_ROOT%{_includedir}/unixodbc_conf_`uname -i`.h
    rm -f unixodbc_conf.h
    sed s/CONFFILE/unixodbc_conf/ %{SOURCE4} >unixodbc_conf.h
    install -m 644 unixodbc_conf.h $RPM_BUILD_ROOT%{_includedir}
    ;;
  *)
    ;;
esac

# add some explanatory documentation
cp %{SOURCE5} README.dist

# remove obsolete Postgres drivers from the package (but not the setup code)
rm -f $RPM_BUILD_ROOT%{_libdir}/libodbcpsql.so*

# copy text driver documentation into main doc directory
# currently disabled because upstream no longer includes text driver
# mkdir -p doc/Drivers/txt
# cp -pr Drivers/txt/doc/* doc/Drivers/txt

# don't want to install doc Makefiles as docs
find doc -name 'Makefile*' | xargs rm

# we do not want to ship static libraries
rm -f $RPM_BUILD_ROOT%{_libdir}/*.a

# remove unpackaged files from the buildroot
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
rm -f $RPM_BUILD_ROOT%{_libdir}/libltdl.*
rm -rf $RPM_BUILD_ROOT%{_datadir}/libtool

# initialize lists of .so files
find $RPM_BUILD_ROOT%{_libdir} -name "*.so.*" | sed "s|^$RPM_BUILD_ROOT||" > base-so-list
find $RPM_BUILD_ROOT%{_libdir} -name "*.so"   | sed "s|^$RPM_BUILD_ROOT||" > devel-so-list

# move these to main package, they're often dlopened...
for lib in libodbc.so libodbcinst.so libodbcpsqlS.so libodbcmyS.so
do
    echo "%{_libdir}/$lib" >> base-so-list
    grep -v "/$lib$" devel-so-list > devel-so-list.x
    mv -f devel-so-list.x devel-so-list
done

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files -f base-so-list
%doc README COPYING AUTHORS ChangeLog NEWS doc
%doc README.dist
%config(noreplace) %{_sysconfdir}/odbc*
%{_bindir}/odbcinst
%{_bindir}/isql
%{_bindir}/dltest
%{_bindir}/iusql
%{_bindir}/odbc_config
%{_bindir}/slencheck
%{_mandir}/man*/*

%files devel -f devel-so-list
%{_includedir}/*

%changelog
* Tue Jan  5 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.3.4-1
- new upstream release.

* Tue Mar 24 2015 Ryoichi INAGAKI <ryo1@toki.waseda.jp> 2.3.2-2
- rebuilt with readline 6.3
- removed kde-subpackage-related BuildRequires
- added Japanese summary

* Tue Jul  8 2014 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.3.2-1
- new upstream release.
- gui was discontinued in upstream.

* Fri Dec 27 2013 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.2.14-3
- rebuild with VineSeed environment

* Tue Apr 12 2011 IWAI, Masaharu <iwai@alib.jp> 2.2.14-2
- add --with-qt-includes option for configure

* Sat Apr 09 2011 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.14-1
- updated to 2.2.14

* Sat Sep 20 2008 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.12-1
- applied new versioning policy
- removed *.la files from devel package

* Sun Sep 02 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.12-0vl1
- updated to 2.2.12
- rebuilt with new toolchain

* Thu Sep 07 2006 NAKAMURA Kenta <kenta@vinelinux.org> 2.2.11-0vl3
- use installed libltdl
- added unixODBC-2.2.11-symbols.patch and nortldglobal.patch

* Sat Apr 29 2006 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.11-0vl2
- rebuilt with readline 5.1

* Wed Aug 24 2005 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.2.11-0vl1
- updated to 2.2.11
- not libtoolize

* Sat Sep 27 2003 MATSUBAYASHI Kohji <shaolin@vinelinux.org> 2.2.5-0vl2
- added Patch100 to fix typo in doc/Makefile.am from failure on compiling

* Fri Jun  6 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.2.5-0vl1
- source upgrade
- remove patch (no need)
- run libtoolize etc for VineSeed

* Wed Feb 12 2003 Tomoya TAKA <taka@vinelinux.org> 2.2.4-0vl2
- enable -kde subpackage on alpha, but still disable for Vine2.5/2.6

* Sun Feb  9 2003 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.2.4-0vl1
- source upgrade
- change spec to build both VineSeed and Vine2.5/2.6
- add patch from rawhide 2.2.3-6

* Sun Oct 13 2002 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.2.3-0vl2
- Requires: libjpeg (not libjpeg-6b)

* Sun Oct  6 2002 AKIYAMA Kazuhito <akiyama@yb3.so-net.ne.jp> 2.2.3-0vl1
- source upgrade
- add BuildPrereq: autoconf253 automake15
- add PreReq: ldconfig
- fix %files section and clean up spec
- for unixODBC-kde package
  - add Requires: unixODBC = %{version}
  - add Requires: XFree86-libs qt freetype2 libjpeg-6b libmng libpng zlib
  - delete .desktop files

* Thu Apr  4 2002 AKIYAMA Kazuhito <akiyama@karen.servepics.com> 2.2.0-0vl2
- rebuild with KDE3

* Sat Feb 23 2002 Satoshi MACHINO <machino@vinelinux.org> 2.2.0-0vl1
- updated unixODBC-2.2.0
- fixed LinuxODBC.xpm and smallLinuxODBC.xpm dir

* Wed Jan 30 2002 Tomoya TAKA <taka@vinelinux.org> 2.0.7-3vl2
- remove -kde package on alpha

* Fri Jan  4 2002 Akira TAGOH <tagoh@gnome.gr.jp> 2.0.7-3vl1
- Rebuild for Vine.

* Sun Jun 24 2001 Than Ngo <than@redhat.com>
- rebuild against qt-2.3.1, kde-2.1.x

* Fri Jun 15 2001 Trond Eivind Glomsrød <teg@redhat.com>
- Better default odbcinst.ini
- Minor cleanups

* Wed Jun  6 2001 Trond Eivind Glomsrød <teg@redhat.com>
- 2.0.7

* Wed Apr 25 2001 Trond Eivind Glomsrød <teg@redhat.com>
- Fix for isql segfault on EOF/ctrl-d exit

* Fri Apr 20 2001 Trond Eivind Glomsrød <teg@redhat.com>
- 2.0.6
- add patch for 64 bit archs (dword shouldn't be "long int")

* Wed Feb 28 2001 Trond Eivind Glomsrød <teg@redhat.com>
- rebuild

* Tue Nov 28 2000 Trond Eivind Glomsrød <teg@redhat.com>
- 1.8.13

* Tue Oct 10 2000 Trond Eivind Glomsrød <teg@redhat.com>
- enable GUI now that we have KDE compiled with the standard
  compiler
- move the applnk entries to the KDE package

* Thu Aug 24 2000 Nalin Dahyabhai <nalin@redhat.com>
- add the missing shared libs to the non-devel package

* Wed Aug 23 2000 Preston Brown <pbrown@redhat.com>
- 1.8.12 fixes problems with the postgresql driver

* Mon Jul 31 2000 Trond Eivind Glomsrød <teg@redhat.com>
- disable KDE subpackage to avoid the mess that is C++ binary
  compatibility 

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Fri Jun 30 2000 Florian La Roche <laroche@redhat.com>
- improved QTDIR detection

* Wed Jun 28 2000 Trond Eivind Glomsrød <teg@redhat.com>
- 1.8.10
- use %%{_tmppath}
- update URL
- including two missing libraries

* Tue Jun 13 2000 Preston Brown <pbrown@redhat.com>
- 1.8.9

* Fri Jun 09 2000 Preston Brown <pbrown@redhat.com>
- adopted for Winston, changed to Red Hat packaging standards

* Tue Apr 18 2000 Murray Todd Williams <murray@codingapes.com>
- added a unixODBC-devel RPM to the group, added KDE links and icons to system
- all of which came from recommendations from Fredrick Meunier
- <Fredrick.Meunier@computershare.com.au>

* Mon Apr 17 2000 Murray Todd Williams <murray@codingapes.com>
- unixODBC-1.8.7
- moved install to $RPM_BUILD_ROOT so it didn't overrun existing files.


