configure.ac 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. dnl Autoconf configure script for GDB server.
  2. dnl Copyright (C) 2000-2022 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 3 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, see <http://www.gnu.org/licenses/>.
  18. dnl Process this file with autoconf to produce a configure script.
  19. AC_INIT
  20. AC_CONFIG_MACRO_DIRS([../config])
  21. AC_CONFIG_SRCDIR([server.cc])
  22. AC_CONFIG_HEADERS(config.h:config.in, [echo > stamp-h])
  23. AM_MAINTAINER_MODE
  24. AC_PROG_CC
  25. AC_PROG_CXX
  26. AC_USE_SYSTEM_EXTENSIONS
  27. AC_SYS_LARGEFILE
  28. AM_PROG_INSTALL_STRIP
  29. # Set build, build_cpu, build_vendor and build_os.
  30. AC_CANONICAL_BUILD
  31. # Set host, host_cpu, host_vendor, and host_os.
  32. AC_CANONICAL_HOST
  33. # Set target, target_cpu, target_vendor, and target_os.
  34. AC_CANONICAL_TARGET
  35. AC_PROG_INSTALL
  36. AC_CHECK_TOOL(AR, ar)
  37. AC_PROG_RANLIB
  38. AC_ARG_PROGRAM
  39. # We require a C++11 compiler. Check if one is available, and if
  40. # necessary, set CXX_DIALECT to some -std=xxx switch.
  41. AX_CXX_COMPILE_STDCXX(11, , mandatory)
  42. AC_HEADER_STDC
  43. GDB_AC_COMMON
  44. # This is set by GDB_AC_COMMON.
  45. AC_SUBST(WIN32APILIBS)
  46. GDB_AC_SELFTEST
  47. ACX_NONCANONICAL_TARGET
  48. ACX_NONCANONICAL_HOST
  49. # Dependency checking.
  50. ZW_CREATE_DEPDIR
  51. dnl Set up for gettext.
  52. ZW_GNU_GETTEXT_SISTER_DIR
  53. # Create sub-directories for objects and dependencies.
  54. CONFIG_SRC_SUBDIR="arch gdbsupport nat target"
  55. AC_SUBST(CONFIG_SRC_SUBDIR)
  56. AC_CONFIG_COMMANDS([gdbdepdir],[
  57. for subdir in ${CONFIG_SRC_SUBDIR}
  58. do
  59. $SHELL $ac_aux_dir/mkinstalldirs $subdir/$DEPDIR
  60. done],
  61. [ac_aux_dir=$ac_aux_dir DEPDIR=$DEPDIR CONFIG_SRC_SUBDIR="$CONFIG_SRC_SUBDIR"])
  62. ZW_PROG_COMPILER_DEPENDENCIES([CC])
  63. AC_CHECK_HEADERS(termios.h sys/reg.h string.h dnl
  64. sys/procfs.h linux/elf.h dnl
  65. fcntl.h signal.h sys/file.h dnl
  66. sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
  67. netinet/tcp.h arpa/inet.h ws2tcpip.h)
  68. AC_FUNC_FORK
  69. AC_CHECK_FUNCS(pread pwrite pread64)
  70. # Check the return and argument types of ptrace.
  71. GDB_AC_PTRACE
  72. # Check for UST
  73. ustlibs=""
  74. ustinc=""
  75. AC_ARG_WITH(ust, [ --with-ust=PATH Specify prefix directory for the installed UST package
  76. Equivalent to --with-ust-include=PATH/include
  77. plus --with-ust-lib=PATH/lib])
  78. AC_ARG_WITH(ust_include, [ --with-ust-include=PATH Specify directory for installed UST include files])
  79. AC_ARG_WITH(ust_lib, [ --with-ust-lib=PATH Specify the directory for the installed UST library])
  80. case $with_ust in
  81. no)
  82. ustlibs=
  83. ustinc=
  84. ;;
  85. "" | yes)
  86. ustlibs=" -lust "
  87. ustinc=""
  88. ;;
  89. *)
  90. ustlibs="-L$with_ust/lib -lust"
  91. ustinc="-I$with_ust/include "
  92. ;;
  93. esac
  94. if test "x$with_ust_include" != x; then
  95. ustinc="-I$with_ust_include "
  96. fi
  97. if test "x$with_ust_lib" != x; then
  98. ustlibs="-L$with_ust_lib -lust"
  99. fi
  100. if test "x$with_ust" != "xno"; then
  101. saved_CFLAGS="$CFLAGS"
  102. CFLAGS="$CFLAGS $ustinc"
  103. AC_MSG_CHECKING([for ust])
  104. AC_COMPILE_IFELSE(
  105. [AC_LANG_PROGRAM(
  106. [
  107. #define CONFIG_UST_GDB_INTEGRATION
  108. #include <ust/ust.h>
  109. ],
  110. []
  111. )],
  112. [AC_MSG_RESULT([yes]);
  113. AC_DEFINE(HAVE_UST, 1, [Define if UST is available])],
  114. [AC_MSG_RESULT([no])
  115. ustlibs= ; ustinc= ]
  116. )
  117. CFLAGS="$saved_CFLAGS"
  118. fi
  119. # Flags needed for UST
  120. AC_SUBST(ustlibs)
  121. AC_SUBST(ustinc)
  122. AM_GDB_COMPILER_TYPE
  123. AM_GDB_WARNINGS
  124. dnl dladdr is glibc-specific. It is used by thread-db.c but only for
  125. dnl debugging messages. It lives in -ldl which is handled below so we don't
  126. dnl use AC_CHECK_LIB (or AC_SEARCH_LIBS) here. Instead we just temporarily
  127. dnl augment LIBS.
  128. old_LIBS="$LIBS"
  129. LIBS="$LIBS -ldl"
  130. AC_CHECK_FUNCS(dladdr)
  131. LIBS="$old_LIBS"
  132. libiberty_INIT
  133. AC_CHECK_DECLS([perror, vasprintf, vsnprintf])
  134. AC_CHECK_TYPES(socklen_t, [], [],
  135. [#include <sys/types.h>
  136. #if HAVE_SYS_SOCKET_H
  137. # include <sys/socket.h>
  138. #elif HAVE_WS2TCPIP_H
  139. # include <ws2tcpip.h>
  140. #endif
  141. ])
  142. case "${target}" in
  143. *-android*)
  144. # Starting with NDK version 9, <elf.h> actually includes definitions
  145. # of Elf32_auxv_t and Elf64_auxv_t. But sadly, <elf.h> includes
  146. # <sys/exec_elf.h> which defines some of the ELF types incorrectly,
  147. # leading to conflicts with the defintions from <linux/elf.h>.
  148. # This makes it impossible for us to include both <elf.h> and
  149. # <linux/elf.h>, which means that, in practice, we do not have
  150. # access to Elf32_auxv_t and Elf64_auxv_t on this platform.
  151. # Therefore, do not try to auto-detect availability, as it would
  152. # get it wrong on this platform.
  153. ;;
  154. *)
  155. AC_CHECK_TYPES([Elf32_auxv_t, Elf64_auxv_t], [], [],
  156. #include <elf.h>
  157. )
  158. esac
  159. ACX_PKGVERSION([GDB])
  160. ACX_BUGURL([http://www.gnu.org/software/gdb/bugs/])
  161. AC_DEFINE_UNQUOTED([PKGVERSION], ["$PKGVERSION"], [Additional package description])
  162. AC_DEFINE_UNQUOTED([REPORT_BUGS_TO], ["$REPORT_BUGS_TO"], [Bug reporting address])
  163. # Check for various supplementary target information (beyond the
  164. # triplet) which might affect the choices in configure.srv.
  165. case "${target}" in
  166. changequote(,)dnl
  167. i[34567]86-*-linux*)
  168. changequote([,])dnl
  169. AC_CACHE_CHECK([if building for x86-64], [gdb_cv_i386_is_x86_64],
  170. [save_CPPFLAGS="$CPPFLAGS"
  171. CPPFLAGS="$CPPFLAGS $CFLAGS"
  172. AC_EGREP_CPP([got it], [
  173. #if __x86_64__
  174. got it
  175. #endif
  176. ], [gdb_cv_i386_is_x86_64=yes],
  177. [gdb_cv_i386_is_x86_64=no])
  178. CPPFLAGS="$save_CPPFLAGS"])
  179. ;;
  180. x86_64-*-linux*)
  181. AC_CACHE_CHECK([if building for x32], [gdb_cv_x86_is_x32],
  182. [save_CPPFLAGS="$CPPFLAGS"
  183. CPPFLAGS="$CPPFLAGS $CFLAGS"
  184. AC_EGREP_CPP([got it], [
  185. #if __x86_64__ && __ILP32__
  186. got it
  187. #endif
  188. ], [gdb_cv_x86_is_x32=yes],
  189. [gdb_cv_x86_is_x32=no])
  190. CPPFLAGS="$save_CPPFLAGS"])
  191. ;;
  192. m68k-*-*)
  193. AC_CACHE_CHECK([if building for Coldfire], [gdb_cv_m68k_is_coldfire],
  194. [save_CPPFLAGS="$CPPFLAGS"
  195. CPPFLAGS="$CPPFLAGS $CFLAGS"
  196. AC_EGREP_CPP([got it], [
  197. #ifdef __mcoldfire__
  198. got it
  199. #endif
  200. ], [gdb_cv_m68k_is_coldfire=yes],
  201. [gdb_cv_m68k_is_coldfire=no])
  202. CPPFLAGS="$save_CPPFLAGS"])
  203. ;;
  204. esac
  205. . ${srcdir}/configure.srv
  206. if test "${srv_mingwce}" = "yes"; then
  207. LIBS="$LIBS -lws2"
  208. elif test "${srv_mingw}" = "yes"; then
  209. # WIN32APILIBS is set by GDB_AC_COMMON.
  210. LIBS="$LIBS $WIN32APILIBS"
  211. fi
  212. if test "${srv_linux_usrregs}" = "yes"; then
  213. AC_DEFINE(HAVE_LINUX_USRREGS, 1,
  214. [Define if the target supports PTRACE_PEEKUSR for register ]
  215. [access.])
  216. fi
  217. if test "${srv_linux_regsets}" = "yes"; then
  218. AC_DEFINE(HAVE_LINUX_REGSETS, 1,
  219. [Define if the target supports register sets.])
  220. AC_MSG_CHECKING(for PTRACE_GETREGS)
  221. AC_CACHE_VAL(
  222. [gdbsrv_cv_have_ptrace_getregs],
  223. [AC_COMPILE_IFELSE(
  224. [AC_LANG_PROGRAM([#include <sys/ptrace.h>], [PTRACE_GETREGS;])],
  225. [gdbsrv_cv_have_ptrace_getregs=yes],
  226. [gdbsrv_cv_have_ptrace_getregs=no]
  227. )]
  228. )
  229. AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getregs)
  230. if test "${gdbsrv_cv_have_ptrace_getregs}" = "yes"; then
  231. AC_DEFINE(HAVE_PTRACE_GETREGS, 1,
  232. [Define if the target supports PTRACE_GETREGS for register ]
  233. [access.])
  234. fi
  235. AC_MSG_CHECKING(for PTRACE_GETFPXREGS)
  236. AC_CACHE_VAL(
  237. [gdbsrv_cv_have_ptrace_getfpxregs],
  238. [AC_COMPILE_IFELSE(
  239. [AC_LANG_PROGRAM([#include <sys/ptrace.h>], [PTRACE_GETFPXREGS;])],
  240. [gdbsrv_cv_have_ptrace_getfpxregs=yes],
  241. [gdbsrv_cv_have_ptrace_getfpxregs=no]
  242. )]
  243. )
  244. AC_MSG_RESULT($gdbsrv_cv_have_ptrace_getfpxregs)
  245. if test "${gdbsrv_cv_have_ptrace_getfpxregs}" = "yes"; then
  246. AC_DEFINE(HAVE_PTRACE_GETFPXREGS, 1,
  247. [Define if the target supports PTRACE_GETFPXREGS for extended ]
  248. [register access.])
  249. fi
  250. fi
  251. if test "${srv_linux_btrace}" = "yes"; then
  252. AC_DEFINE(HAVE_LINUX_BTRACE, 1,
  253. [Define if the target supports branch tracing.])
  254. fi
  255. dnl Some systems (e.g., Android) have lwpid_t defined in libthread_db.h.
  256. if test "$bfd_cv_have_sys_procfs_type_lwpid_t" != yes; then
  257. GDBSERVER_HAVE_THREAD_DB_TYPE(lwpid_t)
  258. fi
  259. dnl Some systems (e.g., Android) have psaddr_t defined in libthread_db.h.
  260. if test "$bfd_cv_have_sys_procfs_type_psaddr_t" != yes; then
  261. GDBSERVER_HAVE_THREAD_DB_TYPE(psaddr_t)
  262. fi
  263. dnl Check for libdl, but do not add it to LIBS as only gdbserver
  264. dnl needs it (and gdbreplay doesn't).
  265. old_LIBS="$LIBS"
  266. AC_CHECK_LIB(dl, dlopen)
  267. LIBS="$old_LIBS"
  268. srv_thread_depfiles=
  269. srv_libs=
  270. if test "$srv_linux_thread_db" = "yes"; then
  271. if test "$ac_cv_lib_dl_dlopen" = "yes"; then
  272. srv_libs="-ldl"
  273. AC_MSG_CHECKING(for the dynamic export flag)
  274. old_LDFLAGS="$LDFLAGS"
  275. # Older GNU ld supports --export-dynamic but --dynamic-list may not be
  276. # supported there.
  277. RDYNAMIC="-Wl,--dynamic-list=${srcdir}/proc-service.list"
  278. LDFLAGS="$LDFLAGS $RDYNAMIC"
  279. AC_LINK_IFELSE(
  280. [AC_LANG_PROGRAM([],[])],
  281. [found="-Wl,--dynamic-list"
  282. RDYNAMIC='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
  283. [RDYNAMIC="-rdynamic"
  284. LDFLAGS="$old_LDFLAGS $RDYNAMIC"
  285. AC_LINK_IFELSE(
  286. [AC_LANG_PROGRAM([], [])],
  287. [found="-rdynamic"],
  288. [found="no"
  289. RDYNAMIC=""]
  290. )]
  291. )
  292. AC_SUBST(RDYNAMIC)
  293. LDFLAGS="$old_LDFLAGS"
  294. AC_MSG_RESULT($found)
  295. else
  296. srv_libs="-lthread_db"
  297. fi
  298. srv_thread_depfiles="thread-db.o proc-service.o"
  299. AC_DEFINE(USE_THREAD_DB, 1, [Define if we should use libthread_db.])
  300. AC_CACHE_CHECK(
  301. [for TD_VERSION],
  302. [gdbsrv_cv_have_td_version],
  303. [AC_COMPILE_IFELSE(
  304. [AC_LANG_PROGRAM([#include <thread_db.h>], [TD_VERSION;])],
  305. [gdbsrv_cv_have_td_version=yes],
  306. [gdbsrv_cv_have_td_version=no]
  307. )]
  308. )
  309. if test "$gdbsrv_cv_have_td_version" = yes; then
  310. AC_DEFINE(HAVE_TD_VERSION, 1, [Define if TD_VERSION is available.])
  311. fi
  312. fi
  313. AC_ARG_WITH(libthread-db,
  314. AS_HELP_STRING([--with-libthread-db=PATH], [use given libthread_db directly]),
  315. [srv_libthread_db_path="${withval}"
  316. srv_libs="$srv_libthread_db_path"
  317. ])
  318. if test "$srv_libs" != "" -a "$srv_libs" != "-ldl"; then
  319. AC_DEFINE(USE_LIBTHREAD_DB_DIRECTLY, 1, [Define if we should use libthread_db directly.])
  320. fi
  321. if test "$srv_xmlfiles" != ""; then
  322. srv_xmlbuiltin="xml-builtin.o"
  323. AC_DEFINE(USE_XML, 1, [Define if an XML target description is available.])
  324. tmp_xmlfiles=$srv_xmlfiles
  325. srv_xmlfiles=""
  326. for f in $tmp_xmlfiles; do
  327. srv_xmlfiles="$srv_xmlfiles \$(XML_DIR)/$f"
  328. done
  329. fi
  330. GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_thread_depfiles"
  331. GDBSERVER_LIBS="$srv_libs"
  332. dnl Check whether the target supports __sync_*_compare_and_swap.
  333. AC_CACHE_CHECK(
  334. [whether the target supports __sync_*_compare_and_swap],
  335. [gdbsrv_cv_have_sync_builtins],
  336. [AC_LINK_IFELSE(
  337. [AC_LANG_PROGRAM(
  338. [],
  339. [int foo, bar;
  340. bar = __sync_val_compare_and_swap(&foo, 0, 1);]
  341. )],
  342. [gdbsrv_cv_have_sync_builtins=yes],
  343. [gdbsrv_cv_have_sync_builtins=no]
  344. )]
  345. )
  346. if test "$gdbsrv_cv_have_sync_builtins" = yes; then
  347. AC_DEFINE(HAVE_SYNC_BUILTINS, 1,
  348. [Define to 1 if the target supports __sync_*_compare_and_swap])
  349. fi
  350. dnl Check for -fvisibility=hidden support in the compiler.
  351. saved_cflags="$CFLAGS"
  352. CFLAGS="$CFLAGS -fvisibility=hidden"
  353. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
  354. [gdbsrv_cv_have_visibility_hidden=yes],
  355. [gdbsrv_cv_have_visibility_hidden=no])
  356. CFLAGS="$saved_cflags"
  357. IPA_DEPFILES=""
  358. extra_libraries=""
  359. # check whether to enable the inprocess agent
  360. if test "$ipa_obj" != "" \
  361. -a "$gdbsrv_cv_have_sync_builtins" = yes \
  362. -a "$gdbsrv_cv_have_visibility_hidden" = yes; then
  363. have_ipa=true
  364. else
  365. have_ipa=false
  366. fi
  367. AC_ARG_ENABLE(inprocess-agent,
  368. AS_HELP_STRING([--enable-inprocess-agent], [inprocess agent]),
  369. [case "$enableval" in
  370. yes) want_ipa=true ;;
  371. no) want_ipa=false ;;
  372. *) AC_MSG_ERROR([bad value $enableval for inprocess-agent]) ;;
  373. esac],
  374. [want_ipa=$have_ipa])
  375. if $want_ipa ; then
  376. if $have_ipa ; then
  377. IPA_DEPFILES="$ipa_obj"
  378. extra_libraries="$extra_libraries libinproctrace.so"
  379. else
  380. AC_MSG_ERROR([inprocess agent not supported for this target])
  381. fi
  382. fi
  383. AC_SUBST(GDBSERVER_DEPFILES)
  384. AC_SUBST(GDBSERVER_LIBS)
  385. AC_SUBST(srv_xmlbuiltin)
  386. AC_SUBST(srv_xmlfiles)
  387. AC_SUBST(IPA_DEPFILES)
  388. AC_SUBST(extra_libraries)
  389. GNULIB=../gnulib/import
  390. GNULIB_STDINT_H=
  391. if test x"$STDINT_H" != x; then
  392. GNULIB_STDINT_H=$GNULIB/$STDINT_H
  393. fi
  394. AC_SUBST(GNULIB_STDINT_H)
  395. AC_CONFIG_FILES([Makefile])
  396. AC_OUTPUT