1dnl acinclude.m4 -- configure macros
2
3dnl Copyright 2009 The Go Authors. All rights reserved.
4dnl Use of this source code is governed by a BSD-style
5dnl license that can be found in the LICENSE file.
6
7dnl Go support--this could be in autoconf.
8dnl This version is probably autoconf 2.64 specific.
9
10AC_LANG_DEFINE([Go], [go], [GO], [],
11[ac_ext=go
12ac_compile='$GOC -c $GOCFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
13ac_link='$GOC -o conftest$ac_exeext $GOCFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
14ac_compile_gnu=yes
15])
16
17AU_DEFUN([AC_LANG_GO], [AC_LANG(Go)])
18
19m4_define([AC_LANG_PROGRAM(Go)],
20[package main
21$1
22func main() {
23$2
24}])
25
26m4_define([AC_LANG_IO_PROGRAM(Go)],
27[AC_LANG_PROGRAM([import "os"],
28[if f, err := os.Open("conftest.out", os.O_WRONLY), err != nil {
29	os.Exit(1);
30 }
31 if err := f.Close(); err != nil {
32	os.Exit(1);
33 }
34 os.Exit(0);
35])])
36
37m4_define([AC_LANG_CALL(Go)],
38[AC_LANG_PROGRAM([$1
39m4_if([$2], [main], ,
40[func $2();])],[$2();])])
41
42m4_define([AC_LANG_FUNC_LINK_TRY(Go)],
43[AC_LANG_PROGRAM(
44[func $1() int;
45var f := $1;
46], [return f();])])
47
48m4_define([AC_LANG_BOOL_COMPILE_TRY(Go)],
49[AC_LANG_PROGRAM([$1], [var test_array @<:@1 - 2 * !($2)@:>@;
50test_array @<:@0@:>@ = 0
51])])
52
53m4_define([AC_LANG_INT_SAVE(Go)],
54[AC_LANG_PROGRAM([$1
55import os
56func longval() long { return $2 }
57func ulongval() ulong { return $2 }],
58[panic("unimplemented")])])
59
60AC_DEFUN([AC_LANG_COMPILER(Go)],
61[AC_REQUIRE([AC_PROG_GO])])
62
63AN_MAKEVAR([GOC], [AC_PROG_GO])
64AN_PROGRAM([gccgo], [AC_PROG_GO])
65AC_DEFUN([AC_PROG_GO],
66[AC_LANG_PUSH(Go)dnl
67AC_ARG_VAR([GOC],   [Go compiler command])dnl
68AC_ARG_VAR([GOCFLAGS], [Go compiler flags])dnl
69_AC_ARG_VAR_LDFLAGS()dnl
70m4_ifval([$1],
71      [AC_CHECK_TOOLS(GOC, [$1])],
72[AC_CHECK_TOOL(GOC, gccgo)
73if test -z "$GOC"; then
74  if test -n "$ac_tool_prefix"; then
75    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [$ac_tool_prefix}gccgo])
76  fi
77fi
78if test -z "$GOC"; then
79  AC_CHECK_PROG(GOC, gccgo, gccgo, , , gccgo)
80fi
81])
82
83# Provide some information about the compiler.
84_AS_ECHO_LOG([checking for _AC_LANG compiler version])
85set X $ac_compile
86ac_compiler=$[2]
87_AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
88m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
89m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
90GOCFLAGS="-g -O2"
91AC_LANG_POP(Go)dnl
92])# AC_PROG_GO
93