-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.nvtop
51 lines (38 loc) · 1.21 KB
/
Makefile.nvtop
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
48
49
50
51
SHELL := /usr/bin/zsh
INSTALL_AT := /opt/nvtop
SRC_FOLDER := ~/src/git-nvtop
ENV_FILE := /etc/environment
ENV_TEMP := /tmp/$(notdir ${ENV_FILE})
PACKAGES := git cmake libncurses-dev
AWK_SCRIPT := /^PATH=/ { \
split ($$0, kv, "\""); \
paths=kv[2]; \
if (paths !~ /$(subst /,\/,${INSTALL_AT})\/bin/) \
paths=sprintf("%s:%s",paths,"${INSTALL_AT}/bin"); \
printf("%s\"%s\"\n",kv[1],paths);}
build : ${SRC_FOLDER}/build
cd $< ; make
${SRC_FOLDER} :
[ -d $@ ] \
&& { cd $@ ; git pull } \
|| { \
[ -d $(@D) ] || mkdir -p $(@D) ; \
git clone 'https://github.com/Syllo/nvtop.git' $@ \
}
%/build : %
[ -d $@ ] || mkdir -p $@
$(MAKE) -f $(firstword ${MAKEFILE_LIST}) ensure-packages
cd $@ ; \
cmake .. -DCMAKE_INSTALL_PREFIX=${INSTALL_AT} \
install : ${SRC_FOLDER}/build
cd $< ; make install
$(MAKE) -f $(firstword ${MAKEFILE_LIST}) update-environment
update-environment :
cp ${ENV_FILE} ${ENV_TEMP}
gawk '${AWK_SCRIPT}' < ${ENV_TEMP} > ${ENV_FILE}
-cat ${ENV_TEMP} | grep -v '^PATH=' >> ${ENV_FILE}
ensure-packages : ${PACKAGES:%=${SRC_FOLDER}/build/ensure-package-%}
${SRC_FOLDER}/build/ensure-package-% :
aptitude search "~i$*" || sudo apt install $*
clean :
rm -rf ${SRC_FOLDER}/build