]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* ltconfig.in (available_tags): The name of each newly added
authorOssama Othman <ossama@debian.org>
Fri, 4 Feb 2000 03:53:36 +0000 (03:53 +0000)
committerOssama Othman <ossama@debian.org>
Fri, 4 Feb 2000 03:53:36 +0000 (03:53 +0000)
tagged configuration is appended to this list.  This is done at
ltconfig time so that the generated `libtool' script need not
determine which tags it supports everytime it is used.  The
available_tags variable is used by `ltmain.in' to iterate over
each of the tagged configurations when attempting to automatically
choose which one to use for the supplied compile/link command.
* ltmain.in: Added ability to automatically determine which tagged
configuration to use based on the compiler found in the supplied
base compile command.
(available_tags): This new variable contains a list of available
tagged configurations.  This gets generated at ltconfig time.
(object_name, old_object): Renamed these to pic_object and
non_pic_object, respectively.
* doc/libtool.texi (Configuration tags): Updated documentation.
Libtool now has the ability to infer which tagged configuration to
use based on the compiler found in the supplied base compile
command.
* tagdemo/configure.in, tagdemo/configure: Removed explicit
substitution of "--tag=CXX" in $LIBTOOL.  The newly added
automatic selection of tagged configurations obviates the need to
explicitly specify which tag to use.

ChangeLog
doc/libtool.texi
ltconfig.in
ltmain.in
tagdemo/configure
tagdemo/configure.in

index ae718d6f2965093a63765e7a2608249545b9146b..d9e05a352113c68b953e222edb9dbb69ce62f4c3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,29 @@
-2200-02-01  Ossama Othman  <ossama@uci.edu>
+2000-02-03  Ossama Othman  <ossama@debian.org>
+
+       * ltconfig.in (available_tags): The name of each newly added
+       tagged configuration is appended to this list.  This is done at
+       ltconfig time so that the generated `libtool' script need not
+       determine which tags it supports everytime it is used.  The
+       available_tags variable is used by `ltmain.in' to iterate over
+       each of the tagged configurations when attempting to automatically
+       choose which one to use for the supplied compile/link command.
+       * ltmain.in: Added ability to automatically determine which tagged
+       configuration to use based on the compiler found in the supplied
+       base compile command.
+       (available_tags): This new variable contains a list of available
+       tagged configurations.  This gets generated at ltconfig time.
+       (object_name, old_object): Renamed these to pic_object and
+       non_pic_object, respectively.
+       * doc/libtool.texi (Configuration tags): Updated documentation.
+       Libtool now has the ability to infer which tagged configuration to
+       use based on the compiler found in the supplied base compile
+       command.
+       * tagdemo/configure.in, tagdemo/configure: Removed explicit
+       substitution of "--tag=CXX" in $LIBTOOL.  The newly added
+       automatic selection of tagged configurations obviates the need to
+       explicitly specify which tag to use.
+
+2000-02-01  Ossama Othman  <ossama@uci.edu>
 
        * ltcf-cxx.sh: Added some untested HPUX aCC support.
        * ltmain.in: Inadvertently removed some of the tags patch.
index dcab3fb22d9ec6007fc134c448fa599099d609ac..905efca4a28fa0483b6c813446420b0cbc9cd86c 100644 (file)
@@ -3269,11 +3269,19 @@ option, whenever you want to compile or link a library using
 @samp{c++}, you should run:
 
 @example
-$ @kbd{./libtool --tag=CXX --mode=compile c++ -c test.cc}
+$ @kbd{./libtool --mode=compile c++ -c test.cc}
 @end example
 
-If you do not use the proper tag name, it is possible that libtool ends
-up using incorrect commands.
+Libtool will automatically detect the appropriate tagged configuration
+to use by matching the compiler used in the above command with the one
+the tagged configuration was configured with.
+
+The tagged configuration that libtool uses can be explicitly specified
+by using the @samp{--tag} option as follows:
+
+@example
+$ @kbd{./libtool --tag=CXX --mode=compile c++ -c test.cc}
+@end example
 
 Conceptually, tags are cumulative, i.e., they could only set a couple of
 configuration variables, leaving others untouched.  In practice, any tag
