1 # This file is part of Autoconf. -*- Autoconf -*-
3 # Copyright (C) 2011-2017, 2020-2022 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/>.
25 # Go support contributed by Ian Lance Taylor.
27 # This currently only supports gccgo, not 6g/8g/5g.
29 # ------------------- #
31 # ------------------- #
35 AC_LANG_DEFINE([Go], [go], [GO], [GOC], [],
37 ac_compile='$GOC -c $GOFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
38 ac_link='$GOC -o conftest$ac_exeext $GOFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
44 AU_DEFUN([AC_LANG_GO], [AC_LANG(Go)])
46 # ------------------- #
48 # ------------------- #
50 # AC_LANG_PROGRAM(Go)([PROLOGUE], [BODY])
51 # ---------------------------------------
52 m4_define([AC_LANG_PROGRAM(Go)],
59 # _AC_LANG_IO_PROGRAM(Go)
60 # -----------------------
61 # Produce source that performs I/O.
62 m4_define([_AC_LANG_IO_PROGRAM(Go)],
63 [AC_LANG_PROGRAM([import ( "fmt"; "os" )],
64 [f, err := os.OpenFile("conftest.out", os.O_CREATE|os.O_WRONLY, 0777)
69 if err = f.Close(); err != nil {
76 # AC_LANG_CALL(Go)(PROLOGUE, FUNCTION)
77 # ------------------------------------
78 # Avoid conflicting decl of main.
79 m4_define([AC_LANG_CALL(Go)],
82 [func $2()])],[$2()])])
84 # AC_LANG_FUNC_LINK_TRY(Go)(FUNCTION)
85 # -----------------------------------
86 # Try to link a program which calls FUNCTION.
87 m4_define([AC_LANG_FUNC_LINK_TRY(Go)],
93 # AC_LANG_BOOL_COMPILE_TRY(Go)(PROLOGUE, EXPRESSION)
94 # --------------------------------------------------
95 # Return a program which is valid if EXPRESSION is nonzero.
96 m4_define([AC_LANG_BOOL_COMPILE_TRY(Go)],
97 [AC_LANG_PROGRAM([$1], [var test_array @<:@1 - 2 * !($2)@:>@int
98 test_array @<:@0@:>@ = 0
101 # AC_LANG_INT_SAVE(Go)(PROLOGUE, EXPRESSION)
102 # ------------------------------------------
103 m4_define([AC_LANG_INT_SAVE(Go)],
110 [f, err := os.OpenFile("conftest.val", os.O_CREATE|os.O_WRONLY, 0777)
119 if _, err := fmt.Print(f, i); err != nil {
123 uint64 i = uint64($2)
127 if _, err := fmt.Print(f, i); err != nil {
131 if err = f.Close(); err != nil {
137 # ---------------------- #
138 # Looking for compilers. #
139 # ---------------------- #
141 # AC_LANG_COMPILER(Go)
142 # --------------------
143 AC_DEFUN([AC_LANG_COMPILER(Go)],
144 [AC_REQUIRE([AC_PROG_GO])])
148 AN_MAKEVAR([GOC], [AC_PROG_GO])
149 AN_PROGRAM([gccgo], [AC_PROG_GO])
150 AC_DEFUN([AC_PROG_GO],
152 AC_ARG_VAR([GOC], [Go compiler command])dnl
153 AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl
154 _AC_ARG_VAR_LDFLAGS()dnl
156 [AC_CHECK_TOOLS(GOC, [$1])],
157 [AC_CHECK_TOOL(GOC, gccgo)
158 if test -z "$GOC"; then
159 if test -n "$ac_tool_prefix"; then
160 AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [$ac_tool_prefix}gccgo])
163 if test -z "$GOC"; then
164 AC_CHECK_PROG(GOC, gccgo, gccgo, , , false)
168 # Provide some information about the compiler.
169 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
172 _AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
173 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
174 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl