diff --git a/bin/smartlink b/bin/smartlink
index b7124d8e7fb4c1beda6d5b6fe14a49e47893726d..6db0785848230fe0392623538b2b6cac1b1cfefa 100755
--- a/bin/smartlink
+++ b/bin/smartlink
@@ -72,7 +72,7 @@ while test "$#" != 0; do
       # Strip '-Wl,' if the linker is ld
 
       if test $LINKER_IS_LD = yes; then
-        LDOPTS="$LDOPTS `echo $1|sed -e 's/^-Wl,//'`"
+        LDOPTS="$LDOPTS `echo $1|sed -e 's/^-Wl,//'|sed -e 's/,/ /g'`"
       else
         LDOPTS="$LDOPTS $1"
       fi
diff --git a/src/smartlink.c b/src/smartlink.c
index 5fbd6f05d616d622c4b20bdd3d903b7fda1fea94..21e5c3011c11c153b2974b3ccc7199558bfedd4b 100644
--- a/src/smartlink.c
+++ b/src/smartlink.c
@@ -1,5 +1,5 @@
 /*
- * $Id: smartlink.c,v 1.5 2000/02/20 00:08:47 hubbe Exp $
+ * $Id: smartlink.c,v 1.6 2000/03/25 22:46:29 hubbe Exp $
  *
  * smartlink - A smarter linker.
  * Based on the /bin/sh script smartlink 1.23.
@@ -87,7 +87,7 @@ int main(int argc, char **argv)
 
   if (!strcmp(argv[1], "-v")) {
     fprintf(stdout,
-	    "$Id: smartlink.c,v 1.5 2000/02/20 00:08:47 hubbe Exp $\n"
+	    "$Id: smartlink.c,v 1.6 2000/03/25 22:46:29 hubbe Exp $\n"
 	    "Usage:\n"
 	    "\t%s binary [args]\n",
 	    argv[0]);
@@ -132,8 +132,8 @@ int main(int argc, char **argv)
   rpath[0] = 0;
   lpath[0] = 0;
 
-  /* 5 extra args should be enough... */
-  if (!(new_argv = malloc(sizeof(char *)*(argc + 5)))) {
+  /* 150 extra args should be enough... */
+  if (!(new_argv = malloc(sizeof(char *)*(argc + 150)))) {
     fatal("Out of memory (5)!\n");
   }
 
@@ -214,7 +214,17 @@ int main(int argc, char **argv)
 	if (new_argv[i][0] == '-' && new_argv[i][1]=='W' &&
 	    new_argv[i][2]=='l' && new_argv[i][3]==',')
 	{
+	  char *ptr;
 	  new_argv[i]=new_argv[i]+4;
+
+	  while((ptr=strchr(new_argv[i],',')))
+	  {
+	    int e;
+	    *ptr=0;
+	    for(e=argc;e>=i;e--) new_argv[e+1]=new_argv[e];
+	    new_argv[i+1]=ptr+1;
+	    i++;
+	  }
 	}
       }
     }