From 252d71f1b89c039b81a9d6cdf6469395f8fbf164 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Thu, 11 Jul 2019 21:21:54 -0400 Subject: [PATCH] Make tools/emul *BSD-friendly --- tools/cfspack/cfspack.c | 4 ++-- tools/emul/Makefile | 4 ++-- tools/emul/shell/shell.c | 4 ++-- tools/zasm.sh | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/cfspack/cfspack.c b/tools/cfspack/cfspack.c index 9e9094f..f222c79 100644 --- a/tools/cfspack/cfspack.c +++ b/tools/cfspack/cfspack.c @@ -1,8 +1,8 @@ -#define _GNU_SOURCE #include #include #include #include +#include #include #define BLKSIZE 0x100 @@ -106,7 +106,7 @@ int spitdir(char *path, char *prefix, char *pattern) } } else { if (pattern) { - if (fnmatch(pattern, ep->d_name, FNM_EXTMATCH) != 0) { + if (fnmatch(pattern, ep->d_name, 0) != 0) { continue; } } diff --git a/tools/emul/Makefile b/tools/emul/Makefile index 372a809..f758068 100644 --- a/tools/emul/Makefile +++ b/tools/emul/Makefile @@ -26,11 +26,11 @@ $(TARGETS): $(CC) $< libz80/libz80.o -o $@ libz80/libz80.o: libz80/z80.c - make -C libz80/codegen opcodes + $(MAKE) -C libz80/codegen opcodes $(CC) -Wall -ansi -g -c -o libz80/libz80.o libz80/z80.c $(CFSPACK): - make -C ../cfspack + $(MAKE) -C ../cfspack $(SHELLAPPS): $(ZASMBIN) $(ZASMSH) $(KERNEL) $(APPS) shell/user.h < $(APPS)/$(notdir $@)/glue.asm > $@ diff --git a/tools/emul/shell/shell.c b/tools/emul/shell/shell.c index 5fac826..97d8714 100644 --- a/tools/emul/shell/shell.c +++ b/tools/emul/shell/shell.c @@ -52,11 +52,11 @@ static uint8_t io_read(int unused, uint16_t addr) { addr &= 0xff; if (addr == STDIO_PORT) { - uint8_t c = getchar(); + int c = getchar(); if (c == EOF) { running = 0; } - return c; + return (uint8_t)c; } else if (addr == FS_DATA_PORT) { if (fsdev_addr_lvl != 0) { fprintf(stderr, "Reading FSDEV in the middle of an addr op (%d)\n", fsdev_ptr); diff --git a/tools/zasm.sh b/tools/zasm.sh index 584ea2c0..574f91b 100755 --- a/tools/zasm.sh +++ b/tools/zasm.sh @@ -1,13 +1,14 @@ -#!/bin/bash +#!/bin/sh # wrapper around ./emul/zasm/zasm that prepares includes CFS prior to call -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +DIR=$(dirname $(readlink -f "$0")) ZASMBIN="${DIR}/emul/zasm/zasm" CFSPACK="${DIR}/cfspack/cfspack" INCCFS=$(mktemp) for p in "$@"; do - "${CFSPACK}" "${p}" "*.+(asm|h)" >> "${INCCFS}" + "${CFSPACK}" "${p}" "*.h" >> "${INCCFS}" + "${CFSPACK}" "${p}" "*.asm" >> "${INCCFS}" done "${ZASMBIN}" "${INCCFS}"