Name:          unixODBC
Version:       2.3.9
Release:       1
Summary:       Open-source project that implements the ODBC API
License:       GPLv2+ and LGPLv2+
URL:           http://www.unixODBC.org/
Source:        http://www.unixODBC.org/%{name}-%{version}.tar.gz
Source1:       odbcinst.ini
Conflicts:     iodbc
BuildRequires: automake autoconf libtool libtool-ltdl-devel bison flex readline-devel

%description
The unixODBC Project goals are to develop and promote unixODBC to be the
definitive standard for ODBC on non MS Windows platforms. This is to
include GUI support for both KDE and GNOME.

%package devel
Summary:   Development and header files for %{name}
Requires:  %{name} = %{version}-%{release}

%description devel
Development and header files for %{name}

%prep
%autosetup -p1
autoreconf -vfi

%build
CFLAGS="%{optflags} -fno-strict-aliasing"
CXXFLAGS="$CFLAGS"
export CFLAGS CXXFLAGS

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

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
%make_install
install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}
rm -f $RPM_BUILD_ROOT%{_libdir}/libodbcpsql.so*
find doc -name 'Makefile*' | xargs rm

%post
/sbin/ldconfig

%postun
/sbin/ldconfig

%files
%doc README COPYING AUTHORS ChangeLog NEWS doc
%config(noreplace) %{_sysconfdir}/odbc*
%{_bindir}/odbcinst
%{_bindir}/isql
%{_bindir}/dltest
%{_bindir}/iusql
%{_bindir}/odbc_config
%{_bindir}/slencheck
%{_libdir}/*.so.*
%{_libdir}/libodbc.so
%{_libdir}/libodbcinst.so
%{_libdir}/libodbcpsqlS.so
%{_libdir}/libodbcmyS.so
%{_libdir}/libtdsS.so
%{_mandir}/man*/*

%files devel
%{_includedir}/*
%_libdir/pkgconfig/*.pc
%{_libdir}/libodbcdrvcfg2S.so
%{_libdir}/liboraodbcS.so
%{_libdir}/libodbcminiS.so
%{_libdir}/libodbccr.so
%{_libdir}/libmimerS.so
%{_libdir}/libodbcdrvcfg1S.so
%{_libdir}/libsapdbS.so
%{_libdir}/libesoobS.so
%{_libdir}/liboplodbcS.so
%{_libdir}/libodbcnnS.so
%{_libdir}/libtemplate.so
%{_libdir}/libnn.so
%{_libdir}/libodbctxtS.so
%exclude %{_libdir}/*.a
%exclude %{_libdir}/*.la
%exclude %{_libdir}/libltdl.*
%exclude %{_datadir}/libtool

%changelog
* Thu Nov 25 2021 Haoran Yang <yanghaoran7@huawei.com> - 2.3.9-1
- update unixODBC from version 2.3.7 to 2.3.9 and delete old patches

* Mon Nov 8 2021 Haoran Yang <yanghaoran7@huawei.com> - 2.3.7-3
- fix some leaks and eliminate duplicated code

* Tue Nov 5 2019 Lijin Yang <yanglijin@huawei.com> - 1.1.0-14
- Package init
