configure.ac: Check for networking libraries; see NET_LIBS.

* configure.ac: Check for networking libraries; see NET_LIBS.
	* Makefile.am (go$(EXEEXT)): Link against NET_LIBS.
	(gofmt$(EXEEXT), cgo$(EXEEXT)): Likewise.
	* configure, Makefile.in: Rebuild.

From-SVN: r219690
This commit is contained in:
Ian Lance Taylor 2015-01-15 21:10:09 +00:00 committed by Ian Lance Taylor
parent 199b7a3586
commit 85d7b5d5c5
5 changed files with 277 additions and 6 deletions

View File

@ -1,3 +1,10 @@
2015-01-15 Ian Lance Taylor <iant@google.com>
* configure.ac: Check for networking libraries; see NET_LIBS.
* Makefile.am (go$(EXEEXT)): Link against NET_LIBS.
(gofmt$(EXEEXT), cgo$(EXEEXT)): Likewise.
* configure, Makefile.in: Rebuild.
2015-01-14 Ian Lance Taylor <iant@google.com>
* Makefile.am (go_cmd_go_files): Sort entries. Add generate.go.

View File

@ -108,11 +108,11 @@ bin_PROGRAMS = go$(EXEEXT) gofmt$(EXEEXT)
libexecsub_PROGRAMS = cgo$(EXEEXT)
go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
$(GOLINK) $(go_cmd_go_files) zdefaultcc.go
$(GOLINK) $(go_cmd_go_files) zdefaultcc.go $(NET_LIBS)
gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
$(GOLINK) $(go_cmd_gofmt_files)
$(GOLINK) $(go_cmd_gofmt_files) $(NET_LIBS)
cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
$(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go
$(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go $(NET_LIBS)
else

View File

@ -122,6 +122,7 @@ LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
NET_LIBS = @NET_LIBS@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
@ -589,11 +590,11 @@ s-zdefaultcc: Makefile
$(STAMP) $@
@NATIVE_TRUE@go$(EXEEXT): $(go_cmd_go_files) zdefaultcc.go $(LIBGODEP)
@NATIVE_TRUE@ $(GOLINK) $(go_cmd_go_files) zdefaultcc.go
@NATIVE_TRUE@ $(GOLINK) $(go_cmd_go_files) zdefaultcc.go $(NET_LIBS)
@NATIVE_TRUE@gofmt$(EXEEXT): $(go_cmd_gofmt_files) $(LIBGODEP)
@NATIVE_TRUE@ $(GOLINK) $(go_cmd_gofmt_files)
@NATIVE_TRUE@ $(GOLINK) $(go_cmd_gofmt_files) $(NET_LIBS)
@NATIVE_TRUE@cgo$(EXEEXT): $(go_cmd_cgo_files) zdefaultcc.go $(LIBGODEP)
@NATIVE_TRUE@ $(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go
@NATIVE_TRUE@ $(GOLINK) $(go_cmd_cgo_files) zdefaultcc.go $(NET_LIBS)
# For a non-native build we have to build the programs using a
# previously built host (or build -> host) Go compiler. We should

232
gotools/configure vendored
View File

@ -555,6 +555,7 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
NET_LIBS
NATIVE_FALSE
NATIVE_TRUE
GOCFLAGS
@ -1423,6 +1424,119 @@ fi
return $ac_retval
} # ac_fn_c_try_compile
# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
rm -f conftest.$ac_objext conftest$ac_exeext
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>conftest.err
ac_status=$?
if test -s conftest.err; then
grep -v '^ *+' conftest.err >conftest.er1
cat conftest.er1 >&5
mv -f conftest.er1 conftest.err
fi
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && {
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
$as_test_x conftest$ac_exeext
}; then :
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
# Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
# created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
return $ac_retval
} # ac_fn_c_try_link
# ac_fn_c_check_func LINENO FUNC VAR
# ----------------------------------
# Tests whether FUNC exists, setting the cache variable VAR accordingly
ac_fn_c_check_func ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
For example, HP-UX 11i <limits.h> declares gettimeofday. */
#define $2 innocuous_$2
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $2 (); below.
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
<limits.h> exists even on freestanding compilers. */
#ifdef __STDC__
# include <limits.h>
#else
# include <assert.h>
#endif
#undef $2
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined __stub_$2 || defined __stub___$2
choke me
#endif
int
main ()
{
return $2 ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$3=yes"
else
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_func
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
@ -3675,6 +3789,124 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket libraries" >&5
$as_echo_n "checking for socket libraries... " >&6; }
if test "${gotools_cv_lib_sockets+set}" = set; then :
$as_echo_n "(cached) " >&6
else
gotools_cv_lib_sockets=
gotools_check_both=no
ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect"
if test "x$ac_cv_func_connect" = x""yes; then :
gotools_check_socket=no
else
gotools_check_socket=yes
fi
if test "$gotools_check_socket" = "yes"; then
unset ac_cv_func_connect
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lsocket" >&5
$as_echo_n "checking for main in -lsocket... " >&6; }
if test "${ac_cv_lib_socket_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsocket $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_socket_main=yes
else
ac_cv_lib_socket_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_main" >&5
$as_echo "$ac_cv_lib_socket_main" >&6; }
if test "x$ac_cv_lib_socket_main" = x""yes; then :
gotools_cv_lib_sockets="-lsocket"
else
gotools_check_both=yes
fi
fi
if test "$gotools_check_both" = "yes"; then
gotools_old_libs=$LIBS
LIBS="$LIBS -lsocket -lnsl"
unset ac_cv_func_accept
ac_fn_c_check_func "$LINENO" "accept" "ac_cv_func_accept"
if test "x$ac_cv_func_accept" = x""yes; then :
gotools_check_nsl=no
gotools_cv_lib_sockets="-lsocket -lnsl"
fi
unset ac_cv_func_accept
LIBS=$gotools_old_libs
fi
unset ac_cv_func_gethostbyname
gotools_old_libs="$LIBS"
ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname"
if test "x$ac_cv_func_gethostbyname" = x""yes; then :
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lnsl" >&5
$as_echo_n "checking for main in -lnsl... " >&6; }
if test "${ac_cv_lib_nsl_main+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lnsl $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
return main ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_nsl_main=yes
else
ac_cv_lib_nsl_main=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_main" >&5
$as_echo "$ac_cv_lib_nsl_main" >&6; }
if test "x$ac_cv_lib_nsl_main" = x""yes; then :
gotools_cv_lib_sockets="$gotools_cv_lib_sockets -lnsl"
fi
fi
unset ac_cv_func_gethostbyname
LIBS=$gotools_old_libs
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gotools_cv_lib_sockets" >&5
$as_echo "$gotools_cv_lib_sockets" >&6; }
NET_LIBS="$gotools_cv_lib_sockets"
ac_config_files="$ac_config_files Makefile"

