Skip to content

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

Closed
fghalasz wants to merge 7 commits intomasterfrom
fgh_libbsd

Conversation

@fghalasz
Copy link
Member

This PR# includes 4 changes to the Makefiles for Linux and the CMakeslist file.

  1. All linux Makefiles now (when necessary) compile and link using the libbsd-overlay scheme via pkg-config.

  2. Cmakelists now has special code for Linux that (when necessary) causes compile and link to use the libbsd-overlay scheme via pkg-config.

  3. All Linux makefiles have been refactored so that common code is factored out of the top level linux makefiles and added to several common code makefiles (linux-*.mk) that are included into the top level makefiles.

  4. Added an install target to CMakeLists that installs lde, ldeinit ldex and ldesdl in the same binary directories that the Makefiles do, e.g., maiko/linux.x86_64.

Also added the pkgconf package to the Builder Docker image since it is required for the libbsd-overlay linux builds.

nbriggs and others added 7 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
@gemini-code-assist
Copy link

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 modernizes and streamlines the build process for Linux targets by introducing a standardized approach to handling BSD-specific functions and refactoring existing build configurations. The changes aim to improve portability, reduce boilerplate, and ensure a more consistent build and installation experience across different Linux environments and architectures, whether using Makefiles or CMake.

Highlights

  • libbsd-overlay Integration: Linux Makefiles and CMakeLists now utilize the libbsd-overlay scheme via pkg-config for compilation and linking, enhancing compatibility and build consistency.
  • Makefile Refactoring: Linux Makefiles have been restructured to extract common build logic into several new, included makefiles (e.g., linux-common.mk, linux-x.mk, linux-sdl.mk), reducing redundancy and improving maintainability.
  • CMake Install Target: An install target has been added to CMakeLists.txt, mirroring the functionality of the Makefiles to install executables (lde, ldeinit, ldex, ldesdl) into architecture-specific binary directories.
  • Build Environment Update: The Builder Docker image has been updated to include the pkgconf package, which is a necessary dependency for the libbsd-overlay Linux builds.

🧠 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.
    • Added conditional logic for Linux to find and link libbsd-overlay using PkgConfig.
    • Linked the 'lde' executable with MAIKO_LIBRARIES.
    • Introduced installation targets for executables, dynamically determining the installation directory.
  • bin/linux-common.mk
    • Added a new Makefile fragment defining common compiler, flags, and object directory settings.
    • Included linux-libbsd.mk for BSD-specific configurations.
  • bin/linux-libbsd.mk
    • Added a new Makefile fragment that checks for pkg-config and libbsd-overlay, providing error messages if dependencies are missing.
    • Defined BSD_CFLAGS and BSD_LDFLAGS using pkg-config.
  • bin/linux-sdl.mk
    • Added a new Makefile fragment defining SDL-specific build options, including XFILES, XFLAGS, and XLDFLAGS.
  • bin/linux-x.mk
    • Added a new Makefile fragment defining X Windows-specific build options, including XFILES, XFLAGS, and XLDFLAGS.
  • bin/makefile-init-linux.aarch64
    • Refactored to include linux-x.mk and linux-common.mk, removing redundant local definitions.
    • Adjusted ADDITIONAL_DFLAGS and OPTFLAGS.
  • bin/makefile-init-linux.x86_64
    • Refactored to include linux-x.mk and linux-common.mk, removing redundant local definitions.
    • Adjusted ADDITIONAL_DFLAGS and OPTFLAGS.
  • bin/makefile-init-wsl1.aarch64
    • Appended '-lbsd' to LDFLAGS and LDELDFLAGS.
  • bin/makefile-init-wsl1.x86_64
    • Appended '-lbsd' to LDFLAGS and LDELDFLAGS.
  • bin/makefile-linux.386-sdl
    • Refactored to include linux-sdl.mk and linux-common.mk, removing redundant local definitions.
    • Adjusted GCC_CFLAGS and CLANG_CFLAGS to include '-m64'.
  • bin/makefile-linux.386-x
    • Refactored to include linux-x.mk and linux-common.mk, removing redundant local definitions.
    • Adjusted GCC_CFLAGS and CLANG_CFLAGS to include '-m32'.
  • bin/makefile-linux.aarch64-sdl
    • Refactored to include linux-sdl.mk and linux-common.mk, removing redundant local definitions.
  • bin/makefile-linux.aarch64-x
    • Refactored to include linux-x.mk and linux-common.mk, removing redundant local definitions.
  • bin/makefile-linux.armv7l-sdl
    • Refactored to include linux-sdl.mk and linux-common.mk, removing redundant local definitions.
  • bin/makefile-linux.armv7l-x
    • Refactored to include linux-x.mk and linux-common.mk, removing redundant local definitions.
  • bin/makefile-linux.x86_64-sdl
    • Refactored to include linux-sdl.mk and linux-common.mk, removing redundant local definitions.
    • Adjusted GCC_CFLAGS and CLANG_CFLAGS to include '-m64'.
  • bin/makefile-linux.x86_64-x
    • Refactored to include linux-x.mk and linux-common.mk, removing redundant local definitions.
    • Adjusted GCC_CFLAGS and CLANG_CFLAGS to include '-m64'.
  • bin/makefile-wsl1.aarch64-sdl
    • Appended '-lbsd' to LDFLAGS and LDELDFLAGS.
  • bin/makefile-wsl1.aarch64-x
    • Appended '-lbsd' to LDFLAGS and LDELDFLAGS.
  • bin/makefile-wsl1.x86_64-sdl
    • Appended '-lbsd' to LDFLAGS and LDELDFLAGS.
  • bin/makefile-wsl1.x86_64-x
    • Appended '-lbsd' to LDFLAGS and LDELDFLAGS.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/Dockerfile_builder
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

