Commit | Line | Data |
---|---|---|
d6e9fb05 | 1 | dnl Autoconf configure script for GDB server. |
abd775ce JB |
2 | dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
3 | dnl 2010 Free Software Foundation, Inc. | |
d6e9fb05 JK |
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 | |
5a0e3bd0 | 9 | dnl the Free Software Foundation; either version 3 of the License, or |
d6e9fb05 JK |
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 | |
5a0e3bd0 | 18 | dnl along with this program. If not, see <http://www.gnu.org/licenses/>. |
d6e9fb05 JK |
19 | |
20 | dnl Process this file with autoconf to produce a configure script. | |
21 | ||
bec39cab AC |
22 | AC_PREREQ(2.59)dnl |
23 | ||
d6e9fb05 | 24 | AC_INIT(server.c) |
84563040 | 25 | AC_CONFIG_HEADER(config.h:config.in) |
e28b3332 | 26 | AC_CONFIG_LIBOBJ_DIR(../gnulib) |
84563040 DJ |
27 | |
28 | AC_PROG_CC | |
fd462a61 | 29 | AC_GNU_SOURCE |
d6e9fb05 JK |
30 | |
31 | AC_CANONICAL_SYSTEM | |
84563040 | 32 | |
d6e9fb05 | 33 | AC_PROG_INSTALL |
c906108c | 34 | |
dcdb98d2 DJ |
35 | AC_ARG_PROGRAM |
36 | ||
ee6e2b82 | 37 | AC_HEADER_STDC |
84563040 | 38 | |
0d62e5e8 | 39 | AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl |
94e10508 | 40 | proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl |
b80864fb | 41 | stdlib.h unistd.h dnl |
1b3f6016 | 42 | errno.h fcntl.h signal.h sys/file.h malloc.h dnl |
61ff6e04 | 43 | sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl |
b80864fb | 44 | netinet/tcp.h arpa/inet.h sys/wait.h) |
4e799345 | 45 | AC_CHECK_FUNCS(pread pwrite pread64) |
e28b3332 | 46 | AC_REPLACE_FUNCS(memmem) |
84563040 | 47 | |
10e86dd7 DE |
48 | dnl dladdr is glibc-specific. It is used by thread-db.c but only for |
49 | dnl debugging messages. It lives in -ldl which is handled below so we don't | |
50 | dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily | |
51 | dnl augment LIBS. | |
52 | old_LIBS="$LIBS" | |
53 | LIBS="$LIBS -ldl" | |
54 | AC_CHECK_FUNCS(dladdr) | |
55 | LIBS="$old_LIBS" | |
56 | ||
68070c10 PA |
57 | have_errno=no |
58 | AC_MSG_CHECKING(for errno) | |
59 | AC_TRY_LINK([ | |
60 | #if HAVE_ERRNO_H | |
61 | #include <errno.h> | |
62 | #endif], [static int x; x = errno;], | |
63 | [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes]) | |
64 | if test $have_errno = no; then | |
65 | AC_TRY_LINK([ | |
66 | #if HAVE_ERRNO_H | |
67 | #include <errno.h> | |
68 | #endif], [extern int errno; static int x; x = errno;], | |
69 | [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])], | |
70 | [AC_MSG_RESULT(no)]) | |
71 | fi | |
72 | ||
ec56be1b | 73 | AC_CHECK_DECLS([strerror, perror, memmem]) |
43d5792c | 74 | |
ccbd4912 MK |
75 | AC_CHECK_TYPES(socklen_t, [], [], |
76 | [#include <sys/types.h> | |
77 | #include <sys/socket.h> | |
78 | ]) | |
fb1e4ffc | 79 | |
c16158bc JM |
80 | ACX_PKGVERSION([GDB]) |
81 | ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/]) | |
82 | AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description]) | |
83 | AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address]) | |
84 | ||
8838b45e NS |
85 | # Check for various supplementary target information (beyond the |
86 | # triplet) which might affect the choices in configure.srv. | |
87 | case "${target}" in | |
88 | changequote(,)dnl | |
89 | i[34567]86-*-linux*) | |
90 | changequote([,])dnl | |
91 | AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64], | |
92 | [save_CPPFLAGS="$CPPFLAGS" | |
93 | CPPFLAGS="$CPPFLAGS $CFLAGS" | |
94 | AC_EGREP_CPP([got it], [ | |
95 | #if __x86_64__ | |
96 | got it | |
97 | #endif | |
98 | ], [gdb_cv_i386_is_x86_64=yes], | |
99 | [gdb_cv_i386_is_x86_64=no]) | |
100 | CPPFLAGS="$save_CPPFLAGS"]) | |
101 | ;; | |
9ac544ce MK |
102 | m68k-*-*) |
103 | AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire], | |
104 | [save_CPPFLAGS="$CPPFLAGS" | |
105 | CPPFLAGS="$CPPFLAGS $CFLAGS" | |
106 | AC_EGREP_CPP([got it], [ | |
107 | #ifdef __mcoldfire__ | |
108 | got it | |
109 | #endif | |
110 | ], [gdb_cv_m68k_is_coldfire=yes], | |
111 | [gdb_cv_m68k_is_coldfire=no]) | |
112 | CPPFLAGS="$save_CPPFLAGS"]) | |
113 | ;; | |
8838b45e NS |
114 | esac |
115 | ||
7ea81414 | 116 | . ${srcdir}/configure.srv |
c906108c | 117 | |
68070c10 PA |
118 | if test "${srv_mingwce}" = "yes"; then |
119 | LIBS="$LIBS -lws2" | |
120 | elif test "${srv_mingw}" = "yes"; then | |
12ea4b69 | 121 | LIBS="$LIBS -lws2_32" |
ac8c974e AR |
122 | elif test "${srv_qnx}" = "yes"; then |
123 | LIBS="$LIBS -lsocket" | |
68070c10 PA |
124 | fi |
125 | ||
126 | if test "${srv_mingw}" = "yes"; then | |
b80864fb DJ |
127 | AC_DEFINE(USE_WIN32API, 1, |
128 | [Define if we should use the Windows API, instead of the | |
129 | POSIX API. On Windows, we use the Windows API when | |
130 | building for MinGW, but the POSIX API when building | |
131 | for Cygwin.]) | |
132 | fi | |
133 | ||
58caa3dc | 134 | if test "${srv_linux_usrregs}" = "yes"; then |
f450004a DJ |
135 | AC_DEFINE(HAVE_LINUX_USRREGS, 1, |
136 | [Define if the target supports PTRACE_PEEKUSR for register ] | |
137 | [access.]) | |
58caa3dc DJ |
138 | fi |
139 | ||
140 | if test "${srv_linux_regsets}" = "yes"; then | |
e9d25b98 DJ |
141 | AC_DEFINE(HAVE_LINUX_REGSETS, 1, |
142 | [Define if the target supports register sets.]) | |
143 | ||
58caa3dc DJ |
144 | AC_MSG_CHECKING(for PTRACE_GETREGS) |
145 | AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs, | |
146 | [AC_TRY_COMPILE([#include <sys/ptrace.h>], | |
147 | [PTRACE_GETREGS;], | |
148 | [gdbsrv_cv_have_ptrace_getregs=yes], | |
149 | [gdbsrv_cv_have_ptrace_getregs=no])]) | |
150 | AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs) | |
151 | if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then | |
e9d25b98 | 152 | AC_DEFINE(HAVE_PTRACE_GETREGS, 1, |
f450004a DJ |
153 | [Define if the target supports PTRACE_GETREGS for register ] |
154 | [access.]) | |
58caa3dc DJ |
155 | fi |
156 | ||
157 | AC_MSG_CHECKING(for PTRACE_GETFPXREGS) | |
158 | AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs, | |
159 | [AC_TRY_COMPILE([#include <sys/ptrace.h>], | |
160 | [PTRACE_GETFPXREGS;], | |
161 | [gdbsrv_cv_have_ptrace_getfpxregs=yes], | |
162 | [gdbsrv_cv_have_ptrace_getfpxregs=no])]) | |
163 | AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs) | |
164 | if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then | |
f450004a DJ |
165 | AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1, |
166 | [Define if the target supports PTRACE_GETFPXREGS for extended ] | |
167 | [register access.]) | |
58caa3dc DJ |
168 | fi |
169 | fi | |
170 | ||
0d62e5e8 DJ |
171 | if test "$ac_cv_header_sys_procfs_h" = yes; then |
172 | BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t) | |
173 | BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t) | |
174 | BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t) | |
0d62e5e8 DJ |
175 | BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t) |
176 | fi | |
177 | ||
193f13e6 MK |
178 | dnl Check for libdl, but do not add it to LIBS as only gdbserver |
179 | dnl needs it (and gdbreplay doesn't). | |
180 | old_LIBS="$LIBS" | |
181 | AC_CHECK_LIB(dl, dlopen) | |
182 | LIBS="$old_LIBS" | |
183 | ||
0d62e5e8 DJ |
184 | srv_thread_depfiles= |
185 | srv_libs= | |
186 | USE_THREAD_DB= | |
187 | ||
188 | if test "$srv_linux_thread_db" = "yes"; then | |
193f13e6 MK |
189 | if test "$ac_cv_lib_dl_dlopen" = "yes"; then |
190 | srv_libs="-ldl" | |
f6528abd | 191 | AC_MSG_CHECKING(for the dynamic export flag) |
193f13e6 | 192 | old_LDFLAGS="$LDFLAGS" |
f6528abd JK |
193 | # Older GNU ld supports --export-dynamic but --dynamic-list may not be |
194 | # supported there. | |
195 | RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list" | |
196 | LDFLAGS="$LDFLAGS $RDYNAMIC" | |
197 | AC_TRY_LINK([], [], | |
198 | [found="-Wl,--dynamic-list" | |
199 | RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'], | |
200 | [RDYNAMIC="-rdynamic" | |
201 | LDFLAGS="$old_LDFLAGS $RDYNAMIC" | |
202 | AC_TRY_LINK([], [], | |
203 | [found="-rdynamic"], | |
204 | [found="no" | |
205 | RDYNAMIC=""])]) | |
193f13e6 MK |
206 | AC_SUBST(RDYNAMIC) |
207 | LDFLAGS="$old_LDFLAGS" | |
f6528abd | 208 | AC_MSG_RESULT($found) |
193f13e6 MK |
209 | else |
210 | srv_libs="-lthread_db" | |
211 | fi | |
0d62e5e8 | 212 | |
0d62e5e8 DJ |
213 | srv_thread_depfiles="thread-db.o proc-service.o" |
214 | USE_THREAD_DB="-DUSE_THREAD_DB" | |
3db0444b DJ |
215 | AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version, |
216 | [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;], | |
1b3f6016 PA |
217 | [gdbsrv_cv_have_td_version=yes], |
218 | [gdbsrv_cv_have_td_version=no])]) | |
3db0444b DJ |
219 | if test $gdbsrv_cv_have_td_version = yes; then |
220 | AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.]) | |
221 | fi | |
0d62e5e8 DJ |
222 | fi |
223 | ||
96f15937 PP |
224 | AC_ARG_WITH(libthread-db, |
225 | AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]), | |
226 | [srv_libthread_db_path="${withval}" | |
96f15937 PP |
227 | srv_libs="$srv_libthread_db_path" |
228 | ]) | |
229 | ||
193f13e6 MK |
230 | if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then |
231 | AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.]) | |
232 | fi | |
233 | ||
9b4b61c8 | 234 | if test "$srv_xmlfiles" != ""; then |
fb1e4ffc DJ |
235 | srv_xmlbuiltin="xml-builtin.o" |
236 | AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.]) | |
237 | ||
238 | tmp_xmlfiles=$srv_xmlfiles | |
9b4b61c8 | 239 | srv_xmlfiles="" |
fb1e4ffc DJ |
240 | for f in $tmp_xmlfiles; do |
241 | srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f" | |
242 | done | |
243 | fi | |
244 | ||
59a016f0 | 245 | GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles" |
0d62e5e8 | 246 | GDBSERVER_LIBS="$srv_libs" |
c906108c | 247 | |
fa593d66 PA |
248 | dnl Check whether the target supports __sync_*_compare_and_swap. |
249 | AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap], | |
250 | gdbsrv_cv_have_sync_builtins, [ | |
251 | AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);], | |
252 | gdbsrv_cv_have_sync_builtins=yes, | |
253 | gdbsrv_cv_have_sync_builtins=no)]) | |
254 | if test $gdbsrv_cv_have_sync_builtins = yes; then | |
255 | AC_DEFINE(HAVE_SYNC_BUILTINS, 1, | |
256 | [Define to 1 if the target supports __sync_*_compare_and_swap]) | |
257 | fi | |
258 | ||
259 | dnl Check for -fvisibility=hidden support in the compiler. | |
260 | saved_cflags="$CFLAGS" | |
261 | CFLAGS="$CFLAGS -fvisibility=hidden" | |
262 | AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]), | |
263 | [gdbsrv_cv_have_visibility_hidden=yes], | |
264 | [gdbsrv_cv_have_visibility_hidden=no]) | |
265 | CFLAGS="$saved_cflags" | |
266 | ||
267 | IPA_DEPFILES="" | |
268 | ||
269 | # Rather than allowing to build a broken IPA, we simply disable it if | |
270 | # we don't find a compiler supporting all the features we need. | |
271 | if test "$ipa_obj" != "" \ | |
272 | -a "$gdbsrv_cv_have_sync_builtins" = yes \ | |
273 | -a "$gdbsrv_cv_have_visibility_hidden" = yes; then | |
274 | IPA_DEPFILES="$ipa_obj" | |
275 | extra_libraries="libinproctrace.so" | |
276 | fi | |
277 | ||
7ea81414 | 278 | AC_SUBST(GDBSERVER_DEPFILES) |
0d62e5e8 DJ |
279 | AC_SUBST(GDBSERVER_LIBS) |
280 | AC_SUBST(USE_THREAD_DB) | |
fb1e4ffc DJ |
281 | AC_SUBST(srv_xmlbuiltin) |
282 | AC_SUBST(srv_xmlfiles) | |
fa593d66 PA |
283 | AC_SUBST(IPA_DEPFILES) |
284 | AC_SUBST(extra_libraries) | |
c906108c | 285 | |
c3a3ccc7 DJ |
286 | AC_OUTPUT(Makefile, |
287 | [case x$CONFIG_HEADERS in | |
288 | xconfig.h:config.in) | |
289 | echo > stamp-h ;; | |
290 | esac | |
291 | ]) |