1 # This file is part of Autoconf. -*- Autoconf -*-
3 # Copyright (C) 2011-2017, 2020-2024 Free Software Foundation, Inc.
5 # This file is part of Autoconf. This program is free
6 # software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the
8 # Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # Under Section 7 of GPL version 3, you are granted additional
17 # permissions described in the Autoconf Configure Script Exception,
18 # version 3.0, as published by the Free Software Foundation.
20 # You should have received a copy of the GNU General Public License
21 # and a copy of the Autoconf Configure Script Exception along with
22 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
23 # respectively. If not, see <https://www.gnu.org/licenses/> and
24 # <https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;f=COPYING.EXCEPTION>.
26 # Go support contributed by Ian Lance Taylor.
28 # This currently only supports gccgo, not 6g/8g/5g.
30 # ------------------- #
32 # ------------------- #
36 AC_LANG_DEFINE([Go], [go], [GO], [GOC], [],
38 ac_compile='$GOC -c $GOFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
39 ac_link='$GOC -o conftest$ac_exeext $GOFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
45 AU_DEFUN([AC_LANG_GO], [AC_LANG(Go)])
47 # ------------------- #
49 # ------------------- #
51 # AC_LANG_PROGRAM(Go)([PROLOGUE], [BODY])
52 # ---------------------------------------
53 m4_define([AC_LANG_PROGRAM(Go)],
60 # _AC_LANG_IO_PROGRAM(Go)
61 # -----------------------
62 # Produce source that performs I/O.
63 m4_define([_AC_LANG_IO_PROGRAM(Go)],
64 [AC_LANG_PROGRAM([import ( "fmt"; "os" )],
65 [f, err := os.OpenFile("conftest.out", os.O_CREATE|os.O_WRONLY, 0777)
70 if err = f.Close(); err != nil {
77 # AC_LANG_CALL(Go)(PROLOGUE, FUNCTION)
78 # ------------------------------------
79 # Avoid conflicting decl of main.
80 m4_define([AC_LANG_CALL(Go)],
83 [func $2()])],[$2()])])
85 # AC_LANG_FUNC_LINK_TRY(Go)(FUNCTION)
86 # -----------------------------------
87 # Try to link a program which calls FUNCTION.
88 m4_define([AC_LANG_FUNC_LINK_TRY(Go)],
94 # AC_LANG_BOOL_COMPILE_TRY(Go)(PROLOGUE, EXPRESSION)
95 # --------------------------------------------------
96 # Return a program which is valid if EXPRESSION is nonzero.
97 m4_define([AC_LANG_BOOL_COMPILE_TRY(Go)],
98 [AC_LANG_PROGRAM([$1], [var test_array @<:@1 - 2 * !($2)@:>@int
99 test_array @<:@0@:>@ = 0
102 # AC_LANG_INT_SAVE(Go)(PROLOGUE, EXPRESSION)
103 # ------------------------------------------
104 m4_define([AC_LANG_INT_SAVE(Go)],
111 [f, err := os.OpenFile("conftest.val", os.O_CREATE|os.O_WRONLY, 0777)
120 if _, err := fmt.Print(f, i); err != nil {
124 uint64 i = uint64($2)
128 if _, err := fmt.Print(f, i); err != nil {
132 if err = f.Close(); err != nil {
138 # ---------------------- #
139 # Looking for compilers. #
140 # ---------------------- #
142 # AC_LANG_COMPILER(Go)
143 # --------------------
144 AC_DEFUN([AC_LANG_COMPILER(Go)],
145 [AC_REQUIRE([AC_PROG_GO])])
149 AN_MAKEVAR([GOC], [AC_PROG_GO])
150 AN_PROGRAM([gccgo], [AC_PROG_GO])
151 AC_DEFUN([AC_PROG_GO],
153 AC_ARG_VAR([GOC], [Go compiler command])dnl
154 AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
155 _AC_ARG_VAR_LDFLAGS()dnl
157 [AC_CHECK_TOOLS(GOC, [$1])],
158 [AC_CHECK_TOOL(GOC, gccgo)
159 if test -z "$GOC"; then
160 if test -n "$ac_tool_prefix"; then
161 AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [$ac_tool_prefix}gccgo])
164 if test -z "$GOC"; then
165 AC_CHECK_PROG(GOC, gccgo, gccgo, , , false)
169 # Provide some information about the compiler.
170 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
173 _AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
174 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
175 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl