diff --git a/client/Makefile.am b/client/Makefile.am
index d47e9f98f5e8c1fda51e76085db68b2887d9bd24..cf9d2884ded4c59f8cc27ec224a3364b70be48cf 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -22,8 +22,10 @@ else
   yassl_dummy_link_fix=
 endif
 #AUTOMAKE_OPTIONS =              nostdinc
-INCLUDES =			-I$(top_builddir)/include -I$(top_srcdir)/include \
-				-I$(top_srcdir)/regex $(openssl_includes)
+INCLUDES =			-I$(top_builddir)/include \
+				-I$(top_srcdir)/include \
+				-I$(top_srcdir)/regex \
+                                $(openssl_includes) $(yassl_includes) 
 LIBS =				@CLIENT_LIBS@
 LDADD=				@CLIENT_EXTRA_LDFLAGS@ \
                                 $(top_builddir)/libmysql/libmysqlclient.la
diff --git a/config/ac-macros/yassl.m4 b/config/ac-macros/yassl.m4
index 921333393438816eb1190b503e63300f0f532dbc..548768fb71713c2561782d2aaf8ce13dd4daa0a7 100644
--- a/config/ac-macros/yassl.m4
+++ b/config/ac-macros/yassl.m4
@@ -15,17 +15,15 @@ AC_DEFUN([MYSQL_CHECK_YASSL], [
     fi
     AC_MSG_RESULT([using bundled yaSSL])
     yassl_dir="extra/yassl"
-    openssl_libs="\
-    -L\$(top_builddir)/extra/yassl/src -lyassl\
-    -L\$(top_builddir)/extra/yassl/taocrypt/src -ltaocrypt"
-    openssl_includes="-I\$(top_srcdir)/extra/yassl/include"
+    yassl_libs="-L\$(top_srcdir)/extra/yassl/src -lyassl -L\$(top_srcdir)/extra/yassl/taocrypt/src -ltaocrypt"
+    yassl_includes="-I\$(top_srcdir)/extra/yassl/include"
     AC_DEFINE([HAVE_OPENSSL], [1], [Defined by configure. Using yaSSL for OpenSSL emulation.])
   else
     yassl_dir=""
     AC_MSG_RESULT(no)
   fi
-  AC_SUBST(openssl_libs)
-  AC_SUBST(openssl_includes)
+  AC_SUBST(yassl_libs)
+  AC_SUBST(yassl_includes)
   AC_SUBST(yassl_dir)
   AM_CONDITIONAL([HAVE_YASSL], [ test "with_yassl" = "yes" ])
 ])
diff --git a/configure.in b/configure.in
index 05aaaa73bfa93faf503442574d3f3ce40120e432..d06cd0e1af13a4baf0cff5c29b17f2362cffa50f 100644
--- a/configure.in
+++ b/configure.in
@@ -1139,7 +1139,7 @@ dnl Is this the right match for DEC OSF on alpha?
         sql/Makefile.in)
           # Use gen_lex_hash.linux instead of gen_lex_hash
           # Add library dependencies to mysqld_DEPENDENCIES
-          lib_DEPENDENCIES="\$(bdb_libs_with_path) \$(innodb_libs) \$(ndbcluster_libs) \$(pstack_libs) \$(innodb_system_libs) \$(openssl_libs)"
+          lib_DEPENDENCIES="\$(bdb_libs_with_path) \$(innodb_libs) \$(ndbcluster_libs) \$(pstack_libs) \$(innodb_system_libs) \$(openssl_libs) \$(yassl_libs)"
           cat > $filesed << EOF
 s,\(^.*\$(MAKE) gen_lex_hash\)\$(EXEEXT),#\1,
 s,\(\./gen_lex_hash\)\$(EXEEXT),\1.linux,
@@ -2423,7 +2423,7 @@ then
   AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe])
 fi
 
-CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
+CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $yassl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS"
 
 AC_SUBST(CLIENT_LIBS)
 AC_SUBST(NON_THREADED_LIBS)
diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am
index 4bd9eddafb03cf53275584a1dac35e3e8adb5454..cb02e0f1235fb9f963fc57a28b869cb85ff7ac92 100644
--- a/libmysql/Makefile.am
+++ b/libmysql/Makefile.am
@@ -24,7 +24,7 @@ target =	libmysqlclient.la
 target_defs =	-DUNDEF_THREADS_HACK -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@
 LIBS =		@CLIENT_LIBS@
 INCLUDES =	-I$(top_builddir)/include -I$(top_srcdir)/include \
-		$(openssl_includes) @ZLIB_INCLUDES@
+		$(openssl_includes) $(yassl_includes) @ZLIB_INCLUDES@
 
 include $(srcdir)/Makefile.shared
 
diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am
index 65255066d45fb34c09acf2b7577affd5e73382e5..6ab09368cc544f2c447f3c90eacfb3cbc73f069b 100644
--- a/libmysql_r/Makefile.am
+++ b/libmysql_r/Makefile.am
@@ -22,10 +22,10 @@
 
 target = libmysqlclient_r.la
 target_defs = -DDONT_USE_RAID -DMYSQL_CLIENT @LIB_EXTRA_CCFLAGS@
-LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@
+LIBS = @LIBS@ @ZLIB_LIBS@ @openssl_libs@ @yassl_libs@
 
 INCLUDES =	-I$(top_builddir)/include -I$(top_srcdir)/include \
-		$(openssl_includes) @ZLIB_INCLUDES@
+		$(openssl_includes) $(yassl_includes) @ZLIB_INCLUDES@
 ## automake barfs if you don't use $(srcdir) or $(top_srcdir) in include
 include $(top_srcdir)/libmysql/Makefile.shared
 
diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am
index 9aef03f20d28da80a5e649c02996276b0f7a23fb..ca8e48aa6124e8241ef64e0c7afa3bb2f2e216d0 100644
--- a/libmysqld/Makefile.am
+++ b/libmysqld/Makefile.am
@@ -29,7 +29,7 @@ INCLUDES=		@bdb_includes@ \
 			-I$(top_builddir)/include -I$(top_srcdir)/include \
 			-I$(top_srcdir)/sql -I$(top_srcdir)/sql/examples \
 			-I$(top_srcdir)/regex \
-			$(openssl_includes) @ZLIB_INCLUDES@
+			$(openssl_includes) $(yassl_includes) @ZLIB_INCLUDES@
 
 noinst_LIBRARIES =	libmysqld_int.a
 pkglib_LIBRARIES =	libmysqld.a
diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am
index b872adca09d351281a83da6506bb0ad51e0b35fe..4fa2a0da40567c5d90634b037c4809e7bc8f4323 100644
--- a/server-tools/instance-manager/Makefile.am
+++ b/server-tools/instance-manager/Makefile.am
@@ -15,7 +15,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 INCLUDES= @ZLIB_INCLUDES@ -I$(top_srcdir)/include \
-	$(openssl_includes) -I$(top_builddir)/include
+	@openssl_includes@ @yassl_includes@ -I$(top_builddir)/include
 
 DEFS= -DMYSQL_INSTANCE_MANAGER -DMYSQL_SERVER
 
@@ -85,7 +85,7 @@ mysqlmanager_LDADD=	liboptions.a \
 			$(top_builddir)/mysys/libmysys.a \
 			$(top_builddir)/strings/libmystrings.a \
 			$(top_builddir)/dbug/libdbug.a \
-			@openssl_libs@ @ZLIB_LIBS@
+			@openssl_libs@ @yassl_libs@ @ZLIB_LIBS@
 
 
 tags:
diff --git a/sql/Makefile.am b/sql/Makefile.am
index 4824a75d6facb3f244ce6ca1f7eda477f264c19c..5074212e6c8eb8c0d4c590ec875e79588fe4cf32 100644
--- a/sql/Makefile.am
+++ b/sql/Makefile.am
@@ -22,7 +22,8 @@ MYSQLBASEdir=		$(prefix)
 INCLUDES =		@ZLIB_INCLUDES@ \
 			@bdb_includes@ @innodb_includes@ @ndbcluster_includes@ \
 			-I$(top_builddir)/include -I$(top_srcdir)/include \
-			-I$(top_srcdir)/regex -I$(srcdir) $(openssl_includes)
+			-I$(top_srcdir)/regex -I$(srcdir) $(yassl_includes) \
+                        $(openssl_includes)
 WRAPLIBS=		@WRAPLIBS@
 SUBDIRS =		share
 libexec_PROGRAMS =	mysqld
@@ -42,7 +43,8 @@ mysqld_LDADD =		@MYSQLD_EXTRA_LDFLAGS@ \
 			@bdb_libs@ @innodb_libs@ @pstack_libs@ \
                         @innodb_system_libs@ \
 			@ndbcluster_libs@ @ndbcluster_system_libs@ \
-			$(LDADD)  $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ @openssl_libs@
+			$(LDADD)  $(CXXLDFLAGS) $(WRAPLIBS) @LIBDL@ \
+                        @yassl_libs@ @openssl_libs@
 noinst_HEADERS =	item.h item_func.h item_sum.h item_cmpfunc.h \
 			item_strfunc.h item_timefunc.h item_uniq.h \
 			item_create.h item_subselect.h item_row.h \
diff --git a/vio/Makefile.am b/vio/Makefile.am
index 0d4f052b30a57ade190b4dea87946aafd2977c17..544639139def18c05626b53ca877b16257c2fbf2 100644
--- a/vio/Makefile.am
+++ b/vio/Makefile.am
@@ -20,23 +20,23 @@ else
   yassl_dummy_link_fix=
 endif
 INCLUDES=		-I$(top_builddir)/include -I$(top_srcdir)/include \
-			$(openssl_includes)
-LDADD=			@CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) 
+			$(openssl_includes) $(yassl_includes)
+LDADD=			@CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs) 
 pkglib_LIBRARIES=	libvio.a
 noinst_PROGRAMS	=	test-ssl test-sslserver test-sslclient
 noinst_HEADERS=	vio_priv.h
 test_ssl_SOURCES=	test-ssl.c $(yassl_dummy_link_fix)
 test_ssl_LDADD=   	@CLIENT_EXTRA_LDFLAGS@ ../dbug/libdbug.a libvio.a \
 			../mysys/libmysys.a ../strings/libmystrings.a \
-			$(openssl_libs)
+			$(openssl_libs) $(yassl_libs)
 test_sslserver_SOURCES= test-sslserver.c $(yassl_dummy_link_fix)
 test_sslserver_LDADD=   @CLIENT_EXTRA_LDFLAGS@	../dbug/libdbug.a libvio.a \
 			../mysys/libmysys.a ../strings/libmystrings.a \
-			$(openssl_libs)
+			$(openssl_libs) $(yassl_libs)
 test_sslclient_SOURCES= test-sslclient.c $(yassl_dummy_link_fix)
 test_sslclient_LDADD=   @CLIENT_EXTRA_LDFLAGS@	../dbug/libdbug.a libvio.a \
 			../mysys/libmysys.a ../strings/libmystrings.a \
-			$(openssl_libs)
+			$(openssl_libs) $(yassl_libs)
 libvio_a_SOURCES=	vio.c viosocket.c viossl.c viosslfactories.c
 
 # Don't update the files from bitkeeper