Browse Source

Resolves: 251262
Summary: Changed ldap-agent to find location of stats file dynamically.

Nathan Kinder 18 years ago
parent
commit
1db2ff6952
4 changed files with 217 additions and 88 deletions
  1. 1 1
      Makefile.am
  2. 3 2
      Makefile.in
  3. 108 28
      ldap/servers/snmp/main.c
  4. 105 57
      ltmain.sh

+ 1 - 1
Makefile.am

@@ -859,7 +859,7 @@ ldap_agent_bin_SOURCES = ldap/servers/snmp/main.c \
 	ldap/servers/slapd/agtmmap.c
 
 ldap_agent_bin_CPPFLAGS = $(AM_CPPFLAGS) @netsnmp_inc@ @ldapsdk_inc@ @nss_inc@ @nspr_inc@
-ldap_agent_bin_LDADD = $(NETSNMP_LINK)
+ldap_agent_bin_LDADD = $(NETSNMP_LINK) $(LDAPSDK_LINK)
 
 #------------------------
 # ldclt

+ 3 - 2
Makefile.in

@@ -559,7 +559,8 @@ am_ldap_agent_bin_OBJECTS =  \
 	ldap/servers/snmp/ldap_agent_bin-ldap-agent.$(OBJEXT) \
 	ldap/servers/slapd/ldap_agent_bin-agtmmap.$(OBJEXT)
 ldap_agent_bin_OBJECTS = $(am_ldap_agent_bin_OBJECTS)
-ldap_agent_bin_DEPENDENCIES = $(am__DEPENDENCIES_1)
+ldap_agent_bin_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+	$(am__DEPENDENCIES_1)
 am__ldclt_bin_SOURCES_DIST = ldap/servers/slapd/tools/ldaptool-sasl.c \
 	ldap/servers/slapd/tools/ldclt/data.c \
 	ldap/servers/slapd/tools/ldclt/ldapfct.c \
@@ -1750,7 +1751,7 @@ ldap_agent_bin_SOURCES = ldap/servers/snmp/main.c \
 	ldap/servers/slapd/agtmmap.c
 
 ldap_agent_bin_CPPFLAGS = $(AM_CPPFLAGS) @netsnmp_inc@ @ldapsdk_inc@ @nss_inc@ @nspr_inc@
-ldap_agent_bin_LDADD = $(NETSNMP_LINK)
+ldap_agent_bin_LDADD = $(NETSNMP_LINK) $(LDAPSDK_LINK)
 
 #------------------------
 # ldclt

+ 108 - 28
ldap/servers/snmp/main.c

@@ -47,6 +47,7 @@
 #include <signal.h>
 #include <sys/stat.h>
 #include "ldap-agent.h"
+#include "ldif.h"
 
 static char *agentx_master = NULL;
 static char *agent_logdir = NULL;
@@ -239,19 +240,21 @@ load_config(char *conf_path)
     FILE *dse_fp = NULL;
     char line[MAXLINE];
     char *p = NULL;
-    char *p2 = NULL;
+    int error = 0;
 
     /* Make sure we are getting an absolute path */
     if (*conf_path != '/') {
         printf("ldap-agent: Error opening config file: %s\n", conf_path);
         printf("ldap-agent: You must specify the absolute path to your config file\n");
-        exit(1);
+        error = 1;
+        goto close_and_exit;
     }
 
     /* Open config file */
     if ((conf_file = fopen(conf_path, "r")) == NULL) {
         printf("ldap-agent: Error opening config file: %s\n", conf_path);
-        exit(1);
+        error = 1;
+        goto close_and_exit;
     } 
 
     /* set pidfile path */
@@ -265,7 +268,8 @@ load_config(char *conf_path)
                 pidfile[((p - conf_path) + strlen(LDAP_AGENT_PIDFILE) + 1)] = (char)0;
             } else {
                 printf("ldap-agent: malloc error processing config file\n");
-                exit(1);
+                error = 1;
+                goto close_and_exit;
             }
 
             /* set default logdir to location of config file */
@@ -275,7 +279,8 @@ load_config(char *conf_path)
                 break;
             } else {
                 printf("ldap-agent: malloc error processing config file\n");
-                exit(1);
+                error = 1;
+                goto close_and_exit;
             }
         }
     }
