Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdb: implement Tcl platform detection and improve private headers scan
@ 2026-04-02 17:58 Patrick Monnerat
  2026-04-03 19:31 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick Monnerat @ 2026-04-02 17:58 UTC (permalink / raw)
  To: gdb-patches; +Cc: Patrick Monnerat

This is needed for recent TEA support.

Autoconf macro CY_AC_TCL_PRIVATE_HEADERS checks more file locations and
determines TCL_PLATFORM according to the private header files found.
A C macro TCL_PLATFORM_DEFINE is computed accordingly and defined from
command line.

The same applies to Tk.

As in-tree Tcl/Tk sources have been removed, this case is left out.

This change primarily targets Insight.
---
 gdb/Makefile.in  |   2 +-
 gdb/acinclude.m4 |  56 +++++++++++++++++++------
 gdb/configure    | 105 +++++++++++++++++++++++++----------------------
 gdb/configure.ac |  54 +++++++-----------------
 4 files changed, 116 insertions(+), 101 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 0668351b6c0..2488d789580 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -583,7 +583,7 @@ SUBDIR_GDBTK_SRCS = \
 
 SUBDIR_GDBTK_DEPS = $(LIBGUI) $(TCL_DEPS) $(TK_DEPS)
 SUBDIR_GDBTK_LDFLAGS =
-SUBDIR_GDBTK_CFLAGS = -DGDBTK
+SUBDIR_GDBTK_CFLAGS= -DGDBTK -D@TCL_PLATFORM_DEFINE@ -D@TK_PLATFORM_DEFINE@
 
 CONFIG_OBS = @CONFIG_OBS@
 CONFIG_SRCS = @CONFIG_SRCS@
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 547dd14d62f..64cbab0b93a 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -132,44 +132,76 @@ fi
 ])
 
 dnl Find the location of the private Tcl headers
-dnl When Tcl is installed, this is TCL_INCLUDE_SPEC/tcl-private/generic
-dnl When Tcl is in the build tree, this is not needed.
+dnl This is TCL_INCLUDE_SPEC/tcl-private/generic or TCL_SRC_DIR/generic.
+dnl As a side effect, determine the TCL platform.
 dnl
 dnl Note: you must use first use SC_LOAD_TCLCONFIG!
 AC_DEFUN([CY_AC_TCL_PRIVATE_HEADERS], [
   AC_MSG_CHECKING([for Tcl private headers])
   private_dir=""
-  dir=`echo ${TCL_INCLUDE_SPEC}/tcl-private/generic | sed -e s/-I//`
-  if test -f ${dir}/tclInt.h ; then
-    private_dir=${dir}
-  fi
+  for dir in "${TCL_INCLUDE_SPEC}/tcl-private" "${TCL_SRC_DIR}"; do
+    dir=`echo "${dir}/generic" | sed -e s/-I//`
+    if test -f "${dir}/tclInt.h"; then
+      private_dir="${dir}"
+      break
+    fi
+  done
 
   if test x"${private_dir}" = x; then
     AC_MSG_ERROR(could not find private Tcl headers)
   else
     TCL_PRIVATE_INCLUDE="-I${private_dir}"
     AC_MSG_RESULT(${private_dir})
+    TCL_PLATFORM=unknown
+    dir="`dirname \"${private_dir}\"`"
+    for platform in Unix Win MacOSX; do
+      # FIXME: actually, MacOSX is not detected. How to do it ?
+      pf="`echo \"${platform}\" | tr 'A-Z' 'a-z'`"
+      if test -f "${dir}/generic/tcl${platform}Port.h"; then
+	TCL_PLATFORM="${pf}"
+	break
+      elif test -f "${dir}/${pf}/tcl${platform}Port.h"; then
+	TCL_PLATFORM="${pf}"
+	TCL_PRIVATE_INCLUDE="${TCL_PRIVATE_INCLUDE} -I${dir}/${pf}"
+	break
+      fi
+    done
   fi
 ])
 
 dnl Find the location of the private Tk headers
-dnl When Tk is installed, this is TK_INCLUDE_SPEC/tk-private/generic
-dnl When Tk is in the build tree, this not needed.
+dnl This is TK_INCLUDE_SPEC/tk-private/generic or TK_SRC_DIR/generic.
 dnl
 dnl Note: you must first use SC_LOAD_TKCONFIG
 AC_DEFUN([CY_AC_TK_PRIVATE_HEADERS], [
   AC_MSG_CHECKING([for Tk private headers])
   private_dir=""
-  dir=`echo ${TK_INCLUDE_SPEC}/tk-private/generic | sed -e s/-I//`
-  if test -f ${dir}/tkInt.h; then
-    private_dir=${dir}
-  fi
+  for dir in "${TK_INCLUDE_SPEC}/tk-private" "${TK_SRC_DIR}"; do
+    dir=`echo "${dir}/generic" | sed -e s/-I//`
+    if test -f "${dir}/tkInt.h"; then
+      private_dir="${dir}"
+      break
+    fi
+  done
 
   if test x"${private_dir}" = x; then
     AC_MSG_ERROR(could not find Tk private headers)
   else
     TK_PRIVATE_INCLUDE="-I${private_dir}"
     AC_MSG_RESULT(${private_dir})
+    TK_PLATFORM=unknown
+    dir="`dirname \"${private_dir}\"`"
+    for platform in Unix Win MacOSX; do
+      pf="`echo \"${platform}\" | tr 'A-Z' 'a-z'`"
+      if test -f "${dir}/generic/tk${platform}Port.h"; then
+	TK_PLATFORM="${pf}"
+	break
+      elif test -f "${dir}/${pf}/tk${platform}Port.h"; then
+	TK_PLATFORM="${pf}"
+	TK_PRIVATE_INCLUDE="${TK_PRIVATE_INCLUDE} -I${dir}/${pf}"
+	break
+      fi
+    done
   fi
 ])
 
diff --git a/gdb/configure b/gdb/configure
index 0f5a26878e2..2ff36178a7e 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -674,6 +674,7 @@ X_LIBS
 X_LDFLAGS
 X_CFLAGS
 TK_XINCLUDES
+TK_PLATFORM_DEFINE
 TK_DEPS
 TK_LIBRARY
 TK_INCLUDE
@@ -686,6 +687,7 @@ TK_LIB_FILE
 TK_SRC_DIR
 TK_BIN_DIR
 TK_VERSION
+TCL_PLATFORM_DEFINE
 TCL_DEPS
 TCL_LIBRARY
 TCL_INCLUDE
@@ -11886,7 +11888,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11889 "configure"
+#line 11891 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11992,7 +11994,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11995 "configure"
+#line 11997 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -32924,27 +32926,18 @@ $as_echo "could not find ${TCL_BIN_DIR}/tclConfig.sh" >&6; }
 
 
 
-	# Check for in-tree tcl
-	here=`pwd`
-	cd ${srcdir}/..
-	topdir=`pwd`
-	cd ${here}
-
-	intree="no"
-	if test "${TCL_SRC_DIR}" = "${topdir}/tcl"; then
-	  intree="yes"
-	fi
-
 	# Find Tcl private headers
-	if test x"${intree}" = xno; then
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl private headers" >&5
 $as_echo_n "checking for Tcl private headers... " >&6; }
   private_dir=""
-  dir=`echo ${TCL_INCLUDE_SPEC}/tcl-private/generic | sed -e s/-I//`
-  if test -f ${dir}/tclInt.h ; then
-    private_dir=${dir}
-  fi
+  for dir in "${TCL_INCLUDE_SPEC}/tcl-private" "${TCL_SRC_DIR}"; do
+    dir=`echo "${dir}/generic" | sed -e s/-I//`
+    if test -f "${dir}/tclInt.h"; then
+      private_dir="${dir}"
+      break
+    fi
+  done
 
   if test x"${private_dir}" = x; then
     as_fn_error $? "could not find private Tcl headers" "$LINENO" 5
@@ -32952,19 +32945,28 @@ $as_echo_n "checking for Tcl private headers... " >&6; }
     TCL_PRIVATE_INCLUDE="-I${private_dir}"
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${private_dir}" >&5
 $as_echo "${private_dir}" >&6; }
+    TCL_PLATFORM=unknown
+    dir="`dirname \"${private_dir}\"`"
+    for platform in Unix Win MacOSX; do
+      # FIXME: actually, MacOSX is not detected. How to do it ?
+      pf="`echo \"${platform}\" | tr 'A-Z' 'a-z'`"
+      if test -f "${dir}/generic/tcl${platform}Port.h"; then
+	TCL_PLATFORM="${pf}"
+	break
+      elif test -f "${dir}/${pf}/tcl${platform}Port.h"; then
+	TCL_PLATFORM="${pf}"
+	TCL_PRIVATE_INCLUDE="${TCL_PRIVATE_INCLUDE} -I${dir}/${pf}"
+	break
+      fi
+    done
   fi
 
