add cross-compile recipe for msdos

- If you want to obtain the djgpp cross-compiler and tools/libs for MSDOS,
which is available for linux and macOS, you can use the following script
to obtain it:

       sh sys/msdos/fetch-cross-compiler.sh

That script won't install anything, it is just file fetches. It will
store the cross-compiler in subfolders of lib and the hints files are
configured to find it appropriately there.

Note: Both the fetch and the msdos cross-compile package target require
unzip and zip to be available on your host build system.

Cross-compiler bits:
       https://github.com/andrewwutw/build-djgpp
   and the pre-built binary for your platform from:
       https://github.com/andrewwutw/build-djgpp/releases/download/v3.0/
   and a DOS-extender (for including in msdos packaging) from
       http://sandmann.dotster.com/cwsdpmi/csdpmi7b.zip
   and pdcurses from:
       https://github.com/wmcbrine/PDCurses.git

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

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

You can explicitly include tty and curses support if desired, otherwise
you'll end up with a tty-only cross-compile build:
       make WANT_WIN_TTY=1 WANT_WIN_CURSES=1 CROSS_TO_MSDOS=1 all

Also note that building the msdos targets using the make command
above, does not preclude you from building local linux or macOS
targets as well. Just drop the CROSS_TO_MSDOS=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.
This commit is contained in:
nhmall
2020-09-28 16:28:15 -04:00
parent b9b4755fe3
commit 14b532bf10
3 changed files with 223 additions and 0 deletions

View File

@@ -3,6 +3,52 @@
#
# Cross-compiling -POST section
ifdef CROSS_TO_MSDOS
#
$(TARGETDIR)/msdos.o : ../sys/msdos/msdos.c $(HACK_H)
$(TARGETDIR)/pckeys.o : ../sys/msdos/pckeys.c $(HACK_H)
$(TARGETDIR)/pctiles.o : ../sys/msdos/pctiles.c ../sys/msdos/portio.h $(HACK_H)
$(TARGETDIR)/video.o : ../sys/msdos/video.c ../sys/msdos/portio.h $(HACK_H)
$(TARGETDIR)/vidtxt.o : ../sys/msdos/vidtxt.c ../sys/msdos/portio.h \
../win/share/tile.h ../include/tileset.h $(HACK_H)
$(TARGETDIR)/vidvga.o : ../sys/msdos/vidvga.c ../sys/msdos/portio.h \
../win/share/tile.h ../include/tileset.h $(HACK_H)
$(TARGETDIR)/vidvesa.o : ../sys/msdos/vidvesa.c ../sys/msdos/portio.h \
../win/share/tile.h ../include/tileset.h $(HACK_H)
$(TARGETDIR)/vidstub.o : ../sys/msdos/vidvesa.c ../sys/msdos/portio.h \
$(HACK_H)
$(TARGETDIR)/tile.o : tile.c
#
#.PHONY: dospkg
dospkg: $(GAMEBIN) $(TARGETDIR)/recover.exe ../dat/nhtiles.bmp
$(TARGET_STUBEDIT) $(GAMEBIN) minstack=2048K
mkdir -p $(TARGETDIR)/pkg
cp $(GAMEBIN) $(TARGETDIR)/pkg/NETHACK.EXE
cp ../dat/nhdat $(TARGETDIR)/pkg/NHDAT
cp ../dat/license $(TARGETDIR)/pkg/LICENSE
cp ../dat/nhtiles.bmp $(TARGETDIR)/pkg/NHTILES.BMP
cp ../dat/symbols $(TARGETDIR)/pkg/SYMBOLS
cp ../sys/share/NetHack.cnf $(TARGETDIR)/pkg/NETHACK.CNF
cp ../sys/msdos/sysconf $(TARGETDIR)/pkg/SYSCONF
cp ../doc/nethack.txt $(TARGETDIR)/pkg/NETHACK.TXT
cp ../lib/djgpp/cwsdpmi/bin/CWSDPMI.EXE $(TARGETDIR)/pkg/CWSDPMI.EXE
-touch $(TARGETDIR)/pkg/RECORD
zip -9 $(TARGETDIR)/NH370DOS.ZIP $(TARGETDIR)/pkg/*
@echo msdos package zip file $(TARGETDIR)/NH370DOS.ZIP
endif # CROSS_TO_MSDOS
#
# shared file dependencies
#
$(TARGETDIR)/pcmain.o : ../sys/share/pcmain.c $(HACK_H)
$(TARGETDIR)/pcsys.o : ../sys/share/pcsys.c $(HACK_H)
$(TARGETDIR)/pctty.o : ../sys/share/pctty.c $(HACK_H)
$(TARGETDIR)/pcunix.o : ../sys/share/pcunix.c $(HACK_H)
$(TARGETDIR)/tileset.o : ../win/share/tileset.c
$(TARGETDIR)/bmptiles.o : ../win/share/bmptiles.c
$(TARGETDIR)/giftiles.o : ../win/share/giftiles.c
$(TARGETDIR)/recover.exe : $(TARGETDIR)/recover.o
#
# Lua lib
$(LUACROSSLIB): $(LUALIBOBJS)

View File

@@ -3,6 +3,15 @@
#
# Cross-compiling -PRE section
#
ifdef CROSS_TO_MSDOS
BUILD_LUA=1
BUILD_PDCURSES=1
override TARGET = msdos
override TARGETDIR = ../targets/$(TARGET)
override TARGET_LIBS=
endif
ifdef BUILD_LUA
#===============-=================================================
# LUA library
@@ -74,6 +83,9 @@ PDCOBJS = $(TARGETDIR)/pdcclip.o $(TARGETDIR)/pdcdisp.o \
$(TARGETDIR)/pdcscrn.o $(TARGETDIR)/pdcsetsc.o \
$(TARGETDIR)/pdcutil.o
override TARGET_LIBS += $(PDCLIB)
ifdef CROSS_TO_MSDOS
PDCINCL += -I$(PDCTOP)/dos
endif
BUILDMORE += $(PDCLIB)
# Rules for PDCurses files
$(TARGETDIR)/%.o : $(PDCTOP)/pdcurses/%.c
@@ -87,6 +99,74 @@ PDCINCL=
endif # WANT_WIN_CURSES
endif # BUILD_PDCURSES
ifdef CROSS_TO_MSDOS
#===============-=================================================
# MSDOS cross-compile recipe
#===============-=================================================
# Uses an MSDOS djgpp cross-compiler on linux or macos.
#
# 1. You can obtain the cross-compiler for your system via:
# sys/msdos/fetch-cross.sh
# 2. Then
# make CROSS_TO_MSDOS=1 WANT_WIN_TTY=1 WANT_WIN_CURSES=1 all
#
# Source from http://www.lua.org/ftp/lua-5.4.0.tar.gz
#=================================================================
CFLAGS += -DCROSSCOMPILE -DCROSSCOMPILE_HOST
#
# Override the build tools and some obj files to
# reflect the msdos djgpp cross-compiler.
#
TOOLTOP1 = ../lib/djgpp/bin
TOOLTOP2 = ../lib/djgpp/i586-pc-msdosdjgpp/bin
override TARGET_CC = $(TOOLTOP1)/i586-pc-msdosdjgpp-gcc
override TARGET_CXX = $(TOOLTOP2)/g++
override TARGET_AR = $(TOOLTOP1)/i586-pc-msdosdjgpp-gcc-ar
override TARGET_STUBEDIT = ../lib/djgpp/i586-pc-msdosdjgpp/bin/stubedit
override TARGET_CFLAGS = -c -O -I../include -I../sys/msdos -I../win/share \
$(LUAINCL) -DDLB $(PDCURSESDEF) \
-DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET
override TARGET_CXXFLAGS = $(TARGET_CFLAGS)
override TARGET_LINK = $(TOOLTOP1)/i586-pc-msdosdjgpp-gcc
override TARGET_LFLAGS=
override TARGET_LIBS += -lpc
override SYSSRC = ../sys/share/pcmain.c ../sys/msdos/msdos.c \
../sys/share/pcsys.c ../sys/share/pctty.c \
../sys/share/pcunix.c ../sys/msdos/video.c \
../sys/msdos/vidtxt.c ../sys/msdos/pckeys.c \
../sys/msdos/vidvga.c ../sys/msdos/vidvesa.c \
../win/share/bmptiles.c ../win/share/giftiles.c \
../win/share/tileset.c
override SYSOBJ= $(TARGETDIR)/pcmain.o $(TARGETDIR)/msdos.o \
$(TARGETDIR)/pcsys.o $(TARGETDIR)/pctty.o \
$(TARGETDIR)/pcunix.o $(TARGETDIR)/video.o \
$(TARGETDIR)/vidtxt.o $(TARGETDIR)/pckeys.o \
$(TARGETDIR)/vidvga.o $(TARGETDIR)/vidvesa.o \
$(TARGETDIR)/bmptiles.o $(TARGETDIR)/giftiles.o \
$(TARGETDIR)/tileset.o $(TARGETDIR)/tile.o
override WINLIB=
override LUALIB=
override GAMEBIN = $(TARGETDIR)/nethack.exe
override PACKAGE= dospkg
VARDATND += nhtiles.bmp
PREGAME = mkdir -p $(TARGETDIR)
CLEANMORE += rm -r $(TARGETDIR)
BUILDMORE += $(TARGETDIR)/recover.exe
#
ifdef WANT_WIN_CURSES
# rules for pdcurses dos-specific files
$(TARGETDIR)/%.o : $(PDCTOP)/dos/%.c
$(TARGET_CC) $(PDCINCL) $(TARGET_CFLAGS) -o$@ $<
endif # WANT_WIN_CURSES
#
# Rule for files in sys/msdos
$(TARGETDIR)/%.o : ../sys/msdos/%.c
$(TARGET_CC) $(TARGET_CFLAGS) -o$@ $<
endif # CROSS_TO_MSDOS
#=================================================================
ifdef WANT_WIN_CURSES
# rules for pdcurses dos-specific files
$(TARGETDIR)/%.o : $(PDCTOP)/sdl1/%.c