Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor portability improvements #74

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
45 changes: 29 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
52 changes: 26 additions & 26 deletions binutils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 9 additions & 0 deletions detect-gnu-make.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 6 additions & 5 deletions extract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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"
37 changes: 18 additions & 19 deletions gzip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,48 @@ 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.
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"