-
Notifications
You must be signed in to change notification settings - Fork 66
/
Makefile
65 lines (51 loc) · 1.89 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
phpspy_cflags:=-std=c11 -Wall -Wextra -pedantic -g -O3 -Wno-address-of-packed-member $(CFLAGS)
phpspy_libs:=-pthread $(LDLIBS)
phpspy_ldflags:=$(LDFLAGS)
phpspy_includes:=-I. -I./vendor
phpspy_defines:=
phpspy_tests:=$(wildcard tests/test_*.sh)
phpspy_sources:=phpspy.c pgrep.c top.c addr_objdump.c event_fout.c event_callgrind.c
termbox_inlcudes=-Ivendor/termbox2/
prefix?=/usr/local
php_path?=php
sinclude config.mk
has_phpconf := $(shell command -v php-config >/dev/null 2>&1 && echo :)
git_sha := $(shell test -d .git && command -v git >/dev/null && git rev-parse --short HEAD)
ifdef USE_ZEND
$(or $(has_phpconf), $(error Need php-config))
phpspy_includes:=$(phpspy_includes) $$(php-config --includes)
phpspy_defines:=$(phpspy_defines) -DUSE_ZEND=1
endif
ifdef COMMIT
phpspy_defines:=$(phpspy_defines) -DCOMMIT=$(COMMIT)
else ifneq ($(git_sha),)
phpspy_defines:=$(phpspy_defines) -DCOMMIT=$(git_sha)
endif
all: phpspy
phpspy: $(wildcard *.c *.h) vendor/termbox2/termbox2.h
$(CC) $(phpspy_cflags) $(phpspy_includes) $(termbox_inlcudes) $(phpspy_defines) $(phpspy_sources) -o phpspy $(phpspy_ldflags) $(phpspy_libs)
vendor/termbox2/termbox2.h:
if [ -d "$(CURDIR)/.git" ]; then \
git submodule update --init --recursive; \
cd vendor/termbox2 && git reset --hard; \
else \
cd vendor; \
git clone https://github.com/termbox/termbox2.git; \
fi
test: phpspy $(phpspy_tests)
@total=0; \
pass=0; \
for t in $(phpspy_tests); do \
tput bold; echo TEST $$t; tput sgr0; \
PHPSPY=./phpspy PHP=$(php_path) TEST_SH=$$(dirname $$t)/test.sh ./$$t; ec=$$?; echo; \
[ $$ec -eq 0 ] && pass=$$((pass+1)); \
total=$$((total+1)); \
done; \
printf "Passed %d out of %d tests\n" $$pass $$total ; \
[ $$pass -eq $$total ] || exit 1
install: phpspy
install -D -v -m 755 phpspy $(DESTDIR)$(prefix)/bin/phpspy
clean:
cd vendor/termbox2 && $(MAKE) clean
rm -f phpspy
.PHONY: all test install clean phpspy