shithub: mc

Download patch

ref: 2ae44d1d451a3d8834c3fb47993ba2fc20d3a343
parent: a349fd1e69f7381661b772b84d910e2e0ad807c4
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Dec 25 18:49:49 EST 2014

Handle objfile suffixes correctly.

--- a/6/main.c
+++ b/6/main.c
@@ -58,9 +58,9 @@
 
     psuffix = strrchr(path, '+');
     if (psuffix != NULL)
-        swapsuffix(objfile, 1024, path, psuffix, ".o");
+        swapsuffix(objfile, 1024, path, psuffix, Objsuffix);
     else
-        swapsuffix(objfile, 1024, path, ".myr", ".o");
+        swapsuffix(objfile, 1024, path, ".myr", Objsuffix);
     cmd = NULL;
     ncmd = 0;
     for (p = asmcmd; *p != NULL; p++)
--- a/configure
+++ b/configure
@@ -39,6 +39,7 @@
 echo '#define Arcmd {"ar", "-rcs", NULL}' >> config.h
 echo '#define Ldcmd {"ld", "-o", NULL}' >> config.h
 echo '#define Defaultasm Gnugas' >> config.h
+echo '#define Objsuffix "o"' >> config.h
 echo 'export SYSCLASS=posixy' >> config.mk
 case $OS in
     *Linux*)
--- a/mkfile
+++ b/mkfile
@@ -41,10 +41,11 @@
 	}
 
 config.h:
-	echo '#define Instroot "'/'"' > config.h
+	echo '#define Instroot "/amd64"' > config.h
 	echo '#define Asmcmd {"6a", "-o", NULL}' >> config.h
 	echo '#define Arcmd {"ar", "ru", NULL}' >> config.h
 	echo '#define Ldcmd {"6l", "-l", "-o", NULL}' >> config.h
 	echo '#define Symprefix ""' >> config.h
 	echo '#define Defaultasm Plan9' >> config.h
+	echo '#define Objsuffix ".6"' >> config.h
 
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -29,7 +29,7 @@
 char *as[] = Asmcmd;
 char *ar[] = Arcmd;
 char *ld[] = Ldcmd;
-char *runtime = Instroot "/lib/myr/_myrrt.o";
+char *runtime = Instroot "/lib/myr/_myrrt";
 /* the name of the output file */
 char *libname;
 char *binname;
@@ -287,7 +287,7 @@
     htput(loopdetect, file, file);
     if (hassuffix(file, ".myr")) {
         swapsuffix(use, sizeof use, file, ".myr", ".use");
-        swapsuffix(obj, sizeof obj, file, ".myr", ".o");
+        swapsuffix(obj, sizeof obj, file, ".myr", Objsuffix);
         getdeps(file, deps, 512, &ndeps);
         for (i = 0; i < ndeps; i++) {
             if (isquoted(deps[i])) {
@@ -309,7 +309,7 @@
         gencmd(&cmd, &ncmd, mc, file, extra, nextra);
         run(cmd);
     } else if (hassuffix(file, ".s")) {
-        swapsuffix(obj, sizeof obj, file, ".s", ".o");
+        swapsuffix(obj, sizeof obj, file, ".s", Objsuffix);
         if (isfresh(file, obj))
             goto done;
         for (i = 1; as[i]; i++)
@@ -367,9 +367,9 @@
     lappend(&args, &nargs, strdup(buf));
     for (i = 0; i < nfiles; i++) {
         if (hassuffix(files[i], ".myr"))
-            swapsuffix(buf, sizeof buf, files[i], ".myr", ".o");
+            swapsuffix(buf, sizeof buf, files[i], ".myr", Objsuffix);
         else if (hassuffix(files[i], ".s"))
-            swapsuffix(buf, sizeof buf, files[i], ".s", ".o");
+            swapsuffix(buf, sizeof buf, files[i], ".s", Objsuffix);
         else
             die("Unknown file type %s", files[i]);
         lappend(&args, &nargs, strdup(buf));
@@ -392,6 +392,9 @@
         if (access(buf, F_OK) == 0)
             return;
     }
+    snprintf(buf, bufsz, "%s/lib/myr/lib%s.a", Instroot, lib);
+    if (access(buf, F_OK) == 0)
+        return;
     fail(1, "unable to find library lib%s.a\n", lib);
 }
 
@@ -458,15 +461,16 @@
     }
 
     if (runtime) {
-        lappend(&args, &nargs, strdup(runtime));
+        snprintf(buf, sizeof buf, "%s%s", runtime, Objsuffix);
+        lappend(&args, &nargs, strdup(buf));
     }
 
     /* ld -T ldscript -o outfile foo.o bar.o baz.o */
     for (i = 0; i < nfiles; i++) {
         if (hassuffix(files[i], ".myr"))
-            swapsuffix(buf, sizeof buf, files[i], ".myr", ".o");
+            swapsuffix(buf, sizeof buf, files[i], ".myr", Objsuffix);
         else if (hassuffix(files[i], ".s"))
-            swapsuffix(buf, sizeof buf, files[i], ".s", ".o");
+            swapsuffix(buf, sizeof buf, files[i], ".s", Objsuffix);
         else
             die("Unknown file type %s", files[i]);
         lappend(&args, &nargs, strdup(buf));