configure.ac 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # Configure script for gotools.
  2. # Copyright (C) 2015-2016 Free Software Foundation, Inc.
  3. #
  4. # This file is free software; you can redistribute it and/or modify it
  5. # under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but
  10. # WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. # General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; see the file COPYING3. If not see
  16. # <http://www.gnu.org/licenses/>.
  17. AC_INIT(package-unused, version-unused,, gotools)
  18. AC_CONFIG_SRCDIR(Makefile.am)
  19. # Determine the noncanonical names used for directories.
  20. ACX_NONCANONICAL_BUILD
  21. ACX_NONCANONICAL_HOST
  22. ACX_NONCANONICAL_TARGET
  23. dnl Autoconf 2.5x and later will set a default program prefix if
  24. dnl --target was used, even if it was the same as --host. Disable
  25. dnl that behavior. This must be done before AC_CANONICAL_SYSTEM
  26. dnl to take effect.
  27. test "$host_noncanonical" = "$target_noncanonical" &&
  28. test "$program_prefix$program_suffix$program_transform_name" = \
  29. NONENONEs,x,x, &&
  30. program_transform_name=s,y,y,
  31. AC_CANONICAL_SYSTEM
  32. AC_ARG_PROGRAM
  33. AM_INIT_AUTOMAKE([1.9.3 no-define foreign no-dist -Wall -Wno-portability])
  34. AM_MAINTAINER_MODE
  35. AC_PROG_INSTALL
  36. AC_PROG_CC
  37. AC_PROG_GO
  38. # These should be defined by the top-level configure.
  39. # Copy them into Makefile.
  40. AC_SUBST(GOC_FOR_TARGET)
  41. AC_SUBST(GCC_FOR_TARGET)
  42. AM_CONDITIONAL(NATIVE, test "$host_alias" = "$target_alias")
  43. dnl Test for -lsocket and -lnsl. Copied from libjava/configure.ac.
  44. AC_CACHE_CHECK([for socket libraries], gotools_cv_lib_sockets,
  45. [gotools_cv_lib_sockets=
  46. gotools_check_both=no
  47. AC_CHECK_FUNC(connect, gotools_check_socket=no, gotools_check_socket=yes)
  48. if test "$gotools_check_socket" = "yes"; then
  49. unset ac_cv_func_connect
  50. AC_CHECK_LIB(socket, main, gotools_cv_lib_sockets="-lsocket",
  51. gotools_check_both=yes)
  52. fi
  53. if test "$gotools_check_both" = "yes"; then
  54. gotools_old_libs=$LIBS
  55. LIBS="$LIBS -lsocket -lnsl"
  56. unset ac_cv_func_accept
  57. AC_CHECK_FUNC(accept,
  58. [gotools_check_nsl=no
  59. gotools_cv_lib_sockets="-lsocket -lnsl"])
  60. unset ac_cv_func_accept
  61. LIBS=$gotools_old_libs
  62. fi
  63. unset ac_cv_func_gethostbyname
  64. gotools_old_libs="$LIBS"
  65. AC_CHECK_FUNC(gethostbyname, ,
  66. [AC_CHECK_LIB(nsl, main,
  67. [gotools_cv_lib_sockets="$gotools_cv_lib_sockets -lnsl"])])
  68. unset ac_cv_func_gethostbyname
  69. LIBS=$gotools_old_libs
  70. ])
  71. NET_LIBS="$gotools_cv_lib_sockets"
  72. AC_SUBST(NET_LIBS)
  73. dnl Test if -lrt is required for sched_yield and/or nanosleep.
  74. AC_SEARCH_LIBS([sched_yield], [rt])
  75. AC_SEARCH_LIBS([nanosleep], [rt])
  76. AC_CONFIG_FILES(Makefile)
  77. AC_OUTPUT