2009-11-17 Nathan Sidwell <nathan@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / gdbserver / configure.ac
1 dnl Autoconf configure script for GDB server.
2 dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008
3 dnl Free Software Foundation, Inc.
4 dnl
5 dnl This file is part of GDB.
6 dnl
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 3 of the License, or
10 dnl (at your option) any later version.
11 dnl
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 dnl GNU General Public License for more details.
16 dnl
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
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 AC_CONFIG_LIBOBJ_DIR(../gnulib)
27
28 AC_PROG_CC
29 AC_GNU_SOURCE
30
31 AC_CANONICAL_SYSTEM
32
33 AC_PROG_INSTALL
34
35 AC_ARG_PROGRAM
36
37 AC_HEADER_STDC
38
39 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
40 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
41 stdlib.h unistd.h dnl
42 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
43 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
44 netinet/tcp.h arpa/inet.h sys/wait.h)
45 AC_CHECK_FUNCS(pread pwrite pread64)
46 AC_REPLACE_FUNCS(memmem)
47
48 have_errno=no
49 AC_MSG_CHECKING(for errno)
50 AC_TRY_LINK([
51 #if HAVE_ERRNO_H
52 #include <errno.h>
53 #endif], [static int x; x = errno;],
54 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
55 if test $have_errno = no; then
56 AC_TRY_LINK([
57 #if HAVE_ERRNO_H
58 #include <errno.h>
59 #endif], [extern int errno; static int x; x = errno;],
60 [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) AC_DEFINE(MUST_DEFINE_ERRNO, 1, [Checking if errno must be defined])],
61 [AC_MSG_RESULT(no)])
62 fi
63
64 AC_CHECK_DECLS([strerror, perror, memmem])
65
66 AC_CHECK_TYPES(socklen_t, [], [],
67 [#include <sys/types.h>
68 #include <sys/socket.h>
69 ])
70
71 ACX_PKGVERSION([GDB])
72 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
73 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
74 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
75
76 # Check for various supplementary target information (beyond the
77 # triplet) which might affect the choices in configure.srv.
78 case "${target}" in
79 changequote(,)dnl
80 i[34567]86-*-linux*)
81 changequote([,])dnl
82 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
83 [save_CPPFLAGS="$CPPFLAGS"
84 CPPFLAGS="$CPPFLAGS $CFLAGS"
85 AC_EGREP_CPP([got it], [
86 #if __x86_64__
87 got it
88 #endif
89 ], [gdb_cv_i386_is_x86_64=yes],
90 [gdb_cv_i386_is_x86_64=no])
91 CPPFLAGS="$save_CPPFLAGS"])
92 ;;
93 m68k-*-*)
94 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
95 [save_CPPFLAGS="$CPPFLAGS"
96 CPPFLAGS="$CPPFLAGS $CFLAGS"
97 AC_EGREP_CPP([got it], [
98 #ifdef __mcoldfire__
99 got it
100 #endif
101 ], [gdb_cv_m68k_is_coldfire=yes],
102 [gdb_cv_m68k_is_coldfire=no])
103 CPPFLAGS="$save_CPPFLAGS"])
104 ;;
105 esac
106
107 . ${srcdir}/configure.srv
108
109 if test "${srv_mingwce}" = "yes"; then
110 LIBS="$LIBS -lws2"
111 elif test "${srv_mingw}" = "yes"; then
112 LIBS="$LIBS -lwsock32"
113 elif test "${srv_qnx}" = "yes"; then
114 LIBS="$LIBS -lsocket"
115 fi
116
117 if test "${srv_mingw}" = "yes"; then
118 AC_DEFINE(USE_WIN32API, 1,
119 [Define if we should use the Windows API, instead of the
120 POSIX API. On Windows, we use the Windows API when
121 building for MinGW, but the POSIX API when building
122 for Cygwin.])
123 fi
124
125 if test "${srv_linux_usrregs}" = "yes"; then
126 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
127 [Define if the target supports PTRACE_PEEKUSR for register ]
128 [access.])
129 fi
130
131 if test "${srv_linux_regsets}" = "yes"; then
132 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
133 [Define if the target supports register sets.])
134
135 AC_MSG_CHECKING(for PTRACE_GETREGS)
136 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
137 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
138 [PTRACE_GETREGS;],
139 [gdbsrv_cv_have_ptrace_getregs=yes],
140 [gdbsrv_cv_have_ptrace_getregs=no])])
141 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
142 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
143 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
144 [Define if the target supports PTRACE_GETREGS for register ]
145 [access.])
146 fi
147
148 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
149 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
150 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
151 [PTRACE_GETFPXREGS;],
152 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
153 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
154 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
155 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
156 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
157 [Define if the target supports PTRACE_GETFPXREGS for extended ]
158 [register access.])
159 fi
160 fi
161
162 if test "$ac_cv_header_sys_procfs_h" = yes; then
163 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
164 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
165 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
166 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
167 fi
168
169 srv_thread_depfiles=
170 srv_libs=
171 USE_THREAD_DB=
172
173 if test "$srv_linux_thread_db" = "yes"; then
174 srv_libs="-ldl"
175 old_LDFLAGS="$LDFLAGS"
176 LDFLAGS="$LDFLAGS -rdynamic"
177 AC_TRY_LINK([], [], [RDYNAMIC=-rdynamic], [RDYNAMIC=])
178 AC_SUBST(RDYNAMIC)
179 LDFLAGS="$old_LDFLAGS"
180
181 srv_thread_depfiles="thread-db.o proc-service.o"
182 USE_THREAD_DB="-DUSE_THREAD_DB"
183 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
184 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
185 [gdbsrv_cv_have_td_version=yes],
186 [gdbsrv_cv_have_td_version=no])])
187 if test $gdbsrv_cv_have_td_version = yes; then
188 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
189 fi
190 fi
191
192 AC_ARG_WITH(libthread-db,
193 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
194 [srv_libthread_db_path="${withval}"
195 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
196 srv_libs="$srv_libthread_db_path"
197 ])
198
199 if test "$srv_xmlfiles" != ""; then
200 srv_xmlbuiltin="xml-builtin.o"
201 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
202
203 tmp_xmlfiles=$srv_xmlfiles
204 srv_xmlfiles=""
205 for f in $tmp_xmlfiles; do
206 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
207 done
208 fi
209
210 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
211 GDBSERVER_LIBS="$srv_libs"
212
213 AC_SUBST(GDBSERVER_DEPFILES)
214 AC_SUBST(GDBSERVER_LIBS)
215 AC_SUBST(USE_THREAD_DB)
216 AC_SUBST(srv_xmlbuiltin)
217 AC_SUBST(srv_xmlfiles)
218
219 AC_OUTPUT(Makefile,
220 [case x$CONFIG_HEADERS in
221 xconfig.h:config.in)
222 echo > stamp-h ;;
223 esac
224 ])
This page took 0.050106 seconds and 4 git commands to generate.