Skip to content

Make the build usable by a package manager such as Homebrew - #17

Open
n8felton wants to merge 3 commits into
AsahiLinux:mainfrom
n8felton:build/makefile-hygiene
Open

Make the build usable by a package manager such as Homebrew#17
n8felton wants to merge 3 commits into
AsahiLinux:mainfrom
n8felton:build/makefile-hygiene

Conversation

@n8felton

@n8felton n8felton commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Make the build suitable for a package manager such as Homebrew. Three independent commits, no change to tool behavior.

Refs #16.

Support DESTDIR and drop sudo from the install rule

A package build must stage the binary into a temporary directory, and it must not call sudo. The current rule fails on both counts, so make install is unusable for Homebrew and for any other packager.

  • Honor DESTDIR on both install paths.
  • Replace the ifeq block with PREFIX ?= /usr/local for the same result in one line.
  • Remove sudo and the -o root -g wheel flags. The caller decides how to elevate.
  • Remove the @ prefixes, so the install commands appear in build logs.

This changes existing behavior. make install no longer elevates itself. Use sudo make install to install to /usr/local.

Link with $(CXX) and add a clean rule

cc links a C++ object file only because -lc++ is passed by hand. $(CXX) is the correct driver, it supplies the C++ runtime itself, and it respects the compiler that a packager sets. -lc++ becomes redundant and is dropped.

clean removes the object file and the binary.

Ignore object files

The build leaves main.o untracked in the working tree. The pattern is *.o, so a new source file does not need another entry.

Test

make clean && make
make install DESTDIR=/tmp/stage PREFIX=/opt/test

Verified on an M4 MacBook Pro, macOS 26, Apple Clang. The binary is an arm64 Mach-O and it stages to /tmp/stage/opt/test/bin/macvdmtool. sudo make install installs to /usr/local/bin as before.

The build leaves `main.o` untracked in the working tree. Match `*.o` so
that a new source file does not need another entry.

Signed-off-by: n8felton <n8felton@gmail.com>
`cc` links a C++ object file only because `-lc++` is passed by hand.
`$(CXX)` is the correct driver, it supplies the C++ runtime itself, and
it respects the compiler that a packager sets. Drop the now redundant
`-lc++`.

Add a `clean` rule to remove the object file and the binary.

Signed-off-by: n8felton <n8felton@gmail.com>
A package build must be able to stage the binary into a temporary
directory, and it must not call `sudo`. Homebrew rejects both of these
today, and other packagers have the same constraint.

Honor `DESTDIR` on the install paths, and replace the `ifeq` block with
`PREFIX ?=` for the same result in one line. Remove `sudo` and the root
ownership flags, so that the caller decides how to elevate. Remove the
`@` prefixes, so that the install commands appear in build logs.

This changes existing behavior: `make install` no longer elevates
itself. Use `sudo make install` to install to `/usr/local`.

Signed-off-by: n8felton <n8felton@gmail.com>
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