#
# spec file for package unixODBC
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           unixODBC
Version:        2.3.6
Release:        1.2
Summary:        ODBC driver manager with some drivers included
License:        GPL-2.0-or-later AND LGPL-2.1-or-later
Group:          Productivity/Databases/Tools
Url:            http://www.unixodbc.org/
Source0:        ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-%{version}.tar.gz
Source1:        baselibs.conf
Source2:        unixODBC-rpmlintrc
Patch1:         unixODBC-paths.patch
Patch2:         unixODBC-gccwarnings.patch
# https://github.com/lurcher/unixODBC/issues/8
Patch3:         unixODBC-2.3.1-libodbcinst-exports.patch
Patch4:         unixODBC-2.3.6-declarations.patch
BuildRequires:  automake
BuildRequires:  bison
BuildRequires:  gcc-c++
BuildRequires:  libltdl-devel
BuildRequires:  libtool
BuildRequires:  pkgconfig
BuildRequires:  readline-devel
# bsc#1062860: to stay feature complete
Recommends:     psqlODBC

%package devel
Summary:        Includes for ODBC Development
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}
Conflicts:      libiodbc-devel

%description
UnixODBC aims to provide a complete ODBC solution for the Linux
platform. Further drivers can be found at http://www.unixodbc.org/.

%description devel
Includes for ODBC development (based on unixODBC).

%prep
%setup -q
%patch1
%patch2
%patch3
%patch4 -p1

%build
perl -i -pe 's{^ACLOCAL_AMFLAGS.*}{}' Makefile.am
export -n LANG LINGUAS LC_ALL
rm -rf libltdl
autoreconf -fvi
%configure \
    --with-gnu-ld \
    --enable-ltdllib \
    --sysconfdir=%{_sysconfdir}/%{name} \
    --enable-iconv \
    --with-iconv-char-enc=UTF8 \
    --with-iconv-ucode-enc=UTF16LE \
    --enable-fastvalidate \
    --enable-threads \
    --enable-gui=no \
    --disable-stats \
    --enable-driverc \
    --enable-drivers \
    --enable-driver-conf
make %{?_smp_mflags}

%install
install -d -m 755 "%{buildroot}/%{_sysconfdir}/%{name}"
install -d -m 755 "%{buildroot}/%{_libdir}/%{name}"
%make_install
rm -rf "%{buildroot}/%{_datadir}/libtool"
# packaged in gui-gtk
rm -f "%{buildroot}/%{_libdir}"/libmimerS.*
find %{buildroot} -type f -name "*.la" -delete -print

