Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade makefile support for Mingw and Wine #1557

Merged
merged 3 commits into from
Feb 2, 2025

Conversation

DanRStevens
Copy link
Member

Upgrades to makefile to make it easier to use for cross compiling with Mingw, and running resulting unit test executables with Wine.

Related:

There may be multiple `sdl2-config` executables present in a given environment. Having a variable for the executable file allows for easier customization of which executable to use.

A common case for this is doing cross compilation using Mingw to build a Windows executable from Linux. Normally the Linux environment would be setup for local building, and so `sdl2-config` would return flags suitable for a local Linux build. When doing cross compilation, there will be a separate binary install of SDL2 for Windows, which will have a separate `sdl2-config` executable, with Windows specific build flags and library paths.

Example:
```
make CXX=x86_64-w64-mingw32-g++ SDL_CONFIG="/usr/local/x86_64-w64-mingw32/bin/sdl2-config"
```
Example:
```
make --output-sync CXX=x86_64-w64-mingw32-g++ CPPFLAGS_EXTRA="-DGLEW_STATIC -I/usr/local/x86_64-w64-mingw32/include/" WARN_EXTRA="-Wno-redundant-decls" SDL_CONFIG_CFLAGS='' SDL_CONFIG_LIBS='' LDFLAGS_EXTRA='-L/usr/local/x86_64-w64-mingw32/lib' TARGET_OS=Windows WINEPATH="/usr/local/x86_64-w64-mingw32/bin/;/usr/lib/gcc/x86_64-w64-mingw32/10-win32/" check
```
Ideally the output filenames should match platform expectations. Normally the `.exe` suffix would be added anyway. Though the `makefile` rules reference the output filenames in a few places. Mostly the `.exe` suffix can be inferred. However, it is better for output names to match exactly, especially for `makefile` rules that need to determine if an output file is up-to-date.

Additionally, it was noted while looking into Wine upgrades that starting with Wine version 7, there seems to be trouble starting executable files when the `.exe` suffix is not explicitly specified. Failure to specify it can result in a hard to understand error message with code `c0000135` (`STATUS_DLL_NOT_FOUND` defined in `ntstatus.h`):
> wine: failed to open ".build/Debug_Linux_testLibOPHD/testLibOPHD": c0000135

The same command works when the file to run is given an explicit suffix when passed to `wine`:
> wine .build/Debug_Linux_testLibOPHD/testLibOPHD.exe
@DanRStevens DanRStevens merged commit 53f10fc into main Feb 2, 2025
7 checks passed
@DanRStevens DanRStevens deleted the makefileMingwWineUpgrades branch February 2, 2025 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant