Fix minor bugs in xified C compiler and linker scripts, tidy up argument vector
authorNick Downing <downing.nick@gmail.com>
Thu, 2 Feb 2017 14:29:41 +0000 (01:29 +1100)
committerNick Downing <downing.nick@gmail.com>
Thu, 2 Feb 2017 14:29:41 +0000 (01:29 +1100)
xify/cc.sh
xify/ld.sh

index 05827bc..bc3fab5 100755 (executable)
@@ -217,18 +217,18 @@ then
         tmp_i="$tmp.i"
       fi
 
-      j=
+      av="$hostcpp $i"
       if test -z "$exflag"
       then
-        j=" $tmp_i"
+        av="$av $tmp_i"
       fi
+#      av="$av$plist"
+      av="$av -nostdinc -DX_ -Dunix -Dvax$plist -I$include"
       if test -n "$debug"
       then
-#        echo $hostcpp $i$j $plist
-        echo $hostcpp $i$j -nostdinc -DX_ -Dunix -Dvax$plist -I$include
+        echo $av
       fi
-#      if ! $hostcpp $i$j$plist
-      if ! $hostcpp $i$j -nostdinc -DX_ -Dunix -Dvax$plist -I$include
+      if ! $av
       then
         cflag=1
         eflag=1
@@ -240,15 +240,16 @@ then
         continue
       fi
 
-#      j=
+      av="$xify $tmp_i"
+# a bit horrible because we cannot redirect sed output to $tmp.c conditionally
+#      pattern='s/va_arg(x_argp, x_\(unsigned_\)\?\(short\|int\|long\))/_va_arg_\1\2(x_argp)/g'
 #      if test -z "$xflag"
 #      then
-## a bit horrible because we cannot redirect sed output to $tmp.c conditionally
 #        if test -n "$debug"
 #        then
-#          echo $xify $tmp_i "|"sed -e "'s/va_arg(x_argp, x_\\\\(unsigned_\\\\)\\\\?\\\\(short\\\\|int\\\\|long\\\\))/_va_arg_\\\\1\\\\2(x_argp)/g'" ">"$tmp.c
+#          echo $av "|"sed -e "'$pattern'" ">"$tmp.c
 #        fi
-#        if ! $xify $tmp_i |sed -e 's/va_arg(x_argp, x_\(unsigned_\)\?\(short\|int\|long\))/_va_arg_\1\2(x_argp)/g' >$tmp.c
+#        if ! $av |sed -e "$pattern" >$tmp.c
 #        then
 #          cflag=1
 #          eflag=1
@@ -257,9 +258,9 @@ then
 #      else
 #        if test -n "$debug"
 #        then
-#          echo $xify $tmp_i "|"sed -e "'s/va_arg(x_argp, x_\\(unsigned_\\)\\?\\(short\\|int\\|long\\))/_va_arg_\\1\\2(x_argp)/g'"
+#          echo $av "|"sed -e "'$pattern'"
 #        fi
-#        if ! $xify $tmp_i |sed -e 's/va_arg(x_argp, x_\(unsigned_\)\?\(short\|int\|long\))/_va_arg_\1\2(x_argp)/g'
+#        if ! $av |sed -e "$pattern"
 #        then
 #          cflag=1
 #          eflag=1
@@ -268,21 +269,21 @@ then
 #        cflag=1
 #        continue
 #      fi
-      j=
       if test -z "$xflag"
       then
-        j=" $tmp.c"
+        av="$av $tmp.c"
       fi
       if test -n "$debug"
       then
-        echo $xify $tmp_i$j
+        echo $av
       fi
-      if ! $xify $tmp_i$j
+      if ! $av
       then
         cflag=1
         eflag=1
         continue
       fi
+      $rm -f $tmp_i
       if test -n "$xflag"
       then
         cflag=1
@@ -302,40 +303,42 @@ then
         tmp_s="$tmp.c"
         assource="$tmp_s"
 # since we can't "goto" out of enclosing if, duplicate all code until "done"
