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

New unified directory structure #70

Merged
merged 2 commits into from
Jun 3, 2022
Merged
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
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export BFD_TARGET_ERROR

.PHONY: clean check

all: check 123 keymaps
@file 123
@size 123
all: check bin/123 keymaps
@file bin/123
@size bin/123

check:
@objdump --info | egrep -q '^coff-i386$$' || (echo "$$BFD_TARGET_ERROR"; exit 1)
Expand All @@ -45,23 +45,24 @@ ttydraw/ttydraw.a:
atfuncs/atfuncs.a:
$(MAKE) -C atfuncs

123: 123.o dl_init.o main.o wrappers.o patch.o filemap.o graphics.o draw.o | ttydraw/ttydraw.a atfuncs/atfuncs.a forceplt.o
bin/123: 123.o dl_init.o main.o wrappers.o patch.o filemap.o graphics.o draw.o | ttydraw/ttydraw.a atfuncs/atfuncs.a forceplt.o
@mkdir -p $(@D)
$(CC) forceplt.o $(CFLAGS) $(LDFLAGS) $^ -Wl,--whole-archive,ttydraw/ttydraw.a,atfuncs/atfuncs.a,--no-whole-archive -o $@ $(LDLIBS)

keymap/keymap:
$(MAKE) -C keymap

# This generates the keymaps in a seperate directory based on the first letter.
$(sort $(KEYMAPS)): keymap/keymap
mkdir -p keymaps/$(shell printf "%c" $@)
keymap/keymap $@ > keymaps/$(shell printf "%c" $@)/$@
mkdir -p share/lotus/keymaps/$(shell printf "%c" $@)
keymap/keymap $@ > share/lotus/keymaps/$(shell printf "%c" $@)/$@

keymaps: $(KEYMAPS)

clean:
$(RM) *.o 123 coffsyrup
$(RM) *.o bin/123 coffsyrup
$(RM) vgcore.* core.* core
$(RM) -r keymaps
$(RM) -r share/lotus/keymaps
$(MAKE) -C ttydraw clean
$(MAKE) -C atfuncs clean
$(MAKE) -C keymap clean
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Run the included `binutils.sh` to download and compile a version of binutils kno