index f52ca639b4e642e9815b56deca32b163222dbd63..0d52ce57d8d69a3e34c9acc8e03f21220c4a68f9 100755 (executable)
@@ -1985,6 +1985,9 @@ Xsed="sed -e s/^X//"
 # if CDPATH is set.
 if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
 
+# The names of the tagged configurations supported by this script.
+available_tags=
+
 ### BEGIN LIBTOOL CONFIG
 EOF
   else
@@ -2491,6 +2494,26 @@ EOF
   ;;
 esac
 
+# Update the list of available tags.
+if test -n "$tagname"; then
+
+  # Extract list of available tagged configurations in $ofile.
+  # Note that this assumes the entire list is on one line.
+  available_tags=`grep "^available_tags=" $ofile | sed -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+  # Append the new tag name to the list of available tags.
+  available_tags="$available_tags $tagname"
+
+  # Now substitute the updated of available tags.
+  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' ${ofile} > ${ofile}.new"; then
+    mv ${ofile}.new ${ofile}
+  else
+    rm -f ${ofile}.new
+    echo "$progname: unable to update list of available tagged configurations."
+    exit 1
+  fi
+fi
+
 # Don't cache tagged configuration!
 test -n "$cache_file" && test -z "$tagname" || exit 0
 
index 81dc742fa995b34362625cfe1864635c66c00546..93aa16da0dece3e7e07641de58879dc38eac2123 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -423,6 +423,36 @@ if test -z "$show_help"; then
       fi
     done
 
+    # Infer tagged configuration to use if any are available and
+    # if one wasn't chosen via the "--tag" command line option.
+    # Only attempt this if the compiler in the base compile
+    # command doesn't match the default compiler.
+    if test -n "$available_tags" && test -z "$tagname" && echo $base_compile | grep -v $CC > /dev/null; then
+      for z in $available_tags; do
+        if grep "^### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
+         # Evaluate the configuration.
+         eval "`sed -n -e '/^### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
+          if echo $base_compile | grep $CC > /dev/null; then
+            # The compiler in the base compile command matches
+            # the one in the tagged configuration.
+            # Assume this is the tagged configuration we want.
+            tagname=$z
+            break
+          fi
+        fi
+      done
+      # If $tagname still isn't set, then no tagged configuration
+      # was found and let the user know that the "--tag" command
+      # line option must be used.
+      if test -z "$tagname"; then
+        echo "$modename: unable to infer tagged configuration"
+        echo "$modename: specify a tag with \`--tag'" 1>&2
+       exit 1
+#     else
+#       echo "$modename: using $tagname tagged configuration"
+      fi
+    fi
+
     case "$user_target" in
     set)
       ;;
@@ -522,7 +552,7 @@ compiler."
 
     $run $rm "$libobj"
 
-    # Create a libtool object file (analogous to a `.la' file),
+    # Create a libtool object file (analogous to a ".la" file),
     # but don't create it if we're doing a dry run.
     test -z "$run" && cat > $libobj <<EOF
 # $libobj - a libtool object file
@@ -564,7 +594,7 @@ EOF
 
       # Append the name of the PIC object to the libtool object file.
       test -z "$run" && cat >> $libobj <<EOF
-object_name='$output_obj'
+pic_object='$output_obj'
 
 EOF
 
@@ -613,7 +643,7 @@ compiler."
       # No PIC object so indicate it doesn't exist in the libtool
       # object file.
       test -z "$run" && cat >> $libobj <<EOF
-object_name=none
+pic_object=none
 
 EOF
     fi
@@ -636,7 +666,7 @@ EOF
       # Only append if the libtool object file exists.
       test -z "$run" && cat >> $libobj <<EOF
 # Name of the non-PIC object.