@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 Linux Makefiles to use common includes and adds support for libbsd-overlay. It also updates CMakeLists.txt with libbsd-overlay support and a new install target. The refactoring of the Makefiles is a great improvement for maintainability. I've found a critical issue in one of the makefiles that would lead to an incorrect build, and have some suggestions to improve the robustness of the CMake changes and the consistency of the Makefile refactoring.

@pamoroso
Copy link
Member

I tried this PR in my submodules repo by executing gh pr checkout 542 but got this error:

paolo@lispmachine:~/smedley/medley$ gh pr checkout 542
fatal: couldn't find remote ref refs/heads/lmm3
failed to run git: exit status 128

Then I tried to directly check out the branch but got several warnings:

paolo@lispmachine:~/smedley/medley$ git checkout fgh_libbsd
warning: unable to rmdir 'loops': Directory not empty
warning: unable to rmdir 'maiko': Directory not empty
warning: unable to rmdir 'notecards': Directory not empty
warning: unable to rmdir 'online': Directory not empty
warning: unable to rmdir 'test': Directory not empty
branch 'fgh_libbsd' set up to track 'origin/fgh_libbsd'.
Switched to a new branch 'fgh_libbsd'
Checkout complete!

How am I supposed to check out a PR in the submodules repo?

When checking out the PR I get the same error also in my non submodules repo:

paolo@lispmachine:~/medley/medley$ gh pr checkout 542
fatal: couldn't find remote ref refs/heads/lmm3
failed to run git: exit status 128

Copy link
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.

I've added comments to the bot's notes.

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),cleanup)

CHK_PKG_CONFIG := $(shell command -v pkg-config)
Copy link
Collaborator

Choose a reason for hiding this comment

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

On online.interlisp.org, this fails with:

$ ./makeright x
making release 351 for linux on x86_64.
making with display x releasename linux.x86_64-x ldename ldex
start making lde for linux.x86_64-x
make: command: Command not found
linux-libbsd.mk:10: *** "pkg-config not found. Please install it to build this project.".  Stop.

This may be a case where $(shell which pkg-config) is needed.

XFLAGS = -DXWINDOW

XLDFLAGS = -L/usr/X11/lib -lX11

Copy link
Collaborator

Choose a reason for hiding this comment

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

One thing I'd note is that we require libx11 version 1.7.0 or later, since we're using XSetIOErrorExitHandler.

@pamoroso
Copy link
Member

Never mind, I executed gh and git checkout from the medley directory and not from the maiko subdirectory. Calling gg from maiko seems to work:

paolo@lispmachine:~/smedley/medley/maiko$ gh pr checkout 542
Previous HEAD position was d791b1d Merge pull request #533 from Interlisp/nhb-rewrite-version-parser-v2
branch 'fgh_libbsd' set up to track 'origin/fgh_libbsd'.
Switched to a new branch 'fgh_libbsd'

At this point I don't have to git submodule update --remote from the medley directory, tight?

@pamoroso
Copy link
Member

With the previously mentioned setup (not executing git submodule update --remote) Maiko and Medley buid and run fine.

One thing to note is that on Linux Mint 22.1 Cinnamon libbsd-dev, which is a dependency of this PR, is not installed by default and I had to install it manually.

@fghalasz
Copy link
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