]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdbserver/configure.ac
gdbserver/linux: probe for libiconv in configure
[thirdparty/binutils-gdb.git] / gdbserver / configure.ac
index 285a297a1c6c1707f768cc1ccec9667fd4198fdc..ee0de9decbdea51ceee7467cf04953868b34c8b6 100644 (file)
@@ -1,5 +1,5 @@
 dnl Autoconf configure script for GDB server.
-dnl Copyright (C) 2000-2020 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2024 Free Software Foundation, Inc.
 dnl
 dnl This file is part of GDB.
 dnl
@@ -18,18 +18,27 @@ dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 dnl Process this file with autoconf to produce a configure script.
 
-AC_INIT(server.c)
+AC_INIT
+AC_CONFIG_MACRO_DIRS([../config])
+AC_CONFIG_SRCDIR([server.cc])
 AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
 
 AM_MAINTAINER_MODE
 
 AC_PROG_CC
 AC_PROG_CXX
-AC_GNU_SOURCE
+AC_USE_SYSTEM_EXTENSIONS
 AC_SYS_LARGEFILE
 AM_PROG_INSTALL_STRIP
 
-AC_CANONICAL_SYSTEM
+# Set build, build_cpu, build_vendor and build_os.
+AC_CANONICAL_BUILD
+
+# Set host, host_cpu, host_vendor, and host_os.
+AC_CANONICAL_HOST
+
+# Set target, target_cpu, target_vendor, and target_os.
+AC_CANONICAL_TARGET
 
 AC_PROG_INSTALL
 AC_CHECK_TOOL(AR, ar)
@@ -37,18 +46,17 @@ AC_PROG_RANLIB
 
 AC_ARG_PROGRAM
 
-# We require a C++11 compiler.  Check if one is available, and if
+# We require a C++17 compiler.  Check if one is available, and if
 # necessary, set CXX_DIALECT to some -std=xxx switch.
-AX_CXX_COMPILE_STDCXX(11, , mandatory)
+AX_CXX_COMPILE_STDCXX(17, , mandatory)
 
 AC_HEADER_STDC
 
-# Set the 'development' global.
-. $srcdir/../bfd/development.sh
+GDB_AC_COMMON
+# This is set by GDB_AC_COMMON.
+AC_SUBST(WIN32APILIBS)
 
-GDB_AC_SELFTEST([
-  srv_selftest_objs="gdbsupport/selftest.o"
-])
+GDB_AC_SELFTEST
 
 ACX_NONCANONICAL_TARGET
 ACX_NONCANONICAL_HOST
@@ -56,6 +64,9 @@ ACX_NONCANONICAL_HOST
 # Dependency checking.
 ZW_CREATE_DEPDIR
 
+dnl Set up for gettext.
+ZW_GNU_GETTEXT_SISTER_DIR
+
 # Create sub-directories for objects and dependencies.
 CONFIG_SRC_SUBDIR="arch gdbsupport nat target"
 AC_SUBST(CONFIG_SRC_SUBDIR)
@@ -69,32 +80,14 @@ AC_CONFIG_COMMANDS([gdbdepdir],[
 
 ZW_PROG_COMPILER_DEPENDENCIES([CC])
 
-gnulib_extra_configure_args=
-# If large-file support is disabled, make sure gnulib does the same.
-if test "$enable_largefile" = no; then
-gnulib_extra_configure_args="$gnulib_extra_configure_args --disable-largefile"
-fi
-
-# Configure gnulib.  We can't use AC_CONFIG_SUBDIRS as that'd expect
-# to find the the source subdir to be configured directly under
-# gdbserver/.  We need to build gnulib under some other directory not
-# "gnulib", to avoid the problem of both GDB and GDBserver wanting to
-# build it in the same directory, when building in the source dir.
-ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"],
-                  ["$gnulib_extra_configure_args"])
-
-ACX_CONFIGURE_DIR(["../libiberty"], ["build-libiberty-gdbserver"])
-
 AC_CHECK_HEADERS(termios.h sys/reg.h string.h dnl
                 sys/procfs.h linux/elf.h dnl
                 fcntl.h signal.h sys/file.h dnl
                 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
-                netinet/tcp.h arpa/inet.h)
+                netinet/tcp.h arpa/inet.h ws2tcpip.h)
 AC_FUNC_FORK
 AC_CHECK_FUNCS(pread pwrite pread64)
 
