add cross-compile recipe for amiga

Disclaimer: This is a minimal recipe, just to get someone else
started if they have a desire to get a full cross-compile of
NetHack-3.7 going for the Amiga. Some NetHack code bitrot was
corrected, and it does seem able to compile the game itself
to a point. See caveats below.

- If you want to obtain the cross-compiler and tools/libs for Amiga
         https://github.com/bebbo/amiga-gcc

  To our knowledge, a pre-built copy isn't available, so you have to
  obtain the source via git and build it on your system.

  The build prerequisite packages for Ubuntu are easily obtained:

    sudo apt install make wget git gcc g++ lhasa libgmp-dev \
        libmpfr-dev libmpc-dev flex bison gettext texinfo ncurses-dev \
        autoconf rsync

  The build prerequisite packages for macOS are apparently easily
  obtained via homebrew, but that was not tested:

    brew install bash wget make lhasa gmp mpfr libmpc flex gettext \
    texinfo gcc make autoconf

  After installing the prerequite packages and the cross-compiler
  it was a straightforward build:

        git clone https://github.com/bebbo/amiga-gcc.git
        cd amiga-gcc
        make update
    [Note that you may have to take ownership of the files in the
     bebbo repo via chown before succesfully carrying out the next
     steps]
        make clean
        make clean-prefix
        date; make all -j3 >&b.log; date
  The compiler pieces are installed in /opt/amiga by default which
  was satisfactory for our initial attempt, but if you want you can
  alter the prefix before you build if you want. That is all
  spelled out on the page at: https://github.com/bebbo/amiga-gcc

  The Amiga cross-compile can then be carried out by specifying
  CROSS_TO_AMIGA=1 on the make command line.

  For example:
       make CROSS_TO_AMIGA=1 all
       make CROSS_TO_AMIGA=1 package

You can explicitly include tty and curses support if desired, otherwise
you'll end up with a tty-only cross-compile build. The SDL1 pdcurses
support has not been tested.

       make WANT_WIN_TTY=1 WANT_WIN_CURSES=1 CROSS_TO_AMIGA=1 all

Also note that building the amiga targets using the make command
above, does not preclude you from building local linux or macOS
targets as well. Just drop the CROSS_TO_AMIGA=1 from the make
command line.

The cross-compiler hints additions are enclosed inside ifdef sections
and won't interfere with the non-cross-compile build in that case.

CAVEATS: The original NetHack Amiga build steps included the source for
some utilities that were built and executed on the amiga: txt2iff and
xpm2iff as part of the NetHack build procedure on amiga. Those did not
compile out-of-the-box on the linux host. They will either have to be:
    - ported to build and run on the linux or macOS cross-compile host

   or

    - their functionality will have to be rolled into amiga NetHack
      itself and executed on the target Amiga the first time the game
      is run, perhaps.

Good luck amiga aficionados, perhaps you'll be able to take this
initial effort forward and get NetHack-3.7 available on the amiga or
amiga-emulator. Let us know if you do, and we can roll changes in
if you provide them.
This commit is contained in:
nhmall
2020-09-28 17:30:22 -04:00
parent 14b532bf10
commit cb223271cb
23 changed files with 405 additions and 31 deletions

View File

@@ -37,6 +37,81 @@ dospkg: $(GAMEBIN) $(TARGETDIR)/recover.exe ../dat/nhtiles.bmp
@echo msdos package zip file $(TARGETDIR)/NH370DOS.ZIP
endif # CROSS_TO_MSDOS
ifdef CROSS_TO_AMIGA
$(TARGETDIR)/amidos.o : ../outdated/sys/amiga/amidos.c $(HACK_H)
$(TARGETDIR)/amigst.o : ../outdated/sys/amiga/amigst.c $(HACK_H)
$(TARGETDIR)/amirip.o : ../outdated/sys/amiga/amirip.c $(HACK_H)
$(TARGETDIR)/amistack.o : ../outdated/sys/amiga/amistack.c $(HACK_H)
$(TARGETDIR)/amitty.o : ../outdated/sys/amiga/amitty.c $(HACK_H)
$(TARGETDIR)/amiwind.o : ../outdated/sys/amiga/amiwind.c \
../outdated/sys/amiga/amimenu.c $(HACK_H)
$(TARGETDIR)/winami.o : ../outdated/sys/amiga/winami.c $(HACK_H)
$(TARGETDIR)/winchar.o : ../outdated/sys/amiga/winchar.c tile.c $(HACK_H)
$(TARGETDIR)/winfuncs.o : ../outdated/sys/amiga/winfuncs.c $(HACK_H)
$(TARGETDIR)/winkey.o : ../outdated/sys/amiga/winkey.c $(HACK_H)
$(TARGETDIR)/winamenu.o : ../outdated/sys/amiga/winamenu.c $(HACK_H)
$(TARGETDIR)/winreq.o : ../outdated/sys/amiga/winreq.c \
../outdated/sys/amiga/colorwin.c \
../outdated/sys/amiga/clipwin.c $(HACK_H)
$(TARGETDIR)/winstr.o : ../outdated/sys/amiga/winstr.c $(HACK_H)
$(TARGETDIR)/tomb.iff : ../util/xpm2iff ../outdated/sys/amiga/gave16.xpm
../util/tiletext.o : ../win/share/tiletext.c
$(CC) $(CFLAGS) -c \
-o $@ ../win/share/tiletext.c
../util/txt2iff : ../util/txt2iff.o ../util/tiletext.o \
../util/tiletxt.o
$(LINK) $(LFLAGS) -L../lib -o $@ ../util/txt2iff.o ../util/tiletext.o \
../util/tiletxt.o -lriffl
../util/txt2iff.o : ../outdated/sys/amiga/txt2iff.c $(HACK_H)
$(CC) $(CFLAGS) -c \
-I../lib/riffl-0.2/include \
-I/opt/amiga/m68k-amigaos/ndk13-include \
-o $@ ../outdated/sys/amiga/txt2iff.c
../util/xpm2iff : ../util/xpm2iff.o
$(LINK) $(LFLAGS) -L../lib -o $@ ../util/txt2iff.o -lriffl
../util/xpm2iff.o : ../outdated/sys/amiga/xpm2iff.c $(HACK_H)
$(CC) $(CFLAGS) -o $@ ../outdated/sys/amiga/xpm2iff.c
$(TARGETDIR)/objects.iff: ../win/share/objects.txt ../util/txt2iff
../util/txt2iff ../win/share/objects.txt $@
$(TARGETDIR)/monsters.iff: ../win/share/monsters.txt ../util/txt2iff
../util/txt2iff ../win/share/monsters.txt $@
$(TARGETDIR)/other.iff: ../win/share/other.txt ../util/txt2iff
../util/txt2iff ../win/share/other.txt $@
#
#.PHONY: amigapkg
amigapkg: $(GAMEBIN) $(TARGETDIR)/recover.exe ../dat/nhtiles.bmp
mkdir -p $(TARGETDIR)/pkg
cp $(GAMEBIN) $(TARGETDIR)/pkg/nethack
cp ../dat/nhdat $(TARGETDIR)/pkg/nhdat
cp ../dat/license $(TARGETDIR)/pkg/license
cp ../dat/nhtiles.bmp $(TARGETDIR)/pkg/nhtiles.bmp
cp $(TARGETDIR)/tomb.iff $(TARGETDIR)/pkg/tomb.iff
cp $(TARGETDIR)/monsters.iff $(TARGETDIR)/pkg/monsters.iff
cp $(TARGETDIR)/objects.iff $(TARGETDIR)/pkg/objects.iff
cp $(TARGETDIR)/other.iff $(TARGETDIR)/pkg/other.iff
cp ../dat/symbols $(TARGETDIR)/pkg/symbols
cp ../sys/share/NetHack.cnf $(TARGETDIR)/pkg/nethack.cnf
cp ../sys/msdos/sysconf $(TARGETDIR)/pkg/sysconf
cp ../outdated/sys/amiga/amii.hlp $(TARGETDIR)/pkg/amii.hlp
cp ../sys/msdos/sysconf $(TARGETDIR)/pkg/sysconf
cp ../doc/nethack.txt $(TARGETDIR)/pkg/nethack.txt
../util/uudecode ../outdated/sys/amiga/amifont8.uu
cp 8 $(TARGETDIR)/pkg/8
../util/uudecode ../outdated/sys/amiga/amifont.uu
cp hack.font $(TARGETDIR)/pkg/hack.font
../util/uudecode ../outdated/sys/amiga/dflticon.uu
cp default.icon $(TARGETDIR)/pkg/default.icon
../util/uudecode ../outdated/sys/amiga/NHinfo.uu
cp NetHack.info $(TARGETDIR)/pkg/NetHack.info
../util/uudecode ../outdated/sys/amiga/NewGame.uu
cp NewGame.info $(TARGETDIR)/pkg/NewGame.info
../util/uudecode ../outdated/sys/amiga/HackWB.uu
cp HackWB.info $(TARGETDIR)/pkg/HackWB.info
-touch $(TARGETDIR)/pkg/record
zip -9 $(TARGETDIR)/NH370AMI.ZIP $(TARGETDIR)/pkg/*
@echo amiga package zip file $(TARGETDIR)/NH370AMI.ZIP
endif # CROSS_TO_AMIGA
#
# shared file dependencies
#

View File

@@ -12,6 +12,14 @@ override TARGETDIR = ../targets/$(TARGET)
override TARGET_LIBS=
endif
ifdef CROSS_TO_AMIGA
BUILD_LUA=1
BUILD_PDCURSES=1
override TARGET = amiga
override TARGETDIR = ../targets/$(TARGET)
override TARGET_LIBS=
endif
ifdef BUILD_LUA
#===============-=================================================
# LUA library
@@ -86,6 +94,10 @@ override TARGET_LIBS += $(PDCLIB)
ifdef CROSS_TO_MSDOS
PDCINCL += -I$(PDCTOP)/dos
endif
ifdef CROSS_TO_AMIGA
PDCINCL += -I$(PDCTOP)/sdl1 -I/opt/amiga/m68k-amigaos/include/SDL
override TARGET_LIBS += -lSDL
endif
BUILDMORE += $(PDCLIB)
# Rules for PDCurses files
$(TARGETDIR)/%.o : $(PDCTOP)/pdcurses/%.c
@@ -167,6 +179,95 @@ $(TARGETDIR)/%.o : ../sys/msdos/%.c
endif # CROSS_TO_MSDOS
#=================================================================
ifdef CROSS_TO_AMIGA
#===============-=================================================
# AmigaOS m68k cross-compile recipe
#===============-=================================================
# Uses an Amiga M68K cross-compiler on linux or macOS.
#
# 1. You can obtain the cross-compiler for your system via:
# sys/amiga/fetch-cross.sh
# 2. Then
# make CROSS_TO_AMIGAOS=1 WANT_WIN_TTY=1 WANT_WIN_CURSES=1 all
#
# Amiga m68k from https://github.com/bebbo/amiga-gcc
#=================================================================
CFLAGS += -DCROSSCOMPILE -DCROSSCOMPILE_HOST
#
# Override the build tools and some obj files to
# reflect the amiga-gccs cross-compiler.
#
TOOLTOP = /opt/amiga/bin
#TOOLARCH = -m68020 -mcrt=clib2
#TOOLARCH = -m68020 #newlib
TOOLARCH = -m68020 -noixemul
override REGEXOBJ = $(TARGETDIR)/cppregex.o
override TARGET_CC = $(TOOLTOP)/m68k-amigaos-gcc
override TARGET_CXX = $(TOOLTOP)/m68k-amigaos-c++
override TARGET_AR = $(TOOLTOP)/m68k-amigaos-ar
override TARGET_STUBEDIT=
#override TARGET_CFLAGS = -c -O $(TOOLARCH) -I../include -I../outdated/include
override TARGET_CFLAGS = -c -O $(TOOLARCH) \
-I../include -I../outdated/include \
-I../outdated/sys/amiga -I../win/share \
$(LUAINCL) -DAMIGA -DAMIGA_CROSS $(PDCURSESDEF) \
-DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET \
-DAMIGA_VERSION_STRING=\""VER: NetHack 3.7.0 \(12.13.2020)\""
override TARGET_CXXFLAGS = $(TARGET_CFLAGS)
ifeq "$(REGEXOBJ)" "$(TARGETDIR)/cppregex.o"
override TARGET_LINK = $(TARGET_CXX)
else
override TARGET_LINK = $(TARGET_CC)
endif
override TARGET_LFLAGS= $(TOOLARCH)
#override TARGET_LIBS +=
VARDATND += nhtiles.bmp
override SYSSRC = ../outdated/sys/amiga/amidos.c ../outdated/sys/amiga/amigst.c \
../outdated/sys/amiga/amimenu.c ../outdated/sys/amiga/amirip.c \
../outdated/sys/amiga/amistack.c ../outdated/sys/amiga/amitty.c \
../outdated/sys/amiga/amiwind.c ../outdated/sys/amiga/clipwin.c \
../outdated/sys/amiga/colorwin.c \
../outdated/sys/amiga/winami.c ../outdated/sys/amiga/winchar.c \
../outdated/sys/amiga/winfuncs.c ../outdated/sys/amiga/winkey.c \
../outdated/sys/amiga/winamenu.c ../outdated/sys/amiga/winreq.c \
../outdated/sys/amiga/winstr.c ../sys/share/pcmain.c \
../win/share/bmptiles.c ../win/share/giftiles.c \
../win/share/tileset.c
# ../outdated/sys/amiga/xpm2iff.c
# ../outdated/sys/amiga/txt2iff.c
override SYSOBJ = $(TARGETDIR)/amidos.o $(TARGETDIR)/amigst.o \
$(TARGETDIR)/amirip.o $(TARGETDIR)/amistack.o \
$(TARGETDIR)/amitty.o $(TARGETDIR)/amiwind.o \
$(TARGETDIR)/winami.o $(TARGETDIR)/winchar.o \
$(TARGETDIR)/winfuncs.o $(TARGETDIR)/winkey.o \
$(TARGETDIR)/winamenu.o $(TARGETDIR)/winreq.o \
$(TARGETDIR)/winstr.o $(TARGETDIR)/pcmain.o \
$(TARGETDIR)/bmptiles.o $(TARGETDIR)/giftiles.o \
$(TARGETDIR)/tileset.o
# $(TARGETDIR)/xpm2iff.o
# ../util/txt2iff.o
override WINLIB=
override LUALIB=
override GAMEBIN = $(TARGETDIR)/nethack.exe
override PACKAGE= amigapkg
PREGAME = mkdir -p ../targets/amiga
CLEANMORE += rm -r ../targets/amiga
BUILDMORE += $(TARGETDIR)/recover.exe
# ../util/txt2iff
#
ifdef WANT_WIN_CURSES
# rules for pdcurses sdl1-specific files
$(TARGETDIR)/%.o : $(PDCTOP)/sdl1/%.c
$(TARGET_CC) $(PDCINCL) $(TARGET_CFLAGS) -o$@ $<
endif # WANT_WIN_CURSES
# Rule for files in sys/amiga
$(TARGETDIR)/%.o : ../outdated/sys/amiga/%.c
$(TARGET_CC) $(TARGET_CFLAGS) -o$@ $<
endif # CROSS_TO_AMIGA
#=================================================================
ifdef WANT_WIN_CURSES
# rules for pdcurses dos-specific files
$(TARGETDIR)/%.o : $(PDCTOP)/sdl1/%.c