libtool-patches
[Top][All Lists]
Advanced

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

Moving creation of libtool/ltmain.sh to config.status


From: Tim Van Holder
Subject: Moving creation of libtool/ltmain.sh to config.status
Date: Sat, 7 Jul 2001 12:03:25 +0200

> > I'll take a stab at the 2.50-fication of the creation of
libtool/ltmain.sh
> > next week.
>
> Fantastic.  I've been trying to badger someone into doing this for a few
> days.  Thanks muchly!

Sorry for the delay - I spent last week at the Microsoft TechEd conference
in Barcelona.
Below is my first attempt, which I find unacceptable as it creates 2
intermediate files ($ofile.cfg and $ofile.tag, which are prepended
and appended, respectively, to ltmain.sh).
The main problem is timing; we need ltmain.sh to exist before we can create
libtool, and I'd want ltmin.sh to be created by config.status.  So we can't
prepend/append anything to libtool before we get to config.status.  But
we need libtool to extract the tag info etc., and running actual
configuration checks during config.status is not acceptable.

I'll try a different approach this weekend:
- during configure, build libtool.in, putting all tag vars in the cache
  instead of directly into libtool (may require resolving some naming
  issues).  Use ltmain.sh or ltmain.in, whichever exists.
- during config.status, simply do ltmain.in->ltmain.sh (if needed) and
  libtool.in->libtool.

Index: libtool.m4
===================================================================
RCS file: /home/cvs/libtool/libtool.m4,v
retrieving revision 1.186
diff -u -r1.186 libtool.m4
--- libtool.m4  2001/07/06 01:08:58     1.186
+++ libtool.m4  2001/07/07 08:50:13
@@ -32,20 +32,17 @@
 [AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
 dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
 dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
-  AC_PROVIDE_IFELSE([AC_PROG_CXX],
-    [AC_LIBTOOL_CXX],
-    [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
-  ])])
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+  [AC_LIBTOOL_CXX],
+  [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+])])

 dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
 dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
 dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
-  AC_PROVIDE_IFELSE([AC_PROG_GCJ],
-    [AC_LIBTOOL_GCJ],
-    [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
-      [AC_LIBTOOL_GCJ],
-      [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
-       [AC_LIBTOOL_GCJ],
+AC_PROVIDE_IFELSE([AC_PROG_GCJ], [AC_LIBTOOL_GCJ],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [AC_LIBTOOL_GCJ],
+    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], [AC_LIBTOOL_GCJ],
       [ifdef([AC_PROG_GCJ],
             [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
        ifdef([A][M_PROG_GCJ],
@@ -53,8 +50,44 @@
        ifdef([LT_AC_PROG_GCJ],
             [define([LT_AC_PROG_GCJ],
                 defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
-])])# AC_PROG_LIBTOOL
+])
+
+AC_CONFIG_COMMANDS(ltmain.sh, [
+if test ! -f "$ltmain"; then
+  if test -f "$srcdir/ltmain.in"; then
+    AC_MSG_NOTICE([creating $ltmain])
+    rm -f ltmain.shT
+    date=`$SHELL $srcdir/mkstamp < $srcdir/ChangeLog` && \
+    sed -e "s/@PACKAGE@/$PACKAGE/" -e "s/@VERSION@/$VERSION/" \
+        -e "address@hidden@%$date%" $srcdir/ltmain.in > ltmain.shT
+    mv -f ltmain.shT $ltmain || \
+    (rm -f $ltmain && cp ltmain.shT $ltmain && rm -f ltmain.shT)
+  else
+    AC_MSG_ERROR([$ltmain not found])
+  fi
+fi
+], [# Variables needed to create $ltmain
+ltmain=$ltmain PACKAGE=$PACKAGE VERSION=$VERSION])

+AC_CONFIG_COMMANDS(libtool, [
+AC_MSG_NOTICE([creating $ofile])
+if test ! -f "$ltmain"; then
+dnl FIXME: Is there a cleaner way to handle this interdependency?
+  $SHELL $0 ltmain.sh || AS_EXIT(1)
+fi
+# We use sed instead of cat because bash on DJGPP gets confused if
+# if finds mixed CR/LF and LF-only lines.  Since sed operates in
+# text mode, it properly converts lines to CR/LF.  This bash problem
+# is reportedly fixed, but why not run on old versions too?
+sed '$q' "$ofile.cfg" >  "$ofile"
+sed '$q' "$ltmain"    >> "$ofile"
+sed '$q' "$ofile.tag" >> "$ofile"
+chmod +x "$ofile"
+], [# Variables needed to create $ofile
+ltmain=$ltmain ofile=$ofile])
+
+])# AC_PROG_LIBTOOL
+

 # _AC_PROG_LIBTOOL
 # ----------------
@@ -193,7 +226,6 @@
   [  --with-pic              try to use only PIC/non-PIC objects
[default=use both]],
 pic_mode="$withval", pic_mode=default)
 test -z "$pic_mode" && pic_mode=default
-
 # Use C for the default configuration in the libtool script
 tagname=
 AC_LIBTOOL_LANG_C_CONFIG
@@ -460,8 +492,7 @@
     # crt.o which will require a address@hidden definition.
     lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;;
   esac
-  ;;
-  ])
+  ;;])
 esac

 need_locks="$enable_libtool_lock"
