tools: Add bits we need for Rabbit R2K support
authorAlan Cox <alan@linux.intel.com>
Sun, 29 Apr 2018 22:07:13 +0000 (23:07 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 29 Apr 2018 22:07:13 +0000 (23:07 +0100)
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
Library/tools/libclean
Library/tools/syscall.c

index 671b2df..8fb4275 100644 (file)
@@ -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);
   }
 }
index 7fbdabf..f4ab00d 100755 (executable)
@@ -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
index e417ae8..b29e797 100644 (file)
@@ -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);