From 3a4647af0ba3e81059765d086dfb2c3862afcfd3 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 29 Apr 2018 23:07:13 +0100 Subject: [PATCH] tools: Add bits we need for Rabbit R2K support There's not a lot we have to do at this level but pass a few differing flags. We should revisit fcc and the idea of z80/ z180/ r2k/ r3ka/ directories for libraries and crt0 ? --- Library/tools/fcc.c | 4 ++-- Library/tools/libclean | 4 ++-- Library/tools/syscall.c | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Library/tools/fcc.c b/Library/tools/fcc.c index 671b2df1..8fb42759 100644 --- a/Library/tools/fcc.c +++ b/Library/tools/fcc.c @@ -196,8 +196,8 @@ static void set_cpu(const char *p) exit(1); } cpu = mstrdup(p); - if (strcmp(cpu, "z80") && strcmp(cpu, "z180")) { - fprintf(stderr,"fcc: only z80 and z180 targets currently handled.\n"); + if (strcmp(cpu, "z80") && strcmp(cpu, "z180") && strcmp(cpu, "r2k") && strcmp(cpu, "r3ka")) { + fprintf(stderr,"fcc: only Zilog z80, z180 and Rabbit r2k/r3ka targets currently handled.\n"); exit(1); } } diff --git a/Library/tools/libclean b/Library/tools/libclean index 7fbdabf0..f4ab00de 100755 --- a/Library/tools/libclean +++ b/Library/tools/libclean @@ -4,7 +4,7 @@ # IMHO beats forking the library or building a private copy. # # -CPU=z80 +CPU=$1 LIBZ80=$(../../Kernel/tools/findsdcc $CPU) cp $LIBZ80/$CPU.lib tmp.lib @@ -20,4 +20,4 @@ sdar d tmp.lib printf_large.rel puts.rel gets.rel assert.rel time.rel sdar d tmp.lib tolower.rel toupper.rel _ltoa.rel _itoa.rel abs.rel atoi.rel # Added in 3.7.0rc so we can't rely on it yet and must always use our own sdar d tmp.lib strtoul.rel -mv tmp.lib sdccz80.lib +mv tmp.lib sdcc$CPU.lib diff --git a/Library/tools/syscall.c b/Library/tools/syscall.c index e417ae8b..b29e7972 100644 --- a/Library/tools/syscall.c +++ b/Library/tools/syscall.c @@ -8,11 +8,12 @@ #include "syscall_name.h" static char namebuf[128]; +static char *cpu; static void write_call(int n) { FILE *fp; - snprintf(namebuf, 128, "fuzix/syscall_%s.s", syscall_name[n]); + snprintf(namebuf, 128, "fuzix%s/syscall_%s.s", cpu, syscall_name[n]); fp = fopen(namebuf, "w"); if (fp == NULL) { perror(namebuf); @@ -36,13 +37,21 @@ static void write_call_table(void) static void write_makefile(void) { int i; - FILE *fp = fopen("fuzix/Makefile", "w"); + char path[256]; + FILE *fp; + + snprintf(path, 256, "fuzix%s/Makefile", cpu); + + fp = fopen(path, "w"); if (fp == NULL) { perror("Makefile"); exit(1); } fprintf(fp, "# Autogenerated by tools/syscall\n"); - fprintf(fp, "CROSS_AS=sdasz80\nCROSS_LD=sdldz80\nCROSS_AR=sdar\n"); + if (*cpu == 'z') + fprintf(fp, "CROSS_AS=sdasz80\nCROSS_LD=sdldz80\nCROSS_AR=sdar\n"); + else + fprintf(fp, "CROSS_AS=sdasrab\nCROSS_LD=sdldz80\nCROSS_AR=sdar\n"); fprintf(fp, "ASOPTS=\n\n"); fprintf(fp, "ASYS=syscall$(PLATFORM).s\n"); fprintf(fp, "ASRCS = syscall_%s.s\n", syscall_name[0]); @@ -62,6 +71,9 @@ static void write_makefile(void) int main(int argc, char *argv[]) { + cpu = argv[1]; + if (cpu == NULL) + cpu = "z80"; write_makefile(); write_call_table(); exit(0); -- 2.34.1