@@ -1329,24 +1360,27 @@
   [  --with-tags=TAGS        include additional configurations [CXX,GCJ]],
   [tagnames="$withval"],
   [tagnames="CXX,GCJ"])
+
+if test -n "$tagnames"; then
+  cfgfile="$ofile.cfg"
+  tagfile="$ofile.tag"

-if test -f "$ltmain" && test -n "$tagnames"; then
-  if test ! -f "${ofile}"; then
-    AC_MSG_WARN([output file `$ofile' does not exist])
+  if test ! -f "${cfgfile}"; then
+    AC_MSG_WARN([output file `$cfgfile' does not exist])
   fi

   if test -z "$LTCC"; then
-    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+    eval "`grep '^LTCC=' ${cfgfile}`"
     if test -z "$LTCC"; then
-      AC_MSG_WARN([output file `$ofile' does not look like a libtool
script])
+      AC_MSG_WARN([output file `$cfgfile' does not look like a libtool
script])
     else
-      AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+      AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$cfgfile'])
     fi
   fi

-  # Extract list of available tagged configurations in $ofile.
+  # Extract list of available tagged configurations in $cfgfile.
   # 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'`
+  available_tags=`grep "^available_tags=" "${cfgfile}" | sed -e
's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`

   IFS="${IFS=  }"; lt_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:},"
   for tagname in $tagnames; do
@@ -1358,14 +1392,14 @@
         ;;
     esac

-    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" >
/dev/null
+    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${tagfile}" >
/dev/null
     then
       AC_MSG_ERROR([tag name $tagname already exists])
     fi

     # Update the list of available tags.
     if test -n "$tagname"; then
-      echo appending configuration tag \"$tagname\" to $ofile
+      AC_MSG_NOTICE([appending configuration tag "$tagname" to $tagfile])

       case $tagname in
       CXX)
@@ -1388,11 +1422,11 @@
   IFS="$lt_save_ifs"

   # Now substitute the updated list of available tags.
-  if eval "sed -e
's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" >
\"${ofile}T\""; then
-    mv "${ofile}T" "$ofile"
-    chmod +x "$ofile"
+  if eval "sed -e
's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$cfgfile\" >
\"${cfgfile}T\""; then
+    mv "${cfgfile}T" "$cfgfile"
+    chmod +x "$cfgfile"
   else
-    rm -f "${ofile}T"
+    rm -f "${cfgfile}T"
     AC_MSG_ERROR([unable to update list of available tagged
configurations.])
   fi
 fi
@@ -2144,7 +2178,7 @@
 AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
 AC_LIBTOOL_DLOPEN_SELF($1)

-# Report which librarie types wil actually be built
+# Report which library types wil actually be built
 AC_MSG_CHECKING([if libtool supports shared libraries])
 AC_MSG_RESULT([$can_build_shared])

