forked from adsr/phpspy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (48 loc) · 2.15 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
phpspy_cflags:=-std=c90 -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/termbox/
termbox_libs:=-Wl,-Bstatic -Lvendor/termbox/ -ltermbox -Wl,-Bdynamic
prefix?=/usr/local
php_path?=php
sinclude config.mk
has_termbox := $(shell $(LD) $(phpspy_ldflags) -ltermbox -o/dev/null >/dev/null 2>&1 && echo :)
has_phpconf := $(shell command -v php-config >/dev/null 2>&1 && echo :)
ifdef USE_ZEND
$(or $(has_phpconf), $(error Need php-config))
phpspy_cflags:=$(subst c90,c11,$(phpspy_cflags))
phpspy_includes:=$(phpspy_includes) $$(php-config --includes)
phpspy_defines:=$(phpspy_defines) -DUSE_ZEND=1
endif
all: phpspy_static
phpspy_static: $(wildcard *.c *.h) vendor/termbox/libtermbox.a
$(CC) $(phpspy_cflags) $(phpspy_includes) $(termbox_inlcudes) $(phpspy_defines) $(phpspy_sources) -o phpspy $(phpspy_ldflags) $(phpspy_libs) $(termbox_libs)
phpspy_dynamic: $(wildcard *.c *.h)
@$(or $(has_termbox), $(error Need libtermbox. Hint: try `make phpspy_static`))
$(CC) $(phpspy_cflags) $(phpspy_includes) $(phpspy_defines) $(phpspy_sources) -o phpspy $(phpspy_ldflags) $(phpspy_libs) -ltermbox
vendor/termbox/libtermbox.a: vendor/termbox/termbox.c
cd vendor/termbox && $(MAKE)
vendor/termbox/termbox.c:
git submodule update --init --remote --recursive
cd vendor/termbox && git reset --hard
test: phpspy_static $(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_static
install -D -v -m 755 phpspy $(DESTDIR)$(prefix)/bin/phpspy
clean:
cd vendor/termbox && $(MAKE) clean
rm -f phpspy
.PHONY: all test install clean phpspy_static phpspy_dynamic