@@ -305,23 +310,34 @@ load_config(char *conf_path)
                     strcpy(agent_logdir, p);
             }
         } else if ((p = strstr(line, "server")) != NULL) {
+            int got_port = 0;
+            int got_tmpdir = 0;
+            int lineno = 0;
+            char *entry = NULL;
+
             /* Allocate a server_instance */
             if ((serv_p = malloc(sizeof(server_instance))) == NULL) {
                 printf("ldap-agent: malloc error processing config file\n");
-                exit(1);
+                error = 1;
+                goto close_and_exit;
             }
 
             /* load server setting */
             p = p + 6;
-            if ((p = strtok_r(p, " :\t\n", &p2)) != NULL) {
-                /* first token is the instance root */
-                if ((serv_p->stats_file = malloc(strlen(p) + 18)) != NULL)
-                    snprintf(serv_p->stats_file, strlen(p) + 18,
-                                     "%s/logs/slapd.stats", p);
-                    serv_p->stats_file[(strlen(p) + 17)] = (char)0;
-                if ((serv_p->dse_ldif = malloc(strlen(p) + 17)) != NULL) {
-                    snprintf(serv_p->dse_ldif, strlen(p) + 17, "%s/config/dse.ldif", p);
-                    serv_p->dse_ldif[(strlen(p) + 16)] = (char)0;
+            if ((p = strtok(p, " \t\n")) != NULL) {
+                /* first token is the instance name */
+                serv_p->dse_ldif = malloc(strlen(p) + strlen(SYSCONFDIR) +
+                                           strlen(PACKAGE_NAME) + 12);
+                if (serv_p->dse_ldif != NULL) {
+                    snprintf(serv_p->dse_ldif, strlen(p) + strlen(SYSCONFDIR) +
+                         strlen(PACKAGE_NAME) + 12, "%s/%s/%s/dse.ldif", 
+                         SYSCONFDIR, PACKAGE_NAME, p);
+                    serv_p->dse_ldif[(strlen(p) + strlen(SYSCONFDIR) +
+                                      strlen(PACKAGE_NAME) + 11)] = (char)0;
+                } else {
+                    printf("ldap-agent: malloc error processing config file\n");
+                    error = 1;
+                    goto close_and_exit;
                 }
             }
  
@@ -329,20 +345,78 @@ load_config(char *conf_path)
             if ((dse_fp = fopen(serv_p->dse_ldif, "r")) == NULL) {
                 printf("ldap-agent: Error opening server config file: %s\n",
                         serv_p->dse_ldif);
-                exit(1);
+                error = 1;
+                goto close_and_exit;
             }
 
-            /* Get port value */
-            while (fgets(line, MAXLINE, dse_fp) != NULL) {
-                if ((p = strstr(line, "nsslapd-port: ")) != NULL) {
-                    p = p + 14;
-                    if ((p = strtok(p, ": \t\n")) != NULL)
-                        serv_p->port = atol(p);
+            /* ldif_get_entry will realloc the entry if it's not null,
+             * so we can just free it when we're done fetching entries
+             * from the dse.ldif.  Unfortunately, ldif_getline moves
+             * the pointer that is passed to it, so we need to save a
+             * pointer to the beginning of the entry so we can free it
+             * later. */
+            while ((entry = ldif_get_entry(dse_fp, &lineno)) != NULL) {
+                char *entryp = entry;
+                char *attr = NULL;
+                char *val = NULL;
+                int vlen;
+
+                /* Check if this is the cn=config entry */
+                ldif_parse_line(ldif_getline(&entryp), &attr, &val, &vlen);
+                if ((strcmp(attr, "dn") == 0) &&
+                    (strcmp(val, "cn=config") == 0)) {
+                    char *dse_line = NULL;
+                    /* Look for port and tmpdir attributes */
+                    while ((dse_line = ldif_getline(&entryp)) != NULL) {
+                        ldif_parse_line(dse_line, &attr, &val, &vlen);
+                        if (strcmp(attr, "nsslapd-port") == 0) {
+                            serv_p->port = atol(val);
+                            got_port = 1;
+                        } else if (strcmp(attr, "nsslapd-tmpdir") == 0) {
+                            serv_p->stats_file = malloc(vlen + 13);
+                            if (serv_p->stats_file != NULL) {
+                                snprintf(serv_p->stats_file, vlen + 13,
+                                         "%s/slapd.stats", val);
+                                serv_p->stats_file[(vlen + 12)] = (char)0;
+                            } else {
+                                printf("ldap-agent: malloc error processing config file\n");
+                                free(entry);
+                                error = 1;
+                                goto close_and_exit;
+                            }
+                            got_tmpdir = 1;
+                        }
+
+                        /* Stop processing this entry if we found the
+                         *  port and tmpdir settings */
+                        if (got_port && got_tmpdir) {
+                            break;
+                        }
+                    }
+                    /* The port and tmpdir settings must be in the
+                     * cn=config entry, so we can stop reading through
+                     * the dse.ldif now. */
+                    break;
                 }
             }
 
-            /* Close dse.ldif */
-            fclose(dse_fp);
+            /* We're done reading entries from dse_ldif now, so
+             * we can free entry */
+            free(entry);
+
+            /* Make sure we were able to read the port and
+             * location of the stats file. */
+            if (!got_port) {
+                printf("ldap-agent: Error reading nsslapd-port from "
+                       "server config file: %s\n", serv_p->dse_ldif);
+                error = 1;
+                goto close_and_exit;
+            } else if (!got_tmpdir) {
+                printf("ldap-agent: Error reading nsslapd-tmpdir from "
+                       "server config file: %s\n", serv_p->dse_ldif);
+                error = 1;
+                goto close_and_exit;
+            }
 
             /* Insert server instance into linked list */
             serv_p->next = server_head;
@@ -350,14 +424,20 @@ load_config(char *conf_path)
         }
     }
 
-    /* Close config file */
-    fclose(conf_file);
-
     /* check for at least one directory server instance */
     if (server_head == NULL) {
         printf("ldap-agent: No server instances defined in config file\n");
-        exit(1);
+        error = 1;
+        goto close_and_exit;
     }
+
+close_and_exit:
+    if (conf_file)
+        fclose(conf_file);
+    if (dse_fp)
+        fclose(dse_fp);
+    if (error)
+        exit(error);
 }
 
 /************************************************************************

+ 105 - 57
ltmain.sh

@@ -46,10 +46,16 @@ PACKAGE=libtool
 VERSION=1.5.22
 TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
 
-# 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
+# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
   setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
 fi
 
 # Check that we have a working $echo.
@@ -105,12 +111,14 @@ esac
 # These must not be set unconditionally because not all systems understand
 # e.g. LANG=C (notably SCO).
 # We save the old values to restore during execute mode.
-if test "${LC_ALL+set}" = set; then
-  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
-fi
-if test "${LANG+set}" = set; then
-  save_LANG="$LANG"; LANG=C; export LANG
-fi
+for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+  eval "if test \"\${$lt_var+set}\" = set; then
+         save_$lt_var=\$$lt_var
+         $lt_var=C
+         export $lt_var
+       fi"
+done
 
 # Make sure IFS has a sensible default
 lt_nl='
@@ -136,6 +144,8 @@ duplicate_deps=no
 preserve_args=
 lo2o="s/\\.lo\$/.${objext}/"
 o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
 
 #####################################
 # Shell function definitions:
@@ -327,7 +337,17 @@ func_extract_archives ()
 	*) my_xabs=`pwd`"/$my_xlib" ;;
       esac
       my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
-      my_xdir="$my_gentop/$my_xlib"
+      my_xlib_u=$my_xlib
+      while :; do
+        case " $extracted_archives " in
+       *" $my_xlib_u "*)
+         extracted_serial=`expr $extracted_serial + 1`
+         my_xlib_u=lt$extracted_serial-$my_xlib ;;
+       *) break ;;
+       esac
+      done
+      extracted_archives="$extracted_archives $my_xlib_u"
+      my_xdir="$my_gentop/$my_xlib_u"
 
       $show "${rm}r $my_xdir"
       $run ${rm}r "$my_xdir"
@@ -758,6 +778,7 @@ if test -z "$show_help"; then
     *.f90) xform=f90 ;;
     *.for) xform=for ;;
     *.java) xform=java ;;
+    *.obj) xform=obj ;;
     esac
 
     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
@@ -1138,8 +1159,9 @@ EOF
     for arg
     do
       case $arg in
-      -all-static | -static)
-	if test "X$arg" = "X-all-static"; then
+      -all-static | -static | -static-libtool-libs)
+    case $arg in
+    -all-static)
 	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
 	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
 	  fi
@@ -1147,12 +1169,20 @@ EOF
 	    dlopen_self=$dlopen_self_static
 	  fi
 	  prefer_static_libs=yes
-	else
+	  ;;
+    -static)
 	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
 	    dlopen_self=$dlopen_self_static
 	  fi
 	  prefer_static_libs=built
-	fi
+	  ;;
+    -static-libtool-libs)
+      if test -z "$pic_flag" && test -n "$link_static_flag"; then
+        dlopen_self=$dlopen_self_static
+      fi
+      prefer_static_libs=yes
+      ;;
+    esac
 	build_libtool_libs=no
 	build_old_libs=yes
 	break
@@ -1712,7 +1742,7 @@ EOF
 	continue
 	;;
 
-      -static)
+      -static | -static-libtool-libs)
 	# The effects of -static are defined in a previous loop.
 	# We used to do the same as -all-static on platforms that
 	# didn't have a PIC flag, but the assumption that the effects
@@ -2490,7 +2520,9 @@ EOF
 
 	if test "$linkmode,$pass" = "prog,link"; then
 	  if test -n "$library_names" &&
-	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+         { { test "$prefer_static_libs" = no ||
+             test "$prefer_static_libs,$installed" = "built,yes"; } ||
+           test -z "$old_library"; }; then
 	    # We need to hardcode the library path
 	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
 	      # Make sure the rpath contains only unique directories.
@@ -3186,7 +3218,7 @@ EOF
 	  # which has an extra 1 added just for fun
 	  #
 	  case $version_type in
-	  darwin|linux|osf|windows)
+	  darwin|linux|osf|windows|none)
 	    current=`expr $number_major + $number_minor`
 	    age="$number_minor"
 	    revision="$number_revision"
@@ -3410,11 +3442,11 @@ EOF
       fi
 
       # Eliminate all temporary directories.
-      for path in $notinst_path; do
-	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
-	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
-	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
-      done
+#      for path in $notinst_path; do
+#	lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
+#	deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
+#	dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
+#      done
 
       if test -n "$xrpath"; then
 	# If the user specified any rpath flags, then add them.
@@ -3515,13 +3547,12 @@ EOF
 	  int main() { return 0; }
 EOF
 	  $rm conftest
-	  $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
-	  if test "$?" -eq 0 ; then
+      if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
 	    ldd_output=`ldd conftest`
 	    for i in $deplibs; do
 	      name=`expr $i : '-l\(.*\)'`
 	      # If $name is empty we are operating on a -L argument.
-              if test "$name" != "" && test "$name" -ne "0"; then
+              if test "$name" != "" && test "$name" != "0"; then
 		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
 		  case " $predeps $postdeps " in
 		  *" $i "*)
@@ -3560,9 +3591,7 @@ EOF
 	      # If $name is empty we are operating on a -L argument.
               if test "$name" != "" && test "$name" != "0"; then
 		$rm conftest
-		$LTCC $LTCFLAGS -o conftest conftest.c $i
-		# Did it work?
-		if test "$?" -eq 0 ; then
+		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
 		  ldd_output=`ldd conftest`
 		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
 		    case " $predeps $postdeps " in
@@ -3594,7 +3623,7 @@ EOF
 		  droppeddeps=yes
 		  $echo
 		  $echo "*** Warning!  Library $i is needed by this library but I was not able to"
-		  $echo "***  make it link in!  You will probably need to install it or some"
+		  $echo "*** make it link in!  You will probably need to install it or some"
 		  $echo "*** library that it depends on before this library will be fully"
 		  $echo "*** functional.  Installing it before continuing would be even better."
 		fi
@@ -4239,12 +4268,14 @@ EOF
       reload_conv_objs=
       gentop=
       # reload_cmds runs $LD directly, so let us get rid of
-      # -Wl from whole_archive_flag_spec
+      # -Wl from whole_archive_flag_spec and hope we can get by with
+      # turning comma into space..
       wl=
 
       if test -n "$convenience"; then
 	if test -n "$whole_archive_flag_spec"; then
-	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+      reload_conv_objs=$reload_objs\ `$echo "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
 	else
 	  gentop="$output_objdir/${obj}x"
 	  generated="$generated $gentop"
@@ -4692,16 +4723,16 @@ static const void *lt_preloaded_setup() {
           case $host in
           *cygwin* | *mingw* )
             if test -f "$output_objdir/${outputname}.def" ; then
-              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
-              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
+              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
+              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%" | $NL2SP`
             else
-              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+              compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+              finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
              fi
             ;;
           * )
-            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
-            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+            compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
+            finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%" | $NL2SP`
             ;;
           esac
 	  ;;
@@ -4716,13 +4747,13 @@ static const void *lt_preloaded_setup() {
 	# really was required.
 
 	# Nullify the symbol file.
-	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
-	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
+	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "s% @SYMFILE@%%" | $NL2SP`
       fi
 
       if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
 	# Replace the output file specification.
-	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$output"'%g' | $NL2SP`
 	link_command="$compile_command$compile_rpath"
 
 	# We have no uninstalled library dependencies, so finalize right now.
@@ -4809,7 +4840,7 @@ static const void *lt_preloaded_setup() {
 	if test "$fast_install" != no; then
 	  link_command="$finalize_var$compile_command$finalize_rpath"
 	  if test "$fast_install" = yes; then
-	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $SP2NL | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g' | $NL2SP`
 	  else
 	    # fast_install is set to needless
 	    relink_command=
@@ -4846,7 +4877,7 @@ static const void *lt_preloaded_setup() {
 	  fi
 	done
 	relink_command="(cd `pwd`; $relink_command)"
-	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+	relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
       fi
 
       # Quote $echo for shipping.
@@ -5253,6 +5284,18 @@ EOF
 Xsed='${SED} -e 1s/^X//'
 sed_quote_subst='$sed_quote_subst'
 
+# Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+
 # The HP-UX ksh and POSIX shell print the target directory to stdout
 # if CDPATH is set.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
@@ -5395,7 +5438,7 @@ else
 	  ;;
 	esac
 	$echo >> $output "\
-      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+      \$echo \"\$0: cannot exec \$program \$*\"
       exit $EXIT_FAILURE
     fi
   else
@@ -5581,7 +5624,7 @@ fi\
       done
       # Quote the link command for shipping.
       relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
-      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e "$sed_quote_subst" | $NL2SP`
       if test "$hardcode_automatic" = yes ; then
 	relink_command=
       fi
@@ -5926,9 +5969,9 @@ relink_command=\"$relink_command\""
 
 	  if test -n "$inst_prefix_dir"; then
 	    # Stick the inst_prefix_dir data into the link command.
-	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%" | $NL2SP`
 	  else
-	    relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+	    relink_command=`$echo "$relink_command" | $SP2NL | $SED "s%@inst_prefix_dir@%%" | $NL2SP`
 	  fi
 
 	  $echo "$modename: warning: relinking \`$file'" 1>&2
@@ -6137,7 +6180,7 @@ relink_command=\"$relink_command\""
 	      file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
 	      outputname="$tmpdir/$file"
 	      # Replace the output file specification.
-	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+	      relink_command=`$echo "X$relink_command" | $SP2NL | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g' | $NL2SP`
 
 	      $show "$relink_command"
 	      if $run eval "$relink_command"; then :
@@ -6413,12 +6456,15 @@ relink_command=\"$relink_command\""
       fi
 
       # Restore saved environment 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
+      for lt_var in LANG LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+      do
+       eval "if test \"\${save_$lt_var+set}\" = set; then
+               $lt_var=\$save_$lt_var; export $lt_var
+             else
+               $lt_unset $lt_var
+             fi"
+      done
+
 
       # Now prepare to actually exec the command.
       exec_cmd="\$cmd$args"
@@ -6775,9 +6821,9 @@ The following components of LINK-COMMAND are treated specially:
   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
   -export-symbols SYMFILE
-		    try to export only the symbols listed in SYMFILE
+                    try to export only the symbols listed in SYMFILE
   -export-symbols-regex REGEX
-		    try to export only the symbols matching REGEX
+                    try to export only the symbols matching REGEX
   -LLIBDIR          search LIBDIR for required installed libraries
   -lNAME            OUTPUT-FILE requires the installed library libNAME
   -module           build a library that can dlopened
@@ -6791,9 +6837,11 @@ The following components of LINK-COMMAND are treated specially:
   -release RELEASE  specify package release information
   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
-  -static           do not do any dynamic linking of libtool libraries
+  -static           do not do any dynamic linking of uninstalled libtool libraries
+  -static-libtool-libs
+                    do not do any dynamic linking of libtool libraries
   -version-info CURRENT[:REVISION[:AGE]]
-		    specify library version info [each variable defaults to 0]
+                    specify library version info [each variable defaults to 0]
 
 All other options (arguments beginning with \`-') are ignored.