From: Ossama Othman Date: Fri, 4 Feb 2000 03:53:36 +0000 (+0000) Subject: * ltconfig.in (available_tags): The name of each newly added X-Git-Tag: multi-language-merge-point~244 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7e7dbcc06d0b685c4a9135b5b53c5f7083fd68dd;p=thirdparty%2Flibtool.git * 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. --- diff --git a/ChangeLog b/ChangeLog index ae718d6f2..d9e05a352 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,29 @@ -2200-02-01 Ossama Othman +2000-02-03 Ossama Othman + + * 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 * ltcf-cxx.sh: Added some untested HPUX aCC support. * ltmain.in: Inadvertently removed some of the tags patch. diff --git a/doc/libtool.texi b/doc/libtool.texi index dcab3fb22..905efca4a 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -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 diff --git a/ltconfig.in b/ltconfig.in index f52ca639b..0d52ce57d 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -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 diff --git a/ltmain.in b/ltmain.in index 81dc742fa..93aa16da0 100644 --- 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 <> $libobj <> $libobj <> $libobj <> $libobj </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 diff --git a/tagdemo/configure b/tagdemo/configure index 01f0f5034..9034d06ac 100755 --- a/tagdemo/configure +++ b/tagdemo/configure @@ -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 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 <&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 <&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 <&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 diff --git a/tagdemo/configure.in b/tagdemo/configure.in index 10cf0cd96..34c4a718a 100644 --- a/tagdemo/configure.in +++ b/tagdemo/configure.in @@ -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