go.m4 2.2 KB

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