1dnl Autoconf configure script for GDB server.
2dnl Copyright 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
3dnl
4dnl This file is part of GDB.
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 2 of the License, or
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program; if not, write to the Free Software
18dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20dnl Process this file with autoconf to produce a configure script.
21
22AC_INIT(server.c)
23AC_CONFIG_HEADER(config.h:config.in)
24
25AC_PROG_CC
26
27AC_CANONICAL_SYSTEM
28
29AC_PROG_INSTALL
30
31AC_HEADER_STDC
32
33AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
34		 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
35		 stdlib.h unistd.h)
36
37BFD_NEED_DECLARATION(strerror)
38
39. ${srcdir}/configure.srv
40
41if test "${srv_linux_usrregs}" = "yes"; then
42  AC_DEFINE(HAVE_LINUX_USRREGS)
43fi
44
45if test "${srv_linux_regsets}" = "yes"; then
46  AC_MSG_CHECKING(for PTRACE_GETREGS)
47  AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
48  [AC_TRY_COMPILE([#include <sys/ptrace.h>],
49		  [PTRACE_GETREGS;],
50		  [gdbsrv_cv_have_ptrace_getregs=yes],
51		  [gdbsrv_cv_have_ptrace_getregs=no])])
52  AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
53  if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
54    AC_DEFINE(HAVE_LINUX_REGSETS)
55  fi
56
57  AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
58  AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
59  [AC_TRY_COMPILE([#include <sys/ptrace.h>],
60		  [PTRACE_GETFPXREGS;],
61		  [gdbsrv_cv_have_ptrace_getfpxregs=yes],
62		  [gdbsrv_cv_have_ptrace_getfpxregs=no])])
63  AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
64  if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
65    AC_DEFINE(HAVE_PTRACE_GETFPXREGS)
66  fi
67fi
68
69if test "$ac_cv_header_sys_procfs_h" = yes; then
70  BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
71  BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
72  BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
73  BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t)
74
75  dnl Check for broken prfpregset_t type
76
77  dnl For Linux/i386, glibc 2.1.3 was released with a bogus
78  dnl prfpregset_t type (it's a typedef for the pointer to a struct
79  dnl instead of the struct itself).  We detect this here, and work
80  dnl around it in gdb_proc_service.h.
81
82  if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then
83    AC_MSG_CHECKING(whether prfpregset_t type is broken)
84    AC_CACHE_VAL(gdb_cv_prfpregset_t_broken,
85      [AC_TRY_RUN([#include <sys/procfs.h>
86       int main ()
87       {
88         if (sizeof (prfpregset_t) == sizeof (void *))
89           return 1;
90         return 0;
91       }],
92       gdb_cv_prfpregset_t_broken=no,
93       gdb_cv_prfpregset_t_broken=yes,
94       gdb_cv_prfpregset_t_broken=yes)])
95    AC_MSG_RESULT($gdb_cv_prfpregset_t_broken)
96    if test $gdb_cv_prfpregset_t_broken = yes; then
97      AC_DEFINE(PRFPREGSET_T_BROKEN)
98    fi
99  fi
100
101  BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
102fi
103
104srv_thread_depfiles=
105srv_libs=
106USE_THREAD_DB=
107
108if test "$srv_linux_thread_db" = "yes"; then
109  SRV_CHECK_THREAD_DB
110  if test "$srv_cv_thread_db" = no; then
111    AC_WARN([Could not find libthread_db.])
112    AC_WARN([Disabling thread support in gdbserver.])
113    srv_linux_thread_db=no
114  else
115    srv_libs="$srv_cv_thread_db"
116  fi
117  old_LDFLAGS="$LDFLAGS"
118  LDFLAGS="$LDFLAGS -rdynamic"
119  AC_TRY_LINK([], [], [RDYNAMIC=-rdynamic], [RDYNAMIC=])
120  AC_SUBST(RDYNAMIC)
121  LDFLAGS="$old_LDFLAGS"
122fi
123
124if test "$srv_linux_thread_db" = "yes"; then
125  srv_thread_depfiles="thread-db.o proc-service.o"
126  USE_THREAD_DB="-DUSE_THREAD_DB"
127fi
128
129GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_thread_depfiles"
130GDBSERVER_LIBS="$srv_libs"
131
132AC_SUBST(GDBSERVER_DEPFILES)
133AC_SUBST(GDBSERVER_LIBS)
134AC_SUBST(USE_THREAD_DB)
135
136AC_OUTPUT(Makefile,
137[case x$CONFIG_HEADERS in
138xconfig.h:config.in)
139echo > stamp-h ;;
140esac
141])
142