aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjozan <jozan@noemail.net>2020-11-16 22:15:04 +0000
committerjozan <jozan@noemail.net>2020-11-16 22:15:04 +0000
commitde38b132abe1961e9d53dc706af96e711e8d94a0 (patch)
treea1cbcd792c63dda06b65475bc57d4e82f5e5d4ea
parentChanged ignore (diff)
downloadunixize-de38b132abe1961e9d53dc706af96e711e8d94a0.tar.gz
unixize-de38b132abe1961e9d53dc706af96e711e8d94a0.tar.bz2
unixize-de38b132abe1961e9d53dc706af96e711e8d94a0.tar.xz
unixize-de38b132abe1961e9d53dc706af96e711e8d94a0.tar.zst
unixize-de38b132abe1961e9d53dc706af96e711e8d94a0.zip
Added install and uninstall rules
FossilOrigin-Name: 68a02f0b88dae4bd52ce6ddbe515189a50572f9daca22bf115f80a83b6ce4eb0
-rw-r--r--Makefile44
1 files changed, 34 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 1fae33b..21950b4 100644
--- a/Makefile
+++ b/Makefile
@@ -19,11 +19,12 @@
.DEFAULT_GOAL := all
SHELL := /bin/sh
-DESTDIR = /usr/local
+DESTDIR =
SRCS_DIR = src/
OBJS_DIR = obj/
+MAN_DIR = man/
-CC = cc
+CC := cc
CFLAGS = -std=c89
CFLAGS += -Wall
CFLAGS += -Wextra
@@ -31,8 +32,11 @@ CFLAGS += -Werror
CFLAGS += -pedantic
CFLAGS += -march=ivybridge -O2 -pipe
-RM = rm -rf
-MKDIR = mkdir -p
+MKDIR := mkdir -p
+RM := rm -f
+INSTALL := install
+GZIP := gzip
+GUNZIP := gunzip
SRCS_NAME = c_lfiles
SRCS_NAME += c_opts
@@ -44,7 +48,8 @@ SRCS = $(addprefix ${SRCS_DIR}, $(addsuffix .c, ${SRCS_NAME}))
INCS = $(addprefix ${SRCS_DIR}, $(addsuffix .h, ${SRCS_NAME}))
OBJS = $(patsubst ${SRCS_DIR}%.c, ${OBJS_DIR}%.c.o, ${SRCS})
-TARGET = unixize
+TARGET := unixize
+MAN := unixize.1.gz
${OBJS_DIR}%.c.o: ${SRCS_DIR}%.c ${INCS} Makefile
@${MKDIR} ${OBJS_DIR}
@@ -53,8 +58,31 @@ ${OBJS_DIR}%.c.o: ${SRCS_DIR}%.c ${INCS} Makefile
${TARGET}: ${OBJS}
${CC} ${CFLAGS} -o ${TARGET} ${OBJS}
+${MAN_DIR}${MAN}:
+ ${GZIP} ${MAN_DIR}${TARGET}.1
+
all: ${TARGET}
+clean:
+ ${RM} -R ${OBJS} ${OBJS_DIR}
+ ${RM} ${TARGET}
+
+install-bin: ${TARGET}
+ ${MKDIR} ${DESDIR}/usr/local/bin
+ ${INSTALL} -m0555 ${TARGET} ${DESTDIR}/usr/local/bin/${TARGET}
+
+install-doc: ${MAN_DIR}${MAN}
+ ${MKDIR} ${DESDIR}/usr/local/man/man1
+ ${INSTALL} -m0444 ${MAN_DIR}${TARGET}.1.gz ${DESTDIR}/usr/local/man/man1/${TARGET}.1.gz
+ ${GUNZIP} ${MAN_DIR}${TARGET}.1.gz
+
+install: install-bin install-doc
+
+
+uninstall:
+ ${RM} ${DESTDIR}/usr/local/bin/${TARGET}
+ ${RM} ${DESTDIR}/usr/local/man/man1/${TARGET}.1.gz
+
debug: CFLAGS += -g3
debug: all
@@ -67,8 +95,4 @@ msan: CFLAGS += -fsanitize=memory
msan: CFLAGS += -fsanitize-memory-track-origins
msan: all
-clean:
- ${RM} ${OBJS_DIR}
- ${RM} ${TARGET}
-
-.PHONY: all clean debug asan msan
+.PHONY: all clean install uninstall debug asan msan