-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathMakefile
112 lines (91 loc) · 2.57 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Copyright (C) 2013-2014 Craig Phillips. All rights reserved.
#
# GSync top level makefile.
all:
@echo "Run make with the following targets:"
@echo " install Install the GSync application in this system"
@echo " uninstall Remove the GSync application from this system"
@echo " runtests Run Gsync unit and regression tests"
@echo " ctags Generate ctags file"
ifneq (0,$(shell id -u))
SUDO:= sudo
else
SUDO:=
endif
reverse = $(if $(1),$(call reverse,\
$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1)\
)
reverse = $(shell printf "%s\n" $(strip $1) | tac)
SRC_FILES:= $(shell find bin/ libgsync/ -type f)
TEST_FILES:= $(shell find tests/ -type f -name "*.py")
PYLINT:= $(shell which pylint)
ifneq (,$(PYLINT))
PYLINT_TARGETS:= $(addprefix pylint/,$(SRC_FILES))
PYLINT_TEST_TARGETS:= $(addprefix pylint/,$(TEST_FILES))
else
PYLINT_TARGETS:=
PYLINT_TEST_TARGETS:=
endif
.PHONY: $(PYLINT_TARGETS) $(PYLINT_TEST_TARGETS)
MANIFEST:= $(if $(wildcard MANIFEST),$(shell cat MANIFEST),)
RM_MANIFEST:= $(addprefix uninstall_,\
$(filter-out \
%/bin/ \
%/dist-packages/ \
,$(wildcard $(MANIFEST) $(call reverse,$(sort $(dir $(MANIFEST))))),\
)\
)
.PHONY: $(RM_MANIFEST)
$(RM_MANIFEST): uninstall_% : %
@[ -e "$<" ] || { \
echo >&2 "Error: GSync is not installed" ; \
exit 1 ; \
}
@[ $(shell id -u) -eq 0 ] || { \
echo >&2 "Error: You must be root" ; \
exit 1 ; \
}
@if [ -d $< ] ; then \
rmdir -v $< ; \
else \
rm -vf $< ; \
fi
clean:
@rm -rf \
build/ dist/ gsync.egg-info/ htmlcov/ \
regression/output/ regression/tmp/
@find . -name \*.pyc -delete
check: $(PYLINT_TARGETS)
check_unittests: $(PYLINT_TEST_TARGETS)
.pylintrc:
@pylint --generate-rcfile >$@
$(PYLINT_TARGETS): pylint/% : % | .pylintrc
@echo Checking $<
@pylint -r n --rcfile .pylintrc $<
$(PYLINT_TEST_TARGETS): pylint/% : % | .pylintrc
@echo Checking $<
@pylint -E -r n --rcfile .pylintrc $<
uninstall: $(RM_MANIFEST)
@echo "Uninstall complete"
ctags: $(SRC_FILES)
@rm -f $@
@ctags -R -f $@ bin/ libgsync/
install: /usr/local/bin/gsync
bdist build: setup.py $(SRC_FILES)
@./setup.py $@
/usr/local/bin/gsync: build bdist
@$(SUDO) ./setup.py install --record MANIFEST
@$(SUDO) find /usr/local/lib/python2.7/dist-packages/ \
! -perm -o=r -exec chmod o+r {} \;
PY_COVERAGE:=$(if $(COVERAGE),$(shell which coverage),)
run_unittests:
ifneq (,$(PY_COVERAGE))
@rm -rf htmlcov/
@$(PY_COVERAGE) erase
@$(PY_COVERAGE) run ./setup.py test
@$(PY_COVERAGE) html --include="libgsync/*"
else
@./setup.py test
endif
run_regression:
@./regression/run.sh --verbose-no-tty