From e6ca57b1a246d09a477a13fa162fefa5f7db0fc8 Mon Sep 17 00:00:00 2001
From: vasil <>
Date: Wed, 30 Apr 2008 07:19:06 +0000
Subject: [PATCH] branches/5.1:

* Use INNODB_CFLAGS insead of cluttering CFLAGS with InnoDB specific
  flags. CFLAGS are used to compile every file in the MySQL source tree.

* Add INNODB_DYNAMIC_CFLAGS to the flags of the dynamic plugin and use
  -prefer-non-pic to make the dynamic plugin faster on i386.

Approved by:	Sunny
---
 Makefile.am |  8 ++++----
 plug.in     | 35 ++++++++++++++++++++---------------
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 30e056d68fb..b9c91a79fc6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -154,15 +154,15 @@ libinnobase_a_SOURCES =	btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c	\
 			ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c		\
 			handler/ha_innodb.cc
 
-libinnobase_a_CXXFLAGS=	$(AM_CFLAGS)
-libinnobase_a_CFLAGS  =	$(AM_CFLAGS)
+libinnobase_a_CXXFLAGS=	$(AM_CFLAGS) $(INNODB_CFLAGS)
+libinnobase_a_CFLAGS  =	$(AM_CFLAGS) $(INNODB_CFLAGS)
 
 EXTRA_LTLIBRARIES =	ha_innodb.la
 pkglib_LTLIBRARIES =	@plugin_innobase_shared_target@
 
 ha_innodb_la_LDFLAGS =	-module -rpath $(MYSQLLIBdir)
-ha_innodb_la_CXXFLAGS=	$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
-ha_innodb_la_CFLAGS  =	$(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN
+ha_innodb_la_CXXFLAGS=	$(AM_CFLAGS) $(INNODB_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
+ha_innodb_la_CFLAGS  =	$(AM_CFLAGS) $(INNODB_CFLAGS) $(INNODB_DYNAMIC_CFLAGS)
 ha_innodb_la_SOURCES =	$(libinnobase_a_SOURCES)
 
 EXTRA_DIST =		CMakeLists.txt plug.in \
diff --git a/plug.in b/plug.in
index b252d471fba..740d9b9ef52 100644
--- a/plug.in
+++ b/plug.in
@@ -16,24 +16,29 @@ MYSQL_PLUGIN_ACTIONS(innobase,  [
   AC_C_BIGENDIAN
   case "$target_os" in
          lin*)
-           CFLAGS="$CFLAGS -DUNIV_LINUX";;
+           INNODB_CFLAGS="-DUNIV_LINUX";;
          hpux10*)
-           CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
+           INNODB_CFLAGS="-DUNIV_MUST_NOT_INLINE -DUNIV_HPUX -DUNIV_HPUX10";;
          hp*)
-           CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";;
+           INNODB_CFLAGS="-DUNIV_MUST_NOT_INLINE -DUNIV_HPUX";;
          aix*)
-           CFLAGS="$CFLAGS -DUNIV_AIX";;
-         irix*)
-           CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
-         osf*)
-           CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
-	 *solaris*|*SunOS*)
-           CFLAGS="$CFLAGS -DUNIV_SOLARIS";;
-         sysv5uw7*)
-           # Problem when linking on SCO
-           CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
-         openbsd*)
-           CFLAGS="$CFLAGS -DUNIV_MUST_NOT_INLINE";;
+           INNODB_CFLAGS="-DUNIV_AIX";;
+         irix*|osf*|sysv5uw7*|openbsd*)
+           INNODB_CFLAGS="-DUNIV_MUST_NOT_INLINE";;
+         *solaris*|*SunOS*)
+           INNODB_CFLAGS="-DUNIV_SOLARIS";;
   esac
+  INNODB_DYNAMIC_CFLAGS="-DMYSQL_DYNAMIC_PLUGIN"
+  case "$target_cpu" in
+	x86_64)
+		# The AMD64 ABI forbids absolute addresses in shared libraries
+		;;
+	*86)
+		# Use absolute addresses on IA-32
+		INNODB_DYNAMIC_CFLAGS="$INNODB_DYNAMIC_CFLAGS -prefer-non-pic"
+		;;
+  esac
+  AC_SUBST(INNODB_CFLAGS)
+  AC_SUBST(INNODB_DYNAMIC_CFLAGS)
   ])
 
-- 
2.30.9