From 8863577ed1d4e6b43333e8ba9e5e527a743448e2 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Sat, 12 May 2001 21:01:45 +0000 Subject: [PATCH] trivial example of templatization --- exe/lt_exe.tpl | 139 +++++++++++++++++++++++++++++++++++++++++++++++++ exe/ltmain.tpl | 2 +- 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 exe/lt_exe.tpl diff --git a/exe/lt_exe.tpl b/exe/lt_exe.tpl new file mode 100644 index 000000000..784c029a2 --- /dev/null +++ b/exe/lt_exe.tpl @@ -0,0 +1,139 @@ +[= AutoGen5 Template =] +[= + +DEFINE test-or-exit =] +if ([=test=]) > /dev/null 2>&1 ; then [= + invert ":\nelse " +=] $echo "$modename: [=msg=]" 1>&2 + $echo "$help" + exit 1 +fi[= + +ENDDEF +=] # The first argument is the command name. + cmd="$nonopt" + [= test-or-exit test = 'test -z "$cmd"' + msg = "you must specify a COMMAND" =] + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + [= test-or-exit invert = yes + test = "sed -e '2q' $file | egrep \"^# Generated by .*$PACKAGE\"" + msg = "\\`$lib' is not a valid libtool archive" =] + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + [= test-or-exit test = 'test -f "$dir/$objdir/$dlname"' invert = yes + msg = "cannot find \\`$dlname' in \\`$dir' or \\`$dir/$objdir'" =] + dir="$dir/$objdir" + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved enviroment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now actually exec the command. + eval "exec \$cmd$args" + + $echo "$modename: cannot exec \$cmd$args" + exit 1 + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi diff --git a/exe/ltmain.tpl b/exe/ltmain.tpl index 8e4e7e85a..aad81cbfa 100644 --- a/exe/ltmain.tpl +++ b/exe/ltmain.tpl @@ -317,7 +317,7 @@ if test -z "$show_help"; then execute) modename="$modename: execute" -[=string[EXECUTE_STRING].text=] +[= include "lt_exe.tpl" =] ;; # libtool clean and uninstall mode -- 2.47.3