+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
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