-GDB_AC_COMMON
-
 # Check the return and argument types of ptrace.
 GDB_AC_PTRACE
 
@@ -133,12 +126,19 @@ if test "x$with_ust" != "xno"; then
   saved_CFLAGS="$CFLAGS"
   CFLAGS="$CFLAGS $ustinc"
   AC_MSG_CHECKING([for ust])
-  AC_TRY_COMPILE([
+  AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM(
+       [
 #define CONFIG_UST_GDB_INTEGRATION
 #include <ust/ust.h>
-  ],[],
-  [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
-  [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
+       ],
+       []
+     )],
+    [AC_MSG_RESULT([yes]);
+     AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
+    [AC_MSG_RESULT([no])
+     ustlibs= ; ustinc= ]
+  )
   CFLAGS="$saved_CFLAGS"
 fi
 
@@ -146,6 +146,7 @@ fi
 AC_SUBST(ustlibs)
 AC_SUBST(ustinc)
 
+AM_GDB_COMPILER_TYPE
 AM_GDB_WARNINGS
 
 dnl dladdr is glibc-specific.  It is used by thread-db.c but only for
@@ -161,17 +162,13 @@ libiberty_INIT
 
 AC_CHECK_DECLS([perror, vasprintf, vsnprintf])
 
-# See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment registers.
-# Older amd64 Linux's don't have the fs_base and gs_base members of
-# `struct user_regs_struct'.
-AC_CHECK_MEMBERS([struct user_regs_struct.fs_base, struct user_regs_struct.gs_base],
-     [], [], [#include <sys/types.h>
-#include <sys/user.h>])
-
-
 AC_CHECK_TYPES(socklen_t, [], [],
 [#include <sys/types.h>
-#include <sys/socket.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
 ])
 
 case "${target}" in
@@ -249,10 +246,6 @@ if test "${srv_mingwce}" = "yes"; then
 elif test "${srv_mingw}" = "yes"; then
   # WIN32APILIBS is set by GDB_AC_COMMON.
   LIBS="$LIBS $WIN32APILIBS"
-elif test "${srv_qnx}" = "yes"; then
-  LIBS="$LIBS -lsocket"
-elif test "${srv_lynxos}" = "yes"; then
-  LIBS="$LIBS -lnetinet"
 fi
 
 if test "${srv_linux_usrregs}" = "yes"; then
@@ -266,11 +259,14 @@ if test "${srv_linux_regsets}" = "yes"; then
            [Define if the target supports register sets.])
 
   AC_MSG_CHECKING(for PTRACE_GETREGS)
-  AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
-  [AC_TRY_COMPILE([#include <sys/ptrace.h>],
-                 [PTRACE_GETREGS;],
-                 [gdbsrv_cv_have_ptrace_getregs=yes],
-                 [gdbsrv_cv_have_ptrace_getregs=no])])
+  AC_CACHE_VAL(
+    [gdbsrv_cv_have_ptrace_getregs],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([#include <sys/ptrace.h>], [PTRACE_GETREGS;])],
+       [gdbsrv_cv_have_ptrace_getregs=yes],
+       [gdbsrv_cv_have_ptrace_getregs=no]
+     )]
+  )
   AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
   if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
     AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
@@ -279,11 +275,14 @@ if test "${srv_linux_regsets}" = "yes"; then
   fi
 
   AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
-  AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
-  [AC_TRY_COMPILE([#include <sys/ptrace.h>],
-                 [PTRACE_GETFPXREGS;],
-                 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
-                 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
+  AC_CACHE_VAL(
+    [gdbsrv_cv_have_ptrace_getfpxregs],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([#include <sys/ptrace.h>], [PTRACE_GETFPXREGS;])],
+       [gdbsrv_cv_have_ptrace_getfpxregs=yes],
+       [gdbsrv_cv_have_ptrace_getfpxregs=no]
+     )]
+  )
   AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
   if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
     AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
@@ -325,15 +324,19 @@ if test "$srv_linux_thread_db" = "yes"; then
     # supported there.
     RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
     LDFLAGS="$LDFLAGS $RDYNAMIC"
-    AC_TRY_LINK([], [],
-               [found="-Wl,--dynamic-list"
-                RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
-               [RDYNAMIC="-rdynamic"
-                LDFLAGS="$old_LDFLAGS $RDYNAMIC"
-                AC_TRY_LINK([], [],
-                            [found="-rdynamic"],
-                            [found="no"
-                             RDYNAMIC=""])])
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([],[])],
+      [found="-Wl,--dynamic-list"
+       RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
+      [RDYNAMIC="-rdynamic"
+       LDFLAGS="$old_LDFLAGS $RDYNAMIC"
+       AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM([], [])],
+        [found="-rdynamic"],
+        [found="no"
+         RDYNAMIC=""]
+       )]
+    )
     AC_SUBST(RDYNAMIC)
     LDFLAGS="$old_LDFLAGS"
     AC_MSG_RESULT($found)
@@ -343,10 +346,15 @@ if test "$srv_linux_thread_db" = "yes"; then
 
   srv_thread_depfiles="thread-db.o proc-service.o"
   AC_DEFINE(USE_THREAD_DB, 1, [Define if we should use libthread_db.])
-  AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
-  [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
-                 [gdbsrv_cv_have_td_version=yes],
-                 [gdbsrv_cv_have_td_version=no])])
+  AC_CACHE_CHECK(
+    [for TD_VERSION],
+    [gdbsrv_cv_have_td_version],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([#include <thread_db.h>], [TD_VERSION;])],
+       [gdbsrv_cv_have_td_version=yes],
+       [gdbsrv_cv_have_td_version=no]
+     )]
+  )
   if test "$gdbsrv_cv_have_td_version" = yes; then
     AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
   fi
@@ -373,15 +381,23 @@ if test "$srv_xmlfiles" != ""; then
   done
 fi
 
-GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles $srv_selftest_objs"
+GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_thread_depfiles"
 GDBSERVER_LIBS="$srv_libs"
 
 dnl Check whether the target supports __sync_*_compare_and_swap.
-AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
-               gdbsrv_cv_have_sync_builtins, [
-AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
-               gdbsrv_cv_have_sync_builtins=yes,
-               gdbsrv_cv_have_sync_builtins=no)])
+AC_CACHE_CHECK(
+  [whether the target supports __sync_*_compare_and_swap],
+  [gdbsrv_cv_have_sync_builtins],
+  [AC_LINK_IFELSE(
+     [AC_LANG_PROGRAM(
+       [],
+       [int foo, bar;
+        bar = __sync_val_compare_and_swap(&foo, 0, 1);]
+      )],
+     [gdbsrv_cv_have_sync_builtins=yes],
+     [gdbsrv_cv_have_sync_builtins=no]
+   )]
+)
 if test "$gdbsrv_cv_have_sync_builtins" = yes; then
   AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
     [Define to 1 if the target supports __sync_*_compare_and_swap])
@@ -432,7 +448,7 @@ AC_SUBST(srv_xmlfiles)
 AC_SUBST(IPA_DEPFILES)
 AC_SUBST(extra_libraries)
 
-GNULIB=build-gnulib-gdbserver/import
+GNULIB=../gnulib/import
 
 GNULIB_STDINT_H=
 if test x"$STDINT_H" != x; then
@@ -440,6 +456,22 @@ if test x"$STDINT_H" != x; then
 fi
 AC_SUBST(GNULIB_STDINT_H)
 
+# Check for libiconv.  It is a requirement for Linux hosts, and others hosts
+# don't use it at all.  Define MAYBE_LIBICONV only if the host is Linux.
+AM_ICONV
+MAYBE_LIBICONV=
+case "$host" in
+  *linux*)
+    if test "$am_cv_func_iconv" != yes; then
+      AC_MSG_ERROR([could not find libiconv (required for host $host)])
+    fi
+
+    MAYBE_LIBICONV="$LIBICONV"
+    ;;
+esac
+
+AC_SUBST(MAYBE_LIBICONV)
+
 AC_CONFIG_FILES([Makefile])
 
 AC_OUTPUT