-old_object='$obj'
+non_pic_object='$obj'
 
 EOF
 
@@ -685,7 +715,7 @@ compiler."
       # Only append if the libtool object file exists.
       test -z "$run" && cat >> $libobj <<EOF
 # Name of the non-PIC object.
-old_object=none
+non_pic_object=none
 
 EOF
     fi
@@ -752,7 +782,7 @@ EOF
     module=no
     no_install=no
     objs=
-    old_objects=
+    non_pic_objects=
     prefer_static_libs=no
     preload=no
     prev=
@@ -1174,8 +1204,8 @@ EOF
 
        # Check to see that this really is a libtool object.
        if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
-          object_name=
-          old_object=
+          pic_object=
+          non_pic_object=
 
           # Read the .lo file
           # If there is no directory component, then add one.
@@ -1184,10 +1214,10 @@ EOF
           *) . ./$arg ;;
           esac
 
-          if test -z "$object_name" || \
-             test -z "$old_object" ||
-             test "$object_name" = none && \
-             test "$old_object" = none; then
+          if test -z "$pic_object" || \
+             test -z "$non_pic_object" ||
+             test "$pic_object" = none && \
+             test "$non_pic_object" = none; then
             $echo "$modename: cannot find name of object for \`$arg'" 1>&2
             exit 1
           fi
@@ -1200,12 +1230,12 @@ EOF
            xdir="$xdir/"
          fi
 
-          if test "$object_name" != none; then
+          if test "$pic_object" != none; then
             # Prepend the subdirectory the object is found in.
-           object_name="$xdir$object_name"
+           pic_object="$xdir$pic_object"
 
            if test "$prev" = dlfiles; then
-             dlfiles="$dlfiles $object_name"
+             dlfiles="$dlfiles $pic_object"
              if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
                prev=
                continue
@@ -1218,21 +1248,21 @@ EOF
            # CHECK ME:  I think I busted this.  -Ossama
             if test "$prev" = dlprefiles; then
              # Preload the old-style object.
-             dlprefiles="$dlprefiles $object_name"
+             dlprefiles="$dlprefiles $pic_object"
              prev=
             fi
 
             # A PIC object.
-           libobjs="$libobjs $object_name"
+           libobjs="$libobjs $pic_object"
           fi
 
           # Non-PIC object.
-          if test "$old_object" != none; then
+          if test "$non_pic_object" != none; then
             # Prepend the subdirectory the object is found in.
-           old_object="$xdir$old_object"
+           non_pic_object="$xdir$non_pic_object"
 
             # A standard non-PIC object
-            old_objects="$old_objects $old_object"
+            non_pic_objects="$non_pic_objects $non_pic_object"
           fi
         else
           # Only an error if not doing a dry-run.
@@ -1250,10 +1280,10 @@ EOF
              xdir="$xdir/"
            fi
 
-            object_name=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
-            old_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
-           libobjs="$libobjs $object_name"
-            old_objects="$old_objects $old_object"
+            pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+            non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+           libobjs="$libobjs $pic_object"
+            non_pic_objects="$non_pic_objects $non_pic_object"
           fi
        fi
        ;;
@@ -1369,6 +1399,38 @@ EOF
       exit 1
     fi
 
+    # Infer tagged configuration to use if any are available and
+    # if one wasn't chosen via the "--tag" command line option.
+    # Only attempt this if the compiler in the base link
+    # command doesn't match the default compiler.
+    if test -n "$available_tags" \
+       && test -z "$tagname" \
+       && echo $compile_command | grep -v $CC > /dev/null; then
+      for z in $available_tags; do
+        if grep "^### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then
+         # Evaluate the configuration.
+         eval "`sed -n -e '/^### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`"
+          if echo $compile_command | grep $CC > /dev/null; then
+            # The compiler in $compile_command matches
+            # the one in the tagged configuration.
+            # Assume this is the tagged configuration we want.
+            tagname=$z
+            break
+          fi
+        fi
+      done
+      # If $tagname still isn't set, then no tagged configuration
+      # was found and let the user know that the "--tag" command
+      # line option must be used.
+      if test -z "$tagname"; then
+        echo "$modename: unable to infer tagged configuration"
+        echo "$modename: specify a tag with \`--tag'" 1>&2
+       exit 1
+#     else
+#       echo "$modename: using $tagname tagged configuration"
+      fi
+    fi
+
     if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
       eval arg=\"$export_dynamic_flag_spec\"
       compile_command="$compile_command $arg"
