libtool-patches
[Top][All Lists]
Advanced

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

[RFC] Custom tag interface


From: Scott James Remnant
Subject: [RFC] Custom tag interface
Date: Wed, 17 Mar 2004 21:24:49 +0000

This is currently a Request For Comments only, if people like this patch
I'll make any necessary changes, write up some documentation for it and
mail a proper patch later.

This patch depends on and extends keybuk-lt-lang.patch.


It gives the user far greater flexibility and control over the tags
their libtool script will support.  It provides three new macros to do
this; LT_TAG, LT_TAG_SETVAR and LT_TAG_GETVAR.

LT_TAG creates a copy of a tag, LT_TAG_SETVAR and LT_TAG_GETVAR get and
set tag variables appropriately.

One example use of these is for package maintainers such as myself; I
might want a 'libtool' that has C++ support through *both* "libtool g++"
and "libtool g++".

        LT_TAG([CXX], [BINCXX])
        LT_TAG_SETVAR([BINCXX], [compiler], ["c++"])


This also splits the language and tag relationship somewhat.  Currently
C++ support is *always* the CXX tag, etc.  This allows the user to
control that by adding a second argument to LT_LANG.

        LT_LANG(C++, MYCXX)

LT_LANG acts like LT_TAG if the language support is already enabled
under a different tag name.

Automake can still trace _LT_LANG, the first argument is *always* a
language name ("C", "CXX", "F77", "GCJ", "RC") the second is a tag
assigned to it.


It also paves the way for breaking the notion that "C" is the built-in
tag.  It would make it very easy for us to simply do away with tagless
Libtool entirely.


This may be a little *too* mad and funky, feel free to discuss.

Scott
-- 
Have you ever, ever felt like this?
Had strange things happen?  Are you going round the twist?

diff -ruNp libtool-CVS~/ChangeLog libtool-CVS/ChangeLog
--- libtool-CVS~/ChangeLog      2004-03-17 20:37:07.000000000 +0000
+++ libtool-CVS/ChangeLog       2004-03-17 21:13:32.000000000 +0000
@@ -0,0 +1,26 @@
+2004-03-17  Scott James Remnant  <address@hidden>
+
+       Extend the libtool user interface to allow users even greater
+       control and flexibility over libtool's tags, allowing them to
+       create them and modify them in their configure.ac files.
+
+       * m4/libtool.m4 (LT_TAG): New user-facing macro to create a copy
+       of a tag with the variables (initially) set to the same value.
+       (LT_TAG_GETVAR, LT_TAG_SETVAR): User-facing wrappers around
+       _LT_AC_TAGVAR.
+       (_LT_TAG_CHECK): New macro to check whether a tag name has
+       already been declared or not.
+       (LT_LANG): Extend to support a second argument specifying the
+       name of the tag to create, defaulting to something sensible if
+       ommitted.
+       (_LT_LANG): Likewise extend.  Additionally where a language has
+       been previously defined under a different tag LT_LANG will act
+       like LT_TAG.
+       (_LT_LANG_TAG_C, _LT_LANG_TAG_CXX, _LT_LANG_TAG_GCJ,
+       _LT_LANG_TAG_F77, _LT_LANG_TAG_RC): Pick suitable default tag
+       names for the supported languages.
+       (_LT_LANG_BUILTIN_TAG): Define the C language to be the built-in one.
+       All macros have specific references to language tags replaced by
+       _LT_LANG_TAG_* and references to the "built-in" support changed
+       from C to _LT_LANG_BUILTIN_TAG.
+
diff -ruNp libtool-CVS~/m4/libtool.m4 libtool-CVS/m4/libtool.m4
--- libtool-CVS~/m4/libtool.m4  2004-03-17 20:37:07.000000000 +0000
+++ libtool-CVS/m4/libtool.m4   2004-03-17 21:06:15.000000000 +0000
@@ -468,8 +468,8 @@ _LT_OUTPUT_LIBTOOL_INIT
 # matching tagged config vars.
 m4_define([_LT_CONFIG],
 [_LT_CONFIG_SAVE_COMMANDS([
-  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
-  m4_if(_LT_TAG, [C], [
+  m4_define([_LT_TAG], m4_if([$1], [], _LT_LANG_BUILTIN_TAG, [$1]))dnl
+  m4_if(_LT_TAG, _LT_LANG_BUILTIN_TAG, [
     # See if we are running on zsh, and set the options which allow our
     # commands through without removal of \ escapes.
     if test -n "${ZSH_VERSION+set}" ; then
@@ -544,38 +544,60 @@ _LT_EOF
     VERSION='$VERSION'
     TIMESTAMP='$TIMESTAMP'
     rm='$rm'
-    ofile='$ofile'], [$1='[$]$1'])
+    ofile='$ofile'], [])
 ])dnl /_LT_CONFIG_SAVE_COMMANDS
 ])# _LT_CONFIG
 
 