View File

@ -48,6 +48,37 @@ AC_PROG_GO
AM_CONDITIONAL(NATIVE, test "$cross_compiling" = no)
dnl Test for -lsocket and -lnsl. Copied from libjava/configure.ac.
AC_CACHE_CHECK([for socket libraries], gotools_cv_lib_sockets,
[gotools_cv_lib_sockets=
gotools_check_both=no
AC_CHECK_FUNC(connect, gotools_check_socket=no, gotools_check_socket=yes)
if test "$gotools_check_socket" = "yes"; then
unset ac_cv_func_connect
AC_CHECK_LIB(socket, main, gotools_cv_lib_sockets="-lsocket",
gotools_check_both=yes)
fi
if test "$gotools_check_both" = "yes"; then
gotools_old_libs=$LIBS
LIBS="$LIBS -lsocket -lnsl"
unset ac_cv_func_accept
AC_CHECK_FUNC(accept,
[gotools_check_nsl=no
gotools_cv_lib_sockets="-lsocket -lnsl"])
unset ac_cv_func_accept
LIBS=$gotools_old_libs
fi
unset ac_cv_func_gethostbyname
gotools_old_libs="$LIBS"
AC_CHECK_FUNC(gethostbyname, ,
[AC_CHECK_LIB(nsl, main,
[gotools_cv_lib_sockets="$gotools_cv_lib_sockets -lnsl"])])
unset ac_cv_func_gethostbyname
LIBS=$gotools_old_libs
])
NET_LIBS="$gotools_cv_lib_sockets"
AC_SUBST(NET_LIBS)
AC_CONFIG_FILES(Makefile)
AC_OUTPUT