Skip to content

Update cygwin and wsl1 makefiles to use the "Common Linux" scheme from PR#542; Update github workflows to use latest versions of actions#543

Closed
fghalasz wants to merge 11 commits intomasterfrom
fgh_makefile-consolidation
Closed

Update cygwin and wsl1 makefiles to use the "Common Linux" scheme from PR#542; Update github workflows to use latest versions of actions#543
fghalasz wants to merge 11 commits intomasterfrom
fgh_makefile-consolidation

Conversation

@fghalasz
Copy link
Copy Markdown
Member

This PR does three things:

  1. Slightly update the Linux makefiles that use the common included makefiles scheme implemented in PR Update linux makefiles to 1) use libbsd-overlay and 2) isolate common code from linux makefiles into included makefiles. And update Cmakelists to use libbsd-overlay package in case of Linux; Update Cmakelists to include an install target similar to that used in the makefiles. #542

  2. Apply the updated common included makefiles scheme to the Cygwin and WSL1 makefiles - since they are essentially the same as the Linux makefiles.

  3. Update all github workflows to use the latest versions of github actions to account for the impending deprecation of Node 20.

nbriggs and others added 10 commits February 21, 2026 17:32
…init-linux*. Add libbsd to MAIKO_LIBRARIES (where appropriate) in CMakeLists.txt. This will support building maiko on Ubuntu 22.04 and Debian 12, where strlcat is found only in libbsd. For Ubuntu 24.04 and beyond and Debian 13 and beyond, strlcat is now in glibc (>2.38).
…on systems with glibc <2.38 (e.g., Ubuntu 22.04 and Debian 12).
…file as well as common makefiles for X and sdl. These included makefiles have the name linux-*.mk. Updated all linux makefiles to use the libbsd-overlay package, using pkg-config to set the appropriate flags. Updated CMakelists to also use the libbsd-overlay package via pkgconfig for Linux only. Finally added install targets to the CMakelists file so that cmake --install . will place the lde binaries into the appropriate directory in maiko as the makefiles currently do.
… be used by libbsd changes to linux makefiles
… depending on whats installed. Refactored Linux makefiles to simplify top level makefiles with slightly more complicated common makefiles. Makefiles for Cygwin and WSL1 all rewritten to use the common linux makefiles code.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the build system by introducing a common set of Makefile includes for Linux-based environments, including Cygwin and WSL1. This change centralizes compiler selection, library dependencies, and display-specific options, reducing redundancy and simplifying maintenance across various Linux, Cygwin, and WSL1 build configurations. Additionally, the CMake build configuration was updated to properly link with 'libbsd-overlay' on Linux and to define installation targets.

Highlights

  • Makefile Refactoring: Refactored Linux makefiles to centralize common build options and logic into a new shared scheme.
  • Cygwin and WSL1 Integration: Applied the newly introduced common makefile scheme to Cygwin and WSL1 build configurations, streamlining their build processes.
  • CMake Build Enhancements: Updated the CMake build configuration to properly link with the 'libbsd-overlay' library on Linux and introduced new installation targets for executables.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • CMakeLists.txt
    • Removed an empty line for cleaner formatting.
    • Added conditional logic to find and link 'libbsd-overlay' using PkgConfig specifically for Linux systems.
    • Linked the 'lde' executable with 'MAIKO_LIBRARIES' to ensure proper dependency resolution.
    • Introduced installation targets for 'lde', 'ldex', 'ldeinit', and 'ldesdl' executables, dynamically determining the installation directory based on OS and machine type.
  • bin/linux-common.mk
    • Added a new file to centralize common Makefile variables and logic for Linux, including compiler selection, libbsd usage, display options (X, SDL, init), optimization flags, and default targets.
  • bin/linux-compiler.mk
    • Added a new file implementing logic to select between 'gcc' and 'clang' based on availability and explicit 'USE_CLANG'/'USE_GCC' flags.
  • bin/linux-libbsd.mk
    • Added a new file to check for 'pkg-config' and 'libbsd-overlay' package availability, and defined 'BSD_CFLAGS' and 'BSD_LDFLAGS'.
  • bin/linux-sdl.mk
    • Added a new file defining 'XFILES', 'XFLAGS' (for SDL version), and 'XLDFLAGS' for SDL-based builds.
  • bin/linux-x.mk
    • Added a new file defining 'XFILES', 'XFLAGS', and 'XLDFLAGS' for X-Windows based builds.
  • bin/makefile-cygwin.x86_64-sdl
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for Cygwin SDL builds.
  • bin/makefile-cygwin.x86_64-x
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for Cygwin X-Window builds.
  • bin/makefile-init-linux.aarch64
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for AArch64 Linux init builds.
  • bin/makefile-init-linux.x86_64
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for x86_64 Linux init builds.
  • bin/makefile-init-wsl1.aarch64
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for AArch64 WSL1 init builds.
  • bin/makefile-init-wsl1.x86_64
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for x86_64 WSL1 init builds.
  • bin/makefile-linux.386-sdl
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for 386 Linux SDL builds.
  • bin/makefile-linux.386-x
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for 386 Linux X-Window builds.
  • bin/makefile-linux.aarch64-sdl
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for AArch64 Linux SDL builds.
  • bin/makefile-linux.aarch64-x
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for AArch64 Linux X-Window builds.
  • bin/makefile-linux.armv7l-sdl
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for ARMv7l Linux SDL builds.
  • bin/makefile-linux.armv7l-x
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for ARMv7l Linux X-Window builds.
  • bin/makefile-linux.x86_64-sdl
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for x86_64 Linux SDL builds.
  • bin/makefile-linux.x86_64-x
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for x86_64 Linux X-Window builds.
  • bin/makefile-wsl1.aarch64-sdl
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for AArch64 WSL1 SDL builds.
  • bin/makefile-wsl1.aarch64-x
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for AArch64 WSL1 X-Window builds.
  • bin/makefile-wsl1.x86_64-sdl
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for x86_64 WSL1 SDL builds.
  • bin/makefile-wsl1.x86_64-x
    • Refactored to remove duplicated build logic and instead include 'bin/linux-common.mk', setting specific variables for x86_64 WSL1 X-Window builds.
