summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-10-05 18:18:19 -0400
committerOri Bernstein <ori@eigenstate.org>2014-10-05 18:18:19 -0400
commitb8e1d4c0252943545bbcde039cc227401b8c03ab (patch)
treeed14ab8997a7d7bee3cadbe91f3d05bfb2b0da94
parent97540583eefeed60052f9831d68e7eb7bbbe8906 (diff)
downloadmc-b8e1d4c0252943545bbcde039cc227401b8c03ab.tar.gz
Add plan9 mkfiles and runtime.
-rw-r--r--6/mkfile15
-rw-r--r--libstd/mkfile66
-rw-r--r--mkfile46
-rw-r--r--muse/mkfile10
-rw-r--r--myrbuild/mkfile10
-rw-r--r--opt/mkfile13
-rw-r--r--parse/gram.y2
-rw-r--r--parse/mkfile29
-rw-r--r--parse/util.c8
-rw-r--r--rt/_myrrt-plan9.s19
-rw-r--r--rt/mkfile6
11 files changed, 220 insertions, 4 deletions
diff --git a/6/mkfile b/6/mkfile
new file mode 100644
index 0000000..c7c0b82
--- /dev/null
+++ b/6/mkfile
@@ -0,0 +1,15 @@
+</$objtype/mkfile
+CC=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse -I../opt
+LDFLAGS=-L../parse -lparse -L../opt -lopt
+
+TARG=6m
+OFILES=isel.$O \
+ locs.$O \
+ main.$O \
+ ra.$O \
+ simp.$O \
+
+LIB=../parse/libparse.a ../opt/libopt.a
+
+</sys/src/cmd/mkone \ No newline at end of file
diff --git a/libstd/mkfile b/libstd/mkfile
new file mode 100644
index 0000000..5eb297e
--- /dev/null
+++ b/libstd/mkfile
@@ -0,0 +1,66 @@
+MYRLIB=std
+MYRSRC= \
+ alloc.myr \
+ bigint.myr \
+ bitset.myr \
+ blat.myr \
+ chartype.myr \
+ cmp.myr \
+ dial.myr \
+ die.myr \
+ dir.myr \
+ endian.myr \
+ env.myr \
+ execvp.myr \
+ extremum.myr \
+ fltbits.myr \
+ fmt.myr \
+ fltfmt.myr \
+ hashfuncs.myr \
+ hasprefix.myr \
+ hassuffix.myr \
+ htab.myr \
+ ifreq.myr \
+ intparse.myr \
+ ipparse.myr \
+ mk.myr \
+ now.myr \
+ option.myr \
+ optparse.myr \
+ pathjoin.myr \
+ rand.myr \
+ resolve.myr \
+ result.myr \
+ search.myr \
+ slcp.myr \
+ sldup.myr \
+ sleq.myr \
+ slfill.myr \
+ sljoin.myr \
+ slpush.myr \
+ slput.myr \
+ slurp.myr \
+ sort.myr \
+ spork.myr \
+ strfind.myr \
+ strjoin.myr \
+ strsplit.myr \
+ strstrip.myr \
+ swap.myr \
+ sys.myr \
+ try.myr \
+ types.myr \
+ units.myr \
+ utf.myr \
+ varargs.myr \
+ waitstatus.myr \
+
+all: lib$MYRLIB.a test
+
+test: libstd.a test.myr ../6/$O.out
+ ../myrbuild/myrbuild -C../6/$O.out -M../muse/muse -b test -I. -r../rt/_myrrt.o test.myr
+
+
+lib$MYRLIB.a: $MYRSRC $ASMSRC
+ ../myrbuild/$O.out -C../6/$O.out -M../muse/$O.out -l $MYRLIB $MYRSRC $ASMSRC
+
diff --git a/mkfile b/mkfile
new file mode 100644
index 0000000..726282b
--- /dev/null
+++ b/mkfile
@@ -0,0 +1,46 @@
+</$objtype/mkfile
+
+SUB = parse \
+ opt \
+ 6 \
+ muse \
+ myrbuild \
+ rt \
+ libstd \
+ doc
+
+all:V: $SUB config.h
+ for(dir in $SUB)@{
+ cd $dir
+ mk $MKFLAGS
+ }
+nuke:V: $SUB
+ rm -f config.h
+ rm -f config.mk
+ for(dir in $SUB)@{
+ cd $dir
+ mk $MKFLAGS nuke
+ }
+
+clean:V: $SUB config.h
+ for(dir in $SUB)@{
+ cd $dir
+ mk $MKFLAGS clean
+ }
+
+install:V: $SUB config.h
+ for(dir in $SUB)@{
+ cd $dir
+ mk $MKFLAGS install
+ }
+
+uninstall:V: $SUB config.h
+ for(dir in $SUB)@{
+ cd $dir
+ mk $MKFLAGS
+ }
+
+config.h:
+ echo '#define Instroot "'/'"' > config.h
+ echo '#define Asmcmd {"6a", "-o", NULL}' >> config.h
+ echo '#define Symprefix "_"' >> config.h
diff --git a/muse/mkfile b/muse/mkfile
new file mode 100644
index 0000000..59c13fb
--- /dev/null
+++ b/muse/mkfile
@@ -0,0 +1,10 @@
+</$objtype/mkfile
+CC=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse -I../opt
+LDFLAGS=-L../parse -lparse -L../opt -lopt
+
+TARG=muse
+OFILES=muse.$O
+LIB=../parse/libparse.a ../opt/libopt.a
+
+</sys/src/cmd/mkone \ No newline at end of file
diff --git a/myrbuild/mkfile b/myrbuild/mkfile
new file mode 100644
index 0000000..e373665
--- /dev/null
+++ b/myrbuild/mkfile
@@ -0,0 +1,10 @@
+</$objtype/mkfile
+CC=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse -I../opt
+LDFLAGS=-L../parse -lparse -L../opt -lopt
+
+TARG=myrbuild
+OFILES=myrbuild.$O
+LIB=../parse/libparse.a ../opt/libopt.a
+
+</sys/src/cmd/mkone \ No newline at end of file
diff --git a/opt/mkfile b/opt/mkfile
new file mode 100644
index 0000000..a5dbe82
--- /dev/null
+++ b/opt/mkfile
@@ -0,0 +1,13 @@
+</$objtype/mkfile
+CC=pcc
+LD=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse
+
+LIB=libopt.a
+OFILES=cfg.$O \
+ fold.$O \
+ df.$O
+
+HFILES=opt.h
+
+</sys/src/cmd/mklib
diff --git a/parse/gram.y b/parse/gram.y
index 44bb0fd..2d1475e 100644
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
-#include <stdint.h>
+#include <inttypes.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
diff --git a/parse/mkfile b/parse/mkfile
new file mode 100644
index 0000000..d2053e8
--- /dev/null
+++ b/parse/mkfile
@@ -0,0 +1,29 @@
+</$objtype/mkfile
+CC=pcc
+LD=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION
+
+LIB=libparse.a
+OFILES=bitset.$O \
+ dump.$O \
+ gram.$O \
+ htab.$O \
+ infer.$O \
+ names.$O \
+ node.$O \
+ specialize.$O \
+ stab.$O \
+ tok.$O \
+ type.$O \
+ use.$O \
+ util.$O
+
+HFILES=parse.h
+CLEANFILES=gram.c gram.h
+
+</sys/src/cmd/mklib
+
+gram.c gram.h: gram.y
+ yacc -d -S gram.y
+ mv y.tab.c gram.c
+ mv y.tab.h gram.h
diff --git a/parse/util.c b/parse/util.c
index ea42f56..d65da39 100644
--- a/parse/util.c
+++ b/parse/util.c
@@ -1,6 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
-#include <stdint.h>
+#include <inttypes.h>
#include <stdarg.h>
#include <ctype.h>
#include <string.h>
@@ -40,7 +40,7 @@ void *zrealloc(void *mem, size_t oldsz, size_t sz)
p = xrealloc(mem, sz);
if (sz > oldsz)
- bzero(&p[oldsz], sz - oldsz);
+ memset(&p[oldsz], 0, sz - oldsz);
return p;
}
@@ -210,11 +210,13 @@ long host32(byte buf[4])
return v;
}
-void wrbuf(FILE *fd, void *buf, size_t sz)
+void wrbuf(FILE *fd, void *p, size_t sz)
{
size_t n;
+ char *buf;
n = 0;
+ buf = p;
while (n < sz) {
n += fwrite(buf + n, 1, sz - n, fd);
if (feof(fd))
diff --git a/rt/_myrrt-plan9.s b/rt/_myrrt-plan9.s
new file mode 100644
index 0000000..c9d5853
--- /dev/null
+++ b/rt/_myrrt-plan9.s
@@ -0,0 +1,19 @@
+#define NPRIVATES 16
+
+TEXT _main(SB), 1, $(2*8+NPRIVATES*8)
+ MOVQ AX, _tos(SB)
+ LEAQ 16(SP), AX
+ MOVQ AX, _privates(SB)
+ MOVL $NPRIVATES, _nprivates(SB)
+ MOVL inargc-8(FP), RARG
+ LEAQ inargv+0(FP), AX
+ MOVQ AX, 8(SP)
+ CALL main(SB)
+
+loop:
+ MOVQ $_exits<>(SB), RARG
+ CALL exits(SB)
+ JMP loop
+
+DATA _exits<>+0(SB)/4, $"main"
+GLOBL _exits<>+0(SB), $5
diff --git a/rt/mkfile b/rt/mkfile
new file mode 100644
index 0000000..18e4310
--- /dev/null
+++ b/rt/mkfile
@@ -0,0 +1,6 @@
+</$objtype/mkfile
+
+_myrrt.$O: _myrrt-plan9.s
+ $AS -o _myrrt.$O _myrrt-plan9.s
+
+</sys/src/cmd/mkone