Secondly, you need a copy of Lotus 1-2-3 for UNIX, you can download it
[here](https://archive.org/details/123-unix). Just place the raw disk images in
the build directory and run `extract.sh`.
the build directory and run `extract`.

Finally, just run `make`.

Expand Down Expand Up @@ -58,13 +58,13 @@ The Makefile should automatically use the new binaries, and continue to build.

## Running

Just run `./123`.
Just run `bin/123`.

### Getting Started

There is a quick start guide in the wiki [here](https://github.com/taviso/123elf/wiki/Getting-Started), and the full manual can be seen here [here](https://archive.org/details/lotus-1-2-3-release-3.1-reference/Lotus%201-2-3%20Release%203.1%20-%20Tutorial).

There is a man page in `./root/lotus/man/man1/123.1` that describes the command line options.
There is a man page in `share/man/man1/123.1` that describes the command line options.

Lotus 1-2-3 has context sensitive online help, you can press <kbd>F1</kbd> at most times to see some hints.

Expand Down
71 changes: 71 additions & 0 deletions extract
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/sh
#
# Extract the necessary files from Lotus 1-2-3 UNIX
#
BASE="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
IMG="${BASE}"
ROOT="${BASE}/share"
ORIG="${BASE}/orig"
ETC="${ROOT}/lotus/etc"
LOTUS="${ROOT}/lotus/123.v10"

CPIO="$(command -v cpio)"
TAR="$(command -v tar)"

if [ "$1" = 'clean' ]; then
rm -rfv "${ROOT}" "${ORIG}" "${ETC}"
exit
fi

# Use any tools placed in this directory first.
export PATH="${BASE}:$PATH"

if ! test -f "${IMG}/123UNIX1.IMG" \
-a -f "${IMG}/123UNIX2.IMG" \
-a -f "${IMG}/123UNIX3.IMG" \
-a -f "${IMG}/123UNIX4.IMG" \
-a -f "${IMG}/123UNIX5.IMG"; then
echo >&2 'You need to download the original 1-2-3 UNIX IMG files.'
echo >&2 'They are available here: https://archive.org/download/123-unix'
exit 1
fi

mkdir "${ROOT}"
mkdir "${ORIG}"

cd "${ROOT}"
echo '==> Extracting 123UNIX1.IMG tar archive'
"${TAR}" xvf "${IMG}/123UNIX1.IMG"
echo '==> Extracting 123UNIX2.IMG cpio archive'
"${CPIO}" -idv < "${IMG}/123UNIX2.IMG"
echo '==> Extracting 123UNIX3.IMG cpio archive'
"${CPIO}" -idv < "${IMG}/123UNIX3.IMG"
echo '==> Seeking into 123UNIX4.IMG to extract cpio archive'
dd if="${IMG}/123UNIX4.IMG" skip=1 bs=550536 | "${CPIO}" -idv
echo '==> Extracting 123UNIX5.IMG cpio archive'
"${CPIO}" -idv < "${IMG}/123UNIX5.IMG"
cd - > /dev/null

echo '==> Uncompressing .z files'
find "${ROOT}" -iname '*.z' -exec gunzip --force {} \;

echo '==> Uncompressing and copying object files'
cat "${LOTUS}"/sysV386/lib/123.o.z_1 "${LOTUS}"/sysV386/lib/123.o.z_2 | zcat > "${ORIG}/123.o"
cp "${LOTUS}"/sysV386/lib/*.o "${ORIG}/"

echo '==> Installing better keymaps'
for t in xterm xterm-256color; do
cp -v "${BASE}/xterm" "${LOTUS}/keymaps/$(echo "${t}" | cut -c1)/${t}"
done
if [ ! -f "${LOTUS}/keymaps/$(echo "${TERM}" | cut -c1)/${TERM}" ]; then
cp -v "${BASE}/xterm" "${LOTUS}/keymaps/$(echo "${TERM}" | cut -c1)/${TERM}"
fi

echo '==> Copying the banner template over'
install -vDm644 "${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"

echo '==> Copying man page'
install -vDm644 "${ROOT}/lotus/man/man1/123.1" "${ROOT}/man/man1/123.1"
37 changes: 0 additions & 37 deletions extract.sh

This file was deleted.

14 changes: 9 additions & 5 deletions filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@
// Figure out where our runtime files are located.
static const char *get_lotus_runtimefile(const char *file)
{
static char procpath[PATH_MAX];
static char filepath[PATH_MAX];
static char *lotusdir;
static char exepath[PATH_MAX];
static char *exedir;
static char filepath[PATH_MAX];
static char localpath[PATH_MAX];

// Cache this path so it only has to be looked up once.
if (lotusdir == NULL) {
if (readlink("/proc/self/exe", procpath, PATH_MAX) == -1) {
if (readlink("/proc/self/exe", exepath, PATH_MAX) == -1) {
err(EXIT_FAILURE, "Failed to determine the lotus root directory");
}
// Figure out the containing directory from the exe path.
lotusdir = dirname(procpath);
exedir = dirname(exepath);
snprintf(localpath, PATH_MAX, "%s/%s", exedir, "../share/lotus");
lotusdir = localpath;
}

// Append the requested filename, obviously this is not reentrant, but 123
Expand Down Expand Up @@ -50,7 +54,7 @@ const char * map_unix_pathname(const char *unixpath)
// we can map it to the default configuration file instead, which
// is the directory where 123 is located.
if (access(unixpath, F_OK) != 0) {
return get_lotus_runtimefile("l123set.cf");
return get_lotus_runtimefile("etc/l123set.cf");
}
}

Expand Down
2 changes: 1 addition & 1 deletion l123set.cf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1001 Lotus 1-2-3 Version "10"
1002 Base Directory "/{LOTUSROOT}/root/lotus"
1002 Base Directory "/{LOTUSROOT}"
1003 Printer Interface "lpr -o dest={dest} {file}"
1004 Graphics Driver "dumb" "ega egas25cc.vbd"
1007 Help Language "USA English" "USA-English"
Expand Down