diff --git a/.gitignore b/.gitignore index c7172ea..02f577c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,19 @@ orig *.IMG real-ld -objcopy -objdump *.o *.sw? coffsyrup 123 -ld binutils-* +as +objcopy +objdump +ld +gzip-* +gzip +gunzip +zcat drawtest *.a keymap/keymap diff --git a/Makefile b/Makefile index 04643d4..5976529 100644 --- a/Makefile +++ b/Makefile @@ -79,21 +79,34 @@ distclean: clean ./extract.sh clean install: all - install -Dm 755 "bin/123" "$(prefix)/bin/123" - install -Dm 644 "share/man/man1/123.1" "$(prefix)/share/man/man1/123.1" - install -Dm 644 "share/lotus/etc/l123set.cf" "$(prefix)/share/lotus/etc/l123set.cf" - find "share/lotus/keymaps" -type f -exec install -Dm 644 {} "$(prefix)/{}" \; - install -Dm 644 "share/lotus/123.v10/sysV386/lotus.bcf" "$(prefix)/share/lotus/123.v10/sysV386/lotus.bcf" - install -Dm 644 "share/lotus/123.v10/sysV386/lib/wyse50-lts123" "$(prefix)/share/lotus/123.v10/sysV386/lib/wyse50-lts123" - find "share/lotus/123.v10/cbd" -type f -exec install -Dm 644 {} "$(prefix)/{}" \; - find "share/lotus/123.v10/fonts" -type f -exec install -Dm 644 {} "$(prefix)/{}" \; - find "share/lotus/123.v10/hlp" -type f -exec install -Dm 644 {} "$(prefix)/{}" \; - find "share/lotus/123.v10/keymaps" -type f -exec install -Dm 644 {} "$(prefix)/{}" \; - find "share/lotus/123.v10/pbd" -type f -exec install -Dm 644 {} "$(prefix)/{}" \; - find "share/lotus/123.v10/ri" -type f -exec install -Dm 644 {} "$(prefix)/{}" \; - find "share/lotus/123.v10/smpfiles" -type f -exec install -Dm 644 {} "$(prefix)/{}" \; + install -m 0755 -d "$(prefix)/bin" + install -m 0755 "bin/123" "$(prefix)/bin/123" + install -m 0755 -d "$(prefix)/share/man/man1" + install -m 0644 "share/man/man1/123.1" "$(prefix)/share/man/man1/123.1" + install -m 0755 -d "$(prefix)/share/lotus/etc" + install -m 0644 "share/lotus/etc/l123set.cf" "$(prefix)/share/lotus/etc/l123set.cf" + find "share/lotus/keymaps" -type d -exec install -m 0755 -d "$(prefix)/{}" \; + find "share/lotus/keymaps" -type f -exec install -m 0644 {} "$(prefix)/{}" \; + install -m 0755 -d "$(prefix)/share/lotus/123.v10/sysV386" + install -m 0644 "share/lotus/123.v10/sysV386/lotus.bcf" "$(prefix)/share/lotus/123.v10/sysV386/lotus.bcf" + install -m 0755 -d "$(prefix)/share/lotus/123.v10/sysV386/lib" + install -m 0644 "share/lotus/123.v10/sysV386/lib/wyse50-lts123" "$(prefix)/share/lotus/123.v10/sysV386/lib/wyse50-lts123" + find "share/lotus/123.v10/cbd" -type d -exec install -m 0755 -d "$(prefix)/{}" \; + find "share/lotus/123.v10/cbd" -type f -exec install -m 0644 {} "$(prefix)/{}" \; + find "share/lotus/123.v10/fonts" -type d -exec install -m 0755 -d "$(prefix)/{}" \; + find "share/lotus/123.v10/fonts" -type f -exec install -m 0644 {} "$(prefix)/{}" \; + find "share/lotus/123.v10/hlp" -type d -exec install -m 0755 -d "$(prefix)/{}" \; + find "share/lotus/123.v10/hlp" -type f -exec install -m 0644 {} "$(prefix)/{}" \; + find "share/lotus/123.v10/keymaps" -type d -exec install -m 0755 -d "$(prefix)/{}" \; + find "share/lotus/123.v10/keymaps" -type f -exec install -m 0644 {} "$(prefix)/{}" \; + find "share/lotus/123.v10/pbd" -type d -exec install -m 0755 -d "$(prefix)/{}" \; + find "share/lotus/123.v10/pbd" -type f -exec install -m 0644 {} "$(prefix)/{}" \; + find "share/lotus/123.v10/ri" -type d -exec install -m 0755 -d "$(prefix)/{}" \; + find "share/lotus/123.v10/ri" -type f -exec install -m 0644 {} "$(prefix)/{}" \; + find "share/lotus/123.v10/smpfiles" -type d -exec install -m 0755 -d "$(prefix)/{}" \; + find "share/lotus/123.v10/smpfiles" -type f -exec install -m 0644 {} "$(prefix)/{}" \; uninstall: - $(RM) "$(prefix)/bin/123" - $(RM) "$(prefix)/share/man/man1/123.1" - $(RM) -r "$(prefix)/share/lotus" + rm -f "$(prefix)/bin/123" + rm -f "$(prefix)/share/man/man1/123.1" + rm -rf "$(prefix)/share/lotus" diff --git a/binutils.sh b/binutils.sh index d6b642d..6f0cc47 100755 --- a/binutils.sh +++ b/binutils.sh @@ -4,55 +4,55 @@ BINUTILS_DL="https://ftp.gnu.org/gnu/binutils" BINUTILS_XZ="binutils-2.38.tar.xz" BINUTILS_DIR="$(basename $BINUTILS_XZ .tar.xz)" BINUTILS_URL="$BINUTILS_DL/$BINUTILS_XZ" -ORIG_DIR="$(pwd)" +ORIGIN_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" -# Dont continue on error. -set -e +# Make sure we have GNU make +. "$ORIGIN_DIR/detect-gnu-make.sh" # Help text. if [ "$1" = '-h' ]; then - echo >&2 "Usage: $0 [clean]" - echo >&2 - echo >&2 'Specify "clean" to remove binutils, otherwise it will be downloaded and built.' - exit 1 + echo >&2 "Usage: $0 [clean]" + echo >&2 + echo >&2 'Specify "clean" to remove binutils, otherwise it will be downloaded and built.' + exit 1 fi # Optional cleanup if requested. if [ "$1" = 'clean' ]; then - rm -fv objcopy objdump ld "$BINUTILS_XZ" - rm -rfv "$BINUTILS_DIR" - exit + rm -fv "$ORIGIN_DIR/objcopy" "$ORIGIN_DIR/objdump" "$ORIGIN_DIR/ld" "$ORIGIN_DIR/as" + rm -rf "$BINUTILS_DIR" + rm -fv "$ORIGIN_DIR/$BINUTILS_XZ" + exit fi # Download binutils. if [ ! -f "$BINUTILS_XZ" ]; then - wget "$BINUTILS_URL" + wget "$BINUTILS_URL" fi # Extract binutils. if [ ! -d "$BINUTILS_DIR" ]; then - tar xf "$BINUTILS_XZ" + xzcat "$BINUTILS_XZ" | tar xf - fi # Compile binutils. if [ ! -x "$BINUTILS_DIR/binutils/objcopy" ]; then - cd "$BINUTILS_DIR" - ./configure --enable-targets=i386-pc-elf32 \ - --disable-gas \ - --disable-libctf \ - --disable-plugins \ - --disable-gprof \ - --enable-compressed-debug-sections=none - - make all-ld -j$(nproc) MAKEINFO=true + cd "$BINUTILS_DIR" && \ + ./configure --enable-targets=i386-pc-elf32 \ + --disable-libctf \ + --disable-plugins \ + --disable-gprof \ + --enable-compressed-debug-sections=none && \ + "$gnu_make" all-ld all-gas MAKEINFO=true + cd "$ORIGIN_DIR" fi # Copy compiled binaries to working directory. copy() { - test ! -x "$2" && cp -v "$1" "$2" + test ! -x "$2" && cp -v "$1" "$2" } -cd "$ORIG_DIR" -copy "$BINUTILS_DIR/binutils/objcopy" objcopy -copy "$BINUTILS_DIR/binutils/objdump" objdump -copy "$BINUTILS_DIR/ld/ld-new" ld +copy "$BINUTILS_DIR/binutils/objcopy" "$ORIGIN_DIR/objcopy" +copy "$BINUTILS_DIR/binutils/objdump" "$ORIGIN_DIR/objdump" +copy "$BINUTILS_DIR/ld/ld-new" "$ORIGIN_DIR/ld" +copy "$BINUTILS_DIR/gas/as-new" "$ORIGIN_DIR/as" diff --git a/detect-gnu-make.sh b/detect-gnu-make.sh new file mode 100644 index 0000000..fdff300 --- /dev/null +++ b/detect-gnu-make.sh @@ -0,0 +1,9 @@ +#!/bin/sh +gnu_make="$(command -v make 2>/dev/null)" +if command -v gmake >/dev/null 2>&1; then + gnu_make="$(command -v gmake)" +fi +if [ -z "$gnu_make" -o "$("$gnu_make" --version 2>/dev/null | head -n 1 | cut -c-3)" != "GNU" ]; then + echo >&2 "Could not find GNU make in PATH" + exit 1 +fi diff --git a/extract.sh b/extract.sh index 0a419bd..08ee3d9 100755 --- a/extract.sh +++ b/extract.sh @@ -13,7 +13,7 @@ CPIO="$(command -v cpio)" TAR="$(command -v tar)" if [ "$1" = 'clean' ]; then - rm -rfv "${ROOT}" "${ORIG}" "${ETC}" + rm -rf "${ROOT}" "${ORIG}" "${ETC}" exit fi @@ -50,7 +50,6 @@ echo '==> Reconstructing object file' if ! cat "${LOTUS}"/sysV386/lib/123.o.z_1 "${LOTUS}"/sysV386/lib/123.o.z_2 | zcat > "${ORIG}/123.o"; then echo >&2 'Failed to decompress object files.' - echo >&2 'If you see the message "code out of range", gzip is too old.' echo >&2 'You can try running ./gzip.sh to build a recent gzip that is known to work.' exit 1 @@ -63,10 +62,12 @@ echo '==> Uncompressing and copying remaining object files' cp "${LOTUS}"/sysV386/lib/*.o "${ORIG}/" echo '==> Copying the banner template over' -install -vDm644 "${ROOT}/usr/tmp/lotus_install/123/banner" "${LOTUS}/ri/USA-English/123ban.ri" +install -m 0644 "${ROOT}/usr/tmp/lotus_install/123/banner" "${LOTUS}/ri/USA-English/123ban.ri" echo '==> Copying default config file' -install -vDm644 l123set.cf "${ETC}/l123set.cf" +install -m 0755 -d "${ETC}" +install -m 0644 "l123set.cf" "${ETC}/l123set.cf" echo '==> Copying man page' -install -vDm644 "${ROOT}/lotus/man/man1/123.1" "${ROOT}/man/man1/123.1" +install -m 0755 -d "${ROOT}/man/man1" +install -m 0644 "${ROOT}/lotus/man/man1/123.1" "${ROOT}/man/man1/123.1" diff --git a/gzip.sh b/gzip.sh index d066fe9..548747c 100755 --- a/gzip.sh +++ b/gzip.sh @@ -6,41 +6,41 @@ GZIP_DL="https://ftp.gnu.org/gnu/gzip" GZIP_XZ="gzip-1.12.tar.xz" GZIP_DIR="$(basename $GZIP_XZ .tar.xz)" GZIP_URL="$GZIP_DL/$GZIP_XZ" -ORIG_DIR="$(pwd)" +ORIGIN_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)" -# Dont continue on error. -set -e +# Make sure we have GNU make +. "$ORIGIN_DIR/detect-gnu-make.sh" # Help text. if [ "$1" = '-h' ]; then - echo >&2 "Usage: $0 [clean]" - echo >&2 - echo >&2 'Specify "clean" to remove gzip, otherwise it will be downloaded and built.' - exit 1 + echo >&2 "Usage: $0 [clean]" + echo >&2 + echo >&2 'Specify "clean" to remove gzip, otherwise it will be downloaded and built.' + exit 1 fi # Optional cleanup if requested. if [ "$1" = 'clean' ]; then - rm -fv gzip gunzip zcat "$GZIP_XZ" - rm -rfv "$GZIP_DIR" - exit + rm -fv "$ORIGIN_DIR/gzip" "$ORIGIN_DIR/gunzip" "$ORIGIN_DIR/zcat" + rm -rf "$GZIP_DIR" + rm -fv "$ORIGIN_DIR/$GZIP_XZ" + exit fi # Download gzip. if [ ! -f "$GZIP_XZ" ]; then - wget "$GZIP_URL" + wget "$GZIP_URL" fi # Extract gzip. if [ ! -d "$GZIP_DIR" ]; then - tar xf "$GZIP_XZ" + xzcat "$GZIP_XZ" | tar xf - fi # Compile gzip. if [ ! -x "$GZIP_DIR/gzip" ]; then - cd "$GZIP_DIR" - ./configure - make -j$(nproc) + cd "$GZIP_DIR" && ./configure && "$gnu_make" + cd "$ORIGIN_DIR" fi # Copy compiled binaries to working directory. @@ -48,7 +48,6 @@ copy() { test ! -x "$2" && cp -v "$1" "$2" } -cd "$ORIG_DIR" -copy "$GZIP_DIR/gzip" gzip -copy "$GZIP_DIR/gunzip" gunzip -copy "$GZIP_DIR/zcat" zcat +copy "$GZIP_DIR/gzip" "$ORIGIN_DIR/gzip" +copy "$GZIP_DIR/gunzip" "$ORIGIN_DIR/gunzip" +copy "$GZIP_DIR/zcat" "$ORIGIN_DIR/zcat"