@@ -3020,91 +3054,87 @@
 # add code to config.status for appending the configuration named by
 # TAGNAME from the matching tagged config vars.
 AC_DEFUN([AC_LIBTOOL_CONFIG],
-[# The else clause should only fire when bootstrapping the
-# libtool distribution, otherwise you forgot to ship ltmain.sh
-# with your package, and you will get complaints that there are
-# no rules to generate ltmain.sh.
-if test -f "$ltmain"; then
-  # Now quote all the things that may contain metacharacters while being
-  # careful not to overquote the AC_SUBSTed values.  We take copies of the
-  # variables and quote the copies for generation of the libtool script.
-  for var in echo old_CC old_CFLAGS AR AR_FLAGS RANLIB LN_S NM SHELL \
-    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
-    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
-    deplibs_check_method reload_flag reload_cmds need_locks \
-    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
-    lt_cv_sys_global_symbol_to_c_name_address \
-    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
-    old_postinstall_cmds old_postuninstall_cmds \
-    _LT_AC_TAGVAR(compiler, $1) \
-    _LT_AC_TAGVAR(CC, $1) \
-    _LT_AC_TAGVAR(LD, $1) \
-    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
-    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
-    _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
-    _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
-    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
-    _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
-    _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
-    _LT_AC_TAGVAR(old_archive_cmds, $1) \
-    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
-    _LT_AC_TAGVAR(predep_objects, $1) \
-    _LT_AC_TAGVAR(postdep_objects, $1) \
-    _LT_AC_TAGVAR(predeps, $1) \
-    _LT_AC_TAGVAR(postdeps, $1) \
-    _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
-    _LT_AC_TAGVAR(archive_cmds, $1) \
-    _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
-    _LT_AC_TAGVAR(postinstall_cmds, $1) \
-    _LT_AC_TAGVAR(postuninstall_cmds, $1) \
-    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
-    _LT_AC_TAGVAR(allow_undefined_flag, $1) \
-    _LT_AC_TAGVAR(no_undefined_flag, $1) \
-    _LT_AC_TAGVAR(export_symbols_cmds, $1) \
-    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
-    _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
-    _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
-    _LT_AC_TAGVAR(exclude_expsyms, $1) \
-    _LT_AC_TAGVAR(include_expsyms, $1); do
-
-    case $var in
-    _LT_AC_TAGVAR(old_archive_cmds, $1) | \
-    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
-    _LT_AC_TAGVAR(archive_cmds, $1) | \
-    _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
-    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
-    _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
-    extract_expsyms_cmds | reload_cmds | finish_cmds | \
-    postinstall_cmds | postuninstall_cmds | \
-    old_postinstall_cmds | old_postuninstall_cmds | \
-    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
-      # Double-quote double-evaled strings.
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e
\"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e
\"\$delay_variable_subst\"\`\\\""
-      ;;
-    *)
-      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e
\"\$sed_quote_subst\"\`\\\""
-      ;;
-    esac
-  done
-
-  case $lt_echo in
-  *'\[$]0 --fallback-echo"')
-    lt_echo=`$echo "X$lt_echo" | $Xsed -e
's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
+[
+# Quote all the things that may contain metacharacters while being
+# careful not to overquote the AC_SUBSTed values.  We take copies of the
+# variables and quote the copies for generation of the libtool script.
+for var in echo old_CC old_CFLAGS AR AR_FLAGS RANLIB LN_S NM SHELL \
+  libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+  old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+  deplibs_check_method reload_flag reload_cmds need_locks \
+  lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+  lt_cv_sys_global_symbol_to_c_name_address \
+  sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+  old_postinstall_cmds old_postuninstall_cmds \
+  _LT_AC_TAGVAR(compiler, $1) \
+  _LT_AC_TAGVAR(CC, $1) \
+  _LT_AC_TAGVAR(LD, $1) \
+  _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+  _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+  _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+  _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+  _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+  _LT_AC_TAGVAR(old_archive_cmds, $1) \
+  _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+  _LT_AC_TAGVAR(predep_objects, $1) \
+  _LT_AC_TAGVAR(postdep_objects, $1) \
+  _LT_AC_TAGVAR(predeps, $1) \
+  _LT_AC_TAGVAR(postdeps, $1) \
+  _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+  _LT_AC_TAGVAR(archive_cmds, $1) \
+  _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+  _LT_AC_TAGVAR(postinstall_cmds, $1) \
+  _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+  _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+  _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+  _LT_AC_TAGVAR(no_undefined_flag, $1) \
+  _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+  _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+  _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+  _LT_AC_TAGVAR(exclude_expsyms, $1) \
+  _LT_AC_TAGVAR(include_expsyms, $1); do
+
+  case $var in
+  _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+  _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+  _LT_AC_TAGVAR(archive_cmds, $1) | \
+  _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+  _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+  _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+  extract_expsyms_cmds | reload_cmds | finish_cmds | \
+  postinstall_cmds | postuninstall_cmds | \
+  old_postinstall_cmds | old_postuninstall_cmds | \
+  sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+    # Double-quote double-evaled strings.
+    eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e
\"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e
\"\$delay_variable_subst\"\`\\\""
     ;;
+  *)
+    eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e
\"\$sed_quote_subst\"\`\\\""
+    ;;
   esac
+done
+
+case $lt_echo in
+*'\[$]0 --fallback-echo"')
+  lt_echo=`$echo "X$lt_echo" | $Xsed -e
's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
+  ;;
+esac

