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