+# Lang/tag variables, a primer:
+#   _LT_TAGS           space separated list of declared tags
+#   _LT_TAG_*_declared defined if the tag has been declared
+#
+#   _LT_LANG_*_enabled defined if the language is enabled
+#   _LT_LANG_TAG_*     the primary tag for this language
+
+m4_define([_LT_LANG_TAG_C],   [C])
+m4_define([_LT_LANG_TAG_CXX], [CXX])
+m4_define([_LT_LANG_TAG_GCJ], [GCJ])
+m4_define([_LT_LANG_TAG_F77], [F77])
+m4_define([_LT_LANG_TAG_RC],  [RC])
+
 # C support is built-in for now
+m4_define([_LT_TAG_C_declared], [])
 m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_LANG_BUILTIN_TAG], _LT_LANG_TAG_C)
+
 m4_define([_LT_TAGS], [])
 m4_define([_LT_LANG_DEFAULT], [AUTO])
 
-# LT_LANG(LANG)
-# -------------
-# Enable libtool support for the given language if not already enabled.
+# LT_LANG(LANG, TAG)
+# ------------------
+# Enable libtool support for the given language under the given tag.
+# The tag may be omitted in which case a reasonable default is chosen.
+# If the language support is already enabled, the original language tag
+# is copied to the new one.
 AC_DEFUN([LT_LANG],
 [m4_case([$1],
-  [C],                 [_LT_LANG(C)],
-  [C++],               [_LT_LANG(CXX)],
-  [Java],              [_LT_LANG(GCJ)],
-  [Fortran 77],                [_LT_LANG(F77)],
-  [Windows Resource],  [_LT_LANG(RC)],
+  [C],               [_LT_LANG(C,   m4_if([$2], [], [_LT_LANG_TAG_C],   
[$2]))],
+  [C++],             [_LT_LANG(CXX, m4_if([$2], [], [_LT_LANG_TAG_CXX], 
[$2]))],
+  [Java],            [_LT_LANG(GCJ, m4_if([$2], [], [_LT_LANG_TAG_GCJ], 
[$2]))],
+  [Fortran 77],      [_LT_LANG(F77, m4_if([$2], [], [_LT_LANG_TAG_F77], 
[$2]))],
+  [Windows Resource],[_LT_LANG(RC,  m4_if([$2], [], [_LT_LANG_TAG_RC],  
[$2]))],
   [m4_ifdef([_LT_LANG_]$1[_CONFIG],
-    [_LT_LANG($1)],
+    [_LT_LANG($1, m4_if([$2], [], [_LT_LANG_TAG_]$1, [$2]))],
     [m4_fatal([$0: unsupported language: "$1"])])])dnl
 ])# LT_LANG
 
 # _LT_LANG(LANGNAME, TAG)
 # ------------------------
 m4_define([_LT_LANG],
-[m4_ifdef([_LT_LANG_]$1[_enabled], [],
-  [m4_append([_LT_TAGS], [$1 ])dnl
+[m4_ifdef([_LT_LANG_]$1[_enabled],
+  [m4_if($2, m4_defn([_LT_LANG_TAG_]$1), [], [LT_TAG([_LT_LANG_TAG_]$1, $2)])],
+  [_LT_TAG_CHECK($2)dnl
+  m4_append([_LT_TAGS], [$2 ])dnl
+  m4_define([_LT_LANG_TAG_]$1, $2)dnl
   m4_define([_LT_LANG_]$1[_enabled], [])dnl
-  _LT_LANG_$1_CONFIG($1)])dnl
+  _LT_LANG_$1_CONFIG($2)])dnl
 ])# _LT_LANG
 
 # _LT_LANG_DEFAULT_CONFIG
@@ -621,6 +643,46 @@ AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fort
 AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java])])
 
 
