feat(build): add install and uninstall targets for Unix systems

- Add PREFIX, LIBDIR, and INCDIR variables (default: /usr/local)
- Implement install target that builds release and installs to system paths
- Implement uninstall target to cleanly remove installed files
- Support custom install locations via PREFIX variable
- Add helpful message on Windows directing users to manual installation

Both gmake.mk and bmake.mk now support standard installation workflow
on Unix-like systems (Linux, BSD, macOS). Windows users are instructed
to copy files manually as per platform conventions.

Usage:
  make install              # Install to /usr/local (requires root)
  make PREFIX=$HOME install # Install to custom location
  make uninstall            # Remove installed files
This commit is contained in:
2026-02-01 11:19:02 +01:00
parent 28dfc89b15
commit 64f7260b3a
2 changed files with 38 additions and 2 deletions
+24 -1
View File
@@ -18,7 +18,11 @@ endif
RELEASE_LDFLAGS := -s
CFLAGS_BASE := -Wall -Wpedantic -I$(INC_DIR) -std=c89 $(CFLAGS_PLAT)
.PHONY: all debug release clean test
PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib
INCDIR ?= $(PREFIX)/include
.PHONY: all debug release clean test install uninstall
all: debug
@@ -53,3 +57,22 @@ clean:
test: debug
@echo "=== Building and running stk tests ==="
@$(MAKE) -C test -f gmake.mk
# Installation (Unix only)
ifneq ($(OS),Windows_NT)
install: release
install -d $(LIBDIR) $(INCDIR)
install -m 755 $(BIN_DIR)/release/$(FULL_LIB) $(LIBDIR)/
install -m 644 $(INC_DIR)/stk.h $(INCDIR)/
uninstall:
rm -f $(LIBDIR)/$(FULL_LIB)
rm -f $(INCDIR)/stk.h
else
install:
@echo "make install is not supported on Windows."
@echo "Copy include/stk.h and bin/release/stk.dll to your project."
uninstall:
@echo "make uninstall is not supported on Windows."
endif