@@ -2364,7 +2426,7 @@ EOF
        oldlibs="$oldlibs $output_objdir/$libname.$libext"
 
        # Transform .lo files to .o files.
-       oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
       fi
 
       # Eliminate all temporary directories.
@@ -3614,7 +3676,7 @@ fi\
          oldobjs="$libobjs_save"
          build_libtool_libs=no
        else
-         oldobjs="$objs$old_deplibs $old_objects"
+         oldobjs="$objs$old_deplibs $non_pic_objects"
        fi
        addlibs="$old_convenience"
       fi
index 01f0f5034306c14ac60b5dd691e10e9c81e073f6..9034d06acaac3692d6f0e77ba7ce776ee9b75569 100755 (executable)
@@ -2386,23 +2386,21 @@ CC="$lt_save_CC"
 CFLAGS="$lt_save_CFLAGS"
 
 
-LIBTOOL="$LIBTOOL --tag=CXX"
-
 for ac_hdr in math.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2396: checking for $ac_hdr" >&5
+echo "configure:2394: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2401 "configure"
+#line 2399 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2406: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2404: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2436,7 +2434,7 @@ case "$lt_target" in
   ;;
 *-ncr-sysv4.3*)
   echo $ac_n "checking for _mwvalidcheckl in -lmw""... $ac_c" 1>&6
-echo "configure:2440: checking for _mwvalidcheckl in -lmw" >&5
+echo "configure:2438: checking for _mwvalidcheckl in -lmw" >&5
 ac_lib_var=`echo mw'_'_mwvalidcheckl | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2444,7 +2442,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lmw  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2448 "configure"
+#line 2446 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 #ifdef __cplusplus
@@ -2458,7 +2456,7 @@ int main() {
 _mwvalidcheckl()
 ; return 0; }
 EOF
-if { (eval echo configure:2462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2479,7 +2477,7 @@ else
 fi
 
   echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
-echo "configure:2483: checking for main in -lm" >&5
+echo "configure:2481: checking for main in -lm" >&5
 ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2487,14 +2485,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2491 "configure"
+#line 2489 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:2498: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2496: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -2517,7 +2515,7 @@ fi
   ;;
 *)
   echo $ac_n "checking for main in -lm""... $ac_c" 1>&6
-echo "configure:2521: checking for main in -lm" >&5
+echo "configure:2519: checking for main in -lm" >&5
 ac_lib_var=`echo m'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2525,14 +2523,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lm  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 2529 "configure"
+#line 2527 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:2536: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
index 10cf0cd967e7f2aca13c17dd136aad0c2b37ada6..34c4a718ad16e583d9a5ee6e75a7c1dadd602c34 100644 (file)
@@ -52,13 +52,9 @@ AM_PROG_LIBTOOL
 
 dnl Enable C++ support in libtool
 dnl This causes a C++ configuration tag to be appended to the libtool
-dnl script generated during the above AC_PROG_LIBTOOL macro execution.
+dnl script generated during the above AM_PROG_LIBTOOL macro execution.
 AC_LIBTOOL_CXX
 
-dnl FIXME:  We need a better place to add the libtool "tag" flag.
-dnl         This is a really ugly hack.
-LIBTOOL="$LIBTOOL --tag=CXX"
-
 AC_CHECK_HEADERS(math.h)
 
 AC_CHECK_LIBM