1# Configure script for gotools.
2#   Copyright 2015 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
18AC_INIT(package-unused, version-unused,, gotools)
19AC_PREREQ(2.64)
20AC_CONFIG_SRCDIR(Makefile.am)
21
22m4_include([config/go.m4])
23
24# Determine the noncanonical names used for directories.
25ACX_NONCANONICAL_BUILD
26ACX_NONCANONICAL_HOST
27ACX_NONCANONICAL_TARGET
28
29dnl Autoconf 2.5x and later will set a default program prefix if
30dnl --target was used, even if it was the same as --host.  Disable
31dnl that behavior.  This must be done before AC_CANONICAL_SYSTEM
32dnl to take effect.
33test "$host_noncanonical" = "$target_noncanonical" &&
34  test "$program_prefix$program_suffix$program_transform_name" = \
35    NONENONEs,x,x, &&
36  program_transform_name=s,y,y,
37
38AC_CANONICAL_SYSTEM
39AC_ARG_PROGRAM
40
41AM_INIT_AUTOMAKE([1.9.3 no-define foreign no-dist -Wall -Wno-portability])
42AM_MAINTAINER_MODE
43
44AC_PROG_INSTALL
45
46AC_PROG_CC
47AC_PROG_GO
48
49AM_CONDITIONAL(NATIVE, test "$cross_compiling" = no)
50
51dnl Test for -lsocket and -lnsl.  Copied from libjava/configure.ac.
52AC_CACHE_CHECK([for socket libraries], gotools_cv_lib_sockets,
53  [gotools_cv_lib_sockets=
54   gotools_check_both=no
55   AC_CHECK_FUNC(connect, gotools_check_socket=no, gotools_check_socket=yes)
56   if test "$gotools_check_socket" = "yes"; then
57     unset ac_cv_func_connect
58     AC_CHECK_LIB(socket, main, gotools_cv_lib_sockets="-lsocket",
59     		  gotools_check_both=yes)
60   fi
61   if test "$gotools_check_both" = "yes"; then
62     gotools_old_libs=$LIBS
63     LIBS="$LIBS -lsocket -lnsl"
64     unset ac_cv_func_accept
65     AC_CHECK_FUNC(accept,
66		   [gotools_check_nsl=no
67		    gotools_cv_lib_sockets="-lsocket -lnsl"])
68     unset ac_cv_func_accept
69     LIBS=$gotools_old_libs
70   fi
71   unset ac_cv_func_gethostbyname
72   gotools_old_libs="$LIBS"
73   AC_CHECK_FUNC(gethostbyname, ,
74		 [AC_CHECK_LIB(nsl, main,
75		 	[gotools_cv_lib_sockets="$gotools_cv_lib_sockets -lnsl"])])
76   unset ac_cv_func_gethostbyname
77   LIBS=$gotools_old_libs
78])
79NET_LIBS="$gotools_cv_lib_sockets"
80AC_SUBST(NET_LIBS)
81
82dnl Test if -lrt is required for sched_yield and/or nanosleep.
83AC_SEARCH_LIBS([sched_yield], [rt])
84AC_SEARCH_LIBS([nanosleep], [rt])
85
86AC_CONFIG_FILES(Makefile)
87
88AC_OUTPUT
89