From 3744bec21887a844157a12bbca46db1c551170a6 Mon Sep 17 00:00:00 2001 From: Leonid Plyushch Date: Fri, 24 Jan 2020 21:11:03 +0200 Subject: [PATCH] new package: 8086tiny Requested in https://github.com/termux/termux-packages/issues/4828. --- packages/8086tiny/8086tiny.sh | 83 +++++++++++++++++++++++++++ packages/8086tiny/Makefile.patch | 27 +++++++++ packages/8086tiny/build.sh | 23 ++++++++ packages/8086tiny/timeb-android.patch | 41 +++++++++++++ 4 files changed, 174 insertions(+) create mode 100755 packages/8086tiny/8086tiny.sh create mode 100644 packages/8086tiny/Makefile.patch create mode 100644 packages/8086tiny/build.sh create mode 100644 packages/8086tiny/timeb-android.patch diff --git a/packages/8086tiny/8086tiny.sh b/packages/8086tiny/8086tiny.sh new file mode 100755 index 000000000..779081e71 --- /dev/null +++ b/packages/8086tiny/8086tiny.sh @@ -0,0 +1,83 @@ +#!@TERMUX_PREFIX@/bin/bash + +VERSION="@PACKAGE_VERSION@" + +PROGRAM="@TERMUX_PREFIX@/libexec/8086tiny" +BIOS_IMAGE="" +FD_IMAGE="" +HDD_IMAGE="" + +cleanup() { + stty cooked echo + echo +} + +usage() { + echo "Usage: 8086tiny [bios image] [floppy image] [harddisk image]" + echo + echo "8086tiny is a tiny, free, open source, portable Intel PC emulator/VM." + echo + echo "Options:" + echo + echo " -h, --help show this help and exit" + echo " -v, --version show version information" + echo +} + +while (( $# > 0 )); do + case "$1" in + -h|--help) + usage + exit 0 + ;; + -v|--version) + echo "8086tiny $VERSION" + exit 0 + ;; + -*) + echo "Unknown option '$1'." + echo + usage + exit 1 + ;; + *) + if [ -z "$BIOS_IMAGE" ]; then + BIOS_IMAGE="$1" + shift 1 + continue + fi + + if [ -z "$FD_IMAGE" ]; then + FD_IMAGE="$1" + shift 1 + continue + fi + + if [ -z "$HDD_IMAGE" ]; then + HDD_IMAGE="$1" + shift 1 + continue + fi + ;; + esac + shift 1 +done + +if [ -z "$BIOS_IMAGE" ]; then + BIOS_IMAGE="@TERMUX_PREFIX@/share/8086tiny/bios.bin" +fi + +if [ -z "$FD_IMAGE" ]; then + FD_IMAGE="@TERMUX_PREFIX@/share/8086tiny/dos.img" +fi + +trap cleanup INT TERM +stty cbreak raw -echo min 0 + +if [ -n "$HDD_IMAGE" ]; then + "$PROGRAM" "$BIOS_IMAGE" "$FD_IMAGE" "$HDD_IMAGE" +else + "$PROGRAM" "$BIOS_IMAGE" "$FD_IMAGE" +fi + +cleanup diff --git a/packages/8086tiny/Makefile.patch b/packages/8086tiny/Makefile.patch new file mode 100644 index 000000000..e44c041ae --- /dev/null +++ b/packages/8086tiny/Makefile.patch @@ -0,0 +1,27 @@ +diff -uNr 8086tiny/Makefile 8086tiny.mod/Makefile +--- 8086tiny/Makefile 2014-03-20 01:08:16.000000000 +0200 ++++ 8086tiny.mod/Makefile 2020-01-24 20:38:58.709164842 +0200 +@@ -7,22 +7,19 @@ + # 8086tiny_slowcpu improves graphics performance on slow platforms (e.g. Raspberry Pi) + # no_graphics compiles without SDL graphics/sound + +-OPTS_ALL=-O3 -fsigned-char -std=c99 ++OPTS_ALL=$(CPPFLAGS) $(CFLAGS) -fsigned-char -std=c99 + OPTS_SDL=`sdl-config --cflags --libs` + OPTS_NOGFX=-DNO_GRAPHICS + OPTS_SLOWCPU=-DGRAPHICS_UPDATE_DELAY=25000 + + 8086tiny: 8086tiny.c + ${CC} 8086tiny.c ${OPTS_SDL} ${OPTS_ALL} -o 8086tiny +- strip 8086tiny + + 8086tiny_slowcpu: 8086tiny.c + ${CC} 8086tiny.c ${OPTS_SDL} ${OPTS_ALL} ${OPTS_SLOWCPU} -o 8086tiny +- strip 8086tiny + + no_graphics: 8086tiny.c + ${CC} 8086tiny.c ${OPTS_NOGFX} ${OPTS_ALL} -o 8086tiny +- strip 8086tiny + + clean: + rm 8086tiny diff --git a/packages/8086tiny/build.sh b/packages/8086tiny/build.sh new file mode 100644 index 000000000..e6589d1d8 --- /dev/null +++ b/packages/8086tiny/build.sh @@ -0,0 +1,23 @@ +TERMUX_PKG_HOMEPAGE=https://github.com/adriancable/8086tiny +TERMUX_PKG_DESCRIPTION="A PC XT-compatible emulator/virtual machine" +TERMUX_PKG_LICENSE="MIT" +TERMUX_PKG_VERSION=1.25 +# Version tag is unavailable. +TERMUX_PKG_SRCURL=https://github.com/adriancable/8086tiny/archive/c79ca2a34d96931d55ef724c815b289d0767ae3a.tar.gz +TERMUX_PKG_SHA256=ede246503a745274430fdee77ba639bc133a2beea9f161bff3f7132a03544bf6 +TERMUX_PKG_BUILD_IN_SRC=true + +termux_step_pre_configure() { + CPPFLAGS+=" -DNO_GRAPHICS" +} + +termux_step_make_install() { + install -Dm700 8086tiny "$TERMUX_PREFIX"/libexec/8086tiny + install -Dm600 bios "$TERMUX_PREFIX"/share/8086tiny/bios.bin + install -Dm600 fd.img "$TERMUX_PREFIX"/share/8086tiny/dos.img + + sed -e "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g" \ + -e "s|@PACKAGE_VERSION@|$TERMUX_PKG_VERSION|g" \ + "$TERMUX_PKG_BUILDER_DIR"/8086tiny.sh > "$TERMUX_PREFIX"/bin/8086tiny + chmod 700 "$TERMUX_PREFIX"/bin/8086tiny +} diff --git a/packages/8086tiny/timeb-android.patch b/packages/8086tiny/timeb-android.patch new file mode 100644 index 000000000..a34a0f8fd --- /dev/null +++ b/packages/8086tiny/timeb-android.patch @@ -0,0 +1,41 @@ +diff -uNr 8086tiny/8086tiny.c 8086tiny.mod/8086tiny.c +--- 8086tiny/8086tiny.c 2014-03-20 01:08:16.000000000 +0200 ++++ 8086tiny.mod/8086tiny.c 2020-01-24 20:36:56.725634080 +0200 +@@ -6,7 +6,37 @@ + // This work is licensed under the MIT License. See included LICENSE.TXT. + + #include ++#ifndef __ANDROID__ + #include ++#else ++struct timeb { ++ time_t time; /* Seconds since epoch, as from `time'. */ ++ unsigned short int millitm; /* Additional milliseconds. */ ++ short int timezone; /* Minutes west of GMT. */ ++ short int dstflag; /* Nonzero if Daylight Savings Time used. */ ++}; ++ ++int ftime(struct timeb *tb) ++{ ++ struct timeval tv; ++ struct timezone tz; ++ ++ if (gettimeofday (&tv, &tz) < 0) ++ return -1; ++ ++ tb->time = tv.tv_sec; ++ tb->millitm = (tv.tv_usec + 500) / 1000; ++ ++ if (tb->millitm == 1000) { ++ ++tb->time; ++ tb->millitm = 0; ++ } ++ tb->timezone = tz.tz_minuteswest; ++ tb->dstflag = tz.tz_dsttime; ++ ++ return 0; ++} ++#endif + #include + + #ifndef _WIN32