From ce5eebcb9b2f73c91b87cfe4940b36bc32b179c2 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 18 May 2020 12:01:23 -0700 Subject: [PATCH] fix lua tmpname() vs mkstemp() on linux Avoid the warning that tmpname should be replaced by mkstemp by replacing tmpname with mkstemp. lua has code to do that but it isn't trivial to activate while leaving the lua distribution unmodified. [I've no idea whether nethack's usage even results in liblua ever creating any temporary files.] Using nethack's hints to pass -DLUA_USE_POSIX from top Makefile to lib/lua-$(LUA_VERSION)/Makefile has been tested, building liblua.a on linux with that has not. --- sys/unix/Makefile.top | 5 +++-- sys/unix/hints/linux | 7 ++++++- sys/unix/hints/linux-chroot | 7 ++++++- sys/unix/hints/linux-minimal | 7 ++++++- sys/unix/hints/linux-qt4 | 7 ++++++- sys/unix/hints/linux-qt5 | 7 ++++++- sys/unix/hints/linux-x11 | 7 ++++++- 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/sys/unix/Makefile.top b/sys/unix/Makefile.top index 5fb067907..784bd35e2 100644 --- a/sys/unix/Makefile.top +++ b/sys/unix/Makefile.top @@ -1,5 +1,5 @@ # NetHack Top-level Makefile. -# NetHack 3.6 Makefile.top $NHDT-Date: 1575932543 2019/12/09 23:02:23 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.44 $ +# NetHack 3.6 Makefile.top $NHDT-Date: 1589828477 2020/05/18 19:01:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.48 $ # Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland # NetHack may be freely redistributed. See license for details. @@ -105,7 +105,8 @@ $(GAME): lua_support lua_support: lib/lua/liblua.a include/nhlua.h @true lib/lua-$(LUA_VERSION)/src/liblua.a: lib/lua-$(LUA_VERSION)/src/lua.h - ( cd lib/lua-$(LUA_VERSION)/src ; make a ; cd ../../.. ) + ( cd lib/lua-$(LUA_VERSION)/src \ + && make SYSCFLAGS=$(SYSCFLAGS) a && cd ../../.. ) lib/lua/liblua.a: lib/lua-$(LUA_VERSION)/src/liblua.a @( if [ ! -d lib/lua ] ; then mkdir -p lib/lua ; fi ) cp lib/lua-$(LUA_VERSION)/src/liblua.a $@ diff --git a/sys/unix/hints/linux b/sys/unix/hints/linux index 862915053..47260f78c 100644 --- a/sys/unix/hints/linux +++ b/sys/unix/hints/linux @@ -1,5 +1,5 @@ # -# NetHack 3.6 linux $NHDT-Date: 1432512814 2015/05/25 00:13:34 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $ +# NetHack 3.6 linux $NHDT-Date: 1589828478 2020/05/18 19:01:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.31 $ # Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007. # NetHack may be freely redistributed. See license for details. # @@ -35,6 +35,11 @@ CFLAGS+=-DCURSES_GRAPHICS #CFLAGS+=-DMSGHANDLER #CFLAGS+=-DTTY_TILES_ESCCODES +# when building liblua.a, avoid warning that use of tmpnam() should be +# replaced by mkstemp(); the lua code doesn't use nethack's config.h so +# this needs to be passed via make rather than defined in unixconf.h +SYSCFLAGS=-DLUA_USE_POSIX + LINK=$(CC) # Only needed for GLIBC stack trace: LFLAGS=-rdynamic diff --git a/sys/unix/hints/linux-chroot b/sys/unix/hints/linux-chroot index e5bb767fb..45425533c 100644 --- a/sys/unix/hints/linux-chroot +++ b/sys/unix/hints/linux-chroot @@ -1,5 +1,5 @@ # -# NetHack 3.5 linux $NHDT-Date: 1524684267 2018/04/25 19:24:27 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.1 $ +# NetHack 3.5 linux $NHDT-Date: 1589828479 2020/05/18 19:01:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.3 $ # NetHack 3.5 linux $Date: 2010/01/15 19:54:37 $ $Revision: 1.8 $ # Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007. # NetHack may be freely redistributed. See license for details. @@ -31,6 +31,11 @@ CFLAGS+=-DTIMED_DELAY CFLAGS+=-DHACKDIR=\"$(HACKDIR)\" CFLAGS+=-DVAR_PLAYGROUND=\"$(HACKDIR)/var\" +# when building liblua.a, avoid warning that use of tmpnam() should be +# replaced by mkstemp(); the lua code doesn't use nethack's config.h so +# this needs to be passed via make rather than defined in unixconf.h +SYSCFLAGS=-DLUA_USE_POSIX + LINK=$(CC) # Only needed for GLIBC stack trace: LFLAGS=-rdynamic diff --git a/sys/unix/hints/linux-minimal b/sys/unix/hints/linux-minimal index 256332cc7..0582792d9 100644 --- a/sys/unix/hints/linux-minimal +++ b/sys/unix/hints/linux-minimal @@ -1,5 +1,5 @@ # -# NetHack 3.6 linux $NHDT-Date: 1432512814 2018/11/23 16:00:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.12 $ +# NetHack 3.6 linux $NHDT-Date: 1589828479 2020/05/18 19:01:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.1 $ # Copyright (c) Patric Mueller # NetHack may be freely redistributed. See license for details. # @@ -15,6 +15,11 @@ VARDIR=$(HACKDIR) CFLAGS=-g -I../include +# when building liblua.a, avoid warning that use of tmpnam() should be +# replaced by mkstemp(); the lua code doesn't use nethack's config.h so +# this needs to be passed via make rather than defined in unixconf.h +SYSCFLAGS=-DLUA_USE_POSIX + LINK=$(CC) WINSRC = $(WINTTYSRC) diff --git a/sys/unix/hints/linux-qt4 b/sys/unix/hints/linux-qt4 index 910345ed1..33abfbc84 100644 --- a/sys/unix/hints/linux-qt4 +++ b/sys/unix/hints/linux-qt4 @@ -1,5 +1,5 @@ # -# NetHack 3.6 linux-qt4 $NHDT-Date: 1566346592 2019/08/21 00:16:32 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.27 $ +# NetHack 3.6 linux-qt4 $NHDT-Date: 1589828479 2020/05/18 19:01:19 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.28 $ # Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007. # NetHack may be freely redistributed. See license for details. # @@ -30,6 +30,11 @@ CFLAGS+=-DCONFIG_ERROR_SECURE=FALSE CFLAGS+=-DQT_GRAPHICS -DDEFAULT_WINDOW_SYS=\"Qt\" -DNOTTYGRAPHICS CFLAGS+=`pkg-config QtGui --cflags` +# when building liblua.a, avoid warning that use of tmpnam() should be +# replaced by mkstemp(); the lua code doesn't use nethack's config.h so +# this needs to be passed via make rather than defined in unixconf.h +SYSCFLAGS=-DLUA_USE_POSIX + LINK=g++ CXX=g++ -std=gnu++11 diff --git a/sys/unix/hints/linux-qt5 b/sys/unix/hints/linux-qt5 index bcf1a06ef..1ee188568 100644 --- a/sys/unix/hints/linux-qt5 +++ b/sys/unix/hints/linux-qt5 @@ -1,5 +1,5 @@ # -# NetHack 3.6 linux-qt5 $NHDT-Date: 1566346602 2019/08/21 00:16:42 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.27 $ +# NetHack 3.6 linux-qt5 $NHDT-Date: 1589828480 2020/05/18 19:01:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.29 $ # Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007. # NetHack may be freely redistributed. See license for details. # @@ -30,6 +30,11 @@ CFLAGS+=-DCONFIG_ERROR_SECURE=FALSE CFLAGS+=-DQT_GRAPHICS -DDEFAULT_WINDOW_SYS=\"Qt\" -DNOTTYGRAPHICS CFLAGS+=`pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --cflags` -fPIC +# when building liblua.a, avoid warning that use of tmpnam() should be +# replaced by mkstemp(); the lua code doesn't use nethack's config.h so +# this needs to be passed via make rather than defined in unixconf.h +SYSCFLAGS=-DLUA_USE_POSIX + LINK=g++ CXX=g++ -std=gnu++11 diff --git a/sys/unix/hints/linux-x11 b/sys/unix/hints/linux-x11 index 2f340e981..0f186e3f0 100644 --- a/sys/unix/hints/linux-x11 +++ b/sys/unix/hints/linux-x11 @@ -1,5 +1,5 @@ # -# NetHack 3.6 linux-x11 $NHDT-Date: 1566346602 2019/08/21 00:16:42 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.24 $ +# NetHack 3.6 linux-x11 $NHDT-Date: 1589828480 2020/05/18 19:01:20 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.25 $ # Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007. # NetHack may be freely redistributed. See license for details. # @@ -27,6 +27,11 @@ CFLAGS+=-DX11_GRAPHICS -DDEFAULT_WINDOW_SYS=\"X11\" -DNOTTYGRAPHICS CFLAGS+=-DDUMPLOG CFLAGS+=-DCONFIG_ERROR_SECURE=FALSE +# when building liblua.a, avoid warning that use of tmpnam() should be +# replaced by mkstemp(); the lua code doesn't use nethack's config.h so +# this needs to be passed via make rather than defined in unixconf.h +SYSCFLAGS=-DLUA_USE_POSIX + LINK=$(CC) WINSRC = $(WINX11SRC)