From e154b30a57cc119f8e47936f23a261324228662f Mon Sep 17 00:00:00 2001
From: unknown <monty@hundin.mysql.fi>
Date: Tue, 18 Sep 2001 15:24:14 +0300
Subject: [PATCH] Another attempt to get pstack into the binary distribution
 Fixed that --enable-assembler works on newer Linux system

Makefile.am:
  Another attempt to get pstack into the binary distribution
configure.in:
  Fixed that --enable-assembler works on newer Linux system
  Fixes for pstack
pstack/Makefile.am:
  Another attempt to get pstack into the binary distribution
---
 Makefile.am        |  2 +-
 configure.in       | 35 +++++++++++++++++++++++++++--------
 pstack/Makefile.am | 14 ++++++++++++--
 3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 8ec9b965757..9df706dceb0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,7 @@ TAR =			gtar
 EXTRA_DIST =		INSTALL-SOURCE README \
 			COPYING COPYING.LIB MIRRORS
 SUBDIRS =		include @docs_dirs@ @readline_dir@ \
-			@thread_dirs@ @pstack_dirs@ @sql_client_dirs@ \
+			@thread_dirs@ pstack @sql_client_dirs@ \
 			@sql_server_dirs@ @libmysqld_dirs@ scripts tests man \
 			@bench_dirs@ support-files @fs_dirs@ @tools_dirs@
 
diff --git a/configure.in b/configure.in
index 8bc274421ab..f6a24498511 100644
--- a/configure.in
+++ b/configure.in
@@ -65,6 +65,12 @@ AC_DEFINE_UNQUOTED(SYSTEM_TYPE, "$SYSTEM_TYPE")
 AC_SUBST(MACHINE_TYPE)
 AC_DEFINE_UNQUOTED(MACHINE_TYPE, "$MACHINE_TYPE")
 
+# Detect intel x86 like processor
+BASE_MACHINE_TYPE=$MACHINE_TYPE
+case $MACHINE_TYPE in
+  i?86) BASE_MACHINE_TYPE=i386 ;;
+esac
+
 # Save some variables and the command line options for mysqlbug
 SAVE_CFLAGS="$CFLAGS"
 SAVE_CXXFLAGS="$CXXFLAGS"
@@ -515,12 +521,22 @@ AC_ARG_ENABLE(assembler,
     [ ENABLE_ASSEMBLER=$enableval ],
     [ ENABLE_ASSEMBLER=no ]
     )
+
+AC_MSG_CHECKING(if we should use assembler functions)
 # For now we only support assembler on i386 and sparc systems
-AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$MACHINE_TYPE" = "i386")
-AM_CONDITIONAL(ASSEMBLER_sparc, test "$ENABLE_ASSEMBLER" = "yes" -a "$MACHINE_TYPE" = "sparc")
-AM_CONDITIONAL(ASSEMBLER, test ASSEMBLER_x86 = "" -o ASSEMBLER_x86 = "")
+AM_CONDITIONAL(ASSEMBLER_x86, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "i386")
+AM_CONDITIONAL(ASSEMBLER_sparc, test "$ENABLE_ASSEMBLER" = "yes" -a "$BASE_MACHINE_TYPE" = "sparc")
+AM_CONDITIONAL(ASSEMBLER, test "$ASSEMBLER_x86_TRUE" = "" -o "$ASSEMBLER_sparc_TRUE" = "")
 
-AC_MSG_CHECKING(whether to use RAID)
+if test "$ASSEMBLER_TRUE" = ""
+then
+  AC_MSG_RESULT([yes])
+else
+  AC_MSG_RESULT([no])
+fi
+
+
+AC_MSG_CHECKING(if we should use RAID)
 AC_ARG_WITH(raid,
     [  --with-raid             Enable RAID Support],
     [   USE_RAID=$withval ],
@@ -688,7 +704,7 @@ int main()
     [USE_PSTACK=yes])
   pstack_libs=
   pstack_dirs=
-  if test "$USE_PSTACK" = yes -a "$IS_LINUX" = "true" -a "$MACHINE_TYPE" = "i686" -a "$with_mit_threads" = "no"
+  if test "$USE_PSTACK" = yes -a "$IS_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no"
   then
     have_libiberty= have_libbfd=
     my_save_LIBS="$LIBS"
@@ -698,7 +714,6 @@ dnl I have no idea if this is a good test - can not find docs for libiberty
        AC_CHECK_LIB([bfd], [bfd_openr], [have_libbfd=yes], , [-liberty])])
     LIBS="$my_save_LIBS"
 
-    AC_MSG_CHECKING([for pstack libs])
     if test x"$have_libiberty" = xyes -a x"$have_libbfd" = xyes
     then
       pstack_dirs='$(top_srcdir)'/pstack
@@ -706,16 +721,20 @@ dnl I have no idea if this is a good test - can not find docs for libiberty
       AC_SUBST([pstack_dirs])
       AC_SUBST([pstack_libs])
       AC_DEFINE([USE_PSTACK])
-      AC_MSG_RESULT([yes])
 dnl This check isn't needed, but might be nice to give some feedback....
 dnl    AC_CHECK_HEADER(libiberty.h,
 dnl      have_libiberty_h=yes,
 dnl      have_libiberty_h=no)
     else
-      AC_MSG_RESULT([no (missing libbfd)])
+      USE_PSTACK="no"
     fi
+  else
+    USE_PSTACK="no"
   fi
 fi
+AM_CONDITIONAL(COMPILE_PSTACK, test "$USE_PSTACK" = "yes")
+AC_MSG_CHECKING([if we should use pstack])
+AC_MSG_RESULT([$USE_PSTACK])
 
 # Check for gtty if termio.h doesn't exists
 if test "$ac_cv_header_termio_h" = "no" -a "$ac_cv_header_termios_h" = "no"
diff --git a/pstack/Makefile.am b/pstack/Makefile.am
index 1c0978379d0..86dddcb6f03 100644
--- a/pstack/Makefile.am
+++ b/pstack/Makefile.am
@@ -14,12 +14,22 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
+#
+# As pstack doesn't work on all configurations, we have to use
+# the USE_PSTACK hack to get all files into distribution
+#
+
 INCLUDES =		-I$(srcdir)/../include -I../include
-pkglib_LIBRARIES =	libpstack.a
 noinst_HEADERS =	bucomm.h debug.h ieee.h budbg.h demangle.h \
 			linuxthreads.h pstack.h pstacktrace.h
-libpstack_a_SOURCES =	bucomm.c filemode.c linuxthreads.c rddbg.c \
+SRC=			bucomm.c filemode.c linuxthreads.c rddbg.c \
 			debug.c ieee.c pstack.c stabs.c
+EXTRA_DIST=		$SRC
+
+if COMPILE_PSTACK
+pkglib_LIBRARIES =	libpstack.a
+libpstack_a_SOURCES =	bucomm.c filemode.c linuxthreads.c rddbg.c debug.c ieee.c pstack.c stabs.c
+endif
 
 # Don't update the files from bitkeeper
 %::SCCS/s.%
-- 
2.30.9