-	  TCL_INCLUDE="${TCL_INCLUDE_SPEC} ${TCL_PRIVATE_INCLUDE}"
-	  TCL_LIBRARY="${TCL_LIB_SPEC}"
-	  TCL_DEPS=""
-	else
-	  # If building tcl in the same src tree, private headers
-	  # are not needed, but we need to be sure to use the right
-	  # headers library
-	  TCL_INCLUDE="-I${TCL_SRC_DIR}/generic"
-	  TCL_LIBRARY="${TCL_BUILD_LIB_SPEC}"
-	  TCL_DEPS="../tcl/${configdir}${TCL_LIB_FILE}"
-	fi
+	TCL_INCLUDE="${TCL_INCLUDE_SPEC} ${TCL_PRIVATE_INCLUDE}"
+	TCL_LIBRARY="${TCL_LIB_SPEC}"
+	TCL_DEPS=""
+	TCL_PLATFORM_DEFINE="TCL_PLATFORM_`echo \"${TCL_PLATFORM}\" | tr 'a-z-' 'A-Z_'`"
+	TCL_PLATFORM_DEFINE="${TCL_PLATFORM_DEFINE}=${TCL_PLATFORM_DEFINE}"
+
 
 
 
@@ -33038,22 +33040,18 @@ $as_echo "could not find ${TK_BIN_DIR}/tkConfig.sh" >&6; }
 
 
 
-	# Check for in-tree Tk
-	intree="no"
-	if test "${TK_SRC_DIR}" = "${topdir}/tk"; then
-	  intree="yes"
-	fi
-
 	# Find Tk private headers
-	if test x"${intree}" = xno; then
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tk private headers" >&5
 $as_echo_n "checking for Tk private headers... " >&6; }
   private_dir=""
-  dir=`echo ${TK_INCLUDE_SPEC}/tk-private/generic | sed -e s/-I//`
-  if test -f ${dir}/tkInt.h; then
-    private_dir=${dir}
-  fi
+  for dir in "${TK_INCLUDE_SPEC}/tk-private" "${TK_SRC_DIR}"; do
+    dir=`echo "${dir}/generic" | sed -e s/-I//`
+    if test -f "${dir}/tkInt.h"; then
+      private_dir="${dir}"
+      break
+    fi
+  done
 
   if test x"${private_dir}" = x; then
     as_fn_error $? "could not find Tk private headers" "$LINENO" 5
@@ -33061,16 +33059,27 @@ $as_echo_n "checking for Tk private headers... " >&6; }
     TK_PRIVATE_INCLUDE="-I${private_dir}"
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${private_dir}" >&5
 $as_echo "${private_dir}" >&6; }
+    TK_PLATFORM=unknown
+    dir="`dirname \"${private_dir}\"`"
+    for platform in Unix Win MacOSX; do
+      pf="`echo \"${platform}\" | tr 'A-Z' 'a-z'`"
+      if test -f "${dir}/generic/tk${platform}Port.h"; then
+	TK_PLATFORM="${pf}"
+	break
+      elif test -f "${dir}/${pf}/tk${platform}Port.h"; then
+	TK_PLATFORM="${pf}"
+	TK_PRIVATE_INCLUDE="${TK_PRIVATE_INCLUDE} -I${dir}/${pf}"
+	break
+      fi
+    done
   fi
 
-	  TK_INCLUDE="${TK_INCLUDE_SPEC} ${TK_PRIVATE_INCLUDE}"
-	  TK_LIBRARY=${TK_LIB_SPEC}
-	  TK_DEPS=""
-	else
-	  TK_INCLUDE="-I${TK_SRC_DIR}/generic"
-	  TK_LIBRARY="${TK_BUILD_LIB_SPEC}"
-	  TK_DEPS="../tk/${configdir}/${TK_LIB_FILE}"
-	fi
+	TK_INCLUDE="${TK_INCLUDE_SPEC} ${TK_PRIVATE_INCLUDE}"
+	TK_LIBRARY=${TK_LIB_SPEC}
+	TK_DEPS=""
+	TK_PLATFORM_DEFINE="TK_PLATFORM_`echo \"${TK_PLATFORM}\" | tr 'a-z-' 'A-Z_'`"
+	TK_PLATFORM_DEFINE="${TK_PLATFORM_DEFINE}=${TK_PLATFORM_DEFINE}"
+
 
 
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index cf8078e1d89..dc918ae28c7 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -2111,57 +2111,31 @@ if test "${enable_gdbtk}" = "yes"; then
     if test -z "${no_tcl}" -a -z "${no_tk}"; then
 	SC_LOAD_TCLCONFIG
 
