From: git Date: Mon, 27 Apr 2026 05:44:50 +0000 (-0400) Subject: add make install and uninstall rules X-Git-Url: https://git.datadissipation.net/?a=commitdiff_plain;h=038212ff88e98164cc749e23fa85927e27e8b26e;p=baseutils.git add make install and uninstall rules add config.mk --- diff --git a/Makefile b/Makefile index dbbd613..8f17082 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,36 @@ +include config.mk + TARGETS = realpath -SRC = ${TARGETS:=.c} +SRC = $(TARGETS:=.c) +BIN = $(TARGETS:=-install) +UNI = $(TARGETS:=-uninstall) all: ${TARGETS} +install: ${BIN} + @printf "All targets installed\n" + +uninstall: ${UNI} + @printf "All targets uninstalled\n" + ${TARGETS}: ${SRC} ${CC} ${CFLAGS} ${LDFLAGS} $@.c -o $@ +${BIN}: + @TARGET=$$(echo $@ | sed "s/-install//");\ + ${MAKE} "$$TARGET";\ + mkdir -p ${PREFIX}/bin;\ + cp -f "$$TARGET" ${PREFIX}/bin;\ + chmod 755 ${PREFIX}/bin/"$$TARGET";\ + mkdir -p ${MANPREFIX}/man1;\ + cp -f "$$TARGET".1 ${MANPREFIX}/man1/;\ + chmod 644 ${MANPREFIX}/man1/"$$TARGET".1 + +${UNI}: + @TARGET=$$(echo $@ | sed "s/-uninstall//");\ + rm ${PREFIX}/bin/"$$TARGET" ${MANPREFIX}/man1/"$$TARGET".1 + clean: rm -f *.[oa] ${TARGETS} -.PHONY: all ${TARGETS} clean +.PHONY: all install uninstall ${TARGETS} ${BIN} ${UNI} clean diff --git a/README.md b/README.md index 98eaa38..d2db688 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ Some of the programs not found in GNU coreutils and Busybox alternatives Mostly ports from BSD systems + +Install or uninstall a single target by appending _-install/-uninstall_ postfix to it's name: + +``` +make realpath-install +make uninstall +``` + +_install_ and _uninstall_ rules do this for all targets at once diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..ff0045d --- /dev/null +++ b/config.mk @@ -0,0 +1,7 @@ +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/share/man + +CFLAGS = -Wall -Wextra -O2 +LDFLAGS = + +CC = cc