libnethack pr385

roll parts of pr385 into source tree

This does not take the PR as is.

Unlike the PR, this streamlines and minimizes the integration somewhat:

- use hints/include mechanism instead of creating alternative
  Makefile.dat, Makefile.src, Makefile.top, Makefile.utl in sys/lib;
  those would have been a maintenance nightmare.

- don't have alternative mkmkfile.sh and setup.sh in sys/lib.

- sys/lib/libnethackmain.c differed from sys/unix/unixmain.c by
  very little, so just place a small bit of conditional code at the
  top of sys/unix/unixmain.c instead.

- changed the conditional code bits from __EMSCRIPTEN__ to
  CROSS_TO_WASM.

- You should be able to build the wasm result by:
    cd sys/unix ; sh setup.sh hints/linux.2020 ; cd ../..
    make fetch-lua    (<-one time)
    make WANT_LIBNH all

- You should be able to build LIBNBH by:
    cd sys/unix ; sh setup.sh hints/linux.2020 ; cd ../..
    make fetch-lua    (<-one time)
    make CROSS_TO_WASM=1 all

As it is currently coded, winshim.c requires C99.
This commit is contained in:
Adam Powers
2020-08-26 19:22:00 -07:00
committed by nhmall
parent 741e6fd5b7
commit dc2d757399
28 changed files with 1555 additions and 120 deletions

View File

@@ -62,6 +62,7 @@ endif
CFLAGS=$(CCFLAGS) -I../include -DNOTPARMDECL
ifndef WANT_WIN_QT
ifndef WANT_LIBNH
# these are normally used when compiling nethack's core
CFLAGS+=-ansi -pedantic -Wno-long-long
# but -ansi forces -std=c90 for C or -std=c++98 for C++;
@@ -70,6 +71,8 @@ CFLAGS+=-ansi -pedantic -Wno-long-long
#.../qt5/include/QtCore/qcompilerdetection.h:561:6:
# error Qt requires a C++11 compiler and yours does not seem to be that.
# so we suppress -ansi when the build includes Qt
#LIBNH's winshim requires C99 for the way it is currently coded
endif
endif
# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
# leave it out by default.
@@ -168,6 +171,16 @@ WINOBJ = $(sort $(WINOBJ0))
# prevent duplicates in VARDATND if both X11 and Qt are being supported
VARDATND += $(sort $(VARDATND0))
ifdef WANT_LIBNH
CFLAGS += -DSHIM_GRAPHICS -DNOTTYGRAPHICS -DNOSHELL -DLIBNH
WINOBJ = winshim.o
MOREALL += ( cd src ; $(MAKE) pregame ; $(MAKE) libnethack.a )
libnethack.a: $(HOBJ) $(SYSOBJ) $(WINOBJ) ../lib/lua/liblua.a
$(AR) rcs $@ $(HOBJ) $(WINOBJ) ../lib/lua/liblua.a
@echo "$@ built."
winshim.o : ../win/shim/winshim.c $(HACK_H)
$(CC) $(CFLAGS) -c -o$@ $<
endif # BUILD_LIBNH
WANT_BUNDLE=1
ifdef WANT_SHARE_INSTALL