sh: fix all the build messes
authorAlan Cox <alan@linux.intel.com>
Sun, 7 Oct 2018 21:48:15 +0000 (22:48 +0100)
committerAlan Cox <alan@linux.intel.com>
Sun, 7 Oct 2018 21:48:15 +0000 (22:48 +0100)
Applications/V7/cmd/sh/Makefile.6502
Applications/V7/cmd/sh/Makefile.6809
Applications/V7/cmd/sh/Makefile.z80
Applications/V7/cmd/sh/defs.h
Applications/V7/cmd/sh/macro.c
Applications/V7/cmd/sh/main.c
Applications/V7/cmd/sh/name.c
Applications/V7/cmd/sh/xec.c

index 1e59fd1..cbff2c5 100644 (file)
@@ -17,7 +17,7 @@ SRCS  = args.c blok.c builtin.c cmd.c ctype.c error.c expand.c fault.c io.c \
 INCS  = brkincr.h ctype.h defs.h mac.h mode.h name.h stak.h sym.h timeout.h
 
 OBJS = $(SRCS:.c=.o)
-FOBJS = $(patsubst %.c,fshbuild/%.o, $(SRCS))
+FOBJS = $(patsubst %.c,fshbuild_%.o, $(SRCS))
 
 LIBS = ../../../../Library/libs/c6502.lib
 
@@ -36,12 +36,14 @@ $(FOBJS): $(INCS)
 $(OBJS): %.o : %.c
        $(CC) -c $(CFLAGS) $(COPT) $<
 
-$(FOBJS): fshbuild/%.o: %.c
-       $(CC) -c $(CFLAGS) -c -DBUILD_FSH $< -o $@
+$(FOBJS): fshbuild_%.o: %.c
+       # -c and -o is busted if used together in cc65
+       cp $< fshbuild_$<
+       $(CC) -c $(CFLAGS) -c -DBUILD_FSH fshbuild_$<
 
 
 clean: 
-       rm -f $(OBJS) fsh sh *~ core
+       rm -f $(OBJS) $(FOBJS) fsh sh *~ core
 
 rmbak:
        rm -f *~ core
index 2677e51..acf9f3e 100644 (file)
@@ -37,13 +37,13 @@ $(FOBJS): fshbuild/%.o: %.c
        $(CC) -c $(CFLAGS) $(COPT) -DBUILD_FSH $< -o $@
 
 sh: $(OBJS) $(CRT0)
-       $(LINKER) -o $@ $(LINKER_OPT) $^
+       $(LINKER) -o  $@ $(LINKER_OPT) $(CRT0) $^
 
 fsh: $(FOBJS)
-       $(LINKER) -o $@ $(LINKER_OPT) $^ -lreadline6809
+       $(LINKER) -o $@ $(LINKER_OPT) $(CRT0) $^ -lreadline6809
 
 clean:
-       rm -f $(OBJS) fsh sh $(SRCS:.c=) core *~
+       rm -f $(OBJS) $(FOBJS) fsh sh $(SRCS:.c=) core *~
 
 rmbak:
        rm -f *~ core
index c661a79..6d37767 100644 (file)
@@ -30,7 +30,7 @@ $(FOBJS): fshbuild/%.rel: %.c
        $(FCC) $(Z80_PLATFORM) -c -DBUILD_FSH $< -o $@
 
 clean:
-       rm -f $(OBJS) sh $(SRCS:.c=) core *~ *.asm *.lst *.sym *.map *.noi *.lk *.ihx *.tmp *.bin
+       rm -f $(OBJS) fsh sh $(SRCS:.c=) core *~ *.asm *.lst *.sym *.map *.noi *.lk *.ihx *.tmp *.bin
 
 rmbak:
        rm -f *~ core
index 4a2fa70..8cea066 100644 (file)
 #include <sys/times.h>
 #include <errno.h>
 
+/* Figure out if we have to deal with bigger buffers specially due to cc65
+   limits. Really cc65 needs fixing. */
+#if defined(__CC65__) && defined(BUILD_FSH)
+#define static6502     static
+#else
+#define static6502
+#endif
+
 /*
  *     UNIX shell
  */
index 534a87a..89beac5 100644 (file)
@@ -258,7 +258,7 @@ static void comsubst(void)
 void subst(int in, int ot)
 {
        register char c;
-       FILEBLK fb;
+       static6502 FILEBLK fb;
        register int count = CPYSIZ;
 
        push(&fb);
index 94a13e0..17bdda9 100644 (file)
@@ -38,7 +38,7 @@ static unsigned int inleft;
 static char *inptr;
 static char ineof;
 
-static int line_input(char *prmpt)
+static int line_input(const char *prmpt)
 {
        int l;
        if (!isatty(standin->fdes))
index 7bd9a9f..ece5e33 100644 (file)
@@ -108,7 +108,7 @@ void assign(NAMPTR n, const char *v)
 
 int readvar(char **names)
 {
-       FILEBLK fb;
+       static6502 FILEBLK fb;
        register FILE f = &fb;
        register char c;
        register int rc = 0;
index 98f6230..c31a278 100644 (file)
@@ -438,7 +438,7 @@ int execute(TREPTR argt, int execflg, int *pf1, int *pf2)
 
 void execexp(char *s, UFD f)
 {
-       FILEBLK fb;
+       static6502 FILEBLK fb;
        push(&fb);
        if (s) {
                estabf(s);