+# _LT_TAG_CHECK(TAG)
+# ------------------
+# Check that the given tag has not yet been defined
+m4_define([_LT_TAG_CHECK],
+[m4_ifdef([_LT_TAG_]$1[_declared],
+  [m4_fatal([$0: tag already declared: "$1"])],
+  [m4_define([_LT_TAG_]$1[_declared], [])])dnl
+])# _LT_TAG_CHECK
+
+# LT_TAG(OLDTAG, NEWTAG)
+# ----------------------
+# Create a copy of OLDTAG called NEWTAG which will initially have every
+# variable set the same way.
+AC_DEFUN([LT_TAG],
+[m4_ifdef([_LT_TAG_]$1[_declared],
+  [_LT_TAG_CHECK($2)dnl
+  m4_append([_LT_TAGS], [$2 ])dnl
+  m4_foreach([_lt_tag_var], m4_quote(lt_decl_tag_varnames),
+    [m4_n(_lt_tag_var[_]$2=[$]_lt_tag_var[_]$1)])dnl
+  _LT_CONFIG($2)],
+  [m4_fatal([$0: tag not declared (missing LT_LANG?): "$1"])])dnl
+])# LT_TAG
+
+# LT_TAG_GETVAR(TAG, VAR)
+# -----------------------
+# Expands to the value of configuration variable VAR for TAG.
+AC_DEFUN([LT_TAG_GETVAR],
+[m4_if($1, _LT_LANG_BUILTIN_TAG,
+  [$_LT_AC_TAGVAR($2)], [$_LT_AC_TAGVAR($2, $1)])
+])# LT_TAG_GETVAR
+
+# LT_TAG_SETVAR(TAG, VAR, VALUE)
+# ------------------------------
+# Sets the configuration variable VAR for TAG to VALUE.
+AC_DEFUN([LT_TAG_SETVAR],
+[m4_if($1, _LT_LANG_BUILTIN_TAG,
+  [_LT_AC_TAGVAR($2)=$3], [_LT_AC_TAGVAR($2, $1)=$3])
+])# LT_TAG_SETVAR
+
+
 # _LT_AC_SYS_COMPILER
 # -------------------
 AC_DEFUN([_LT_AC_SYS_COMPILER],
@@ -2881,7 +2943,7 @@ _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
 _LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
 
 AC_MSG_CHECKING([for $compiler option to produce PIC])
-m4_if([$1], [CXX], [
+m4_if([$1], _LT_LANG_TAG_CXX, [
   # C++ specific cases for pic, static, wl, etc.
   if test "$GXX" = yes; then
     _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
@@ -3316,7 +3378,7 @@ case "$host_os" in
     _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
     ;;
   *)
-    _LT_AC_TAGVAR(lt_prog_compiler_pic, 
$1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)@&address@hidden([$1],[],[ 
-DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, 
$1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)@&address@hidden([$1],[],[ 
-DPIC],[m4_if([$1],_LT_LANG_TAG_CXX,[ -DPIC],[])])"
     ;;
 esac
 AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
@@ -3329,7 +3391,7 @@ _LT_TAGDECL([wl], [lt_prog_compiler_wl],
 if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
   AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag 
$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
     [_LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1)],
-    [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)@&address@hidden([$1],[],[ 
-DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+    [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)@&address@hidden([$1],[],[ 
-DPIC],[m4_if([$1],_LT_LANG_TAG_CXX,[ -DPIC],[])])], [],
     [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
      "" | " "*) ;;
      *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" 
$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
@@ -3362,7 +3424,7 @@ AC_REQUIRE([AC_PROG_LD])dnl
 AC_REQUIRE([AC_PROG_NM])dnl
 AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl
 AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
-m4_if([$1], [CXX], [
+m4_if([$1], _LT_LANG_TAG_CXX, [
   _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | 
$global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
   case $host_os in
   aix4* | aix5*)
@@ -5268,7 +5330,7 @@ m4_if([$1], [], [cat > conftest.$ac_ext 
 int a;
 void foo (void) { a = 0; }
 _LT_EOF
-], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+], [$1], _LT_LANG_TAG_CXX, [cat > conftest.$ac_ext <<_LT_EOF
 class Foo
 {
 public:
@@ -5277,7 +5339,7 @@ private:
   int a;
 };
 _LT_EOF
-], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+], [$1], _LT_LANG_TAG_F77, [cat > conftest.$ac_ext <<_LT_EOF
       subroutine foo
       implicit none
       integer*4 a
@@ -5285,7 +5347,7 @@ _LT_EOF
       return
       end
 _LT_EOF
-], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+], [$1], _LT_LANG_TAG_GCJ, [cat > conftest.$ac_ext <<_LT_EOF
 public class foo {
   private int a;
   public void bar (void) {

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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