-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (33 loc) · 1.13 KB
/
Copy pathMakefile
File metadata and controls
46 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
TARGETS := all clean clobber distclean install install.bin install.awks uninstall uninstall.all
.PHONEY: ${TARGETS}
PREFIX =${DESTDIR}/opt/cfmt
BINDIR =${PREFIX}/bin
MANDIR =${PREFIX}/man
SCRIPTS =castfmt cfmt comment ifnest parens
AWKS =castfmt.awk comment.awk ifnest.awk parens.awk
OWNER =$(shell id -u)
GRP =$(shell id -g)
MODE =0755
DMODE =0644
TRASH =$(shell [ -f .gitignore ] && cat .gitignore )
define INSTALL_BIN_template
install:: install-${1}
install-${1}:: ${1}
@cmp -s ${1} $${BINDIR}/${1} || $${SHELL} -xc "install -D -m '${MODE}' -o '${OWNER}' -g '${GRP}' '${1}' '$${BINDIR}/${1}'"
.PHONY: install-${1}
endef
define INSTALL_AWK_template
install:: install-${1}
install-${1}:: ${1}
@cmp -s ${1} $${BINDIR}/${1} || $${SHELL} -xc "install -D -m '${DMODE}' -o '${OWNER}' -g '${GRP}' '${1}' '$${BINDIR}/${1}'"
.PHONY: install-${1}
endef
all:: ${SCRIPTS} ${AWKS}
$(foreach f,${SCRIPTS},$(eval $(call INSTALL_BIN_template,${f})))
$(foreach f,${AWKS},$(eval $(call INSTALL_AWK_template,${f})))
uninstall:: uninstall.all
uninstall.all::
cd ${BINDIR} && ${RM} ${SCRIPTS} ${AWKS}
clean::
${RM} ${TRASH}
clobber distclean:: clean