From 62018bd8f556bc8c968f70b22d7894a051263bd2 Mon Sep 17 00:00:00 2001 From: n8felton Date: Tue, 4 Aug 2026 12:17:23 -0400 Subject: [PATCH 1/3] Ignore object files 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 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d9a9ed6..0afa3e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ macvdmtool +*.o From b4628244b36d4cb2dc93afe67f135561d8264402 Mon Sep 17 00:00:00 2001 From: n8felton Date: Tue, 4 Aug 2026 12:17:50 -0400 Subject: [PATCH 2/3] 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. Drop the now redundant `-lc++`. Add a `clean` rule to remove the object file and the binary. Signed-off-by: n8felton --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 202cb1c..fe308c0 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,16 @@ CXXFLAGS := -std=c++14 -LDFLAGS := -framework CoreFoundation -framework IOKit -lc++ +LDFLAGS := -framework CoreFoundation -framework IOKit OBJS := main.o all: macvdmtool macvdmtool: $(OBJS) - cc -o $@ $(OBJS) $(LDFLAGS) + $(CXX) -o $@ $(OBJS) $(LDFLAGS) + +.PHONY: clean +clean: + rm -f $(OBJS) macvdmtool ifeq ($(PREFIX),) PREFIX := /usr/local From 9216e68337cd17103e8e4a694b33eb0dc2754a21 Mon Sep 17 00:00:00 2001 From: n8felton Date: Tue, 4 Aug 2026 12:17:59 -0400 Subject: [PATCH 3/3] Support DESTDIR and drop sudo from the install rule 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 --- Makefile | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index fe308c0..fe0b38b 100644 --- a/Makefile +++ b/Makefile @@ -3,22 +3,21 @@ LDFLAGS := -framework CoreFoundation -framework IOKit OBJS := main.o +PREFIX ?= /usr/local +DESTDIR ?= + +INSTALL := /usr/bin/install + all: macvdmtool macvdmtool: $(OBJS) $(CXX) -o $@ $(OBJS) $(LDFLAGS) +.PHONY: install +install: macvdmtool + $(INSTALL) -d "$(DESTDIR)$(PREFIX)/bin" + $(INSTALL) -m 755 "$(<)" "$(DESTDIR)$(PREFIX)/bin" + .PHONY: clean clean: rm -f $(OBJS) macvdmtool - -ifeq ($(PREFIX),) - PREFIX := /usr/local -endif - -INSTALL := /usr/bin/install - -.PHONY: install -install: macvdmtool - @sudo $(INSTALL) -d "$(PREFIX)/bin/" - @sudo $(INSTALL) -m 755 -o root -g wheel "$(<)" "$(PREFIX)/bin/"