-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcompletion.makefile
47 lines (32 loc) · 1.19 KB
/
completion.makefile
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
47
# -*- Makefile for completion files -*-
# Copyright 2013 Saevon <[email protected]>
TOP := $(dir $(lastword $(MAKEFILE_LIST)))
COMP_DIR ?= ${HOME}/.bash_completion.d
# COMPLETIONS ?= $(wildcard *.complete.bash)
COMPLETIONS ?= $(shell find ${PWD} -iname "*.complete.bash")
RESET_COMPLETIONS ?= $(shell find ${PWD} -iname "*.complete.bash" -exec basename {} \; )
# if [ "${HOME}/.bash_completion.d/git.complete.bash" -ef "git.complete.bash" ]; then echo '!!'; fi
.PHONY: FORCE
FORCE:
################
# Cleanup
.PHONY: reset-completion
reset-completion: ${PRE_COMP_RESET_DEP} $(addprefix REMOVE--,${RESET_COMPLETIONS}) ${POST_COMP_RESET_DEP}
@# Remove the completion directory if its empty too
@if [ $(find ${COMP_DIR} -maxdepth 0 -type d -empty) ]; then \
rmdir ${COMP_DIR}; \
rm ${HOME}/.bash_completion; \
fi
REMOVE--%.complete.bash: FORCE
@RM_FILE=${COMP_DIR}/$(@:REMOVE--%=%); \
if [[ -f $${RM_FILE} || -L $${RM_FILE} ]]; then \
rm -i $${RM_FILE} || true; \
fi
################
# Setup
.PHONY: completion
completion: ${PRE_COMP_DEP} ${COMP_DIR} ${COMPLETIONS} ${POST_COMP_DEP}
%.complete.bash: FORCE
@CPI="${CPI}" ${COPY} "$@" "${COMP_DIR}/$$(basename $@)"
${COMP_DIR}:
@mkdir -p $@