Ignored Files
  • Ignored by pattern: .github/workflows/** (4)
    • .github/workflows/Dockerfile_builder
    • .github/workflows/build.yml
    • .github/workflows/buildBuilderImage.yml
    • .github/workflows/buildRelease.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the various Linux, Cygwin, and WSL1 makefiles to use a common set of included makefiles, reducing code duplication and improving maintainability. It also introduces some changes to CMakeLists.txt to add installation targets and handle Linux-specific libraries. The refactoring is a good improvement, but I've found a few issues that need to be addressed to ensure the build system is correct and robust. I've identified a critical bug in one of the makefiles using the wrong architecture flag, and a couple of high-severity issues related to linking and path robustness in the build scripts.

Comment on lines +3 to +4
GCC_CFLAGS := -m64 $(GCC_CFLAGS)
CLANG_CFLAGS := -m64 $(CLANG_CFLAGS)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This makefile is for the 386 (i.e., 32-bit x86) architecture, but GCC_CFLAGS and CLANG_CFLAGS are being set with the -m64 flag, which is for the 64-bit architecture. This will result in a build for the wrong architecture. The flag should be -m32.

GCC_CFLAGS := -m32 $(GCC_CFLAGS)
CLANG_CFLAGS := -m32 $(CLANG_CFLAGS)

Comment on lines +542 to +547
execute_process(
COMMAND sh -c "echo $(../bin/osversion).$(../bin/machinetype)"
OUTPUT_VARIABLE release_dir
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The execute_process command uses relative paths like ../bin/osversion. This approach is not robust for out-of-source builds, where the build directory is not a direct subdirectory of the source root, and will cause the build to fail in such standard setups. You should use absolute paths constructed with CMAKE_SOURCE_DIR to make the command reliable regardless of the build directory location.

execute_process(
  COMMAND sh -c "echo $(${CMAKE_SOURCE_DIR}/bin/osversion).$(${CMAKE_SOURCE_DIR}/bin/machinetype)"
  OUTPUT_VARIABLE release_dir
  OUTPUT_STRIP_TRAILING_WHITESPACE
)

DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) $(ADDITIONAL_DFLAGS)

LDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS)
LDELDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The LDELDFLAGS variable is being set to include $(XLDFLAGS). When building with SDL (USE_DISPLAY=sdl), XLDFLAGS contains SDL-related linker flags. The lde executable, which is linked using LDELDFLAGS, does not use SDL and should not be linked against SDL libraries. This will likely cause build failures. LDELDFLAGS should only include X11 flags when USE_DISPLAY=x.

ifeq ($(USE_DISPLAY),x)
LDELDFLAGS =  $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS)
else
LDELDFLAGS = -lc -lm $(BSD_LDFLAGS)
endif

Copy link
Copy Markdown
Collaborator

@nbriggs nbriggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gemini is correct that bin/makefile-linux.386-SDL must have "-m32" not "-m64" for the 32-bit 386 build.

…king to libbsd (if requested) only if glibc < version 2.38 since glibc >= 2.38 includes strlcat and friends.
@pamoroso
Copy link
Copy Markdown
Member

It builds and works with no issues on Linux Mint 22.1 Cinnamon.

@fghalasz
Copy link
Copy Markdown
Member Author

Merged into PR 544 (fgh_redo-linux-makefiles branch). Closing without merge to master.

@fghalasz fghalasz closed this Mar 18, 2026
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.

3 participants