+    #    av="$as -o"
+        av="$hostcc -o"
         if test -n "$cflag" -a $nc -eq 1 -a -n "$outfile"
         then
-          j="$outfile"
+          av="$av $outfile"
         else
-          j=`echo $i |sed -e 's/.$/o/'`
+          av="$av `echo $i |sed -e 's/.$/o/'`"
         fi
     #    if test -n "$Rflag"
     #    then
-    #      j="$j -R"
+    #      av="$av -R"
     #    fi
     #    if test -n "$dflag"
     #    then
-    #      j="$j $dflag"
+    #      av="$av $dflag"
     #    fi
-        j="$j -fno-strict-aliasing"
+        av="$av -fno-strict-aliasing"
         if test -n "$proflag"
         then
-          j="$j -pg"
+          av="$av -pg"
         fi
         if test -n "$gflag" -o -n "$Gflag"
         then
-          j="$j -g"
+          av="$av -g"
         fi
         if test -z "$wflag"
         then
-          j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
+          av="$av -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
         fi
+        av="$av -c $assource"
         if test -n "$debug"
         then
-    #      echo $as -o $j $assource
-          echo $hostcc -o $j -c $assource
+          echo $av
         fi
-    #    if ! $as -o $j $assource && $? -gt 1
-        if ! $hostcc -o $j -c $assource
+    #    if ! $av && $? -gt 1
+        if ! $av
         then
           cflag=1
           eflag=1
@@ -351,32 +354,37 @@ then
 # end
       fi
 
+#      if test -n "$fflag"
+#        av="$sccom"
+#      else
+#        av="$ccom"
+#      fi
 #      if test -n "$oflag"
 #      then
-#        k="$tmp.c2s"
+#        av="$av $tmp.c2s"
 #      else
-#        k="$tmp_s"
+#        av="$av $tmp_s"
 #      fi
 #      if test -n "$proflag"
 #      then
-#        k="$k -XP"
+#        av="$av -XP"
 #      fi
 #      if test -n "$gflag"
 #      then
-#        k="$k -Xg"
+#        av="$av -Xg"
 #      elif test -n "$Gflag"
 #      then
-#        k="$k -XG"
+#        av="$av -XG"
 #      fi
 #      if test -n "$wflag"
 #      then
-#        k="$k -w"
+#        av="$av -w"
 #      fi
 #      if test -n "$debug"
 #      then
-#        echo $j $tmp_i $k
+#        echo $av
 #      fi
-#      if ! $j $tmp_i $k
+#      if ! $av
 #      then
 #        cflag=1
 #        eflag=1
@@ -386,11 +394,12 @@ then
 #
 #      if test -n "$oflag"
 #      then
+#        av="$c2 $tmp.c2s $tmp_s"
 #        if test -n "$debug"
 #        then
-#          echo $c2 $tmp.c2s $tmp_s
+#          echo $av
 #        fi
-#        if ! $c2 $tmp.c2s $tmp_s
+#        if ! $av
 #        then
 #          $rm -f $tmp_s
 #          tmp_s="$tmp.c2s"
@@ -398,24 +407,25 @@ then
 #          $rm -f $tmp.c2s
 #        fi
 #      fi
-      j="$tmp_s -fno-strict-aliasing"
+      av="$hostcc -o $tmp_s -fno-strict-aliasing"
       if test -n "$proflag"
       then
-        j="$j -pg"
+        av="$av -pg"
       fi
       if test -n "$gflag" -o -n "$Gflag"
       then
-        j="$j -g"
+        av="$av -g"
       fi
       if test -z "$wflag"
       then
-        j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
+        av="$av -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
       fi
+      av="$av -S $tmp.c"
       if test -n "$debug"
       then
-        echo $hostcc -o $j -S $tmp.c
+        echo $av
       fi
-      if ! $hostcc -o $j -S $tmp.c
+      if ! $av
       then
         cflag=1
         eflag=1
@@ -430,40 +440,42 @@ then
 #      assource="$tmp_s"
     fi
 
