fix: replace GNU make syntax with portable shell script #3

Closed
opened 2026-05-16 20:48:24 +02:00 by michael · 0 comments
Owner

Problem

lua.mk uses GNU make syntax (ifeq/else ifeq/endif) which is not compatible
with BSD make on OpenBSD.

Solution

Extract system detection into a portable shell script lua-env.sh.
lua.mk uses != to call the script (compatible with both GNU make and BSD make).

lua-env.sh

#!/bin/sh
# make-include/lua-env.sh
# Detect Lua paths for the current system.
# Usage: called by lua.mk via !=

LUA_VERSION=${1:-5.4}
OS=$(uname -s)
DISTRO=$(. /etc/os-release 2>/dev/null && echo $ID || echo "")

case "$OS:$DISTRO" in
  OpenBSD:*)
    SHAREDIR=/usr/local/share/lua/$LUA_VERSION
    LIBDIR=/usr/local/lib/lua/$LUA_VERSION
    GROUP=wheel
    ;;
  *:debian|*:arch)
    SHAREDIR=/usr/share/lua/$LUA_VERSION
    LIBDIR=/usr/lib/lua/$LUA_VERSION
    GROUP=root
    ;;
  *)
    echo "ERROR: Unsupported system: $OS/$DISTRO" >&2
    exit 1
    ;;
esac

printf 'DAW_LUA_SHAREDIR=%s\n'  "$SHAREDIR"
printf 'DAW_LUA_LIBDIR=%s\n'    "$LIBDIR"
printf 'DAW_INSTALL_GROUP=%s\n' "$GROUP"

lua.mk

DAW_LUA_VERSION ?= 5.4
DAW_LUA_BIN     ?= lua${DAW_LUA_VERSION}
DAW_OS          != uname -s

DAW_LUA_SHAREDIR  != sh lib/daw/make-include/lua-env.sh ${DAW_LUA_VERSION} | grep SHAREDIR  | cut -d= -f2
DAW_LUA_LIBDIR    != sh lib/daw/make-include/lua-env.sh ${DAW_LUA_VERSION} | grep LIBDIR    | cut -d= -f2
DAW_INSTALL_GROUP != sh lib/daw/make-include/lua-env.sh ${DAW_LUA_VERSION} | grep GROUP     | cut -d= -f2

Affected projects

All DAW projects that include lua.mk.

## Problem lua.mk uses GNU make syntax (ifeq/else ifeq/endif) which is not compatible with BSD make on OpenBSD. ## Solution Extract system detection into a portable shell script lua-env.sh. lua.mk uses != to call the script (compatible with both GNU make and BSD make). ## lua-env.sh ```sh #!/bin/sh # make-include/lua-env.sh # Detect Lua paths for the current system. # Usage: called by lua.mk via != LUA_VERSION=${1:-5.4} OS=$(uname -s) DISTRO=$(. /etc/os-release 2>/dev/null && echo $ID || echo "") case "$OS:$DISTRO" in OpenBSD:*) SHAREDIR=/usr/local/share/lua/$LUA_VERSION LIBDIR=/usr/local/lib/lua/$LUA_VERSION GROUP=wheel ;; *:debian|*:arch) SHAREDIR=/usr/share/lua/$LUA_VERSION LIBDIR=/usr/lib/lua/$LUA_VERSION GROUP=root ;; *) echo "ERROR: Unsupported system: $OS/$DISTRO" >&2 exit 1 ;; esac printf 'DAW_LUA_SHAREDIR=%s\n' "$SHAREDIR" printf 'DAW_LUA_LIBDIR=%s\n' "$LIBDIR" printf 'DAW_INSTALL_GROUP=%s\n' "$GROUP" ``` ## lua.mk ```makefile DAW_LUA_VERSION ?= 5.4 DAW_LUA_BIN ?= lua${DAW_LUA_VERSION} DAW_OS != uname -s DAW_LUA_SHAREDIR != sh lib/daw/make-include/lua-env.sh ${DAW_LUA_VERSION} | grep SHAREDIR | cut -d= -f2 DAW_LUA_LIBDIR != sh lib/daw/make-include/lua-env.sh ${DAW_LUA_VERSION} | grep LIBDIR | cut -d= -f2 DAW_INSTALL_GROUP != sh lib/daw/make-include/lua-env.sh ${DAW_LUA_VERSION} | grep GROUP | cut -d= -f2 ``` ## Affected projects All DAW projects that include lua.mk.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-make-include#3
No description provided.