From 74672f0ba7e84799f4c7177e077b47f1d9bdcf4b Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <praiskup@redhat.com>
Date: Mon, 27 Jun 2016 08:25:45 +0200
Subject: [PATCH] multilib fixes

Delegate most of the multilib decisions to multilib-rpm-config,
this allows us to maintain the rules at central place.

Version: 5.7.12-2
---
 community-mysql.spec | 26 +++++++++++---------------
 my_config.h          | 34 ----------------------------------
 2 files changed, 11 insertions(+), 49 deletions(-)
 delete mode 100644 my_config.h

diff --git a/community-mysql.spec b/community-mysql.spec
index 91f4b98..57d75cf 100644
--- a/community-mysql.spec
+++ b/community-mysql.spec
@@ -80,7 +80,7 @@
 
 Name:             community-mysql
 Version:          5.7.12
-Release:          1%{?with_debug:.debug}%{?dist}
+Release:          2%{?with_debug:.debug}%{?dist}
 Summary:          MySQL client programs and shared libraries
 Group:            Applications/Databases
 URL:              http://www.mysql.com
@@ -92,7 +92,6 @@ License:          GPLv2 with exceptions and LGPLv2 and BSD
 Source0:          https://cdn.mysql.com/Downloads/MySQL-5.7/mysql-boost-%{version}.tar.gz
 Source2:          mysql_config_multilib.sh
 Source3:          my.cnf.in
-Source4:          my_config.h
 Source6:          README.mysql-docs
 Source7:          README.mysql-license
 Source10:         mysql.tmpfiles.d.in
@@ -143,6 +142,7 @@ BuildRequires:    perl
 BuildRequires:    perl-generators
 BuildRequires:    systemtap-sdt-devel
 BuildRequires:    zlib-devel
+BuildRequires:    multilib-rpm-config
 # Tests requires time and ps and some perl modules
 BuildRequires:    procps
 BuildRequires:    time
@@ -631,20 +631,14 @@ pushd build
 make DESTDIR=%{buildroot} install
 
 # multilib header support
+%multilib_fix_c_header --file %{_includedir}/mysql/my_config.h
+
+# multilib support for shell scripts
 # we only apply this to known Red Hat multilib arches, per bug #181335
-unamei=$(uname -i)
-%ifarch %{arm}
-unamei=arm
-%endif
-%ifarch %{power64}
-unamei=ppc64
-%endif
-%ifarch %{arm} aarch64 %{ix86} x86_64 ppc %{power64} %{sparc} s390 s390x
-mv %{buildroot}%{_includedir}/mysql/my_config.h %{buildroot}%{_includedir}/mysql/my_config_${unamei}.h
-install -p -m 644 %{SOURCE4} %{buildroot}%{_includedir}/mysql/
+if %multilib_capable; then
 mv %{buildroot}%{_bindir}/mysql_config %{buildroot}%{_bindir}/mysql_config-%{__isa_bits}
 install -p -m 0755 scripts/mysql_config_multilib %{buildroot}%{_bindir}/mysql_config
-%endif
+fi
 
 # install INFO_SRC, INFO_BIN into libdir (upstream thinks these are doc files,
 # but that's pretty wacko --- see also %%{name}-file-contents.patch)
@@ -1030,8 +1024,7 @@ fi
 
 %if %{with devel}
 %files devel
-%{_bindir}/mysql_config
-%{_bindir}/mysql_config-%{__isa_bits}
+%{_bindir}/mysql_config*
 %{_includedir}/mysql
 %{_datadir}/aclocal/mysql.m4
 %if %{with clibrary}
@@ -1063,6 +1056,9 @@ fi
 %endif
 
 %changelog
+* Mon Jun 27 2016 Pavel Raiskup <praiskup@redhat.com> - 5.7.12-2
+- BR multilib-rpm-config and use it for multilib workarounds
+
 * Tue May 24 2016 Jakub Dorňák <jdornak@redhat.com> - 5.7.12-1
 - Update to 5.7.12
   Thanks to Norvald H. Ryeng
diff --git a/my_config.h b/my_config.h
deleted file mode 100644
index 0672f49..0000000
--- a/my_config.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Kluge to support multilib installation of both 32- and 64-bit RPMS:
- * we need to arrange that header files that appear in both RPMs are
- * identical.  Hence, this file is architecture-independent and calls
- * in an arch-dependent file that will appear in just one RPM.
- *
- * To avoid breaking arches not explicitly supported by Red Hat, we
- * use this indirection file *only* on known multilib arches.
- *
- * Note: this may well fail if user tries to use gcc's -I- option.
- * But that option is deprecated anyway.
- */
-#if defined(__x86_64__)
-#include "my_config_x86_64.h"
-#elif defined(__i386__)
-#include "my_config_i386.h"
-#elif defined(__ppc64__) || defined(__powerpc64__)
-#include "my_config_ppc64.h"
-#elif defined(__ppc__) || defined(__powerpc__)
-#include "my_config_ppc.h"
-#elif defined(__s390x__)
-#include "my_config_s390x.h"
-#elif defined(__s390__)
-#include "my_config_s390.h"
-#elif defined(__sparc__) && defined(__arch64__)
-#include "my_config_sparc64.h"
-#elif defined(__sparc__)
-#include "my_config_sparc.h"
-#elif defined(__arm__)
-#include "my_config_arm.h"
-#elif defined(__aarch64__)
-#include "my_config_aarch64.h"
-#endif
-