From bdd4522ca98c5ead1c7bad4cd2e13517de4d0a08 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 7 Jul 2025 22:34:45 +0300 Subject: [PATCH] Migrate the Windows build from GNUWin to Git Bash and ezwinports's Make --- Makefile | 15 ++++++++++----- README.md | 5 +++-- build-faq.md | 19 +++---------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 17cd55e9d..fc067f5ee 100644 --- a/Makefile +++ b/Makefile @@ -36,10 +36,14 @@ else DEFAULT := sdl endif + NULL := /dev/null ifeq ($(PLATFORM),windows32) +ifneq ($(shell echo /dev/null*),/dev/null) +# Windows shell is not "aware" of /dev/null, use NUL and pray NULL := NUL endif +endif PREFIX ?= /usr/local ifneq ($(shell which xdg-open 2> $(NULL))$(FREEDESKTOP),) @@ -210,9 +214,10 @@ CFLAGS += -DUPDATE_SUPPORT endif ifeq (,$(PKG_CONFIG)) +ifneq ($(PLATFORM),windows32) SDL_CFLAGS := $(shell sdl2-config --cflags) SDL_LDFLAGS := $(shell sdl2-config --libs) -lpthread - +endif ifeq ($(PLATFORM),Darwin) SDL_LDFLAGS += -framework AppKit endif @@ -668,11 +673,11 @@ $(BIN)/SDL/sameboy.exe: $(CORE_OBJECTS) $(SDL_OBJECTS) $(OBJ)/Windows/resources. $(BIN)/SDL/sameboy_debugger.txt: echo Looking for sameboy_debugger.exe? > $@ - echo\>> $@ + echo >> $@ echo Starting with SameBoy v1.0.1, sameboy.exe and sameboy_debugger.exe >> $@ echo have been merged into a single executable. You can open a debugger >> $@ echo console at any time by pressing Ctrl+C to interrupt the currently >> $@ - echo open ROM. Once you're done debugging, you can close the debugger >> $@ + echo open ROM. Once you\'re done debugging, you can close the debugger >> $@ echo console and resume normal execution. >> $@ ifneq ($(USE_WINDRES),) @@ -685,13 +690,13 @@ $(OBJ)/%.res: %.rc rc /fo $@ /dVERSION=\"$(VERSION)\" /dCOPYRIGHT_YEAR=\"$(COPYRIGHT_YEAR)\" $^ %.o: %.res - cvtres /OUT:"$@" $^ + cvtres /MACHINE:X64 /OUT:"$@" $^ endif # Copy required DLL files for the Windows port $(BIN)/SDL/%.dll: -@$(MKDIR) -p $(dir $@) - @$(eval MATCH := $(shell where $$LIB:$(notdir $@))) + @$(eval MATCH := $(shell where "$(lib)":$(notdir $@))) cp "$(MATCH)" $@ # Tester diff --git a/README.md b/README.md index a35cc9a24..3e9afc054 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,9 @@ SameBoy requires the following tools and libraries to build: On Windows, SameBoy also requires: * Visual Studio (For headers, etc.) - * [GnuWin](http://gnuwin32.sourceforge.net/) - * Running vcvars64 before running make. Make sure all required tools and libraries are in %PATH% and %lib%, respectively. (see [Build FAQ](https://github.com/LIJI32/SameBoy/blob/master/build-faq.md) for more details on Windows compilation) + * [Git Bash](https://git-scm.com/downloads/win) or another distribution of basic Unix utilities + * Git Bash does not include make, you can get it [here](https://sourceforge.net/projects/ezwinports/files/make-4.4.1-without-guile-w32-bin.zip/download). + * Running `vcvars64.bat` or `vcvarsx86_amd64.bat` before running make. Make sure all required tools, libraries, and headers are in %PATH%, %lib%, and %include%`, respectively. (see [Build FAQ](https://github.com/LIJI32/SameBoy/blob/master/build-faq.md) for more details on Windows compilation) To compile, simply run `make`. The targets are: * `cocoa` (Default for macOS) diff --git a/build-faq.md b/build-faq.md index b2b791ef2..6cf1a4b7f 100644 --- a/build-faq.md +++ b/build-faq.md @@ -26,9 +26,9 @@ The following examples will be referenced later: After downloading [rgbds](https://github.com/gbdev/rgbds/releases/), ensure that it is added to the `%PATH%`. This may be done by adding it to the user's or SYSTEM's Environment Variables, or may be added to the command line at compilation time via `set path=%path%;C:\path\to\rgbds`. -### GnuWin +### Git Bash & Make -Ensure that the `gnuwin32\bin\` directory is included in `%PATH%`. Like rgbds above, this may instead be manually included on the command line before installation: `set path=%path%;C:\path\to\gnuwin32\bin`. +Ensure that the `Git\usr\bin` directory is included in `%PATH%`. Like rgbds above, this may instead be manually included on the command line before installation: `set path=%path%;C:\path\to\Git\usr\bin`. Similarly, make sure that the directory containing `make.exe` is also included. ## Building @@ -40,18 +40,5 @@ set lib=%lib%;C:\SDL2\lib\x64 set include=%include%;C:\SDL2\include make ``` -Please note that these directories (`C:\SDL2\*`) are the examples given within the "SDL Port" section above. Ensure that your `%PATH%` properly includes `rgbds` and `gnuwin32\bin`, and that the `lib` and `include` paths include the appropriate SDL2 directories. +On some versions of Visual Studio, you might need to use `vcvarsx86_amd64` instead of `vcvars64`. Please note that these directories (`C:\SDL2\*`) are the examples given within the "SDL Port" section above. Ensure that your `%PATH%` properly includes `rgbds` and `Git\usr\bin`, and that the `lib` and `include` paths include the appropriate SDL2 directories. -## Common Errors - -### Error -1073741819 - -If encountering an error that appears as follows: - -``` make: *** [build/bin/BootROMs/dmg_boot.bin] Error -1073741819``` - -Simply run `make` again, and the process will continue. This appears to happen occasionally with `build/bin/BootROMs/dmg_boot.bin` and `build/bin/BootROMs/sgb2_boot.bin`. It does not affect the compiled output. This appears to be an issue with GnuWin. - -### The system cannot find the file specified (`usr/bin/mkdir`) - -If errors arise (i.e., particularly with the `CREATE_PROCESS('usr/bin/mkdir')` calls, also verify that Git for Windows has not been installed with full Linux support. If it has, remove `C:\Program Files\Git\usr\bin` from the SYSTEM %PATH% until after compilation. This happens because the Git for Windows version of `which` is used instead of the GnuWin one, and it returns a Unix-style path instead of a Windows one.