From fec6320e6870d12c90f12ffaac055c2ed330e84d Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 2 Dec 2024 19:04:08 -0500 Subject: [PATCH] rename sys/windows/Makefile.mingw32 to GNUmakefile GNU make looks first for a file called GNUmakefile, ahead of looking for Makefile and then makefile. Renaming sys/windows/Makefile.mingw32 to sys/windows/GNUmakefile allows: o src/GNUmakefile (for use by GNU make) and src/Makefile (for use Microsoft nmake) to both reside in the src folder during build. o src/GNUmakefile will be used by GNU make, without having to explicitly specify "-f GNUmakefile" on the GNU make command line. o src/Makefile will be used by Microsoft nmake, without having to explicitly specify "-f Makefile" on the Microsoft nmake command line. For the gcc build, the movemement of sys/windows/GNUmakefile needs to be copied to src/GNUmakefile as part of the build process (see sys/windows/build-msys2.txt). For the Microsoft Visual Studio command line build with nmake, sys/windows/Makefile.nmake needs to be copied to src/Makefile as part of the build process (see sys/windows/build-nmake.txt). They are both copied to the src folder from their respective repository source file names when the nhsetup.bat file is used. --- azure-pipelines.yml | 8 +++--- doc/fixes3-7-0.txt | 5 ++-- doc/sound.txt | 4 +-- include/windconf.h | 5 ---- src/.gitattributes | 6 ++--- src/.gitignore | 4 +-- sys/windows/{Makefile.mingw32 => GNUmakefile} | 8 +++--- ...file.mingw32.depend => GNUmakefile.depend} | 4 +-- sys/windows/build-msys2.txt | 26 ++++++++++--------- sys/windows/nhsetup.bat | 8 +++--- win/curses/Readme.txt | 2 +- win/share/safeproc.c | 9 +++++-- 12 files changed, 45 insertions(+), 44 deletions(-) rename sys/windows/{Makefile.mingw32 => GNUmakefile} (99%) rename sys/windows/{Makefile.mingw32.depend => GNUmakefile.depend} (96%) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2a8a4ee87..624d4a640 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -164,10 +164,10 @@ steps: export cd ../src pwd - cp ../sys/windows/Makefile.mingw32* . - mingw32-make -f Makefile.mingw32 CI_COMPILER=1 GIT=1 MSYSTEM=$MSYSTEM LUA_VERSION=$LUA_VERSION clean - mingw32-make -f Makefile.mingw32 CI_COMPILER=1 GIT=1 MSYSTEM=$MSYSTEM LUA_VERSION=$LUA_VERSION depend - mingw32-make -f Makefile.mingw32 CI_COMPILER=1 GIT=1 MSYSTEM=$MSYSTEM LUA_VERSION=$LUA_VERSION + cp ../sys/windows/GNUmakefile* . + mingw32-make -f GNUmakefile CI_COMPILER=1 GIT=1 MSYSTEM=$MSYSTEM LUA_VERSION=$LUA_VERSION clean + mingw32-make -f GNUmakefile CI_COMPILER=1 GIT=1 MSYSTEM=$MSYSTEM LUA_VERSION=$LUA_VERSION depend + mingw32-make -f GNUmakefile CI_COMPILER=1 GIT=1 MSYSTEM=$MSYSTEM LUA_VERSION=$LUA_VERSION condition: eq( variables.toolchain, 'mingw' ) workingDirectory: $(Agent.BuildDirectory)/$(netHackPath)/src displayName: 'MinGW Build' diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 1a60a914a..5aaf97818 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2863,9 +2863,8 @@ use %lu, not %d, in format string in timer_sanity_check() (pr #617 by argrath) bad cast making sp_lev chameleon light source (pr #625 by entrez) add Ray Chason's adaptation of nethack's Qt5 interface to work with Qt6 (issue #525 followup comment by chasonr) -mingw32 build updates and replacement of sys/windows/Makefile.gcc with new - sys/windows/Makefile.mingw32 and sys/windows/Makefile.mingw32.depend - (pr #661 by feiyunw) +mingw32 build updates to replace contents of sys/windows/GNUmakefile and new + sys/windows/GNUmakefile.depend (pr #661 by feiyunw) mark various pointers to const char as const pointers (pr #624 by argrath) function fill_special_room() in sp_lev.c was dereferencing a pointer argument prior to a subsequent check for a NULL pointer that diff --git a/doc/sound.txt b/doc/sound.txt index 6af2a9707..2f90d3334 100644 --- a/doc/sound.txt +++ b/doc/sound.txt @@ -508,8 +508,8 @@ use the following guidelines: Windows with Visual studio nmake at the command line. - sys/windows/Makefile.mingw32 - sys/windows/Makefile.mingw32.depend + sys/windows/GNUmakefile + sys/windows/GNUmakefile.depend Will require updates in order to build on Windows with mingw32 or MSYS2 using GNU make at diff --git a/include/windconf.h b/include/windconf.h index 1b5b45d92..63c58cdbc 100644 --- a/include/windconf.h +++ b/include/windconf.h @@ -107,11 +107,6 @@ extern char *windows_exepath(void); #ifdef strcasecmp #undef strcasecmp /* https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ */ -#ifdef __USE_MINGW_ANSI_STDIO -#undef __USE_MINGW_ANSI_STDIO -#endif -/* with UCRT, we don't define this to 1 */ -#define __USE_MINGW_ANSI_STDIO 0 #endif /* extern int getlock(void); */ #endif /* __GNUC__ */ diff --git a/src/.gitattributes b/src/.gitattributes index 1e3746cde..a618fdc82 100644 --- a/src/.gitattributes +++ b/src/.gitattributes @@ -1,8 +1,8 @@ * NH_filestag=(file%s_for_all_versions) -..files NH_filegenerated=Makefile,Makefile.mingw32,qt_kde0.moc,qt_main.moc,qt_map.moc,qt_menu.moc,qt_msg.moc,qt_plsel.moc,qt_set.moc,qt_stat.moc,qt_xcmd.moc,qt_yndlg.moc,tile.c,monstr.c +..files NH_filegenerated=Makefile,GNUmakefile,qt_kde0.moc,qt_main.moc,qt_map.moc,qt_menu.moc,qt_msg.moc,qt_plsel.moc,qt_set.moc,qt_stat.moc,qt_xcmd.moc,qt_yndlg.moc,tile.c,monstr.c -Makefile.mingw32 NH_filesgentag=(file%s_for_win32_that_are_moved_into_src_at_compile_time) -Makefile NH_filesgentag=>Makefile.mingw32 +GNUmakefile NH_filesgentag=(file%s_for_win32_that_are_moved_into_src_at_compile_time) +Makefile NH_filesgentag=>GNUmakefile qt_kde0.moc NH_filesgentag=(file%s_generated_by_'moc'_for_Qt_interface_at_compile_time) qt_main.moc NH_filesgentag=>qt_kde0.moc diff --git a/src/.gitignore b/src/.gitignore index 9343f331b..dda3abdac 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -28,6 +28,6 @@ objutil/* objlua/* objpdc/* bundle/* -Makefile.mingw32 -Makefile.mingw32.depend +GNUmakefile +GNUmakefile.depend .*.c diff --git a/sys/windows/Makefile.mingw32 b/sys/windows/GNUmakefile similarity index 99% rename from sys/windows/Makefile.mingw32 rename to sys/windows/GNUmakefile index 809b822bd..bd2d71d2b 100644 --- a/sys/windows/Makefile.mingw32 +++ b/sys/windows/GNUmakefile @@ -1,11 +1,11 @@ -# NetHack 3.7 Makefile.mingw32 +# NetHack 3.7 GNUmakefile # Copyright (c) 2022 by Feiyun Wang #-Copyright (c) 2022 by Michael Allison # NetHack may be freely redistributed. See license for details. # #============================================================================== # -# Win32 Compilers Tested with this Makefile.mingw32: +# Win32 Compilers Tested with this GNUmakefile: # mingw-w64 # from: # https://sourceforge.net/p/mingw-w64/wiki2/GeneralUsageInstructions/ @@ -430,7 +430,7 @@ CLEAN_FILE += $(LUATARGETS) $(LUAOBJS) $(OLUA)/lua.o $(OLUA)/luac.o NHLUAH = $(INCL)/nhlua.h $(NHLUAH): - echo "/* nhlua.h - generated by Makefile.mingw32 */" > $@ + echo "/* nhlua.h - generated by GNUmakefile */" > $@ @echo "#include \"$(LUASRC)/lua.h\"" >> $@ @echo "LUA_API int (lua_error) (lua_State *L) NORETURN;" >>$@ @echo "#include \"$(LUASRC)/lualib.h\"" >> $@ @@ -1296,6 +1296,6 @@ clean: @$(foreach dir, $(CLEAN_DIR), \ if [ -d $(dir) ] ; then rmdir -p --ignore $(dir) ; fi ; ) --include Makefile.mingw32.depend +-include GNUmakefile.depend -include .depend # end of file diff --git a/sys/windows/Makefile.mingw32.depend b/sys/windows/GNUmakefile.depend similarity index 96% rename from sys/windows/Makefile.mingw32.depend rename to sys/windows/GNUmakefile.depend index 71c925c67..230bf8e38 100644 --- a/sys/windows/Makefile.mingw32.depend +++ b/sys/windows/GNUmakefile.depend @@ -2,12 +2,12 @@ cce = gcc -E -MM -MT "$(@:d=o) $@" -# Copy all $(cc) commands w/ their targets from Makefile.mingw32, 3rd party code unnecessary +# Copy all $(cc) commands w/ their targets from GNUmakefile, 3rd party code unnecessary # Replace .o w/ .d, $(cc) w/ $(cce) # Check extraordinary "OBJ): " and handle them properly # Check all CLEAN_FILE lines, add obj files to $(OBJS4DEP) # Run -# mingw32-make depend +# make depend $(HL)/%.d: $(SRC)/%.c | $(HL) $(cce) $(CFLAGSU) $< -o$@ diff --git a/sys/windows/build-msys2.txt b/sys/windows/build-msys2.txt index 4ce421f2e..1258f7be9 100644 --- a/sys/windows/build-msys2.txt +++ b/sys/windows/build-msys2.txt @@ -92,9 +92,11 @@ I. Dispelling the Myths: as it looks, however it will behoove you to read this entire section through before beginning the task. - We have provided Makefile.mingw32 in - sys/windows/Makefile.mingw32, which you use from the bash Windows command - shell included with MSYS2. + We have provided GNUmakefile in sys/windows/GNUmakefile, which you use + from the bash Windows command shell included with MSYS2. It is called + GNUmakefile because that is the first name searched for by the GNU + make utility thus preventing conflict with the Makefile used by the + Microsoft nmake utility. II. To compile your copy of NetHack on a Windows machine using MSYS2: @@ -106,7 +108,7 @@ Setting Up 2. Execute the following command to place copies of the Makefiles in the src subfolder. - cp sys/windows/Makefile.mingw32* src + cp sys/windows/GNUmakefile* src 3. Change your current directory to the src subfolder of the nethack source tree. The following command assumes you are still in the @@ -120,10 +122,12 @@ Compiling Your current directory should be the NetHack src directory. - Issue these following commands: - make -f Makefile.mingw32 clean - make -f Makefile.mingw32 depend - make -f Makefile.mingw32 + Issue these following commands, which will find and use GNUmakefile + by default: + + make clean + make depend + make If all goes well, intermediate NetHack files will be placed in the binary subfolder of the NetHack tree, and the final NetHack package @@ -132,10 +136,8 @@ Compiling Notes: 1. To rebuild NetHack after changing something, change your current directory - to src and issue the appropriate command for your compiler: - - For gcc: - make -f Makefile.mingw32 + to src and issue the following command: + make 2. An alternative to MSYS2 may be MinGW-w64 - winlibs standalone build. That has not been tested by us at time of writing. diff --git a/sys/windows/nhsetup.bat b/sys/windows/nhsetup.bat index d365c1558..ed41d2361 100755 --- a/sys/windows/nhsetup.bat +++ b/sys/windows/nhsetup.bat @@ -47,10 +47,10 @@ echo ..\..\src\Makefile-orig copy /Y Makefile.nmake ..\..\src\Makefile >nul echo Microsoft nmake Makefile.nmake copy to ..\..\src\Makefile completed. -echo Copying mingw-w64 Makefile.mingw32 to ..\..\src\Makefile.mingw32 -copy /Y Makefile.mingw32 ..\..\src\Makefile.mingw32 >nul -echo Copying mingw-w64 Makefile.mingw32.depend to ..\..\src\Makefile.mingw32.depend -copy /Y Makefile.mingw32.depend ..\..\src\Makefile.mingw32.depend >nul +echo Copying mingw-w64 GNUmakefile to ..\..\src\GNUmakefile +copy /Y GNUmakefile ..\..\src\GNUmakefile >nul +echo Copying mingw-w64 GNUmakefile.depend to ..\..\src\GNUmakefile.depend +copy /Y GNUmakefile.depend ..\..\src\GNUmakefile.depend >nul echo mingw-w64 Makefile copies to ..\..\src completed. echo Done copying files. diff --git a/win/curses/Readme.txt b/win/curses/Readme.txt index 2cc207238..a9ae0be7b 100644 --- a/win/curses/Readme.txt +++ b/win/curses/Readme.txt @@ -33,7 +33,7 @@ NetHack 3.7 and above. Windows build instructions: -By default, the Makefile.msc and Makefile.mingw32 are set up to build +By default, the Makefile.nmake and GNUmakefile are set up to build curses from the submodules/pdcurses submodules folder (assumes you obtained your NetHack sources via cloning a git repository), If you obtained your NetHack by another means, such as a zip download, diff --git a/win/share/safeproc.c b/win/share/safeproc.c index 2862117ff..aa2b3c478 100644 --- a/win/share/safeproc.c +++ b/win/share/safeproc.c @@ -65,6 +65,11 @@ * *********************************************************** */ +void safe_dismiss_nhwindow(winid); +void safe_putstr(winid, int, const char *); +void win_safe_init(int); +void safe_number_pad(int); + struct window_procs safe_procs = { WPID(safestartup), (0 @@ -225,7 +230,7 @@ safe_curs(winid window UNUSED, int x UNUSED, int y UNUSED) } void -safe_putstr(winid window, int attr, const char *str) +safe_putstr(winid window UNUSED, int attr UNUSED, const char *str UNUSED) { return; } @@ -424,7 +429,7 @@ safe_get_ext_cmd(void) } void -safe_number_pad(int mode) +safe_number_pad(int mode UNUSED) { return; }