+#    av="$as -o"
+    av="$hostcc -o"
     if test -n "$cflag" -a $nc -eq 1 -a -n "$outfile"
     then
-      j="$outfile"
+      av="$av $outfile"
     else
-      j=`echo $i |sed -e 's/.$/o/'`
+      av="$av `echo $i |sed -e 's/.$/o/'`"
     fi
 #    if test -n "$Rflag"
 #    then
-#      j="$j -R"
+#      av="$av -R"
 #    fi
 #    if test -n "$dflag"
 #    then
-#      j="$j $dflag"
+#      av="$av $dflag"
 #    fi
-    j="$j -fno-strict-aliasing"
+    av="$av -fno-strict-aliasing"
     if test -n "$proflag"
     then
-      j="$j -pg"
+      av="$av -pg"
     fi
     if test -n "$gflag" -o -n "$Gflag"
     then
-      j="$j -g"
+      av="$av -g"
     fi
     if test -z "$wflag"
     then
-      j="$j -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
+      av="$av -Wall -Wno-char-subscripts -Wno-deprecated-declarations -Wno-maybe-uninitialized -Wno-parentheses -Wno-strict-aliasing -Wno-unused-result"
     fi
+    av="$av -c $assource"
     if test -n "$debug"
     then
-#      echo $as -o $j $assource
-      echo $hostcc -o $j -c $assource
+      echo $av
     fi
-#    if ! $as -o $j $assource && $? -gt 1
-    if ! $hostcc -o $j -c $assource
+#    if ! $av && $? -gt 1
+    if ! $av
     then
       cflag=1
       eflag=1
@@ -478,29 +490,28 @@ fi
 
 if test -z "$cflag" -a -n "$llist"
 then
+  av="$ld -X $crt0"
   if test -n "$outfile"
   then
-    j=" -o $outfile"
-  else
-    j=
+    av="$av -o $outfile"
   fi
   if test -n "$gflag" -o -n "$Gflag"
   then
-    k=" -lg"
-  else
-    k=
+    av="$av -lg"
   fi
+  av="$av$llist"
   if test -n "$proflag"
   then
-    k="$k -lc_p"
+    av="$av -lc_p"
   else
-    k="$k -lc"
+    av="$av -lc"
   fi
   if test -n "$debug"
   then
-    echo $ld -X $crt0$j $llist$k
+    av="$av -t"
+    echo $av
   fi
-  if ! $ld -X $crt0$j $llist$k
+  if ! $av
   then
     eflag=1
   elif test $nc -eq 1 -a $nxo -eq 1 -a -z "$eflag"
index 06d33be..ab9e6a3 100755 (executable)
@@ -150,27 +150,27 @@ fi
 
 if test -n "$rflag"
 then
-  cmd="$hostld"
+  av="$hostld"
 else
-  cmd="$hostcc"
+  av="$hostcc"
 fi
 if test -n "$outfile"
 then
-  cmd="$cmd -o $outfile"
+  av="$av -o $outfile"
 fi
 for i in $dirs
 do
-  cmd="$cmd -L$i/.xify"
+  av="$av -L$i/.xify"
 done
 if test -n "$rflag"
 then
-  cmd="$cmd -r"
+  av="$av -r"
 fi
 for i in $files
 do
   case "$i" in
   -lnox_*)
-    cmd="$cmd `echo $i |sed -e 's/^-lnox_/-l/'`"
+    av="$av `echo $i |sed -e 's/^-lnox_/-l/'`"
     ;;
   -l*)
     j=`echo $i |sed -e 's/^-l//'`
@@ -199,16 +199,16 @@ do
       fi
       $rm -f $k/.xify/libx_$j.a
     done
-    cmd="$cmd -lx_$j"
+    av="$av -lx_$j"
     ;;
   *)
-    cmd="$cmd $i"
+    av="$av $i"
     ;;
   esac
 done
 if test -n "$trace"
 then
-  echo $cmd
+  echo $av
 fi
-$cmd
+$av
 exit $?