]> granicus.if.org Git - nethack/commitdiff
unix/Makefile.top fetch-Lua bit
authorPatR <rankin@nethack.org>
Thu, 3 Jun 2021 00:13:56 +0000 (17:13 -0700)
committerPatR <rankin@nethack.org>
Thu, 3 Jun 2021 00:13:56 +0000 (17:13 -0700)
% make spotless
% sh sys/unix/setup.sh sys/unix/hints/macOS.2020
% make fetch-Lua

worked, but the last ended with

|rm include/nhlua.h
|rm: include/nhlua.h: No such file or directory
|make: [fetch-Lua] Error 1 (ignored)

which might frighten skittish users (like me).  Check whether the
constructed header file exists (so is assumed to be for an earlier
Lua version) and only delete it in that case.  No more scary report
of benign failure when it isn't there (after 'make spotless' or for
brand new source setup).

Also, some time ago we came to the conclusion that 'if [ ]' was an
extension for GNU 'bash' and wouldn't work with some older actual
'sh' implementations.  This replaces the one post-3.6 instance of
|if [ ! -d foo ] then bar; fi
in Makefile.top with
|if test -d foo; then true; else bar; fi
Testing was successful but done with bash rather than an old sh. :-}

sys/unix/Makefile.top

index 533c80a6da83f978b4c4a47a8c6d6f942a8b5ab2..1c8bdf54ab829b3044557347c1c6243c3e51f518 100644 (file)
@@ -121,7 +121,7 @@ lib/lua-$(LUA_VERSION)/src/liblua.a: lib/lua-$(LUA_VERSION)/src/lua.h
        ( cd lib/lua-$(LUA_VERSION)/src \
          && make CC='$(CC)' 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 )
+       @( if test -d lib/lua ; then true ; else mkdir -p lib/lua ; fi )
        cp lib/lua-$(LUA_VERSION)/src/liblua.a $@
 include/nhlua.h: $(TOPLUALIB)
        echo '/* nhlua.h - generated by top Makefile */' > $@
@@ -286,8 +286,9 @@ fetch-Lua:
          curl -R -O http://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz && \
          tar zxf lua-$(LUA_VERSION).tar.gz && \
          rm -f lua-$(LUA_VERSION).tar.gz )
-#if we just fetched lua, force include/nhlua.h to be built based on it
-       -rm include/nhlua.h
+# remove include/nhlua.h in case it was created for some other Lua version
+       @( if test -f include/nhlua.h ; then \
+            rm -f include/nhlua.h && echo 'rm include/nhlua.h' ; fi )
 
 # 'make update' can be used to install a revised version after making
 # customizations or such.  Unlike 'make install', it doesn't delete everything