# bsc#1062860: we want psqlODBC instead of this unmaintained example driver
rm -f "%{buildroot}/%{_libdir}"/unixODBC/libodbcpsql.*

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%license COPYING
%attr(644,root,root) %doc AUTHORS ChangeLog NEWS README doc/*.html doc/*.gif
%docdir %{_mandir}
%{_mandir}/man1/dltest.1%{?ext_man}
%{_mandir}/man1/isql.1%{?ext_man}
%{_mandir}/man1/iusql.1%{?ext_man}
%{_mandir}/man1/odbc_config.1%{?ext_man}
%{_mandir}/man1/odbcinst.1%{?ext_man}
%{_mandir}/man5/odbc.ini.5%{?ext_man}
%{_mandir}/man5/odbcinst.ini.5%{?ext_man}
%{_mandir}/man7/unixODBC.7%{?ext_man}
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/ODBCDataSources
%dir %{_libdir}/%{name}
%config %{_sysconfdir}/%{name}/odbc.ini
%config %{_sysconfdir}/%{name}/odbcinst.ini
%{_bindir}/dltest
%{_bindir}/isql
%{_bindir}/iusql
%{_bindir}/odbcinst
%{_bindir}/odbc_config
%{_bindir}/slencheck
%{_libdir}/libodbc.so.*
%{_libdir}/libodbcinst.so.*
%{_libdir}/libodbccr.so.*
%{_libdir}/libodbc.so
%{_libdir}/libodbcinst.so
%{_libdir}/libodbccr.so
%{_libdir}/%{name}

# All .so files are in the main package as many ext apps
# dlopen those so you need these on regular package.
%files devel
%{_includedir}/*
%{_libdir}/pkgconfig/odbc.pc
%{_libdir}/pkgconfig/odbccr.pc
%{_libdir}/pkgconfig/odbcinst.pc

%changelog
* Thu Mar 22 2018 mvetter@suse.com
- Add BuildRequires: pkgconfig since we install .pc files
- Add unixODBC-rpmlintrc: devel files are in the right place
* Mon Mar 19 2018 mvetter@suse.com
- bsc#1062860: Recommend psqlODBC to stay feature complete
* Mon Mar 19 2018 mvetter@suse.com
- bsc#1082060: Update to 2.3.6:
  * Fix order of arguments in SQLWriteFileDSN.c, fix unwanted
    free() in iusql.c
  * Add pkg-config files
- bsc#1082290 (CVE-2018-7409): Buffer overflow in
  unicode_to_ansi_copy() was fixed in 2.3.5
- bsc#1082484 (CVE-2018-7485): Swapped arguments in
  SQLWriteFileDSN() in odbcinst/SQLWriteFileDSN.c
- Remove unixODBC-2.3.1-bison.patch: upstreamed
- Remove unixODBC-iaddr.patch: upstreamed
- Adapt unixODBC-2.3.1-declarations.patch to
  unixODBC-2.3.6-declarations.patch
- Update unixODBC-gccwarnings.patch
* Wed Feb 21 2018 mvetter@suse.com
- bsc#1062860: Don't install postgres example driver
  psqlODBC package should be used instead of the example driver
  provided by unixODBC (libodbcpsql.*). It is unmaintained.
* Fri Jun 23 2017 adam.majer@suse.de
- Enabled --enable-fastvalidate option in configure (bnc#1044970)
* Wed May 11 2016 mvetter@suse.com
- Requested by fate#319390
* Wed May 11 2016 mvetter@suse.com
- Add comment in spec file so people know why the .so files are
  not in the devel package
* Thu Jan 28 2016 markus.beth@web.de
- dropped obsolete unixODBC-2.3.1-uninitialized.patch and
  unixODBC-nonvoid.patch
* Tue Sep  1 2015 tchvatal@suse.com
- Version bump to 2.3.4:
  * Fix typo in the loading of the cursor lib
* Mon Aug 24 2015 zeke@zekesdominion.com
- update to version 2.3.3
  * Various buffer overflow and unchecked memory references
  * More ODBC 3.80 additions (streaming parameters)
  * Allow setting custom non standard attributes via DMStmtAttr
  * Add -L option to isql to increase max column data display
  * More manual pages for the tools
  * many other fixes, see http://www.unixodbc.org
* Mon Dec  1 2014 tchvatal@suse.com
- Move all .so files from devel as many ext apps dlopen those so
  you need these on regular package.
- Clean up with spec-cleaner
- Remove readme.suse as it is obsolete like hell
- Wipe all la files as we don't provide static libs anyway
- Do not append no-strict-aliasing to cflags, pointless
- --enable-driverc enabled too
* Thu Nov 27 2014 jengelh@inai.de
- Account for changes in libtool 2.4.3: remove ACLOCAL_AMFLAGS
  and explicit libtoolize call.
- Replace $RPM_BUILD_ROOT by macro (fits with the other macros used)
* Mon Sep  8 2014 jengelh@inai.de
- Turn Obsoletes: libiodbc-devel back into Conflicts.
  The iODBC project has not shut down, and unixODBC-devel does
  _not_ provide all files from iODBC, like libiodbc.pc.
- Kill manual provides of libiodbc*.so, they are in the wrong spot
  and thus never could have been effective.
- Remove redundant %%clean section.
* Tue Jan 28 2014 adler_187@yahoo.com
- Don't hard code gz extension for man pages
* Fri Jan 24 2014 adler_187@yahoo.com
- update to version 2.3.2
  * Some ODBC 3.80 support added
  * Unicode/ANSI conversion fixes
  * isql regained -e option since it was missing
  * Add slencheck executable to try and find the sizeof(SQLLEN) from an installed driver
  * some man pages added
  * many other fixes, see http://www.unixodbc.org
* Fri Apr  5 2013 idonmez@suse.com
- Cleanup spec file
- Add Source URL, see https://en.opensuse.org/SourceUrls
* Fri Jan  4 2013 mhrusecky@suse.cz
- Adding missing includes
* Fri Jan  4 2013 mhrusecky@suse.cz
- fixed compilation issues with bison
* Tue Nov 27 2012 cfarrell@suse.com
- license update: GPL-2.0+ and LGPL-2.1+
  Semicolon is ambigous. Use ^and^ or ^or^ depending on the nature of the
  interaction of the license code componentes
* Wed Nov  7 2012 mhrusecky@suse.cz
- Including some basic drivers
* Tue Nov  6 2012 mhrusecky@suse.cz
- updated to versio 2.3.1
  * reduced unixODBC, after the GUI and additional driver parts have
    been split off to their own project.
  * change to the new default SQLLEN size for 64 bit platforms
  * number of bug fixes and changes, see http://www.unixodbc.org/
* Sun Nov 27 2011 coolo@suse.com
- add libtool as buildrequire to avoid implicit dependency
* Wed Oct  5 2011 uli@suse.com
- cross-build fix: use %%configure macro
* Mon Jun 20 2011 mhrusecky@suse.cz
- fixed mutex locking (bnc#637115)
  - patch by Petr Vandrovec
* Mon Jun 13 2011 mhrusecky@suse.cz
- fixed CVE-2011-1145 (bnc#678796)
* Sat Dec 19 2009 jengelh@medozas.de
- add baselibs.conf as a source
* Wed Jan  7 2009 olh@suse.de
- obsolete old -XXbit packages (bnc#437293)
* Mon Oct 13 2008 nadvornik@suse.cz
- dropped the dlopen patch, it no longer matches
* Thu Apr 10 2008 ro@suse.de
- added baselibs.conf file to build xxbit packages
  for multilib support
* Fri May 25 2007 dmueller@suse.de
- add missing ldconfig fall to %%post/un
* Wed Oct 18 2006 anosek@suse.cz
- updated to version 2.2.12
  * Add missing SQLSetStmtOptionA and SQLSetStmtOptionW
  * The config string being passed into ConfigDsn was wrong,
    removed semicolon, and added terminating double null
  * Add help help to isql
  * Alter odbctest FullConnect to use SQLDriverConnect
  * Replace a missed flag for true 64 bit operation
  * Add ODBC3<->ODBC2 type mapping in SQLSetParam
  * Tidy up the search for GUI lib code in SQLManageDatasource
  * Fix possible exit from SQLConnect without having closed
    in the driver
  * Alter args to SQLParamOptions
  * Fix bug preventing attribute length from being returned from
    SQLDrivers
  * Fixed broken iusql
- dropped obsolete unixODBC-2.2.12.patch unixODBC-qt-dirs.patch
* Thu Jun 15 2006 mmarek@suse.cz
- moved %%{_libdir}/unixODBC/*.so to main package, so that libfoo.so
  and libfooS.so can be used in driver configuration.
* Thu Jun 15 2006 mmarek@suse.cz
- updated distributed libltdl to make autoconf happy
- dropped unixODBC-gui-gtk
* Mon Mar 27 2006 mmarek@suse.cz
- fixed some uninitialized variables reported by David Binderman
  [#160570] (uninitialized.patch)
* Tue Jan 31 2006 mmarek@suse.cz
- fixed txt driver
  [#146507] (sqp.patch)
* Wed Jan 25 2006 mls@suse.de
- converted neededforbuild to BuildRequires
* Fri Jan 20 2006 ro@suse.de
- split gui packages to own specfile
* Tue Jan 17 2006 sbrabec@suse.cz
- Remove unneeded libunicode from neededforbuild.
* Tue Nov 29 2005 mmarek@suse.cz
- fix build with flex-2.5.31
  (flex.patch)
* Tue Nov  1 2005 mmarek@suse.cz
- add libtool and libinilc symbols to odbcinst/odbcinst.exp
  (#131175)
- disable unixODBC-2.2.11-dm.patch since it's probably no more
  needed
* Thu Oct 20 2005 mmarek@suse.cz
- remove LT_GLOBAL flag from libtool to enable dlopen()ing libodbc.so
  (#96312)
- remove headers for compatibility with qt3 (no longer needed)
- added norootforbuild
* Tue Sep 27 2005 mmarek@suse.cz
- compile with --disable-stats to prevent DoS [#118547]
* Mon Sep 19 2005 mmarek@suse.cz
- fix gcc warnings about implicit function declarations
* Wed Apr 27 2005 ltinkl@suse.cz
- updated to 2.2.11
- fix build with gcc4
* Tue Apr 12 2005 ro@suse.de
- added audiofile-devel to neededforbuild
* Fri Feb 11 2005 ltinkl@suse.cz
- update to 2.2.10, adapt patches
* Wed Nov 10 2004 ro@suse.de
- reduced neededforbuild
* Tue Sep 14 2004 ltinkl@suse.cz
- put the .desktop file in the right package (#44790)
* Mon Jul 26 2004 ro@suse.de
- fix some compiler warnings
* Mon Jul 19 2004 ltinkl@suse.cz
- update to 2.2.9
* Mon May 24 2004 ro@suse.de
- fix some compiler warnings
* Tue Mar 23 2004 ltinkl@suse.cz
- don't package generated files (#36304)
* Thu Feb 26 2004 kukuk@suse.de
- Obsolete libiodbc-devel instead of conflicting with it.
- provide 64bit libodbcinst.so/libobdc.so on all 64bit
  architectures.
* Wed Feb 25 2004 schwab@suse.de
- Provide libodbcinst.so()(64bit), libodbc.so()(64bit) on ia64 for
  BEAJava2 [#29515].
* Fri Feb 20 2004 ltinkl@suse.cz
- update to 2.2.8
* Wed Jan 14 2004 ltinkl@suse.cz
- added patch to fix SQL results
* Wed Dec  3 2003 ltinkl@suse.cz
- update to 2.2.7
* Fri Sep  5 2003 ltinkl@suse.cz
- fix #29515
* Mon Sep  1 2003 ltinkl@suse.cz
- created patch unixODBC-odbctest.patch to fix #29639
* Fri Aug 15 2003 adrian@suse.de
- add desktop file
* Wed Jul 30 2003 ro@suse.de
- fix gODBCconfig configure.in for autoreconf
* Wed Jul 30 2003 ltinkl@suse.de
- update to version 2.2.6
* Tue Jul 29 2003 ro@suse.de
- remove traces of buildroot from installed files
* Fri Jul 18 2003 sbrabec@suse.cz
- GNOME prefix change to /opt/gnome.
* Mon Jul 14 2003 sbrabec@suse.cz
- Added gnome-filesystem to neededforbuild.
* Mon Jun 23 2003 ro@suse.de
- fix for current automake
* Fri Dec 27 2002 prehak@suse.cz
- temporarily added two header files from Qt which make it build with Qt-3.1.1
  (remove them when they won't be needed to build)
* Tue Nov 19 2002 ro@suse.de
- add AM_GNU_GETTEXT_VERSION
* Sun Nov 17 2002 prehak@suse.cz
- fixed to build with autoconf 2.56
* Tue Nov 12 2002 tcrhak@suse.cz
- fixed for bison 1.75: end rules with semicolons
* Tue Oct  1 2002 prehak@suse.cz
- updated to version 2.2.3
- libodbcinstQ.{so,la} moved from unixODBC-devel to unixODBC-gui-qt
  [#19743]
* Fri Sep 27 2002 ro@suse.de
- Added alsa alsa-devel to neededforbuild (esound)
* Mon Sep  9 2002 meissner@suse.de
- Use qt3 instead of qt2.
* Sun Aug 18 2002 prehak@suse.cz
- fixed segfaulting isql when using SAPDB driver
  (created unixODBC-segfault.dif)
* Mon Aug 12 2002 schwab@suse.de
- Fix configure script.
* Sat Jul 27 2002 adrian@suse.de
- fix neededforbuild
* Tue Jul  9 2002 prehak@suse.de
- updated to version 2.2.2 (mainly bugfixes, some unicode changes)
* Mon Jun 10 2002 prehak@suse.cz
- updated to version 2.2.1  (mainly bugfixes)
- changed group to Productivity/Databases/Tools
- changed path for .ini files to /etc/unixODBC/
  and path for drivers to /usr/lib/unixODBC/
- removed sample odbcinst.ini (TXT driver is not used so freqvently)
- created patch to apply %%{_lib} macro
- added new configure feature --with-odbc-libs in gODBCConfig
- moved *.so files to devel package
- created README.SuSE
* Thu May 16 2002 ro@suse.de
- use libdir
* Thu Apr  4 2002 ro@suse.de
- build with current autoconf/automake/gettext
* Wed Feb 27 2002 poeml@suse.de
- don't include the (empty anyway) .ini files to the package, to
  avoid a file conflict with the libiodbc package. The .ini files
  are now packed as %%ghost and touched in %%post in both packages.
- rewrote %%post to not use absolute paths.
* Tue Jan  8 2002 ro@suse.de
- help libtool with RPM_BUILD_ROOT
* Fri Jan  4 2002 poeml@suse.de
- update to 2.1.1 (bugfixes, 64 bit fixes, support for FILEDSN's,
  changes to ODBCConfig. See http://www.unixodbc.org/ for the
  changelog.)
- add new libodbcinstQ.so* to filelist
- remove libodbccr.so* from filelist (not to be installed)
* Fri Nov  9 2001 ro@suse.de
- use qt-devel-packages in neededforbuild
* Tue Oct  2 2001 rbarn@suse.de
- update to version 2.0.9
- Fix small bug in postgres driver
* Sun May 13 2001 schwab@suse.de
- Fix missing declarations.
* Wed May  9 2001 poeml@suse.de
- bzip2 sources
* Fri Apr 13 2001 ro@suse.de
- hack for new gettext
* Sun Apr  1 2001 mfrueh@suse.de
- created initial package