libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PATCH RFA: Add Go support


From: Ian Lance Taylor
Subject: PATCH RFA: Add Go support
Date: Tue, 12 Oct 2010 14:42:56 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

This patch adds support for the Go programming language to libtool.  Go
is described at http://golang.org/ .

I'm not very familiar with libtool.  This patch is mostly a
cut-and-paste job.  It is enough to let me use automake with LIBTOOL to
build libraries from Go code.

The patch requires a patch which I've proposed for autoconf:

http://lists.gnu.org/archive/html/autoconf-patches/2010-10/msg00004.html

I'm not sure how to handle a libtool patch which requires an autoconf
patch.  Perhaps this can not be committed until the next libtool
release.

In any case I would appreciate any comments and any advice as to how to
get this committed to libtool.  Thanks.

Ian

>From b4af7daf876a49174e87a76345f4c8f96521702c Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor <address@hidden>
Date: Tue, 12 Oct 2010 14:38:49 -0700
Subject: [PATCH] Add Go support.

---
 ChangeLog                  |   11 ++++++
 doc/libtool.texi           |    3 +-
 libltdl/config/ltmain.m4sh |    2 +-
 libltdl/m4/libtool.m4      |   84 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9caba84..732b2d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2010-10-12  Ian Lance Taylor  <address@hidden>
+
+       * libltdl/m4/libtool.m4 (LT_LANG): Add Go.
+       (AC_PROG_GO): Provide.
+       (_LT_SYS_HIDDEN_LIBDEPS): Add Go case.
+       (_LT_LANG_GO_CONFIG): Define.
+       (LT_PROG_GO): Define.
+       * libltdl/config/ltmain.m4sh: Match *.go.
+       * doc/libtool.texi (LT_INIT): Mention Go.
+       (Tags): Mention Go.
+
 2010-10-07  Roumen Petrov  <address@hidden>
 
        Add test case for 69e77671 (cwrapper PATH manipulation order)
diff --git a/doc/libtool.texi b/doc/libtool.texi
index cd5a181..302e6ed 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -2169,7 +2169,7 @@ specifying @option{--with-pic} to @command{configure}.
 @defmac LT_LANG (@var{language})
 Enable @command{libtool} support for the language given if it
 has not yet already been enabled.  Languages accepted are ``C++'',
-``Fortran 77'', ``Java'' and ``Windows Resource''.
+``Fortran 77'', ``Java'', ``Go'', and ``Windows Resource''.
 
 If Autoconf language support macros such as @code{AC_PROG_CXX} are
 used in your @file{configure.ac}, Libtool language support will automatically
@@ -2768,6 +2768,7 @@ correspondence between language names and tags names.
 @item Java             @tab GCJ
 @item Fortran 77       @tab F77
 @item Fortran          @tab FC
address@hidden Go               @tab GO
 @item Windows Resource @tab RC
 @end multitable
 
diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh
index 1078e75..ee09925 100644
--- a/libltdl/config/ltmain.m4sh
+++ b/libltdl/config/ltmain.m4sh
@@ -1270,7 +1270,7 @@ func_mode_compile ()
     *.[cCFSifmso] | \
     *.ada | *.adb | *.ads | *.asm | \
     *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
-    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
+    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
       func_xform "$libobj"
       libobj=$func_xform_result
       ;;
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4
index 967dd38..fac9cc6 100644
--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -801,6 +801,7 @@ AC_DEFUN([LT_LANG],
 m4_case([$1],
   [C],                 [_LT_LANG(C)],
   [C++],               [_LT_LANG(CXX)],
+  [Go],                        [_LT_LANG(GO)],
   [Java],              [_LT_LANG(GCJ)],
   [Fortran 77],                [_LT_LANG(F77)],
   [Fortran],           [_LT_LANG(FC)],
@@ -852,6 +853,10 @@ AC_PROVIDE_IFELSE([AC_PROG_GCJ],
        m4_ifdef([LT_PROG_GCJ],
        [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
 
+AC_PROVIDE_IFELSE([AC_PROG_GO],
+  [LT_LANG(GO)],
+  [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])
+
 AC_PROVIDE_IFELSE([LT_PROG_RC],
   [LT_LANG(RC)],
   [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
@@ -6902,6 +6907,11 @@ public class foo {
   }
 };
 _LT_EOF
+], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF
+package foo
+func foo() {
+}
+_LT_EOF
 ])
 
 _lt_libdeps_save_CFLAGS=$CFLAGS
@@ -7423,6 +7433,75 @@ CC=$lt_save_CC
 CFLAGS=$lt_save_CFLAGS
 ])# _LT_LANG_GCJ_CONFIG
 
+# _LT_LANG_GO_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Go compiler
+# are suitably defined.  These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GO_CONFIG],
+[AC_REQUIRE([LT_PROG_GO])dnl
+AC_LANG_SAVE
+
+# Source file extension for Go test sources.
+ac_ext=go
+
+# Object file extension for compiled Go test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="package main; func main() { }"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='package main; func main() { }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_CFLAGS=$CFLAGS
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCCGO-"gccgo"}
+CFLAGS=$GOFLAGS
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# Go did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(reload_flag, $1)=$reload_flag
+_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+  _LT_COMPILER_NO_RTTI($1)
+  _LT_COMPILER_PIC($1)
+  _LT_COMPILER_C_O($1)
+  _LT_COMPILER_FILE_LOCKS($1)
+  _LT_LINKER_SHLIBS($1)
+  _LT_LINKER_HARDCODE_LIBPATH($1)
+
+  _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC=$lt_save_CC
+CFLAGS=$lt_save_CFLAGS
+])# _LT_LANG_GO_CONFIG
 
 # _LT_LANG_RC_CONFIG([TAG])
 # -------------------------
@@ -7492,6 +7571,11 @@ AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
 dnl aclocal-1.4 backwards compatibility:
 dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
 
+# LT_PROG_GO
+# ----------
+AC_DEFUN([LT_PROG_GO],
+[AC_CHECK_TOOL(GCCGO, gccgo,)
+])
 
 # LT_PROG_RC
 # ----------
-- 
1.7.1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]