-ifelse([$1], [],
-  [cfgfile="${ofile}T"
-  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
-  $rm -f "$cfgfile"
-  AC_MSG_NOTICE([creating $ofile])],
-  [cfgfile="$ofile"])
+ifelse([$1], [], [cfgfile="$ofile.cfg"
+tagfile="$ofile.tag"
+rm -f $cfgfile $tagfile
+AC_MSG_NOTICE([creating $cfgfile and $tagfile])
+echo >$tagfile
+], [cfgfile="$ofile.tag"])

-  cat <<__EOF__ >> "$cfgfile"
+cat <<__EOF__ >> "$cfgfile"
 ifelse([$1], [],
 [#! $SHELL

-# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized
library-building support services.
+# `$echo "$ofile" | sed 's%^.*[\\/]%%'` - Provide generalized
library-building support services.
 # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
@@ -3423,9 +3453,9 @@
 __EOF__

 ifelse([$1],[], [
-  case $host_os in
-  aix3*)
-    cat <<\EOF >> "$cfgfile"
+case $host_os in
+aix3*)
+  cat <<\EOF >> "$cfgfile"

 # AIX sometimes has problems with the GCC collect2 program.  For some
 # reason, if we set the COLLECT_NAMES environment variable, the problems
@@ -3437,35 +3467,19 @@
 EOF
     ;;

-  cygwin* | mingw* | pw32* | os2*)
-    cat <<'EOF' >> "$cfgfile"
-    # This is a source program that is used to create dlls on Windows
-    # Don't remove nor modify the starting and closing comments
-    _LT_AC_FILE_LTDLL_C
-    # This is a source program that is used to create import libraries
-    # on Windows for dlls which lack them. Don't remove nor modify the
-    # starting and closing comments
-    _LT_AC_FILE_IMPGEN_C
+cygwin* | mingw* | pw32* | os2*)
+  cat <<'EOF' >> "$cfgfile"
+# This is a source program that is used to create dlls on Windows
+# Don't remove nor modify the starting and closing comments
+_LT_AC_FILE_LTDLL_C
+# This is a source program that is used to create import libraries
+# on Windows for dlls which lack them. Don't remove nor modify the
+# starting and closing comments
+_LT_AC_FILE_IMPGEN_C
 EOF
-    ;;
-  esac
-
-  # We use sed instead of cat because bash on DJGPP gets confused if
-  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
-  # text mode, it properly converts lines to CR/LF.  This bash problem
-  # is reportedly fixed, but why not run on old versions too?
-  sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
-
-  mv -f "$cfgfile" "$ofile" || \
-    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
-  chmod +x "$ofile"
+  ;;
+esac
 ])
-else
-  # If there is no Makefile yet, we rely on a make rule to execute
-  # `config.status --recheck' to rerun these tests and create the
-  # libtool script then.
-  test -f Makefile && make "$ltmain"
-fi
 ])# AC_LIBTOOL_CONFIG


@@ -4733,7 +4747,6 @@
 # _LT_AC_TAGVAR(VARNAME, [TAGNAME])
 # ---------------------------------
 AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
-

 # old names
 AC_DEFUN([AM_PROG_LIBTOOL],   [AC_PROG_LIBTOOL])




reply via email to

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