Skip to content

Instantly share code, notes, and snippets.

@devzendo
Created July 21, 2014 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devzendo/ac454b4f0fd4e1ee7155 to your computer and use it in GitHub Desktop.
Save devzendo/ac454b4f0fd4e1ee7155 to your computer and use it in GitHub Desktop.
Summary: A complete ODBC driver manager for Linux
Name: unixODBC
Version: 2.3.0
Release: 1%{?dist}
Group: System Environment/Libraries
URL: http://www.unixODBC.org/
# Programs are GPL, libraries are LGPL, except News Server library is GPL.
License: GPLv2+ and LGPLv2+
Source: http://www.unixODBC.org/%{name}-%{version}.tar.gz
Source1: odbcinst.ini
Source4: conffile.h
Source5: README.fedora
Patch1: depcomp.patch
Patch6: export-symbols.patch
Patch8: so-version-bump.patch
Patch9: keep-typedefs.patch
Patch10: lib2.patch
Conflicts: iodbc
BuildRequires: automake autoconf libtool libtool-ltdl-devel bison flex
BuildRequires: readline-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
%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
Group: Development/Libraries
Requires: %{name}%{?_isa} = %{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
%patch1 -p1
%patch6 -p1
%patch8 -p1
%patch9 -p1
%patch10 -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
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.fedora
# 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
%files -f base-so-list
%defattr(-,root,root)
%doc README COPYING AUTHORS ChangeLog NEWS doc
%doc README.fedora
%config(noreplace) %{_sysconfdir}/odbc*
%{_bindir}/odbcinst
%{_bindir}/isql
%{_bindir}/dltest
%{_bindir}/iusql
%{_bindir}/odbc_config
%files devel -f devel-so-list
%defattr(-,root,root)
%{_includedir}/*
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment