- 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.
188 lines
6.8 KiB
Plaintext
188 lines
6.8 KiB
Plaintext
#===============-=================================================
|
|
# NetHack 3.7 include/cross-pre $NHDT-Date: 1597332785 2020/08/13 15:33:05 $ $NHDT-Branch: NetHack-3.7 $
|
|
#
|
|
# 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
|
|
# Source from http://www.lua.org/ftp/lua-5.4.0.tar.gz
|
|
#=================================================================
|
|
LUA_VERSION ?=5.4.0
|
|
LUATOP ?= ../lib/lua-$(LUA_VERSION)
|
|
LUASRCDIR ?= $(LUATOP)/src
|
|
LUAOBJFILES1 = $(TARGETDIR)/lapi.o $(TARGETDIR)/lauxlib.o \
|
|
$(TARGETDIR)/lbaselib.o $(TARGETDIR)/lcode.o \
|
|
$(TARGETDIR)/lcorolib.o $(TARGETDIR)/lctype.o \
|
|
$(TARGETDIR)/ldblib.o
|
|
ifeq "$(LUA_VERSION)" "5.3.5"
|
|
LUAOBJFILES1 += $(TARGETDIR)/lbitlib.o
|
|
endif
|
|
LUAOBJFILES2 = $(TARGETDIR)/ldebug.o $(TARGETDIR)/ldo.o $(TARGETDIR)/ldump.o \
|
|
$(TARGETDIR)/lfunc.o $(TARGETDIR)/lgc.o $(TARGETDIR)/linit.o \
|
|
$(TARGETDIR)/liolib.o $(TARGETDIR)/llex.o
|
|
LUAOBJFILES3 = $(TARGETDIR)/lmathlib.o $(TARGETDIR)/lmem.o \
|
|
$(TARGETDIR)/loadlib.o $(TARGETDIR)/lobject.o \
|
|
$(TARGETDIR)/lopcodes.o $(TARGETDIR)/loslib.o \
|
|
$(TARGETDIR)/lparser.o $(TARGETDIR)/lstate.o
|
|
LUAOBJFILES4 = $(TARGETDIR)/lstring.o $(TARGETDIR)/lstrlib.o \
|
|
$(TARGETDIR)/ltable.o $(TARGETDIR)/ltablib.o \
|
|
$(TARGETDIR)/ltm.o $(TARGETDIR)/lundump.o \
|
|
$(TARGETDIR)/lutf8lib.o $(TARGETDIR)/lvm.o $(TARGETDIR)/lzio.o
|
|
LUALIBOBJS = $(LUAOBJFILES1) $(LUAOBJFILES2) $(LUAOBJFILES3) $(LUAOBJFILES4)
|
|
LUACROSSLIB = $(TARGETDIR)/$(O)lua$(subst .,,$(LUA_VERSION)).a
|
|
LUAINCL = -I$(LUASRCDIR)
|
|
BUILDMORE += $(LUACROSSLIB)
|
|
override TARGET_LIBS += $(LUACROSSLIB) -lm
|
|
else
|
|
LUAINCL=
|
|
endif # BUILD_LUA
|
|
|
|
ifdef BUILD_PDCURSES
|
|
#===============-=================================================
|
|
# PD Curses library
|
|
#===============-=================================================
|
|
ifdef WANT_WIN_CURSES
|
|
PDCTOP = ../lib/pdcurses
|
|
PDCURSESDEF= -I../lib/pdcurses -I../lib/pdcurses/dos \
|
|
-D"CURSES_GRAPHICS" -D"CURSES_BRIEF_INCLUDE"
|
|
PDCLIBOBJ1= $(TARGETDIR)/addch.o $(TARGETDIR)/addchstr.o \
|
|
$(TARGETDIR)/addstr.o $(TARGETDIR)/attr.o \
|
|
$(TARGETDIR)/beep.o $(TARGETDIR)/bkgd.o \
|
|
$(TARGETDIR)/border.o $(TARGETDIR)/clear.o \
|
|
$(TARGETDIR)/color.o $(TARGETDIR)/delch.o \
|
|
$(TARGETDIR)/deleteln.o $(TARGETDIR)/getch.o \
|
|
$(TARGETDIR)/getstr.o $(TARGETDIR)/getyx.o \
|
|
$(TARGETDIR)/inch.o
|
|
PDCLIBOBJ2= $(TARGETDIR)/inchstr.o $(TARGETDIR)/initscr.o \
|
|
$(TARGETDIR)/inopts.o $(TARGETDIR)/insch.o \
|
|
$(TARGETDIR)/insstr.o $(TARGETDIR)/instr.o \
|
|
$(TARGETDIR)/kernel.o $(TARGETDIR)/keyname.o \
|
|
$(TARGETDIR)/mouse.o $(TARGETDIR)/move.o \
|
|
$(TARGETDIR)/outopts.o $(TARGETDIR)/overlay.o
|
|
PDCLIBOBJ3= $(TARGETDIR)/pad.o $(TARGETDIR)/panel.o $(TARGETDIR)/printw.o \
|
|
$(TARGETDIR)/refresh.o $(TARGETDIR)/scanw.o \
|
|
$(TARGETDIR)/scr_dump.o $(TARGETDIR)/scroll.o \
|
|
$(TARGETDIR)/slk.o $(TARGETDIR)/termattr.o
|
|
PDCLIBOBJ4= $(TARGETDIR)/touch.o $(TARGETDIR)/util.o $(TARGETDIR)/window.o \
|
|
$(TARGETDIR)/debug.o
|
|
PDCLIBOBJS = $(PDCLIBOBJ1) $(PDCLIBOBJ2) $(PDCLIBOBJ3) $(PDCLIBOBJ4)
|
|
PDCLIB = $(TARGETDIR)/pdclib.a
|
|
PDCINCL = -I$(PDCTOP) -I$(PDCTOP)/pdcurses
|
|
PDCOBJS = $(TARGETDIR)/pdcclip.o $(TARGETDIR)/pdcdisp.o \
|
|
$(TARGETDIR)/pdcgetsc.o $(TARGETDIR)/pdckbd.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
|
|
$(TARGET_CC) $(PDCINCL) $(TARGET_CFLAGS) -o$@ $<
|
|
else #WANT_WIN_CURSES
|
|
PDCURSESDEF=
|
|
PDCLIBOBJS=
|
|
PDCOBJS=
|
|
PDCLIB=
|
|
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
|
|
$(TARGET_CC) $(PDCINCL) $(TARGET_CFLAGS) -o$@ $<
|
|
endif # WANT_WIN_CURSES
|
|
# Rule for LUA files
|
|
$(TARGETDIR)/%.o : $(LUATOP)/src/%.c
|
|
$(TARGET_CC) $(TARGET_CFLAGS) $(LUA_FLAGS) -o$@ $<
|
|
ifdef WANT_WIN_CURSES
|
|
# Rules for PDCurses files
|
|
$(TARGETDIR)/%.o : $(PDCTOP)/pdcurses/%.c
|
|
$(TARGET_CC) $(PDCINCL) $(TARGET_CFLAGS) -o$@ $<
|
|
endif # WANT_WIN_CURSES
|
|
|
|
#
|
|
# End of cross-compiling -PRE section
|
|
#===============-=================================================
|
|
|