2011-07-22 Kwok Cheung Yeung <kcy@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, 2009,
3 dnl 2010, 2011 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 AC_HEADER_DIRENT
39
40 AC_FUNC_ALLOCA
41 AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
42 proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl
43 stdlib.h unistd.h dnl
44 errno.h fcntl.h signal.h sys/file.h malloc.h dnl
45 sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
46 netinet/tcp.h arpa/inet.h sys/wait.h)
47 AC_CHECK_FUNCS(pread pwrite pread64)
48 AC_REPLACE_FUNCS(memmem vasprintf vsnprintf)
49
50 # Check for UST
51 ustlibs=""
52 ustinc=""
53
54 AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
55 Equivalent to --with-ust-include=PATH/include
56 plus --with-ust-lib=PATH/lib])
57 AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
58 AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
59
60 case $with_ust in
61 no)
62 ustlibs=
63 ustinc=
64 ;;
65 "" | yes)
66 ustlibs=" -lust "
67 ustinc=""
68 ;;
69 *)
70 ustlibs="-L$with_ust/lib -lust"
71 ustinc="-I$with_ust/include "
72 ;;
73 esac
74 if test "x$with_ust_include" != x; then
75 ustinc="-I$with_ust_include "
76 fi
77 if test "x$with_ust_lib" != x; then
78 ustlibs="-L$with_ust_lib -lust"
79 fi
80
81 if test "x$with_ust" != "xno"; then
82 saved_CFLAGS="$CFLAGS"
83 CFLAGS="$CFLAGS $ustinc"
84 AC_MSG_CHECKING([for ust])
85 AC_TRY_COMPILE([
86 #define CONFIG_UST_GDB_INTEGRATION
87 #include <ust/ust.h>
88 ],[],
89 [AC_MSG_RESULT([yes]); AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
90 [AC_MSG_RESULT([no]); ustlibs= ; ustinc= ])
91 CFLAGS="$saved_CFLAGS"
92 fi
93
94 # Flags needed for UST
95 AC_SUBST(ustlibs)
96 AC_SUBST(ustinc)
97
98 AC_ARG_ENABLE(werror,
99 AS_HELP_STRING([--enable-werror], [treat compile warnings as errors]),
100 [case "${enableval}" in
101 yes | y) ERROR_ON_WARNING="yes" ;;
102 no | n) ERROR_ON_WARNING="no" ;;
103 *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
104 esac])
105
106 # Enable -Werror by default when using gcc
107 if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
108 ERROR_ON_WARNING=yes
109 fi
110
111 WERROR_CFLAGS=""
112 if test "${ERROR_ON_WARNING}" = yes ; then
113 WERROR_CFLAGS="-Werror"
114 fi
115
116 build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
117 -Wformat-nonliteral -Wno-char-subscripts"
118
119 WARN_CFLAGS=""
120 if test "x$GCC" = xyes
121 then
122 AC_MSG_CHECKING(compiler warning flags)
123 # Separate out the -Werror flag as some files just cannot be
124 # compiled with it enabled.
125 for w in ${build_warnings}; do
126 case $w in
127 -Werr*) WERROR_CFLAGS=-Werror ;;
128 *) # Check that GCC accepts it
129 saved_CFLAGS="$CFLAGS"
130 CFLAGS="$CFLAGS $w"
131 AC_TRY_COMPILE([],[],WARN_CFLAGS="${WARN_CFLAGS} $w",)
132 CFLAGS="$saved_CFLAGS"
133 esac
134 done
135 AC_MSG_RESULT(${WARN_CFLAGS} ${WERROR_CFLAGS})
136 fi
137 AC_SUBST(WARN_CFLAGS)
138 AC_SUBST(WERROR_CFLAGS)
139
140 dnl dladdr is glibc-specific. It is used by thread-db.c but only for
141 dnl debugging messages. It lives in -ldl which is handled below so we don't
142 dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
143 dnl augment LIBS.
144 old_LIBS="$LIBS"
145 LIBS="$LIBS -ldl"
146 AC_CHECK_FUNCS(dladdr)
147 LIBS="$old_LIBS"
148
149 have_errno=no
150 AC_MSG_CHECKING(for errno)
151 AC_TRY_LINK([
152 #if HAVE_ERRNO_H
153 #include <errno.h>
154 #endif], [static int x; x = errno;],
155 [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO, 1, [Define if errno is available]) have_errno=yes])
156 if test $have_errno = no; then
157 AC_TRY_LINK([
158 #if HAVE_ERRNO_H
159 #include <errno.h>
160 #endif], [extern int errno; static int x; x = errno;],
161 [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])],
162 [AC_MSG_RESULT(no)])
163 fi
164
165 AC_CHECK_DECLS([strerror, perror, memmem, vasprintf, vsnprintf])
166
167 AC_CHECK_TYPES(socklen_t, [], [],
168 [#include <sys/types.h>
169 #include <sys/socket.h>
170 ])
171
172 ACX_PKGVERSION([GDB])
173 ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
174 AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
175 AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
176
177 # Check for various supplementary target information (beyond the
178 # triplet) which might affect the choices in configure.srv.
179 case "${target}" in
180 changequote(,)dnl
181 i[34567]86-*-linux*)
182 changequote([,])dnl
183 AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
184 [save_CPPFLAGS="$CPPFLAGS"
185 CPPFLAGS="$CPPFLAGS $CFLAGS"
186 AC_EGREP_CPP([got it], [
187 #if __x86_64__
188 got it
189 #endif
190 ], [gdb_cv_i386_is_x86_64=yes],
191 [gdb_cv_i386_is_x86_64=no])
192 CPPFLAGS="$save_CPPFLAGS"])
193 ;;
194 m68k-*-*)
195 AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
196 [save_CPPFLAGS="$CPPFLAGS"
197 CPPFLAGS="$CPPFLAGS $CFLAGS"
198 AC_EGREP_CPP([got it], [
199 #ifdef __mcoldfire__
200 got it
201 #endif
202 ], [gdb_cv_m68k_is_coldfire=yes],
203 [gdb_cv_m68k_is_coldfire=no])
204 CPPFLAGS="$save_CPPFLAGS"])
205 ;;
206 esac
207
208 . ${srcdir}/configure.srv
209
210 if test "${srv_mingwce}" = "yes"; then
211 LIBS="$LIBS -lws2"
212 elif test "${srv_mingw}" = "yes"; then
213 LIBS="$LIBS -lws2_32"
214 elif test "${srv_qnx}" = "yes"; then
215 LIBS="$LIBS -lsocket"
216 elif test "${srv_lynxos}" = "yes"; then
217 LIBS="$LIBS -lnetinet"
218 fi
219
220 if test "${srv_mingw}" = "yes"; then
221 AC_DEFINE(USE_WIN32API, 1,
222 [Define if we should use the Windows API, instead of the
223 POSIX API. On Windows, we use the Windows API when
224 building for MinGW, but the POSIX API when building
225 for Cygwin.])
226 fi
227
228 if test "${srv_linux_usrregs}" = "yes"; then
229 AC_DEFINE(HAVE_LINUX_USRREGS, 1,
230 [Define if the target supports PTRACE_PEEKUSR for register ]
231 [access.])
232 fi
233
234 if test "${srv_linux_regsets}" = "yes"; then
235 AC_DEFINE(HAVE_LINUX_REGSETS, 1,
236 [Define if the target supports register sets.])
237
238 AC_MSG_CHECKING(for PTRACE_GETREGS)
239 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getregs,
240 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
241 [PTRACE_GETREGS;],
242 [gdbsrv_cv_have_ptrace_getregs=yes],
243 [gdbsrv_cv_have_ptrace_getregs=no])])
244 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
245 if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
246 AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
247 [Define if the target supports PTRACE_GETREGS for register ]
248 [access.])
249 fi
250
251 AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
252 AC_CACHE_VAL(gdbsrv_cv_have_ptrace_getfpxregs,
253 [AC_TRY_COMPILE([#include <sys/ptrace.h>],
254 [PTRACE_GETFPXREGS;],
255 [gdbsrv_cv_have_ptrace_getfpxregs=yes],
256 [gdbsrv_cv_have_ptrace_getfpxregs=no])])
257 AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
258 if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
259 AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
260 [Define if the target supports PTRACE_GETFPXREGS for extended ]
261 [register access.])
262 fi
263 fi
264
265 if test "$ac_cv_header_sys_procfs_h" = yes; then
266 BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
267 BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
268 BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t)
269 BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
270 fi
271
272 dnl Check for libdl, but do not add it to LIBS as only gdbserver
273 dnl needs it (and gdbreplay doesn't).
274 old_LIBS="$LIBS"
275 AC_CHECK_LIB(dl, dlopen)
276 LIBS="$old_LIBS"
277
278 srv_thread_depfiles=
279 srv_libs=
280 USE_THREAD_DB=
281
282 if test "$srv_linux_thread_db" = "yes"; then
283 if test "$ac_cv_lib_dl_dlopen" = "yes"; then
284 srv_libs="-ldl"
285 AC_MSG_CHECKING(for the dynamic export flag)
286 old_LDFLAGS="$LDFLAGS"
287 # Older GNU ld supports --export-dynamic but --dynamic-list may not be
288 # supported there.
289 RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
290 LDFLAGS="$LDFLAGS $RDYNAMIC"
291 AC_TRY_LINK([], [],
292 [found="-Wl,--dynamic-list"
293 RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
294 [RDYNAMIC="-rdynamic"
295 LDFLAGS="$old_LDFLAGS $RDYNAMIC"
296 AC_TRY_LINK([], [],
297 [found="-rdynamic"],
298 [found="no"
299 RDYNAMIC=""])])
300 AC_SUBST(RDYNAMIC)
301 LDFLAGS="$old_LDFLAGS"
302 AC_MSG_RESULT($found)
303 else
304 srv_libs="-lthread_db"
305 fi
306
307 srv_thread_depfiles="thread-db.o proc-service.o"
308 USE_THREAD_DB="-DUSE_THREAD_DB"
309 AC_CACHE_CHECK([for TD_VERSION], gdbsrv_cv_have_td_version,
310 [AC_TRY_COMPILE([#include <thread_db.h>], [TD_VERSION;],
311 [gdbsrv_cv_have_td_version=yes],
312 [gdbsrv_cv_have_td_version=no])])
313 if test $gdbsrv_cv_have_td_version = yes; then
314 AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
315 fi
316 fi
317
318 AC_ARG_WITH(libthread-db,
319 AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
320 [srv_libthread_db_path="${withval}"
321 srv_libs="$srv_libthread_db_path"
322 ])
323
324 if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
325 AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
326 fi
327
328 if test "$srv_xmlfiles" != ""; then
329 srv_xmlbuiltin="xml-builtin.o"
330 AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
331
332 tmp_xmlfiles=$srv_xmlfiles
333 srv_xmlfiles=""
334 for f in $tmp_xmlfiles; do
335 srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
336 done
337 fi
338
339 GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles"
340 GDBSERVER_LIBS="$srv_libs"
341
342 dnl Check whether the target supports __sync_*_compare_and_swap.
343 AC_CACHE_CHECK([whether the target supports __sync_*_compare_and_swap],
344 gdbsrv_cv_have_sync_builtins, [
345 AC_TRY_LINK([], [int foo, bar; bar = __sync_val_compare_and_swap(&foo, 0, 1);],
346 gdbsrv_cv_have_sync_builtins=yes,
347 gdbsrv_cv_have_sync_builtins=no)])
348 if test $gdbsrv_cv_have_sync_builtins = yes; then
349 AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
350 [Define to 1 if the target supports __sync_*_compare_and_swap])
351 fi
352
353 dnl Check for -fvisibility=hidden support in the compiler.
354 saved_cflags="$CFLAGS"
355 CFLAGS="$CFLAGS -fvisibility=hidden"
356 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
357 [gdbsrv_cv_have_visibility_hidden=yes],
358 [gdbsrv_cv_have_visibility_hidden=no])
359 CFLAGS="$saved_cflags"
360
361
362 IPA_DEPFILES=""
363 extra_libraries=""
364
365 # check whether to enable the inprocess agent
366 if test "$ipa_obj" != "" \
367 -a "$gdbsrv_cv_have_sync_builtins" = yes \
368 -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
369 have_ipa=true
370 else
371 have_ipa=false
372 fi
373
374 AC_ARG_ENABLE(inprocess-agent,
375 AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
376 [case "$enableval" in
377 yes) want_ipa=true ;;
378 no) want_ipa=false ;;
379 *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
380 esac],
381 [want_ipa=$have_ipa])
382
383 if $want_ipa ; then
384 if $have_ipa ; then
385 IPA_DEPFILES="$ipa_obj"
386 extra_libraries="$extra_libraries libinproctrace.so"
387 else
388 AC_MSG_ERROR([inprocess agent not supported for this target])
389 fi
390 fi
391
392 AC_SUBST(GDBSERVER_DEPFILES)
393 AC_SUBST(GDBSERVER_LIBS)
394 AC_SUBST(USE_THREAD_DB)
395 AC_SUBST(srv_xmlbuiltin)
396 AC_SUBST(srv_xmlfiles)
397 AC_SUBST(IPA_DEPFILES)
398 AC_SUBST(extra_libraries)
399
400 AC_OUTPUT(Makefile,
401 [case x$CONFIG_HEADERS in
402 xconfig.h:config.in)
403 echo > stamp-h ;;
404 esac
405 ])
This page took 0.03894 seconds and 4 git commands to generate.