-	# Check for in-tree tcl
-	here=`pwd`
-	cd ${srcdir}/..
-	topdir=`pwd`
-	cd ${here}
-
-	intree="no"
-	if test "${TCL_SRC_DIR}" = "${topdir}/tcl"; then
-	  intree="yes"
-	fi
-
 	# Find Tcl private headers
-	if test x"${intree}" = xno; then
-	  CY_AC_TCL_PRIVATE_HEADERS
-	  TCL_INCLUDE="${TCL_INCLUDE_SPEC} ${TCL_PRIVATE_INCLUDE}"
-	  TCL_LIBRARY="${TCL_LIB_SPEC}"
-	  TCL_DEPS=""
-	else
-	  # If building tcl in the same src tree, private headers
-	  # are not needed, but we need to be sure to use the right
-	  # headers library
-	  TCL_INCLUDE="-I${TCL_SRC_DIR}/generic"
-	  TCL_LIBRARY="${TCL_BUILD_LIB_SPEC}"
-	  TCL_DEPS="../tcl/${configdir}${TCL_LIB_FILE}"
-	fi
+	CY_AC_TCL_PRIVATE_HEADERS
+	TCL_INCLUDE="${TCL_INCLUDE_SPEC} ${TCL_PRIVATE_INCLUDE}"
+	TCL_LIBRARY="${TCL_LIB_SPEC}"
+	TCL_DEPS=""
+	TCL_PLATFORM_DEFINE="TCL_PLATFORM_`echo \"${TCL_PLATFORM}\" | tr 'a-z-' 'A-Z_'`"
+	TCL_PLATFORM_DEFINE="${TCL_PLATFORM_DEFINE}=${TCL_PLATFORM_DEFINE}"
 	AC_SUBST(TCL_INCLUDE)
 	AC_SUBST(TCL_LIBRARY)
 	AC_SUBST(TCL_DEPS)
+	AC_SUBST(TCL_PLATFORM_DEFINE)
 
 	SC_LOAD_TKCONFIG
 
-	# Check for in-tree Tk
-	intree="no"
-	if test "${TK_SRC_DIR}" = "${topdir}/tk"; then
-	  intree="yes"
-	fi
-
 	# Find Tk private headers
-	if test x"${intree}" = xno; then
-	  CY_AC_TK_PRIVATE_HEADERS
-	  TK_INCLUDE="${TK_INCLUDE_SPEC} ${TK_PRIVATE_INCLUDE}"
-	  TK_LIBRARY=${TK_LIB_SPEC}
-	  TK_DEPS=""
-	else
-	  TK_INCLUDE="-I${TK_SRC_DIR}/generic"
-	  TK_LIBRARY="${TK_BUILD_LIB_SPEC}"
-	  TK_DEPS="../tk/${configdir}/${TK_LIB_FILE}"
-	fi
+	CY_AC_TK_PRIVATE_HEADERS
+	TK_INCLUDE="${TK_INCLUDE_SPEC} ${TK_PRIVATE_INCLUDE}"
+	TK_LIBRARY=${TK_LIB_SPEC}
+	TK_DEPS=""
+	TK_PLATFORM_DEFINE="TK_PLATFORM_`echo \"${TK_PLATFORM}\" | tr 'a-z-' 'A-Z_'`"
+	TK_PLATFORM_DEFINE="${TK_PLATFORM_DEFINE}=${TK_PLATFORM_DEFINE}"
 	AC_SUBST(TK_INCLUDE)
 	AC_SUBST(TK_LIBRARY)
 	AC_SUBST(TK_DEPS)
+	AC_SUBST(TK_PLATFORM_DEFINE)
 	AC_SUBST(TK_XINCLUDES)
 
 	ENABLE_CFLAGS="${ENABLE_CFLAGS} \$(SUBDIR_GDBTK_CFLAGS)"
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-04-07  9:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-02 17:58 [PATCH] gdb: implement Tcl platform detection and improve private headers scan Patrick Monnerat
2026-04-03 19:31 ` Tom Tromey
2026-04-03 22:55   ` Patrick Monnerat
2026-04-06 18:12     ` Tom Tromey
2026-04-07  9:46       ` Patrick Monnerat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox