From 5ced7a05182a05413f6a5d279ed36631ee32a507 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 21 Mar 2025 23:51:22 -0400 Subject: [PATCH] By default, install to ~/.local/bin and warn if PREFIX is not on user's $PATH --- Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ae98554..29bc722 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ SHELL := /bin/bash -PREFIX=/usr +PREFIX=$(HOME)/.local VERSION=0.0.1 CC=gcc CCONFIG=-std=c2x -Werror -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -fPIC -I. \ @@ -85,6 +85,13 @@ deps: ./install_dependencies.sh install: build/tomo build/libtomo.so + @if ! echo "$$PATH" | tr ':' '\n' | grep -qx "$(PREFIX)/bin"; then \ + printf "\033[31;1mError: '$(PREFIX)' is not in your \$$PATH variable!\033[m\n" >&2; \ + printf "\033[31;1mSpecify a different prefix with 'make PREFIX=... install'\033[m\n" >&2; \ + printf "\033[31;1mor add the following line to your .profile:\033[m\n" >&2; \ + printf "\n\033[1mexport PATH=\"$(PREFIX):\$$PATH\"\033[m\n\n" >&2; \ + exit 1; \ + fi mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/bin" "$(PREFIX)/include/tomo" "$(PREFIX)/lib" "$(PREFIX)/share/tomo/modules" cp -v src/stdlib/*.h "$(PREFIX)/include/tomo/" cp -v build/libtomo.so "$(PREFIX)/lib/"