add make install and uninstall rules
authorgit <redacted>
Mon, 27 Apr 2026 05:44:50 +0000 (01:44 -0400)
committergit <redacted>
Mon, 27 Apr 2026 05:44:50 +0000 (01:44 -0400)
add config.mk

Makefile
README.md
config.mk [new file with mode: 0644]

index dbbd613beee4c072ff0023bd42c00b68a7b17de5..8f1708271564380eeb73751888372be93e1b2de7 100644 (file)
--- 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
index 98eaa38008eea92d07e3f261bbc3523124eeda1f..d2db688818764a48c017739db031d5a7033132d4 100644 (file)
--- 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 (file)
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