add -Wpedantic to default CFLAGS
[baseutils.git] / Makefile
index dbbd613beee4c072ff0023bd42c00b68a7b17de5..3c50667672e9d36863ace764b4f9b7a4115203af 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,36 @@
-TARGETS = realpath
-SRC = ${TARGETS:=.c}
+include config.mk
+
+TARGETS = arch fmt getopt nproc realpath
+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