summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-12-25 23:49:49 -0800
committerOri Bernstein <ori@eigenstate.org>2014-12-25 23:49:49 -0800
commit2ae44d1d451a3d8834c3fb47993ba2fc20d3a343 (patch)
treea903b19cdcb2b25302c93c94de56266c8ef9b969
parenta349fd1e69f7381661b772b84d910e2e0ad807c4 (diff)
downloadmc-2ae44d1d451a3d8834c3fb47993ba2fc20d3a343.tar.gz
Handle objfile suffixes correctly.
-rw-r--r--6/main.c4
-rwxr-xr-xconfigure1
-rw-r--r--mkfile3
-rw-r--r--myrbuild/myrbuild.c20
4 files changed, 17 insertions, 11 deletions
diff --git a/6/main.c b/6/main.c
index 2bcd6ff..70167c9 100644
--- a/6/main.c
+++ b/6/main.c
@@ -58,9 +58,9 @@ static void assemble(char *asmsrc, char *path)
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++)
diff --git a/configure b/configure
index d8f61f3..34ced8f 100755
--- a/configure
+++ b/configure
@@ -39,6 +39,7 @@ echo '#define Asmcmd {"as", "-g", "-o", NULL}' >> config.h
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*)
diff --git a/mkfile b/mkfile
index 706d865..2a580b6 100644
--- a/mkfile
+++ b/mkfile
@@ -41,10 +41,11 @@ uninstall:V: $SUB config.h
}
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
diff --git a/myrbuild/myrbuild.c b/myrbuild/myrbuild.c
index 35fe134..c1741c3 100644
--- a/myrbuild/myrbuild.c
+++ b/myrbuild/myrbuild.c
@@ -29,7 +29,7 @@ char *muse = "muse";
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 @@ void compile(char *file, char ***stack, size_t *nstack)
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 @@ void compile(char *file, char ***stack, size_t *nstack)
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 @@ void archive(char **files, size_t nfiles)
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 @@ void findlib(char *buf, size_t bufsz, char *lib)
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 @@ void linkobj(char **files, size_t nfiles)
}
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));