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